From: "Herton R. Krzesinski" <herton@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Manfred Spraul <manfred@colorfullife.com>,
Rafael Aquini <aquini@redhat.com>, Joe Perches <joe@perches.com>,
Aristeu Rozanski <aris@redhat.com>,
djeffery@redhat.com, herton@redhat.com
Subject: [PATCH 2/2] ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()
Date: Tue, 11 Aug 2015 14:19:16 -0300 [thread overview]
Message-ID: <1439313556-13923-3-git-send-email-herton@redhat.com> (raw)
In-Reply-To: <1439313556-13923-1-git-send-email-herton@redhat.com>
After we acquire the sma->sem_perm lock in exit_sem(), we are protected against
a racing IPC_RMID operation. Also at that point, we are the last user of
sem_undo_list. Therefore it isn't required that we acquire or use ulp->lock.
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
---
ipc/sem.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ipc/sem.c b/ipc/sem.c
index 3b8b66b..c4c2911 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -2121,9 +2121,11 @@ void exit_sem(struct task_struct *tsk)
ipc_assert_locked_object(&sma->sem_perm);
list_del(&un->list_id);
- spin_lock(&ulp->lock);
+ /* we are the last process using this ulp, acquiring ulp->lock
+ * isn't required. Besides that, we are also protected against
+ * IPC_RMID as we hold sma->sem_perm lock now
+ */
list_del_rcu(&un->list_proc);
- spin_unlock(&ulp->lock);
/* perform adjustments registered in un */
for (i = 0; i < sma->sem_nsems; i++) {
--
2.4.3
next prev parent reply other threads:[~2015-08-11 17:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 17:19 ipc,sem: fix use after free on IPC_RMID v2 Herton R. Krzesinski
2015-08-11 17:19 ` [PATCH 1/2 v2] ipc,sem: fix use after free on IPC_RMID after a task using same semaphore set exits Herton R. Krzesinski
2015-08-11 18:30 ` Manfred Spraul
2015-08-11 17:19 ` Herton R. Krzesinski [this message]
2015-08-11 18:31 ` [PATCH 2/2] ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem() Manfred Spraul
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=1439313556-13923-3-git-send-email-herton@redhat.com \
--to=herton@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=aquini@redhat.com \
--cc=aris@redhat.com \
--cc=dave@stgolabs.net \
--cc=djeffery@redhat.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
/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
all inboxes | Powered by JetHome®