From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16F5979C0 for ; Wed, 30 Nov 2022 18:42:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F953C433D7; Wed, 30 Nov 2022 18:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669833747; bh=vWMEbVvNdHPubew5vTnqpn02m4SxoFtJfnZgLzQzJmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a12OHUVbg/PE5ftegw2sQ4907CdhWSam+vrAaxyPBUILeuY4LjaY7fG/ff26WE2YC Hw0kPt3/slosBHqUkno00OEUAlSPXba3MY+xEaEFdkRZdqBkhvXCxRKrFGkAt/nzXK /w63iniFgXPqZ78xzfpYTWyw17lR9nQFjvZavTqg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Anand Jain , David Sterba Subject: [PATCH 5.15 197/206] btrfs: free btrfs_path before copying fspath to userspace Date: Wed, 30 Nov 2022 19:24:09 +0100 Message-Id: <20221130180538.030923703@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221130180532.974348590@linuxfoundation.org> References: <20221130180532.974348590@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anand Jain commit 8cf96b409d9b3946ece58ced13f92d0f775b0442 upstream. btrfs_ioctl_ino_to_path() frees the search path after the userspace copy from the temp buffer @ipath->fspath. Which potentially can lead to a lock splat warning. Fix this by freeing the path before we copy it to userspace. CC: stable@vger.kernel.org # 4.19+ Signed-off-by: Anand Jain Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/ioctl.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3892,6 +3892,8 @@ static long btrfs_ioctl_ino_to_path(stru ipath->fspath->val[i] = rel_ptr; } + btrfs_free_path(path); + path = NULL; ret = copy_to_user((void __user *)(unsigned long)ipa->fspath, ipath->fspath, size); if (ret) {