[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1539530741.146842026@decadent.org.uk>
Date: Sun, 14 Oct 2018 16:25:41 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org,
"Linus Torvalds" <torvalds@...ux-foundation.org>,
"PrasannaKumar Muralidharan" <prasannatsmkumar@...il.com>,
"Davidlohr Bueso" <dbueso@...e.de>,
"Philip Semanchuk" <linux_kernel.20.ick@...mgourmet.com>,
"Herton R. Krzesinski" <herton@...hat.com>,
"Manfred Spraul" <manfred@...orfullife.com>,
"Michael Kerrisk" <mtk.manpages@...il.com>,
"Davidlohr Bueso" <dave@...olabs.net>
Subject: [PATCH 3.16 070/366] ipc/sem: make semctl setting sempid consistent
3.16.60-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <dave@...olabs.net>
commit a5f4db877177d2a3d7ae62a7bac3a5a27e083d7f upstream.
As indicated by bug#112271, Linux sets the sempid value upon semctl, and
not only for semop calls. However, within semctl we only do this for
SETVAL, leaving SETALL without updating the field, and therefore rather
inconsistent behavior when compared to other Unices.
There is really no documentation regarding this and therefore users
should not make assumptions. With this patch, along with updating
semctl.2 manpages, this scenario should become less ambiguous As such,
set sempid on SETALL cmd.
Also update some in-code documentation, specifying where the sempid is
set.
Passes ltp and custom testcase where a child (fork) does SETALL to the
set.
Signed-off-by: Davidlohr Bueso <dbueso@...e.de>
Reported-by: Philip Semanchuk <linux_kernel.20.ick@...mgourmet.com>
Cc: Michael Kerrisk <mtk.manpages@...il.com>
Cc: PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>
Cc: Manfred Spraul <manfred@...orfullife.com>
Cc: Herton R. Krzesinski <herton@...hat.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
ipc/sem.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -92,7 +92,14 @@
/* One semaphore structure for each semaphore in the system. */
struct sem {
int semval; /* current value */
- int sempid; /* pid of last operation */
+ /*
+ * PID of the process that last modified the semaphore. For
+ * Linux, specifically these are:
+ * - semop
+ * - semctl, via SETVAL and SETALL.
+ * - at task exit when performing undo adjustments (see exit_sem).
+ */
+ int sempid;
spinlock_t lock; /* spinlock for fine-grained semtimedop */
struct list_head pending_alter; /* pending single-sop operations */
/* that alter the semaphore */
@@ -1469,8 +1476,10 @@ static int semctl_main(struct ipc_namesp
goto out_unlock;
}
- for (i = 0; i < nsems; i++)
+ for (i = 0; i < nsems; i++) {
sma->sem_base[i].semval = sem_io[i];
+ sma->sem_base[i].sempid = task_tgid_vnr(current);
+ }
ipc_assert_locked_object(&sma->sem_perm);
list_for_each_entry(un, &sma->list_id, list_id) {
Powered by blists - more mailing lists