Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2230102ybl; Thu, 29 Aug 2019 05:33:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoyMi7OYW4P79Ek0GpYG7F41nCizk8GGiL6LI3monNeGzJmX1GZku35inRSlfPJcs6H/ry X-Received: by 2002:a63:89c2:: with SMTP id v185mr8028318pgd.241.1567081988624; Thu, 29 Aug 2019 05:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567081988; cv=none; d=google.com; s=arc-20160816; b=Lu57GIkYbO48Mo0e8HJWatXi9rynvj5b8zocf0H0z2qAs5UYQwZ2x0njwPycj8NNJI P2U0cIsShMbjFXiZF143FJHkan65GHjbWyTeuS5/IW0IGXFH95BBgCb7PlVRe0eGDRAg wWo9LRyfKkXBtyOkhRg+dh9orrhshulT8pPWlugYjEhyjdyGHN0Ciwq4a4bvd0lcC+9h 6dtlWoLplmG6rYvKejztrplplMDG18rMtDzZk2CS4c2QBhKgMS8Z8Tw/t+QaUZLKMEdb i8eS0AiBtXreicSUgvbbtFrXcfZHLRexCnHFmEjUr4gTDYb7P8Cli5fQ5ae3mP1YZved lAtw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=g5nr1wxZaFtQaXof7Cz3YMyF3zE+aEfwo8+K67a8y/M=; b=LDxg7sris+bb+3CR/itpGbmsBGSVhCOD2gM35qsC3Xeqe/NiO+amy21KtmS9NY75EG GbN+EYpS7vQgPjeDEzzEmoiF7/kb4yGwPIPsZ6KgSBDJxQGWtMKdjyMvTkqLDKLANzwa 6aZT+VO+ODj5MYu9D+ixUj3n/zHyemLVuKeWMhC/ELIk+kWSA11AMYJIr36qPClFu7rz HDVRgOqPIyuSo2Ps/ZGXg6ESIlALZ89Zc2fWeI1PduR46f7MQiGcRkRo/UXlJBU65jBZ xGYlWEn02bnKugk65g4L/zkxPf8byJTfqP2dQhCo0FGZ94suJ85vXxZK9eJkhzsE06rc Q+rw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r16si2615450pfl.146.2019.08.29.05.32.47; Thu, 29 Aug 2019 05:33:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727381AbfH2Mbu (ORCPT + 99 others); Thu, 29 Aug 2019 08:31:50 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:36572 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727069AbfH2Mbu (ORCPT ); Thu, 29 Aug 2019 08:31:50 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3226DFB200799E2FEAAB; Thu, 29 Aug 2019 20:31:48 +0800 (CST) Received: from [127.0.0.1] (10.74.191.121) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Thu, 29 Aug 2019 20:31:45 +0800 Subject: Re: [PATCH v2 2/6] mdev: Make mdev alias unique among all mdevs To: Parav Pandit , , , , , CC: , , References: <20190826204119.54386-1-parav@mellanox.com> <20190829111904.16042-1-parav@mellanox.com> <20190829111904.16042-3-parav@mellanox.com> From: Yunsheng Lin Message-ID: <56a88778-c90e-1ac6-9a31-d1aaa5dec97b@huawei.com> Date: Thu, 29 Aug 2019 20:31:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20190829111904.16042-3-parav@mellanox.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.74.191.121] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/8/29 19:19, 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) { !strcmp(alias, tmp->alias) is a more common kernel pattern. Also if we limit max len of the alias in patch 1, maybe use that to limit the string compare too. > + 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); >