ext4: accept non-zero padding bytes in HTree dot/dotdot names - #424
Conversation
|
For this one, I have a use case which is failing to parse a pycache directory where the bytes 0xa-0xb of the dot entry are '/' and 'a' instead of zero. Reading the on-disk format spec, it certainly seems these should be zero, but even the kernel code (ref) itself only checks the So perhaps it is ok to only be as strict as the kernel here. |
|
A review bot recommended 96d6229 to me. Pushed here as separate commit while I have the hood open. |
parseDirectoryTreeRoot validated the full 4-byte name fields of the "." and ".." directory entries against ['.', 0, 0, 0] / ['.', '.', 0, 0]. The ext4 spec only guarantees that the first name_len bytes are meaningful; the trailing padding bytes may be non-zero and the Linux kernel does not check them. The strict check broke ReadDir on any HTree-indexed directory whose block happened to contain non-zero padding, e.g. a large __pycache__ directory where bytes 0xa–0xb of the dot entry were observed as '/' (0x2f) and 'a' (0x61). Fix both checks to compare only the first name_len bytes and remove the now-unused bytes import. Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
96d6229 to
f7331b3
Compare
deitch
left a comment
There was a problem hiding this comment.
This one really is funny. But if the kernel is not strict about it, no reason we should be.
|
You're a Docker and containerd maintainer? We probably have lots of common friends. I will pop you a LinkedIn, we can say hello. |
parseDirectoryTreeRoot validated the full 4-byte name fields of the "." and ".." directory entries against ['.', 0, 0, 0] / ['.', '.', 0, 0]. The ext4 spec only guarantees that the first name_len bytes are meaningful; the trailing padding bytes may be non-zero and the Linux kernel does not check them.
The strict check broke ReadDir on any HTree-indexed directory whose block happened to contain non-zero padding, e.g. a large pycache directory where bytes 0xa–0xb of the dot entry were observed as '/' (0x2f) and 'a' (0x61).
Fix both checks to compare only the first name_len bytes and remove the now-unused bytes import.