vmx: add missing entries in the l1d_param array
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 33 lines · Bandan Das
This can cause a host crash if an access attempts
to reach the missing entry. Future-proof the get
function against any overflows as well.Signed-off-by Bandan Das <[email protected]>--- arch/x86/kvm/vmx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/x86/kvm/vmx.c +6
-1@@ -203,6 +203,8 @@ static const struct { {"never", VMENTER_L1D_FLUSH_NEVER}, {"cond", VMENTER_L1D_FLUSH_COND}, {"always", VMENTER_L1D_FLUSH_ALWAYS}, + {"disabled", VMENTER_L1D_FLUSH_EPT_DISABLED}, + {"not required", VMENTER_L1D_FLUSH_NOT_REQUIRED}, };#define L1D_CACHE_ORDER 4@@ -323,7 +325,17 @@ static int vmentry_l1d_flush_set(const char *s, const struct kernel_param *kp)static int vmentry_l1d_flush_get (char *s,const struct kernel_param *kp) { -return sprintf (s,"%s\n" , vmentry_l1d_param[l1tf_vmx_mitigation].option); +int i; + +for (i =0 ; i <ARRAY_SIZE (vmentry_l1d_param); i++) { +if (vmentry_l1d_param[i].cmd == l1tf_vmx_mitigation)
arch/x86/kvm/vmx.c static int vmentry_l1d_flush_set(const char *s, const struct kernel_param *kp) · line 341
Quoted 10 lines
arch/x86/kvm/vmx.c +7
-0+break ; + } + +if (i ==ARRAY_SIZE (vmentry_l1d_param)) +return -EINVAL ; + +return sprintf (s,"%s\n" , vmentry_l1d_param[i].option); }static const struct kernel_param_ops vmentry_l1d_flush_ops = {
Queued, thanks.
Paolo
Paolo Bonzini
maintainerQuoted 33 lines · Bandan Das
This can cause a host crash if an access attempts
to reach the missing entry. Future-proof the get
function against any overflows as well.Signed-off-by Bandan Das <[email protected]>--- arch/x86/kvm/vmx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/x86/kvm/vmx.c +6
-1@@ -203,6 +203,8 @@ static const struct { {"never", VMENTER_L1D_FLUSH_NEVER}, {"cond", VMENTER_L1D_FLUSH_COND}, {"always", VMENTER_L1D_FLUSH_ALWAYS}, + {"disabled", VMENTER_L1D_FLUSH_EPT_DISABLED}, + {"not required", VMENTER_L1D_FLUSH_NOT_REQUIRED}, };#define L1D_CACHE_ORDER 4@@ -323,7 +325,17 @@ static int vmentry_l1d_flush_set(const char *s, const struct kernel_param *kp)static int vmentry_l1d_flush_get (char *s,const struct kernel_param *kp) { -return sprintf (s,"%s\n" , vmentry_l1d_param[l1tf_vmx_mitigation].option); +int i; + +for (i =0 ; i <ARRAY_SIZE (vmentry_l1d_param); i++) { +if (vmentry_l1d_param[i].cmd == l1tf_vmx_mitigation)
arch/x86/kvm/vmx.c static int vmentry_l1d_flush_set(const char *s, const struct kernel_param *kp) · line 341
Quoted 10 lines
arch/x86/kvm/vmx.c +7
-0+break ; + } + +if (i ==ARRAY_SIZE (vmentry_l1d_param)) +return -EINVAL ; + +return sprintf (s,"%s\n" , vmentry_l1d_param[i].option); }static const struct kernel_param_ops vmentry_l1d_flush_ops = {
Hmm, actually the two missing entries must be rejected by vmentry_l1d_flush_parse. I've fixed up the patch since I'm going to send a pull request to Linus today.
Paolo