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=1796386460; b=QRJ5c5vowVt/tdzEPSwKW4nnrZXVDjGCrc21gQKv0qWSyacU3JZgYIELbz0+EleR+Rcy D9exVMqyRiEieTqbZwbuRHcv0h2abZVmyBz6z4l0SSKcmG+BqEyJgFqeBK1U3x326gu9k hIcUw5CMOlfqYwK+2D6oX+abc0+m84g2jdhApswKxKL7U+8qvA0ImW0qPa4PbEIRyS10o Orx/FhO2sFpcfQxn9HX4ilQkK9v4rdalg0wzIy5SikY2154+GFxT0BAfmMOY4UFFqQLbi HVy4QezIWOJzvs3/aeiRECoEsimjbfh4+fQibGXWSRD5LoqFvdSsZODW9zSCLtiEQNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386460; 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=mXH3BToQ3u+fJKJhdLWBnCw66MsQXftF4g4/N0BLBCM=; b=TpIIw+KAACBkDXPYxWT8HVxvxfV9NvvCd3D4/FVFqRPvaBZL/QqGLwaAwfwlUPf87dDe dzJhF56KyB19grubgJKZFCk9rQaCTemowpvl16DVbJJjyDz7pEA17MnSf0DV0BYkLiQc/ nUfWwr0Iergg4Zx7FCTO5s9s7G9pzlAqx/S6TotbN6f1cRr8OhtmMNvigOdY7Rkbcrei0 dktC1HwuuW0wyRgluaAePkJhUH+g9TNxfcvLkTrRAgDohvoS/kVgArx0ZCubn9R/Li2hY w0iWVLw2cvot3fbYLgueDhyKxwstAiCk4ToQn6KlVIf9SeYExfA4SItKVRq1IO46rfA== 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=uLIcLZoi; 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 80569606A322; Fri, 4 Dec 2026 12:14:20 +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=uLIcLZoi Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE4D51F000C2; Fri, 4 Dec 2026 12:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386460; bh=mXH3BToQ3u+fJKJhdLWBnCw66MsQXftF4g4/N0BLBCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uLIcLZoihFBPa8ZtRu4dtVrtajCV2pWqaXOMLXPoHfGWUmDpuTerh6fN3msZ/BvWn oWEh6plS6sBK83T/iz6FgdyjROkOXVXjwMxS0DoAHVTgj1iTF9zxfPllyiXnakA4wz ifcmjDpClvNb0dJrz3eHVbMxwxitULI0sAoFrKSM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.6 0971/1167] bpf: Zero bpf_list_head in copies of map values Date: Fri, 4 Dec 2026 19:06:38 +0900 Message-ID: <20261204100727.484674222@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: 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 1283266e02aee..9adeac08438b2 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -453,7 +453,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