Skip to contentSkip to conversation

livepatch: use appropriate type for buffer offset variables

PATCH In review Jan Beulich 3 participants 3 messages Jun 20, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 livepatch: use appropriate type for buffer offset variables

As was made noticeable by the last of the commits referenced below, using a fixed-size type for such purposes is not only against ./CODING_STYLE, but can lead to actual issues. Switch to using size_t instead, thus also allowing calculations to be lighter-weight in 32-bit builds.

No functional change for 64-bit builds.

Fixes b145b4a39c13 ("livepatch: Handle arbitrary size names with the list operation")
Fixes 5083e0ff939d ("livepatch: Add metadata runtime retrieval mechanism")
Fixes 43d5c5d5f70b ("xen: avoid UB in guest handle arithmetic")
xen/common/livepatch.c +1 -1
@@ -1252,7 +1252,7 @@ static int livepatch_list(struct xen_sys
     list->metadata_total_size = 0;
     if ( list->nr )
     {
-        uint64_t name_offset = 0, metadata_offset = 0;
+        size_t name_offset = 0, metadata_offset = 0;
 
         list_for_each_entry( data, &payload_list, list )
         {
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

As was made noticeable by the last of the commits referenced below, using a fixed-size type for such purposes is not only against ./CODING_STYLE, but can lead to actual issues. Switch to using size_t instead, thus also allowing calculations to be lighter-weight in 32-bit builds.

Quoted 9 lines

No functional change for 64-bit builds.

Fixes b145b4a39c13 ("livepatch: Handle arbitrary size names with the list operation")
Fixes 5083e0ff939d ("livepatch: Add metadata runtime retrieval mechanism")
Fixes 43d5c5d5f70b ("xen: avoid UB in guest handle arithmetic")

Thanks

#2 lore raw
Quoted 23 lines · Ross Lagerwall
Quoted 11 lines · Jan Beulich

As was made noticeable by the last of the commits referenced below, using a fixed-size type for such purposes is not only against ./CODING_STYLE, but can lead to actual issues. Switch to using size_t
instead, thus also allowing calculations to be lighter-weight in 32-bit
builds.

No functional change for 64-bit builds.

Quoted 9 lines
Fixes b145b4a39c13 ("livepatch: Handle arbitrary size names with

the list operation")

Fixes 5083e0ff939d ("livepatch: Add metadata runtime retrieval

mechanism")

Fixes 43d5c5d5f70b ("xen: avoid UB in guest handle arithmetic")
Quoted 1 line

~ Oleksii