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:	Mon, 2 Apr 2007 01:01:41 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	NeilBrown <neilb@...e.de>
Cc:	linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
	Alan Stern <stern@...land.harvard.edu>
Subject: Re: [PATCH] md: Avoid a deadlock when removing a device from an md
 array via sysfs.

On Mon, 2 Apr 2007 17:44:17 +1000 NeilBrown <neilb@...e.de> wrote:

> (This patch should go in 2.6.21 as it fixes a recent regression - NB)
> 
> A device can be removed from an md array via e.g.
>   echo remove > /sys/block/md3/md/dev-sde/state
> 
> This will try to remove the 'dev-sde' subtree which will deadlock
> since
>   commit e7b0d26a86943370c04d6833c6edba2a72a6e240
> 
> With this patch we run the kobject_del via schedule_work so as to
> avoid the deadlock.
> 
> Cc: Alan Stern <stern@...land.harvard.edu>
> Signed-off-by: Neil Brown <neilb@...e.de>
> 
> ### Diffstat output
>  ./drivers/md/md.c           |   13 ++++++++++++-
>  ./include/linux/raid/md_k.h |    1 +
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff .prev/drivers/md/md.c ./drivers/md/md.c
> --- .prev/drivers/md/md.c	2007-04-02 17:43:03.000000000 +1000
> +++ ./drivers/md/md.c	2007-04-02 17:38:46.000000000 +1000
> @@ -1389,6 +1389,12 @@ static int bind_rdev_to_array(mdk_rdev_t
>  	return err;
>  }
>  
> +static void delayed_delete(struct work_struct *ws)
> +{
> +	mdk_rdev_t *rdev = container_of(ws, mdk_rdev_t, del_work);
> +	kobject_del(&rdev->kobj);
> +}
> +
>  static void unbind_rdev_from_array(mdk_rdev_t * rdev)
>  {
>  	char b[BDEVNAME_SIZE];
> @@ -1401,7 +1407,12 @@ static void unbind_rdev_from_array(mdk_r
>  	printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b));
>  	rdev->mddev = NULL;
>  	sysfs_remove_link(&rdev->kobj, "block");
> -	kobject_del(&rdev->kobj);
> +
> +	/* We need to delay this, otherwise we can deadlock when
> +	 * writing to 'remove' to "dev/state"
> +	 */
> +	INIT_WORK(&rdev->del_work, delayed_delete);
> +	schedule_work(&rdev->del_work);
>  }
>  
>  /*
> 
> diff .prev/include/linux/raid/md_k.h ./include/linux/raid/md_k.h
> --- .prev/include/linux/raid/md_k.h	2007-04-02 17:43:03.000000000 +1000
> +++ ./include/linux/raid/md_k.h	2007-04-02 17:36:32.000000000 +1000
> @@ -104,6 +104,7 @@ struct mdk_rdev_s
>  					   * for reporting to userspace and storing
>  					   * in superblock.
>  					   */
> +	struct work_struct del_work;	/* used for delayed sysfs removal */
>  };
>  

What guarantees that *rdev is still valid when delayed_delete() runs?

And what guarantees that the md module hasn't been rmmodded when
delayed_delete() tries to run?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ