Messages in this thread | | | Subject | Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects | From | Waiman Long <> | Date | Tue, 5 May 2020 21:29:58 -0400 |
| |
On 5/5/20 4:35 PM, Andrew Morton wrote: > On Tue, 07 Apr 2020 21:21:57 +0100 David Howells <dhowells@redhat.com> wrote: > >> David Howells <dhowells@redhat.com> wrote: >> >>>> if (unlikely(key_data)) >>>> - __kvzfree(key_data, key_data_len); >>>> + kvfree_sensitive(key_data, key_data_len); >>> I think the if-statement is redundant. >> Ah - I see that you explicitly wanted to keep it. > Why's that?
There is a comment above it:
/* * The key may change (unlikely) in between 2 consecutive * __keyctl_read_key() calls. In this case, we reallocate * a larger buffer and redo the key read when * key_data_len < ret <= buflen. */ if (ret > key_data_len) { if (unlikely(key_data)) __kvzfree(key_data, key_data_len);
key_data will be defined only if the unlikely case that the key increase in length between the 2 consecutive __keyctl_read_key() call and we have to enlarge the buffer and read the key again. I want to keep the unlikely() macro to emphasize the fact that this condition should not happen.
>> There's a good chance it'll get janitored at some point. > Indeed. Perhaps add a few little comments to explain the reasoning and > to keep the janitorial fingers away? > I can reword the comment to make it more explicit and send a v4 if you think the current comment is not clear enough.
Cheers, Longman
| |