mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+ad601904231505ad6617@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [can?] WARNING: refcount bug in j1939_session_put
Date: Wed,  7 Aug 2024 10:38:58 +0800	[thread overview]
Message-ID: <tencent_FADDBB192B4F958DFF25E68DEF920F5D8507@qq.com> (raw)
In-Reply-To: <000000000000af9991061ef63774@google.com>

Fixes: c9c0ee5f20c5 ("net: skbuff: Skip early return in skb_unref when debugging")

Root cause: In commit c9c0ee5f20c5, There are following rules:
In debug builds (CONFIG_DEBUG_NET set), the reference count is always  decremented, even when it's 1

This rule will cause the reference count to be 0 after calling skc_unref,
which will affect the release of skb.

#syz test: net-next 743ff02152bc

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 4be73de5033c..257740076616 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -279,6 +279,9 @@ static void j1939_session_destroy(struct j1939_session *session)
 	while ((skb = skb_dequeue(&session->skb_queue)) != NULL) {
 		/* drop ref taken in j1939_session_skb_queue() */
 		skb_unref(skb);
+		if (IS_ENABLED(CONFIG_DEBUG_NET) &&
+		    refcount_read(&skb->users) <= 0)
+			refcount_set(&skb->users, 1);
 		kfree_skb(skb);
 	}
 	__j1939_session_drop(session);


  parent reply	other threads:[~2024-08-07  2:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 21:18 syzbot
2024-08-06 13:12 ` Edward Adam Davis
2024-08-06 13:32   ` syzbot
2024-08-06 13:39 ` Edward Adam Davis
2024-08-06 14:04   ` syzbot
2024-08-07  0:51 ` Edward Adam Davis
2024-08-07  1:22   ` syzbot
2024-08-07  1:18 ` Edward Adam Davis
2024-08-07  1:39   ` syzbot
2024-08-07  1:42 ` Edward Adam Davis
2024-08-07  2:00   ` syzbot
2024-08-07  8:02   ` Breno Leitao
2024-08-07 23:06     ` Edward Adam Davis
2024-08-07  2:38 ` Edward Adam Davis [this message]
2024-08-07  3:11   ` syzbot
2024-08-07  6:21 ` Edward Adam Davis
2024-08-07  6:40   ` syzbot
2024-08-07  6:56 ` Edward Adam Davis
2024-08-07  8:20   ` syzbot
2024-08-07  8:30 ` Edward Adam Davis
2024-08-07  9:14   ` syzbot
2024-08-07  9:29 ` Edward Adam Davis
2024-08-07 10:20   ` syzbot
2024-08-07 10:59 ` Edward Adam Davis
2024-08-07 12:12   ` syzbot
2024-08-07 12:35 ` [PATCH net-next] can: j1939: fix uaf in j1939_session_destroy Edward Adam Davis
2024-08-07 14:16   ` Jakub Kicinski
2024-08-07 23:08     ` [PATCH net-next V2] can: j1939: fix uaf warning " Edward Adam Davis
2024-08-08  7:49       ` Oleksij Rempel
2024-08-08 11:07         ` Edward Adam Davis
2024-08-08 11:57           ` Marc Kleine-Budde
2024-10-11 13:41           ` Sabyrzhan Tasbolatov
2024-10-11 14:10             ` Oleksij Rempel

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=tencent_FADDBB192B4F958DFF25E68DEF920F5D8507@qq.com \
    --to=eadavis@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+ad601904231505ad6617@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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®