From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f197.google.com (mail-io0-f197.google.com [209.85.223.197]) by kanga.kvack.org (Postfix) with ESMTP id EB4D76B0008 for ; Tue, 27 Mar 2018 09:03:27 -0400 (EDT) Received: by mail-io0-f197.google.com with SMTP id r69so12607390ioe.20 for ; Tue, 27 Mar 2018 06:03:27 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j64sor451930iof.281.2018.03.27.06.03.23 for (Google Transport Security); Tue, 27 Mar 2018 06:03:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20180326093241.lba7k4pdjskr4gsv@lakrids.cambridge.arm.com> References: <20180305145111.bbycnzpgzkir2dz4@lakrids.cambridge.arm.com> <20180326093241.lba7k4pdjskr4gsv@lakrids.cambridge.arm.com> From: Andrey Konovalov Date: Tue, 27 Mar 2018 15:03:21 +0200 Message-ID: Subject: Re: [RFC PATCH 11/14] khwasan: add brk handler for inline instrumentation Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Mark Rutland Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Jonathan Corbet , Catalin Marinas , Will Deacon , Theodore Ts'o , Jan Kara , Christopher Li , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Masahiro Yamada , Michal Marek , Ard Biesheuvel , Yury Norov , Nick Desaulniers , Marc Zyngier , Suzuki K Poulose , Kristina Martsenko , Punit Agrawal , Dave Martin , James Morse , Julien Thierry , Michael Weiser , Steve Capper , Ingo Molnar , Thomas Gleixner , Sandipan Das , Paul Lawrence , David Woodhouse , Kees Cook , Geert Uytterhoeven , Josh Poimboeuf , Arnd Bergmann , kasan-dev , linux-doc@vger.kernel.org, LKML , Linux ARM , linux-ext4@vger.kernel.org, linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Kees Cook , Jann Horn , Mark Brand On Mon, Mar 26, 2018 at 11:36 AM, Mark Rutland wrote: > On Fri, Mar 23, 2018 at 04:59:36PM +0100, Andrey Konovalov wrote: >> I saw BUG handler using this (which also inserts a brk), so I used it >> as well. > > Ah; I think that's broken today. > >> What should I do instead to jump over the faulting brk instruction? > > I don't think we have anything to do this properly today. > > The simplest fix would be to split arm64_skip_faulting_instruction() > into separate functions for user/kernel, something like the below. OK, will do that! > > It would be nice to drop _user_ in the name of the userspace-specific > helper, though. I'm not familiar with the code, but having "user" in a userspace-specific function name sounds logical :) I think I'm not going to include this change, and it probably needs to be done in a separate patch/patchset anyway. > > Thanks > Mark. > > ---->8---- > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index eb2d15147e8d..101e3d4ed6c8 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -235,9 +235,14 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, > } > } > > -void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) > +void __arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) > { > regs->pc += size; > +} > + > +void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size) > +{ > + __arm64_skip_faulting_instruction(regs, size); > > /* > * If we were single stepping, we want to get the step exception after > @@ -761,7 +766,7 @@ static int bug_handler(struct pt_regs *regs, unsigned int esr) > } > > /* If thread survives, skip over the BUG instruction and continue: */ > - arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE); > + __arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE); > return DBG_HOOK_HANDLED; > } > >