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=1796383626; b=VHlNm8/VGMNro1CwKwSMEfyK2tJh+rs3kq+AKjJpFtr8VdduKdkler2YE0MgPPbJau2f 3z8HziHjVbQ5sbts++W2lT2B9HDf3mUpDyehH8CkX8AA5j51UiCJ9UHrMm4u8CFjT+C/C YSZK9pManPdiMqfaGtSXyD6Zr1KnHKkxLXUEJCM8KD2UtE7baR2aQ9e9cJAAI200k6r8p 7bGOLV/nAa4UxBCw9FyLgdjbzGjU6m/bENKCqa0+UyPkt7/P0r9OP1xLde3xDclnXJMEr CdsHLK7N89KhlCOmpxyGhoNflIwfU/tYdyJlgjT+t7txkUNTJPB0Tj5NvnZhrGb5ZrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383626; 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=l9DdYeChCNGdy34W8r+T4Dwf0XLUURBUzFTkagjOKBU=; b=KyCVjuE3JZVc4v+daQpKqOU0/N4QcrRM8jbI0860gHB4HVUKGcT+et/jyIddze2uVExf U1AhrOCoYtYKENFe6z0uftqZYsryn41vHdVqlh8wu5EQxZkEZcPQeGZlKsEWhHTiMVFjV g5NbDivtlBPfBuAyts3y2Md5wgMr+rmL+s4cppsOxvEwWYh824lpQBPSxErjM0JHL2Oe9 e0L16RT8qlaJHRyvY17VlpsnUNdGYQhT1a8XF3oDlPylj8JTPy+GpeqzoKb/67N8DsKIo noZzfjs2hH6BLkrZD2CwP8/xO7W5AN0HKsYtB8fNzmArchaGip/gjmh5PQmbllTxLnw== 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=fEyJq3QU; 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 5923A606A332; Fri, 4 Dec 2026 11:27: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=fEyJq3QU Received: by smtp.kernel.org (Postfix) with ESMTPSA id C87591F000C2; Fri, 4 Dec 2026 11:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383626; bh=l9DdYeChCNGdy34W8r+T4Dwf0XLUURBUzFTkagjOKBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fEyJq3QUpKUb1dC+CgHfIwRpHuBUq6buySEAzIOkOndvYxHnRHaKoNw84TmedmN8z F1PoHsnCKOx7XZmg7IGuUMpohLgx1hZV75cez+xXLGxInCT76MdvR68EiMyDqz6AIH t5fBpyMiUH01/el/+UbGOwdLd+smfwsg7LKMOBDQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.12 302/555] bpf: Zero bpf_list_head in copies of map values Date: Fri, 4 Dec 2026 19:05:45 +0900 Message-ID: <20261204100620.878679372@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit 8252c3517f95f02a8569480563a773e0462dce52 ] Lookups from user space copy the value to a buffer and init special fields there. An empty list_head points to itself. The caller gets the address of the buffer. Fill the fields with zeros. It's what a new element of a map has. bpf_refcount in a value reads as 0. Fixes: 3e81740a9062 ("bpf: Centralize btf_field-specific initialization logic") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261125032938.670542-31-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- include/linux/bpf.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index c8d8663b63915..9e8d82248cf56 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -471,7 +471,14 @@ static inline void bpf_obj_init(const struct btf_record *rec, void *obj) */ static inline void check_and_init_map_value(struct bpf_map *map, void *dst) { - bpf_obj_init(map->record, dst); + const struct btf_record *rec = map->record; + int i; + + if (IS_ERR_OR_NULL(rec)) + return; + /* Not bpf_obj_init(): an empty list_head has the address of 'dst' */ + for (i = 0; i < rec->cnt; i++) + memset(dst + rec->fields[i].offset, 0, rec->fields[i].size); } /* memcpy that is used with 8-byte aligned pointers, power-of-8 size and -- 2.53.0