linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Manfred Spraul <manfred@colorfullife.com>,
	linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 1/2] ipc,shm: move BUG_ON check into shm_lock
Date: Mon, 1 Jun 2015 15:52:23 -0700	[thread overview]
Message-ID: <20150601155223.d919df461c92ff82e3fafd20@linux-foundation.org> (raw)
In-Reply-To: <1432944186-7305-1-git-send-email-dave@stgolabs.net>

On Fri, 29 May 2015 17:03:05 -0700 Davidlohr Bueso <dave@stgolabs.net> wrote:

> Upon every shm_lock call, we BUG_ON if an error was returned,
> indicating racing either in idr or in RMID. Move this logic
> into the locking.
> 
> ...
>
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -155,8 +155,14 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
>  {
>  	struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id);
>  
> -	if (IS_ERR(ipcp))
> +	if (IS_ERR(ipcp)) {
> +		/*
> +		 * We raced in the idr lookup or with RMID,
> +		 * either way, the ID is busted.
> +		 */
> +		BUG_ON(1);
>  		return (struct shmid_kernel *)ipcp;
> +	}
>  

That's a bit odd.  Why not

--- a/ipc/shm.c~ipcshm-move-bug_on-check-into-shm_lock-fix-2
+++ a/ipc/shm.c
@@ -160,7 +160,7 @@ static inline struct shmid_kernel *shm_l
 		 * We raced in the idr lookup or with RMID,
 		 * either way, the ID is busted.
 		 */
-		BUG_ON(1);
+		BUG();
 		return (struct shmid_kernel *)ipcp;
 	}
 

and/or

--- a/ipc/shm.c~ipcshm-move-bug_on-check-into-shm_lock-fix
+++ a/ipc/shm.c
@@ -155,14 +155,11 @@ static inline struct shmid_kernel *shm_l
 {
 	struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id);
 
-	if (IS_ERR(ipcp)) {
-		/*
-		 * We raced in the idr lookup or with RMID,
-		 * either way, the ID is busted.
-		 */
-		BUG();
-		return (struct shmid_kernel *)ipcp;
-	}
+	/*
+	 * We raced in the idr lookup or with RMID.  Either way, the ID is
+	 * busted.
+	 */
+	BUG_ON(IS_ERR(ipcp));
 
 	return container_of(ipcp, struct shmid_kernel, shm_perm);
 }
_


  parent reply	other threads:[~2015-06-01 22:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-30  0:03 [PATCH 1/2] ipc,shm: move BUG_ON check into shm_lock Davidlohr Bueso
2015-05-30  0:03 ` [PATCH 2/2] ipc,msg: provide barrier pairings for lockless receive Davidlohr Bueso
2015-06-04 17:57   ` Manfred Spraul
2015-06-04 18:41     ` Davidlohr Bueso
2015-06-04 18:56       ` Davidlohr Bueso
2015-06-01 22:52 ` Andrew Morton [this message]
2015-06-04  0:24   ` [PATCH 1/2] ipc,shm: move BUG_ON check into shm_lock Davidlohr Bueso
2015-06-04  0:25   ` Davidlohr Bueso
2015-06-04 18:35 ` Manfred Spraul
2015-06-04 18:58   ` Davidlohr Bueso
2015-06-04 20:31   ` Davidlohr Bueso

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=20150601155223.d919df461c92ff82e3fafd20@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --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;
as well as URLs for NNTP newsgroup(s).