public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"afish@apple.com" <afish@apple.com>,
	Laszlo Ersek <lersek@redhat.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>,
	"bret.barkelew@microsoft.com" <Bret.Barkelew@microsoft.com>,
	"Wang, Jian J" <jian.j.wang@intel.com>,
	"Wu, Hao A" <hao.a.wu@intel.com>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	"Ni, Ray" <ray.ni@intel.com>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data
Date: Tue, 30 Mar 2021 01:35:44 +0000	[thread overview]
Message-ID: <MWHPR11MB16477863102ED893F637ADA2F67D9@MWHPR11MB1647.namprd11.prod.outlook.com> (raw)
In-Reply-To: <4834AF3E-A929-4911-AB8E-0665AB2033FB@apple.com>

[-- Attachment #1: Type: text/plain, Size: 3545 bytes --]

The patch would let the BMP file that with a bunch of data pass the check, no matter the data is valid or not. Do we have other docs to descript which data is allowed and valid?

Correct the Cc mail address and invite more experts for security review.

Thanks,
Zhichao

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Andrew Fish via groups.io
Sent: Thursday, March 25, 2021 11:00 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Laszlo Ersek <lersek@redhat.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>; bret.barkelew@microsoft.com; Wang, Jian J <jian.j.wang@intel.com>; ao.a.wu@intel.com
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data




On Mar 24, 2021, at 11:26 AM, Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>> wrote:

On 03/24/21 16:25, Jeff Brasen wrote:

Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0xE1038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0xE1038
  DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x2A3038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x2A3038
  DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x5EEC38
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x5EEC38
  DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.

If there's a spec describing the BMP format,

Yes and there are various flavors as at some point I had some graphics given to me in a format that did not work (I think it was BITMAPV4HEADER) :(.

https://en.wikipedia.org/wiki/BMP_file_format#cite_note-DIBhelp-5

edk2 supports ‘BM’ and the BITMAPINFOHEADER DIB. I seem to remember DIBs are defined by the size. So ‘BM' is a Microsoft Spec:
https://docs.microsoft.com/en-us/previous-versions/ms969901(v=msdn.10)?redirectedfrom=MSDN

The quote in that spec is:

The file extension of a Windows DIB file is BMP. The file consists of a BITMAPFILEHEADER structure followed by the DIB itself. Unfortunately, because the BITMAPFILEHEADER structure is never actually passed to the API, not every application that generates BMP files fills out the data structure carefully. To add to this confusion, the "proper" definition of the structure is at odds with the documentation. Properly, the data structure contains the following fields:


The explanation of size field is:
A DWORD that specifies the size of the file in bytes. The Microsoft Windows Software Development Kit (SDK) documentation claims otherwise. To be on the safe side, many applications calculate their own sizes for reading in a file.

I would say that is not exactly a ringing endorsement from a spec point of view on depending on that field. So it seems like that patch may be reasonable, but we should triple check it does not break any security related assumptions.

Thanks,

Andrew Fish


and edk2 is needlessly
strict, and the check can be relaxed without security risks, then I
think a patch would be fair.

Thanks
Laszlo







[-- Attachment #2: Type: text/html, Size: 9968 bytes --]

  reply	other threads:[~2021-03-30  1:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 17:29 [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data Jeff Brasen
2021-03-23 17:41 ` [EXTERNAL] [edk2-devel] " Bret Barkelew
2021-03-24 11:31   ` Laszlo Ersek
2021-03-24 15:25     ` Jeff Brasen
2021-03-24 18:26       ` Laszlo Ersek
2021-03-25  3:00         ` Andrew Fish
2021-03-30  1:35           ` Gao, Zhichao [this message]
2021-04-01 17:37             ` Bret Barkelew
2021-04-16 17:12               ` Jeff Brasen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR11MB16477863102ED893F637ADA2F67D9@MWHPR11MB1647.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox