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] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 3 Oct 2014 19:56:54 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	Fengguang Wu <fengguang.wu@...el.com>,
	Jet Chen <jet.chen@...el.com>, Su Tao <tao.su@...el.com>,
	Yuanhan Liu <yuanhan.liu@...el.com>, LKP <lkp@...org>,
	linux-kernel@...r.kernel.org,
	Marcel Holtmann <marcel@...tmann.org>,
	Peter Hurley <peter@...leysoftware.com>
Subject: Re: [rfcomm_run] WARNING: CPU: 1 PID: 79 at
	kernel/sched/core.c:7156 __might_sleep()

On 10/03, Peter Zijlstra wrote:
>
> On Thu, Oct 02, 2014 at 10:10:20PM +0200, Oleg Nesterov wrote:
>
> > As for rfcomm_run(), perhaps it can ise it too?
> >
> > 	set_kthread_wants_signal(true);
> >
> > 	add_wait_queue(&rfcomm_wq, &wait);
> > 	for (;;) {
> > 		// This is only possible if kthread_should_stop() == T
>
> True because kthreads SIG_IGN everything, right?

Yes,

> > 		if (signal_pending(current))
> > 			break;
> >
> > 		rfcomm_process_sessions();
> > 		wait_woken(TASK_INTERRUPTIBLE);
> > 	}
> >
> > Of course, this assumes that rfcomm_process_sessions() can't do something
> > "really bad" if signal_pending() is true.
>
> So from what I can think of, everything that does an INTERRUPTIBLE sleep
> will 'malfunction' after that, right? Which might be quite a lot
> actually.

Yes.

> > What do you think?
>
> Interesting approach, but somewhat risky I tihnk, due to that
> INTERRUPTIBLE thing.

OK, this is fixable.  rfcomm_run() can do

	add_wait_queue(&rfcomm_wq, &wait);
	while (!kthread_should_stop()) {
		rfcomm_process_sessions();

		set_kthread_wants_signal(true);
		wait_woken(TASK_INTERRUPTIBLE);
		set_kthread_wants_signal(false);
	}
	remove_wait_queue(&rfcomm_wq, &wait);

Or. perhaps we can change wait_woken

	-	set_current_state(mode);
	+	if (mode)
	+		set_current_state(mode);


then rfcomm_run() can do

	for (;;) {
		rfcomm_process_sessions();

		set_current_state(TASK_INTERRUPTIBLE);
		if (kthread_should_stop())
			break;
		wait_woken(0);
	}

Or perhaps we can split wait_woken() into 2 helpers,

	static inline long wait_woken(wq, mode, timeout)
	{
		set_current_state(mode);
		schedule_woken(wq, timeout); // does the rest
	}

to avoid "mode == 0" hack; rfcomm_run() should use schedule_woken().

What do you think?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ