Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A14AC00528 for ; Sun, 30 Jul 2023 17:17:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30EFE86A5F; Sun, 30 Jul 2023 19:16:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UiTxTK2t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A835A86A37; Sun, 30 Jul 2023 19:16:35 +0200 (CEST) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7A0DB8692B for ; Sun, 30 Jul 2023 19:16:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7878e573827so146014139f.1 for ; Sun, 30 Jul 2023 10:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690737389; x=1691342189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aVuaeJhNsaby4f/2wJGZdc+2cW1L1IKbUt1cRlt1bOQ=; b=UiTxTK2tAdm+z46ClX9r1f4W7PfMB5Nr74oUYFJR6dh9efxNCDDr4BmMw8jmjIw/Jp mSoij8lPYiBVAmUoEIG9+Np7y88oCHql4kOSrauqTegvS1h1cL3sf+PrQm38n+1XYgg8 YlrD2pf63oqOwzbG9Epi4zKVmA7h2+0VtU1e4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690737389; x=1691342189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aVuaeJhNsaby4f/2wJGZdc+2cW1L1IKbUt1cRlt1bOQ=; b=iKnLrB3myFrK4jnLgpV1HR50HBH/rQ9z+LAm7Yui3eyCbAHCJR2nJonZzxs32ZSU0U oidl9VMeaaOTmXalQ867blp1qgDZSK1f7zrAsEm7s+ZzHwQAlWHIfkqD3ZmRNFcpa4/p mHBqJxc5NwSEKQ8vmNUQcM5oNrWqVi5l11Bd5JyQr0LS/JhW5BDQxPoZjPuonS/tFDfu xpSTs/aMjxvyYqgZvnO0GcDYqfJz9UDIzpaPSgOQMcrRKy89v46Dp4MCVj2Cled5iamK cYMHd2UXkV459b2eCheDJq7jZwHFGSMbSWoV18Jm0r3QsxhSC+HCYbR7mfOuMJG7J44o h26Q== X-Gm-Message-State: ABy/qLbVxB/GtOttSpVI4mj43Rw6nCRl8Xher305ifNZl0HjsqOe3SzF XhInCiKFwC6hbJsHamYaB3zHvadg6gjDlZzBq+w= X-Google-Smtp-Source: APBJJlEq4v3kH3aVIa8u0JCTUDdKbNtkZVI6HVGUh9fB5atGQQe6FnH/Jv5PygdWuL3eYACB1L5Hwg== X-Received: by 2002:a05:6e02:1486:b0:345:a01b:45a with SMTP id n6-20020a056e02148600b00345a01b045amr8066302ilk.19.1690737389137; Sun, 30 Jul 2023 10:16:29 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a02cd81000000b0042b57bbbaf2sm2519732jap.26.2023.07.30.10.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 10:16:28 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Bin Meng Subject: [PATCH v2 6/9] x86: Correct copying of BIOS mode information Date: Sun, 30 Jul 2023 11:16:04 -0600 Message-ID: <20230730171619.915576-6-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230730171619.915576-1-sjg@chromium.org> References: <20230730171619.915576-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This is copying beyond the end of the destination buffer. Correct the code by using the size of the vesa_mode_info struct. We don't need to copy the rest of the bytes in the buffer. This long-standing bug prevents virtio bootdevs working correctly on qemu-x86 at present. Signed-off-by: Simon Glass Fixes: 0ca2426beae ("x86: Add support for running option ROMs natively") Reviewed-by: Bin Meng --- Changes in v2: - Use sizeof(struct vesa_mode_info) instead arch/x86/lib/bios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c index e29cae78e509..f146bbd54227 100644 --- a/arch/x86/lib/bios.c +++ b/arch/x86/lib/bios.c @@ -204,7 +204,7 @@ static u8 vbe_get_mode_info(struct vesa_state *mi) realmode_interrupt(0x10, VESA_GET_MODE_INFO, 0x0000, mi->video_mode, 0x0000, buffer_seg, buffer_adr); - memcpy(mi->mode_info_block, buffer, sizeof(struct vesa_state)); + memcpy(mi->mode_info_block, buffer, sizeof(struct vesa_mode_info)); mi->valid = true; return 0; -- 2.41.0.487.g6d72f3e995-goog