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

[xen stable-4.22] x86/mkelf32: correct off-by-1 in empty PHDR checking loop



commit e5867ed7bbbacfe3c483c04df19e7d6af7a478a5
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Nov 25 14:36:10 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 25 14:36:10 2026 +0100

    x86/mkelf32: correct off-by-1 in empty PHDR checking loop
    
    To read the trailing PHDR, we need to seek to its start position within
    the file, not its ending one.
    
    Fixes: 54279f87ecbc ("x86/build: make linking work again with ld incapable 
of generating build ID")
    Reported-by: Roger Pau Monné <roger.pau@xxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: 033a241688d2f340df6301d1d31e2cda842911c4
    master date: 2026-11-25 09:44:04 +0100
---
 xen/arch/x86/boot/mkelf32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/boot/mkelf32.c b/xen/arch/x86/boot/mkelf32.c
index 4f742a4e69..e87bc48e28 100644
--- a/xen/arch/x86/boot/mkelf32.c
+++ b/xen/arch/x86/boot/mkelf32.c
@@ -320,7 +320,8 @@ int main(int argc, char **argv)
     while ( in64_ehdr.e_phnum > num_phdrs )
     {
         (void)lseek(infd,
-                    in64_ehdr.e_phoff + in64_ehdr.e_phnum * sizeof(in64_phdr),
+                    in64_ehdr.e_phoff + (in64_ehdr.e_phnum - 1) *
+                                        sizeof(in64_phdr),
                     SEEK_SET);
         do_read(infd, &in64_phdr, sizeof(in64_phdr));
         endianadjust_phdr64(&in64_phdr);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.22



 


Rackspace

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