Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158942
b: refs/heads/master
c: 1be491f
h: refs/heads/master
v: v3
  • Loading branch information
Johannes Berg authored and John W. Linville committed Jul 10, 2009
1 parent 2c32e63 commit 47dc046
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3355443ad7601991affa5992b0d53870335af765
refs/heads/master: 1be491fca12ff599c37ceaf7e9042ebee9f0068e
14 changes: 14 additions & 0 deletions trunk/include/linux/rfkill.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ struct rfkill_event {
__u8 soft, hard;
} __packed;

/*
* We are planning to be backward and forward compatible with changes
* to the event struct, by adding new, optional, members at the end.
* When reading an event (whether the kernel from userspace or vice
* versa) we need to accept anything that's at least as large as the
* version 1 event size, but might be able to accept other sizes in
* the future.
*
* One exception is the kernel -- we already have two event sizes in
* that we've made the 'hard' member optional since our only option
* is to ignore it anyway.
*/
#define RFKILL_EVENT_SIZE_V1 8

/* ioctl for turning off rfkill-input (if present) */
#define RFKILL_IOC_MAGIC 'R'
#define RFKILL_IOC_NOINPUT 1
Expand Down
10 changes: 8 additions & 2 deletions trunk/net/rfkill/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,10 +1076,16 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
struct rfkill_event ev;

/* we don't need the 'hard' variable but accept it */
if (count < sizeof(ev) - 1)
if (count < RFKILL_EVENT_SIZE_V1 - 1)
return -EINVAL;

if (copy_from_user(&ev, buf, sizeof(ev) - 1))
/*
* Copy as much data as we can accept into our 'ev' buffer,
* but tell userspace how much we've copied so it can determine
* our API version even in a write() call, if it cares.
*/
count = min(count, sizeof(ev));
if (copy_from_user(&ev, buf, count))
return -EFAULT;

if (ev.op != RFKILL_OP_CHANGE && ev.op != RFKILL_OP_CHANGE_ALL)
Expand Down

0 comments on commit 47dc046

Please sign in to comment.