diff options
author | Rupesh Gujare <rupesh.gujare@atmel.com> | 2013-08-05 12:28:33 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-12 14:02:58 -0700 |
commit | b2271b5bdf1fd8b7d5442e2452e9242b88c56e8f (patch) | |
tree | eb5c4d0f2fa8bb4f5fed94e4308d0f7cb7bf530a | |
parent | 5cf9d2577f22eebf2263e6cd91b942b7016845d2 (diff) |
staging: ozwpan: Fix farewell report.
This patch fix following issues reported by Dan:-
1) There is no check limiting the size to 32 and it could be up to
253 bytes.
2) Use defines instead of magic numbers.
3) The oz_farewell struct is supposed to be a variable length struct
but the variable part is put in the middle. It doesn't make any
sense to put the length of the variable size array after then end
of the array because we can never find it again! Put the
variable size array at the end. Make it a zero length array.
u8 len;
u8 report[0];
4) In oz_add_farewell() we do this:
f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC);
The "- 1" refers to sizeof(f->report) but because it was a magic
number then it was missed when the sizeof(f->report) changed.
5) In [patch 6/6] we set the ->len member. But because it is at the
end of a variable length array with no limit check the remote
attacker can just rewrite it using the memcpy() on the next line.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rupesh Gujare <rupesh.gujare@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/ozwpan/ozpd.h | 2 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozproto.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index 57e98c89771..996ef65ed31 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -48,8 +48,8 @@ struct oz_farewell { struct list_head link; u8 ep_num; u8 index; - u8 report[32]; u8 len; + u8 report[0]; }; /* Data structure that holds information on a specific peripheral device (PD). diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 084307a1083..3d1a89f0735 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -291,7 +291,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, struct oz_farewell *f; struct oz_farewell *f2; int found = 0; - f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC); + f = kmalloc(sizeof(struct oz_farewell) + len, GFP_ATOMIC); if (!f) return; f->ep_num = ep_num; |