From: Simon Horman <horms@kernel.org>
To: Wang Liang <wangliang74@huawei.com>
Cc: chuck.lever@oracle.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, brauner@kernel.org,
kernel-tls-handshake@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, yuehaibing@huawei.com,
zhangchangzhong@huawei.com
Subject: Re: [PATCH net v2] net/handshake: Fix null-ptr-deref in handshake_complete()
Date: Fri, 12 Dec 2025 16:50:52 +0000 [thread overview]
Message-ID: <aTxH7E2Jq_S9b6rq@horms.kernel.org> (raw)
In-Reply-To: <20251212012723.4111831-1-wangliang74@huawei.com>
On Fri, Dec 12, 2025 at 09:27:23AM +0800, Wang Liang wrote:
> A null pointer dereference in handshake_complete() was observed [1].
>
> When handshake_req_next() return NULL in handshake_nl_accept_doit(),
> function handshake_complete() will be called unexpectedly which triggers
> this crash. Fix it by goto out_status when req is NULL.
>
> [1]
> Oops: general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] SMP KASAN PTI
> RIP: 0010:handshake_complete+0x36/0x2b0 net/handshake/request.c:288
> Call Trace:
> <TASK>
> handshake_nl_accept_doit+0x32d/0x7e0 net/handshake/netlink.c:129
> genl_family_rcv_msg_doit+0x204/0x300 net/netlink/genetlink.c:1115
> genl_family_rcv_msg+0x436/0x670 net/netlink/genetlink.c:1195
> genl_rcv_msg+0xcc/0x170 net/netlink/genetlink.c:1210
> netlink_rcv_skb+0x14c/0x430 net/netlink/af_netlink.c:2550
> genl_rcv+0x2d/0x40 net/netlink/genetlink.c:1219
> netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
> netlink_unicast+0x878/0xb20 net/netlink/af_netlink.c:1344
> netlink_sendmsg+0x897/0xd70 net/netlink/af_netlink.c:1894
> sock_sendmsg_nosec net/socket.c:727 [inline]
> __sock_sendmsg net/socket.c:742 [inline]
> ____sys_sendmsg+0xa39/0xbf0 net/socket.c:2592
> ___sys_sendmsg+0x121/0x1c0 net/socket.c:2646
> __sys_sendmsg+0x155/0x200 net/socket.c:2678
> do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> do_syscall_64+0x5f/0x350 arch/x86/entry/syscall_64.c:94
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
> </TASK>
>
> Fixes: fe67b063f687 ("net/handshake: convert handshake_nl_accept_doit() to FD_PREPARE()")
> Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/kernel-tls-handshake/aScekpuOYHRM9uOd@morisot.1015granger.net/T/#m7cfa5c11efc626d77622b2981591197a2acdd65e
> Signed-off-by: Wang Liang <wangliang74@huawei.com>
> ---
> net/handshake/netlink.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Thanks for the update and for addressing my review of v1.
Considering that this function combines __cleanup (via FD_PREPARE) with
goto labels, which IMHO leads to an awkward arrangement of the code, I
think this approach is a good one for a bug fix.
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2025-12-12 16:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 1:27 [PATCH net v2] net/handshake: Fix null-ptr-deref in handshake_complete() Wang Liang
2025-12-12 16:50 ` Simon Horman [this message]
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=aTxH7E2Jq_S9b6rq@horms.kernel.org \
--to=horms@kernel.org \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-tls-handshake@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wangliang74@huawei.com \
--cc=yuehaibing@huawei.com \
--cc=zhangchangzhong@huawei.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).