Re: [RFC 2/1] kill task_ucounts()->rcu_read_lock(), add __task_ucounts()

From: David Howells
Date: Mon Oct 27 2025 - 10:58:31 EST


Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

> So I think task_ucounts() can just do
>
> /* The caller must ensure that ->real_cred is stable or take rcu_read_lock() */
> #define task_ucounts(task) \
> rcu_dereference_check((task)->real_cred, 1)->ucounts

Can you use rcu_access_pointer() within exit.c? E.g.:

struct cred *pcreds = rcu_access_pointer(task->real_cred);
dec_rlimit_ucounts(pcreds->ucounts, UCOUNT_RLIMIT_NPROC, 1);

David