/* * Copyright (C) 2014-2017 Tobias Klauser * Copyright (C) 2009-2012 Daniel Borkmann * * This file is part of llmnrd. * * llmnrd is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 2 of the License. * * llmnrd is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with llmnrd. If not, see . */ #ifndef UTIL_H #define UTIL_H #include #include #include #include #include "compiler.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* * min()/max() macros with strict type-checking. * Taken from linux/kernel.h */ #undef min #define min(x, y) ({ \ typeof(x) _min1 = (x); \ typeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; }) #undef max #define max(x, y) ({ \ typeof(x) _max1 = (x); \ typeof(y) _max2 = (y); \ (void) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) static inline void panic(const char *fmt, ...) __check_format_printf(1, 2); static inline void __noreturn panic(const char *fmt, ...) { va_list vl; va_start(vl, fmt); vfprintf(stderr, fmt, vl); va_end(vl); exit(EXIT_FAILURE); } void *xmalloc(size_t size) __warn_unused_result; void *xzalloc(size_t size) __warn_unused_result; void *xrealloc(void *ptr, size_t size) __warn_unused_result; char *xstrdup(const char *s) __warn_unused_result; static inline bool xstreq(const char *str1, const char *str2) { size_t n = strlen(str1); if (n != strlen(str2)) return false; if (strncmp(str1, str2, n) != 0) return false; return true; } #endif /* UTIL_H */ da5ccc6b85dc05bbe6a091e58be896a'>treecommitdiff
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2016-05-16 15:16:18 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-05-17 14:26:52 +0800
commit4a6b27b79da5ccc6b85dc05bbe6a091e58be896a (patch)
tree3b6c2e16d410844d288165218e62c037cb0e8ca3 /Documentation/i2c
parent256b1cfb9a346bb4808cd27b7b8f9b120f96491e (diff)
crypto: sha1-mb - make sha1_x8_avx2() conform to C function ABI
Megha Dey reported a kernel panic in crypto code. The problem is that sha1_x8_avx2() clobbers registers r12-r15 without saving and restoring them. Before commit aec4d0e301f1 ("x86/asm/crypto: Simplify stack usage in sha-mb functions"), those registers were saved and restored by the callers of the function. I removed them with that commit because I didn't realize sha1_x8_avx2() clobbered them. Fix the potential undefined behavior associated with clobbering the registers and make the behavior less surprising by changing the registers to be callee saved/restored to conform with the C function call ABI. Also, rdx (aka RSP_SAVE) doesn't need to be saved: I verified that none of the callers rely on it being saved, and it's not a callee-saved register in the C ABI. Fixes: aec4d0e301f1 ("x86/asm/crypto: Simplify stack usage in sha-mb functions") Cc: stable@vger.kernel.org # 4.6 Reported-by: Megha Dey <megha.dey@linux.intel.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'Documentation/i2c')