linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM
@ 2020-01-24  9:41 Michael Ellerman
  2020-01-25  8:48 ` Sergei Shtylyov
  2020-01-25  9:53 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Ellerman @ 2020-01-24  9:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-kernel, security, ivansprundel, vishal

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 <ivansprundel@ioactive.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 58f89f6a040f..97ff8608f0ab 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -2448,6 +2448,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
 
 		if (!is_offload(adapter))
 			return -EOPNOTSUPP;
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
 		if (!(adapter->flags & FULL_INIT_DONE))
 			return -EIO;	/* need the memory controllers */
 		if (copy_from_user(&t, useraddr, sizeof(t)))
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM
  2020-01-24  9:41 [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM Michael Ellerman
@ 2020-01-25  8:48 ` Sergei Shtylyov
  2020-01-28  9:42   ` Michael Ellerman
  2020-01-25  9:53 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2020-01-25  8:48 UTC (permalink / raw)
  To: Michael Ellerman, netdev
  Cc: davem, linux-kernel, security, ivansprundel, vishal

Hello!

On 24.01.2020 12:41, Michael Ellerman wrote:

> 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

    s/contains/is/? Else it sounds tautological. :-)

> 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 <ivansprundel@ioactive.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM
  2020-01-24  9:41 [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM Michael Ellerman
  2020-01-25  8:48 ` Sergei Shtylyov
@ 2020-01-25  9:53 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2020-01-25  9:53 UTC (permalink / raw)
  To: mpe; +Cc: netdev, linux-kernel, security, ivansprundel, vishal

From: Michael Ellerman <mpe@ellerman.id.au>
Date: Fri, 24 Jan 2020 20:41:44 +1100

> 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 <ivansprundel@ioactive.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM
  2020-01-25  8:48 ` Sergei Shtylyov
@ 2020-01-28  9:42   ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2020-01-28  9:42 UTC (permalink / raw)
  To: Sergei Shtylyov, netdev
  Cc: davem, linux-kernel, security, ivansprundel, vishal

Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> writes:
> Hello!
>
> On 24.01.2020 12:41, Michael Ellerman wrote:
>
>> 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
>
>     s/contains/is/? Else it sounds tautological. :-)

Yeah you're right that would have been clearer.

Dave beat me to it and has already applied it, but thanks for reviewing
it anyway.

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-28  9:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24  9:41 [PATCH] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM Michael Ellerman
2020-01-25  8:48 ` Sergei Shtylyov
2020-01-28  9:42   ` Michael Ellerman
2020-01-25  9:53 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).