Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2109309lkv; Thu, 20 May 2021 03:37:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvkANKDSuZ+2AO/PH8XUwwLzpIpz70nxFLBW7pdqFHE//o/tJeFBOfWxoaPLbSN1pGjHAP X-Received: by 2002:a02:69ca:: with SMTP id e193mr5267464jac.130.1621507069905; Thu, 20 May 2021 03:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507069; cv=none; d=google.com; s=arc-20160816; b=t1HnsZgbNi12VLEDQLro31G1ITUBj9AKQDr2aoB/Ck+QplCWsnvlksut9ePGwJaV6f nQfbwcfNQR+PZfW7ArwHSnFFx39eNWz2XkpeSmDAvEPRgFoFXfbL8HmVMtsYTq5gB2rY hKX9d+XTBARx49pxaeZaNG4Ll68JT0rXY0taGxbuLuUWenohVfmeAcjU4Yk/PV098Gny ZNZZZrbFFqlowb4f7Z+DLTy4ziDo3rTB9cZZSmpQTDPFF0lcQzhogWMJWSU9U5WA4mH1 5oXIfQGuXyk9xlzSFvEqVpNIkmqVjuS7P49gUGi/r/uwx6WzR78WaCUhk+ukk4xx8pHI V0Bw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jKCvIOWNqJjOmDOPJToJVdC2oEpAENf40e6P8Y0eaxU=; b=f05Te1+i+uOvoM9IdImqT1a39+oeJm2psEM7kgPM41fdVk6xM6tH3t0+WFnnxaOX+d Wjpo8fzLm6Qj96iWud07gPMF14UcXFHkKuzKRVCt9nSzAshStiJf6FxQ4Jhh8XqB/aN9 brXC3pOsrCtON4+sCFFA8OPOBzCbx4T09xPy1VgxsG2QhEzqbY4UA8v305lekdKLQj+E u9X7K0Esx9tildezbfUS5Cn779Y56VB4FLnQYUNWqFFIEoZKFV/qMHTIxv7L8DxG9rA4 jn/be+3VtJRwzUUd2NpqNIuk1zsiwpMsvXdjY8shgQBlQsgmGboy8BuihIGgJOCEfj2i Lzzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xIfmWOUZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w14si2705600ilu.141.2021.05.20.03.37.36; Thu, 20 May 2021 03:37:49 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=xIfmWOUZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237265AbhETKh4 (ORCPT + 99 others); Thu, 20 May 2021 06:37:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:55508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236421AbhETKYH (ORCPT ); Thu, 20 May 2021 06:24:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CDDA061460; Thu, 20 May 2021 09:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504138; bh=+Nar8B+XdP8NwF/ZCr2KB8T0QubYq5vrKZbySDxcwVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xIfmWOUZ0bAXMKUpHN3UfYv7bJ+gqaVRMWCqKfCKaY52l6SQcsCVHldFODazv1TIs X9XKYHxB6MoCdA/t79/MriV+/c9YHWfQltRtpd2AQZ+2DPGqJ3swdcLVzA9DWXNKTl cyvTH3jWFWqJer2lWaNAiLWDEzsp0qz4zcTvIimU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Vetter , Christoph Hellwig , Jessica Yu Subject: [PATCH 4.14 110/323] modules: inherit TAINT_PROPRIETARY_MODULE Date: Thu, 20 May 2021 11:20:02 +0200 Message-Id: <20210520092123.867230675@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig commit 262e6ae7081df304fc625cf368d5c2cbba2bb991 upstream. If a TAINT_PROPRIETARY_MODULE exports symbol, inherit the taint flag for all modules importing these symbols, and don't allow loading symbols from TAINT_PROPRIETARY_MODULE modules if the module previously imported gplonly symbols. Add a anti-circumvention devices so people don't accidentally get themselves into trouble this way. Comment from Greg: "Ah, the proven-to-be-illegal "GPL Condom" defense :)" [jeyu: pr_info -> pr_err and pr_warn as per discussion] Link: http://lore.kernel.org/r/20200730162957.GA22469@lst.de Acked-by: Daniel Vetter Reviewed-by: Greg Kroah-Hartman Signed-off-by: Christoph Hellwig Signed-off-by: Jessica Yu Signed-off-by: Greg Kroah-Hartman --- include/linux/module.h | 1 + kernel/module.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) --- a/include/linux/module.h +++ b/include/linux/module.h @@ -357,6 +357,7 @@ struct module { unsigned int num_gpl_syms; const struct kernel_symbol *gpl_syms; const s32 *gpl_crcs; + bool using_gplonly_symbols; #ifdef CONFIG_UNUSED_SYMBOLS /* unused exported symbols. */ --- a/kernel/module.c +++ b/kernel/module.c @@ -1380,6 +1380,25 @@ static inline int same_magic(const char } #endif /* CONFIG_MODVERSIONS */ +static bool inherit_taint(struct module *mod, struct module *owner) +{ + 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); + 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); + set_bit(TAINT_PROPRIETARY_MODULE, &mod->taints); + } + return true; +} + /* Resolve a symbol for this module. I.e. if we find one, record usage. */ static const struct kernel_symbol *resolve_symbol(struct module *mod, const struct load_info *info, @@ -1404,6 +1423,14 @@ static const struct kernel_symbol *resol if (!sym) goto unlock; + if (license == GPL_ONLY) + mod->using_gplonly_symbols = true; + + if (!inherit_taint(mod, owner)) { + sym = NULL; + goto getname; + } + if (!check_version(info, name, mod, crc)) { sym = ERR_PTR(-EINVAL); goto getname;