Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2193298pxb; Wed, 9 Feb 2022 12:54:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9I4VrA7o2on0+ylvUTFp/SpU/6f959KgA4jYeNc4Hh5cP3oVAwqHeBPNuf2E+7NcM4FmM X-Received: by 2002:a17:903:1cf:: with SMTP id e15mr4072004plh.132.1644440071721; Wed, 09 Feb 2022 12:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644440071; cv=none; d=google.com; s=arc-20160816; b=hwdrYvtHUtxM/a1d8YXdfKnwyB4u7cVGTGfzB4iBTOg1lPS3Y4nElwzqTJIhhTdESQ 1nV4PDcwQs059vWIjVnCSpITYeIPcGT3P4PHf7Hak3PwpS4lNMoWCMM4SiHSd7Mq0U2L gBmeMqONH0ZM3awJulPH8pqnfvwY9EnVEVlura+7waOU/qPy61bO3h3ilqFWnipSuIcQ dNwmwlkL7NRiVDaVN3rd3xw+6TuQzp7HHspWZVnyp8ERlEjC0rKP1yk9nzrnazH4DreZ 1Qpqz2RJGbWtLA1j/ta+PNd61ViY9YT05JPrlvKEzCnhfT/u7yn0/ok2n2VpyaNiEEjP 3iuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=UwgkA68ySmUW5/i3EYiZiiSs6H2oCiJiHMFUbdE9/kA=; b=jy3ZroTnitLll2pKXjCqDW9JdGC4NldqjQuH3VWcvsQbs5xuD8ITimMjpOShkmAuWS 6ZJ2aTgecNIxyqqGCMG+muE3wNC6TVxPJxKv2Z49AO4brlLMFXdnWQAxJvjbGgUeucPy 3Ra5wFxewVXGX+3LC08n5TYwSbxCawW3KETrpbOCL6QKpJh2zid9zTpSVKIMt3e+8iNG kMpnuTju6a9YnpMqcGB8trt/SR0UfwwREF41G3C+mUl8O6aPg+MkM1XHbR3c20f1TA+H U3g2DTs8/4r+zKQeGRwnoxXummUz3ZA/7XGdKHUvvYkmKhJlidimSfefeS/LObjiiTe/ lJig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CPF3aVkr; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m132si15531253pfd.160.2022.02.09.12.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 12:54:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CPF3aVkr; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 017A0C033255; Wed, 9 Feb 2022 12:50:40 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbiBIUsO (ORCPT + 99 others); Wed, 9 Feb 2022 15:48:14 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232243AbiBIUsN (ORCPT ); Wed, 9 Feb 2022 15:48:13 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7564C05CB96; Wed, 9 Feb 2022 12:48:15 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 270F7210FA; Wed, 9 Feb 2022 20:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644439694; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UwgkA68ySmUW5/i3EYiZiiSs6H2oCiJiHMFUbdE9/kA=; b=CPF3aVkrSzk+DBrQI/8fTVHvPc/tYv/I2kzg7FwUpfmyHrZOeX9O21As8lz0HrmzyKsL2y hxIOBDJPcrtAzqP9BQXbIgVxYAz5OqulJGI3tMWsNuHDAddzw4XYnZIVxj5Hp7uwEwZtM3 Ugc52ItjjFh1AVsL3SLir3b71BSC/lc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644439694; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UwgkA68ySmUW5/i3EYiZiiSs6H2oCiJiHMFUbdE9/kA=; b=9mPNk4VVo0bx3x9okO/NLh0S98fPaNi7/M5VzvTXgQhxCf/psAEuD5j5Bi/7SHm5a/79Qc rJ/GpXhB8PXyQLAA== Received: from kunlun.suse.cz (unknown [10.100.128.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B5E91A3B85; Wed, 9 Feb 2022 20:48:13 +0000 (UTC) Date: Wed, 9 Feb 2022 21:48:12 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: 20220209170358.3266629-1-atomlin@redhat.com Cc: mcgrof@kernel.org, cl@linux.com, pmladek@suse.com, mbenes@suse.cz, akpm@linux-foundation.org, jeyu@kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, live-patching@vger.kernel.org, atomlin@atomlin.com, ghalat@redhat.com, allen.lkml@gmail.com, void@manifault.com, joe@perches.com, christophe.leroy@csgroup.eu, oleksandr@natalenko.name Subject: Re: [PATCH v5 07/13] module: Move extra signature support out of core code Message-ID: <20220209204812.GD3113@kunlun.suse.cz> References: <20220209170814.3268487-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220209170814.3268487-1-atomlin@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Feb 09, 2022 at 05:08:08PM +0000, Aaron Tomlin wrote: > No functional change. There is functional change. > @@ -2565,70 +2542,6 @@ static inline void kmemleak_load_module(const struct module *mod, > } > #endif > > -#ifdef CONFIG_MODULE_SIG > -static int module_sig_check(struct load_info *info, int flags) > -{ > - int err = -ENODATA; > - const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; > - const char *reason; > - const void *mod = info->hdr; > - bool mangled_module = flags & (MODULE_INIT_IGNORE_MODVERSIONS | > - MODULE_INIT_IGNORE_VERMAGIC); > - /* > - * Do not allow mangled modules as a module with version information > - * removed is no longer the module that was signed. > - */ > - if (!mangled_module && ^^^^^^^^^^^^^ > - info->len > markerlen && > - memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) { > - /* We truncate the module to discard the signature */ > - info->len -= markerlen; > - err = mod_verify_sig(mod, info); > - if (!err) { > - info->sig_ok = true; > - return 0; > - } > - } > diff --git a/kernel/module/signing.c b/kernel/module/signing.c > index 8aeb6d2ee94b..ff41541e982a 100644 > --- a/kernel/module/signing.c > +++ b/kernel/module/signing.c > @@ -43,3 +62,59 @@ int mod_verify_sig(const void *mod, struct load_info *info) > VERIFYING_MODULE_SIGNATURE, > NULL, NULL); > } > + > +int module_sig_check(struct load_info *info, int flags) > +{ > + int err = -ENODATA; > + const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; > + const char *reason; > + const void *mod = info->hdr; > + > + /* > + * Require flags == 0, as a module with version information > + * removed is no longer the module that was signed > + */ > + if (flags == 0 && ^^^^^^ This reverts a97ac8cb24a3c3ad74794adb83717ef1605d1b47 Please re-apply. Thanks Michal > + info->len > markerlen && > + memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) { > + /* We truncate the module to discard the signature */ > + info->len -= markerlen; > + err = mod_verify_sig(mod, info); > + if (!err) { > + info->sig_ok = true; > + return 0; > + } > + }