mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: sunrpc: fix slab-out-of-bounds read in cache_seq_start_rcu
@ 2026-04-28 13:42 Alessandro Zanni
  2026-04-28 13:56 ` Chuck Lever
  0 siblings, 1 reply; 2+ messages in thread
From: Alessandro Zanni @ 2026-04-28 13:42 UTC (permalink / raw)
  To: chuck.lever, jlayton, neil, okorniev, Dai.Ngo, tom, trondmy,
	anna, davem, edumazet, kuba, pabeni, horms
  Cc: Alessandro Zanni, linux-nfs, netdev, linux-kernel,
	syzbot+60cfa08822470bbebe44

Syzbot reported slab-out-of-bounds read in cache_seq_start_rcu().

The issue happens in function __cache_seq_start() when is invoked
hlist_for_each_entry_rcu() and the hash value is greater than the
hash_size.

This fix verifies that the hash index is within the hash_size value
before dereferencing the hash table: if the hash index is out of
bounds return NULL, otherwise access the value.

Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock")
Reported-by: syzbot+60cfa08822470bbebe44@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=60cfa08822470bbebe44
Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
---
 net/sunrpc/cache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 7081c1214e6c..aac5f03112f5 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1348,6 +1348,9 @@ static void *__cache_seq_start(struct seq_file *m, loff_t *pos)
 	hash = n >> 32;
 	entry = n & ((1LL<<32) - 1);
 
+	if (hash >= cd->hash_size)
+		return NULL;
+
 	hlist_for_each_entry_rcu(ch, &cd->hash_table[hash], cache_list)
 		if (!entry--)
 			return ch;
-- 
2.47.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: sunrpc: fix slab-out-of-bounds read in cache_seq_start_rcu
  2026-04-28 13:42 [PATCH] net: sunrpc: fix slab-out-of-bounds read in cache_seq_start_rcu Alessandro Zanni
@ 2026-04-28 13:56 ` Chuck Lever
  0 siblings, 0 replies; 2+ messages in thread
From: Chuck Lever @ 2026-04-28 13:56 UTC (permalink / raw)
  To: Alessandro Zanni, Chuck Lever, Jeff Layton, NeilBrown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Trond Myklebust,
	Anna Schumaker, davem, edumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: linux-nfs, netdev, linux-kernel, syzbot+60cfa08822470bbebe44



On Tue, Apr 28, 2026, at 9:42 AM, Alessandro Zanni wrote:
> Syzbot reported slab-out-of-bounds read in cache_seq_start_rcu().
>
> The issue happens in function __cache_seq_start() when is invoked
> hlist_for_each_entry_rcu() and the hash value is greater than the
> hash_size.
>
> This fix verifies that the hash index is within the hash_size value
> before dereferencing the hash table: if the hash index is out of
> bounds return NULL, otherwise access the value.
>
> Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection 
> rather than the r/w spinlock")
> Reported-by: syzbot+60cfa08822470bbebe44@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=60cfa08822470bbebe44
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
>  net/sunrpc/cache.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
> index 7081c1214e6c..aac5f03112f5 100644
> --- a/net/sunrpc/cache.c
> +++ b/net/sunrpc/cache.c
> @@ -1348,6 +1348,9 @@ static void *__cache_seq_start(struct seq_file 
> *m, loff_t *pos)
>  	hash = n >> 32;
>  	entry = n & ((1LL<<32) - 1);
> 
> +	if (hash >= cd->hash_size)
> +		return NULL;
> +
>  	hlist_for_each_entry_rcu(ch, &cd->hash_table[hash], cache_list)
>  		if (!entry--)
>  			return ch;
> -- 
> 2.47.3

Thank you for the patch! We have this fixed in the nfsd-testing
tree already:

https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/commit/?h=nfsd-testing&id=72fe9e528c68aa7b9ed5afab98c44f8b83bbe287


-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-28 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-28 13:42 [PATCH] net: sunrpc: fix slab-out-of-bounds read in cache_seq_start_rcu Alessandro Zanni
2026-04-28 13:56 ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®