From patchwork Tue Jul 16 07:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13734063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC0DAC3DA59 for ; Tue, 16 Jul 2024 07:19:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 015BB6B007B; Tue, 16 Jul 2024 03:19:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F08516B0083; Tue, 16 Jul 2024 03:19:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCFAB6B0085; Tue, 16 Jul 2024 03:19:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BE7746B007B for ; Tue, 16 Jul 2024 03:19:26 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B426CA1785 for ; Tue, 16 Jul 2024 07:19:25 +0000 (UTC) X-FDA: 82344765090.11.A39CEC1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id DD4DA40017 for ; Tue, 16 Jul 2024 07:19:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dnoohVBL; spf=pass (imf11.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721114325; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EB3wMFlxbrsjfnnROX2dRnoTSwPU+Urzy/34m9Yppno=; b=aco2Vu7g/g4OL2usZo2voeHNsvnSMB4z2F9eUz2Fhk2m+3M0WIO8MZPxOuRnY58gQ63bfG /IsZO20ki52cMdrtrwAv4FUcda8ASyE8Osk5DH3PP0sTTaYnZvVX5sIzH5yhG71ynLTf3/ Se/II46p68B2R4iHcaikf6sTLMKlaLw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721114325; a=rsa-sha256; cv=none; b=KKVay2F8yEssysFAjb/vfdUQaeOGmtMBKwuMNXgoNjFNOc8WO7oeIZbjTLAKigFvzq5WBg 2JGsahB9DZKw+dUnRb4jUS4nDnWLzyxGYzcA+OH7LycLvz+odxsSAzffGkGuALHyHwENEK M//YNxPlZbXBF3wFIpZf+xoH5xb7lzw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dnoohVBL; spf=pass (imf11.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BC63060E83; Tue, 16 Jul 2024 07:19:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA893C116B1; Tue, 16 Jul 2024 07:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721114361; bh=IHbOlthUDde/1Qg4ACzZafpb7XBZ2FC+wr18+zf+5gg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dnoohVBLpFeCsb16MupJzO5EHjMN/W0DrnUEFPB1KoJtFlLxu0A35XgLJvABwCESV hw1R6Na5QXfQEMjMGbO1bcnhe/B1ivt1yigZlCG0S0+GBvgd8BWFkEkkFLalUshOcK MF6+OeFGb7cnt+xTuuoRag/A09+Ldu1+YZRtkksLSsolEJBo9e9ViG1/Z/A7gd4J9k 73aGty2Nr3PRg8hwlM92B0sR/FSzzzKy0TiKQi6LcdcNVH3a++rgEWntTpUDMqIekC IB0M8lpxjy1fh6ZrxkQmMaJhqyUQ4yuDiOvEbaoQkRzot0TfkmncWb33GUa2trh+/e e4vLjeH7Qg2Fw== From: Christian Brauner To: syzkaller-bugs@googlegroups.com, syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com Cc: Christian Brauner , akpm@linux-foundation.org, aleksandr.mikhalitsyn@canonical.com, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, viro@zeniv.linux.org.uk Subject: [PATCH] nsfs: use cleanup guard Date: Tue, 16 Jul 2024 09:19:11 +0200 Message-ID: <20240716-elixier-fliesen-1ab342151a61@brauner> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240715205140.c260410215836e753a44b5e9@linux-foundation.org> References: <20240715205140.c260410215836e753a44b5e9@linux-foundation.org>, <00000000000069b4ee061d5334e4@google.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1198; i=brauner@kernel.org; h=from:subject:message-id; bh=IHbOlthUDde/1Qg4ACzZafpb7XBZ2FC+wr18+zf+5gg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRNk/tw7aG63qxQT29G+UTT4iCjfYfXP2xYwLdzU5ZGZ vjkRXb1HaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABP5+ozhf+j9i/IzBeT43KcE n4/K9j7yN/+ceTb//m9peifzdt5/WMDwv3j9vRmtWe7hGpx888XiowyTM3n0zPafPxh8cLvgnZ0 NTAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: DD4DA40017 X-Stat-Signature: dokc4ogq64589io3dmgrw4ccaiixfbwf X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721114362-792430 X-HE-Meta: U2FsdGVkX1+bnYiXXOKGs4s+mYkd+aaIi2W0ZUoupMr0T/9hBlmWKgmpW+OhQpJR7Y29t5tL0izSScRp2hfSCdD7QpfE5NricL13seztOSzoPjAw7ACShoOxirhvBnk0V8Z2mmwPp7j98wijBUjhrU519DowkwZE0xVf5IkR8ZKcmXkUCwpqh+dzzFVs/58gPM6qYlJzbM+Va+IbDF/DaabkRtfzEKPya9QyglX9EYHDf/W90o4VDdZ1XSaQa+/UeFoYFoHblJ0vaF5B4hzteYY1RZIAWGdJepsIQFzktikn6DKH0/2ReRAAKJFThgofMMahtEPNEv7lisuXZumaoQQWoeS/+ey4iwuV0cHS5qohGFKYjo6X6PCfpFwKQNhfoH+47Fc0DH4LrLe6A+PSHP5+xYg3J85s1rXyOlpt2RG08Ilz/qrvyrVn2knvWiwj5zkhr9mhFXE2w1C4i+iCm23DJOkEir1meWmYf2TcwHRYgSdBW+RW79mzN68/UmvhTzCPk8/thpSor1twT58EeRFwOZ89IeQTo8xuRn6OLPpzoX5PhQqL6b9haMWdfWDskkcqPECdoN0nDpQ06PXP/KXVTN9FHTCdIOEqAaGom4mbvvgllL4yaBFx4Yp519qdmHqxVZ5NNuPtVfsrNG9xH6tlj/W77nnNdy2L3qCyn8ho06UCOLFqq+e7+KjSpB6igZGWnES7WaTTVJvaV2tfu3UlEvbnr9TIRfVMwlUnEBZblK9jABiAEN31H2jRkBIQEiks/aU4yiargz41tWq4Z7SDmUogDisTmchBHk4dya3JZmwhPokJVt2Tnr80cXdQHjhRLubEwU2Ns4jribbxEDtb6RWO/qWFG3yFdpFKJ0Xg/Y+hcKSTF0VmxFHL5k/Ym69xyXB+FgHcW37N4siULIPRIk0ZNJbWXVPHmzTaZ+KPlsFNMM3qAi0UnXCtIxpCyVwZOnO/07pPhysvTXS 0qxshcCc LxnJdBbPHPhsXgc7lJdsyxYF540v0mBfrMMzpB70HAHFD4/4XWYQ7fp85gwvCqFINoXsBBu1/e073g9leQJVXmGnmFhkPhb/NviTf3ohmF5V5eVGxGGvvDG9TApRw8kgqVVTYFa/fRVvaaanqIcWG4Kh/VwrJqQctgM0Q6QEqiVT87fSw+WzprLFjBubHMdTYFtFxuNYoMtt1v9+k7CwyEBUS6F4ycCyphqr2sPdQ1LrWS1p7DRzsUT7qZT3VNjn7Jvc1rAmDW8VwFvLjkpCiGXCNGp2+CCXxC53R5Hrnf73wJGomf+LXxfn9VZ7cjf9T0nqHmGBgddHxSKvP0L1Gg4W3zYqDsHMTMltvuIE/ljSXE3UNrNSC3obknuto/rG0FgE8B1zEoPK9pcOh98HH3gsxMCKk3c20P7oa8sMs73rTbSMKxm4fz0+XN7CabdANaZaF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Ensure that rcu read lock is given up before returning. Reported-by: syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com Fixes: ca567df74a28 ("nsfs: add pid translation ioctls") Signed-off-by: Christian Brauner --- I have a few fixes pending I plan to send out asap. --- fs/nsfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/nsfs.c b/fs/nsfs.c index a4a925dce331..97c37a9631e5 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -174,14 +174,14 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, fallthrough; case NS_GET_PID_IN_PIDNS: fallthrough; - case NS_GET_TGID_IN_PIDNS: + case NS_GET_TGID_IN_PIDNS: { if (ns->ops->type != CLONE_NEWPID) return -EINVAL; ret = -ESRCH; pid_ns = container_of(ns, struct pid_namespace, ns); - rcu_read_lock(); + guard(rcu)(); if (ioctl == NS_GET_PID_IN_PIDNS || ioctl == NS_GET_TGID_IN_PIDNS) @@ -208,11 +208,11 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, ret = 0; break; } - rcu_read_unlock(); if (!ret) ret = -ESRCH; break; + } default: ret = -ENOTTY; }