From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 82BD61C8FBA for ; Wed, 10 Dec 2025 01:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765328430; cv=none; b=t//itRswawEffpshnSst6DrF7mIFCdTys+Ed4QWylaUWbepckAN6RcPTYbZFm6GkbFxRnLUCqFzzI8kVxaL+U+oRRg0ynIU5/cCvIRtfhEkyI4mZpo7Vafd8hWlluEN63RAACm9bifhdF1tR+EPG2tz3P0gKMDTKp08qNMuPG3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765328430; c=relaxed/simple; bh=3ajHi0yHPov0SKg4O4bcCBy0K1fDiVaVSenJjs4a1bQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oNZqIlvnV6S/1di2KZ1RNUKmVdERDiqNysuXn82hUx1a1VybOGQqGNTH5kqvCQlTKY+F7h7hP8lDbbIZfcPNhaOvelbt64Uu7TYCimsj7MyPEANmnUlg39/qCax3zBfWJWz4siaaRKqJ3IIFV+3wkBEs7HIgmXSSi76w1hjXZSY= 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.178 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-f178.google.com with SMTP id d9443c01a7336-297e13bf404so99155ad.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=kqRbdQMwgHAR769dBguvaNr8zW/0+yRCicFjiGUE9bgdvFR8vePS45DWfcyfLVKTnh N+W8AwJxNk2vrC37uZQ9n4zIcf1uygzX0t+LnDUwNfpAORKeqDM0/exfp2FgGxwZnyfg oxcKA+M6lj4uvGYrXMPcvnMTpFmxWIcUBqSPe7xuSOsj3O7lB7V1JNgV9+AvicY9zEZD N1UlSkDqWEDeoGT7r/HmbNxWuJhB5xL7jvD2gJRTjq0Eiw2iptplGP/NacurS22Lu6CV 4fz3WVlyWHomNYor2XzxhVAGZVAuzTUiTs//P3KhwyQtua4y3TV3/kKRMEHVhnsN1gkk H4SQ== X-Forwarded-Encrypted: i=1; AJvYcCV0dqBKpPTzlwAQaHCjuAgb1jhXhJJWqyMJ7O9MwT1USEX1L+JOp20xp/miKP2fOGd+eJmQUQiU5mJdXhY=@vger.kernel.org X-Gm-Message-State: AOJu0YzNycEIr5FlE41FGrASH7GXu/EYSLzjOL23ZmukSKkDNok7RfrC B15qXjMJ/TNulRZottZfHK5Ugz+r7lLrHaAxrs4qoTtZQOjuLe/rzFFnKTqLpqNdPw== X-Gm-Gg: AY/fxX6+8UziJMeyhDtuZR7/Ow00icVJMG4UZLo6JM0x98Ig9xmxfc5U26BfAw8rB+y NY6kixcHYKN6S5qH+dDkaQpPEtWQeC9KXn8qu+vjI7aqpoitBcj+5yUg7/NLTUiuRKjO9w0uT4Y /ok9mDPo1DaMFuD/3oxIY3bW9oxMXseutT482xUHqQtMzDPForf0y/w/yOhL8OuPk4ZOqpdscgZ hP6v3D9XBoe+wpPZDzGA79b1bvk39HXFEc83PSo/a/EXVJ14pUwS/Bq6tfzpfZ2pkTH43mX2pwI GRxiYiV4BdtGR4Bl6BSbKP3cXzizXfGkeCMCCig/pzr4haPpaFqnMuNpSxTsvyzLYADO8RvyQyu Ev8V32EvTifFaC6UJEgUBNG7m4KDsxc6YZ9Ajmz4p0+1Z+dmslM920ba5/VlyY/FXeatxETvRfD BXmJzzoO5BNoi4npPhAm3Q1vjH34iWKCjj8CRZ1uGxU5xTPaSNtl9f/mg= 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-kernel@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