Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2693696pxj; Mon, 14 Jun 2021 05:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH3OrpY/rjhOIU+67yV8sPAD8CF8IGwwqDFI3uiR/YmsrvDq9CTK+1Ui5Xb5w2GVq9qPj+ X-Received: by 2002:aa7:d284:: with SMTP id w4mr16864601edq.347.1623672494894; Mon, 14 Jun 2021 05:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623672494; cv=none; d=google.com; s=arc-20160816; b=hEcmr+DjsrH6jbI+O9O9RhtaMVh2UlB6hSW2J8atYBwH31Hi+zv+nJxjw2OhLLI6fL Aq6SaKVm++2Rc3kVcmYjjPynozP/tiNFdhrsT9j2cFa0tQ51uaX35SvVEC5FTO9HDwPR NU/TEqWE1+QqQqK0qv3qIRiRMK+RMPikmy7gMhjtl5H/rS8CPV8QDJV7i1Ta7WMcgePN BQLHEiVi4uI4lNdaoX8I0IvVthAD6vA76E5EqnHMfTRXUEnDT/v+8UnB3sCETVuS0fPc us6iowTkB5+0n0iyQ3M5lY8chOXATkD9O1heLR8ww2n/y4aZilrfpk/2aLA7TqxYsEHX 3/Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/YouAYtqlbFRNna3g6Q+ZTUChYeKJWnRxIJIZpqpOSE=; b=VSjfTlsP9+A77tIce+earMmZl2/VdYclYkNM8HyBLUlv4py3Rdjd8c6ZghdHQSTscM l0bQZHwZsF/vQrhFJSWCrtjENqQEW7kglMlEgLWabyXEdCAUWBc84GXUh5sHXKRF1fw3 Km6cqWBpw35T33xWK5VyPJeHFZTyxi36NigLGMRCcLscCLsYO6Jtjfq+fI9urstKPETL i8rDELa6td+1DCFFZy5gMwKIR6MACTqhprFCBgyCntd8VoJU0R45RlqxjTvpEBy70V8Z 3xNTOXMoxl5dK+EGsgt3QdyVvv30r26Xjw8jOPkYi+TYImAjJpxs4+xnh6LNKpzO6PdX o73g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=frBzwAnJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si11670479edr.339.2021.06.14.05.07.51; Mon, 14 Jun 2021 05:08:14 -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=@kernel.org header.s=k20201202 header.b=frBzwAnJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233082AbhFNMI6 (ORCPT + 99 others); Mon, 14 Jun 2021 08:08:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:47182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232809AbhFNMI5 (ORCPT ); Mon, 14 Jun 2021 08:08:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5B4C611BD; Mon, 14 Jun 2021 12:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623672414; bh=Q2MM4OE/VICRfAoB7Alej8C61pteU8OP3UNtKNHFWJk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=frBzwAnJ6zHGxnI4UWPXOTUCB87KxBhhiG+0T0rvQX/xBVgtn1hKgCdKqyEoLzk5M XX9/xSGDPSWzrgKQ1ZSbNYG45isW7jotLC1aK9yfzSD6qQM4+BRLJ9FrY7Q6pHoJyW v/DDpdcNgTMpleWD8rd65cPLspYigpANxiYJpxSaLHlMAIACHgdAAdwm0GiclVavEn QLXSFBd08OZmcN3ZerK5Ht9PUzcWuyegBjl5qQtia09yJ8v+fzLDFlDePrm5OoTgSQ x6hw30cowSi7PcR3kUpWt6oruoY9yvNzgAt3/JLh7P5h4x+oeVxvtlAH1rKkLrJPBH cAnxe0btDbjYw== Date: Mon, 14 Jun 2021 14:06:50 +0200 From: Jessica Yu To: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michal =?iso-8859-1?Q?Such=E1nek?= , Michael Ellerman Subject: Re: [PATCH v4 1/2] module: add elf_check_module_arch for module specific elf arch checks Message-ID: References: <20210611093959.821525-1-npiggin@gmail.com> <20210611093959.821525-2-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210611093959.821525-2-npiggin@gmail.com> X-OS: Linux p200300cbcf109700df096d564fe976c3.dip0.t-ipconnect.de 5.12.9-1-default x86_64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ 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. Thanks, Jessica >+ > /* Adjust arch-specific sections. Return 0 on success. */ > int module_frob_arch_sections(Elf_Ehdr *hdr, > Elf_Shdr *sechdrs, >diff --git a/kernel/module.c b/kernel/module.c >index 7e78dfabca97..7c3f9b7478dc 100644 >--- a/kernel/module.c >+++ b/kernel/module.c >@@ -2946,7 +2946,7 @@ static int elf_validity_check(struct load_info *info) > > if (memcmp(info->hdr->e_ident, ELFMAG, SELFMAG) != 0 > || info->hdr->e_type != ET_REL >- || !elf_check_arch(info->hdr) >+ || !elf_check_module_arch(info->hdr) > || info->hdr->e_shentsize != sizeof(Elf_Shdr)) > return -ENOEXEC; > >-- >2.23.0 >