On Tue, Sep 14, 2021 at 10:32 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote: > > On Mon, Sep 13, 2021 at 11:05:02PM +0200, Rasmus Villemoes wrote: > > So, I'd sleep a little better if we got the 64 bit tests commented back > > in in test_overflow.c, and [assuming that the above would actually make > > that file build with gcc 4.9] that patch also backported to 5.10, so we > > had some confidence that the whole house of cards is actually solid. > > Yeah, I'm all for that too. Hmm. Another thing that might be worth doing is to just say "don't do that". IOW, don't do silly overflow checks with 64-bit things on 32-bit architectures. Apparently the first and only use case of this is the ndb code, and the fact is, that ndb code is just being truly horrendously stupid. That 'blksize' thing shouldn't be a blocksize, it should be a blockshift instead. The code to set blksize already expressly verifies that it's a power-of-2, and less or equial to PAGE_SIZE so this: loff_t blksize; is just plain silly. Doubly silly. Why is it a 'loff_t'? It should never have been a loff_t in the first place, and honestly, it really should have been a shift count that fits in a few bits. All this pain could have been trivially avoided with just people writing better code, knowing that multiplies and divides are expensive, and that shift counts are small and cheap. Linus