From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B2EC7618A for ; Sun, 19 Mar 2023 21:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbjCSV1w (ORCPT ); Sun, 19 Mar 2023 17:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbjCSV1w (ORCPT ); Sun, 19 Mar 2023 17:27:52 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ACB21B2F4; Sun, 19 Mar 2023 14:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=TgcmLQQdyElaRgOFKPmxQnBZLdzQrkkBcxBFD4PRGHw=; b=bxpbjCtQm1SSlUhuFd6bmJaWap nJqLlxA+Igeo4aloU/snQFDDS9j9szPzmaX1hzCc/e+QMsLiXj7y3eOqpR24lRfOTxDp8IrBvx2Jy q4Y8qLW4R40q05IHiZoe4fJ6z378s73dN9JlSQt8QZogNm7Qlri8ssBXfAZNmXGDulI6Ez1eCBVUs X4CRskRlYQBGZnueynO2TVWktXG/b5FIZW6FfsnkN7TSTS7E51feFJh2s6XFej3LWOb4Pnu+x6Nt8 cpFKVulK8o7aymcFwkGi9IMf670+BJVE+tQmtz5gwbkzjAK7yM5ZPwBve3Zix4H/E7bnnatGnM0v7 kVkV6idg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pe0Z9-007Tr7-2d; Sun, 19 Mar 2023 21:27:47 +0000 From: Luis Chamberlain To: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, pmladek@suse.com, david@redhat.com, petr.pavlu@suse.com, prarit@redhat.com Cc: christophe.leroy@csgroup.eu, song@kernel.org, mcgrof@kernel.org Subject: [PATCH 05/12] module: move check_modinfo() early to early_mod_check() Date: Sun, 19 Mar 2023 14:27:39 -0700 Message-Id: <20230319212746.1783033-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230319212746.1783033-1-mcgrof@kernel.org> References: <20230319212746.1783033-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Precedence: bulk List-ID: This moves check_modinfo() to early_mod_check(). This doesn't make any functional changes either, as check_modinfo() was the first call on layout_and_allocate(), so we're just moving it back one routine and at the end. This let's us keep separate the checkers from the allocator. Signed-off-by: Luis Chamberlain --- kernel/module/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/module/main.c b/kernel/module/main.c index 933cef72ae13..95fd705328ac 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2273,10 +2273,6 @@ static struct module *layout_and_allocate(struct load_info *info, int flags) unsigned int ndx; int err; - err = check_modinfo(info->mod, info, flags); - if (err) - return ERR_PTR(err); - /* Allow arches to frob section contents and sizes. */ err = module_frob_arch_sections(info->hdr, info->sechdrs, info->secstrings, info->mod); @@ -2688,7 +2684,11 @@ static int early_mod_check(struct load_info *info, int flags) /* Check module struct version now, before we try to use module. */ if (!check_modstruct_version(info, info->mod)) - return ENOEXEC; + return -ENOEXEC; + + err = check_modinfo(info->mod, info, flags); + if (err) + return err; return 0; } -- 2.39.1