From patchwork Thu Dec 27 11:51:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Hanselmann X-Patchwork-Id: 10743659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6E9913AD for ; Thu, 27 Dec 2018 11:54:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D420288BA for ; Thu, 27 Dec 2018 11:54:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80EA5288CA; Thu, 27 Dec 2018 11:54:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C45ED288BA for ; Thu, 27 Dec 2018 11:54:07 +0000 (UTC) Received: from localhost ([127.0.0.1]:51391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcUEo-0006Rz-K8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Dec 2018 06:54:06 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcUDu-0005iZ-7K for qemu-devel@nongnu.org; Thu, 27 Dec 2018 06:53:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gcUDq-0003Ir-Qs for qemu-devel@nongnu.org; Thu, 27 Dec 2018 06:53:10 -0500 Received: from mail-gateway-shared02.cyon.net ([194.126.200.224]:53040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gcUDq-0003Gq-Gs for qemu-devel@nongnu.org; Thu, 27 Dec 2018 06:53:06 -0500 Received: from s013.cyon.net ([149.126.4.22]) by mail-gateway-shared02.cyon.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim) (envelope-from ) id 1gcUDk-0005lE-TN for qemu-devel@nongnu.org; Thu, 27 Dec 2018 12:53:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hansmi.ch; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wzIMTble6C1BbDBSY6gXzkNcmvF9EHOX4ijSUV05AQU=; b=YRIXv231JCf52Eh+zHlqd8EcvH hdCd5GH/y9Q82/07CCfrlz2DI7Br0+qQkby5elJu44egvKaIX7znaBppeqW97PmIwFUzyz3uhST2r mXNY2QWDQUDdXZzRd2x/6f+iZ3+8pq9Osn+xccweOZtqdkb/8VN76+gJTXn8UzMkLugc=; Received: from [10.20.10.233] (port=50272 helo=mail.cyon.ch) by s013.cyon.net with esmtpa (Exim 4.91) (envelope-from ) id 1gcUDj-003BE4-NA; Thu, 27 Dec 2018 12:52:59 +0100 Received: from hansmi by lepus.hansmi.ch with local (Exim 4.89) (envelope-from ) id 1gcUDj-0001hu-6r; Thu, 27 Dec 2018 11:52:59 +0000 From: Michael Hanselmann To: qemu-devel@nongnu.org Date: Thu, 27 Dec 2018 11:51:55 +0000 Message-Id: X-Mailer: git-send-email 2.11.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - s013.cyon.net X-AntiAbuse: Original Domain - nongnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hansmi.ch X-Get-Message-Sender-Via: s013.cyon.net: authenticated_id: mailrelay-cervus@hansmi.ch X-Authenticated-Sender: s013.cyon.net: mailrelay-cervus@hansmi.ch X-Source: X-Source-Args: X-Source-Dir: X-OutGoing-Spam-Status: No, score=-0.8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.126.200.224 Subject: [Qemu-devel] [PATCH] smbus_eeprom: Limit data writes to 255 bytes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Michael Hanselmann , mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The "eeprom_write_data" function in "smbus_eeprom.c" had no provisions to limit the length of data written. If a caller were able to manipulate the "len" parameter they could potentially write before or after the target buffer. Signed-off-by: Michael Hanselmann --- hw/i2c/smbus_eeprom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index f18aa3de35..74fa1c328c 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -76,6 +76,7 @@ static void eeprom_write_data(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, int l It is a block write without a length byte. Fortunately we get the full block anyway. */ /* TODO: Should this set the current location? */ + len &= 0xff; if (cmd + len > 256) n = 256 - cmd; else