Re: [patch 1/7] slab: introduce kzfree()



On Thu, 19 Feb 2009, Pekka Enberg wrote:
Hugh Dickins wrote:

But I fail to see it as a justification for kzfree(const void *):
if someone has "const char *string = kmalloc(size)" and then
wants that string zeroed before it is freed, then I think it's
quite right to cast out the const when calling kzfree().

Quite frankly, I fail to see how kzfree() is fundamentally different from
kfree(). I don't see kzfree() as a memset() + kfree() but rather as a kfree()
"and make sure no one sees my data". So the zeroing happens _after_ you've
invalidated the pointer with kzfree() so there's no "zeroing of buffer going
on".

Well, that would be one way of picturing it, yes.
Imagine the "z" as for "zap" rather than "zero",
and the mechanism as opaque as Hannes suggests.

So the way I see it, Linus' argument for having const for kfree() applies
to kzfree().

That said, if you guys think it's a merge blocker, by all means remove the
const. I just want few less open-coded ksize() users, that's all.

I wouldn't call it a merge blocker, no; though I still
think it makes far more sense without the "const" there.

Hugh
--
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/



Relevant Pages

  • Re: [patch 1/7] slab: introduce kzfree()
    ... I don't see kzfreeas a memset+ kfree() but rather as a ... _after_ you've invalidated the pointer with kzfree() so there's no ... That said, if you guys think it's a merge blocker, by all means remove ... think it makes far more sense without the "const" there. ...
    (Linux-Kernel)
  • Re: wmi fails after large number of calls
    ... Or, does it connect to a given computer sometimes, but fail at ... ' | <Script Description> ... Const ForAppending = 8 ... Function PingHost ...
    (microsoft.public.scripting.vbscript)
  • Re: BDA driver, question about get properties from node
    ... return code is 80004002 is for fail case. ... // Input pin to Output pin Topology Joints ... >> IN PKSPROPERTY pKSProperty, ...
    (microsoft.public.development.device.drivers)
  • Re: Whats the deal with the "toupper" family?
    ... No matter what you think `const' means in this context, ... it's up to the programmer to pass the right value. ... and doesn't want to validate the string for such ... Under what circumstances will casting to unsigned char fail, ...
    (comp.lang.c)
  • Re: [patch 1/7] slab: introduce kzfree()
    ... that's some justification for kfree(const void *). ... I fail to see how kzfreeis fundamentally different from kfree(). ...
    (Linux-Kernel)