Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp680342ybl; Fri, 30 Aug 2019 05:42:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyDXUzvVhN2s2g7ClHiY9XpA0FO1zxMsmsINQ2qVCLZ14gz/PQgpxVxN9ppXri6LarliED X-Received: by 2002:aa7:939c:: with SMTP id t28mr18671447pfe.111.1567168926541; Fri, 30 Aug 2019 05:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567168926; cv=none; d=google.com; s=arc-20160816; b=jYGVmNxxdoIb134q/IeovVY0GCcXgkK/g597v9nZfzqRmxwoatPAF05tThBbQv1jp8 GgryX9ZyGA5bdpXLCIydUOv15hykSeugtdCb9glggxILgYLX/ehnTCB758GHopfaYhL7 0IfUn9DT/8zNY4VcaD6iyG5CAFdxa4P1l0pV8e1I5pNBmImyPUjPauUTWXAgT+KYN1tl dG7DYkRnmUSPLVlOY6diD7zswHG4MsNuTkYBmw7jCtgCG8EaWoMeE0tjlSmbQBc53WWd xq/sFb0u/vIrF/pgbb6gjy2ftc3fdeM687lw04MbPmDRUBAuP3IOjaylLWeoECu91jLk rl6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=d48bwig87YLEqvvM7uBWHnRKyCDL6yJRayIDGvHZVTE=; b=VLjUyHpfYnxj5Vn97tnQSTEwoVfqTSOTYds+WgsFwWtbrJEDUK09T2LkH7qMi15qn/ E83EI1StnRVhj3cay8Jept1IlSJislcy3YdRVz6Vikhosf3J0cui3GGg0ciyzDhCyKwM +3j4IrR8xPRwsfmPmXLvLjbQb7Hv6IIuPIvEX7NOzdoHnxlQrTBw0hyY9E6pzLeYT6z5 WXMBuZvBy6v9uTuaOXtuasl9ySTHTLRbp0K0/Yl8N4w56TSUQzdPMDN+UbXxqFCPGOux 0FwDRy+Egf80F4kMX2bz2LVk47Te7WpC1ROMLidOGQFs8NykpS7s6ixEUG6O20YWf1VV uiLg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si4815058pjr.20.2019.08.30.05.41.51; Fri, 30 Aug 2019 05:42:06 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbfH3Mk7 (ORCPT + 99 others); Fri, 30 Aug 2019 08:40:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40976 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727603AbfH3Mk7 (ORCPT ); Fri, 30 Aug 2019 08:40:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E000018C427D; Fri, 30 Aug 2019 12:40:58 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06111100194E; Fri, 30 Aug 2019 12:40:54 +0000 (UTC) Date: Fri, 30 Aug 2019 14:40:52 +0200 From: Cornelia Huck To: Parav Pandit Cc: alex.williamson@redhat.com, jiri@mellanox.com, kwankhede@nvidia.com, davem@davemloft.net, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2 2/6] mdev: Make mdev alias unique among all mdevs Message-ID: <20190830144052.11d23ec3.cohuck@redhat.com> In-Reply-To: <20190829111904.16042-3-parav@mellanox.com> References: <20190826204119.54386-1-parav@mellanox.com> <20190829111904.16042-1-parav@mellanox.com> <20190829111904.16042-3-parav@mellanox.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Fri, 30 Aug 2019 12:40:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Aug 2019 06:19:00 -0500 Parav Pandit wrote: > Mdev alias should be unique among all the mdevs, so that when such alias > is used by the mdev users to derive other objects, there is no > collision in a given system. > > Signed-off-by: Parav Pandit > > --- > Changelog: > v1->v2: > - Moved alias NULL check at beginning > v0->v1: > - Fixed inclusiong of alias for NULL check > - Added ratelimited debug print for sha1 hash collision error > --- > drivers/vfio/mdev/mdev_core.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c > index 3bdff0469607..c9bf2ac362b9 100644 > --- a/drivers/vfio/mdev/mdev_core.c > +++ b/drivers/vfio/mdev/mdev_core.c > @@ -388,6 +388,13 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, > ret = -EEXIST; > goto mdev_fail; > } > + if (alias && tmp->alias && strcmp(alias, tmp->alias) == 0) { > + mutex_unlock(&mdev_list_lock); > + ret = -EEXIST; > + dev_dbg_ratelimited(dev, "Hash collision in alias creation for UUID %pUl\n", > + uuid); > + goto mdev_fail; > + } > } > > mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); Any reason not to merge this into the first patch?