Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4175873rwb; Mon, 31 Jul 2023 02:44:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlH302Ol+FPBHQusWpaGYeujYR98QaA+5iLzZu2pr4tZ2TGKi3jx+s3hPua/usDdScRc50Ut X-Received: by 2002:a05:6358:94a0:b0:137:8c47:ba55 with SMTP id i32-20020a05635894a000b001378c47ba55mr8603156rwb.1.1690796698774; Mon, 31 Jul 2023 02:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690796698; cv=none; d=google.com; s=arc-20160816; b=iSmHJMlBdsHC8XvKtFSheaTZuDflCSiMR3bp4l26vrfhJXFW3ONzBvSCn7RlTdeuAC Fzdygu7bc/LuLHcJGo0txp7PXN7w6B3XhvhAF0+eyLcQ5kotVAYHdiyTub/6VqwAKYFS aRsfoi2Q/7DKEmtyUsjGSJY1n8S88bjsI4sA2FwDSsrpmROSKQyMcoZbkRpQfQxlmslL PtRDNIV/HKmsaejitwnOVb8NrvpoPt3LUfRR0XMO/wdOuCZPlfcyI9rVNikVb27zgmuF 9oxNC/+JXhTD0al00xmXKg6895IsffYqQG6u334mOIHArg0ao/PEd2ZezCfwgi2C3fwz PQqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fpzWiCemt8iyK69nP61qCLs36MXwZ+pdOr4ITT1eya0=; fh=Jf3M7ygXb8W1KLUVtb0UJCFyg9JtKT8TxO5XgFASIj0=; b=uRIdwO2klnJ5wrJxItKPD9wUdr7VmuHB5FUBzXiZWc8GjYo/HIBLAeh0+yLbxl4HN6 GM+KBMcmTC8BTbwDeV9zSa0fgrv3HbYbOd94yrUQRSvpRjORE5fsYEPLQv96P80f6Ah4 4RGt4piG17b/22TIXZLWyyVWsYbOGSm1vnulJc8baBChUar9j0VZ/DKFC8V4zxKcilZ6 qjDZA1BU5sGGHHhv3v3LNJkLi9tnZjrPJNgFWEDF6j8zcg1tJxsF8uL+1bhRQmJv2oBw X3t0tD+nibjrVNjOKJd7z5dzlu+J4xTYImrTyPIIJEMrzoSL26kEnA6S0QJM0OSeRSiw EMBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=haZPeO5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a634e45000000b0055c4c9cbfedsi6909581pgl.862.2023.07.31.02.44.46; Mon, 31 Jul 2023 02:44:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=haZPeO5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbjGaIkB (ORCPT + 99 others); Mon, 31 Jul 2023 04:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbjGaIjT (ORCPT ); Mon, 31 Jul 2023 04:39:19 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9ECE10F0; Mon, 31 Jul 2023 01:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=fpzWiCemt8iyK69nP61qCLs36MXwZ+pdOr4ITT1eya0=; b=haZPeO5LdCP8/cngv1IF8GYnCB JpI6Oqi+D5JWYV1zV+UjHB17TpOjFoeZZzwl1VQafULr2qvZRn/XoTAXSHIEjVqtWdVCMz8RpuO6N o6gFWkRf/SJGeERduYeO8nm11vdejRYzeBlpu8QN5MxNjuAxE/FZHwOrcL+9NtHTnvsc1MUJqDMMt cXSljNq6m1mtzPD90yydTLSCGm866aXjcZtAE+wJufjf9+QUNmVjm+JGAx/+tmp3PNtX1yf4QYSqg JOn2InDeSov1ckzUOPpiLvTZO86uQ3G/hx3/Us7Jx/uXyo6lci2OF1mLPe6VF9vpF6DDFvT+Y5p5m u2OKnHLQ==; 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 1qQOQ6-00EYvK-1x; Mon, 31 Jul 2023 08:38:26 +0000 From: Christoph Hellwig To: Luis Chamberlain , Greg Kroah-Hartman , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Ulf Hansson , Yangbo Lu , Joshua Kinard Cc: Daniel Vetter , 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: Mon, 31 Jul 2023 10:38:06 +0200 Message-Id: <20230731083806.453036-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230731083806.453036-1-hch@lst.de> References: <20230731083806.453036-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 propriertary modules into an allegedly GPL licensed module and then rexporting them. Given that symbol_get was only ever inteded for tightly cooperating modules using very internal symbols it is logical to restrict it to being used on EXPORY_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 --- 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; 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) + 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, void __symbol_put(const char *symbol) { struct find_symbol_arg fsa = { - .name = symbol, - .gplok = true, + .name = symbol, + .gplok = true, + .gplonly = true, }; preempt_disable(); @@ -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", + symbol); return NULL; } preempt_enable(); -- 2.39.2