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=1796382118; b=lh2Uh6iPUNaRtMt7Bp+iE00Vcxq8ig4nCB1gqsvLjH5MKD18i7wVxiIeN5bajADrOetO gix6dpHT5I2tccol8VUXDzxSrukuCxcCqd3WHpO4rpl1m996jR4LiiovfsThMzV0biP2x MD4/Zd9fSKbImHlU/4B77MxfmIym0Szw6mgs/h7GnWEuqDYeRQcmcdxkUpkcRTqDA9DWS ciEl0WAZjR2OccxCxsotxckziFRl7JFTVnMRKwQD4MY9xcH/jyycnR0g+I0E0phXnk+iR k33XKhHqNQII4+n/ewFF2Y+sYNXrUzIVqnRt4NRqp06Kc3P5C6O3YAofVw62BI1daKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382118; 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=tR/0uSfGhtHsNgXtU0yQHxlzEUI380dTKK8mjABYvhA=; b=O8nbjB17LFC6jk1eoZpORCrwyynuRy5HYvK/YeJ1e93a58Cv1bpbtsH5Ka1LEHz/93w/ PPW2B69t6AbdWM0JYE4lV19ioC8+xswB8NOxOIr/DDG/c7d6+hrbz7fxJ6JI0XzZNDnb8 NRYMtctxbEJvnYeGllp2Tm68cB71flHakxRCTZU1Ih8EuOpQoJc2H07ZocFUS8cW+pFTs F3VwQCKveQ31mGhgOY7At5XcNemrTgwgZhKqdUbUi043PDkhNJIvdaep/DtPZE7N1x73V 0N7UuHa7J4c8fdY1q2U3YIOU/wi2HQclUOe/xq7QVHp0T4wftlNTLWG6pjwIN+r7Dbw== 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=yg16OKQl; 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 1A3F1606A32C; Fri, 4 Dec 2026 11:01:58 +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=yg16OKQl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86C751F000CE; Fri, 4 Dec 2026 11:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382118; bh=tR/0uSfGhtHsNgXtU0yQHxlzEUI380dTKK8mjABYvhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yg16OKQlH7ILZ5ja9T9YH4HVgsWJI5VktpxPOschl+bH1smymaoINtv8Aj7zKLl9D katVbjTWtdfC9WmK/VNVoi3n2G0qpcCoBKPOkvBlbSC98by51QyZD+qkNrRWYruEKu 7Q8RDofQ04Ur+J6OGkqKgFo68VxBUmvZLKjRe+YU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.18 314/703] bpf: Zero bpf_list_head in copies of map values Date: Fri, 4 Dec 2026 19:03:33 +0900 Message-ID: <20261204100636.133876568@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 74110a8c800d9..ca45adf8ddd8e 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -507,7 +507,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