From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 6ACF813C9C4 for ; Wed, 10 Dec 2025 01:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765328429; cv=none; b=DCKydL3FYa4SrqqroheOYft0Vb4fLkcmg4DNsBpC7xGFBoQqeXB1/C+q7ZJxxMVteTyi0N41dLLXLRGKCO1sk/xyqQ+JC/OKUzbTxEVqJUxR2gsja/50f6dDW4Tw+NizQVyAreA7Hb5zhF6b9u9XQnfmv88PhP+Cdoa9A6oD/zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765328429; c=relaxed/simple; bh=3ajHi0yHPov0SKg4O4bcCBy0K1fDiVaVSenJjs4a1bQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mC5FkEdmgcWKyM+pikU0NNGHqqt6ser+Lt2NLuLTuGwBOu0dgp6DXwJ+AqcK0Byg5wh8srAX4VeYptWh9o+ExVbAJphLaFe6sZrlEwyxKFV4ht7EuFBcfwbgjOfp4cwT4K/otSb20ySVl6cuqepe9TM28E0+XXQJHqDrxkyCvBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kgKyzH2s; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kgKyzH2s" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-297e13bf404so99185ad.0 for ; Tue, 09 Dec 2025 17:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765328428; x=1765933228; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=691lAnJLGf8S4+TJC63j4SAsoo3YOyh4dWuPiM7IB1Y=; b=kgKyzH2swSxVXBMaeFB7gJNTGVVgRjudOLs5hyYnbuQNDZYS3DQU5oDVuypi7nzWg9 UoL+4TIYLG/v7OPda7a+tAnkkmJ99+fzXqQD+m3yO1/Ha/p3V85KH7NdXFrAOiyo0m3i u2tNWXzPMA9rX/jwPHk9jlYKQap0e0xHDMIAE/jkQzpulvbUSO4e/mwHjOtPwzVBIcue vedJDref403j9C210J/b2na+jJ5GArAgTkXCoCx1P+NPuRnGGOjE/YFnvoh5FldRbm9R FNEMj5Obb9gRP0A692VrbA8jYKtIC3y5ccADwF5EWJa8Zzy/eIoj2kXZU+PgZsDB7WqZ CBFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765328428; x=1765933228; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=691lAnJLGf8S4+TJC63j4SAsoo3YOyh4dWuPiM7IB1Y=; b=sKUBSO5rMnV1NcjU5rypRyLTGx23ID7PvwynU04+sMF2ym872UIPA+oASZ0sqklsRd wojwpAAoHLC7ll4dp2eKm6Q+ZmbmVCXj2dESxSH3pWkeYTPAPXW2TFAkQpZ6Ax5MzoDn BDGCvYF51TeHq/ITt6OEz/qEFMZo/bReEIQ0tzt3uqsce9ZjUn0O+PpDEm7NDGy+lrqm 1XMaGB20OW4InpfUt3H60ASvGeisYjAqQvgSXL6XeNJ7VNzhUUvceh4z72h/qJFZcKlx qYUfhAHmZJhdkXj/2LWCSoGL6TT0xGQIOAD0o1TzthN2c+lPvog8tDnQ9XwxetoZE44X 5Zug== X-Forwarded-Encrypted: i=1; AJvYcCX51wzNYuc0CfJPMnYG7sA4lIM6KyWL3kSemQgWVPyzNhgnouXWCfc2ulGaH9OUzfR7NvvgHeADvweK/g+4@vger.kernel.org X-Gm-Message-State: AOJu0YzNZ+pIl0oXAfzV/0564F0Y8bz1rJ8wHz9/HBGFR0rrRCXYd7Q+ 60eErEahJmyZW01M9H1f/PQ4A8kjMPeY0FSDTSlfrgioHjdVdL/b7nNQxyUZzHS5xg== X-Gm-Gg: AY/fxX7LqT7myiICKljMUNPdozYpBJ/3jHBq08jbezrxTQpq2k3pD5LKML0jPKM/sOa quAVtPbrRE9mnX/ClHSYeEKjKyl7RGTXzjZWUlpwUBa/deuQE9qZDrrx9en3kOHWKbyVfggZsmL YZ8+VjZ4NjkHtvJn4g5pc65gG/B0rHXjjy681DQdMNjHcnmUFKBsA43dqWHivZReUBaAlrBimco FAReL7f32vdW3x1BGUuhIa9onRLlSHEpoLjeufz17pQi1CLS0xnsZBTay8zu5bQACZlT+yjpAle O7l4buWuslKcYOHrG5cMs9YubKfv/KOrtiqsrFWJU6fofxwm9xNZEBjFQUVJTQUJGv614fYH/lD vv23OOCWgorayxezr54ZxrHgfsDk+2kaDYac9dQ5cvHib7iMZZelZlzdAzcl6p02EY+hPuvrL/9 mgUqsC1RDE+0xqMFf2Pu+17W2XfF8GJkbxlWA/5JmqBmqhp7xJCLr7cuo= X-Google-Smtp-Source: AGHT+IHwazsr/LFDDUVLr6lpCN1u73yiv9zYWPNsYlgfC/SF2jnbI472ByJ0qhQLxPF8fI22SQq4QA== X-Received: by 2002:a17:902:d4c2:b0:295:1351:f63e with SMTP id d9443c01a7336-29ebf8ce459mr1596665ad.10.1765328427004; Tue, 09 Dec 2025 17:00:27 -0800 (PST) Received: from google.com (99.181.125.34.bc.googleusercontent.com. [34.125.181.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7e2a07213b6sm17205315b3a.26.2025.12.09.17.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 17:00:26 -0800 (PST) Date: Wed, 10 Dec 2025 01:00:20 +0000 From: Sami Tolvanen To: "Luck, Tony" Cc: Daniel Gomez , Eric Biggers , Kees Cook , Luis Chamberlain , Rusty Russell , Petr Pavlu , "linux-modules@vger.kernel.org" , Malcolm Priestley , Mauro Carvalho Chehab , Hans Verkuil , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , "linux-kernel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-hardening@vger.kernel.org" Subject: Re: [PATCH 3/3] module: Add compile-time check for embedded NUL characters Message-ID: <20251210010020.GA2522829@google.com> References: <20251008033844.work.801-kees@kernel.org> <20251008035938.838263-3-kees@kernel.org> <20251209001139.GA7982@quark> Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Dec 09, 2025 at 10:29:06AM -0800, Luck, Tony wrote: > On Tue, Dec 09, 2025 at 08:45:14AM -0800, Luck, Tony wrote: > > On Tue, Dec 09, 2025 at 04:20:06PM +0000, Luck, Tony wrote: > > > >> Likewise, I just got the following kernel test robot report sent to me, > > > >> where it's warning about MODULE_LICENSE("GPL"): > > > >> https://lore.kernel.org/all/202512090359.7BkUaiC9-lkp@intel.com/ > > > > > > > > Can you both confirm which version of sparse are you using? > > > > > > > > My understanding was that this patch fixed that problem: > > > > >https://lore.kernel.org/linux-sparse/CACePvbVG2KrGQq4cNKV=wbO5h=jp3M0RO1SdfX8kV4OukjPG8A@mail.gmail.com/T/#mf838b3e2e3245d88c30a801ea7473d5a5c0eb121 > > > > > > > The patch is already merged into the sparse tree, and I was not able to > > > > reproduce the issue. > > > > > > I pulled the latest sparse source and re-checked before reporting. Top commit I have is the one you mention: > > > > > > fbdde3127b83 ("builtin: implement __builtin_strlen() for constants") > > > > > > I'm building latest Linus tree from the current merge window (well latest as-of yesterday): > > > > > > c2f2b01b74be ("Merge tag 'i3c/for-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux") > > > > I added a debug trace to the new expand_strlen() function added to > > sparse. It is being called and doing the right thing. My trace says: > > > > len(GPL) = 3 > > Simple test case: > > $ cat -n s.c > 1 > 2 _Static_assert(sizeof("GPL") - 1 == 3, "sizeof"); > 3 > 4 _Static_assert(__builtin_strlen("GPL") == 3, "strlen"); > > $ sparse s.c > s.c:4:40: error: bad integer constant expression > s.c:4:40: error: static assertion failed: "strlen" > > So the "sizeof" bit is OK. But the __builtin_strlen() isn't. This looks like a bug in Sparse. The CEF_ICE flag isn't propagated to the comparison expression, which it presumably should be when both sides are integer constant expressions. I'm not really familiar enough with Sparse to know whether this is the correct place to handle this case, but this quick hack fixes the issue for me: diff --git a/expand.c b/expand.c index f14e7181..71221d35 100644 --- a/expand.c +++ b/expand.c @@ -535,6 +535,8 @@ static int expand_compare(struct expression *expr) expr->taint = 0; return 0; } + if (left->flags & CEF_ICE && right->flags & CEF_ICE) + expr->flags |= CEF_SET_ICE; if (simplify_cmp_binop(expr, left->ctype)) return 0; if (simplify_float_cmp(expr, left->ctype)) Sami