Skip to contentSkip to conversation

x86/sysctl: Fix NULL pointer dereference in error path

PATCH In review Andrew Cooper 2 participants 3 messages Jan 11, 2017 – Jan 12, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/sysctl: Fix NULL pointer dereference in error path

This was introduced by c/s c38869e711 "x86/cpuid: Drop the temporary linear feature bitmap from struct cpuid_policy", and caught by Coverity.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/sysctl.c | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/x86/sysctl.c +3 -0
index 87da541..274ca0c 100644
@@ -229,7 +229,10 @@ long arch_do_sysctl(
 
         /* Bad featureset index? */
         if ( !p )
+        {
             ret = -EINVAL;
+            break;
+        }
 
         cpuid_policy_to_featureset(p, featureset);
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 237

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 11.01.17 at 18:57, <[email protected]> wrote:
xen/arch/x86/sysctl.c +3 -0
@@ -229,7 +229,10 @@ long arch_do_sysctl(
 
         /* Bad featureset index? */
         if ( !p )
+        {
             ret = -EINVAL;
+            break;
+        }
 
         cpuid_policy_to_featureset(p, featureset);

Considering how the following code is written, adding an "else" would seem more natural. With the patch above the !ret check right out of context would then be dead code. With either of the possible adjustments

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 11.01.17 at 18:57, <[email protected]> wrote:
xen/arch/x86/sysctl.c +3 -0
@@ -229,7 +229,10 @@ long arch_do_sysctl(
 
         /* Bad featureset index? */
         if ( !p )
+        {
             ret = -EINVAL;
+            break;
+        }
 
Quoted 6 lines

xen/arch/x86/sysctl.c long arch_do_sysctl( · line 237

Quoted 1 line
xen/arch/x86/sysctl.c +0 -0
         cpuid_policy_to_featureset(p, featureset);

Considering how the following code is written, adding an "else" would seem more natural. With the patch above the !ret check right out of context would then be dead code. With either of the possible adjustments

Good point - I will make that adjustment.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel