fs/mount_setattr: always cleanup mount_kattr
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 30 Dec 2021 19:23:09 +0000 (20:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Jan 2022 11:42:39 +0000 (12:42 +0100)
commit47b5d0a7532d39e42a938f81e3904268145c341d
treef52ac4442b9c713adc751bb5e40ebb400c7d5565
parent08eacbd141e2495d2fcdde84358a06c4f95cbb13
fs/mount_setattr: always cleanup mount_kattr

commit 012e332286e2bb9f6ac77d195f17e74b2963d663 upstream.

Make sure that finish_mount_kattr() is called after mount_kattr was
succesfully built in both the success and failure case to prevent
leaking any references we took when we built it.  We returned early if
path lookup failed thereby risking to leak an additional reference we
took when building mount_kattr when an idmapped mount was requested.

Cc: linux-fsdevel@vger.kernel.org
Cc: stable@vger.kernel.org
Fixes: 9caccd41541a ("fs: introduce MOUNT_ATTR_IDMAP")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namespace.c