From: alexander.levin@verizon.com
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
alexander.levin@verizon.com
Subject: [PATCH AUTOSEL for 4.14 35/64] bpf: fix lockdep splat
Date: Sat, 2 Dec 2017 15:51:30 +0000 [thread overview]
Message-ID: <20171202155101.7573-35-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171202155101.7573-1-alexander.levin@verizon.com>
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 89ad2fa3f043a1e8daae193bcb5fe34d5f8caf28 ]
pcpu_freelist_pop() needs the same lockdep awareness than
pcpu_freelist_populate() to avoid a false positive.
[ INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected ]
switchto-defaul/12508 [HC0[0]:SC0[6]:HE0:SE0] is trying to acquire:
(&htab->buckets[i].lock){......}, at: [<ffffffff9dc099cb>] __htab_percpu_map_update_elem+0x1cb/0x300
and this task is already holding:
(dev_queue->dev->qdisc_class ?: &qdisc_tx_lock#2){+.-...}, at: [<ffffffff9e135848>] __dev_queue_xmit+0
x868/0x1240
which would create a new lock dependency:
(dev_queue->dev->qdisc_class ?: &qdisc_tx_lock#2){+.-...} -> (&htab->buckets[i].lock){......}
but this new dependency connects a SOFTIRQ-irq-safe lock:
(dev_queue->dev->qdisc_class ?: &qdisc_tx_lock#2){+.-...}
... which became SOFTIRQ-irq-safe at:
[<ffffffff9db5931b>] __lock_acquire+0x42b/0x1f10
[<ffffffff9db5b32c>] lock_acquire+0xbc/0x1b0
[<ffffffff9da05e38>] _raw_spin_lock+0x38/0x50
[<ffffffff9e135848>] __dev_queue_xmit+0x868/0x1240
[<ffffffff9e136240>] dev_queue_xmit+0x10/0x20
[<ffffffff9e1965d9>] ip_finish_output2+0x439/0x590
[<ffffffff9e197410>] ip_finish_output+0x150/0x2f0
[<ffffffff9e19886d>] ip_output+0x7d/0x260
[<ffffffff9e19789e>] ip_local_out+0x5e/0xe0
[<ffffffff9e197b25>] ip_queue_xmit+0x205/0x620
[<ffffffff9e1b8398>] tcp_transmit_skb+0x5a8/0xcb0
[<ffffffff9e1ba152>] tcp_write_xmit+0x242/0x1070
[<ffffffff9e1baffc>] __tcp_push_pending_frames+0x3c/0xf0
[<ffffffff9e1b3472>] tcp_rcv_established+0x312/0x700
[<ffffffff9e1c1acc>] tcp_v4_do_rcv+0x11c/0x200
[<ffffffff9e1c3dc2>] tcp_v4_rcv+0xaa2/0xc30
[<ffffffff9e191107>] ip_local_deliver_finish+0xa7/0x240
[<ffffffff9e191a36>] ip_local_deliver+0x66/0x200
[<ffffffff9e19137d>] ip_rcv_finish+0xdd/0x560
[<ffffffff9e191e65>] ip_rcv+0x295/0x510
[<ffffffff9e12ff88>] __netif_receive_skb_core+0x988/0x1020
[<ffffffff9e130641>] __netif_receive_skb+0x21/0x70
[<ffffffff9e1306ff>] process_backlog+0x6f/0x230
[<ffffffff9e132129>] net_rx_action+0x229/0x420
[<ffffffff9da07ee8>] __do_softirq+0xd8/0x43d
[<ffffffff9e282bcc>] do_softirq_own_stack+0x1c/0x30
[<ffffffff9dafc2f5>] do_softirq+0x55/0x60
[<ffffffff9dafc3a8>] __local_bh_enable_ip+0xa8/0xb0
[<ffffffff9db4c727>] cpu_startup_entry+0x1c7/0x500
[<ffffffff9daab333>] start_secondary+0x113/0x140
to a SOFTIRQ-irq-unsafe lock:
(&head->lock){+.+...}
... which became SOFTIRQ-irq-unsafe at:
... [<ffffffff9db5971f>] __lock_acquire+0x82f/0x1f10
[<ffffffff9db5b32c>] lock_acquire+0xbc/0x1b0
[<ffffffff9da05e38>] _raw_spin_lock+0x38/0x50
[<ffffffff9dc0b7fa>] pcpu_freelist_pop+0x7a/0xb0
[<ffffffff9dc08b2c>] htab_map_alloc+0x50c/0x5f0
[<ffffffff9dc00dc5>] SyS_bpf+0x265/0x1200
[<ffffffff9e28195f>] entry_SYSCALL_64_fastpath+0x12/0x17
other info that might help us debug this:
Chain exists of:
dev_queue->dev->qdisc_class ?: &qdisc_tx_lock#2 --> &htab->buckets[i].lock --> &head->lock
Possible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&head->lock);
local_irq_disable();
lock(dev_queue->dev->qdisc_class ?: &qdisc_tx_lock#2);
lock(&htab->buckets[i].lock);
<Interrupt>
lock(dev_queue->dev->qdisc_class ?: &qdisc_tx_lock#2);
*** DEADLOCK ***
Fixes: e19494edab82 ("bpf: introduce percpu_freelist")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
kernel/bpf/percpu_freelist.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/percpu_freelist.c b/kernel/bpf/percpu_freelist.c
index 5c51d1985b51..673fa6fe2d73 100644
--- a/kernel/bpf/percpu_freelist.c
+++ b/kernel/bpf/percpu_freelist.c
@@ -78,8 +78,10 @@ struct pcpu_freelist_node *pcpu_freelist_pop(struct pcpu_freelist *s)
{
struct pcpu_freelist_head *head;
struct pcpu_freelist_node *node;
+ unsigned long flags;
int orig_cpu, cpu;
+ local_irq_save(flags);
orig_cpu = cpu = raw_smp_processor_id();
while (1) {
head = per_cpu_ptr(s->freelist, cpu);
@@ -87,14 +89,16 @@ struct pcpu_freelist_node *pcpu_freelist_pop(struct pcpu_freelist *s)
node = head->first;
if (node) {
head->first = node->next;
- raw_spin_unlock(&head->lock);
+ raw_spin_unlock_irqrestore(&head->lock, flags);
return node;
}
raw_spin_unlock(&head->lock);
cpu = cpumask_next(cpu, cpu_possible_mask);
if (cpu >= nr_cpu_ids)
cpu = 0;
- if (cpu == orig_cpu)
+ if (cpu == orig_cpu) {
+ local_irq_restore(flags);
return NULL;
+ }
}
}
--
2.11.0
next prev parent reply other threads:[~2017-12-02 15:52 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-02 15:51 [PATCH AUTOSEL for 4.14 01/64] irqchip/qcom: Fix u32 comparison with value less than zero alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 03/64] net/smc: use sk_rcvbuf as start for rmb creation alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 02/64] net: ipv6: Fixup device for anycast routes during copy alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 04/64] kbuild: pkg: use --transform option to prefix paths in tar alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 07/64] net: qmi_wwan: add Quectel BG96 2c7c:0296 alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 06/64] powerpc/perf: Fix pmu_count to count only nest imc pmus alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 08/64] apparmor: fix leak of null profile name if profile allocation fails alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 05/64] coccinelle: fix parallel build with CHECK=scripts/coccicheck alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 10/64] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl() alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 11/64] tun: fix rcu_read_lock imbalance in tun_build_skb alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 09/64] x86/mpx/selftests: Fix up weird arrays alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 12/64] gre6: use log_ecn_error module parameter in ip6_tnl_rcv() alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 13/64] tcp: when scheduling TLP, time of RTO should account for current ACK alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 14/64] route: also update fnhe_genid when updating a route cache alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 15/64] route: update fnhe_expires for redirect when the fnhe exists alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 16/64] rsi: fix memory leak on buf and usb_reg_buf alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 17/64] drivers/rapidio/devices/rio_mport_cdev.c: fix resource leak in error handling path in 'rio_dma_transfer()' alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 20/64] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0 alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 19/64] lib/genalloc.c: make the avail variable an atomic_long_t alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 18/64] pipe: match pipe_max_size data type with procfs alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 21/64] NFS: Fix a typo in nfs_rename() alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 22/64] sunrpc: Fix rpc_task_begin trace point alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 25/64] xfs: fix forgotten rcu read unlock when skipping inode reclaim alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 23/64] nfp: inherit the max_mtu from the PF netdev alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 24/64] nfp: fix flower offload metadata flag usage alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 27/64] block: wake up all tasks blocked in get_request() alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 26/64] dt-bindings: usb: fix reg-property port-number range alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 28/64] sparc64/mm: set fields in deferred pages alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 30/64] slub: fix sysfs duplicate filename creation when slub_debug=O alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 29/64] zsmalloc: calling zs_map_object() from irq is a bug alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 31/64] sctp: do not free asoc when it is already dead in sctp_sendmsg alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 32/64] sctp: use the right sk after waking up from wait_buf sleep alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 34/64] geneve: fix fill_info when link down alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 33/64] fcntl: don't leak fd reference when fixup_compat_flock fails alexander.levin
2017-12-02 15:51 ` alexander.levin [this message]
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 37/64] clk: stm32h7: fix test of clock config alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 36/64] ipv6: set all.accept_dad to 0 by default alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 38/64] clk: sunxi-ng: a83t: Fix i2c buses bits alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 40/64] clk: uniphier: fix DAPLL2 clock rate of Pro5 alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 39/64] clk: qcom: common: fix legacy board-clock registration alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 41/64] clk: hi3660: fix incorrect uart3 clock freqency alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 42/64] mailbox: mailbox-test: don't rely on rx_buffer content to signal data ready alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 45/64] jump_label: Invoke jump_label_test() via early_initcall() alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 44/64] atm: horizon: Fix irq release error alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 46/64] tls: Use kzalloc for aead_request allocation alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 43/64] kbuild: rpm-pkg: fix jobserver unavailable warning alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 47/64] xfrm: Copy policy family in clone_policy alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 49/64] bnxt_re: changing the ip address shouldn't affect new connections alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 48/64] f2fs: fix to clear FI_NO_PREALLOC alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 50/64] IB/mlx4: Increase maximal message size under UD QP alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 53/64] afs: Connect up the CB.ProbeUuid alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 51/64] IB/mlx5: Assign send CQ and recv CQ of UMR QP alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 52/64] afs: Fix total-length calculation for multiple-page send alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 54/64] kbuild: do not call cc-option before KBUILD_CFLAGS initialization alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 55/64] powerpc/powernv/idle: Round up latency and residency values alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 56/64] ipvlan: fix ipv6 outbound device alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 57/64] ide: ide-atapi: fix compile error with defining macro DEBUG alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 58/64] blk-mq: Avoid that request queue removal can trigger list corruption alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 59/64] nvmet-rdma: update queue list during ib_device removal alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 61/64] audit: ensure that 'audit=1' actually enables audit for PID 1 alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 62/64] dm raid: fix panic when attempting to force a raid to sync alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 60/64] audit: Allow auditd to set pid to 0 to end auditing alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 63/64] md: free unused memory after bitmap resize alexander.levin
2017-12-02 15:51 ` [PATCH AUTOSEL for 4.14 64/64] RDMA/cxgb4: Annotate r2 and stag as __be32 alexander.levin
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=20171202155101.7573-35-alexander.levin@verizon.com \
--to=alexander.levin@verizon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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®