From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2466915C158; Tue, 24 Feb 2026 16:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771949829; cv=none; b=S6qMwrriie1roBXeAN6pfx93S3G3cfxaarWgWwbBzIGv8Be1YOkrY+dxcPJLFsTSUwu8XL/a8v2fQAb1y0LJX7F9l5DQdLqgZZo+rbXYPT3+zr4WT/Q7HREA7zwF5kkRd5kPTggDd5T6pJVmVVEQGQNezDZtmQCZ/s7JMWYbmeM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771949829; c=relaxed/simple; bh=SXv8kNok4zxMnc5pPBCN8E77XIiooRBkXlI+BOUS8Dc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p07QnTuF645xLHf2PmQ5IVhPmAv5mAsEqXWd5g48U2457vAqOASgk6w9PF7uzLT6JSp/YrKxt9Ab0KErPXgqUs0EtrQhLMg1/pNVHsefvIpVpMeLSpx3IB2eTx0ImjkMhiLZnrptPC5lF+jm5RfbtNoROh/7Fxd6WKmh6k6iS+k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dE5DsgJe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dE5DsgJe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D2CAC116D0; Tue, 24 Feb 2026 16:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771949828; bh=SXv8kNok4zxMnc5pPBCN8E77XIiooRBkXlI+BOUS8Dc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dE5DsgJe4eWwAhLUkc52afWpncNFQHm3ITfjxXTQs8pZ3HAdZoxX3E9+yw84PuWfc 8hv0jBSBocClUd7acb2nBgtY0uf3R+6IJ9CaSBzL6ITcI6T+FBM4oFlesEeJM8ib+K 5uZ/5NDfic7g+vqbPRCzSUckWiK+3QDVPDhtTPlOjE84675xU/g2iZz6oR/8YvKW4l 4AL1i725kN9lXS1UU2SngsrbrekRgSdTqNC7/UOua/J6J9V+z4azuGI6LX2qWBuTwE SZwRe4f0R4aadCnfUfk4peBnSm5w+WJWSP6gTO15tqNeDIuiLzQBAAPazq1vUyzKiJ dizgCboB6pIOA== Date: Tue, 24 Feb 2026 17:14:52 +0100 From: Nicolas Schier To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Nathan Chancellor , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , 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 , Daniel Gomez , Aaron Tomlin , "Christophe Leroy (CS GROUP)" , Nicolas Bouchinet , Xiu Jianfeng , Fabian =?iso-8859-1?Q?Gr=FCnbichler?= , Arnout Engelen , Mattia Rizzolo , kpcyrd , Christian Heusel , =?iso-8859-1?Q?C=E2ju?= 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: Mail-Followup-To: Nicolas Schier , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Nathan Chancellor , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , 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 , Daniel Gomez , Aaron Tomlin , "Christophe Leroy (CS GROUP)" , Nicolas Bouchinet , Xiu Jianfeng , Fabian =?iso-8859-1?Q?Gr=FCnbichler?= , Arnout Engelen , Mattia Rizzolo , kpcyrd , Christian Heusel , =?iso-8859-1?Q?C=E2ju?= 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 References: <20260113-module-hashes-v4-0-0b932db9b56b@weissschuh.net> <20260113-module-hashes-v4-15-0b932db9b56b@weissschuh.net> <0d70db8d-702b-46ec-a010-298fe6515aab@t-8ch.de> <06054e9a-2b7a-4063-98b8-7d6c539e543f@t-8ch.de> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <06054e9a-2b7a-4063-98b8-7d6c539e543f@t-8ch.de> On Mon, Feb 23, 2026 at 10:43:30PM +0100, Thomas Weißschuh wrote: > On 2026-02-23 19:41:52+0100, Nicolas Schier wrote: > > On Mon, Feb 23, 2026 at 08:53:29AM +0100, Thomas Weißschuh wrote: > > > On 2026-02-21 22:38:29+0100, Nicolas Schier wrote: > > > > On Tue, Jan 13, 2026 at 01:28:59PM +0100, Thomas Weißschuh wrote: [...] > > > > [...] > > > > > diff --git a/scripts/modules-merkle-tree.c b/scripts/modules-merkle-tree.c > > > > > new file mode 100644 > > > > > index 000000000000..a6ec0e21213b > > > > > --- /dev/null > > > > > +++ b/scripts/modules-merkle-tree.c > > > > > @@ -0,0 +1,467 @@ > > > > > +// SPDX-License-Identifier: GPL-2.0-or-later > > > > > +/* > > > > > + * Compute hashes for modules files and build a merkle tree. > > > > > + * > > > > > + * Copyright (C) 2025 Sebastian Andrzej Siewior > > > > > + * Copyright (C) 2025 Thomas Weißschuh > > > > > + * > > > > > + */ > > > > > +#define _GNU_SOURCE 1 > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > + > > > > > +#include > > > > > +#include > > > > > + > > > > > +#include > > > > > +#include > > > > > + > > > > > +#include "ssl-common.h" > > > > > + > > > > > +static int hash_size; > > > > > +static EVP_MD_CTX *ctx; > > > > > + > > > > > +struct module_signature { > > > > > + uint8_t algo; /* Public-key crypto algorithm [0] */ > > > > > + uint8_t hash; /* Digest algorithm [0] */ > > > > > + uint8_t id_type; /* Key identifier type [PKEY_ID_PKCS7] */ > > > > > + uint8_t signer_len; /* Length of signer's name [0] */ > > > > > + uint8_t key_id_len; /* Length of key identifier [0] */ > > > > > + uint8_t __pad[3]; > > > > > + uint32_t sig_len; /* Length of signature data */ > > > > > +}; > > > > > + > > > > > +#define PKEY_ID_MERKLE 3 > > > > > + > > > > > +static const char magic_number[] = "~Module signature appended~\n"; > > > > > > > > This here will be the forth definition of struct module_signature, > > > > increasing the risk of unwanted diversion. I second Petr's suggestion > > > > to reuse a _common_ definition instead. > > > > > > Ack. > > > > > > > (Here, even include/linux/module_signature.h could be included itself.) > > > > > > I'd like to avoid including internal headers from other components. > > > We could move it to an UAPI header. Various other subsystems use those > > > for not-really-UAPI but still ABI definitions. > > > > Yeah, ack. > > What exactly is the 'ack' for? > * Avoiding to include internal headers? > * Moving the definition to UAPI headers? ah, sorry. I think reduction of duplicated definitions is good; moving these definitions to UAPI headers sounds like a valid compromise to me. > (...) > > > > > Can you verify if I get the mechanics roughly correct? > > > > > > > > * Modules are merkle tree leaves. Modules are built and logically > > > > paired by the order from modules.order; a single left-over module is > > > > paired with itself. > > > > > > > > * Hashes of paired modules are hashed again (branch node hash); > > > > hashes of pairs of branch nodes' hashes are hashed again; > > > > repeat until we reach the single merkle tree root hash > > > > > > > > * The final merkle tree root hash (and the count of tree levels) is > > > > included in vmlinux > > > > > > The merkle tree code was written by Sebastian so he will have the best > > > knowledge about it. But this is also my understanding. > > > > I'd like to see some (rough) description in Documentation or in a commit > > message at least, otherwise future me will have to ask that again. > > Ack in general. I'd prefer to document it in a source code comment, > though. That feels like the best fit to me. Great, thanks. -- Nicolas