Re: [PATCH] mm: Add kvfree_sensitive() for freeing sensitive data objects

Linus Torvalds
2020-04-06T17:33:59Z

On Mon, Apr 6, 2020 at 10:22 AM Joe Perches <joe@perches.com> wrote:
>
> API function naming symmetry is good.

BS.

Naming should be symmetric if _use_ is symmetric.

But if the use is completely different, then the naming should be
completely different too.

A symmetric naming is only helpful if it implies symmetries in use.
Otherwise it's actively misleading.

In "kzalloc()", the z is meaningful and an important part of what the
caller wants.

In "kzfree()", the z is actively detrimental, because maybe in the
future we really _might_ want to use that "memfill(0xdeadbeef)" or
something. The "zero" part of the interface isn't even _relevant_.

See? There is no API symmetry. There is only a small and immaterial
implementation detail.

We don't put an "l" into the kfree/kmalloc names because they
internally use a percpu list to manage the allocations, do we? That's
a "symmetry" too. But it's an irrelevant implementation detail that
makes no sense to the caller.

Linus