Re: [PATCH] apply: Avoid ambiguous pointer provenance for CHERI/Arm's Morello
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Jan 6, 2022, 22:50 UTC
- Message-ID
- <YddySiBCOOYYKDmC@nand.local>
- In-Reply-To
- <20220105132310.6600-1-jrtc27@jrtc27.com>
On Wed, Jan 05, 2022 at 01:23:10PM +0000, Jessica Clarke wrote:
Show 6 quoted lines
> [...] 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).
Thanks, Taylor