diff mbox series

[for-4.19] livepatch: use appropriate type for buffer offset variables

Message ID a4d780fd-90c2-405e-be21-c323a22a78c6@suse.com (mailing list archive)
State New, archived
Headers show
Series [for-4.19] livepatch: use appropriate type for buffer offset variables | expand

Commit Message

Jan Beulich June 20, 2024, 7:15 a.m. UTC
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.

Link: https://gitlab.com/xen-project/xen/-/jobs/7136417308
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")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Ross Lagerwall June 20, 2024, 8:04 a.m. UTC | #1
On Thu, Jun 20, 2024 at 8:16 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> 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.
>
> Link: https://gitlab.com/xen-project/xen/-/jobs/7136417308
> 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")
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>

Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Thanks
Oleksii Kurochko June 20, 2024, 9:46 a.m. UTC | #2
On Thu, 2024-06-20 at 09:04 +0100, Ross Lagerwall wrote:
> On Thu, Jun 20, 2024 at 8:16 AM Jan Beulich <jbeulich@suse.com>
> wrote:
> > 
> > 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.
> > 
> > Link: https://gitlab.com/xen-project/xen/-/jobs/7136417308
> > 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")
> > Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> > 
> 
> Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

~ Oleksii
diff mbox series

Patch

--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -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 )
         {