Skip to contentSkip to conversation

x86/domctl: remove impossible condition in XEN_DOMCTL_getpageframeinfo3

PATCH In review Olaf Hering 2 participants 2 messages Mar 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/domctl: remove impossible condition in XEN_DOMCTL_getpageframeinfo3

The value of num is always the same as domctl->u.getpageframeinfo3.num, it was assigned just a few lines before. Avoid truncation by making num the same size as i, which is the only place where num is used.

---
 xen/arch/x86/domctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
xen/arch/x86/domctl.c +2 -3
index daf733de4f..5d979e3a0f 100644
@@ -415,14 +415,13 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_getpageframeinfo3:
     {
-        unsigned int num = domctl->u.getpageframeinfo3.num;
+        unsigned long num = domctl->u.getpageframeinfo3.num;
         unsigned int width = has_32bit_shinfo(currd) ? 4 : 8;
 
         /* Games to allow this code block to handle a compat guest. */
         void __user *guest_handle = domctl->u.getpageframeinfo3.array.p;
 
-        if ( unlikely(num > XEN_GETPAGEFRAMEINFO3_MAX_SIZE) ||
-             unlikely(num != domctl->u.getpageframeinfo3.num) )
+        if ( unlikely(num > XEN_GETPAGEFRAMEINFO3_MAX_SIZE) )
         {
             ret = -E2BIG;
             break;

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

#1 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 09.03.18 at 17:23, <[email protected]> wrote:
xen/arch/x86/domctl.c +0 -0
@@ -415,14 +415,13 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_getpageframeinfo3:
     {

xen/arch/x86/domctl.c long arch_do_domctl( · line 424

Quoted 10 lines
xen/arch/x86/domctl.c +2 -3
-        unsigned int num = domctl->u.getpageframeinfo3.num;
+        unsigned long num = domctl->u.getpageframeinfo3.num;
         unsigned int width = has_32bit_shinfo(currd) ? 4 : 8;
 
         /* Games to allow this code block to handle a compat guest. */
         void __user *guest_handle = domctl->u.getpageframeinfo3.array.p;
 
-        if ( unlikely(num > XEN_GETPAGEFRAMEINFO3_MAX_SIZE) ||
-             unlikely(num != domctl->u.getpageframeinfo3.num) )
+        if ( unlikely(num > XEN_GETPAGEFRAMEINFO3_MAX_SIZE) )

IMO this doesn't improve anything. If you wanted the types to remain in sync (and document that), you'd need to use typeof().

Jan

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