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] [day] [month] [year] [list]
Message-ID: <a44a8b7d-c8c8-4bc1-b9f1-b8becb966db2@oracle.com>
Date: Wed, 2 Jul 2025 10:57:35 +0100
From: John Garry <john.g.garry@...cle.com>
To: Luis Chamberlain <mcgrof@...nel.org>,
        James.Bottomley@...senPartnership.com, martin.petersen@...cle.com,
        linux-scsi@...r.kernel.org
Cc: gost.dev@...sung.com, s.prabhu@...sung.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scsi_debug: Fix shared UUID issue when creating multiple
 hosts

On 01/07/2025 23:02, Luis Chamberlain wrote:
> When creating multiple scsi_debug hosts (e.g., modprobe scsi_debug
> add_host=2), all devices share the same backing storage by default.
> This causes filesystem UUIDs to be shared between devices like /dev/sda
> and /dev/sdb, leading to confusion and potential mount issues.
> 
> For example:
>    # modprobe scsi_debug add_host=2 dev_size_mb=1024
>    # mkfs.xfs -f /dev/sda
>    # wipefs /dev/sda /dev/sdb
> Both devices show the same UUID, which is incorrect behavior.
> 
> Fix this by automatically enabling separate per-host stores when
> multiple hosts are created, while preserving backward compatibility
> for single-host scenarios. Users can still explicitly control this
> behavior via the per_host_store parameter.
> 
> After this fix:
> - Single host: Uses shared store (unchanged behavior)

Does phs even have any affect for only a single scsi_debug host?

I thought that phs means that each host has its own backing storage 
which is shared among all devices for that host.

> - Multiple hosts: Automatically uses separate stores (fixes UUID issue)
> - Explicit per_host_store=1: Always separate stores (unchanged behavior)
 > > Reported-by: Swarna Prabhu <s.prabhu@...sung.com>
> Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
> ---
>   drivers/scsi/scsi_debug.c | 17 ++++++++++++++---
>   1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index f0eec4708ddd..4d0b17861adb 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -8034,12 +8034,18 @@ static ssize_t add_host_store(struct device_driver *ddp, const char *buf,
>   	bool found;
>   	unsigned long idx;
>   	struct sdeb_store_info *sip;
> +	bool uniq_uuid_required = false;
>   	bool want_phs = (sdebug_fake_rw == 0) && sdebug_per_host_store;
>   	int delta_hosts;
>   
>   	if (sscanf(buf, "%d", &delta_hosts) != 1)
>   		return -EINVAL;
>   	if (delta_hosts > 0) {
> +		if (delta_hosts > 1) {
> +			uniq_uuid_required = true;
> +			if (sdebug_fake_rw == 0)
> +				want_phs = true;
> +		}
>   		do {
>   			found = false;
>   			if (want_phs) {
> @@ -8054,7 +8060,7 @@ static ssize_t add_host_store(struct device_driver *ddp, const char *buf,
>   				else
>   					sdebug_do_add_host(true);
>   			} else {
> -				sdebug_do_add_host(false);
> +				sdebug_do_add_host(uniq_uuid_required);
>   			}
>   		} while (--delta_hosts);
>   	} else if (delta_hosts < 0) {
> @@ -8383,6 +8389,7 @@ static struct device *pseudo_primary;
>   static int __init scsi_debug_init(void)
>   {
>   	bool want_store = (sdebug_fake_rw == 0);
> +	bool uniq_uuid_required = false;
>   	unsigned long sz;
>   	int k, ret, hosts_to_add;
>   	int idx = -1;
> @@ -8578,6 +8585,9 @@ static int __init scsi_debug_init(void)
>   	}
>   
>   	hosts_to_add = sdebug_add_host;
> +	if (hosts_to_add > 1)
> +		uniq_uuid_required = true;
> +
>   	sdebug_add_host = 0;
>   
>   	sdebug_debugfs_root = debugfs_create_dir("scsi_debug", NULL);
> @@ -8593,8 +8603,9 @@ static int __init scsi_debug_init(void)
>   				break;
>   			}
>   		} else {
> -			ret = sdebug_do_add_host(want_store &&
> -						 sdebug_per_host_store);
> +			bool use_store = want_store &&
> +				(sdebug_per_host_store || uniq_uuid_required);
> +			ret = sdebug_do_add_host(use_store);
>   			if (ret < 0) {
>   				pr_err("add_host k=%d error=%d\n", k, -ret);
>   				break;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ