* re: EFI: Stash ROMs if they're not in the PCI BAR
@ 2013-03-15 8:29 Dan Carpenter
[not found] ` <20130315082928.GA14520-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2013-03-15 8:29 UTC (permalink / raw)
To: matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA; +Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA
Hello Matthew Garrett,
The patch dd5fc854de5f: "EFI: Stash ROMs if they're not in the PCI
BAR" from Dec 5, 2012, leads to the following warning:
"arch/x86/boot/compressed/eboot.c:290 setup_efi_pci()
error: potentially dereferencing uninitialized 'pci_handle'."
254 static efi_status_t setup_efi_pci(struct boot_params *params)
255 {
256 efi_pci_io_protocol *pci;
257 efi_status_t status;
258 void **pci_handle;
259 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID;
260 unsigned long nr_pci, size = 0;
261 int i;
262 struct setup_data *data;
263
264 data = (struct setup_data *)(unsigned long)params->hdr.setup_data;
265
266 while (data && data->next)
267 data = (struct setup_data *)(unsigned long)data->next;
268
269 status = efi_call_phys5(sys_table->boottime->locate_handle,
270 EFI_LOCATE_BY_PROTOCOL, &pci_proto,
271 NULL, &size, pci_handle);
^^^^^^^^^^
This hasn't been initialized yet.
272
273 if (status == EFI_BUFFER_TOO_SMALL) {
274 status = efi_call_phys3(sys_table->boottime->allocate_pool,
275 EFI_LOADER_DATA, size, &pci_handle);
276
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread[parent not found: <20130315082928.GA14520-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>]
* Re: EFI: Stash ROMs if they're not in the PCI BAR [not found] ` <20130315082928.GA14520-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org> @ 2013-03-15 8:57 ` David Woodhouse [not found] ` <1363337872.2444.9.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: David Woodhouse @ 2013-03-15 8:57 UTC (permalink / raw) To: Dan Carpenter Cc: matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA, linux-efi-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1630 bytes --] On Fri, 2013-03-15 at 11:29 +0300, Dan Carpenter wrote: > Hello Matthew Garrett, > > The patch dd5fc854de5f: "EFI: Stash ROMs if they're not in the PCI > BAR" from Dec 5, 2012, leads to the following warning: > "arch/x86/boot/compressed/eboot.c:290 setup_efi_pci() > error: potentially dereferencing uninitialized 'pci_handle'." > > 254 static efi_status_t setup_efi_pci(struct boot_params *params) > 255 { > 256 efi_pci_io_protocol *pci; > 257 efi_status_t status; > 258 void **pci_handle; > 259 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; > 260 unsigned long nr_pci, size = 0; > 261 int i; > 262 struct setup_data *data; > 263 > 264 data = (struct setup_data *)(unsigned long)params->hdr.setup_data; > 265 > 266 while (data && data->next) > 267 data = (struct setup_data *)(unsigned long)data->next; > 268 > 269 status = efi_call_phys5(sys_table->boottime->locate_handle, > 270 EFI_LOCATE_BY_PROTOCOL, &pci_proto, > 271 NULL, &size, pci_handle); > ^^^^^^^^^^ > This hasn't been initialized yet. True. It probably doesn't *matter* because the size is zero so the firmware is just going to ignore the pointer anyway. Although in that case I wonder why we couldn't have just passed NULL. Perhaps we expected that some firmware might do some validation on the pointer before getting to the size check? -- dwmw2 [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 6171 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1363337872.2444.9.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org>]
* Re: EFI: Stash ROMs if they're not in the PCI BAR [not found] ` <1363337872.2444.9.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org> @ 2013-03-18 11:36 ` Matt Fleming [not found] ` <1363606563.15011.333.camel-ZqTwcBeJ+wsBof6jY8KHXm7IUlhRatedral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Matt Fleming @ 2013-03-18 11:36 UTC (permalink / raw) To: David Woodhouse Cc: Dan Carpenter, matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA, linux-efi-u79uwXL29TY76Z2rM5mHXA On Fri, 2013-03-15 at 08:57 +0000, David Woodhouse wrote: > On Fri, 2013-03-15 at 11:29 +0300, Dan Carpenter wrote: > > Hello Matthew Garrett, > > > > The patch dd5fc854de5f: "EFI: Stash ROMs if they're not in the PCI > > BAR" from Dec 5, 2012, leads to the following warning: > > "arch/x86/boot/compressed/eboot.c:290 setup_efi_pci() > > error: potentially dereferencing uninitialized 'pci_handle'." > > > > 254 static efi_status_t setup_efi_pci(struct boot_params *params) > > 255 { > > 256 efi_pci_io_protocol *pci; > > 257 efi_status_t status; > > 258 void **pci_handle; > > 259 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; > > 260 unsigned long nr_pci, size = 0; > > 261 int i; > > 262 struct setup_data *data; > > 263 > > 264 data = (struct setup_data *)(unsigned long)params->hdr.setup_data; > > 265 > > 266 while (data && data->next) > > 267 data = (struct setup_data *)(unsigned long)data->next; > > 268 > > 269 status = efi_call_phys5(sys_table->boottime->locate_handle, > > 270 EFI_LOCATE_BY_PROTOCOL, &pci_proto, > > 271 NULL, &size, pci_handle); > > ^^^^^^^^^^ > > This hasn't been initialized yet. > > True. It probably doesn't *matter* because the size is zero so the > firmware is just going to ignore the pointer anyway. Although in that > case I wonder why we couldn't have just passed NULL. Perhaps we expected > that some firmware might do some validation on the pointer before > getting to the size check? I doubt that the firmware checks the validity of pci_handle when size is zero, and I agree it's worth passing NULL to silence the warning (which is also more explicit that just initialising pci_handle), unless Matthew knows of a reason we shouldn't do that? -- Matt Fleming, Intel Open Source Technology Center ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1363606563.15011.333.camel-ZqTwcBeJ+wsBof6jY8KHXm7IUlhRatedral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: EFI: Stash ROMs if they're not in the PCI BAR [not found] ` <1363606563.15011.333.camel-ZqTwcBeJ+wsBof6jY8KHXm7IUlhRatedral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2013-03-18 16:02 ` Matthew Garrett [not found] ` <1363622520.2553.8.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Matthew Garrett @ 2013-03-18 16:02 UTC (permalink / raw) To: Matt Fleming Cc: David Woodhouse, Dan Carpenter, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Mon, 2013-03-18 at 11:36 +0000, Matt Fleming wrote: > On Fri, 2013-03-15 at 08:57 +0000, David Woodhouse wrote: > > True. It probably doesn't *matter* because the size is zero so the > > firmware is just going to ignore the pointer anyway. Although in that > > case I wonder why we couldn't have just passed NULL. Perhaps we expected > > that some firmware might do some validation on the pointer before > > getting to the size check? > > I doubt that the firmware checks the validity of pci_handle when size is > zero, and I agree it's worth passing NULL to silence the warning (which > is also more explicit that just initialising pci_handle), unless Matthew > knows of a reason we shouldn't do that? No reason I can think of, and any failure will be pretty immediately obvious. -- Matthew Garrett | mjg59@srcf.ucam.org ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1363622520.2553.8.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>]
* Re: EFI: Stash ROMs if they're not in the PCI BAR [not found] ` <1363622520.2553.8.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> @ 2013-03-20 8:44 ` Matt Fleming [not found] ` <514976F3.2-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org> 2013-03-20 9:27 ` David Woodhouse 1 sibling, 1 reply; 7+ messages in thread From: Matt Fleming @ 2013-03-20 8:44 UTC (permalink / raw) To: Matthew Garrett Cc: David Woodhouse, Dan Carpenter, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 03/18/2013 04:02 PM, Matthew Garrett wrote: > On Mon, 2013-03-18 at 11:36 +0000, Matt Fleming wrote: >> On Fri, 2013-03-15 at 08:57 +0000, David Woodhouse wrote: >>> True. It probably doesn't *matter* because the size is zero so the >>> firmware is just going to ignore the pointer anyway. Although in that >>> case I wonder why we couldn't have just passed NULL. Perhaps we expected >>> that some firmware might do some validation on the pointer before >>> getting to the size check? >> >> I doubt that the firmware checks the validity of pci_handle when size is >> zero, and I agree it's worth passing NULL to silence the warning (which >> is also more explicit that just initialising pci_handle), unless Matthew >> knows of a reason we shouldn't do that? > > No reason I can think of, and any failure will be pretty immediately > obvious. Anyone want to submit a patch? -- Matt Fleming, Intel Open Source Technology Center ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <514976F3.2-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>]
* Re: EFI: Stash ROMs if they're not in the PCI BAR [not found] ` <514976F3.2-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org> @ 2013-03-20 9:09 ` Dan Carpenter 0 siblings, 0 replies; 7+ messages in thread From: Dan Carpenter @ 2013-03-20 9:09 UTC (permalink / raw) To: Matt Fleming Cc: Matthew Garrett, David Woodhouse, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Wed, Mar 20, 2013 at 08:44:35AM +0000, Matt Fleming wrote: > On 03/18/2013 04:02 PM, Matthew Garrett wrote: > > On Mon, 2013-03-18 at 11:36 +0000, Matt Fleming wrote: > >> On Fri, 2013-03-15 at 08:57 +0000, David Woodhouse wrote: > >>> True. It probably doesn't *matter* because the size is zero so the > >>> firmware is just going to ignore the pointer anyway. Although in that > >>> case I wonder why we couldn't have just passed NULL. Perhaps we expected > >>> that some firmware might do some validation on the pointer before > >>> getting to the size check? > >> > >> I doubt that the firmware checks the validity of pci_handle when size is > >> zero, and I agree it's worth passing NULL to silence the warning (which > >> is also more explicit that just initialising pci_handle), unless Matthew > >> knows of a reason we shouldn't do that? > > > > No reason I can think of, and any failure will be pretty immediately > > obvious. > > Anyone want to submit a patch? > Sure. I'll send one tomorrow. regards, dan carpenter ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: EFI: Stash ROMs if they're not in the PCI BAR [not found] ` <1363622520.2553.8.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org> 2013-03-20 8:44 ` Matt Fleming @ 2013-03-20 9:27 ` David Woodhouse 1 sibling, 0 replies; 7+ messages in thread From: David Woodhouse @ 2013-03-20 9:27 UTC (permalink / raw) To: Matthew Garrett Cc: Matt Fleming, Dan Carpenter, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [-- Attachment #1: Type: text/plain, Size: 1954 bytes --] On Mon, 2013-03-18 at 16:02 +0000, Matthew Garrett wrote: > On Mon, 2013-03-18 at 11:36 +0000, Matt Fleming wrote: > > On Fri, 2013-03-15 at 08:57 +0000, David Woodhouse wrote: > > > True. It probably doesn't *matter* because the size is zero so the > > > firmware is just going to ignore the pointer anyway. Although in that > > > case I wonder why we couldn't have just passed NULL. Perhaps we expected > > > that some firmware might do some validation on the pointer before > > > getting to the size check? > > > > I doubt that the firmware checks the validity of pci_handle when size is > > zero, and I agree it's worth passing NULL to silence the warning (which > > is also more explicit that just initialising pci_handle), unless Matthew > > knows of a reason we shouldn't do that? > > No reason I can think of, and any failure will be pretty immediately > obvious. I agree with Matthew that I can think of no reason why a sane implementation of EFI would ever actually dereference the pointer in that case¹. But there's an important difference in the way I phrased it... I can't see why a *sane* implementation of EFI would do a lot of things. Many of which have actually been seen in the field, much to our distress. So I'm starting to to think "hm, maybe we should give it a valid pointer anyway, just in case". Remember: Any sufficiently advanced incompetence is indistinguishable from malice. Assuming malice on the part of firmware authors is a fairly good way to model their potential behaviour. So I'm perfectly prepared that someone would ship an implementation which does *no* input checking, ever. Except for gratuitously checking that particular pointer for NULL and bailing out with an 'invalid parameters' error, even if the length was zero. -- dwmw2 ¹ Although I haven't actually checked the spec to see if the pointer is required to be valid even when length is zero. [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 6171 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-20 9:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-15 8:29 EFI: Stash ROMs if they're not in the PCI BAR Dan Carpenter
[not found] ` <20130315082928.GA14520-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2013-03-15 8:57 ` David Woodhouse
[not found] ` <1363337872.2444.9.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org>
2013-03-18 11:36 ` Matt Fleming
[not found] ` <1363606563.15011.333.camel-ZqTwcBeJ+wsBof6jY8KHXm7IUlhRatedral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-03-18 16:02 ` Matthew Garrett
[not found] ` <1363622520.2553.8.camel-tCUS0Eywp2Pehftex57rkxo58HMYffqeLoYNBG0abjxeoWH0uzbU5w@public.gmane.org>
2013-03-20 8:44 ` Matt Fleming
[not found] ` <514976F3.2-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-03-20 9:09 ` Dan Carpenter
2013-03-20 9:27 ` David Woodhouse
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.