From patchwork Mon Sep 18 14:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Kartikeya Dwivedi X-Patchwork-Id: 13390111 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE2D420B03 for ; Mon, 18 Sep 2023 16:51:00 +0000 (UTC) Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0065A3 for ; Mon, 18 Sep 2023 09:50:58 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id 38308e7fff4ca-2ba1e9b1fa9so77281751fa.3 for ; Mon, 18 Sep 2023 09:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695055857; x=1695660657; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bWLbZ1J0oeUlS0QBC3LOMF2rfKN6MrliiLEkPfiun10=; b=NdxCFkyWf209AvcZKs47dhp2N8HmVcsPShcp1bPtgGCygBoWcrXkMTdcl7Ud3HIPfQ rdKGGfszU/8pNkls/iSGxDGdhaqcj6IMfMiwdsmSnH8eb9+EriexLeauwRvWs55F1jW7 q6th4VpMUtLAfZXvINKL1awRf/a8e4zrf/lrU+AR9JJPIodslw9f5fzzkNfPvuLJTlqV +rpFZB4LT2d8gT8aFUKJPf5OG1Z0U9SjWBmun2pMHZaZ5v7FFm4QgMQOvYRPwcxt/0Zl age+YFzQOoUVHDWNuuC7HhAN6lXGpvacV9/qyE1b86YG68TOgXP8XeRsM6QZmFGAi36D ISLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695055857; x=1695660657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bWLbZ1J0oeUlS0QBC3LOMF2rfKN6MrliiLEkPfiun10=; b=LxYt2zrQnInpGeHyxfLQsf1o7/BN9hjn4vDwn+gOnF+lw6VwmMDZ0ENzkogb1Bhbxy MkTbLWq6+BcyYwj0fXqNkk4MtHR4SCjfLZD7ODGdP7/mvWXHz7GyWL5AtFDxC5TRmRQ2 4O433rWW49WVlHHgbX3TQHYbB4+SPmlvx981qWAZK4sXXasVsJXDIhkggdBN4ak8KtNZ YBw6icFRLCsxEhdzHao9t9WD398neMQrtQXXV5g6/jB/coTJysPaUvZ0PhQtPZ0XddVN JNSM9h43fTvdZwSLNOEY242uDEJTJeoPvIty9O+uxeJfTLS7BDA2Ynj8j7Wvn2AzUZYY s3zA== X-Gm-Message-State: AOJu0YzdLHzpN8cWDjPQgtljN0lGe2dCop/NTpZ0v3QSNIGjQiW+XfKJ 30o/TYhD9Yk81APRjhslAWG8eQaO9c/4Ww== X-Google-Smtp-Source: AGHT+IG1ZOQV5T09QxeURfYnxY46S6+4ssVGNP19+FYPoXnTwf1oPUWch8iqyt+5pmzjwzhNFL57EA== X-Received: by 2002:ac2:5dd0:0:b0:500:75e5:a2f0 with SMTP id x16-20020ac25dd0000000b0050075e5a2f0mr7702260lfq.51.1695047957533; Mon, 18 Sep 2023 07:39:17 -0700 (PDT) Received: from localhost (vpn-253-124.epfl.ch. [128.179.253.124]) by smtp.gmail.com with ESMTPSA id t16-20020a508d50000000b0053112d6a40esm1699777edt.82.2023.09.18.07.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:39:17 -0700 (PDT) From: Kumar Kartikeya Dwivedi To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , David Vernet , Puranjay Mohan Subject: [PATCH bpf-next v1 1/3] selftests/bpf: Print log buffer for exceptions test only on failure Date: Mon, 18 Sep 2023 16:39:12 +0200 Message-ID: <20230918143914.292526-2-memxor@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918143914.292526-1-memxor@gmail.com> References: <20230918143914.292526-1-memxor@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1440; i=memxor@gmail.com; h=from:subject; bh=oHvLk0ZHhNY+L7Ri8crRqUByZW+W4S/TRihF1kQbWZ4=; b=owEBbQKS/ZANAwAIAUzgyIZIvxHKAcsmYgBlCGDZ68qPVyIcWw95cm+Qf50mRMtCOeMoIpeaU jCwVNvFr96JAjMEAAEIAB0WIQRLvip+Buz51YI8YRFM4MiGSL8RygUCZQhg2QAKCRBM4MiGSL8R yocEEAC6nF1AMBGImozCUvZkDtGTC58p07gCI6dNDJ4ihlviNahJdFLeJ7FMRg4tG6DiALrHw9T w00P1S2ZcCjwbNQLO04jEhVNIBVqBbH6spYtihXM01weKo9mGXEj71cyJNmY6Tgf6h5qXJkY7hM 5S3QKee0ZXa4TDdoczkRIKAf7PQXmmQ5t/uUtmoGU8t1zxnzaWhUmIa+pn/ang1it4cO/HmTYut d02EgIRw4scWLOKYFRds/mr6v8f7QaRCnR4pxlPM37JXRpTEDfMdsl1uPyW07toO1ysiHRkbHm7 6+s4LJ+cij1rPvSoKHtHqodnSriDGamuybLsseELUsw62SsdOU54XtqBG7vFqokDajjAXPTgfI4 Kmd2yhYULU2+ISpzoNWtGXbjjbTrJf3oP59hY9+M3a/l1hCDu2WsWGNa0SKQIMTb8I7IHKb8x5U KM7UEEnEXcQnlz5GULMj6Q1u8rGL6R9kRCqUWbpneTiLVdMiybqxzq2KUTNLRWFJ+hsb/z4O/HD X9fFp2MQ+IViQXgIRUXARNQbiT2rjmzDmifyLdnqjBU3LZL8PIadyg0fPn7gepNEGK1IcGVa5rd yDgnLhcizpB+Vg2852hpK8IL3RRaaFRXYzokYjmQe+Y+VUPKzREzokyh8IhdzFZNzN/5y6qedZg nVuHPLwDQhxziUg== X-Developer-Key: i=memxor@gmail.com; a=openpgp; fpr=4BBE2A7E06ECF9D5823C61114CE0C88648BF11CA X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net Alexei reported seeing log messages for some test cases even though we just wanted to match the error string from the verifier. Move the printing of the log buffer to a guarded condition so that we only print it when we fail to match on the expected string in the log buffer, preventing unneeded output when running the test. Reported-by: Alexei Starovoitov Fixes: d2a93715bfb0 ("selftests/bpf: Add tests for BPF exceptions") Signed-off-by: Kumar Kartikeya Dwivedi --- tools/testing/selftests/bpf/prog_tests/exceptions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/exceptions.c b/tools/testing/selftests/bpf/prog_tests/exceptions.c index 5663e427dc00..516f4a13013c 100644 --- a/tools/testing/selftests/bpf/prog_tests/exceptions.c +++ b/tools/testing/selftests/bpf/prog_tests/exceptions.c @@ -103,9 +103,10 @@ static void test_exceptions_success(void) goto done; \ } \ if (load_ret != 0) { \ - printf("%s\n", log_buf); \ - if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) \ + if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) { \ + printf("%s\n", log_buf); \ goto done; \ + } \ } \ if (!load_ret && attach_err) { \ if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \ From patchwork Mon Sep 18 14:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Kartikeya Dwivedi X-Patchwork-Id: 13390064 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2BA8262A9 for ; Mon, 18 Sep 2023 16:34:08 +0000 (UTC) Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8BBA9EED for ; Mon, 18 Sep 2023 09:33:55 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id ffacd0b85a97d-31aeef88a55so4224807f8f.2 for ; Mon, 18 Sep 2023 09:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695054834; x=1695659634; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r3Naoc4gG2mkQtePsEFFN2S+1KQG8MR2mniab1JfQY8=; b=jZ35HKH/bxUEogN4Cdt1CmdUHJ4OpBmAcy3ZA8SKuLVzpQc7Wdq1kBRPaOqa8MH7jZ HqkktHqGIZ8mCQsSNbOQxo4OBJj+OsWcyBulpeqztCMqsthb3VUJWSrMPf9YyePR9/YP 8hyHZqSMn//PBm3+cgKRhs/a7O8tPhtsO7+0sQfUWAlhUuhbkB+KRBZmaVT9v8+A1tIq 07F5ZbGq2Fu5XgFc6H5o7Syqh7hApDYzS55YrIT7a0iISfIIe6OvwJdpX4sdV6F28z9I bKD45TxsDZkjdarfs71d82TC8vpkM3ckURYRvJPnATzlAl0ol7J8EKRbH5eAO0rBqg7R wUfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695054834; x=1695659634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r3Naoc4gG2mkQtePsEFFN2S+1KQG8MR2mniab1JfQY8=; b=rmhBLNwzpYC+dZJhMUoCo942/ltc1OwnGuSX4P21/0tyyF1AI+ETLNmAz9YXiLYWHM GgZHTDNYV5IaG+sERFvtwJHug4jLuMHfsNmyNGYyTd2rDtfJGO4wqflWQqC5Pz1BtdYL w7P/Uojt3kk/Tnv0HJWNJ+je1VzyRlwyfojYMVFQL2VNQlL1H6MUEPuMWEuL7dRKmM7Q hniAXxQ7efffBtEFJ0uW6701Ib5mD9O0LLbkqCFq8dSyubxLBsdCbxEBcS1XaRkMnVPs yg9GNXUtglk5S9xhO1S2D/RfQttdP2v5FiZKJ+BNhY5xuMJD4pDPLvaFjC/Dd0h4qi5f /8qA== X-Gm-Message-State: AOJu0YxAQrsSHm0prR9Y8hRrwZgbTo8Dh4bHvFHHeUTLHhRGRDKQkxw4 Xxu5xyAURpH+S7O6T5YUZVkO9V1Va2dc7g== X-Google-Smtp-Source: AGHT+IHCbsvkotmWKbRUe2jnayZm2q5L0JeKRmRUv8GpP0/5wv6mAv5LIYkmThpoBoP2Ad0uSd/WXw== X-Received: by 2002:a17:906:cc9:b0:9a1:af6f:e373 with SMTP id l9-20020a1709060cc900b009a1af6fe373mr7925959ejh.42.1695047958765; Mon, 18 Sep 2023 07:39:18 -0700 (PDT) Received: from localhost (vpn-253-124.epfl.ch. [128.179.253.124]) by smtp.gmail.com with ESMTPSA id v15-20020a17090606cf00b009829d2e892csm6660350ejb.15.2023.09.18.07.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:39:18 -0700 (PDT) From: Kumar Kartikeya Dwivedi To: bpf@vger.kernel.org Cc: Matthieu Baerts , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , David Vernet , Puranjay Mohan Subject: [PATCH bpf-next v1 2/3] bpf: Fix bpf_throw warning on 32-bit arch Date: Mon, 18 Sep 2023 16:39:13 +0200 Message-ID: <20230918143914.292526-3-memxor@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918143914.292526-1-memxor@gmail.com> References: <20230918143914.292526-1-memxor@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1155; i=memxor@gmail.com; h=from:subject; bh=ZOTWQIcL62XArqSGkyZTul7LUdFIfys+cfEYyQUk+J0=; b=owEBbQKS/ZANAwAIAUzgyIZIvxHKAcsmYgBlCGDZNFkPeR7f1jtQEtzuoZ6FDD6EEp2fT9oP7 fA8CdQa9qiJAjMEAAEIAB0WIQRLvip+Buz51YI8YRFM4MiGSL8RygUCZQhg2QAKCRBM4MiGSL8R yrk0D/0fQJ9uVcnSnINXcKuy1/VPmpM/LQJJaFyZvH+A0P5TwzD2sJplIkKaUnCO755SLNI0bqF Xc4jJ0v0GgfikWt3eimeT9K/CvM4UHFOPle7MDUc+VwQs4r/T7MPpy0J5S9p0Nui/ckqGr5hLsg /h3j0x1wc0JMPeMT6qXCWTiqmtwiWYuue7af7zBuN4m68wc8XMQNAZbbRu1cBYcFmjecWL1x00T UGDYAtcm0gRhzRXptMHRz9HyzFcgJ/YTNNo1BhtTMgdY68J+WDpV3YH3ezmkR8JTbmAVgGhlMke XdUY0aQXNKCBAxJjOL+ELdJD3tx0hTabasfDJHLA5EuD3GEiuetm4zuZS21bAtISroUPAOSm6Ef MEDI2aXPsLZ/Rj8sXw0EFaRswOWLGecmpvk8YOWpnDP+n9GqZvFZZy4DbE+Ri3NiaXBqeppOPUy B3mz9d7/kpmoX9PkqxH5hjQfmYUAG9Hg1//CRQ29W8hUKh+184D8yfj2OdizIocn8CdQWJm6YQA IkS3UKiVHFSctHbkoqzK+vq4Z/IJQy2zdZcpMw8rWyg507Im/fLrUqHvE0RscjhpTRDTnjx54Cb NcZMHPzhN5NK1QpaW3Co8Sfx0FfcUQRRapup84xcr5G59/oOgb+avAShQ9+A6l6Js3/VIjlBYv2 2lgbz7sC3iUM3mA== X-Developer-Key: i=memxor@gmail.com; a=openpgp; fpr=4BBE2A7E06ECF9D5823C61114CE0C88648BF11CA X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net On 32-bit architectures, the pointer width is 32-bit, while we try to cast from a u64 down to it, the compiler complains on mismatch in integer size. Fix this by first casting to long which should match the pointer width on targets supported by Linux. Fixes: ec5290a178b7 ("bpf: Prevent KASAN false positive with bpf_throw") Reported-by: Matthieu Baerts Signed-off-by: Kumar Kartikeya Dwivedi --- kernel/bpf/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 7ff2a42f1996..dd1c69ee3375 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2488,7 +2488,7 @@ __bpf_kfunc void bpf_throw(u64 cookie) * deeper stack depths than ctx.sp as we do not return from bpf_throw, * which skips compiler generated instrumentation to do the same. */ - kasan_unpoison_task_stack_below((void *)ctx.sp); + kasan_unpoison_task_stack_below((void *)(long)ctx.sp); ctx.aux->bpf_exception_cb(cookie, ctx.sp, ctx.bp); WARN(1, "A call to BPF exception callback should never return\n"); } From patchwork Mon Sep 18 14:39:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Kartikeya Dwivedi X-Patchwork-Id: 13389847 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FF3A1C289 for ; Mon, 18 Sep 2023 15:36:09 +0000 (UTC) Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13BD01706 for ; Mon, 18 Sep 2023 08:33:01 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id a640c23a62f3a-9adc75f6f09so474493066b.0 for ; Mon, 18 Sep 2023 08:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695050989; x=1695655789; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1YiCPcSujgZLNKIlHUVm+vvy2lgJ4MowgcIqAbJ/rmc=; b=KbNe0xMHjsitcj8rdrAnZ3LUKrtLhdBFDpJeW4hHk0p863fvFHTT0wrfDy7lc7eKMh OWHnG8Yf+gNuuyYcfPvrPUUNBz7ak10fEZ2mSj8EIWOZknoGGoWXQyOovLD797g40kpP lwWF++mytXWZfrSqwkIdcD7Vup1pwqCm4X1fhU2U5V/pPHr0xmQNv5yInGw6F51sSK9p NKfqQAojyVr+mxHs+WR2Hc7ee6uOJFxd62niewNLfYpBchvE+MeVy13vPCKbkJqfriGP g3uznwMJuYFcqXfFTu8HTspiY9RNrW3tOwns72c0Xwb65GdWV6h23jweeeecLtpKc7NG ln5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695050989; x=1695655789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1YiCPcSujgZLNKIlHUVm+vvy2lgJ4MowgcIqAbJ/rmc=; b=CX2OWoAeaJHg9Vi7ZU/aa1CKiQVoIdtezAWlE6v72n5/aicqM2H/pO0QcdeKY8xMLm DCD1oaZEwfMPVBxUiIj2DxYtFc1DUe/90IySrjwRm2thhS1A3lnENtugyrAKiD3eYv4m RGWynS9c9mpoJ/6sekKpcFgDzzK/oapImutSV/0PAjOeDkC0CdbAPvbIjZru3lQofSfu yfWk4gMS8vAiXsD+vVexEQgu/WhlXABsFmo9K7Er58HGRXtfdTZCFz3kpIqHHSY4vz3C UbSnYrD4JlCYEgsJzGAD4HSz+CIzKk+Rm4zKwlZHwR2s54zSlQcVxyXHbp4yGCej/NRu 2kdw== X-Gm-Message-State: AOJu0YwTIKA1RgafpeBNk0Whq4Ii311XW9xBnGn86GV5sVFanabfB6U0 LpRBU3WwtCK2tMs/OT9NWmAuaHmfQg1p/w== X-Google-Smtp-Source: AGHT+IGDlgpk4SMAnwmzydIfWpcDsuXIR1s+XP+sc0EgWsJa4IQq6cy2MHd66g9m/PBnCkMZ7JOYwA== X-Received: by 2002:a05:6512:2526:b0:503:9ea:3a67 with SMTP id be38-20020a056512252600b0050309ea3a67mr5140809lfb.26.1695047959858; Mon, 18 Sep 2023 07:39:19 -0700 (PDT) Received: from localhost (vpn-253-124.epfl.ch. [128.179.253.124]) by smtp.gmail.com with ESMTPSA id v15-20020a056402348f00b005308a170845sm4698778edc.29.2023.09.18.07.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 07:39:19 -0700 (PDT) From: Kumar Kartikeya Dwivedi To: bpf@vger.kernel.org Cc: Eric Dumazet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , David Vernet , Puranjay Mohan Subject: [PATCH bpf-next v1 3/3] bpf: Disable exceptions when CONFIG_UNWINDER_FRAME_POINTER=y Date: Mon, 18 Sep 2023 16:39:14 +0200 Message-ID: <20230918143914.292526-4-memxor@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918143914.292526-1-memxor@gmail.com> References: <20230918143914.292526-1-memxor@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1606; i=memxor@gmail.com; h=from:subject; bh=znk/eRrHas+L6qZGPKLxKYJFS9c8+0jZu8DHA5j7bn8=; b=owEBbQKS/ZANAwAIAUzgyIZIvxHKAcsmYgBlCGDalXKT6QxLcISac8/HqhxMxlkR+GK7znj4E +bFGXLmgz+JAjMEAAEIAB0WIQRLvip+Buz51YI8YRFM4MiGSL8RygUCZQhg2gAKCRBM4MiGSL8R ykQ/D/9btE9cc7zW6cRgnyZ1s6zbD2imMI5MPYJTEygnC+fvhYpOxiVDlmV15iRj86mBXeCgEmF xaxUP7crsJpgs07huyeFoM8CHSnS+/AOFZQC8yOJxJquc02mToLl2DwCz5R/RQwcoYjHxlVpe0s jbZGJ2qs2jOj3BoFm1vwxGg+6ouMPT+K49bCq9E3kZlW2+jU+CnzZKAt3pIUacW8vhvP9sTrmZC V0ijsGVK0yMWe1My7dTL2W0FhIK9iJir/1Q/cAwSQqxnqFI7tq2+RxGx38Af+0tBGGO1DnropSx ztU5vihHb9z7Qd29x43dyGZRrHai33ykYAEHbr3BvcEVlkoFv6dSk7fFv7DGlm4OPxL4/PuOx5J ZhxqAf81eETt3pYQuERXvllZgMVjPcFldbhhqQhedGmXvCbMkAlhvG80vQf6o4QHMmK48K//0dA n7jifOEa9FoDNga00DFy0a45JAqVHLLBuKymrOWptJwrZ8Yy0H4PV1xGqVZGW6rph0QvR0/gq3s elQ6V00lPnzzl9JwRmyu6O3yhdvxA4RVAjjRnF1UMSGacFvpj0k4Il8PEtJfac47zKqNMpZZnbv 8BGegR40ABbMY2mSDu3T++VzNQcYcps5S8P6+ZYamjthYV0G8pRYvRBXdo6ngOabh/eHmgYDyKo 3YBNSqOAbJk0MXw== X-Developer-Key: i=memxor@gmail.com; a=openpgp; fpr=4BBE2A7E06ECF9D5823C61114CE0C88648BF11CA X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net The build with CONFIG_UNWINDER_FRAME_POINTER=y is broken for current exceptions feature as it assumes ORC unwinder specific fields in the unwind_state. Disable exceptions when frame_pointer unwinder is enabled for now. Fixes: fd5d27b70188 ("arch/x86: Implement arch_bpf_stack_walk") Reported-by: Eric Dumazet Signed-off-by: Kumar Kartikeya Dwivedi --- arch/x86/net/bpf_jit_comp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 84005f2114e0..8c10d9abc239 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -3003,16 +3003,15 @@ void bpf_jit_free(struct bpf_prog *prog) bool bpf_jit_supports_exceptions(void) { /* We unwind through both kernel frames (starting from within bpf_throw - * call) and BPF frames. Therefore we require one of ORC or FP unwinder - * to be enabled to walk kernel frames and reach BPF frames in the stack - * trace. + * call) and BPF frames. Therefore we require ORC unwinder to be enabled + * to walk kernel frames and reach BPF frames in the stack trace. */ - return IS_ENABLED(CONFIG_UNWINDER_ORC) || IS_ENABLED(CONFIG_UNWINDER_FRAME_POINTER); + return IS_ENABLED(CONFIG_UNWINDER_ORC); } void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp), void *cookie) { -#if defined(CONFIG_UNWINDER_ORC) || defined(CONFIG_UNWINDER_FRAME_POINTER) +#if defined(CONFIG_UNWINDER_ORC) struct unwind_state state; unsigned long addr;