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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDE62C00528 for ; Mon, 31 Jul 2023 20:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ft1StSCrOCVO2tl9tBGLKpdqBb5CDqFd7OlvJXWV3rM=; b=AppVUnLjpIlg/X lRRT/LYhz+ZKi5VmKi318lX8rBLRPxBjG4H1adiTzcr9SfpywEHM0DDAAkHpB8Qbt4vswxpP4awkj dMhSC2djEQVPiaYzKpwNdORRt5vfjU0wcc7Jtrc+pA+LwdCnHa47h+kmeFM8h0yGcFkjoRoMwoKAB 3IEBAj5kKCTKUzBzTFbskTwS6Jv3tNOaW+D6v2bTw52/Kor0OtQ4RBIvnOQL/IItcuY8yi/dq+VBX REr4MO7CgKcewYlRylkyVfYMj0pq26cdyOEzYlDVlnzZozwdTesPS6zkdQXO46OCjf/fQsZ4U1CRo ZUsgAK3XEsl0Xy6sNIvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQZf0-00HJ4A-0O; Mon, 31 Jul 2023 20:38:34 +0000 Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qQZey-00HJ3x-0X; Mon, 31 Jul 2023 20:38:32 +0000 Date: Mon, 31 Jul 2023 13:38:32 -0700 From: Luis Chamberlain To: Christoph Hellwig Cc: Greg Kroah-Hartman , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Ulf Hansson , Yangbo Lu , Joshua Kinard , Daniel Vetter , linux-arm-kernel@lists.infradead.org, open list , linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-rtc@vger.kernel.org, linux-modules@vger.kernel.org Subject: Re: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules Message-ID: References: <20230731083806.453036-1-hch@lst.de> <20230731083806.453036-6-hch@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230731083806.453036-6-hch@lst.de> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 31, 2023 at 10:38:06AM +0200, Christoph Hellwig wrote: > --- > kernel/module/internal.h | 1 + > kernel/module/main.c | 17 ++++++++++++----- > 2 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/kernel/module/internal.h b/kernel/module/internal.h > index c8b7b4dcf7820d..add687c2abde8b 100644 > --- a/kernel/module/internal.h > +++ b/kernel/module/internal.h > @@ -93,6 +93,7 @@ struct find_symbol_arg { > /* Input */ > const char *name; > bool gplok; > + bool gplonly; We'd want to add here a reason or something like that to allow the caller to know why we failed if we want to provide feedback. > bool warn; > > /* Output */ > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 59b1d067e52890..85d3f00ca65758 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -281,6 +281,8 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms, > > if (!fsa->gplok && syms->license == GPL_ONLY) > return false; > + if (fsa->gplonly && syms->license != GPL_ONLY) And set it here to something other than perhaps a default of NOT_FOUND. > + return false; > > sym = bsearch(fsa->name, syms->start, syms->stop - syms->start, > sizeof(struct kernel_symbol), cmp_name); > @@ -776,8 +778,9 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, > @@ -1289,14 +1292,18 @@ static void free_module(struct module *mod) > void *__symbol_get(const char *symbol) > { > struct find_symbol_arg fsa = { > - .name = symbol, > - .gplok = true, > - .warn = true, > + .name = symbol, > + .gplok = true, > + .gplonly = true, > + .warn = true, > }; > > preempt_disable(); > if (!find_symbol(&fsa) || strong_try_module_get(fsa.owner)) { > preempt_enable(); > + if (fsa.gplonly) > + pr_warn("failing symbol_get of non-GPLONLY symbol %s.\n", Because here fsa.gplonly is always true here so the above warn will print even if a symbol is just not found. Luis _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel