From patchwork Wed Oct 19 08:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp223675wrs; Wed, 19 Oct 2022 02:38:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DZvrmqy4PSr3Ee/PJi5W4iRNAQpNiJcHQQ+YauRhPL7JLKw0/Y685SZzO5YFKJlfPF6js X-Received: by 2002:a17:907:847:b0:77f:f489:cc25 with SMTP id ww7-20020a170907084700b0077ff489cc25mr5946765ejb.80.1666172289793; Wed, 19 Oct 2022 02:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172289; cv=none; d=google.com; s=arc-20160816; b=F5nsjSPtt5OtSjukEVeFKF/dY/xE1L17yEGqvkoDE5ycaGWI77SjMTBAZp1KgSIKLQ 9Eoray6Jw/OwjxqsfPkoTl74Rb9FGhYwkkXudO8Ex/Qp53+SLEwvQxRLmt4jfgpsyn9l SQVb5Npfr/L1XgE6twiVFSHO3kTZxf69b5s7uxTfQr+dO6QCKcB86764ks5HRRfCHTcR rocVTMWrCekp0sZ7jIe3DxE+9a1eiL4/DgR3uk50TUMZkUOatr00+p20Sa2O7x5OsK9m q+nUx05WxK/2Y86lJvua8FTaN/ldklsg2atFugyRufoYthJ7O3g+76mQwkrN4fjBj+1D 7SEA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn22-20020a1709070d1600b007429f0c69ccsi16860588ejc.579.2022.10.19.02.37.42; Wed, 19 Oct 2022 02:38:09 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747108275054985084?= X-GMAIL-MSGID: =?utf-8?q?1747108275054985084?= 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) &&