From patchwork Fri Mar 18 15:08:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 8621201 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BDAB0C0553 for ; Fri, 18 Mar 2016 15:08:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1B9520351 for ; Fri, 18 Mar 2016 15:08:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0EE8202E9 for ; Fri, 18 Mar 2016 15:08:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756785AbcCRPIF (ORCPT ); Fri, 18 Mar 2016 11:08:05 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36151 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753585AbcCRPIE (ORCPT ); Fri, 18 Mar 2016 11:08:04 -0400 Received: from cpc86913-craw7-2-0-cust134.16-3.cable.virginm.net ([92.239.46.135] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1agw0P-0007mC-GP; Fri, 18 Mar 2016 15:08:01 +0000 From: Colin King To: "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, devel@acpica.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] ACPI / util: cast data to u64 before shifting to fix sign extension Date: Fri, 18 Mar 2016 15:08:01 +0000 Message-Id: <1458313681-24239-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.7.3 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King obj->buffer.pointer[i] should be cast to u64 to prevent an unintentional sign extension. For example, if pointer[7] is 0x80, then the value 0xffffffffff000000 is or'd into mask rather than the intended value 0xff00000000000000 Detected with static analysis by CoverityScan Signed-off-by: Colin Ian King --- drivers/acpi/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index f12a724..050673f 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -692,7 +692,7 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs) mask = obj->integer.value; else if (obj->type == ACPI_TYPE_BUFFER) for (i = 0; i < obj->buffer.length && i < 8; i++) - mask |= (((u8)obj->buffer.pointer[i]) << (i * 8)); + mask |= (((u64)obj->buffer.pointer[i]) << (i * 8)); ACPI_FREE(obj); /*