[LU-15827] BUG: KASAN: slab-out-of-bounds in osd_ldiskfs_filldir+0x16c2/0x1860 [osd_ldiskfs] Created: 26/Apr/22 Updated: 13/May/22 Resolved: 09/May/22 |
|
| Status: | Resolved |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Lustre 2.15.0 |
| Type: | Bug | Priority: | Minor |
| Reporter: | John Hammond | Assignee: | John Hammond |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Severity: | 3 | ||||||||
| Rank (Obsolete): | 9223372036854775807 | ||||||||
| Description |
In osd_ldiskfs_filldir() we check that the buffer has enough space for namelen bytes but we do not account for the possibility that it does not have enough space for presented_len.
if ((void *)ent - it->oie_buf + sizeof(*ent) + namelen >
OSD_IT_EA_BUFSIZE)
RETURN(1);
....
int presented_len = critical_chars(name, namelen);
if (presented_len == namelen)
memcpy(ent->oied_name, name, namelen);
else
namelen = critical_encode(name, namelen,
ent->oied_name);
ent->oied_name[namelen] = '\0'; /* osd_ldiskfs_filldir+0x16c2 */
It also seems like the original check is wrong. It seems to be missing a +1 for the trailing NUL. |
| Comments |
| Comment by John Hammond [ 05/May/22 ] |
|
I have a fix for this. Will push shortly. |
| Comment by Gerrit Updater [ 05/May/22 ] |
|
"John L. Hammond <jhammond@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/47224 |
| Comment by Gerrit Updater [ 09/May/22 ] |
|
"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/47224/ |
| Comment by Peter Jones [ 09/May/22 ] |
|
Landed for 2.15 |