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=1796380477; b=y15FIVrBYtfa2zfNVeg/Hcq5fe6AVZ6Y+51ckoEpS3HXsmZonLTCrJdeLtTyii8CPGw0 W3sniMjjWwnRzCu5Q4+ae1xawOrwGLM36lK5ewCHiSBQ9t+RJiuVmOu+sWmPpahv9fHlh psd2zepmD+WxH5gRwLfL489MRqwiLT0sA6Q16skmzfEfRFT8qisp3E1A5jCHuJ76v9ABc b9WDj5ZnneVZhCCdJFC64IJ1gmXjvWD6bJHBdA1CSvIiT/kCZE44u9JYBrDachJw0xfIA 7HkJJM2On93nsUbnbYmbszNaVPP8gJumCmO2WFEF1xWMryKHizR7EF1G1ts3xJ2bXRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380477; 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=q2NRQQhHLlWXyq4MgWHesBC/28Ucwa+VBEVV0VjmcYI=; b=WSVeg3Ox+tsWBBaZqiyLP6CT239V5cgEnyCLQk4CpjI3F7RZm3I6WWxgACtfYkceKSPz ce15uujJ4ssjri6L7YHFh3t+B+UZvbP14NBeCVc36pydQo9czqSoVHHlt0AZCk/qdwKW1 0S9WuHGvcjJ1+ZU2QyhlmOk6nHwcUuYKntPUSirI4DJeQArGr1VeGm0SZX276Om/m1W5M w0ATTUX1GnSXCYVIWi2kbInK8uTD7bIFaqvS3mQvo15wHB9wYYEYuruiJ+A7Ls55D+9S+ k/0HuC/DKVtBPyVKHvw7WXhX898M9jLkXDxR4TaB157vXTg/WjUXGk4wln9wJsZKIAA== 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=lGrwNZwg; 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 2B8D9606A68F; Fri, 4 Dec 2026 10:34:36 +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=lGrwNZwg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6415B1F00897; Fri, 4 Dec 2026 10:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380476; bh=q2NRQQhHLlWXyq4MgWHesBC/28Ucwa+VBEVV0VjmcYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lGrwNZwg/Q0LKIcFoNjobYrwmo2B9wNX7iGwY6fxI3kCz+cZH3F6iAuZLdsfnGK6i AhJ6ySwnuisgtzv01ESTOkQRLyY3Uoi6l1yjiW4qKfC3mStVlNqAlOQuwWYVNgXXDr 7QDgQyAd83XFeNsDJ+PHsmtRvc2xUXFROQaJ4mG0= 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 290/742] bpf: Zero bpf_list_head in copies of map values Date: Fri, 4 Dec 2026 19:02:34 +0900 Message-ID: <20261204100642.747610847@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: 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 7.3-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 a5e49895d6901..8a8c54cc3d862 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -544,7 +544,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