Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1459779
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality |
| Date | 2016-08-10 22:10 +0200 |
| Message-ID | <s4HZ8-1pa-35@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <s4lYC-3WM-19@gated-at.bofh.it> <s4HcK-NR-35@gated-at.bofh.it> <s4HcK-NR-37@gated-at.bofh.it> <s4HcK-NR-33@gated-at.bofh.it> <s4HZ8-1pa-37@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Aug 10, 2016 at 12:40 PM, Chris Metcalf <cmetcalf@mellanox.com> wrote:
> On 8/10/2016 3:17 PM, Andy Lutomirski wrote:
>>
>> On Aug 10, 2016 5:30 PM, "Chris Metcalf" <cmetcalf@mellanox.com> wrote:
>>>
>>> On 8/10/2016 3:52 AM, Andy Lutomirski wrote:
>>>>
>>>> On Aug 9, 2016 11:30 PM, "Chris Metcalf" <cmetcalf@mellanox.com> wrote:
>>>> @@ -91,6 +92,15 @@ static long syscall_trace_enter(struct pt_regs *regs)
>>>> if (emulated)
>>>> return -1L;
>>>>
>>>> + /* In isolation mode, we may prevent the syscall from running.
>>>> */
>>>> + if (work & _TIF_TASK_ISOLATION) {
>>>> + if (task_isolation_syscall(regs->orig_ax) == -1) {
>>>> + regs->orig_ax = -1;
>>>> + return 0;
>>>> + }
>>>> + work &= ~_TIF_TASK_ISOLATION;
>>>> + }
>>>> +
>>>> What is this? It's not mentioned in the changelog. It seems
>>>> nonsensical to me. If nothing else, you forgot to update regs->ax,
>>>> but I don't even know what you're trying to do.
>>>
>>>
>>> It's mentioned in the changelog as "Fixes a bug in x86
>>> syscall_trace_enter()
>>> [seen by Francis Giraldeau]." To be fair, I didn't hear back from
>>> Francis, and
>>> you're right, this doesn't look like it makes any sense now. (I've added
>>> him
>>> to the cc's on this email; for this series I had just put him on the
>>> cover letter.)
>>>
>>> I modeled this code on a snippet from the old two-phase syscall entry
>>> work:
>>>
>>> if (ret == SECCOMP_PHASE1_SKIP) {
>>> regs->orig_ax = -1;
>>> ret = 0;
>>> }
>>>
>>> You got rid of this during the 4.7-rc series, but my code above was at
>>> least
>>> plausibly valid until then :-)
>>>
>>> Regardless, I assume that the right thing for that condition to do now
>>> when
>>> it triggers is to set regs->ax = -ENOSYS and return -1L? I'll update the
>>> git repository with that in any case.
>>
>> regs->ax will already be -ENOSYS unless something changed it
>
>
> Right, I see that now in entry_SYSCALL_64_after_swapgs. Good.
>
>> but I'm
>> not sure what this code is trying to do. Is the idea that
>> task_isolation_syscall might enqueue a signal and you want to deliver
>> it without processing the syscall? If so, a comment would be nice.
>> You could even WARN_ON(!signal_pending()).
>
>
> If you are in task isolation mode (and you haven't also requested NOSIG),
> then attempting a system call fails, and you get a signal delivered. You
> convinced me that failing the syscall was the thing to do back here:
>
> https://lkml.kernel.org/r/CALCETrUrc_LJyLJLHefSDYagCrNqqzKuknr6uLgVXnPW8PmZKw@mail.gmail.com
Indeed. Then please add the comment any maybe the WARN_ON.
>
>>>>> #ifdef CONFIG_SECCOMP
>>>>> /*
>>>>> * Do seccomp after ptrace, to catch any tracer changes.
>>>>> @@ -136,7 +146,7 @@ static long syscall_trace_enter(struct pt_regs
>>>>> *regs)
>>>>>
>>>>> #define EXIT_TO_USERMODE_LOOP_FLAGS \
>>>>> (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
>>>>> - _TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY)
>>>>> + _TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY |
>>>>> _TIF_TASK_ISOLATION)
>>>>>
>>>> Where are you updating the conditions to force use of the slow path?
>>>> (That's _TIF_ALLWORK_MASK.)
>>>
>>>
>>> Whenever _TIF_TASK_ISOLATION is set, _TIF_NOHZ is also set.
>>
>> OK, but why not decouple it a bit and add it to the mask? I keep
>> meaning to add a BUILD_BUG_ON checking for bits in
>> EXIT_TO_USERMODE_LOOP_FLAGS that aren't in the appropriate slow path
>> masks.
>
>
> That does seem reasonable; I'll make the change.
>
>
> --
> Chris Metcalf, Mellanox Technologies
> http://www.mellanox.com
>
--
Andy Lutomirski
AMA Capital Management, LLC
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v14 00/14] support "task_isolation" mode Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 06/14] arch/x86: enable task isolation functionality Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality Andy Lutomirski <luto@amacapital.net> - 2016-08-10 21:20 +0200
Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality Andy Lutomirski <luto@amacapital.net> - 2016-08-10 22:10 +0200
Re: [PATCH v14 06/14] arch/x86: enable task isolation functionality Andy Lutomirski <luto@amacapital.net> - 2016-08-10 21:20 +0200
[PATCH v14 10/14] arm, tile: turn off timer tick for oneshot_stopped state Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 02/14] vmstat: add vmstat_idle function Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 08/14] arch/arm64: enable task isolation functionality Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 05/14] task_isolation: track asynchronous interrupts Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 09/14] arch/tile: enable task isolation functionality Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
[PATCH v14 04/14] task_isolation: add initial support Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
Re: [PATCH v14 04/14] task_isolation: add initial support Frederic Weisbecker <fweisbec@gmail.com> - 2016-08-11 20:20 +0200
Re: [PATCH v14 04/14] task_isolation: add initial support Christoph Lameter <cl@linux.com> - 2016-08-11 21:00 +0200
[PATCH v14 07/14] arm64: factor work_pending state machine to C Chris Metcalf <cmetcalf@mellanox.com> - 2016-08-09 22:40 +0200
csiph-web