Thread (9 messages) read the whole thread 9 messages, 6 authors, 2020-07-28

Re: [Linux-kernel-mentees] [PATCH net] xdp: Prevent kernel-infoleak in xsk_getsockopt()

From: Peilin Ye <hidden>
Date: 2020-07-28 05:25:20
Also in: bpf, lkml, netdev

On Mon, Jul 27, 2020 at 10:07:20PM -0700, Song Liu wrote:
On Mon, Jul 27, 2020 at 7:30 PM Peilin Ye [off-list ref] wrote:
quoted
xsk_getsockopt() is copying uninitialized stack memory to userspace when
`extra_stats` is `false`. Fix it by initializing `stats` with memset().

Cc: stable@vger.kernel.org
8aa5a33578e9 is not in stable branches yet, so we don't need to Cc stable.
quoted
Fixes: 8aa5a33578e9 ("xsk: Add new statistics")
Suggested-by: Dan Carpenter <redacted>
Signed-off-by: Peilin Ye <redacted>
---
 net/xdp/xsk.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 26e3bba8c204..acf001908a0d 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -844,6 +844,8 @@ static int xsk_getsockopt(struct socket *sock, int level, int optname,
                bool extra_stats = true;
                size_t stats_size;

+               memset(&stats, 0, sizeof(stats));
+
xsk.c doesn't include linux/string.h directly, so using memset may break
build for some config combinations. We can probably just use

struct xdp_statistics stats = {};
I see. I will send v2 soon. Thank you for reviewing the patch!

Peilin Ye
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help