Patch "tun: revert fix group permission check" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tun: revert fix group permission check

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tun-revert-fix-group-permission-check.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 744f400cd615d02674b6c916b0e79284e07132ec
Author: Willem de Bruijn <willemb@xxxxxxxxxx>
Date:   Tue Feb 4 11:10:06 2025 -0500

    tun: revert fix group permission check
    
    [ Upstream commit a70c7b3cbc0688016810bb2e0b9b8a0d6a530045 ]
    
    This reverts commit 3ca459eaba1bf96a8c7878de84fa8872259a01e3.
    
    The blamed commit caused a regression when neither tun->owner nor
    tun->group is set. This is intended to be allowed, but now requires
    CAP_NET_ADMIN.
    
    Discussion in the referenced thread pointed out that the original
    issue that prompted this patch can be resolved in userspace.
    
    The relaxed access control may also make a device accessible when it
    previously wasn't, while existing users may depend on it to not be.
    
    This is a clean pure git revert, except for fixing the indentation on
    the gid_valid line that checkpatch correctly flagged.
    
    Fixes: 3ca459eaba1b ("tun: fix group permission check")
    Link: https://lore.kernel.org/netdev/CAFqZXNtkCBT4f+PwyVRmQGoT3p1eVa01fCG_aNtpt6dakXncUg@xxxxxxxxxxxxxx/
    Signed-off-by: Willem de Bruijn <willemb@xxxxxxxxxx>
    Cc: Ondrej Mosnacek <omosnace@xxxxxxxxxx>
    Cc: Stas Sergeev <stsp2@xxxxxxxxx>
    Link: https://patch.msgid.link/20250204161015.739430-1-willemdebruijn.kernel@xxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a6c9f9062dbd4..03478ae3ff244 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -574,18 +574,14 @@ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb,
 	return ret;
 }
 
-static inline bool tun_capable(struct tun_struct *tun)
+static inline bool tun_not_capable(struct tun_struct *tun)
 {
 	const struct cred *cred = current_cred();
 	struct net *net = dev_net(tun->dev);
 
-	if (ns_capable(net->user_ns, CAP_NET_ADMIN))
-		return 1;
-	if (uid_valid(tun->owner) && uid_eq(cred->euid, tun->owner))
-		return 1;
-	if (gid_valid(tun->group) && in_egroup_p(tun->group))
-		return 1;
-	return 0;
+	return ((uid_valid(tun->owner) && !uid_eq(cred->euid, tun->owner)) ||
+		(gid_valid(tun->group) && !in_egroup_p(tun->group))) &&
+		!ns_capable(net->user_ns, CAP_NET_ADMIN);
 }
 
 static void tun_set_real_num_queues(struct tun_struct *tun)
@@ -2771,7 +2767,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 		    !!(tun->flags & IFF_MULTI_QUEUE))
 			return -EINVAL;
 
-		if (!tun_capable(tun))
+		if (tun_not_capable(tun))
 			return -EPERM;
 		err = security_tun_dev_open(tun->security);
 		if (err < 0)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux