lkml.org 
[lkml]   [2015]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC v3 6/9] kmsg: add ioctl for adding and deleting kmsg* devices
Date
On Monday 19 October 2015 14:58:20 Paul Osmialowski wrote:
> +
> +struct kmsg_cmd_buffer_add {
> + size_t size;
> + unsigned short mode;
> + int minor;
> +} __attribute__((packed));
> +
> +#define KMSG_IOCTL_MAGIC 0xBB
> +
> +/*
>

Try to avoid using packed unaligned data structures. Here I would
just use __u64 and __u32 members.

> + case KMSG_CMD_BUFFER_ADD:
> + if (copy_from_user(&size, argp, sizeof(size)))
> + return -EFAULT;
> + argp += sizeof(size);
> + if (copy_from_user(&mode, argp, sizeof(mode)))
> + return -EFAULT;

This is a rather unusual way to access the data. Just copy the
entire structure to the stack.

Arnd


\
 
 \ /
  Last update: 2015-10-19 15:41    [W:0.134 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site