From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>,
ralf@linux-mips.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>,
linux-hams@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+0145ea560de205bc09f0@syzkaller.appspotmail.com
Subject: Re: [PATCH] net: memory leak in nr_rx_frame
Date: Sun, 12 Nov 2023 19:56:56 -0500 [thread overview]
Message-ID: <65517458ef995_a08352943@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20231110173632.2511-1-bragathemanick0908@gmail.com>
Bragatheswaran Manickavel wrote:
> 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.
>
> Added sock_put() for make which can potentially solve
> this issue
>
> Reported-by: syzbot+0145ea560de205bc09f0@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=0145ea560de205bc09f0
> Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.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);
> return 0;
> }
If the branch is entered because (make = nr_make_new(sk)) == NULL then
make is.. NULL. If the branch is entered for one if the earlier two
conditions failing, then make is undefined.
The syzbot report is that make is allocated here and eventually
nothing points to this still allocated memory. It does not report
where the last reference was lost. Not inside this branch.
prev parent reply other threads:[~2023-11-13 0:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 17:36 Bragatheswaran Manickavel
2023-11-10 21:31 ` Kuniyuki Iwashima
2023-11-11 6:16 ` Bragatheswaran Manickavel
2023-11-11 6:37 ` kernel test robot
2023-11-13 0:56 ` Willem de Bruijn [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=65517458ef995_a08352943@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=bragathemanick0908@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-hams@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@linux-mips.org \
--cc=syzbot+0145ea560de205bc09f0@syzkaller.appspotmail.com \
/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
all inboxes | Powered by JetHome®