linux/net/9p
Tyler Hicks aa7aeee169 net/9p: Initialize the iounit field during fid creation
Ensure that the fid's iounit field is set to zero when a new fid is
created. Certain 9P operations, such as OPEN and CREATE, allow the
server to reply with an iounit size which the client code assigns to the
p9_fid struct shortly after the fid is created by p9_fid_create(). On
the other hand, an XATTRWALK operation doesn't allow for the server to
specify an iounit value. The iounit field of the newly allocated p9_fid
struct remained uninitialized in that case. Depending on allocation
patterns, the iounit value could have been something reasonable that was
carried over from previously freed fids or, in the worst case, could
have been arbitrary values from non-fid related usages of the memory
location.

The bug was detected in the Windows Subsystem for Linux 2 (WSL2) kernel
after the uninitialized iounit field resulted in the typical sequence of
two getxattr(2) syscalls, one to get the size of an xattr and another
after allocating a sufficiently sized buffer to fit the xattr value, to
hit an unexpected ERANGE error in the second call to getxattr(2). An
uninitialized iounit field would sometimes force rsize to be smaller
than the xattr value size in p9_client_read_once() and the 9P server in
WSL refused to chunk up the READ on the attr_fid and, instead, returned
ERANGE to the client. The virtfs server in QEMU seems happy to chunk up
the READ and this problem goes undetected there.

Link: https://lkml.kernel.org/r/20220710141402.803295-1-tyhicks@linux.microsoft.com
Fixes: ebf46264a0 ("fs/9p: Add support user. xattr")
Cc: stable@vger.kernel.org
Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
2022-07-16 07:16:55 +09:00
..
client.c net/9p: Initialize the iounit field during fid creation 2022-07-16 07:16:55 +09:00
error.c 9p: fix a bunch of checkpatch warnings 2021-11-04 21:04:25 +09:00
Kconfig 9p/trans_fd: split into dedicated module 2022-01-10 09:58:30 +09:00
Makefile 9p/trans_fd: split into dedicated module 2022-01-10 09:58:30 +09:00
mod.c net/p9: load default transports 2022-01-10 10:00:09 +09:00
protocol.c 9p: fix a bunch of checkpatch warnings 2021-11-04 21:04:25 +09:00
protocol.h 9p: fix a bunch of checkpatch warnings 2021-11-04 21:04:25 +09:00
trans_common.c 9p: fix file headers 2021-11-03 17:45:04 +09:00
trans_common.h 9p: fix a bunch of checkpatch warnings 2021-11-04 21:04:25 +09:00
trans_fd.c net: 9p: fix refcount leak in p9_read_work() error handling 2022-07-15 20:22:21 +09:00
trans_rdma.c 9p: Add client parameter to p9_req_put() 2022-07-09 14:38:35 +09:00
trans_virtio.c 9p: Add client parameter to p9_req_put() 2022-07-09 14:38:35 +09:00
trans_xen.c 9p: Add client parameter to p9_req_put() 2022-07-09 14:38:35 +09:00