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


Groups > linux.kernel > #1617260

Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of verify_pre_usermode_state

From Thomas Garnier <thgarnie@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of verify_pre_usermode_state
Date 2017-04-05 20:20 +0200
Message-ID <tsXHc-66T-7@gated-at.bofh.it> (permalink)
References <tsAKB-81K-13@gated-at.bofh.it> <tsAKB-81K-11@gated-at.bofh.it> <tsU6B-3Kb-3@gated-at.bofh.it> <tsUgj-3Nd-33@gated-at.bofh.it> <tsXe9-5FW-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Apr 5, 2017 at 10:49 AM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Wed, Apr 05, 2017 at 07:36:17AM -0700, Thomas Garnier wrote:
>> On Wed, Apr 5, 2017 at 7:22 AM, Catalin Marinas <catalin.marinas@arm.com> wrote:
>> > On Tue, Apr 04, 2017 at 10:47:27AM -0700, Thomas Garnier wrote:
>> >> +
>> >>       ldr     x1, [tsk, #TSK_TI_FLAGS]
>> >>       and     x2, x1, #_TIF_WORK_MASK
>> >>       cbnz    x2, work_pending
>> >> @@ -779,6 +788,12 @@ finish_ret_to_user:
>> >>       kernel_exit 0
>> >>  ENDPROC(ret_to_user)
>> >>
>> >> +addr_limit_fail:
>> >> +     stp     x0, lr, [sp,#-16]!
>> >> +     bl      asm_verify_pre_usermode_state
>> >> +     ldp     x0, lr, [sp],#16
>> >> +     ret     lr
>> >
>> > Where is this supposed to return? What is the value of lr when branching
>> > to addr_limit_fail?
>>
>> It is not supposed to return. Do you think I should remove stp, ldp,
>> ret and jut add a brk 0x100 or jmp/call a break/bug function?
>
> Can you not just make addr_limit_fail a C function which never returns
> (similar to what we to with bad_mode() on arm64)? Since addr_limit_fail
> is only called when the segment is not the right one, I don't really see
> why you need another call to asm_verify_pre_usermode_state() to do a
> similar check again. Just panic in addr_limit_fail (unless I
> misunderstood what you are trying to achieve).

Calling asm_verify_pre_usermode_state has the advantage of having a
clear BUG_ON for the error (versus a panic description).

What do you think about replacing asm_verify_pre_usermode_state by a
"address_limit_fail" function that still calls
verify_pre_usermode_state but panic afterwards (because it should
never return)?

The assembly code would be easier to understand and in case of error
the BUG_ON is clear for the user.

>
> --
> Catalin



-- 
Thomas

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


Thread

[PATCH v6 4/4] arm64/syscalls: Specific usage of verify_pre_usermode_state Thomas Garnier <thgarnie@google.com> - 2017-04-04 19:50 +0200
  Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of  verify_pre_usermode_state Catalin Marinas <catalin.marinas@arm.com> - 2017-04-05 16:30 +0200
    Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of verify_pre_usermode_state Thomas Garnier <thgarnie@google.com> - 2017-04-05 16:40 +0200
      Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of  verify_pre_usermode_state Catalin Marinas <catalin.marinas@arm.com> - 2017-04-05 19:50 +0200
        Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of verify_pre_usermode_state Thomas Garnier <thgarnie@google.com> - 2017-04-05 20:20 +0200
          Re: [PATCH v6 4/4] arm64/syscalls: Specific usage of  verify_pre_usermode_state Catalin Marinas <catalin.marinas@arm.com> - 2017-04-07 18:20 +0200

csiph-web