diff options
| author | Zhenyu Wang <zhenyuw@linux.intel.com> | 2020-02-20 11:23:37 +0300 |
|---|---|---|
| committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2020-02-20 11:23:37 +0300 |
| commit | c95baf12f5077419db01313ab61c2aac007d40cd (patch) | |
| tree | 8c2aed3b89aecfb100b0546b601b7c7ae513a974 /include/linux/string.h | |
| parent | 690c3df85f107c7e2b5726392e0f53bb18ec9f73 (diff) | |
| parent | e24bcd34c1dd7dabde4a8546920537f7137e3c5f (diff) | |
| download | linux-c95baf12f5077419db01313ab61c2aac007d40cd.tar.xz | |
Merge drm-intel-next-queued into gvt-next
Backmerge to pull in
https://patchwork.freedesktop.org/patch/353621/?series=73544&rev=1
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Diffstat (limited to 'include/linux/string.h')
| -rw-r--r-- | include/linux/string.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/linux/string.h b/include/linux/string.h index b2f9df7f0761..02894e417565 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -216,6 +216,8 @@ int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4); extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, const void *from, size_t available); +int ptr_to_hashval(const void *ptr, unsigned long *hashval_out); + /** * strstarts - does @str start with @prefix? * @str: string to examine @@ -227,7 +229,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. |
