* [PATCH] Crypto : Fix Null deref in scatterwalk_pagedone
@ 2026-02-21 15:10 Manas
2026-02-21 16:46 ` Greg KH
2026-02-21 18:39 ` Eric Biggers
0 siblings, 2 replies; 3+ messages in thread
From: Manas @ 2026-02-21 15:10 UTC (permalink / raw)
To: davem, herbert; +Cc: linux-crypto, linux-kernel, stable, Manas, Rakshit Awasthi
`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));
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Crypto : Fix Null deref in scatterwalk_pagedone
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
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-02-21 16:46 UTC (permalink / raw)
To: Manas; +Cc: davem, herbert, linux-crypto, linux-kernel, stable,
Rakshit Awasthi
On Sat, Feb 21, 2026 at 08:40:41PM +0530, Manas wrote:
> `sg_next` can return NULL which causes NULL deref in
> `scatterwalk_start`
How can it return NULL in this case?
> 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>
Reported by isn't needed if you sign off on a patch. But you got the
order wrong here for the signed off by lines, please read the
documentation.
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Crypto : Fix Null deref in scatterwalk_pagedone
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
1 sibling, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2026-02-21 18:39 UTC (permalink / raw)
To: Manas; +Cc: davem, herbert, linux-crypto, linux-kernel, stable,
Rakshit Awasthi
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-21 18:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox