Re: [PATCH] Add build time guard to detect off_t mismatch
Richard Weinberger <[email protected]>
| Newsgroups | dev.linux.lists.xenomai |
|---|---|
| Message-ID | <CAFLxGvzYXjy3kkZMSiOqFbHgWTOaBccg3oBtVDKbyB97fedfGw@mail.gmail.com> |
On Thu, May 7, 2026 at 4:22 PM Jan Kiszka <[email protected]> wrote: > OK, given that Xenomai intercepts the mmap path, we could argue that > this is also stable relevant. > > Can you confirm that this issue is truly gone in next, whatever mode you > choose on both sides? Still had no chance to build or run tests with Xenomai next on my ARM boards. But I had a look at the code. I think it's still broken, at least for the following scenario: - 32 bit application built with _FILE_OFFSET_BITS=64 - 32 bit libcobalt without - application calls mmap() using __RT(mmap), so __cobalt_mmap() in libcobalt - off_t differs in size ass seen by caller and callee On x86 it works by chance because callee reads only the first 4 bytes of the 8 byte off_t. All parameters are on the stack and have 4 byte alignment. On ARM EABI the story is different. The first four parameters are in registers r0 to r3, all others on the stack. 5th parameter, fd, is a 4 byte integer, so the caller needs to add 4 bytes padding to make sure the 6th parameter, off_t, is on an 8 byte alignment boundary since off_t is from the callers point of view 8 bytes. The callee expects off_t being 4 bytes, knows nothing about the padding and reads the uninitialized padding bytes as offset. I don't see how this case is avoided in next. -- Thanks, //richard