From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D68361A2392 for ; Sat, 9 May 2026 14:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778337466; cv=none; b=EtCtLlDcJPSjyRT52Qm5SjNgpI+q8DsNIfzzl5NEqXod7YEQ9e4Q17gIMoJc0eNZFRgR2pRDoNdeHJcsUgJTBeOJ3Cafe60BFVg0/8Rv31wnNuPiHrbVew8IEkJNnZJ1ElRAef25yL9d9LXGbcL+jJYvtSHVW7FwFpMG5VW28KE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778337466; c=relaxed/simple; bh=UojDEiS+a7ahpuK82RudsaPwn4v3xANM0iS4jcGkw88=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=f2UywvE+DJEweOdXFuYBR76TFbmO/I8X7biOqjCv1hXk08Hep0Gw6FAH4Dwa7KhHOQ8VKYrK1NE9NgU19DHkbv8OJF1Esbs4KWGiAztASLrprYIcGOkelrPF0Ybytyvl3FFcUylsrS+6dp4LmE+HUxVM6p/bc11h7p7mZXmrOW4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=xteuvk60; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="xteuvk60" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4891e5b9c1fso27910135e9.2 for ; Sat, 09 May 2026 07:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1778337462; x=1778942262; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cOcGfIOtFOkiWqfncI0KZjtYci+VZ44xdjbjhNWu6Xc=; b=xteuvk60IjPYHi/gx+b+w99IA+qnNFOgsqV/ytkxYGzWiOZ16UZcRtMqX/LGdB6dAf 2pgg70fZMRJ46Z2fF03GHN1o+5ep9nUf2yBpjhuhhwxLeuUPsSuMd9L7TFhEFN1hFdN0 tmC5hjo43CdSfuH1sy5kpaY7Rwo1koyQ0e0bN3Nv88y97hOP8OFEogIWM8xCNAXx5Fyl MMnGf2+4DCMG79Ftmn2/Vrnv7P4K9C1/Ge5NIfBLxPbyZCTq2ZCc7FOgsPKkgPifNJoY L5WqRfIxPCKf8gEyDgmz79nt6qWO+jFCAbcZUXIkqEGGVGz4chvJqC/Idtp1ejBa38fz kwCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778337462; x=1778942262; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cOcGfIOtFOkiWqfncI0KZjtYci+VZ44xdjbjhNWu6Xc=; b=WSwdGYvyfeiQOKwrctRQlpctyE/wPaqJUqOeyTMqn9M5ZTuGSnmjnXoqvOJ4TwC6tn J0ifOcp/zBpDOvzPSmclBWX7YKhoS5K6AtakCJ0Eqb0K2J4RjliGUfslv4e088LaASgv vu2kmu3TLU9QdVnblCL/eU3eKPKN9k64D9qsuL5oDfD3t/garIHhvxobDyJYRKabu2gP ujAKO2WnLIVU3GZcL+07zTGgxzDQ13EvIxgpGMPCcEgXwF3nRu0VryBUKEKSqq+eAxEx p9V7GDK7dTX70hu8So7YXAKEfr5Y2+i7oPi09tgU2gMkvr49OPcd0GCE6qBskGecHvqM Kltg== X-Forwarded-Encrypted: i=1; AFNElJ/gZLGkcMOcfmIPjgqw3VUJkxVRvUwaU3KKdznEZJQxTeedOq1bknadd8SPfu+hfyxcWsUQZO/VrLhVjNk=@vger.kernel.org X-Gm-Message-State: AOJu0YyPe7Nht9VilzYLfBRRHCSzekMtLZxZUijkFvjOMrgkU6UwohiO /LeIDse98Dih60FOyhEQZJ8eoFadvNUf1CRiPHuaIgXKqpsYs7Vf85XK8+d2EkdloD8= X-Gm-Gg: Acq92OE5tLmcPV7jlnVtfmU/a1dVn4p+qrhFm16WSKKb2Kn4ItcfSzmBv+X97BdTM7a jtDFi5zi0UI0HB45k/sEPbgZxZJDhI7OXhocx74LaaRVA4/KFQ0xkxpaoD62dWk6BxEGfJigLPG c4vX5uN9+V1aF/97uinITQB/eak+0Wg+odaEy0HHIM3kSKs6RirC+dv3d1SKHDo575PGe42OnGy bKm0rTxcQU0sD9R86Vp/iS9ryugFm89D8yncszpG1yEySbOSWPN0ODpS8r7g/9n7VlMi9xu/EoK CEnlQA4V/lIcMPihZZQne0x3Lkj1T92lR4r6Y4aGx5//R2ryeB4OEzugPM1afpOiJRGfJePkshk uv2acfI5V+6r7PX9XKlrB7DQC4KNMcbMq2hive/hWGvkY9KJza976A60r3dyfh91ZicSBti0IFw xwsnflOppdEXoVPStgOQOkLal3zAD/gTuOeajiuGVCH/+VlOel1/3xExU= X-Received: by 2002:a05:600c:4a25:b0:48a:768b:eea9 with SMTP id 5b1f17b1804b1-48e51e09797mr153144355e9.4.1778337461682; Sat, 09 May 2026 07:37:41 -0700 (PDT) Received: from localhost (ppp-94-65-157-136.home.otenet.gr. [94.65.157.136]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e6db1413csm23237805e9.29.2026.05.09.07.37.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 May 2026 07:37:41 -0700 (PDT) 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 Content-Type: text/plain; charset=UTF-8 Date: Sat, 09 May 2026 10:37:39 -0400 Message-Id: Cc: "Emil Tsalapatis" , Subject: Re: [PATCH sched_ext/for-7.2] sched_ext: Fix ops_cid layout assert From: "Emil Tsalapatis" To: "Tejun Heo" , , "David Vernet" , "Andrea Righi" , "Changwoo Min" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260508235946.215232-1-tj@kernel.org> In-Reply-To: <20260508235946.215232-1-tj@kernel.org> On Fri May 8, 2026 at 7:59 PM EDT, Tejun Heo wrote: > ca1d48a86fab ("sched_ext: Use offsetofend on both sides of the ops_cid > layout assert") replaced sizeof() with offsetofend() to dodge 32-bit > PPC trailing padding, but the resulting check is tautological: with > CID_OFFSET_MATCH(priv, priv) already enforcing offsetof(priv) equality > and @priv being the same type in both structs, the two offsetofends > are equal by construction. The original protection - catching a stray > field added past @priv in sched_ext_ops_cid - is gone. > > Anchor on a zero-size __end[] marker appended after @priv. Its offset > sits flush after @priv regardless of trailing struct padding; if a > field is inserted past @priv, __end shifts and the assert fires. > > Closes: https://lore.kernel.org/all/20260508215211.0C03AC2BCB0@smtp.kerne= l.org/ > Signed-off-by: Tejun Heo Reviewed-by: Emil Tsalapatis > --- > kernel/sched/ext.c | 6 ++---- > kernel/sched/ext_internal.h | 3 +++ > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index f86ee15be7cb..b685f45b4fd0 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -10380,11 +10380,9 @@ static int __init scx_init(void) > /* > * cid-form must end exactly at @priv - validate_ops() skips > * cpu_acquire/cpu_release for cid-form because reading those fields > - * past the BPF allocation would be UB. offsetofend() on both sides > - * instead of sizeof() on sched_ext_ops_cid to sidestep trailing > - * struct padding (e.g. 32-bit PPC tail-pads ops_cid past @priv). > + * past the BPF allocation would be UB. > */ > - BUILD_BUG_ON(offsetofend(struct sched_ext_ops_cid, priv) !=3D > + BUILD_BUG_ON(offsetof(struct sched_ext_ops_cid, __end) !=3D > offsetofend(struct sched_ext_ops, priv)); > #undef CID_OFFSET_MATCH > =20 > diff --git a/kernel/sched/ext_internal.h b/kernel/sched/ext_internal.h > index 0ed79bd891c7..cd33984cffcf 100644 > --- a/kernel/sched/ext_internal.h > +++ b/kernel/sched/ext_internal.h > @@ -938,6 +938,9 @@ struct sched_ext_ops_cid { > =20 > /* internal use only, must be NULL */ > void __rcu *priv; > + > + /* layout end anchor for the BUILD_BUG_ON in scx_init(); keep last */ > + char __end[0]; > }; > =20 > enum scx_opi {