From patchwork Sat Oct 22 07:26:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1105811wrr; Sat, 22 Oct 2022 01:36:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59E8y9E62zjHRwCoBG+aAJ31n89A1u4wLsvhOzNwF3XRGMtKDLkFHxP8m7odcdY2JgI8cd X-Received: by 2002:a63:1450:0:b0:439:3806:9b91 with SMTP id 16-20020a631450000000b0043938069b91mr19555739pgu.407.1666427772972; Sat, 22 Oct 2022 01:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427772; cv=none; d=google.com; s=arc-20160816; b=Sk08mxQKNPY7N1kA/p2qqUvjH14XpVv4mPliNVJZCPE45atWT6xlWMTotKnDIdjB6I eC7DPHJHK4bCN7wl6jGCQI9bbjYtWtb+7b8DSKQ0ksgmsCqdza3k1+q1PM5mQ1xPkyBv WFffkK3Wa7fKCBvmIhR1EIYnND5RhyR+IksZaP0zMWxby+IDwtGObV5LUfPRyHDK38Bd 8s/YwNyFRLOLWXlNZ1iKQsi2c9vadezDMJKoevakSZ1aJ2jTjLozWaeQUcpZX3mYyrG+ E7lCgq4GEWfpm54BFmnVkiuSkBsxE2Muu0zoyglPS26ztRx18gYxVY16jvBFzdh3isjv bjuQ== 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=baLLyv7rhvwOPdpev0d/yMdBkWZE8T7hf6de3lVI9sJT/AzcPev1tqq+iSW85td+pi oGMkrpotKGta16P1dQGSfHaYWsjYUhKLBRJBhe+hunfeDxMX+x8AndkS/GiAQOKmq9jL oT8Lelgm3BWS0eYZSEBcaZFBWQC+p2WCV9nz15Y+I/HfPXS/ioG7kvUWAk+7dFwFKMmI WEMevyNsrFGguf0dA29MFerMLrTVmiCCT9TTIbwnrhzqnFMRh0cAXZ6H6TgyCxbJd1z9 +lO67z1b24znufjM81qs3GFwsgIE5cJQ2xLoNX4IBDgoskneoSWncHMg7tLZ0kruZQzN z2Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a1XiWn27; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r138-20020a632b90000000b0046086f8f5d0si27266533pgr.537.2022.10.22.01.35.56; Sat, 22 Oct 2022 01:36:12 -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=a1XiWn27; 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 S230331AbiJVIZV (ORCPT + 99 others); Sat, 22 Oct 2022 04:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233621AbiJVIW1 (ORCPT ); Sat, 22 Oct 2022 04:22:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8C623B956; Sat, 22 Oct 2022 00:59:13 -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 ams.source.kernel.org (Postfix) with ESMTPS id 597F3B82DFA; Sat, 22 Oct 2022 07:59:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B47DC433D6; Sat, 22 Oct 2022 07:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425552; bh=vu7rJYj1z+XfoxBx4lR0BrFlu16v+YMPOdlO7pyXxkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a1XiWn27v3kSFkQTfDxiw0z0eaZQ/jnqlo8kURX0UtiEHhxDZ0i5bIxvm4vg3jNoW q2+QMxaLMJmZ4zc67brD4MyLXGoeywjq6h473os0xsdjL9a49+aIc5ypVyemB9VBkB XlNNuUrL7cLtPTg67eIR1FJmT5UpHscc2hOilj6Q= 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 5.19 539/717] module: tracking: Keep a record of tainted unloaded modules only Date: Sat, 22 Oct 2022 09:26:58 +0200 Message-Id: <20221022072522.179159829@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376168495064403?= X-GMAIL-MSGID: =?utf-8?q?1747376168495064403?= 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) &&