mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+40bf00346c3fe40f90f2@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [lsm?] [net?] WARNING in kvfree_call_rcu
Date: Fri, 11 Jul 2025 17:32:56 +0800	[thread overview]
Message-ID: <20250711093257.3460-1-hdanton@sina.com> (raw)
In-Reply-To: <686d9b50.050a0220.1ffab7.0020.GAE@google.com>

> Date: Tue, 08 Jul 2025 15:27:28 -0700	[thread overview]
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    7482bb149b9f Merge branch 'for-next/core' into for-kernelci
> git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> console output: https://syzkaller.appspot.com/x/log.txt?x=130c528c580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=3c06e3e2454512b3
> dashboard link: https://syzkaller.appspot.com/bug?extid=40bf00346c3fe40f90f2
> userspace arch: arm64
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1257428c580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15fe9582580000

#syz test

--- x/net/ipv4/cipso_ipv4.c
+++ y/net/ipv4/cipso_ipv4.c
@@ -1848,6 +1848,7 @@ static int cipso_v4_get_actual_opt_len(c
  * values on failure.
  *
  */
+static DEFINE_SPINLOCK(setattr_spinlock);
 int cipso_v4_sock_setattr(struct sock *sk,
 			  const struct cipso_v4_doi *doi_def,
 			  const struct netlbl_lsm_secattr *secattr,
@@ -1899,6 +1900,7 @@ int cipso_v4_sock_setattr(struct sock *s
 	kfree(buf);
 	buf = NULL;
 
+	spin_lock(&setattr_spinlock);
 	sk_inet = inet_sk(sk);
 
 	old = rcu_dereference_protected(sk_inet->inet_opt, sk_locked);
@@ -1912,6 +1914,7 @@ int cipso_v4_sock_setattr(struct sock *s
 	rcu_assign_pointer(sk_inet->inet_opt, opt);
 	if (old)
 		kfree_rcu(old, rcu);
+	spin_unlock(&setattr_spinlock);
 
 	return 0;
 
@@ -1976,9 +1979,11 @@ int cipso_v4_req_setattr(struct request_
 	buf = NULL;
 
 	req_inet = inet_rsk(req);
+	spin_lock(&setattr_spinlock);
 	opt = unrcu_pointer(xchg(&req_inet->ireq_opt, RCU_INITIALIZER(opt)));
 	if (opt)
 		kfree_rcu(opt, rcu);
+	spin_unlock(&setattr_spinlock);
 
 	return 0;
 
@@ -2000,11 +2005,15 @@ req_setattr_failure:
  */
 static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr)
 {
-	struct ip_options_rcu *opt = rcu_dereference_protected(*opt_ptr, 1);
+	struct ip_options_rcu *opt;
 	int hdr_delta = 0;
 
-	if (!opt || opt->opt.cipso == 0)
+	spin_lock(&setattr_spinlock);
+	opt = rcu_dereference_protected(*opt_ptr, 1);
+	if (!opt || opt->opt.cipso == 0) {
+		spin_unlock(&setattr_spinlock);
 		return 0;
+	}
 	if (opt->opt.srr || opt->opt.rr || opt->opt.ts || opt->opt.router_alert) {
 		u8 cipso_len;
 		u8 cipso_off;
@@ -2040,6 +2049,7 @@ static int cipso_v4_delopt(struct ip_opt
 		hdr_delta = opt->opt.optlen;
 		kfree_rcu(opt, rcu);
 	}
+	spin_unlock(&setattr_spinlock);
 
 	return hdr_delta;
 }
--

  parent reply	other threads:[~2025-07-11  9:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08 22:27 syzbot
2025-07-08 22:41 ` Kuniyuki Iwashima
2025-07-08 22:54   ` syzbot
2025-07-08 23:17     ` Kuniyuki Iwashima
2025-07-08 23:55       ` syzbot
2025-07-10 16:04       ` Paolo Abeni
2025-07-10 23:09 ` Hillf Danton
2025-07-11  1:38   ` syzbot
2025-07-11  6:11 ` Hillf Danton
2025-07-11  6:31   ` syzbot
2025-07-11  9:32 ` Hillf Danton [this message]
2025-07-11 10:40   ` syzbot
2025-07-11 13:04 ` Hillf Danton
2025-07-11 13:39   ` syzbot
2025-07-12  0:20 ` Hillf Danton
2025-07-12  0:49   ` syzbot
2025-07-12  1:54 ` Hillf Danton
2025-07-12  3:13   ` syzbot
2025-07-12  6:07 ` Hillf Danton
2025-07-12  6:26   ` syzbot
2025-07-12 23:54 ` Hillf Danton
2025-07-13  1:05   ` syzbot
2025-07-13  2:38 ` Hillf Danton
2025-07-13  2:59   ` syzbot
2025-07-13  5:10 ` Hillf Danton
2025-07-13  6:23   ` syzbot
2025-07-13  7:38 ` Hillf Danton
2025-07-13  8:04   ` syzbot
2025-07-13  8:43 ` Hillf Danton
2025-07-13  9:09   ` syzbot
2025-07-14  2:36 ` Hillf Danton
2025-07-14  4:33   ` syzbot

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=20250711093257.3460-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+40bf00346c3fe40f90f2@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®