EFI: Fix getting EFI variable list on some systems
PATCH 1/1 EFI: Fix getting EFI variable list on some systems
Copy the entire output buffer to the guest because it may contain data beyond the output size that the firmware requires on a subsequent GetNextVariableName() call (e.g. a NULL character).
The spec requires that on each call, "the previous results" be passed in.
Without this change, the following (simplified) sequence would occur:
GetNextVariableName: in \0, out AdminPw\0, size 7
GetNextVariableName: in AdminPw\0, out UserPw\0, size 6
GetNextVariableName: in UserPww\0, NOT FOUND
--- xen/common/efi/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/efi/runtime.c +1 -1
@@ -518,7 +518,7 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op)if ( !EFI_ERROR (status) &©_to_guest (op->u.get_next_variable_name.name, - name.raw, size) ) + name.raw, op->u.get_next_variable_name.size) ) rc = -EFAULT ; op->u.get_next_variable_name.size = size; }
Signature · 1 line
2.1.0
Quoted 4 lines · Ross Lagerwall
Copy the entire output buffer to the guest because it may contain data beyond the output size that the firmware requires on a subsequent
GetNextVariableName()call (e.g. a NULL character).
Quoted 8 lines
The spec requires that on each call, "the previous results" be passed in.
Without this change, the following (simplified) sequence would occur:
GetNextVariableName: in \0, out AdminPw\0, size 7
GetNextVariableName: in AdminPw\0, out UserPw\0, size 6
GetNextVariableName: in UserPww\0, NOT FOUNDSigned-off-by Ross Lagerwall <[email protected]>
Quoted 17 lines
--- xen/common/efi/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/common/efi/runtime.c +1
-1@@ -518,7 +518,7 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op)if ( !EFI_ERROR (status) &©_to_guest (op->u.get_next_variable_name.name, - name.raw, size) ) + name.raw, op->u.get_next_variable_name.size) ) rc = -EFAULT ; op->u.get_next_variable_name.size = size; }
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 09.03.15 at 17:47, <[email protected]> wrote:
Copy the entire output buffer to the guest because it may contain data beyond the output size that the firmware requires on a subsequent
GetNextVariableName()call (e.g. a NULL character).The spec requires that on each call, "the previous results" be passed in.
Without this change, the following (simplified) sequence would occur:
GetNextVariableName: in \0, out AdminPw\0, size 7
GetNextVariableName: in AdminPw\0, out UserPw\0, size 6
GetNextVariableName: in UserPww\0, NOT FOUND
As such behavior is outside the specification, please name the system needing this workaround: The runtime services function is documented to update *VariableNameSize only upon EFI_BUFFER_TOO_SMALL. A code comment would also seem to be on order, as otherwise people like me might be tempted to undo this again, as it's sub-optimal code for spec conforming firmware.
And to save me from having to do an incremental patch on top, you may want to consider switching to __copy_to_user() at once.
Jan