[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150601155223.d919df461c92ff82e3fafd20@linux-foundation.org>
Date: Mon, 1 Jun 2015 15:52:23 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Davidlohr Bueso <dave@...olabs.net>
Cc: Manfred Spraul <manfred@...orfullife.com>,
linux-kernel@...r.kernel.org, Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH 1/2] ipc,shm: move BUG_ON check into shm_lock
On Fri, 29 May 2015 17:03:05 -0700 Davidlohr Bueso <dave@...olabs.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);
}
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists