mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
ksmbd: zero pipe read compound padding
Compound response handling extends the last response iov to an eight-byte
boundary.
smb2_read_pipe() allocates only the payload size, so the alignment padding
can expose up to seven bytes of uninitialized kernel heap memory.
Allocate the aligned size and clear the unused tail before pinning the
response buffer.
Fixes: e2b76ab8b5 ("ksmbd: add support for read compound")
Reported-by: Cheryl Babcock <cheryl@renat.io>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
parent
d12168084c
commit
73f860489e
|
|
@ -8657,13 +8657,18 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
|
|||
}
|
||||
|
||||
aux_payload_buf =
|
||||
kvmalloc(rpc_resp->payload_sz, KSMBD_DEFAULT_GFP);
|
||||
kvmalloc(ALIGN(rpc_resp->payload_sz, 8),
|
||||
KSMBD_DEFAULT_GFP);
|
||||
if (!aux_payload_buf) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(aux_payload_buf, rpc_resp->payload, rpc_resp->payload_sz);
|
||||
if (rpc_resp->payload_sz & 7)
|
||||
memset(aux_payload_buf + rpc_resp->payload_sz, 0,
|
||||
ALIGN(rpc_resp->payload_sz, 8) -
|
||||
rpc_resp->payload_sz);
|
||||
|
||||
nbytes = rpc_resp->payload_sz;
|
||||
err = ksmbd_iov_pin_rsp_read(work, (void *)rsp,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user