All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	manfred <manfred@colorfullife.com>,
	Peter Zijlstra <peterz@infradead.org>,
	fabf@skynet.be, kernel@kyup.com,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller <syzkaller@googlegroups.com>
Subject: Re: ipc: BUG: sem_unlock unlocks non-locked lock
Date: Sun, 18 Dec 2016 08:28:38 -0800	[thread overview]
Message-ID: <20161218162838.GA24788@linux-80c1.suse> (raw)
In-Reply-To: <CACT4Y+a-MavOOisxqLpQqoje5YthZLtKeg0yqe7UnhVPuO4Pag@mail.gmail.com>

On Fri, 16 Dec 2016, Dmitry Vyukov wrote:

>[ BUG: bad unlock balance detected! ]
>4.9.0+ #89 Not tainted

Thanks for the report, I can reproduce the issue as of (which I obviously
should have tested with lockdep):

370b262c896 (ipc/sem: avoid idr tree lookup for interrupted semop)

I need to think more about it this evening, but I believe the issue to be
the potentially bogus locknum in the unlock path, as we are calling sem_lock
without updating the variable. I'll send a patch after more testing. This
fixes it for me:

diff --git a/ipc/sem.c b/ipc/sem.c
index e08b94851922..fba6139e7208 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1977,7 +1977,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
 		}
 
 		rcu_read_lock();
-		sem_lock(sma, sops, nsops);
+	        sem_lock(sma, sops, nsops);
 
 		if (!ipc_valid_object(&sma->sem_perm))
 			goto out_unlock_free;

Thanks,
Davidlohr

  reply	other threads:[~2016-12-18 16:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16  9:33 ipc: BUG: sem_unlock unlocks non-locked lock Dmitry Vyukov
2016-12-18 16:28 ` Davidlohr Bueso [this message]
2016-12-18 16:29   ` Davidlohr Bueso
2016-12-18 18:32     ` Manfred Spraul
2016-12-18 18:38       ` [PATCH] ipc/sem.c: fix semop()/semop() locking failure Manfred Spraul
2016-12-19  3:45         ` Davidlohr Bueso
2017-01-07  4:45           ` Mike Galbraith
2016-12-20  6:34       ` [PATCH v2] ipc/sem.c: fix incorrect sem_lock pairing 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=20161218162838.GA24788@linux-80c1.suse \
    --to=dave@stgolabs.net \
    --cc=akpm@linux-foundation.org \
    --cc=dvyukov@google.com \
    --cc=fabf@skynet.be \
    --cc=kernel@kyup.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=syzkaller@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.