Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581243

Re: <Query> Looking more details and reasons for using orig_add_limit.

From Will Deacon <will.deacon@arm.com>
Newsgroups linux.kernel
Subject Re: <Query> Looking more details and reasons for using orig_add_limit.
Date 2017-02-15 12:40 +0100
Message-ID <tb66e-7Lf-29@gated-at.bofh.it> (permalink)
References <tb0Nb-44T-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Feb 14, 2017 at 09:52:30PM -0800, Sodagudi Prasad wrote:
> 
> Hi All,
> 
>  Would like to understand the reasons behind using the orig_add_limit
> variable in the following code. Can you please share more details ?
> 
> "arch/arm64/mm/fault.c"
> static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>                                    struct pt_regs *regs)
> {
> …
> …
> …
>         if (addr < USER_DS && is_permission_fault(esr, regs)) {
> =====>> condition_1
>                 /* regs->orig_addr_limit may be 0 if we entered from EL0 */
>                 if (regs->orig_addr_limit == KERNEL_DS)             	
> =====>> condition_2
>                         die("Accessing user space memory with fs=KERNEL_DS",
> regs, esr);
> 
>                 if (is_el1_instruction_abort(esr))
>                         die("Attempting to execute userspace memory", regs,
> esr);
> 
>                 if (!search_exception_tables(regs->pc))
>                         die("Accessing user space memory outside uaccess.h
> routines", regs, esr);
>         }
> 
> 
> When any sys call is made from user space orig_addr_limit will be zero and
> after that driver is calling set_fs(KERNEL_DS) and  then copy_to_user() to
> user space memory.  If there is permission fault for user space address the
> above condition is leading to kernel crash. Because orig_add_limit is having
> KERNEL_DS as set_fs called before copy_to_user().

Which driver is setting KERNEL_DS prior to accessing userspace and why? It
sounds broken to me. I also don't think it will work with PAN + UAO enabled.

Will

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

<Query> Looking more details and reasons for using orig_add_limit. Sodagudi Prasad <psodagud@codeaurora.org> - 2017-02-15 07:00 +0100
  Re: <Query> Looking more details and reasons for using  orig_add_limit. Will Deacon <will.deacon@arm.com> - 2017-02-15 12:40 +0100
  Re: <Query> Looking more details and reasons for using orig_add_limit. James Morse <james.morse@arm.com> - 2017-02-15 13:20 +0100
    Re: <Query> Looking more details and reasons for using  orig_add_limit. Sodagudi Prasad <psodagud@codeaurora.org> - 2017-02-15 22:20 +0100
      Re: <Query> Looking more details and reasons for using orig_add_limit. James Morse <james.morse@arm.com> - 2017-02-16 11:40 +0100
        Re: <Query> Looking more details and reasons for using  orig_add_limit. Sodagudi Prasad <psodagud@codeaurora.org> - 2017-02-21 15:30 +0100
          Re: <Query> Looking more details and reasons for using  orig_add_limit. Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-02-22 21:00 +0100
          Re: <Query> Looking more details and reasons for using orig_add_limit. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-02-22 21:00 +0100
            Re: <Query> Looking more details and reasons for using  orig_add_limit. Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-02-22 21:40 +0100
              Re: <Query> Looking more details and reasons for using orig_add_limit. Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-02-23 01:30 +0100

csiph-web