Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp285274pxj; Tue, 18 May 2021 03:25:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPMWtk1qUg6PEyNQKy9NCKCNpCjyTlZ1OAXVCixxXVKTOX8RWJtKnNVGUAfqw9uQU5QAx4 X-Received: by 2002:a92:c26f:: with SMTP id h15mr3498931ild.298.1621333511362; Tue, 18 May 2021 03:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621333511; cv=none; d=google.com; s=arc-20160816; b=lr4ayiHlSzElfS/d3b/XjoEnT3ve6NteV6qZyynfsiRkVpS3i1zc6YQTvoSqioGk5T SDivAPyFAWEugUvJxK0PlFoQYnW+Nxh687HggW8Ly26H6Lb7WMy36a3o/I+Dd0MvbxtJ KEnN/Mbijx1dKvPuZ73zm1uZVTWkzKHbQIY+OJWDdn3lKHUI1BZSwn1P8YEVmn3xfsGB E4V905mnK4Np/LgYXtg2iz8+uk7chgWO3EMLD/M7+NCg3d3GZCja8PIyMf7Xi2up8J4Y 8fMTpG6ugXJWnk/pDt7qtld0b4IeUs1N+jWTQJfVxfk3eEiE4ApO21QVEwcfcEJkvx/D tUVw== 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=BBPOesFVZumsT/Si21WtAnOb6/LecsrBWCb4pcidCU8=; b=HQ+nu5lWzacsRtaGQN0Ctb5vFGYxzqzptkWxLYc37G13xeV4KgJSa2K/3Tqz1kx55Z Ka5H4P0oEUc236PIf4gntMUy74qUYSLwEnAf0cBJA/FSYZ4Dh0CjRFGDXbpiEQ+Rto5c b1wzI0fLR8ywINsg8tXwqhfELmoxNrqpZF5whEz0ZreQbtlFdWhu0RKdI4Q72JSD7RYq BvlmDekr9GmAp80bExiUcdg1gPVL3j+PNesb0kSC4Vv32qzNzp3Ad5Gn0MLvx4sVFwod UpEca0U2WkYr+6E37H5FWPJW67EAjvUVFifyvOMDHBJ3s1It+Cyhf1gRqSfnj7WWydbT uNwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tzRnx5Bj; 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 y6si5778840ilu.153.2021.05.18.03.24.59; Tue, 18 May 2021 03:25:11 -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=tzRnx5Bj; 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 S242791AbhEQPOJ (ORCPT + 99 others); Mon, 17 May 2021 11:14:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:45116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242582AbhEQPD6 (ORCPT ); Mon, 17 May 2021 11:03:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4FFF861A30; Mon, 17 May 2021 14:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261688; bh=tNVJ+LDtBX91Fx5MjoR9ruWpDQ+/PZ5ajZRw+uohgOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tzRnx5BjXYugUpUON18p8stkXP1CqZ4qepLXCiAYogsfCxf02Ur1u7FOs61NlIEvH PdFEniYZY4CK5d8XGFoRcoEgoztm1aGR0a3UYt31EXqPBLlY0kM8ZISF6C4+jUBryB jVbOc5v1HkmtFmfnKHJ3V7zVWVffS6/YoHR3Mgmk= 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.10 052/289] virtiofs: fix userns Date: Mon, 17 May 2021 15:59:37 +0200 Message-Id: <20210517140306.955759648@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 f0a7f1b7b75f..b9cfb1165ff4 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1457,8 +1457,7 @@ static int virtio_fs_get_tree(struct fs_context *fsc) return -ENOMEM; } - 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