Re: [patch 1/2] ptrace, security: rename ptrace_may_access =>ptrace_access_check

From: Ingo Molnar
Date: Mon May 11 2009 - 09:41:20 EST



* Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Thu, 7 May 2009 11:49:47 +0200
> Ingo Molnar <mingo@xxxxxxx> wrote:
>
> > The ptrace_may_access() methods are named confusingly - some
> > variants return a bool, while the security subsystem methods have a
> > retval convention.
> >
> > Rename it to ptrace_access_check, to reduce the confusion factor. A
> > followup patch eliminates the bool usage.
>
> s/may_access/access_check/ is a poor change. The new name conveys
> less information than the old one.
>
> It's quite clear what the return value from "may_access" means.

it isnt clear at all. In fact there's two variants: one that returns
'int' and one that returns 'bool' - the two have inverted values.

> It's less clear what the return value from a function called
> "access_check" means.
>
> Switching to something like ptrace_task_accessible() or
> ptrace_may_access_task() would be better.
>
> This happens quite often. The string "check" in the name of a
> predicate function is a red flag.

I disagree. To repeat the argument i made in this thread, the 'may'
suggests/attracts a logical value, i.e. yes or no, or boolean. But
that goes against the desire of actual call sites wanting a Linux
retval.

I.e. any function name that can be plain-English answered with:
'yes' or 'no' is a red flag for a retval function.

You cannot answer ptrace_access_check() with 'yes' or 'no'. You
could if it was ptrace_access_ok() or ptrace_may_access.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/