From: Eric Biggers <ebiggers@kernel.org>
To: Manas <ghandatmanas@gmail.com>
Cc: davem@davemloft.net, herbert@gondor.apana.org.au,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Rakshit Awasthi <rakshitawasthi17@gmail.com>
Subject: Re: [PATCH] Crypto : Fix Null deref in scatterwalk_pagedone
Date: Sat, 21 Feb 2026 10:39:15 -0800 [thread overview]
Message-ID: <20260221183915.GA2536@quark> (raw)
In-Reply-To: <20260221151041.65141-1-ghandatmanas@gmail.com>
On Sat, Feb 21, 2026 at 08:40:41PM +0530, Manas wrote:
> `sg_next` can return NULL which causes NULL deref in
> `scatterwalk_start`
>
> Reported-by: Manas Ghandat <ghandatmanas@gmail.com>
> Reported-by: Rakshit Awasthi <rakshitawasthi17@gmail.com>
> Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
> Signed-off-by: Rakshit Awasthi <rakshitawasthi17@gmail.com>
> ---
> include/crypto/scatterwalk.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
> index 32fc4473175b..abbb67391710 100644
> --- a/include/crypto/scatterwalk.h
> +++ b/include/crypto/scatterwalk.h
> @@ -78,7 +78,8 @@ static inline void scatterwalk_pagedone(struct scatter_walk *walk, int out,
> page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT);
> flush_dcache_page(page);
> }
> -
> + if (sg_next(walk->sg) == NULL)
> + return;
> if (more && walk->offset >= walk->sg->offset + walk->sg->length)
> scatterwalk_start(walk, sg_next(walk->sg));
First, this patch doesn't apply to the mainline kernel. This seems to
be a patch against an older version.
Second, 'sg_next(walk->sg)' returning NULL during the line
'scatterwalk_start(walk, sg_next(walk->sg));' means that the end of the
scatterlist has been reached, despite more data needing to be processed.
For example, this could happen if some in-kernel user asked to encrypt
200 bytes from a scatterlist containing only 100 bytes. But that would
be a bug in the code that requested the invalid encryption operation in
the first place, not here. It would need to be fixed there.
What is the full call stack of the crash? That would point to what
actually needs to be fixed.
- Eric
prev parent reply other threads:[~2026-02-21 18:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-21 15:10 [PATCH] Crypto : Fix Null deref in scatterwalk_pagedone Manas
2026-02-21 16:46 ` Greg KH
2026-02-21 18:39 ` Eric Biggers [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=20260221183915.GA2536@quark \
--to=ebiggers@kernel.org \
--cc=davem@davemloft.net \
--cc=ghandatmanas@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rakshitawasthi17@gmail.com \
--cc=stable@vger.kernel.org \
/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