From nobody Thu Apr 9 23:23:24 2026 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96FC531F9B6 for ; Thu, 5 Mar 2026 07:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772696071; cv=none; b=foIiGt48c0FJWGV/TP+LoWm2OuVzEwxx3vRQ2Tcn1XunkAwvQoOwtMTsZNLc4OIsqKgvw8J2RNORE4oUtuiCfm0xYHnELLiP7WU3TpmplMAWu9z20kit/REfXsC/in8ZhZUz3PrfilUj0hHudbap6TdwN6jA1JUMbZXjfBxROms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772696071; c=relaxed/simple; bh=MHxiNpiYg4UslTUbQeAmuvquHyi/On2XedZkol9Nn/k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tztWu73QLMRCTTjXZnYD46j/r1cfeEt8C1Mzl6sb6Gi4ikdViTYAYNGdkg9IztFZ2wggyUG+JdofRxV4fxLLkImVUP7wRq5eoiu2mm851U8NZdqjH5lVC7mo36vGvRUdawc1mzIxmPBGV2vuCk6KUMEnVbSGKaaBg8pyzvAB4nc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=P63IjC4I; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="P63IjC4I" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772696057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vrhmpsYNV6AoYX0jQ9J/i2Jc+3t5kMVOzCIjalv+idU=; b=P63IjC4IGxxcuTS7WhuQl6yfkOo6B4soN64++OupOMPQ8Qd7t/A75JO606nyKl82dJymoC Baw2Z9bvrTLPFexr4lJcOhjdi5aT7VJoJkZJK+AfnJSgPElUbrqgxquOaiOdyjxn0K1dpo v04jkUG5514uVuAlYpVX6jvCfXxzctY= From: Jiayuan Chen To: netdev@vger.kernel.org Cc: jiayuan.chen@linux.dev, Jiayuan Chen , syzbot+d5ace703ed883df56e42@syzkaller.appspotmail.com, Jamal Hadi Salim , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kees Cook , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH net-next v1] net: sched: cls_u32: Avoid memcpy() false-positive warning in u32_init_knode() Date: Thu, 5 Mar 2026 15:33:43 +0800 Message-ID: <20260305073343.250702-1-jiayuan.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Jiayuan Chen Syzbot reported a warning in u32_init_knode() [1]. Similar to commit 7cba18332e36 ("net: sched: cls_u32: Avoid memcpy() false-positive warning") which addressed the same issue in u32_change(), use unsafe_memcpy() in u32_init_knode() to work around the compiler's inability to see into composite flexible array structs. This silences the false-positive reported by syzbot: memcpy: detected field-spanning write (size 32) of single field "&new->sel" at net/sched/cls_u32.c:855 (size 16) Since the memory is correctly allocated with kzalloc_flex() using s->nkeys, this is purely a false positive and does not need a Fixes tag. [1] https://syzkaller.appspot.com/bug?extid=3Dd5ace703ed883df56e42 Reported-by: syzbot+d5ace703ed883df56e42@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/69a811b9.a70a0220.b118c.0019.GAE@google= .com/T/ Signed-off-by: Jiayuan Chen Made-with: Cursor Acked-by: Gustavo A. R. Silva Reviewed-by: Simon Horman --- net/sched/cls_u32.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 9241c025aa74..8f30cc82181d 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -852,7 +852,10 @@ static struct tc_u_knode *u32_init_knode(struct net *n= et, struct tcf_proto *tp, /* Similarly success statistics must be moved as pointers */ new->pcpu_success =3D n->pcpu_success; #endif - memcpy(&new->sel, s, struct_size(s, keys, s->nkeys)); + unsafe_memcpy(&new->sel, s, struct_size(s, keys, s->nkeys), + /* A composite flex-array structure destination, + * which was correctly sized with kzalloc_flex(), + * above. */); =20 if (tcf_exts_init(&new->exts, net, TCA_U32_ACT, TCA_U32_POLICE)) { kfree(new); --=20 2.43.0