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]
Message-ID: <4F612706.4060407@codeaurora.org>
Date:	Wed, 14 Mar 2012 16:17:26 -0700
From:	Stephen Boyd <sboyd@...eaurora.org>
To:	"Rafael J. Wysocki" <rjw@...k.pl>
CC:	Saravana Kannan <skannan@...eaurora.org>,
	Kay Sievers <kay.sievers@...y.org>,
	Greg KH <gregkh@...uxfoundation.org>,
	Christian Lamparter <chunkeey@...glemail.com>,
	linux-kernel@...r.kernel.org,
	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>,
	alan@...rguk.ukuu.org.uk,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Linux PM mailing list <linux-pm@...r.kernel.org>
Subject: Re: [PATCH] firmware loader: don't cancel _nowait requests when helper
 is not yet available

On 03/14/12 16:13, Rafael J. Wysocki wrote:
> On Thursday, March 15, 2012, Rafael J. Wysocki wrote:
>> On Wednesday, March 14, 2012, Stephen Boyd wrote:
>>> On 03/13/12 13:14, Rafael J. Wysocki wrote:
>>>> All of those use cases are in fact of the "wait for user space to be thawed
>>>> and then load the firmware" type, which I believe may be handled without
>>>> changing that code.
>>>>
>>>> Why don't you make your kthread freezable, for one example?
>>>>
>>>> Why don't you use a freezable workqueue instead?
>>>>
>>> If we put it on the freezable workqueue or make it a freezable thread
>>> will it work?
>> That depends on what exactly you want to achieve, which isn't entirely clear
>> to me at this point.
>>
>>> In my scenario a wakeup interrupt comes in that wakes us up from
>>> suspend. Within that wakeup handler a work item is scheduled to the
>>> freezable workqueue. That work item then calls request_firmware().
>> That should work.
>>
>>> It looks like we call schedule() after thawing the workqueues and tasks
>>> so the work item could run before usermodehelpers are enabled and then
>>> request_firmware() would fail. Do we need something like this (ignore
>>> the fact that we call usermodhelper_enable() twice)?
>>>
>>> diff --git a/kernel/power/process.c b/kernel/power/process.c
>>> index 7e42645..61bfa95 100644
>>> --- a/kernel/power/process.c
>>> +++ b/kernel/power/process.c
>>> @@ -187,6 +187,7 @@ void thaw_processes(void)
>>>         } while_each_thread(g, p);
>>>         read_unlock(&tasklist_lock);
>>>  
>>> +       usermodehelper_enable();
>> That would be a reasonable change.
>>
>>>         schedule();
>>>         printk("done.\n");
>>>  }
>>>
>>>
>>> Is there a reason we disable usermodehelpers if
>>> CONFIG_SUSPEND_FREEZER=n?
>> Not really, but CONFIG_SUSPEND_FREEZER=n can only work reliably in a
>> very limited set of cases, so I don't think it's even worth making the
>> general code depend on it.
>>
>> I'd actually prefer to remove CONFIG_SUSPEND_FREEZER altogether,
>> because it's not very useful nowadays (probably isn't useful at all).
>>
>>> Should we do this instead so that
>>> usermodehelpers are only disabled if we freeze userspace? Also what is
>>> that schedule() call in thaw_kernel_threads() for? It looks like we'll
>>> call schedule between kernel thread thawing and userspace thawing.
>> Which is OK, I think.
> Moreover, thaw_kernel_threads() is _only_ called by (a) freeze_kernel_threads()
> on error and (b) user-space hibernate interface in kernel/power/user.c
> (and please read the comment in there describing what it's there for, which
> also explains why the schedule() call in there is necessary).

Exactly. So in case (a) when the error occurs we'll have this call flow:

usermodehelpers_disable()
suspend_freeze_processes()
    freeze_processes()
    freeze_kernel_threads()
        try_to_freeze_tasks() <-- returns error
        thaw_kernel_threads()
            schedule()
    thaw_processes()
usermodehelpers_enable()

Shouldn't we schedule only after we thaw all processes (not just tasks)?
Otherwise we may run a kernel thread before userspace is thawed?

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
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