From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 16B33941A78 for ; Wed, 3 Jan 2024 13:09:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ovfX4rPXUUOQiUo8RuLZWy+19gas9yQgyajBg45Y5mo=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1704287357; v=1; b=axHu+KtszUMm1d90/TFikBEIX2Uy9PvD1yTScqqe3bsysEHgtYL+2AmBYkWVg3G2QfHFcxy5 OKo3KBufEKcWOIk/6TeOOQCUom5DYZ4EZm24SZkQVB+uupf2WHoQeyqB9s9Vb7bRsFt0GaDvelW PncaqHgijm+HHs7Im8NU9FRc= X-Received: by 127.0.0.2 with SMTP id mhoZYY7687511x7Qh2tZPtV8; Wed, 03 Jan 2024 05:09:17 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.16997.1704287357007041866 for ; Wed, 03 Jan 2024 05:09:17 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-aYXVUH1tMFOlRfi5KsnM4w-1; Wed, 03 Jan 2024 08:09:11 -0500 X-MC-Unique: aYXVUH1tMFOlRfi5KsnM4w-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6DBCC85A588; Wed, 3 Jan 2024 13:09:11 +0000 (UTC) X-Received: from [10.39.193.243] (unknown [10.39.193.243]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79A26492BC6; Wed, 3 Jan 2024 13:09:10 +0000 (UTC) Message-ID: <9c5074b8-767d-dd64-b68c-ec5cb6b5e743@redhat.com> Date: Wed, 3 Jan 2024 14:09:09 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v3 1/1] OvmfPkg/VirtNorFlashDxe: sanity-check variables From: "Laszlo Ersek" To: devel@edk2.groups.io, kraxel@redhat.com Cc: Ard Biesheuvel , oliver@redhat.com, mike.maslenkin@gmail.com, Jiewen Yao References: <20231214153156.46812-1-kraxel@redhat.com> In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: yYCXTUVT8r5FpS8OJpTU10vTx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=axHu+Kts; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 1/3/24 13:56, Laszlo Ersek wrote: > (8) Apologies if it was me who suggested ALIGN_VALUE() previously, but > this is, in effect, an unchecked addition. I can't off-hand see evidence > that it can never overflow (the previous checks don't seem to prevent an > overflow here), so I suggest: >=20 > // > // the next variable header starts aligned at 4 bytes > // > Status =3D SafeUintnAdd (VarEnd, (4 - (VarEnd & 4)) & 4, &VarOffset); > if RETURN_ERROR (Status) { > DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); > return EFI_NOT_FOUND; > } Heh, what I wrote is bogus. Man, binary is hard. :) So, let me try again: Status =3D SafeUintnAdd (VarEnd, (4 - (VarEnd & 3)) & 3, &VarOffset); Ideally, we'd have a SafeIntLib set of APIs for aligning up... Sorry :) Laszlo -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113087): https://edk2.groups.io/g/devel/message/113087 Mute This Topic: https://groups.io/mt/103171811/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-