Skip to content

Commit 4950276

Browse files
Levin, Alexander (Sasha Levin)torvalds
authored andcommitted
kmemcheck: remove annotations
Patch series "kmemcheck: kill kmemcheck", v2. As discussed at LSF/MM, kill kmemcheck. KASan is a replacement that is able to work without the limitation of kmemcheck (single CPU, slow). KASan is already upstream. We are also not aware of any users of kmemcheck (or users who don't consider KASan as a suitable replacement). The only objection was that since KASAN wasn't supported by all GCC versions provided by distros at that time we should hold off for 2 years, and try again. Now that 2 years have passed, and all distros provide gcc that supports KASAN, kill kmemcheck again for the very same reasons. This patch (of 4): Remove kmemcheck annotations, and calls to kmemcheck from the kernel. [alexander.levin@verizon.com: correctly remove kmemcheck call from dma_map_sg_attrs] Link: http://lkml.kernel.org/r/20171012192151.26531-1-alexander.levin@verizon.com Link: http://lkml.kernel.org/r/20171007030159.22241-2-alexander.levin@verizon.com Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Cc: Alexander Potapenko <glider@google.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tim Hansen <devtimhansen@gmail.com> Cc: Vegard Nossum <vegardno@ifi.uio.no> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cdb07bd commit 4950276

File tree

34 files changed

+2
-152
lines changed

34 files changed

+2
-152
lines changed

arch/arm/include/asm/dma-iommu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <linux/mm_types.h>
88
#include <linux/scatterlist.h>
99
#include <linux/dma-debug.h>
10-
#include <linux/kmemcheck.h>
1110
#include <linux/kref.h>
1211

1312
#define ARM_MAPPING_ERROR (~(dma_addr_t)0x0)

arch/openrisc/include/asm/dma-mapping.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424

2525
#include <linux/dma-debug.h>
26-
#include <linux/kmemcheck.h>
2726
#include <linux/dma-mapping.h>
2827

2928
extern const struct dma_map_ops or1k_dma_map_ops;

arch/x86/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,6 @@ ifdef CONFIG_X86_X32
158158
endif
159159
export CONFIG_X86_X32_ABI
160160

161-
# Don't unroll struct assignments with kmemcheck enabled
162-
ifeq ($(CONFIG_KMEMCHECK),y)
163-
KBUILD_CFLAGS += $(call cc-option,-fno-builtin-memcpy)
164-
endif
165-
166161
#
167162
# If the function graph tracer is used with mcount instead of fentry,
168163
# '-maccumulate-outgoing-args' is needed to prevent a GCC bug

arch/x86/include/asm/dma-mapping.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* Documentation/DMA-API.txt for documentation.
88
*/
99

10-
#include <linux/kmemcheck.h>
1110
#include <linux/scatterlist.h>
1211
#include <linux/dma-debug.h>
1312
#include <asm/io.h>

arch/x86/include/asm/xor.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#ifdef CONFIG_KMEMCHECK
2-
/* kmemcheck doesn't handle MMX/SSE/SSE2 instructions */
3-
# include <asm-generic/xor.h>
4-
#elif !defined(_ASM_X86_XOR_H)
1+
#ifndef _ASM_X86_XOR_H
52
#define _ASM_X86_XOR_H
63

74
/*

arch/x86/kernel/traps.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <linux/edac.h>
4343
#endif
4444

45-
#include <asm/kmemcheck.h>
4645
#include <asm/stacktrace.h>
4746
#include <asm/processor.h>
4847
#include <asm/debugreg.h>
@@ -749,10 +748,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
749748
if (!dr6 && user_mode(regs))
750749
user_icebp = 1;
751750

752-
/* Catch kmemcheck conditions! */
753-
if ((dr6 & DR_STEP) && kmemcheck_trap(regs))
754-
goto exit;
755-
756751
/* Store the virtualized DR6 value */
757752
tsk->thread.debugreg6 = dr6;
758753

arch/x86/mm/fault.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <asm/cpufeature.h> /* boot_cpu_has, ... */
2121
#include <asm/traps.h> /* dotraplinkage, ... */
2222
#include <asm/pgalloc.h> /* pgd_*(), ... */
23-
#include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
2423
#include <asm/fixmap.h> /* VSYSCALL_ADDR */
2524
#include <asm/vsyscall.h> /* emulate_vsyscall */
2625
#include <asm/vm86.h> /* struct vm86 */
@@ -1256,8 +1255,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
12561255
* Detect and handle instructions that would cause a page fault for
12571256
* both a tracked kernel page and a userspace page.
12581257
*/
1259-
if (kmemcheck_active(regs))
1260-
kmemcheck_hide(regs);
12611258
prefetchw(&mm->mmap_sem);
12621259

12631260
if (unlikely(kmmio_fault(regs, address)))
@@ -1280,9 +1277,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code,
12801277
if (!(error_code & (X86_PF_RSVD | X86_PF_USER | X86_PF_PROT))) {
12811278
if (vmalloc_fault(address) >= 0)
12821279
return;
1283-
1284-
if (kmemcheck_fault(regs, address, error_code))
1285-
return;
12861280
}
12871281

12881282
/* Can handle a stale RO->RW TLB: */

drivers/char/random.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@
259259
#include <linux/cryptohash.h>
260260
#include <linux/fips.h>
261261
#include <linux/ptrace.h>
262-
#include <linux/kmemcheck.h>
263262
#include <linux/workqueue.h>
264263
#include <linux/irq.h>
265264
#include <linux/syscalls.h>

drivers/misc/c2port/core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/errno.h>
1616
#include <linux/err.h>
1717
#include <linux/kernel.h>
18-
#include <linux/kmemcheck.h>
1918
#include <linux/ctype.h>
2019
#include <linux/delay.h>
2120
#include <linux/idr.h>
@@ -904,7 +903,6 @@ struct c2port_device *c2port_device_register(char *name,
904903
return ERR_PTR(-EINVAL);
905904

906905
c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL);
907-
kmemcheck_annotate_bitfield(c2dev, flags);
908906
if (unlikely(!c2dev))
909907
return ERR_PTR(-ENOMEM);
910908

fs/dcache.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,8 +2705,6 @@ static void swap_names(struct dentry *dentry, struct dentry *target)
27052705
*/
27062706
unsigned int i;
27072707
BUILD_BUG_ON(!IS_ALIGNED(DNAME_INLINE_LEN, sizeof(long)));
2708-
kmemcheck_mark_initialized(dentry->d_iname, DNAME_INLINE_LEN);
2709-
kmemcheck_mark_initialized(target->d_iname, DNAME_INLINE_LEN);
27102708
for (i = 0; i < DNAME_INLINE_LEN / sizeof(long); i++) {
27112709
swap(((long *) &dentry->d_iname)[i],
27122710
((long *) &target->d_iname)[i]);

include/linux/c2port.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* the Free Software Foundation
1010
*/
1111

12-
#include <linux/kmemcheck.h>
13-
1412
#define C2PORT_NAME_LEN 32
1513

1614
struct device;
@@ -22,10 +20,8 @@ struct device;
2220
/* Main struct */
2321
struct c2port_ops;
2422
struct c2port_device {
25-
kmemcheck_bitfield_begin(flags);
2623
unsigned int access:1;
2724
unsigned int flash_access:1;
28-
kmemcheck_bitfield_end(flags);
2925

3026
int id;
3127
char name[C2PORT_NAME_LEN];

include/linux/dma-mapping.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <linux/dma-debug.h>
1010
#include <linux/dma-direction.h>
1111
#include <linux/scatterlist.h>
12-
#include <linux/kmemcheck.h>
1312
#include <linux/bug.h>
1413
#include <linux/mem_encrypt.h>
1514

@@ -232,7 +231,6 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
232231
const struct dma_map_ops *ops = get_dma_ops(dev);
233232
dma_addr_t addr;
234233

235-
kmemcheck_mark_initialized(ptr, size);
236234
BUG_ON(!valid_dma_direction(dir));
237235
addr = ops->map_page(dev, virt_to_page(ptr),
238236
offset_in_page(ptr), size,
@@ -265,11 +263,8 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
265263
unsigned long attrs)
266264
{
267265
const struct dma_map_ops *ops = get_dma_ops(dev);
268-
int i, ents;
269-
struct scatterlist *s;
266+
int ents;
270267

271-
for_each_sg(sg, s, nents, i)
272-
kmemcheck_mark_initialized(sg_virt(s), s->length);
273268
BUG_ON(!valid_dma_direction(dir));
274269
ents = ops->map_sg(dev, sg, nents, dir, attrs);
275270
BUG_ON(ents < 0);
@@ -299,7 +294,6 @@ static inline dma_addr_t dma_map_page_attrs(struct device *dev,
299294
const struct dma_map_ops *ops = get_dma_ops(dev);
300295
dma_addr_t addr;
301296

302-
kmemcheck_mark_initialized(page_address(page) + offset, size);
303297
BUG_ON(!valid_dma_direction(dir));
304298
addr = ops->map_page(dev, page, offset, size, dir, attrs);
305299
debug_dma_map_page(dev, page, offset, size, dir, addr, false);

include/linux/filter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,11 @@ struct bpf_binary_header {
454454

455455
struct bpf_prog {
456456
u16 pages; /* Number of allocated pages */
457-
kmemcheck_bitfield_begin(meta);
458457
u16 jited:1, /* Is our filter JIT'ed? */
459458
locked:1, /* Program image locked? */
460459
gpl_compatible:1, /* Is filter GPL compatible? */
461460
cb_access:1, /* Is control block accessed? */
462461
dst_needed:1; /* Do we need dst entry? */
463-
kmemcheck_bitfield_end(meta);
464462
enum bpf_prog_type type; /* Type of BPF program */
465463
u32 len; /* Number of filter blocks */
466464
u32 jited_len; /* Size of jited insns in bytes */

include/linux/mm_types.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,6 @@ struct page {
209209
not kmapped, ie. highmem) */
210210
#endif /* WANT_PAGE_VIRTUAL */
211211

212-
#ifdef CONFIG_KMEMCHECK
213-
/*
214-
* kmemcheck wants to track the status of each byte in a page; this
215-
* is a pointer to such a status block. NULL if not tracked.
216-
*/
217-
void *shadow;
218-
#endif
219-
220212
#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
221213
int _last_cpupid;
222214
#endif

include/linux/net.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/random.h>
2323
#include <linux/wait.h>
2424
#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */
25-
#include <linux/kmemcheck.h>
2625
#include <linux/rcupdate.h>
2726
#include <linux/once.h>
2827
#include <linux/fs.h>
@@ -111,9 +110,7 @@ struct socket_wq {
111110
struct socket {
112111
socket_state state;
113112

114-
kmemcheck_bitfield_begin(type);
115113
short type;
116-
kmemcheck_bitfield_end(type);
117114

118115
unsigned long flags;
119116

include/linux/ring_buffer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#ifndef _LINUX_RING_BUFFER_H
33
#define _LINUX_RING_BUFFER_H
44

5-
#include <linux/kmemcheck.h>
65
#include <linux/mm.h>
76
#include <linux/seq_file.h>
87
#include <linux/poll.h>
@@ -14,9 +13,7 @@ struct ring_buffer_iter;
1413
* Don't refer to this struct directly, use functions below.
1514
*/
1615
struct ring_buffer_event {
17-
kmemcheck_bitfield_begin(bitfield);
1816
u32 type_len:5, time_delta:27;
19-
kmemcheck_bitfield_end(bitfield);
2017

2118
u32 array[];
2219
};

include/linux/skbuff.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define _LINUX_SKBUFF_H
1616

1717
#include <linux/kernel.h>
18-
#include <linux/kmemcheck.h>
1918
#include <linux/compiler.h>
2019
#include <linux/time.h>
2120
#include <linux/bug.h>
@@ -704,7 +703,6 @@ struct sk_buff {
704703
/* Following fields are _not_ copied in __copy_skb_header()
705704
* Note that queue_mapping is here mostly to fill a hole.
706705
*/
707-
kmemcheck_bitfield_begin(flags1);
708706
__u16 queue_mapping;
709707

710708
/* if you move cloned around you also must adapt those constants */
@@ -723,7 +721,6 @@ struct sk_buff {
723721
head_frag:1,
724722
xmit_more:1,
725723
__unused:1; /* one bit hole */
726-
kmemcheck_bitfield_end(flags1);
727724

728725
/* fields enclosed in headers_start/headers_end are copied
729726
* using a single memcpy() in __copy_skb_header()

include/net/inet_sock.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define _INET_SOCK_H
1818

1919
#include <linux/bitops.h>
20-
#include <linux/kmemcheck.h>
2120
#include <linux/string.h>
2221
#include <linux/types.h>
2322
#include <linux/jhash.h>
@@ -84,7 +83,6 @@ struct inet_request_sock {
8483
#define ireq_state req.__req_common.skc_state
8584
#define ireq_family req.__req_common.skc_family
8685

87-
kmemcheck_bitfield_begin(flags);
8886
u16 snd_wscale : 4,
8987
rcv_wscale : 4,
9088
tstamp_ok : 1,
@@ -93,7 +91,6 @@ struct inet_request_sock {
9391
ecn_ok : 1,
9492
acked : 1,
9593
no_srccheck: 1;
96-
kmemcheck_bitfield_end(flags);
9794
u32 ir_mark;
9895
union {
9996
struct ip_options_rcu __rcu *ireq_opt;

include/net/inet_timewait_sock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#ifndef _INET_TIMEWAIT_SOCK_
1616
#define _INET_TIMEWAIT_SOCK_
1717

18-
19-
#include <linux/kmemcheck.h>
2018
#include <linux/list.h>
2119
#include <linux/timer.h>
2220
#include <linux/types.h>
@@ -69,14 +67,12 @@ struct inet_timewait_sock {
6967
/* Socket demultiplex comparisons on incoming packets. */
7068
/* these three are in inet_sock */
7169
__be16 tw_sport;
72-
kmemcheck_bitfield_begin(flags);
7370
/* And these are ours. */
7471
unsigned int tw_kill : 1,
7572
tw_transparent : 1,
7673
tw_flowlabel : 20,
7774
tw_pad : 2, /* 2 bits hole */
7875
tw_tos : 8;
79-
kmemcheck_bitfield_end(flags);
8076
struct timer_list tw_timer;
8177
struct inet_bind_bucket *tw_tb;
8278
};

include/net/sock.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ struct sock {
436436
#define SK_FL_TYPE_MASK 0xffff0000
437437
#endif
438438

439-
kmemcheck_bitfield_begin(flags);
440439
unsigned int sk_padding : 1,
441440
sk_kern_sock : 1,
442441
sk_no_check_tx : 1,
@@ -445,8 +444,6 @@ struct sock {
445444
sk_protocol : 8,
446445
sk_type : 16;
447446
#define SK_PROTOCOL_MAX U8_MAX
448-
kmemcheck_bitfield_end(flags);
449-
450447
u16 sk_gso_max_segs;
451448
unsigned long sk_lingertime;
452449
struct proto *sk_prot_creator;

init/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
#include <linux/kgdb.h>
7171
#include <linux/ftrace.h>
7272
#include <linux/async.h>
73-
#include <linux/kmemcheck.h>
7473
#include <linux/sfi.h>
7574
#include <linux/shmem_fs.h>
7675
#include <linux/slab.h>

kernel/bpf/core.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)
8585
if (fp == NULL)
8686
return NULL;
8787

88-
kmemcheck_annotate_bitfield(fp, meta);
89-
9088
aux = kzalloc(sizeof(*aux), GFP_KERNEL | gfp_extra_flags);
9189
if (aux == NULL) {
9290
vfree(fp);
@@ -127,8 +125,6 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size,
127125
if (fp == NULL) {
128126
__bpf_prog_uncharge(fp_old->aux->user, delta);
129127
} else {
130-
kmemcheck_annotate_bitfield(fp, meta);
131-
132128
memcpy(fp, fp_old, fp_old->pages * PAGE_SIZE);
133129
fp->pages = pages;
134130
fp->aux->prog = fp;
@@ -662,8 +658,6 @@ static struct bpf_prog *bpf_prog_clone_create(struct bpf_prog *fp_other,
662658

663659
fp = __vmalloc(fp_other->pages * PAGE_SIZE, gfp_flags, PAGE_KERNEL);
664660
if (fp != NULL) {
665-
kmemcheck_annotate_bitfield(fp, meta);
666-
667661
/* aux->prog still points to the fp_other one, so
668662
* when promoting the clone to the real program,
669663
* this still needs to be adapted.

kernel/locking/lockdep.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include <linux/stringify.h>
4848
#include <linux/bitops.h>
4949
#include <linux/gfp.h>
50-
#include <linux/kmemcheck.h>
5150
#include <linux/random.h>
5251
#include <linux/jhash.h>
5352

@@ -3238,8 +3237,6 @@ static void __lockdep_init_map(struct lockdep_map *lock, const char *name,
32383237
{
32393238
int i;
32403239

3241-
kmemcheck_mark_initialized(lock, sizeof(*lock));
3242-
32433240
for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++)
32443241
lock->class_cache[i] = NULL;
32453242

0 commit comments

Comments
 (0)