[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.18] xen/spinlock: Fix UBSAN "load of address with insufficient space" in lock_prof_init()



commit c2b8041904378ef5ecc8182fed4b904b1b30f021
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Oct 29 16:41:30 2024 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Oct 29 16:41:30 2024 +0100

    xen/spinlock: Fix UBSAN "load of address with insufficient space" in 
lock_prof_init()
    
    UBSAN complains:
    
      (XEN) 
================================================================================
      (XEN) UBSAN: Undefined behaviour in common/spinlock.c:794:10
      (XEN) load of address ffff82d040ae24c8 with insufficient space
      (XEN) for an object of type 'struct lock_profile *'
      (XEN) ----[ Xen-4.20-unstable  x86_64  debug=y ubsan=y  Tainted:   C    
]----
    
    This shows up with GCC-14, but not with GCC-12.  I have not bisected 
further.
    
    Either way, the types for __lock_profile_{start,end} are incorrect.
    
    They are an array of struct lock_profile pointers.  Correct the extern's
    types, and adjust the loop to match.
    
    No practical change.
    
    Reported-by: Andreas Glashauser <ag@xxxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
    master commit: 542ac112fc68c66cfafc577e252404c21da4f75b
    master date: 2024-10-14 16:14:26 +0100
---
 xen/common/spinlock.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c
index 7f453234a9..4fc6f00177 100644
--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -501,9 +501,6 @@ struct lock_profile_anc {
 typedef void lock_profile_subfunc(
     struct lock_profile *, int32_t, int32_t, void *);
 
-extern struct lock_profile *__lock_profile_start;
-extern struct lock_profile *__lock_profile_end;
-
 static s_time_t lock_profile_start;
 static struct lock_profile_anc lock_profile_ancs[] = {
     [LOCKPROF_TYPE_GLOBAL] = { .name = "Global" },
@@ -659,13 +656,16 @@ void _lock_profile_deregister_struct(
     spin_unlock(&lock_profile_lock);
 }
 
+extern struct lock_profile *__lock_profile_start[];
+extern struct lock_profile *__lock_profile_end[];
+
 static int __init cf_check lock_prof_init(void)
 {
     struct lock_profile **q;
 
     BUILD_BUG_ON(ARRAY_SIZE(lock_profile_ancs) != LOCKPROF_TYPE_N);
 
-    for ( q = &__lock_profile_start; q < &__lock_profile_end; q++ )
+    for ( q = __lock_profile_start; q < __lock_profile_end; q++ )
     {
         (*q)->next = lock_profile_glb_q.elem_q;
         lock_profile_glb_q.elem_q = *q;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.