[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878qix0wx4.ffs@tglx>
Date: Tue, 02 Sep 2025 16:08:23 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, LKML
<linux-kernel@...r.kernel.org>
Cc: Jens Axboe <axboe@...nel.dk>, Peter Zijlstra <peterz@...radead.org>,
"Paul E. McKenney" <paulmck@...nel.org>, Boqun Feng
<boqun.feng@...il.com>, Paolo Bonzini <pbonzini@...hat.com>, Sean
Christopherson <seanjc@...gle.com>, Wei Liu <wei.liu@...nel.org>, Dexuan
Cui <decui@...rosoft.com>, x86@...nel.org, Arnd Bergmann <arnd@...db.de>,
Heiko Carstens <hca@...ux.ibm.com>, Christian Borntraeger
<borntraeger@...ux.ibm.com>, Sven Schnelle <svens@...ux.ibm.com>, Huacai
Chen <chenhuacai@...nel.org>, Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>
Subject: Re: [patch V2 23/37] rseq: Provide and use rseq_set_uids()
On Tue, Aug 26 2025 at 10:52, Mathieu Desnoyers wrote:
>> +{
>> + u32 cpu_id, uval, node_id = cpu_to_node(task_cpu(t));
>> + struct rseq __user *rseq = t->rseq;
>> +
>> + if (t->rseq_ids.cpu_cid == ~0)
>> + return true;
>> +
>> + if (!user_read_masked_begin(rseq))
>> + return false;
>> +
>> + unsafe_get_user(cpu_id, &rseq->cpu_id_start, efault);
>> + if (cpu_id != t->rseq_ids.cpu_id)
>> + goto die;
>> + unsafe_get_user(uval, &rseq->cpu_id, efault);
>> + if (uval != cpu_id)
>> + goto die;
>> + unsafe_get_user(uval, &rseq->node_id, efault);
>> + if (uval != node_id)
>> + goto die;
>
> AFAIU, when a task migrates across NUMA nodes, userspace will have a
> stale value and this check will fail, thus killing the process. To fix
> this you'd need to derive "node_id" from
> cpu_to_node(t->rseq_ids.cpu_id).
Good catch.
> But doing that will not work on powerpc, where the mapping between
> node_id and cpu_id can change dynamically, AFAIU this can kill processes
> even though userspace did not alter the node_id behind the kernel's
> back.
Still not an issue. You might need to reread the related PPC code :)
>> +
>> + /* Cache the new values */
>> + t->rseq_ids.cpu_cid = ids->cpu_cid;
>
> I may be missing something, but I think we're missing updates to
> t->rseq_ids.mm_cid and we may want to keep track of t->rseq_ids.node_id
> as well.
Oops. I'm sure I had that mm_cid caching, but somehow dropped it. And
again, no need to keep track of the node id. It's stable vs. CPU ID.
Thanks,
tglx
Powered by blists - more mailing lists