Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp881043ybg; Tue, 28 Jul 2020 23:29:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxv/gx2pcmSsx+C3fD40W07Stw0+I5+n3qwCJz4G6pqw7LgX1Z46gWoBXoSap4AvcyKTE1 X-Received: by 2002:a05:6402:899:: with SMTP id e25mr17212569edy.311.1596004140396; Tue, 28 Jul 2020 23:29:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596004140; cv=none; d=google.com; s=arc-20160816; b=OhRJmWWYHOl40CCMyXavd+8HWLHzC6h8o983uTuzNr6EHaRNTGH4puf/3/GU+oRSTJ tzhbeIEuoaajYIR8ccx77etCYVPnl0vazXs1f0US0Slj4P4rYCCvxVL427ZhTRm1faMw VOf+GSUUYLWsyR51iAIzwYCisYIqDYa0dbdljqYC/AfyvpVlPh5q53ml/OItZnRQm32S aWsTgWs36DQgBZePb+R8rWzWiIEVNvdkihvyEeWmJNTljZ22DdHHe0YFCLJRNlP1JnKj W2rFFIRqfTonC19HsRS9YipXwgXsn3RLOfRPC4qKV+LbSJxf2Jm88/Z4xbAp2OKRe+fP lPKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UBprACODBjOLjJevzfOKPNyb2O0cetF4oGdIgYedFkE=; b=Ka9YX30UpdOFVkOjKwR32eycKB1lUje58A7AwoU0KotuDh3kdlzWT67+Np3qHxjg84 R0+iX/kqfJbVt4bj3FV5ijgfyXPJRjBlo9QYr9HZJnegQL8qLYrY8MqAjrY1+kFJn/BX GeIIjw8abWA+ScZguCzVq956tJnFkbD5Jc9uKJYje2Ruh31vgCjZXbqhldSSd3ZrKstk 1GMetJtyljiJxrpzw3Q5oOJsy4PR8USTSMxA1yW2dFG+KL+YSXvymcSv3FuBT/PKLnk3 MJHuqm7SL3BOlwi1MhETQiT7BgeReeHLxu/7lXWyi7hZoYrWt0yKmUMOD0+voSmrQWp6 OV1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=ikcwhykr; 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 v13si606954ejc.348.2020.07.28.23.28.37; Tue, 28 Jul 2020 23:29:00 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=ikcwhykr; 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 S1727067AbgG2G12 (ORCPT + 99 others); Wed, 29 Jul 2020 02:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbgG2G1Y (ORCPT ); Wed, 29 Jul 2020 02:27:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9108FC061794 for ; Tue, 28 Jul 2020 23:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UBprACODBjOLjJevzfOKPNyb2O0cetF4oGdIgYedFkE=; b=ikcwhykrj5CFJc/dPxRMAuOkuS MO8QDNmIQaKYhfD6hBHCfFTeOo54r4/6KbtMZ+wU8agBtSDsfyUevMJ2fO98sX2bxq6KUMoLousRg /CJuBXhl4ovjFPnXroVa5z1b7I36pKg3A24IxFJvKAxLpNLUbqQw0mUqjP1saKosP9cqN6CvGasc+ /haD8C2aOMlFHk4qvgqCTXWO/QmEzsx+Q96q0ovxZuDQYXpyFBNmtHigM1FdN4zjnGu216po1JrIz hAGpQNCCfghPO3Scnr9u85Ym3H830AyE3nVRhCK2A5sgpXQJydolsr/ru8R9iv8nHOjbe5AAAlvG2 W/z9wQhA==; Received: from 089144218008.atnat0027.highway.a1.net ([89.144.218.8] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0fYg-00041d-A8; Wed, 29 Jul 2020 06:27:22 +0000 From: Christoph Hellwig To: Jessica Yu Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 6/7] modules: return licensing information from find_symbol Date: Wed, 29 Jul 2020 08:27:10 +0200 Message-Id: <20200729062711.13016-7-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200729062711.13016-1-hch@lst.de> References: <20200729062711.13016-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Report the GPLONLY status through a new argument. Signed-off-by: Christoph Hellwig --- include/linux/module.h | 2 +- kernel/module.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index b79219eed83c56..c9bc3412ae4465 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -582,7 +582,7 @@ struct module *find_module(const char *name); struct symsearch { const struct kernel_symbol *start, *stop; const s32 *crcs; - enum { + enum mod_licence { NOT_GPL_ONLY, GPL_ONLY, WILL_BE_GPL_ONLY, diff --git a/kernel/module.c b/kernel/module.c index 54e853c7212f72..a907bc57d343f9 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -495,6 +495,7 @@ struct find_symbol_arg { struct module *owner; const s32 *crc; const struct kernel_symbol *sym; + enum mod_licence licence; }; static bool check_exported_symbol(const struct symsearch *syms, @@ -528,6 +529,7 @@ static bool check_exported_symbol(const struct symsearch *syms, fsa->owner = owner; fsa->crc = symversion(syms->crcs, symnum); fsa->sym = &syms->start[symnum]; + fsa->licence = syms->licence; return true; } @@ -587,6 +589,7 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms, static const struct kernel_symbol *find_symbol(const char *name, struct module **owner, const s32 **crc, + enum mod_licence *licence, bool gplok, bool warn) { @@ -601,6 +604,8 @@ static const struct kernel_symbol *find_symbol(const char *name, *owner = fsa.owner; if (crc) *crc = fsa.crc; + if (licence) + *licence = fsa.licence; return fsa.sym; } @@ -1074,7 +1079,7 @@ void __symbol_put(const char *symbol) struct module *owner; preempt_disable(); - if (!find_symbol(symbol, &owner, NULL, true, false)) + if (!find_symbol(symbol, &owner, NULL, NULL, true, false)) BUG(); module_put(owner); preempt_enable(); @@ -1352,7 +1357,7 @@ static inline int check_modstruct_version(const struct load_info *info, * locking is necessary -- use preempt_disable() to placate lockdep. */ preempt_disable(); - if (!find_symbol("module_layout", NULL, &crc, true, false)) { + if (!find_symbol("module_layout", NULL, &crc, NULL, true, false)) { preempt_enable(); BUG(); } @@ -1436,6 +1441,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, struct module *owner; const struct kernel_symbol *sym; const s32 *crc; + enum mod_licence licence; int err; /* @@ -1445,7 +1451,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, */ sched_annotate_sleep(); mutex_lock(&module_mutex); - sym = find_symbol(name, &owner, &crc, + sym = find_symbol(name, &owner, &crc, &licence, !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); if (!sym) goto unlock; @@ -2216,7 +2222,7 @@ void *__symbol_get(const char *symbol) const struct kernel_symbol *sym; preempt_disable(); - sym = find_symbol(symbol, &owner, NULL, true, true); + sym = find_symbol(symbol, &owner, NULL, NULL, true, true); if (sym && strong_try_module_get(owner)) sym = NULL; preempt_enable(); @@ -2252,7 +2258,7 @@ static int verify_exported_symbols(struct module *mod) for (i = 0; i < ARRAY_SIZE(arr); i++) { for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) { if (find_symbol(kernel_symbol_name(s), &owner, NULL, - true, false)) { + NULL, true, false)) { pr_err("%s: exports duplicate symbol %s" " (owned by %s)\n", mod->name, kernel_symbol_name(s), -- 2.27.0