Skip to content

Commit 3546d8f

Browse files
mpedavem330
authored andcommitted
net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM
The cxgb3 driver for "Chelsio T3-based gigabit and 10Gb Ethernet adapters" implements a custom ioctl as SIOCCHIOCTL/SIOCDEVPRIVATE in cxgb_extension_ioctl(). One of the subcommands of the ioctl is CHELSIO_GET_MEM, which appears to read memory directly out of the adapter and return it to userspace. It's not entirely clear what the contents of the adapter memory contains, but the assumption is that it shouldn't be accessible to all users. So add a CAP_NET_ADMIN check to the CHELSIO_GET_MEM case. Put it after the is_offload() check, which matches two of the other subcommands in the same function which also check for is_offload() and CAP_NET_ADMIN. Found by Ilja by code inspection, not tested as I don't have the required hardware. Reported-by: Ilja Van Sprundel <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 148965d commit 3546d8f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
24482448

24492449
if (!is_offload(adapter))
24502450
return -EOPNOTSUPP;
2451+
if (!capable(CAP_NET_ADMIN))
2452+
return -EPERM;
24512453
if (!(adapter->flags & FULL_INIT_DONE))
24522454
return -EIO; /* need the memory controllers */
24532455
if (copy_from_user(&t, useraddr, sizeof(t)))

0 commit comments

Comments
 (0)