[PATCH] pfinet: fix privilege check in S_iioctl_siocsifmtu

Sophiel Zhou <[email protected]>
Newsgroups gmane.os.hurd.bugs
Message-ID <[email protected]>
Non-root users could bypass the EPERM check and still modify
the interface MTU because the isroot check was not chained into
the same if-else block as the device and mtu validation.

Add the missing else to ensure the modification is skipped when
the caller is not root.
---
 pfinet/iioctl-ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pfinet/iioctl-ops.c b/pfinet/iioctl-ops.c
index aae09df1..ccebec87 100644
--- a/pfinet/iioctl-ops.c
+++ b/pfinet/iioctl-ops.c
@@ -596,7 +596,7 @@ S_iioctl_siocsifmtu (struct sock_user *user,
 
   if (!user->isroot)
     err = EPERM;
-  if (!dev)
+  else if (!dev)
     err = ENODEV;
   else if (mtu <= 0)
     err = EINVAL;
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.