iPXE
efi_veto.c File Reference

EFI driver vetoes. More...

Go to the source code of this file.

Data Structures

struct  efi_veto_candidate
 A driver veto candidate. More...
struct  efi_veto
 A driver veto. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int efi_veto_unload (struct efi_veto *veto)
 Unload an EFI driver.
static int efi_veto_disconnect (struct efi_veto *veto)
 Disconnect an EFI driver from all handles.
static int efi_veto_uninstall (struct efi_veto *veto)
 Uninstall an EFI driver binding protocol.
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.
static int efi_veto_close_handle (struct efi_veto *veto, EFI_HANDLE handle)
 Close handle potentially opened by an EFI driver.
static int efi_veto_close (struct efi_veto *veto)
 Close all remaining handles opened by an EFI driver.
static int efi_veto_destroy (struct efi_veto *veto)
 Terminate an EFI driver with extreme prejudice.
static int efi_veto_driver (struct efi_veto *veto)
 Veto an EFI driver.
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.
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.
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.
static int efi_veto_find (EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto)
 Find driver veto, if any.
void efi_veto (void)
 Remove any vetoed drivers.

Variables

static struct efi_veto_candidate efi_vetoes []
 Driver vetoes.

Detailed Description

EFI driver vetoes.

Definition in file efi_veto.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ efi_veto_unload()

int efi_veto_unload ( struct efi_veto * veto)
static

Unload an EFI driver.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 78 of file efi_veto.c.

78 {
79 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
80 EFI_HANDLE driver = veto->driver;
81 EFI_HANDLE image = veto->image;
82 struct efi_dropped_tpl tpl;
83 EFI_STATUS efirc;
84 int rc;
85
86 /* Unload the driver at external TPL */
87 efi_drop_tpl ( &tpl );
88 efirc = bs->UnloadImage ( image );
89 efi_undrop_tpl ( &tpl );
90 if ( efirc != 0 ) {
91 rc = -EEFI ( efirc );
92 DBGC ( driver, "EFIVETO %s could not unload",
93 efi_handle_name ( driver ) );
94 DBGC ( driver, " %s: %s\n", efi_handle_name ( image ),
95 strerror ( rc ) );
96 return rc;
97 }
98
99 return 0;
100}
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition efi_debug.c:652
void efi_undrop_tpl(struct efi_dropped_tpl *tpl)
Restore dropped task priority level.
Definition efi_init.c:430
void efi_drop_tpl(struct efi_dropped_tpl *tpl)
Drop task priority level temporarily to external level.
Definition efi_init.c:414
#define DBGC(...)
Definition compiler.h:530
#define EFI_HANDLE
Definition efi.h:53
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition efi.h:181
EFI_SYSTEM_TABLE * efi_systab
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
EFI Boot Services Table.
Definition UefiSpec.h:1930
EFI_IMAGE_UNLOAD UnloadImage
Definition UefiSpec.h:1980
An EFI dropped task priority level.
Definition efi.h:88
EFI_HANDLE driver
Driver binding handle.
Definition efi_veto.c:63
EFI_HANDLE image
Image handle.
Definition efi_veto.c:67
An executable image.
Definition image.h:24

References DBGC, efi_veto::driver, EEFI, efi_drop_tpl(), EFI_HANDLE, efi_handle_name(), efi_systab, efi_undrop_tpl(), efi_veto::image, rc, strerror(), and EFI_BOOT_SERVICES::UnloadImage.

Referenced by efi_veto_driver().

◆ efi_veto_disconnect()

int efi_veto_disconnect ( struct efi_veto * veto)
static

Disconnect an EFI driver from all handles.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 108 of file efi_veto.c.

108 {
109 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
110 EFI_HANDLE driver = veto->driver;
111 EFI_HANDLE *handles;
113 UINTN count;
114 unsigned int i;
115 EFI_STATUS efirc;
116 int rc;
117
118 /* Enumerate all handles */
119 if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
120 &count, &handles ) ) != 0 ) {
121 rc = -EEFI ( efirc );
122 DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
123 efi_handle_name ( driver ), strerror ( rc ) );
124 goto err_list;
125 }
126
127 /* Disconnect driver from all handles, in reverse order */
128 for ( i = 0 ; i < count ; i++ ) {
129 handle = handles[ count - i - 1 ];
130 if ( ( rc = efi_disconnect ( handle, driver ) ) != 0 ) {
131 DBGC ( driver, "EFIVETO %s could not disconnect",
132 efi_handle_name ( driver ) );
133 DBGC ( driver, " %s: %s\n",
135 goto err_disconnect;
136 }
137 }
138
139 /* Success */
140 rc = 0;
141 DBGC2 ( driver, "EFIVETO %s disconnected all handles\n",
142 efi_handle_name ( driver ) );
143
144 err_disconnect:
145 bs->FreePool ( handles );
146 err_list:
147 return rc;
148}
UINT64 UINTN
Unsigned value of native width.
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
@ AllHandles
Retrieve all the handles in the handle database.
Definition UefiSpec.h:1521
int efi_disconnect(EFI_HANDLE device, EFI_HANDLE driver)
Disconnect UEFI driver(s).
Definition efi_connect.c:91
#define DBGC2(...)
Definition compiler.h:547
static unsigned int count
Number of entries.
Definition dwmac.h:220
uint16_t handle
Handle.
Definition smbios.h:5
EFI_FREE_POOL FreePool
Definition UefiSpec.h:1949
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition UefiSpec.h:2007

References AllHandles, count, DBGC, DBGC2, efi_veto::driver, EEFI, efi_disconnect(), EFI_HANDLE, efi_handle_name(), efi_systab, EFI_BOOT_SERVICES::FreePool, handle, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, rc, and strerror().

Referenced by efi_veto_destroy().

◆ efi_veto_uninstall()

int efi_veto_uninstall ( struct efi_veto * veto)
static

Uninstall an EFI driver binding protocol.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 156 of file efi_veto.c.

156 {
157 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
158 EFI_HANDLE driver = veto->driver;
160 EFI_STATUS efirc;
161 int rc;
162
163 /* Open driver binding protocol */
164 if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
165 &binding ) ) != 0 ) {
166 DBGC ( driver, "EFIVETO %s could not open driver binding "
167 "protocol: %s\n", efi_handle_name ( driver ),
168 strerror ( rc ) );
169 return rc;
170 }
171
172 /* Uninstall driver binding protocol */
173 if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
175 binding, NULL ) ) != 0 ) {
176 rc = -EEFI ( efirc );
177 DBGC ( driver, "EFIVETO %s could not uninstall driver "
178 "binding protocol: %s\n",
179 efi_handle_name ( driver ), strerror ( rc ) );
180 return rc;
181 }
182
183 DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
184 efi_handle_name ( driver ) );
185 return 0;
186}
struct _EFI_DRIVER_BINDING_PROTOCOL EFI_DRIVER_BINDING_PROTOCOL
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition efi_guid.c:210
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition efi.h:453
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition UefiSpec.h:2010

References DBGC, DBGC2, efi_veto::driver, EEFI, efi_driver_binding_protocol_guid, EFI_HANDLE, efi_handle_name(), efi_open, efi_systab, NULL, rc, strerror(), and EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces.

Referenced by efi_veto_destroy().

◆ efi_veto_close_protocol()

int efi_veto_close_protocol ( struct efi_veto * veto,
EFI_HANDLE handle,
EFI_GUID * protocol )
static

Close protocol on handle potentially opened by an EFI driver.

Parameters
vetoDriver veto
handlePotentially opened handle
protocolOpened protocol
Return values
rcReturn status code

Definition at line 196 of file efi_veto.c.

197 {
198 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
199 EFI_HANDLE driver = veto->driver;
200 EFI_HANDLE image = veto->image;
204 UINTN count;
205 unsigned int i;
206 EFI_STATUS efirc;
207 int rc;
208
209 /* Retrieve list of openers */
210 if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
211 &count ) ) != 0 ) {
212 rc = -EEFI ( efirc );
213 DBGC ( driver, "EFIVETO %s could not retrieve openers",
214 efi_handle_name ( driver ) );
215 DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
217 goto err_list;
218 }
219
220 /* Close anything opened by this driver */
221 for ( i = 0 ; i < count ; i++ ) {
222 opener = &openers[ count - i - 1 ];
223 if ( ( opener->AgentHandle != driver ) &&
224 ( opener->AgentHandle != image ) ) {
225 continue;
226 }
228 DBGC_EFI_OPENER ( driver, handle, protocol, opener );
229 if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
230 controller ) ) != 0 ) {
231 rc = -EEFI ( efirc );
232 DBGC ( driver, "EFIVETO %s could not close stray open",
233 efi_handle_name ( driver ) );
234 DBGC ( driver, " of %s: %s\n",
236 goto err_close;
237 }
238 }
239
240 /* Success */
241 rc = 0;
242
243 err_close:
244 bs->FreePool ( openers );
245 err_list:
246 return rc;
247}
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition efi_guid.c:733
uint8_t controller
CD-ROM controller number.
Definition int13.h:7
#define DBGC_EFI_OPENER(...)
Definition efi.h:350
uint16_t protocol
Protocol ID.
Definition stp.h:7
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition UefiSpec.h:2001
EFI_CLOSE_PROTOCOL CloseProtocol
Definition UefiSpec.h:2000
EFI Oprn Protocol Information Entry.
Definition UefiSpec.h:1431
EFI_HANDLE AgentHandle
Definition UefiSpec.h:1432
EFI_HANDLE ControllerHandle
Definition UefiSpec.h:1433

References EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::AgentHandle, EFI_BOOT_SERVICES::CloseProtocol, controller, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::ControllerHandle, count, DBGC, DBGC_EFI_OPENER, efi_veto::driver, EEFI, efi_guid_ntoa(), EFI_HANDLE, efi_handle_name(), efi_systab, EFI_BOOT_SERVICES::FreePool, handle, efi_veto::image, EFI_BOOT_SERVICES::OpenProtocolInformation, protocol, rc, and strerror().

Referenced by efi_veto_close_handle().

◆ efi_veto_close_handle()

int efi_veto_close_handle ( struct efi_veto * veto,
EFI_HANDLE handle )
static

Close handle potentially opened by an EFI driver.

Parameters
vetoDriver veto
handlePotentially opened handle
Return values
rcReturn status code

Definition at line 256 of file efi_veto.c.

256 {
257 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
258 EFI_HANDLE driver = veto->driver;
259 EFI_GUID **protocols;
261 UINTN count;
262 unsigned int i;
263 EFI_STATUS efirc;
264 int rc;
265
266 /* Retrieve list of protocols */
267 if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
268 &count ) ) != 0 ) {
269 rc = -EEFI ( efirc );
270 DBGC ( driver, "EFIVETO %s could not retrieve protocols",
271 efi_handle_name ( driver ) );
272 DBGC ( driver, " for %s: %s\n",
274 goto err_list;
275 }
276
277 /* Close each protocol */
278 for ( i = 0 ; i < count ; i++ ) {
279 protocol = protocols[ count - i - 1];
280 if ( ( rc = efi_veto_close_protocol ( veto, handle,
281 protocol ) ) != 0 )
282 goto err_close;
283 }
284
285 /* Success */
286 rc = 0;
287
288 err_close:
289 bs->FreePool ( protocols );
290 err_list:
291 return rc;
292}
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
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:196
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition UefiSpec.h:2006

References count, DBGC, efi_veto::driver, EEFI, EFI_HANDLE, efi_handle_name(), efi_systab, efi_veto_close_protocol(), EFI_BOOT_SERVICES::FreePool, handle, protocol, EFI_BOOT_SERVICES::ProtocolsPerHandle, rc, and strerror().

Referenced by efi_veto_close().

◆ efi_veto_close()

int efi_veto_close ( struct efi_veto * veto)
static

Close all remaining handles opened by an EFI driver.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 300 of file efi_veto.c.

300 {
301 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
302 EFI_HANDLE driver = veto->driver;
303 EFI_HANDLE *handles;
305 UINTN count;
306 unsigned int i;
307 EFI_STATUS efirc;
308 int rc;
309
310 /* Enumerate all handles */
311 if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
312 &count, &handles ) ) != 0 ) {
313 rc = -EEFI ( efirc );
314 DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
315 efi_handle_name ( driver ), strerror ( rc ) );
316 goto err_list;
317 }
318
319 /* Close each handle */
320 for ( i = 0 ; i < count ; i++ ) {
321 handle = handles[ count - i - 1 ];
322 if ( ( rc = efi_veto_close_handle ( veto, handle ) ) != 0 )
323 goto err_close;
324 }
325
326 /* Success */
327 rc = 0;
328 DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
329 efi_handle_name ( driver ) );
330
331 err_close:
332 bs->FreePool ( handles );
333 err_list:
334 return rc;
335}
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:256

References AllHandles, count, DBGC, DBGC2, efi_veto::driver, EEFI, EFI_HANDLE, efi_handle_name(), efi_systab, efi_veto_close_handle(), EFI_BOOT_SERVICES::FreePool, handle, EFI_BOOT_SERVICES::LocateHandleBuffer, NULL, rc, and strerror().

Referenced by efi_veto_destroy().

◆ efi_veto_destroy()

int efi_veto_destroy ( struct efi_veto * veto)
static

Terminate an EFI driver with extreme prejudice.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 343 of file efi_veto.c.

343 {
344 EFI_HANDLE driver = veto->driver;
345 int rc;
346
347 /* Disconnect driver from all handles */
348 if ( ( rc = efi_veto_disconnect ( veto ) ) != 0 )
349 return rc;
350
351 /* Uninstall driver binding protocol */
352 if ( ( rc = efi_veto_uninstall ( veto ) ) != 0 )
353 return rc;
354
355 /* Close any remaining opened handles */
356 if ( ( rc = efi_veto_close ( veto ) ) != 0 )
357 return rc;
358
359 DBGC ( driver, "EFIVETO %s forcibly removed\n",
360 efi_handle_name ( driver ) );
361 return 0;
362}
static int efi_veto_disconnect(struct efi_veto *veto)
Disconnect an EFI driver from all handles.
Definition efi_veto.c:108
static int efi_veto_close(struct efi_veto *veto)
Close all remaining handles opened by an EFI driver.
Definition efi_veto.c:300
static int efi_veto_uninstall(struct efi_veto *veto)
Uninstall an EFI driver binding protocol.
Definition efi_veto.c:156

References DBGC, efi_veto::driver, EFI_HANDLE, efi_handle_name(), efi_veto_close(), efi_veto_disconnect(), efi_veto_uninstall(), and rc.

Referenced by efi_veto_driver().

◆ efi_veto_driver()

int efi_veto_driver ( struct efi_veto * veto)
static

Veto an EFI driver.

Parameters
vetoDriver veto
Return values
rcReturn status code

Definition at line 370 of file efi_veto.c.

370 {
371 int rc;
372
373 /* Try gracefully unloading the driver */
374 if ( ( rc = efi_veto_unload ( veto ) ) == 0 )
375 return 0;
376
377 /* If that fails, use a hammer */
378 if ( ( rc = efi_veto_destroy ( veto ) ) == 0 )
379 return 0;
380
381 return rc;
382}
static int efi_veto_unload(struct efi_veto *veto)
Unload an EFI driver.
Definition efi_veto.c:78
static int efi_veto_destroy(struct efi_veto *veto)
Terminate an EFI driver with extreme prejudice.
Definition efi_veto.c:343

References efi_veto_destroy(), efi_veto_unload(), and rc.

Referenced by efi_veto().

◆ efi_veto_ip4config()

int efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
const char * manufacturer,
const CHAR16 * name )
static

Veto Ip4ConfigDxe driver on some platforms.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 394 of file efi_veto.c.

396 {
397 static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
398 static const char *dell = "Dell Inc.";
399 static const char *itautec = "Itautec S.A.";
400
401 /* Check manufacturer and driver name */
402 if ( ! manufacturer )
403 return 0;
404 if ( ! name )
405 return 0;
406 if ( ( strcmp ( manufacturer, dell ) != 0 ) &&
407 ( strcmp ( manufacturer, itautec ) != 0 ) )
408 return 0;
409 if ( memcmp ( name, ip4cfg, sizeof ( ip4cfg ) ) != 0 )
410 return 0;
411
412 return 1;
413}
unsigned short CHAR16
2-byte Character.
const char * name
Definition ath9k_hw.c:1986
uint8_t manufacturer
Manufacturer string.
Definition smbios.h:3
int strcmp(const char *first, const char *second)
Compare strings.
Definition string.c:174
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115

References __unused, manufacturer, memcmp(), name, and strcmp().

◆ efi_veto_hp_xhci()

int efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
const char * manufacturer,
const CHAR16 * name )
static

Veto HP XhciDxe driver.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 425 of file efi_veto.c.

427 {
428 static const CHAR16 xhci[] = L"Usb Xhci Driver";
429 static const char *hp = "HP";
430 struct pci_driver *driver;
431
432 /* Check manufacturer and driver name */
433 if ( ! manufacturer )
434 return 0;
435 if ( ! name )
436 return 0;
437 if ( strcmp ( manufacturer, hp ) != 0 )
438 return 0;
439 if ( memcmp ( name, xhci, sizeof ( xhci ) ) != 0 )
440 return 0;
441
442 /* Veto driver only if we have our own xHCI driver */
444 if ( driver->class.class ==
447 return 1;
448 }
449 }
450
451 return 0;
452}
#define PCI_CLASS_SERIAL
Definition Pci22.h:266
#define PCI_CLASS_SERIAL_USB
Definition Pci22.h:272
#define PCI_CLASS(base, sub, progif)
Construct PCI class.
Definition pci.h:170
#define PCI_CLASS_SERIAL_USB_XHCI
xHCI USB controller
Definition pci.h:144
#define PCI_DRIVERS
PCI driver table.
Definition pci.h:278
uint32_t class
Class.
Definition pci.h:195
A PCI driver.
Definition pci.h:255
struct pci_class_id class
PCI class ID.
Definition pci.h:261
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition tables.h:386

References __unused, pci_class_id::class, pci_driver::class, for_each_table_entry, manufacturer, memcmp(), name, PCI_CLASS, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB, PCI_CLASS_SERIAL_USB_XHCI, PCI_DRIVERS, and strcmp().

◆ efi_veto_vmware_uefipxebc()

int efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
const char * manufacturer,
const CHAR16 * name )
static

Veto VMware UefiPxeBcDxe driver.

Parameters
bindingDriver binding protocol
loadedLoaded image protocol
manufacturerManufacturer name, if present
nameDriver name, if present
Return values
vetoedDriver is to be vetoed

Definition at line 464 of file efi_veto.c.

466 {
467 static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
468 static const char *vmware = "VMware, Inc.";
469
470 /* Check manufacturer and driver name */
471 if ( ! manufacturer )
472 return 0;
473 if ( ! name )
474 return 0;
475 if ( strcmp ( manufacturer, vmware ) != 0 )
476 return 0;
477 if ( memcmp ( name, uefipxebc, sizeof ( uefipxebc ) ) != 0 )
478 return 0;
479
480 return 1;
481}

References __unused, manufacturer, memcmp(), name, and strcmp().

◆ efi_veto_find()

int efi_veto_find ( EFI_HANDLE driver,
const char * manufacturer,
struct efi_veto * veto )
static

Find driver veto, if any.

Parameters
driverDriver binding handle
manufacturerManufacturer name, if present
Return values
vetoDriver veto to fill in
rcReturn status code

Definition at line 507 of file efi_veto.c.

508 {
513 CHAR16 *name;
514 unsigned int i;
516 EFI_STATUS efirc;
517 int rc;
518
519 /* Mark as not vetoed */
520 memset ( veto, 0, sizeof ( *veto ) );
521
522 /* Open driver binding protocol */
523 if ( ( rc = efi_open ( driver, &efi_driver_binding_protocol_guid,
524 &binding ) ) != 0 ) {
525 DBGC ( driver, "EFIVETO %s could not open driver binding "
526 "protocol: %s\n", efi_handle_name ( driver ),
527 strerror ( rc ) );
528 return rc;
529 }
530 image = binding->ImageHandle;
531
532 /* Open loaded image protocol */
534 &loaded ) ) != 0 ) {
535 DBGC ( driver, "EFIVETO %s could not open",
536 efi_handle_name ( driver ) );
537 DBGC ( driver, " %s loaded image protocol: %s\n",
538 efi_handle_name ( image ), strerror ( rc ) );
539 return rc;
540 }
541
542 /* Open component name protocol, if present */
544 &wtf2 ) ) != 0 ) {
545 /* Ignore failure; is not required to be present */
546 }
547
548 /* Open obsolete component name protocol, if present */
550 &wtf ) ) != 0 ) {
551 /* Ignore failure; is not required to be present */
552 }
553
554 /* Get driver name, if available */
555 if ( ( wtf2 && ( ( efirc = wtf2->GetDriverName ( wtf2, "en",
556 &name ) == 0 ) ) ) ||
557 ( wtf && ( ( efirc = wtf->GetDriverName ( wtf, "eng",
558 &name ) == 0 ) ) ) ) {
559 /* Driver has a name */
560 } else {
561 /* Ignore failure; name is not required to be present */
562 name = NULL;
563 }
564
565 /* Check vetoes */
566 DBGC2 ( &efi_vetoes, "EFIVETO checking %s [%p,%p)\n",
567 efi_handle_name ( driver ), loaded->ImageBase,
568 ( loaded->ImageBase + loaded->ImageSize ) );
569 for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
570 sizeof ( efi_vetoes[0] ) ) ; i++ ) {
571 if ( efi_vetoes[i].veto ( binding, loaded, manufacturer,
572 name ) ) {
573 DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
574 efi_handle_name ( driver ),
575 efi_vetoes[i].name );
576 veto->driver = driver;
577 veto->binding = binding;
578 veto->image = image;
579 veto->loaded = loaded;
580 break;
581 }
582 }
583
584 return 0;
585}
struct _EFI_COMPONENT_NAME2_PROTOCOL EFI_COMPONENT_NAME2_PROTOCOL
struct _EFI_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME_PROTOCOL
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition efi_guid.c:274
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition efi_guid.c:162
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition efi_guid.c:158
static struct efi_veto_candidate efi_vetoes[]
Driver vetoes.
Definition efi_veto.c:484
void * memset(void *dest, int character, size_t len) __nonnull
char wtf[42]
Authenticator response string.
Definition mschapv2.h:7
Can be used on any image handle to obtain information about the loaded image.
Definition LoadedImage.h:45
UINT64 ImageSize
The size in bytes of the loaded image.
Definition LoadedImage.h:70
VOID * ImageBase
The base address at which the image was loaded.
Definition LoadedImage.h:69
EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName
EFI_HANDLE ImageHandle
The image handle of the UEFI driver that produced this instance of the EFI_DRIVER_BINDING_PROTOCOL.
EFI_DRIVER_BINDING_PROTOCOL * binding
Driving binding protocol.
Definition efi_veto.c:65
EFI_LOADED_IMAGE_PROTOCOL * loaded
Loaded image protocol.
Definition efi_veto.c:69

References DBGC, DBGC2, efi_component_name2_protocol_guid, efi_component_name_protocol_guid, efi_driver_binding_protocol_guid, EFI_HANDLE, efi_handle_name(), efi_loaded_image_protocol_guid, efi_open, efi_vetoes, _EFI_COMPONENT_NAME2_PROTOCOL::GetDriverName, EFI_LOADED_IMAGE_PROTOCOL::ImageBase, _EFI_DRIVER_BINDING_PROTOCOL::ImageHandle, EFI_LOADED_IMAGE_PROTOCOL::ImageSize, manufacturer, memset(), name, NULL, rc, strerror(), efi_veto_candidate::veto, and wtf.

Referenced by efi_veto().

◆ efi_veto()

void efi_veto ( void )

Remove any vetoed drivers.

Definition at line 591 of file efi_veto.c.

591 {
592 EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
593 struct efi_veto veto;
594 EFI_HANDLE *drivers;
596 UINTN count;
597 unsigned int i;
598 char *manufacturer;
599 EFI_STATUS efirc;
600 int rc;
601
602 /* Locate all driver binding protocol handles */
603 if ( ( efirc = bs->LocateHandleBuffer (
605 NULL, &count, &drivers ) ) != 0 ) {
606 rc = -EEFI ( efirc );
607 DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
608 "%s\n", strerror ( rc ) );
609 return;
610 }
611
612 /* Get manufacturer name */
613 fetch_string_setting_copy ( NULL, &manufacturer_setting,
614 &manufacturer );
615 DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
616
617 /* Unload any vetoed drivers */
618 for ( i = 0 ; i < count ; i++ ) {
619 driver = drivers[ count - i - 1 ];
621 &veto ) ) != 0 ) {
622 DBGC ( driver, "EFIVETO %s could not determine "
623 "vetoing: %s\n",
625 continue;
626 }
627 if ( ! veto.driver )
628 continue;
629 if ( ( rc = efi_veto_driver ( &veto ) ) != 0 ) {
630 DBGC ( driver, "EFIVETO %s could not veto: %s\n",
632 }
633 }
634
635 /* Free manufacturer name */
636 free ( manufacturer );
637
638 /* Free handle list */
639 bs->FreePool ( drivers );
640}
@ ByProtocol
Retrieve the set of handles from the handle database that support a specified protocol.
Definition UefiSpec.h:1530
static int efi_veto_driver(struct efi_veto *veto)
Veto an EFI driver.
Definition efi_veto.c:370
static int efi_veto_find(EFI_HANDLE driver, const char *manufacturer, struct efi_veto *veto)
Find driver veto, if any.
Definition efi_veto.c:507
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
Definition settings.c:874
A driver veto.
Definition efi_veto.c:61

References ByProtocol, count, DBGC, efi_veto::driver, EEFI, efi_driver_binding_protocol_guid, EFI_HANDLE, efi_handle_name(), efi_systab, efi_veto_driver(), efi_veto_find(), efi_vetoes, fetch_string_setting_copy(), free, EFI_BOOT_SERVICES::FreePool, EFI_BOOT_SERVICES::LocateHandleBuffer, manufacturer, NULL, rc, and strerror().

Referenced by efi_probe().

Variable Documentation

◆ efi_vetoes

struct efi_veto_candidate efi_vetoes[]
static
Initial value:
= {
{
.name = "Ip4Config",
},
{
.name = "HP Xhci",
},
{
.name = "VMware UefiPxeBc",
},
}
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:464
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:394
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:425

Driver vetoes.

Definition at line 484 of file efi_veto.c.

484 {
485 {
486 .name = "Ip4Config",
487 .veto = efi_veto_ip4config,
488 },
489 {
490 .name = "HP Xhci",
491 .veto = efi_veto_hp_xhci,
492 },
493 {
494 .name = "VMware UefiPxeBc",
496 },
497};

Referenced by efi_veto(), and efi_veto_find().