mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
vhost/net: fix clear_user start address in VHOST_GET_FEATURES_ARRAY
The clear_user() call in VHOST_GET_FEATURES_ARRAY incorrectly starts
at argp, which is the beginning of the features array, overwriting the
data just written by copy_to_user(). It should start after the copied
elements at argp + copied * sizeof(u64) to only zero the trailing
unused space.
Use size_mul() for both the offset and length calculations so the
arithmetic stays consistent with the surrounding code and remains
overflow-safe.
Fixes: 333c515d18 ("vhost-net: allow configuring extended features")
Signed-off-by: Yufeng Wang <wangyufeng@kylinos.cn>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260626070438.59149-1-r4o5m6e8o@163.com>
This commit is contained in:
parent
d62fb5cc8a
commit
92a7b138f2
|
|
@ -1777,7 +1777,8 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
|
|||
return -EFAULT;
|
||||
|
||||
/* Zero the trailing space provided by user-space, if any */
|
||||
if (clear_user(argp, size_mul(count - copied, sizeof(u64))))
|
||||
if (clear_user(argp + size_mul(copied, sizeof(u64)),
|
||||
size_mul(count - copied, sizeof(u64))))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
case VHOST_SET_FEATURES_ARRAY:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user