Re: [PATCH] Kconfig.debug: disable CONFIG_FRAME_WARN for KASAN_STACK && CC_IS_CLANG by default

From: Arnd Bergmann
Date: Sat Apr 29 2023 - 18:04:22 EST


On Fri, Apr 21, 2023, at 17:28, Arnd Bergmann wrote:
> On Fri, Apr 21, 2023, at 17:10, Tudor Ambarus wrote:
>> On 4/21/23 15:30, Arnd Bergmann wrote:
>
> The main problem with stack frame usage is that the compiler cannot know
> during compile time what the other functions are going to use, so it's
> always a bit of guesswork, and we just try to make the limit as small
> as possible without causing too much work addressing the warnings.

Hi Tudor,

One follow-up here regarding the risk of actually overflowing the
stack on production systems: There is a possible feature that I've
discussed with Ard in the past, if we add a user-configurable stack offset
for syscall entry, it becomes possible to test kernels with an
artificially low stack size to find out the most critical call chain
that one can hit from user space.

You mentioned elsewhere that you are using syzkaller for testing for bugs,
and this would be the perfect way to exercise the modified kernels as
well, since it can hit all kinds of unusual call chains.

We already call add_random_kstack_offset() on four architectures (arm64,
powerpc, s390 and x86), and the same location could add a fixed offset
that is configurable e.g. system-wide using sysctl() or per task using
prctl(), depending on what makes this more useful for testing.

When CONFIG_VMAP_STACK is set, the result should be a process crash
with a full call chain printed to see how it got this bad, similar to
what you get with a KASAN violation. This probably makes most sense
with KASAN_STACK disabled to see which functions are the most critical
in real systems, though testing with KASAN_STACK enabled could also
give some hints at which of the warnings you see are worth fixing first.

If you would like to run tests with this, I might be able to come
up with a prototype patch for it.

Arnd