[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231110213147.68823-1-kuniyu@amazon.com>
Date: Fri, 10 Nov 2023 13:31:47 -0800
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <bragathemanick0908@...il.com>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<linux-hams@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<netdev@...r.kernel.org>, <pabeni@...hat.com>, <ralf@...ux-mips.org>,
<syzbot+0145ea560de205bc09f0@...kaller.appspotmail.com>, <kuniyu@...zon.com>
Subject: Re: [PATCH] net: memory leak in nr_rx_frame
From: Bragatheswaran Manickavel <bragathemanick0908@...il.com>
Date: Fri, 10 Nov 2023 23:06:32 +0530
> The condition (make = nr_make_new(sk)) == NULL suggests
> that nr_make_new allocates memory and returns a pointer.
> If this allocation fails (returns NULL), it indicates a
> potential memory leak.
If make is NULL, nothing is allocated and leaked here, and
your code will never be executed as "if (make)" is always false.
>
> Added sock_put() for make which can potentially solve
> this issue
Sounds like the patch is not tested with kmemleak.
>
> Reported-by: syzbot+0145ea560de205bc09f0@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=0145ea560de205bc09f0
> Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@...il.com>
> ---
> net/netrom/af_netrom.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
> index 0eed00184adf..7d7cda4ae300 100644
> --- a/net/netrom/af_netrom.c
> +++ b/net/netrom/af_netrom.c
> @@ -970,6 +970,8 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
> nr_transmit_refusal(skb, 0);
> if (sk)
> sock_put(sk);
> + if (make)
> + sock_put(make);
Also, make could be uninitialised here if the first two
condition is true.
if (sk == NULL || sk_acceptq_is_full(sk) ||
> return 0;
> }
>
> --
> 2.34.1
Powered by blists - more mailing lists