mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davidlohr Bueso <davidlohr.bueso@hp.com>
To: Rik van Riel <riel@redhat.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	sedat.dilek@gmail.com, Emmanuel Benisty <benisty.e@gmail.com>
Subject: Re: [PATCH -mm] ipc,sem: fix locking in semctl_main
Date: Tue, 23 Apr 2013 10:36:50 -0700	[thread overview]
Message-ID: <1366738610.1802.9.camel@buesod1.americas.hpqcorp.net> (raw)
In-Reply-To: <20130423122905.33ac0d3c@annuminas.surriel.com>

On Tue, 2013-04-23 at 12:29 -0400, Rik van Riel wrote:
> Andrew, here is the patch I promised :)
> 
> Everywhere else in the code, we check sma->sem_perm.deleted under
> the semaphore array lock, so we should do teh same here.
> The easy fix is to simply not drop and re-take the lock, but keep
> it locked.
> 

CCing Linus, Sedat and Emmanuel.

This looks very much like a patch I asked Sedat to test during the
weekend, which according to him didn't solve his issue. The patch is
correct in any case.

> This patch can be folded into ipcsem-fine-grained-locking-for-semtimedop.patch
> 
> Signed-off-by: Rik van Riel <riel@redhat.com>

Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com>

> ---
>  ipc/sem.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/ipc/sem.c b/ipc/sem.c
> index 5711616..efdaee6 100644
> --- a/ipc/sem.c
> +++ b/ipc/sem.c
> @@ -1243,10 +1243,9 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
>  				err = -EIDRM;
>  				goto out_free;
>  			}
> -			sem_unlock(sma, -1);
> -		}
> +		} else
> +			sem_lock(sma, NULL, -1);
>  
> -		sem_lock(sma, NULL, -1);
>  		for (i = 0; i < sma->sem_nsems; i++)
>  			sem_io[i] = sma->sem_base[i].semval;
>  		sem_unlock(sma, -1);



  reply	other threads:[~2013-04-23 17:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 16:29 Rik van Riel
2013-04-23 17:36 ` Davidlohr Bueso [this message]
2013-04-23 18:06   ` Sedat Dilek

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=1366738610.1802.9.camel@buesod1.americas.hpqcorp.net \
    --to=davidlohr.bueso@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=benisty.e@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riel@redhat.com \
    --cc=sedat.dilek@gmail.com \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®