iPXE
efi_veto.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
21 FILE_SECBOOT ( PERMITTED );
22 
23 #include <stddef.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <errno.h>
27 #include <ipxe/settings.h>
28 #include <ipxe/pci.h>
29 #include <ipxe/efi/efi.h>
34 #include <ipxe/efi/efi_veto.h>
35 
36 /** @file
37  *
38  * EFI driver vetoes
39  *
40  */
41 
42 /** A driver veto candidate */
44  /** Veto name (for debugging) */
45  const char *name;
46  /**
47  * Check if driver is vetoed
48  *
49  * @v binding Driver binding protocol
50  * @v loaded Loaded image protocol
51  * @v manufacturer Manufacturer name, if present
52  * @v name Driver name, if present
53  * @ret vetoed Driver is to be vetoed
54  */
55  int ( * veto ) ( EFI_DRIVER_BINDING_PROTOCOL *binding,
57  const char *manufacturer, const CHAR16 *name );
58 };
59 
60 /** A driver veto */
61 struct efi_veto {
62  /** Driver binding handle */
64  /** Driving binding protocol */
66  /** Image handle */
68  /** Loaded image protocol */
70 };
71 
72 /**
73  * Unload an EFI driver
74  *
75  * @v veto Driver veto
76  * @ret rc Return status code
77  */
78 static int efi_veto_unload ( struct efi_veto *veto ) {
80  EFI_HANDLE driver = veto->driver;
81  EFI_HANDLE image = veto->image;
82  EFI_STATUS efirc;
83  int rc;
84 
85  /* Unload the driver */
86  if ( ( efirc = bs->UnloadImage ( image ) ) != 0 ) {
87  rc = -EEFI ( efirc );
88  DBGC ( driver, "EFIVETO %s could not unload",
89  efi_handle_name ( driver ) );
90  DBGC ( driver, " %s: %s\n", efi_handle_name ( image ),
91  strerror ( rc ) );
92  return rc;
93  }
94 
95  return 0;
96 }
97 
98 /**
99  * Disconnect an EFI driver from all handles
100  *
101  * @v veto Driver veto
102  * @ret rc Return status code
103  */
104 static int efi_veto_disconnect ( struct efi_veto *veto ) {
106  EFI_HANDLE driver = veto->driver;
107  EFI_HANDLE *handles;
109  UINTN count;
110  unsigned int i;
111  EFI_STATUS efirc;
112  int rc;
113 
114  /* Enumerate all handles */
115  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
116  &count, &handles ) ) != 0 ) {
117  rc = -EEFI ( efirc );
118  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
119  efi_handle_name ( driver ), strerror ( rc ) );
120  goto err_list;
121  }
122 
123  /* Disconnect driver from all handles, in reverse order */
124  for ( i = 0 ; i < count ; i++ ) {
125  handle = handles[ count - i - 1 ];
126  if ( ( rc = efi_disconnect ( handle, driver ) ) != 0 ) {
127  DBGC ( driver, "EFIVETO %s could not disconnect",
128  efi_handle_name ( driver ) );
129  DBGC ( driver, " %s: %s\n",
130  efi_handle_name ( handle ), strerror ( rc ) );
131  goto err_disconnect;
132  }
133  }
134 
135  /* Success */
136  rc = 0;
137  DBGC2 ( driver, "EFIVETO %s disconnected all handles\n",
138  efi_handle_name ( driver ) );
139 
140  err_disconnect:
141  bs->FreePool ( handles );
142  err_list:
143  return rc;
144 }
145 
146 /**
147  * Uninstall an EFI driver binding protocol
148  *
149  * @v veto Driver veto
150  * @ret rc Return status code
151  */
152 static int efi_veto_uninstall ( struct efi_veto *veto ) {
154  EFI_HANDLE driver = veto->driver;
156  EFI_STATUS efirc;
157  int rc;
158 
159  /* Open driver binding protocol */
160  if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
161  &binding ) ) != 0 ) {
162  DBGC ( driver, "EFIVETO %s could not open driver binding "
163  "protocol: %s\n", efi_handle_name ( driver ),
164  strerror ( rc ) );
165  return rc;
166  }
167 
168  /* Uninstall driver binding protocol */
169  if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
171  binding, NULL ) ) != 0 ) {
172  rc = -EEFI ( efirc );
173  DBGC ( driver, "EFIVETO %s could not uninstall driver "
174  "binding protocol: %s\n",
175  efi_handle_name ( driver ), strerror ( rc ) );
176  return rc;
177  }
178 
179  DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
180  efi_handle_name ( driver ) );
181  return 0;
182 }
183 
184 /**
185  * Close protocol on handle potentially opened by an EFI driver
186  *
187  * @v veto Driver veto
188  * @v handle Potentially opened handle
189  * @v protocol Opened protocol
190  * @ret rc Return status code
191  */
193  EFI_GUID *protocol ) {
195  EFI_HANDLE driver = veto->driver;
196  EFI_HANDLE image = veto->image;
200  UINTN count;
201  unsigned int i;
202  EFI_STATUS efirc;
203  int rc;
204 
205  /* Retrieve list of openers */
206  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
207  &count ) ) != 0 ) {
208  rc = -EEFI ( efirc );
209  DBGC ( driver, "EFIVETO %s could not retrieve openers",
210  efi_handle_name ( driver ) );
211  DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
212  efi_guid_ntoa ( protocol ), strerror ( rc ) );
213  goto err_list;
214  }
215 
216  /* Close anything opened by this driver */
217  for ( i = 0 ; i < count ; i++ ) {
218  opener = &openers[ count - i - 1 ];
219  if ( ( opener->AgentHandle != driver ) &&
220  ( opener->AgentHandle != image ) ) {
221  continue;
222  }
223  controller = opener->ControllerHandle;
224  DBGC_EFI_OPENER ( driver, handle, protocol, opener );
225  if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
226  controller ) ) != 0 ) {
227  rc = -EEFI ( efirc );
228  DBGC ( driver, "EFIVETO %s could not close stray open",
229  efi_handle_name ( driver ) );
230  DBGC ( driver, " of %s: %s\n",
231  efi_handle_name ( handle ), strerror ( rc ) );
232  goto err_close;
233  }
234  }
235 
236  /* Success */
237  rc = 0;
238 
239  err_close:
240  bs->FreePool ( openers );
241  err_list:
242  return rc;
243 }
244 
245 /**
246  * Close handle potentially opened by an EFI driver
247  *
248  * @v veto Driver veto
249  * @v handle Potentially opened handle
250  * @ret rc Return status code
251  */
252 static int efi_veto_close_handle ( struct efi_veto *veto, EFI_HANDLE handle ) {
254  EFI_HANDLE driver = veto->driver;
255  EFI_GUID **protocols;
257  UINTN count;
258  unsigned int i;
259  EFI_STATUS efirc;
260  int rc;
261 
262  /* Retrieve list of protocols */
263  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
264  &count ) ) != 0 ) {
265  rc = -EEFI ( efirc );
266  DBGC ( driver, "EFIVETO %s could not retrieve protocols",
267  efi_handle_name ( driver ) );
268  DBGC ( driver, " for %s: %s\n",
269  efi_handle_name ( handle ), strerror ( rc ) );
270  goto err_list;
271  }
272 
273  /* Close each protocol */
274  for ( i = 0 ; i < count ; i++ ) {
275  protocol = protocols[ count - i - 1];
276  if ( ( rc = efi_veto_close_protocol ( veto, handle,
277  protocol ) ) != 0 )
278  goto err_close;
279  }
280 
281  /* Success */
282  rc = 0;
283 
284  err_close:
285  bs->FreePool ( protocols );
286  err_list:
287  return rc;
288 }
289 
290 /**
291  * Close all remaining handles opened by an EFI driver
292  *
293  * @v veto Driver veto
294  * @ret rc Return status code
295  */
296 static int efi_veto_close ( struct efi_veto *veto ) {
298  EFI_HANDLE driver = veto->driver;
299  EFI_HANDLE *handles;
301  UINTN count;
302  unsigned int i;
303  EFI_STATUS efirc;
304  int rc;
305 
306  /* Enumerate all handles */
307  if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
308  &count, &handles ) ) != 0 ) {
309  rc = -EEFI ( efirc );
310  DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
311  efi_handle_name ( driver ), strerror ( rc ) );
312  goto err_list;
313  }
314 
315  /* Close each handle */
316  for ( i = 0 ; i < count ; i++ ) {
317  handle = handles[ count - i - 1 ];
318  if ( ( rc = efi_veto_close_handle ( veto, handle ) ) != 0 )
319  goto err_close;
320  }
321 
322  /* Success */
323  rc = 0;
324  DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
325  efi_handle_name ( driver ) );
326 
327  err_close:
328  bs->FreePool ( handles );
329  err_list:
330  return rc;
331 }
332 
333 /**
334  * Terminate an EFI driver with extreme prejudice
335  *
336  * @v veto Driver veto
337  * @ret rc Return status code
338  */
339 static int efi_veto_destroy ( struct efi_veto *veto ) {
340  EFI_HANDLE driver = veto->driver;
341  int rc;
342 
343  /* Disconnect driver from all handles */
344  if ( ( rc = efi_veto_disconnect ( veto ) ) != 0 )
345  return rc;
346 
347  /* Uninstall driver binding protocol */
348  if ( ( rc = efi_veto_uninstall ( veto ) ) != 0 )
349  return rc;
350 
351  /* Close any remaining opened handles */
352  if ( ( rc = efi_veto_close ( veto ) ) != 0 )
353  return rc;
354 
355  DBGC ( driver, "EFIVETO %s forcibly removed\n",
356  efi_handle_name ( driver ) );
357  return 0;
358 }
359 
360 /**
361  * Veto an EFI driver
362  *
363  * @v veto Driver veto
364  * @ret rc Return status code
365  */
366 static int efi_veto_driver ( struct efi_veto *veto ) {
367  int rc;
368 
369  /* Try gracefully unloading the driver */
370  if ( ( rc = efi_veto_unload ( veto ) ) == 0 )
371  return 0;
372 
373  /* If that fails, use a hammer */
374  if ( ( rc = efi_veto_destroy ( veto ) ) == 0 )
375  return 0;
376 
377  return rc;
378 }
379 
380 /**
381  * Veto Ip4ConfigDxe driver on some platforms
382  *
383  * @v binding Driver binding protocol
384  * @v loaded Loaded image protocol
385  * @v manufacturer Manufacturer name, if present
386  * @v name Driver name, if present
387  * @ret vetoed Driver is to be vetoed
388  */
389 static int
392  const char *manufacturer, const CHAR16 *name ) {
393  static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
394  static const char *dell = "Dell Inc.";
395  static const char *itautec = "Itautec S.A.";
396 
397  /* Check manufacturer and driver name */
398  if ( ! manufacturer )
399  return 0;
400  if ( ! name )
401  return 0;
402  if ( ( strcmp ( manufacturer, dell ) != 0 ) &&
403  ( strcmp ( manufacturer, itautec ) != 0 ) )
404  return 0;
405  if ( memcmp ( name, ip4cfg, sizeof ( ip4cfg ) ) != 0 )
406  return 0;
407 
408  return 1;
409 }
410 
411 /**
412  * Veto HP XhciDxe driver
413  *
414  * @v binding Driver binding protocol
415  * @v loaded Loaded image protocol
416  * @v manufacturer Manufacturer name, if present
417  * @v name Driver name, if present
418  * @ret vetoed Driver is to be vetoed
419  */
420 static int
423  const char *manufacturer, const CHAR16 *name ) {
424  static const CHAR16 xhci[] = L"Usb Xhci Driver";
425  static const char *hp = "HP";
426  struct pci_driver *driver;
427 
428  /* Check manufacturer and driver name */
429  if ( ! manufacturer )
430  return 0;
431  if ( ! name )
432  return 0;
433  if ( strcmp ( manufacturer, hp ) != 0 )
434  return 0;
435  if ( memcmp ( name, xhci, sizeof ( xhci ) ) != 0 )
436  return 0;
437 
438  /* Veto driver only if we have our own xHCI driver */
439  for_each_table_entry ( driver, PCI_DRIVERS ) {
440  if ( driver->class.class ==
443  return 1;
444  }
445  }
446 
447  return 0;
448 }
449 
450 /**
451  * Veto VMware UefiPxeBcDxe driver
452  *
453  * @v binding Driver binding protocol
454  * @v loaded Loaded image protocol
455  * @v manufacturer Manufacturer name, if present
456  * @v name Driver name, if present
457  * @ret vetoed Driver is to be vetoed
458  */
459 static int
462  const char *manufacturer, const CHAR16 *name ) {
463  static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
464  static const char *vmware = "VMware, Inc.";
465 
466  /* Check manufacturer and driver name */
467  if ( ! manufacturer )
468  return 0;
469  if ( ! name )
470  return 0;
471  if ( strcmp ( manufacturer, vmware ) != 0 )
472  return 0;
473  if ( memcmp ( name, uefipxebc, sizeof ( uefipxebc ) ) != 0 )
474  return 0;
475 
476  return 1;
477 }
478 
479 /**
480  * Veto Dhcp6Dxe driver
481  *
482  * @v binding Driver binding protocol
483  * @v loaded Loaded image protocol
484  * @v manufacturer Manufacturer name, if present
485  * @v name Driver name, if present
486  * @ret vetoed Driver is to be vetoed
487  */
490  const char *manufacturer __unused,
491  const CHAR16 *name ) {
492  static const CHAR16 dhcp6[] = L"DHCP6 Protocol Driver";
493 
494  /* Check driver name */
495  if ( ! name )
496  return 0;
497  if ( memcmp ( name, dhcp6, sizeof ( dhcp6 ) ) != 0 )
498  return 0;
499 
500  return 1;
501 }
502 
503 /** Driver vetoes */
504 static struct efi_veto_candidate efi_vetoes[] = {
505  {
506  .name = "Ip4Config",
507  .veto = efi_veto_ip4config,
508  },
509  {
510  .name = "HP Xhci",
511  .veto = efi_veto_hp_xhci,
512  },
513  {
514  .name = "VMware UefiPxeBc",
516  },
517  {
518  .name = "Dhcp6",
519  .veto = efi_veto_dhcp6,
520  },
521 };
522 
523 /**
524  * Find driver veto, if any
525  *
526  * @v driver Driver binding handle
527  * @v manufacturer Manufacturer name, if present
528  * @ret veto Driver veto to fill in
529  * @ret rc Return status code
530  */
531 static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
532  struct efi_veto *veto ) {
537  CHAR16 *name;
538  unsigned int i;
540  EFI_STATUS efirc;
541  int rc;
542 
543  /* Mark as not vetoed */
544  memset ( veto, 0, sizeof ( *veto ) );
545 
546  /* Open driver binding protocol */
547  if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
548  &binding ) ) != 0 ) {
549  DBGC ( driver, "EFIVETO %s could not open driver binding "
550  "protocol: %s\n", efi_handle_name ( driver ),
551  strerror ( rc ) );
552  return rc;
553  }
554  image = binding->ImageHandle;
555 
556  /* Open loaded image protocol */
558  &loaded ) ) != 0 ) {
559  DBGC ( driver, "EFIVETO %s could not open",
560  efi_handle_name ( driver ) );
561  DBGC ( driver, " %s loaded image protocol: %s\n",
562  efi_handle_name ( image ), strerror ( rc ) );
563  return rc;
564  }
565 
566  /* Open component name protocol, if present */
568  &wtf2 ) ) != 0 ) {
569  /* Ignore failure; is not required to be present */
570  }
571 
572  /* Open obsolete component name protocol, if present */
574  &wtf ) ) != 0 ) {
575  /* Ignore failure; is not required to be present */
576  }
577 
578  /* Get driver name, if available */
579  if ( ( wtf2 && ( ( efirc = wtf2->GetDriverName ( wtf2, "en",
580  &name ) == 0 ) ) ) ||
581  ( wtf && ( ( efirc = wtf->GetDriverName ( wtf, "eng",
582  &name ) == 0 ) ) ) ) {
583  /* Driver has a name */
584  } else {
585  /* Ignore failure; name is not required to be present */
586  name = NULL;
587  }
588 
589  /* Check vetoes */
590  DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n",
591  efi_handle_name ( driver ), loaded->ImageBase,
592  ( loaded->ImageBase + loaded->ImageSize ) );
593  for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
594  sizeof ( efi_vetoes[0] ) ) ; i++ ) {
595  if ( efi_vetoes[i].veto ( binding, loaded, manufacturer,
596  name ) ) {
597  DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
598  efi_handle_name ( driver ),
599  efi_vetoes[i].name );
600  veto->driver = driver;
601  veto->binding = binding;
602  veto->image = image;
603  veto->loaded = loaded;
604  break;
605  }
606  }
607 
608  return 0;
609 }
610 
611 /**
612  * Remove any vetoed drivers
613  *
614  */
615 void efi_veto ( void ) {
617  struct efi_veto veto;
618  EFI_HANDLE *drivers;
620  UINTN count;
621  unsigned int i;
622  char *manufacturer;
623  EFI_STATUS efirc;
624  int rc;
625 
626  /* Locate all driver binding protocol handles */
627  if ( ( efirc = bs->LocateHandleBuffer (
629  NULL, &count, &drivers ) ) != 0 ) {
630  rc = -EEFI ( efirc );
631  DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
632  "%s\n", strerror ( rc ) );
633  return;
634  }
635 
636  /* Get manufacturer name */
637  fetch_string_setting_copy ( NULL, &manufacturer_setting,
638  &manufacturer );
639  DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
640 
641  /* Unload any vetoed drivers */
642  for ( i = 0 ; i < count ; i++ ) {
643  driver = drivers[ count - i - 1 ];
644  if ( ( rc = efi_veto_find ( driver, manufacturer,
645  &veto ) ) != 0 ) {
646  DBGC ( driver, "EFIVETO %s could not determine "
647  "vetoing: %s\n",
648  efi_handle_name ( driver ), strerror ( rc ) );
649  continue;
650  }
651  if ( ! veto.driver )
652  continue;
653  if ( ( rc = efi_veto_driver ( &veto ) ) != 0 ) {
654  DBGC ( driver, "EFIVETO %s could not veto: %s\n",
655  efi_handle_name ( driver ), strerror ( rc ) );
656  }
657  }
658 
659  /* Free manufacturer name */
660  free ( manufacturer );
661 
662  /* Free handle list */
663  bs->FreePool ( drivers );
664 }
UEFI DriverBinding Protocol is defined in UEFI specification.
static int efi_veto_vmware_uefipxebc(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer, const CHAR16 *name)
Veto VMware UefiPxeBcDxe driver.
Definition: efi_veto.c:460
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
const char * name
Veto name (for debugging)
Definition: efi_veto.c:45
int(* veto)(EFI_DRIVER_BINDING_PROTOCOL *binding, EFI_LOADED_IMAGE_PROTOCOL *loaded, const char *manufacturer, const CHAR16 *name)
Check if driver is vetoed.
Definition: efi_veto.c:55
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1986
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1432
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
struct pci_class_id class
PCI class ID.
Definition: pci.h:258
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:175
static int efi_veto_close_handle(struct efi_veto *veto, EFI_HANDLE handle)
Close handle potentially opened by an EFI driver.
Definition: efi_veto.c:252
A PCI driver.
Definition: pci.h:252
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1434
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
void efi_veto(void)
Remove any vetoed drivers.
Definition: efi_veto.c:615
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1433
EFI_HANDLE image
Image handle.
Definition: efi_veto.c:67
static int efi_veto_driver(struct efi_veto *veto)
Veto an EFI driver.
Definition: efi_veto.c:366
128 bit buffer containing a unique identifier value.
Definition: Base.h:216
UINT64 ImageSize
The size in bytes of the loaded image.
Definition: LoadedImage.h:71
Error codes.
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1522
static int efi_veto_uninstall(struct efi_veto *veto)
Uninstall an EFI driver binding protocol.
Definition: efi_veto.c:152
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:273
A driver veto candidate.
Definition: efi_veto.c:43
static int efi_veto_ip4config(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer, const CHAR16 *name)
Veto Ip4ConfigDxe driver on some platforms.
Definition: efi_veto.c:390
EFI driver vetoes.
unsigned short CHAR16
uint32_t class
Class.
Definition: pci.h:192
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1981
An executable image.
Definition: image.h:24
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:70
EFI Component Name Protocol as defined in the EFI 1.1 specification.
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:2001
static int efi_veto_find(EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto)
Find driver veto, if any.
Definition: efi_veto.c:531
#define PCI_CLASS_SERIAL_USB_XHCI
xHCI USB controller
Definition: pci.h:141
FILE_SECBOOT(PERMITTED)
#define PCI_CLASS_SERIAL
Definition: Pci22.h:267
UEFI 2.0 Loaded image protocol definition.
EFI_HANDLE driver
Driver binding handle.
Definition: efi_veto.c:63
Can be used on any image handle to obtain information about the loaded image.
Definition: LoadedImage.h:46
char wtf[42]
Authenticator response string.
Definition: mschapv2.h:18
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition: efi_veto.c:504
UEFI Component Name 2 Protocol as defined in the UEFI 2.1 specification.
EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName
#define PCI_CLASS(base, sub, progif)
Construct PCI class.
Definition: pci.h:167
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static unsigned int count
Number of entries.
Definition: dwmac.h:225
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
Definition: settings.c:874
static int efi_veto_unload(struct efi_veto *veto)
Unload an EFI driver.
Definition: efi_veto.c:78
Configuration settings.
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
EFI Boot Services Table.
Definition: UefiSpec.h:1931
#define PCI_CLASS_SERIAL_USB
Definition: Pci22.h:273
PCI bus.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:386
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:2011
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:444
UINT64 UINTN
Unsigned value of native width.
This protocol provides the services required to determine if a driver supports a given controller.
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_guid.c:726
EFI_DRIVER_BINDING_PROTOCOL * binding
Driving binding protocol.
Definition: efi_veto.c:65
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:161
EFI_HANDLE ImageHandle
The image handle of the UEFI driver that produced this instance of the EFI_DRIVER_BINDING_PROTOCOL.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1950
uint8_t manufacturer
Manufacturer string.
Definition: smbios.h:15
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:2002
EFI API.
static int efi_veto_hp_xhci(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer, const CHAR16 *name)
Veto HP XhciDxe driver.
Definition: efi_veto.c:421
static int efi_veto_destroy(struct efi_veto *veto)
Terminate an EFI driver with extreme prejudice.
Definition: efi_veto.c:339
EFI_LOADED_IMAGE_PROTOCOL * loaded
Loaded image protocol.
Definition: efi_veto.c:69
uint8_t controller
CD-ROM controller number.
Definition: int13.h:18
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:2007
#define DBGC2(...)
Definition: compiler.h:522
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:174
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
static int efi_veto_close_protocol(struct efi_veto *veto, EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol on handle potentially opened by an EFI driver.
Definition: efi_veto.c:192
static int efi_veto_dhcp6(EFI_DRIVER_BINDING_PROTOCOL *binding __unused, EFI_LOADED_IMAGE_PROTOCOL *loaded __unused, const char *manufacturer __unused, const CHAR16 *name)
Veto Dhcp6Dxe driver.
Definition: efi_veto.c:488
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1531
EFI_SYSTEM_TABLE * efi_systab
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:157
uint16_t protocol
Protocol ID.
Definition: stp.h:19
static int efi_veto_disconnect(struct efi_veto *veto)
Disconnect an EFI driver from all handles.
Definition: efi_veto.c:104
static int efi_veto_close(struct efi_veto *veto)
Close all remaining handles opened by an EFI driver.
Definition: efi_veto.c:296
uint16_t handle
Handle.
Definition: smbios.h:17
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:115
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:209
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
String functions.
A driver veto.
Definition: efi_veto.c:61
Definition: efi.h:62
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2008
int efi_disconnect(EFI_HANDLE device, EFI_HANDLE driver)
Disconnect UEFI driver(s)
Definition: efi_connect.c:90
#define PCI_DRIVERS
PCI driver table.
Definition: pci.h:275
void * memset(void *dest, int character, size_t len) __nonnull
#define DBGC_EFI_OPENER(...)
Definition: efi.h:343