From nobody Sat Dec 21 16:51:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass(p=reject dis=none) header.from=seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1686058219; cv=none; d=zohomail.com; s=zohoarc; b=AgWwFsCVyaUXaJgQMMDw/nRqJuVm1QN0f4Qkn1nyCDqyxv14hjOiZwWPJ5teRwOT9X2Nq0WSm4W09xWWIlqt9SfbSJm7vFoZCTpcnoiYpphBYeZVoiVkVe7TPr9WVV7GE9U2CN+eX2G65QUWbyqdG9Ym/H8l6DxonJGrnmmc4Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686058219; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Subject:To; bh=Ex2jZhUBpi2qKy6Uo0liTwS8RNbzuKjaPtUERWzjOGw=; b=BuEPudDXYcM+VhzA4t7DOwI+ymJwVPvMb2lFmlEUZaa0D/L6DQQcdxynUquTFybFepetlGIklORysoS6V0DCnWMQYqV6L75I2WIRXImTCPuQPFiGXY5K8IxetmJvmF6oGhcCN1CJshfBvnUGBINwAXxZ+PNMD1HaxHN9jQ87XYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 168605821913045.94451187009054; Tue, 6 Jun 2023 06:30:19 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id E64C5215DA; Tue, 6 Jun 2023 13:30:13 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 9E202203CE for ; Tue, 6 Jun 2023 13:29:57 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Tue, 06 Jun 2023 06:29:57 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id la24-20020a170906ad9800b009745482c5b7sm5549679ejb.94.2023.06.06.06.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 06:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seabios.org; s=dkim; t=1686058215; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:list-id:list-owner:list-unsubscribe:list-subscribe:list-post; bh=Ex2jZhUBpi2qKy6Uo0liTwS8RNbzuKjaPtUERWzjOGw=; b=k4omdsq+KD6wxQCwI3eWIuCuQAM1pE3rNPGOZQmHkLEIxk1LT76K5KqOgBjMlYT2iZx9zv cJqFni/iY7Op0Pb2LPGGnP59wtkz0dQq8C9q32mzDvZZPPx/amsBBg8CIYsxxSTAOvlqNK YNOohTbGWrRdnU0+RTc3L/Qp4ybYlJc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=genesiscloud.com; s=genesiscloud.com; t=1686058197; x=1688650197; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kSTnPbTphz4TW1r0AMVtXC/WMRpsv17qMkEjJhz+gwI=; b=kekye3wFJ1jAZRuY3Hg9X3oLsO4yH/MYmu8MsSHenImSN3wvBwuCzgmvzdJO+zAR9J xxvLuAmsrQyG5yJw6BTYT/O/De8oZ9+TfOMf7Wu0COSlR+Mi5XJJQhnVFzOGRdyC1H+T 3CYrKnhGaJDP1dxA1SN2kieG2mqXoBX6y599lo3PD746an/mHsoTiCcc1bcXs9Fj299w AdUStepTcUbQdNnqtf4hvLDuHNMcNcld0KCtiWHsa46oH603LR6UnfNW8oEqXYiV4UiO tMVDyT0CXWdUCgTjl7hLWQQKvS7vA1tpODsWX7GPgMSLLiKic3TscfpbgKMhyexhNfLU fNrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686058197; x=1688650197; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kSTnPbTphz4TW1r0AMVtXC/WMRpsv17qMkEjJhz+gwI=; b=T9rZD4tMhFPhrhOoX2arrfheYisklAOcdbtqCr5dqLIv143NfE0lujo26B6mnlXPXl TUoyuXNgClR2fSK51PzbVWwdLkqG5nNOCirwFFUuJHkIGK3FAiFCGnh5mMaJ/WzbfpIH JG3t1oi20WRSw2dkhsfOCxge5IGfy1VSMv+dbLaH1YIEv7Nl7skma7jqZUia5jvM8xmi UeenA5YTAZQ+GIt4sbuZmMsNMgGel6MMy5SBtu+qmo2QeACQ56RAYlYcuAXWOh4B8jR/ dDp8wWvNeufjfHPgxyH1F48gkocQ+DkpWuyI/C7LwDfZvNA99JyzolA84z8EYAj6Pt2p OuAg== X-Gm-Message-State: AC+VfDxPuejvYbxNgVPCvTc93J89wUdKj8g7gO+a8XUA1HSnKMF0S6rK w6zhPnU3+KMMkxNbps5A7xf4HtrO+Hq5Tk9gUxhYs83BHuu20/XSmlIDYnASuCN5OEsvQxVrAAU l/hu6u/SLVBS8d3XmmozeOKawhHJ2OCYVlIdKAchlW6D6BzDRkTjUkgPkxHlY/yeKlXEsOKAS7j QCEjiv2UE= X-Google-Smtp-Source: ACHHUZ6MQD0qIGfNcLN2KUcJU9XYcND3rDLVyOj970CZHbys5MOm+wiDZsocbgairIEMvWqP8dgF6A== X-Received: by 2002:a17:907:161f:b0:974:623c:f136 with SMTP id hb31-20020a170907161f00b00974623cf136mr2343282ejc.21.1686058196737; Tue, 06 Jun 2023 06:29:56 -0700 (PDT) To: seabios@seabios.org Date: Tue, 6 Jun 2023 15:29:52 +0200 Message-ID: <20230606132952.2820557-1-lstockner@genesiscloud.com> MIME-Version: 1.0 X-Spam-Level: ** Message-ID-Hash: HBKBAJVQFJTD5CNQXCFBF62QAX6T2JG3 X-Message-ID-Hash: HBKBAJVQFJTD5CNQXCFBF62QAX6T2JG3 X-MailFrom: lstockner@genesiscloud.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Lukas Stockner X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH] virtio-blk: Fix integer overflow for large max IO sizes List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Lukas Stockner via SeaBIOS Reply-To: Lukas Stockner Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: pass (identity @seabios.org) X-ZM-MESSAGEID: 1686058220289100001 Content-Type: text/plain; charset="utf-8" When the maximum IO size supported by the virtio-blk backend is large enough (>=3D 32MiB for 512B sectors), the computed blk_num_max will overflow. In particular, if it's a multiple of 32MiB, blk_num_max will end up as zero, causing IO requests to fail. This is triggered by e.g. the SPDK virtio-blk vhost-user backend. To fix it, just limit blk_num_max to 65535 before converting to u16. Signed-off-by: Lukas Stockner --- src/hw/virtio-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index e087fe4..137a2c3 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -92,7 +92,7 @@ virtio_blk_op(struct disk_op_s *op, int write) u16 blk_num_max; =20 if (vdrive->drive.blksize !=3D 0 && max_io_size !=3D 0) - blk_num_max =3D (u16)(max_io_size / vdrive->drive.blksize); + blk_num_max =3D (u16) min(max_io_size / vdrive->drive.blksize, 0xf= fff); else /* default blk_num_max if hardware doesnot advise a proper value */ blk_num_max =3D 64; --=20 2.41.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org