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=1796380456; b=XgkhAaT/nqXgCQgZmMKgdR4H0JfnbrzM+Ld39wUpDJS2amWXB+0HN64eF8V1rKU9R2TQ A3KmmfOiPIxs958RQ7HtAFmn8/yV5ztrPt4zSh4azqpOweVPliVeynfNtOtabtssSBTL1 gAA9IweeRByCPMpJmeC4PqIcIP5Mgr5g3zO8NE2LblMwTX42SvsOsSHrUT+KxOZZdXJ2T cibh29Zco65V4HodVSs9SpAkkGKSnsmSapgvCTbQQMZ/vrbL0yzVYkbXIBqxPSM24WRcL jozsBML7VqzPcougjV/yBJhAOHwz8QmD59LOTLFTUtyl+6cdSXeitNbAP9bnOvv4n6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380456; 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=XHW/MJu+nzziopNKr1f+LYbqOiYF6Oc+zONbTZQ6pFo=; b=W9HggW2VMzESxREboLh93MjSfBdR+l3v9kucCdM9/VPWVIg0yuUwlCGWQzTyhYQv5NqQ uqZZsp056C17G/Y6sNzv8QUb3fYaNzcfHZVnRy38gDdLFa8J+iIWITxp7r9NduGGDNzJR H80kHhk7siJFdYddV8KYVC8qDOiu64of3Ac4klTYOptB8mPSxIboQss2vq0uglOhAGGio RgYz3jIWYHIsKTHhhkyCJgwss3xb79n0zcdXVHM0LSDelw+OEzP3ujDy153hN21z8/1Fs ijOlR2wEi46TPlrZwncsGewH6N/gNI7ZGIRpBMsHwjolNLMw+JhUHOg2Ahj2a9dpiaA== 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=GGIwxcfi; 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 D44BF606A68F; Fri, 4 Dec 2026 10:34:16 +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=GGIwxcfi Received: by smtp.kernel.org (Postfix) with ESMTPSA id F21571F00897; Fri, 4 Dec 2026 10:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380456; bh=XHW/MJu+nzziopNKr1f+LYbqOiYF6Oc+zONbTZQ6pFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GGIwxcfiYp8qCDwzv3xRuTbUj8Tia7PX7jqkuIjjqJKpX1mMIaG0G5QP/7pmOCDUT APOct6bW1/3LD8kaY89MMo6qtQQkTkBbTNyzX7YaNRAdo0/tuVA59eQNQ3XHULrS2n l/sETm1KP6QOd4G4VKECoU5D9cIbmNyyp6+d4r9k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 7.3 282/742] bpf: Refuse metadata maps of signed programs that can be mapped writable Date: Fri, 4 Dec 2026 19:02:26 +0900 Message-ID: <20261204100642.539924233@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit c66c8adf3226e02b74a33728d1fa1e911c3f0d21 ] The signature of a program covers the value of its metadata maps. It holds because they are frozen and exclusive. The freeze is not final for an array that user space was allowed to map for writing, which is why bpf_map_mmap() refuses that for read-only maps. A loader writes to its map, so it's not one of those. Refuse a map that has BPF_F_MMAPABLE without BPF_F_RDONLY_PROG. Light skeletons do not set it. Fixes: b707068e0ed9 ("bpf: Verify signed loader metadata at load time") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261125032938.670542-19-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- Documentation/bpf/signing.rst | 3 ++- kernel/bpf/verifier.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/bpf/signing.rst b/Documentation/bpf/signing.rst index e73eaaebd8b15..102d86f18a6e6 100644 --- a/Documentation/bpf/signing.rst +++ b/Documentation/bpf/signing.rst @@ -141,7 +141,8 @@ reuses the existing ``fd_array``: ``excl_prog_sha``) and a plain array map (``BPF_MAP_TYPE_ARRAY``); only an array map exposes its value buffer through ``map_direct_value_addr()`` as a kernel address spanning ``value_size`` bytes. A map that is not exclusive, not - frozen, or not a plain array is rejected, with a verifier log message naming + frozen, not a plain array, or that user space could map for writing + (``BPF_F_MMAPABLE``) is rejected, with a verifier log message naming the offending map. The kernel appends each map's frozen contents to the instruction buffer and verifies the PKCS#7 signature over the concatenation ``insns || metadata_0 || metadata_1 || ...`` in ``used_maps`` diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 74a5277c5b352..7667982d4e38e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -21405,6 +21405,13 @@ static int bpf_prog_verify_signature(struct bpf_verifier_env *env, err = -EPERM; goto out; } + /* The freeze is not final for it, see bpf_map_mmap() */ + if ((map->map_flags & BPF_F_MMAPABLE) && !(map->map_flags & BPF_F_RDONLY_PROG)) { + verbose(env, "signed program metadata map '%s' must not be mmapable\n", + map->name); + err = -EPERM; + goto out; + } data_sz += map->value_size; } if (bpf_dynptr_check_size(data_sz)) { -- 2.53.0