qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, dorjoychy111@gmail.com
Subject: Re: [PATCH] eif: cope with huge section offsets
Date: Wed, 6 Nov 2024 09:54:26 -0800	[thread overview]
Message-ID: <b463bc8a-4625-43e6-a9da-4df526aa89a3@linaro.org> (raw)
In-Reply-To: <CABgObfajkp+5vFnQuV+V6Mp+LuP_Yo-=JtZtGUcYB_GDDbWoJQ@mail.gmail.com>

On 11/6/24 09:49, Paolo Bonzini wrote:
> On Wed, Nov 6, 2024 at 6:47 PM Pierrick Bouvier
> <pierrick.bouvier@linaro.org> wrote:
> 
>>>        for (int i = 0; i < MAX_SECTIONS; ++i) {
>>>            header->section_offsets[i] = be64_to_cpu(header->section_offsets[i]);
>>> +        if (header->section_offsets[i] > OFF_MAX) {
>>
>> Maybe we could add a comment that sections_offsets is unsigned, as it
>> can be confusing to read value > INT_MAX without more context.
> 
> It does sound like OFF_MAX is related to section_offsets[], but it's
> actually related to off_t.  So the comparison is with the maximum
> value of off_t, which is signed.
> 
> The problem would happen even if section_offsets[] was signed (for
> example off_t could be 32-bit).
> 

I'm a bit confused.
It works because section_offsets[i] is unsigned. If it was signed, and 
sizeof(off_t) is 8, we can never satisfy "(int64) > INT64_MAX".

> Paolo
> 
>>> +            error_setg(errp, "Invalid EIF image. Section offset out of bounds");
>>> +            return false;
>>> +        }
>>>        }
>>>
>>>        for (int i = 0; i < MAX_SECTIONS; ++i) {
>>
>> Else,
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
> 


  reply	other threads:[~2024-11-06 17:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 17:42 [PATCH] eif: cope with huge section offsets Paolo Bonzini
2024-11-06 17:47 ` Pierrick Bouvier
2024-11-06 17:49   ` Paolo Bonzini
2024-11-06 17:54     ` Pierrick Bouvier [this message]
2024-11-06 17:58       ` Paolo Bonzini
2024-11-06 18:07         ` Dorjoy Chowdhury

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b463bc8a-4625-43e6-a9da-4df526aa89a3@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=dorjoychy111@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).