* [PATCH 3/4] drivers/hid: Eliminate use after free
@ 2010-05-15 9:46 Julia Lawall
2010-05-17 8:43 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-05-15 9:46 UTC (permalink / raw)
To: Jiri Kosina, linux-input, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
The skip label frees resp, which has not been allocated at the point of
this goto and then does a break, based on the fact that err is non-zero.
This is replaced by a break directly.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@free@
expression E;
position p;
@@
kfree@p(E)
@@
expression free.E, subE<=free.E, E1;
position free.p;
@@
kfree@p(E)
...
(
subE = E1
|
* E
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/hid/hid-picolcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index 95253b3..7aabf65 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -1616,7 +1616,7 @@ static ssize_t _picolcd_flash_write(struct picolcd_data *data, int report_id,
raw_data[len_off] = s > 32 ? 32 : s;
if (copy_from_user(raw_data+len_off+1, u, raw_data[len_off])) {
err = -EFAULT;
- goto skip;
+ break;
}
resp = picolcd_send_and_wait(data->hdev, report_id, raw_data,
len_off+1+raw_data[len_off]);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] drivers/hid: Eliminate use after free
2010-05-15 9:46 [PATCH 3/4] drivers/hid: Eliminate use after free Julia Lawall
@ 2010-05-17 8:43 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2010-05-17 8:43 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-input, linux-kernel, kernel-janitors
On Sat, 15 May 2010, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> The skip label frees resp, which has not been allocated at the point of
> this goto and then does a break, based on the fact that err is non-zero.
> This is replaced by a break directly.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @free@
> expression E;
> position p;
> @@
> kfree@p(E)
>
> @@
> expression free.E, subE<=free.E, E1;
> position free.p;
> @@
>
> kfree@p(E)
> ...
> (
> subE = E1
> |
> * E
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> drivers/hid/hid-picolcd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
> index 95253b3..7aabf65 100644
> --- a/drivers/hid/hid-picolcd.c
> +++ b/drivers/hid/hid-picolcd.c
> @@ -1616,7 +1616,7 @@ static ssize_t _picolcd_flash_write(struct picolcd_data *data, int report_id,
> raw_data[len_off] = s > 32 ? 32 : s;
> if (copy_from_user(raw_data+len_off+1, u, raw_data[len_off])) {
> err = -EFAULT;
> - goto skip;
> + break;
> }
> resp = picolcd_send_and_wait(data->hdev, report_id, raw_data,
> len_off+1+raw_data[len_off]);
Good catch, applied. Thanks,
--
Jiri Kosina
SUSE Labs, Novell Inc.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-17 8:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-15 9:46 [PATCH 3/4] drivers/hid: Eliminate use after free Julia Lawall
2010-05-17 8:43 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).