[PATCH 1/2] nvme: check duplicate unique identifiers in order

Keith Busch kbusch at kernel.org
Fri May 9 08:33:15 PDT 2025


On Fri, May 09, 2025 at 11:16:27AM -0400, Bryan Gurney wrote:
> +	if (has_uuid) {
> +		list_for_each_entry(h, &subsys->nsheads, entry)
> +			if (uuid_equal(&ids->uuid, &h->ids.uuid))
> +				return -EINVAL;
> +		return 0;
> +	}

You're returning success too early here. It may have a unique uuid, but
that doesn't mean we don't want to check for nguid and eui64 too. If
those are not unique, they need to be blanked out to make sure we don't
expose these on the namespace's sysfs attributes.

> +
> +	if (has_nguid) {
> +		list_for_each_entry(h, &subsys->nsheads, entry)
> +			if (memcmp(&ids->nguid,
> +				   &h->ids.nguid,
> +				   sizeof(ids->nguid)) == 0)
> +				return -EINVAL;
> +		return 0;
> +	}
> +
> +	if (has_eui64) {
> +		list_for_each_entry(h, &subsys->nsheads, entry)
> +			if (memcmp(&ids->eui64,
> +				   &h->ids.eui64,
> +				   sizeof(ids->eui64)) == 0)
> +				return -EINVAL;
> +		return 0;
>  	}
>  
>  	return 0;



More information about the Linux-nvme mailing list