From: Pranav Tyagi <pranav.tyagi03@gmail.com>
To: john.fastabend@gmail.com, jakub@cloudflare.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, ast@kernel.org, cong.wang@bytedance.com,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
Pranav Tyagi <pranav.tyagi03@gmail.com>,
syzbot+b18872ea9631b5dcef3b@syzkaller.appspotmail.com
Subject: [PATCH] net: skmsg: fix NULL pointer dereference in sk_msg_recvmsg()
Date: Tue, 15 Jul 2025 13:41:58 +0530 [thread overview]
Message-ID: <20250715081158.7651-1-pranav.tyagi03@gmail.com> (raw)
A NULL page from sg_page() in sk_msg_recvmsg() can reach
__kmap_local_page_prot() and crash the kernel. Add a check for the page
before calling copy_page_to_iter() and fail early with -EFAULT to
prevent the crash.
Reported-by: syzbot+b18872ea9631b5dcef3b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b18872ea9631b5dcef3b
Fixes: 2bc793e3272a ("skmsg: Extract __tcp_bpf_recvmsg() and tcp_bpf_wait_data()")
Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
---
net/core/skmsg.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 4d75ef9d24bf..f5367356a483 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -432,6 +432,10 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
sge = sk_msg_elem(msg_rx, i);
copy = sge->length;
page = sg_page(sge);
+ if (!page) {
+ copied = copied ? copied : -EFAULT;
+ goto out;
+ }
if (copied + copy > len)
copy = len - copied;
copy = copy_page_to_iter(page, sge->offset, copy, iter);
--
2.49.0
next reply other threads:[~2025-07-15 8:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 8:11 Pranav Tyagi [this message]
2025-07-15 8:19 ` [PATCH] net: skmsg: fix NULL pointer dereference in sk_msg_recvmsg() Greg KH
2025-07-17 11:10 ` Paolo Abeni
2025-07-25 11:55 ` Pranav Tyagi
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=20250715081158.7651-1-pranav.tyagi03@gmail.com \
--to=pranav.tyagi03@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+b18872ea9631b5dcef3b@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