Message ID | 20220405142810.8208-1-dwysocha@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] cachefiles: Fix KASAN slab-out-of-bounds in cachefiles_set_volume_xattr | expand |
Dave Wysochanski <dwysocha@redhat.com> wrote: > - len += sizeof(*buf); > - buf = kmalloc(len, GFP_KERNEL); > + buf = kmalloc(sizeof(*buf) + len, GFP_KERNEL); Okay, your V2 is wrong and your V1 is correct (len must include the reserverd word so that it gets saved onto disk). David
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c index 35465109d9c4..f13b642c1d14 100644 --- a/fs/cachefiles/xattr.c +++ b/fs/cachefiles/xattr.c @@ -198,8 +198,7 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume) _enter("%x,#%d", volume->vcookie->debug_id, len); - len += sizeof(*buf); - buf = kmalloc(len, GFP_KERNEL); + buf = kmalloc(sizeof(*buf) + len, GFP_KERNEL); if (!buf) return false; buf->reserved = cpu_to_be32(0);