stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, "Boyd Yang" <boyd.yang@gmail.com>,
	"Lino Sanfilippo" <LinoSanfilipp@gmx.de>,
	"Eric Paris" <eparis@redhat.com>,
	"Mihai Donțu" <mihai.dontu@gmail.com>
Subject: [ 14/17] fanotify: dont merge permission events
Date: Sun, 29 Sep 2013 12:26:53 -0700	[thread overview]
Message-ID: <20130929190758.113469341@linuxfoundation.org> (raw)
In-Reply-To: <20130929190757.138351117@linuxfoundation.org>

3.0-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lino Sanfilippo <LinoSanfilippo@gmx.de>

commit 03a1cec1f17ac1a6041996b3e40f96b5a2f90e1b upstream.

Boyd Yang reported a problem for the case that multiple threads of the same
thread group are waiting for a reponse for a permission event.
In this case it is possible that some of the threads are never woken up, even
if the response for the event has been received
(see http://marc.info/?l=linux-kernel&m=131822913806350&w=2).

The reason is that we are currently merging permission events if they belong to
the same thread group. But we are not prepared to wake up more than one waiter
for each event. We do

wait_event(group->fanotify_data.access_waitq, event->response ||
			atomic_read(&group->fanotify_data.bypass_perm));
and after that
  event->response = 0;

which is the reason that even if we woke up all waiters for the same event
some of them may see event->response being already set 0 again, then go back to
sleep and block forever.

With this patch we avoid that more than one thread is waiting for a response
by not merging permission events for the same thread group any more.

Reported-by: Boyd Yang <boyd.yang@gmail.com>
Signed-off-by: Lino Sanfilippo <LinoSanfilipp@gmx.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
Cc: Mihai Donțu <mihai.dontu@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/notify/fanotify/fanotify.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -18,6 +18,12 @@ static bool should_merge(struct fsnotify
 	    old->tgid == new->tgid) {
 		switch (old->data_type) {
 		case (FSNOTIFY_EVENT_PATH):
+#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
+			/* dont merge two permission events */
+			if ((old->mask & FAN_ALL_PERM_EVENTS) &&
+			    (new->mask & FAN_ALL_PERM_EVENTS))
+				return false;
+#endif
 			if ((old->path.mnt == new->path.mnt) &&
 			    (old->path.dentry == new->path.dentry))
 				return true;



  parent reply	other threads:[~2013-09-29 19:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-29 19:26 [ 00/17] 3.0.98-stable review Greg Kroah-Hartman
2013-09-29 19:26 ` [ 01/17] Revert "sctp: fix call to SCTP_CMD_PROCESS_SACK in sctp_cmd_interpreter()" Greg Kroah-Hartman
2013-09-29 19:26 ` [ 02/17] net: usb: cdc_ether: Use wwan interface for Telit modules Greg Kroah-Hartman
2013-09-29 19:26 ` [ 03/17] rt2800: fix wrong TX power compensation Greg Kroah-Hartman
2013-09-29 19:26 ` [ 04/17] HID: provide a helper for validating hid reports Greg Kroah-Hartman
2013-09-29 19:26 ` [ 05/17] HID: zeroplus: validate output report details Greg Kroah-Hartman
2013-09-29 19:26 ` [ 06/17] drm/radeon: fix LCD record parsing Greg Kroah-Hartman
2013-09-29 19:26 ` [ 07/17] drm/radeon: update line buffer allocation for dce4.1/5 Greg Kroah-Hartman
2013-09-29 19:26 ` [ 08/17] drm/radeon: fix resume on some rs4xx boards (v2) Greg Kroah-Hartman
2013-09-29 19:26 ` [ 09/17] drm/radeon: fix handling of variable sized arrays for router objects Greg Kroah-Hartman
2013-09-29 19:26 ` [ 10/17] SCSI: iscsi: dont hang in endless loop if no targets present Greg Kroah-Hartman
2013-09-29 19:26 ` [ 11/17] cgroup: fail if monitored file and event_control are in different cgroup Greg Kroah-Hartman
2013-09-29 19:26 ` [ 12/17] perf: Clarify perf_cpu_context::active_pmu usage by renaming it to ::unique_pmu Greg Kroah-Hartman
2013-09-29 19:26 ` [ 13/17] perf: Fix perf_cgroup_switch for sw-events Greg Kroah-Hartman
2013-09-29 19:26 ` Greg Kroah-Hartman [this message]
2013-09-29 19:26 ` [ 15/17] perf tools: Handle JITed code in shared memory Greg Kroah-Hartman
2013-09-29 19:26 ` [ 16/17] sfc: Fix efx_rx_buf_offset() for recycled pages Greg Kroah-Hartman
2013-09-29 19:26 ` [ 17/17] kernel-doc: bugfix - multi-line macros Greg Kroah-Hartman
2013-09-30  1:24 ` [ 00/17] 3.0.98-stable review Guenter Roeck
2013-09-30  1:50   ` Greg Kroah-Hartman
2013-10-01 19:24 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130929190758.113469341@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=LinoSanfilipp@gmx.de \
    --cc=boyd.yang@gmail.com \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mihai.dontu@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).