MdeModulePkg/Core/Dxe: Acquire a lock when iterating gHandleList
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3680 This patch fixes the following issue: The global variable gHandleList is a linked list. This list is locked when a entry is added or removed from the list, but there is no lock when iterating this list in function CoreValidateHandle(). It can lead to "Handle.c (76): CR has Bad Signature" assertion if the iterated entry in the list is just removed by other task during iterating. Currently some caller functions of CoreValidateHandle() have CoreAcquireProtocolLock(), but some caller functions of CoreValidateHandle() do not CoreAcquireProtocolLock(). Add CoreAcquireProtocolLock() always when CoreValidateHandle() is called, Also, A lock check is added in the CoreValidateHandle(). Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Hua Ma <hua.ma@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
This commit is contained in:
@@ -68,7 +68,12 @@ CoreConnectController (
|
||||
//
|
||||
// Make sure ControllerHandle is valid
|
||||
//
|
||||
CoreAcquireProtocolLock ();
|
||||
|
||||
Status = CoreValidateHandle (ControllerHandle);
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -268,7 +273,12 @@ AddSortedDriverBindingProtocol (
|
||||
//
|
||||
// Make sure the DriverBindingHandle is valid
|
||||
//
|
||||
CoreAcquireProtocolLock ();
|
||||
|
||||
Status = CoreValidateHandle (DriverBindingHandle);
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
@@ -746,8 +756,11 @@ CoreDisconnectController (
|
||||
//
|
||||
// Make sure ControllerHandle is valid
|
||||
//
|
||||
CoreAcquireProtocolLock ();
|
||||
|
||||
Status = CoreValidateHandle (ControllerHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
CoreReleaseProtocolLock ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -757,10 +770,13 @@ CoreDisconnectController (
|
||||
if (ChildHandle != NULL) {
|
||||
Status = CoreValidateHandle (ChildHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
CoreReleaseProtocolLock ();
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
|
||||
Handle = ControllerHandle;
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user