History

compiler_types.h: Remove __compiletime_object_size()

Since all compilers support __builtin_object_size(), and there is only one user of __compiletime_object_size, remove it to avoid the needless indirection. This lets Clang reason about check_copy_size() correctly.

Kees Cook committed 5 years ago

Commit c80d92f1 parent 86100473 files · +1 −8Browse files

Unified · Split

3 files
  1. include/linux/compiler-gcc.h +0 −2
  2. include/linux/compiler_types.h +0 −5
  3. include/linux/thread_info.h +1 −1
include/linux/compiler-gcc.h+0−2
@@ -41,8 +41,6 @@ · 40 unmodified lines
41 41
42#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)42#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
43 43
44#define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
45
46#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)44#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
47#define __latent_entropy __attribute__((latent_entropy))45#define __latent_entropy __attribute__((latent_entropy))
48#endif46#endif
include/linux/compiler_types.h+0−5
@@ -290,11 +290,6 @@ struct ftrace_likely_data { · 289 unmodified lines
290 (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \290 (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
291 sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))291 sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
292 292
293/* Compile time object size, -1 for unknown */
294#ifndef __compiletime_object_size
295# define __compiletime_object_size(obj) -1
296#endif
297
298#ifdef __OPTIMIZE__293#ifdef __OPTIMIZE__
299# define __compiletime_assert(condition, msg, prefix, suffix) \294# define __compiletime_assert(condition, msg, prefix, suffix) \
300 do { \295 do { \
include/linux/thread_info.h+1−1
@@ -203,7 +203,7 @@ static inline void copy_overflow(int size, unsigned long count) · 202 unmodified lines
203static __always_inline __must_check bool203static __always_inline __must_check bool
204check_copy_size(const void *addr, size_t bytes, bool is_source)204check_copy_size(const void *addr, size_t bytes, bool is_source)
205{205{
206 int sz = __compiletime_object_size(addr);206 int sz = __builtin_object_size(addr, 0);
207 if (unlikely(sz >= 0 && sz < bytes)) {207 if (unlikely(sz >= 0 && sz < bytes)) {
208 if (!__builtin_constant_p(bytes))208 if (!__builtin_constant_p(bytes))
209 copy_overflow(sz, bytes);209 copy_overflow(sz, bytes);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t