Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1576707

RE: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack overflow with CONFIG_KASAN

From David Laight <David.Laight@ACULAB.COM>
Newsgroups linux.kernel
Subject RE: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack overflow with CONFIG_KASAN
Date 2017-02-08 17:50 +0100
Message-ID <t8DBn-2Hv-9@gated-at.bofh.it> (permalink)
References <t6P3X-47k-5@gated-at.bofh.it> <t7UXD-7LS-11@gated-at.bofh.it> <t8zeq-a8-25@gated-at.bofh.it> <t8A0P-rN-39@gated-at.bofh.it> <t8A0P-rN-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> From: Johannes Berg
> Sent: 08 February 2017 12:24
...
> Btw, what's causing this to start with? Can't the compiler reuse the
> stack places?

Only if it realises they've gone out of scope - which probably
doesn't happen when the functions are inlined.
The address of the parameter can be saved by the calling function
and used in a later call.

Something like this is valid:

int foo(int *p, int v)
{
	static int *sv;
	int old = -1;
	if (sv) {old = *sv; *sv = v;}
	sv = v;
	return old;
}

void bar(...) {
	int a, b;
	...
	foo(&a, 0);
	...
	foo(&b, 1);
	...
	foo(NULL, 2);
	...

If the compiler starts sharing stack it all goes wrong.

	David


Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] [net-next?] hns: avoid stack overflow with CONFIG_KASAN Arnd Bergmann <arnd@arndb.de> - 2017-02-03 17:40 +0100
  Re: [PATCH] [net-next?] hns: avoid stack overflow with CONFIG_KASAN David Miller <davem@davemloft.net> - 2017-02-06 18:10 +0100
    KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack overflow with CONFIG_KASAN Arnd Bergmann <arnd@arndb.de> - 2017-02-08 13:10 +0100
      Re: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack  overflow with CONFIG_KASAN Johannes Berg <johannes@sipsolutions.net> - 2017-02-08 14:00 +0100
        Re: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack overflow  with CONFIG_KASAN Arnd Bergmann <arnd@arndb.de> - 2017-02-08 14:20 +0100
          Re: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack overflow  with CONFIG_KASAN Andrey Ryabinin <ryabinin.a.a@gmail.com> - 2017-02-08 16:30 +0100
        RE: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack  overflow with CONFIG_KASAN David Laight <David.Laight@ACULAB.COM> - 2017-02-08 17:50 +0100
      Re: KASAN+netlink, was: [PATCH] [net-next?] hns: avoid stack  overflow with CONFIG_KASAN David Miller <davem@davemloft.net> - 2017-02-08 17:40 +0100

csiph-web