Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp873027rwi; Wed, 19 Oct 2022 04:09:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59OoTHYfG1qiGEEOpfGnNkDxHecD8a2vZd5N68GXy+1APZiVVYmPmb6q0DS7y2EBoHT2GF X-Received: by 2002:a17:90b:1d0e:b0:20d:a61f:84b1 with SMTP id on14-20020a17090b1d0e00b0020da61f84b1mr36666443pjb.172.1666177774506; Wed, 19 Oct 2022 04:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177774; cv=none; d=google.com; s=arc-20160816; b=MM8QGMibQrTZzT/k674ibDbkoSlTwKMSYPr/RAhmD34xmehtera/567Okb4sDvTB/r 4n30Y9HOfsOgc30+w1n/XJD2D5IAgcrZug1+MSlWVRO4cQrJvwTESJ2sHN0eFS7BnmQX 4qhEwQX3kxGziU+0Z5H7aaZ4g+TnodbQEtM32KkCq0CTw9sAJvebkauidFoH4U2TEjNY FZ46qAcuKw7WegQwLUXb0WZDP31dF6fVfPBMTAaUz/yka4lUxKnbqWylUEjZoiJF/LXk 0g50WJ0S3NmkbBA0/iPtEkuDa3IyDj0BW3uT3x+TuN/LTRu7L6VAXPOZgXhVPcMhrEHE 0/eA== 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=I8DkjVnHvipYjZWYYer0sDnqPw4kNhj2E0HivcOn//s=; b=SGdWsSTeGa6HsiPF75/iIZSe+hZ+/MnuPwSSd/FCS5ae7KY9gEXEP3vnKgBN22hNTz f6cxvE1Ia2oezKvdswhBBJbZ5Kj/Tb8Pb+WgIdC0pPEMpLKxNjVQejYrlcW+M7zSqacy 3rRLuStQaWZ0GMx8SZR3NEJt1LsfIzR+9YxN4uw+l2GhHaNnD5RK5whHPO51ZiTv/8Pa 8HGY2oUGmGiSRwTl8DueEpGAQepF7zyNzIFhDTxLFrR/HGf2kickMcfw2+h5z0PWNaFr y6yb2gVoNe3GLrgh4q/XKgMMsRp5nUCVCQ0d1CKtE3jv9V6f5daZoZ0L4T/ipwl8MV8T SX1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PyXAqdqa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x70-20020a638649000000b00458085e9e70si17649753pgd.577.2022.10.19.04.09.22; Wed, 19 Oct 2022 04:09:34 -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=@linuxfoundation.org header.s=korg header.b=PyXAqdqa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233403AbiJSJVR (ORCPT + 99 others); Wed, 19 Oct 2022 05:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233681AbiJSJTx (ORCPT ); Wed, 19 Oct 2022 05:19:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EBA8DBE7C; Wed, 19 Oct 2022 02:08:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E5516187F; Wed, 19 Oct 2022 09:07:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8061AC433D6; Wed, 19 Oct 2022 09:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170451; bh=vu7rJYj1z+XfoxBx4lR0BrFlu16v+YMPOdlO7pyXxkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PyXAqdqac90ZmB1MepO//b2fHO5VewApjA0nM1EdRMLgyMBM+NOR9jt7FlypDYvV0 FB365IlwZBwif0uMjxkE9XU9jJbEgeP5bhg0jnL+rsHf52Oq96H8dB1wZSbMeZTyfj r0tWp4gSTD4r1JA6305ZH5Jccpb6tgND98xH2s0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Dobriyan , Aaron Tomlin , Luis Chamberlain , Linus Torvalds , Sasha Levin Subject: [PATCH 6.0 660/862] module: tracking: Keep a record of tainted unloaded modules only Date: Wed, 19 Oct 2022 10:32:27 +0200 Message-Id: <20221019083319.135652075@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: Aaron Tomlin [ Upstream commit 47cc75aa92837a9d3f15157d6272ff285585d75d ] This ensures that no module record/or entry is added to the unloaded_tainted_modules list if it does not carry a taint. Reported-by: Alexey Dobriyan Fixes: 99bd9956551b ("module: Introduce module unload taint tracking") Signed-off-by: Aaron Tomlin Acked-by: Luis Chamberlain Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/module/tracking.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/module/tracking.c b/kernel/module/tracking.c index 7f8133044d09..af52cabfe632 100644 --- a/kernel/module/tracking.c +++ b/kernel/module/tracking.c @@ -21,6 +21,9 @@ int try_add_tainted_module(struct module *mod) module_assert_mutex_or_preempt(); + if (!mod->taints) + goto out; + list_for_each_entry_rcu(mod_taint, &unloaded_tainted_modules, list, lockdep_is_held(&module_mutex)) { if (!strcmp(mod_taint->name, mod->name) && -- 2.35.1