From patchwork Tue Apr 26 04:21:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lecopzer Chen X-Patchwork-Id: 12826454 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 47128C433EF for ; Tue, 26 Apr 2022 04:32:05 +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:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HJe8zur+FBF1HV3FT9z/pda0WhCmbjNwiae7dWXAgqE=; b=n4i3AtbrEIhCln zeOJooW/fznNIQ1tWu16w9aoMeSW6Agxr71RX7zdfRjaoW4zaJNg8gOgXfuaTGndoT79Skz8XIBoV qWe2W3TrklUIaF8JH+bEEiAPqHWkzXyQMzNRzndSDlDdkqTFuu7qmJjCBBJdieE/kfVVE5zWhOpjY pPAcFh14Ni2JK8wcRtGeUzmw0E/xDIwaHX1gnTLsrEynSPdhgeTnZeH4Eeo+KMn/xadoF6BreJshc nc+A92y8StJ6clmaZpJVG5PVD7yLOD8TahxHfJ4NkY+PhsA1SWCElNsHzr5wNAR+Xdfgp9pNdkaq8 uhd0mOQOoPEzJ2MZU4lA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njCrk-00CQ6a-6H; Tue, 26 Apr 2022 04:31:56 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njCrg-00CQ5Y-AU for linux-mediatek@lists.infradead.org; Tue, 26 Apr 2022 04:31:55 +0000 X-UUID: 1230a85ae5aa47e7adc966e8340b4391-20220425 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.4, REQID:54bc1e2a-7f46-4241-bb69-7230b60502b5, OB:0, LO B:0,IP:0,URL:0,TC:0,Content:-20,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,AC TION:release,TS:-20 X-CID-META: VersionHash:faefae9, CLOUDID:53e4f2f0-da02-41b4-b6df-58f4ccd36682, C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,File:nil,QS:0,BEC:nil X-UUID: 1230a85ae5aa47e7adc966e8340b4391-20220425 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 168557693; Mon, 25 Apr 2022 21:31:40 -0700 Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 25 Apr 2022 21:21:37 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 26 Apr 2022 12:21:36 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 26 Apr 2022 12:21:36 +0800 From: Lecopzer Chen To: Luis Chamberlain , CC: Matthias Brugger , , , , Subject: [PATCH] module: show disallowed symbol name for inherit_taint() Date: Tue, 26 Apr 2022 12:21:20 +0800 Message-ID: <20220426042120.9686-1-lecopzer.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220425_213152_393942_7B35D96C X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The error log for inherit_taint() doesn't really help to find the symbols which violate GPL rules. For example, if a module has 50 disallowed symbols, the log only shows the content below and is duplicated with 50 lines. AAA: module using GPL-only symbols uses symbols from proprietary module BBB. AAA: module using GPL-only symbols uses symbols from proprietary module BBB. ... This patch add symbol name to tell the offending symbols explicitly. To-be: AAA: module using GPL-only symbols uses symbols SS1 from proprietary module BBB. AAA: module using GPL-only symbols uses symbols SS2 from proprietary module BBB. ... Signed-off-by: Lecopzer Chen --- kernel/module.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 6cea788fd965..30973f0d2b7c 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1372,20 +1372,20 @@ static int verify_namespace_is_imported(const struct load_info *info, return 0; } -static bool inherit_taint(struct module *mod, struct module *owner) +static bool inherit_taint(struct module *mod, struct module *owner, const char *name) { if (!owner || !test_bit(TAINT_PROPRIETARY_MODULE, &owner->taints)) return true; if (mod->using_gplonly_symbols) { - pr_err("%s: module using GPL-only symbols uses symbols from proprietary module %s.\n", - mod->name, owner->name); + pr_err("%s: module using GPL-only symbols uses symbols %s from proprietary module %s.\n", + mod->name, name, owner->name); return false; } if (!test_bit(TAINT_PROPRIETARY_MODULE, &mod->taints)) { - pr_warn("%s: module uses symbols from proprietary module %s, inheriting taint.\n", - mod->name, owner->name); + pr_warn("%s: module uses symbols %s from proprietary module %s, inheriting taint.\n", + mod->name, name, owner->name); set_bit(TAINT_PROPRIETARY_MODULE, &mod->taints); } return true; @@ -1417,7 +1417,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, if (fsa.license == GPL_ONLY) mod->using_gplonly_symbols = true; - if (!inherit_taint(mod, fsa.owner)) { + if (!inherit_taint(mod, fsa.owner, name)) { fsa.sym = NULL; goto getname; }