diff options
| author | Rodrigo Vivi <[email protected]> | 2022-12-30 04:09:09 -0500 |
|---|---|---|
| committer | Rodrigo Vivi <[email protected]> | 2022-12-30 04:18:36 -0500 |
| commit | b501d4dc83aa3940189b68045cadc8b3eac73988 (patch) | |
| tree | e5310a4fafd59505c3db86bb05baf964cb8da944 /include/linux/stackprotector.h | |
| parent | 4071d98b296a5bc5fd4b15ec651bd05800ec9510 (diff) | |
| parent | 1b929c02afd37871d5afb9d498426f83432e71c2 (diff) | |
Merge drm/drm-next into drm-intel-gt-next
Sync after v6.2-rc1 landed in drm-next.
We need to get some dependencies in place before we can merge
the fixes series from Gwan-gyeong and Chris.
References: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Rodrigo Vivi <[email protected]>
Diffstat (limited to 'include/linux/stackprotector.h')
| -rw-r--r-- | include/linux/stackprotector.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/stackprotector.h b/include/linux/stackprotector.h index 4c678c4fec58..9c88707d9a0f 100644 --- a/include/linux/stackprotector.h +++ b/include/linux/stackprotector.h @@ -6,6 +6,25 @@ #include <linux/sched.h> #include <linux/random.h> +/* + * On 64-bit architectures, protect against non-terminated C string overflows + * by zeroing out the first byte of the canary; this leaves 56 bits of entropy. + */ +#ifdef CONFIG_64BIT +# ifdef __LITTLE_ENDIAN +# define CANARY_MASK 0xffffffffffffff00UL +# else /* big endian, 64 bits: */ +# define CANARY_MASK 0x00ffffffffffffffUL +# endif +#else /* 32 bits: */ +# define CANARY_MASK 0xffffffffUL +#endif + +static inline unsigned long get_random_canary(void) +{ + return get_random_long() & CANARY_MASK; +} + #if defined(CONFIG_STACKPROTECTOR) || defined(CONFIG_ARM64_PTR_AUTH) # include <asm/stackprotector.h> #else |