On Fri, Mar 17, 2023 at 9:51 PM Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > Yeah, I see what it's doing. Yeah, sorry, I saw your later email after sending that one. > Yeah, but clang really should have generated a proper third iteration, > which calls that "out of bounds" case, and then returns, instead fo > falling off the end. > > I do think that on the kernel side, the fix is to just change > > } while (type++ != SIZE_DEFAULT_FFMT); > > to > > } while (++type != SIZE_DEFAULT_FFMT); > > but I would *really* like clang to be fixed to not silently generate > code that does insane things and would be basically impossible to > debug if it ever triggers. Not sure how easy is for them to realize that they should do a 3rd iteration. But perhaps it would be possible that Clang/LLVM does a similar check to objtool and at least emit a warning about similar situations that would help developers diagnose this (since it should have way more information about what happened than objtool). Cheers, Miguel