Skip to content

Commit

Permalink
thinkpad_acpi: buffer overflow in fan_get_status()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
  • Loading branch information
Dan Carpenter authored and Matthew Garrett committed Sep 13, 2012
1 parent f661848 commit eceeb43
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/platform/x86/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit eceeb43

Please sign in to comment.