From: Khalid Masum <khalid.masum.92@gmail.com>
To: linux-kernel-mentees@lists.linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Pavel Skripkin <paskripkin@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
syzbot+1fa91bcd05206ff8cbb5@syzkaller.appspotmail.com,
Marc Kleine-Budde <mkl@pengutronix.de>,
Nikolay Aleksandrov <nikolay@nvidia.com>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: [RFC PATCH 1/1] net: kcm: Use sk_psock size for kcm_psock_cache
Date: Wed, 13 Jul 2022 12:32:04 +0600 [thread overview]
Message-ID: <20220713063204.6294-2-khalid.masum.92@gmail.com> (raw)
In-Reply-To: <20220713063204.6294-1-khalid.masum.92@gmail.com>
`struct sock` has a member `sk_user_data`, which got its memory allocated
in `kcm_attach` by `kcm_psock_cache` with the size of `kcm_psock`. Which
is not enough when the member is used as `sk_psock` causing out of bound
read.
Use `sk_psock` size to allocate memory instead for `sk_user_data`.
Reported-by: syzbot+1fa91bcd05206ff8cbb5@syzkaller.appspotmail.com
Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
---
net/kcm/kcmsock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 71899e5a5a11..688bee56f90c 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -23,6 +23,7 @@
#include <linux/workqueue.h>
#include <linux/syscalls.h>
#include <linux/sched/signal.h>
+#include <linux/skmsg.h>
#include <net/kcm.h>
#include <net/netns/generic.h>
@@ -2041,7 +2042,7 @@ static int __init kcm_init(void)
goto fail;
kcm_psockp = kmem_cache_create("kcm_psock_cache",
- sizeof(struct kcm_psock), 0,
+ sizeof(struct sk_psock), 0,
SLAB_HWCACHE_ALIGN, NULL);
if (!kcm_psockp)
goto fail;
--
2.36.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next prev parent reply other threads:[~2022-07-13 6:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 6:32 [RFC PATCH 0/1] Fix KASAN: slab-out-of-bounds Read in sk_psock_get Khalid Masum
2022-07-13 6:32 ` Khalid Masum [this message]
2022-07-13 6:37 ` [RFC PATCH 1/1] net: kcm: Use sk_psock size for kcm_psock_cache Greg KH
2022-07-13 18:16 ` Jakub Kicinski
2022-07-13 18:25 ` Khalid Masum
2022-07-13 18:13 [RFC PATCH 0/1][RESEND] Fix KASAN: slab-out-of-bounds Read in sk_psock_get Khalid Masum
2022-07-13 18:13 ` [RFC PATCH 1/1] net: kcm: Use sk_psock size for kcm_psock_cache Khalid Masum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220713063204.6294-2-khalid.masum.92@gmail.com \
--to=khalid.masum.92@gmail.com \
--cc=ast@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=nikolay@nvidia.com \
--cc=pabeni@redhat.com \
--cc=paskripkin@gmail.com \
--cc=sgarzare@redhat.com \
--cc=syzbot+1fa91bcd05206ff8cbb5@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).