lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 25 Feb 2019 07:53:01 -0800 From: Andy Lutomirski <luto@...capital.net> To: Peter Zijlstra <peterz@...radead.org> Cc: Linus Torvalds <torvalds@...ux-foundation.org>, Thomas Gleixner <tglx@...utronix.de>, "H. Peter Anvin" <hpa@...or.com>, Julien Thierry <julien.thierry@....com>, Will Deacon <will.deacon@....com>, Ingo Molnar <mingo@...nel.org>, Catalin Marinas <catalin.marinas@....com>, James Morse <james.morse@....com>, valentin.schneider@....com, Brian Gerst <brgerst@...il.com>, Josh Poimboeuf <jpoimboe@...hat.com>, Andrew Lutomirski <luto@...nel.org>, Borislav Petkov <bp@...en8.de>, Denys Vlasenko <dvlasenk@...hat.com>, LKML <linux-kernel@...r.kernel.org> Subject: Re: [PATCH 5/6] objtool: Add UACCESS validation On Mon, Feb 25, 2019 at 4:53 AM Peter Zijlstra <peterz@...radead.org> wrote: > > It is important that UACCESS regions are as small as possible; > furthermore the UACCESS state is not scheduled, so doing anything that > might directly call into the scheduler will cause random code to be > ran with UACCESS enabled. > > Teach objtool too track UACCESS state and warn about any CALL made > while UACCESS is enabled. This very much includes the __fentry__() > tracing calls and __preempt_schedule() calls. > > Note that exceptions _do_ save/restore the UACCESS state, and therefore > they can drive preemption. This also means that all exception handlers > must have an otherwise dedundant UACCESS disable instruction; > therefore ignore this warning for !STT_FUNC code (exception handlers > are not normal functions). > > It also provides a UACCESS_SAFE() annotation which allows explicit > annotation. This is meant to be used for future things like: > unsafe_copy_{to,from}_user(). > > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org> > --- > include/linux/frame.h | 30 +++++++++++- > tools/objtool/arch.h | 4 + > tools/objtool/arch/x86/decode.c | 14 +++++ > tools/objtool/check.c | 100 ++++++++++++++++++++++++++++++++++++---- > tools/objtool/check.h | 2 > tools/objtool/elf.h | 1 > 6 files changed, 138 insertions(+), 13 deletions(-) > > --- a/include/linux/frame.h > +++ b/include/linux/frame.h > @@ -28,10 +28,38 @@ asm (".pushsection .discard.nonstd_frame > ".byte 0\n\t" > ".popsection\n\t"); > > +/* > + * This macro marks functions as UACCESS-safe, that is, it is safe to call from an > + * UACCESS enabled region (typically user_access_begin() / > + * user_access_end()). > + * > + * These functions in turn will only call UACCESS-safe functions themselves (which > + * precludes tracing, including __fentry__ and scheduling, including > + * preempt_enable). > + * > + * UACCESS-safe functions will obviously also not change UACCESS themselves. > + */ > +#define UACCESS_SAFE(func) \ > + asm (".pushsection .discard.uaccess_safe_strtab, \"S\", @3\n\t" \ > + "999: .ascii \"" #func "\"\n\t" \ > + " .byte 0\n\t" \ > + ".popsection\n\t" \ > + ".pushsection .discard.uaccess_safe\n\t" \ > + ".long 999b - .\n\t" \ > + ".popsection") Minor nit: using big numbers like 999: like this always bugs me. It relies on there not being a macro nested inside or outside this that uses the same number. My general preference is to do something like .Ldescription_\@ instead. Otherwise this looks conceptually good :)
Powered by blists - more mailing lists