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=1796385126; b=QROhznFYGjTck8rEXfENJolD+hGlUOoqHDkSoEdVAtft9GXbXbJ1lrt3KpjPQS7hGImv dnKVw8VD9hPRtHub+G0Li6JJXDD4KFqpjJ4ndY2knAD7WN40cPbLPNm5bp7FYSoA1+vmG 8DOUEqpCnErMz7wylx8gTcv+jp0wz+KgkRmBg5ubEqhirXa/IzGFYhL/ktD/+d/e+RVAY GlQkKJtROmEdTnP4eYsZ2YEhIXwikqerUYc+MYQA89Ro5YZWWjqRJqcAnfwFSBOy1dY/F SQwwnlMVm9k/F9WoTuETQTQpjHkJKObewGACaBISYUe//+rT5+zkOz/78KbEHK2dvAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385126; 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=MKf5xoG8weZhEsPmzPV+MhLNNBPLUH9tmFQvdB5ps/A=; b=YR18tPadbDuuwV98iZAiIPyBFA2UMFmlZZz7di1Y5wbrkDF+XIF/iSDSqg4qI0E6kqg3 /1Y2U4Y+eJrOPvJBLZMa1W3IQVlkpd3dq7yaN2alQTMtzPGgGvdryVzQVppfQm1YalCvQ G5oL/qyd1nnILv/eu0kY5gAhBJE6zRcf6dp5CfteyP8uJHa0L2O6Qged5LgQmGp7wU1QP oUR6z13JerZzgOd6hTJVZSMAWuhLWdQW+jWlBdZei0gVpIZFX6TlFRs6EoviMPTo4z6uc FdduaHxfUkCuWDSFMBEIg+el+Njf7dFg+yRqutkvWulDTF5dy8MJd24Xhr+zqSHicqQ== 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=mng223V3; 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 D576F606A32C; Fri, 4 Dec 2026 11:52:06 +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=mng223V3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 511781F00897; Fri, 4 Dec 2026 11:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385126; bh=MKf5xoG8weZhEsPmzPV+MhLNNBPLUH9tmFQvdB5ps/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mng223V3SNnzK1GVeivf7cBsY8GHPYUIUTyb4kw34LXJIt2qHs3BFVPnZVbNW1MkH K5x2J9R2pctqhy5ymfJyliAxIQKIAhxzTNI//e9bRWqQdtyOLZWyYNdULyE5DQrkhD R+i02r2dkUVrO9kF96shEo1KAZGmFPBIJ3GCpZo0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josef Bacik , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.6 0430/1167] bpf: Assume no bounds for buffers behind a tail call Date: Fri, 4 Dec 2026 18:57:37 +0900 Message-ID: <20261204100713.217770109@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit 7fa323d77688e8b62b2f0bf6c3208a2c96d4a5e7 ] The bpf_map_elem, bpf_sk_storage_map and sockmap iterators hand the key and the value of an element to the program as buffers. The verifier notes how far a program reaches into them, and the iterator compares that with the map when the program is attached. A program that does not touch the buffers passes. It can tail-call another program of the same target, which gets the same context, and whose reach nobody compares with the map: BUG: KASAN: slab-out-of-bounds in ___bpf_prog_run+0xa46a/0xae80 The program array can be filled at any time, so there is nothing to look at when the link is made. For the same reason a program with a tail call is taken to use the whole stack and the whole packet. Take it to reach as far as can be into the buffers as well, so that these iterators refuse it with -EACCES. Fixes: d6c4503cc296 ("bpf: Implement bpf iterator for hash maps") Fixes: 5ce6e77c7edf ("bpf: Implement bpf iterator for sock local storage map") Fixes: 0365351524d7 ("net: Allow iterating sockmap and sockhash") Signed-off-by: Josef Bacik Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261017163745.3341787-26-alexei.starovoitov@gmail.com [ sashal: adjusted the tail-call fixup to the older file and function names (verifier.c, do_misc_fixups) with the older allow_tail_call_in_subprogs() context line. ] Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 771d0c5a46ac4..8d60218344b4d 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -19548,6 +19548,8 @@ static int do_misc_fixups(struct bpf_verifier_env *env) if (!allow_tail_call_in_subprogs(env)) prog->aux->stack_depth = MAX_BPF_STACK; prog->aux->max_pkt_offset = MAX_PACKET_OFF; + prog->aux->max_rdonly_access = U32_MAX; + prog->aux->max_rdwr_access = U32_MAX; /* mark bpf_tail_call as different opcode to avoid * conditional branch in the interpreter for every normal -- 2.53.0