From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387925; b=KwTLOm9bvpz8RzkwiID3mufuFJPjjU/AOR0NDeJ38YBhxO0xeKeCJOXD1QTDbIdiEAkd o+KxOPw56XNP3hf6x8laxV5Sd8VRjALoHhtPr49vGVdMKN+0zQq2JBn7lFoSENcV8d4Ey sfLCGmqvdmc7K+CGZuHAxxWcvK7P/fIT029xdqQHoC/LnuG32tuFQTXWl1TzS4YGPuMk4 d+otbuioPl6kPMZHwpPWbnvx9p7alURckthuJu5DOKwAhT20MiuyTm4kpsLvC7yBVP2bw ijsayBq+aPVUruzvILnmRMu25zmFPX9HAZ9JtdTVqFj95aIcKHKn4tNiCcNE/dkHyng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387925; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=2TRuq1zc0eciUkC0gd6ZGhKBNUNMtKUi0TU0LeWfoK0=; b=UkRjKPxNu5hGZDEBP8hZ185tJUTEMBlJxeQF0WRKhRVgwunlVrA/itB/Tl4QrAI5+c4a 0PiLwv7BYF+Hj2ICrbNSgETOkeBGk8vC/mHmbAzV1cdTCtfwrZZOnQfrMMX2TQTm8znL+ QiOEm9rDTM7ec3K1tJ+B9jjCK+j9t9WyBDIy+enIO+vHaAiVqvv7jG6hF7Gsw5af+5sxb l9nBYF4H9Mz/1d1g7lZwtPaCSY/2JDHTlOdT7hL7Eh+gxtVUI5Aw3Dy5284lImHLOLTld icDgdYbtWWnsQYA7latWdiOCjQ8L3NqEWctkOFsUHIj+F8jr/9hUv2BqTV317cnSXfw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JecKaaTy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A399606A322; Fri, 4 Dec 2026 12:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JecKaaTy Received: by smtp.kernel.org (Postfix) with ESMTPSA id F39DA1F000C2; Fri, 4 Dec 2026 12:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387925; bh=2TRuq1zc0eciUkC0gd6ZGhKBNUNMtKUi0TU0LeWfoK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JecKaaTypdfdZ3PfsAKUex0m/S6RedM7BmJecfELvy7jaUFcua6XndZXMNBSHmxTk Gm8Zrs5HCh/iZToSK+FgxDx215Rtf9/72NK88c0ikYYsX/W6XG+SNTzmZsR3X/SqGm xxFLupivY277eDhw0wGJ/1E2fTymYjf3vlkNFNEA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.1 0415/1059] bpf: Dont take an extension for a writable raw tracepoint program Date: Fri, 4 Dec 2026 18:59:06 +0900 Message-ID: <20261204100655.087554784@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit 7fe348f18b37b3f4c8beb981ef3f84564047380a ] bpf_probe_register() compares max_tp_access of the program that is attached with the size of the buffer that the tracepoint lets programs write to. An extension of that program, or of one of its global functions, gets the same context and the same pointer to the buffer. What it accesses is noted in its own max_tp_access, which nobody looks at. So it reads and writes behind the buffer, of a tracepoint that may have none: BUG: KASAN: stack-out-of-bounds in bpf_prog_5843f2b820eb4929_tr26_ext_far+0xf4/0x10c Write of size 4 at addr ffffc90000d8f894 by task wext/103 Refuse such extensions. Fixes: be8704ff07d2 ("bpf: Introduce dynamic program extensions") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261017163745.3341787-29-alexei.starovoitov@gmail.com [ sashal: Context-only difference: the hunk's anchor lines for the packet-data-change feature are absent, so the check is inserted as the last statement of the extension-program block after the JIT check. ] Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 2cbf43f3149ed..3e2865e0dc80b 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -15231,6 +15231,15 @@ int bpf_check_attach_target(struct bpf_verifier_log *log, "Extension programs should be JITed\n"); return -EINVAL; } + /* + * How much of the buffer of the tracepoint is used + * is checked for the program that is attached to it. + */ + if (tgt_prog->type == BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE) { + bpf_log(log, + "Cannot extend a writable raw tracepoint program\n"); + return -EINVAL; + } } if (!tgt_prog->jited) { bpf_log(log, "Can attach to only JITed progs\n"); -- 2.53.0