Patch "rfkill: fix rfkill_fop_read wait_event usage" has been added to the 3.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
rfkill: fix rfkill_fop_read wait_event usage
to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
rfkill-fix-rfkill_fop_read-wait_event-usage.patch
and it can be found in the queue-3.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
6736fde9672ff6717ac576e9bba2fd5f3dfec822Mon Sep 17 00:00:00 2001
From: Johannes Berg <[email protected]>
Date: Tue, 26 Jan 2016 11:29:03 +0100
Subject: rfkill: fix rfkill_fop_read wait_event usage
From: Johannes Berg <[email protected]>
commit 6736fde9672ff6717ac576e9bba2fd5f3dfec822 upstream.
The code within wait_event_interruptible() is called with !TASK_RUNNING, so mustn't call any functions that can sleep, like mutex_lock().
Since we re-check the list_empty() in a loop after the wait, it's safe to simply use list_empty() without locking.
This bug has existed forever, but was only discovered now because all userspace implementations, including the default 'rfkill' tool, use poll() or select() to get a readable fd before attempting to read.
--- net/rfkill/core.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
net/rfkill/core.c +4 -12
@@ -1078,17 +1078,6 @@ static unsigned int rfkill_fop_poll(strureturn res; } -static bool rfkill_readable (struct rfkill_data *data) -{ -bool r; - -mutex_lock (&data->mtx); - r = !list_empty (&data->events); -mutex_unlock (&data->mtx); - -return r; -} -static ssize_t rfkill_fop_read (struct file *file,char __user *buf,size_t count,loff_t *pos) {
@@ -1105,8 +1094,11 @@ static ssize_t rfkill_fop_read(struct fi goto out; }mutex_unlock (&data->mtx); +/* since we re-check and it just compares pointers, +* using !list_empty() without locking isn't a problem +*/ ret =wait_event_interruptible (data->read_wait, -rfkill_readable (data)); + !list_empty (&data->events));mutex_lock (&data->mtx);if (ret)
Patches currently in stable-queue which might be from [email protected] are
queue-3.14/rfkill-copy-the-name-into-the-rfkill-struct.patch queue-3.14/mac80211-mesh-fix-call_rcu-usage.patch queue-3.14/rfkill-fix-rfkill_fop_read-wait_event-usage.patch