Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp66244pxb; Mon, 13 Sep 2021 13:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLkYXbvHGJlMuS8M81no+HDEj6f7ig5GmUdHwpsvQjB3c2DIMnhqXMs+hmUO+0qcSF39up X-Received: by 2002:a17:906:b807:: with SMTP id dv7mr11608903ejb.543.1631563570000; Mon, 13 Sep 2021 13:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563569; cv=none; d=google.com; s=arc-20160816; b=Js+XtAvBXwXA3xWcAyIrm6N/MMCNHTvhx6nOo9bLuzxWPHHm5kObYlPduwjOwY56Tr GsSHgr9N5KOD9qT5cusJMt2CBdvj3DkgMiTWRFH9OtIjmbcvGvOPpB8Md36Pf0twprZt 3EsJifX0q3owOkUudoIbUhrGW0k0jVZUfzk5wqkOFovz1zvEQXx7KQdEGWKrsFUzPs4o QBdxi+L0j7T1LXadwQngIXcMUme/n3S3n8iWA3yDjeP7k+MccW0k5eI4BT7culh2hdcd hX/ReUwG6m4CWavr1jRZNtq5YuSl1jqVGMBIxmGnnioakN3+RsuLZ1JaEkznTet6k3h2 vefw== 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=vlSbxeg1Q36UeUbS0WMUzoH+b2kpyRIJq7lKGUc0y/c=; b=GWvmmHlxjs6p4z7PJdfUgtoDEn1YK56knCl4vesGOt8WTCBTAk95rpKBt0Su0H1YJ7 /rLkUanMPB2wfXrwNPjG6PeW+OXG1aFZTFDr8oMhpig29Py4U+n6Clr/vurmD6K5Un10 3Fr9htinDBQyHj344V5QzRFCfAjHjDPF+/eXcqPzgewnWKTTFOZ9J5zF0AAQ6S+bUrGx fgUWDPP5A6GXQnad5ihl3yaKFFT1BXEYQDs0u6vPJZZirtNv5inm8R2tNAov0yMcgHFZ CiOKTEnzGYuNHsdDwVQUtO+LEq3irGqnzCv77vuZZKfZ3gutRS0Vxy3ECwZAoFbPXOml slJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sJdGbDK3; 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 y2si8623232ejr.90.2021.09.13.13.05.40; Mon, 13 Sep 2021 13:06:09 -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=sJdGbDK3; 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 S243182AbhIMNoR (ORCPT + 99 others); Mon, 13 Sep 2021 09:44:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:37818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243167AbhIMNiW (ORCPT ); Mon, 13 Sep 2021 09:38:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0AB6661263; Mon, 13 Sep 2021 13:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539711; bh=27IrT8vsW4e8GkIYRRNTNr2+Lx8YE0AXCSgSjVcfQLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJdGbDK3hfVJ5vgL+Cb2RLdooyhDRDbNqNJUDs6sgq9ZKtWLSX5YFH7bZZlzCSiS+ lk+8aS1QPe8sgMQkUBzEc4q4d2NdbuvioOyzUAVnXsLeDb47DDSQxMwqS3LPAGJ1eu A4CUc/VrZT2XiUlK1bwNyaRV9oC5mNd9Q8KvPn9o= 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.10 129/236] debugfs: Return error during {full/open}_proxy_open() on rmmod Date: Mon, 13 Sep 2021 15:13:54 +0200 Message-Id: <20210913131104.753295134@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 686e0ad28788..3aa5eb9ce498 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -179,8 +179,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? */ @@ -314,8 +316,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