diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-14 08:32:24 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-14 08:32:24 +0300 |
| commit | 7ca932e441325f4fb1444c568446b4338ff28ae7 (patch) | |
| tree | b8928d59da95a4f0c19b30735e58d7fe2730661b /include/linux/string.h | |
| parent | d1a1af2cdf19770d69947769f5d5a16c39de93e6 (diff) | |
| parent | 4f5cafb5cb8471e54afdc9054d973535614f7675 (diff) | |
| download | linux-7ca932e441325f4fb1444c568446b4338ff28ae7.tar.xz | |
Merge 5.4-rc3 into tty-next
We need the tty/serial fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/string.h')
| -rw-r--r-- | include/linux/string.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/include/linux/string.h b/include/linux/string.h index b2f9df7f0761..b6ccdc2c7f02 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -227,7 +227,26 @@ static inline bool strstarts(const char *str, const char *prefix) } size_t memweight(const void *ptr, size_t bytes); -void memzero_explicit(void *s, size_t count); + +/** + * memzero_explicit - Fill a region of memory (e.g. sensitive + * keying data) with 0s. + * @s: Pointer to the start of the area. + * @count: The size of the area. + * + * Note: usually using memset() is just fine (!), but in cases + * where clearing out _local_ data at the end of a scope is + * necessary, memzero_explicit() should be used instead in + * order to prevent the compiler from optimising away zeroing. + * + * memzero_explicit() doesn't need an arch-specific version as + * it just invokes the one of memset() implicitly. + */ +static inline void memzero_explicit(void *s, size_t count) +{ + memset(s, 0, count); + barrier_data(s); +} /** * kbasename - return the last part of a pathname. |
