From patchwork Tue Aug 1 17:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13337117 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 20051C04A94 for ; Tue, 1 Aug 2023 17:36:59 +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:References:In-Reply-To: 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: List-Owner; bh=N09APFG6RSQVCnei4jx0ZAnitNnoBDNMDaopKq4wNO0=; b=Wby2fbpKfRVsGU 7b5ehU4EgfYa1kJqzeMp+YAG4AY//SoMzkPvvZCUu6KTV/+nEY7x5GCKLjTk29m10OBlFJnzh/yB7 /7G2jn9h7WmFYiv2UuZP4a77uigkHbIMag0dUMgF1zjZaEMFHo5aBiWuqUhGJKSHR5B/RNij5YLE2 5cS0Wk0UJ0xS/rl7NHafB8MHQ8qhqKG4k8ZJutrhBAdTXNfdBmVM/Tz3UtoUrMJczoa0WMjfeX+Xd o7b7HpS0oRJ6q/AB8zBPBLYV9YuWpjMO0JdaGwGn6s/XNKcUvtBoZnXDqIxD0C1WHk6R62oC1HMiH qopp6y/Zlfrw7JFcFI0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQtIO-002wCk-2y; Tue, 01 Aug 2023 17:36:33 +0000 Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qQtIM-002w9v-03; Tue, 01 Aug 2023 17:36:30 +0000 From: Christoph Hellwig To: Luis Chamberlain , Greg Kroah-Hartman , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Ulf Hansson , Manuel Lauss , Yangbo Lu , Joshua Kinard Cc: Daniel Vetter , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org (open list), linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-rtc@vger.kernel.org, linux-modules@vger.kernel.org Subject: [PATCH 5/5] modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules Date: Tue, 1 Aug 2023 19:35:44 +0200 Message-Id: <20230801173544.1929519-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230801173544.1929519-1-hch@lst.de> References: <20230801173544.1929519-1-hch@lst.de> MIME-Version: 1.0 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It has recently come to my attention that nvidia is circumventing the protection added in 262e6ae7081d ("modules: inherit TAINT_PROPRIETARY_MODULE") by importing exports from their proprietary modules into an allegedly GPL licensed module and then rexporting them. Given that symbol_get was only ever intended for tightly cooperating modules using very internal symbols it is logical to restrict it to being used on EXPORT_SYMBOL_GPL and prevent nvidia from costly DMCA Circumvention of Access Controls law suites. All symbols except for four used through symbol_get were already exported as EXPORT_SYMBOL_GPL, and the remaining four ones were switched over in the preparation patches. Fixes: 262e6ae7081d ("modules: inherit TAINT_PROPRIETARY_MODULE") Signed-off-by: Christoph Hellwig Reviewed-by: Greg Kroah-Hartman --- kernel/module/main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/module/main.c b/kernel/module/main.c index 59b1d067e52890..c395af9eced114 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1295,12 +1295,20 @@ void *__symbol_get(const char *symbol) }; preempt_disable(); - if (!find_symbol(&fsa) || strong_try_module_get(fsa.owner)) { - preempt_enable(); - return NULL; + if (!find_symbol(&fsa)) + goto fail; + if (fsa.license != GPL_ONLY) { + pr_warn("failing symbol_get of non-GPLONLY symbol %s.\n", + symbol); + goto fail; } + if (strong_try_module_get(fsa.owner)) + goto fail; preempt_enable(); return (void *)kernel_symbol_value(fsa.sym); +fail: + preempt_enable(); + return NULL; } EXPORT_SYMBOL_GPL(__symbol_get);