Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2455762pxj; Mon, 10 May 2021 03:29:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXwJsg3hVoYGlUF0LiXBcrPEJi9c+FxoCPAbgr+vWm6EI5VBM04wgsmmLYPd++7Pa0gpLa X-Received: by 2002:a17:907:2176:: with SMTP id rl22mr24904907ejb.155.1620642570200; Mon, 10 May 2021 03:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620642570; cv=none; d=google.com; s=arc-20160816; b=z3ZA073GAit5+aK9mfWsZG8CLtpLtmAEe6aiYUz2/FeCa1TfzzxJ4Kc/sfmWc2sbtG rbE7v/KPvMNdNTPanZ+5XB8cj6ARyORIJKgtmA/ntWKhj4/DU5AofllyRUHKQY1wHR6+ iW+9rmc/GMqF1se9DqAH92UakwXE0yOB7YihHhvrsZaY9rJ7h5I9m70Zar4kgSwZby12 seDaDBGrE6DCjvoRV1vJVziiWudJtguj90f3ZH8Vv+MtG0gt5kVoxcXllsgJ9l2yNuX/ eZ5IzVzRDLsaTxcK64floUpqNdZNfG0ufBfB0jdaat/Q+d5OXVPXpBGGgNpVIa+WkDhx vb/Q== 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=QKR4sQFS7XtLqiz/ew+wq/mVC5mBoG017nAUYtwL2hE=; b=rpA3x3pbUemHFVFodvzs9qXeJx1KFD6/vhMm2zXefkMndOpaX0wvKKauny8fdh6tPy LAUXPld5w/YAHkamovtsu+KTKbTuTWjvdcES8qhbaGDLDoxHs9saYMhNfkAZVHbPMwRl TBcbTsDRqTBr05WIILwzSNWsDOvX10L9nz0Ag62JHRuTDb//FvrY8+9Pj9HLJkt/LHWV kiqxa4l9OFj5V2S7fEuusPJVL1AQfcf5mZIpejdST4+fwKOXinWAnpx9cNhv3cVFsrMA YOJMZcyASnK3aDayyHusEOWUjkY4RerGxy4dAOomUo/5G67Rl/GN543RcSXh2erkbpAx cj8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UfQ0i1BK; 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 u6si12606242ejc.208.2021.05.10.03.29.06; Mon, 10 May 2021 03:29:30 -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=UfQ0i1BK; 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 S231360AbhEJK0h (ORCPT + 99 others); Mon, 10 May 2021 06:26:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:59230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbhEJKZs (ORCPT ); Mon, 10 May 2021 06:25:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDB2E6144F; Mon, 10 May 2021 10:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642281; bh=bM5vnLEX9oW3SHbz0ddTRPsiZuD0vRSfgOYjYyjAByo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UfQ0i1BKBDUWzj+15YA7uLvYdqLuDs8Yucdpvy85FXJ8LDr43oMjjqC7C2X422boJ 5rZGWaXV5gxHsQcWH60UMqLfhXnMsdqAnpWLCxYshOo5S51cCHayg5MKsxZ5yNWUCy Kq9C5i3jdoYOKBCCS/xjgmpi4T0Q80Z/1/Z8oK9E= 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 5.4 031/184] modules: inherit TAINT_PROPRIETARY_MODULE Date: Mon, 10 May 2021 12:18:45 +0200 Message-Id: <20210510101951.249384110@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510101950.200777181@linuxfoundation.org> References: <20210510101950.200777181@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 | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) --- a/include/linux/module.h +++ b/include/linux/module.h @@ -376,6 +376,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 @@ -1429,6 +1429,24 @@ static int verify_namespace_is_imported( return 0; } +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, @@ -1454,6 +1472,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;