Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp530221rwd; Mon, 12 Jun 2023 18:11:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4h46fckejpe+iR91AKapfW3A2jx9h+RKcBRxAkgY4GeVkmTjkVjh5dHvjryOtKB4xlQDzT X-Received: by 2002:a17:907:318d:b0:974:6176:2223 with SMTP id xe13-20020a170907318d00b0097461762223mr12587926ejb.13.1686618666580; Mon, 12 Jun 2023 18:11:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686618666; cv=pass; d=google.com; s=arc-20160816; b=M75uc9CuCjh625iaSGGsiwJUlO03enjQCIzGr6jtMroh2ggQcBKhquVPSEhYhY4vYO FUpGd2NJqcoR90wV7+VVpR/LXk78WmF9Gu88TtweseqpM3BwHiGXUyUei1+q5RtJB+e9 CNyYiA+MaJ+P7vb2Yul5OeJpy4elxXhc0dUjr2CjBpgDhAqb1LOxtPRi6CHA4ylErqfc ynkjAtvGoI+ZY+CvxC9cdZCrZE55LsWMr7l/wm30uA5dzQbV7/bssq1POW9Q8fKieWYs F3oVgSc3XfKwyNg5DpQoXW0zFpNW3dErsDIQkD/mN8XURiHWwf7oOS3lA4lrZ7pjOm+X Pkig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=vmQhC6SeaPxx97c+zFJ563SLRjLwlbU/iq8B+BP3oDM=; b=N9rxJOxZEP9kcBotOlV/rxqeR394ngsk0He9aILLehbkHjqlIOwXFyB7vKXJqMjHjL Ggt9jNE332nvqqjQTKzFuEWeNQIXf7m6wKv3Ar82gG87z6ae0O+SaTlAqcMnp3RPMGyV VCFVU1/ooiLMer5Q9XpzVxl4C1st5kXu+aEkf0tevVWOJj9REGpn/0Ymz7k1hBQ53U72 KWSLNtqUiJh1vKgjzs1ktVp4yZb6kvkuO4UTcg+CuvgRxSl9C+I9dcLuF7ppBmyqgPRL WrxzhxNkTygzoNfUT9AW+FYY1JR5NiHDsP8EllbW8reyg5z/5hL1l3NP8gOZ9z8w58+D W6Ng== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=bTIfQAi0; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a170906081700b0097668bb795asi3188114ejd.312.2023.06.12.18.10.41; Mon, 12 Jun 2023 18:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=bTIfQAi0; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236430AbjFMAod (ORCPT + 99 others); Mon, 12 Jun 2023 20:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236297AbjFMAob (ORCPT ); Mon, 12 Jun 2023 20:44:31 -0400 Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C122E52 for ; Mon, 12 Jun 2023 17:44:26 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 44B2241955 for ; Tue, 13 Jun 2023 00:44:26 +0000 (UTC) Received: from pdx1-sub0-mail-a313.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id CE749418D6 for ; Tue, 13 Jun 2023 00:44:25 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1686617065; a=rsa-sha256; cv=none; b=KHljh0IZ8rSfqDmGJjYFVcAAI4nLJHJpz+0WtBVpJHEKJP+dncCJSw0uuosU6t8or0E5dA UWxH5TXp7+0w/J+uKjP70CmCD+VwOVa4Tkqto57GQKJbZ/A4HRnmK/w3BnJPuzSDDHnteR ZP/uui+HfRvkhPP6uFBJIv5++P+l74nVY0hrALS2VqVAty32OFnBLSAlO9fBDtdX7/tpNa leAL4wM7QTLXbPcdUGavivxNSjBq3jHrOwJCn0s1BUvif1Dl+Nk7P7VANiloqSbtVb0nz2 SIFhsNFveLoBb04YzzNuRp2NVl7GV+uzs9l97Nhc//Qx0rqs5VYBVRHEEREl5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1686617065; 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: dkim-signature; bh=vmQhC6SeaPxx97c+zFJ563SLRjLwlbU/iq8B+BP3oDM=; b=o66KDktqdBPUqCwGb/TUP3T0by3vFEI3MLnL4l/V+XS/WSW/VVCQyak/UtHxew6Lw1MHNY LZhWjhnyynDKzyuj7BqqUzaJ+f7iHMiQDSpPP3jfwZXrxXfnomceDI/uNqCIxYdIwPsWe/ rPCAuMePKir6/he0YTDATAfjg++L9eg+2QtKm7USn3F8SblAHlVAlPDd7x81Eo1RZzLkJH AVxScNGiNXt/yRjFOZJMSB2f7mIWFg9bZAdL/oPuvr1HT5vhrfIZqsVnGWt5bp/0cqSCvs 69Le/FLtSxeqMxjMJWLUD4bxQ0Hklu+w10IBPc80Ul94h7UgdQDWPLiH7KH7eA== ARC-Authentication-Results: i=1; rspamd-7c78575475-lvc6p; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@templeofstupid.com X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|kjlx@templeofstupid.com X-MailChannels-Auth-Id: dreamhost X-Little-Army: 2377cfc855bfe16a_1686617066072_2781353134 X-MC-Loop-Signature: 1686617066072:537619545 X-MC-Ingress-Time: 1686617066072 Received: from pdx1-sub0-mail-a313.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.115.252.216 (trex/6.8.1); Tue, 13 Jun 2023 00:44:26 +0000 Received: from kmjvbox (c-73-93-64-36.hsd1.ca.comcast.net [73.93.64.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by pdx1-sub0-mail-a313.dreamhost.com (Postfix) with ESMTPSA id 4Qg8vY0vcfzj6 for ; Mon, 12 Jun 2023 17:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=templeofstupid.com; s=dreamhost; t=1686617065; bh=vmQhC6SeaPxx97c+zFJ563SLRjLwlbU/iq8B+BP3oDM=; h=Date:From:To:Cc:Subject:Content-Type; b=bTIfQAi0v35ZalghH08IYi7gkPdgICLUA3+w/CA7XBekZmY+arRr33qiX7O85W04o rpvdgcC4rWEezjTo9KM5bO2pvp2lleBKf40ZQZe8hrbaKhHlHgPWcdp8aEXc81R4Jj ohGM6qvt+BAgKTpSf3/qQoMNjiFfs+6j6X8GsQKY= Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e027c by kmjvbox (DragonFly Mail Agent v0.12); Mon, 12 Jun 2023 17:44:24 -0700 Date: Mon, 12 Jun 2023 17:44:24 -0700 From: Krister Johansen To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Ilya Leoshkevich , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf v5 0/2] bpf: fix NULL dereference during extable search Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Enclosed are a pair of patches for an oops that can occur if an exception is generated while a bpf subprogram is running. One of the bpf_prog_aux entries for the subprograms are missing an extable. This can lead to an exception that would otherwise be handled turning into a NULL pointer bug. These changes were tested via the verifier and progs selftests and no regressions were observed. Changes from v4: - Ensure that num_exentries is copied to prog->aux from func[0] (Feedback from Ilya Leoshkevich) Changes from v3: - Selftest style fixups (Feedback from Yonghong Song) - Selftest needs to assert that test bpf program executed (Feedback from Yonghong Song) - Selftest should combine open and load using open_and_load (Feedback from Yonghong Song) Changes from v2: - Insert only the main program's kallsyms (Feedback from Yonghong Song and Alexei Starovoitov) - Selftest should use ASSERT instead of CHECK (Feedback from Yonghong Song) - Selftest needs some cleanup (Feedback from Yonghong Song) - Switch patch order (Feedback from Alexei Starovoitov) Changes from v1: - Add a selftest (Feedback From Alexei Starovoitov) - Move to a 1-line verifier change instead of searching multiple extables Krister Johansen (2): bpf: ensure main program has an extable selftests/bpf: add a test for subprogram extables kernel/bpf/verifier.c | 7 ++- .../bpf/prog_tests/subprogs_extable.c | 29 +++++++++++ .../bpf/progs/test_subprogs_extable.c | 51 +++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/subprogs_extable.c create mode 100644 tools/testing/selftests/bpf/progs/test_subprogs_extable.c -- 2.25.1