sysctl: use xmalloc_array() for XEN_SYSCTL_page_offline_op
PATCH v2 1/1 sysctl: use xmalloc_array() for XEN_SYSCTL_page_offline_op
This is more robust than the raw xmalloc_bytes().
Also add a sanity check on the input page range, to avoid returning the less applicable -ENOMEM in such cases (and trying the allocation in the first place).
---
v2: Expand a bit the description of the sanity check addition.
xen/common/sysctl.c +7 -3
@@ -187,13 +187,17 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xeuint32_t *status, *ptr;mfn_t mfn; + ret = -EINVAL ; +if ( op->u.page_offline.end < op->u.page_offline.start ) +break ; + ret =xsm_page_offline (XSM_HOOK , op->u.page_offline.cmd);if ( ret )break ; - ptr = status =xmalloc_bytes (sizeof (uint32_t ) * - (op->u.page_offline.end - - op->u.page_offline.start +1 )); + ptr = status =xmalloc_array (uint32_t, + (op->u.page_offline.end - + op->u.page_offline.start +1 ));if ( !status ) {dprintk (XENLOG_WARNING ,"Out of memory for page offline op\n" );
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Jan Beulich
This is more robust than the raw
xmalloc_bytes().Also add a sanity check on the input page range, to avoid returning the less applicable
-ENOMEMin such cases (and trying the allocation in the first place).Signed-off-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Julien,
Quoted 10 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich
This is more robust than the raw
xmalloc_bytes().Also add a sanity check on the input page range, to avoid returning the less applicable
-ENOMEMin such cases (and trying the allocation in the first place).Signed-off-by Jan Beulich <[email protected]>Acked-by Andrew Cooper <[email protected]>
I notice you've committed this, but somehow you've lost Andrew's ack. I don't think it was intended by the recent check-in policy change for commits to go in without suitable acks (iirc I did notice a few others recently as well, albeit not ones committed by you).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 12 lines · Jan Beulich
Julien,
Quoted 9 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich
This is more robust than the raw
xmalloc_bytes().Also add a sanity check on the input page range, to avoid returning the less applicable
-ENOMEMin such cases (and trying the allocation in the first place).Signed-off-by Jan Beulich <[email protected]>
Quoted 7 lines
Quoted 1 line
Acked-by Andrew Cooper <[email protected]>I notice you've committed this, but somehow you've lost Andrew's ack. I don't think it was intended by the recent check-in policy change for commits to go in without suitable acks (iirc I did notice a few others recently as well, albeit not ones committed by you).
In this case, this was a lack of attention while committing the patch.
Mistakes can happen and this has nothing to do with a check-in policy.
You will never be able to fully prevent any mistakes until you remove the human from the equation. Please provide scripts that fully automate the committers job if you are concern about this.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel