* [patch] thinkpad_acpi: buffer overflow in fan_get_status()
@ 2012-09-01 19:54 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-09-01 19:54 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: Matthew Garrett, open list:THINKPAD ACPI EXT...,
open list:THINKPAD ACPI EXT..., kernel-janitors
The acpi_evalf() function modifies four bytes of data but in
fan_get_status() we pass a pointer to u8. I have modified the
function to use type checking now.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index df3016b..0735fb7 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -545,7 +545,7 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
*/
static int acpi_evalf(acpi_handle handle,
- void *res, char *method, char *fmt, ...)
+ int *res, char *method, char *fmt, ...)
{
char *fmt0 = fmt;
struct acpi_object_list params;
@@ -606,7 +606,7 @@ static int acpi_evalf(acpi_handle handle,
success = (status = AE_OK &&
out_obj.type = ACPI_TYPE_INTEGER);
if (success && res)
- *(int *)res = out_obj.integer.value;
+ *res = out_obj.integer.value;
break;
case 'v': /* void */
success = status = AE_OK;
@@ -7386,17 +7386,18 @@ static int fan_get_status(u8 *status)
* Add TPACPI_FAN_RD_ACPI_FANS ? */
switch (fan_status_access_mode) {
- case TPACPI_FAN_RD_ACPI_GFAN:
+ case TPACPI_FAN_RD_ACPI_GFAN: {
/* 570, 600e/x, 770e, 770x */
+ int res;
- if (unlikely(!acpi_evalf(gfan_handle, &s, NULL, "d")))
+ if (unlikely(!acpi_evalf(gfan_handle, &res, NULL, "d")))
return -EIO;
if (likely(status))
- *status = s & 0x07;
+ *status = res & 0x07;
break;
-
+ }
case TPACPI_FAN_RD_TPEC:
/* all except 570, 600e/x, 770e, 770x */
if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [patch] thinkpad_acpi: buffer overflow in fan_get_status()
@ 2012-09-01 19:54 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-09-01 19:54 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: Matthew Garrett, open list:THINKPAD ACPI EXT...,
open list:THINKPAD ACPI EXT..., kernel-janitors
The acpi_evalf() function modifies four bytes of data but in
fan_get_status() we pass a pointer to u8. I have modified the
function to use type checking now.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index df3016b..0735fb7 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -545,7 +545,7 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
*/
static int acpi_evalf(acpi_handle handle,
- void *res, char *method, char *fmt, ...)
+ int *res, char *method, char *fmt, ...)
{
char *fmt0 = fmt;
struct acpi_object_list params;
@@ -606,7 +606,7 @@ static int acpi_evalf(acpi_handle handle,
success = (status == AE_OK &&
out_obj.type == ACPI_TYPE_INTEGER);
if (success && res)
- *(int *)res = out_obj.integer.value;
+ *res = out_obj.integer.value;
break;
case 'v': /* void */
success = status == AE_OK;
@@ -7386,17 +7386,18 @@ static int fan_get_status(u8 *status)
* Add TPACPI_FAN_RD_ACPI_FANS ? */
switch (fan_status_access_mode) {
- case TPACPI_FAN_RD_ACPI_GFAN:
+ case TPACPI_FAN_RD_ACPI_GFAN: {
/* 570, 600e/x, 770e, 770x */
+ int res;
- if (unlikely(!acpi_evalf(gfan_handle, &s, NULL, "d")))
+ if (unlikely(!acpi_evalf(gfan_handle, &res, NULL, "d")))
return -EIO;
if (likely(status))
- *status = s & 0x07;
+ *status = res & 0x07;
break;
-
+ }
case TPACPI_FAN_RD_TPEC:
/* all except 570, 600e/x, 770e, 770x */
if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] thinkpad_acpi: buffer overflow in fan_get_status()
2012-09-01 19:54 ` Dan Carpenter
@ 2012-09-01 20:16 ` Henrique de Moraes Holschuh
-1 siblings, 0 replies; 4+ messages in thread
From: Henrique de Moraes Holschuh @ 2012-09-01 20:16 UTC (permalink / raw)
To: Dan Carpenter
Cc: Henrique de Moraes Holschuh, Matthew Garrett,
open list:THINKPAD ACPI EXT..., open list:THINKPAD ACPI EXT...,
kernel-janitors
On Sat, 01 Sep 2012, Dan Carpenter wrote:
> The acpi_evalf() function modifies four bytes of data but in
> fan_get_status() we pass a pointer to u8. I have modified the
> function to use type checking now.
This makes the function unextensible to return other ACPI object types, but
it can be changed back to void* later if required.
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Thanks for noticing this problem, fortunately it affects only _really_
ancient thinkpads, which are extremely rare.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] thinkpad_acpi: buffer overflow in fan_get_status()
@ 2012-09-01 20:16 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 4+ messages in thread
From: Henrique de Moraes Holschuh @ 2012-09-01 20:16 UTC (permalink / raw)
To: Dan Carpenter
Cc: Henrique de Moraes Holschuh, Matthew Garrett,
open list:THINKPAD ACPI EXT..., open list:THINKPAD ACPI EXT...,
kernel-janitors
On Sat, 01 Sep 2012, Dan Carpenter wrote:
> The acpi_evalf() function modifies four bytes of data but in
> fan_get_status() we pass a pointer to u8. I have modified the
> function to use type checking now.
This makes the function unextensible to return other ACPI object types, but
it can be changed back to void* later if required.
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Thanks for noticing this problem, fortunately it affects only _really_
ancient thinkpads, which are extremely rare.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-01 20:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-01 19:54 [patch] thinkpad_acpi: buffer overflow in fan_get_status() Dan Carpenter
2012-09-01 19:54 ` Dan Carpenter
2012-09-01 20:16 ` Henrique de Moraes Holschuh
2012-09-01 20:16 ` Henrique de Moraes Holschuh
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.