From: Eric Dumazet <edumazet@google.com>
To: Mikhail Lobanov <m.lobanov@rosalinux.ru>
Cc: Martin Schiller <ms@dev.tdt.de>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
linux-x25@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x_25: Adding a null pointer dereference check to the x25_accept() function
Date: Wed, 13 Mar 2024 15:13:25 +0100 [thread overview]
Message-ID: <CANn89iLfExAa7T+0bjyBHdbwrF-77SF+QaMHpy-tg7dYEp0YKQ@mail.gmail.com> (raw)
In-Reply-To: <20240313132214.48716-1-m.lobanov@rosalinux.ru>
On Wed, Mar 13, 2024 at 2:23 PM Mikhail Lobanov <m.lobanov@rosalinux.ru> wrote:
>
> To avoid the problem of dereferencing the null pointer in the x25_accept()
> function, you need to add an additional check that the pointer skb is
> not equal to NULL.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Mikhail Lobanov <m.lobanov@rosalinux.ru>
> ---
> net/x25/af_x25.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
> index f7a7c7798c3b..91bc5994cef6 100644
> --- a/net/x25/af_x25.c
> +++ b/net/x25/af_x25.c
> @@ -896,7 +896,7 @@ static int x25_accept(struct socket *sock, struct socket *newsock, int flags,
> goto out2;
> skb = skb_dequeue(&sk->sk_receive_queue);
skb can not be NULL at this point, we hold the socket lock.
Otherwise the bug would be in x25_wait_for_data()
> rc = -EINVAL;
> - if (!skb->sk)
> + if (!skb || !skb->sk)
> goto out2;
> newsk = skb->sk;
> sock_graft(newsk, newsock);
> --
> 2.43.0
>
prev parent reply other threads:[~2024-03-13 14:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 13:22 [PATCH] x_25: Adding a null pointer dereference check to the x25_accept() function Mikhail Lobanov
2024-03-13 14:13 ` Eric Dumazet [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=CANn89iLfExAa7T+0bjyBHdbwrF-77SF+QaMHpy-tg7dYEp0YKQ@mail.gmail.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=m.lobanov@rosalinux.ru \
--cc=ms@dev.tdt.de \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).