ext4: don't fail GETFSUUID when the caller provides a long buffer
authorDarrick J. Wong <djwong@kernel.org>
Thu, 10 Nov 2022 20:16:34 +0000 (12:16 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 10:12:01 +0000 (11:12 +0100)
commitb753b0be45ae3eb4a37a6a9efb69a3ba486b81ea
tree37938bee3898d3963f19d76f16134bee08eeb23a
parent13271fbbe85d73a7c47058f56a52f2a7f00d6e39
ext4: don't fail GETFSUUID when the caller provides a long buffer

commit a7e9d977e031fceefe1e7cd69ebd7202d5758b56 upstream.

If userspace provides a longer UUID buffer than is required, we
shouldn't fail the call with EINVAL -- rather, we can fill the caller's
buffer with the bytes we /can/ fill, and update the length field to
reflect what we copied.  This doesn't break the UAPI since we're
enabling a case that currently fails, and so far Ted hasn't released a
version of e2fsprogs that uses the new ext4 ioctl.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Catherine Hoang <catherine.hoang@oracle.com>
Link: https://lore.kernel.org/r/166811139478.327006.13879198441587445544.stgit@magnolia
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ioctl.c