Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp7441pxb; Mon, 13 Sep 2021 11:30:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJqlYNyGPuH57m2yubpkNM/ihr7WaY94zdLH8moyyaeRu4Ed1A7oFyCN/m09LrxPRbRlgz X-Received: by 2002:a92:d2c7:: with SMTP id w7mr6081210ilg.71.1631557803477; Mon, 13 Sep 2021 11:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631557803; cv=none; d=google.com; s=arc-20160816; b=km7vUtwfixzScW7Halb9e63h2spKHAw/9PJUtvYwhoGDSz9KAIydVj+WX86eZlqF7e pmBNBkXUqUZ9kU4YmA0cTUfZJqyLUWRYd9W45pcEd2dFh3yew8p+c4AxGGlqRkITIBSc LlMRDtRHnckxWIr8LYNKPh8VVl0G7OghynhM2BnINQ2W8eh2YGosY7NUbWWqIg1njjV5 AQ2pywVm6EG457AkurROtoHsipzjYIe7jK7ep4nyOKx/A8hUBvsm68SZ4kTNrzJ0ePM/ 8jo2UJ9IXgoXiXqcxDqS9ogF2Bml3rJavTZGJOx3y2o9dwIkFiazy2Gaz5wrPdeVBiZb EKUg== 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=4zGq9LK7zMpiIe6SsWFDqc60UokmIqNfx/U99xpUozg=; b=NoSHPPIEnI97vPPlMtXAirdCgLBuZc7PVQswJDztCVUJwztZ58yHsZNL7Yoyv5SKLu wjgGyO05UJ36WBfFTKNhfW3dbFrTvBmqMcXXEnRt9x3KctgTOTOPQrdfsgmcobNm5KBj ugeTfrpKegD9kKv5POlbmABX39K03ekt8Jt4Ktzd5NPCiwxlG6K+3k8LiT3o1GUvURCk q1vWRrAEwhXHysXRTyh37H/y3m7QGptU8el618CpueYq3PoM/e0SzNqM2jL16EtYyE0Z tPe5CiTSNCo3hUWDDWoh9nyu6oYFGkjNGYD0xDvnmvocpqC9bxZ/rMi2TlmmcbHAYuVM JHWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bxVWZZ+g; 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 a10si7039143jaa.15.2021.09.13.11.29.51; Mon, 13 Sep 2021 11:30:03 -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=bxVWZZ+g; 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 S241134AbhIMNXX (ORCPT + 99 others); Mon, 13 Sep 2021 09:23:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240635AbhIMNVW (ORCPT ); Mon, 13 Sep 2021 09:21:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 192046112D; Mon, 13 Sep 2021 13:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539204; bh=OPddaRiK+9M+Rx4KrOe4SDXtMoeMPsr7BQV8MVDSbAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxVWZZ+gN6+WBEAssQi4m21sDgE0UBjOhIUTyb4KjvHB46qhmJdlVK7ssL38mr7Nn yuR1vUwcMNQJnTB/8gVJskxUd0y9HRdhQOGBK8VOZIoNy+bOkt0rjOElqHhJfBX197 CpRr7jVOlrJa2FA2Wtp4w5YVpwNSMgQzM6mBjEnA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , =?UTF-8?q?M=C3=A1rio=20Lopes?= , Sven Eckelmann , Sasha Levin Subject: [PATCH 5.4 080/144] debugfs: Return error during {full/open}_proxy_open() on rmmod Date: Mon, 13 Sep 2021 15:14:21 +0200 Message-Id: <20210913131050.641470610@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@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: Sven Eckelmann [ Upstream commit 112cedc8e600b668688eb809bf11817adec58ddc ] If a kernel module gets unloaded then it printed report about a leak before commit 275678e7a9be ("debugfs: Check module state before warning in {full/open}_proxy_open()"). An additional check was added in this commit to avoid this printing. But it was forgotten that the function must return an error in this case because it was not actually opened. As result, the systems started to crash or to hang when a module was unloaded while something was trying to open a file. Fixes: 275678e7a9be ("debugfs: Check module state before warning in {full/open}_proxy_open()") Cc: Taehee Yoo Reported-by: Mário Lopes Signed-off-by: Sven Eckelmann Link: https://lore.kernel.org/r/20210802162444.7848-1-sven@narfation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- fs/debugfs/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 943637298f65..a32c5c7dcfd8 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -178,8 +178,10 @@ static int open_proxy_open(struct inode *inode, struct file *filp) if (!fops_get(real_fops)) { #ifdef CONFIG_MODULES if (real_fops->owner && - real_fops->owner->state == MODULE_STATE_GOING) + real_fops->owner->state == MODULE_STATE_GOING) { + r = -ENXIO; goto out; + } #endif /* Huh? Module did not clean up after itself at exit? */ @@ -313,8 +315,10 @@ static int full_proxy_open(struct inode *inode, struct file *filp) if (!fops_get(real_fops)) { #ifdef CONFIG_MODULES if (real_fops->owner && - real_fops->owner->state == MODULE_STATE_GOING) + real_fops->owner->state == MODULE_STATE_GOING) { + r = -ENXIO; goto out; + } #endif /* Huh? Module did not cleanup after itself at exit? */ -- 2.30.2