* [PATCH] Btrfs: ensure path name is null terminated at btrfs_control_ioctl
@ 2018-11-14 11:35 fdmanana
2018-11-14 13:22 ` Anand Jain
2018-11-14 17:13 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2018-11-14 11:35 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
We were using the path name received from user space without checking that
it is null terminated. While btrfs-progs is well behaved and does proper
validation and null termination, someone could call the ioctl and pass
a non-null terminated patch, leading to buffer overrun problems in the
kernel.
So just set the last byte of the path to a null character, similar to what
we do in other ioctls (add/remove/resize device, snapshot creation, etc).
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6601c9aa5e35..8ad145820ea8 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2235,6 +2235,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
vol = memdup_user((void __user *)arg, sizeof(*vol));
if (IS_ERR(vol))
return PTR_ERR(vol);
+ vol->name[BTRFS_PATH_NAME_MAX] = '\0';
switch (cmd) {
case BTRFS_IOC_SCAN_DEV:
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: ensure path name is null terminated at btrfs_control_ioctl
2018-11-14 11:35 [PATCH] Btrfs: ensure path name is null terminated at btrfs_control_ioctl fdmanana
@ 2018-11-14 13:22 ` Anand Jain
2018-11-14 17:13 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2018-11-14 13:22 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 11/14/2018 07:35 PM, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> We were using the path name received from user space without checking that
> it is null terminated. While btrfs-progs is well behaved and does proper
> validation and null termination, someone could call the ioctl and pass
> a non-null terminated patch, leading to buffer overrun problems in the
> kernel.
>
> So just set the last byte of the path to a null character, similar to what
> we do in other ioctls (add/remove/resize device, snapshot creation, etc).
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Thanks, Anand
> ---
> fs/btrfs/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 6601c9aa5e35..8ad145820ea8 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -2235,6 +2235,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
> vol = memdup_user((void __user *)arg, sizeof(*vol));
> if (IS_ERR(vol))
> return PTR_ERR(vol);
> + vol->name[BTRFS_PATH_NAME_MAX] = '\0';
>
> switch (cmd) {
> case BTRFS_IOC_SCAN_DEV:
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: ensure path name is null terminated at btrfs_control_ioctl
2018-11-14 11:35 [PATCH] Btrfs: ensure path name is null terminated at btrfs_control_ioctl fdmanana
2018-11-14 13:22 ` Anand Jain
@ 2018-11-14 17:13 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2018-11-14 17:13 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Wed, Nov 14, 2018 at 11:35:24AM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> We were using the path name received from user space without checking that
> it is null terminated. While btrfs-progs is well behaved and does proper
> validation and null termination, someone could call the ioctl and pass
> a non-null terminated patch, leading to buffer overrun problems in the
> kernel.
>
> So just set the last byte of the path to a null character, similar to what
> we do in other ioctls (add/remove/resize device, snapshot creation, etc).
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Good catch, thanks
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-14 17:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-14 11:35 [PATCH] Btrfs: ensure path name is null terminated at btrfs_control_ioctl fdmanana
2018-11-14 13:22 ` Anand Jain
2018-11-14 17:13 ` David Sterba
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.