On Tue, Mar 29, 2022 at 1:43 PM <aissur0002@xxxxxxxxx> wrote: > > As for the solution you proposed, I agree with it: definitely the problem > was caused by an incorrect alignment of max_fds. Frankly speaking, I > didn't know that > > sane_fdtable_size() really should never return a value that > > isn't BITS_PER_LONG aligned > because there is no explicit alignment of max_fds value in the code as > I can see. Yeah, I think a lot of it is implicit and historical knowledge. Much of it is basically just part of the whole "all bitmap operations act on arrays of 'unsigned long'". That whole bitmap base type is perhaps not as well known as it should be, but it's one reason why the allocation granularity really *cannot* be a byte - because on big-endian machines, the next bits you need is not "one more byte". So on a 64-bit big-endian machine, the least significant bits are not one byte away, but seven bytes away. Of course, big-endian is fairly rare these days, so your "copy one more byte" would have worked in practice on most machines out there. Which together with "it's hard to hit this situation in the first place" would have made it really hard to notice that it didn't _really_ work. I will apply that ALIGN() thing since Christian could confirm it fixes things, and try to add a few more comments about how bitmaps are fundamentally in chunks of BITS_PER_LONG. Linus