Messages in this thread | | | From | Sven Schnelle <> | Subject | Re: [PATCH 2/2] kfence: only handle kernel mode faults | Date | Fri, 14 May 2021 12:55:01 +0200 |
| |
Marco Elver <elver@google.com> writes:
> On Fri, 14 May 2021 at 11:22, Sven Schnelle <svens@linux.ibm.com> wrote: >> >> Signed-off-by: Sven Schnelle <svens@linux.ibm.com> >> --- >> mm/kfence/core.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/mm/kfence/core.c b/mm/kfence/core.c >> index bc15e3cb71d5..161df492750c 100644 >> --- a/mm/kfence/core.c >> +++ b/mm/kfence/core.c >> @@ -813,6 +813,9 @@ bool kfence_handle_page_fault(unsigned long addr, bool is_write, struct pt_regs >> enum kfence_error_type error_type; >> unsigned long flags; >> >> + if (user_mode(regs)) >> + return false; >> + > > I don't think it's required on all architectures, correct? If so, I > think this should be part of the arch-specific code, i.e. just do "if > (user_mode(regs) && kfence_handle_page_fault(...))" or similar. > Because otherwise we'll wonder in future why we ever needed this, and > e.g. determine it's useless and remove it again. ;-) Either that, or a > comment. But I'd prefer to just keep it in the arch-specific code if > required, because it seems to be the exception rather than the norm.
Ok, that's fine, i add it to our code then.
Thanks Sven
| |