Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753455AbbFDSfl (ORCPT ); Thu, 4 Jun 2015 14:35:41 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:34859 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103AbbFDSfj (ORCPT ); Thu, 4 Jun 2015 14:35:39 -0400 Message-ID: <55709A77.5050504@colorfullife.com> Date: Thu, 04 Jun 2015 20:35:35 +0200 From: Manfred Spraul User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Davidlohr Bueso , Andrew Morton CC: linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 1/2] ipc,shm: move BUG_ON check into shm_lock References: <1432944186-7305-1-git-send-email-dave@stgolabs.net> In-Reply-To: <1432944186-7305-1-git-send-email-dave@stgolabs.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1389 Lines: 44 Hi Davidlohr, On 05/30/2015 02:03 AM, Davidlohr Bueso 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. > > Signed-off-by: Davidlohr Bueso > --- > ipc/shm.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/ipc/shm.c b/ipc/shm.c > index 6d76707..3152dea 100644 > --- 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. The comment is wrong: "We raced in the idr lookup or with shm_destroy()" shm is not like msg or sem: RMID merely marks a shmid as deletable (SHM_DEST), delete (i.e.: shm_rmid(), then ipc_rmid()) happens only after the last attached segment is detatched. And: (unrelated to the patch) For do_shmat(), I'm not 100% sure that the BUG can't be triggered. -- Manfred -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/