lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 21 Sep 2021 23:17:09 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Vasily Gorbik <gor@...ux.ibm.com>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Jiri Kosina <jikos@...nel.org>,
        Miroslav Benes <mbenes@...e.cz>,
        Petr Mladek <pmladek@...e.com>,
        Joe Lawrence <joe.lawrence@...hat.com>,
        Frederic Weisbecker <fweisbec@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Heiko Carstens <hca@...ux.ibm.com>,
        Sven Schnelle <svens@...ux.ibm.com>,
        Sumanth Korikkar <sumanthk@...ux.ibm.com>,
        live-patching@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] livepatch: Fix idle cpu's tasks transition

On Tue, Sep 21, 2021 at 07:43:16PM +0200, Peter Zijlstra wrote:
> On Wed, Sep 15, 2021 at 04:18:01PM +0200, Vasily Gorbik wrote:
> 
> > diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c
> > index 291b857a6e20..2846a879f2dc 100644
> > --- a/kernel/livepatch/transition.c
> > +++ b/kernel/livepatch/transition.c
> > @@ -278,6 +278,8 @@ static int klp_check_stack(struct task_struct *task, char *err_buf)
> >   * Try to safely switch a task to the target patch state.  If it's currently
> >   * running, or it's sleeping on a to-be-patched or to-be-unpatched function, or
> >   * if the stack is unreliable, return false.
> > + *
> > + * Idle tasks are switched in the main loop when running.
> >   */
> >  static bool klp_try_switch_task(struct task_struct *task)
> >  {
> > @@ -308,6 +310,12 @@ static bool klp_try_switch_task(struct task_struct *task)
> >  	rq = task_rq_lock(task, &flags);
> >  
> >  	if (task_running(rq, task) && task != current) {
> > +		/*
> > +		 * Idle task might stay running for a long time. Switch them
> > +		 * in the main loop.
> > +		 */
> > +		if (is_idle_task(task))
> > +			resched_curr(rq);
> >  		snprintf(err_buf, STACK_ERR_BUF_SIZE,
> >  			 "%s: %s:%d is running\n", __func__, task->comm,
> >  			 task->pid);
> 
> So 'recently' we grew try_invoke_on_locked_down_task() (yes, that's a
> crap name), and I'm thinking this code is very similar to that. So
> perhaps we re-use that.
> 
> Perhaps have func() > 0 imply resched.
> 
> I'll have a play...

https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=sched/livepatch

I'll write proper changelogs and post tomorrow,... (and fix robot fail,
if any).

(also, notes to later self:

 - task_try_func() might need to re-check on_rq after acquiring rq_lock
 - klp_send_signal() might want wake_up_process()/TASK_NORMAL due to TASK_IDLE
)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ