x86/domctl: remove impossible condition in XEN_DOMCTL_getpageframeinfo3
PATCH 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.
--- xen/arch/x86/domctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
xen/arch/x86/domctl.c +1 -2
@@ -421,8 +421,7 @@ long arch_do_domctl(/* Games to allow this code block to handle a compat guest. */ void __user *guest_handle = domctl->u.getpageframeinfo3.array.p; -if (unlikely (num >1024 ) || -unlikely (num != domctl->u.getpageframeinfo3.num) ) +if (unlikely (num >1024 ) ) { ret = -E2BIG ;break ;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 4 lines · Olaf Hering
The value of num is always the same as
domctl->u.getpageframeinfo3.num, it was assigned just a few lines before.Signed-off-by Olaf Hering <[email protected]>
This isn't dead code. It is a truncation check.
~Andrew
Quoted 9 lines
--- xen/arch/x86/domctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)xen/arch/x86/domctl.c +0
-0
xen/arch/x86/domctl.c long arch_do_domctl( · line 427
Quoted 9 lines
xen/arch/x86/domctl.c +1
-2@@ -421,8 +421,7 @@ long arch_do_domctl(/* Games to allow this code block to handle a compat guest. */ void __user *guest_handle = domctl->u.getpageframeinfo3.array.p; -if (unlikely (num >1024 ) || -unlikely (num != domctl->u.getpageframeinfo3.num) ) +if (unlikely (num >1024 ) ) { ret = -E2BIG ;break ;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 4 lines · Olaf Hering
The value of num is always the same as
domctl->u.getpageframeinfo3.num, it was assigned just a few lines before.Signed-off-by Olaf Hering <[email protected]>
It is still useful. The field in getpageframeinfo3 is uint64_aligned_t while here num is just unsigned int. The check makes sure no truncation happens.
Quoted 19 lines
--- xen/arch/x86/domctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)xen/arch/x86/domctl.c +1
-2@@ -421,8 +421,7 @@ long arch_do_domctl(/* Games to allow this code block to handle a compat guest. */ void __user *guest_handle = domctl->u.getpageframeinfo3.array.p; -if (unlikely (num >1024 ) || -unlikely (num != domctl->u.getpageframeinfo3.num) ) +if (unlikely (num >1024 ) ) { ret = -E2BIG ;break ;
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Andrew Cooper
Quoted 4 lines · Olaf Hering
The value of num is always the same as
domctl->u.getpageframeinfo3.num, it was assigned just a few lines before.Signed-off-by Olaf Hering <[email protected]>This isn't dead code. It is a truncation check.
How can this happen, other than num being a 32bit type? Perhaps the type of num should match the type of i?
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel