]> xenbits.xensource.com Git - xen.git/commitdiff
xen: re-add type checking to {,__}copy_from_guest_offset()
authorJan Beulich <jbeulich@suse.com>
Tue, 25 Jun 2024 09:36:59 +0000 (11:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 25 Jun 2024 09:36:59 +0000 (11:36 +0200)
When re-working them to avoid UB on guest address calculations, I failed
to add explicit type checks in exchange for the implicit ones that until
then had happened in assignments that were there anyway.

Fixes: 43d5c5d5f70b ("xen: avoid UB in guest handle arithmetic")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
xen/include/xen/guest_access.h

index 96dbef2e0251a97ce6f433e06266f723852a426c..a2146749e396712f11752241c926ea6f821a3273 100644 (file)
@@ -86,6 +86,7 @@
 #define copy_from_guest_offset(ptr, hnd, off, nr) ({    \
     unsigned long s_ = (unsigned long)(hnd).p;          \
     typeof(*(ptr)) *_d = (ptr);                         \
+    (void)((hnd).p == _d);                              \
     raw_copy_from_guest(_d,                             \
                         (const void *)(s_ + (off) * sizeof(*_d)), \
                         (nr) * sizeof(*_d));            \
 #define __copy_from_guest_offset(ptr, hnd, off, nr) ({          \
     unsigned long s_ = (unsigned long)(hnd).p;                  \
     typeof(*(ptr)) *_d = (ptr);                                 \
+    (void)((hnd).p == _d);                                      \
     __raw_copy_from_guest(_d,                                   \
                           (const void *)(s_ + (off) * sizeof(*_d)), \
                           (nr) * sizeof(*_d));                  \