Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp649961imm; Mon, 9 Jul 2018 08:13:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFvnqU321WfzDPiXnA/wklSUkUZTr0ZJoALfASnH/zEVz4pUWOVm6kx/3gcp0zmioy3ItZ X-Received: by 2002:a62:ca0d:: with SMTP id n13-v6mr21563895pfg.69.1531149236184; Mon, 09 Jul 2018 08:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531149236; cv=none; d=google.com; s=arc-20160816; b=oR0xNaXnf8WtXfMX5wRUIUGaPQPR7OfKxGjwZJtLtO2BRHoEr/DWP4geQDmUYtz8bk 4BGhg7G4/9tSSY3lHQM2uZFZymoB48HOdY/H7VkfGc7NzTE8iw+U5EapWj1l2rQhULh5 MFcaMXMB2aEPdpVqqifcyhft16g9LEHxfMYIuKIl8hd2C9Q3EKcSJ5SbVDefg211HOJV lkkrJMeKUocC357GuRumXX2Bzva8GCMX3khkzay048AVilw5LcfYT/WHlueT+3CSwoFx zTDZ3eT8K7Hpsb2r3q89gmVe5TR3QMpPqDr3jVWtD0sGD9I57MXSYaw7B3cFiP84p2LL PyuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=+vBLahhfd5+9YQ7Z0ZgVCrIcJVCAuZwQo7uCf3w6NkE=; b=Gi2skcOx/VoGXJeToCuyHfyIWJ2pgSQkNStHkltZF5fTqS/ktEswsyP+jCVLskgX/N CHDExoaHla5Zpn1B3gxySaP+fny2iaAUkPG8cRlBd5/RWwNYKq1bnNLQv7sJlrSfQKxx CiZS5tehNlKHvU8TgUTTQaVP3iI2K7zwltSVcIyPYUcXGA4ryZawfl2y+1LxXkr8R9E/ F+AKGSlotyssrsWsEvWzQW0vFSP27bZNoyz36mVLaj9vji8kBkpbpgcLXurILwmGstG6 g3HmvPAf59ZyjiKrjlZfuoZrv0XHhi8D/s8FAFRZVkNrxbgTcUSJup0L1j1F0xWE6KGo LD9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@colorfullife-com.20150623.gappssmtp.com header.s=20150623 header.b=Am27Ccff; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2-v6si13351806pgq.675.2018.07.09.08.13.41; Mon, 09 Jul 2018 08:13:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@colorfullife-com.20150623.gappssmtp.com header.s=20150623 header.b=Am27Ccff; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933605AbeGIPM1 (ORCPT + 99 others); Mon, 9 Jul 2018 11:12:27 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51302 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933412AbeGIPKi (ORCPT ); Mon, 9 Jul 2018 11:10:38 -0400 Received: by mail-wm0-f65.google.com with SMTP id s12-v6so21575082wmc.1 for ; Mon, 09 Jul 2018 08:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=colorfullife-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+vBLahhfd5+9YQ7Z0ZgVCrIcJVCAuZwQo7uCf3w6NkE=; b=Am27CcffrL25heBC58U3MogrbOhZg7u08lRupjdX10fy/0mCpZWSI5sWr0XUJDnYgz oxOs3QimkC2AG4SVjGITRxxxeRcbDn5bxzt5hi/uD2y028VvSIyw6CtZoeMm6DqZk01V mgjZebC38by4sM1oMgcmwDxX7xC/FgNHKyj/aPMMNiJtvKpSaU7zBeSZyELtA9orfhqn nGApcUpiiQaZskKN8B2qKVW6NWpngqnjWCsplIDSnhg+9R5z4ThMkv5gl48qGFrElk76 0ebUuQEf37Q70TeTlvaqxlNJmMjO60yb5n+9GtIc30NwuXLf9Cmlj7ud0UX5VEZTfPkA 7INw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+vBLahhfd5+9YQ7Z0ZgVCrIcJVCAuZwQo7uCf3w6NkE=; b=Myj1hdiwTpeK15i2FjsA7FfoTkRYnShz3x2stOYd7NxxPQVVQq+553OjHjjClGqh28 F/PpbNHY7x8gIQZLcmcQMiUuDffVqTW3k+9jPWUfQ0v1cV+/ENltGQ3f5JDge916xjJD OBwh396giFxM2dxU7uE2mjFXeSxBTMvssGKBFJho6bgml7bUaKOCY36los4Nts4aemV/ cQRSAV3fhPmzH/XO3YcC/S5d/4ZkAvsgEWwr20nPBM3//tFhtmCVcJ+hFAtz5fzF+Bcq zwslCqvf78fk1vRRLvwJsreJ2Ayet12+q7AgNslLbjxwi/6KOvBDPoO4xRnvpFwQulPN Fz/g== X-Gm-Message-State: APt69E34BVYx0cVwPjaudONcF2vK0XzZUebMeYQpdpKPGSjRg7xkE9jE /3ULrFrdxd1JmuEwXPtGdLWYzQ== X-Received: by 2002:a1c:5b09:: with SMTP id p9-v6mr9873205wmb.0.1531149036844; Mon, 09 Jul 2018 08:10:36 -0700 (PDT) Received: from localhost.localdomain (p200300D993C227000209466FFA2F090C.dip0.t-ipconnect.de. [2003:d9:93c2:2700:209:466f:fa2f:90c]) by smtp.googlemail.com with ESMTPSA id u124-v6sm7817330wme.26.2018.07.09.08.10.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 08:10:36 -0700 (PDT) From: Manfred Spraul To: Andrew Morton , Davidlohr Bueso , Dmitry Vyukov Cc: LKML , 1vier1@web.de, Kees Cook , Manfred Spraul Subject: [PATCH 06/12] ipc: rename ipc_lock() to ipc_lock_idr() Date: Mon, 9 Jul 2018 17:10:13 +0200 Message-Id: <20180709151019.1336-7-manfred@colorfullife.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180709151019.1336-1-manfred@colorfullife.com> References: <20180709151019.1336-1-manfred@colorfullife.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ipc/util.c contains multiple functions to get the ipc object pointer given an id number. There are two sets of function: One set verifies the sequence counter part of the id number, other functions do not check the sequence counter. The standard for function names in ipc/util.c is - ..._check() functions verify the sequence counter - ..._idr() functions do not verify the sequence counter ipc_lock() is an exception: It does not verify the sequence counter value, but this is not obvious from the function name. Therefore: Rename the function to ipc_lock_idr(), to make it obvious that it does not check the sequence counter. Signed-off-by: Manfred Spraul Cc: Davidlohr Bueso --- ipc/shm.c | 4 ++-- ipc/util.c | 10 ++++++---- ipc/util.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index 426ba1039a7b..cd8655c7bb77 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -179,11 +179,11 @@ static inline struct shmid_kernel *shm_obtain_object_check(struct ipc_namespace */ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) { - struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); + struct kern_ipc_perm *ipcp = ipc_lock_idr(&shm_ids(ns), id); /* * Callers of shm_lock() must validate the status of the returned ipc - * object pointer (as returned by ipc_lock()), and error out as + * object pointer (as returned by ipc_lock_idr()), and error out as * appropriate. */ if (IS_ERR(ipcp)) diff --git a/ipc/util.c b/ipc/util.c index 8133f10832a9..8bc166bb4981 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -604,15 +604,17 @@ struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id) } /** - * ipc_lock - lock an ipc structure without rwsem held + * ipc_lock_idr - lock an ipc structure without rwsem held * @ids: ipc identifier set * @id: ipc id to look for * * Look for an id in the ipc ids idr and lock the associated ipc object. + * The function does not check if the sequence counter matches the + * found ipc object. * * The ipc object is locked on successful exit. */ -struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id) +struct kern_ipc_perm *ipc_lock_idr(struct ipc_ids *ids, int id) { struct kern_ipc_perm *out; @@ -624,8 +626,8 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id) spin_lock(&out->lock); /* - * ipc_rmid() may have already freed the ID while ipc_lock() - * was spinning: here verify that the structure is still valid. + * ipc_rmid() may have already freed the ID while waiting for + * the lock. Here verify that the structure is still valid. * Upon races with RMID, return -EIDRM, thus indicating that * the ID points to a removed identifier. */ diff --git a/ipc/util.h b/ipc/util.h index fcf81425ae98..25d8ee052ac9 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -142,7 +142,7 @@ int ipc_rcu_getref(struct kern_ipc_perm *ptr); void ipc_rcu_putref(struct kern_ipc_perm *ptr, void (*func)(struct rcu_head *head)); -struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); +struct kern_ipc_perm *ipc_lock_idr(struct ipc_ids *ids, int id); struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id); void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out); -- 2.17.1