From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+dddd99ae26c656485d89@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bpf?] possible deadlock in __stack_map_get
Date: Fri, 19 Apr 2024 07:09:32 +0800 [thread overview]
Message-ID: <20240418230932.2689-1-hdanton@sina.com> (raw)
In-Reply-To: <0000000000003f81750616646cb8@google.com>
On Thu, 18 Apr 2024 13:00:28 -0700
> syzbot found the following issue on:
>
> HEAD commit: f99c5f563c17 Merge tag 'nf-24-03-21' of git://git.kernel.o..
> git tree: net
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12f1f7cb180000
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git f99c5f563c17
--- x/kernel/bpf/queue_stack_maps.c
+++ y/kernel/bpf/queue_stack_maps.c
@@ -124,7 +124,7 @@ out:
return err;
}
-
+static DEFINE_PER_CPU(int, map_depth);
static long __stack_map_get(struct bpf_map *map, void *value, bool delete)
{
struct bpf_queue_stack *qs = bpf_queue_stack(map);
@@ -132,12 +132,22 @@ static long __stack_map_get(struct bpf_m
int err = 0;
void *ptr;
u32 index;
+ int dumy;
+ int *depth = &dumy;
if (in_nmi()) {
if (!raw_spin_trylock_irqsave(&qs->lock, flags))
return -EBUSY;
} else {
+ preempt_disable_notrace();
+ depth = this_cpu_ptr(&map_depth);
+ if (*depth) {
+ preempt_enable_notrace();
+ return -EDEADLK;
+ }
raw_spin_lock_irqsave(&qs->lock, flags);
+ *depth += 1;
+ preempt_enable_notrace();
}
if (queue_stack_map_is_empty(qs)) {
@@ -157,6 +167,7 @@ static long __stack_map_get(struct bpf_m
qs->head = index;
out:
+ *depth -= 1;
raw_spin_unlock_irqrestore(&qs->lock, flags);
return err;
}
--
next prev parent reply other threads:[~2024-04-18 23:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 20:00 syzbot
2024-04-18 23:09 ` Hillf Danton [this message]
2024-04-19 5:06 ` syzbot
2024-04-19 10:44 ` Hillf Danton
2024-04-19 14:12 ` syzbot
2026-05-12 10:06 ` Forwarded: 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=20240418230932.2689-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+dddd99ae26c656485d89@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
Powered by JetHome