Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp273057rdd; Tue, 9 Jan 2024 03:57:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjesIsqt/DLbSXyFA/pFLAuhdBbWr3BVhiTkHYPBPjYKQutuUdaxGdFcJySpdbIj7m+jH3 X-Received: by 2002:a05:6a00:1c86:b0:6d9:ad3d:7d8 with SMTP id y6-20020a056a001c8600b006d9ad3d07d8mr773642pfw.19.1704801453442; Tue, 09 Jan 2024 03:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704801453; cv=none; d=google.com; s=arc-20160816; b=JLBoodm/J122+RdHka89NigluXUdpo2/ntEvfvylZaRUlteb5Mz2JSsn4teY+HRSpM eqD9XQtN5RNY3cFQXKf9FotvR6HEyuNxz5WwFLYDf2OjK9bsk+GVtX69OjGc/c9ct/yF gAJCZcPFlyAwCvJoWX+jFEd4/c8pkfN3soit9LoVjXggz7fsFZInpNKmvbBrrsapKE75 Pvjnbc7OIuBRdRJlDR/hAhuiF758iYiVRsgk6Eczx9jS8v5z9winycJ1AC3Xqp5x17fb pjR0pa2Zt2cBAmBdQ5kayRc8AQegM96pHPj+xWpt4hwCgfJmQ3v3K0UYQTKThHWB+4V3 68DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=ZGy/wfG3TQf/vRE/4F986f8vqNPMiqYWXQi5KrKjYik=; fh=kXyUKGTE+Ga8TQRwJibFl4jDnUC694Py1qVUEOFttt4=; b=lMkkNfqgV51Vhe60ePMqpRBhUJd7yDe6GD4m/aeSO5UX6fE6LqeXq80E6cd39w0O8/ BmMgznBvHFauuFQDmULafUm/zwzU72/5m87t+1TpBEb3SCqgF72fsVh1VoODlBS8fASC qJI//Kg6xoHbR8jtmIjWyarKICl6Z8VKU7iaox1+SKSgNM5PwWaYVgNtxNWQkf0Emfmi ah3nb2aYFmDvAy87ohc2zf2A1tDYV8QYDw6wYtHgHeQXLeomfpoCGMTxI+ju5C1F/YPY EKUxrgbWzUosE31R5oy9b4klJ4T/DWfcC6NK31LMv9bjPlE0Ea7dRz0S0oFiUuP0dBWE JO7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Vt8eCdKq; spf=pass (google.com: domain of linux-kernel+bounces-20815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p22-20020a639516000000b005cdfde5e3f3si1365758pgd.250.2024.01.09.03.57.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 03:57:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Vt8eCdKq; spf=pass (google.com: domain of linux-kernel+bounces-20815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 19166288AED for ; Tue, 9 Jan 2024 11:57:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C780A374F3; Tue, 9 Jan 2024 11:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="Vt8eCdKq" Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 1AB2F374CA for ; Tue, 9 Jan 2024 11:57:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 74FB73F582 for ; Tue, 9 Jan 2024 11:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704801435; bh=ZGy/wfG3TQf/vRE/4F986f8vqNPMiqYWXQi5KrKjYik=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Vt8eCdKq3qFentUmDqmXlpkHokTgrtJCpbYzOQ1yXdLW5SzjSwBIyHz4TRGGDpZ5f r62lLF0dmnvyCJb3yGMoZCkgfY4fiU8Z3+zrIWv7FqmPCd7whZ4dzBlBc3gemeD1Za bK42b3chb/U3SEWIwwFxnbl7fJByyRv+XcRgRddJrpBBKp7wq1QnjjA6Mr+CThwJGS IlLqalYf7AxcFiVe67+bTi7iJHL19Jw4Z+1HNw6YKYQTrBzYv/zJYdpNEEmr/w1vQC MN3W2uJkKcwdGq6gU1zob/dM6N39ibN16C0W47by7kZto6KeHcHfK8709tGxrkZz0i 6LiCSg8w7PGCA== Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40d2fa6b23eso23846865e9.2 for ; Tue, 09 Jan 2024 03:57:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704801435; x=1705406235; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZGy/wfG3TQf/vRE/4F986f8vqNPMiqYWXQi5KrKjYik=; b=lNcW9uztMxnus/nCb6frR7k2n4v9eD1xuERkEv2BBT99DbAUtwaVkVeg+HkkJW0Nph WDV1jri7Rvp/9tHlcpZNlXIW2lGOS8pEKJ/ArIzaLkHyDEwFvaoXMQrOGOFWHq9nspYN 1iFi3cFectFGzYAZxaF4DOFTuVzDLFh1ehmRZNCX3+avkgOlvilzZv3xgDcrIO67OAih 5gvjD6zE1Lq4p+X6w2MtgVp1zCndyTKwEXynVpk0t/BYqYcjISt3LZiKT04n4+Xol4Y8 AWLq2y8ba+g4+rWqYYpPzOZxv80XT8xzWAYqlOh1cks8Ek94e7xgTwaGYLuFgOzfPQ9u mKUw== X-Gm-Message-State: AOJu0Yyd7zGrATLwE28Tm0loNgj+CfFcT4GnAZFRZIPKIqnLZ+joK9WY /haGzEBFB5NuPWBuOEDnHoaI69KAgPbRX1zihV/canbpe/4VY01WTAmAG+i/nUw84VcqccylzEX t4qmglzD2nDhJQFNllIG9objaiqLO0mjB5iEWLYryTouYReqh83cDCwENpVFAA15Qyy9pcIBOLP f7vA== X-Received: by 2002:a05:600c:3d13:b0:40e:5121:d89c with SMTP id bh19-20020a05600c3d1300b0040e5121d89cmr227627wmb.58.1704801434967; Tue, 09 Jan 2024 03:57:14 -0800 (PST) X-Received: by 2002:a05:600c:3d13:b0:40e:5121:d89c with SMTP id bh19-20020a05600c3d1300b0040e5121d89cmr227617wmb.58.1704801434644; Tue, 09 Jan 2024 03:57:14 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Dimitri John Ledkov Date: Tue, 9 Jan 2024 11:56:37 +0000 Message-ID: Subject: Re: [BUG] SHA-3 causes kmod 28 to segfault To: "Russell King (Oracle)" Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Tue, 9 Jan 2024 at 11:15, Russell King (Oracle) wrote: > > On Mon, Jan 08, 2024 at 10:09:49PM +0000, Russell King (Oracle) wrote: > > On Mon, Jan 08, 2024 at 06:46:10PM +0000, Dimitri John Ledkov wrote: > > > On Mon, 8 Jan 2024 at 18:30, Russell King (Oracle) > > > wrote: > > > > > > > > On Mon, Jan 08, 2024 at 06:14:17PM +0000, Dimitri John Ledkov wrote: > > > > > Hi, > > > > > > > > > > On Mon, 8 Jan 2024 at 16:38, Russell King (Oracle) > > > > > wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > When building 6.7 under Debian Oldstable with kmod 28, the installation > > > > > > of modules fails during depmod with a SEGV. > > > > > > > > > > > > > > > > What is your kernel configuration, and I hope you make config choices > > > > > compatible with your target host OS. > > > > > > > > "target host OS" - that's a total misnomer. "host" is generally what > > > > you're building under. "target" is generally what you're building _for_. > > > > So I don't fully understand your comment. Maybe you meant "target _and_ > > > > host" ? > > > > > > the kernel configuration you use, should target the operating system > > > you are planning to use the given kernel on. > > > > Thank you for stating the damn obvious. I've been developing Linux > > kernels for 30 years, I think I know this. > > > > > using bleeding edge kernel features, with an obsolete userspace often > > > can have compatibility issues. > > > > You're still not being clear. I wonder whether you understand the > > terms "target" and "host". > > > > > > > > Running under gdb: > > > > > > > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > > > > __strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-vec.S:133 > > > > > > > > > > > > I have no further information as I can't remember how to get the debug > > > > > > info for packages under Debian - and even if I could, it's probably a > > > > > > bug in the kmod package that Debian will have absolutely no interest in > > > > > > fixing (based on previous experience reporting bugs to Debian.) > > > > > > > > > > For latest kernel and latest kernel features support in kmod, latest > > > > > kmod is required. I.e. patched with > > > > > https://github.com/kmod-project/kmod/commit/510c8b7f7455c6613dd1706e5e41ec7b09cf6703 > > > > > > > > Would be nice if there was some documentation. Also, as kconfig provides > > > > a mechanism to detect e.g. the version of tooling used to build the > > > > kernel, it would've been nice to detect whether depmod was sufficiently > > > > recent to support SHA3 and make the module signing SHA3 options depend > > > > on that. > > > > > > > > Leaving this to a SEGV to indicate that something is wrong isn't user > > > > friendly. > > > > > > > > > > There is no ability to detect runtime kmod at build time, given the > > > two are usually often not the same. > > > > Again, you CLEARLY don't understand the problem. I am *NOT* reporting > > a problem on the target. I am reporting a problem on the *build* > > *host*. > > > > > Can you please provide your config? > > > Can you please explain how you chose it? > > > > No, because it's totally irrelevant to the problem I'm reporting. > > > > What I'm reporting to you is that _IF_ you build a kernel with the > > SHA3 modsigning options on a HOST that has kmod 28, then depmod > > SEGVs when _INSTALLING_ the modules to a directory on the _HOST_. > > > > This has *nothing* to do with the capabilities of the _TARGET_. > > Whether the configuration matches the capabilities of the _TARGET_ > > is *totally* irrelevant at _this_ stage. In fact, with the _HOST_ > > depmod segfaulting, one can't complete the installation process > > to even _think_ about transferring it to the _TARGET_. > > Here's a patch that checks the version of depmod on the _build_ > _host_, preventing the use of the SHA3 module signing if it isn't > recent enough, which causes > > make modules_install INSTALL_MOD_PATH=/foo/bar/bzz > > run on the _build_ _host_ to fail with a segfault. > > diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig > index 0ea1b2970a23..d2ba454026a9 100644 > --- a/kernel/module/Kconfig > +++ b/kernel/module/Kconfig > @@ -223,6 +223,11 @@ config MODULE_SIG_ALL > Sign all modules during make modules_install. Without this option, > modules must be signed manually, using the scripts/sign-file tool. > > +config DEPMOD_VERSION > + int > + default $(depmod-version) > + default 0 > + > comment "Do not forget to sign required modules with scripts/sign-file" > depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL > > @@ -250,14 +255,17 @@ config MODULE_SIG_SHA512 > > config MODULE_SIG_SHA3_256 > bool "Sign modules with SHA3-256" > + depends on DEPMOD_VERSION > 28 > select CRYPTO_SHA3 > Did you test that things are successful wtih kmod 29, 30, 31? The code to correctly support sha3 in kmod was committed after 31 was tagged, and there is no newer tag yet hence the revision that has the correct code is v31-6-g510c8b7f74. If such check is desired, kmod 32 should be tagged and check should check for 32. > config MODULE_SIG_SHA3_384 > bool "Sign modules with SHA3-384" > + depends on DEPMOD_VERSION > 28 > select CRYPTO_SHA3 > > config MODULE_SIG_SHA3_512 > bool "Sign modules with SHA3-512" > + depends on DEPMOD_VERSION > 28 > select CRYPTO_SHA3 > > endchoice > diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include > index 5a84b6443875..052f581c86da 100644 > --- a/scripts/Kconfig.include > +++ b/scripts/Kconfig.include > @@ -63,3 +63,6 @@ ld-version := $(shell,set -- $(ld-info) && echo $2) > cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1)) > m32-flag := $(cc-option-bit,-m32) > m64-flag := $(cc-option-bit,-m64) > + > +# depmod version > +depmod-version := $(shell,$(srctree)/scripts/depmod-version.sh) > diff --git a/scripts/depmod-version.sh b/scripts/depmod-version.sh > new file mode 100755 > index 000000000000..32a8a6f6b737 > --- /dev/null > +++ b/scripts/depmod-version.sh > @@ -0,0 +1,11 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > + > +set -e > + > +: ${DEPMOD:=depmod} > + > +# legacy behavior: "depmod" in /sbin, no /sbin in PATH > +PATH="$PATH:/sbin" > + > +LC_ALL=C "$DEPMOD" --version | sed -n '1s/kmod version //p' > If possible please use min-tool-version.sh to set the lower bound of kmod that is supported by the build. Assuming module signing is generally desired to be supported, the minimum required kmod should be set to 26. Otherwise at least modinfo doesn't work. -- Dimitri Sent from Ubuntu Pro https://ubuntu.com/pro