-
Improvement
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
linkea_init() (lustre/obdclass/linkea.c) checks the LINK_EA_MAGIC and leh_reccount/leh_overflow_time, but never checks the on-disk leh_len header field against ld_buf->lb_len, the actual byte count __mdd_links_read() (lustre/mdd/mdd_dir.c) read for the xattr. linkea_next_entry() (lustre/include/lustre_linkea.h) then uses leh_len alone to bound iteration.
If leh_len on disk were ever larger than the real buffer (corruption, not reachable from any known race in normal operation), every ordinary consumer of a file's linkEA – rename, unlink, fid2path, not only LFSCK – would iterate past the allocated buffer rather than stopping, before LFSCK gets a chance to repair the corruption.
Suggested fix: in linkea_init(), reject leh_len > ld_buf->lb_len (and less than sizeof(struct link_ea_header)) alongside the existing magic/reccount checks.
Not a live bug in any current code path found – both write-side helpers (linkea_add_buf, linkea_overflow_shrink) maintain leh_len consistent with the buffer by construction, and trusted.link is not writable by an unprivileged client. Filed as a defensive hardening gap: the read path should not trust the length field for the LFSCK-repair case it exists to guard against.