From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5BB4C35C682; Tue, 21 Jul 2026 22:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671668; cv=none; b=OPtVAbW5su97CaTzbWUTP68Y79vPC9OG2POQMiMBIGRZvSPO6oQc4UtZuedr5I+LjsbHRBhh5npO9QnzM/QO8/k0mUH1tBzyJ/wo9G/uuQh45TVqFf/esFaNqbtvwiJG0dk7l1DVbYMoO5VbCY+9zMVdotfGkKtX+1j1Kjg3E68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671668; c=relaxed/simple; bh=eRcP/iWYc8Uima3znT4HJqgkzIB0yt2BU4BtI7kkVTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUJX4c7vyws+FQIgWMRCB+12VbaEL6LZClsxNVqFG95EDzneAmMF1aAbniD8MmWXuQihSsAnF3XhWXveDUeqRlsZ+I2NplBUkGikIAK0HIOPy6+1pzWIua5MxGiep5lo8Npfia1ih4sHsoyE+fQTl+2wWVVabWMtiG8RtenDZGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X6xjU4Tt; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X6xjU4Tt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C12C21F000E9; Tue, 21 Jul 2026 22:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671667; bh=Esy02s+UPLPl8zf+8J5DwXaaV3HUC7U45SldZECppCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X6xjU4Tt2+Yv5pFufjJdSPFUHEa1tGbC7v9V/0yJfksIgcNKjL5hbpO4YMA+lYWei G/qQIyNq6a2N31AHRpVBB6m3P6/FERjNhjX1OM0M3rULuJWjlaL26aUes4LFLFtPvB Si6MRN3UyH3GltetAlQpCqGDL9Dc+d+HnjhgEjUE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lin Ma , Daniel Borkmann , Yonghong Song , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.15 333/843] bpf: Tighten cgroup storage cookie checks for prog arrays Date: Tue, 21 Jul 2026 17:19:28 +0200 Message-ID: <20260721152413.511565274@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann [ Upstream commit 10627ddc0167aab5c1c390a10ef461e9937aba08 ] The fix in commit abad3d0bad72 ("bpf: Fix oob access in cgroup local storage") is still incomplete. The prog-array compatibility check treats a program with no cgroup storage as compatible with any stored storage cookie. This allows a storage-less program to bridge a tail call chain between an entry program and a storage-using callee even though cgroup local storage at runtime still follows the caller's context, that is, A -> B(no storage) -> C(storage) path. Requiring exact cookie equality would break the legitimate case of a storage-less leaf program being tail called from a storage-using one. Instead, only accept a zero storage cookie if the program cannot perform tail calls itself. This keeps A -> B(no storage) working while rejecting the A -> B(no storage) -> C(storage) bridge. Fixes: abad3d0bad72 ("bpf: Fix oob access in cgroup local storage") Reported-by: Lin Ma Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://lore.kernel.org/r/20260610105539.705887-1-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 73a1c66e541756..ac921214059f44 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1872,7 +1872,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map, cookie = aux->cgroup_storage[i] ? aux->cgroup_storage[i]->cookie : 0; ret = map->owner->storage_cookie[i] == cookie || - !cookie; + (!cookie && !aux->tail_call_reachable); } if (ret && map->owner->attach_func_proto != aux->attach_func_proto) { -- 2.53.0