Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp45162pxj; Tue, 15 Jun 2021 19:38:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznX6FzbpHE7d8yzIPqVtcBNLR72GWVgaVyBdjk8Jb9n5sjf73ejh8AfarOGQYk0OtCyN1x X-Received: by 2002:aa7:dc51:: with SMTP id g17mr1340701edu.43.1623811129333; Tue, 15 Jun 2021 19:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623811129; cv=none; d=google.com; s=arc-20160816; b=E8XEwvyBFUOLi4HzpHKfOMMeqQKTDWzO4ROyZ408G/vEdYCEpJocdXkiAHC6fL+okH AjkH83bMqM+JMZt52aJCk+mnwQOCWKkDDHylr14uX3dY5I1vmjxIkiaUhdabvQxZ8M4Q O155mAruRS9JIqnf8cd+zTmqYXpcQuOxhVMlsG1yoDx5LbiQ64PP5vP2AvKFwICETFPs HqCnvpERXe+1FLbz9JfTKEJD6PcCFWSVfCZF0RBXBT3QGVbU/HJvojIKUPe5vZ1W3cCi YiSGty7ck5LvBuywWOm5w3mWT4+MeGMxUOEts0N3vVTcb2u6eucjuWUgZdIQbUOfFTs1 NL7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=CSNvdGlh5qgtOslXrN6YlqZlPpnQg5LOB6FdjVeyRBo=; b=F1817DP5h5leRCwoCEPe/qYbQZycTNEJ2OP7rcYOipOVa4XWavWpwA69C4o8geoI9X N33GOuk9fX9YJYi3vkbffBaIwt7Qjn+W1HDtfEkJ82szJkDpu79coigikBkUdEydd8Ub 8fhHe49T8/uGLbufydtZPAqcSuVRanJ3fGOVvdOicxtA0r8rfXl5LRe58/Zbz5Q4zpBj 0B2cuP1kQCVXHbfkL4Nw2XlYf4qYHRxxs1X5OPt3KEhxny27yuqZVjunmnpSfM7p+Zyd oNsr107sfONRI3oHEq5uO87P4CMOyAfPApXKxtPnfXY5yBi/Aup7qnIBF0l7PHSW07oK j3lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=NZzhBvT3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 9si707783ejd.281.2021.06.15.19.38.05; Tue, 15 Jun 2021 19:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=NZzhBvT3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231494AbhFPCjV (ORCPT + 99 others); Tue, 15 Jun 2021 22:39:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbhFPCjU (ORCPT ); Tue, 15 Jun 2021 22:39:20 -0400 Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5950AC061574 for ; Tue, 15 Jun 2021 19:37:15 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4G4TqD69pYz9sX2; Wed, 16 Jun 2021 12:37:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1623811033; bh=lA6UO9NxGGPOC1a5HOGjw4Q7bzdLNOudpAIg0k6A/lA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NZzhBvT3qJnsyG3TF2/OsF7bfFluITDaef/BYo/dZnyohI9jjLrbtyVUlgOobe1+4 hlsPxfzxJiPmmtb91sfrJ3sRmdjMPnV/OuDHNjNz8ToFUPV+Iq5c9xVMRy/s7d5dkR F/k/ytclvbCpwU8BsWwsXS2Z/URD+PWX2uPxj+41nWtNZB/1zQzxnx0tVwPx3JYZkG Br3kcyzI/PKmXudnq60Gband1tHmhmfVqJzMMcsRAzkpgJkVp4QyokJ/3ezmAHa1WY d8+vyH7leVzdEQEUGPny8kRx7FBmWkjY7N6O/UYP3/mSQlbQxyiohrBN9ZlRPg6n4t 259C4wLfTLpbA== From: Michael Ellerman To: Jessica Yu , Nicholas Piggin Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michal =?utf-8?Q?Such=C3=A1nek?= Subject: Re: [PATCH v4 1/2] module: add elf_check_module_arch for module specific elf arch checks In-Reply-To: References: <20210611093959.821525-1-npiggin@gmail.com> <20210611093959.821525-2-npiggin@gmail.com> <1623722110.amu32mwaqs.astroid@bobo.none> Date: Wed, 16 Jun 2021 12:37:12 +1000 Message-ID: <87v96esffr.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jessica Yu writes: > +++ Nicholas Piggin [15/06/21 12:05 +1000]: >>Excerpts from Jessica Yu's message of June 14, 2021 10:06 pm: >>> +++ Nicholas Piggin [11/06/21 19:39 +1000]: >>>>The elf_check_arch() function is used to test usermode binaries, but >>>>kernel modules may have more specific requirements. powerpc would like >>>>to test for ABI version compatibility. >>>> >>>>Add an arch-overridable function elf_check_module_arch() that defaults >>>>to elf_check_arch() and use it in elf_validity_check(). >>>> >>>>Signed-off-by: Michael Ellerman >>>>[np: split patch, added changelog] >>>>Signed-off-by: Nicholas Piggin >>>>--- >>>> include/linux/moduleloader.h | 5 +++++ >>>> kernel/module.c | 2 +- >>>> 2 files changed, 6 insertions(+), 1 deletion(-) >>>> >>>>diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h >>>>index 9e09d11ffe5b..fdc042a84562 100644 >>>>--- a/include/linux/moduleloader.h >>>>+++ b/include/linux/moduleloader.h >>>>@@ -13,6 +13,11 @@ >>>> * must be implemented by each architecture. >>>> */ >>>> >>>>+// Allow arch to optionally do additional checking of module ELF header >>>>+#ifndef elf_check_module_arch >>>>+#define elf_check_module_arch elf_check_arch >>>>+#endif >>> >>> Hi Nicholas, >>> >>> Why not make elf_check_module_arch() consistent with the other >>> arch-specific functions? Please see module_frob_arch_sections(), >>> module_{init,exit}_section(), etc in moduleloader.h. That is, they are >>> all __weak functions that are overridable by arches. We can maybe make >>> elf_check_module_arch() a weak symbol, available for arches to >>> override if they want to perform additional elf checks. Then we don't >>> have to have this one-off #define. >>Like this? I like it. Good idea. > > Yeah! Also, maybe we can alternatively make elf_check_module_arch() a > separate check entirely so that the powerpc implementation doesn't > have to include that extra elf_check_arch() call. Something like this maybe? My thinking for making elf_check_module_arch() the only hook was that conceivably you might not want/need to call elf_check_arch() from elf_check_module_arch(). So having a single module specific hook allows arch code to decide how to implement the check, which may or may not involve calling elf_check_arch(), but that becomes an arch implementation detail. It's also one arch hook instead of two (although elf_check_arch() already exists). But I don't feel that strongly either way, whatever you prefer. cheers