All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result
@ 2012-04-26 16:36 Jim Meyering
  2012-04-26 18:22 ` Josef Bacik
  2012-04-26 18:26 ` Josef Bacik
  0 siblings, 2 replies; 3+ messages in thread
From: Jim Meyering @ 2012-04-26 16:36 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Josef Bacik


A device with name of length BTRFS_DEVICE_PATH_NAME_MAX or longer
would not be NUL-terminated in the DEV_INFO ioctl result buffer.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 fs/btrfs/ioctl.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 18cc23d..1578676 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2258,16 +2258,17 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
 		goto out;
 	}

 	di_args->devid = dev->devid;
 	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));
+	di_args->path[sizeof(di_args->path) - 1] = 0;

 out:
 	if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))
 		ret = -EFAULT;

 	kfree(di_args);
 	return ret;
 }
--
1.7.10.336.gc5e31

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

* Re: [PATCH] Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result
  2012-04-26 16:36 [PATCH] Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result Jim Meyering
@ 2012-04-26 18:22 ` Josef Bacik
  2012-04-26 18:26 ` Josef Bacik
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2012-04-26 18:22 UTC (permalink / raw)
  To: Jim Meyering; +Cc: Linux Kernel Mailing List, Josef Bacik

On Thu, Apr 26, 2012 at 06:36:56PM +0200, Jim Meyering wrote:
> 
> A device with name of length BTRFS_DEVICE_PATH_NAME_MAX or longer
> would not be NUL-terminated in the DEV_INFO ioctl result buffer.
> 
> Signed-off-by: Jim Meyering <meyering@redhat.com>

Reviewed-by: Josef Bacik <josef@redhat.com>

Thanks,

Josef

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

* Re: [PATCH] Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result
  2012-04-26 16:36 [PATCH] Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result Jim Meyering
  2012-04-26 18:22 ` Josef Bacik
@ 2012-04-26 18:26 ` Josef Bacik
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2012-04-26 18:26 UTC (permalink / raw)
  To: Jim Meyering; +Cc: Linux Kernel Mailing List, Josef Bacik

On Thu, Apr 26, 2012 at 06:36:56PM +0200, Jim Meyering wrote:
> 
> A device with name of length BTRFS_DEVICE_PATH_NAME_MAX or longer
> would not be NUL-terminated in the DEV_INFO ioctl result buffer.
> 
> Signed-off-by: Jim Meyering <meyering@redhat.com>
> ---
>  fs/btrfs/ioctl.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 18cc23d..1578676 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2258,16 +2258,17 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
>  		goto out;
>  	}
> 
>  	di_args->devid = dev->devid;
>  	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));
> +	di_args->path[sizeof(di_args->path) - 1] = 0;
> 
>  out:
>  	if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))
>  		ret = -EFAULT;
> 
>  	kfree(di_args);
>  	return ret;
>  }
> --
> 1.7.10.336.gc5e31

This didn't merge quite right onto btrfs-next btw so I've fixed it up manually
(but left the log/author/signed off intact).  Thanks,

Josef

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

end of thread, other threads:[~2012-04-26 18:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-26 16:36 [PATCH] Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result Jim Meyering
2012-04-26 18:22 ` Josef Bacik
2012-04-26 18:26 ` Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.