linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix btrfs_ioctl_dev_info() crash on missing device
@ 2012-03-19 15:17 Stefan Behrens
  2012-03-19 15:54 ` Helmut Hullen
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Behrens @ 2012-03-19 15:17 UTC (permalink / raw)
  To: linux-btrfs

When a filesystem is mounted with the degraded option, it is
possible that some of the devices are not there.
btrfs_ioctl_dev_info() crashs in this case because the device
name is a NULL pointer. This ioctl was only used for scrub.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
 fs/btrfs/ioctl.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6834be4..9b4028b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2188,7 +2188,10 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
 	di_args->bytes_used = dev->bytes_used;
 	di_args->total_bytes = dev->total_bytes;
 	memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
-	strncpy(di_args->path, dev->name, sizeof(di_args->path));
+	if (dev->name)
+		strncpy(di_args->path, dev->name, sizeof(di_args->path));
+	else
+		di_args->path[0] = '\0';
 
 out:
 	if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: fix btrfs_ioctl_dev_info() crash on missing device
  2012-03-19 15:17 [PATCH] Btrfs: fix btrfs_ioctl_dev_info() crash on missing device Stefan Behrens
@ 2012-03-19 15:54 ` Helmut Hullen
  0 siblings, 0 replies; 2+ messages in thread
From: Helmut Hullen @ 2012-03-19 15:54 UTC (permalink / raw)
  To: linux-btrfs

Hallo, Stefan,

Du meintest am 19.03.12:

> When a filesystem is mounted with the degraded option, it is
> possible that some of the devices are not there.
> btrfs_ioctl_dev_info() crashs in this case because the device
> name is a NULL pointer. This ioctl was only used for scrub.

Just for curiosity: can that happen when I first delete a partition/disk  
and then run "btrfs scrub start"?

Viele Gruesse!
Helmut

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-19 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-19 15:17 [PATCH] Btrfs: fix btrfs_ioctl_dev_info() crash on missing device Stefan Behrens
2012-03-19 15:54 ` Helmut Hullen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).