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 88A17C0015E for ; Mon, 24 Jul 2023 14:53:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 41C038682A; Mon, 24 Jul 2023 16:52:48 +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="YbV4/Wf1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E8DAF86806; Mon, 24 Jul 2023 16:52:27 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 750E586721 for ; Mon, 24 Jul 2023 16:52:25 +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-xd32.google.com with SMTP id ca18e2360f4ac-76c64da0e46so198023139f.0 for ; Mon, 24 Jul 2023 07:52:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690210344; x=1690815144; 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=7OmE46c0wCU9ELWoP+XprdQn4zVPRG8NARQ8gbrAxWk=; b=YbV4/Wf1SOjRaEJIrRMJUKgU7WjNrVpjgDK35Pq5vIrNB00KciCYvscT8RXFIagpWt t18jPjci+gWxpjBZoznjRyoHesSKo3S0fmpqkMbWWoWS8arQJuNxI8B0iyCuXNZe6vSp 0eFuj4vIPctmiUtND/UaoO2vj59mse+FJp62k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690210344; x=1690815144; 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=7OmE46c0wCU9ELWoP+XprdQn4zVPRG8NARQ8gbrAxWk=; b=YaOdYYG6Go1ZaOJnofIFkNV9gF9XJZvHX3YBAaAOp5AR3a4w3NclO7iNcWdKugvlTP gbemxHXBEU/Jqx0RxLh0OfuVPuyMSd1Lu8uFX7D1RviWWjXRPz88y/LK0kOQaJg8cjJw PT/TxR8lAqM8zInwWZIKyGB2Os77fBZU7TMY3Xhf+xFJp5C/tr69MruKbpmjNT+S68Hh NOpTFCpDz6EvA/QrMIK9ad9c0dHMeinQNFrirWid5I1lnVMzSLeI+MCGLtsj9DkToW5F bdrk1Nz8TzEAykcMzMt1r/BFhwYjuPTlbP6woG0CDVQB2Kz+3q30IyenlemnG51xLOvE ceyw== X-Gm-Message-State: ABy/qLZ30kF0jZq3wXAYHbusFe18uqQionSXgIQjo7UsJVSkp6kjsiQX g7zaQxua52lUDtQWW33+cvkkWodHeaWTqnM3AqI= X-Google-Smtp-Source: APBJJlEWcFb41KGW4ezehxgkEVosbT8hOve7jT8VrZT79jzsYM+8+7k1mO/ApwtD49Re3D8QwW3e1Q== X-Received: by 2002:a6b:7618:0:b0:783:62d0:88c with SMTP id g24-20020a6b7618000000b0078362d0088cmr107487iom.19.1690210344068; Mon, 24 Jul 2023 07:52:24 -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 n12-20020a5d824c000000b007862c74cec6sm3462225ioo.1.2023.07.24.07.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 07:52:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 6/9] x86: Correct copying of BIOS mode information Date: Mon, 24 Jul 2023 08:52:02 -0600 Message-ID: <20230724145210.304917-6-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230724145210.304917-1-sjg@chromium.org> References: <20230724145210.304917-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 a constant for the buffer size. 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") --- arch/x86/lib/bios.c | 2 +- include/vesa.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c index e29cae78e509..3a9d7f5ddd41 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, VESA_MODE_INFO_SIZE); mi->valid = true; return 0; diff --git a/include/vesa.h b/include/vesa.h index 9285bfa921a2..28828ab56aa4 100644 --- a/include/vesa.h +++ b/include/vesa.h @@ -83,12 +83,14 @@ struct __packed vesa_mode_info { u8 reserved[206]; }; +#define VESA_MODE_INFO_SIZE 256 + struct vesa_state { u16 video_mode; bool valid; union { struct vesa_mode_info vesa; - u8 mode_info_block[256]; + u8 mode_info_block[VESA_MODE_INFO_SIZE]; }; }; -- 2.41.0.487.g6d72f3e995-goog