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
4141
4242 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
4343
44−#define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
45−
4644 #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
4745 #define __latent_entropy __attribute__((latent_entropy))
4846 #endif
include/linux/compiler_types.h+0−5
@@ -290,11 +290,6 @@ struct ftrace_likely_data { · 289 unmodified lines
290290 (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
291291 sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
292292
293−/* Compile time object size, -1 for unknown */
294−#ifndef __compiletime_object_size
295−# define __compiletime_object_size(obj) -1
296−#endif
297−
298293 #ifdef __OPTIMIZE__
299294 # define __compiletime_assert(condition, msg, prefix, suffix) \
300295 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
203203 static __always_inline __must_check bool
204204 check_copy_size(const void *addr, size_t bytes, bool is_source)
205205 {
206− int sz = __compiletime_object_size(addr);
206+ int sz = __builtin_object_size(addr, 0);
207207 if (unlikely(sz >= 0 && sz < bytes)) {
208208 if (!__builtin_constant_p(bytes))
209209 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