Re: Buggy __free(kfree) usage pattern already in tree

From: Peter Zijlstra
Date: Fri Sep 15 2023 - 17:18:59 EST


On Fri, Sep 15, 2023 at 11:08:51PM +0200, Peter Zijlstra wrote:

> But a little later in that same function I then have:
>
> do {
> struct rw_semaphore *exec_update_lock __free(up_read) = NULL;
> if (task) {
> err = down_read_interruptible(&task->signal->exec_update_lock);
> if (err)
> return err;
>
> exec_update_lock = &task->signal->exec_update_lock;
>
> if (!perf_check_permissions(&attr, task))
> return -EACCESS;
> }
>
> ... stuff serialized against exec *if* this is a task event ...
>
> } while (0);
>
>
> And that might be a little harder to 'fix'.

Hmm, perhaps I can do a class for it and write the thing like:

do {
CLASS(cond_exec_update_lock, exec_lock_guard)(task); /* allow task == NULL */
if (task && !exec_lock_guard)
return -EINTR;

if (task && !perf_check_permissions(&attr, task))
return -EACCESS;

... the rest ...

} while (0);

that might be nicer..