x86/AMD-ucode: correct multiple container handling
PATCH 1/1 x86/AMD-ucode: correct multiple container handling
Avoid emitting an error message referring to an incorrect or corrupt container file just because no entry was found for the running CPU.
Additionally switch the order of data validation and consumption in cpu_request_microcode()'s first loop, and also check the types of skipped blocks in container_fast_forward().
xen/arch/x86/microcode_amd.c +14 -4
@@ -331,12 +331,17 @@ static int container_fast_forward(const header[1] == UCODE_EQUIV_CPU_TABLE_TYPE )break ; +if ( header[0 ] !=UCODE_UCODE_TYPE ) +return -EINVAL ; size = header[1 ] +SECTION_HDR_SIZE ;if ( size <PATCH_HDR_SIZE || size_left < size )return -EINVAL ; size_left -= size; *offset += size; + +if ( !size_left ) +return -ENODATA ; }return 0 ;
@@ -386,10 +391,6 @@ static int cpu_request_microcode(int cpubreak ; } -if (find_equiv_cpu_id (mc_amd->equiv_cpu_table, current_cpu_id, - &equiv_cpu_id) ) -break ; -/* * Could happen as we advance 'offset' early * in install_equiv_cpu_table
@@ -401,7 +402,16 @@ static int cpu_request_microcode(int cpubreak ; } +if (find_equiv_cpu_id (mc_amd->equiv_cpu_table, current_cpu_id, + &equiv_cpu_id) ) +break ; + error =container_fast_forward (buf, bufsize - offset, &offset); +if ( error == -ENODATA ) + { +ASSERT (offset == bufsize); +break ; + }if ( error ) { printk(KERN_ERR "microcode: CPU%d incorrect or corrupt container file\n"
x86/AMD-ucode: correct multiple container handling
Avoid emitting an error message referring to an incorrect or corrupt container file just because no entry was found for the running CPU.
Additionally switch the order of data validation and consumption in cpu_request_microcode()'s first loop, and also check the types of skipped blocks in container_fast_forward().
xen/arch/x86/microcode_amd.c +14 -4
@@ -331,12 +331,17 @@ static int container_fast_forward(const header[1] == UCODE_EQUIV_CPU_TABLE_TYPE )break ; +if ( header[0 ] !=UCODE_UCODE_TYPE ) +return -EINVAL ; size = header[1 ] +SECTION_HDR_SIZE ;if ( size <PATCH_HDR_SIZE || size_left < size )return -EINVAL ; size_left -= size; *offset += size; + +if ( !size_left ) +return -ENODATA ; }return 0 ;
@@ -386,10 +391,6 @@ static int cpu_request_microcode(int cpubreak ; } -if (find_equiv_cpu_id (mc_amd->equiv_cpu_table, current_cpu_id, - &equiv_cpu_id) ) -break ; -/* * Could happen as we advance 'offset' early * in install_equiv_cpu_table
@@ -401,7 +402,16 @@ static int cpu_request_microcode(int cpubreak ; } +if (find_equiv_cpu_id (mc_amd->equiv_cpu_table, current_cpu_id, + &equiv_cpu_id) ) +break ; + error =container_fast_forward (buf, bufsize - offset, &offset); +if ( error == -ENODATA ) + { +ASSERT (offset == bufsize); +break ; + }if ( error ) { printk(KERN_ERR "microcode: CPU%d incorrect or corrupt container file\n"
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 8 lines · Jan Beulich
Avoid emitting an error message referring to an incorrect or corrupt container file just because no entry was found for the running CPU.
Additionally switch the order of data validation and consumption in cpu_request_microcode()'s first loop, and also check the types of skipped blocks in
container_fast_forward().Signed-off-by Jan Beulich <[email protected]>
Quoted 54 lines
xen/arch/x86/microcode_amd.c +14
-4@@ -331,12 +331,17 @@ static int container_fast_forward(const header[1] == UCODE_EQUIV_CPU_TABLE_TYPE )break ; +if ( header[0 ] !=UCODE_UCODE_TYPE ) +return -EINVAL ; size = header[1 ] +SECTION_HDR_SIZE ;if ( size <PATCH_HDR_SIZE || size_left < size )return -EINVAL ; size_left -= size; *offset += size; + +if ( !size_left ) +return -ENODATA ; }return 0 ;@@ -386,10 +391,6 @@ static int cpu_request_microcode(int cpubreak ; } -if (find_equiv_cpu_id (mc_amd->equiv_cpu_table, current_cpu_id, - &equiv_cpu_id) ) -break ; -/* * Could happen as we advance 'offset' early * in install_equiv_cpu_table @@ -401,7 +402,16 @@ static int cpu_request_microcode(int cpubreak ; } +if (find_equiv_cpu_id (mc_amd->equiv_cpu_table, current_cpu_id, + &equiv_cpu_id) ) +break ; + error =container_fast_forward (buf, bufsize - offset, &offset); +if ( error == -ENODATA ) + { +ASSERT (offset == bufsize); +break ; + }if ( error ) { printk(KERN_ERR "microcode: CPU%d incorrect or corrupt container file\n"
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Aravind Gopalakrishnan
Reviewed-byQuoted 4 lines · Andrew Cooper
Quoted 3 lines · Jan Beulich
Avoid emitting an error message referring to an incorrect or corrupt container file just because no entry was found for the running CPU.
Quoted 9 lines
Quoted 5 lines
Additionally switch the order of data validation and consumption in cpu_request_microcode()'s first loop, and also check the types of skipped blocks in
container_fast_forward().Signed-off-by Jan Beulich<[email protected]>Reviewed-by Andrew Cooper <[email protected]>