Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1468033
| From | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder |
| Date | 2016-08-22 22:40 +0200 |
| Message-ID | <s94aJ-2HA-7@gated-at.bofh.it> (permalink) |
| References | <s7vf3-dJ-11@gated-at.bofh.it> <s7vf4-dJ-23@gated-at.bofh.it> <s7WIh-Ez-5@gated-at.bofh.it> <s7ZZw-2CM-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Aug 19, 2016 at 04:55:22PM -0500, Josh Poimboeuf wrote: > On Fri, Aug 19, 2016 at 11:27:18AM -0700, Kees Cook wrote: > > On Thu, Aug 18, 2016 at 6:06 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote: > > > Convert arch_within_stack_frames() to use the new unwinder. > > > > > > This also changes some existing behavior: > > > > > > - Skip checking of pt_regs frames. > > > - Warn if it can't reach the grandparent's stack frame. > > > - Warn if it doesn't unwind to the end of the stack. > > > > > > Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> > > > > All the stuff touching usercopy looks good to me. One question, > > though, in looking through the unwinder. It seems like it's much more > > complex than just the frame-hopping that the old > > arch_within_stack_frames() did, but I'm curious to hear what you think > > about its performance. We'll be calling this with every usercopy that > > touches the stack, so I'd like to be able to estimate the performance > > impact of this replacement... > > Yeah, good point. I'll take some measurements from before and after and > get back to you. I took some before/after measurements by enclosing the affected functions with ktime calls to get the total time spent in each function, and did a "find /usr >/dev/null" to trigger a bunch of user copies. copy_to/from_user check_object_size arch_within_stack_frames before: 13ms 6.8ms 0.61ms after: 17ms 11ms 4.6ms The unwinder port made arch_within_stack_frames() *much* (8x) slower than its current simple implementation, and added about 30% (4ms) to the total copy_to/from_user() run time. Note that hardened usercopy itself is already quite slow: it made user copies about 52% slower. With the unwinder port, that worsened to ~65%. "find /usr" took about 170ms of kernel time and 2.3s total. So the unwinder port added about 2% on the kernel side and 0.2% total for this particular test case. Though I'm sure there are more I/O-intensive workloads out there which would be more adversely affected. I haven't yet looked to see where the bottlenecks are and if there could be any obvious performance improvements. BTW, ignoring the performance issues, using the unwinder here would have some benefits: - It protects pt_regs frames from being changed. For example, during a page fault operation, the saved regs->ip on the stack is protected. - Unlike the existing code, it could potentially work with __copy_from_user_inatomic() and copy_from_user_nmi(), which can copy to/from an irq/exception stack. (I think check_stack_object() would need to be rewritten a bit so that it doesn't always assume the task stack.) - It complains loudly if there's stack corruption or something else goes wrong with walking the stack instead of just silently failing. - The same code could also work with DWARF if we ever add a DWARF unwinder (with a possible tweak to the unwinder API to get the stack frame header size). -- Josh
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-18 15:10 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Kees Cook <keescook@chromium.org> - 2016-08-19 20:30 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-20 00:00 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-22 22:40 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 01:40 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Kees Cook <keescook@chromium.org> - 2016-08-23 03:00 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 06:30 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Linus Torvalds <torvalds@linux-foundation.org> - 2016-08-23 00:20 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Kees Cook <keescook@chromium.org> - 2016-08-23 03:30 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 18:40 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Linus Torvalds <torvalds@linux-foundation.org> - 2016-08-24 01:20 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 18:10 +0200
[PATCH 2/2] mm/usercopy: enable usercopy size checking for modern versions of gcc Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 21:30 +0200
Re: [PATCH 2/2] mm/usercopy: enable usercopy size checking for modern versions of gcc Kees Cook <keescook@chromium.org> - 2016-08-24 05:50 +0200
[PATCH 1/2] mm/usercopy: get rid of "provably correct" warnings Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 21:30 +0200
Re: [PATCH 1/2] mm/usercopy: get rid of "provably correct" warnings Kees Cook <keescook@chromium.org> - 2016-08-24 04:40 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Andy Lutomirski <luto@kernel.org> - 2016-08-23 22:50 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Linus Torvalds <torvalds@linux-foundation.org> - 2016-08-23 23:10 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Josh Poimboeuf <jpoimboe@redhat.com> - 2016-08-23 23:20 +0200
Re: [PATCH v4 54/57] x86/mm: convert arch_within_stack_frames() to use the new unwinder Kees Cook <keescook@chromium.org> - 2016-08-24 03:50 +0200
csiph-web