Re: [PATCH v1 3/3] x86: call instrumentation hooks from copy_mc.c

From: Linus Torvalds
Date: Tue Mar 19 2024 - 13:58:33 EST


On Tue, 19 Mar 2024 at 09:37, Alexander Potapenko <glider@xxxxxxxxxx> wrote:
>
> if (copy_mc_fragile_enabled) {
> __uaccess_begin();
> + instrument_copy_to_user(dst, src, len);
> ret = copy_mc_fragile((__force void *)dst, src, len);
> __uaccess_end();

I'd actually prefer that instrument_copy_to_user() to be *outside* the
__uaccess_begin.

In fact, I'm a bit surprised that objtool didn't complain about it in that form.

__uaccess_begin() causes the CPU to accept kernel accesses to user
mode, and I don't think instrument_copy_to_user() has any business
actually touching user mode memory.

In fact it might be better to rename the function and change the prototype to

instrument_src(src, len);

because you really can't sanely instrument the destination of a user
copy, but "instrument_src()" might be useful in other situations than
just user copies.

Hmm?

Linus