[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/2] xen: Fix latent check-endbr.sh bug with 32bit build environments
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Mon, 18 Jul 2022 12:07:17 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=71G+fStirrYUkJ4mzyRcDJxUWxpHi1a7C+0G8jbybpg=; b=n6JrQ8TJU7cVXTptCLsaTPBZP0fvCCIgefhj32r3Bq5gm1AJN71iHNcS1OKSh69uxEJ5iKM9C8SJA7eKLbAoQmssxM29Q5RcLGv3RoiPzIukT4hRD6LBwZ3ZLUvj7Nzql5rdAJQCf37pq7rYIKT9s0dxfgH1I9sYjzIWKVK3ncGnifnELnr2Jd2EWrJDl3vsHWaTifse271i2vvt6RUBpOzQhAUxymkL7tU1aOxD/f4KL+0O7/ar3jwoJmdGNOKPjDBMJenBotBmIxJ9tCTGVIiNlaN/J5RCh9ZKEzYUUtnf+ZrF3WrC4acueFP68m5ZGmtqlPJQWhqUwvR1RNfxAQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RSXQyinIdFmiJBEb3vluSjQQuY+8ZhhDX3ySD+V2tpCYtxVCTL6BDNoVcXRxImniaeum6rZj4XGIsSt7RP9WbQpka9awXiH6ILHgy9LH0J7cduEHeZn9kAzStwHI0mmK7uZkljKUxeZvZvyrt9NQw8hPO31l8Th/y6L0yWzC1bTRM8ANnSCFluZ3iZduC/oFKUrcijnEAXHGE/V3zfR+rDN65RWT4YKI7+JrzO8ZvLFl13mVVmjZgr2I75nHuN53dqEGjpJhS26dEU6XsWVgcmekp5vZ1fn5GiibtZtBIz1gh64dr4lyXtlowbxQ7GhmYOlD0Gb/QmDkIabA06vIHg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: George Dunlap <George.Dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Luca Fancellu <Luca.Fancellu@xxxxxxx>, Mathieu Tarral <mathieu.tarral@xxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Mon, 18 Jul 2022 12:07:32 +0000
- Ironport-data: A9a23:2MSlZ6gCTtyCuAC91B6zpIaNX17brhtdnwn6uqucsGbUi9Gq9fh2uw5+26WXqo9YJnHy/Jhw1uoMPFhmrcXU2MMGZ0S4wqaCU6ZbeYpXDXyySKj/mddbAKH6d1lOz2nMjEBqjBo3k4vwclWaj57F57BiDyQmzVpxU/lCn3VQ0buTWZElw7iyawxo5YFTZnw3CIpsBp8KOIVA038YH5uEYqLK6UxHJdfLjukIWiOTjwzLRQe/iTvNMJ0RP0zkKs4G3FzZwiq8MvA9PNl9k2Mc/NLta+paKIS5pKe2nNq9Dchqd6xohxXnh2rgzWEzQbjLjUEf86kRYAbHb/5bXvzWG1GwxFFfSEsaIADBe1/YU0NpyRVd9E2rTYHaGKWPAg2p+SchuGOwXNR+vfzyuNdV/rShhkTvUbfiOAk+NesarXhjov7a7PdZWwYYQwif7QzCZHZjbGK6C4D7dD2gL5me5i6ZAZ2NcDRhaO4j+bheI+EP7RsSoYNaz0q1qFC54IatEGc0iiD2UAutAWAcfoppLCiZuB1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eyiMjJgX4cYaZq9Q==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYmE6f3nf19rITF02bMhbJMzY4w62D3CgAgAAFn4CAAATogIAAJoyA
- Thread-topic: [PATCH v2 2/2] xen: Fix latent check-endbr.sh bug with 32bit build environments
On 18/07/2022 10:49, Jan Beulich wrote:
> On 18.07.2022 11:31, Andrew Cooper wrote:
>> On 18/07/2022 10:11, Jan Beulich wrote:
>>> On 15.07.2022 15:26, Andrew Cooper wrote:
>>>> --- a/xen/tools/check-endbr.sh
>>>> +++ b/xen/tools/check-endbr.sh
>>>> @@ -61,19 +61,36 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' |
>>>> cut -f 1 -d ':' > $VALID &
>>>> # the lower bits, rounding integers to the nearest 4k.
>>>> #
>>>> # Instead, use the fact that Xen's .text is within a 1G aligned
>>>> region, and
>>>> -# split the VMA in half so AWK's numeric addition is only working on
>>>> 32 bit
>>>> -# numbers, which don't lose precision.
>>>> +# split the VMA so AWK's numeric addition is only working on <32 bit
>>>> +# numbers, which don't lose precision. (See point 5)
>>>> #
>>>> # 4) MAWK doesn't support plain hex constants (an optional part of the
>>>> POSIX
>>>> # spec), and GAWK and MAWK can't agree on how to work with hex
>>>> constants in
>>>> # a string. Use the shell to convert $vma_lo to decimal before
>>>> passing to
>>>> # AWK.
>>>> #
>>>> +# 5) Point 4 isn't fully portable. POSIX only requires that $((0xN)) be
>>>> +# evaluated as long, which in 32bit shells turns negative if bit 31 of
>>>> the
>>>> +# VMA is set. AWK then interprets this negative number as a double
>>>> before
>>>> +# adding the offsets from the binary grep.
>>>> +#
>>>> +# Instead of doing an 8/8 split with vma_hi/lo, do a 9/7 split.
>>>> +#
>>>> +# The consequence of this is that for all offsets, $vma_lo + offset
>>>> needs
>>>> +# to be less that 256M (i.e. 7 nibbles) so as to be successfully
>>>> recombined
>>>> +# with the 9 nibbles of $vma_hi. This is fine; .text is at the start
>>>> of a
>>>> +# 1G aligned region, and Xen is far far smaller than 256M, but leave
>>>> safety
>>>> +# check nevertheless.
>>>> +#
>>>> eval $(${OBJDUMP} -j .text $1 -h |
>>>> - $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1,
>>>> 8), substr($4, 9, 16)}')
>>>> + $AWK '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1,
>>>> 9), substr($4, 10, 16)}')
>>>>
>>>> ${OBJCOPY} -j .text $1 -O binary $TEXT_BIN
>>>>
>>>> +bin_sz=$(stat -c '%s' $TEXT_BIN)
>>>> +[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] &&
>>>> + { echo "$MSG_PFX Error: .text offsets can exceed 256M" >&2; exit 1; }
>>> ... s/can/cannot/ ?
>> Why? "Can" is correct here. If the offsets can't exceed 256M, then
>> everything is good.
> Hmm, the wording then indeed is ambiguous.
I see your point. In this case it's meant as "are able to", but this is
still clearer than using "can't" because at least the text matches the
check which triggered it.
> I read "can" as "are allowed
> to", when we mean "aren't allowed to". Maybe ".text is 256M or more in
> size"? If you mention "offsets", then I think the check should be based
> on actually observing an offset which is too large (which .text size
> alone doesn't guarantee will happen).
It's not just .text on its own because the VMA of offset by 2M, hence
the subtraction of $vma_lo in the main calculation.
There's no point searching for offsets. There will be one near the end,
so all searching for an offset would do is complicate the critical loop.
How about ".text offsets must not exceed 256M" ?
That should be unambiguous.
~Andrew
|