lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 8 Oct 2020 20:20:11 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Dave Ertman <david.m.ertman@...el.com>
Cc:     alsa-devel@...a-project.org, tiwai@...e.de, broonie@...nel.org,
        linux-rdma@...r.kernel.org, jgg@...dia.com, dledford@...hat.com,
        netdev@...r.kernel.org, davem@...emloft.net, kuba@...nel.org,
        gregkh@...uxfoundation.org, ranjani.sridharan@...ux.intel.com,
        pierre-louis.bossart@...ux.intel.com, fred.oh@...ux.intel.com,
        parav@...lanox.com, shiraz.saleem@...el.com,
        dan.j.williams@...el.com, kiran.patil@...el.com
Subject: Re: [PATCH v2 1/6] Add ancillary bus support

On Mon, Oct 05, 2020 at 11:24:41AM -0700, Dave Ertman wrote:
> Add support for the Ancillary Bus, ancillary_device and ancillary_driver.
> It enables drivers to create an ancillary_device and bind an
> ancillary_driver to it.
>
> The bus supports probe/remove shutdown and suspend/resume callbacks.
> Each ancillary_device has a unique string based id; driver binds to
> an ancillary_device based on this id through the bus.
>
> Co-developed-by: Kiran Patil <kiran.patil@...el.com>
> Signed-off-by: Kiran Patil <kiran.patil@...el.com>
> Co-developed-by: Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>
> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>
> Co-developed-by: Fred Oh <fred.oh@...ux.intel.com>
> Signed-off-by: Fred Oh <fred.oh@...ux.intel.com>
> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
> Reviewed-by: Shiraz Saleem <shiraz.saleem@...el.com>
> Reviewed-by: Parav Pandit <parav@...lanox.com>
> Reviewed-by: Dan Williams <dan.j.williams@...el.com>
> Signed-off-by: Dave Ertman <david.m.ertman@...el.com>
> ---

<...>

> +
> +static const struct ancillary_device_id *ancillary_match_id(const struct ancillary_device_id *id,
> +							    const struct ancillary_device *ancildev)
> +{
> +	while (id->name[0]) {
> +		const char *p = strrchr(dev_name(&ancildev->dev), '.');
> +		int match_size;
> +
> +		if (!p) {
> +			id++;
> +			continue;
> +		}
> +		match_size = p - dev_name(&ancildev->dev);
> +
> +		/* use dev_name(&ancildev->dev) prefix before last '.' char to match to */
> +		if (!strncmp(dev_name(&ancildev->dev), id->name, match_size))

This check is wrong, it causes to wrong matching if strlen(id->name) > match_size
In my case, the trigger was:
[    5.175848] ancillary:ancillary_match_id: dev mlx5_core.ib.0, id mlx5_core.ib_rep

>From cf8f10af72f9e0d57c7ec077d59238cc12b0650f Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <leonro@...dia.com>
Date: Thu, 8 Oct 2020 19:40:03 +0300
Subject: [PATCH] fixup! Fixes to ancillary bus

Signed-off-by: Leon Romanovsky <leonro@...dia.com>
---
 drivers/bus/ancillary.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/ancillary.c b/drivers/bus/ancillary.c
index 54858f744ef5..615ce40ef8e4 100644
--- a/drivers/bus/ancillary.c
+++ b/drivers/bus/ancillary.c
@@ -31,8 +31,10 @@ static const struct ancillary_device_id *ancillary_match_id(const struct ancilla
 		match_size = p - dev_name(&ancildev->dev);

 		/* use dev_name(&ancildev->dev) prefix before last '.' char to match to */
-		if (!strncmp(dev_name(&ancildev->dev), id->name, match_size))
+		if (match_size == strlen(id->name) && !strncmp(dev_name(&ancildev->dev), id->name, match_size)) {
 			return id;
+		}
+
 		id++;
 	}
 	return NULL;
--
2.26.2



> +			return id;
> +		id++;
> +	}
> +	return NULL;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ