From: tglx@linutronix.de (Thomas Gleixner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/9] mm: Hardened usercopy
Date: Thu, 7 Jul 2016 09:42:17 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.11.1607070938430.4083@nanos> (raw)
In-Reply-To: <1467843928-29351-2-git-send-email-keescook@chromium.org>
On Wed, 6 Jul 2016, Kees Cook wrote:
> +
> +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
> + const void *frame = NULL;
> + const void *oldframe;
> +#endif
That's ugly
> +
> + /* Object is not on the stack at all. */
> + if (obj + len <= stack || stackend <= obj)
> + return 0;
> +
> + /*
> + * Reject: object partially overlaps the stack (passing the
> + * the check above means at least one end is within the stack,
> + * so if this check fails, the other end is outside the stack).
> + */
> + if (obj < stack || stackend < obj + len)
> + return -1;
> +
> +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
> + oldframe = __builtin_frame_address(1);
> + if (oldframe)
> + frame = __builtin_frame_address(2);
> + /*
> + * low ----------------------------------------------> high
> + * [saved bp][saved ip][args][local vars][saved bp][saved ip]
> + * ^----------------^
> + * allow copies only within here
> + */
> + while (stack <= frame && frame < stackend) {
> + /*
> + * If obj + len extends past the last frame, this
> + * check won't pass and the next frame will be 0,
> + * causing us to bail out and correctly report
> + * the copy as invalid.
> + */
> + if (obj + len <= frame)
> + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
> + oldframe = frame;
> + frame = *(const void * const *)frame;
> + }
> + return -1;
> +#else
> + return 1;
> +#endif
I'd rather make that a weak function returning 1 which can be replaced by
x86 for CONFIG_FRAME_POINTER=y. That also allows other architectures to
implement their specific frame checks.
Thanks,
tglx
next prev parent reply other threads:[~2016-07-07 7:42 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 22:25 [PATCH 0/9] mm: Hardened usercopy Kees Cook
2016-07-06 22:25 ` [PATCH 1/9] " Kees Cook
2016-07-07 5:37 ` Baruch Siach
2016-07-07 17:25 ` Kees Cook
2016-07-07 18:35 ` Baruch Siach
2016-07-07 7:42 ` Thomas Gleixner [this message]
2016-07-07 17:29 ` Kees Cook
2016-07-07 19:34 ` Thomas Gleixner
2016-07-07 8:01 ` Arnd Bergmann
2016-07-07 17:37 ` Kees Cook
2016-07-08 9:22 ` Arnd Bergmann
2016-07-07 16:19 ` Rik van Riel
2016-07-07 16:35 ` Rik van Riel
2016-07-07 17:41 ` Kees Cook
2016-07-06 22:25 ` [PATCH 2/9] x86/uaccess: Enable hardened usercopy Kees Cook
2016-07-06 22:25 ` [PATCH 3/9] ARM: uaccess: " Kees Cook
2016-07-06 22:25 ` [PATCH 4/9] arm64/uaccess: " Kees Cook
2016-07-07 10:07 ` Mark Rutland
2016-07-07 17:19 ` Kees Cook
2016-07-06 22:25 ` [PATCH 5/9] ia64/uaccess: " Kees Cook
2016-07-06 22:25 ` [PATCH 6/9] powerpc/uaccess: " Kees Cook
2016-07-06 22:25 ` [PATCH 7/9] sparc/uaccess: " Kees Cook
2016-07-06 22:25 ` [PATCH 8/9] mm: SLAB hardened usercopy support Kees Cook
2016-07-06 22:25 ` [PATCH 9/9] mm: SLUB " Kees Cook
2016-07-07 7:30 ` [PATCH 0/9] mm: Hardened usercopy Christian Borntraeger
2016-07-07 17:27 ` Kees Cook
2016-07-08 8:46 ` Ingo Molnar
2016-07-08 16:19 ` Linus Torvalds
2016-07-08 18:23 ` Ingo Molnar
[not found] ` <b113b487-acc6-24b8-d58c-425d3c884f4c@redhat.com>
2016-07-09 2:44 ` Rik van Riel
2016-07-09 7:55 ` Ingo Molnar
2016-07-09 8:25 ` Ard Biesheuvel
2016-07-09 17:03 ` Kees Cook
2016-07-09 17:01 ` Kees Cook
2016-07-09 21:27 ` Andy Lutomirski
2016-07-09 23:16 ` PaX Team
2016-07-10 9:16 ` Ingo Molnar
2016-07-10 12:03 ` PaX Team
2016-07-10 12:38 ` Andy Lutomirski
2016-07-11 18:40 ` Kees Cook
2016-07-11 18:34 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.11.1607070938430.4083@nanos \
--to=tglx@linutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox