Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2982245pxj; Mon, 17 May 2021 14:49:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyYYxW/SzChEN5yBZ73my3hE94bPKSTSUuKOXp8DEpAakoV4Rp6pmTbNOw3yQtNRpWeD0i X-Received: by 2002:a05:6e02:1d15:: with SMTP id i21mr1537740ila.2.1621288198175; Mon, 17 May 2021 14:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621288198; cv=none; d=google.com; s=arc-20160816; b=HeFtfV8kC7sFoSdiODgD8RPoq+qniEIxOEwz9FOFSPtKuyOyLO6bsNyOdxL7EEibGr QNWDYnlLmZpEwxvAeD2LpJ0LilBQLSbJDNmgk/N0XCdWQ918D8MUAIH4AxJWJozJk3XF fdjsb9MyUQq0LwqqJqYqmgoWPXL0rVprysvkI2wi7UGeJrtS5Bm/jmgocYuGvn58ugCZ kH/g+DFsNT/j+uAUdPx1zYlb/4ZuODHpRk8JSUrtMN1OmYmsXgNhPEyTC5HF46xlbY6u 8Nm0kfc/0XRmmhgZuaEu3kj29XHX65xGqdLyvn348+FHibCGH3Tjgd85q7TdZ7e54tIc HA0Q== 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=bsasv35ZJWD5oQx5dOe10Tuk0p6xQiT5xYC69r8PV68=; b=PIRIEaBkB9ieBU2PjmME7hUJlcGqTGwbVI6CxtolfiLZCx/gOfidvoalC+2ZfenPxn /2KJxWOgbnxHuE8SF4l2cEV2GiW+GnZrNaQrLIDxshQHj2VjM/dJCpxQ1oxWI4P+AeFD 4HlEV7jS5lsOtItEq92tJdRKjmvGTYnd2vqVPno09XOmjEX5AkfR3qzSF7blh/qJdp6X W1Ih0qvZ3bKPk6sFvjDNfpmvdWj+a/9GqOsS5DQnoiMQ7Plh2/WHS72+MEYRvX4zpX1G 0EFkWrA5ssp25Smb9cZ+7TTNtytgFGvlPKzY+jq5znITPvkzkmADB7iMqDGpR3WDIfGF LYRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ABRjBNaX; 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 s8si20146454ilt.116.2021.05.17.14.49.45; Mon, 17 May 2021 14:49:58 -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=ABRjBNaX; 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 S237973AbhEQOL7 (ORCPT + 99 others); Mon, 17 May 2021 10:11:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:58460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238079AbhEQOJk (ORCPT ); Mon, 17 May 2021 10:09:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D5B0661221; Mon, 17 May 2021 14:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260420; bh=2zX5QNryXuHkHppIJ6sRzAzN6z5+2bkOJWv9MaTigCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ABRjBNaXRE6WSBCrYMYY5narjyqjNQTME7E1YmqGcVNaXuwgehmRVCfuvYggQrZe2 x8FI62VBryo9rOkLLYqoR1EQxXBdu/5rg/pSoNS+I1UnvUxS67x6YsE2iJwC/zuVt7 cK5nqvT3Q1b6kVt4O+5K7Xd/a2ObHsN7HzqQKQQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi , Sasha Levin Subject: [PATCH 5.12 074/363] virtiofs: fix userns Date: Mon, 17 May 2021 15:59:00 +0200 Message-Id: <20210517140305.092320987@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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: Miklos Szeredi [ Upstream commit 0a7419c68a45d2d066b996be5087aa2d07ce80eb ] get_user_ns() is done twice (once in virtio_fs_get_tree() and once in fuse_conn_init()), resulting in a reference leak. Also looks better to use fsc->user_ns (which *should* be the current_user_ns() at this point). Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/fuse/virtio_fs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 1e5affed158e..005209b1cd50 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1437,8 +1437,7 @@ static int virtio_fs_get_tree(struct fs_context *fsc) if (!fm) goto out_err; - fuse_conn_init(fc, fm, get_user_ns(current_user_ns()), - &virtio_fs_fiq_ops, fs); + fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs); fc->release = fuse_free_conn; fc->delete_stale = true; fc->auto_submounts = true; -- 2.30.2