public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind
@ 2026-02-17 13:53 Tabrez Ahmed
  2026-02-17 14:07 ` Charalampos Mitrodimas
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tabrez Ahmed @ 2026-02-17 13:53 UTC (permalink / raw)
  To: allison.henderson
  Cc: davem, edumazet, kuba, pabeni, horms, gerd.rausch, charmitro,
	linux-rdma, netdev, linux-kernel, Tabrez Ahmed,
	syzbot+aae646f09192f72a68dc

KMSAN reported an uninit-value access in __inet_bind() when binding
an RDS TCP socket.

The uninitialized memory originates from rds_tcp_conn_alloc(),
which uses kmem_cache_alloc() to allocate the rds_tcp_connection structure.

Specifically, the field 't_client_port_group' is incremented in
rds_tcp_conn_path_connect() without being initialized first:

    if (++tc->t_client_port_group >= port_groups)

Since kmem_cache_alloc() does not zero the memory, this field contains
garbage, leading to the KMSAN report.

Fix this by using kmem_cache_zalloc() to ensure the structure is
zero-initialized upon allocation.

Reported-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=aae646f09192f72a68dc
Tested-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
Fixes: a20a6992558f ("net/rds: Encode cp_index in TCP source port")

Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
---
v2:
 - Updated Fixes tag to point to commit a20a6992558f as requested by
   Charalampos Mitrodimas and Allison Henderson.
 - Explicitly mentioned 't_client_port_group' in the commit message.
 - Fixed line wrapping to be under 75 characters. 

 net/rds/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index 45484a93d75f..04f310255692 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -373,7 +373,7 @@ static int rds_tcp_conn_alloc(struct rds_connection *conn, gfp_t gfp)
 	int ret = 0;
 
 	for (i = 0; i < RDS_MPATH_WORKERS; i++) {
-		tc = kmem_cache_alloc(rds_tcp_conn_slab, gfp);
+		tc = kmem_cache_zalloc(rds_tcp_conn_slab, gfp);
 		if (!tc) {
 			ret = -ENOMEM;
 			goto fail;
-- 
2.43.0


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

* Re: [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind
  2026-02-17 13:53 [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind Tabrez Ahmed
@ 2026-02-17 14:07 ` Charalampos Mitrodimas
  2026-02-18  4:19 ` Allison Henderson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Charalampos Mitrodimas @ 2026-02-17 14:07 UTC (permalink / raw)
  To: Tabrez Ahmed
  Cc: allison.henderson, davem, edumazet, kuba, pabeni, horms,
	gerd.rausch, linux-rdma, netdev, linux-kernel,
	syzbot+aae646f09192f72a68dc

Tabrez Ahmed <tabreztalks@gmail.com> writes:

> KMSAN reported an uninit-value access in __inet_bind() when binding
> an RDS TCP socket.
>
> The uninitialized memory originates from rds_tcp_conn_alloc(),
> which uses kmem_cache_alloc() to allocate the rds_tcp_connection structure.
>
> Specifically, the field 't_client_port_group' is incremented in
> rds_tcp_conn_path_connect() without being initialized first:
>
>     if (++tc->t_client_port_group >= port_groups)
>
> Since kmem_cache_alloc() does not zero the memory, this field contains
> garbage, leading to the KMSAN report.
>
> Fix this by using kmem_cache_zalloc() to ensure the structure is
> zero-initialized upon allocation.
>
> Reported-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=aae646f09192f72a68dc
> Tested-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
> Fixes: a20a6992558f ("net/rds: Encode cp_index in TCP source port")
>
> Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
> ---

Reviewed-by: Charalampos Mitrodimas <charmitro@posteo.net>

-- 
C. Mitrodimas

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

* Re: [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind
  2026-02-17 13:53 [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind Tabrez Ahmed
  2026-02-17 14:07 ` Charalampos Mitrodimas
@ 2026-02-18  4:19 ` Allison Henderson
  2026-02-19 15:05 ` Paolo Abeni
  2026-02-19 15:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Allison Henderson @ 2026-02-18  4:19 UTC (permalink / raw)
  To: tabreztalks@gmail.com
  Cc: linux-rdma@vger.kernel.org, charmitro@posteo.net,
	davem@davemloft.net,
	syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	kuba@kernel.org, horms@kernel.org, Gerd Rausch,
	edumazet@google.com, pabeni@redhat.com

On Tue, 2026-02-17 at 19:23 +0530, Tabrez Ahmed wrote:
> KMSAN reported an uninit-value access in __inet_bind() when binding
> an RDS TCP socket.
> 
> The uninitialized memory originates from rds_tcp_conn_alloc(),
> which uses kmem_cache_alloc() to allocate the rds_tcp_connection structure.
> 
> Specifically, the field 't_client_port_group' is incremented in
> rds_tcp_conn_path_connect() without being initialized first:
> 
>     if (++tc->t_client_port_group >= port_groups)
> 
> Since kmem_cache_alloc() does not zero the memory, this field contains
> garbage, leading to the KMSAN report.
> 
> Fix this by using kmem_cache_zalloc() to ensure the structure is
> zero-initialized upon allocation.
> 
> Reported-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
> Closes: https://urldefense.com/v3/__https://syzkaller.appspot.com/bug?extid=aae646f09192f72a68dc__;!!ACWV5N9M2RV99hQ!KzzjhqabhC2dy_AOmRK4QHF3FILzGR2FxPlBFUOY6bjNqwGNvvtgnZXhnab3n-7b79hRhEkCBy86Zpzts1dzLrHgWg$ 
> Tested-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
> Fixes: a20a6992558f ("net/rds: Encode cp_index in TCP source port")
> 
> Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
This looks good to me.  Thanks Tabrez.

Reviewed-by: Allison Henderson <achender@kernel.org>

> ---
> v2:
>  - Updated Fixes tag to point to commit a20a6992558f as requested by
>    Charalampos Mitrodimas and Allison Henderson.
>  - Explicitly mentioned 't_client_port_group' in the commit message.
>  - Fixed line wrapping to be under 75 characters. 
> 
>  net/rds/tcp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/rds/tcp.c b/net/rds/tcp.c
> index 45484a93d75f..04f310255692 100644
> --- a/net/rds/tcp.c
> +++ b/net/rds/tcp.c
> @@ -373,7 +373,7 @@ static int rds_tcp_conn_alloc(struct rds_connection *conn, gfp_t gfp)
>  	int ret = 0;
>  
>  	for (i = 0; i < RDS_MPATH_WORKERS; i++) {
> -		tc = kmem_cache_alloc(rds_tcp_conn_slab, gfp);
> +		tc = kmem_cache_zalloc(rds_tcp_conn_slab, gfp);
>  		if (!tc) {
>  			ret = -ENOMEM;
>  			goto fail;


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

* Re: [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind
  2026-02-17 13:53 [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind Tabrez Ahmed
  2026-02-17 14:07 ` Charalampos Mitrodimas
  2026-02-18  4:19 ` Allison Henderson
@ 2026-02-19 15:05 ` Paolo Abeni
  2026-02-19 15:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2026-02-19 15:05 UTC (permalink / raw)
  To: Tabrez Ahmed, allison.henderson
  Cc: davem, edumazet, kuba, horms, gerd.rausch, charmitro, linux-rdma,
	netdev, linux-kernel, syzbot+aae646f09192f72a68dc

On 2/17/26 2:53 PM, Tabrez Ahmed wrote:
> KMSAN reported an uninit-value access in __inet_bind() when binding
> an RDS TCP socket.
> 
> The uninitialized memory originates from rds_tcp_conn_alloc(),
> which uses kmem_cache_alloc() to allocate the rds_tcp_connection structure.
> 
> Specifically, the field 't_client_port_group' is incremented in
> rds_tcp_conn_path_connect() without being initialized first:
> 
>     if (++tc->t_client_port_group >= port_groups)
> 
> Since kmem_cache_alloc() does not zero the memory, this field contains
> garbage, leading to the KMSAN report.
> 
> Fix this by using kmem_cache_zalloc() to ensure the structure is
> zero-initialized upon allocation.
> 
> Reported-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=aae646f09192f72a68dc
> Tested-by: syzbot+aae646f09192f72a68dc@syzkaller.appspotmail.com
> Fixes: a20a6992558f ("net/rds: Encode cp_index in TCP source port")
> 

I'll fix this while applying the patch but for next submissions please
avoid any empty line in the tag area.

/P


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

* Re: [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind
  2026-02-17 13:53 [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind Tabrez Ahmed
                   ` (2 preceding siblings ...)
  2026-02-19 15:05 ` Paolo Abeni
@ 2026-02-19 15:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-19 15:10 UTC (permalink / raw)
  To: Tabrez Ahmed
  Cc: allison.henderson, davem, edumazet, kuba, pabeni, horms,
	gerd.rausch, charmitro, linux-rdma, netdev, linux-kernel,
	syzbot+aae646f09192f72a68dc

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 17 Feb 2026 19:23:49 +0530 you wrote:
> KMSAN reported an uninit-value access in __inet_bind() when binding
> an RDS TCP socket.
> 
> The uninitialized memory originates from rds_tcp_conn_alloc(),
> which uses kmem_cache_alloc() to allocate the rds_tcp_connection structure.
> 
> Specifically, the field 't_client_port_group' is incremented in
> rds_tcp_conn_path_connect() without being initialized first:
> 
> [...]

Here is the summary with links:
  - [net,v2] rds: tcp: fix uninit-value in __inet_bind
    https://git.kernel.org/netdev/net/c/7b821da55b3f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-02-19 15:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-17 13:53 [PATCH net v2] rds: tcp: fix uninit-value in __inet_bind Tabrez Ahmed
2026-02-17 14:07 ` Charalampos Mitrodimas
2026-02-18  4:19 ` Allison Henderson
2026-02-19 15:05 ` Paolo Abeni
2026-02-19 15:10 ` patchwork-bot+netdevbpf

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