Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4445983pxv; Tue, 29 Jun 2021 07:14:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNVcL5vfzOt/bEsXVRp7VtSu7J3R7c9cio7qTe7N+pqwutOR3ErEDGugrPifpTj79OOT9p X-Received: by 2002:aa7:d818:: with SMTP id v24mr39847895edq.22.1624976067980; Tue, 29 Jun 2021 07:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624976067; cv=none; d=google.com; s=arc-20160816; b=EDmaXCzaGPrG54Tux/KDZZCiRsN8wyN9dVo0WHtUS+WrbX/+Mct1AZDZwiK553ZZdQ FrzsIjufizYKb4yQB8mT3DQUZy54QnA3rw3XVeDlR83jsfCBC5wG6c3gwTUJqI9bv7t9 X/4LABNMm6r5WVK2Xn19Eil4Xau9FAZ2DKhsx6+LpewG9vrMFpGvr8uheE8Luxn5bdRu 0Cj7Hv5wfecnFFfQomuw8PePugrsonGFwh+6M7Zm1lWfdhgQwJisCabCi+AqUmeVScLr GeGzrginx9zXzFPyx75SU68FlsMDmnZx2OFELv2vL5lou1Snxkf+mxSVtJ8aM+ZpOzFc HZbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Td2jaOtu1OIAJ2dbnNafo3OTJR7dFIW9/V+YM1ko/D8=; b=UP5cA0pAU2IvhNtLnm3eCN8PGP9UQQf5zR1qUd7fVjGvIw5W0j2oK7d5HbZhYxj6aR klB7s8Su9LiW243WU9hIUTEq+EW+gwQpmW+I5npvV1hHtz0ntED58I4Sw/sBum8PLOpq BXLbh6Nqfz9l06HHhz87UJa8JixvMjZIHD6pCmx0ekbOb/OpOCLW0xlJNyIhNk/zSU8/ nC+1NXjda53mgK7nZVPL1GXsYLgLmMaKLHLb+HDgRdtZhogzZBgOgunrm6hPEC67qtie yeigVKfkA0C9gb2/0Kjxvkfn1BAcaTPPglVkarWRGW7JdNjwlvmoAAN7DjITUxOS0Wn1 0vXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AQEABwaS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si14255710edb.437.2021.06.29.07.14.01; Tue, 29 Jun 2021 07:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AQEABwaS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234018AbhF2OMv (ORCPT + 99 others); Tue, 29 Jun 2021 10:12:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41164 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233524AbhF2OMr (ORCPT ); Tue, 29 Jun 2021 10:12:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624975819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Td2jaOtu1OIAJ2dbnNafo3OTJR7dFIW9/V+YM1ko/D8=; b=AQEABwaSSCthlEXyTqd9M7tBsJWOk3CZgNyF/kKReGRzKRxXG92aW6Wf4NUporHEuz9jrN DwyglfG6GrqCbFiDk1Pp1FP/Jez/FMPk0086s6cZRk6Se7YFNmLr8K+rxMbAUseEzD+Vdd bFhilsRhzz+RxfzHm2Ai/JYXYMfflmM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-aSi2ynLONXmuDKwcUzSH7Q-1; Tue, 29 Jun 2021 10:10:13 -0400 X-MC-Unique: aSi2ynLONXmuDKwcUzSH7Q-1 Received: by mail-wm1-f70.google.com with SMTP id u64-20020a1cdd430000b02901ed0109da5fso1349132wmg.4 for ; Tue, 29 Jun 2021 07:10:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Td2jaOtu1OIAJ2dbnNafo3OTJR7dFIW9/V+YM1ko/D8=; b=PVui0svOlXQJMDH9fqqU76ii+dNJ9fcURi7wFbDT1dbgqc5wQ78BQ1BGzLOo0O9rpL t1uhCpdkFxnKk5qy5PS+q2z8qndk7pyUOT8SkaIWkZiEoL1ZNjnWyBO8X6Wz1gjReS9d sIa0/nqoCpkLIID+mtt1xlMFsVUvKkFGDw4eqvy0olFwWasjDiVmCNq+bu2bsCYIWRHa GyQ4/6r6XsYhNJ//JHLIl7Jm2smlW7egHytauoeyymoH6+49jVr7jhe/1Lha6nlvCYkE ssFQgJubdVEbBiz3NMHlbBJI+ugRe3LqcW86HXH8awpaveXyVDMIDwrZikq1wNGbmVq5 5ACQ== X-Gm-Message-State: AOAM531tLd0teD59NMzBeFRiHkTT0UX+wd6hIqLEQkmUjlINGjlzbEBX LKIW6e9bCkgL/fIOPfioId43dM1JyOHkHGOOq8fUgsg7PH5v0wHbYie5sAyMnNu9vV+T4F5Cxpn RGURcukjaV8VVWI4NU21EBHYV X-Received: by 2002:a1c:2142:: with SMTP id h63mr33528935wmh.84.1624975812359; Tue, 29 Jun 2021 07:10:12 -0700 (PDT) X-Received: by 2002:a1c:2142:: with SMTP id h63mr33528890wmh.84.1624975812136; Tue, 29 Jun 2021 07:10:12 -0700 (PDT) Received: from krava ([109.53.15.83]) by smtp.gmail.com with ESMTPSA id p3sm1658779wmq.17.2021.06.29.07.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 07:10:11 -0700 (PDT) Date: Tue, 29 Jun 2021 16:10:08 +0200 From: Jiri Olsa To: Brendan Jackman Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , KP Singh , Florent Revest , John Fastabend , LKML , "Naveen N. Rao" , Sandipan Das Subject: Re: [BUG soft lockup] Re: [PATCH bpf-next v3] bpf: Propagate stack bounds to registers in atomics w/ BPF_FETCH Message-ID: References: <20210202135002.4024825-1-jackmanb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 28, 2021 at 11:21:42AM +0200, Brendan Jackman wrote: > On Sun, 27 Jun 2021 at 17:34, Jiri Olsa wrote: > > > > On Tue, Feb 02, 2021 at 01:50:02PM +0000, Brendan Jackman wrote: > > > > SNIP > > > > > diff --git a/tools/testing/selftests/bpf/verifier/atomic_bounds.c b/tools/testing/selftests/bpf/verifier/atomic_bounds.c > > > new file mode 100644 > > > index 000000000000..e82183e4914f > > > --- /dev/null > > > +++ b/tools/testing/selftests/bpf/verifier/atomic_bounds.c > > > @@ -0,0 +1,27 @@ > > > +{ > > > + "BPF_ATOMIC bounds propagation, mem->reg", > > > + .insns = { > > > + /* a = 0; */ > > > + /* > > > + * Note this is implemented with two separate instructions, > > > + * where you might think one would suffice: > > > + * > > > + * BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), > > > + * > > > + * This is because BPF_ST_MEM doesn't seem to set the stack slot > > > + * type to 0 when storing an immediate. > > > + */ > > > + BPF_MOV64_IMM(BPF_REG_0, 0), > > > + BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8), > > > + /* b = atomic_fetch_add(&a, 1); */ > > > + BPF_MOV64_IMM(BPF_REG_1, 1), > > > + BPF_ATOMIC_OP(BPF_DW, BPF_ADD | BPF_FETCH, BPF_REG_10, BPF_REG_1, -8), > > > + /* Verifier should be able to tell that this infinite loop isn't reachable. */ > > > + /* if (b) while (true) continue; */ > > > + BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, -1), > > > + BPF_EXIT_INSN(), > > > + }, > > > + .result = ACCEPT, > > > + .result_unpriv = REJECT, > > > + .errstr_unpriv = "back-edge", > > > +}, > > > > > > base-commit: 61ca36c8c4eb3bae35a285b1ae18c514cde65439 > > > -- > > > 2.30.0.365.g02bc693789-goog > > > > > > > hi, > > I tracked soft lock up on powerpc to this test: > > > > [root@ibm-p9z-07-lp1 bpf]# ./test_verifier 25 > > #25/u BPF_ATOMIC bounds propagation, mem->reg SKIP > > #25/p BPF_ATOMIC bounds propagation, mem->reg > > > > Message from syslogd@ibm-p9z-07-lp1 at Jun 27 11:24:34 ... > > kernel:watchdog: BUG: soft lockup - CPU#2 stuck for 26s! [test_verifier:1055] > > > > Message from syslogd@ibm-p9z-07-lp1 at Jun 27 11:25:04 ... > > kernel:watchdog: BUG: soft lockup - CPU#2 stuck for 48s! [test_verifier:1055] > > > > please check the console output below.. it looks like the verifier > > allowed the loop to happen for some reason on powerpc.. any idea? > > > > I'm on latest bpf-next/master, I can send the config if needed > > > > thanks, > > jirka > > > > > > --- > > ibm-p9z-07-lp1 login: [ 184.108655] watchdog: BUG: soft lockup - CPU#2 stuck for 26s! [test_verifier:1055] > > [ 184.108679] Modules linked in: snd_seq_dummy(E) snd_hrtimer(E) snd_seq(E) snd_seq_device(E) snd_timer(E) snd(E) soundcore(E) bonding(E) tls(E) rfkill(E) pseries_rng(E) drm(E) fuse(E) drm_panel_orientation_quirks(E) xfs(E) libcrc32c(E) sd_mod(E) t10_pi(E) ibmvscsi(E) ibmveth(E) scsi_transport_srp(E) vmx_crypto(E) dm_mirror(E) dm_region_hash(E) dm_log(E) dm_mod(E) > > [ 184.108722] CPU: 2 PID: 1055 Comm: test_verifier Tainted: G E 5.13.0-rc3+ #3 > > [ 184.108728] NIP: c00800000131314c LR: c000000000c56918 CTR: c008000001313118 > > [ 184.108733] REGS: c0000000119ef820 TRAP: 0900 Tainted: G E (5.13.0-rc3+) > > [ 184.108739] MSR: 8000000000009033 CR: 44222840 XER: 20040003 > > [ 184.108752] CFAR: c008000001313150 IRQMASK: 0 > > [ 184.108752] GPR00: c000000000c5671c c0000000119efac0 c000000002a08400 0000000000000001 > > [ 184.108752] GPR04: c0080000010c0048 ffffffffffffffff 0000000001f3f8ec 0000000000000008 > > [ 184.108752] GPR08: 0000000000000000 c0000000119efae8 0000000000000001 49adb8fcb8417937 > > [ 184.108752] GPR12: c008000001313118 c00000001ecae400 0000000000000000 0000000000000000 > > [ 184.108752] GPR16: 0000000000000000 0000000000000000 0000000000000000 c0000000021cf6f8 > > [ 184.108752] GPR20: 0000000000000000 c0000000119efc34 c0000000119efc30 c0080000010c0048 > > [ 184.108752] GPR24: c00000000a1dc100 0000000000000001 c000000011fadc80 c0000000021cf638 > > [ 184.108752] GPR28: c0080000010c0000 0000000000000001 c0000000021cf638 c0000000119efaf0 > > [ 184.108812] NIP [c00800000131314c] bpf_prog_a2eb9104e5e8a5bf+0x34/0xcee8 > > [ 184.108819] LR [c000000000c56918] bpf_test_run+0x2f8/0x470 > > [ 184.108826] Call Trace: > > [ 184.108828] [c0000000119efac0] [c0000000119efb30] 0xc0000000119efb30 (unreliable) > > [ 184.108835] [c0000000119efb30] [c000000000c5671c] bpf_test_run+0xfc/0x470 > > [ 184.108841] [c0000000119efc10] [c000000000c57b6c] bpf_prog_test_run_skb+0x38c/0x660 > > [ 184.108848] [c0000000119efcb0] [c00000000035de6c] __sys_bpf+0x46c/0xd60 > > [ 184.108854] [c0000000119efd90] [c00000000035e810] sys_bpf+0x30/0x40 > > [ 184.108859] [c0000000119efdb0] [c00000000002ea34] system_call_exception+0x144/0x280 > > [ 184.108866] [c0000000119efe10] [c00000000000c570] system_call_vectored_common+0xf0/0x268 > > [ 184.108874] --- interrupt: 3000 at 0x7fff8bb3ef24 > > [ 184.108878] NIP: 00007fff8bb3ef24 LR: 0000000000000000 CTR: 0000000000000000 > > [ 184.108883] REGS: c0000000119efe80 TRAP: 3000 Tainted: G E (5.13.0-rc3+) > > [ 184.108887] MSR: 800000000280f033 CR: 28000848 XER: 00000000 > > [ 184.108903] IRQMASK: 0 > > [ 184.108903] GPR00: 0000000000000169 00007fffe4577710 00007fff8bc27200 000000000000000a > > [ 184.108903] GPR04: 00007fffe45777b8 0000000000000080 0000000000000001 0000000000000008 > > [ 184.108903] GPR08: 000000000000000a 0000000000000000 0000000000000000 0000000000000000 > > [ 184.108903] GPR12: 0000000000000000 00007fff8be1c400 0000000000000000 0000000000000000 > > [ 184.108903] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > > [ 184.108903] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > > [ 184.108903] GPR24: 0000000000000000 0000000000000000 0000000000000000 000000001000d1d0 > > [ 184.108903] GPR28: 0000000000000002 00007fffe4578128 00007fffe45782c0 00007fffe4577710 > > [ 184.108960] NIP [00007fff8bb3ef24] 0x7fff8bb3ef24 > > [ 184.108964] LR [0000000000000000] 0x0 > > [ 184.108967] --- interrupt: 3000 > > [ 184.108970] Instruction dump: > > [ 184.108974] 60000000 f821ff91 fbe10068 3be10030 39000000 f91ffff8 38600001 393ffff8 > > [ 184.108985] 7d4048a8 7d4a1a14 7d4049ad 4082fff4 <28230000> 4082fffc 60000000 ebe10068 > > Hmm, is the test prog from atomic_bounds.c getting JITed there (my > dumb guess at what '0xc0000000119efb30 (unreliable)' means)? That > shouldn't happen - should get 'eBPF filter atomic op code %02x (@%d) > unsupported\n' in dmesg instead. I wonder if I missed something in > commit 91c960b0056 (bpf: Rename BPF_XADD and prepare to encode other > atomics in .imm). Any idea if this test was ever passing on PowerPC? > hum, I guess not.. will check jirka