Re: [PATCH 1/1] arm64: syscall: Direct PRNG kstack randomization

From: Jeremy Linton
Date: Fri Mar 22 2024 - 19:41:06 EST


Hi,

Sorry about the delay here, PTO and I actually wanted to verify my assumptions.

On 3/8/24 14:29, Arnd Bergmann wrote:
On Fri, Mar 8, 2024, at 17:49, Jeremy Linton wrote:
On 3/7/24 05:10, Arnd Bergmann wrote:

I'm not sure I understand the logic. Do you mean that accessing
CNTVCT itself is slow, or that reseeding based on CNTVCT is slow
because of the overhead of reseeding?

Slow, as in, its running at a much lower frequency than a cycle counter.

Ok, I see. Would it be possible to use PMEVCNTR0 instead?

So, I presume you actually mean PMCCNTR_EL0 because I don't see the point of a dedicated event, although maybe...

So, the first and maybe largest problem is the PMxxx registers are all optional because the PMU is optional! Although, they are strongly recommended and most (AFAIK) machines do implement them. So, maybe if its just using a cycle counter to dump some entropy into rnd_state it becomes a statement that kstack randomization is slower or unsupported if there isn't a PMU?

But then we have to basically enable the PMU cycle counter globally, which requires reworking how it works, because the cycle counter is enabled/disabled and reset on the fly depending on whether the user is trying to profile something. So, I have hacked that up, and it appears to be working, although i'm not sure what kind of interaction will happen with KVM yet.

But I guess the larger question is whether its worth changing the PMU behavior for this?


Thanks,