From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 1A46486341; Tue, 3 Feb 2026 12:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770123546; cv=none; b=uJGerNazbpAgp+r2V+JQDbZannVE+p6OWHlgbC44IfXmPVJT/UlMzBDn4r/aUtdbpuAt5eUYgSSzeF8bs99VlG+6YYSM/jkBCN+6K30kpXaDQ40Ys7qVCC873YpTX/GwjYqced9+E3NnXBqUxB4UAeTm5A1/G6pJRbWiK/pd1rU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770123546; c=relaxed/simple; bh=6LS/kA+onmwNe8A7Ynby1iar5OwBoPJ8XKnL5twRNZI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=esTfFlucMrd0IjtGBK7ug8gaN3Hw3+WrTzD4g2WeObrVnMsSLbB5qIr4UYIQ5EhZ9YSZRhIgENFW42t4DaaEfwHZwQJlsthujWt5OlwH/DQXVlz7WHiC4kOq6VECxN8gv9aSNRUxs6DsPQfwbh5orkSr5P/F/czfgQ8sg3LBQYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=SPdtsnUd; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="SPdtsnUd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1770123542; bh=6LS/kA+onmwNe8A7Ynby1iar5OwBoPJ8XKnL5twRNZI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SPdtsnUdSSGeLAvpGs66Yc7fwhPORRh9r7ctAvysXw3f//3u70CJ0gLtNJWuXJQC9 7MAnhu/JI34H1H6OHyalZvy4k5hxQXNQ1m/yLoFxdGWEao2ummshchk8d8wnhmjVOu e+aM1OBp2myV2ypeuFFm6aPHmRqcdO/MCSevgV0o= Date: Tue, 3 Feb 2026 13:59:02 +0100 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Petr Pavlu Cc: Nathan Chancellor , Arnd Bergmann , Luis Chamberlain , Sami Tolvanen , Daniel Gomez , Paul Moore , James Morris , "Serge E. Hallyn" , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Nicolas Schier , Daniel Gomez , Aaron Tomlin , "Christophe Leroy (CS GROUP)" , Nicolas Schier , Nicolas Bouchinet , Xiu Jianfeng , Fabian =?utf-8?Q?Gr=C3=BCnbichler?= , Arnout Engelen , Mattia Rizzolo , kpcyrd , Christian Heusel , =?utf-8?B?Q8OianU=?= Mihai-Drosi , Sebastian Andrzej Siewior , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-security-module@vger.kernel.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org Subject: Re: [PATCH v4 15/17] module: Introduce hash-based integrity checking Message-ID: <633ddd60-edbf-4072-932e-2d67d2173edd@t-8ch.de> References: <20260113-module-hashes-v4-0-0b932db9b56b@weissschuh.net> <20260113-module-hashes-v4-15-0b932db9b56b@weissschuh.net> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 2026-02-03 13:19:20+0100, Petr Pavlu wrote: > On 1/13/26 1:28 PM, Thomas Weißschuh wrote: > > The current signature-based module integrity checking has some drawbacks > > in combination with reproducible builds. Either the module signing key > > is generated at build time, which makes the build unreproducible, or a > > static signing key is used, which precludes rebuilds by third parties > > and makes the whole build and packaging process much more complicated. > > > > The goal is to reach bit-for-bit reproducibility. Excluding certain > > parts of the build output from the reproducibility analysis would be > > error-prone and force each downstream consumer to introduce new tooling. > > > > Introduce a new mechanism to ensure only well-known modules are loaded > > by embedding a merkle tree root of all modules built as part of the full > > kernel build into vmlinux. > > > > Non-builtin modules can be validated as before through signatures. > > > > Normally the .ko module files depend on a fully built vmlinux to be > > available for modpost validation and BTF generation. With > > CONFIG_MODULE_HASHES, vmlinux now depends on the modules > > to build a merkle tree. This introduces a dependency cycle which is > > impossible to satisfy. Work around this by building the modules during > > link-vmlinux.sh, after vmlinux is complete enough for modpost and BTF > > but before the final module hashes are > > > > The PKCS7 format which is used for regular module signatures can not > > represent Merkle proofs, so a new kind of module signature is > > introduced. As this signature type is only ever used for builtin > > modules, no compatibility issues can arise. > > Nit: The description uses the term "builtin modules" in a misleading > way. Typically, "builtin modules" refers to modules that are linked > directly into vmlinux. However, this text uses the term to refer to > loadable modules that are built together with the main kernel image, > which is something different. Agreed. I'll go through everything again, to consistently use "in-tree". (...) > > + > > + while (fgets(line, PATH_MAX, in)) { > > + struct file_entry *entry; > > + > > + fh_list = xreallocarray(fh_list, num_files + 1, sizeof(*fh_list)); > > It might be useful to not reallocate this array for each file, although > I don't immediately see that it contributes any significant time to the > runtime. The libc implementation should optimize this internally to not actually grow one elemet at a time. I'd like to keep this as-is. (...) Ack to everything else.