git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] apply: Avoid ambiguous pointer provenance for CHERI/Arm's Morello

From
Jessica Clarke <jrtc27@jrtc27.com>
Date
Jan 6, 2022, 22:57 UTC
Message-ID
<C2DD77CA-D1F1-45ED-912F-C4532EB2720C@jrtc27.com>
In-Reply-To
<YddySiBCOOYYKDmC@nand.local>
]On 6 Jan 2022, at 22:50, Taylor Blau <me@ttaylorr.com> wrote:
Show 20 quoted lines
> 
> On Wed, Jan 05, 2022 at 01:23:10PM +0000, Jessica Clarke wrote:
>> [...] In most cases this is clear, as normally at least one operand is
>> provably a plain integer, but if both operands are uintptr_t and have
>> no indication they're just plain integers then it is ambiguous, and
>> the current implementation will arbitrarily, but deterministically,
>> pick the left-hand side, due to empirical evidence that it is more
>> likely to be correct.
> 
> Wouldn't a simpler, less invasive fix be to instead write the expression
> so that the left-hand operand is a pointer? IOW, shouldn't the following
> work (with no other changes):
> 
>    ent->util = (void *)((uintptr_t)what | ent->util);
> 
> ?
> 
> (I dropped the explicit cast on the right-hand side, since ent->util is
> already a uintptr_t, and the left-hand side has an explicit cast, so
> there isn't any type promotion going on here).

That would still warn as it’s still ambiguous. It just happens that the arbitrary choice picks the right side. Better to clean up the code to remove the ambiguity and clarify it to the programmer.

Jess
Previous: Taylor BlauNext: Junio C Hamano
Message 5 of 14 in “apply: Avoid ambiguous pointer provenance for CHERI/Arm's Morello”
  1. apply: Avoid ambiguous pointer provenance for CHERI/Arm's MorelloJessica Clarke, Jan 5, 2022
  2. Konstantin KhomoutovJan 5, 2022
  3. Jessica ClarkeJan 5, 2022
  4. Taylor BlauJan 6, 2022
  5. Jessica ClarkeJan 6, 2022
  6. Junio C HamanoJan 6, 2022
  7. Jessica ClarkeJan 6, 2022
  8. Junio C HamanoJan 6, 2022
  9. René ScharfeJan 7, 2022
  10. Jessica ClarkeJan 7, 2022
  11. Junio C HamanoJan 7, 2022
  12. René ScharfeJan 8, 2022
  13. Junio C HamanoJan 8, 2022
  14. Junio C HamanoJan 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.