new_inode_autonum: intro -- ensure uniqueness of i_ino and try to prevent st_ino EOVERFLOW in userspace
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | new_inode_autonum: add per-sb lastino counter and add new_inode_autonum function that guarantees i_ino uniquenessfs/ include/ | +50 | 2 replies | |
| 2/3 | new_inode_autonum: convert filesystems to use new functionarch/ arch/ arch/ +26 more | +34 | 1 reply | |
| 3/3 | new_inode_autonum: fix up possible i_ino collision in simple_fill_super()fs/ | +4 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Joern Engel |
|---|---|
| 1/3 | A-b |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/3] new_inode_autonum: intro -- ensure uniqueness of i_ino and try to prevent st_ino EOVERFLOW in userspace
This started as a rather simple problem. glibc uses fstat64() internally when making a stat() call. If the st_ino field returned by this call does not fit in the buffer allocated by the program, glibc (rightly) generates an EOVERFLOW in userspace. This is generally only a problem when the program is compiled without -D_FILE_OFFSET_BITS=64.
The kernel declares ino_t to be an unsigned long which is generally 32-bits on 32-bit kernels and 64-bits on 64-bit kernels. The new_inode function has a static unsigned long counter that it uses to assign out i_ino values.
On a 64-bit kernel, the value in this counter eventually becomes too large to fit in 32-bits, and glibc starts throwing EOVERFLOW errors to programs compiled without large file offsets. This creates a situation where such a program will work fine on a 32-bit kernel, but when run on a 64-bit kernel it will eventually start falling down.
We can't do much about this on filesystems that have true 64-bit inodes, but on filesystems that get "pseudo_inode" values via new_inode or iunique, we should attempt to make them fit in a 32-bit value.
While fixing this, we discovered that many filesystems seem to blindly accept the i_ino value given by new_inode. new_inode makes no actual check to see if an i_ino value is unique, so once the counter overflows you can end up with more than one inode with the same i_ino value.
The following set of patches should remedy both of these problems. While these are arguably security-related, these patches are probably better suited to 2.6.20 than anything earlier.
-- Jeff