]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.5-201308091415.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.5-201308091415.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 2fe6e76..df58221 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -2195,6 +2199,22 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 the specified number of seconds. This is to be used if
248 your oopses keep scrolling off the screen.
249
250 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
251 + virtualization environments that don't cope well with the
252 + expand down segment used by UDEREF on X86-32 or the frequent
253 + page table updates on X86-64.
254 +
255 + pax_sanitize_slab=
256 + 0/1 to disable/enable slab object sanitization (enabled by
257 + default).
258 +
259 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
260 +
261 + pax_extra_latent_entropy
262 + Enable a very simple form of latent entropy extraction
263 + from the first 4GB of memory as the bootmem allocator
264 + passes the memory pages to the buddy allocator.
265 +
266 pcbit= [HW,ISDN]
267
268 pcd. [PARIDE]
269 diff --git a/Makefile b/Makefile
270 index f8349d0..563a504 100644
271 --- a/Makefile
272 +++ b/Makefile
273 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
274
275 HOSTCC = gcc
276 HOSTCXX = g++
277 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
278 -HOSTCXXFLAGS = -O2
279 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
280 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
281 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
282
283 # Decide whether to build built-in, modular, or both.
284 # Normally, just do built-in.
285 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
286 # Rules shared between *config targets and build targets
287
288 # Basic helpers built in scripts/
289 -PHONY += scripts_basic
290 -scripts_basic:
291 +PHONY += scripts_basic gcc-plugins
292 +scripts_basic: gcc-plugins
293 $(Q)$(MAKE) $(build)=scripts/basic
294 $(Q)rm -f .tmp_quiet_recordmcount
295
296 @@ -576,6 +577,65 @@ else
297 KBUILD_CFLAGS += -O2
298 endif
299
300 +ifndef DISABLE_PAX_PLUGINS
301 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
302 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
303 +else
304 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
305 +endif
306 +ifneq ($(PLUGINCC),)
307 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
308 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
309 +endif
310 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
311 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
312 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
313 +endif
314 +ifdef CONFIG_KALLOCSTAT_PLUGIN
315 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
316 +endif
317 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
318 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
319 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
320 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
321 +endif
322 +ifdef CONFIG_CHECKER_PLUGIN
323 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
324 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
325 +endif
326 +endif
327 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
328 +ifdef CONFIG_PAX_SIZE_OVERFLOW
329 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
330 +endif
331 +ifdef CONFIG_PAX_LATENT_ENTROPY
332 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
333 +endif
334 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
335 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
336 +endif
337 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
338 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
339 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
340 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
341 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
342 +ifeq ($(KBUILD_EXTMOD),)
343 +gcc-plugins:
344 + $(Q)$(MAKE) $(build)=tools/gcc
345 +else
346 +gcc-plugins: ;
347 +endif
348 +else
349 +gcc-plugins:
350 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
351 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
352 +else
353 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
354 +endif
355 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
356 +endif
357 +endif
358 +
359 include $(srctree)/arch/$(SRCARCH)/Makefile
360
361 ifdef CONFIG_READABLE_ASM
362 @@ -733,7 +793,7 @@ export mod_sign_cmd
363
364
365 ifeq ($(KBUILD_EXTMOD),)
366 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
367 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
368
369 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
370 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
371 @@ -782,6 +842,8 @@ endif
372
373 # The actual objects are generated when descending,
374 # make sure no implicit rule kicks in
375 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
376 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
377 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
378
379 # Handle descending into subdirectories listed in $(vmlinux-dirs)
380 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
381 # Error messages still appears in the original language
382
383 PHONY += $(vmlinux-dirs)
384 -$(vmlinux-dirs): prepare scripts
385 +$(vmlinux-dirs): gcc-plugins prepare scripts
386 $(Q)$(MAKE) $(build)=$@
387
388 # Store (new) KERNELRELASE string in include/config/kernel.release
389 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
390 $(Q)$(MAKE) $(build)=.
391
392 # All the preparing..
393 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
394 prepare: prepare0
395
396 # Generate some files
397 @@ -942,6 +1005,8 @@ all: modules
398 # using awk while concatenating to the final file.
399
400 PHONY += modules
401 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
402 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
403 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
404 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
405 @$(kecho) ' Building modules, stage 2.';
406 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
407
408 # Target to prepare building external modules
409 PHONY += modules_prepare
410 -modules_prepare: prepare scripts
411 +modules_prepare: gcc-plugins prepare scripts
412
413 # Target to install modules
414 PHONY += modules_install
415 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
416 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
417 signing_key.priv signing_key.x509 x509.genkey \
418 extra_certificates signing_key.x509.keyid \
419 - signing_key.x509.signer
420 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
421
422 # clean - Delete most, but leave enough to build external modules
423 #
424 @@ -1063,6 +1128,7 @@ distclean: mrproper
425 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
426 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
427 -o -name '.*.rej' \
428 + -o -name '.*.rej' -o -name '*.so' \
429 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
430 -type f -print | xargs rm -f
431
432 @@ -1223,6 +1289,8 @@ PHONY += $(module-dirs) modules
433 $(module-dirs): crmodverdir $(objtree)/Module.symvers
434 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
435
436 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
437 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
438 modules: $(module-dirs)
439 @$(kecho) ' Building modules, stage 2.';
440 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
441 @@ -1359,17 +1427,21 @@ else
442 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
443 endif
444
445 -%.s: %.c prepare scripts FORCE
446 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
447 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
448 +%.s: %.c gcc-plugins prepare scripts FORCE
449 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
450 %.i: %.c prepare scripts FORCE
451 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
452 -%.o: %.c prepare scripts FORCE
453 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
454 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
455 +%.o: %.c gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.lst: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 -%.s: %.S prepare scripts FORCE
460 +%.s: %.S gcc-plugins prepare scripts FORCE
461 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
462 -%.o: %.S prepare scripts FORCE
463 +%.o: %.S gcc-plugins prepare scripts FORCE
464 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
465 %.symtypes: %.c prepare scripts FORCE
466 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
467 @@ -1379,11 +1451,15 @@ endif
468 $(cmd_crmodverdir)
469 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
470 $(build)=$(build-dir)
471 -%/: prepare scripts FORCE
472 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
473 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
474 +%/: gcc-plugins prepare scripts FORCE
475 $(cmd_crmodverdir)
476 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
477 $(build)=$(build-dir)
478 -%.ko: prepare scripts FORCE
479 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
480 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
481 +%.ko: gcc-plugins prepare scripts FORCE
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir) $(@:.ko=.o)
485 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
486 index c2cbe4f..f7264b4 100644
487 --- a/arch/alpha/include/asm/atomic.h
488 +++ b/arch/alpha/include/asm/atomic.h
489 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
490 #define atomic_dec(v) atomic_sub(1,(v))
491 #define atomic64_dec(v) atomic64_sub(1,(v))
492
493 +#define atomic64_read_unchecked(v) atomic64_read(v)
494 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
495 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
496 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
497 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
498 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
499 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
500 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
501 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
502 +
503 #define smp_mb__before_atomic_dec() smp_mb()
504 #define smp_mb__after_atomic_dec() smp_mb()
505 #define smp_mb__before_atomic_inc() smp_mb()
506 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
507 index ad368a9..fbe0f25 100644
508 --- a/arch/alpha/include/asm/cache.h
509 +++ b/arch/alpha/include/asm/cache.h
510 @@ -4,19 +4,19 @@
511 #ifndef __ARCH_ALPHA_CACHE_H
512 #define __ARCH_ALPHA_CACHE_H
513
514 +#include <linux/const.h>
515
516 /* Bytes per L1 (data) cache line. */
517 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
518 -# define L1_CACHE_BYTES 64
519 # define L1_CACHE_SHIFT 6
520 #else
521 /* Both EV4 and EV5 are write-through, read-allocate,
522 direct-mapped, physical.
523 */
524 -# define L1_CACHE_BYTES 32
525 # define L1_CACHE_SHIFT 5
526 #endif
527
528 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
529 #define SMP_CACHE_BYTES L1_CACHE_BYTES
530
531 #endif
532 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
533 index 968d999..d36b2df 100644
534 --- a/arch/alpha/include/asm/elf.h
535 +++ b/arch/alpha/include/asm/elf.h
536 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
537
538 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
539
540 +#ifdef CONFIG_PAX_ASLR
541 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
542 +
543 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
544 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
545 +#endif
546 +
547 /* $0 is set by ld.so to a pointer to a function which might be
548 registered using atexit. This provides a mean for the dynamic
549 linker to call DT_FINI functions for shared libraries that have
550 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
551 index bc2a0da..8ad11ee 100644
552 --- a/arch/alpha/include/asm/pgalloc.h
553 +++ b/arch/alpha/include/asm/pgalloc.h
554 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
555 pgd_set(pgd, pmd);
556 }
557
558 +static inline void
559 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
560 +{
561 + pgd_populate(mm, pgd, pmd);
562 +}
563 +
564 extern pgd_t *pgd_alloc(struct mm_struct *mm);
565
566 static inline void
567 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
568 index 81a4342..348b927 100644
569 --- a/arch/alpha/include/asm/pgtable.h
570 +++ b/arch/alpha/include/asm/pgtable.h
571 @@ -102,6 +102,17 @@ struct vm_area_struct;
572 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
573 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
574 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
575 +
576 +#ifdef CONFIG_PAX_PAGEEXEC
577 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
578 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
579 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
580 +#else
581 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
582 +# define PAGE_COPY_NOEXEC PAGE_COPY
583 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
584 +#endif
585 +
586 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
587
588 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
589 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
590 index 2fd00b7..cfd5069 100644
591 --- a/arch/alpha/kernel/module.c
592 +++ b/arch/alpha/kernel/module.c
593 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
594
595 /* The small sections were sorted to the end of the segment.
596 The following should definitely cover them. */
597 - gp = (u64)me->module_core + me->core_size - 0x8000;
598 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
599 got = sechdrs[me->arch.gotsecindex].sh_addr;
600
601 for (i = 0; i < n; i++) {
602 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
603 index b9e37ad..44c24e7 100644
604 --- a/arch/alpha/kernel/osf_sys.c
605 +++ b/arch/alpha/kernel/osf_sys.c
606 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
607 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
608
609 static unsigned long
610 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
611 - unsigned long limit)
612 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
613 + unsigned long limit, unsigned long flags)
614 {
615 struct vm_unmapped_area_info info;
616 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
617
618 info.flags = 0;
619 info.length = len;
620 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
621 info.high_limit = limit;
622 info.align_mask = 0;
623 info.align_offset = 0;
624 + info.threadstack_offset = offset;
625 return vm_unmapped_area(&info);
626 }
627
628 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
629 merely specific addresses, but regions of memory -- perhaps
630 this feature should be incorporated into all ports? */
631
632 +#ifdef CONFIG_PAX_RANDMMAP
633 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
634 +#endif
635 +
636 if (addr) {
637 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
638 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641 }
642
643 /* Next, try allocating at TASK_UNMAPPED_BASE. */
644 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
645 - len, limit);
646 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
647 +
648 if (addr != (unsigned long) -ENOMEM)
649 return addr;
650
651 /* Finally, try allocating in low memory. */
652 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
653 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
654
655 return addr;
656 }
657 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
658 index 0c4132d..88f0d53 100644
659 --- a/arch/alpha/mm/fault.c
660 +++ b/arch/alpha/mm/fault.c
661 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
662 __reload_thread(pcb);
663 }
664
665 +#ifdef CONFIG_PAX_PAGEEXEC
666 +/*
667 + * PaX: decide what to do with offenders (regs->pc = fault address)
668 + *
669 + * returns 1 when task should be killed
670 + * 2 when patched PLT trampoline was detected
671 + * 3 when unpatched PLT trampoline was detected
672 + */
673 +static int pax_handle_fetch_fault(struct pt_regs *regs)
674 +{
675 +
676 +#ifdef CONFIG_PAX_EMUPLT
677 + int err;
678 +
679 + do { /* PaX: patched PLT emulation #1 */
680 + unsigned int ldah, ldq, jmp;
681 +
682 + err = get_user(ldah, (unsigned int *)regs->pc);
683 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
684 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
685 +
686 + if (err)
687 + break;
688 +
689 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
690 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
691 + jmp == 0x6BFB0000U)
692 + {
693 + unsigned long r27, addr;
694 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
695 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
696 +
697 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
698 + err = get_user(r27, (unsigned long *)addr);
699 + if (err)
700 + break;
701 +
702 + regs->r27 = r27;
703 + regs->pc = r27;
704 + return 2;
705 + }
706 + } while (0);
707 +
708 + do { /* PaX: patched PLT emulation #2 */
709 + unsigned int ldah, lda, br;
710 +
711 + err = get_user(ldah, (unsigned int *)regs->pc);
712 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
713 + err |= get_user(br, (unsigned int *)(regs->pc+8));
714 +
715 + if (err)
716 + break;
717 +
718 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
719 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
720 + (br & 0xFFE00000U) == 0xC3E00000U)
721 + {
722 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
723 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
724 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
725 +
726 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
727 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
728 + return 2;
729 + }
730 + } while (0);
731 +
732 + do { /* PaX: unpatched PLT emulation */
733 + unsigned int br;
734 +
735 + err = get_user(br, (unsigned int *)regs->pc);
736 +
737 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
738 + unsigned int br2, ldq, nop, jmp;
739 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
740 +
741 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + err = get_user(br2, (unsigned int *)addr);
743 + err |= get_user(ldq, (unsigned int *)(addr+4));
744 + err |= get_user(nop, (unsigned int *)(addr+8));
745 + err |= get_user(jmp, (unsigned int *)(addr+12));
746 + err |= get_user(resolver, (unsigned long *)(addr+16));
747 +
748 + if (err)
749 + break;
750 +
751 + if (br2 == 0xC3600000U &&
752 + ldq == 0xA77B000CU &&
753 + nop == 0x47FF041FU &&
754 + jmp == 0x6B7B0000U)
755 + {
756 + regs->r28 = regs->pc+4;
757 + regs->r27 = addr+16;
758 + regs->pc = resolver;
759 + return 3;
760 + }
761 + }
762 + } while (0);
763 +#endif
764 +
765 + return 1;
766 +}
767 +
768 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
769 +{
770 + unsigned long i;
771 +
772 + printk(KERN_ERR "PAX: bytes at PC: ");
773 + for (i = 0; i < 5; i++) {
774 + unsigned int c;
775 + if (get_user(c, (unsigned int *)pc+i))
776 + printk(KERN_CONT "???????? ");
777 + else
778 + printk(KERN_CONT "%08x ", c);
779 + }
780 + printk("\n");
781 +}
782 +#endif
783
784 /*
785 * This routine handles page faults. It determines the address,
786 @@ -133,8 +251,29 @@ retry:
787 good_area:
788 si_code = SEGV_ACCERR;
789 if (cause < 0) {
790 - if (!(vma->vm_flags & VM_EXEC))
791 + if (!(vma->vm_flags & VM_EXEC)) {
792 +
793 +#ifdef CONFIG_PAX_PAGEEXEC
794 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
795 + goto bad_area;
796 +
797 + up_read(&mm->mmap_sem);
798 + switch (pax_handle_fetch_fault(regs)) {
799 +
800 +#ifdef CONFIG_PAX_EMUPLT
801 + case 2:
802 + case 3:
803 + return;
804 +#endif
805 +
806 + }
807 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
808 + do_group_exit(SIGKILL);
809 +#else
810 goto bad_area;
811 +#endif
812 +
813 + }
814 } else if (!cause) {
815 /* Allow reads even for write-only mappings */
816 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
817 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
818 index 136f263..f471277 100644
819 --- a/arch/arm/Kconfig
820 +++ b/arch/arm/Kconfig
821 @@ -1766,7 +1766,7 @@ config ALIGNMENT_TRAP
822
823 config UACCESS_WITH_MEMCPY
824 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
825 - depends on MMU
826 + depends on MMU && !PAX_MEMORY_UDEREF
827 default y if CPU_FEROCEON
828 help
829 Implement faster copy_to_user and clear_user methods for CPU
830 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
831 index da1c77d..2ee6056 100644
832 --- a/arch/arm/include/asm/atomic.h
833 +++ b/arch/arm/include/asm/atomic.h
834 @@ -17,17 +17,35 @@
835 #include <asm/barrier.h>
836 #include <asm/cmpxchg.h>
837
838 +#ifdef CONFIG_GENERIC_ATOMIC64
839 +#include <asm-generic/atomic64.h>
840 +#endif
841 +
842 #define ATOMIC_INIT(i) { (i) }
843
844 #ifdef __KERNEL__
845
846 +#define _ASM_EXTABLE(from, to) \
847 +" .pushsection __ex_table,\"a\"\n"\
848 +" .align 3\n" \
849 +" .long " #from ", " #to"\n" \
850 +" .popsection"
851 +
852 /*
853 * On ARM, ordinary assignment (str instruction) doesn't clear the local
854 * strex/ldrex monitor on some implementations. The reason we can use it for
855 * atomic_set() is the clrex or dummy strex done on every exception return.
856 */
857 #define atomic_read(v) (*(volatile int *)&(v)->counter)
858 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
859 +{
860 + return v->counter;
861 +}
862 #define atomic_set(v,i) (((v)->counter) = (i))
863 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
864 +{
865 + v->counter = i;
866 +}
867
868 #if __LINUX_ARM_ARCH__ >= 6
869
870 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
871 int result;
872
873 __asm__ __volatile__("@ atomic_add\n"
874 +"1: ldrex %1, [%3]\n"
875 +" adds %0, %1, %4\n"
876 +
877 +#ifdef CONFIG_PAX_REFCOUNT
878 +" bvc 3f\n"
879 +"2: bkpt 0xf103\n"
880 +"3:\n"
881 +#endif
882 +
883 +" strex %1, %0, [%3]\n"
884 +" teq %1, #0\n"
885 +" bne 1b"
886 +
887 +#ifdef CONFIG_PAX_REFCOUNT
888 +"\n4:\n"
889 + _ASM_EXTABLE(2b, 4b)
890 +#endif
891 +
892 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
893 + : "r" (&v->counter), "Ir" (i)
894 + : "cc");
895 +}
896 +
897 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
898 +{
899 + unsigned long tmp;
900 + int result;
901 +
902 + __asm__ __volatile__("@ atomic_add_unchecked\n"
903 "1: ldrex %0, [%3]\n"
904 " add %0, %0, %4\n"
905 " strex %1, %0, [%3]\n"
906 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
907 smp_mb();
908
909 __asm__ __volatile__("@ atomic_add_return\n"
910 +"1: ldrex %1, [%3]\n"
911 +" adds %0, %1, %4\n"
912 +
913 +#ifdef CONFIG_PAX_REFCOUNT
914 +" bvc 3f\n"
915 +" mov %0, %1\n"
916 +"2: bkpt 0xf103\n"
917 +"3:\n"
918 +#endif
919 +
920 +" strex %1, %0, [%3]\n"
921 +" teq %1, #0\n"
922 +" bne 1b"
923 +
924 +#ifdef CONFIG_PAX_REFCOUNT
925 +"\n4:\n"
926 + _ASM_EXTABLE(2b, 4b)
927 +#endif
928 +
929 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
930 + : "r" (&v->counter), "Ir" (i)
931 + : "cc");
932 +
933 + smp_mb();
934 +
935 + return result;
936 +}
937 +
938 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
939 +{
940 + unsigned long tmp;
941 + int result;
942 +
943 + smp_mb();
944 +
945 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
946 "1: ldrex %0, [%3]\n"
947 " add %0, %0, %4\n"
948 " strex %1, %0, [%3]\n"
949 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
950 int result;
951
952 __asm__ __volatile__("@ atomic_sub\n"
953 +"1: ldrex %1, [%3]\n"
954 +" subs %0, %1, %4\n"
955 +
956 +#ifdef CONFIG_PAX_REFCOUNT
957 +" bvc 3f\n"
958 +"2: bkpt 0xf103\n"
959 +"3:\n"
960 +#endif
961 +
962 +" strex %1, %0, [%3]\n"
963 +" teq %1, #0\n"
964 +" bne 1b"
965 +
966 +#ifdef CONFIG_PAX_REFCOUNT
967 +"\n4:\n"
968 + _ASM_EXTABLE(2b, 4b)
969 +#endif
970 +
971 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
972 + : "r" (&v->counter), "Ir" (i)
973 + : "cc");
974 +}
975 +
976 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
977 +{
978 + unsigned long tmp;
979 + int result;
980 +
981 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
982 "1: ldrex %0, [%3]\n"
983 " sub %0, %0, %4\n"
984 " strex %1, %0, [%3]\n"
985 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
986 smp_mb();
987
988 __asm__ __volatile__("@ atomic_sub_return\n"
989 -"1: ldrex %0, [%3]\n"
990 -" sub %0, %0, %4\n"
991 +"1: ldrex %1, [%3]\n"
992 +" subs %0, %1, %4\n"
993 +
994 +#ifdef CONFIG_PAX_REFCOUNT
995 +" bvc 3f\n"
996 +" mov %0, %1\n"
997 +"2: bkpt 0xf103\n"
998 +"3:\n"
999 +#endif
1000 +
1001 " strex %1, %0, [%3]\n"
1002 " teq %1, #0\n"
1003 " bne 1b"
1004 +
1005 +#ifdef CONFIG_PAX_REFCOUNT
1006 +"\n4:\n"
1007 + _ASM_EXTABLE(2b, 4b)
1008 +#endif
1009 +
1010 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1011 : "r" (&v->counter), "Ir" (i)
1012 : "cc");
1013 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1014 return oldval;
1015 }
1016
1017 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1018 +{
1019 + unsigned long oldval, res;
1020 +
1021 + smp_mb();
1022 +
1023 + do {
1024 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1025 + "ldrex %1, [%3]\n"
1026 + "mov %0, #0\n"
1027 + "teq %1, %4\n"
1028 + "strexeq %0, %5, [%3]\n"
1029 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1030 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1031 + : "cc");
1032 + } while (res);
1033 +
1034 + smp_mb();
1035 +
1036 + return oldval;
1037 +}
1038 +
1039 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1040 {
1041 unsigned long tmp, tmp2;
1042 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1043
1044 return val;
1045 }
1046 +
1047 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1048 +{
1049 + return atomic_add_return(i, v);
1050 +}
1051 +
1052 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1053 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1054 +{
1055 + (void) atomic_add_return(i, v);
1056 +}
1057
1058 static inline int atomic_sub_return(int i, atomic_t *v)
1059 {
1060 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1061 return val;
1062 }
1063 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1064 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1065 +{
1066 + (void) atomic_sub_return(i, v);
1067 +}
1068
1069 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1070 {
1071 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1072 return ret;
1073 }
1074
1075 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1076 +{
1077 + return atomic_cmpxchg(v, old, new);
1078 +}
1079 +
1080 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1081 {
1082 unsigned long flags;
1083 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1084 #endif /* __LINUX_ARM_ARCH__ */
1085
1086 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1087 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1088 +{
1089 + return xchg(&v->counter, new);
1090 +}
1091
1092 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1093 {
1094 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1095 }
1096
1097 #define atomic_inc(v) atomic_add(1, v)
1098 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1099 +{
1100 + atomic_add_unchecked(1, v);
1101 +}
1102 #define atomic_dec(v) atomic_sub(1, v)
1103 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1104 +{
1105 + atomic_sub_unchecked(1, v);
1106 +}
1107
1108 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1109 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1110 +{
1111 + return atomic_add_return_unchecked(1, v) == 0;
1112 +}
1113 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1114 #define atomic_inc_return(v) (atomic_add_return(1, v))
1115 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1116 +{
1117 + return atomic_add_return_unchecked(1, v);
1118 +}
1119 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1120 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1121
1122 @@ -241,6 +428,14 @@ typedef struct {
1123 u64 __aligned(8) counter;
1124 } atomic64_t;
1125
1126 +#ifdef CONFIG_PAX_REFCOUNT
1127 +typedef struct {
1128 + u64 __aligned(8) counter;
1129 +} atomic64_unchecked_t;
1130 +#else
1131 +typedef atomic64_t atomic64_unchecked_t;
1132 +#endif
1133 +
1134 #define ATOMIC64_INIT(i) { (i) }
1135
1136 #ifdef CONFIG_ARM_LPAE
1137 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1138 return result;
1139 }
1140
1141 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1142 +{
1143 + u64 result;
1144 +
1145 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1146 +" ldrd %0, %H0, [%1]"
1147 + : "=&r" (result)
1148 + : "r" (&v->counter), "Qo" (v->counter)
1149 + );
1150 +
1151 + return result;
1152 +}
1153 +
1154 static inline void atomic64_set(atomic64_t *v, u64 i)
1155 {
1156 __asm__ __volatile__("@ atomic64_set\n"
1157 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1158 : "r" (&v->counter), "r" (i)
1159 );
1160 }
1161 +
1162 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1163 +{
1164 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1165 +" strd %2, %H2, [%1]"
1166 + : "=Qo" (v->counter)
1167 + : "r" (&v->counter), "r" (i)
1168 + );
1169 +}
1170 #else
1171 static inline u64 atomic64_read(const atomic64_t *v)
1172 {
1173 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1174 return result;
1175 }
1176
1177 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1178 +{
1179 + u64 result;
1180 +
1181 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1182 +" ldrexd %0, %H0, [%1]"
1183 + : "=&r" (result)
1184 + : "r" (&v->counter), "Qo" (v->counter)
1185 + );
1186 +
1187 + return result;
1188 +}
1189 +
1190 static inline void atomic64_set(atomic64_t *v, u64 i)
1191 {
1192 u64 tmp;
1193 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1194 : "r" (&v->counter), "r" (i)
1195 : "cc");
1196 }
1197 +
1198 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1199 +{
1200 + u64 tmp;
1201 +
1202 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1203 +"1: ldrexd %0, %H0, [%2]\n"
1204 +" strexd %0, %3, %H3, [%2]\n"
1205 +" teq %0, #0\n"
1206 +" bne 1b"
1207 + : "=&r" (tmp), "=Qo" (v->counter)
1208 + : "r" (&v->counter), "r" (i)
1209 + : "cc");
1210 +}
1211 +
1212 #endif
1213
1214 static inline void atomic64_add(u64 i, atomic64_t *v)
1215 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1216 __asm__ __volatile__("@ atomic64_add\n"
1217 "1: ldrexd %0, %H0, [%3]\n"
1218 " adds %0, %0, %4\n"
1219 +" adcs %H0, %H0, %H4\n"
1220 +
1221 +#ifdef CONFIG_PAX_REFCOUNT
1222 +" bvc 3f\n"
1223 +"2: bkpt 0xf103\n"
1224 +"3:\n"
1225 +#endif
1226 +
1227 +" strexd %1, %0, %H0, [%3]\n"
1228 +" teq %1, #0\n"
1229 +" bne 1b"
1230 +
1231 +#ifdef CONFIG_PAX_REFCOUNT
1232 +"\n4:\n"
1233 + _ASM_EXTABLE(2b, 4b)
1234 +#endif
1235 +
1236 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1237 + : "r" (&v->counter), "r" (i)
1238 + : "cc");
1239 +}
1240 +
1241 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1242 +{
1243 + u64 result;
1244 + unsigned long tmp;
1245 +
1246 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1247 +"1: ldrexd %0, %H0, [%3]\n"
1248 +" adds %0, %0, %4\n"
1249 " adc %H0, %H0, %H4\n"
1250 " strexd %1, %0, %H0, [%3]\n"
1251 " teq %1, #0\n"
1252 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1253
1254 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1255 {
1256 - u64 result;
1257 - unsigned long tmp;
1258 + u64 result, tmp;
1259
1260 smp_mb();
1261
1262 __asm__ __volatile__("@ atomic64_add_return\n"
1263 +"1: ldrexd %1, %H1, [%3]\n"
1264 +" adds %0, %1, %4\n"
1265 +" adcs %H0, %H1, %H4\n"
1266 +
1267 +#ifdef CONFIG_PAX_REFCOUNT
1268 +" bvc 3f\n"
1269 +" mov %0, %1\n"
1270 +" mov %H0, %H1\n"
1271 +"2: bkpt 0xf103\n"
1272 +"3:\n"
1273 +#endif
1274 +
1275 +" strexd %1, %0, %H0, [%3]\n"
1276 +" teq %1, #0\n"
1277 +" bne 1b"
1278 +
1279 +#ifdef CONFIG_PAX_REFCOUNT
1280 +"\n4:\n"
1281 + _ASM_EXTABLE(2b, 4b)
1282 +#endif
1283 +
1284 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1285 + : "r" (&v->counter), "r" (i)
1286 + : "cc");
1287 +
1288 + smp_mb();
1289 +
1290 + return result;
1291 +}
1292 +
1293 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1294 +{
1295 + u64 result;
1296 + unsigned long tmp;
1297 +
1298 + smp_mb();
1299 +
1300 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1301 "1: ldrexd %0, %H0, [%3]\n"
1302 " adds %0, %0, %4\n"
1303 " adc %H0, %H0, %H4\n"
1304 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1305 __asm__ __volatile__("@ atomic64_sub\n"
1306 "1: ldrexd %0, %H0, [%3]\n"
1307 " subs %0, %0, %4\n"
1308 +" sbcs %H0, %H0, %H4\n"
1309 +
1310 +#ifdef CONFIG_PAX_REFCOUNT
1311 +" bvc 3f\n"
1312 +"2: bkpt 0xf103\n"
1313 +"3:\n"
1314 +#endif
1315 +
1316 +" strexd %1, %0, %H0, [%3]\n"
1317 +" teq %1, #0\n"
1318 +" bne 1b"
1319 +
1320 +#ifdef CONFIG_PAX_REFCOUNT
1321 +"\n4:\n"
1322 + _ASM_EXTABLE(2b, 4b)
1323 +#endif
1324 +
1325 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1326 + : "r" (&v->counter), "r" (i)
1327 + : "cc");
1328 +}
1329 +
1330 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1331 +{
1332 + u64 result;
1333 + unsigned long tmp;
1334 +
1335 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1336 +"1: ldrexd %0, %H0, [%3]\n"
1337 +" subs %0, %0, %4\n"
1338 " sbc %H0, %H0, %H4\n"
1339 " strexd %1, %0, %H0, [%3]\n"
1340 " teq %1, #0\n"
1341 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1342
1343 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1344 {
1345 - u64 result;
1346 - unsigned long tmp;
1347 + u64 result, tmp;
1348
1349 smp_mb();
1350
1351 __asm__ __volatile__("@ atomic64_sub_return\n"
1352 -"1: ldrexd %0, %H0, [%3]\n"
1353 -" subs %0, %0, %4\n"
1354 -" sbc %H0, %H0, %H4\n"
1355 +"1: ldrexd %1, %H1, [%3]\n"
1356 +" subs %0, %1, %4\n"
1357 +" sbcs %H0, %H1, %H4\n"
1358 +
1359 +#ifdef CONFIG_PAX_REFCOUNT
1360 +" bvc 3f\n"
1361 +" mov %0, %1\n"
1362 +" mov %H0, %H1\n"
1363 +"2: bkpt 0xf103\n"
1364 +"3:\n"
1365 +#endif
1366 +
1367 " strexd %1, %0, %H0, [%3]\n"
1368 " teq %1, #0\n"
1369 " bne 1b"
1370 +
1371 +#ifdef CONFIG_PAX_REFCOUNT
1372 +"\n4:\n"
1373 + _ASM_EXTABLE(2b, 4b)
1374 +#endif
1375 +
1376 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1377 : "r" (&v->counter), "r" (i)
1378 : "cc");
1379 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1380 return oldval;
1381 }
1382
1383 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1384 +{
1385 + u64 oldval;
1386 + unsigned long res;
1387 +
1388 + smp_mb();
1389 +
1390 + do {
1391 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1392 + "ldrexd %1, %H1, [%3]\n"
1393 + "mov %0, #0\n"
1394 + "teq %1, %4\n"
1395 + "teqeq %H1, %H4\n"
1396 + "strexdeq %0, %5, %H5, [%3]"
1397 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1398 + : "r" (&ptr->counter), "r" (old), "r" (new)
1399 + : "cc");
1400 + } while (res);
1401 +
1402 + smp_mb();
1403 +
1404 + return oldval;
1405 +}
1406 +
1407 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1408 {
1409 u64 result;
1410 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1411
1412 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1413 {
1414 - u64 result;
1415 - unsigned long tmp;
1416 + u64 result, tmp;
1417
1418 smp_mb();
1419
1420 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1421 -"1: ldrexd %0, %H0, [%3]\n"
1422 -" subs %0, %0, #1\n"
1423 -" sbc %H0, %H0, #0\n"
1424 +"1: ldrexd %1, %H1, [%3]\n"
1425 +" subs %0, %1, #1\n"
1426 +" sbcs %H0, %H1, #0\n"
1427 +
1428 +#ifdef CONFIG_PAX_REFCOUNT
1429 +" bvc 3f\n"
1430 +" mov %0, %1\n"
1431 +" mov %H0, %H1\n"
1432 +"2: bkpt 0xf103\n"
1433 +"3:\n"
1434 +#endif
1435 +
1436 " teq %H0, #0\n"
1437 -" bmi 2f\n"
1438 +" bmi 4f\n"
1439 " strexd %1, %0, %H0, [%3]\n"
1440 " teq %1, #0\n"
1441 " bne 1b\n"
1442 -"2:"
1443 +"4:\n"
1444 +
1445 +#ifdef CONFIG_PAX_REFCOUNT
1446 + _ASM_EXTABLE(2b, 4b)
1447 +#endif
1448 +
1449 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1450 : "r" (&v->counter)
1451 : "cc");
1452 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1453 " teq %0, %5\n"
1454 " teqeq %H0, %H5\n"
1455 " moveq %1, #0\n"
1456 -" beq 2f\n"
1457 +" beq 4f\n"
1458 " adds %0, %0, %6\n"
1459 -" adc %H0, %H0, %H6\n"
1460 +" adcs %H0, %H0, %H6\n"
1461 +
1462 +#ifdef CONFIG_PAX_REFCOUNT
1463 +" bvc 3f\n"
1464 +"2: bkpt 0xf103\n"
1465 +"3:\n"
1466 +#endif
1467 +
1468 " strexd %2, %0, %H0, [%4]\n"
1469 " teq %2, #0\n"
1470 " bne 1b\n"
1471 -"2:"
1472 +"4:\n"
1473 +
1474 +#ifdef CONFIG_PAX_REFCOUNT
1475 + _ASM_EXTABLE(2b, 4b)
1476 +#endif
1477 +
1478 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1479 : "r" (&v->counter), "r" (u), "r" (a)
1480 : "cc");
1481 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1482
1483 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1484 #define atomic64_inc(v) atomic64_add(1LL, (v))
1485 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1486 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1487 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1488 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1489 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1490 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1491 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1492 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1493 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1494 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1495 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1496 index 75fe66b..ba3dee4 100644
1497 --- a/arch/arm/include/asm/cache.h
1498 +++ b/arch/arm/include/asm/cache.h
1499 @@ -4,8 +4,10 @@
1500 #ifndef __ASMARM_CACHE_H
1501 #define __ASMARM_CACHE_H
1502
1503 +#include <linux/const.h>
1504 +
1505 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1506 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1507 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1508
1509 /*
1510 * Memory returned by kmalloc() may be used for DMA, so we must make
1511 @@ -24,5 +26,6 @@
1512 #endif
1513
1514 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1515 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1516
1517 #endif
1518 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1519 index 17d0ae8..014e350 100644
1520 --- a/arch/arm/include/asm/cacheflush.h
1521 +++ b/arch/arm/include/asm/cacheflush.h
1522 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1523 void (*dma_unmap_area)(const void *, size_t, int);
1524
1525 void (*dma_flush_range)(const void *, const void *);
1526 -};
1527 +} __no_const;
1528
1529 /*
1530 * Select the calling method
1531 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1532 index 6dcc164..b14d917 100644
1533 --- a/arch/arm/include/asm/checksum.h
1534 +++ b/arch/arm/include/asm/checksum.h
1535 @@ -37,7 +37,19 @@ __wsum
1536 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1537
1538 __wsum
1539 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1540 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1541 +
1542 +static inline __wsum
1543 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1544 +{
1545 + __wsum ret;
1546 + pax_open_userland();
1547 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1548 + pax_close_userland();
1549 + return ret;
1550 +}
1551 +
1552 +
1553
1554 /*
1555 * Fold a partial checksum without adding pseudo headers
1556 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1557 index 4f009c1..466c59b 100644
1558 --- a/arch/arm/include/asm/cmpxchg.h
1559 +++ b/arch/arm/include/asm/cmpxchg.h
1560 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1561
1562 #define xchg(ptr,x) \
1563 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1564 +#define xchg_unchecked(ptr,x) \
1565 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1566
1567 #include <asm-generic/cmpxchg-local.h>
1568
1569 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1570 index 6ddbe44..b5e38b1 100644
1571 --- a/arch/arm/include/asm/domain.h
1572 +++ b/arch/arm/include/asm/domain.h
1573 @@ -48,18 +48,37 @@
1574 * Domain types
1575 */
1576 #define DOMAIN_NOACCESS 0
1577 -#define DOMAIN_CLIENT 1
1578 #ifdef CONFIG_CPU_USE_DOMAINS
1579 +#define DOMAIN_USERCLIENT 1
1580 +#define DOMAIN_KERNELCLIENT 1
1581 #define DOMAIN_MANAGER 3
1582 +#define DOMAIN_VECTORS DOMAIN_USER
1583 #else
1584 +
1585 +#ifdef CONFIG_PAX_KERNEXEC
1586 #define DOMAIN_MANAGER 1
1587 +#define DOMAIN_KERNEXEC 3
1588 +#else
1589 +#define DOMAIN_MANAGER 1
1590 +#endif
1591 +
1592 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1593 +#define DOMAIN_USERCLIENT 0
1594 +#define DOMAIN_UDEREF 1
1595 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1596 +#else
1597 +#define DOMAIN_USERCLIENT 1
1598 +#define DOMAIN_VECTORS DOMAIN_USER
1599 +#endif
1600 +#define DOMAIN_KERNELCLIENT 1
1601 +
1602 #endif
1603
1604 #define domain_val(dom,type) ((type) << (2*(dom)))
1605
1606 #ifndef __ASSEMBLY__
1607
1608 -#ifdef CONFIG_CPU_USE_DOMAINS
1609 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1610 static inline void set_domain(unsigned val)
1611 {
1612 asm volatile(
1613 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1614 isb();
1615 }
1616
1617 -#define modify_domain(dom,type) \
1618 - do { \
1619 - struct thread_info *thread = current_thread_info(); \
1620 - unsigned int domain = thread->cpu_domain; \
1621 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1622 - thread->cpu_domain = domain | domain_val(dom, type); \
1623 - set_domain(thread->cpu_domain); \
1624 - } while (0)
1625 -
1626 +extern void modify_domain(unsigned int dom, unsigned int type);
1627 #else
1628 static inline void set_domain(unsigned val) { }
1629 static inline void modify_domain(unsigned dom, unsigned type) { }
1630 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1631 index 38050b1..9d90e8b 100644
1632 --- a/arch/arm/include/asm/elf.h
1633 +++ b/arch/arm/include/asm/elf.h
1634 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1635 the loader. We need to make sure that it is out of the way of the program
1636 that it will "exec", and that there is sufficient room for the brk. */
1637
1638 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1639 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1640 +
1641 +#ifdef CONFIG_PAX_ASLR
1642 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1643 +
1644 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1645 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1646 +#endif
1647
1648 /* When the program starts, a1 contains a pointer to a function to be
1649 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1650 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1651 extern void elf_set_personality(const struct elf32_hdr *);
1652 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1653
1654 -struct mm_struct;
1655 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1656 -#define arch_randomize_brk arch_randomize_brk
1657 -
1658 #endif
1659 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1660 index de53547..52b9a28 100644
1661 --- a/arch/arm/include/asm/fncpy.h
1662 +++ b/arch/arm/include/asm/fncpy.h
1663 @@ -81,7 +81,9 @@
1664 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1665 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1666 \
1667 + pax_open_kernel(); \
1668 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1669 + pax_close_kernel(); \
1670 flush_icache_range((unsigned long)(dest_buf), \
1671 (unsigned long)(dest_buf) + (size)); \
1672 \
1673 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1674 index e42cf59..7b94b8f 100644
1675 --- a/arch/arm/include/asm/futex.h
1676 +++ b/arch/arm/include/asm/futex.h
1677 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1678 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1679 return -EFAULT;
1680
1681 + pax_open_userland();
1682 +
1683 smp_mb();
1684 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1685 "1: ldrex %1, [%4]\n"
1686 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1687 : "cc", "memory");
1688 smp_mb();
1689
1690 + pax_close_userland();
1691 +
1692 *uval = val;
1693 return ret;
1694 }
1695 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1696 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1697 return -EFAULT;
1698
1699 + pax_open_userland();
1700 +
1701 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1702 "1: " TUSER(ldr) " %1, [%4]\n"
1703 " teq %1, %2\n"
1704 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1705 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1706 : "cc", "memory");
1707
1708 + pax_close_userland();
1709 +
1710 *uval = val;
1711 return ret;
1712 }
1713 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1714 return -EFAULT;
1715
1716 pagefault_disable(); /* implies preempt_disable() */
1717 + pax_open_userland();
1718
1719 switch (op) {
1720 case FUTEX_OP_SET:
1721 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1722 ret = -ENOSYS;
1723 }
1724
1725 + pax_close_userland();
1726 pagefault_enable(); /* subsumes preempt_enable() */
1727
1728 if (!ret) {
1729 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1730 index 83eb2f7..ed77159 100644
1731 --- a/arch/arm/include/asm/kmap_types.h
1732 +++ b/arch/arm/include/asm/kmap_types.h
1733 @@ -4,6 +4,6 @@
1734 /*
1735 * This is the "bare minimum". AIO seems to require this.
1736 */
1737 -#define KM_TYPE_NR 16
1738 +#define KM_TYPE_NR 17
1739
1740 #endif
1741 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1742 index 9e614a1..3302cca 100644
1743 --- a/arch/arm/include/asm/mach/dma.h
1744 +++ b/arch/arm/include/asm/mach/dma.h
1745 @@ -22,7 +22,7 @@ struct dma_ops {
1746 int (*residue)(unsigned int, dma_t *); /* optional */
1747 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1748 const char *type;
1749 -};
1750 +} __do_const;
1751
1752 struct dma_struct {
1753 void *addr; /* single DMA address */
1754 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1755 index 2fe141f..192dc01 100644
1756 --- a/arch/arm/include/asm/mach/map.h
1757 +++ b/arch/arm/include/asm/mach/map.h
1758 @@ -27,13 +27,16 @@ struct map_desc {
1759 #define MT_MINICLEAN 6
1760 #define MT_LOW_VECTORS 7
1761 #define MT_HIGH_VECTORS 8
1762 -#define MT_MEMORY 9
1763 +#define MT_MEMORY_RWX 9
1764 #define MT_ROM 10
1765 -#define MT_MEMORY_NONCACHED 11
1766 +#define MT_MEMORY_NONCACHED_RX 11
1767 #define MT_MEMORY_DTCM 12
1768 #define MT_MEMORY_ITCM 13
1769 #define MT_MEMORY_SO 14
1770 #define MT_MEMORY_DMA_READY 15
1771 +#define MT_MEMORY_RW 16
1772 +#define MT_MEMORY_RX 17
1773 +#define MT_MEMORY_NONCACHED_RW 18
1774
1775 #ifdef CONFIG_MMU
1776 extern void iotable_init(struct map_desc *, int);
1777 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1778 index 12f71a1..04e063c 100644
1779 --- a/arch/arm/include/asm/outercache.h
1780 +++ b/arch/arm/include/asm/outercache.h
1781 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1782 #endif
1783 void (*set_debug)(unsigned long);
1784 void (*resume)(void);
1785 -};
1786 +} __no_const;
1787
1788 #ifdef CONFIG_OUTER_CACHE
1789
1790 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1791 index 812a494..71fc0b6 100644
1792 --- a/arch/arm/include/asm/page.h
1793 +++ b/arch/arm/include/asm/page.h
1794 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1795 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1796 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1797 unsigned long vaddr, struct vm_area_struct *vma);
1798 -};
1799 +} __no_const;
1800
1801 #ifdef MULTI_USER
1802 extern struct cpu_user_fns cpu_user;
1803 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1804 index 943504f..c37a730 100644
1805 --- a/arch/arm/include/asm/pgalloc.h
1806 +++ b/arch/arm/include/asm/pgalloc.h
1807 @@ -17,6 +17,7 @@
1808 #include <asm/processor.h>
1809 #include <asm/cacheflush.h>
1810 #include <asm/tlbflush.h>
1811 +#include <asm/system_info.h>
1812
1813 #define check_pgt_cache() do { } while (0)
1814
1815 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1816 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1817 }
1818
1819 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1820 +{
1821 + pud_populate(mm, pud, pmd);
1822 +}
1823 +
1824 #else /* !CONFIG_ARM_LPAE */
1825
1826 /*
1827 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1828 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1829 #define pmd_free(mm, pmd) do { } while (0)
1830 #define pud_populate(mm,pmd,pte) BUG()
1831 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1832
1833 #endif /* CONFIG_ARM_LPAE */
1834
1835 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1836 __free_page(pte);
1837 }
1838
1839 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1840 +{
1841 +#ifdef CONFIG_ARM_LPAE
1842 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1843 +#else
1844 + if (addr & SECTION_SIZE)
1845 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1846 + else
1847 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1848 +#endif
1849 + flush_pmd_entry(pmdp);
1850 +}
1851 +
1852 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1853 pmdval_t prot)
1854 {
1855 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1856 static inline void
1857 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1858 {
1859 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1860 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1861 }
1862 #define pmd_pgtable(pmd) pmd_page(pmd)
1863
1864 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1865 index 5cfba15..f415e1a 100644
1866 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1867 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1868 @@ -20,12 +20,15 @@
1869 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1870 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1871 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1872 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1873 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1874 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1875 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1876 +
1877 /*
1878 * - section
1879 */
1880 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1881 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1882 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1883 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1884 @@ -37,6 +40,7 @@
1885 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1886 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1887 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1888 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1889
1890 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1891 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1892 @@ -66,6 +70,7 @@
1893 * - extended small page/tiny page
1894 */
1895 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1896 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1897 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1898 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1899 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1900 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1901 index f97ee02..cc9fe9e 100644
1902 --- a/arch/arm/include/asm/pgtable-2level.h
1903 +++ b/arch/arm/include/asm/pgtable-2level.h
1904 @@ -126,6 +126,9 @@
1905 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1906 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1907
1908 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1909 +#define L_PTE_PXN (_AT(pteval_t, 0))
1910 +
1911 /*
1912 * These are the memory types, defined to be compatible with
1913 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1914 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1915 index 18f5cef..25b8f43 100644
1916 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1917 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1918 @@ -41,6 +41,7 @@
1919 */
1920 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1921 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1922 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1923 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1924 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1925 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1926 @@ -71,6 +72,7 @@
1927 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1928 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1929 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1930 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1931 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1932
1933 /*
1934 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1935 index 86b8fe3..e25f975 100644
1936 --- a/arch/arm/include/asm/pgtable-3level.h
1937 +++ b/arch/arm/include/asm/pgtable-3level.h
1938 @@ -74,6 +74,7 @@
1939 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1940 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1941 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1942 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1943 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1944 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1945 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1946 @@ -82,6 +83,7 @@
1947 /*
1948 * To be used in assembly code with the upper page attributes.
1949 */
1950 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1951 #define L_PTE_XN_HIGH (1 << (54 - 32))
1952 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1953
1954 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1955 index 9bcd262..fba731c 100644
1956 --- a/arch/arm/include/asm/pgtable.h
1957 +++ b/arch/arm/include/asm/pgtable.h
1958 @@ -30,6 +30,9 @@
1959 #include <asm/pgtable-2level.h>
1960 #endif
1961
1962 +#define ktla_ktva(addr) (addr)
1963 +#define ktva_ktla(addr) (addr)
1964 +
1965 /*
1966 * Just any arbitrary offset to the start of the vmalloc VM area: the
1967 * current 8MB value just means that there will be a 8MB "hole" after the
1968 @@ -45,6 +48,9 @@
1969 #define LIBRARY_TEXT_START 0x0c000000
1970
1971 #ifndef __ASSEMBLY__
1972 +extern pteval_t __supported_pte_mask;
1973 +extern pmdval_t __supported_pmd_mask;
1974 +
1975 extern void __pte_error(const char *file, int line, pte_t);
1976 extern void __pmd_error(const char *file, int line, pmd_t);
1977 extern void __pgd_error(const char *file, int line, pgd_t);
1978 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1979 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1980 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1981
1982 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1983 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1984 +
1985 +#ifdef CONFIG_PAX_KERNEXEC
1986 +#include <asm/domain.h>
1987 +#include <linux/thread_info.h>
1988 +#include <linux/preempt.h>
1989 +#endif
1990 +
1991 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1992 +static inline int test_domain(int domain, int domaintype)
1993 +{
1994 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1995 +}
1996 +#endif
1997 +
1998 +#ifdef CONFIG_PAX_KERNEXEC
1999 +static inline unsigned long pax_open_kernel(void) {
2000 +#ifdef CONFIG_ARM_LPAE
2001 + /* TODO */
2002 +#else
2003 + preempt_disable();
2004 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2005 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2006 +#endif
2007 + return 0;
2008 +}
2009 +
2010 +static inline unsigned long pax_close_kernel(void) {
2011 +#ifdef CONFIG_ARM_LPAE
2012 + /* TODO */
2013 +#else
2014 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2015 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2016 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2017 + preempt_enable_no_resched();
2018 +#endif
2019 + return 0;
2020 +}
2021 +#else
2022 +static inline unsigned long pax_open_kernel(void) { return 0; }
2023 +static inline unsigned long pax_close_kernel(void) { return 0; }
2024 +#endif
2025 +
2026 /*
2027 * This is the lowest virtual address we can permit any user space
2028 * mapping to be mapped at. This is particularly important for
2029 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2030 /*
2031 * The pgprot_* and protection_map entries will be fixed up in runtime
2032 * to include the cachable and bufferable bits based on memory policy,
2033 - * as well as any architecture dependent bits like global/ASID and SMP
2034 - * shared mapping bits.
2035 + * as well as any architecture dependent bits like global/ASID, PXN,
2036 + * and SMP shared mapping bits.
2037 */
2038 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2039
2040 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2041 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2042 {
2043 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2044 - L_PTE_NONE | L_PTE_VALID;
2045 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2046 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2047 return pte;
2048 }
2049 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2050 index f3628fb..a0672dd 100644
2051 --- a/arch/arm/include/asm/proc-fns.h
2052 +++ b/arch/arm/include/asm/proc-fns.h
2053 @@ -75,7 +75,7 @@ extern struct processor {
2054 unsigned int suspend_size;
2055 void (*do_suspend)(void *);
2056 void (*do_resume)(void *);
2057 -} processor;
2058 +} __do_const processor;
2059
2060 #ifndef MULTI_CPU
2061 extern void cpu_proc_init(void);
2062 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2063 index 06e7d50..8a8e251 100644
2064 --- a/arch/arm/include/asm/processor.h
2065 +++ b/arch/arm/include/asm/processor.h
2066 @@ -65,9 +65,8 @@ struct thread_struct {
2067 regs->ARM_cpsr |= PSR_ENDSTATE; \
2068 regs->ARM_pc = pc & ~1; /* pc */ \
2069 regs->ARM_sp = sp; /* sp */ \
2070 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2071 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2072 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2073 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2074 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2075 nommu_start_thread(regs); \
2076 })
2077
2078 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2079 index ce0dbe7..c085b6f 100644
2080 --- a/arch/arm/include/asm/psci.h
2081 +++ b/arch/arm/include/asm/psci.h
2082 @@ -29,7 +29,7 @@ struct psci_operations {
2083 int (*cpu_off)(struct psci_power_state state);
2084 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2085 int (*migrate)(unsigned long cpuid);
2086 -};
2087 +} __no_const;
2088
2089 extern struct psci_operations psci_ops;
2090
2091 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2092 index d3a22be..3a69ad5 100644
2093 --- a/arch/arm/include/asm/smp.h
2094 +++ b/arch/arm/include/asm/smp.h
2095 @@ -107,7 +107,7 @@ struct smp_operations {
2096 int (*cpu_disable)(unsigned int cpu);
2097 #endif
2098 #endif
2099 -};
2100 +} __no_const;
2101
2102 /*
2103 * set platform specific SMP operations
2104 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2105 index 1995d1a..76693a2 100644
2106 --- a/arch/arm/include/asm/thread_info.h
2107 +++ b/arch/arm/include/asm/thread_info.h
2108 @@ -77,9 +77,9 @@ struct thread_info {
2109 .flags = 0, \
2110 .preempt_count = INIT_PREEMPT_COUNT, \
2111 .addr_limit = KERNEL_DS, \
2112 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2113 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2114 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2115 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2116 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2117 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2118 .restart_block = { \
2119 .fn = do_no_restart_syscall, \
2120 }, \
2121 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2122 #define TIF_SYSCALL_AUDIT 9
2123 #define TIF_SYSCALL_TRACEPOINT 10
2124 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2125 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2126 +/* within 8 bits of TIF_SYSCALL_TRACE
2127 + * to meet flexible second operand requirements
2128 + */
2129 +#define TIF_GRSEC_SETXID 12
2130 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2131 #define TIF_USING_IWMMXT 17
2132 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2133 #define TIF_RESTORE_SIGMASK 20
2134 @@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2135 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2136 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2137 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2138 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2139
2140 /* Checks for any syscall work in entry-common.S */
2141 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2142 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2143 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2144
2145 /*
2146 * Change these and you break ASM code in entry-common.S
2147 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2148 index 7e1f760..d42d7f8 100644
2149 --- a/arch/arm/include/asm/uaccess.h
2150 +++ b/arch/arm/include/asm/uaccess.h
2151 @@ -18,6 +18,7 @@
2152 #include <asm/domain.h>
2153 #include <asm/unified.h>
2154 #include <asm/compiler.h>
2155 +#include <asm/pgtable.h>
2156
2157 #define VERIFY_READ 0
2158 #define VERIFY_WRITE 1
2159 @@ -63,11 +64,35 @@ extern int __put_user_bad(void);
2160 static inline void set_fs(mm_segment_t fs)
2161 {
2162 current_thread_info()->addr_limit = fs;
2163 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2164 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2165 }
2166
2167 #define segment_eq(a,b) ((a) == (b))
2168
2169 +static inline void pax_open_userland(void)
2170 +{
2171 +
2172 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2173 + if (segment_eq(get_fs(), USER_DS)) {
2174 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2175 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2176 + }
2177 +#endif
2178 +
2179 +}
2180 +
2181 +static inline void pax_close_userland(void)
2182 +{
2183 +
2184 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2185 + if (segment_eq(get_fs(), USER_DS)) {
2186 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2187 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2188 + }
2189 +#endif
2190 +
2191 +}
2192 +
2193 #define __addr_ok(addr) ({ \
2194 unsigned long flag; \
2195 __asm__("cmp %2, %0; movlo %0, #0" \
2196 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2197
2198 #define get_user(x,p) \
2199 ({ \
2200 + int __e; \
2201 might_fault(); \
2202 - __get_user_check(x,p); \
2203 + pax_open_userland(); \
2204 + __e = __get_user_check(x,p); \
2205 + pax_close_userland(); \
2206 + __e; \
2207 })
2208
2209 extern int __put_user_1(void *, unsigned int);
2210 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2211
2212 #define put_user(x,p) \
2213 ({ \
2214 + int __e; \
2215 might_fault(); \
2216 - __put_user_check(x,p); \
2217 + pax_open_userland(); \
2218 + __e = __put_user_check(x,p); \
2219 + pax_close_userland(); \
2220 + __e; \
2221 })
2222
2223 #else /* CONFIG_MMU */
2224 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2225 #define __get_user(x,ptr) \
2226 ({ \
2227 long __gu_err = 0; \
2228 + pax_open_userland(); \
2229 __get_user_err((x),(ptr),__gu_err); \
2230 + pax_close_userland(); \
2231 __gu_err; \
2232 })
2233
2234 #define __get_user_error(x,ptr,err) \
2235 ({ \
2236 + pax_open_userland(); \
2237 __get_user_err((x),(ptr),err); \
2238 + pax_close_userland(); \
2239 (void) 0; \
2240 })
2241
2242 @@ -312,13 +349,17 @@ do { \
2243 #define __put_user(x,ptr) \
2244 ({ \
2245 long __pu_err = 0; \
2246 + pax_open_userland(); \
2247 __put_user_err((x),(ptr),__pu_err); \
2248 + pax_close_userland(); \
2249 __pu_err; \
2250 })
2251
2252 #define __put_user_error(x,ptr,err) \
2253 ({ \
2254 + pax_open_userland(); \
2255 __put_user_err((x),(ptr),err); \
2256 + pax_close_userland(); \
2257 (void) 0; \
2258 })
2259
2260 @@ -418,11 +459,44 @@ do { \
2261
2262
2263 #ifdef CONFIG_MMU
2264 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2265 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2266 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2267 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2268 +
2269 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2270 +{
2271 + unsigned long ret;
2272 +
2273 + check_object_size(to, n, false);
2274 + pax_open_userland();
2275 + ret = ___copy_from_user(to, from, n);
2276 + pax_close_userland();
2277 + return ret;
2278 +}
2279 +
2280 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2281 +{
2282 + unsigned long ret;
2283 +
2284 + check_object_size(from, n, true);
2285 + pax_open_userland();
2286 + ret = ___copy_to_user(to, from, n);
2287 + pax_close_userland();
2288 + return ret;
2289 +}
2290 +
2291 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2292 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2293 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2294 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2295 +
2296 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2297 +{
2298 + unsigned long ret;
2299 + pax_open_userland();
2300 + ret = ___clear_user(addr, n);
2301 + pax_close_userland();
2302 + return ret;
2303 +}
2304 +
2305 #else
2306 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2307 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2308 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2309
2310 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2311 {
2312 + if ((long)n < 0)
2313 + return n;
2314 +
2315 if (access_ok(VERIFY_READ, from, n))
2316 n = __copy_from_user(to, from, n);
2317 else /* security hole - plug it */
2318 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2319
2320 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2321 {
2322 + if ((long)n < 0)
2323 + return n;
2324 +
2325 if (access_ok(VERIFY_WRITE, to, n))
2326 n = __copy_to_user(to, from, n);
2327 return n;
2328 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2329 index 96ee092..37f1844 100644
2330 --- a/arch/arm/include/uapi/asm/ptrace.h
2331 +++ b/arch/arm/include/uapi/asm/ptrace.h
2332 @@ -73,7 +73,7 @@
2333 * ARMv7 groups of PSR bits
2334 */
2335 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2336 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2337 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2338 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2339 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2340
2341 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2342 index 60d3b73..e5a0f22 100644
2343 --- a/arch/arm/kernel/armksyms.c
2344 +++ b/arch/arm/kernel/armksyms.c
2345 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2346
2347 /* networking */
2348 EXPORT_SYMBOL(csum_partial);
2349 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2350 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2351 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2352 EXPORT_SYMBOL(__csum_ipv6_magic);
2353
2354 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2355 #ifdef CONFIG_MMU
2356 EXPORT_SYMBOL(copy_page);
2357
2358 -EXPORT_SYMBOL(__copy_from_user);
2359 -EXPORT_SYMBOL(__copy_to_user);
2360 -EXPORT_SYMBOL(__clear_user);
2361 +EXPORT_SYMBOL(___copy_from_user);
2362 +EXPORT_SYMBOL(___copy_to_user);
2363 +EXPORT_SYMBOL(___clear_user);
2364
2365 EXPORT_SYMBOL(__get_user_1);
2366 EXPORT_SYMBOL(__get_user_2);
2367 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2368 index 582b405..a78366b 100644
2369 --- a/arch/arm/kernel/entry-armv.S
2370 +++ b/arch/arm/kernel/entry-armv.S
2371 @@ -47,6 +47,87 @@
2372 9997:
2373 .endm
2374
2375 + .macro pax_enter_kernel
2376 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2377 + @ make aligned space for saved DACR
2378 + sub sp, sp, #8
2379 + @ save regs
2380 + stmdb sp!, {r1, r2}
2381 + @ read DACR from cpu_domain into r1
2382 + mov r2, sp
2383 + @ assume 8K pages, since we have to split the immediate in two
2384 + bic r2, r2, #(0x1fc0)
2385 + bic r2, r2, #(0x3f)
2386 + ldr r1, [r2, #TI_CPU_DOMAIN]
2387 + @ store old DACR on stack
2388 + str r1, [sp, #8]
2389 +#ifdef CONFIG_PAX_KERNEXEC
2390 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2391 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2392 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2393 +#endif
2394 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2395 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2396 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2397 +#endif
2398 + @ write r1 to current_thread_info()->cpu_domain
2399 + str r1, [r2, #TI_CPU_DOMAIN]
2400 + @ write r1 to DACR
2401 + mcr p15, 0, r1, c3, c0, 0
2402 + @ instruction sync
2403 + instr_sync
2404 + @ restore regs
2405 + ldmia sp!, {r1, r2}
2406 +#endif
2407 + .endm
2408 +
2409 + .macro pax_open_userland
2410 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2411 + @ save regs
2412 + stmdb sp!, {r0, r1}
2413 + @ read DACR from cpu_domain into r1
2414 + mov r0, sp
2415 + @ assume 8K pages, since we have to split the immediate in two
2416 + bic r0, r0, #(0x1fc0)
2417 + bic r0, r0, #(0x3f)
2418 + ldr r1, [r0, #TI_CPU_DOMAIN]
2419 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2420 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2421 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2422 + @ write r1 to current_thread_info()->cpu_domain
2423 + str r1, [r0, #TI_CPU_DOMAIN]
2424 + @ write r1 to DACR
2425 + mcr p15, 0, r1, c3, c0, 0
2426 + @ instruction sync
2427 + instr_sync
2428 + @ restore regs
2429 + ldmia sp!, {r0, r1}
2430 +#endif
2431 + .endm
2432 +
2433 + .macro pax_close_userland
2434 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2435 + @ save regs
2436 + stmdb sp!, {r0, r1}
2437 + @ read DACR from cpu_domain into r1
2438 + mov r0, sp
2439 + @ assume 8K pages, since we have to split the immediate in two
2440 + bic r0, r0, #(0x1fc0)
2441 + bic r0, r0, #(0x3f)
2442 + ldr r1, [r0, #TI_CPU_DOMAIN]
2443 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2444 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2445 + @ write r1 to current_thread_info()->cpu_domain
2446 + str r1, [r0, #TI_CPU_DOMAIN]
2447 + @ write r1 to DACR
2448 + mcr p15, 0, r1, c3, c0, 0
2449 + @ instruction sync
2450 + instr_sync
2451 + @ restore regs
2452 + ldmia sp!, {r0, r1}
2453 +#endif
2454 + .endm
2455 +
2456 .macro pabt_helper
2457 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2458 #ifdef MULTI_PABORT
2459 @@ -89,11 +170,15 @@
2460 * Invalid mode handlers
2461 */
2462 .macro inv_entry, reason
2463 +
2464 + pax_enter_kernel
2465 +
2466 sub sp, sp, #S_FRAME_SIZE
2467 ARM( stmib sp, {r1 - lr} )
2468 THUMB( stmia sp, {r0 - r12} )
2469 THUMB( str sp, [sp, #S_SP] )
2470 THUMB( str lr, [sp, #S_LR] )
2471 +
2472 mov r1, #\reason
2473 .endm
2474
2475 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2476 .macro svc_entry, stack_hole=0
2477 UNWIND(.fnstart )
2478 UNWIND(.save {r0 - pc} )
2479 +
2480 + pax_enter_kernel
2481 +
2482 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2483 +
2484 #ifdef CONFIG_THUMB2_KERNEL
2485 SPFIX( str r0, [sp] ) @ temporarily saved
2486 SPFIX( mov r0, sp )
2487 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2488 ldmia r0, {r3 - r5}
2489 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2490 mov r6, #-1 @ "" "" "" ""
2491 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2492 + @ offset sp by 8 as done in pax_enter_kernel
2493 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2494 +#else
2495 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2496 +#endif
2497 SPFIX( addeq r2, r2, #4 )
2498 str r3, [sp, #-4]! @ save the "real" r0 copied
2499 @ from the exception stack
2500 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2501 .macro usr_entry
2502 UNWIND(.fnstart )
2503 UNWIND(.cantunwind ) @ don't unwind the user space
2504 +
2505 + pax_enter_kernel_user
2506 +
2507 sub sp, sp, #S_FRAME_SIZE
2508 ARM( stmib sp, {r1 - r12} )
2509 THUMB( stmia sp, {r0 - r12} )
2510 @@ -414,7 +511,9 @@ __und_usr:
2511 tst r3, #PSR_T_BIT @ Thumb mode?
2512 bne __und_usr_thumb
2513 sub r4, r2, #4 @ ARM instr at LR - 4
2514 + pax_open_userland
2515 1: ldrt r0, [r4]
2516 + pax_close_userland
2517 #ifdef CONFIG_CPU_ENDIAN_BE8
2518 rev r0, r0 @ little endian instruction
2519 #endif
2520 @@ -449,10 +548,14 @@ __und_usr_thumb:
2521 */
2522 .arch armv6t2
2523 #endif
2524 + pax_open_userland
2525 2: ldrht r5, [r4]
2526 + pax_close_userland
2527 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2528 blo __und_usr_fault_16 @ 16bit undefined instruction
2529 + pax_open_userland
2530 3: ldrht r0, [r2]
2531 + pax_close_userland
2532 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2533 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2534 orr r0, r0, r5, lsl #16
2535 @@ -481,7 +584,8 @@ ENDPROC(__und_usr)
2536 */
2537 .pushsection .fixup, "ax"
2538 .align 2
2539 -4: mov pc, r9
2540 +4: pax_close_userland
2541 + mov pc, r9
2542 .popsection
2543 .pushsection __ex_table,"a"
2544 .long 1b, 4b
2545 @@ -690,7 +794,7 @@ ENTRY(__switch_to)
2546 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2547 THUMB( str sp, [ip], #4 )
2548 THUMB( str lr, [ip], #4 )
2549 -#ifdef CONFIG_CPU_USE_DOMAINS
2550 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2551 ldr r6, [r2, #TI_CPU_DOMAIN]
2552 #endif
2553 set_tls r3, r4, r5
2554 @@ -699,7 +803,7 @@ ENTRY(__switch_to)
2555 ldr r8, =__stack_chk_guard
2556 ldr r7, [r7, #TSK_STACK_CANARY]
2557 #endif
2558 -#ifdef CONFIG_CPU_USE_DOMAINS
2559 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2560 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2561 #endif
2562 mov r5, r0
2563 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2564 index bc5bc0a..d0998ca 100644
2565 --- a/arch/arm/kernel/entry-common.S
2566 +++ b/arch/arm/kernel/entry-common.S
2567 @@ -10,18 +10,46 @@
2568
2569 #include <asm/unistd.h>
2570 #include <asm/ftrace.h>
2571 +#include <asm/domain.h>
2572 #include <asm/unwind.h>
2573
2574 +#include "entry-header.S"
2575 +
2576 #ifdef CONFIG_NEED_RET_TO_USER
2577 #include <mach/entry-macro.S>
2578 #else
2579 .macro arch_ret_to_user, tmp1, tmp2
2580 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2581 + @ save regs
2582 + stmdb sp!, {r1, r2}
2583 + @ read DACR from cpu_domain into r1
2584 + mov r2, sp
2585 + @ assume 8K pages, since we have to split the immediate in two
2586 + bic r2, r2, #(0x1fc0)
2587 + bic r2, r2, #(0x3f)
2588 + ldr r1, [r2, #TI_CPU_DOMAIN]
2589 +#ifdef CONFIG_PAX_KERNEXEC
2590 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2591 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2592 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2593 +#endif
2594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2595 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2596 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2597 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2598 +#endif
2599 + @ write r1 to current_thread_info()->cpu_domain
2600 + str r1, [r2, #TI_CPU_DOMAIN]
2601 + @ write r1 to DACR
2602 + mcr p15, 0, r1, c3, c0, 0
2603 + @ instruction sync
2604 + instr_sync
2605 + @ restore regs
2606 + ldmia sp!, {r1, r2}
2607 +#endif
2608 .endm
2609 #endif
2610
2611 -#include "entry-header.S"
2612 -
2613 -
2614 .align 5
2615 /*
2616 * This is the fast syscall return path. We do as little as
2617 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2618
2619 .align 5
2620 ENTRY(vector_swi)
2621 +
2622 sub sp, sp, #S_FRAME_SIZE
2623 stmia sp, {r0 - r12} @ Calling r0 - r12
2624 ARM( add r8, sp, #S_PC )
2625 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2626 ldr scno, [lr, #-4] @ get SWI instruction
2627 #endif
2628
2629 + /*
2630 + * do this here to avoid a performance hit of wrapping the code above
2631 + * that directly dereferences userland to parse the SWI instruction
2632 + */
2633 + pax_enter_kernel_user
2634 +
2635 #ifdef CONFIG_ALIGNMENT_TRAP
2636 ldr ip, __cr_alignment
2637 ldr ip, [ip]
2638 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2639 index 160f337..db67ee4 100644
2640 --- a/arch/arm/kernel/entry-header.S
2641 +++ b/arch/arm/kernel/entry-header.S
2642 @@ -73,6 +73,60 @@
2643 msr cpsr_c, \rtemp @ switch back to the SVC mode
2644 .endm
2645
2646 + .macro pax_enter_kernel_user
2647 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2648 + @ save regs
2649 + stmdb sp!, {r0, r1}
2650 + @ read DACR from cpu_domain into r1
2651 + mov r0, sp
2652 + @ assume 8K pages, since we have to split the immediate in two
2653 + bic r0, r0, #(0x1fc0)
2654 + bic r0, r0, #(0x3f)
2655 + ldr r1, [r0, #TI_CPU_DOMAIN]
2656 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2657 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2658 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2659 +#endif
2660 +#ifdef CONFIG_PAX_KERNEXEC
2661 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2662 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2663 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2664 +#endif
2665 + @ write r1 to current_thread_info()->cpu_domain
2666 + str r1, [r0, #TI_CPU_DOMAIN]
2667 + @ write r1 to DACR
2668 + mcr p15, 0, r1, c3, c0, 0
2669 + @ instruction sync
2670 + instr_sync
2671 + @ restore regs
2672 + ldmia sp!, {r0, r1}
2673 +#endif
2674 + .endm
2675 +
2676 + .macro pax_exit_kernel
2677 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2678 + @ save regs
2679 + stmdb sp!, {r0, r1}
2680 + @ read old DACR from stack into r1
2681 + ldr r1, [sp, #(8 + S_SP)]
2682 + sub r1, r1, #8
2683 + ldr r1, [r1]
2684 +
2685 + @ write r1 to current_thread_info()->cpu_domain
2686 + mov r0, sp
2687 + @ assume 8K pages, since we have to split the immediate in two
2688 + bic r0, r0, #(0x1fc0)
2689 + bic r0, r0, #(0x3f)
2690 + str r1, [r0, #TI_CPU_DOMAIN]
2691 + @ write r1 to DACR
2692 + mcr p15, 0, r1, c3, c0, 0
2693 + @ instruction sync
2694 + instr_sync
2695 + @ restore regs
2696 + ldmia sp!, {r0, r1}
2697 +#endif
2698 + .endm
2699 +
2700 #ifndef CONFIG_THUMB2_KERNEL
2701 .macro svc_exit, rpsr, irq = 0
2702 .if \irq != 0
2703 @@ -92,6 +146,9 @@
2704 blne trace_hardirqs_off
2705 #endif
2706 .endif
2707 +
2708 + pax_exit_kernel
2709 +
2710 msr spsr_cxsf, \rpsr
2711 #if defined(CONFIG_CPU_V6)
2712 ldr r0, [sp]
2713 @@ -155,6 +212,9 @@
2714 blne trace_hardirqs_off
2715 #endif
2716 .endif
2717 +
2718 + pax_exit_kernel
2719 +
2720 ldr lr, [sp, #S_SP] @ top of the stack
2721 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2722 clrex @ clear the exclusive monitor
2723 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2724 index 2adda11..7fbe958 100644
2725 --- a/arch/arm/kernel/fiq.c
2726 +++ b/arch/arm/kernel/fiq.c
2727 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2728 #if defined(CONFIG_CPU_USE_DOMAINS)
2729 memcpy((void *)0xffff001c, start, length);
2730 #else
2731 + pax_open_kernel();
2732 memcpy(vectors_page + 0x1c, start, length);
2733 + pax_close_kernel();
2734 #endif
2735 flush_icache_range(0xffff001c, 0xffff001c + length);
2736 if (!vectors_high())
2737 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2738 index 8bac553..caee108 100644
2739 --- a/arch/arm/kernel/head.S
2740 +++ b/arch/arm/kernel/head.S
2741 @@ -52,7 +52,9 @@
2742 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2743
2744 .macro pgtbl, rd, phys
2745 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2746 + mov \rd, #TEXT_OFFSET
2747 + sub \rd, #PG_DIR_SIZE
2748 + add \rd, \rd, \phys
2749 .endm
2750
2751 /*
2752 @@ -434,7 +436,7 @@ __enable_mmu:
2753 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2754 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2755 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2756 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2757 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2758 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2759 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2760 #endif
2761 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2762 index 1fd749e..47adb08 100644
2763 --- a/arch/arm/kernel/hw_breakpoint.c
2764 +++ b/arch/arm/kernel/hw_breakpoint.c
2765 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2766 return NOTIFY_OK;
2767 }
2768
2769 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2770 +static struct notifier_block dbg_reset_nb = {
2771 .notifier_call = dbg_reset_notify,
2772 };
2773
2774 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2775 index 1e9be5d..03edbc2 100644
2776 --- a/arch/arm/kernel/module.c
2777 +++ b/arch/arm/kernel/module.c
2778 @@ -37,12 +37,37 @@
2779 #endif
2780
2781 #ifdef CONFIG_MMU
2782 -void *module_alloc(unsigned long size)
2783 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2784 {
2785 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2786 + return NULL;
2787 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2788 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2789 + GFP_KERNEL, prot, -1,
2790 __builtin_return_address(0));
2791 }
2792 +
2793 +void *module_alloc(unsigned long size)
2794 +{
2795 +
2796 +#ifdef CONFIG_PAX_KERNEXEC
2797 + return __module_alloc(size, PAGE_KERNEL);
2798 +#else
2799 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2800 +#endif
2801 +
2802 +}
2803 +
2804 +#ifdef CONFIG_PAX_KERNEXEC
2805 +void module_free_exec(struct module *mod, void *module_region)
2806 +{
2807 + module_free(mod, module_region);
2808 +}
2809 +
2810 +void *module_alloc_exec(unsigned long size)
2811 +{
2812 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2813 +}
2814 +#endif
2815 #endif
2816
2817 int
2818 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2819 index 07314af..c46655c 100644
2820 --- a/arch/arm/kernel/patch.c
2821 +++ b/arch/arm/kernel/patch.c
2822 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2823 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2824 int size;
2825
2826 + pax_open_kernel();
2827 if (thumb2 && __opcode_is_thumb16(insn)) {
2828 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2829 size = sizeof(u16);
2830 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2831 *(u32 *)addr = insn;
2832 size = sizeof(u32);
2833 }
2834 + pax_close_kernel();
2835
2836 flush_icache_range((uintptr_t)(addr),
2837 (uintptr_t)(addr) + size);
2838 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2839 index 1f2740e..b36e225 100644
2840 --- a/arch/arm/kernel/perf_event_cpu.c
2841 +++ b/arch/arm/kernel/perf_event_cpu.c
2842 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2843 return NOTIFY_OK;
2844 }
2845
2846 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2847 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2848 .notifier_call = cpu_pmu_notify,
2849 };
2850
2851 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2852 index 6e8931c..82ec6a5 100644
2853 --- a/arch/arm/kernel/process.c
2854 +++ b/arch/arm/kernel/process.c
2855 @@ -28,7 +28,6 @@
2856 #include <linux/tick.h>
2857 #include <linux/utsname.h>
2858 #include <linux/uaccess.h>
2859 -#include <linux/random.h>
2860 #include <linux/hw_breakpoint.h>
2861 #include <linux/cpuidle.h>
2862 #include <linux/leds.h>
2863 @@ -223,6 +222,7 @@ void machine_power_off(void)
2864
2865 if (pm_power_off)
2866 pm_power_off();
2867 + BUG();
2868 }
2869
2870 /*
2871 @@ -236,7 +236,7 @@ void machine_power_off(void)
2872 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2873 * to use. Implementing such co-ordination would be essentially impossible.
2874 */
2875 -void machine_restart(char *cmd)
2876 +__noreturn void machine_restart(char *cmd)
2877 {
2878 smp_send_stop();
2879
2880 @@ -258,8 +258,8 @@ void __show_regs(struct pt_regs *regs)
2881
2882 show_regs_print_info(KERN_DEFAULT);
2883
2884 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2885 - print_symbol("LR is at %s\n", regs->ARM_lr);
2886 + printk("PC is at %pA\n", instruction_pointer(regs));
2887 + printk("LR is at %pA\n", regs->ARM_lr);
2888 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2889 "sp : %08lx ip : %08lx fp : %08lx\n",
2890 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2891 @@ -426,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2892 return 0;
2893 }
2894
2895 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2896 -{
2897 - unsigned long range_end = mm->brk + 0x02000000;
2898 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2899 -}
2900 -
2901 #ifdef CONFIG_MMU
2902 /*
2903 * The vectors page is always readable from user space for the
2904 @@ -441,12 +435,12 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
2905 static struct vm_area_struct gate_vma = {
2906 .vm_start = 0xffff0000,
2907 .vm_end = 0xffff0000 + PAGE_SIZE,
2908 - .vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC,
2909 + .vm_flags = VM_NONE,
2910 };
2911
2912 static int __init gate_vma_init(void)
2913 {
2914 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2915 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2916 return 0;
2917 }
2918 arch_initcall(gate_vma_init);
2919 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2920 index 3653164..d83e55d 100644
2921 --- a/arch/arm/kernel/psci.c
2922 +++ b/arch/arm/kernel/psci.c
2923 @@ -24,7 +24,7 @@
2924 #include <asm/opcodes-virt.h>
2925 #include <asm/psci.h>
2926
2927 -struct psci_operations psci_ops;
2928 +struct psci_operations psci_ops __read_only;
2929
2930 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2931
2932 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2933 index 03deeff..741ce88 100644
2934 --- a/arch/arm/kernel/ptrace.c
2935 +++ b/arch/arm/kernel/ptrace.c
2936 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2937 return current_thread_info()->syscall;
2938 }
2939
2940 +#ifdef CONFIG_GRKERNSEC_SETXID
2941 +extern void gr_delayed_cred_worker(void);
2942 +#endif
2943 +
2944 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2945 {
2946 current_thread_info()->syscall = scno;
2947
2948 +#ifdef CONFIG_GRKERNSEC_SETXID
2949 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2950 + gr_delayed_cred_worker();
2951 +#endif
2952 +
2953 /* Do the secure computing check first; failures should be fast. */
2954 if (secure_computing(scno) == -1)
2955 return -1;
2956 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2957 index b4b1d39..efdc9be 100644
2958 --- a/arch/arm/kernel/setup.c
2959 +++ b/arch/arm/kernel/setup.c
2960 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2961 unsigned int elf_hwcap __read_mostly;
2962 EXPORT_SYMBOL(elf_hwcap);
2963
2964 +pteval_t __supported_pte_mask __read_only;
2965 +pmdval_t __supported_pmd_mask __read_only;
2966
2967 #ifdef MULTI_CPU
2968 -struct processor processor __read_mostly;
2969 +struct processor processor;
2970 #endif
2971 #ifdef MULTI_TLB
2972 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2973 +struct cpu_tlb_fns cpu_tlb __read_only;
2974 #endif
2975 #ifdef MULTI_USER
2976 -struct cpu_user_fns cpu_user __read_mostly;
2977 +struct cpu_user_fns cpu_user __read_only;
2978 #endif
2979 #ifdef MULTI_CACHE
2980 -struct cpu_cache_fns cpu_cache __read_mostly;
2981 +struct cpu_cache_fns cpu_cache __read_only;
2982 #endif
2983 #ifdef CONFIG_OUTER_CACHE
2984 -struct outer_cache_fns outer_cache __read_mostly;
2985 +struct outer_cache_fns outer_cache __read_only;
2986 EXPORT_SYMBOL(outer_cache);
2987 #endif
2988
2989 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
2990 asm("mrc p15, 0, %0, c0, c1, 4"
2991 : "=r" (mmfr0));
2992 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2993 - (mmfr0 & 0x000000f0) >= 0x00000030)
2994 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2995 cpu_arch = CPU_ARCH_ARMv7;
2996 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2997 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2998 + __supported_pte_mask |= L_PTE_PXN;
2999 + __supported_pmd_mask |= PMD_PXNTABLE;
3000 + }
3001 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3002 (mmfr0 & 0x000000f0) == 0x00000020)
3003 cpu_arch = CPU_ARCH_ARMv6;
3004 else
3005 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
3006 __cpu_architecture = __get_cpu_architecture();
3007
3008 #ifdef MULTI_CPU
3009 - processor = *list->proc;
3010 + memcpy((void *)&processor, list->proc, sizeof processor);
3011 #endif
3012 #ifdef MULTI_TLB
3013 cpu_tlb = *list->tlb;
3014 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3015 index 296786b..a8d4dd5 100644
3016 --- a/arch/arm/kernel/signal.c
3017 +++ b/arch/arm/kernel/signal.c
3018 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3019 __put_user(sigreturn_codes[idx+1], rc+1))
3020 return 1;
3021
3022 - if (cpsr & MODE32_BIT) {
3023 - /*
3024 - * 32-bit code can use the new high-page
3025 - * signal return code support.
3026 - */
3027 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3028 - } else {
3029 - /*
3030 - * Ensure that the instruction cache sees
3031 - * the return code written onto the stack.
3032 - */
3033 - flush_icache_range((unsigned long)rc,
3034 - (unsigned long)(rc + 2));
3035 + /*
3036 + * Ensure that the instruction cache sees
3037 + * the return code written onto the stack.
3038 + */
3039 + flush_icache_range((unsigned long)rc,
3040 + (unsigned long)(rc + 2));
3041
3042 - retcode = ((unsigned long)rc) + thumb;
3043 - }
3044 + retcode = ((unsigned long)rc) + thumb;
3045 }
3046
3047 regs->ARM_r0 = map_sig(ksig->sig);
3048 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3049 index 5919eb4..b5d6dfe 100644
3050 --- a/arch/arm/kernel/smp.c
3051 +++ b/arch/arm/kernel/smp.c
3052 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3053
3054 static DECLARE_COMPLETION(cpu_running);
3055
3056 -static struct smp_operations smp_ops;
3057 +static struct smp_operations smp_ops __read_only;
3058
3059 void __init smp_set_ops(struct smp_operations *ops)
3060 {
3061 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3062 index 18b32e8..b0c8dca 100644
3063 --- a/arch/arm/kernel/traps.c
3064 +++ b/arch/arm/kernel/traps.c
3065 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3066 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3067 {
3068 #ifdef CONFIG_KALLSYMS
3069 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3070 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3071 #else
3072 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3073 #endif
3074 @@ -259,6 +259,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3075 static int die_owner = -1;
3076 static unsigned int die_nest_count;
3077
3078 +extern void gr_handle_kernel_exploit(void);
3079 +
3080 static unsigned long oops_begin(void)
3081 {
3082 int cpu;
3083 @@ -301,6 +303,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3084 panic("Fatal exception in interrupt");
3085 if (panic_on_oops)
3086 panic("Fatal exception");
3087 +
3088 + gr_handle_kernel_exploit();
3089 +
3090 if (signr)
3091 do_exit(signr);
3092 }
3093 @@ -594,7 +599,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3094 * The user helper at 0xffff0fe0 must be used instead.
3095 * (see entry-armv.S for details)
3096 */
3097 + pax_open_kernel();
3098 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3099 + pax_close_kernel();
3100 }
3101 return 0;
3102
3103 @@ -834,13 +841,10 @@ void __init early_trap_init(void *vectors_base)
3104 */
3105 kuser_get_tls_init(vectors);
3106
3107 - /*
3108 - * Copy signal return handlers into the vector page, and
3109 - * set sigreturn to be a pointer to these.
3110 - */
3111 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3112 - sigreturn_codes, sizeof(sigreturn_codes));
3113 -
3114 flush_icache_range(vectors, vectors + PAGE_SIZE);
3115 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3116 +
3117 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3118 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3119 +#endif
3120 +
3121 }
3122 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3123 index a871b8e..123b00a 100644
3124 --- a/arch/arm/kernel/vmlinux.lds.S
3125 +++ b/arch/arm/kernel/vmlinux.lds.S
3126 @@ -8,7 +8,11 @@
3127 #include <asm/thread_info.h>
3128 #include <asm/memory.h>
3129 #include <asm/page.h>
3130 -
3131 +
3132 +#ifdef CONFIG_PAX_KERNEXEC
3133 +#include <asm/pgtable.h>
3134 +#endif
3135 +
3136 #define PROC_INFO \
3137 . = ALIGN(4); \
3138 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3139 @@ -94,6 +98,11 @@ SECTIONS
3140 _text = .;
3141 HEAD_TEXT
3142 }
3143 +
3144 +#ifdef CONFIG_PAX_KERNEXEC
3145 + . = ALIGN(1<<SECTION_SHIFT);
3146 +#endif
3147 +
3148 .text : { /* Real text segment */
3149 _stext = .; /* Text and read-only data */
3150 __exception_text_start = .;
3151 @@ -116,6 +125,8 @@ SECTIONS
3152 ARM_CPU_KEEP(PROC_INFO)
3153 }
3154
3155 + _etext = .; /* End of text section */
3156 +
3157 RO_DATA(PAGE_SIZE)
3158
3159 . = ALIGN(4);
3160 @@ -146,7 +157,9 @@ SECTIONS
3161
3162 NOTES
3163
3164 - _etext = .; /* End of text and rodata section */
3165 +#ifdef CONFIG_PAX_KERNEXEC
3166 + . = ALIGN(1<<SECTION_SHIFT);
3167 +#endif
3168
3169 #ifndef CONFIG_XIP_KERNEL
3170 . = ALIGN(PAGE_SIZE);
3171 @@ -207,6 +220,11 @@ SECTIONS
3172 . = PAGE_OFFSET + TEXT_OFFSET;
3173 #else
3174 __init_end = .;
3175 +
3176 +#ifdef CONFIG_PAX_KERNEXEC
3177 + . = ALIGN(1<<SECTION_SHIFT);
3178 +#endif
3179 +
3180 . = ALIGN(THREAD_SIZE);
3181 __data_loc = .;
3182 #endif
3183 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3184 index 14a0d98..7771a7d 100644
3185 --- a/arch/arm/lib/clear_user.S
3186 +++ b/arch/arm/lib/clear_user.S
3187 @@ -12,14 +12,14 @@
3188
3189 .text
3190
3191 -/* Prototype: int __clear_user(void *addr, size_t sz)
3192 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3193 * Purpose : clear some user memory
3194 * Params : addr - user memory address to clear
3195 * : sz - number of bytes to clear
3196 * Returns : number of bytes NOT cleared
3197 */
3198 ENTRY(__clear_user_std)
3199 -WEAK(__clear_user)
3200 +WEAK(___clear_user)
3201 stmfd sp!, {r1, lr}
3202 mov r2, #0
3203 cmp r1, #4
3204 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3205 USER( strnebt r2, [r0])
3206 mov r0, #0
3207 ldmfd sp!, {r1, pc}
3208 -ENDPROC(__clear_user)
3209 +ENDPROC(___clear_user)
3210 ENDPROC(__clear_user_std)
3211
3212 .pushsection .fixup,"ax"
3213 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3214 index 66a477a..bee61d3 100644
3215 --- a/arch/arm/lib/copy_from_user.S
3216 +++ b/arch/arm/lib/copy_from_user.S
3217 @@ -16,7 +16,7 @@
3218 /*
3219 * Prototype:
3220 *
3221 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3222 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3223 *
3224 * Purpose:
3225 *
3226 @@ -84,11 +84,11 @@
3227
3228 .text
3229
3230 -ENTRY(__copy_from_user)
3231 +ENTRY(___copy_from_user)
3232
3233 #include "copy_template.S"
3234
3235 -ENDPROC(__copy_from_user)
3236 +ENDPROC(___copy_from_user)
3237
3238 .pushsection .fixup,"ax"
3239 .align 0
3240 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3241 index 6ee2f67..d1cce76 100644
3242 --- a/arch/arm/lib/copy_page.S
3243 +++ b/arch/arm/lib/copy_page.S
3244 @@ -10,6 +10,7 @@
3245 * ASM optimised string functions
3246 */
3247 #include <linux/linkage.h>
3248 +#include <linux/const.h>
3249 #include <asm/assembler.h>
3250 #include <asm/asm-offsets.h>
3251 #include <asm/cache.h>
3252 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3253 index d066df6..df28194 100644
3254 --- a/arch/arm/lib/copy_to_user.S
3255 +++ b/arch/arm/lib/copy_to_user.S
3256 @@ -16,7 +16,7 @@
3257 /*
3258 * Prototype:
3259 *
3260 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3261 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3262 *
3263 * Purpose:
3264 *
3265 @@ -88,11 +88,11 @@
3266 .text
3267
3268 ENTRY(__copy_to_user_std)
3269 -WEAK(__copy_to_user)
3270 +WEAK(___copy_to_user)
3271
3272 #include "copy_template.S"
3273
3274 -ENDPROC(__copy_to_user)
3275 +ENDPROC(___copy_to_user)
3276 ENDPROC(__copy_to_user_std)
3277
3278 .pushsection .fixup,"ax"
3279 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3280 index 7d08b43..f7ca7ea 100644
3281 --- a/arch/arm/lib/csumpartialcopyuser.S
3282 +++ b/arch/arm/lib/csumpartialcopyuser.S
3283 @@ -57,8 +57,8 @@
3284 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3285 */
3286
3287 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3288 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3289 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3290 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3291
3292 #include "csumpartialcopygeneric.S"
3293
3294 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3295 index 64dbfa5..84a3fd9 100644
3296 --- a/arch/arm/lib/delay.c
3297 +++ b/arch/arm/lib/delay.c
3298 @@ -28,7 +28,7 @@
3299 /*
3300 * Default to the loop-based delay implementation.
3301 */
3302 -struct arm_delay_ops arm_delay_ops = {
3303 +struct arm_delay_ops arm_delay_ops __read_only = {
3304 .delay = __loop_delay,
3305 .const_udelay = __loop_const_udelay,
3306 .udelay = __loop_udelay,
3307 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3308 index 025f742..8432b08 100644
3309 --- a/arch/arm/lib/uaccess_with_memcpy.c
3310 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3311 @@ -104,7 +104,7 @@ out:
3312 }
3313
3314 unsigned long
3315 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3316 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3317 {
3318 /*
3319 * This test is stubbed out of the main function above to keep
3320 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3321 index f389228..592ef66 100644
3322 --- a/arch/arm/mach-kirkwood/common.c
3323 +++ b/arch/arm/mach-kirkwood/common.c
3324 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3325 clk_gate_ops.disable(hw);
3326 }
3327
3328 -static struct clk_ops clk_gate_fn_ops;
3329 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3330 +{
3331 + return clk_gate_ops.is_enabled(hw);
3332 +}
3333 +
3334 +static struct clk_ops clk_gate_fn_ops = {
3335 + .enable = clk_gate_fn_enable,
3336 + .disable = clk_gate_fn_disable,
3337 + .is_enabled = clk_gate_fn_is_enabled,
3338 +};
3339
3340 static struct clk __init *clk_register_gate_fn(struct device *dev,
3341 const char *name,
3342 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3343 gate_fn->fn_en = fn_en;
3344 gate_fn->fn_dis = fn_dis;
3345
3346 - /* ops is the gate ops, but with our enable/disable functions */
3347 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3348 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3349 - clk_gate_fn_ops = clk_gate_ops;
3350 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3351 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3352 - }
3353 -
3354 clk = clk_register(dev, &gate_fn->gate.hw);
3355
3356 if (IS_ERR(clk))
3357 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3358 index f6eeb87..cc90868 100644
3359 --- a/arch/arm/mach-omap2/board-n8x0.c
3360 +++ b/arch/arm/mach-omap2/board-n8x0.c
3361 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3362 }
3363 #endif
3364
3365 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3366 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3367 .late_init = n8x0_menelaus_late_init,
3368 };
3369
3370 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3371 index 6c4da12..d9ca72d 100644
3372 --- a/arch/arm/mach-omap2/gpmc.c
3373 +++ b/arch/arm/mach-omap2/gpmc.c
3374 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3375 };
3376
3377 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3378 -static struct irq_chip gpmc_irq_chip;
3379 static unsigned gpmc_irq_start;
3380
3381 static struct resource gpmc_mem_root;
3382 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3383
3384 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3385
3386 +static struct irq_chip gpmc_irq_chip = {
3387 + .name = "gpmc",
3388 + .irq_startup = gpmc_irq_noop_ret,
3389 + .irq_enable = gpmc_irq_enable,
3390 + .irq_disable = gpmc_irq_disable,
3391 + .irq_shutdown = gpmc_irq_noop,
3392 + .irq_ack = gpmc_irq_noop,
3393 + .irq_mask = gpmc_irq_noop,
3394 + .irq_unmask = gpmc_irq_noop,
3395 +
3396 +};
3397 +
3398 static int gpmc_setup_irq(void)
3399 {
3400 int i;
3401 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3402 return gpmc_irq_start;
3403 }
3404
3405 - gpmc_irq_chip.name = "gpmc";
3406 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3407 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3408 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3409 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3410 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3411 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3412 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3413 -
3414 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3415 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3416
3417 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3418 index f8bb3b9..831e7b8 100644
3419 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3420 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3421 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3422 return NOTIFY_OK;
3423 }
3424
3425 -static struct notifier_block __refdata irq_hotplug_notifier = {
3426 +static struct notifier_block irq_hotplug_notifier = {
3427 .notifier_call = irq_cpu_hotplug_notify,
3428 };
3429
3430 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3431 index e6d2307..d057195 100644
3432 --- a/arch/arm/mach-omap2/omap_device.c
3433 +++ b/arch/arm/mach-omap2/omap_device.c
3434 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3435 struct platform_device __init *omap_device_build(const char *pdev_name,
3436 int pdev_id,
3437 struct omap_hwmod *oh,
3438 - void *pdata, int pdata_len)
3439 + const void *pdata, int pdata_len)
3440 {
3441 struct omap_hwmod *ohs[] = { oh };
3442
3443 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3444 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3445 int pdev_id,
3446 struct omap_hwmod **ohs,
3447 - int oh_cnt, void *pdata,
3448 + int oh_cnt, const void *pdata,
3449 int pdata_len)
3450 {
3451 int ret = -ENOMEM;
3452 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3453 index 044c31d..2ee0861 100644
3454 --- a/arch/arm/mach-omap2/omap_device.h
3455 +++ b/arch/arm/mach-omap2/omap_device.h
3456 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3457 /* Core code interface */
3458
3459 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3460 - struct omap_hwmod *oh, void *pdata,
3461 + struct omap_hwmod *oh, const void *pdata,
3462 int pdata_len);
3463
3464 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3465 struct omap_hwmod **oh, int oh_cnt,
3466 - void *pdata, int pdata_len);
3467 + const void *pdata, int pdata_len);
3468
3469 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3470 struct omap_hwmod **ohs, int oh_cnt);
3471 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3472 index 7341eff..fd75e34 100644
3473 --- a/arch/arm/mach-omap2/omap_hwmod.c
3474 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3475 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3476 int (*init_clkdm)(struct omap_hwmod *oh);
3477 void (*update_context_lost)(struct omap_hwmod *oh);
3478 int (*get_context_lost)(struct omap_hwmod *oh);
3479 -};
3480 +} __no_const;
3481
3482 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3483 -static struct omap_hwmod_soc_ops soc_ops;
3484 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3485
3486 /* omap_hwmod_list contains all registered struct omap_hwmods */
3487 static LIST_HEAD(omap_hwmod_list);
3488 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3489 index d15c7bb..b2d1f0c 100644
3490 --- a/arch/arm/mach-omap2/wd_timer.c
3491 +++ b/arch/arm/mach-omap2/wd_timer.c
3492 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3493 struct omap_hwmod *oh;
3494 char *oh_name = "wd_timer2";
3495 char *dev_name = "omap_wdt";
3496 - struct omap_wd_timer_platform_data pdata;
3497 + static struct omap_wd_timer_platform_data pdata = {
3498 + .read_reset_sources = prm_read_reset_sources
3499 + };
3500
3501 if (!cpu_class_is_omap2() || of_have_populated_dt())
3502 return 0;
3503 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3504 return -EINVAL;
3505 }
3506
3507 - pdata.read_reset_sources = prm_read_reset_sources;
3508 -
3509 pdev = omap_device_build(dev_name, id, oh, &pdata,
3510 sizeof(struct omap_wd_timer_platform_data));
3511 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3512 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3513 index 0cdba8d..297993e 100644
3514 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3515 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3516 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3517 bool entered_lp2 = false;
3518
3519 if (tegra_pending_sgi())
3520 - ACCESS_ONCE(abort_flag) = true;
3521 + ACCESS_ONCE_RW(abort_flag) = true;
3522
3523 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3524
3525 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3526 index cad3ca86..1d79e0f 100644
3527 --- a/arch/arm/mach-ux500/setup.h
3528 +++ b/arch/arm/mach-ux500/setup.h
3529 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3530 .type = MT_DEVICE, \
3531 }
3532
3533 -#define __MEM_DEV_DESC(x, sz) { \
3534 - .virtual = IO_ADDRESS(x), \
3535 - .pfn = __phys_to_pfn(x), \
3536 - .length = sz, \
3537 - .type = MT_MEMORY, \
3538 -}
3539 -
3540 extern struct smp_operations ux500_smp_ops;
3541 extern void ux500_cpu_die(unsigned int cpu);
3542
3543 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3544 index 35955b5..b475042 100644
3545 --- a/arch/arm/mm/Kconfig
3546 +++ b/arch/arm/mm/Kconfig
3547 @@ -432,7 +432,7 @@ config CPU_32v5
3548
3549 config CPU_32v6
3550 bool
3551 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3552 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3553 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3554
3555 config CPU_32v6K
3556 @@ -581,6 +581,7 @@ config CPU_CP15_MPU
3557
3558 config CPU_USE_DOMAINS
3559 bool
3560 + depends on !ARM_LPAE && !PAX_KERNEXEC
3561 help
3562 This option enables or disables the use of domain switching
3563 via the set_fs() function.
3564 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3565 index 6f4585b..7b6f52b 100644
3566 --- a/arch/arm/mm/alignment.c
3567 +++ b/arch/arm/mm/alignment.c
3568 @@ -211,10 +211,12 @@ union offset_union {
3569 #define __get16_unaligned_check(ins,val,addr) \
3570 do { \
3571 unsigned int err = 0, v, a = addr; \
3572 + pax_open_userland(); \
3573 __get8_unaligned_check(ins,v,a,err); \
3574 val = v << ((BE) ? 8 : 0); \
3575 __get8_unaligned_check(ins,v,a,err); \
3576 val |= v << ((BE) ? 0 : 8); \
3577 + pax_close_userland(); \
3578 if (err) \
3579 goto fault; \
3580 } while (0)
3581 @@ -228,6 +230,7 @@ union offset_union {
3582 #define __get32_unaligned_check(ins,val,addr) \
3583 do { \
3584 unsigned int err = 0, v, a = addr; \
3585 + pax_open_userland(); \
3586 __get8_unaligned_check(ins,v,a,err); \
3587 val = v << ((BE) ? 24 : 0); \
3588 __get8_unaligned_check(ins,v,a,err); \
3589 @@ -236,6 +239,7 @@ union offset_union {
3590 val |= v << ((BE) ? 8 : 16); \
3591 __get8_unaligned_check(ins,v,a,err); \
3592 val |= v << ((BE) ? 0 : 24); \
3593 + pax_close_userland(); \
3594 if (err) \
3595 goto fault; \
3596 } while (0)
3597 @@ -249,6 +253,7 @@ union offset_union {
3598 #define __put16_unaligned_check(ins,val,addr) \
3599 do { \
3600 unsigned int err = 0, v = val, a = addr; \
3601 + pax_open_userland(); \
3602 __asm__( FIRST_BYTE_16 \
3603 ARM( "1: "ins" %1, [%2], #1\n" ) \
3604 THUMB( "1: "ins" %1, [%2]\n" ) \
3605 @@ -268,6 +273,7 @@ union offset_union {
3606 " .popsection\n" \
3607 : "=r" (err), "=&r" (v), "=&r" (a) \
3608 : "0" (err), "1" (v), "2" (a)); \
3609 + pax_close_userland(); \
3610 if (err) \
3611 goto fault; \
3612 } while (0)
3613 @@ -281,6 +287,7 @@ union offset_union {
3614 #define __put32_unaligned_check(ins,val,addr) \
3615 do { \
3616 unsigned int err = 0, v = val, a = addr; \
3617 + pax_open_userland(); \
3618 __asm__( FIRST_BYTE_32 \
3619 ARM( "1: "ins" %1, [%2], #1\n" ) \
3620 THUMB( "1: "ins" %1, [%2]\n" ) \
3621 @@ -310,6 +317,7 @@ union offset_union {
3622 " .popsection\n" \
3623 : "=r" (err), "=&r" (v), "=&r" (a) \
3624 : "0" (err), "1" (v), "2" (a)); \
3625 + pax_close_userland(); \
3626 if (err) \
3627 goto fault; \
3628 } while (0)
3629 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3630 index 5dbf13f..1a60561 100644
3631 --- a/arch/arm/mm/fault.c
3632 +++ b/arch/arm/mm/fault.c
3633 @@ -25,6 +25,7 @@
3634 #include <asm/system_misc.h>
3635 #include <asm/system_info.h>
3636 #include <asm/tlbflush.h>
3637 +#include <asm/sections.h>
3638
3639 #include "fault.h"
3640
3641 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3642 if (fixup_exception(regs))
3643 return;
3644
3645 +#ifdef CONFIG_PAX_KERNEXEC
3646 + if ((fsr & FSR_WRITE) &&
3647 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3648 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3649 + {
3650 + if (current->signal->curr_ip)
3651 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3652 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3653 + else
3654 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3655 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3656 + }
3657 +#endif
3658 +
3659 /*
3660 * No handler, we'll have to terminate things with extreme prejudice.
3661 */
3662 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3663 }
3664 #endif
3665
3666 +#ifdef CONFIG_PAX_PAGEEXEC
3667 + if (fsr & FSR_LNX_PF) {
3668 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3669 + do_group_exit(SIGKILL);
3670 + }
3671 +#endif
3672 +
3673 tsk->thread.address = addr;
3674 tsk->thread.error_code = fsr;
3675 tsk->thread.trap_no = 14;
3676 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3677 }
3678 #endif /* CONFIG_MMU */
3679
3680 +#ifdef CONFIG_PAX_PAGEEXEC
3681 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3682 +{
3683 + long i;
3684 +
3685 + printk(KERN_ERR "PAX: bytes at PC: ");
3686 + for (i = 0; i < 20; i++) {
3687 + unsigned char c;
3688 + if (get_user(c, (__force unsigned char __user *)pc+i))
3689 + printk(KERN_CONT "?? ");
3690 + else
3691 + printk(KERN_CONT "%02x ", c);
3692 + }
3693 + printk("\n");
3694 +
3695 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3696 + for (i = -1; i < 20; i++) {
3697 + unsigned long c;
3698 + if (get_user(c, (__force unsigned long __user *)sp+i))
3699 + printk(KERN_CONT "???????? ");
3700 + else
3701 + printk(KERN_CONT "%08lx ", c);
3702 + }
3703 + printk("\n");
3704 +}
3705 +#endif
3706 +
3707 /*
3708 * First Level Translation Fault Handler
3709 *
3710 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3711 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3712 struct siginfo info;
3713
3714 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3715 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3716 + if (current->signal->curr_ip)
3717 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3718 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3719 + else
3720 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3721 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3722 + goto die;
3723 + }
3724 +#endif
3725 +
3726 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3727 return;
3728
3729 +die:
3730 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3731 inf->name, fsr, addr);
3732
3733 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3734 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3735 struct siginfo info;
3736
3737 + if (user_mode(regs)) {
3738 + if (addr == 0xffff0fe0UL) {
3739 + /*
3740 + * PaX: __kuser_get_tls emulation
3741 + */
3742 + regs->ARM_r0 = current_thread_info()->tp_value;
3743 + regs->ARM_pc = regs->ARM_lr;
3744 + return;
3745 + }
3746 + }
3747 +
3748 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3749 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3750 + if (current->signal->curr_ip)
3751 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3752 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3753 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3754 + else
3755 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3756 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3757 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3758 + goto die;
3759 + }
3760 +#endif
3761 +
3762 +#ifdef CONFIG_PAX_REFCOUNT
3763 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3764 + unsigned int bkpt;
3765 +
3766 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3767 + current->thread.error_code = ifsr;
3768 + current->thread.trap_no = 0;
3769 + pax_report_refcount_overflow(regs);
3770 + fixup_exception(regs);
3771 + return;
3772 + }
3773 + }
3774 +#endif
3775 +
3776 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3777 return;
3778
3779 +die:
3780 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3781 inf->name, ifsr, addr);
3782
3783 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3784 index cf08bdf..772656c 100644
3785 --- a/arch/arm/mm/fault.h
3786 +++ b/arch/arm/mm/fault.h
3787 @@ -3,6 +3,7 @@
3788
3789 /*
3790 * Fault status register encodings. We steal bit 31 for our own purposes.
3791 + * Set when the FSR value is from an instruction fault.
3792 */
3793 #define FSR_LNX_PF (1 << 31)
3794 #define FSR_WRITE (1 << 11)
3795 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3796 }
3797 #endif
3798
3799 +/* valid for LPAE and !LPAE */
3800 +static inline int is_xn_fault(unsigned int fsr)
3801 +{
3802 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3803 +}
3804 +
3805 +static inline int is_domain_fault(unsigned int fsr)
3806 +{
3807 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3808 +}
3809 +
3810 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3811 unsigned long search_exception_table(unsigned long addr);
3812
3813 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3814 index 0ecc43f..190b956 100644
3815 --- a/arch/arm/mm/init.c
3816 +++ b/arch/arm/mm/init.c
3817 @@ -30,6 +30,8 @@
3818 #include <asm/setup.h>
3819 #include <asm/tlb.h>
3820 #include <asm/fixmap.h>
3821 +#include <asm/system_info.h>
3822 +#include <asm/cp15.h>
3823
3824 #include <asm/mach/arch.h>
3825 #include <asm/mach/map.h>
3826 @@ -726,7 +728,46 @@ void free_initmem(void)
3827 {
3828 #ifdef CONFIG_HAVE_TCM
3829 extern char __tcm_start, __tcm_end;
3830 +#endif
3831
3832 +#ifdef CONFIG_PAX_KERNEXEC
3833 + unsigned long addr;
3834 + pgd_t *pgd;
3835 + pud_t *pud;
3836 + pmd_t *pmd;
3837 + int cpu_arch = cpu_architecture();
3838 + unsigned int cr = get_cr();
3839 +
3840 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3841 + /* make pages tables, etc before .text NX */
3842 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3843 + pgd = pgd_offset_k(addr);
3844 + pud = pud_offset(pgd, addr);
3845 + pmd = pmd_offset(pud, addr);
3846 + __section_update(pmd, addr, PMD_SECT_XN);
3847 + }
3848 + /* make init NX */
3849 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3850 + pgd = pgd_offset_k(addr);
3851 + pud = pud_offset(pgd, addr);
3852 + pmd = pmd_offset(pud, addr);
3853 + __section_update(pmd, addr, PMD_SECT_XN);
3854 + }
3855 + /* make kernel code/rodata RX */
3856 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3857 + pgd = pgd_offset_k(addr);
3858 + pud = pud_offset(pgd, addr);
3859 + pmd = pmd_offset(pud, addr);
3860 +#ifdef CONFIG_ARM_LPAE
3861 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3862 +#else
3863 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3864 +#endif
3865 + }
3866 + }
3867 +#endif
3868 +
3869 +#ifdef CONFIG_HAVE_TCM
3870 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3871 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
3872 #endif
3873 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3874 index 04d9006..c547d85 100644
3875 --- a/arch/arm/mm/ioremap.c
3876 +++ b/arch/arm/mm/ioremap.c
3877 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3878 unsigned int mtype;
3879
3880 if (cached)
3881 - mtype = MT_MEMORY;
3882 + mtype = MT_MEMORY_RX;
3883 else
3884 - mtype = MT_MEMORY_NONCACHED;
3885 + mtype = MT_MEMORY_NONCACHED_RX;
3886
3887 return __arm_ioremap_caller(phys_addr, size, mtype,
3888 __builtin_return_address(0));
3889 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3890 index 10062ce..8695745 100644
3891 --- a/arch/arm/mm/mmap.c
3892 +++ b/arch/arm/mm/mmap.c
3893 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3894 struct vm_area_struct *vma;
3895 int do_align = 0;
3896 int aliasing = cache_is_vipt_aliasing();
3897 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3898 struct vm_unmapped_area_info info;
3899
3900 /*
3901 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3902 if (len > TASK_SIZE)
3903 return -ENOMEM;
3904
3905 +#ifdef CONFIG_PAX_RANDMMAP
3906 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3907 +#endif
3908 +
3909 if (addr) {
3910 if (do_align)
3911 addr = COLOUR_ALIGN(addr, pgoff);
3912 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3913 addr = PAGE_ALIGN(addr);
3914
3915 vma = find_vma(mm, addr);
3916 - if (TASK_SIZE - len >= addr &&
3917 - (!vma || addr + len <= vma->vm_start))
3918 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3919 return addr;
3920 }
3921
3922 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3923 info.high_limit = TASK_SIZE;
3924 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3925 info.align_offset = pgoff << PAGE_SHIFT;
3926 + info.threadstack_offset = offset;
3927 return vm_unmapped_area(&info);
3928 }
3929
3930 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3931 unsigned long addr = addr0;
3932 int do_align = 0;
3933 int aliasing = cache_is_vipt_aliasing();
3934 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3935 struct vm_unmapped_area_info info;
3936
3937 /*
3938 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3939 return addr;
3940 }
3941
3942 +#ifdef CONFIG_PAX_RANDMMAP
3943 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3944 +#endif
3945 +
3946 /* requesting a specific address */
3947 if (addr) {
3948 if (do_align)
3949 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3950 else
3951 addr = PAGE_ALIGN(addr);
3952 vma = find_vma(mm, addr);
3953 - if (TASK_SIZE - len >= addr &&
3954 - (!vma || addr + len <= vma->vm_start))
3955 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3956 return addr;
3957 }
3958
3959 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3960 info.high_limit = mm->mmap_base;
3961 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3962 info.align_offset = pgoff << PAGE_SHIFT;
3963 + info.threadstack_offset = offset;
3964 addr = vm_unmapped_area(&info);
3965
3966 /*
3967 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3968 {
3969 unsigned long random_factor = 0UL;
3970
3971 +#ifdef CONFIG_PAX_RANDMMAP
3972 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3973 +#endif
3974 +
3975 /* 8 bits of randomness in 20 address space bits */
3976 if ((current->flags & PF_RANDOMIZE) &&
3977 !(current->personality & ADDR_NO_RANDOMIZE))
3978 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3979
3980 if (mmap_is_legacy()) {
3981 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3982 +
3983 +#ifdef CONFIG_PAX_RANDMMAP
3984 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3985 + mm->mmap_base += mm->delta_mmap;
3986 +#endif
3987 +
3988 mm->get_unmapped_area = arch_get_unmapped_area;
3989 mm->unmap_area = arch_unmap_area;
3990 } else {
3991 mm->mmap_base = mmap_base(random_factor);
3992 +
3993 +#ifdef CONFIG_PAX_RANDMMAP
3994 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3995 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3996 +#endif
3997 +
3998 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3999 mm->unmap_area = arch_unmap_area_topdown;
4000 }
4001 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4002 index 4d409e6..f375351 100644
4003 --- a/arch/arm/mm/mmu.c
4004 +++ b/arch/arm/mm/mmu.c
4005 @@ -36,6 +36,22 @@
4006 #include "mm.h"
4007 #include "tcm.h"
4008
4009 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4010 +void modify_domain(unsigned int dom, unsigned int type)
4011 +{
4012 + struct thread_info *thread = current_thread_info();
4013 + unsigned int domain = thread->cpu_domain;
4014 + /*
4015 + * DOMAIN_MANAGER might be defined to some other value,
4016 + * use the arch-defined constant
4017 + */
4018 + domain &= ~domain_val(dom, 3);
4019 + thread->cpu_domain = domain | domain_val(dom, type);
4020 + set_domain(thread->cpu_domain);
4021 +}
4022 +EXPORT_SYMBOL(modify_domain);
4023 +#endif
4024 +
4025 /*
4026 * empty_zero_page is a special page that is used for
4027 * zero-initialized data and COW.
4028 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4029
4030 #endif /* ifdef CONFIG_CPU_CP15 / else */
4031
4032 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4033 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4034 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4035
4036 -static struct mem_type mem_types[] = {
4037 +#ifdef CONFIG_PAX_KERNEXEC
4038 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4039 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4040 +#else
4041 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4042 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4043 +#endif
4044 +
4045 +static struct mem_type mem_types[] __read_only = {
4046 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4047 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4048 L_PTE_SHARED,
4049 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4050 [MT_UNCACHED] = {
4051 .prot_pte = PROT_PTE_DEVICE,
4052 .prot_l1 = PMD_TYPE_TABLE,
4053 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4054 + .prot_sect = PROT_SECT_DEVICE,
4055 .domain = DOMAIN_IO,
4056 },
4057 [MT_CACHECLEAN] = {
4058 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4059 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4060 .domain = DOMAIN_KERNEL,
4061 },
4062 #ifndef CONFIG_ARM_LPAE
4063 [MT_MINICLEAN] = {
4064 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4065 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4066 .domain = DOMAIN_KERNEL,
4067 },
4068 #endif
4069 @@ -277,36 +301,65 @@ static struct mem_type mem_types[] = {
4070 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4071 L_PTE_RDONLY,
4072 .prot_l1 = PMD_TYPE_TABLE,
4073 - .domain = DOMAIN_USER,
4074 + .domain = DOMAIN_VECTORS,
4075 },
4076 [MT_HIGH_VECTORS] = {
4077 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4078 - L_PTE_USER | L_PTE_RDONLY,
4079 + /* we always want the vector page to be noaccess for userland on archs with
4080 + XN where we can enforce some reasonable measure of security
4081 + therefore, when kernexec is disabled, instead of L_PTE_USER | L_PTE_RDONLY
4082 + which turns into supervisor rwx, userland rx, we instead omit that entirely,
4083 + leaving it as supervisor rwx only
4084 + */
4085 +#ifdef CONFIG_PAX_KERNEXEC
4086 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_RDONLY,
4087 +#elif __LINUX_ARM_ARCH__ >= 6
4088 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4089 +#else
4090 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_USER | L_PTE_RDONLY,
4091 +#endif
4092 .prot_l1 = PMD_TYPE_TABLE,
4093 - .domain = DOMAIN_USER,
4094 + .domain = DOMAIN_VECTORS,
4095 },
4096 - [MT_MEMORY] = {
4097 + [MT_MEMORY_RWX] = {
4098 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4099 .prot_l1 = PMD_TYPE_TABLE,
4100 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4101 .domain = DOMAIN_KERNEL,
4102 },
4103 + [MT_MEMORY_RW] = {
4104 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4105 + .prot_l1 = PMD_TYPE_TABLE,
4106 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4107 + .domain = DOMAIN_KERNEL,
4108 + },
4109 + [MT_MEMORY_RX] = {
4110 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4111 + .prot_l1 = PMD_TYPE_TABLE,
4112 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4113 + .domain = DOMAIN_KERNEL,
4114 + },
4115 [MT_ROM] = {
4116 - .prot_sect = PMD_TYPE_SECT,
4117 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4118 .domain = DOMAIN_KERNEL,
4119 },
4120 - [MT_MEMORY_NONCACHED] = {
4121 + [MT_MEMORY_NONCACHED_RW] = {
4122 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4123 L_PTE_MT_BUFFERABLE,
4124 .prot_l1 = PMD_TYPE_TABLE,
4125 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4126 .domain = DOMAIN_KERNEL,
4127 },
4128 + [MT_MEMORY_NONCACHED_RX] = {
4129 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4130 + L_PTE_MT_BUFFERABLE,
4131 + .prot_l1 = PMD_TYPE_TABLE,
4132 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4133 + .domain = DOMAIN_KERNEL,
4134 + },
4135 [MT_MEMORY_DTCM] = {
4136 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4137 - L_PTE_XN,
4138 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4139 .prot_l1 = PMD_TYPE_TABLE,
4140 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4141 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4142 .domain = DOMAIN_KERNEL,
4143 },
4144 [MT_MEMORY_ITCM] = {
4145 @@ -316,10 +369,10 @@ static struct mem_type mem_types[] = {
4146 },
4147 [MT_MEMORY_SO] = {
4148 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4149 - L_PTE_MT_UNCACHED | L_PTE_XN,
4150 + L_PTE_MT_UNCACHED,
4151 .prot_l1 = PMD_TYPE_TABLE,
4152 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4153 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4154 + PMD_SECT_UNCACHED,
4155 .domain = DOMAIN_KERNEL,
4156 },
4157 [MT_MEMORY_DMA_READY] = {
4158 @@ -405,9 +458,35 @@ static void __init build_mem_type_table(void)
4159 * to prevent speculative instruction fetches.
4160 */
4161 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4162 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4163 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4164 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4165 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4166 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4167 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4168 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4169 +
4170 + /* Mark other regions on ARMv6+ as execute-never */
4171 +
4172 +#ifdef CONFIG_PAX_KERNEXEC
4173 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4174 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4175 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4176 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4177 +#ifndef CONFIG_ARM_LPAE
4178 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4179 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4180 +#endif
4181 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4182 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4183 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4184 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4185 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4186 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4187 +#endif
4188 +
4189 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4190 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4191 }
4192 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4193 /*
4194 @@ -468,6 +547,9 @@ static void __init build_mem_type_table(void)
4195 * from SVC mode and no access from userspace.
4196 */
4197 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4198 +#ifdef CONFIG_PAX_KERNEXEC
4199 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4200 +#endif
4201 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4202 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4203 #endif
4204 @@ -485,11 +567,17 @@ static void __init build_mem_type_table(void)
4205 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4206 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4207 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4208 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4209 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4210 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4211 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4212 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4213 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4214 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4215 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4216 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4217 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4218 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4219 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4220 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4221 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4222 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4223 }
4224 }
4225
4226 @@ -500,15 +588,20 @@ static void __init build_mem_type_table(void)
4227 if (cpu_arch >= CPU_ARCH_ARMv6) {
4228 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4229 /* Non-cacheable Normal is XCB = 001 */
4230 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4231 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4232 + PMD_SECT_BUFFERED;
4233 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4234 PMD_SECT_BUFFERED;
4235 } else {
4236 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4237 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4238 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4239 + PMD_SECT_TEX(1);
4240 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4241 PMD_SECT_TEX(1);
4242 }
4243 } else {
4244 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4245 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4246 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4247 }
4248
4249 #ifdef CONFIG_ARM_LPAE
4250 @@ -524,6 +617,8 @@ static void __init build_mem_type_table(void)
4251 vecs_pgprot |= PTE_EXT_AF;
4252 #endif
4253
4254 + user_pgprot |= __supported_pte_mask;
4255 +
4256 for (i = 0; i < 16; i++) {
4257 pteval_t v = pgprot_val(protection_map[i]);
4258 protection_map[i] = __pgprot(v | user_pgprot);
4259 @@ -541,10 +636,15 @@ static void __init build_mem_type_table(void)
4260
4261 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4262 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4263 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4264 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4265 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4266 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4267 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4268 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4269 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4270 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4271 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4272 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4273 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4274 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4275 mem_types[MT_ROM].prot_sect |= cp->pmd;
4276
4277 switch (cp->pmd) {
4278 @@ -1166,18 +1266,15 @@ void __init arm_mm_memblock_reserve(void)
4279 * called function. This means you can't use any function or debugging
4280 * method which may touch any device, otherwise the kernel _will_ crash.
4281 */
4282 +
4283 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4284 +
4285 static void __init devicemaps_init(struct machine_desc *mdesc)
4286 {
4287 struct map_desc map;
4288 unsigned long addr;
4289 - void *vectors;
4290
4291 - /*
4292 - * Allocate the vector page early.
4293 - */
4294 - vectors = early_alloc(PAGE_SIZE);
4295 -
4296 - early_trap_init(vectors);
4297 + early_trap_init(&vectors);
4298
4299 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4300 pmd_clear(pmd_off_k(addr));
4301 @@ -1217,7 +1314,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4302 * location (0xffff0000). If we aren't using high-vectors, also
4303 * create a mapping at the low-vectors virtual address.
4304 */
4305 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4306 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4307 map.virtual = 0xffff0000;
4308 map.length = PAGE_SIZE;
4309 map.type = MT_HIGH_VECTORS;
4310 @@ -1275,8 +1372,39 @@ static void __init map_lowmem(void)
4311 map.pfn = __phys_to_pfn(start);
4312 map.virtual = __phys_to_virt(start);
4313 map.length = end - start;
4314 - map.type = MT_MEMORY;
4315
4316 +#ifdef CONFIG_PAX_KERNEXEC
4317 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4318 + struct map_desc kernel;
4319 + struct map_desc initmap;
4320 +
4321 + /* when freeing initmem we will make this RW */
4322 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4323 + initmap.virtual = (unsigned long)__init_begin;
4324 + initmap.length = _sdata - __init_begin;
4325 + initmap.type = MT_MEMORY_RWX;
4326 + create_mapping(&initmap);
4327 +
4328 + /* when freeing initmem we will make this RX */
4329 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4330 + kernel.virtual = (unsigned long)_stext;
4331 + kernel.length = __init_begin - _stext;
4332 + kernel.type = MT_MEMORY_RWX;
4333 + create_mapping(&kernel);
4334 +
4335 + if (map.virtual < (unsigned long)_stext) {
4336 + map.length = (unsigned long)_stext - map.virtual;
4337 + map.type = MT_MEMORY_RWX;
4338 + create_mapping(&map);
4339 + }
4340 +
4341 + map.pfn = __phys_to_pfn(__pa(_sdata));
4342 + map.virtual = (unsigned long)_sdata;
4343 + map.length = end - __pa(_sdata);
4344 + }
4345 +#endif
4346 +
4347 + map.type = MT_MEMORY_RW;
4348 create_mapping(&map);
4349 }
4350 }
4351 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4352 index a5bc92d..0bb4730 100644
4353 --- a/arch/arm/plat-omap/sram.c
4354 +++ b/arch/arm/plat-omap/sram.c
4355 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4356 * Looks like we need to preserve some bootloader code at the
4357 * beginning of SRAM for jumping to flash for reboot to work...
4358 */
4359 + pax_open_kernel();
4360 memset_io(omap_sram_base + omap_sram_skip, 0,
4361 omap_sram_size - omap_sram_skip);
4362 + pax_close_kernel();
4363 }
4364 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4365 index ce6d763..cfea917 100644
4366 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4367 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4368 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4369 int (*started)(unsigned ch);
4370 int (*flush)(unsigned ch);
4371 int (*stop)(unsigned ch);
4372 -};
4373 +} __no_const;
4374
4375 extern void *samsung_dmadev_get_ops(void);
4376 extern void *s3c_dma_get_ops(void);
4377 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4378 index f4726dc..39ed646 100644
4379 --- a/arch/arm64/kernel/debug-monitors.c
4380 +++ b/arch/arm64/kernel/debug-monitors.c
4381 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4382 return NOTIFY_OK;
4383 }
4384
4385 -static struct notifier_block __cpuinitdata os_lock_nb = {
4386 +static struct notifier_block os_lock_nb = {
4387 .notifier_call = os_lock_notify,
4388 };
4389
4390 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4391 index 5ab825c..96aaec8 100644
4392 --- a/arch/arm64/kernel/hw_breakpoint.c
4393 +++ b/arch/arm64/kernel/hw_breakpoint.c
4394 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4395 return NOTIFY_OK;
4396 }
4397
4398 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4399 +static struct notifier_block hw_breakpoint_reset_nb = {
4400 .notifier_call = hw_breakpoint_reset_notify,
4401 };
4402
4403 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4404 index c3a58a1..78fbf54 100644
4405 --- a/arch/avr32/include/asm/cache.h
4406 +++ b/arch/avr32/include/asm/cache.h
4407 @@ -1,8 +1,10 @@
4408 #ifndef __ASM_AVR32_CACHE_H
4409 #define __ASM_AVR32_CACHE_H
4410
4411 +#include <linux/const.h>
4412 +
4413 #define L1_CACHE_SHIFT 5
4414 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4415 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4416
4417 /*
4418 * Memory returned by kmalloc() may be used for DMA, so we must make
4419 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4420 index d232888..87c8df1 100644
4421 --- a/arch/avr32/include/asm/elf.h
4422 +++ b/arch/avr32/include/asm/elf.h
4423 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4424 the loader. We need to make sure that it is out of the way of the program
4425 that it will "exec", and that there is sufficient room for the brk. */
4426
4427 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4428 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4429
4430 +#ifdef CONFIG_PAX_ASLR
4431 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4432 +
4433 +#define PAX_DELTA_MMAP_LEN 15
4434 +#define PAX_DELTA_STACK_LEN 15
4435 +#endif
4436
4437 /* This yields a mask that user programs can use to figure out what
4438 instruction set this CPU supports. This could be done in user space,
4439 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4440 index 479330b..53717a8 100644
4441 --- a/arch/avr32/include/asm/kmap_types.h
4442 +++ b/arch/avr32/include/asm/kmap_types.h
4443 @@ -2,9 +2,9 @@
4444 #define __ASM_AVR32_KMAP_TYPES_H
4445
4446 #ifdef CONFIG_DEBUG_HIGHMEM
4447 -# define KM_TYPE_NR 29
4448 +# define KM_TYPE_NR 30
4449 #else
4450 -# define KM_TYPE_NR 14
4451 +# define KM_TYPE_NR 15
4452 #endif
4453
4454 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4455 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4456 index b2f2d2d..d1c85cb 100644
4457 --- a/arch/avr32/mm/fault.c
4458 +++ b/arch/avr32/mm/fault.c
4459 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4460
4461 int exception_trace = 1;
4462
4463 +#ifdef CONFIG_PAX_PAGEEXEC
4464 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4465 +{
4466 + unsigned long i;
4467 +
4468 + printk(KERN_ERR "PAX: bytes at PC: ");
4469 + for (i = 0; i < 20; i++) {
4470 + unsigned char c;
4471 + if (get_user(c, (unsigned char *)pc+i))
4472 + printk(KERN_CONT "???????? ");
4473 + else
4474 + printk(KERN_CONT "%02x ", c);
4475 + }
4476 + printk("\n");
4477 +}
4478 +#endif
4479 +
4480 /*
4481 * This routine handles page faults. It determines the address and the
4482 * problem, and then passes it off to one of the appropriate routines.
4483 @@ -174,6 +191,16 @@ bad_area:
4484 up_read(&mm->mmap_sem);
4485
4486 if (user_mode(regs)) {
4487 +
4488 +#ifdef CONFIG_PAX_PAGEEXEC
4489 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4490 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4491 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4492 + do_group_exit(SIGKILL);
4493 + }
4494 + }
4495 +#endif
4496 +
4497 if (exception_trace && printk_ratelimit())
4498 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4499 "sp %08lx ecr %lu\n",
4500 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4501 index 568885a..f8008df 100644
4502 --- a/arch/blackfin/include/asm/cache.h
4503 +++ b/arch/blackfin/include/asm/cache.h
4504 @@ -7,6 +7,7 @@
4505 #ifndef __ARCH_BLACKFIN_CACHE_H
4506 #define __ARCH_BLACKFIN_CACHE_H
4507
4508 +#include <linux/const.h>
4509 #include <linux/linkage.h> /* for asmlinkage */
4510
4511 /*
4512 @@ -14,7 +15,7 @@
4513 * Blackfin loads 32 bytes for cache
4514 */
4515 #define L1_CACHE_SHIFT 5
4516 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4517 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4518 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4519
4520 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4521 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4522 index aea2718..3639a60 100644
4523 --- a/arch/cris/include/arch-v10/arch/cache.h
4524 +++ b/arch/cris/include/arch-v10/arch/cache.h
4525 @@ -1,8 +1,9 @@
4526 #ifndef _ASM_ARCH_CACHE_H
4527 #define _ASM_ARCH_CACHE_H
4528
4529 +#include <linux/const.h>
4530 /* Etrax 100LX have 32-byte cache-lines. */
4531 -#define L1_CACHE_BYTES 32
4532 #define L1_CACHE_SHIFT 5
4533 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4534
4535 #endif /* _ASM_ARCH_CACHE_H */
4536 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4537 index 7caf25d..ee65ac5 100644
4538 --- a/arch/cris/include/arch-v32/arch/cache.h
4539 +++ b/arch/cris/include/arch-v32/arch/cache.h
4540 @@ -1,11 +1,12 @@
4541 #ifndef _ASM_CRIS_ARCH_CACHE_H
4542 #define _ASM_CRIS_ARCH_CACHE_H
4543
4544 +#include <linux/const.h>
4545 #include <arch/hwregs/dma.h>
4546
4547 /* A cache-line is 32 bytes. */
4548 -#define L1_CACHE_BYTES 32
4549 #define L1_CACHE_SHIFT 5
4550 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4551
4552 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4553
4554 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4555 index b86329d..6709906 100644
4556 --- a/arch/frv/include/asm/atomic.h
4557 +++ b/arch/frv/include/asm/atomic.h
4558 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4559 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4560 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4561
4562 +#define atomic64_read_unchecked(v) atomic64_read(v)
4563 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4564 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4565 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4566 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4567 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4568 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4569 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4570 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4571 +
4572 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4573 {
4574 int c, old;
4575 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4576 index 2797163..c2a401d 100644
4577 --- a/arch/frv/include/asm/cache.h
4578 +++ b/arch/frv/include/asm/cache.h
4579 @@ -12,10 +12,11 @@
4580 #ifndef __ASM_CACHE_H
4581 #define __ASM_CACHE_H
4582
4583 +#include <linux/const.h>
4584
4585 /* bytes per L1 cache line */
4586 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4587 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4588 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4589
4590 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4591 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4592 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4593 index 43901f2..0d8b865 100644
4594 --- a/arch/frv/include/asm/kmap_types.h
4595 +++ b/arch/frv/include/asm/kmap_types.h
4596 @@ -2,6 +2,6 @@
4597 #ifndef _ASM_KMAP_TYPES_H
4598 #define _ASM_KMAP_TYPES_H
4599
4600 -#define KM_TYPE_NR 17
4601 +#define KM_TYPE_NR 18
4602
4603 #endif
4604 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4605 index 836f147..4cf23f5 100644
4606 --- a/arch/frv/mm/elf-fdpic.c
4607 +++ b/arch/frv/mm/elf-fdpic.c
4608 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4609 {
4610 struct vm_area_struct *vma;
4611 struct vm_unmapped_area_info info;
4612 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4613
4614 if (len > TASK_SIZE)
4615 return -ENOMEM;
4616 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4617 if (addr) {
4618 addr = PAGE_ALIGN(addr);
4619 vma = find_vma(current->mm, addr);
4620 - if (TASK_SIZE - len >= addr &&
4621 - (!vma || addr + len <= vma->vm_start))
4622 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4623 goto success;
4624 }
4625
4626 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4627 info.high_limit = (current->mm->start_stack - 0x00200000);
4628 info.align_mask = 0;
4629 info.align_offset = 0;
4630 + info.threadstack_offset = offset;
4631 addr = vm_unmapped_area(&info);
4632 if (!(addr & ~PAGE_MASK))
4633 goto success;
4634 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4635 index f4ca594..adc72fd6 100644
4636 --- a/arch/hexagon/include/asm/cache.h
4637 +++ b/arch/hexagon/include/asm/cache.h
4638 @@ -21,9 +21,11 @@
4639 #ifndef __ASM_CACHE_H
4640 #define __ASM_CACHE_H
4641
4642 +#include <linux/const.h>
4643 +
4644 /* Bytes per L1 cache line */
4645 -#define L1_CACHE_SHIFT (5)
4646 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4647 +#define L1_CACHE_SHIFT 5
4648 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4649
4650 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4651 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4652 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4653 index 6e6fe18..a6ae668 100644
4654 --- a/arch/ia64/include/asm/atomic.h
4655 +++ b/arch/ia64/include/asm/atomic.h
4656 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4657 #define atomic64_inc(v) atomic64_add(1, (v))
4658 #define atomic64_dec(v) atomic64_sub(1, (v))
4659
4660 +#define atomic64_read_unchecked(v) atomic64_read(v)
4661 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4662 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4663 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4664 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4665 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4666 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4667 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4668 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4669 +
4670 /* Atomic operations are already serializing */
4671 #define smp_mb__before_atomic_dec() barrier()
4672 #define smp_mb__after_atomic_dec() barrier()
4673 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4674 index 988254a..e1ee885 100644
4675 --- a/arch/ia64/include/asm/cache.h
4676 +++ b/arch/ia64/include/asm/cache.h
4677 @@ -1,6 +1,7 @@
4678 #ifndef _ASM_IA64_CACHE_H
4679 #define _ASM_IA64_CACHE_H
4680
4681 +#include <linux/const.h>
4682
4683 /*
4684 * Copyright (C) 1998-2000 Hewlett-Packard Co
4685 @@ -9,7 +10,7 @@
4686
4687 /* Bytes per L1 (data) cache line. */
4688 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4689 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4690 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4691
4692 #ifdef CONFIG_SMP
4693 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4694 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4695 index 5a83c5c..4d7f553 100644
4696 --- a/arch/ia64/include/asm/elf.h
4697 +++ b/arch/ia64/include/asm/elf.h
4698 @@ -42,6 +42,13 @@
4699 */
4700 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4701
4702 +#ifdef CONFIG_PAX_ASLR
4703 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4704 +
4705 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4706 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4707 +#endif
4708 +
4709 #define PT_IA_64_UNWIND 0x70000001
4710
4711 /* IA-64 relocations: */
4712 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4713 index 96a8d92..617a1cf 100644
4714 --- a/arch/ia64/include/asm/pgalloc.h
4715 +++ b/arch/ia64/include/asm/pgalloc.h
4716 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4717 pgd_val(*pgd_entry) = __pa(pud);
4718 }
4719
4720 +static inline void
4721 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4722 +{
4723 + pgd_populate(mm, pgd_entry, pud);
4724 +}
4725 +
4726 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4727 {
4728 return quicklist_alloc(0, GFP_KERNEL, NULL);
4729 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4730 pud_val(*pud_entry) = __pa(pmd);
4731 }
4732
4733 +static inline void
4734 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4735 +{
4736 + pud_populate(mm, pud_entry, pmd);
4737 +}
4738 +
4739 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4740 {
4741 return quicklist_alloc(0, GFP_KERNEL, NULL);
4742 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4743 index 815810c..d60bd4c 100644
4744 --- a/arch/ia64/include/asm/pgtable.h
4745 +++ b/arch/ia64/include/asm/pgtable.h
4746 @@ -12,7 +12,7 @@
4747 * David Mosberger-Tang <davidm@hpl.hp.com>
4748 */
4749
4750 -
4751 +#include <linux/const.h>
4752 #include <asm/mman.h>
4753 #include <asm/page.h>
4754 #include <asm/processor.h>
4755 @@ -142,6 +142,17 @@
4756 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4757 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4758 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4759 +
4760 +#ifdef CONFIG_PAX_PAGEEXEC
4761 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4762 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4763 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4764 +#else
4765 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4766 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4767 +# define PAGE_COPY_NOEXEC PAGE_COPY
4768 +#endif
4769 +
4770 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4771 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4772 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4773 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4774 index 54ff557..70c88b7 100644
4775 --- a/arch/ia64/include/asm/spinlock.h
4776 +++ b/arch/ia64/include/asm/spinlock.h
4777 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4778 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4779
4780 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4781 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4782 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4783 }
4784
4785 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4786 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4787 index 449c8c0..18965fb 100644
4788 --- a/arch/ia64/include/asm/uaccess.h
4789 +++ b/arch/ia64/include/asm/uaccess.h
4790 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4791 static inline unsigned long
4792 __copy_to_user (void __user *to, const void *from, unsigned long count)
4793 {
4794 + if (count > INT_MAX)
4795 + return count;
4796 +
4797 + if (!__builtin_constant_p(count))
4798 + check_object_size(from, count, true);
4799 +
4800 return __copy_user(to, (__force void __user *) from, count);
4801 }
4802
4803 static inline unsigned long
4804 __copy_from_user (void *to, const void __user *from, unsigned long count)
4805 {
4806 + if (count > INT_MAX)
4807 + return count;
4808 +
4809 + if (!__builtin_constant_p(count))
4810 + check_object_size(to, count, false);
4811 +
4812 return __copy_user((__force void __user *) to, from, count);
4813 }
4814
4815 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4816 ({ \
4817 void __user *__cu_to = (to); \
4818 const void *__cu_from = (from); \
4819 - long __cu_len = (n); \
4820 + unsigned long __cu_len = (n); \
4821 \
4822 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4823 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4824 + if (!__builtin_constant_p(n)) \
4825 + check_object_size(__cu_from, __cu_len, true); \
4826 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4827 + } \
4828 __cu_len; \
4829 })
4830
4831 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4832 ({ \
4833 void *__cu_to = (to); \
4834 const void __user *__cu_from = (from); \
4835 - long __cu_len = (n); \
4836 + unsigned long __cu_len = (n); \
4837 \
4838 __chk_user_ptr(__cu_from); \
4839 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4840 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4841 + if (!__builtin_constant_p(n)) \
4842 + check_object_size(__cu_to, __cu_len, false); \
4843 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4844 + } \
4845 __cu_len; \
4846 })
4847
4848 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4849 index 2d67317..07d8bfa 100644
4850 --- a/arch/ia64/kernel/err_inject.c
4851 +++ b/arch/ia64/kernel/err_inject.c
4852 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4853 return NOTIFY_OK;
4854 }
4855
4856 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4857 +static struct notifier_block err_inject_cpu_notifier =
4858 {
4859 .notifier_call = err_inject_cpu_callback,
4860 };
4861 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4862 index d7396db..b33e873 100644
4863 --- a/arch/ia64/kernel/mca.c
4864 +++ b/arch/ia64/kernel/mca.c
4865 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4866 return NOTIFY_OK;
4867 }
4868
4869 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4870 +static struct notifier_block mca_cpu_notifier = {
4871 .notifier_call = mca_cpu_callback
4872 };
4873
4874 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4875 index 24603be..948052d 100644
4876 --- a/arch/ia64/kernel/module.c
4877 +++ b/arch/ia64/kernel/module.c
4878 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4879 void
4880 module_free (struct module *mod, void *module_region)
4881 {
4882 - if (mod && mod->arch.init_unw_table &&
4883 - module_region == mod->module_init) {
4884 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4885 unw_remove_unwind_table(mod->arch.init_unw_table);
4886 mod->arch.init_unw_table = NULL;
4887 }
4888 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4889 }
4890
4891 static inline int
4892 +in_init_rx (const struct module *mod, uint64_t addr)
4893 +{
4894 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4895 +}
4896 +
4897 +static inline int
4898 +in_init_rw (const struct module *mod, uint64_t addr)
4899 +{
4900 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4901 +}
4902 +
4903 +static inline int
4904 in_init (const struct module *mod, uint64_t addr)
4905 {
4906 - return addr - (uint64_t) mod->module_init < mod->init_size;
4907 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4908 +}
4909 +
4910 +static inline int
4911 +in_core_rx (const struct module *mod, uint64_t addr)
4912 +{
4913 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4914 +}
4915 +
4916 +static inline int
4917 +in_core_rw (const struct module *mod, uint64_t addr)
4918 +{
4919 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4920 }
4921
4922 static inline int
4923 in_core (const struct module *mod, uint64_t addr)
4924 {
4925 - return addr - (uint64_t) mod->module_core < mod->core_size;
4926 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4927 }
4928
4929 static inline int
4930 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4931 break;
4932
4933 case RV_BDREL:
4934 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4935 + if (in_init_rx(mod, val))
4936 + val -= (uint64_t) mod->module_init_rx;
4937 + else if (in_init_rw(mod, val))
4938 + val -= (uint64_t) mod->module_init_rw;
4939 + else if (in_core_rx(mod, val))
4940 + val -= (uint64_t) mod->module_core_rx;
4941 + else if (in_core_rw(mod, val))
4942 + val -= (uint64_t) mod->module_core_rw;
4943 break;
4944
4945 case RV_LTV:
4946 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4947 * addresses have been selected...
4948 */
4949 uint64_t gp;
4950 - if (mod->core_size > MAX_LTOFF)
4951 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4952 /*
4953 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4954 * at the end of the module.
4955 */
4956 - gp = mod->core_size - MAX_LTOFF / 2;
4957 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4958 else
4959 - gp = mod->core_size / 2;
4960 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4961 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4962 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4963 mod->arch.gp = gp;
4964 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4965 }
4966 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4967 index 2b3c2d7..a318d84 100644
4968 --- a/arch/ia64/kernel/palinfo.c
4969 +++ b/arch/ia64/kernel/palinfo.c
4970 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4971 return NOTIFY_OK;
4972 }
4973
4974 -static struct notifier_block __refdata palinfo_cpu_notifier =
4975 +static struct notifier_block palinfo_cpu_notifier =
4976 {
4977 .notifier_call = palinfo_cpu_callback,
4978 .priority = 0,
4979 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4980 index 4bc580a..7767f24 100644
4981 --- a/arch/ia64/kernel/salinfo.c
4982 +++ b/arch/ia64/kernel/salinfo.c
4983 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4984 return NOTIFY_OK;
4985 }
4986
4987 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4988 +static struct notifier_block salinfo_cpu_notifier =
4989 {
4990 .notifier_call = salinfo_cpu_callback,
4991 .priority = 0,
4992 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4993 index 41e33f8..65180b2 100644
4994 --- a/arch/ia64/kernel/sys_ia64.c
4995 +++ b/arch/ia64/kernel/sys_ia64.c
4996 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4997 unsigned long align_mask = 0;
4998 struct mm_struct *mm = current->mm;
4999 struct vm_unmapped_area_info info;
5000 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5001
5002 if (len > RGN_MAP_LIMIT)
5003 return -ENOMEM;
5004 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5005 if (REGION_NUMBER(addr) == RGN_HPAGE)
5006 addr = 0;
5007 #endif
5008 +
5009 +#ifdef CONFIG_PAX_RANDMMAP
5010 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5011 + addr = mm->free_area_cache;
5012 + else
5013 +#endif
5014 +
5015 if (!addr)
5016 addr = TASK_UNMAPPED_BASE;
5017
5018 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5019 info.high_limit = TASK_SIZE;
5020 info.align_mask = align_mask;
5021 info.align_offset = 0;
5022 + info.threadstack_offset = offset;
5023 return vm_unmapped_area(&info);
5024 }
5025
5026 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5027 index dc00b2c..cce53c2 100644
5028 --- a/arch/ia64/kernel/topology.c
5029 +++ b/arch/ia64/kernel/topology.c
5030 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5031 return NOTIFY_OK;
5032 }
5033
5034 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5035 +static struct notifier_block cache_cpu_notifier =
5036 {
5037 .notifier_call = cache_cpu_callback
5038 };
5039 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5040 index 0ccb28f..8992469 100644
5041 --- a/arch/ia64/kernel/vmlinux.lds.S
5042 +++ b/arch/ia64/kernel/vmlinux.lds.S
5043 @@ -198,7 +198,7 @@ SECTIONS {
5044 /* Per-cpu data: */
5045 . = ALIGN(PERCPU_PAGE_SIZE);
5046 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5047 - __phys_per_cpu_start = __per_cpu_load;
5048 + __phys_per_cpu_start = per_cpu_load;
5049 /*
5050 * ensure percpu data fits
5051 * into percpu page size
5052 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5053 index 6cf0341..d352594 100644
5054 --- a/arch/ia64/mm/fault.c
5055 +++ b/arch/ia64/mm/fault.c
5056 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5057 return pte_present(pte);
5058 }
5059
5060 +#ifdef CONFIG_PAX_PAGEEXEC
5061 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5062 +{
5063 + unsigned long i;
5064 +
5065 + printk(KERN_ERR "PAX: bytes at PC: ");
5066 + for (i = 0; i < 8; i++) {
5067 + unsigned int c;
5068 + if (get_user(c, (unsigned int *)pc+i))
5069 + printk(KERN_CONT "???????? ");
5070 + else
5071 + printk(KERN_CONT "%08x ", c);
5072 + }
5073 + printk("\n");
5074 +}
5075 +#endif
5076 +
5077 # define VM_READ_BIT 0
5078 # define VM_WRITE_BIT 1
5079 # define VM_EXEC_BIT 2
5080 @@ -149,8 +166,21 @@ retry:
5081 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5082 goto bad_area;
5083
5084 - if ((vma->vm_flags & mask) != mask)
5085 + if ((vma->vm_flags & mask) != mask) {
5086 +
5087 +#ifdef CONFIG_PAX_PAGEEXEC
5088 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5089 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5090 + goto bad_area;
5091 +
5092 + up_read(&mm->mmap_sem);
5093 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5094 + do_group_exit(SIGKILL);
5095 + }
5096 +#endif
5097 +
5098 goto bad_area;
5099 + }
5100
5101 /*
5102 * If for any reason at all we couldn't handle the fault, make
5103 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5104 index 76069c1..c2aa816 100644
5105 --- a/arch/ia64/mm/hugetlbpage.c
5106 +++ b/arch/ia64/mm/hugetlbpage.c
5107 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5108 unsigned long pgoff, unsigned long flags)
5109 {
5110 struct vm_unmapped_area_info info;
5111 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5112
5113 if (len > RGN_MAP_LIMIT)
5114 return -ENOMEM;
5115 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5116 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5117 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5118 info.align_offset = 0;
5119 + info.threadstack_offset = offset;
5120 return vm_unmapped_area(&info);
5121 }
5122
5123 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5124 index d1fe4b4..2628f37 100644
5125 --- a/arch/ia64/mm/init.c
5126 +++ b/arch/ia64/mm/init.c
5127 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5128 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5129 vma->vm_end = vma->vm_start + PAGE_SIZE;
5130 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5131 +
5132 +#ifdef CONFIG_PAX_PAGEEXEC
5133 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5134 + vma->vm_flags &= ~VM_EXEC;
5135 +
5136 +#ifdef CONFIG_PAX_MPROTECT
5137 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5138 + vma->vm_flags &= ~VM_MAYEXEC;
5139 +#endif
5140 +
5141 + }
5142 +#endif
5143 +
5144 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5145 down_write(&current->mm->mmap_sem);
5146 if (insert_vm_struct(current->mm, vma)) {
5147 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5148 index 40b3ee9..8c2c112 100644
5149 --- a/arch/m32r/include/asm/cache.h
5150 +++ b/arch/m32r/include/asm/cache.h
5151 @@ -1,8 +1,10 @@
5152 #ifndef _ASM_M32R_CACHE_H
5153 #define _ASM_M32R_CACHE_H
5154
5155 +#include <linux/const.h>
5156 +
5157 /* L1 cache line size */
5158 #define L1_CACHE_SHIFT 4
5159 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5160 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5161
5162 #endif /* _ASM_M32R_CACHE_H */
5163 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5164 index 82abd15..d95ae5d 100644
5165 --- a/arch/m32r/lib/usercopy.c
5166 +++ b/arch/m32r/lib/usercopy.c
5167 @@ -14,6 +14,9 @@
5168 unsigned long
5169 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5170 {
5171 + if ((long)n < 0)
5172 + return n;
5173 +
5174 prefetch(from);
5175 if (access_ok(VERIFY_WRITE, to, n))
5176 __copy_user(to,from,n);
5177 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5178 unsigned long
5179 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5180 {
5181 + if ((long)n < 0)
5182 + return n;
5183 +
5184 prefetchw(to);
5185 if (access_ok(VERIFY_READ, from, n))
5186 __copy_user_zeroing(to,from,n);
5187 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5188 index 0395c51..5f26031 100644
5189 --- a/arch/m68k/include/asm/cache.h
5190 +++ b/arch/m68k/include/asm/cache.h
5191 @@ -4,9 +4,11 @@
5192 #ifndef __ARCH_M68K_CACHE_H
5193 #define __ARCH_M68K_CACHE_H
5194
5195 +#include <linux/const.h>
5196 +
5197 /* bytes per L1 cache line */
5198 #define L1_CACHE_SHIFT 4
5199 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5200 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5201
5202 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5203
5204 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5205 index 3c52fa6..11b2ad8 100644
5206 --- a/arch/metag/mm/hugetlbpage.c
5207 +++ b/arch/metag/mm/hugetlbpage.c
5208 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5209 info.high_limit = TASK_SIZE;
5210 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5211 info.align_offset = 0;
5212 + info.threadstack_offset = 0;
5213 return vm_unmapped_area(&info);
5214 }
5215
5216 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5217 index 4efe96a..60e8699 100644
5218 --- a/arch/microblaze/include/asm/cache.h
5219 +++ b/arch/microblaze/include/asm/cache.h
5220 @@ -13,11 +13,12 @@
5221 #ifndef _ASM_MICROBLAZE_CACHE_H
5222 #define _ASM_MICROBLAZE_CACHE_H
5223
5224 +#include <linux/const.h>
5225 #include <asm/registers.h>
5226
5227 #define L1_CACHE_SHIFT 5
5228 /* word-granular cache in microblaze */
5229 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5230 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5231
5232 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5233
5234 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5235 index 08b6079..eb272cf 100644
5236 --- a/arch/mips/include/asm/atomic.h
5237 +++ b/arch/mips/include/asm/atomic.h
5238 @@ -21,6 +21,10 @@
5239 #include <asm/cmpxchg.h>
5240 #include <asm/war.h>
5241
5242 +#ifdef CONFIG_GENERIC_ATOMIC64
5243 +#include <asm-generic/atomic64.h>
5244 +#endif
5245 +
5246 #define ATOMIC_INIT(i) { (i) }
5247
5248 /*
5249 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5250 */
5251 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5252
5253 +#define atomic64_read_unchecked(v) atomic64_read(v)
5254 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5255 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5256 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5257 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5258 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5259 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5260 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5261 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5262 +
5263 #endif /* CONFIG_64BIT */
5264
5265 /*
5266 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5267 index b4db69f..8f3b093 100644
5268 --- a/arch/mips/include/asm/cache.h
5269 +++ b/arch/mips/include/asm/cache.h
5270 @@ -9,10 +9,11 @@
5271 #ifndef _ASM_CACHE_H
5272 #define _ASM_CACHE_H
5273
5274 +#include <linux/const.h>
5275 #include <kmalloc.h>
5276
5277 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5278 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5279 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5280
5281 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5282 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5283 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5284 index cf3ae24..238d22f 100644
5285 --- a/arch/mips/include/asm/elf.h
5286 +++ b/arch/mips/include/asm/elf.h
5287 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5288 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5289 #endif
5290
5291 +#ifdef CONFIG_PAX_ASLR
5292 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5293 +
5294 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5295 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5296 +#endif
5297 +
5298 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5299 struct linux_binprm;
5300 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5301 int uses_interp);
5302
5303 -struct mm_struct;
5304 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5305 -#define arch_randomize_brk arch_randomize_brk
5306 -
5307 #endif /* _ASM_ELF_H */
5308 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5309 index c1f6afa..38cc6e9 100644
5310 --- a/arch/mips/include/asm/exec.h
5311 +++ b/arch/mips/include/asm/exec.h
5312 @@ -12,6 +12,6 @@
5313 #ifndef _ASM_EXEC_H
5314 #define _ASM_EXEC_H
5315
5316 -extern unsigned long arch_align_stack(unsigned long sp);
5317 +#define arch_align_stack(x) ((x) & ~0xfUL)
5318
5319 #endif /* _ASM_EXEC_H */
5320 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5321 index f59552f..3abe9b9 100644
5322 --- a/arch/mips/include/asm/page.h
5323 +++ b/arch/mips/include/asm/page.h
5324 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5325 #ifdef CONFIG_CPU_MIPS32
5326 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5327 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5328 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5329 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5330 #else
5331 typedef struct { unsigned long long pte; } pte_t;
5332 #define pte_val(x) ((x).pte)
5333 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5334 index 881d18b..cea38bc 100644
5335 --- a/arch/mips/include/asm/pgalloc.h
5336 +++ b/arch/mips/include/asm/pgalloc.h
5337 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5338 {
5339 set_pud(pud, __pud((unsigned long)pmd));
5340 }
5341 +
5342 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5343 +{
5344 + pud_populate(mm, pud, pmd);
5345 +}
5346 #endif
5347
5348 /*
5349 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5350 index 895320e..bf63e10 100644
5351 --- a/arch/mips/include/asm/thread_info.h
5352 +++ b/arch/mips/include/asm/thread_info.h
5353 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5354 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5355 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5356 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5357 +/* li takes a 32bit immediate */
5358 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5359 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5360
5361 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5362 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5363 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5364 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5365 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5366 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5367 +
5368 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5369
5370 /* work to do in syscall_trace_leave() */
5371 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5372 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5373
5374 /* work to do on interrupt/exception return */
5375 #define _TIF_WORK_MASK \
5376 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5377 /* work to do on any return to u-space */
5378 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5379 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5380
5381 #endif /* __KERNEL__ */
5382
5383 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5384 index 1188e00..41cf144 100644
5385 --- a/arch/mips/kernel/binfmt_elfn32.c
5386 +++ b/arch/mips/kernel/binfmt_elfn32.c
5387 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5388 #undef ELF_ET_DYN_BASE
5389 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5390
5391 +#ifdef CONFIG_PAX_ASLR
5392 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5393 +
5394 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5395 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5396 +#endif
5397 +
5398 #include <asm/processor.h>
5399 #include <linux/module.h>
5400 #include <linux/elfcore.h>
5401 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5402 index 202e581..689ca79 100644
5403 --- a/arch/mips/kernel/binfmt_elfo32.c
5404 +++ b/arch/mips/kernel/binfmt_elfo32.c
5405 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5406 #undef ELF_ET_DYN_BASE
5407 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5408
5409 +#ifdef CONFIG_PAX_ASLR
5410 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5411 +
5412 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5413 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5414 +#endif
5415 +
5416 #include <asm/processor.h>
5417
5418 /*
5419 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5420 index c6a041d..b3e7318 100644
5421 --- a/arch/mips/kernel/process.c
5422 +++ b/arch/mips/kernel/process.c
5423 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5424 out:
5425 return pc;
5426 }
5427 -
5428 -/*
5429 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5430 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5431 - */
5432 -unsigned long arch_align_stack(unsigned long sp)
5433 -{
5434 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5435 - sp -= get_random_int() & ~PAGE_MASK;
5436 -
5437 - return sp & ALMASK;
5438 -}
5439 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5440 index 9c6299c..2fb4c22 100644
5441 --- a/arch/mips/kernel/ptrace.c
5442 +++ b/arch/mips/kernel/ptrace.c
5443 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5444 return arch;
5445 }
5446
5447 +#ifdef CONFIG_GRKERNSEC_SETXID
5448 +extern void gr_delayed_cred_worker(void);
5449 +#endif
5450 +
5451 /*
5452 * Notification of system call entry/exit
5453 * - triggered by current->work.syscall_trace
5454 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5455 /* do the secure computing check first */
5456 secure_computing_strict(regs->regs[2]);
5457
5458 +#ifdef CONFIG_GRKERNSEC_SETXID
5459 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5460 + gr_delayed_cred_worker();
5461 +#endif
5462 +
5463 if (!(current->ptrace & PT_PTRACED))
5464 goto out;
5465
5466 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5467 index 9b36424..e7f4154 100644
5468 --- a/arch/mips/kernel/scall32-o32.S
5469 +++ b/arch/mips/kernel/scall32-o32.S
5470 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5471
5472 stack_done:
5473 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5474 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5475 + li t1, _TIF_SYSCALL_WORK
5476 and t0, t1
5477 bnez t0, syscall_trace_entry # -> yes
5478
5479 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5480 index 97a5909..59622f8 100644
5481 --- a/arch/mips/kernel/scall64-64.S
5482 +++ b/arch/mips/kernel/scall64-64.S
5483 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5484
5485 sd a3, PT_R26(sp) # save a3 for syscall restarting
5486
5487 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5488 + li t1, _TIF_SYSCALL_WORK
5489 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5490 and t0, t1, t0
5491 bnez t0, syscall_trace_entry
5492 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5493 index edcb659..fb2ab09 100644
5494 --- a/arch/mips/kernel/scall64-n32.S
5495 +++ b/arch/mips/kernel/scall64-n32.S
5496 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5497
5498 sd a3, PT_R26(sp) # save a3 for syscall restarting
5499
5500 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5501 + li t1, _TIF_SYSCALL_WORK
5502 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5503 and t0, t1, t0
5504 bnez t0, n32_syscall_trace_entry
5505 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5506 index 74f485d..47d2c38 100644
5507 --- a/arch/mips/kernel/scall64-o32.S
5508 +++ b/arch/mips/kernel/scall64-o32.S
5509 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5510 PTR 4b, bad_stack
5511 .previous
5512
5513 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5514 + li t1, _TIF_SYSCALL_WORK
5515 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5516 and t0, t1, t0
5517 bnez t0, trace_a_syscall
5518 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5519 index 0fead53..eeb00a6 100644
5520 --- a/arch/mips/mm/fault.c
5521 +++ b/arch/mips/mm/fault.c
5522 @@ -27,6 +27,23 @@
5523 #include <asm/highmem.h> /* For VMALLOC_END */
5524 #include <linux/kdebug.h>
5525
5526 +#ifdef CONFIG_PAX_PAGEEXEC
5527 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5528 +{
5529 + unsigned long i;
5530 +
5531 + printk(KERN_ERR "PAX: bytes at PC: ");
5532 + for (i = 0; i < 5; i++) {
5533 + unsigned int c;
5534 + if (get_user(c, (unsigned int *)pc+i))
5535 + printk(KERN_CONT "???????? ");
5536 + else
5537 + printk(KERN_CONT "%08x ", c);
5538 + }
5539 + printk("\n");
5540 +}
5541 +#endif
5542 +
5543 /*
5544 * This routine handles page faults. It determines the address,
5545 * and the problem, and then passes it off to one of the appropriate
5546 @@ -196,6 +213,14 @@ bad_area:
5547 bad_area_nosemaphore:
5548 /* User mode accesses just cause a SIGSEGV */
5549 if (user_mode(regs)) {
5550 +
5551 +#ifdef CONFIG_PAX_PAGEEXEC
5552 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
5553 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
5554 + do_group_exit(SIGKILL);
5555 + }
5556 +#endif
5557 +
5558 tsk->thread.cp0_badvaddr = address;
5559 tsk->thread.error_code = write;
5560 #if 0
5561 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5562 index 7e5fe27..9656513 100644
5563 --- a/arch/mips/mm/mmap.c
5564 +++ b/arch/mips/mm/mmap.c
5565 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5566 struct vm_area_struct *vma;
5567 unsigned long addr = addr0;
5568 int do_color_align;
5569 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5570 struct vm_unmapped_area_info info;
5571
5572 if (unlikely(len > TASK_SIZE))
5573 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5574 do_color_align = 1;
5575
5576 /* requesting a specific address */
5577 +
5578 +#ifdef CONFIG_PAX_RANDMMAP
5579 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5580 +#endif
5581 +
5582 if (addr) {
5583 if (do_color_align)
5584 addr = COLOUR_ALIGN(addr, pgoff);
5585 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5586 addr = PAGE_ALIGN(addr);
5587
5588 vma = find_vma(mm, addr);
5589 - if (TASK_SIZE - len >= addr &&
5590 - (!vma || addr + len <= vma->vm_start))
5591 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5592 return addr;
5593 }
5594
5595 info.length = len;
5596 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5597 info.align_offset = pgoff << PAGE_SHIFT;
5598 + info.threadstack_offset = offset;
5599
5600 if (dir == DOWN) {
5601 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5602 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5603 {
5604 unsigned long random_factor = 0UL;
5605
5606 +#ifdef CONFIG_PAX_RANDMMAP
5607 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5608 +#endif
5609 +
5610 if (current->flags & PF_RANDOMIZE) {
5611 random_factor = get_random_int();
5612 random_factor = random_factor << PAGE_SHIFT;
5613 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5614
5615 if (mmap_is_legacy()) {
5616 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5617 +
5618 +#ifdef CONFIG_PAX_RANDMMAP
5619 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5620 + mm->mmap_base += mm->delta_mmap;
5621 +#endif
5622 +
5623 mm->get_unmapped_area = arch_get_unmapped_area;
5624 mm->unmap_area = arch_unmap_area;
5625 } else {
5626 mm->mmap_base = mmap_base(random_factor);
5627 +
5628 +#ifdef CONFIG_PAX_RANDMMAP
5629 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5630 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5631 +#endif
5632 +
5633 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5634 mm->unmap_area = arch_unmap_area_topdown;
5635 }
5636 }
5637
5638 -static inline unsigned long brk_rnd(void)
5639 -{
5640 - unsigned long rnd = get_random_int();
5641 -
5642 - rnd = rnd << PAGE_SHIFT;
5643 - /* 8MB for 32bit, 256MB for 64bit */
5644 - if (TASK_IS_32BIT_ADDR)
5645 - rnd = rnd & 0x7ffffful;
5646 - else
5647 - rnd = rnd & 0xffffffful;
5648 -
5649 - return rnd;
5650 -}
5651 -
5652 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5653 -{
5654 - unsigned long base = mm->brk;
5655 - unsigned long ret;
5656 -
5657 - ret = PAGE_ALIGN(base + brk_rnd());
5658 -
5659 - if (ret < mm->brk)
5660 - return mm->brk;
5661 -
5662 - return ret;
5663 -}
5664 -
5665 int __virt_addr_valid(const volatile void *kaddr)
5666 {
5667 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5668 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5669 index 967d144..db12197 100644
5670 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5671 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5672 @@ -11,12 +11,14 @@
5673 #ifndef _ASM_PROC_CACHE_H
5674 #define _ASM_PROC_CACHE_H
5675
5676 +#include <linux/const.h>
5677 +
5678 /* L1 cache */
5679
5680 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5681 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5682 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5683 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5684 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5685 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5686
5687 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5688 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5689 index bcb5df2..84fabd2 100644
5690 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5691 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5692 @@ -16,13 +16,15 @@
5693 #ifndef _ASM_PROC_CACHE_H
5694 #define _ASM_PROC_CACHE_H
5695
5696 +#include <linux/const.h>
5697 +
5698 /*
5699 * L1 cache
5700 */
5701 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5702 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5703 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5704 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5705 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5706 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5707
5708 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5709 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5710 index 4ce7a01..449202a 100644
5711 --- a/arch/openrisc/include/asm/cache.h
5712 +++ b/arch/openrisc/include/asm/cache.h
5713 @@ -19,11 +19,13 @@
5714 #ifndef __ASM_OPENRISC_CACHE_H
5715 #define __ASM_OPENRISC_CACHE_H
5716
5717 +#include <linux/const.h>
5718 +
5719 /* FIXME: How can we replace these with values from the CPU...
5720 * they shouldn't be hard-coded!
5721 */
5722
5723 -#define L1_CACHE_BYTES 16
5724 #define L1_CACHE_SHIFT 4
5725 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5726
5727 #endif /* __ASM_OPENRISC_CACHE_H */
5728 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5729 index 472886c..00e7df9 100644
5730 --- a/arch/parisc/include/asm/atomic.h
5731 +++ b/arch/parisc/include/asm/atomic.h
5732 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
5733 return dec;
5734 }
5735
5736 +#define atomic64_read_unchecked(v) atomic64_read(v)
5737 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5738 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5739 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5740 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5741 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5742 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5743 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5744 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5745 +
5746 #endif /* !CONFIG_64BIT */
5747
5748
5749 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5750 index 47f11c7..3420df2 100644
5751 --- a/arch/parisc/include/asm/cache.h
5752 +++ b/arch/parisc/include/asm/cache.h
5753 @@ -5,6 +5,7 @@
5754 #ifndef __ARCH_PARISC_CACHE_H
5755 #define __ARCH_PARISC_CACHE_H
5756
5757 +#include <linux/const.h>
5758
5759 /*
5760 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5761 @@ -15,13 +16,13 @@
5762 * just ruin performance.
5763 */
5764 #ifdef CONFIG_PA20
5765 -#define L1_CACHE_BYTES 64
5766 #define L1_CACHE_SHIFT 6
5767 #else
5768 -#define L1_CACHE_BYTES 32
5769 #define L1_CACHE_SHIFT 5
5770 #endif
5771
5772 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5773 +
5774 #ifndef __ASSEMBLY__
5775
5776 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5777 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5778 index ad2b503..bdf1651 100644
5779 --- a/arch/parisc/include/asm/elf.h
5780 +++ b/arch/parisc/include/asm/elf.h
5781 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5782
5783 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5784
5785 +#ifdef CONFIG_PAX_ASLR
5786 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5787 +
5788 +#define PAX_DELTA_MMAP_LEN 16
5789 +#define PAX_DELTA_STACK_LEN 16
5790 +#endif
5791 +
5792 /* This yields a mask that user programs can use to figure out what
5793 instruction set this CPU supports. This could be done in user space,
5794 but it's not easy, and we've already done it here. */
5795 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5796 index fc987a1..6e068ef 100644
5797 --- a/arch/parisc/include/asm/pgalloc.h
5798 +++ b/arch/parisc/include/asm/pgalloc.h
5799 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5800 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5801 }
5802
5803 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5804 +{
5805 + pgd_populate(mm, pgd, pmd);
5806 +}
5807 +
5808 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5809 {
5810 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5811 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5812 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5813 #define pmd_free(mm, x) do { } while (0)
5814 #define pgd_populate(mm, pmd, pte) BUG()
5815 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5816
5817 #endif
5818
5819 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5820 index 1e40d7f..a3eb445 100644
5821 --- a/arch/parisc/include/asm/pgtable.h
5822 +++ b/arch/parisc/include/asm/pgtable.h
5823 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5824 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5825 #define PAGE_COPY PAGE_EXECREAD
5826 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5827 +
5828 +#ifdef CONFIG_PAX_PAGEEXEC
5829 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5830 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5831 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5832 +#else
5833 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5834 +# define PAGE_COPY_NOEXEC PAGE_COPY
5835 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5836 +#endif
5837 +
5838 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5839 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5840 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5841 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5842 index e0a8235..ce2f1e1 100644
5843 --- a/arch/parisc/include/asm/uaccess.h
5844 +++ b/arch/parisc/include/asm/uaccess.h
5845 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5846 const void __user *from,
5847 unsigned long n)
5848 {
5849 - int sz = __compiletime_object_size(to);
5850 + size_t sz = __compiletime_object_size(to);
5851 int ret = -EFAULT;
5852
5853 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5854 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5855 ret = __copy_from_user(to, from, n);
5856 else
5857 copy_from_user_overflow();
5858 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5859 index 2a625fb..9908930 100644
5860 --- a/arch/parisc/kernel/module.c
5861 +++ b/arch/parisc/kernel/module.c
5862 @@ -98,16 +98,38 @@
5863
5864 /* three functions to determine where in the module core
5865 * or init pieces the location is */
5866 +static inline int in_init_rx(struct module *me, void *loc)
5867 +{
5868 + return (loc >= me->module_init_rx &&
5869 + loc < (me->module_init_rx + me->init_size_rx));
5870 +}
5871 +
5872 +static inline int in_init_rw(struct module *me, void *loc)
5873 +{
5874 + return (loc >= me->module_init_rw &&
5875 + loc < (me->module_init_rw + me->init_size_rw));
5876 +}
5877 +
5878 static inline int in_init(struct module *me, void *loc)
5879 {
5880 - return (loc >= me->module_init &&
5881 - loc <= (me->module_init + me->init_size));
5882 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5883 +}
5884 +
5885 +static inline int in_core_rx(struct module *me, void *loc)
5886 +{
5887 + return (loc >= me->module_core_rx &&
5888 + loc < (me->module_core_rx + me->core_size_rx));
5889 +}
5890 +
5891 +static inline int in_core_rw(struct module *me, void *loc)
5892 +{
5893 + return (loc >= me->module_core_rw &&
5894 + loc < (me->module_core_rw + me->core_size_rw));
5895 }
5896
5897 static inline int in_core(struct module *me, void *loc)
5898 {
5899 - return (loc >= me->module_core &&
5900 - loc <= (me->module_core + me->core_size));
5901 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5902 }
5903
5904 static inline int in_local(struct module *me, void *loc)
5905 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5906 }
5907
5908 /* align things a bit */
5909 - me->core_size = ALIGN(me->core_size, 16);
5910 - me->arch.got_offset = me->core_size;
5911 - me->core_size += gots * sizeof(struct got_entry);
5912 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5913 + me->arch.got_offset = me->core_size_rw;
5914 + me->core_size_rw += gots * sizeof(struct got_entry);
5915
5916 - me->core_size = ALIGN(me->core_size, 16);
5917 - me->arch.fdesc_offset = me->core_size;
5918 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5919 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5920 + me->arch.fdesc_offset = me->core_size_rw;
5921 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5922
5923 me->arch.got_max = gots;
5924 me->arch.fdesc_max = fdescs;
5925 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5926
5927 BUG_ON(value == 0);
5928
5929 - got = me->module_core + me->arch.got_offset;
5930 + got = me->module_core_rw + me->arch.got_offset;
5931 for (i = 0; got[i].addr; i++)
5932 if (got[i].addr == value)
5933 goto out;
5934 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5935 #ifdef CONFIG_64BIT
5936 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5937 {
5938 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5939 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5940
5941 if (!value) {
5942 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5943 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5944
5945 /* Create new one */
5946 fdesc->addr = value;
5947 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5948 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5949 return (Elf_Addr)fdesc;
5950 }
5951 #endif /* CONFIG_64BIT */
5952 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5953
5954 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5955 end = table + sechdrs[me->arch.unwind_section].sh_size;
5956 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5957 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5958
5959 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5960 me->arch.unwind_section, table, end, gp);
5961 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5962 index 5dfd248..64914ac 100644
5963 --- a/arch/parisc/kernel/sys_parisc.c
5964 +++ b/arch/parisc/kernel/sys_parisc.c
5965 @@ -33,9 +33,11 @@
5966 #include <linux/utsname.h>
5967 #include <linux/personality.h>
5968
5969 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5970 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5971 + unsigned long flags)
5972 {
5973 struct vm_unmapped_area_info info;
5974 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5975
5976 info.flags = 0;
5977 info.length = len;
5978 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5979 info.high_limit = TASK_SIZE;
5980 info.align_mask = 0;
5981 info.align_offset = 0;
5982 + info.threadstack_offset = offset;
5983 return vm_unmapped_area(&info);
5984 }
5985
5986 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5987 return (unsigned long) mapping >> 8;
5988 }
5989
5990 -static unsigned long get_shared_area(struct address_space *mapping,
5991 - unsigned long addr, unsigned long len, unsigned long pgoff)
5992 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5993 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5994 {
5995 struct vm_unmapped_area_info info;
5996 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5997
5998 info.flags = 0;
5999 info.length = len;
6000 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6001 info.high_limit = TASK_SIZE;
6002 info.align_mask = PAGE_MASK & (SHMLBA - 1);
6003 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
6004 + info.threadstack_offset = offset;
6005 return vm_unmapped_area(&info);
6006 }
6007
6008 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6009 return -EINVAL;
6010 return addr;
6011 }
6012 - if (!addr)
6013 + if (!addr) {
6014 addr = TASK_UNMAPPED_BASE;
6015
6016 +#ifdef CONFIG_PAX_RANDMMAP
6017 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
6018 + addr += current->mm->delta_mmap;
6019 +#endif
6020 +
6021 + }
6022 +
6023 if (filp) {
6024 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6025 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6026 } else if(flags & MAP_SHARED) {
6027 - addr = get_shared_area(NULL, addr, len, pgoff);
6028 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6029 } else {
6030 - addr = get_unshared_area(addr, len);
6031 + addr = get_unshared_area(filp, addr, len, flags);
6032 }
6033 return addr;
6034 }
6035 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6036 index 04e47c6..7a8faf6 100644
6037 --- a/arch/parisc/kernel/traps.c
6038 +++ b/arch/parisc/kernel/traps.c
6039 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6040
6041 down_read(&current->mm->mmap_sem);
6042 vma = find_vma(current->mm,regs->iaoq[0]);
6043 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6044 - && (vma->vm_flags & VM_EXEC)) {
6045 -
6046 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6047 fault_address = regs->iaoq[0];
6048 fault_space = regs->iasq[0];
6049
6050 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6051 index f247a34..dc0f219 100644
6052 --- a/arch/parisc/mm/fault.c
6053 +++ b/arch/parisc/mm/fault.c
6054 @@ -15,6 +15,7 @@
6055 #include <linux/sched.h>
6056 #include <linux/interrupt.h>
6057 #include <linux/module.h>
6058 +#include <linux/unistd.h>
6059
6060 #include <asm/uaccess.h>
6061 #include <asm/traps.h>
6062 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6063 static unsigned long
6064 parisc_acctyp(unsigned long code, unsigned int inst)
6065 {
6066 - if (code == 6 || code == 16)
6067 + if (code == 6 || code == 7 || code == 16)
6068 return VM_EXEC;
6069
6070 switch (inst & 0xf0000000) {
6071 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6072 }
6073 #endif
6074
6075 +#ifdef CONFIG_PAX_PAGEEXEC
6076 +/*
6077 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6078 + *
6079 + * returns 1 when task should be killed
6080 + * 2 when rt_sigreturn trampoline was detected
6081 + * 3 when unpatched PLT trampoline was detected
6082 + */
6083 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6084 +{
6085 +
6086 +#ifdef CONFIG_PAX_EMUPLT
6087 + int err;
6088 +
6089 + do { /* PaX: unpatched PLT emulation */
6090 + unsigned int bl, depwi;
6091 +
6092 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6093 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6094 +
6095 + if (err)
6096 + break;
6097 +
6098 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6099 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6100 +
6101 + err = get_user(ldw, (unsigned int *)addr);
6102 + err |= get_user(bv, (unsigned int *)(addr+4));
6103 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6104 +
6105 + if (err)
6106 + break;
6107 +
6108 + if (ldw == 0x0E801096U &&
6109 + bv == 0xEAC0C000U &&
6110 + ldw2 == 0x0E881095U)
6111 + {
6112 + unsigned int resolver, map;
6113 +
6114 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6115 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6116 + if (err)
6117 + break;
6118 +
6119 + regs->gr[20] = instruction_pointer(regs)+8;
6120 + regs->gr[21] = map;
6121 + regs->gr[22] = resolver;
6122 + regs->iaoq[0] = resolver | 3UL;
6123 + regs->iaoq[1] = regs->iaoq[0] + 4;
6124 + return 3;
6125 + }
6126 + }
6127 + } while (0);
6128 +#endif
6129 +
6130 +#ifdef CONFIG_PAX_EMUTRAMP
6131 +
6132 +#ifndef CONFIG_PAX_EMUSIGRT
6133 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6134 + return 1;
6135 +#endif
6136 +
6137 + do { /* PaX: rt_sigreturn emulation */
6138 + unsigned int ldi1, ldi2, bel, nop;
6139 +
6140 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6141 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6142 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6143 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6144 +
6145 + if (err)
6146 + break;
6147 +
6148 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6149 + ldi2 == 0x3414015AU &&
6150 + bel == 0xE4008200U &&
6151 + nop == 0x08000240U)
6152 + {
6153 + regs->gr[25] = (ldi1 & 2) >> 1;
6154 + regs->gr[20] = __NR_rt_sigreturn;
6155 + regs->gr[31] = regs->iaoq[1] + 16;
6156 + regs->sr[0] = regs->iasq[1];
6157 + regs->iaoq[0] = 0x100UL;
6158 + regs->iaoq[1] = regs->iaoq[0] + 4;
6159 + regs->iasq[0] = regs->sr[2];
6160 + regs->iasq[1] = regs->sr[2];
6161 + return 2;
6162 + }
6163 + } while (0);
6164 +#endif
6165 +
6166 + return 1;
6167 +}
6168 +
6169 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6170 +{
6171 + unsigned long i;
6172 +
6173 + printk(KERN_ERR "PAX: bytes at PC: ");
6174 + for (i = 0; i < 5; i++) {
6175 + unsigned int c;
6176 + if (get_user(c, (unsigned int *)pc+i))
6177 + printk(KERN_CONT "???????? ");
6178 + else
6179 + printk(KERN_CONT "%08x ", c);
6180 + }
6181 + printk("\n");
6182 +}
6183 +#endif
6184 +
6185 int fixup_exception(struct pt_regs *regs)
6186 {
6187 const struct exception_table_entry *fix;
6188 @@ -194,8 +305,33 @@ good_area:
6189
6190 acc_type = parisc_acctyp(code,regs->iir);
6191
6192 - if ((vma->vm_flags & acc_type) != acc_type)
6193 + if ((vma->vm_flags & acc_type) != acc_type) {
6194 +
6195 +#ifdef CONFIG_PAX_PAGEEXEC
6196 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6197 + (address & ~3UL) == instruction_pointer(regs))
6198 + {
6199 + up_read(&mm->mmap_sem);
6200 + switch (pax_handle_fetch_fault(regs)) {
6201 +
6202 +#ifdef CONFIG_PAX_EMUPLT
6203 + case 3:
6204 + return;
6205 +#endif
6206 +
6207 +#ifdef CONFIG_PAX_EMUTRAMP
6208 + case 2:
6209 + return;
6210 +#endif
6211 +
6212 + }
6213 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6214 + do_group_exit(SIGKILL);
6215 + }
6216 +#endif
6217 +
6218 goto bad_area;
6219 + }
6220
6221 /*
6222 * If for any reason at all we couldn't handle the fault, make
6223 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6224 index e3b1d41..8e81edf 100644
6225 --- a/arch/powerpc/include/asm/atomic.h
6226 +++ b/arch/powerpc/include/asm/atomic.h
6227 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6228 return t1;
6229 }
6230
6231 +#define atomic64_read_unchecked(v) atomic64_read(v)
6232 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6233 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6234 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6235 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6236 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6237 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6238 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6239 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6240 +
6241 #endif /* __powerpc64__ */
6242
6243 #endif /* __KERNEL__ */
6244 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6245 index 9e495c9..b6878e5 100644
6246 --- a/arch/powerpc/include/asm/cache.h
6247 +++ b/arch/powerpc/include/asm/cache.h
6248 @@ -3,6 +3,7 @@
6249
6250 #ifdef __KERNEL__
6251
6252 +#include <linux/const.h>
6253
6254 /* bytes per L1 cache line */
6255 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6256 @@ -22,7 +23,7 @@
6257 #define L1_CACHE_SHIFT 7
6258 #endif
6259
6260 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6261 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6262
6263 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6264
6265 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6266 index cc0655a..13eac2e 100644
6267 --- a/arch/powerpc/include/asm/elf.h
6268 +++ b/arch/powerpc/include/asm/elf.h
6269 @@ -28,8 +28,19 @@
6270 the loader. We need to make sure that it is out of the way of the program
6271 that it will "exec", and that there is sufficient room for the brk. */
6272
6273 -extern unsigned long randomize_et_dyn(unsigned long base);
6274 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6275 +#define ELF_ET_DYN_BASE (0x20000000)
6276 +
6277 +#ifdef CONFIG_PAX_ASLR
6278 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6279 +
6280 +#ifdef __powerpc64__
6281 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6282 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6283 +#else
6284 +#define PAX_DELTA_MMAP_LEN 15
6285 +#define PAX_DELTA_STACK_LEN 15
6286 +#endif
6287 +#endif
6288
6289 /*
6290 * Our registers are always unsigned longs, whether we're a 32 bit
6291 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6292 (0x7ff >> (PAGE_SHIFT - 12)) : \
6293 (0x3ffff >> (PAGE_SHIFT - 12)))
6294
6295 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6296 -#define arch_randomize_brk arch_randomize_brk
6297 -
6298 -
6299 #ifdef CONFIG_SPU_BASE
6300 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6301 #define NT_SPU 1
6302 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6303 index 8196e9c..d83a9f3 100644
6304 --- a/arch/powerpc/include/asm/exec.h
6305 +++ b/arch/powerpc/include/asm/exec.h
6306 @@ -4,6 +4,6 @@
6307 #ifndef _ASM_POWERPC_EXEC_H
6308 #define _ASM_POWERPC_EXEC_H
6309
6310 -extern unsigned long arch_align_stack(unsigned long sp);
6311 +#define arch_align_stack(x) ((x) & ~0xfUL)
6312
6313 #endif /* _ASM_POWERPC_EXEC_H */
6314 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6315 index 5acabbd..7ea14fa 100644
6316 --- a/arch/powerpc/include/asm/kmap_types.h
6317 +++ b/arch/powerpc/include/asm/kmap_types.h
6318 @@ -10,7 +10,7 @@
6319 * 2 of the License, or (at your option) any later version.
6320 */
6321
6322 -#define KM_TYPE_NR 16
6323 +#define KM_TYPE_NR 17
6324
6325 #endif /* __KERNEL__ */
6326 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6327 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6328 index 8565c25..2865190 100644
6329 --- a/arch/powerpc/include/asm/mman.h
6330 +++ b/arch/powerpc/include/asm/mman.h
6331 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6332 }
6333 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6334
6335 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6336 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6337 {
6338 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6339 }
6340 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6341 index 988c812..63c7d70 100644
6342 --- a/arch/powerpc/include/asm/page.h
6343 +++ b/arch/powerpc/include/asm/page.h
6344 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6345 * and needs to be executable. This means the whole heap ends
6346 * up being executable.
6347 */
6348 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6349 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6350 +#define VM_DATA_DEFAULT_FLAGS32 \
6351 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6352 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6353
6354 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6355 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6356 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6357 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6358 #endif
6359
6360 +#define ktla_ktva(addr) (addr)
6361 +#define ktva_ktla(addr) (addr)
6362 +
6363 #ifndef CONFIG_PPC_BOOK3S_64
6364 /*
6365 * Use the top bit of the higher-level page table entries to indicate whether
6366 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6367 index 88693ce..ac6f9ab 100644
6368 --- a/arch/powerpc/include/asm/page_64.h
6369 +++ b/arch/powerpc/include/asm/page_64.h
6370 @@ -153,15 +153,18 @@ do { \
6371 * stack by default, so in the absence of a PT_GNU_STACK program header
6372 * we turn execute permission off.
6373 */
6374 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6375 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6376 +#define VM_STACK_DEFAULT_FLAGS32 \
6377 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6378 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6379
6380 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6381 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6382
6383 +#ifndef CONFIG_PAX_PAGEEXEC
6384 #define VM_STACK_DEFAULT_FLAGS \
6385 (is_32bit_task() ? \
6386 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6387 +#endif
6388
6389 #include <asm-generic/getorder.h>
6390
6391 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6392 index b66ae72..4a378cd 100644
6393 --- a/arch/powerpc/include/asm/pgalloc-64.h
6394 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6395 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6396 #ifndef CONFIG_PPC_64K_PAGES
6397
6398 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6399 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6400
6401 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6402 {
6403 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6404 pud_set(pud, (unsigned long)pmd);
6405 }
6406
6407 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6408 +{
6409 + pud_populate(mm, pud, pmd);
6410 +}
6411 +
6412 #define pmd_populate(mm, pmd, pte_page) \
6413 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6414 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6415 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6416 #endif
6417
6418 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6419 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6420
6421 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6422 pte_t *pte)
6423 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6424 index 7aeb955..19f748e 100644
6425 --- a/arch/powerpc/include/asm/pgtable.h
6426 +++ b/arch/powerpc/include/asm/pgtable.h
6427 @@ -2,6 +2,7 @@
6428 #define _ASM_POWERPC_PGTABLE_H
6429 #ifdef __KERNEL__
6430
6431 +#include <linux/const.h>
6432 #ifndef __ASSEMBLY__
6433 #include <asm/processor.h> /* For TASK_SIZE */
6434 #include <asm/mmu.h>
6435 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6436 index 4aad413..85d86bf 100644
6437 --- a/arch/powerpc/include/asm/pte-hash32.h
6438 +++ b/arch/powerpc/include/asm/pte-hash32.h
6439 @@ -21,6 +21,7 @@
6440 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6441 #define _PAGE_USER 0x004 /* usermode access allowed */
6442 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6443 +#define _PAGE_EXEC _PAGE_GUARDED
6444 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6445 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6446 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6447 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6448 index 362142b..8b22c1b 100644
6449 --- a/arch/powerpc/include/asm/reg.h
6450 +++ b/arch/powerpc/include/asm/reg.h
6451 @@ -234,6 +234,7 @@
6452 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6453 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6454 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6455 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6456 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6457 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6458 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6459 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6460 index ffbaabe..eabe843 100644
6461 --- a/arch/powerpc/include/asm/smp.h
6462 +++ b/arch/powerpc/include/asm/smp.h
6463 @@ -50,7 +50,7 @@ struct smp_ops_t {
6464 int (*cpu_disable)(void);
6465 void (*cpu_die)(unsigned int nr);
6466 int (*cpu_bootable)(unsigned int nr);
6467 -};
6468 +} __no_const;
6469
6470 extern void smp_send_debugger_break(void);
6471 extern void start_secondary_resume(void);
6472 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6473 index ba7b197..d292e26 100644
6474 --- a/arch/powerpc/include/asm/thread_info.h
6475 +++ b/arch/powerpc/include/asm/thread_info.h
6476 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6477 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6478 TIF_NEED_RESCHED */
6479 #define TIF_32BIT 4 /* 32 bit binary */
6480 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6481 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6482 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6483 #define TIF_SINGLESTEP 8 /* singlestepping active */
6484 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6485 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6486 for stack store? */
6487 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6488 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6489 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6490 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6491
6492 /* as above, but as bit values */
6493 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6494 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6495 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6496 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6497 #define _TIF_NOHZ (1<<TIF_NOHZ)
6498 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6499 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6500 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6501 - _TIF_NOHZ)
6502 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6503
6504 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6505 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6506 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6507 index 4db4959..aba5c41 100644
6508 --- a/arch/powerpc/include/asm/uaccess.h
6509 +++ b/arch/powerpc/include/asm/uaccess.h
6510 @@ -318,52 +318,6 @@ do { \
6511 extern unsigned long __copy_tofrom_user(void __user *to,
6512 const void __user *from, unsigned long size);
6513
6514 -#ifndef __powerpc64__
6515 -
6516 -static inline unsigned long copy_from_user(void *to,
6517 - const void __user *from, unsigned long n)
6518 -{
6519 - unsigned long over;
6520 -
6521 - if (access_ok(VERIFY_READ, from, n))
6522 - return __copy_tofrom_user((__force void __user *)to, from, n);
6523 - if ((unsigned long)from < TASK_SIZE) {
6524 - over = (unsigned long)from + n - TASK_SIZE;
6525 - return __copy_tofrom_user((__force void __user *)to, from,
6526 - n - over) + over;
6527 - }
6528 - return n;
6529 -}
6530 -
6531 -static inline unsigned long copy_to_user(void __user *to,
6532 - const void *from, unsigned long n)
6533 -{
6534 - unsigned long over;
6535 -
6536 - if (access_ok(VERIFY_WRITE, to, n))
6537 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6538 - if ((unsigned long)to < TASK_SIZE) {
6539 - over = (unsigned long)to + n - TASK_SIZE;
6540 - return __copy_tofrom_user(to, (__force void __user *)from,
6541 - n - over) + over;
6542 - }
6543 - return n;
6544 -}
6545 -
6546 -#else /* __powerpc64__ */
6547 -
6548 -#define __copy_in_user(to, from, size) \
6549 - __copy_tofrom_user((to), (from), (size))
6550 -
6551 -extern unsigned long copy_from_user(void *to, const void __user *from,
6552 - unsigned long n);
6553 -extern unsigned long copy_to_user(void __user *to, const void *from,
6554 - unsigned long n);
6555 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6556 - unsigned long n);
6557 -
6558 -#endif /* __powerpc64__ */
6559 -
6560 static inline unsigned long __copy_from_user_inatomic(void *to,
6561 const void __user *from, unsigned long n)
6562 {
6563 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6564 if (ret == 0)
6565 return 0;
6566 }
6567 +
6568 + if (!__builtin_constant_p(n))
6569 + check_object_size(to, n, false);
6570 +
6571 return __copy_tofrom_user((__force void __user *)to, from, n);
6572 }
6573
6574 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6575 if (ret == 0)
6576 return 0;
6577 }
6578 +
6579 + if (!__builtin_constant_p(n))
6580 + check_object_size(from, n, true);
6581 +
6582 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6583 }
6584
6585 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6586 return __copy_to_user_inatomic(to, from, size);
6587 }
6588
6589 +#ifndef __powerpc64__
6590 +
6591 +static inline unsigned long __must_check copy_from_user(void *to,
6592 + const void __user *from, unsigned long n)
6593 +{
6594 + unsigned long over;
6595 +
6596 + if ((long)n < 0)
6597 + return n;
6598 +
6599 + if (access_ok(VERIFY_READ, from, n)) {
6600 + if (!__builtin_constant_p(n))
6601 + check_object_size(to, n, false);
6602 + return __copy_tofrom_user((__force void __user *)to, from, n);
6603 + }
6604 + if ((unsigned long)from < TASK_SIZE) {
6605 + over = (unsigned long)from + n - TASK_SIZE;
6606 + if (!__builtin_constant_p(n - over))
6607 + check_object_size(to, n - over, false);
6608 + return __copy_tofrom_user((__force void __user *)to, from,
6609 + n - over) + over;
6610 + }
6611 + return n;
6612 +}
6613 +
6614 +static inline unsigned long __must_check copy_to_user(void __user *to,
6615 + const void *from, unsigned long n)
6616 +{
6617 + unsigned long over;
6618 +
6619 + if ((long)n < 0)
6620 + return n;
6621 +
6622 + if (access_ok(VERIFY_WRITE, to, n)) {
6623 + if (!__builtin_constant_p(n))
6624 + check_object_size(from, n, true);
6625 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6626 + }
6627 + if ((unsigned long)to < TASK_SIZE) {
6628 + over = (unsigned long)to + n - TASK_SIZE;
6629 + if (!__builtin_constant_p(n))
6630 + check_object_size(from, n - over, true);
6631 + return __copy_tofrom_user(to, (__force void __user *)from,
6632 + n - over) + over;
6633 + }
6634 + return n;
6635 +}
6636 +
6637 +#else /* __powerpc64__ */
6638 +
6639 +#define __copy_in_user(to, from, size) \
6640 + __copy_tofrom_user((to), (from), (size))
6641 +
6642 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6643 +{
6644 + if ((long)n < 0 || n > INT_MAX)
6645 + return n;
6646 +
6647 + if (!__builtin_constant_p(n))
6648 + check_object_size(to, n, false);
6649 +
6650 + if (likely(access_ok(VERIFY_READ, from, n)))
6651 + n = __copy_from_user(to, from, n);
6652 + else
6653 + memset(to, 0, n);
6654 + return n;
6655 +}
6656 +
6657 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6658 +{
6659 + if ((long)n < 0 || n > INT_MAX)
6660 + return n;
6661 +
6662 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6663 + if (!__builtin_constant_p(n))
6664 + check_object_size(from, n, true);
6665 + n = __copy_to_user(to, from, n);
6666 + }
6667 + return n;
6668 +}
6669 +
6670 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6671 + unsigned long n);
6672 +
6673 +#endif /* __powerpc64__ */
6674 +
6675 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6676
6677 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6678 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6679 index 645170a..6cf0271 100644
6680 --- a/arch/powerpc/kernel/exceptions-64e.S
6681 +++ b/arch/powerpc/kernel/exceptions-64e.S
6682 @@ -757,6 +757,7 @@ storage_fault_common:
6683 std r14,_DAR(r1)
6684 std r15,_DSISR(r1)
6685 addi r3,r1,STACK_FRAME_OVERHEAD
6686 + bl .save_nvgprs
6687 mr r4,r14
6688 mr r5,r15
6689 ld r14,PACA_EXGEN+EX_R14(r13)
6690 @@ -765,8 +766,7 @@ storage_fault_common:
6691 cmpdi r3,0
6692 bne- 1f
6693 b .ret_from_except_lite
6694 -1: bl .save_nvgprs
6695 - mr r5,r3
6696 +1: mr r5,r3
6697 addi r3,r1,STACK_FRAME_OVERHEAD
6698 ld r4,_DAR(r1)
6699 bl .bad_page_fault
6700 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6701 index 4e00d22..b26abcc 100644
6702 --- a/arch/powerpc/kernel/exceptions-64s.S
6703 +++ b/arch/powerpc/kernel/exceptions-64s.S
6704 @@ -1356,10 +1356,10 @@ handle_page_fault:
6705 11: ld r4,_DAR(r1)
6706 ld r5,_DSISR(r1)
6707 addi r3,r1,STACK_FRAME_OVERHEAD
6708 + bl .save_nvgprs
6709 bl .do_page_fault
6710 cmpdi r3,0
6711 beq+ 12f
6712 - bl .save_nvgprs
6713 mr r5,r3
6714 addi r3,r1,STACK_FRAME_OVERHEAD
6715 lwz r4,_DAR(r1)
6716 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6717 index 2e3200c..72095ce 100644
6718 --- a/arch/powerpc/kernel/module_32.c
6719 +++ b/arch/powerpc/kernel/module_32.c
6720 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6721 me->arch.core_plt_section = i;
6722 }
6723 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6724 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6725 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6726 return -ENOEXEC;
6727 }
6728
6729 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6730
6731 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6732 /* Init, or core PLT? */
6733 - if (location >= mod->module_core
6734 - && location < mod->module_core + mod->core_size)
6735 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6736 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6737 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6738 - else
6739 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6740 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6741 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6742 + else {
6743 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6744 + return ~0UL;
6745 + }
6746
6747 /* Find this entry, or if that fails, the next avail. entry */
6748 while (entry->jump[0]) {
6749 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6750 index 076d124..6cb2cbf 100644
6751 --- a/arch/powerpc/kernel/process.c
6752 +++ b/arch/powerpc/kernel/process.c
6753 @@ -874,8 +874,8 @@ void show_regs(struct pt_regs * regs)
6754 * Lookup NIP late so we have the best change of getting the
6755 * above info out without failing
6756 */
6757 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6758 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6759 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6760 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6761 #endif
6762 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6763 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6764 @@ -1335,10 +1335,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6765 newsp = stack[0];
6766 ip = stack[STACK_FRAME_LR_SAVE];
6767 if (!firstframe || ip != lr) {
6768 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6769 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6770 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6771 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6772 - printk(" (%pS)",
6773 + printk(" (%pA)",
6774 (void *)current->ret_stack[curr_frame].ret);
6775 curr_frame--;
6776 }
6777 @@ -1358,7 +1358,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6778 struct pt_regs *regs = (struct pt_regs *)
6779 (sp + STACK_FRAME_OVERHEAD);
6780 lr = regs->link;
6781 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6782 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6783 regs->trap, (void *)regs->nip, (void *)lr);
6784 firstframe = 1;
6785 }
6786 @@ -1394,58 +1394,3 @@ void notrace __ppc64_runlatch_off(void)
6787 mtspr(SPRN_CTRLT, ctrl);
6788 }
6789 #endif /* CONFIG_PPC64 */
6790 -
6791 -unsigned long arch_align_stack(unsigned long sp)
6792 -{
6793 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6794 - sp -= get_random_int() & ~PAGE_MASK;
6795 - return sp & ~0xf;
6796 -}
6797 -
6798 -static inline unsigned long brk_rnd(void)
6799 -{
6800 - unsigned long rnd = 0;
6801 -
6802 - /* 8MB for 32bit, 1GB for 64bit */
6803 - if (is_32bit_task())
6804 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6805 - else
6806 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6807 -
6808 - return rnd << PAGE_SHIFT;
6809 -}
6810 -
6811 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6812 -{
6813 - unsigned long base = mm->brk;
6814 - unsigned long ret;
6815 -
6816 -#ifdef CONFIG_PPC_STD_MMU_64
6817 - /*
6818 - * If we are using 1TB segments and we are allowed to randomise
6819 - * the heap, we can put it above 1TB so it is backed by a 1TB
6820 - * segment. Otherwise the heap will be in the bottom 1TB
6821 - * which always uses 256MB segments and this may result in a
6822 - * performance penalty.
6823 - */
6824 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6825 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6826 -#endif
6827 -
6828 - ret = PAGE_ALIGN(base + brk_rnd());
6829 -
6830 - if (ret < mm->brk)
6831 - return mm->brk;
6832 -
6833 - return ret;
6834 -}
6835 -
6836 -unsigned long randomize_et_dyn(unsigned long base)
6837 -{
6838 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6839 -
6840 - if (ret < base)
6841 - return base;
6842 -
6843 - return ret;
6844 -}
6845 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6846 index 64f7bd5..8dd550f 100644
6847 --- a/arch/powerpc/kernel/ptrace.c
6848 +++ b/arch/powerpc/kernel/ptrace.c
6849 @@ -1783,6 +1783,10 @@ long arch_ptrace(struct task_struct *child, long request,
6850 return ret;
6851 }
6852
6853 +#ifdef CONFIG_GRKERNSEC_SETXID
6854 +extern void gr_delayed_cred_worker(void);
6855 +#endif
6856 +
6857 /*
6858 * We must return the syscall number to actually look up in the table.
6859 * This can be -1L to skip running any syscall at all.
6860 @@ -1795,6 +1799,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6861
6862 secure_computing_strict(regs->gpr[0]);
6863
6864 +#ifdef CONFIG_GRKERNSEC_SETXID
6865 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6866 + gr_delayed_cred_worker();
6867 +#endif
6868 +
6869 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6870 tracehook_report_syscall_entry(regs))
6871 /*
6872 @@ -1829,6 +1838,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6873 {
6874 int step;
6875
6876 +#ifdef CONFIG_GRKERNSEC_SETXID
6877 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6878 + gr_delayed_cred_worker();
6879 +#endif
6880 +
6881 audit_syscall_exit(regs);
6882
6883 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6884 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6885 index 0f83122..c0aca6a 100644
6886 --- a/arch/powerpc/kernel/signal_32.c
6887 +++ b/arch/powerpc/kernel/signal_32.c
6888 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6889 /* Save user registers on the stack */
6890 frame = &rt_sf->uc.uc_mcontext;
6891 addr = frame;
6892 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6893 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6894 sigret = 0;
6895 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6896 } else {
6897 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6898 index 887e99d..310bc11 100644
6899 --- a/arch/powerpc/kernel/signal_64.c
6900 +++ b/arch/powerpc/kernel/signal_64.c
6901 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6902 #endif
6903
6904 /* Set up to return from userspace. */
6905 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6906 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6907 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6908 } else {
6909 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6910 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6911 index e68a845..8b140e6 100644
6912 --- a/arch/powerpc/kernel/sysfs.c
6913 +++ b/arch/powerpc/kernel/sysfs.c
6914 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6915 return NOTIFY_OK;
6916 }
6917
6918 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6919 +static struct notifier_block sysfs_cpu_nb = {
6920 .notifier_call = sysfs_cpu_notify,
6921 };
6922
6923 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6924 index e4f205a..8bfffb8 100644
6925 --- a/arch/powerpc/kernel/traps.c
6926 +++ b/arch/powerpc/kernel/traps.c
6927 @@ -143,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6928 return flags;
6929 }
6930
6931 +extern void gr_handle_kernel_exploit(void);
6932 +
6933 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6934 int signr)
6935 {
6936 @@ -192,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6937 panic("Fatal exception in interrupt");
6938 if (panic_on_oops)
6939 panic("Fatal exception");
6940 +
6941 + gr_handle_kernel_exploit();
6942 +
6943 do_exit(signr);
6944 }
6945
6946 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6947 index d4f463a..8fb7431 100644
6948 --- a/arch/powerpc/kernel/vdso.c
6949 +++ b/arch/powerpc/kernel/vdso.c
6950 @@ -34,6 +34,7 @@
6951 #include <asm/firmware.h>
6952 #include <asm/vdso.h>
6953 #include <asm/vdso_datapage.h>
6954 +#include <asm/mman.h>
6955
6956 #include "setup.h"
6957
6958 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6959 vdso_base = VDSO32_MBASE;
6960 #endif
6961
6962 - current->mm->context.vdso_base = 0;
6963 + current->mm->context.vdso_base = ~0UL;
6964
6965 /* vDSO has a problem and was disabled, just don't "enable" it for the
6966 * process
6967 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6968 vdso_base = get_unmapped_area(NULL, vdso_base,
6969 (vdso_pages << PAGE_SHIFT) +
6970 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6971 - 0, 0);
6972 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6973 if (IS_ERR_VALUE(vdso_base)) {
6974 rc = vdso_base;
6975 goto fail_mmapsem;
6976 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6977 index 5eea6f3..5d10396 100644
6978 --- a/arch/powerpc/lib/usercopy_64.c
6979 +++ b/arch/powerpc/lib/usercopy_64.c
6980 @@ -9,22 +9,6 @@
6981 #include <linux/module.h>
6982 #include <asm/uaccess.h>
6983
6984 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6985 -{
6986 - if (likely(access_ok(VERIFY_READ, from, n)))
6987 - n = __copy_from_user(to, from, n);
6988 - else
6989 - memset(to, 0, n);
6990 - return n;
6991 -}
6992 -
6993 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6994 -{
6995 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6996 - n = __copy_to_user(to, from, n);
6997 - return n;
6998 -}
6999 -
7000 unsigned long copy_in_user(void __user *to, const void __user *from,
7001 unsigned long n)
7002 {
7003 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7004 return n;
7005 }
7006
7007 -EXPORT_SYMBOL(copy_from_user);
7008 -EXPORT_SYMBOL(copy_to_user);
7009 EXPORT_SYMBOL(copy_in_user);
7010
7011 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7012 index 8726779..a33c512 100644
7013 --- a/arch/powerpc/mm/fault.c
7014 +++ b/arch/powerpc/mm/fault.c
7015 @@ -33,6 +33,10 @@
7016 #include <linux/magic.h>
7017 #include <linux/ratelimit.h>
7018 #include <linux/context_tracking.h>
7019 +#include <linux/slab.h>
7020 +#include <linux/pagemap.h>
7021 +#include <linux/compiler.h>
7022 +#include <linux/unistd.h>
7023
7024 #include <asm/firmware.h>
7025 #include <asm/page.h>
7026 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7027 }
7028 #endif
7029
7030 +#ifdef CONFIG_PAX_PAGEEXEC
7031 +/*
7032 + * PaX: decide what to do with offenders (regs->nip = fault address)
7033 + *
7034 + * returns 1 when task should be killed
7035 + */
7036 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7037 +{
7038 + return 1;
7039 +}
7040 +
7041 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7042 +{
7043 + unsigned long i;
7044 +
7045 + printk(KERN_ERR "PAX: bytes at PC: ");
7046 + for (i = 0; i < 5; i++) {
7047 + unsigned int c;
7048 + if (get_user(c, (unsigned int __user *)pc+i))
7049 + printk(KERN_CONT "???????? ");
7050 + else
7051 + printk(KERN_CONT "%08x ", c);
7052 + }
7053 + printk("\n");
7054 +}
7055 +#endif
7056 +
7057 /*
7058 * Check whether the instruction at regs->nip is a store using
7059 * an update addressing form which will update r1.
7060 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7061 * indicate errors in DSISR but can validly be set in SRR1.
7062 */
7063 if (trap == 0x400)
7064 - error_code &= 0x48200000;
7065 + error_code &= 0x58200000;
7066 else
7067 is_write = error_code & DSISR_ISSTORE;
7068 #else
7069 @@ -371,7 +402,7 @@ good_area:
7070 * "undefined". Of those that can be set, this is the only
7071 * one which seems bad.
7072 */
7073 - if (error_code & 0x10000000)
7074 + if (error_code & DSISR_GUARDED)
7075 /* Guarded storage error. */
7076 goto bad_area;
7077 #endif /* CONFIG_8xx */
7078 @@ -386,7 +417,7 @@ good_area:
7079 * processors use the same I/D cache coherency mechanism
7080 * as embedded.
7081 */
7082 - if (error_code & DSISR_PROTFAULT)
7083 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7084 goto bad_area;
7085 #endif /* CONFIG_PPC_STD_MMU */
7086
7087 @@ -471,6 +502,23 @@ bad_area:
7088 bad_area_nosemaphore:
7089 /* User mode accesses cause a SIGSEGV */
7090 if (user_mode(regs)) {
7091 +
7092 +#ifdef CONFIG_PAX_PAGEEXEC
7093 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7094 +#ifdef CONFIG_PPC_STD_MMU
7095 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7096 +#else
7097 + if (is_exec && regs->nip == address) {
7098 +#endif
7099 + switch (pax_handle_fetch_fault(regs)) {
7100 + }
7101 +
7102 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7103 + do_group_exit(SIGKILL);
7104 + }
7105 + }
7106 +#endif
7107 +
7108 _exception(SIGSEGV, regs, code, address);
7109 goto bail;
7110 }
7111 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7112 index 67a42ed..cd463e0 100644
7113 --- a/arch/powerpc/mm/mmap_64.c
7114 +++ b/arch/powerpc/mm/mmap_64.c
7115 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7116 {
7117 unsigned long rnd = 0;
7118
7119 +#ifdef CONFIG_PAX_RANDMMAP
7120 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7121 +#endif
7122 +
7123 if (current->flags & PF_RANDOMIZE) {
7124 /* 8MB for 32bit, 1GB for 64bit */
7125 if (is_32bit_task())
7126 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7127 */
7128 if (mmap_is_legacy()) {
7129 mm->mmap_base = TASK_UNMAPPED_BASE;
7130 +
7131 +#ifdef CONFIG_PAX_RANDMMAP
7132 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7133 + mm->mmap_base += mm->delta_mmap;
7134 +#endif
7135 +
7136 mm->get_unmapped_area = arch_get_unmapped_area;
7137 mm->unmap_area = arch_unmap_area;
7138 } else {
7139 mm->mmap_base = mmap_base();
7140 +
7141 +#ifdef CONFIG_PAX_RANDMMAP
7142 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7143 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7144 +#endif
7145 +
7146 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7147 mm->unmap_area = arch_unmap_area_topdown;
7148 }
7149 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7150 index e779642..e5bb889 100644
7151 --- a/arch/powerpc/mm/mmu_context_nohash.c
7152 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7153 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7154 return NOTIFY_OK;
7155 }
7156
7157 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7158 +static struct notifier_block mmu_context_cpu_nb = {
7159 .notifier_call = mmu_context_cpu_notify,
7160 };
7161
7162 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7163 index 2859a1f..74f9a6e 100644
7164 --- a/arch/powerpc/mm/numa.c
7165 +++ b/arch/powerpc/mm/numa.c
7166 @@ -919,7 +919,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7167 return ret;
7168 }
7169
7170 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7171 +static struct notifier_block ppc64_numa_nb = {
7172 .notifier_call = cpu_numa_callback,
7173 .priority = 1 /* Must run before sched domains notifier. */
7174 };
7175 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7176 index 3e99c14..f00953c 100644
7177 --- a/arch/powerpc/mm/slice.c
7178 +++ b/arch/powerpc/mm/slice.c
7179 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7180 if ((mm->task_size - len) < addr)
7181 return 0;
7182 vma = find_vma(mm, addr);
7183 - return (!vma || (addr + len) <= vma->vm_start);
7184 + return check_heap_stack_gap(vma, addr, len, 0);
7185 }
7186
7187 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7188 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7189 info.align_offset = 0;
7190
7191 addr = TASK_UNMAPPED_BASE;
7192 +
7193 +#ifdef CONFIG_PAX_RANDMMAP
7194 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7195 + addr += mm->delta_mmap;
7196 +#endif
7197 +
7198 while (addr < TASK_SIZE) {
7199 info.low_limit = addr;
7200 if (!slice_scan_available(addr, available, 1, &addr))
7201 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7202 if (fixed && addr > (mm->task_size - len))
7203 return -EINVAL;
7204
7205 +#ifdef CONFIG_PAX_RANDMMAP
7206 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7207 + addr = 0;
7208 +#endif
7209 +
7210 /* If hint, make sure it matches our alignment restrictions */
7211 if (!fixed && addr) {
7212 addr = _ALIGN_UP(addr, 1ul << pshift);
7213 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7214 index 9098692..3d54cd1 100644
7215 --- a/arch/powerpc/platforms/cell/spufs/file.c
7216 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7217 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7218 return VM_FAULT_NOPAGE;
7219 }
7220
7221 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7222 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7223 unsigned long address,
7224 - void *buf, int len, int write)
7225 + void *buf, size_t len, int write)
7226 {
7227 struct spu_context *ctx = vma->vm_file->private_data;
7228 unsigned long offset = address - vma->vm_start;
7229 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7230 index bdb738a..49c9f95 100644
7231 --- a/arch/powerpc/platforms/powermac/smp.c
7232 +++ b/arch/powerpc/platforms/powermac/smp.c
7233 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7234 return NOTIFY_OK;
7235 }
7236
7237 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7238 +static struct notifier_block smp_core99_cpu_nb = {
7239 .notifier_call = smp_core99_cpu_notify,
7240 };
7241 #endif /* CONFIG_HOTPLUG_CPU */
7242 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7243 index c797832..ce575c8 100644
7244 --- a/arch/s390/include/asm/atomic.h
7245 +++ b/arch/s390/include/asm/atomic.h
7246 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7247 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7248 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7249
7250 +#define atomic64_read_unchecked(v) atomic64_read(v)
7251 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7252 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7253 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7254 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7255 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7256 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7257 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7258 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7259 +
7260 #define smp_mb__before_atomic_dec() smp_mb()
7261 #define smp_mb__after_atomic_dec() smp_mb()
7262 #define smp_mb__before_atomic_inc() smp_mb()
7263 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7264 index 4d7ccac..d03d0ad 100644
7265 --- a/arch/s390/include/asm/cache.h
7266 +++ b/arch/s390/include/asm/cache.h
7267 @@ -9,8 +9,10 @@
7268 #ifndef __ARCH_S390_CACHE_H
7269 #define __ARCH_S390_CACHE_H
7270
7271 -#define L1_CACHE_BYTES 256
7272 +#include <linux/const.h>
7273 +
7274 #define L1_CACHE_SHIFT 8
7275 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7276 #define NET_SKB_PAD 32
7277
7278 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7279 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7280 index 78f4f87..598ce39 100644
7281 --- a/arch/s390/include/asm/elf.h
7282 +++ b/arch/s390/include/asm/elf.h
7283 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7284 the loader. We need to make sure that it is out of the way of the program
7285 that it will "exec", and that there is sufficient room for the brk. */
7286
7287 -extern unsigned long randomize_et_dyn(unsigned long base);
7288 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7289 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7290 +
7291 +#ifdef CONFIG_PAX_ASLR
7292 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7293 +
7294 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7295 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7296 +#endif
7297
7298 /* This yields a mask that user programs can use to figure out what
7299 instruction set this CPU supports. */
7300 @@ -222,9 +228,6 @@ struct linux_binprm;
7301 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7302 int arch_setup_additional_pages(struct linux_binprm *, int);
7303
7304 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7305 -#define arch_randomize_brk arch_randomize_brk
7306 -
7307 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7308
7309 #endif
7310 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7311 index c4a93d6..4d2a9b4 100644
7312 --- a/arch/s390/include/asm/exec.h
7313 +++ b/arch/s390/include/asm/exec.h
7314 @@ -7,6 +7,6 @@
7315 #ifndef __ASM_EXEC_H
7316 #define __ASM_EXEC_H
7317
7318 -extern unsigned long arch_align_stack(unsigned long sp);
7319 +#define arch_align_stack(x) ((x) & ~0xfUL)
7320
7321 #endif /* __ASM_EXEC_H */
7322 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7323 index 9c33ed4..e40cbef 100644
7324 --- a/arch/s390/include/asm/uaccess.h
7325 +++ b/arch/s390/include/asm/uaccess.h
7326 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7327 copy_to_user(void __user *to, const void *from, unsigned long n)
7328 {
7329 might_fault();
7330 +
7331 + if ((long)n < 0)
7332 + return n;
7333 +
7334 return __copy_to_user(to, from, n);
7335 }
7336
7337 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7338 static inline unsigned long __must_check
7339 __copy_from_user(void *to, const void __user *from, unsigned long n)
7340 {
7341 + if ((long)n < 0)
7342 + return n;
7343 +
7344 if (__builtin_constant_p(n) && (n <= 256))
7345 return uaccess.copy_from_user_small(n, from, to);
7346 else
7347 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7348 static inline unsigned long __must_check
7349 copy_from_user(void *to, const void __user *from, unsigned long n)
7350 {
7351 - unsigned int sz = __compiletime_object_size(to);
7352 + size_t sz = __compiletime_object_size(to);
7353
7354 might_fault();
7355 - if (unlikely(sz != -1 && sz < n)) {
7356 +
7357 + if ((long)n < 0)
7358 + return n;
7359 +
7360 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7361 copy_from_user_overflow();
7362 return n;
7363 }
7364 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7365 index 7845e15..59c4353 100644
7366 --- a/arch/s390/kernel/module.c
7367 +++ b/arch/s390/kernel/module.c
7368 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7369
7370 /* Increase core size by size of got & plt and set start
7371 offsets for got and plt. */
7372 - me->core_size = ALIGN(me->core_size, 4);
7373 - me->arch.got_offset = me->core_size;
7374 - me->core_size += me->arch.got_size;
7375 - me->arch.plt_offset = me->core_size;
7376 - me->core_size += me->arch.plt_size;
7377 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7378 + me->arch.got_offset = me->core_size_rw;
7379 + me->core_size_rw += me->arch.got_size;
7380 + me->arch.plt_offset = me->core_size_rx;
7381 + me->core_size_rx += me->arch.plt_size;
7382 return 0;
7383 }
7384
7385 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7386 if (info->got_initialized == 0) {
7387 Elf_Addr *gotent;
7388
7389 - gotent = me->module_core + me->arch.got_offset +
7390 + gotent = me->module_core_rw + me->arch.got_offset +
7391 info->got_offset;
7392 *gotent = val;
7393 info->got_initialized = 1;
7394 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7395 rc = apply_rela_bits(loc, val, 0, 64, 0);
7396 else if (r_type == R_390_GOTENT ||
7397 r_type == R_390_GOTPLTENT) {
7398 - val += (Elf_Addr) me->module_core - loc;
7399 + val += (Elf_Addr) me->module_core_rw - loc;
7400 rc = apply_rela_bits(loc, val, 1, 32, 1);
7401 }
7402 break;
7403 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7404 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7405 if (info->plt_initialized == 0) {
7406 unsigned int *ip;
7407 - ip = me->module_core + me->arch.plt_offset +
7408 + ip = me->module_core_rx + me->arch.plt_offset +
7409 info->plt_offset;
7410 #ifndef CONFIG_64BIT
7411 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7412 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7413 val - loc + 0xffffUL < 0x1ffffeUL) ||
7414 (r_type == R_390_PLT32DBL &&
7415 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7416 - val = (Elf_Addr) me->module_core +
7417 + val = (Elf_Addr) me->module_core_rx +
7418 me->arch.plt_offset +
7419 info->plt_offset;
7420 val += rela->r_addend - loc;
7421 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7422 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7423 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7424 val = val + rela->r_addend -
7425 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7426 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7427 if (r_type == R_390_GOTOFF16)
7428 rc = apply_rela_bits(loc, val, 0, 16, 0);
7429 else if (r_type == R_390_GOTOFF32)
7430 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7431 break;
7432 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7433 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7434 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7435 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7436 rela->r_addend - loc;
7437 if (r_type == R_390_GOTPC)
7438 rc = apply_rela_bits(loc, val, 1, 32, 0);
7439 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7440 index 2bc3edd..ab9d598 100644
7441 --- a/arch/s390/kernel/process.c
7442 +++ b/arch/s390/kernel/process.c
7443 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7444 }
7445 return 0;
7446 }
7447 -
7448 -unsigned long arch_align_stack(unsigned long sp)
7449 -{
7450 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7451 - sp -= get_random_int() & ~PAGE_MASK;
7452 - return sp & ~0xf;
7453 -}
7454 -
7455 -static inline unsigned long brk_rnd(void)
7456 -{
7457 - /* 8MB for 32bit, 1GB for 64bit */
7458 - if (is_32bit_task())
7459 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7460 - else
7461 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7462 -}
7463 -
7464 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7465 -{
7466 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7467 -
7468 - if (ret < mm->brk)
7469 - return mm->brk;
7470 - return ret;
7471 -}
7472 -
7473 -unsigned long randomize_et_dyn(unsigned long base)
7474 -{
7475 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7476 -
7477 - if (!(current->flags & PF_RANDOMIZE))
7478 - return base;
7479 - if (ret < base)
7480 - return base;
7481 - return ret;
7482 -}
7483 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7484 index 06bafec..2bca531 100644
7485 --- a/arch/s390/mm/mmap.c
7486 +++ b/arch/s390/mm/mmap.c
7487 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7488 */
7489 if (mmap_is_legacy()) {
7490 mm->mmap_base = TASK_UNMAPPED_BASE;
7491 +
7492 +#ifdef CONFIG_PAX_RANDMMAP
7493 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7494 + mm->mmap_base += mm->delta_mmap;
7495 +#endif
7496 +
7497 mm->get_unmapped_area = arch_get_unmapped_area;
7498 mm->unmap_area = arch_unmap_area;
7499 } else {
7500 mm->mmap_base = mmap_base();
7501 +
7502 +#ifdef CONFIG_PAX_RANDMMAP
7503 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7504 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7505 +#endif
7506 +
7507 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7508 mm->unmap_area = arch_unmap_area_topdown;
7509 }
7510 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7511 */
7512 if (mmap_is_legacy()) {
7513 mm->mmap_base = TASK_UNMAPPED_BASE;
7514 +
7515 +#ifdef CONFIG_PAX_RANDMMAP
7516 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7517 + mm->mmap_base += mm->delta_mmap;
7518 +#endif
7519 +
7520 mm->get_unmapped_area = s390_get_unmapped_area;
7521 mm->unmap_area = arch_unmap_area;
7522 } else {
7523 mm->mmap_base = mmap_base();
7524 +
7525 +#ifdef CONFIG_PAX_RANDMMAP
7526 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7527 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7528 +#endif
7529 +
7530 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7531 mm->unmap_area = arch_unmap_area_topdown;
7532 }
7533 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7534 index ae3d59f..f65f075 100644
7535 --- a/arch/score/include/asm/cache.h
7536 +++ b/arch/score/include/asm/cache.h
7537 @@ -1,7 +1,9 @@
7538 #ifndef _ASM_SCORE_CACHE_H
7539 #define _ASM_SCORE_CACHE_H
7540
7541 +#include <linux/const.h>
7542 +
7543 #define L1_CACHE_SHIFT 4
7544 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7545 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7546
7547 #endif /* _ASM_SCORE_CACHE_H */
7548 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7549 index f9f3cd5..58ff438 100644
7550 --- a/arch/score/include/asm/exec.h
7551 +++ b/arch/score/include/asm/exec.h
7552 @@ -1,6 +1,6 @@
7553 #ifndef _ASM_SCORE_EXEC_H
7554 #define _ASM_SCORE_EXEC_H
7555
7556 -extern unsigned long arch_align_stack(unsigned long sp);
7557 +#define arch_align_stack(x) (x)
7558
7559 #endif /* _ASM_SCORE_EXEC_H */
7560 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7561 index f4c6d02..e9355c3 100644
7562 --- a/arch/score/kernel/process.c
7563 +++ b/arch/score/kernel/process.c
7564 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7565
7566 return task_pt_regs(task)->cp0_epc;
7567 }
7568 -
7569 -unsigned long arch_align_stack(unsigned long sp)
7570 -{
7571 - return sp;
7572 -}
7573 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7574 index ef9e555..331bd29 100644
7575 --- a/arch/sh/include/asm/cache.h
7576 +++ b/arch/sh/include/asm/cache.h
7577 @@ -9,10 +9,11 @@
7578 #define __ASM_SH_CACHE_H
7579 #ifdef __KERNEL__
7580
7581 +#include <linux/const.h>
7582 #include <linux/init.h>
7583 #include <cpu/cache.h>
7584
7585 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7586 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7587
7588 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7589
7590 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7591 index 03f2b55..b0270327 100644
7592 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7593 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7594 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7595 return NOTIFY_OK;
7596 }
7597
7598 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7599 +static struct notifier_block shx3_cpu_notifier = {
7600 .notifier_call = shx3_cpu_callback,
7601 };
7602
7603 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7604 index 6777177..cb5e44f 100644
7605 --- a/arch/sh/mm/mmap.c
7606 +++ b/arch/sh/mm/mmap.c
7607 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7608 struct mm_struct *mm = current->mm;
7609 struct vm_area_struct *vma;
7610 int do_colour_align;
7611 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7612 struct vm_unmapped_area_info info;
7613
7614 if (flags & MAP_FIXED) {
7615 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7616 if (filp || (flags & MAP_SHARED))
7617 do_colour_align = 1;
7618
7619 +#ifdef CONFIG_PAX_RANDMMAP
7620 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7621 +#endif
7622 +
7623 if (addr) {
7624 if (do_colour_align)
7625 addr = COLOUR_ALIGN(addr, pgoff);
7626 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7627 addr = PAGE_ALIGN(addr);
7628
7629 vma = find_vma(mm, addr);
7630 - if (TASK_SIZE - len >= addr &&
7631 - (!vma || addr + len <= vma->vm_start))
7632 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7633 return addr;
7634 }
7635
7636 info.flags = 0;
7637 info.length = len;
7638 - info.low_limit = TASK_UNMAPPED_BASE;
7639 + info.low_limit = mm->mmap_base;
7640 info.high_limit = TASK_SIZE;
7641 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7642 info.align_offset = pgoff << PAGE_SHIFT;
7643 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7644 struct mm_struct *mm = current->mm;
7645 unsigned long addr = addr0;
7646 int do_colour_align;
7647 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7648 struct vm_unmapped_area_info info;
7649
7650 if (flags & MAP_FIXED) {
7651 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7652 if (filp || (flags & MAP_SHARED))
7653 do_colour_align = 1;
7654
7655 +#ifdef CONFIG_PAX_RANDMMAP
7656 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7657 +#endif
7658 +
7659 /* requesting a specific address */
7660 if (addr) {
7661 if (do_colour_align)
7662 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7663 addr = PAGE_ALIGN(addr);
7664
7665 vma = find_vma(mm, addr);
7666 - if (TASK_SIZE - len >= addr &&
7667 - (!vma || addr + len <= vma->vm_start))
7668 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7669 return addr;
7670 }
7671
7672 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7673 VM_BUG_ON(addr != -ENOMEM);
7674 info.flags = 0;
7675 info.low_limit = TASK_UNMAPPED_BASE;
7676 +
7677 +#ifdef CONFIG_PAX_RANDMMAP
7678 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7679 + info.low_limit += mm->delta_mmap;
7680 +#endif
7681 +
7682 info.high_limit = TASK_SIZE;
7683 addr = vm_unmapped_area(&info);
7684 }
7685 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7686 index be56a24..443328f 100644
7687 --- a/arch/sparc/include/asm/atomic_64.h
7688 +++ b/arch/sparc/include/asm/atomic_64.h
7689 @@ -14,18 +14,40 @@
7690 #define ATOMIC64_INIT(i) { (i) }
7691
7692 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7693 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7694 +{
7695 + return v->counter;
7696 +}
7697 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7698 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7699 +{
7700 + return v->counter;
7701 +}
7702
7703 #define atomic_set(v, i) (((v)->counter) = i)
7704 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7705 +{
7706 + v->counter = i;
7707 +}
7708 #define atomic64_set(v, i) (((v)->counter) = i)
7709 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7710 +{
7711 + v->counter = i;
7712 +}
7713
7714 extern void atomic_add(int, atomic_t *);
7715 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7716 extern void atomic64_add(long, atomic64_t *);
7717 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7718 extern void atomic_sub(int, atomic_t *);
7719 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7720 extern void atomic64_sub(long, atomic64_t *);
7721 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7722
7723 extern int atomic_add_ret(int, atomic_t *);
7724 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7725 extern long atomic64_add_ret(long, atomic64_t *);
7726 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7727 extern int atomic_sub_ret(int, atomic_t *);
7728 extern long atomic64_sub_ret(long, atomic64_t *);
7729
7730 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7731 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7732
7733 #define atomic_inc_return(v) atomic_add_ret(1, v)
7734 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7735 +{
7736 + return atomic_add_ret_unchecked(1, v);
7737 +}
7738 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7739 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7740 +{
7741 + return atomic64_add_ret_unchecked(1, v);
7742 +}
7743
7744 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7745 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7746
7747 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7748 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7749 +{
7750 + return atomic_add_ret_unchecked(i, v);
7751 +}
7752 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7753 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7754 +{
7755 + return atomic64_add_ret_unchecked(i, v);
7756 +}
7757
7758 /*
7759 * atomic_inc_and_test - increment and test
7760 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7761 * other cases.
7762 */
7763 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7764 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7765 +{
7766 + return atomic_inc_return_unchecked(v) == 0;
7767 +}
7768 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7769
7770 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7771 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7772 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7773
7774 #define atomic_inc(v) atomic_add(1, v)
7775 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7776 +{
7777 + atomic_add_unchecked(1, v);
7778 +}
7779 #define atomic64_inc(v) atomic64_add(1, v)
7780 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7781 +{
7782 + atomic64_add_unchecked(1, v);
7783 +}
7784
7785 #define atomic_dec(v) atomic_sub(1, v)
7786 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7787 +{
7788 + atomic_sub_unchecked(1, v);
7789 +}
7790 #define atomic64_dec(v) atomic64_sub(1, v)
7791 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7792 +{
7793 + atomic64_sub_unchecked(1, v);
7794 +}
7795
7796 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7797 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7798
7799 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7800 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7801 +{
7802 + return cmpxchg(&v->counter, old, new);
7803 +}
7804 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7805 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7806 +{
7807 + return xchg(&v->counter, new);
7808 +}
7809
7810 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7811 {
7812 - int c, old;
7813 + int c, old, new;
7814 c = atomic_read(v);
7815 for (;;) {
7816 - if (unlikely(c == (u)))
7817 + if (unlikely(c == u))
7818 break;
7819 - old = atomic_cmpxchg((v), c, c + (a));
7820 +
7821 + asm volatile("addcc %2, %0, %0\n"
7822 +
7823 +#ifdef CONFIG_PAX_REFCOUNT
7824 + "tvs %%icc, 6\n"
7825 +#endif
7826 +
7827 + : "=r" (new)
7828 + : "0" (c), "ir" (a)
7829 + : "cc");
7830 +
7831 + old = atomic_cmpxchg(v, c, new);
7832 if (likely(old == c))
7833 break;
7834 c = old;
7835 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7836 #define atomic64_cmpxchg(v, o, n) \
7837 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7838 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7839 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7840 +{
7841 + return xchg(&v->counter, new);
7842 +}
7843
7844 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7845 {
7846 - long c, old;
7847 + long c, old, new;
7848 c = atomic64_read(v);
7849 for (;;) {
7850 - if (unlikely(c == (u)))
7851 + if (unlikely(c == u))
7852 break;
7853 - old = atomic64_cmpxchg((v), c, c + (a));
7854 +
7855 + asm volatile("addcc %2, %0, %0\n"
7856 +
7857 +#ifdef CONFIG_PAX_REFCOUNT
7858 + "tvs %%xcc, 6\n"
7859 +#endif
7860 +
7861 + : "=r" (new)
7862 + : "0" (c), "ir" (a)
7863 + : "cc");
7864 +
7865 + old = atomic64_cmpxchg(v, c, new);
7866 if (likely(old == c))
7867 break;
7868 c = old;
7869 }
7870 - return c != (u);
7871 + return c != u;
7872 }
7873
7874 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7875 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7876 index 5bb6991..5c2132e 100644
7877 --- a/arch/sparc/include/asm/cache.h
7878 +++ b/arch/sparc/include/asm/cache.h
7879 @@ -7,10 +7,12 @@
7880 #ifndef _SPARC_CACHE_H
7881 #define _SPARC_CACHE_H
7882
7883 +#include <linux/const.h>
7884 +
7885 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7886
7887 #define L1_CACHE_SHIFT 5
7888 -#define L1_CACHE_BYTES 32
7889 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7890
7891 #ifdef CONFIG_SPARC32
7892 #define SMP_CACHE_BYTES_SHIFT 5
7893 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7894 index a24e41f..47677ff 100644
7895 --- a/arch/sparc/include/asm/elf_32.h
7896 +++ b/arch/sparc/include/asm/elf_32.h
7897 @@ -114,6 +114,13 @@ typedef struct {
7898
7899 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7900
7901 +#ifdef CONFIG_PAX_ASLR
7902 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7903 +
7904 +#define PAX_DELTA_MMAP_LEN 16
7905 +#define PAX_DELTA_STACK_LEN 16
7906 +#endif
7907 +
7908 /* This yields a mask that user programs can use to figure out what
7909 instruction set this cpu supports. This can NOT be done in userspace
7910 on Sparc. */
7911 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7912 index 370ca1e..d4f4a98 100644
7913 --- a/arch/sparc/include/asm/elf_64.h
7914 +++ b/arch/sparc/include/asm/elf_64.h
7915 @@ -189,6 +189,13 @@ typedef struct {
7916 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7917 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7918
7919 +#ifdef CONFIG_PAX_ASLR
7920 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7921 +
7922 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7923 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7924 +#endif
7925 +
7926 extern unsigned long sparc64_elf_hwcap;
7927 #define ELF_HWCAP sparc64_elf_hwcap
7928
7929 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7930 index 9b1c36d..209298b 100644
7931 --- a/arch/sparc/include/asm/pgalloc_32.h
7932 +++ b/arch/sparc/include/asm/pgalloc_32.h
7933 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7934 }
7935
7936 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7937 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7938
7939 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7940 unsigned long address)
7941 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7942 index bcfe063..b333142 100644
7943 --- a/arch/sparc/include/asm/pgalloc_64.h
7944 +++ b/arch/sparc/include/asm/pgalloc_64.h
7945 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7946 }
7947
7948 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7949 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7950
7951 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7952 {
7953 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7954 index 6fc1348..390c50a 100644
7955 --- a/arch/sparc/include/asm/pgtable_32.h
7956 +++ b/arch/sparc/include/asm/pgtable_32.h
7957 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7958 #define PAGE_SHARED SRMMU_PAGE_SHARED
7959 #define PAGE_COPY SRMMU_PAGE_COPY
7960 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7961 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7962 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7963 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7964 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7965
7966 /* Top-level page directory - dummy used by init-mm.
7967 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7968
7969 /* xwr */
7970 #define __P000 PAGE_NONE
7971 -#define __P001 PAGE_READONLY
7972 -#define __P010 PAGE_COPY
7973 -#define __P011 PAGE_COPY
7974 +#define __P001 PAGE_READONLY_NOEXEC
7975 +#define __P010 PAGE_COPY_NOEXEC
7976 +#define __P011 PAGE_COPY_NOEXEC
7977 #define __P100 PAGE_READONLY
7978 #define __P101 PAGE_READONLY
7979 #define __P110 PAGE_COPY
7980 #define __P111 PAGE_COPY
7981
7982 #define __S000 PAGE_NONE
7983 -#define __S001 PAGE_READONLY
7984 -#define __S010 PAGE_SHARED
7985 -#define __S011 PAGE_SHARED
7986 +#define __S001 PAGE_READONLY_NOEXEC
7987 +#define __S010 PAGE_SHARED_NOEXEC
7988 +#define __S011 PAGE_SHARED_NOEXEC
7989 #define __S100 PAGE_READONLY
7990 #define __S101 PAGE_READONLY
7991 #define __S110 PAGE_SHARED
7992 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7993 index 79da178..c2eede8 100644
7994 --- a/arch/sparc/include/asm/pgtsrmmu.h
7995 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7996 @@ -115,6 +115,11 @@
7997 SRMMU_EXEC | SRMMU_REF)
7998 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7999 SRMMU_EXEC | SRMMU_REF)
8000 +
8001 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8002 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8003 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8004 +
8005 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8006 SRMMU_DIRTY | SRMMU_REF)
8007
8008 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8009 index 9689176..63c18ea 100644
8010 --- a/arch/sparc/include/asm/spinlock_64.h
8011 +++ b/arch/sparc/include/asm/spinlock_64.h
8012 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8013
8014 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8015
8016 -static void inline arch_read_lock(arch_rwlock_t *lock)
8017 +static inline void arch_read_lock(arch_rwlock_t *lock)
8018 {
8019 unsigned long tmp1, tmp2;
8020
8021 __asm__ __volatile__ (
8022 "1: ldsw [%2], %0\n"
8023 " brlz,pn %0, 2f\n"
8024 -"4: add %0, 1, %1\n"
8025 +"4: addcc %0, 1, %1\n"
8026 +
8027 +#ifdef CONFIG_PAX_REFCOUNT
8028 +" tvs %%icc, 6\n"
8029 +#endif
8030 +
8031 " cas [%2], %0, %1\n"
8032 " cmp %0, %1\n"
8033 " bne,pn %%icc, 1b\n"
8034 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8035 " .previous"
8036 : "=&r" (tmp1), "=&r" (tmp2)
8037 : "r" (lock)
8038 - : "memory");
8039 + : "memory", "cc");
8040 }
8041
8042 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8043 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8044 {
8045 int tmp1, tmp2;
8046
8047 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8048 "1: ldsw [%2], %0\n"
8049 " brlz,a,pn %0, 2f\n"
8050 " mov 0, %0\n"
8051 -" add %0, 1, %1\n"
8052 +" addcc %0, 1, %1\n"
8053 +
8054 +#ifdef CONFIG_PAX_REFCOUNT
8055 +" tvs %%icc, 6\n"
8056 +#endif
8057 +
8058 " cas [%2], %0, %1\n"
8059 " cmp %0, %1\n"
8060 " bne,pn %%icc, 1b\n"
8061 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8062 return tmp1;
8063 }
8064
8065 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8066 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8067 {
8068 unsigned long tmp1, tmp2;
8069
8070 __asm__ __volatile__(
8071 "1: lduw [%2], %0\n"
8072 -" sub %0, 1, %1\n"
8073 +" subcc %0, 1, %1\n"
8074 +
8075 +#ifdef CONFIG_PAX_REFCOUNT
8076 +" tvs %%icc, 6\n"
8077 +#endif
8078 +
8079 " cas [%2], %0, %1\n"
8080 " cmp %0, %1\n"
8081 " bne,pn %%xcc, 1b\n"
8082 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8083 : "memory");
8084 }
8085
8086 -static void inline arch_write_lock(arch_rwlock_t *lock)
8087 +static inline void arch_write_lock(arch_rwlock_t *lock)
8088 {
8089 unsigned long mask, tmp1, tmp2;
8090
8091 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8092 : "memory");
8093 }
8094
8095 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8096 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8097 {
8098 __asm__ __volatile__(
8099 " stw %%g0, [%0]"
8100 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8101 : "memory");
8102 }
8103
8104 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8105 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8106 {
8107 unsigned long mask, tmp1, tmp2, result;
8108
8109 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8110 index dd38075..e7cac83 100644
8111 --- a/arch/sparc/include/asm/thread_info_32.h
8112 +++ b/arch/sparc/include/asm/thread_info_32.h
8113 @@ -49,6 +49,8 @@ struct thread_info {
8114 unsigned long w_saved;
8115
8116 struct restart_block restart_block;
8117 +
8118 + unsigned long lowest_stack;
8119 };
8120
8121 /*
8122 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8123 index d5e5042..9bfee76 100644
8124 --- a/arch/sparc/include/asm/thread_info_64.h
8125 +++ b/arch/sparc/include/asm/thread_info_64.h
8126 @@ -63,6 +63,8 @@ struct thread_info {
8127 struct pt_regs *kern_una_regs;
8128 unsigned int kern_una_insn;
8129
8130 + unsigned long lowest_stack;
8131 +
8132 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8133 };
8134
8135 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8136 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8137 /* flag bit 6 is available */
8138 #define TIF_32BIT 7 /* 32-bit binary */
8139 -/* flag bit 8 is available */
8140 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8141 #define TIF_SECCOMP 9 /* secure computing */
8142 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8143 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8144 +
8145 /* NOTE: Thread flags >= 12 should be ones we have no interest
8146 * in using in assembly, else we can't use the mask as
8147 * an immediate value in instructions such as andcc.
8148 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8149 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8150 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8151 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8152 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8153
8154 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8155 _TIF_DO_NOTIFY_RESUME_MASK | \
8156 _TIF_NEED_RESCHED)
8157 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8158
8159 +#define _TIF_WORK_SYSCALL \
8160 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8161 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8162 +
8163 +
8164 /*
8165 * Thread-synchronous status.
8166 *
8167 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8168 index 0167d26..767bb0c 100644
8169 --- a/arch/sparc/include/asm/uaccess.h
8170 +++ b/arch/sparc/include/asm/uaccess.h
8171 @@ -1,5 +1,6 @@
8172 #ifndef ___ASM_SPARC_UACCESS_H
8173 #define ___ASM_SPARC_UACCESS_H
8174 +
8175 #if defined(__sparc__) && defined(__arch64__)
8176 #include <asm/uaccess_64.h>
8177 #else
8178 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8179 index 53a28dd..50c38c3 100644
8180 --- a/arch/sparc/include/asm/uaccess_32.h
8181 +++ b/arch/sparc/include/asm/uaccess_32.h
8182 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8183
8184 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8185 {
8186 - if (n && __access_ok((unsigned long) to, n))
8187 + if ((long)n < 0)
8188 + return n;
8189 +
8190 + if (n && __access_ok((unsigned long) to, n)) {
8191 + if (!__builtin_constant_p(n))
8192 + check_object_size(from, n, true);
8193 return __copy_user(to, (__force void __user *) from, n);
8194 - else
8195 + } else
8196 return n;
8197 }
8198
8199 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8200 {
8201 + if ((long)n < 0)
8202 + return n;
8203 +
8204 + if (!__builtin_constant_p(n))
8205 + check_object_size(from, n, true);
8206 +
8207 return __copy_user(to, (__force void __user *) from, n);
8208 }
8209
8210 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8211 {
8212 - if (n && __access_ok((unsigned long) from, n))
8213 + if ((long)n < 0)
8214 + return n;
8215 +
8216 + if (n && __access_ok((unsigned long) from, n)) {
8217 + if (!__builtin_constant_p(n))
8218 + check_object_size(to, n, false);
8219 return __copy_user((__force void __user *) to, from, n);
8220 - else
8221 + } else
8222 return n;
8223 }
8224
8225 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8226 {
8227 + if ((long)n < 0)
8228 + return n;
8229 +
8230 return __copy_user((__force void __user *) to, from, n);
8231 }
8232
8233 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8234 index e562d3c..191f176 100644
8235 --- a/arch/sparc/include/asm/uaccess_64.h
8236 +++ b/arch/sparc/include/asm/uaccess_64.h
8237 @@ -10,6 +10,7 @@
8238 #include <linux/compiler.h>
8239 #include <linux/string.h>
8240 #include <linux/thread_info.h>
8241 +#include <linux/kernel.h>
8242 #include <asm/asi.h>
8243 #include <asm/spitfire.h>
8244 #include <asm-generic/uaccess-unaligned.h>
8245 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8246 static inline unsigned long __must_check
8247 copy_from_user(void *to, const void __user *from, unsigned long size)
8248 {
8249 - unsigned long ret = ___copy_from_user(to, from, size);
8250 + unsigned long ret;
8251
8252 + if ((long)size < 0 || size > INT_MAX)
8253 + return size;
8254 +
8255 + if (!__builtin_constant_p(size))
8256 + check_object_size(to, size, false);
8257 +
8258 + ret = ___copy_from_user(to, from, size);
8259 if (unlikely(ret))
8260 ret = copy_from_user_fixup(to, from, size);
8261
8262 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8263 static inline unsigned long __must_check
8264 copy_to_user(void __user *to, const void *from, unsigned long size)
8265 {
8266 - unsigned long ret = ___copy_to_user(to, from, size);
8267 + unsigned long ret;
8268
8269 + if ((long)size < 0 || size > INT_MAX)
8270 + return size;
8271 +
8272 + if (!__builtin_constant_p(size))
8273 + check_object_size(from, size, true);
8274 +
8275 + ret = ___copy_to_user(to, from, size);
8276 if (unlikely(ret))
8277 ret = copy_to_user_fixup(to, from, size);
8278 return ret;
8279 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8280 index d432fb2..6056af1 100644
8281 --- a/arch/sparc/kernel/Makefile
8282 +++ b/arch/sparc/kernel/Makefile
8283 @@ -3,7 +3,7 @@
8284 #
8285
8286 asflags-y := -ansi
8287 -ccflags-y := -Werror
8288 +#ccflags-y := -Werror
8289
8290 extra-y := head_$(BITS).o
8291
8292 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
8293 index 5ef48da..11d460f 100644
8294 --- a/arch/sparc/kernel/ds.c
8295 +++ b/arch/sparc/kernel/ds.c
8296 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
8297 char *base, *p;
8298 int msg_len, loops;
8299
8300 + if (strlen(var) + strlen(value) + 2 >
8301 + sizeof(pkt) - sizeof(pkt.header)) {
8302 + printk(KERN_ERR PFX
8303 + "contents length: %zu, which more than max: %lu,"
8304 + "so could not set (%s) variable to (%s).\n",
8305 + strlen(var) + strlen(value) + 2,
8306 + sizeof(pkt) - sizeof(pkt.header), var, value);
8307 + return;
8308 + }
8309 +
8310 memset(&pkt, 0, sizeof(pkt));
8311 pkt.header.data.tag.type = DS_DATA;
8312 pkt.header.data.handle = cp->handle;
8313 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8314 index fdd819d..5af08c8 100644
8315 --- a/arch/sparc/kernel/process_32.c
8316 +++ b/arch/sparc/kernel/process_32.c
8317 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8318
8319 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8320 r->psr, r->pc, r->npc, r->y, print_tainted());
8321 - printk("PC: <%pS>\n", (void *) r->pc);
8322 + printk("PC: <%pA>\n", (void *) r->pc);
8323 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8324 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8325 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8326 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8327 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8328 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8329 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8330 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8331
8332 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8333 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8334 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8335 rw = (struct reg_window32 *) fp;
8336 pc = rw->ins[7];
8337 printk("[%08lx : ", pc);
8338 - printk("%pS ] ", (void *) pc);
8339 + printk("%pA ] ", (void *) pc);
8340 fp = rw->ins[6];
8341 } while (++count < 16);
8342 printk("\n");
8343 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8344 index baebab2..9cd13b1 100644
8345 --- a/arch/sparc/kernel/process_64.c
8346 +++ b/arch/sparc/kernel/process_64.c
8347 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8348 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8349 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8350 if (regs->tstate & TSTATE_PRIV)
8351 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8352 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8353 }
8354
8355 void show_regs(struct pt_regs *regs)
8356 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8357
8358 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8359 regs->tpc, regs->tnpc, regs->y, print_tainted());
8360 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8361 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8362 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8363 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8364 regs->u_regs[3]);
8365 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8366 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8367 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8368 regs->u_regs[15]);
8369 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8370 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8371 show_regwindow(regs);
8372 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8373 }
8374 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8375 ((tp && tp->task) ? tp->task->pid : -1));
8376
8377 if (gp->tstate & TSTATE_PRIV) {
8378 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8379 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8380 (void *) gp->tpc,
8381 (void *) gp->o7,
8382 (void *) gp->i7,
8383 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8384 index 79cc0d1..ec62734 100644
8385 --- a/arch/sparc/kernel/prom_common.c
8386 +++ b/arch/sparc/kernel/prom_common.c
8387 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8388
8389 unsigned int prom_early_allocated __initdata;
8390
8391 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8392 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8393 .nextprop = prom_common_nextprop,
8394 .getproplen = prom_getproplen,
8395 .getproperty = prom_getproperty,
8396 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8397 index 7ff45e4..a58f271 100644
8398 --- a/arch/sparc/kernel/ptrace_64.c
8399 +++ b/arch/sparc/kernel/ptrace_64.c
8400 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8401 return ret;
8402 }
8403
8404 +#ifdef CONFIG_GRKERNSEC_SETXID
8405 +extern void gr_delayed_cred_worker(void);
8406 +#endif
8407 +
8408 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8409 {
8410 int ret = 0;
8411 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8412 /* do the secure computing check first */
8413 secure_computing_strict(regs->u_regs[UREG_G1]);
8414
8415 +#ifdef CONFIG_GRKERNSEC_SETXID
8416 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8417 + gr_delayed_cred_worker();
8418 +#endif
8419 +
8420 if (test_thread_flag(TIF_SYSCALL_TRACE))
8421 ret = tracehook_report_syscall_entry(regs);
8422
8423 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8424
8425 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8426 {
8427 +#ifdef CONFIG_GRKERNSEC_SETXID
8428 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8429 + gr_delayed_cred_worker();
8430 +#endif
8431 +
8432 audit_syscall_exit(regs);
8433
8434 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8435 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8436 index 3a8d184..49498a8 100644
8437 --- a/arch/sparc/kernel/sys_sparc_32.c
8438 +++ b/arch/sparc/kernel/sys_sparc_32.c
8439 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8440 if (len > TASK_SIZE - PAGE_SIZE)
8441 return -ENOMEM;
8442 if (!addr)
8443 - addr = TASK_UNMAPPED_BASE;
8444 + addr = current->mm->mmap_base;
8445
8446 info.flags = 0;
8447 info.length = len;
8448 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8449 index 2daaaa6..4fb84dc 100644
8450 --- a/arch/sparc/kernel/sys_sparc_64.c
8451 +++ b/arch/sparc/kernel/sys_sparc_64.c
8452 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8453 struct vm_area_struct * vma;
8454 unsigned long task_size = TASK_SIZE;
8455 int do_color_align;
8456 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8457 struct vm_unmapped_area_info info;
8458
8459 if (flags & MAP_FIXED) {
8460 /* We do not accept a shared mapping if it would violate
8461 * cache aliasing constraints.
8462 */
8463 - if ((flags & MAP_SHARED) &&
8464 + if ((filp || (flags & MAP_SHARED)) &&
8465 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8466 return -EINVAL;
8467 return addr;
8468 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8469 if (filp || (flags & MAP_SHARED))
8470 do_color_align = 1;
8471
8472 +#ifdef CONFIG_PAX_RANDMMAP
8473 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8474 +#endif
8475 +
8476 if (addr) {
8477 if (do_color_align)
8478 addr = COLOR_ALIGN(addr, pgoff);
8479 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8480 addr = PAGE_ALIGN(addr);
8481
8482 vma = find_vma(mm, addr);
8483 - if (task_size - len >= addr &&
8484 - (!vma || addr + len <= vma->vm_start))
8485 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8486 return addr;
8487 }
8488
8489 info.flags = 0;
8490 info.length = len;
8491 - info.low_limit = TASK_UNMAPPED_BASE;
8492 + info.low_limit = mm->mmap_base;
8493 info.high_limit = min(task_size, VA_EXCLUDE_START);
8494 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8495 info.align_offset = pgoff << PAGE_SHIFT;
8496 + info.threadstack_offset = offset;
8497 addr = vm_unmapped_area(&info);
8498
8499 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8500 VM_BUG_ON(addr != -ENOMEM);
8501 info.low_limit = VA_EXCLUDE_END;
8502 +
8503 +#ifdef CONFIG_PAX_RANDMMAP
8504 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8505 + info.low_limit += mm->delta_mmap;
8506 +#endif
8507 +
8508 info.high_limit = task_size;
8509 addr = vm_unmapped_area(&info);
8510 }
8511 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8512 unsigned long task_size = STACK_TOP32;
8513 unsigned long addr = addr0;
8514 int do_color_align;
8515 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8516 struct vm_unmapped_area_info info;
8517
8518 /* This should only ever run for 32-bit processes. */
8519 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8520 /* We do not accept a shared mapping if it would violate
8521 * cache aliasing constraints.
8522 */
8523 - if ((flags & MAP_SHARED) &&
8524 + if ((filp || (flags & MAP_SHARED)) &&
8525 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8526 return -EINVAL;
8527 return addr;
8528 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8529 if (filp || (flags & MAP_SHARED))
8530 do_color_align = 1;
8531
8532 +#ifdef CONFIG_PAX_RANDMMAP
8533 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8534 +#endif
8535 +
8536 /* requesting a specific address */
8537 if (addr) {
8538 if (do_color_align)
8539 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8540 addr = PAGE_ALIGN(addr);
8541
8542 vma = find_vma(mm, addr);
8543 - if (task_size - len >= addr &&
8544 - (!vma || addr + len <= vma->vm_start))
8545 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8546 return addr;
8547 }
8548
8549 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8550 info.high_limit = mm->mmap_base;
8551 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8552 info.align_offset = pgoff << PAGE_SHIFT;
8553 + info.threadstack_offset = offset;
8554 addr = vm_unmapped_area(&info);
8555
8556 /*
8557 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8558 VM_BUG_ON(addr != -ENOMEM);
8559 info.flags = 0;
8560 info.low_limit = TASK_UNMAPPED_BASE;
8561 +
8562 +#ifdef CONFIG_PAX_RANDMMAP
8563 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8564 + info.low_limit += mm->delta_mmap;
8565 +#endif
8566 +
8567 info.high_limit = STACK_TOP32;
8568 addr = vm_unmapped_area(&info);
8569 }
8570 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
8571 EXPORT_SYMBOL(get_fb_unmapped_area);
8572
8573 /* Essentially the same as PowerPC. */
8574 -static unsigned long mmap_rnd(void)
8575 +static unsigned long mmap_rnd(struct mm_struct *mm)
8576 {
8577 unsigned long rnd = 0UL;
8578
8579 +#ifdef CONFIG_PAX_RANDMMAP
8580 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8581 +#endif
8582 +
8583 if (current->flags & PF_RANDOMIZE) {
8584 unsigned long val = get_random_int();
8585 if (test_thread_flag(TIF_32BIT))
8586 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
8587
8588 void arch_pick_mmap_layout(struct mm_struct *mm)
8589 {
8590 - unsigned long random_factor = mmap_rnd();
8591 + unsigned long random_factor = mmap_rnd(mm);
8592 unsigned long gap;
8593
8594 /*
8595 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8596 gap == RLIM_INFINITY ||
8597 sysctl_legacy_va_layout) {
8598 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8599 +
8600 +#ifdef CONFIG_PAX_RANDMMAP
8601 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8602 + mm->mmap_base += mm->delta_mmap;
8603 +#endif
8604 +
8605 mm->get_unmapped_area = arch_get_unmapped_area;
8606 mm->unmap_area = arch_unmap_area;
8607 } else {
8608 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8609 gap = (task_size / 6 * 5);
8610
8611 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8612 +
8613 +#ifdef CONFIG_PAX_RANDMMAP
8614 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8615 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8616 +#endif
8617 +
8618 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8619 mm->unmap_area = arch_unmap_area_topdown;
8620 }
8621 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8622 index 22a1098..6255eb9 100644
8623 --- a/arch/sparc/kernel/syscalls.S
8624 +++ b/arch/sparc/kernel/syscalls.S
8625 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8626 #endif
8627 .align 32
8628 1: ldx [%g6 + TI_FLAGS], %l5
8629 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8630 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8631 be,pt %icc, rtrap
8632 nop
8633 call syscall_trace_leave
8634 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8635
8636 srl %i5, 0, %o5 ! IEU1
8637 srl %i2, 0, %o2 ! IEU0 Group
8638 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8639 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8640 bne,pn %icc, linux_syscall_trace32 ! CTI
8641 mov %i0, %l5 ! IEU1
8642 call %l7 ! CTI Group brk forced
8643 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8644
8645 mov %i3, %o3 ! IEU1
8646 mov %i4, %o4 ! IEU0 Group
8647 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8648 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8649 bne,pn %icc, linux_syscall_trace ! CTI Group
8650 mov %i0, %l5 ! IEU0
8651 2: call %l7 ! CTI Group brk forced
8652 @@ -223,7 +223,7 @@ ret_sys_call:
8653
8654 cmp %o0, -ERESTART_RESTARTBLOCK
8655 bgeu,pn %xcc, 1f
8656 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8657 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8658 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8659
8660 2:
8661 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8662 index 654e8aa..45f431b 100644
8663 --- a/arch/sparc/kernel/sysfs.c
8664 +++ b/arch/sparc/kernel/sysfs.c
8665 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8666 return NOTIFY_OK;
8667 }
8668
8669 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8670 +static struct notifier_block sysfs_cpu_nb = {
8671 .notifier_call = sysfs_cpu_notify,
8672 };
8673
8674 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8675 index 6629829..036032d 100644
8676 --- a/arch/sparc/kernel/traps_32.c
8677 +++ b/arch/sparc/kernel/traps_32.c
8678 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8679 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8680 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8681
8682 +extern void gr_handle_kernel_exploit(void);
8683 +
8684 void die_if_kernel(char *str, struct pt_regs *regs)
8685 {
8686 static int die_counter;
8687 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8688 count++ < 30 &&
8689 (((unsigned long) rw) >= PAGE_OFFSET) &&
8690 !(((unsigned long) rw) & 0x7)) {
8691 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8692 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8693 (void *) rw->ins[7]);
8694 rw = (struct reg_window32 *)rw->ins[6];
8695 }
8696 }
8697 printk("Instruction DUMP:");
8698 instruction_dump ((unsigned long *) regs->pc);
8699 - if(regs->psr & PSR_PS)
8700 + if(regs->psr & PSR_PS) {
8701 + gr_handle_kernel_exploit();
8702 do_exit(SIGKILL);
8703 + }
8704 do_exit(SIGSEGV);
8705 }
8706
8707 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8708 index b3f833a..ac74b2d 100644
8709 --- a/arch/sparc/kernel/traps_64.c
8710 +++ b/arch/sparc/kernel/traps_64.c
8711 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8712 i + 1,
8713 p->trapstack[i].tstate, p->trapstack[i].tpc,
8714 p->trapstack[i].tnpc, p->trapstack[i].tt);
8715 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8716 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8717 }
8718 }
8719
8720 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8721
8722 lvl -= 0x100;
8723 if (regs->tstate & TSTATE_PRIV) {
8724 +
8725 +#ifdef CONFIG_PAX_REFCOUNT
8726 + if (lvl == 6)
8727 + pax_report_refcount_overflow(regs);
8728 +#endif
8729 +
8730 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8731 die_if_kernel(buffer, regs);
8732 }
8733 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8734 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8735 {
8736 char buffer[32];
8737 -
8738 +
8739 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8740 0, lvl, SIGTRAP) == NOTIFY_STOP)
8741 return;
8742
8743 +#ifdef CONFIG_PAX_REFCOUNT
8744 + if (lvl == 6)
8745 + pax_report_refcount_overflow(regs);
8746 +#endif
8747 +
8748 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8749
8750 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8751 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8752 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8753 printk("%s" "ERROR(%d): ",
8754 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8755 - printk("TPC<%pS>\n", (void *) regs->tpc);
8756 + printk("TPC<%pA>\n", (void *) regs->tpc);
8757 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8758 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8759 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8760 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8761 smp_processor_id(),
8762 (type & 0x1) ? 'I' : 'D',
8763 regs->tpc);
8764 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8765 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8766 panic("Irrecoverable Cheetah+ parity error.");
8767 }
8768
8769 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8770 smp_processor_id(),
8771 (type & 0x1) ? 'I' : 'D',
8772 regs->tpc);
8773 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8774 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8775 }
8776
8777 struct sun4v_error_entry {
8778 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8779
8780 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8781 regs->tpc, tl);
8782 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8783 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8784 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8785 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8786 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8787 (void *) regs->u_regs[UREG_I7]);
8788 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8789 "pte[%lx] error[%lx]\n",
8790 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8791
8792 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8793 regs->tpc, tl);
8794 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8795 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8796 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8797 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8798 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8799 (void *) regs->u_regs[UREG_I7]);
8800 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8801 "pte[%lx] error[%lx]\n",
8802 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8803 fp = (unsigned long)sf->fp + STACK_BIAS;
8804 }
8805
8806 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8807 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8808 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8809 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8810 int index = tsk->curr_ret_stack;
8811 if (tsk->ret_stack && index >= graph) {
8812 pc = tsk->ret_stack[index - graph].ret;
8813 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8814 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8815 graph++;
8816 }
8817 }
8818 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8819 return (struct reg_window *) (fp + STACK_BIAS);
8820 }
8821
8822 +extern void gr_handle_kernel_exploit(void);
8823 +
8824 void die_if_kernel(char *str, struct pt_regs *regs)
8825 {
8826 static int die_counter;
8827 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8828 while (rw &&
8829 count++ < 30 &&
8830 kstack_valid(tp, (unsigned long) rw)) {
8831 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8832 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8833 (void *) rw->ins[7]);
8834
8835 rw = kernel_stack_up(rw);
8836 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8837 }
8838 user_instruction_dump ((unsigned int __user *) regs->tpc);
8839 }
8840 - if (regs->tstate & TSTATE_PRIV)
8841 + if (regs->tstate & TSTATE_PRIV) {
8842 + gr_handle_kernel_exploit();
8843 do_exit(SIGKILL);
8844 + }
8845 do_exit(SIGSEGV);
8846 }
8847 EXPORT_SYMBOL(die_if_kernel);
8848 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8849 index 8201c25e..072a2a7 100644
8850 --- a/arch/sparc/kernel/unaligned_64.c
8851 +++ b/arch/sparc/kernel/unaligned_64.c
8852 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8853 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8854
8855 if (__ratelimit(&ratelimit)) {
8856 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8857 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8858 regs->tpc, (void *) regs->tpc);
8859 }
8860 }
8861 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8862 index dbe119b..089c7c1 100644
8863 --- a/arch/sparc/lib/Makefile
8864 +++ b/arch/sparc/lib/Makefile
8865 @@ -2,7 +2,7 @@
8866 #
8867
8868 asflags-y := -ansi -DST_DIV0=0x02
8869 -ccflags-y := -Werror
8870 +#ccflags-y := -Werror
8871
8872 lib-$(CONFIG_SPARC32) += ashrdi3.o
8873 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8874 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8875 index 85c233d..68500e0 100644
8876 --- a/arch/sparc/lib/atomic_64.S
8877 +++ b/arch/sparc/lib/atomic_64.S
8878 @@ -17,7 +17,12 @@
8879 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8880 BACKOFF_SETUP(%o2)
8881 1: lduw [%o1], %g1
8882 - add %g1, %o0, %g7
8883 + addcc %g1, %o0, %g7
8884 +
8885 +#ifdef CONFIG_PAX_REFCOUNT
8886 + tvs %icc, 6
8887 +#endif
8888 +
8889 cas [%o1], %g1, %g7
8890 cmp %g1, %g7
8891 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8892 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8893 2: BACKOFF_SPIN(%o2, %o3, 1b)
8894 ENDPROC(atomic_add)
8895
8896 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8897 + BACKOFF_SETUP(%o2)
8898 +1: lduw [%o1], %g1
8899 + add %g1, %o0, %g7
8900 + cas [%o1], %g1, %g7
8901 + cmp %g1, %g7
8902 + bne,pn %icc, 2f
8903 + nop
8904 + retl
8905 + nop
8906 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8907 +ENDPROC(atomic_add_unchecked)
8908 +
8909 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8910 BACKOFF_SETUP(%o2)
8911 1: lduw [%o1], %g1
8912 - sub %g1, %o0, %g7
8913 + subcc %g1, %o0, %g7
8914 +
8915 +#ifdef CONFIG_PAX_REFCOUNT
8916 + tvs %icc, 6
8917 +#endif
8918 +
8919 cas [%o1], %g1, %g7
8920 cmp %g1, %g7
8921 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8922 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8923 2: BACKOFF_SPIN(%o2, %o3, 1b)
8924 ENDPROC(atomic_sub)
8925
8926 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8927 + BACKOFF_SETUP(%o2)
8928 +1: lduw [%o1], %g1
8929 + sub %g1, %o0, %g7
8930 + cas [%o1], %g1, %g7
8931 + cmp %g1, %g7
8932 + bne,pn %icc, 2f
8933 + nop
8934 + retl
8935 + nop
8936 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8937 +ENDPROC(atomic_sub_unchecked)
8938 +
8939 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8940 BACKOFF_SETUP(%o2)
8941 1: lduw [%o1], %g1
8942 - add %g1, %o0, %g7
8943 + addcc %g1, %o0, %g7
8944 +
8945 +#ifdef CONFIG_PAX_REFCOUNT
8946 + tvs %icc, 6
8947 +#endif
8948 +
8949 cas [%o1], %g1, %g7
8950 cmp %g1, %g7
8951 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8952 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8953 2: BACKOFF_SPIN(%o2, %o3, 1b)
8954 ENDPROC(atomic_add_ret)
8955
8956 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8957 + BACKOFF_SETUP(%o2)
8958 +1: lduw [%o1], %g1
8959 + addcc %g1, %o0, %g7
8960 + cas [%o1], %g1, %g7
8961 + cmp %g1, %g7
8962 + bne,pn %icc, 2f
8963 + add %g7, %o0, %g7
8964 + sra %g7, 0, %o0
8965 + retl
8966 + nop
8967 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8968 +ENDPROC(atomic_add_ret_unchecked)
8969 +
8970 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8971 BACKOFF_SETUP(%o2)
8972 1: lduw [%o1], %g1
8973 - sub %g1, %o0, %g7
8974 + subcc %g1, %o0, %g7
8975 +
8976 +#ifdef CONFIG_PAX_REFCOUNT
8977 + tvs %icc, 6
8978 +#endif
8979 +
8980 cas [%o1], %g1, %g7
8981 cmp %g1, %g7
8982 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8983 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8984 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8985 BACKOFF_SETUP(%o2)
8986 1: ldx [%o1], %g1
8987 - add %g1, %o0, %g7
8988 + addcc %g1, %o0, %g7
8989 +
8990 +#ifdef CONFIG_PAX_REFCOUNT
8991 + tvs %xcc, 6
8992 +#endif
8993 +
8994 casx [%o1], %g1, %g7
8995 cmp %g1, %g7
8996 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8997 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8998 2: BACKOFF_SPIN(%o2, %o3, 1b)
8999 ENDPROC(atomic64_add)
9000
9001 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9002 + BACKOFF_SETUP(%o2)
9003 +1: ldx [%o1], %g1
9004 + addcc %g1, %o0, %g7
9005 + casx [%o1], %g1, %g7
9006 + cmp %g1, %g7
9007 + bne,pn %xcc, 2f
9008 + nop
9009 + retl
9010 + nop
9011 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9012 +ENDPROC(atomic64_add_unchecked)
9013 +
9014 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9015 BACKOFF_SETUP(%o2)
9016 1: ldx [%o1], %g1
9017 - sub %g1, %o0, %g7
9018 + subcc %g1, %o0, %g7
9019 +
9020 +#ifdef CONFIG_PAX_REFCOUNT
9021 + tvs %xcc, 6
9022 +#endif
9023 +
9024 casx [%o1], %g1, %g7
9025 cmp %g1, %g7
9026 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9027 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9028 2: BACKOFF_SPIN(%o2, %o3, 1b)
9029 ENDPROC(atomic64_sub)
9030
9031 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9032 + BACKOFF_SETUP(%o2)
9033 +1: ldx [%o1], %g1
9034 + subcc %g1, %o0, %g7
9035 + casx [%o1], %g1, %g7
9036 + cmp %g1, %g7
9037 + bne,pn %xcc, 2f
9038 + nop
9039 + retl
9040 + nop
9041 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9042 +ENDPROC(atomic64_sub_unchecked)
9043 +
9044 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9045 BACKOFF_SETUP(%o2)
9046 1: ldx [%o1], %g1
9047 - add %g1, %o0, %g7
9048 + addcc %g1, %o0, %g7
9049 +
9050 +#ifdef CONFIG_PAX_REFCOUNT
9051 + tvs %xcc, 6
9052 +#endif
9053 +
9054 casx [%o1], %g1, %g7
9055 cmp %g1, %g7
9056 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9057 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9058 2: BACKOFF_SPIN(%o2, %o3, 1b)
9059 ENDPROC(atomic64_add_ret)
9060
9061 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9062 + BACKOFF_SETUP(%o2)
9063 +1: ldx [%o1], %g1
9064 + addcc %g1, %o0, %g7
9065 + casx [%o1], %g1, %g7
9066 + cmp %g1, %g7
9067 + bne,pn %xcc, 2f
9068 + add %g7, %o0, %g7
9069 + mov %g7, %o0
9070 + retl
9071 + nop
9072 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9073 +ENDPROC(atomic64_add_ret_unchecked)
9074 +
9075 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9076 BACKOFF_SETUP(%o2)
9077 1: ldx [%o1], %g1
9078 - sub %g1, %o0, %g7
9079 + subcc %g1, %o0, %g7
9080 +
9081 +#ifdef CONFIG_PAX_REFCOUNT
9082 + tvs %xcc, 6
9083 +#endif
9084 +
9085 casx [%o1], %g1, %g7
9086 cmp %g1, %g7
9087 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9088 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9089 index 0c4e35e..745d3e4 100644
9090 --- a/arch/sparc/lib/ksyms.c
9091 +++ b/arch/sparc/lib/ksyms.c
9092 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9093
9094 /* Atomic counter implementation. */
9095 EXPORT_SYMBOL(atomic_add);
9096 +EXPORT_SYMBOL(atomic_add_unchecked);
9097 EXPORT_SYMBOL(atomic_add_ret);
9098 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9099 EXPORT_SYMBOL(atomic_sub);
9100 +EXPORT_SYMBOL(atomic_sub_unchecked);
9101 EXPORT_SYMBOL(atomic_sub_ret);
9102 EXPORT_SYMBOL(atomic64_add);
9103 +EXPORT_SYMBOL(atomic64_add_unchecked);
9104 EXPORT_SYMBOL(atomic64_add_ret);
9105 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9106 EXPORT_SYMBOL(atomic64_sub);
9107 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9108 EXPORT_SYMBOL(atomic64_sub_ret);
9109 EXPORT_SYMBOL(atomic64_dec_if_positive);
9110
9111 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9112 index 30c3ecc..736f015 100644
9113 --- a/arch/sparc/mm/Makefile
9114 +++ b/arch/sparc/mm/Makefile
9115 @@ -2,7 +2,7 @@
9116 #
9117
9118 asflags-y := -ansi
9119 -ccflags-y := -Werror
9120 +#ccflags-y := -Werror
9121
9122 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9123 obj-y += fault_$(BITS).o
9124 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9125 index e98bfda..ea8d221 100644
9126 --- a/arch/sparc/mm/fault_32.c
9127 +++ b/arch/sparc/mm/fault_32.c
9128 @@ -21,6 +21,9 @@
9129 #include <linux/perf_event.h>
9130 #include <linux/interrupt.h>
9131 #include <linux/kdebug.h>
9132 +#include <linux/slab.h>
9133 +#include <linux/pagemap.h>
9134 +#include <linux/compiler.h>
9135
9136 #include <asm/page.h>
9137 #include <asm/pgtable.h>
9138 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9139 return safe_compute_effective_address(regs, insn);
9140 }
9141
9142 +#ifdef CONFIG_PAX_PAGEEXEC
9143 +#ifdef CONFIG_PAX_DLRESOLVE
9144 +static void pax_emuplt_close(struct vm_area_struct *vma)
9145 +{
9146 + vma->vm_mm->call_dl_resolve = 0UL;
9147 +}
9148 +
9149 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9150 +{
9151 + unsigned int *kaddr;
9152 +
9153 + vmf->page = alloc_page(GFP_HIGHUSER);
9154 + if (!vmf->page)
9155 + return VM_FAULT_OOM;
9156 +
9157 + kaddr = kmap(vmf->page);
9158 + memset(kaddr, 0, PAGE_SIZE);
9159 + kaddr[0] = 0x9DE3BFA8U; /* save */
9160 + flush_dcache_page(vmf->page);
9161 + kunmap(vmf->page);
9162 + return VM_FAULT_MAJOR;
9163 +}
9164 +
9165 +static const struct vm_operations_struct pax_vm_ops = {
9166 + .close = pax_emuplt_close,
9167 + .fault = pax_emuplt_fault
9168 +};
9169 +
9170 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9171 +{
9172 + int ret;
9173 +
9174 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9175 + vma->vm_mm = current->mm;
9176 + vma->vm_start = addr;
9177 + vma->vm_end = addr + PAGE_SIZE;
9178 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9179 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9180 + vma->vm_ops = &pax_vm_ops;
9181 +
9182 + ret = insert_vm_struct(current->mm, vma);
9183 + if (ret)
9184 + return ret;
9185 +
9186 + ++current->mm->total_vm;
9187 + return 0;
9188 +}
9189 +#endif
9190 +
9191 +/*
9192 + * PaX: decide what to do with offenders (regs->pc = fault address)
9193 + *
9194 + * returns 1 when task should be killed
9195 + * 2 when patched PLT trampoline was detected
9196 + * 3 when unpatched PLT trampoline was detected
9197 + */
9198 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9199 +{
9200 +
9201 +#ifdef CONFIG_PAX_EMUPLT
9202 + int err;
9203 +
9204 + do { /* PaX: patched PLT emulation #1 */
9205 + unsigned int sethi1, sethi2, jmpl;
9206 +
9207 + err = get_user(sethi1, (unsigned int *)regs->pc);
9208 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9209 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9210 +
9211 + if (err)
9212 + break;
9213 +
9214 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9215 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9216 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9217 + {
9218 + unsigned int addr;
9219 +
9220 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9221 + addr = regs->u_regs[UREG_G1];
9222 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9223 + regs->pc = addr;
9224 + regs->npc = addr+4;
9225 + return 2;
9226 + }
9227 + } while (0);
9228 +
9229 + do { /* PaX: patched PLT emulation #2 */
9230 + unsigned int ba;
9231 +
9232 + err = get_user(ba, (unsigned int *)regs->pc);
9233 +
9234 + if (err)
9235 + break;
9236 +
9237 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9238 + unsigned int addr;
9239 +
9240 + if ((ba & 0xFFC00000U) == 0x30800000U)
9241 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9242 + else
9243 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9244 + regs->pc = addr;
9245 + regs->npc = addr+4;
9246 + return 2;
9247 + }
9248 + } while (0);
9249 +
9250 + do { /* PaX: patched PLT emulation #3 */
9251 + unsigned int sethi, bajmpl, nop;
9252 +
9253 + err = get_user(sethi, (unsigned int *)regs->pc);
9254 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9255 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9256 +
9257 + if (err)
9258 + break;
9259 +
9260 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9261 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9262 + nop == 0x01000000U)
9263 + {
9264 + unsigned int addr;
9265 +
9266 + addr = (sethi & 0x003FFFFFU) << 10;
9267 + regs->u_regs[UREG_G1] = addr;
9268 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9269 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9270 + else
9271 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9272 + regs->pc = addr;
9273 + regs->npc = addr+4;
9274 + return 2;
9275 + }
9276 + } while (0);
9277 +
9278 + do { /* PaX: unpatched PLT emulation step 1 */
9279 + unsigned int sethi, ba, nop;
9280 +
9281 + err = get_user(sethi, (unsigned int *)regs->pc);
9282 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9283 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9284 +
9285 + if (err)
9286 + break;
9287 +
9288 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9289 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9290 + nop == 0x01000000U)
9291 + {
9292 + unsigned int addr, save, call;
9293 +
9294 + if ((ba & 0xFFC00000U) == 0x30800000U)
9295 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9296 + else
9297 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9298 +
9299 + err = get_user(save, (unsigned int *)addr);
9300 + err |= get_user(call, (unsigned int *)(addr+4));
9301 + err |= get_user(nop, (unsigned int *)(addr+8));
9302 + if (err)
9303 + break;
9304 +
9305 +#ifdef CONFIG_PAX_DLRESOLVE
9306 + if (save == 0x9DE3BFA8U &&
9307 + (call & 0xC0000000U) == 0x40000000U &&
9308 + nop == 0x01000000U)
9309 + {
9310 + struct vm_area_struct *vma;
9311 + unsigned long call_dl_resolve;
9312 +
9313 + down_read(&current->mm->mmap_sem);
9314 + call_dl_resolve = current->mm->call_dl_resolve;
9315 + up_read(&current->mm->mmap_sem);
9316 + if (likely(call_dl_resolve))
9317 + goto emulate;
9318 +
9319 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9320 +
9321 + down_write(&current->mm->mmap_sem);
9322 + if (current->mm->call_dl_resolve) {
9323 + call_dl_resolve = current->mm->call_dl_resolve;
9324 + up_write(&current->mm->mmap_sem);
9325 + if (vma)
9326 + kmem_cache_free(vm_area_cachep, vma);
9327 + goto emulate;
9328 + }
9329 +
9330 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9331 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9332 + up_write(&current->mm->mmap_sem);
9333 + if (vma)
9334 + kmem_cache_free(vm_area_cachep, vma);
9335 + return 1;
9336 + }
9337 +
9338 + if (pax_insert_vma(vma, call_dl_resolve)) {
9339 + up_write(&current->mm->mmap_sem);
9340 + kmem_cache_free(vm_area_cachep, vma);
9341 + return 1;
9342 + }
9343 +
9344 + current->mm->call_dl_resolve = call_dl_resolve;
9345 + up_write(&current->mm->mmap_sem);
9346 +
9347 +emulate:
9348 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9349 + regs->pc = call_dl_resolve;
9350 + regs->npc = addr+4;
9351 + return 3;
9352 + }
9353 +#endif
9354 +
9355 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9356 + if ((save & 0xFFC00000U) == 0x05000000U &&
9357 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9358 + nop == 0x01000000U)
9359 + {
9360 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9361 + regs->u_regs[UREG_G2] = addr + 4;
9362 + addr = (save & 0x003FFFFFU) << 10;
9363 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9364 + regs->pc = addr;
9365 + regs->npc = addr+4;
9366 + return 3;
9367 + }
9368 + }
9369 + } while (0);
9370 +
9371 + do { /* PaX: unpatched PLT emulation step 2 */
9372 + unsigned int save, call, nop;
9373 +
9374 + err = get_user(save, (unsigned int *)(regs->pc-4));
9375 + err |= get_user(call, (unsigned int *)regs->pc);
9376 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9377 + if (err)
9378 + break;
9379 +
9380 + if (save == 0x9DE3BFA8U &&
9381 + (call & 0xC0000000U) == 0x40000000U &&
9382 + nop == 0x01000000U)
9383 + {
9384 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9385 +
9386 + regs->u_regs[UREG_RETPC] = regs->pc;
9387 + regs->pc = dl_resolve;
9388 + regs->npc = dl_resolve+4;
9389 + return 3;
9390 + }
9391 + } while (0);
9392 +#endif
9393 +
9394 + return 1;
9395 +}
9396 +
9397 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9398 +{
9399 + unsigned long i;
9400 +
9401 + printk(KERN_ERR "PAX: bytes at PC: ");
9402 + for (i = 0; i < 8; i++) {
9403 + unsigned int c;
9404 + if (get_user(c, (unsigned int *)pc+i))
9405 + printk(KERN_CONT "???????? ");
9406 + else
9407 + printk(KERN_CONT "%08x ", c);
9408 + }
9409 + printk("\n");
9410 +}
9411 +#endif
9412 +
9413 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9414 int text_fault)
9415 {
9416 @@ -230,6 +504,24 @@ good_area:
9417 if (!(vma->vm_flags & VM_WRITE))
9418 goto bad_area;
9419 } else {
9420 +
9421 +#ifdef CONFIG_PAX_PAGEEXEC
9422 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9423 + up_read(&mm->mmap_sem);
9424 + switch (pax_handle_fetch_fault(regs)) {
9425 +
9426 +#ifdef CONFIG_PAX_EMUPLT
9427 + case 2:
9428 + case 3:
9429 + return;
9430 +#endif
9431 +
9432 + }
9433 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9434 + do_group_exit(SIGKILL);
9435 + }
9436 +#endif
9437 +
9438 /* Allow reads even for write-only mappings */
9439 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9440 goto bad_area;
9441 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9442 index 5062ff3..e0b75f3 100644
9443 --- a/arch/sparc/mm/fault_64.c
9444 +++ b/arch/sparc/mm/fault_64.c
9445 @@ -21,6 +21,9 @@
9446 #include <linux/kprobes.h>
9447 #include <linux/kdebug.h>
9448 #include <linux/percpu.h>
9449 +#include <linux/slab.h>
9450 +#include <linux/pagemap.h>
9451 +#include <linux/compiler.h>
9452
9453 #include <asm/page.h>
9454 #include <asm/pgtable.h>
9455 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9456 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9457 regs->tpc);
9458 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9459 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9460 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9461 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9462 dump_stack();
9463 unhandled_fault(regs->tpc, current, regs);
9464 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9465 show_regs(regs);
9466 }
9467
9468 +#ifdef CONFIG_PAX_PAGEEXEC
9469 +#ifdef CONFIG_PAX_DLRESOLVE
9470 +static void pax_emuplt_close(struct vm_area_struct *vma)
9471 +{
9472 + vma->vm_mm->call_dl_resolve = 0UL;
9473 +}
9474 +
9475 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9476 +{
9477 + unsigned int *kaddr;
9478 +
9479 + vmf->page = alloc_page(GFP_HIGHUSER);
9480 + if (!vmf->page)
9481 + return VM_FAULT_OOM;
9482 +
9483 + kaddr = kmap(vmf->page);
9484 + memset(kaddr, 0, PAGE_SIZE);
9485 + kaddr[0] = 0x9DE3BFA8U; /* save */
9486 + flush_dcache_page(vmf->page);
9487 + kunmap(vmf->page);
9488 + return VM_FAULT_MAJOR;
9489 +}
9490 +
9491 +static const struct vm_operations_struct pax_vm_ops = {
9492 + .close = pax_emuplt_close,
9493 + .fault = pax_emuplt_fault
9494 +};
9495 +
9496 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9497 +{
9498 + int ret;
9499 +
9500 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9501 + vma->vm_mm = current->mm;
9502 + vma->vm_start = addr;
9503 + vma->vm_end = addr + PAGE_SIZE;
9504 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9505 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9506 + vma->vm_ops = &pax_vm_ops;
9507 +
9508 + ret = insert_vm_struct(current->mm, vma);
9509 + if (ret)
9510 + return ret;
9511 +
9512 + ++current->mm->total_vm;
9513 + return 0;
9514 +}
9515 +#endif
9516 +
9517 +/*
9518 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9519 + *
9520 + * returns 1 when task should be killed
9521 + * 2 when patched PLT trampoline was detected
9522 + * 3 when unpatched PLT trampoline was detected
9523 + */
9524 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9525 +{
9526 +
9527 +#ifdef CONFIG_PAX_EMUPLT
9528 + int err;
9529 +
9530 + do { /* PaX: patched PLT emulation #1 */
9531 + unsigned int sethi1, sethi2, jmpl;
9532 +
9533 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9534 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9535 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9536 +
9537 + if (err)
9538 + break;
9539 +
9540 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9541 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9542 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9543 + {
9544 + unsigned long addr;
9545 +
9546 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9547 + addr = regs->u_regs[UREG_G1];
9548 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9549 +
9550 + if (test_thread_flag(TIF_32BIT))
9551 + addr &= 0xFFFFFFFFUL;
9552 +
9553 + regs->tpc = addr;
9554 + regs->tnpc = addr+4;
9555 + return 2;
9556 + }
9557 + } while (0);
9558 +
9559 + do { /* PaX: patched PLT emulation #2 */
9560 + unsigned int ba;
9561 +
9562 + err = get_user(ba, (unsigned int *)regs->tpc);
9563 +
9564 + if (err)
9565 + break;
9566 +
9567 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9568 + unsigned long addr;
9569 +
9570 + if ((ba & 0xFFC00000U) == 0x30800000U)
9571 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9572 + else
9573 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9574 +
9575 + if (test_thread_flag(TIF_32BIT))
9576 + addr &= 0xFFFFFFFFUL;
9577 +
9578 + regs->tpc = addr;
9579 + regs->tnpc = addr+4;
9580 + return 2;
9581 + }
9582 + } while (0);
9583 +
9584 + do { /* PaX: patched PLT emulation #3 */
9585 + unsigned int sethi, bajmpl, nop;
9586 +
9587 + err = get_user(sethi, (unsigned int *)regs->tpc);
9588 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9589 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9590 +
9591 + if (err)
9592 + break;
9593 +
9594 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9595 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9596 + nop == 0x01000000U)
9597 + {
9598 + unsigned long addr;
9599 +
9600 + addr = (sethi & 0x003FFFFFU) << 10;
9601 + regs->u_regs[UREG_G1] = addr;
9602 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9603 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9604 + else
9605 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9606 +
9607 + if (test_thread_flag(TIF_32BIT))
9608 + addr &= 0xFFFFFFFFUL;
9609 +
9610 + regs->tpc = addr;
9611 + regs->tnpc = addr+4;
9612 + return 2;
9613 + }
9614 + } while (0);
9615 +
9616 + do { /* PaX: patched PLT emulation #4 */
9617 + unsigned int sethi, mov1, call, mov2;
9618 +
9619 + err = get_user(sethi, (unsigned int *)regs->tpc);
9620 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9621 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9622 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9623 +
9624 + if (err)
9625 + break;
9626 +
9627 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9628 + mov1 == 0x8210000FU &&
9629 + (call & 0xC0000000U) == 0x40000000U &&
9630 + mov2 == 0x9E100001U)
9631 + {
9632 + unsigned long addr;
9633 +
9634 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9635 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9636 +
9637 + if (test_thread_flag(TIF_32BIT))
9638 + addr &= 0xFFFFFFFFUL;
9639 +
9640 + regs->tpc = addr;
9641 + regs->tnpc = addr+4;
9642 + return 2;
9643 + }
9644 + } while (0);
9645 +
9646 + do { /* PaX: patched PLT emulation #5 */
9647 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9648 +
9649 + err = get_user(sethi, (unsigned int *)regs->tpc);
9650 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9651 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9652 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9653 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9654 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9655 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9656 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9657 +
9658 + if (err)
9659 + break;
9660 +
9661 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9662 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9663 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9664 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9665 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9666 + sllx == 0x83287020U &&
9667 + jmpl == 0x81C04005U &&
9668 + nop == 0x01000000U)
9669 + {
9670 + unsigned long addr;
9671 +
9672 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9673 + regs->u_regs[UREG_G1] <<= 32;
9674 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9675 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9676 + regs->tpc = addr;
9677 + regs->tnpc = addr+4;
9678 + return 2;
9679 + }
9680 + } while (0);
9681 +
9682 + do { /* PaX: patched PLT emulation #6 */
9683 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9684 +
9685 + err = get_user(sethi, (unsigned int *)regs->tpc);
9686 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9687 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9688 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9689 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9690 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9691 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9692 +
9693 + if (err)
9694 + break;
9695 +
9696 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9697 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9698 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9699 + sllx == 0x83287020U &&
9700 + (or & 0xFFFFE000U) == 0x8A116000U &&
9701 + jmpl == 0x81C04005U &&
9702 + nop == 0x01000000U)
9703 + {
9704 + unsigned long addr;
9705 +
9706 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9707 + regs->u_regs[UREG_G1] <<= 32;
9708 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9709 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9710 + regs->tpc = addr;
9711 + regs->tnpc = addr+4;
9712 + return 2;
9713 + }
9714 + } while (0);
9715 +
9716 + do { /* PaX: unpatched PLT emulation step 1 */
9717 + unsigned int sethi, ba, nop;
9718 +
9719 + err = get_user(sethi, (unsigned int *)regs->tpc);
9720 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9721 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9722 +
9723 + if (err)
9724 + break;
9725 +
9726 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9727 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9728 + nop == 0x01000000U)
9729 + {
9730 + unsigned long addr;
9731 + unsigned int save, call;
9732 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9733 +
9734 + if ((ba & 0xFFC00000U) == 0x30800000U)
9735 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9736 + else
9737 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9738 +
9739 + if (test_thread_flag(TIF_32BIT))
9740 + addr &= 0xFFFFFFFFUL;
9741 +
9742 + err = get_user(save, (unsigned int *)addr);
9743 + err |= get_user(call, (unsigned int *)(addr+4));
9744 + err |= get_user(nop, (unsigned int *)(addr+8));
9745 + if (err)
9746 + break;
9747 +
9748 +#ifdef CONFIG_PAX_DLRESOLVE
9749 + if (save == 0x9DE3BFA8U &&
9750 + (call & 0xC0000000U) == 0x40000000U &&
9751 + nop == 0x01000000U)
9752 + {
9753 + struct vm_area_struct *vma;
9754 + unsigned long call_dl_resolve;
9755 +
9756 + down_read(&current->mm->mmap_sem);
9757 + call_dl_resolve = current->mm->call_dl_resolve;
9758 + up_read(&current->mm->mmap_sem);
9759 + if (likely(call_dl_resolve))
9760 + goto emulate;
9761 +
9762 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9763 +
9764 + down_write(&current->mm->mmap_sem);
9765 + if (current->mm->call_dl_resolve) {
9766 + call_dl_resolve = current->mm->call_dl_resolve;
9767 + up_write(&current->mm->mmap_sem);
9768 + if (vma)
9769 + kmem_cache_free(vm_area_cachep, vma);
9770 + goto emulate;
9771 + }
9772 +
9773 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9774 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9775 + up_write(&current->mm->mmap_sem);
9776 + if (vma)
9777 + kmem_cache_free(vm_area_cachep, vma);
9778 + return 1;
9779 + }
9780 +
9781 + if (pax_insert_vma(vma, call_dl_resolve)) {
9782 + up_write(&current->mm->mmap_sem);
9783 + kmem_cache_free(vm_area_cachep, vma);
9784 + return 1;
9785 + }
9786 +
9787 + current->mm->call_dl_resolve = call_dl_resolve;
9788 + up_write(&current->mm->mmap_sem);
9789 +
9790 +emulate:
9791 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9792 + regs->tpc = call_dl_resolve;
9793 + regs->tnpc = addr+4;
9794 + return 3;
9795 + }
9796 +#endif
9797 +
9798 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9799 + if ((save & 0xFFC00000U) == 0x05000000U &&
9800 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9801 + nop == 0x01000000U)
9802 + {
9803 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9804 + regs->u_regs[UREG_G2] = addr + 4;
9805 + addr = (save & 0x003FFFFFU) << 10;
9806 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9807 +
9808 + if (test_thread_flag(TIF_32BIT))
9809 + addr &= 0xFFFFFFFFUL;
9810 +
9811 + regs->tpc = addr;
9812 + regs->tnpc = addr+4;
9813 + return 3;
9814 + }
9815 +
9816 + /* PaX: 64-bit PLT stub */
9817 + err = get_user(sethi1, (unsigned int *)addr);
9818 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9819 + err |= get_user(or1, (unsigned int *)(addr+8));
9820 + err |= get_user(or2, (unsigned int *)(addr+12));
9821 + err |= get_user(sllx, (unsigned int *)(addr+16));
9822 + err |= get_user(add, (unsigned int *)(addr+20));
9823 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9824 + err |= get_user(nop, (unsigned int *)(addr+28));
9825 + if (err)
9826 + break;
9827 +
9828 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9829 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9830 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9831 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9832 + sllx == 0x89293020U &&
9833 + add == 0x8A010005U &&
9834 + jmpl == 0x89C14000U &&
9835 + nop == 0x01000000U)
9836 + {
9837 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9838 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9839 + regs->u_regs[UREG_G4] <<= 32;
9840 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9841 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9842 + regs->u_regs[UREG_G4] = addr + 24;
9843 + addr = regs->u_regs[UREG_G5];
9844 + regs->tpc = addr;
9845 + regs->tnpc = addr+4;
9846 + return 3;
9847 + }
9848 + }
9849 + } while (0);
9850 +
9851 +#ifdef CONFIG_PAX_DLRESOLVE
9852 + do { /* PaX: unpatched PLT emulation step 2 */
9853 + unsigned int save, call, nop;
9854 +
9855 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9856 + err |= get_user(call, (unsigned int *)regs->tpc);
9857 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9858 + if (err)
9859 + break;
9860 +
9861 + if (save == 0x9DE3BFA8U &&
9862 + (call & 0xC0000000U) == 0x40000000U &&
9863 + nop == 0x01000000U)
9864 + {
9865 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9866 +
9867 + if (test_thread_flag(TIF_32BIT))
9868 + dl_resolve &= 0xFFFFFFFFUL;
9869 +
9870 + regs->u_regs[UREG_RETPC] = regs->tpc;
9871 + regs->tpc = dl_resolve;
9872 + regs->tnpc = dl_resolve+4;
9873 + return 3;
9874 + }
9875 + } while (0);
9876 +#endif
9877 +
9878 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9879 + unsigned int sethi, ba, nop;
9880 +
9881 + err = get_user(sethi, (unsigned int *)regs->tpc);
9882 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9883 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9884 +
9885 + if (err)
9886 + break;
9887 +
9888 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9889 + (ba & 0xFFF00000U) == 0x30600000U &&
9890 + nop == 0x01000000U)
9891 + {
9892 + unsigned long addr;
9893 +
9894 + addr = (sethi & 0x003FFFFFU) << 10;
9895 + regs->u_regs[UREG_G1] = addr;
9896 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9897 +
9898 + if (test_thread_flag(TIF_32BIT))
9899 + addr &= 0xFFFFFFFFUL;
9900 +
9901 + regs->tpc = addr;
9902 + regs->tnpc = addr+4;
9903 + return 2;
9904 + }
9905 + } while (0);
9906 +
9907 +#endif
9908 +
9909 + return 1;
9910 +}
9911 +
9912 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9913 +{
9914 + unsigned long i;
9915 +
9916 + printk(KERN_ERR "PAX: bytes at PC: ");
9917 + for (i = 0; i < 8; i++) {
9918 + unsigned int c;
9919 + if (get_user(c, (unsigned int *)pc+i))
9920 + printk(KERN_CONT "???????? ");
9921 + else
9922 + printk(KERN_CONT "%08x ", c);
9923 + }
9924 + printk("\n");
9925 +}
9926 +#endif
9927 +
9928 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9929 {
9930 struct mm_struct *mm = current->mm;
9931 @@ -341,6 +804,29 @@ retry:
9932 if (!vma)
9933 goto bad_area;
9934
9935 +#ifdef CONFIG_PAX_PAGEEXEC
9936 + /* PaX: detect ITLB misses on non-exec pages */
9937 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9938 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9939 + {
9940 + if (address != regs->tpc)
9941 + goto good_area;
9942 +
9943 + up_read(&mm->mmap_sem);
9944 + switch (pax_handle_fetch_fault(regs)) {
9945 +
9946 +#ifdef CONFIG_PAX_EMUPLT
9947 + case 2:
9948 + case 3:
9949 + return;
9950 +#endif
9951 +
9952 + }
9953 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9954 + do_group_exit(SIGKILL);
9955 + }
9956 +#endif
9957 +
9958 /* Pure DTLB misses do not tell us whether the fault causing
9959 * load/store/atomic was a write or not, it only says that there
9960 * was no match. So in such a case we (carefully) read the
9961 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9962 index d2b5944..bd813f2 100644
9963 --- a/arch/sparc/mm/hugetlbpage.c
9964 +++ b/arch/sparc/mm/hugetlbpage.c
9965 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9966
9967 info.flags = 0;
9968 info.length = len;
9969 - info.low_limit = TASK_UNMAPPED_BASE;
9970 + info.low_limit = mm->mmap_base;
9971 info.high_limit = min(task_size, VA_EXCLUDE_START);
9972 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9973 info.align_offset = 0;
9974 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9975 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9976 VM_BUG_ON(addr != -ENOMEM);
9977 info.low_limit = VA_EXCLUDE_END;
9978 +
9979 +#ifdef CONFIG_PAX_RANDMMAP
9980 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9981 + info.low_limit += mm->delta_mmap;
9982 +#endif
9983 +
9984 info.high_limit = task_size;
9985 addr = vm_unmapped_area(&info);
9986 }
9987 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9988 VM_BUG_ON(addr != -ENOMEM);
9989 info.flags = 0;
9990 info.low_limit = TASK_UNMAPPED_BASE;
9991 +
9992 +#ifdef CONFIG_PAX_RANDMMAP
9993 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9994 + info.low_limit += mm->delta_mmap;
9995 +#endif
9996 +
9997 info.high_limit = STACK_TOP32;
9998 addr = vm_unmapped_area(&info);
9999 }
10000 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10001 struct mm_struct *mm = current->mm;
10002 struct vm_area_struct *vma;
10003 unsigned long task_size = TASK_SIZE;
10004 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10005
10006 if (test_thread_flag(TIF_32BIT))
10007 task_size = STACK_TOP32;
10008 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10009 return addr;
10010 }
10011
10012 +#ifdef CONFIG_PAX_RANDMMAP
10013 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10014 +#endif
10015 +
10016 if (addr) {
10017 addr = ALIGN(addr, HPAGE_SIZE);
10018 vma = find_vma(mm, addr);
10019 - if (task_size - len >= addr &&
10020 - (!vma || addr + len <= vma->vm_start))
10021 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10022 return addr;
10023 }
10024 if (mm->get_unmapped_area == arch_get_unmapped_area)
10025 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10026 index f4500c6..889656c 100644
10027 --- a/arch/tile/include/asm/atomic_64.h
10028 +++ b/arch/tile/include/asm/atomic_64.h
10029 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10030
10031 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10032
10033 +#define atomic64_read_unchecked(v) atomic64_read(v)
10034 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10035 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10036 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10037 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10038 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10039 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10040 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10041 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10042 +
10043 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10044 #define smp_mb__before_atomic_dec() smp_mb()
10045 #define smp_mb__after_atomic_dec() smp_mb()
10046 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10047 index a9a5299..0fce79e 100644
10048 --- a/arch/tile/include/asm/cache.h
10049 +++ b/arch/tile/include/asm/cache.h
10050 @@ -15,11 +15,12 @@
10051 #ifndef _ASM_TILE_CACHE_H
10052 #define _ASM_TILE_CACHE_H
10053
10054 +#include <linux/const.h>
10055 #include <arch/chip.h>
10056
10057 /* bytes per L1 data cache line */
10058 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10059 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10060 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10061
10062 /* bytes per L2 cache line */
10063 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10064 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10065 index 8a082bc..7a6bf87 100644
10066 --- a/arch/tile/include/asm/uaccess.h
10067 +++ b/arch/tile/include/asm/uaccess.h
10068 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10069 const void __user *from,
10070 unsigned long n)
10071 {
10072 - int sz = __compiletime_object_size(to);
10073 + size_t sz = __compiletime_object_size(to);
10074
10075 - if (likely(sz == -1 || sz >= n))
10076 + if (likely(sz == (size_t)-1 || sz >= n))
10077 n = _copy_from_user(to, from, n);
10078 else
10079 copy_from_user_overflow();
10080 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10081 index 650ccff..45fe2d6 100644
10082 --- a/arch/tile/mm/hugetlbpage.c
10083 +++ b/arch/tile/mm/hugetlbpage.c
10084 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10085 info.high_limit = TASK_SIZE;
10086 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10087 info.align_offset = 0;
10088 + info.threadstack_offset = 0;
10089 return vm_unmapped_area(&info);
10090 }
10091
10092 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10093 info.high_limit = current->mm->mmap_base;
10094 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10095 info.align_offset = 0;
10096 + info.threadstack_offset = 0;
10097 addr = vm_unmapped_area(&info);
10098
10099 /*
10100 diff --git a/arch/um/Makefile b/arch/um/Makefile
10101 index 133f7de..1d6f2f1 100644
10102 --- a/arch/um/Makefile
10103 +++ b/arch/um/Makefile
10104 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10105 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10106 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10107
10108 +ifdef CONSTIFY_PLUGIN
10109 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10110 +endif
10111 +
10112 #This will adjust *FLAGS accordingly to the platform.
10113 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10114
10115 diff --git a/arch/um/defconfig b/arch/um/defconfig
10116 index 08107a7..ab22afe 100644
10117 --- a/arch/um/defconfig
10118 +++ b/arch/um/defconfig
10119 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10120 CONFIG_X86_L1_CACHE_SHIFT=5
10121 CONFIG_X86_XADD=y
10122 CONFIG_X86_PPRO_FENCE=y
10123 -CONFIG_X86_WP_WORKS_OK=y
10124 CONFIG_X86_INVLPG=y
10125 CONFIG_X86_BSWAP=y
10126 CONFIG_X86_POPAD_OK=y
10127 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10128 index 19e1bdd..3665b77 100644
10129 --- a/arch/um/include/asm/cache.h
10130 +++ b/arch/um/include/asm/cache.h
10131 @@ -1,6 +1,7 @@
10132 #ifndef __UM_CACHE_H
10133 #define __UM_CACHE_H
10134
10135 +#include <linux/const.h>
10136
10137 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10138 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10139 @@ -12,6 +13,6 @@
10140 # define L1_CACHE_SHIFT 5
10141 #endif
10142
10143 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10144 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10145
10146 #endif
10147 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10148 index 2e0a6b1..a64d0f5 100644
10149 --- a/arch/um/include/asm/kmap_types.h
10150 +++ b/arch/um/include/asm/kmap_types.h
10151 @@ -8,6 +8,6 @@
10152
10153 /* No more #include "asm/arch/kmap_types.h" ! */
10154
10155 -#define KM_TYPE_NR 14
10156 +#define KM_TYPE_NR 15
10157
10158 #endif
10159 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10160 index 5ff53d9..5850cdf 100644
10161 --- a/arch/um/include/asm/page.h
10162 +++ b/arch/um/include/asm/page.h
10163 @@ -14,6 +14,9 @@
10164 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10165 #define PAGE_MASK (~(PAGE_SIZE-1))
10166
10167 +#define ktla_ktva(addr) (addr)
10168 +#define ktva_ktla(addr) (addr)
10169 +
10170 #ifndef __ASSEMBLY__
10171
10172 struct page;
10173 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10174 index 0032f92..cd151e0 100644
10175 --- a/arch/um/include/asm/pgtable-3level.h
10176 +++ b/arch/um/include/asm/pgtable-3level.h
10177 @@ -58,6 +58,7 @@
10178 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10179 #define pud_populate(mm, pud, pmd) \
10180 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10181 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10182
10183 #ifdef CONFIG_64BIT
10184 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10185 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10186 index bbcef52..6a2a483 100644
10187 --- a/arch/um/kernel/process.c
10188 +++ b/arch/um/kernel/process.c
10189 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10190 return 2;
10191 }
10192
10193 -/*
10194 - * Only x86 and x86_64 have an arch_align_stack().
10195 - * All other arches have "#define arch_align_stack(x) (x)"
10196 - * in their asm/system.h
10197 - * As this is included in UML from asm-um/system-generic.h,
10198 - * we can use it to behave as the subarch does.
10199 - */
10200 -#ifndef arch_align_stack
10201 -unsigned long arch_align_stack(unsigned long sp)
10202 -{
10203 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10204 - sp -= get_random_int() % 8192;
10205 - return sp & ~0xf;
10206 -}
10207 -#endif
10208 -
10209 unsigned long get_wchan(struct task_struct *p)
10210 {
10211 unsigned long stack_page, sp, ip;
10212 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10213 index ad8f795..2c7eec6 100644
10214 --- a/arch/unicore32/include/asm/cache.h
10215 +++ b/arch/unicore32/include/asm/cache.h
10216 @@ -12,8 +12,10 @@
10217 #ifndef __UNICORE_CACHE_H__
10218 #define __UNICORE_CACHE_H__
10219
10220 -#define L1_CACHE_SHIFT (5)
10221 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10222 +#include <linux/const.h>
10223 +
10224 +#define L1_CACHE_SHIFT 5
10225 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10226
10227 /*
10228 * Memory returned by kmalloc() may be used for DMA, so we must make
10229 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10230 index fe120da..24177f7 100644
10231 --- a/arch/x86/Kconfig
10232 +++ b/arch/x86/Kconfig
10233 @@ -239,7 +239,7 @@ config X86_HT
10234
10235 config X86_32_LAZY_GS
10236 def_bool y
10237 - depends on X86_32 && !CC_STACKPROTECTOR
10238 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10239
10240 config ARCH_HWEIGHT_CFLAGS
10241 string
10242 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10243
10244 config X86_MSR
10245 tristate "/dev/cpu/*/msr - Model-specific register support"
10246 + depends on !GRKERNSEC_KMEM
10247 ---help---
10248 This device gives privileged processes access to the x86
10249 Model-Specific Registers (MSRs). It is a character device with
10250 @@ -1096,7 +1097,7 @@ choice
10251
10252 config NOHIGHMEM
10253 bool "off"
10254 - depends on !X86_NUMAQ
10255 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10256 ---help---
10257 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10258 However, the address space of 32-bit x86 processors is only 4
10259 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10260
10261 config HIGHMEM4G
10262 bool "4GB"
10263 - depends on !X86_NUMAQ
10264 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10265 ---help---
10266 Select this if you have a 32-bit processor and between 1 and 4
10267 gigabytes of physical RAM.
10268 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10269 hex
10270 default 0xB0000000 if VMSPLIT_3G_OPT
10271 default 0x80000000 if VMSPLIT_2G
10272 - default 0x78000000 if VMSPLIT_2G_OPT
10273 + default 0x70000000 if VMSPLIT_2G_OPT
10274 default 0x40000000 if VMSPLIT_1G
10275 default 0xC0000000
10276 depends on X86_32
10277 @@ -1584,6 +1585,7 @@ config SECCOMP
10278
10279 config CC_STACKPROTECTOR
10280 bool "Enable -fstack-protector buffer overflow detection"
10281 + depends on X86_64 || !PAX_MEMORY_UDEREF
10282 ---help---
10283 This option turns on the -fstack-protector GCC feature. This
10284 feature puts, at the beginning of functions, a canary value on
10285 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10286 config PHYSICAL_ALIGN
10287 hex "Alignment value to which kernel should be aligned" if X86_32
10288 default "0x1000000"
10289 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10290 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10291 range 0x2000 0x1000000
10292 ---help---
10293 This value puts the alignment restrictions on physical address
10294 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10295 If unsure, say N.
10296
10297 config COMPAT_VDSO
10298 - def_bool y
10299 + def_bool n
10300 prompt "Compat VDSO support"
10301 depends on X86_32 || IA32_EMULATION
10302 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10303 ---help---
10304 Map the 32-bit VDSO to the predictable old-style address too.
10305
10306 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10307 index c026cca..14657ae 100644
10308 --- a/arch/x86/Kconfig.cpu
10309 +++ b/arch/x86/Kconfig.cpu
10310 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10311
10312 config X86_F00F_BUG
10313 def_bool y
10314 - depends on M586MMX || M586TSC || M586 || M486
10315 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10316
10317 config X86_INVD_BUG
10318 def_bool y
10319 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10320
10321 config X86_ALIGNMENT_16
10322 def_bool y
10323 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10324 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10325
10326 config X86_INTEL_USERCOPY
10327 def_bool y
10328 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10329 # generates cmov.
10330 config X86_CMOV
10331 def_bool y
10332 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10333 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10334
10335 config X86_MINIMUM_CPU_FAMILY
10336 int
10337 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10338 index c198b7e..63eea60 100644
10339 --- a/arch/x86/Kconfig.debug
10340 +++ b/arch/x86/Kconfig.debug
10341 @@ -84,7 +84,7 @@ config X86_PTDUMP
10342 config DEBUG_RODATA
10343 bool "Write protect kernel read-only data structures"
10344 default y
10345 - depends on DEBUG_KERNEL
10346 + depends on DEBUG_KERNEL && BROKEN
10347 ---help---
10348 Mark the kernel read-only data as write-protected in the pagetables,
10349 in order to catch accidental (and incorrect) writes to such const
10350 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10351
10352 config DEBUG_SET_MODULE_RONX
10353 bool "Set loadable kernel module data as NX and text as RO"
10354 - depends on MODULES
10355 + depends on MODULES && BROKEN
10356 ---help---
10357 This option helps catch unintended modifications to loadable
10358 kernel module's text and read-only data. It also prevents execution
10359 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10360 index 5c47726..8c4fa67 100644
10361 --- a/arch/x86/Makefile
10362 +++ b/arch/x86/Makefile
10363 @@ -54,6 +54,7 @@ else
10364 UTS_MACHINE := x86_64
10365 CHECKFLAGS += -D__x86_64__ -m64
10366
10367 + biarch := $(call cc-option,-m64)
10368 KBUILD_AFLAGS += -m64
10369 KBUILD_CFLAGS += -m64
10370
10371 @@ -234,3 +235,12 @@ define archhelp
10372 echo ' FDARGS="..." arguments for the booted kernel'
10373 echo ' FDINITRD=file initrd for the booted kernel'
10374 endef
10375 +
10376 +define OLD_LD
10377 +
10378 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10379 +*** Please upgrade your binutils to 2.18 or newer
10380 +endef
10381 +
10382 +archprepare:
10383 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10384 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10385 index 379814b..add62ce 100644
10386 --- a/arch/x86/boot/Makefile
10387 +++ b/arch/x86/boot/Makefile
10388 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10389 $(call cc-option, -fno-stack-protector) \
10390 $(call cc-option, -mpreferred-stack-boundary=2)
10391 KBUILD_CFLAGS += $(call cc-option, -m32)
10392 +ifdef CONSTIFY_PLUGIN
10393 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10394 +endif
10395 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10396 GCOV_PROFILE := n
10397
10398 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10399 index 878e4b9..20537ab 100644
10400 --- a/arch/x86/boot/bitops.h
10401 +++ b/arch/x86/boot/bitops.h
10402 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10403 u8 v;
10404 const u32 *p = (const u32 *)addr;
10405
10406 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10407 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10408 return v;
10409 }
10410
10411 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10412
10413 static inline void set_bit(int nr, void *addr)
10414 {
10415 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10416 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10417 }
10418
10419 #endif /* BOOT_BITOPS_H */
10420 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10421 index 5b75319..331a4ca 100644
10422 --- a/arch/x86/boot/boot.h
10423 +++ b/arch/x86/boot/boot.h
10424 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10425 static inline u16 ds(void)
10426 {
10427 u16 seg;
10428 - asm("movw %%ds,%0" : "=rm" (seg));
10429 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10430 return seg;
10431 }
10432
10433 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10434 static inline int memcmp(const void *s1, const void *s2, size_t len)
10435 {
10436 u8 diff;
10437 - asm("repe; cmpsb; setnz %0"
10438 + asm volatile("repe; cmpsb; setnz %0"
10439 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10440 return diff;
10441 }
10442 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10443 index 5ef205c..342191d 100644
10444 --- a/arch/x86/boot/compressed/Makefile
10445 +++ b/arch/x86/boot/compressed/Makefile
10446 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10447 KBUILD_CFLAGS += $(cflags-y)
10448 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10449 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10450 +ifdef CONSTIFY_PLUGIN
10451 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10452 +endif
10453
10454 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10455 GCOV_PROFILE := n
10456 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10457 index d606463..b887794 100644
10458 --- a/arch/x86/boot/compressed/eboot.c
10459 +++ b/arch/x86/boot/compressed/eboot.c
10460 @@ -150,7 +150,6 @@ again:
10461 *addr = max_addr;
10462 }
10463
10464 -free_pool:
10465 efi_call_phys1(sys_table->boottime->free_pool, map);
10466
10467 fail:
10468 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10469 if (i == map_size / desc_size)
10470 status = EFI_NOT_FOUND;
10471
10472 -free_pool:
10473 efi_call_phys1(sys_table->boottime->free_pool, map);
10474 fail:
10475 return status;
10476 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10477 index a53440e..c3dbf1e 100644
10478 --- a/arch/x86/boot/compressed/efi_stub_32.S
10479 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10480 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10481 * parameter 2, ..., param n. To make things easy, we save the return
10482 * address of efi_call_phys in a global variable.
10483 */
10484 - popl %ecx
10485 - movl %ecx, saved_return_addr(%edx)
10486 - /* get the function pointer into ECX*/
10487 - popl %ecx
10488 - movl %ecx, efi_rt_function_ptr(%edx)
10489 + popl saved_return_addr(%edx)
10490 + popl efi_rt_function_ptr(%edx)
10491
10492 /*
10493 * 3. Call the physical function.
10494 */
10495 - call *%ecx
10496 + call *efi_rt_function_ptr(%edx)
10497
10498 /*
10499 * 4. Balance the stack. And because EAX contain the return value,
10500 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10501 1: popl %edx
10502 subl $1b, %edx
10503
10504 - movl efi_rt_function_ptr(%edx), %ecx
10505 - pushl %ecx
10506 + pushl efi_rt_function_ptr(%edx)
10507
10508 /*
10509 * 10. Push the saved return address onto the stack and return.
10510 */
10511 - movl saved_return_addr(%edx), %ecx
10512 - pushl %ecx
10513 - ret
10514 + jmpl *saved_return_addr(%edx)
10515 ENDPROC(efi_call_phys)
10516 .previous
10517
10518 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10519 index 1e3184f..0d11e2e 100644
10520 --- a/arch/x86/boot/compressed/head_32.S
10521 +++ b/arch/x86/boot/compressed/head_32.S
10522 @@ -118,7 +118,7 @@ preferred_addr:
10523 notl %eax
10524 andl %eax, %ebx
10525 #else
10526 - movl $LOAD_PHYSICAL_ADDR, %ebx
10527 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10528 #endif
10529
10530 /* Target address to relocate to for decompression */
10531 @@ -204,7 +204,7 @@ relocated:
10532 * and where it was actually loaded.
10533 */
10534 movl %ebp, %ebx
10535 - subl $LOAD_PHYSICAL_ADDR, %ebx
10536 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10537 jz 2f /* Nothing to be done if loaded at compiled addr. */
10538 /*
10539 * Process relocations.
10540 @@ -212,8 +212,7 @@ relocated:
10541
10542 1: subl $4, %edi
10543 movl (%edi), %ecx
10544 - testl %ecx, %ecx
10545 - jz 2f
10546 + jecxz 2f
10547 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10548 jmp 1b
10549 2:
10550 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10551 index 16f24e6..47491a3 100644
10552 --- a/arch/x86/boot/compressed/head_64.S
10553 +++ b/arch/x86/boot/compressed/head_64.S
10554 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10555 notl %eax
10556 andl %eax, %ebx
10557 #else
10558 - movl $LOAD_PHYSICAL_ADDR, %ebx
10559 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10560 #endif
10561
10562 /* Target address to relocate to for decompression */
10563 @@ -272,7 +272,7 @@ preferred_addr:
10564 notq %rax
10565 andq %rax, %rbp
10566 #else
10567 - movq $LOAD_PHYSICAL_ADDR, %rbp
10568 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10569 #endif
10570
10571 /* Target address to relocate to for decompression */
10572 @@ -363,8 +363,8 @@ gdt:
10573 .long gdt
10574 .word 0
10575 .quad 0x0000000000000000 /* NULL descriptor */
10576 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10577 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10578 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10579 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10580 .quad 0x0080890000000000 /* TS descriptor */
10581 .quad 0x0000000000000000 /* TS continued */
10582 gdt_end:
10583 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10584 index 7cb56c6..d382d84 100644
10585 --- a/arch/x86/boot/compressed/misc.c
10586 +++ b/arch/x86/boot/compressed/misc.c
10587 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10588 case PT_LOAD:
10589 #ifdef CONFIG_RELOCATABLE
10590 dest = output;
10591 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10592 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10593 #else
10594 dest = (void *)(phdr->p_paddr);
10595 #endif
10596 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10597 error("Destination address too large");
10598 #endif
10599 #ifndef CONFIG_RELOCATABLE
10600 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10601 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10602 error("Wrong destination address");
10603 #endif
10604
10605 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10606 index 4d3ff03..e4972ff 100644
10607 --- a/arch/x86/boot/cpucheck.c
10608 +++ b/arch/x86/boot/cpucheck.c
10609 @@ -74,7 +74,7 @@ static int has_fpu(void)
10610 u16 fcw = -1, fsw = -1;
10611 u32 cr0;
10612
10613 - asm("movl %%cr0,%0" : "=r" (cr0));
10614 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10615 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10616 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10617 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10618 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10619 {
10620 u32 f0, f1;
10621
10622 - asm("pushfl ; "
10623 + asm volatile("pushfl ; "
10624 "pushfl ; "
10625 "popl %0 ; "
10626 "movl %0,%1 ; "
10627 @@ -115,7 +115,7 @@ static void get_flags(void)
10628 set_bit(X86_FEATURE_FPU, cpu.flags);
10629
10630 if (has_eflag(X86_EFLAGS_ID)) {
10631 - asm("cpuid"
10632 + asm volatile("cpuid"
10633 : "=a" (max_intel_level),
10634 "=b" (cpu_vendor[0]),
10635 "=d" (cpu_vendor[1]),
10636 @@ -124,7 +124,7 @@ static void get_flags(void)
10637
10638 if (max_intel_level >= 0x00000001 &&
10639 max_intel_level <= 0x0000ffff) {
10640 - asm("cpuid"
10641 + asm volatile("cpuid"
10642 : "=a" (tfms),
10643 "=c" (cpu.flags[4]),
10644 "=d" (cpu.flags[0])
10645 @@ -136,7 +136,7 @@ static void get_flags(void)
10646 cpu.model += ((tfms >> 16) & 0xf) << 4;
10647 }
10648
10649 - asm("cpuid"
10650 + asm volatile("cpuid"
10651 : "=a" (max_amd_level)
10652 : "a" (0x80000000)
10653 : "ebx", "ecx", "edx");
10654 @@ -144,7 +144,7 @@ static void get_flags(void)
10655 if (max_amd_level >= 0x80000001 &&
10656 max_amd_level <= 0x8000ffff) {
10657 u32 eax = 0x80000001;
10658 - asm("cpuid"
10659 + asm volatile("cpuid"
10660 : "+a" (eax),
10661 "=c" (cpu.flags[6]),
10662 "=d" (cpu.flags[1])
10663 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10664 u32 ecx = MSR_K7_HWCR;
10665 u32 eax, edx;
10666
10667 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10668 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10669 eax &= ~(1 << 15);
10670 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10671 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10672
10673 get_flags(); /* Make sure it really did something */
10674 err = check_flags();
10675 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10676 u32 ecx = MSR_VIA_FCR;
10677 u32 eax, edx;
10678
10679 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10680 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10681 eax |= (1<<1)|(1<<7);
10682 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10683 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10684
10685 set_bit(X86_FEATURE_CX8, cpu.flags);
10686 err = check_flags();
10687 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10688 u32 eax, edx;
10689 u32 level = 1;
10690
10691 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10692 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10693 - asm("cpuid"
10694 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10695 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10696 + asm volatile("cpuid"
10697 : "+a" (level), "=d" (cpu.flags[0])
10698 : : "ecx", "ebx");
10699 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10700 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10701
10702 err = check_flags();
10703 }
10704 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10705 index 9ec06a1..2c25e79 100644
10706 --- a/arch/x86/boot/header.S
10707 +++ b/arch/x86/boot/header.S
10708 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10709 # single linked list of
10710 # struct setup_data
10711
10712 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10713 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10714
10715 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10716 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10717 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10718 +#else
10719 #define VO_INIT_SIZE (VO__end - VO__text)
10720 +#endif
10721 #if ZO_INIT_SIZE > VO_INIT_SIZE
10722 #define INIT_SIZE ZO_INIT_SIZE
10723 #else
10724 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10725 index db75d07..8e6d0af 100644
10726 --- a/arch/x86/boot/memory.c
10727 +++ b/arch/x86/boot/memory.c
10728 @@ -19,7 +19,7 @@
10729
10730 static int detect_memory_e820(void)
10731 {
10732 - int count = 0;
10733 + unsigned int count = 0;
10734 struct biosregs ireg, oreg;
10735 struct e820entry *desc = boot_params.e820_map;
10736 static struct e820entry buf; /* static so it is zeroed */
10737 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10738 index 11e8c6e..fdbb1ed 100644
10739 --- a/arch/x86/boot/video-vesa.c
10740 +++ b/arch/x86/boot/video-vesa.c
10741 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10742
10743 boot_params.screen_info.vesapm_seg = oreg.es;
10744 boot_params.screen_info.vesapm_off = oreg.di;
10745 + boot_params.screen_info.vesapm_size = oreg.cx;
10746 }
10747
10748 /*
10749 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10750 index 43eda28..5ab5fdb 100644
10751 --- a/arch/x86/boot/video.c
10752 +++ b/arch/x86/boot/video.c
10753 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10754 static unsigned int get_entry(void)
10755 {
10756 char entry_buf[4];
10757 - int i, len = 0;
10758 + unsigned int i, len = 0;
10759 int key;
10760 unsigned int v;
10761
10762 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10763 index 9105655..5e37f27 100644
10764 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10765 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10766 @@ -8,6 +8,8 @@
10767 * including this sentence is retained in full.
10768 */
10769
10770 +#include <asm/alternative-asm.h>
10771 +
10772 .extern crypto_ft_tab
10773 .extern crypto_it_tab
10774 .extern crypto_fl_tab
10775 @@ -70,6 +72,8 @@
10776 je B192; \
10777 leaq 32(r9),r9;
10778
10779 +#define ret pax_force_retaddr 0, 1; ret
10780 +
10781 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10782 movq r1,r2; \
10783 movq r3,r4; \
10784 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10785 index 477e9d7..3ab339f 100644
10786 --- a/arch/x86/crypto/aesni-intel_asm.S
10787 +++ b/arch/x86/crypto/aesni-intel_asm.S
10788 @@ -31,6 +31,7 @@
10789
10790 #include <linux/linkage.h>
10791 #include <asm/inst.h>
10792 +#include <asm/alternative-asm.h>
10793
10794 #ifdef __x86_64__
10795 .data
10796 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
10797 pop %r14
10798 pop %r13
10799 pop %r12
10800 + pax_force_retaddr 0, 1
10801 ret
10802 ENDPROC(aesni_gcm_dec)
10803
10804 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
10805 pop %r14
10806 pop %r13
10807 pop %r12
10808 + pax_force_retaddr 0, 1
10809 ret
10810 ENDPROC(aesni_gcm_enc)
10811
10812 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
10813 pxor %xmm1, %xmm0
10814 movaps %xmm0, (TKEYP)
10815 add $0x10, TKEYP
10816 + pax_force_retaddr_bts
10817 ret
10818 ENDPROC(_key_expansion_128)
10819 ENDPROC(_key_expansion_256a)
10820 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
10821 shufps $0b01001110, %xmm2, %xmm1
10822 movaps %xmm1, 0x10(TKEYP)
10823 add $0x20, TKEYP
10824 + pax_force_retaddr_bts
10825 ret
10826 ENDPROC(_key_expansion_192a)
10827
10828 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
10829
10830 movaps %xmm0, (TKEYP)
10831 add $0x10, TKEYP
10832 + pax_force_retaddr_bts
10833 ret
10834 ENDPROC(_key_expansion_192b)
10835
10836 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
10837 pxor %xmm1, %xmm2
10838 movaps %xmm2, (TKEYP)
10839 add $0x10, TKEYP
10840 + pax_force_retaddr_bts
10841 ret
10842 ENDPROC(_key_expansion_256b)
10843
10844 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
10845 #ifndef __x86_64__
10846 popl KEYP
10847 #endif
10848 + pax_force_retaddr 0, 1
10849 ret
10850 ENDPROC(aesni_set_key)
10851
10852 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
10853 popl KLEN
10854 popl KEYP
10855 #endif
10856 + pax_force_retaddr 0, 1
10857 ret
10858 ENDPROC(aesni_enc)
10859
10860 @@ -1974,6 +1983,7 @@ _aesni_enc1:
10861 AESENC KEY STATE
10862 movaps 0x70(TKEYP), KEY
10863 AESENCLAST KEY STATE
10864 + pax_force_retaddr_bts
10865 ret
10866 ENDPROC(_aesni_enc1)
10867
10868 @@ -2083,6 +2093,7 @@ _aesni_enc4:
10869 AESENCLAST KEY STATE2
10870 AESENCLAST KEY STATE3
10871 AESENCLAST KEY STATE4
10872 + pax_force_retaddr_bts
10873 ret
10874 ENDPROC(_aesni_enc4)
10875
10876 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
10877 popl KLEN
10878 popl KEYP
10879 #endif
10880 + pax_force_retaddr 0, 1
10881 ret
10882 ENDPROC(aesni_dec)
10883
10884 @@ -2164,6 +2176,7 @@ _aesni_dec1:
10885 AESDEC KEY STATE
10886 movaps 0x70(TKEYP), KEY
10887 AESDECLAST KEY STATE
10888 + pax_force_retaddr_bts
10889 ret
10890 ENDPROC(_aesni_dec1)
10891
10892 @@ -2273,6 +2286,7 @@ _aesni_dec4:
10893 AESDECLAST KEY STATE2
10894 AESDECLAST KEY STATE3
10895 AESDECLAST KEY STATE4
10896 + pax_force_retaddr_bts
10897 ret
10898 ENDPROC(_aesni_dec4)
10899
10900 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
10901 popl KEYP
10902 popl LEN
10903 #endif
10904 + pax_force_retaddr 0, 1
10905 ret
10906 ENDPROC(aesni_ecb_enc)
10907
10908 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
10909 popl KEYP
10910 popl LEN
10911 #endif
10912 + pax_force_retaddr 0, 1
10913 ret
10914 ENDPROC(aesni_ecb_dec)
10915
10916 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
10917 popl LEN
10918 popl IVP
10919 #endif
10920 + pax_force_retaddr 0, 1
10921 ret
10922 ENDPROC(aesni_cbc_enc)
10923
10924 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
10925 popl LEN
10926 popl IVP
10927 #endif
10928 + pax_force_retaddr 0, 1
10929 ret
10930 ENDPROC(aesni_cbc_dec)
10931
10932 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
10933 mov $1, TCTR_LOW
10934 MOVQ_R64_XMM TCTR_LOW INC
10935 MOVQ_R64_XMM CTR TCTR_LOW
10936 + pax_force_retaddr_bts
10937 ret
10938 ENDPROC(_aesni_inc_init)
10939
10940 @@ -2579,6 +2598,7 @@ _aesni_inc:
10941 .Linc_low:
10942 movaps CTR, IV
10943 PSHUFB_XMM BSWAP_MASK IV
10944 + pax_force_retaddr_bts
10945 ret
10946 ENDPROC(_aesni_inc)
10947
10948 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
10949 .Lctr_enc_ret:
10950 movups IV, (IVP)
10951 .Lctr_enc_just_ret:
10952 + pax_force_retaddr 0, 1
10953 ret
10954 ENDPROC(aesni_ctr_enc)
10955
10956 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
10957 pxor INC, STATE4
10958 movdqu STATE4, 0x70(OUTP)
10959
10960 + pax_force_retaddr 0, 1
10961 ret
10962 ENDPROC(aesni_xts_crypt8)
10963
10964 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10965 index 246c670..4d1ed00 100644
10966 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10967 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10968 @@ -21,6 +21,7 @@
10969 */
10970
10971 #include <linux/linkage.h>
10972 +#include <asm/alternative-asm.h>
10973
10974 .file "blowfish-x86_64-asm.S"
10975 .text
10976 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10977 jnz .L__enc_xor;
10978
10979 write_block();
10980 + pax_force_retaddr 0, 1
10981 ret;
10982 .L__enc_xor:
10983 xor_block();
10984 + pax_force_retaddr 0, 1
10985 ret;
10986 ENDPROC(__blowfish_enc_blk)
10987
10988 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10989
10990 movq %r11, %rbp;
10991
10992 + pax_force_retaddr 0, 1
10993 ret;
10994 ENDPROC(blowfish_dec_blk)
10995
10996 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10997
10998 popq %rbx;
10999 popq %rbp;
11000 + pax_force_retaddr 0, 1
11001 ret;
11002
11003 .L__enc_xor4:
11004 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11005
11006 popq %rbx;
11007 popq %rbp;
11008 + pax_force_retaddr 0, 1
11009 ret;
11010 ENDPROC(__blowfish_enc_blk_4way)
11011
11012 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11013 popq %rbx;
11014 popq %rbp;
11015
11016 + pax_force_retaddr 0, 1
11017 ret;
11018 ENDPROC(blowfish_dec_blk_4way)
11019 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11020 index 310319c..ce174a4 100644
11021 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11022 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11023 @@ -21,6 +21,7 @@
11024 */
11025
11026 #include <linux/linkage.h>
11027 +#include <asm/alternative-asm.h>
11028
11029 .file "camellia-x86_64-asm_64.S"
11030 .text
11031 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11032 enc_outunpack(mov, RT1);
11033
11034 movq RRBP, %rbp;
11035 + pax_force_retaddr 0, 1
11036 ret;
11037
11038 .L__enc_xor:
11039 enc_outunpack(xor, RT1);
11040
11041 movq RRBP, %rbp;
11042 + pax_force_retaddr 0, 1
11043 ret;
11044 ENDPROC(__camellia_enc_blk)
11045
11046 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11047 dec_outunpack();
11048
11049 movq RRBP, %rbp;
11050 + pax_force_retaddr 0, 1
11051 ret;
11052 ENDPROC(camellia_dec_blk)
11053
11054 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11055
11056 movq RRBP, %rbp;
11057 popq %rbx;
11058 + pax_force_retaddr 0, 1
11059 ret;
11060
11061 .L__enc2_xor:
11062 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11063
11064 movq RRBP, %rbp;
11065 popq %rbx;
11066 + pax_force_retaddr 0, 1
11067 ret;
11068 ENDPROC(__camellia_enc_blk_2way)
11069
11070 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11071
11072 movq RRBP, %rbp;
11073 movq RXOR, %rbx;
11074 + pax_force_retaddr 0, 1
11075 ret;
11076 ENDPROC(camellia_dec_blk_2way)
11077 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11078 index c35fd5d..c1ee236 100644
11079 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11080 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11081 @@ -24,6 +24,7 @@
11082 */
11083
11084 #include <linux/linkage.h>
11085 +#include <asm/alternative-asm.h>
11086
11087 .file "cast5-avx-x86_64-asm_64.S"
11088
11089 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11090 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11091 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11092
11093 + pax_force_retaddr 0, 1
11094 ret;
11095 ENDPROC(__cast5_enc_blk16)
11096
11097 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11098 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11099 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11100
11101 + pax_force_retaddr 0, 1
11102 ret;
11103
11104 .L__skip_dec:
11105 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11106 vmovdqu RR4, (6*4*4)(%r11);
11107 vmovdqu RL4, (7*4*4)(%r11);
11108
11109 + pax_force_retaddr
11110 ret;
11111 ENDPROC(cast5_ecb_enc_16way)
11112
11113 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11114 vmovdqu RR4, (6*4*4)(%r11);
11115 vmovdqu RL4, (7*4*4)(%r11);
11116
11117 + pax_force_retaddr
11118 ret;
11119 ENDPROC(cast5_ecb_dec_16way)
11120
11121 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11122
11123 popq %r12;
11124
11125 + pax_force_retaddr
11126 ret;
11127 ENDPROC(cast5_cbc_dec_16way)
11128
11129 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11130
11131 popq %r12;
11132
11133 + pax_force_retaddr
11134 ret;
11135 ENDPROC(cast5_ctr_16way)
11136 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11137 index e3531f8..18ded3a 100644
11138 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11139 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11140 @@ -24,6 +24,7 @@
11141 */
11142
11143 #include <linux/linkage.h>
11144 +#include <asm/alternative-asm.h>
11145 #include "glue_helper-asm-avx.S"
11146
11147 .file "cast6-avx-x86_64-asm_64.S"
11148 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11149 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11150 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11151
11152 + pax_force_retaddr 0, 1
11153 ret;
11154 ENDPROC(__cast6_enc_blk8)
11155
11156 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11157 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11158 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11159
11160 + pax_force_retaddr 0, 1
11161 ret;
11162 ENDPROC(__cast6_dec_blk8)
11163
11164 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11165
11166 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11167
11168 + pax_force_retaddr
11169 ret;
11170 ENDPROC(cast6_ecb_enc_8way)
11171
11172 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11173
11174 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11175
11176 + pax_force_retaddr
11177 ret;
11178 ENDPROC(cast6_ecb_dec_8way)
11179
11180 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11181
11182 popq %r12;
11183
11184 + pax_force_retaddr
11185 ret;
11186 ENDPROC(cast6_cbc_dec_8way)
11187
11188 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11189
11190 popq %r12;
11191
11192 + pax_force_retaddr
11193 ret;
11194 ENDPROC(cast6_ctr_8way)
11195
11196 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11197 /* dst <= regs xor IVs(in dst) */
11198 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11199
11200 + pax_force_retaddr
11201 ret;
11202 ENDPROC(cast6_xts_enc_8way)
11203
11204 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11205 /* dst <= regs xor IVs(in dst) */
11206 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11207
11208 + pax_force_retaddr
11209 ret;
11210 ENDPROC(cast6_xts_dec_8way)
11211 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11212 index 9279e0b..9270820 100644
11213 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11214 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11215 @@ -1,4 +1,5 @@
11216 #include <linux/linkage.h>
11217 +#include <asm/alternative-asm.h>
11218
11219 # enter salsa20_encrypt_bytes
11220 ENTRY(salsa20_encrypt_bytes)
11221 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11222 add %r11,%rsp
11223 mov %rdi,%rax
11224 mov %rsi,%rdx
11225 + pax_force_retaddr 0, 1
11226 ret
11227 # bytesatleast65:
11228 ._bytesatleast65:
11229 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11230 add %r11,%rsp
11231 mov %rdi,%rax
11232 mov %rsi,%rdx
11233 + pax_force_retaddr
11234 ret
11235 ENDPROC(salsa20_keysetup)
11236
11237 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11238 add %r11,%rsp
11239 mov %rdi,%rax
11240 mov %rsi,%rdx
11241 + pax_force_retaddr
11242 ret
11243 ENDPROC(salsa20_ivsetup)
11244 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11245 index 2f202f4..d9164d6 100644
11246 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11247 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11248 @@ -24,6 +24,7 @@
11249 */
11250
11251 #include <linux/linkage.h>
11252 +#include <asm/alternative-asm.h>
11253 #include "glue_helper-asm-avx.S"
11254
11255 .file "serpent-avx-x86_64-asm_64.S"
11256 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11257 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11258 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11259
11260 + pax_force_retaddr
11261 ret;
11262 ENDPROC(__serpent_enc_blk8_avx)
11263
11264 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11265 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11266 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11267
11268 + pax_force_retaddr
11269 ret;
11270 ENDPROC(__serpent_dec_blk8_avx)
11271
11272 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11273
11274 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11275
11276 + pax_force_retaddr
11277 ret;
11278 ENDPROC(serpent_ecb_enc_8way_avx)
11279
11280 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11281
11282 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11283
11284 + pax_force_retaddr
11285 ret;
11286 ENDPROC(serpent_ecb_dec_8way_avx)
11287
11288 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11289
11290 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11291
11292 + pax_force_retaddr
11293 ret;
11294 ENDPROC(serpent_cbc_dec_8way_avx)
11295
11296 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
11297
11298 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11299
11300 + pax_force_retaddr
11301 ret;
11302 ENDPROC(serpent_ctr_8way_avx)
11303
11304 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
11305 /* dst <= regs xor IVs(in dst) */
11306 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11307
11308 + pax_force_retaddr
11309 ret;
11310 ENDPROC(serpent_xts_enc_8way_avx)
11311
11312 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
11313 /* dst <= regs xor IVs(in dst) */
11314 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11315
11316 + pax_force_retaddr
11317 ret;
11318 ENDPROC(serpent_xts_dec_8way_avx)
11319 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11320 index acc066c..1559cc4 100644
11321 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11322 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11323 @@ -25,6 +25,7 @@
11324 */
11325
11326 #include <linux/linkage.h>
11327 +#include <asm/alternative-asm.h>
11328
11329 .file "serpent-sse2-x86_64-asm_64.S"
11330 .text
11331 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11332 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11333 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11334
11335 + pax_force_retaddr
11336 ret;
11337
11338 .L__enc_xor8:
11339 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11340 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11341
11342 + pax_force_retaddr
11343 ret;
11344 ENDPROC(__serpent_enc_blk_8way)
11345
11346 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11347 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11348 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11349
11350 + pax_force_retaddr
11351 ret;
11352 ENDPROC(serpent_dec_blk_8way)
11353 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11354 index a410950..3356d42 100644
11355 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11356 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11357 @@ -29,6 +29,7 @@
11358 */
11359
11360 #include <linux/linkage.h>
11361 +#include <asm/alternative-asm.h>
11362
11363 #define CTX %rdi // arg1
11364 #define BUF %rsi // arg2
11365 @@ -104,6 +105,7 @@
11366 pop %r12
11367 pop %rbp
11368 pop %rbx
11369 + pax_force_retaddr 0, 1
11370 ret
11371
11372 ENDPROC(\name)
11373 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11374 index 0505813..63b1d00 100644
11375 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11376 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11377 @@ -24,6 +24,7 @@
11378 */
11379
11380 #include <linux/linkage.h>
11381 +#include <asm/alternative-asm.h>
11382 #include "glue_helper-asm-avx.S"
11383
11384 .file "twofish-avx-x86_64-asm_64.S"
11385 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
11386 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11387 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11388
11389 + pax_force_retaddr 0, 1
11390 ret;
11391 ENDPROC(__twofish_enc_blk8)
11392
11393 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
11394 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11395 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11396
11397 + pax_force_retaddr 0, 1
11398 ret;
11399 ENDPROC(__twofish_dec_blk8)
11400
11401 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
11402
11403 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11404
11405 + pax_force_retaddr 0, 1
11406 ret;
11407 ENDPROC(twofish_ecb_enc_8way)
11408
11409 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
11410
11411 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11412
11413 + pax_force_retaddr 0, 1
11414 ret;
11415 ENDPROC(twofish_ecb_dec_8way)
11416
11417 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
11418
11419 popq %r12;
11420
11421 + pax_force_retaddr 0, 1
11422 ret;
11423 ENDPROC(twofish_cbc_dec_8way)
11424
11425 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
11426
11427 popq %r12;
11428
11429 + pax_force_retaddr 0, 1
11430 ret;
11431 ENDPROC(twofish_ctr_8way)
11432
11433 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
11434 /* dst <= regs xor IVs(in dst) */
11435 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11436
11437 + pax_force_retaddr 0, 1
11438 ret;
11439 ENDPROC(twofish_xts_enc_8way)
11440
11441 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
11442 /* dst <= regs xor IVs(in dst) */
11443 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11444
11445 + pax_force_retaddr 0, 1
11446 ret;
11447 ENDPROC(twofish_xts_dec_8way)
11448 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11449 index 1c3b7ce..b365c5e 100644
11450 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11451 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11452 @@ -21,6 +21,7 @@
11453 */
11454
11455 #include <linux/linkage.h>
11456 +#include <asm/alternative-asm.h>
11457
11458 .file "twofish-x86_64-asm-3way.S"
11459 .text
11460 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11461 popq %r13;
11462 popq %r14;
11463 popq %r15;
11464 + pax_force_retaddr 0, 1
11465 ret;
11466
11467 .L__enc_xor3:
11468 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11469 popq %r13;
11470 popq %r14;
11471 popq %r15;
11472 + pax_force_retaddr 0, 1
11473 ret;
11474 ENDPROC(__twofish_enc_blk_3way)
11475
11476 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11477 popq %r13;
11478 popq %r14;
11479 popq %r15;
11480 + pax_force_retaddr 0, 1
11481 ret;
11482 ENDPROC(twofish_dec_blk_3way)
11483 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11484 index a039d21..29e7615 100644
11485 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11486 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11487 @@ -22,6 +22,7 @@
11488
11489 #include <linux/linkage.h>
11490 #include <asm/asm-offsets.h>
11491 +#include <asm/alternative-asm.h>
11492
11493 #define a_offset 0
11494 #define b_offset 4
11495 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11496
11497 popq R1
11498 movq $1,%rax
11499 + pax_force_retaddr 0, 1
11500 ret
11501 ENDPROC(twofish_enc_blk)
11502
11503 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11504
11505 popq R1
11506 movq $1,%rax
11507 + pax_force_retaddr 0, 1
11508 ret
11509 ENDPROC(twofish_dec_blk)
11510 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11511 index 52ff81c..98af645 100644
11512 --- a/arch/x86/ia32/ia32_aout.c
11513 +++ b/arch/x86/ia32/ia32_aout.c
11514 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11515 unsigned long dump_start, dump_size;
11516 struct user32 dump;
11517
11518 + memset(&dump, 0, sizeof(dump));
11519 +
11520 fs = get_fs();
11521 set_fs(KERNEL_DS);
11522 has_dumped = 1;
11523 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11524 index cf1a471..3bc4cf8 100644
11525 --- a/arch/x86/ia32/ia32_signal.c
11526 +++ b/arch/x86/ia32/ia32_signal.c
11527 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11528 sp -= frame_size;
11529 /* Align the stack pointer according to the i386 ABI,
11530 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11531 - sp = ((sp + 4) & -16ul) - 4;
11532 + sp = ((sp - 12) & -16ul) - 4;
11533 return (void __user *) sp;
11534 }
11535
11536 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11537 * These are actually not used anymore, but left because some
11538 * gdb versions depend on them as a marker.
11539 */
11540 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11541 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11542 } put_user_catch(err);
11543
11544 if (err)
11545 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11546 0xb8,
11547 __NR_ia32_rt_sigreturn,
11548 0x80cd,
11549 - 0,
11550 + 0
11551 };
11552
11553 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11554 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11555
11556 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11557 restorer = ksig->ka.sa.sa_restorer;
11558 + else if (current->mm->context.vdso)
11559 + /* Return stub is in 32bit vsyscall page */
11560 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11561 else
11562 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11563 - rt_sigreturn);
11564 + restorer = &frame->retcode;
11565 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11566
11567 /*
11568 * Not actually used anymore, but left because some gdb
11569 * versions need it.
11570 */
11571 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11572 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11573 } put_user_catch(err);
11574
11575 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11576 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11577 index 474dc1b..24aaa3e 100644
11578 --- a/arch/x86/ia32/ia32entry.S
11579 +++ b/arch/x86/ia32/ia32entry.S
11580 @@ -15,8 +15,10 @@
11581 #include <asm/irqflags.h>
11582 #include <asm/asm.h>
11583 #include <asm/smap.h>
11584 +#include <asm/pgtable.h>
11585 #include <linux/linkage.h>
11586 #include <linux/err.h>
11587 +#include <asm/alternative-asm.h>
11588
11589 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11590 #include <linux/elf-em.h>
11591 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11592 ENDPROC(native_irq_enable_sysexit)
11593 #endif
11594
11595 + .macro pax_enter_kernel_user
11596 + pax_set_fptr_mask
11597 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11598 + call pax_enter_kernel_user
11599 +#endif
11600 + .endm
11601 +
11602 + .macro pax_exit_kernel_user
11603 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11604 + call pax_exit_kernel_user
11605 +#endif
11606 +#ifdef CONFIG_PAX_RANDKSTACK
11607 + pushq %rax
11608 + pushq %r11
11609 + call pax_randomize_kstack
11610 + popq %r11
11611 + popq %rax
11612 +#endif
11613 + .endm
11614 +
11615 + .macro pax_erase_kstack
11616 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11617 + call pax_erase_kstack
11618 +#endif
11619 + .endm
11620 +
11621 /*
11622 * 32bit SYSENTER instruction entry.
11623 *
11624 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11625 CFI_REGISTER rsp,rbp
11626 SWAPGS_UNSAFE_STACK
11627 movq PER_CPU_VAR(kernel_stack), %rsp
11628 - addq $(KERNEL_STACK_OFFSET),%rsp
11629 - /*
11630 - * No need to follow this irqs on/off section: the syscall
11631 - * disabled irqs, here we enable it straight after entry:
11632 - */
11633 - ENABLE_INTERRUPTS(CLBR_NONE)
11634 movl %ebp,%ebp /* zero extension */
11635 pushq_cfi $__USER32_DS
11636 /*CFI_REL_OFFSET ss,0*/
11637 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11638 CFI_REL_OFFSET rsp,0
11639 pushfq_cfi
11640 /*CFI_REL_OFFSET rflags,0*/
11641 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11642 - CFI_REGISTER rip,r10
11643 + orl $X86_EFLAGS_IF,(%rsp)
11644 + GET_THREAD_INFO(%r11)
11645 + movl TI_sysenter_return(%r11), %r11d
11646 + CFI_REGISTER rip,r11
11647 pushq_cfi $__USER32_CS
11648 /*CFI_REL_OFFSET cs,0*/
11649 movl %eax, %eax
11650 - pushq_cfi %r10
11651 + pushq_cfi %r11
11652 CFI_REL_OFFSET rip,0
11653 pushq_cfi %rax
11654 cld
11655 SAVE_ARGS 0,1,0
11656 + pax_enter_kernel_user
11657 +
11658 +#ifdef CONFIG_PAX_RANDKSTACK
11659 + pax_erase_kstack
11660 +#endif
11661 +
11662 + /*
11663 + * No need to follow this irqs on/off section: the syscall
11664 + * disabled irqs, here we enable it straight after entry:
11665 + */
11666 + ENABLE_INTERRUPTS(CLBR_NONE)
11667 /* no need to do an access_ok check here because rbp has been
11668 32bit zero extended */
11669 +
11670 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11671 + mov pax_user_shadow_base,%r11
11672 + add %r11,%rbp
11673 +#endif
11674 +
11675 ASM_STAC
11676 1: movl (%rbp),%ebp
11677 _ASM_EXTABLE(1b,ia32_badarg)
11678 ASM_CLAC
11679 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11680 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11681 + GET_THREAD_INFO(%r11)
11682 + orl $TS_COMPAT,TI_status(%r11)
11683 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11684 CFI_REMEMBER_STATE
11685 jnz sysenter_tracesys
11686 cmpq $(IA32_NR_syscalls-1),%rax
11687 @@ -162,12 +204,15 @@ sysenter_do_call:
11688 sysenter_dispatch:
11689 call *ia32_sys_call_table(,%rax,8)
11690 movq %rax,RAX-ARGOFFSET(%rsp)
11691 + GET_THREAD_INFO(%r11)
11692 DISABLE_INTERRUPTS(CLBR_NONE)
11693 TRACE_IRQS_OFF
11694 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11695 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11696 jnz sysexit_audit
11697 sysexit_from_sys_call:
11698 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11699 + pax_exit_kernel_user
11700 + pax_erase_kstack
11701 + andl $~TS_COMPAT,TI_status(%r11)
11702 /* clear IF, that popfq doesn't enable interrupts early */
11703 andl $~0x200,EFLAGS-R11(%rsp)
11704 movl RIP-R11(%rsp),%edx /* User %eip */
11705 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11706 movl %eax,%esi /* 2nd arg: syscall number */
11707 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11708 call __audit_syscall_entry
11709 +
11710 + pax_erase_kstack
11711 +
11712 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11713 cmpq $(IA32_NR_syscalls-1),%rax
11714 ja ia32_badsys
11715 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11716 .endm
11717
11718 .macro auditsys_exit exit
11719 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11720 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11721 jnz ia32_ret_from_sys_call
11722 TRACE_IRQS_ON
11723 ENABLE_INTERRUPTS(CLBR_NONE)
11724 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11725 1: setbe %al /* 1 if error, 0 if not */
11726 movzbl %al,%edi /* zero-extend that into %edi */
11727 call __audit_syscall_exit
11728 + GET_THREAD_INFO(%r11)
11729 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11730 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11731 DISABLE_INTERRUPTS(CLBR_NONE)
11732 TRACE_IRQS_OFF
11733 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11734 + testl %edi,TI_flags(%r11)
11735 jz \exit
11736 CLEAR_RREGS -ARGOFFSET
11737 jmp int_with_check
11738 @@ -237,7 +286,7 @@ sysexit_audit:
11739
11740 sysenter_tracesys:
11741 #ifdef CONFIG_AUDITSYSCALL
11742 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11743 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11744 jz sysenter_auditsys
11745 #endif
11746 SAVE_REST
11747 @@ -249,6 +298,9 @@ sysenter_tracesys:
11748 RESTORE_REST
11749 cmpq $(IA32_NR_syscalls-1),%rax
11750 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11751 +
11752 + pax_erase_kstack
11753 +
11754 jmp sysenter_do_call
11755 CFI_ENDPROC
11756 ENDPROC(ia32_sysenter_target)
11757 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11758 ENTRY(ia32_cstar_target)
11759 CFI_STARTPROC32 simple
11760 CFI_SIGNAL_FRAME
11761 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11762 + CFI_DEF_CFA rsp,0
11763 CFI_REGISTER rip,rcx
11764 /*CFI_REGISTER rflags,r11*/
11765 SWAPGS_UNSAFE_STACK
11766 movl %esp,%r8d
11767 CFI_REGISTER rsp,r8
11768 movq PER_CPU_VAR(kernel_stack),%rsp
11769 + SAVE_ARGS 8*6,0,0
11770 + pax_enter_kernel_user
11771 +
11772 +#ifdef CONFIG_PAX_RANDKSTACK
11773 + pax_erase_kstack
11774 +#endif
11775 +
11776 /*
11777 * No need to follow this irqs on/off section: the syscall
11778 * disabled irqs and here we enable it straight after entry:
11779 */
11780 ENABLE_INTERRUPTS(CLBR_NONE)
11781 - SAVE_ARGS 8,0,0
11782 movl %eax,%eax /* zero extension */
11783 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11784 movq %rcx,RIP-ARGOFFSET(%rsp)
11785 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11786 /* no need to do an access_ok check here because r8 has been
11787 32bit zero extended */
11788 /* hardware stack frame is complete now */
11789 +
11790 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11791 + mov pax_user_shadow_base,%r11
11792 + add %r11,%r8
11793 +#endif
11794 +
11795 ASM_STAC
11796 1: movl (%r8),%r9d
11797 _ASM_EXTABLE(1b,ia32_badarg)
11798 ASM_CLAC
11799 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11800 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11801 + GET_THREAD_INFO(%r11)
11802 + orl $TS_COMPAT,TI_status(%r11)
11803 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11804 CFI_REMEMBER_STATE
11805 jnz cstar_tracesys
11806 cmpq $IA32_NR_syscalls-1,%rax
11807 @@ -319,12 +384,15 @@ cstar_do_call:
11808 cstar_dispatch:
11809 call *ia32_sys_call_table(,%rax,8)
11810 movq %rax,RAX-ARGOFFSET(%rsp)
11811 + GET_THREAD_INFO(%r11)
11812 DISABLE_INTERRUPTS(CLBR_NONE)
11813 TRACE_IRQS_OFF
11814 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11815 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11816 jnz sysretl_audit
11817 sysretl_from_sys_call:
11818 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11819 + pax_exit_kernel_user
11820 + pax_erase_kstack
11821 + andl $~TS_COMPAT,TI_status(%r11)
11822 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11823 movl RIP-ARGOFFSET(%rsp),%ecx
11824 CFI_REGISTER rip,rcx
11825 @@ -352,7 +420,7 @@ sysretl_audit:
11826
11827 cstar_tracesys:
11828 #ifdef CONFIG_AUDITSYSCALL
11829 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11830 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11831 jz cstar_auditsys
11832 #endif
11833 xchgl %r9d,%ebp
11834 @@ -366,6 +434,9 @@ cstar_tracesys:
11835 xchgl %ebp,%r9d
11836 cmpq $(IA32_NR_syscalls-1),%rax
11837 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11838 +
11839 + pax_erase_kstack
11840 +
11841 jmp cstar_do_call
11842 END(ia32_cstar_target)
11843
11844 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11845 CFI_REL_OFFSET rip,RIP-RIP
11846 PARAVIRT_ADJUST_EXCEPTION_FRAME
11847 SWAPGS
11848 - /*
11849 - * No need to follow this irqs on/off section: the syscall
11850 - * disabled irqs and here we enable it straight after entry:
11851 - */
11852 - ENABLE_INTERRUPTS(CLBR_NONE)
11853 movl %eax,%eax
11854 pushq_cfi %rax
11855 cld
11856 /* note the registers are not zero extended to the sf.
11857 this could be a problem. */
11858 SAVE_ARGS 0,1,0
11859 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11860 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11861 + pax_enter_kernel_user
11862 +
11863 +#ifdef CONFIG_PAX_RANDKSTACK
11864 + pax_erase_kstack
11865 +#endif
11866 +
11867 + /*
11868 + * No need to follow this irqs on/off section: the syscall
11869 + * disabled irqs and here we enable it straight after entry:
11870 + */
11871 + ENABLE_INTERRUPTS(CLBR_NONE)
11872 + GET_THREAD_INFO(%r11)
11873 + orl $TS_COMPAT,TI_status(%r11)
11874 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11875 jnz ia32_tracesys
11876 cmpq $(IA32_NR_syscalls-1),%rax
11877 ja ia32_badsys
11878 @@ -442,6 +520,9 @@ ia32_tracesys:
11879 RESTORE_REST
11880 cmpq $(IA32_NR_syscalls-1),%rax
11881 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11882 +
11883 + pax_erase_kstack
11884 +
11885 jmp ia32_do_call
11886 END(ia32_syscall)
11887
11888 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11889 index 8e0ceec..af13504 100644
11890 --- a/arch/x86/ia32/sys_ia32.c
11891 +++ b/arch/x86/ia32/sys_ia32.c
11892 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11893 */
11894 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11895 {
11896 - typeof(ubuf->st_uid) uid = 0;
11897 - typeof(ubuf->st_gid) gid = 0;
11898 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11899 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11900 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11901 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11902 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11903 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11904 index 372231c..a5aa1a1 100644
11905 --- a/arch/x86/include/asm/alternative-asm.h
11906 +++ b/arch/x86/include/asm/alternative-asm.h
11907 @@ -18,6 +18,45 @@
11908 .endm
11909 #endif
11910
11911 +#ifdef KERNEXEC_PLUGIN
11912 + .macro pax_force_retaddr_bts rip=0
11913 + btsq $63,\rip(%rsp)
11914 + .endm
11915 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11916 + .macro pax_force_retaddr rip=0, reload=0
11917 + btsq $63,\rip(%rsp)
11918 + .endm
11919 + .macro pax_force_fptr ptr
11920 + btsq $63,\ptr
11921 + .endm
11922 + .macro pax_set_fptr_mask
11923 + .endm
11924 +#endif
11925 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11926 + .macro pax_force_retaddr rip=0, reload=0
11927 + .if \reload
11928 + pax_set_fptr_mask
11929 + .endif
11930 + orq %r10,\rip(%rsp)
11931 + .endm
11932 + .macro pax_force_fptr ptr
11933 + orq %r10,\ptr
11934 + .endm
11935 + .macro pax_set_fptr_mask
11936 + movabs $0x8000000000000000,%r10
11937 + .endm
11938 +#endif
11939 +#else
11940 + .macro pax_force_retaddr rip=0, reload=0
11941 + .endm
11942 + .macro pax_force_fptr ptr
11943 + .endm
11944 + .macro pax_force_retaddr_bts rip=0
11945 + .endm
11946 + .macro pax_set_fptr_mask
11947 + .endm
11948 +#endif
11949 +
11950 .macro altinstruction_entry orig alt feature orig_len alt_len
11951 .long \orig - .
11952 .long \alt - .
11953 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11954 index 58ed6d9..f1cbe58 100644
11955 --- a/arch/x86/include/asm/alternative.h
11956 +++ b/arch/x86/include/asm/alternative.h
11957 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11958 ".pushsection .discard,\"aw\",@progbits\n" \
11959 DISCARD_ENTRY(1) \
11960 ".popsection\n" \
11961 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11962 + ".pushsection .altinstr_replacement, \"a\"\n" \
11963 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11964 ".popsection"
11965
11966 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11967 DISCARD_ENTRY(1) \
11968 DISCARD_ENTRY(2) \
11969 ".popsection\n" \
11970 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11971 + ".pushsection .altinstr_replacement, \"a\"\n" \
11972 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11973 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11974 ".popsection"
11975 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11976 index 3388034..050f0b9 100644
11977 --- a/arch/x86/include/asm/apic.h
11978 +++ b/arch/x86/include/asm/apic.h
11979 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11980
11981 #ifdef CONFIG_X86_LOCAL_APIC
11982
11983 -extern unsigned int apic_verbosity;
11984 +extern int apic_verbosity;
11985 extern int local_apic_timer_c2_ok;
11986
11987 extern int disable_apic;
11988 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11989 index 20370c6..a2eb9b0 100644
11990 --- a/arch/x86/include/asm/apm.h
11991 +++ b/arch/x86/include/asm/apm.h
11992 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11993 __asm__ __volatile__(APM_DO_ZERO_SEGS
11994 "pushl %%edi\n\t"
11995 "pushl %%ebp\n\t"
11996 - "lcall *%%cs:apm_bios_entry\n\t"
11997 + "lcall *%%ss:apm_bios_entry\n\t"
11998 "setc %%al\n\t"
11999 "popl %%ebp\n\t"
12000 "popl %%edi\n\t"
12001 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12002 __asm__ __volatile__(APM_DO_ZERO_SEGS
12003 "pushl %%edi\n\t"
12004 "pushl %%ebp\n\t"
12005 - "lcall *%%cs:apm_bios_entry\n\t"
12006 + "lcall *%%ss:apm_bios_entry\n\t"
12007 "setc %%bl\n\t"
12008 "popl %%ebp\n\t"
12009 "popl %%edi\n\t"
12010 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12011 index 722aa3b..3a0bb27 100644
12012 --- a/arch/x86/include/asm/atomic.h
12013 +++ b/arch/x86/include/asm/atomic.h
12014 @@ -22,7 +22,18 @@
12015 */
12016 static inline int atomic_read(const atomic_t *v)
12017 {
12018 - return (*(volatile int *)&(v)->counter);
12019 + return (*(volatile const int *)&(v)->counter);
12020 +}
12021 +
12022 +/**
12023 + * atomic_read_unchecked - read atomic variable
12024 + * @v: pointer of type atomic_unchecked_t
12025 + *
12026 + * Atomically reads the value of @v.
12027 + */
12028 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12029 +{
12030 + return (*(volatile const int *)&(v)->counter);
12031 }
12032
12033 /**
12034 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12035 }
12036
12037 /**
12038 + * atomic_set_unchecked - set atomic variable
12039 + * @v: pointer of type atomic_unchecked_t
12040 + * @i: required value
12041 + *
12042 + * Atomically sets the value of @v to @i.
12043 + */
12044 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12045 +{
12046 + v->counter = i;
12047 +}
12048 +
12049 +/**
12050 * atomic_add - add integer to atomic variable
12051 * @i: integer value to add
12052 * @v: pointer of type atomic_t
12053 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12054 */
12055 static inline void atomic_add(int i, atomic_t *v)
12056 {
12057 - asm volatile(LOCK_PREFIX "addl %1,%0"
12058 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12059 +
12060 +#ifdef CONFIG_PAX_REFCOUNT
12061 + "jno 0f\n"
12062 + LOCK_PREFIX "subl %1,%0\n"
12063 + "int $4\n0:\n"
12064 + _ASM_EXTABLE(0b, 0b)
12065 +#endif
12066 +
12067 + : "+m" (v->counter)
12068 + : "ir" (i));
12069 +}
12070 +
12071 +/**
12072 + * atomic_add_unchecked - add integer to atomic variable
12073 + * @i: integer value to add
12074 + * @v: pointer of type atomic_unchecked_t
12075 + *
12076 + * Atomically adds @i to @v.
12077 + */
12078 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12079 +{
12080 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12081 : "+m" (v->counter)
12082 : "ir" (i));
12083 }
12084 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12085 */
12086 static inline void atomic_sub(int i, atomic_t *v)
12087 {
12088 - asm volatile(LOCK_PREFIX "subl %1,%0"
12089 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12090 +
12091 +#ifdef CONFIG_PAX_REFCOUNT
12092 + "jno 0f\n"
12093 + LOCK_PREFIX "addl %1,%0\n"
12094 + "int $4\n0:\n"
12095 + _ASM_EXTABLE(0b, 0b)
12096 +#endif
12097 +
12098 + : "+m" (v->counter)
12099 + : "ir" (i));
12100 +}
12101 +
12102 +/**
12103 + * atomic_sub_unchecked - subtract integer from atomic variable
12104 + * @i: integer value to subtract
12105 + * @v: pointer of type atomic_unchecked_t
12106 + *
12107 + * Atomically subtracts @i from @v.
12108 + */
12109 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12110 +{
12111 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12112 : "+m" (v->counter)
12113 : "ir" (i));
12114 }
12115 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12116 {
12117 unsigned char c;
12118
12119 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12120 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12121 +
12122 +#ifdef CONFIG_PAX_REFCOUNT
12123 + "jno 0f\n"
12124 + LOCK_PREFIX "addl %2,%0\n"
12125 + "int $4\n0:\n"
12126 + _ASM_EXTABLE(0b, 0b)
12127 +#endif
12128 +
12129 + "sete %1\n"
12130 : "+m" (v->counter), "=qm" (c)
12131 : "ir" (i) : "memory");
12132 return c;
12133 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12134 */
12135 static inline void atomic_inc(atomic_t *v)
12136 {
12137 - asm volatile(LOCK_PREFIX "incl %0"
12138 + asm volatile(LOCK_PREFIX "incl %0\n"
12139 +
12140 +#ifdef CONFIG_PAX_REFCOUNT
12141 + "jno 0f\n"
12142 + LOCK_PREFIX "decl %0\n"
12143 + "int $4\n0:\n"
12144 + _ASM_EXTABLE(0b, 0b)
12145 +#endif
12146 +
12147 + : "+m" (v->counter));
12148 +}
12149 +
12150 +/**
12151 + * atomic_inc_unchecked - increment atomic variable
12152 + * @v: pointer of type atomic_unchecked_t
12153 + *
12154 + * Atomically increments @v by 1.
12155 + */
12156 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12157 +{
12158 + asm volatile(LOCK_PREFIX "incl %0\n"
12159 : "+m" (v->counter));
12160 }
12161
12162 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12163 */
12164 static inline void atomic_dec(atomic_t *v)
12165 {
12166 - asm volatile(LOCK_PREFIX "decl %0"
12167 + asm volatile(LOCK_PREFIX "decl %0\n"
12168 +
12169 +#ifdef CONFIG_PAX_REFCOUNT
12170 + "jno 0f\n"
12171 + LOCK_PREFIX "incl %0\n"
12172 + "int $4\n0:\n"
12173 + _ASM_EXTABLE(0b, 0b)
12174 +#endif
12175 +
12176 + : "+m" (v->counter));
12177 +}
12178 +
12179 +/**
12180 + * atomic_dec_unchecked - decrement atomic variable
12181 + * @v: pointer of type atomic_unchecked_t
12182 + *
12183 + * Atomically decrements @v by 1.
12184 + */
12185 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12186 +{
12187 + asm volatile(LOCK_PREFIX "decl %0\n"
12188 : "+m" (v->counter));
12189 }
12190
12191 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12192 {
12193 unsigned char c;
12194
12195 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12196 + asm volatile(LOCK_PREFIX "decl %0\n"
12197 +
12198 +#ifdef CONFIG_PAX_REFCOUNT
12199 + "jno 0f\n"
12200 + LOCK_PREFIX "incl %0\n"
12201 + "int $4\n0:\n"
12202 + _ASM_EXTABLE(0b, 0b)
12203 +#endif
12204 +
12205 + "sete %1\n"
12206 : "+m" (v->counter), "=qm" (c)
12207 : : "memory");
12208 return c != 0;
12209 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12210 {
12211 unsigned char c;
12212
12213 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12214 + asm volatile(LOCK_PREFIX "incl %0\n"
12215 +
12216 +#ifdef CONFIG_PAX_REFCOUNT
12217 + "jno 0f\n"
12218 + LOCK_PREFIX "decl %0\n"
12219 + "int $4\n0:\n"
12220 + _ASM_EXTABLE(0b, 0b)
12221 +#endif
12222 +
12223 + "sete %1\n"
12224 + : "+m" (v->counter), "=qm" (c)
12225 + : : "memory");
12226 + return c != 0;
12227 +}
12228 +
12229 +/**
12230 + * atomic_inc_and_test_unchecked - increment and test
12231 + * @v: pointer of type atomic_unchecked_t
12232 + *
12233 + * Atomically increments @v by 1
12234 + * and returns true if the result is zero, or false for all
12235 + * other cases.
12236 + */
12237 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12238 +{
12239 + unsigned char c;
12240 +
12241 + asm volatile(LOCK_PREFIX "incl %0\n"
12242 + "sete %1\n"
12243 : "+m" (v->counter), "=qm" (c)
12244 : : "memory");
12245 return c != 0;
12246 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12247 {
12248 unsigned char c;
12249
12250 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12251 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12252 +
12253 +#ifdef CONFIG_PAX_REFCOUNT
12254 + "jno 0f\n"
12255 + LOCK_PREFIX "subl %2,%0\n"
12256 + "int $4\n0:\n"
12257 + _ASM_EXTABLE(0b, 0b)
12258 +#endif
12259 +
12260 + "sets %1\n"
12261 : "+m" (v->counter), "=qm" (c)
12262 : "ir" (i) : "memory");
12263 return c;
12264 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12265 */
12266 static inline int atomic_add_return(int i, atomic_t *v)
12267 {
12268 + return i + xadd_check_overflow(&v->counter, i);
12269 +}
12270 +
12271 +/**
12272 + * atomic_add_return_unchecked - add integer and return
12273 + * @i: integer value to add
12274 + * @v: pointer of type atomic_unchecked_t
12275 + *
12276 + * Atomically adds @i to @v and returns @i + @v
12277 + */
12278 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12279 +{
12280 return i + xadd(&v->counter, i);
12281 }
12282
12283 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12284 }
12285
12286 #define atomic_inc_return(v) (atomic_add_return(1, v))
12287 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12288 +{
12289 + return atomic_add_return_unchecked(1, v);
12290 +}
12291 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12292
12293 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12294 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12295 return cmpxchg(&v->counter, old, new);
12296 }
12297
12298 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12299 +{
12300 + return cmpxchg(&v->counter, old, new);
12301 +}
12302 +
12303 static inline int atomic_xchg(atomic_t *v, int new)
12304 {
12305 return xchg(&v->counter, new);
12306 }
12307
12308 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12309 +{
12310 + return xchg(&v->counter, new);
12311 +}
12312 +
12313 /**
12314 * __atomic_add_unless - add unless the number is already a given value
12315 * @v: pointer of type atomic_t
12316 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12317 */
12318 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12319 {
12320 - int c, old;
12321 + int c, old, new;
12322 c = atomic_read(v);
12323 for (;;) {
12324 - if (unlikely(c == (u)))
12325 + if (unlikely(c == u))
12326 break;
12327 - old = atomic_cmpxchg((v), c, c + (a));
12328 +
12329 + asm volatile("addl %2,%0\n"
12330 +
12331 +#ifdef CONFIG_PAX_REFCOUNT
12332 + "jno 0f\n"
12333 + "subl %2,%0\n"
12334 + "int $4\n0:\n"
12335 + _ASM_EXTABLE(0b, 0b)
12336 +#endif
12337 +
12338 + : "=r" (new)
12339 + : "0" (c), "ir" (a));
12340 +
12341 + old = atomic_cmpxchg(v, c, new);
12342 if (likely(old == c))
12343 break;
12344 c = old;
12345 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12346 }
12347
12348 /**
12349 + * atomic_inc_not_zero_hint - increment if not null
12350 + * @v: pointer of type atomic_t
12351 + * @hint: probable value of the atomic before the increment
12352 + *
12353 + * This version of atomic_inc_not_zero() gives a hint of probable
12354 + * value of the atomic. This helps processor to not read the memory
12355 + * before doing the atomic read/modify/write cycle, lowering
12356 + * number of bus transactions on some arches.
12357 + *
12358 + * Returns: 0 if increment was not done, 1 otherwise.
12359 + */
12360 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12361 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12362 +{
12363 + int val, c = hint, new;
12364 +
12365 + /* sanity test, should be removed by compiler if hint is a constant */
12366 + if (!hint)
12367 + return __atomic_add_unless(v, 1, 0);
12368 +
12369 + do {
12370 + asm volatile("incl %0\n"
12371 +
12372 +#ifdef CONFIG_PAX_REFCOUNT
12373 + "jno 0f\n"
12374 + "decl %0\n"
12375 + "int $4\n0:\n"
12376 + _ASM_EXTABLE(0b, 0b)
12377 +#endif
12378 +
12379 + : "=r" (new)
12380 + : "0" (c));
12381 +
12382 + val = atomic_cmpxchg(v, c, new);
12383 + if (val == c)
12384 + return 1;
12385 + c = val;
12386 + } while (c);
12387 +
12388 + return 0;
12389 +}
12390 +
12391 +/**
12392 * atomic_inc_short - increment of a short integer
12393 * @v: pointer to type int
12394 *
12395 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12396 #endif
12397
12398 /* These are x86-specific, used by some header files */
12399 -#define atomic_clear_mask(mask, addr) \
12400 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12401 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12402 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12403 +{
12404 + asm volatile(LOCK_PREFIX "andl %1,%0"
12405 + : "+m" (v->counter)
12406 + : "r" (~(mask))
12407 + : "memory");
12408 +}
12409
12410 -#define atomic_set_mask(mask, addr) \
12411 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12412 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12413 - : "memory")
12414 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12415 +{
12416 + asm volatile(LOCK_PREFIX "andl %1,%0"
12417 + : "+m" (v->counter)
12418 + : "r" (~(mask))
12419 + : "memory");
12420 +}
12421 +
12422 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12423 +{
12424 + asm volatile(LOCK_PREFIX "orl %1,%0"
12425 + : "+m" (v->counter)
12426 + : "r" (mask)
12427 + : "memory");
12428 +}
12429 +
12430 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12431 +{
12432 + asm volatile(LOCK_PREFIX "orl %1,%0"
12433 + : "+m" (v->counter)
12434 + : "r" (mask)
12435 + : "memory");
12436 +}
12437
12438 /* Atomic operations are already serializing on x86 */
12439 #define smp_mb__before_atomic_dec() barrier()
12440 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12441 index b154de7..aadebd8 100644
12442 --- a/arch/x86/include/asm/atomic64_32.h
12443 +++ b/arch/x86/include/asm/atomic64_32.h
12444 @@ -12,6 +12,14 @@ typedef struct {
12445 u64 __aligned(8) counter;
12446 } atomic64_t;
12447
12448 +#ifdef CONFIG_PAX_REFCOUNT
12449 +typedef struct {
12450 + u64 __aligned(8) counter;
12451 +} atomic64_unchecked_t;
12452 +#else
12453 +typedef atomic64_t atomic64_unchecked_t;
12454 +#endif
12455 +
12456 #define ATOMIC64_INIT(val) { (val) }
12457
12458 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12459 @@ -37,21 +45,31 @@ typedef struct {
12460 ATOMIC64_DECL_ONE(sym##_386)
12461
12462 ATOMIC64_DECL_ONE(add_386);
12463 +ATOMIC64_DECL_ONE(add_unchecked_386);
12464 ATOMIC64_DECL_ONE(sub_386);
12465 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12466 ATOMIC64_DECL_ONE(inc_386);
12467 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12468 ATOMIC64_DECL_ONE(dec_386);
12469 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12470 #endif
12471
12472 #define alternative_atomic64(f, out, in...) \
12473 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12474
12475 ATOMIC64_DECL(read);
12476 +ATOMIC64_DECL(read_unchecked);
12477 ATOMIC64_DECL(set);
12478 +ATOMIC64_DECL(set_unchecked);
12479 ATOMIC64_DECL(xchg);
12480 ATOMIC64_DECL(add_return);
12481 +ATOMIC64_DECL(add_return_unchecked);
12482 ATOMIC64_DECL(sub_return);
12483 +ATOMIC64_DECL(sub_return_unchecked);
12484 ATOMIC64_DECL(inc_return);
12485 +ATOMIC64_DECL(inc_return_unchecked);
12486 ATOMIC64_DECL(dec_return);
12487 +ATOMIC64_DECL(dec_return_unchecked);
12488 ATOMIC64_DECL(dec_if_positive);
12489 ATOMIC64_DECL(inc_not_zero);
12490 ATOMIC64_DECL(add_unless);
12491 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12492 }
12493
12494 /**
12495 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12496 + * @p: pointer to type atomic64_unchecked_t
12497 + * @o: expected value
12498 + * @n: new value
12499 + *
12500 + * Atomically sets @v to @n if it was equal to @o and returns
12501 + * the old value.
12502 + */
12503 +
12504 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12505 +{
12506 + return cmpxchg64(&v->counter, o, n);
12507 +}
12508 +
12509 +/**
12510 * atomic64_xchg - xchg atomic64 variable
12511 * @v: pointer to type atomic64_t
12512 * @n: value to assign
12513 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12514 }
12515
12516 /**
12517 + * atomic64_set_unchecked - set atomic64 variable
12518 + * @v: pointer to type atomic64_unchecked_t
12519 + * @n: value to assign
12520 + *
12521 + * Atomically sets the value of @v to @n.
12522 + */
12523 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12524 +{
12525 + unsigned high = (unsigned)(i >> 32);
12526 + unsigned low = (unsigned)i;
12527 + alternative_atomic64(set, /* no output */,
12528 + "S" (v), "b" (low), "c" (high)
12529 + : "eax", "edx", "memory");
12530 +}
12531 +
12532 +/**
12533 * atomic64_read - read atomic64 variable
12534 * @v: pointer to type atomic64_t
12535 *
12536 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12537 }
12538
12539 /**
12540 + * atomic64_read_unchecked - read atomic64 variable
12541 + * @v: pointer to type atomic64_unchecked_t
12542 + *
12543 + * Atomically reads the value of @v and returns it.
12544 + */
12545 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12546 +{
12547 + long long r;
12548 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12549 + return r;
12550 + }
12551 +
12552 +/**
12553 * atomic64_add_return - add and return
12554 * @i: integer value to add
12555 * @v: pointer to type atomic64_t
12556 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12557 return i;
12558 }
12559
12560 +/**
12561 + * atomic64_add_return_unchecked - add and return
12562 + * @i: integer value to add
12563 + * @v: pointer to type atomic64_unchecked_t
12564 + *
12565 + * Atomically adds @i to @v and returns @i + *@v
12566 + */
12567 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12568 +{
12569 + alternative_atomic64(add_return_unchecked,
12570 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12571 + ASM_NO_INPUT_CLOBBER("memory"));
12572 + return i;
12573 +}
12574 +
12575 /*
12576 * Other variants with different arithmetic operators:
12577 */
12578 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12579 return a;
12580 }
12581
12582 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12583 +{
12584 + long long a;
12585 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12586 + "S" (v) : "memory", "ecx");
12587 + return a;
12588 +}
12589 +
12590 static inline long long atomic64_dec_return(atomic64_t *v)
12591 {
12592 long long a;
12593 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12594 }
12595
12596 /**
12597 + * atomic64_add_unchecked - add integer to atomic64 variable
12598 + * @i: integer value to add
12599 + * @v: pointer to type atomic64_unchecked_t
12600 + *
12601 + * Atomically adds @i to @v.
12602 + */
12603 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12604 +{
12605 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12606 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12607 + ASM_NO_INPUT_CLOBBER("memory"));
12608 + return i;
12609 +}
12610 +
12611 +/**
12612 * atomic64_sub - subtract the atomic64 variable
12613 * @i: integer value to subtract
12614 * @v: pointer to type atomic64_t
12615 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12616 index 0e1cbfc..5623683 100644
12617 --- a/arch/x86/include/asm/atomic64_64.h
12618 +++ b/arch/x86/include/asm/atomic64_64.h
12619 @@ -18,7 +18,19 @@
12620 */
12621 static inline long atomic64_read(const atomic64_t *v)
12622 {
12623 - return (*(volatile long *)&(v)->counter);
12624 + return (*(volatile const long *)&(v)->counter);
12625 +}
12626 +
12627 +/**
12628 + * atomic64_read_unchecked - read atomic64 variable
12629 + * @v: pointer of type atomic64_unchecked_t
12630 + *
12631 + * Atomically reads the value of @v.
12632 + * Doesn't imply a read memory barrier.
12633 + */
12634 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12635 +{
12636 + return (*(volatile const long *)&(v)->counter);
12637 }
12638
12639 /**
12640 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12641 }
12642
12643 /**
12644 + * atomic64_set_unchecked - set atomic64 variable
12645 + * @v: pointer to type atomic64_unchecked_t
12646 + * @i: required value
12647 + *
12648 + * Atomically sets the value of @v to @i.
12649 + */
12650 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12651 +{
12652 + v->counter = i;
12653 +}
12654 +
12655 +/**
12656 * atomic64_add - add integer to atomic64 variable
12657 * @i: integer value to add
12658 * @v: pointer to type atomic64_t
12659 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12660 */
12661 static inline void atomic64_add(long i, atomic64_t *v)
12662 {
12663 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12664 +
12665 +#ifdef CONFIG_PAX_REFCOUNT
12666 + "jno 0f\n"
12667 + LOCK_PREFIX "subq %1,%0\n"
12668 + "int $4\n0:\n"
12669 + _ASM_EXTABLE(0b, 0b)
12670 +#endif
12671 +
12672 + : "=m" (v->counter)
12673 + : "er" (i), "m" (v->counter));
12674 +}
12675 +
12676 +/**
12677 + * atomic64_add_unchecked - add integer to atomic64 variable
12678 + * @i: integer value to add
12679 + * @v: pointer to type atomic64_unchecked_t
12680 + *
12681 + * Atomically adds @i to @v.
12682 + */
12683 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12684 +{
12685 asm volatile(LOCK_PREFIX "addq %1,%0"
12686 : "=m" (v->counter)
12687 : "er" (i), "m" (v->counter));
12688 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12689 */
12690 static inline void atomic64_sub(long i, atomic64_t *v)
12691 {
12692 - asm volatile(LOCK_PREFIX "subq %1,%0"
12693 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12694 +
12695 +#ifdef CONFIG_PAX_REFCOUNT
12696 + "jno 0f\n"
12697 + LOCK_PREFIX "addq %1,%0\n"
12698 + "int $4\n0:\n"
12699 + _ASM_EXTABLE(0b, 0b)
12700 +#endif
12701 +
12702 + : "=m" (v->counter)
12703 + : "er" (i), "m" (v->counter));
12704 +}
12705 +
12706 +/**
12707 + * atomic64_sub_unchecked - subtract the atomic64 variable
12708 + * @i: integer value to subtract
12709 + * @v: pointer to type atomic64_unchecked_t
12710 + *
12711 + * Atomically subtracts @i from @v.
12712 + */
12713 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12714 +{
12715 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12716 : "=m" (v->counter)
12717 : "er" (i), "m" (v->counter));
12718 }
12719 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12720 {
12721 unsigned char c;
12722
12723 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12724 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12725 +
12726 +#ifdef CONFIG_PAX_REFCOUNT
12727 + "jno 0f\n"
12728 + LOCK_PREFIX "addq %2,%0\n"
12729 + "int $4\n0:\n"
12730 + _ASM_EXTABLE(0b, 0b)
12731 +#endif
12732 +
12733 + "sete %1\n"
12734 : "=m" (v->counter), "=qm" (c)
12735 : "er" (i), "m" (v->counter) : "memory");
12736 return c;
12737 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12738 */
12739 static inline void atomic64_inc(atomic64_t *v)
12740 {
12741 + asm volatile(LOCK_PREFIX "incq %0\n"
12742 +
12743 +#ifdef CONFIG_PAX_REFCOUNT
12744 + "jno 0f\n"
12745 + LOCK_PREFIX "decq %0\n"
12746 + "int $4\n0:\n"
12747 + _ASM_EXTABLE(0b, 0b)
12748 +#endif
12749 +
12750 + : "=m" (v->counter)
12751 + : "m" (v->counter));
12752 +}
12753 +
12754 +/**
12755 + * atomic64_inc_unchecked - increment atomic64 variable
12756 + * @v: pointer to type atomic64_unchecked_t
12757 + *
12758 + * Atomically increments @v by 1.
12759 + */
12760 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12761 +{
12762 asm volatile(LOCK_PREFIX "incq %0"
12763 : "=m" (v->counter)
12764 : "m" (v->counter));
12765 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12766 */
12767 static inline void atomic64_dec(atomic64_t *v)
12768 {
12769 - asm volatile(LOCK_PREFIX "decq %0"
12770 + asm volatile(LOCK_PREFIX "decq %0\n"
12771 +
12772 +#ifdef CONFIG_PAX_REFCOUNT
12773 + "jno 0f\n"
12774 + LOCK_PREFIX "incq %0\n"
12775 + "int $4\n0:\n"
12776 + _ASM_EXTABLE(0b, 0b)
12777 +#endif
12778 +
12779 + : "=m" (v->counter)
12780 + : "m" (v->counter));
12781 +}
12782 +
12783 +/**
12784 + * atomic64_dec_unchecked - decrement atomic64 variable
12785 + * @v: pointer to type atomic64_t
12786 + *
12787 + * Atomically decrements @v by 1.
12788 + */
12789 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12790 +{
12791 + asm volatile(LOCK_PREFIX "decq %0\n"
12792 : "=m" (v->counter)
12793 : "m" (v->counter));
12794 }
12795 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12796 {
12797 unsigned char c;
12798
12799 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12800 + asm volatile(LOCK_PREFIX "decq %0\n"
12801 +
12802 +#ifdef CONFIG_PAX_REFCOUNT
12803 + "jno 0f\n"
12804 + LOCK_PREFIX "incq %0\n"
12805 + "int $4\n0:\n"
12806 + _ASM_EXTABLE(0b, 0b)
12807 +#endif
12808 +
12809 + "sete %1\n"
12810 : "=m" (v->counter), "=qm" (c)
12811 : "m" (v->counter) : "memory");
12812 return c != 0;
12813 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12814 {
12815 unsigned char c;
12816
12817 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12818 + asm volatile(LOCK_PREFIX "incq %0\n"
12819 +
12820 +#ifdef CONFIG_PAX_REFCOUNT
12821 + "jno 0f\n"
12822 + LOCK_PREFIX "decq %0\n"
12823 + "int $4\n0:\n"
12824 + _ASM_EXTABLE(0b, 0b)
12825 +#endif
12826 +
12827 + "sete %1\n"
12828 : "=m" (v->counter), "=qm" (c)
12829 : "m" (v->counter) : "memory");
12830 return c != 0;
12831 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12832 {
12833 unsigned char c;
12834
12835 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12836 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12837 +
12838 +#ifdef CONFIG_PAX_REFCOUNT
12839 + "jno 0f\n"
12840 + LOCK_PREFIX "subq %2,%0\n"
12841 + "int $4\n0:\n"
12842 + _ASM_EXTABLE(0b, 0b)
12843 +#endif
12844 +
12845 + "sets %1\n"
12846 : "=m" (v->counter), "=qm" (c)
12847 : "er" (i), "m" (v->counter) : "memory");
12848 return c;
12849 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12850 */
12851 static inline long atomic64_add_return(long i, atomic64_t *v)
12852 {
12853 + return i + xadd_check_overflow(&v->counter, i);
12854 +}
12855 +
12856 +/**
12857 + * atomic64_add_return_unchecked - add and return
12858 + * @i: integer value to add
12859 + * @v: pointer to type atomic64_unchecked_t
12860 + *
12861 + * Atomically adds @i to @v and returns @i + @v
12862 + */
12863 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12864 +{
12865 return i + xadd(&v->counter, i);
12866 }
12867
12868 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12869 }
12870
12871 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12872 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12873 +{
12874 + return atomic64_add_return_unchecked(1, v);
12875 +}
12876 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12877
12878 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12879 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12880 return cmpxchg(&v->counter, old, new);
12881 }
12882
12883 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12884 +{
12885 + return cmpxchg(&v->counter, old, new);
12886 +}
12887 +
12888 static inline long atomic64_xchg(atomic64_t *v, long new)
12889 {
12890 return xchg(&v->counter, new);
12891 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12892 */
12893 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12894 {
12895 - long c, old;
12896 + long c, old, new;
12897 c = atomic64_read(v);
12898 for (;;) {
12899 - if (unlikely(c == (u)))
12900 + if (unlikely(c == u))
12901 break;
12902 - old = atomic64_cmpxchg((v), c, c + (a));
12903 +
12904 + asm volatile("add %2,%0\n"
12905 +
12906 +#ifdef CONFIG_PAX_REFCOUNT
12907 + "jno 0f\n"
12908 + "sub %2,%0\n"
12909 + "int $4\n0:\n"
12910 + _ASM_EXTABLE(0b, 0b)
12911 +#endif
12912 +
12913 + : "=r" (new)
12914 + : "0" (c), "ir" (a));
12915 +
12916 + old = atomic64_cmpxchg(v, c, new);
12917 if (likely(old == c))
12918 break;
12919 c = old;
12920 }
12921 - return c != (u);
12922 + return c != u;
12923 }
12924
12925 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12926 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12927 index 6dfd019..28e188d 100644
12928 --- a/arch/x86/include/asm/bitops.h
12929 +++ b/arch/x86/include/asm/bitops.h
12930 @@ -40,7 +40,7 @@
12931 * a mask operation on a byte.
12932 */
12933 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12934 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12935 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12936 #define CONST_MASK(nr) (1 << ((nr) & 7))
12937
12938 /**
12939 @@ -486,7 +486,7 @@ static inline int fls(int x)
12940 * at position 64.
12941 */
12942 #ifdef CONFIG_X86_64
12943 -static __always_inline int fls64(__u64 x)
12944 +static __always_inline long fls64(__u64 x)
12945 {
12946 int bitpos = -1;
12947 /*
12948 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12949 index 4fa687a..60f2d39 100644
12950 --- a/arch/x86/include/asm/boot.h
12951 +++ b/arch/x86/include/asm/boot.h
12952 @@ -6,10 +6,15 @@
12953 #include <uapi/asm/boot.h>
12954
12955 /* Physical address where kernel should be loaded. */
12956 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12957 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12958 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12959 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12960
12961 +#ifndef __ASSEMBLY__
12962 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12963 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12964 +#endif
12965 +
12966 /* Minimum kernel alignment, as a power of two */
12967 #ifdef CONFIG_X86_64
12968 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12969 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12970 index 48f99f1..d78ebf9 100644
12971 --- a/arch/x86/include/asm/cache.h
12972 +++ b/arch/x86/include/asm/cache.h
12973 @@ -5,12 +5,13 @@
12974
12975 /* L1 cache line size */
12976 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12977 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12978 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12979
12980 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12981 +#define __read_only __attribute__((__section__(".data..read_only")))
12982
12983 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12984 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12985 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12986
12987 #ifdef CONFIG_X86_VSMP
12988 #ifdef CONFIG_SMP
12989 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12990 index 9863ee3..4a1f8e1 100644
12991 --- a/arch/x86/include/asm/cacheflush.h
12992 +++ b/arch/x86/include/asm/cacheflush.h
12993 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12994 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12995
12996 if (pg_flags == _PGMT_DEFAULT)
12997 - return -1;
12998 + return ~0UL;
12999 else if (pg_flags == _PGMT_WC)
13000 return _PAGE_CACHE_WC;
13001 else if (pg_flags == _PGMT_UC_MINUS)
13002 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13003 index 46fc474..b02b0f9 100644
13004 --- a/arch/x86/include/asm/checksum_32.h
13005 +++ b/arch/x86/include/asm/checksum_32.h
13006 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13007 int len, __wsum sum,
13008 int *src_err_ptr, int *dst_err_ptr);
13009
13010 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13011 + int len, __wsum sum,
13012 + int *src_err_ptr, int *dst_err_ptr);
13013 +
13014 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13015 + int len, __wsum sum,
13016 + int *src_err_ptr, int *dst_err_ptr);
13017 +
13018 /*
13019 * Note: when you get a NULL pointer exception here this means someone
13020 * passed in an incorrect kernel address to one of these functions.
13021 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13022 int *err_ptr)
13023 {
13024 might_sleep();
13025 - return csum_partial_copy_generic((__force void *)src, dst,
13026 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13027 len, sum, err_ptr, NULL);
13028 }
13029
13030 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13031 {
13032 might_sleep();
13033 if (access_ok(VERIFY_WRITE, dst, len))
13034 - return csum_partial_copy_generic(src, (__force void *)dst,
13035 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13036 len, sum, NULL, err_ptr);
13037
13038 if (len)
13039 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13040 index d47786a..ce1b05d 100644
13041 --- a/arch/x86/include/asm/cmpxchg.h
13042 +++ b/arch/x86/include/asm/cmpxchg.h
13043 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13044 __compiletime_error("Bad argument size for cmpxchg");
13045 extern void __xadd_wrong_size(void)
13046 __compiletime_error("Bad argument size for xadd");
13047 +extern void __xadd_check_overflow_wrong_size(void)
13048 + __compiletime_error("Bad argument size for xadd_check_overflow");
13049 extern void __add_wrong_size(void)
13050 __compiletime_error("Bad argument size for add");
13051 +extern void __add_check_overflow_wrong_size(void)
13052 + __compiletime_error("Bad argument size for add_check_overflow");
13053
13054 /*
13055 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13056 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13057 __ret; \
13058 })
13059
13060 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13061 + ({ \
13062 + __typeof__ (*(ptr)) __ret = (arg); \
13063 + switch (sizeof(*(ptr))) { \
13064 + case __X86_CASE_L: \
13065 + asm volatile (lock #op "l %0, %1\n" \
13066 + "jno 0f\n" \
13067 + "mov %0,%1\n" \
13068 + "int $4\n0:\n" \
13069 + _ASM_EXTABLE(0b, 0b) \
13070 + : "+r" (__ret), "+m" (*(ptr)) \
13071 + : : "memory", "cc"); \
13072 + break; \
13073 + case __X86_CASE_Q: \
13074 + asm volatile (lock #op "q %q0, %1\n" \
13075 + "jno 0f\n" \
13076 + "mov %0,%1\n" \
13077 + "int $4\n0:\n" \
13078 + _ASM_EXTABLE(0b, 0b) \
13079 + : "+r" (__ret), "+m" (*(ptr)) \
13080 + : : "memory", "cc"); \
13081 + break; \
13082 + default: \
13083 + __ ## op ## _check_overflow_wrong_size(); \
13084 + } \
13085 + __ret; \
13086 + })
13087 +
13088 /*
13089 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13090 * Since this is generally used to protect other memory information, we
13091 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13092 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13093 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13094
13095 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13096 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13097 +
13098 #define __add(ptr, inc, lock) \
13099 ({ \
13100 __typeof__ (*(ptr)) __ret = (inc); \
13101 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13102 index 59c6c40..5e0b22c 100644
13103 --- a/arch/x86/include/asm/compat.h
13104 +++ b/arch/x86/include/asm/compat.h
13105 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13106 typedef u32 compat_uint_t;
13107 typedef u32 compat_ulong_t;
13108 typedef u64 __attribute__((aligned(4))) compat_u64;
13109 -typedef u32 compat_uptr_t;
13110 +typedef u32 __user compat_uptr_t;
13111
13112 struct compat_timespec {
13113 compat_time_t tv_sec;
13114 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13115 index e99ac27..e89e28c 100644
13116 --- a/arch/x86/include/asm/cpufeature.h
13117 +++ b/arch/x86/include/asm/cpufeature.h
13118 @@ -211,7 +211,7 @@
13119 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13120 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13121 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13122 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13123 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13124 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13125 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13126 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13127 @@ -394,7 +394,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13128 ".section .discard,\"aw\",@progbits\n"
13129 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13130 ".previous\n"
13131 - ".section .altinstr_replacement,\"ax\"\n"
13132 + ".section .altinstr_replacement,\"a\"\n"
13133 "3: movb $1,%0\n"
13134 "4:\n"
13135 ".previous\n"
13136 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13137 index 8bf1c06..b6ae785 100644
13138 --- a/arch/x86/include/asm/desc.h
13139 +++ b/arch/x86/include/asm/desc.h
13140 @@ -4,6 +4,7 @@
13141 #include <asm/desc_defs.h>
13142 #include <asm/ldt.h>
13143 #include <asm/mmu.h>
13144 +#include <asm/pgtable.h>
13145
13146 #include <linux/smp.h>
13147 #include <linux/percpu.h>
13148 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13149
13150 desc->type = (info->read_exec_only ^ 1) << 1;
13151 desc->type |= info->contents << 2;
13152 + desc->type |= info->seg_not_present ^ 1;
13153
13154 desc->s = 1;
13155 desc->dpl = 0x3;
13156 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13157 }
13158
13159 extern struct desc_ptr idt_descr;
13160 -extern gate_desc idt_table[];
13161 extern struct desc_ptr nmi_idt_descr;
13162 -extern gate_desc nmi_idt_table[];
13163 -
13164 -struct gdt_page {
13165 - struct desc_struct gdt[GDT_ENTRIES];
13166 -} __attribute__((aligned(PAGE_SIZE)));
13167 -
13168 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13169 +extern gate_desc idt_table[256];
13170 +extern gate_desc nmi_idt_table[256];
13171
13172 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13173 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13174 {
13175 - return per_cpu(gdt_page, cpu).gdt;
13176 + return cpu_gdt_table[cpu];
13177 }
13178
13179 #ifdef CONFIG_X86_64
13180 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13181 unsigned long base, unsigned dpl, unsigned flags,
13182 unsigned short seg)
13183 {
13184 - gate->a = (seg << 16) | (base & 0xffff);
13185 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13186 + gate->gate.offset_low = base;
13187 + gate->gate.seg = seg;
13188 + gate->gate.reserved = 0;
13189 + gate->gate.type = type;
13190 + gate->gate.s = 0;
13191 + gate->gate.dpl = dpl;
13192 + gate->gate.p = 1;
13193 + gate->gate.offset_high = base >> 16;
13194 }
13195
13196 #endif
13197 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13198
13199 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13200 {
13201 + pax_open_kernel();
13202 memcpy(&idt[entry], gate, sizeof(*gate));
13203 + pax_close_kernel();
13204 }
13205
13206 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13207 {
13208 + pax_open_kernel();
13209 memcpy(&ldt[entry], desc, 8);
13210 + pax_close_kernel();
13211 }
13212
13213 static inline void
13214 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13215 default: size = sizeof(*gdt); break;
13216 }
13217
13218 + pax_open_kernel();
13219 memcpy(&gdt[entry], desc, size);
13220 + pax_close_kernel();
13221 }
13222
13223 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13224 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13225
13226 static inline void native_load_tr_desc(void)
13227 {
13228 + pax_open_kernel();
13229 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13230 + pax_close_kernel();
13231 }
13232
13233 static inline void native_load_gdt(const struct desc_ptr *dtr)
13234 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13235 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13236 unsigned int i;
13237
13238 + pax_open_kernel();
13239 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13240 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13241 + pax_close_kernel();
13242 }
13243
13244 #define _LDT_empty(info) \
13245 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13246 preempt_enable();
13247 }
13248
13249 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13250 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13251 {
13252 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13253 }
13254 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13255 }
13256
13257 #ifdef CONFIG_X86_64
13258 -static inline void set_nmi_gate(int gate, void *addr)
13259 +static inline void set_nmi_gate(int gate, const void *addr)
13260 {
13261 gate_desc s;
13262
13263 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13264 }
13265 #endif
13266
13267 -static inline void _set_gate(int gate, unsigned type, void *addr,
13268 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13269 unsigned dpl, unsigned ist, unsigned seg)
13270 {
13271 gate_desc s;
13272 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13273 * Pentium F0 0F bugfix can have resulted in the mapped
13274 * IDT being write-protected.
13275 */
13276 -static inline void set_intr_gate(unsigned int n, void *addr)
13277 +static inline void set_intr_gate(unsigned int n, const void *addr)
13278 {
13279 BUG_ON((unsigned)n > 0xFF);
13280 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13281 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13282 /*
13283 * This routine sets up an interrupt gate at directory privilege level 3.
13284 */
13285 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13286 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13287 {
13288 BUG_ON((unsigned)n > 0xFF);
13289 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13290 }
13291
13292 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13293 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13294 {
13295 BUG_ON((unsigned)n > 0xFF);
13296 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13297 }
13298
13299 -static inline void set_trap_gate(unsigned int n, void *addr)
13300 +static inline void set_trap_gate(unsigned int n, const void *addr)
13301 {
13302 BUG_ON((unsigned)n > 0xFF);
13303 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13304 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13305 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13306 {
13307 BUG_ON((unsigned)n > 0xFF);
13308 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13309 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13310 }
13311
13312 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13313 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13314 {
13315 BUG_ON((unsigned)n > 0xFF);
13316 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13317 }
13318
13319 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13320 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13321 {
13322 BUG_ON((unsigned)n > 0xFF);
13323 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13324 }
13325
13326 +#ifdef CONFIG_X86_32
13327 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13328 +{
13329 + struct desc_struct d;
13330 +
13331 + if (likely(limit))
13332 + limit = (limit - 1UL) >> PAGE_SHIFT;
13333 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13334 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13335 +}
13336 +#endif
13337 +
13338 #endif /* _ASM_X86_DESC_H */
13339 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13340 index 278441f..b95a174 100644
13341 --- a/arch/x86/include/asm/desc_defs.h
13342 +++ b/arch/x86/include/asm/desc_defs.h
13343 @@ -31,6 +31,12 @@ struct desc_struct {
13344 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13345 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13346 };
13347 + struct {
13348 + u16 offset_low;
13349 + u16 seg;
13350 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13351 + unsigned offset_high: 16;
13352 + } gate;
13353 };
13354 } __attribute__((packed));
13355
13356 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13357 index ced283a..ffe04cc 100644
13358 --- a/arch/x86/include/asm/div64.h
13359 +++ b/arch/x86/include/asm/div64.h
13360 @@ -39,7 +39,7 @@
13361 __mod; \
13362 })
13363
13364 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13365 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13366 {
13367 union {
13368 u64 v64;
13369 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13370 index 9c999c1..3860cb8 100644
13371 --- a/arch/x86/include/asm/elf.h
13372 +++ b/arch/x86/include/asm/elf.h
13373 @@ -243,7 +243,25 @@ extern int force_personality32;
13374 the loader. We need to make sure that it is out of the way of the program
13375 that it will "exec", and that there is sufficient room for the brk. */
13376
13377 +#ifdef CONFIG_PAX_SEGMEXEC
13378 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13379 +#else
13380 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13381 +#endif
13382 +
13383 +#ifdef CONFIG_PAX_ASLR
13384 +#ifdef CONFIG_X86_32
13385 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13386 +
13387 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13388 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13389 +#else
13390 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13391 +
13392 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13393 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13394 +#endif
13395 +#endif
13396
13397 /* This yields a mask that user programs can use to figure out what
13398 instruction set this CPU supports. This could be done in user space,
13399 @@ -296,16 +314,12 @@ do { \
13400
13401 #define ARCH_DLINFO \
13402 do { \
13403 - if (vdso_enabled) \
13404 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13405 - (unsigned long)current->mm->context.vdso); \
13406 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13407 } while (0)
13408
13409 #define ARCH_DLINFO_X32 \
13410 do { \
13411 - if (vdso_enabled) \
13412 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13413 - (unsigned long)current->mm->context.vdso); \
13414 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13415 } while (0)
13416
13417 #define AT_SYSINFO 32
13418 @@ -320,7 +334,7 @@ else \
13419
13420 #endif /* !CONFIG_X86_32 */
13421
13422 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13423 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13424
13425 #define VDSO_ENTRY \
13426 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13427 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13428 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13429 #define compat_arch_setup_additional_pages syscall32_setup_pages
13430
13431 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13432 -#define arch_randomize_brk arch_randomize_brk
13433 -
13434 /*
13435 * True on X86_32 or when emulating IA32 on X86_64
13436 */
13437 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13438 index 75ce3f4..882e801 100644
13439 --- a/arch/x86/include/asm/emergency-restart.h
13440 +++ b/arch/x86/include/asm/emergency-restart.h
13441 @@ -13,6 +13,6 @@ enum reboot_type {
13442
13443 extern enum reboot_type reboot_type;
13444
13445 -extern void machine_emergency_restart(void);
13446 +extern void machine_emergency_restart(void) __noreturn;
13447
13448 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13449 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13450 index e25cc33..425d099 100644
13451 --- a/arch/x86/include/asm/fpu-internal.h
13452 +++ b/arch/x86/include/asm/fpu-internal.h
13453 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13454 ({ \
13455 int err; \
13456 asm volatile(ASM_STAC "\n" \
13457 - "1:" #insn "\n\t" \
13458 + "1:" \
13459 + __copyuser_seg \
13460 + #insn "\n\t" \
13461 "2: " ASM_CLAC "\n" \
13462 ".section .fixup,\"ax\"\n" \
13463 "3: movl $-1,%[err]\n" \
13464 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13465 "emms\n\t" /* clear stack tags */
13466 "fildl %P[addr]", /* set F?P to defined value */
13467 X86_FEATURE_FXSAVE_LEAK,
13468 - [addr] "m" (tsk->thread.fpu.has_fpu));
13469 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13470
13471 return fpu_restore_checking(&tsk->thread.fpu);
13472 }
13473 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13474 index be27ba1..8f13ff9 100644
13475 --- a/arch/x86/include/asm/futex.h
13476 +++ b/arch/x86/include/asm/futex.h
13477 @@ -12,6 +12,7 @@
13478 #include <asm/smap.h>
13479
13480 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13481 + typecheck(u32 __user *, uaddr); \
13482 asm volatile("\t" ASM_STAC "\n" \
13483 "1:\t" insn "\n" \
13484 "2:\t" ASM_CLAC "\n" \
13485 @@ -20,15 +21,16 @@
13486 "\tjmp\t2b\n" \
13487 "\t.previous\n" \
13488 _ASM_EXTABLE(1b, 3b) \
13489 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13490 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13491 : "i" (-EFAULT), "0" (oparg), "1" (0))
13492
13493 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13494 + typecheck(u32 __user *, uaddr); \
13495 asm volatile("\t" ASM_STAC "\n" \
13496 "1:\tmovl %2, %0\n" \
13497 "\tmovl\t%0, %3\n" \
13498 "\t" insn "\n" \
13499 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13500 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13501 "\tjnz\t1b\n" \
13502 "3:\t" ASM_CLAC "\n" \
13503 "\t.section .fixup,\"ax\"\n" \
13504 @@ -38,7 +40,7 @@
13505 _ASM_EXTABLE(1b, 4b) \
13506 _ASM_EXTABLE(2b, 4b) \
13507 : "=&a" (oldval), "=&r" (ret), \
13508 - "+m" (*uaddr), "=&r" (tem) \
13509 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13510 : "r" (oparg), "i" (-EFAULT), "1" (0))
13511
13512 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13513 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13514
13515 switch (op) {
13516 case FUTEX_OP_SET:
13517 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13518 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13519 break;
13520 case FUTEX_OP_ADD:
13521 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13522 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13523 uaddr, oparg);
13524 break;
13525 case FUTEX_OP_OR:
13526 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13527 return -EFAULT;
13528
13529 asm volatile("\t" ASM_STAC "\n"
13530 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13531 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13532 "2:\t" ASM_CLAC "\n"
13533 "\t.section .fixup, \"ax\"\n"
13534 "3:\tmov %3, %0\n"
13535 "\tjmp 2b\n"
13536 "\t.previous\n"
13537 _ASM_EXTABLE(1b, 3b)
13538 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13539 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13540 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13541 : "memory"
13542 );
13543 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13544 index 1da97ef..9c2ebff 100644
13545 --- a/arch/x86/include/asm/hw_irq.h
13546 +++ b/arch/x86/include/asm/hw_irq.h
13547 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
13548 extern void enable_IO_APIC(void);
13549
13550 /* Statistics */
13551 -extern atomic_t irq_err_count;
13552 -extern atomic_t irq_mis_count;
13553 +extern atomic_unchecked_t irq_err_count;
13554 +extern atomic_unchecked_t irq_mis_count;
13555
13556 /* EISA */
13557 extern void eisa_set_level_irq(unsigned int irq);
13558 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13559 index a203659..9889f1c 100644
13560 --- a/arch/x86/include/asm/i8259.h
13561 +++ b/arch/x86/include/asm/i8259.h
13562 @@ -62,7 +62,7 @@ struct legacy_pic {
13563 void (*init)(int auto_eoi);
13564 int (*irq_pending)(unsigned int irq);
13565 void (*make_irq)(unsigned int irq);
13566 -};
13567 +} __do_const;
13568
13569 extern struct legacy_pic *legacy_pic;
13570 extern struct legacy_pic null_legacy_pic;
13571 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13572 index d8e8eef..1765f78 100644
13573 --- a/arch/x86/include/asm/io.h
13574 +++ b/arch/x86/include/asm/io.h
13575 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13576 "m" (*(volatile type __force *)addr) barrier); }
13577
13578 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13579 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13580 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13581 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13582 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13583
13584 build_mmio_read(__readb, "b", unsigned char, "=q", )
13585 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13586 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13587 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13588 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13589
13590 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13591 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13592 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13593 return ioremap_nocache(offset, size);
13594 }
13595
13596 -extern void iounmap(volatile void __iomem *addr);
13597 +extern void iounmap(const volatile void __iomem *addr);
13598
13599 extern void set_iounmap_nonlazy(void);
13600
13601 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13602
13603 #include <linux/vmalloc.h>
13604
13605 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13606 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13607 +{
13608 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13609 +}
13610 +
13611 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13612 +{
13613 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13614 +}
13615 +
13616 /*
13617 * Convert a virtual cached pointer to an uncached pointer
13618 */
13619 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13620 index bba3cf8..06bc8da 100644
13621 --- a/arch/x86/include/asm/irqflags.h
13622 +++ b/arch/x86/include/asm/irqflags.h
13623 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13624 sti; \
13625 sysexit
13626
13627 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13628 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13629 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13630 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13631 +
13632 #else
13633 #define INTERRUPT_RETURN iret
13634 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13635 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13636 index 5a6d287..f815789 100644
13637 --- a/arch/x86/include/asm/kprobes.h
13638 +++ b/arch/x86/include/asm/kprobes.h
13639 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13640 #define RELATIVEJUMP_SIZE 5
13641 #define RELATIVECALL_OPCODE 0xe8
13642 #define RELATIVE_ADDR_SIZE 4
13643 -#define MAX_STACK_SIZE 64
13644 -#define MIN_STACK_SIZE(ADDR) \
13645 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13646 - THREAD_SIZE - (unsigned long)(ADDR))) \
13647 - ? (MAX_STACK_SIZE) \
13648 - : (((unsigned long)current_thread_info()) + \
13649 - THREAD_SIZE - (unsigned long)(ADDR)))
13650 +#define MAX_STACK_SIZE 64UL
13651 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13652
13653 #define flush_insn_slot(p) do { } while (0)
13654
13655 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13656 index 2d89e39..baee879 100644
13657 --- a/arch/x86/include/asm/local.h
13658 +++ b/arch/x86/include/asm/local.h
13659 @@ -10,33 +10,97 @@ typedef struct {
13660 atomic_long_t a;
13661 } local_t;
13662
13663 +typedef struct {
13664 + atomic_long_unchecked_t a;
13665 +} local_unchecked_t;
13666 +
13667 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13668
13669 #define local_read(l) atomic_long_read(&(l)->a)
13670 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13671 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13672 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13673
13674 static inline void local_inc(local_t *l)
13675 {
13676 - asm volatile(_ASM_INC "%0"
13677 + asm volatile(_ASM_INC "%0\n"
13678 +
13679 +#ifdef CONFIG_PAX_REFCOUNT
13680 + "jno 0f\n"
13681 + _ASM_DEC "%0\n"
13682 + "int $4\n0:\n"
13683 + _ASM_EXTABLE(0b, 0b)
13684 +#endif
13685 +
13686 + : "+m" (l->a.counter));
13687 +}
13688 +
13689 +static inline void local_inc_unchecked(local_unchecked_t *l)
13690 +{
13691 + asm volatile(_ASM_INC "%0\n"
13692 : "+m" (l->a.counter));
13693 }
13694
13695 static inline void local_dec(local_t *l)
13696 {
13697 - asm volatile(_ASM_DEC "%0"
13698 + asm volatile(_ASM_DEC "%0\n"
13699 +
13700 +#ifdef CONFIG_PAX_REFCOUNT
13701 + "jno 0f\n"
13702 + _ASM_INC "%0\n"
13703 + "int $4\n0:\n"
13704 + _ASM_EXTABLE(0b, 0b)
13705 +#endif
13706 +
13707 + : "+m" (l->a.counter));
13708 +}
13709 +
13710 +static inline void local_dec_unchecked(local_unchecked_t *l)
13711 +{
13712 + asm volatile(_ASM_DEC "%0\n"
13713 : "+m" (l->a.counter));
13714 }
13715
13716 static inline void local_add(long i, local_t *l)
13717 {
13718 - asm volatile(_ASM_ADD "%1,%0"
13719 + asm volatile(_ASM_ADD "%1,%0\n"
13720 +
13721 +#ifdef CONFIG_PAX_REFCOUNT
13722 + "jno 0f\n"
13723 + _ASM_SUB "%1,%0\n"
13724 + "int $4\n0:\n"
13725 + _ASM_EXTABLE(0b, 0b)
13726 +#endif
13727 +
13728 + : "+m" (l->a.counter)
13729 + : "ir" (i));
13730 +}
13731 +
13732 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13733 +{
13734 + asm volatile(_ASM_ADD "%1,%0\n"
13735 : "+m" (l->a.counter)
13736 : "ir" (i));
13737 }
13738
13739 static inline void local_sub(long i, local_t *l)
13740 {
13741 - asm volatile(_ASM_SUB "%1,%0"
13742 + asm volatile(_ASM_SUB "%1,%0\n"
13743 +
13744 +#ifdef CONFIG_PAX_REFCOUNT
13745 + "jno 0f\n"
13746 + _ASM_ADD "%1,%0\n"
13747 + "int $4\n0:\n"
13748 + _ASM_EXTABLE(0b, 0b)
13749 +#endif
13750 +
13751 + : "+m" (l->a.counter)
13752 + : "ir" (i));
13753 +}
13754 +
13755 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13756 +{
13757 + asm volatile(_ASM_SUB "%1,%0\n"
13758 : "+m" (l->a.counter)
13759 : "ir" (i));
13760 }
13761 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13762 {
13763 unsigned char c;
13764
13765 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13766 + asm volatile(_ASM_SUB "%2,%0\n"
13767 +
13768 +#ifdef CONFIG_PAX_REFCOUNT
13769 + "jno 0f\n"
13770 + _ASM_ADD "%2,%0\n"
13771 + "int $4\n0:\n"
13772 + _ASM_EXTABLE(0b, 0b)
13773 +#endif
13774 +
13775 + "sete %1\n"
13776 : "+m" (l->a.counter), "=qm" (c)
13777 : "ir" (i) : "memory");
13778 return c;
13779 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13780 {
13781 unsigned char c;
13782
13783 - asm volatile(_ASM_DEC "%0; sete %1"
13784 + asm volatile(_ASM_DEC "%0\n"
13785 +
13786 +#ifdef CONFIG_PAX_REFCOUNT
13787 + "jno 0f\n"
13788 + _ASM_INC "%0\n"
13789 + "int $4\n0:\n"
13790 + _ASM_EXTABLE(0b, 0b)
13791 +#endif
13792 +
13793 + "sete %1\n"
13794 : "+m" (l->a.counter), "=qm" (c)
13795 : : "memory");
13796 return c != 0;
13797 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13798 {
13799 unsigned char c;
13800
13801 - asm volatile(_ASM_INC "%0; sete %1"
13802 + asm volatile(_ASM_INC "%0\n"
13803 +
13804 +#ifdef CONFIG_PAX_REFCOUNT
13805 + "jno 0f\n"
13806 + _ASM_DEC "%0\n"
13807 + "int $4\n0:\n"
13808 + _ASM_EXTABLE(0b, 0b)
13809 +#endif
13810 +
13811 + "sete %1\n"
13812 : "+m" (l->a.counter), "=qm" (c)
13813 : : "memory");
13814 return c != 0;
13815 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13816 {
13817 unsigned char c;
13818
13819 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13820 + asm volatile(_ASM_ADD "%2,%0\n"
13821 +
13822 +#ifdef CONFIG_PAX_REFCOUNT
13823 + "jno 0f\n"
13824 + _ASM_SUB "%2,%0\n"
13825 + "int $4\n0:\n"
13826 + _ASM_EXTABLE(0b, 0b)
13827 +#endif
13828 +
13829 + "sets %1\n"
13830 : "+m" (l->a.counter), "=qm" (c)
13831 : "ir" (i) : "memory");
13832 return c;
13833 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13834 static inline long local_add_return(long i, local_t *l)
13835 {
13836 long __i = i;
13837 + asm volatile(_ASM_XADD "%0, %1\n"
13838 +
13839 +#ifdef CONFIG_PAX_REFCOUNT
13840 + "jno 0f\n"
13841 + _ASM_MOV "%0,%1\n"
13842 + "int $4\n0:\n"
13843 + _ASM_EXTABLE(0b, 0b)
13844 +#endif
13845 +
13846 + : "+r" (i), "+m" (l->a.counter)
13847 + : : "memory");
13848 + return i + __i;
13849 +}
13850 +
13851 +/**
13852 + * local_add_return_unchecked - add and return
13853 + * @i: integer value to add
13854 + * @l: pointer to type local_unchecked_t
13855 + *
13856 + * Atomically adds @i to @l and returns @i + @l
13857 + */
13858 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13859 +{
13860 + long __i = i;
13861 asm volatile(_ASM_XADD "%0, %1;"
13862 : "+r" (i), "+m" (l->a.counter)
13863 : : "memory");
13864 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13865
13866 #define local_cmpxchg(l, o, n) \
13867 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13868 +#define local_cmpxchg_unchecked(l, o, n) \
13869 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13870 /* Always has a lock prefix */
13871 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13872
13873 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13874 new file mode 100644
13875 index 0000000..2bfd3ba
13876 --- /dev/null
13877 +++ b/arch/x86/include/asm/mman.h
13878 @@ -0,0 +1,15 @@
13879 +#ifndef _X86_MMAN_H
13880 +#define _X86_MMAN_H
13881 +
13882 +#include <uapi/asm/mman.h>
13883 +
13884 +#ifdef __KERNEL__
13885 +#ifndef __ASSEMBLY__
13886 +#ifdef CONFIG_X86_32
13887 +#define arch_mmap_check i386_mmap_check
13888 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13889 +#endif
13890 +#endif
13891 +#endif
13892 +
13893 +#endif /* X86_MMAN_H */
13894 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13895 index 5f55e69..e20bfb1 100644
13896 --- a/arch/x86/include/asm/mmu.h
13897 +++ b/arch/x86/include/asm/mmu.h
13898 @@ -9,7 +9,7 @@
13899 * we put the segment information here.
13900 */
13901 typedef struct {
13902 - void *ldt;
13903 + struct desc_struct *ldt;
13904 int size;
13905
13906 #ifdef CONFIG_X86_64
13907 @@ -18,7 +18,19 @@ typedef struct {
13908 #endif
13909
13910 struct mutex lock;
13911 - void *vdso;
13912 + unsigned long vdso;
13913 +
13914 +#ifdef CONFIG_X86_32
13915 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13916 + unsigned long user_cs_base;
13917 + unsigned long user_cs_limit;
13918 +
13919 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13920 + cpumask_t cpu_user_cs_mask;
13921 +#endif
13922 +
13923 +#endif
13924 +#endif
13925 } mm_context_t;
13926
13927 #ifdef CONFIG_SMP
13928 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13929 index cdbf367..adb37ac 100644
13930 --- a/arch/x86/include/asm/mmu_context.h
13931 +++ b/arch/x86/include/asm/mmu_context.h
13932 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13933
13934 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13935 {
13936 +
13937 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13938 + unsigned int i;
13939 + pgd_t *pgd;
13940 +
13941 + pax_open_kernel();
13942 + pgd = get_cpu_pgd(smp_processor_id());
13943 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13944 + set_pgd_batched(pgd+i, native_make_pgd(0));
13945 + pax_close_kernel();
13946 +#endif
13947 +
13948 #ifdef CONFIG_SMP
13949 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13950 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13951 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13952 struct task_struct *tsk)
13953 {
13954 unsigned cpu = smp_processor_id();
13955 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13956 + int tlbstate = TLBSTATE_OK;
13957 +#endif
13958
13959 if (likely(prev != next)) {
13960 #ifdef CONFIG_SMP
13961 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13962 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13963 +#endif
13964 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13965 this_cpu_write(cpu_tlbstate.active_mm, next);
13966 #endif
13967 cpumask_set_cpu(cpu, mm_cpumask(next));
13968
13969 /* Re-load page tables */
13970 +#ifdef CONFIG_PAX_PER_CPU_PGD
13971 + pax_open_kernel();
13972 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13973 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13974 + pax_close_kernel();
13975 + load_cr3(get_cpu_pgd(cpu));
13976 +#else
13977 load_cr3(next->pgd);
13978 +#endif
13979
13980 /* stop flush ipis for the previous mm */
13981 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13982 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13983 */
13984 if (unlikely(prev->context.ldt != next->context.ldt))
13985 load_LDT_nolock(&next->context);
13986 - }
13987 +
13988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13989 + if (!(__supported_pte_mask & _PAGE_NX)) {
13990 + smp_mb__before_clear_bit();
13991 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13992 + smp_mb__after_clear_bit();
13993 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13994 + }
13995 +#endif
13996 +
13997 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13998 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13999 + prev->context.user_cs_limit != next->context.user_cs_limit))
14000 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14001 #ifdef CONFIG_SMP
14002 + else if (unlikely(tlbstate != TLBSTATE_OK))
14003 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14004 +#endif
14005 +#endif
14006 +
14007 + }
14008 else {
14009 +
14010 +#ifdef CONFIG_PAX_PER_CPU_PGD
14011 + pax_open_kernel();
14012 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14013 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14014 + pax_close_kernel();
14015 + load_cr3(get_cpu_pgd(cpu));
14016 +#endif
14017 +
14018 +#ifdef CONFIG_SMP
14019 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14020 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14021
14022 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14023 * tlb flush IPI delivery. We must reload CR3
14024 * to make sure to use no freed page tables.
14025 */
14026 +
14027 +#ifndef CONFIG_PAX_PER_CPU_PGD
14028 load_cr3(next->pgd);
14029 +#endif
14030 +
14031 load_LDT_nolock(&next->context);
14032 +
14033 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14034 + if (!(__supported_pte_mask & _PAGE_NX))
14035 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14036 +#endif
14037 +
14038 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14039 +#ifdef CONFIG_PAX_PAGEEXEC
14040 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14041 +#endif
14042 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14043 +#endif
14044 +
14045 }
14046 +#endif
14047 }
14048 -#endif
14049 }
14050
14051 #define activate_mm(prev, next) \
14052 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14053 index e3b7819..b257c64 100644
14054 --- a/arch/x86/include/asm/module.h
14055 +++ b/arch/x86/include/asm/module.h
14056 @@ -5,6 +5,7 @@
14057
14058 #ifdef CONFIG_X86_64
14059 /* X86_64 does not define MODULE_PROC_FAMILY */
14060 +#define MODULE_PROC_FAMILY ""
14061 #elif defined CONFIG_M486
14062 #define MODULE_PROC_FAMILY "486 "
14063 #elif defined CONFIG_M586
14064 @@ -57,8 +58,20 @@
14065 #error unknown processor family
14066 #endif
14067
14068 -#ifdef CONFIG_X86_32
14069 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14070 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14071 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14072 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14073 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14074 +#else
14075 +#define MODULE_PAX_KERNEXEC ""
14076 #endif
14077
14078 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14079 +#define MODULE_PAX_UDEREF "UDEREF "
14080 +#else
14081 +#define MODULE_PAX_UDEREF ""
14082 +#endif
14083 +
14084 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14085 +
14086 #endif /* _ASM_X86_MODULE_H */
14087 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14088 index 86f9301..b365cda 100644
14089 --- a/arch/x86/include/asm/nmi.h
14090 +++ b/arch/x86/include/asm/nmi.h
14091 @@ -40,11 +40,11 @@ struct nmiaction {
14092 nmi_handler_t handler;
14093 unsigned long flags;
14094 const char *name;
14095 -};
14096 +} __do_const;
14097
14098 #define register_nmi_handler(t, fn, fg, n, init...) \
14099 ({ \
14100 - static struct nmiaction init fn##_na = { \
14101 + static const struct nmiaction init fn##_na = { \
14102 .handler = (fn), \
14103 .name = (n), \
14104 .flags = (fg), \
14105 @@ -52,7 +52,7 @@ struct nmiaction {
14106 __register_nmi_handler((t), &fn##_na); \
14107 })
14108
14109 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14110 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14111
14112 void unregister_nmi_handler(unsigned int, const char *);
14113
14114 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
14115 index c878924..21f4889 100644
14116 --- a/arch/x86/include/asm/page.h
14117 +++ b/arch/x86/include/asm/page.h
14118 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
14119 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
14120
14121 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
14122 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
14123
14124 #define __boot_va(x) __va(x)
14125 #define __boot_pa(x) __pa(x)
14126 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14127 index 0f1ddee..e2fc3d1 100644
14128 --- a/arch/x86/include/asm/page_64.h
14129 +++ b/arch/x86/include/asm/page_64.h
14130 @@ -7,9 +7,9 @@
14131
14132 /* duplicated to the one in bootmem.h */
14133 extern unsigned long max_pfn;
14134 -extern unsigned long phys_base;
14135 +extern const unsigned long phys_base;
14136
14137 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14138 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14139 {
14140 unsigned long y = x - __START_KERNEL_map;
14141
14142 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14143 index cfdc9ee..3f7b5d6 100644
14144 --- a/arch/x86/include/asm/paravirt.h
14145 +++ b/arch/x86/include/asm/paravirt.h
14146 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
14147 return (pmd_t) { ret };
14148 }
14149
14150 -static inline pmdval_t pmd_val(pmd_t pmd)
14151 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14152 {
14153 pmdval_t ret;
14154
14155 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14156 val);
14157 }
14158
14159 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14160 +{
14161 + pgdval_t val = native_pgd_val(pgd);
14162 +
14163 + if (sizeof(pgdval_t) > sizeof(long))
14164 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14165 + val, (u64)val >> 32);
14166 + else
14167 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14168 + val);
14169 +}
14170 +
14171 static inline void pgd_clear(pgd_t *pgdp)
14172 {
14173 set_pgd(pgdp, __pgd(0));
14174 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14175 pv_mmu_ops.set_fixmap(idx, phys, flags);
14176 }
14177
14178 +#ifdef CONFIG_PAX_KERNEXEC
14179 +static inline unsigned long pax_open_kernel(void)
14180 +{
14181 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14182 +}
14183 +
14184 +static inline unsigned long pax_close_kernel(void)
14185 +{
14186 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14187 +}
14188 +#else
14189 +static inline unsigned long pax_open_kernel(void) { return 0; }
14190 +static inline unsigned long pax_close_kernel(void) { return 0; }
14191 +#endif
14192 +
14193 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14194
14195 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14196 @@ -926,7 +953,7 @@ extern void default_banner(void);
14197
14198 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14199 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14200 -#define PARA_INDIRECT(addr) *%cs:addr
14201 +#define PARA_INDIRECT(addr) *%ss:addr
14202 #endif
14203
14204 #define INTERRUPT_RETURN \
14205 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
14206 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14207 CLBR_NONE, \
14208 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14209 +
14210 +#define GET_CR0_INTO_RDI \
14211 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14212 + mov %rax,%rdi
14213 +
14214 +#define SET_RDI_INTO_CR0 \
14215 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14216 +
14217 +#define GET_CR3_INTO_RDI \
14218 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14219 + mov %rax,%rdi
14220 +
14221 +#define SET_RDI_INTO_CR3 \
14222 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14223 +
14224 #endif /* CONFIG_X86_32 */
14225
14226 #endif /* __ASSEMBLY__ */
14227 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14228 index 0db1fca..52310cc 100644
14229 --- a/arch/x86/include/asm/paravirt_types.h
14230 +++ b/arch/x86/include/asm/paravirt_types.h
14231 @@ -84,7 +84,7 @@ struct pv_init_ops {
14232 */
14233 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14234 unsigned long addr, unsigned len);
14235 -};
14236 +} __no_const;
14237
14238
14239 struct pv_lazy_ops {
14240 @@ -98,7 +98,7 @@ struct pv_time_ops {
14241 unsigned long long (*sched_clock)(void);
14242 unsigned long long (*steal_clock)(int cpu);
14243 unsigned long (*get_tsc_khz)(void);
14244 -};
14245 +} __no_const;
14246
14247 struct pv_cpu_ops {
14248 /* hooks for various privileged instructions */
14249 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14250
14251 void (*start_context_switch)(struct task_struct *prev);
14252 void (*end_context_switch)(struct task_struct *next);
14253 -};
14254 +} __no_const;
14255
14256 struct pv_irq_ops {
14257 /*
14258 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14259 unsigned long start_eip,
14260 unsigned long start_esp);
14261 #endif
14262 -};
14263 +} __no_const;
14264
14265 struct pv_mmu_ops {
14266 unsigned long (*read_cr2)(void);
14267 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14268 struct paravirt_callee_save make_pud;
14269
14270 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14271 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14272 #endif /* PAGETABLE_LEVELS == 4 */
14273 #endif /* PAGETABLE_LEVELS >= 3 */
14274
14275 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14276 an mfn. We can tell which is which from the index. */
14277 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14278 phys_addr_t phys, pgprot_t flags);
14279 +
14280 +#ifdef CONFIG_PAX_KERNEXEC
14281 + unsigned long (*pax_open_kernel)(void);
14282 + unsigned long (*pax_close_kernel)(void);
14283 +#endif
14284 +
14285 };
14286
14287 struct arch_spinlock;
14288 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14289 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14290 int (*spin_trylock)(struct arch_spinlock *lock);
14291 void (*spin_unlock)(struct arch_spinlock *lock);
14292 -};
14293 +} __no_const;
14294
14295 /* This contains all the paravirt structures: we get a convenient
14296 * number for each function using the offset which we use to indicate
14297 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14298 index b4389a4..7024269 100644
14299 --- a/arch/x86/include/asm/pgalloc.h
14300 +++ b/arch/x86/include/asm/pgalloc.h
14301 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14302 pmd_t *pmd, pte_t *pte)
14303 {
14304 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14305 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14306 +}
14307 +
14308 +static inline void pmd_populate_user(struct mm_struct *mm,
14309 + pmd_t *pmd, pte_t *pte)
14310 +{
14311 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14312 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14313 }
14314
14315 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14316
14317 #ifdef CONFIG_X86_PAE
14318 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14319 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14320 +{
14321 + pud_populate(mm, pudp, pmd);
14322 +}
14323 #else /* !CONFIG_X86_PAE */
14324 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14325 {
14326 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14327 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14328 }
14329 +
14330 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14331 +{
14332 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14333 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14334 +}
14335 #endif /* CONFIG_X86_PAE */
14336
14337 #if PAGETABLE_LEVELS > 3
14338 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14339 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14340 }
14341
14342 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14343 +{
14344 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14345 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14346 +}
14347 +
14348 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14349 {
14350 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14351 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14352 index f2b489c..4f7e2e5 100644
14353 --- a/arch/x86/include/asm/pgtable-2level.h
14354 +++ b/arch/x86/include/asm/pgtable-2level.h
14355 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14356
14357 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14358 {
14359 + pax_open_kernel();
14360 *pmdp = pmd;
14361 + pax_close_kernel();
14362 }
14363
14364 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14365 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14366 index 4cc9f2b..5fd9226 100644
14367 --- a/arch/x86/include/asm/pgtable-3level.h
14368 +++ b/arch/x86/include/asm/pgtable-3level.h
14369 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14370
14371 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14372 {
14373 + pax_open_kernel();
14374 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14375 + pax_close_kernel();
14376 }
14377
14378 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14379 {
14380 + pax_open_kernel();
14381 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14382 + pax_close_kernel();
14383 }
14384
14385 /*
14386 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14387 index 1e67223..dd6e7ea 100644
14388 --- a/arch/x86/include/asm/pgtable.h
14389 +++ b/arch/x86/include/asm/pgtable.h
14390 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14391
14392 #ifndef __PAGETABLE_PUD_FOLDED
14393 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14394 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14395 #define pgd_clear(pgd) native_pgd_clear(pgd)
14396 #endif
14397
14398 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14399
14400 #define arch_end_context_switch(prev) do {} while(0)
14401
14402 +#define pax_open_kernel() native_pax_open_kernel()
14403 +#define pax_close_kernel() native_pax_close_kernel()
14404 #endif /* CONFIG_PARAVIRT */
14405
14406 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14407 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14408 +
14409 +#ifdef CONFIG_PAX_KERNEXEC
14410 +static inline unsigned long native_pax_open_kernel(void)
14411 +{
14412 + unsigned long cr0;
14413 +
14414 + preempt_disable();
14415 + barrier();
14416 + cr0 = read_cr0() ^ X86_CR0_WP;
14417 + BUG_ON(cr0 & X86_CR0_WP);
14418 + write_cr0(cr0);
14419 + return cr0 ^ X86_CR0_WP;
14420 +}
14421 +
14422 +static inline unsigned long native_pax_close_kernel(void)
14423 +{
14424 + unsigned long cr0;
14425 +
14426 + cr0 = read_cr0() ^ X86_CR0_WP;
14427 + BUG_ON(!(cr0 & X86_CR0_WP));
14428 + write_cr0(cr0);
14429 + barrier();
14430 + preempt_enable_no_resched();
14431 + return cr0 ^ X86_CR0_WP;
14432 +}
14433 +#else
14434 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14435 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14436 +#endif
14437 +
14438 /*
14439 * The following only work if pte_present() is true.
14440 * Undefined behaviour if not..
14441 */
14442 +static inline int pte_user(pte_t pte)
14443 +{
14444 + return pte_val(pte) & _PAGE_USER;
14445 +}
14446 +
14447 static inline int pte_dirty(pte_t pte)
14448 {
14449 return pte_flags(pte) & _PAGE_DIRTY;
14450 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14451 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14452 }
14453
14454 +static inline unsigned long pgd_pfn(pgd_t pgd)
14455 +{
14456 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14457 +}
14458 +
14459 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14460
14461 static inline int pmd_large(pmd_t pte)
14462 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14463 return pte_clear_flags(pte, _PAGE_RW);
14464 }
14465
14466 +static inline pte_t pte_mkread(pte_t pte)
14467 +{
14468 + return __pte(pte_val(pte) | _PAGE_USER);
14469 +}
14470 +
14471 static inline pte_t pte_mkexec(pte_t pte)
14472 {
14473 - return pte_clear_flags(pte, _PAGE_NX);
14474 +#ifdef CONFIG_X86_PAE
14475 + if (__supported_pte_mask & _PAGE_NX)
14476 + return pte_clear_flags(pte, _PAGE_NX);
14477 + else
14478 +#endif
14479 + return pte_set_flags(pte, _PAGE_USER);
14480 +}
14481 +
14482 +static inline pte_t pte_exprotect(pte_t pte)
14483 +{
14484 +#ifdef CONFIG_X86_PAE
14485 + if (__supported_pte_mask & _PAGE_NX)
14486 + return pte_set_flags(pte, _PAGE_NX);
14487 + else
14488 +#endif
14489 + return pte_clear_flags(pte, _PAGE_USER);
14490 }
14491
14492 static inline pte_t pte_mkdirty(pte_t pte)
14493 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14494 #endif
14495
14496 #ifndef __ASSEMBLY__
14497 +
14498 +#ifdef CONFIG_PAX_PER_CPU_PGD
14499 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14500 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14501 +{
14502 + return cpu_pgd[cpu];
14503 +}
14504 +#endif
14505 +
14506 #include <linux/mm_types.h>
14507 #include <linux/log2.h>
14508
14509 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14510 * Currently stuck as a macro due to indirect forward reference to
14511 * linux/mmzone.h's __section_mem_map_addr() definition:
14512 */
14513 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14514 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14515
14516 /* Find an entry in the second-level page table.. */
14517 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14518 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14519 * Currently stuck as a macro due to indirect forward reference to
14520 * linux/mmzone.h's __section_mem_map_addr() definition:
14521 */
14522 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14523 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14524
14525 /* to find an entry in a page-table-directory. */
14526 static inline unsigned long pud_index(unsigned long address)
14527 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14528
14529 static inline int pgd_bad(pgd_t pgd)
14530 {
14531 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14532 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14533 }
14534
14535 static inline int pgd_none(pgd_t pgd)
14536 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14537 * pgd_offset() returns a (pgd_t *)
14538 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14539 */
14540 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14541 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14542 +
14543 +#ifdef CONFIG_PAX_PER_CPU_PGD
14544 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14545 +#endif
14546 +
14547 /*
14548 * a shortcut which implies the use of the kernel's pgd, instead
14549 * of a process's
14550 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14551 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14552 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14553
14554 +#ifdef CONFIG_X86_32
14555 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14556 +#else
14557 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14558 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14559 +
14560 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14561 +#ifdef __ASSEMBLY__
14562 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14563 +#else
14564 +extern unsigned long pax_user_shadow_base;
14565 +#endif
14566 +#endif
14567 +
14568 +#endif
14569 +
14570 #ifndef __ASSEMBLY__
14571
14572 extern int direct_gbpages;
14573 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14574 * dst and src can be on the same page, but the range must not overlap,
14575 * and must not cross a page boundary.
14576 */
14577 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14578 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14579 {
14580 - memcpy(dst, src, count * sizeof(pgd_t));
14581 + pax_open_kernel();
14582 + while (count--)
14583 + *dst++ = *src++;
14584 + pax_close_kernel();
14585 }
14586
14587 +#ifdef CONFIG_PAX_PER_CPU_PGD
14588 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14589 +#endif
14590 +
14591 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14592 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14593 +#else
14594 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14595 +#endif
14596 +
14597 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14598 static inline int page_level_shift(enum pg_level level)
14599 {
14600 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14601 index 9ee3221..b979c6b 100644
14602 --- a/arch/x86/include/asm/pgtable_32.h
14603 +++ b/arch/x86/include/asm/pgtable_32.h
14604 @@ -25,9 +25,6 @@
14605 struct mm_struct;
14606 struct vm_area_struct;
14607
14608 -extern pgd_t swapper_pg_dir[1024];
14609 -extern pgd_t initial_page_table[1024];
14610 -
14611 static inline void pgtable_cache_init(void) { }
14612 static inline void check_pgt_cache(void) { }
14613 void paging_init(void);
14614 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14615 # include <asm/pgtable-2level.h>
14616 #endif
14617
14618 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14619 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14620 +#ifdef CONFIG_X86_PAE
14621 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14622 +#endif
14623 +
14624 #if defined(CONFIG_HIGHPTE)
14625 #define pte_offset_map(dir, address) \
14626 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14627 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14628 /* Clear a kernel PTE and flush it from the TLB */
14629 #define kpte_clear_flush(ptep, vaddr) \
14630 do { \
14631 + pax_open_kernel(); \
14632 pte_clear(&init_mm, (vaddr), (ptep)); \
14633 + pax_close_kernel(); \
14634 __flush_tlb_one((vaddr)); \
14635 } while (0)
14636
14637 #endif /* !__ASSEMBLY__ */
14638
14639 +#define HAVE_ARCH_UNMAPPED_AREA
14640 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14641 +
14642 /*
14643 * kern_addr_valid() is (1) for FLATMEM and (0) for
14644 * SPARSEMEM and DISCONTIGMEM
14645 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14646 index ed5903b..c7fe163 100644
14647 --- a/arch/x86/include/asm/pgtable_32_types.h
14648 +++ b/arch/x86/include/asm/pgtable_32_types.h
14649 @@ -8,7 +8,7 @@
14650 */
14651 #ifdef CONFIG_X86_PAE
14652 # include <asm/pgtable-3level_types.h>
14653 -# define PMD_SIZE (1UL << PMD_SHIFT)
14654 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14655 # define PMD_MASK (~(PMD_SIZE - 1))
14656 #else
14657 # include <asm/pgtable-2level_types.h>
14658 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14659 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14660 #endif
14661
14662 +#ifdef CONFIG_PAX_KERNEXEC
14663 +#ifndef __ASSEMBLY__
14664 +extern unsigned char MODULES_EXEC_VADDR[];
14665 +extern unsigned char MODULES_EXEC_END[];
14666 +#endif
14667 +#include <asm/boot.h>
14668 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14669 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14670 +#else
14671 +#define ktla_ktva(addr) (addr)
14672 +#define ktva_ktla(addr) (addr)
14673 +#endif
14674 +
14675 #define MODULES_VADDR VMALLOC_START
14676 #define MODULES_END VMALLOC_END
14677 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14678 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14679 index e22c1db..23a625a 100644
14680 --- a/arch/x86/include/asm/pgtable_64.h
14681 +++ b/arch/x86/include/asm/pgtable_64.h
14682 @@ -16,10 +16,14 @@
14683
14684 extern pud_t level3_kernel_pgt[512];
14685 extern pud_t level3_ident_pgt[512];
14686 +extern pud_t level3_vmalloc_start_pgt[512];
14687 +extern pud_t level3_vmalloc_end_pgt[512];
14688 +extern pud_t level3_vmemmap_pgt[512];
14689 +extern pud_t level2_vmemmap_pgt[512];
14690 extern pmd_t level2_kernel_pgt[512];
14691 extern pmd_t level2_fixmap_pgt[512];
14692 -extern pmd_t level2_ident_pgt[512];
14693 -extern pgd_t init_level4_pgt[];
14694 +extern pmd_t level2_ident_pgt[512*2];
14695 +extern pgd_t init_level4_pgt[512];
14696
14697 #define swapper_pg_dir init_level4_pgt
14698
14699 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14700
14701 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14702 {
14703 + pax_open_kernel();
14704 *pmdp = pmd;
14705 + pax_close_kernel();
14706 }
14707
14708 static inline void native_pmd_clear(pmd_t *pmd)
14709 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14710
14711 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14712 {
14713 + pax_open_kernel();
14714 *pudp = pud;
14715 + pax_close_kernel();
14716 }
14717
14718 static inline void native_pud_clear(pud_t *pud)
14719 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14720
14721 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14722 {
14723 + pax_open_kernel();
14724 + *pgdp = pgd;
14725 + pax_close_kernel();
14726 +}
14727 +
14728 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14729 +{
14730 *pgdp = pgd;
14731 }
14732
14733 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14734 index 2d88344..4679fc3 100644
14735 --- a/arch/x86/include/asm/pgtable_64_types.h
14736 +++ b/arch/x86/include/asm/pgtable_64_types.h
14737 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14738 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14739 #define MODULES_END _AC(0xffffffffff000000, UL)
14740 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14741 +#define MODULES_EXEC_VADDR MODULES_VADDR
14742 +#define MODULES_EXEC_END MODULES_END
14743 +
14744 +#define ktla_ktva(addr) (addr)
14745 +#define ktva_ktla(addr) (addr)
14746
14747 #define EARLY_DYNAMIC_PAGE_TABLES 64
14748
14749 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14750 index e642300..0ef8f31 100644
14751 --- a/arch/x86/include/asm/pgtable_types.h
14752 +++ b/arch/x86/include/asm/pgtable_types.h
14753 @@ -16,13 +16,12 @@
14754 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14755 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14756 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14757 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14758 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14759 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14760 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14761 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14762 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14763 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14764 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14765 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14766 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14767 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14768
14769 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14770 @@ -40,7 +39,6 @@
14771 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14772 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14773 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14774 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14775 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14776 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14777 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14778 @@ -57,8 +55,10 @@
14779
14780 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14781 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14782 -#else
14783 +#elif defined(CONFIG_KMEMCHECK)
14784 #define _PAGE_NX (_AT(pteval_t, 0))
14785 +#else
14786 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14787 #endif
14788
14789 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14790 @@ -116,6 +116,9 @@
14791 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14792 _PAGE_ACCESSED)
14793
14794 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14795 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14796 +
14797 #define __PAGE_KERNEL_EXEC \
14798 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14799 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14800 @@ -126,7 +129,7 @@
14801 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14802 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14803 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14804 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14805 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14806 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14807 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14808 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14809 @@ -188,8 +191,8 @@
14810 * bits are combined, this will alow user to access the high address mapped
14811 * VDSO in the presence of CONFIG_COMPAT_VDSO
14812 */
14813 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14814 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14815 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14816 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14817 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14818 #endif
14819
14820 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14821 {
14822 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14823 }
14824 +#endif
14825
14826 +#if PAGETABLE_LEVELS == 3
14827 +#include <asm-generic/pgtable-nopud.h>
14828 +#endif
14829 +
14830 +#if PAGETABLE_LEVELS == 2
14831 +#include <asm-generic/pgtable-nopmd.h>
14832 +#endif
14833 +
14834 +#ifndef __ASSEMBLY__
14835 #if PAGETABLE_LEVELS > 3
14836 typedef struct { pudval_t pud; } pud_t;
14837
14838 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14839 return pud.pud;
14840 }
14841 #else
14842 -#include <asm-generic/pgtable-nopud.h>
14843 -
14844 static inline pudval_t native_pud_val(pud_t pud)
14845 {
14846 return native_pgd_val(pud.pgd);
14847 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14848 return pmd.pmd;
14849 }
14850 #else
14851 -#include <asm-generic/pgtable-nopmd.h>
14852 -
14853 static inline pmdval_t native_pmd_val(pmd_t pmd)
14854 {
14855 return native_pgd_val(pmd.pud.pgd);
14856 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14857
14858 extern pteval_t __supported_pte_mask;
14859 extern void set_nx(void);
14860 -extern int nx_enabled;
14861
14862 #define pgprot_writecombine pgprot_writecombine
14863 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14864 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14865 index 22224b3..30c80ca 100644
14866 --- a/arch/x86/include/asm/processor.h
14867 +++ b/arch/x86/include/asm/processor.h
14868 @@ -282,7 +282,7 @@ struct tss_struct {
14869
14870 } ____cacheline_aligned;
14871
14872 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14873 +extern struct tss_struct init_tss[NR_CPUS];
14874
14875 /*
14876 * Save the original ist values for checking stack pointers during debugging
14877 @@ -823,11 +823,18 @@ static inline void spin_lock_prefetch(const void *x)
14878 */
14879 #define TASK_SIZE PAGE_OFFSET
14880 #define TASK_SIZE_MAX TASK_SIZE
14881 +
14882 +#ifdef CONFIG_PAX_SEGMEXEC
14883 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14884 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14885 +#else
14886 #define STACK_TOP TASK_SIZE
14887 -#define STACK_TOP_MAX STACK_TOP
14888 +#endif
14889 +
14890 +#define STACK_TOP_MAX TASK_SIZE
14891
14892 #define INIT_THREAD { \
14893 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14894 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14895 .vm86_info = NULL, \
14896 .sysenter_cs = __KERNEL_CS, \
14897 .io_bitmap_ptr = NULL, \
14898 @@ -841,7 +848,7 @@ static inline void spin_lock_prefetch(const void *x)
14899 */
14900 #define INIT_TSS { \
14901 .x86_tss = { \
14902 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14903 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14904 .ss0 = __KERNEL_DS, \
14905 .ss1 = __KERNEL_CS, \
14906 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14907 @@ -852,11 +859,7 @@ static inline void spin_lock_prefetch(const void *x)
14908 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14909
14910 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14911 -#define KSTK_TOP(info) \
14912 -({ \
14913 - unsigned long *__ptr = (unsigned long *)(info); \
14914 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14915 -})
14916 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14917
14918 /*
14919 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14920 @@ -871,7 +874,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14921 #define task_pt_regs(task) \
14922 ({ \
14923 struct pt_regs *__regs__; \
14924 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14925 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14926 __regs__ - 1; \
14927 })
14928
14929 @@ -881,13 +884,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14930 /*
14931 * User space process size. 47bits minus one guard page.
14932 */
14933 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14934 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14935
14936 /* This decides where the kernel will search for a free chunk of vm
14937 * space during mmap's.
14938 */
14939 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14940 - 0xc0000000 : 0xFFFFe000)
14941 + 0xc0000000 : 0xFFFFf000)
14942
14943 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14944 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14945 @@ -898,11 +901,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14946 #define STACK_TOP_MAX TASK_SIZE_MAX
14947
14948 #define INIT_THREAD { \
14949 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14950 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14951 }
14952
14953 #define INIT_TSS { \
14954 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14955 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14956 }
14957
14958 /*
14959 @@ -930,6 +933,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14960 */
14961 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14962
14963 +#ifdef CONFIG_PAX_SEGMEXEC
14964 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14965 +#endif
14966 +
14967 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14968
14969 /* Get/set a process' ability to use the timestamp counter instruction */
14970 @@ -942,7 +949,8 @@ extern int set_tsc_mode(unsigned int val);
14971 extern u16 amd_get_nb_id(int cpu);
14972
14973 struct aperfmperf {
14974 - u64 aperf, mperf;
14975 + u64 aperf __intentional_overflow(0);
14976 + u64 mperf __intentional_overflow(0);
14977 };
14978
14979 static inline void get_aperfmperf(struct aperfmperf *am)
14980 @@ -970,7 +978,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
14981 return ratio;
14982 }
14983
14984 -extern unsigned long arch_align_stack(unsigned long sp);
14985 +#define arch_align_stack(x) ((x) & ~0xfUL)
14986 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14987
14988 void default_idle(void);
14989 @@ -980,6 +988,6 @@ bool xen_set_default_idle(void);
14990 #define xen_set_default_idle 0
14991 #endif
14992
14993 -void stop_this_cpu(void *dummy);
14994 +void stop_this_cpu(void *dummy) __noreturn;
14995
14996 #endif /* _ASM_X86_PROCESSOR_H */
14997 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14998 index 942a086..6c26446 100644
14999 --- a/arch/x86/include/asm/ptrace.h
15000 +++ b/arch/x86/include/asm/ptrace.h
15001 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15002 }
15003
15004 /*
15005 - * user_mode_vm(regs) determines whether a register set came from user mode.
15006 + * user_mode(regs) determines whether a register set came from user mode.
15007 * This is true if V8086 mode was enabled OR if the register set was from
15008 * protected mode with RPL-3 CS value. This tricky test checks that with
15009 * one comparison. Many places in the kernel can bypass this full check
15010 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15011 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15012 + * be used.
15013 */
15014 -static inline int user_mode(struct pt_regs *regs)
15015 +static inline int user_mode_novm(struct pt_regs *regs)
15016 {
15017 #ifdef CONFIG_X86_32
15018 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15019 #else
15020 - return !!(regs->cs & 3);
15021 + return !!(regs->cs & SEGMENT_RPL_MASK);
15022 #endif
15023 }
15024
15025 -static inline int user_mode_vm(struct pt_regs *regs)
15026 +static inline int user_mode(struct pt_regs *regs)
15027 {
15028 #ifdef CONFIG_X86_32
15029 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15030 USER_RPL;
15031 #else
15032 - return user_mode(regs);
15033 + return user_mode_novm(regs);
15034 #endif
15035 }
15036
15037 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15038 #ifdef CONFIG_X86_64
15039 static inline bool user_64bit_mode(struct pt_regs *regs)
15040 {
15041 + unsigned long cs = regs->cs & 0xffff;
15042 #ifndef CONFIG_PARAVIRT
15043 /*
15044 * On non-paravirt systems, this is the only long mode CPL 3
15045 * selector. We do not allow long mode selectors in the LDT.
15046 */
15047 - return regs->cs == __USER_CS;
15048 + return cs == __USER_CS;
15049 #else
15050 /* Headers are too twisted for this to go in paravirt.h. */
15051 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15052 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15053 #endif
15054 }
15055
15056 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15057 * Traps from the kernel do not save sp and ss.
15058 * Use the helper function to retrieve sp.
15059 */
15060 - if (offset == offsetof(struct pt_regs, sp) &&
15061 - regs->cs == __KERNEL_CS)
15062 - return kernel_stack_pointer(regs);
15063 + if (offset == offsetof(struct pt_regs, sp)) {
15064 + unsigned long cs = regs->cs & 0xffff;
15065 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15066 + return kernel_stack_pointer(regs);
15067 + }
15068 #endif
15069 return *(unsigned long *)((unsigned long)regs + offset);
15070 }
15071 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15072 index 9c6b890..5305f53 100644
15073 --- a/arch/x86/include/asm/realmode.h
15074 +++ b/arch/x86/include/asm/realmode.h
15075 @@ -22,16 +22,14 @@ struct real_mode_header {
15076 #endif
15077 /* APM/BIOS reboot */
15078 u32 machine_real_restart_asm;
15079 -#ifdef CONFIG_X86_64
15080 u32 machine_real_restart_seg;
15081 -#endif
15082 };
15083
15084 /* This must match data at trampoline_32/64.S */
15085 struct trampoline_header {
15086 #ifdef CONFIG_X86_32
15087 u32 start;
15088 - u16 gdt_pad;
15089 + u16 boot_cs;
15090 u16 gdt_limit;
15091 u32 gdt_base;
15092 #else
15093 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15094 index a82c4f1..ac45053 100644
15095 --- a/arch/x86/include/asm/reboot.h
15096 +++ b/arch/x86/include/asm/reboot.h
15097 @@ -6,13 +6,13 @@
15098 struct pt_regs;
15099
15100 struct machine_ops {
15101 - void (*restart)(char *cmd);
15102 - void (*halt)(void);
15103 - void (*power_off)(void);
15104 + void (* __noreturn restart)(char *cmd);
15105 + void (* __noreturn halt)(void);
15106 + void (* __noreturn power_off)(void);
15107 void (*shutdown)(void);
15108 void (*crash_shutdown)(struct pt_regs *);
15109 - void (*emergency_restart)(void);
15110 -};
15111 + void (* __noreturn emergency_restart)(void);
15112 +} __no_const;
15113
15114 extern struct machine_ops machine_ops;
15115
15116 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15117 index cad82c9..2e5c5c1 100644
15118 --- a/arch/x86/include/asm/rwsem.h
15119 +++ b/arch/x86/include/asm/rwsem.h
15120 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15121 {
15122 asm volatile("# beginning down_read\n\t"
15123 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15124 +
15125 +#ifdef CONFIG_PAX_REFCOUNT
15126 + "jno 0f\n"
15127 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15128 + "int $4\n0:\n"
15129 + _ASM_EXTABLE(0b, 0b)
15130 +#endif
15131 +
15132 /* adds 0x00000001 */
15133 " jns 1f\n"
15134 " call call_rwsem_down_read_failed\n"
15135 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15136 "1:\n\t"
15137 " mov %1,%2\n\t"
15138 " add %3,%2\n\t"
15139 +
15140 +#ifdef CONFIG_PAX_REFCOUNT
15141 + "jno 0f\n"
15142 + "sub %3,%2\n"
15143 + "int $4\n0:\n"
15144 + _ASM_EXTABLE(0b, 0b)
15145 +#endif
15146 +
15147 " jle 2f\n\t"
15148 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15149 " jnz 1b\n\t"
15150 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15151 long tmp;
15152 asm volatile("# beginning down_write\n\t"
15153 LOCK_PREFIX " xadd %1,(%2)\n\t"
15154 +
15155 +#ifdef CONFIG_PAX_REFCOUNT
15156 + "jno 0f\n"
15157 + "mov %1,(%2)\n"
15158 + "int $4\n0:\n"
15159 + _ASM_EXTABLE(0b, 0b)
15160 +#endif
15161 +
15162 /* adds 0xffff0001, returns the old value */
15163 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
15164 /* was the active mask 0 before? */
15165 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15166 long tmp;
15167 asm volatile("# beginning __up_read\n\t"
15168 LOCK_PREFIX " xadd %1,(%2)\n\t"
15169 +
15170 +#ifdef CONFIG_PAX_REFCOUNT
15171 + "jno 0f\n"
15172 + "mov %1,(%2)\n"
15173 + "int $4\n0:\n"
15174 + _ASM_EXTABLE(0b, 0b)
15175 +#endif
15176 +
15177 /* subtracts 1, returns the old value */
15178 " jns 1f\n\t"
15179 " call call_rwsem_wake\n" /* expects old value in %edx */
15180 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15181 long tmp;
15182 asm volatile("# beginning __up_write\n\t"
15183 LOCK_PREFIX " xadd %1,(%2)\n\t"
15184 +
15185 +#ifdef CONFIG_PAX_REFCOUNT
15186 + "jno 0f\n"
15187 + "mov %1,(%2)\n"
15188 + "int $4\n0:\n"
15189 + _ASM_EXTABLE(0b, 0b)
15190 +#endif
15191 +
15192 /* subtracts 0xffff0001, returns the old value */
15193 " jns 1f\n\t"
15194 " call call_rwsem_wake\n" /* expects old value in %edx */
15195 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15196 {
15197 asm volatile("# beginning __downgrade_write\n\t"
15198 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15199 +
15200 +#ifdef CONFIG_PAX_REFCOUNT
15201 + "jno 0f\n"
15202 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15203 + "int $4\n0:\n"
15204 + _ASM_EXTABLE(0b, 0b)
15205 +#endif
15206 +
15207 /*
15208 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15209 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15210 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15211 */
15212 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15213 {
15214 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15215 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15216 +
15217 +#ifdef CONFIG_PAX_REFCOUNT
15218 + "jno 0f\n"
15219 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15220 + "int $4\n0:\n"
15221 + _ASM_EXTABLE(0b, 0b)
15222 +#endif
15223 +
15224 : "+m" (sem->count)
15225 : "er" (delta));
15226 }
15227 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15228 */
15229 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15230 {
15231 - return delta + xadd(&sem->count, delta);
15232 + return delta + xadd_check_overflow(&sem->count, delta);
15233 }
15234
15235 #endif /* __KERNEL__ */
15236 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15237 index c48a950..c6d7468 100644
15238 --- a/arch/x86/include/asm/segment.h
15239 +++ b/arch/x86/include/asm/segment.h
15240 @@ -64,10 +64,15 @@
15241 * 26 - ESPFIX small SS
15242 * 27 - per-cpu [ offset to per-cpu data area ]
15243 * 28 - stack_canary-20 [ for stack protector ]
15244 - * 29 - unused
15245 - * 30 - unused
15246 + * 29 - PCI BIOS CS
15247 + * 30 - PCI BIOS DS
15248 * 31 - TSS for double fault handler
15249 */
15250 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15251 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15252 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15253 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15254 +
15255 #define GDT_ENTRY_TLS_MIN 6
15256 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15257
15258 @@ -79,6 +84,8 @@
15259
15260 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15261
15262 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15263 +
15264 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15265
15266 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15267 @@ -104,6 +111,12 @@
15268 #define __KERNEL_STACK_CANARY 0
15269 #endif
15270
15271 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15272 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15273 +
15274 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15275 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15276 +
15277 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15278
15279 /*
15280 @@ -141,7 +154,7 @@
15281 */
15282
15283 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15284 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15285 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15286
15287
15288 #else
15289 @@ -165,6 +178,8 @@
15290 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15291 #define __USER32_DS __USER_DS
15292
15293 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15294 +
15295 #define GDT_ENTRY_TSS 8 /* needs two entries */
15296 #define GDT_ENTRY_LDT 10 /* needs two entries */
15297 #define GDT_ENTRY_TLS_MIN 12
15298 @@ -185,6 +200,7 @@
15299 #endif
15300
15301 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15302 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15303 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15304 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15305 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15306 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15307 {
15308 unsigned long __limit;
15309 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15310 - return __limit + 1;
15311 + return __limit;
15312 }
15313
15314 #endif /* !__ASSEMBLY__ */
15315 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15316 index b073aae..39f9bdd 100644
15317 --- a/arch/x86/include/asm/smp.h
15318 +++ b/arch/x86/include/asm/smp.h
15319 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15320 /* cpus sharing the last level cache: */
15321 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15322 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15323 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15324 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15325
15326 static inline struct cpumask *cpu_sibling_mask(int cpu)
15327 {
15328 @@ -79,7 +79,7 @@ struct smp_ops {
15329
15330 void (*send_call_func_ipi)(const struct cpumask *mask);
15331 void (*send_call_func_single_ipi)(int cpu);
15332 -};
15333 +} __no_const;
15334
15335 /* Globals due to paravirt */
15336 extern void set_cpu_sibling_map(int cpu);
15337 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15338 extern int safe_smp_processor_id(void);
15339
15340 #elif defined(CONFIG_X86_64_SMP)
15341 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15342 -
15343 -#define stack_smp_processor_id() \
15344 -({ \
15345 - struct thread_info *ti; \
15346 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15347 - ti->cpu; \
15348 -})
15349 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15350 +#define stack_smp_processor_id() raw_smp_processor_id()
15351 #define safe_smp_processor_id() smp_processor_id()
15352
15353 #endif
15354 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15355 index 33692ea..350a534 100644
15356 --- a/arch/x86/include/asm/spinlock.h
15357 +++ b/arch/x86/include/asm/spinlock.h
15358 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15359 static inline void arch_read_lock(arch_rwlock_t *rw)
15360 {
15361 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15362 +
15363 +#ifdef CONFIG_PAX_REFCOUNT
15364 + "jno 0f\n"
15365 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15366 + "int $4\n0:\n"
15367 + _ASM_EXTABLE(0b, 0b)
15368 +#endif
15369 +
15370 "jns 1f\n"
15371 "call __read_lock_failed\n\t"
15372 "1:\n"
15373 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15374 static inline void arch_write_lock(arch_rwlock_t *rw)
15375 {
15376 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15377 +
15378 +#ifdef CONFIG_PAX_REFCOUNT
15379 + "jno 0f\n"
15380 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15381 + "int $4\n0:\n"
15382 + _ASM_EXTABLE(0b, 0b)
15383 +#endif
15384 +
15385 "jz 1f\n"
15386 "call __write_lock_failed\n\t"
15387 "1:\n"
15388 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15389
15390 static inline void arch_read_unlock(arch_rwlock_t *rw)
15391 {
15392 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15393 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15394 +
15395 +#ifdef CONFIG_PAX_REFCOUNT
15396 + "jno 0f\n"
15397 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15398 + "int $4\n0:\n"
15399 + _ASM_EXTABLE(0b, 0b)
15400 +#endif
15401 +
15402 :"+m" (rw->lock) : : "memory");
15403 }
15404
15405 static inline void arch_write_unlock(arch_rwlock_t *rw)
15406 {
15407 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15408 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15409 +
15410 +#ifdef CONFIG_PAX_REFCOUNT
15411 + "jno 0f\n"
15412 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15413 + "int $4\n0:\n"
15414 + _ASM_EXTABLE(0b, 0b)
15415 +#endif
15416 +
15417 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15418 }
15419
15420 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15421 index 6a99859..03cb807 100644
15422 --- a/arch/x86/include/asm/stackprotector.h
15423 +++ b/arch/x86/include/asm/stackprotector.h
15424 @@ -47,7 +47,7 @@
15425 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15426 */
15427 #define GDT_STACK_CANARY_INIT \
15428 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15429 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15430
15431 /*
15432 * Initialize the stackprotector canary value.
15433 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15434
15435 static inline void load_stack_canary_segment(void)
15436 {
15437 -#ifdef CONFIG_X86_32
15438 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15439 asm volatile ("mov %0, %%gs" : : "r" (0));
15440 #endif
15441 }
15442 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15443 index 70bbe39..4ae2bd4 100644
15444 --- a/arch/x86/include/asm/stacktrace.h
15445 +++ b/arch/x86/include/asm/stacktrace.h
15446 @@ -11,28 +11,20 @@
15447
15448 extern int kstack_depth_to_print;
15449
15450 -struct thread_info;
15451 +struct task_struct;
15452 struct stacktrace_ops;
15453
15454 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15455 - unsigned long *stack,
15456 - unsigned long bp,
15457 - const struct stacktrace_ops *ops,
15458 - void *data,
15459 - unsigned long *end,
15460 - int *graph);
15461 +typedef unsigned long walk_stack_t(struct task_struct *task,
15462 + void *stack_start,
15463 + unsigned long *stack,
15464 + unsigned long bp,
15465 + const struct stacktrace_ops *ops,
15466 + void *data,
15467 + unsigned long *end,
15468 + int *graph);
15469
15470 -extern unsigned long
15471 -print_context_stack(struct thread_info *tinfo,
15472 - unsigned long *stack, unsigned long bp,
15473 - const struct stacktrace_ops *ops, void *data,
15474 - unsigned long *end, int *graph);
15475 -
15476 -extern unsigned long
15477 -print_context_stack_bp(struct thread_info *tinfo,
15478 - unsigned long *stack, unsigned long bp,
15479 - const struct stacktrace_ops *ops, void *data,
15480 - unsigned long *end, int *graph);
15481 +extern walk_stack_t print_context_stack;
15482 +extern walk_stack_t print_context_stack_bp;
15483
15484 /* Generic stack tracer with callbacks */
15485
15486 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15487 void (*address)(void *data, unsigned long address, int reliable);
15488 /* On negative return stop dumping */
15489 int (*stack)(void *data, char *name);
15490 - walk_stack_t walk_stack;
15491 + walk_stack_t *walk_stack;
15492 };
15493
15494 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15495 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15496 index 4ec45b3..a4f0a8a 100644
15497 --- a/arch/x86/include/asm/switch_to.h
15498 +++ b/arch/x86/include/asm/switch_to.h
15499 @@ -108,7 +108,7 @@ do { \
15500 "call __switch_to\n\t" \
15501 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15502 __switch_canary \
15503 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15504 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15505 "movq %%rax,%%rdi\n\t" \
15506 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15507 "jnz ret_from_fork\n\t" \
15508 @@ -119,7 +119,7 @@ do { \
15509 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15510 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15511 [_tif_fork] "i" (_TIF_FORK), \
15512 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15513 + [thread_info] "m" (current_tinfo), \
15514 [current_task] "m" (current_task) \
15515 __switch_canary_iparam \
15516 : "memory", "cc" __EXTRA_CLOBBER)
15517 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15518 index a1df6e8..e002940 100644
15519 --- a/arch/x86/include/asm/thread_info.h
15520 +++ b/arch/x86/include/asm/thread_info.h
15521 @@ -10,6 +10,7 @@
15522 #include <linux/compiler.h>
15523 #include <asm/page.h>
15524 #include <asm/types.h>
15525 +#include <asm/percpu.h>
15526
15527 /*
15528 * low level task data that entry.S needs immediate access to
15529 @@ -23,7 +24,6 @@ struct exec_domain;
15530 #include <linux/atomic.h>
15531
15532 struct thread_info {
15533 - struct task_struct *task; /* main task structure */
15534 struct exec_domain *exec_domain; /* execution domain */
15535 __u32 flags; /* low level flags */
15536 __u32 status; /* thread synchronous flags */
15537 @@ -33,19 +33,13 @@ struct thread_info {
15538 mm_segment_t addr_limit;
15539 struct restart_block restart_block;
15540 void __user *sysenter_return;
15541 -#ifdef CONFIG_X86_32
15542 - unsigned long previous_esp; /* ESP of the previous stack in
15543 - case of nested (IRQ) stacks
15544 - */
15545 - __u8 supervisor_stack[0];
15546 -#endif
15547 + unsigned long lowest_stack;
15548 unsigned int sig_on_uaccess_error:1;
15549 unsigned int uaccess_err:1; /* uaccess failed */
15550 };
15551
15552 -#define INIT_THREAD_INFO(tsk) \
15553 +#define INIT_THREAD_INFO \
15554 { \
15555 - .task = &tsk, \
15556 .exec_domain = &default_exec_domain, \
15557 .flags = 0, \
15558 .cpu = 0, \
15559 @@ -56,7 +50,7 @@ struct thread_info {
15560 }, \
15561 }
15562
15563 -#define init_thread_info (init_thread_union.thread_info)
15564 +#define init_thread_info (init_thread_union.stack)
15565 #define init_stack (init_thread_union.stack)
15566
15567 #else /* !__ASSEMBLY__ */
15568 @@ -97,6 +91,7 @@ struct thread_info {
15569 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15570 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15571 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15572 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15573
15574 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15575 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15576 @@ -121,17 +116,18 @@ struct thread_info {
15577 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15578 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15579 #define _TIF_X32 (1 << TIF_X32)
15580 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15581
15582 /* work to do in syscall_trace_enter() */
15583 #define _TIF_WORK_SYSCALL_ENTRY \
15584 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15585 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15586 - _TIF_NOHZ)
15587 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15588
15589 /* work to do in syscall_trace_leave() */
15590 #define _TIF_WORK_SYSCALL_EXIT \
15591 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15592 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15593 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15594
15595 /* work to do on interrupt/exception return */
15596 #define _TIF_WORK_MASK \
15597 @@ -142,7 +138,7 @@ struct thread_info {
15598 /* work to do on any return to user space */
15599 #define _TIF_ALLWORK_MASK \
15600 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15601 - _TIF_NOHZ)
15602 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15603
15604 /* Only used for 64 bit */
15605 #define _TIF_DO_NOTIFY_MASK \
15606 @@ -158,45 +154,40 @@ struct thread_info {
15607
15608 #define PREEMPT_ACTIVE 0x10000000
15609
15610 -#ifdef CONFIG_X86_32
15611 -
15612 -#define STACK_WARN (THREAD_SIZE/8)
15613 -/*
15614 - * macros/functions for gaining access to the thread information structure
15615 - *
15616 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15617 - */
15618 -#ifndef __ASSEMBLY__
15619 -
15620 -
15621 -/* how to get the current stack pointer from C */
15622 -register unsigned long current_stack_pointer asm("esp") __used;
15623 -
15624 -/* how to get the thread information struct from C */
15625 -static inline struct thread_info *current_thread_info(void)
15626 -{
15627 - return (struct thread_info *)
15628 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15629 -}
15630 -
15631 -#else /* !__ASSEMBLY__ */
15632 -
15633 +#ifdef __ASSEMBLY__
15634 /* how to get the thread information struct from ASM */
15635 #define GET_THREAD_INFO(reg) \
15636 - movl $-THREAD_SIZE, reg; \
15637 - andl %esp, reg
15638 + mov PER_CPU_VAR(current_tinfo), reg
15639
15640 /* use this one if reg already contains %esp */
15641 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15642 - andl $-THREAD_SIZE, reg
15643 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15644 +#else
15645 +/* how to get the thread information struct from C */
15646 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15647 +
15648 +static __always_inline struct thread_info *current_thread_info(void)
15649 +{
15650 + return this_cpu_read_stable(current_tinfo);
15651 +}
15652 +#endif
15653 +
15654 +#ifdef CONFIG_X86_32
15655 +
15656 +#define STACK_WARN (THREAD_SIZE/8)
15657 +/*
15658 + * macros/functions for gaining access to the thread information structure
15659 + *
15660 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15661 + */
15662 +#ifndef __ASSEMBLY__
15663 +
15664 +/* how to get the current stack pointer from C */
15665 +register unsigned long current_stack_pointer asm("esp") __used;
15666
15667 #endif
15668
15669 #else /* X86_32 */
15670
15671 -#include <asm/percpu.h>
15672 -#define KERNEL_STACK_OFFSET (5*8)
15673 -
15674 /*
15675 * macros/functions for gaining access to the thread information structure
15676 * preempt_count needs to be 1 initially, until the scheduler is functional.
15677 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15678 #ifndef __ASSEMBLY__
15679 DECLARE_PER_CPU(unsigned long, kernel_stack);
15680
15681 -static inline struct thread_info *current_thread_info(void)
15682 -{
15683 - struct thread_info *ti;
15684 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15685 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15686 - return ti;
15687 -}
15688 -
15689 -#else /* !__ASSEMBLY__ */
15690 -
15691 -/* how to get the thread information struct from ASM */
15692 -#define GET_THREAD_INFO(reg) \
15693 - movq PER_CPU_VAR(kernel_stack),reg ; \
15694 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15695 -
15696 -/*
15697 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15698 - * a certain register (to be used in assembler memory operands).
15699 - */
15700 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15701 -
15702 +/* how to get the current stack pointer from C */
15703 +register unsigned long current_stack_pointer asm("rsp") __used;
15704 #endif
15705
15706 #endif /* !X86_32 */
15707 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
15708 extern void arch_task_cache_init(void);
15709 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15710 extern void arch_release_task_struct(struct task_struct *tsk);
15711 +
15712 +#define __HAVE_THREAD_FUNCTIONS
15713 +#define task_thread_info(task) (&(task)->tinfo)
15714 +#define task_stack_page(task) ((task)->stack)
15715 +#define setup_thread_stack(p, org) do {} while (0)
15716 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15717 +
15718 #endif
15719 #endif /* _ASM_X86_THREAD_INFO_H */
15720 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15721 index 5ee2687..70d5895 100644
15722 --- a/arch/x86/include/asm/uaccess.h
15723 +++ b/arch/x86/include/asm/uaccess.h
15724 @@ -7,6 +7,7 @@
15725 #include <linux/compiler.h>
15726 #include <linux/thread_info.h>
15727 #include <linux/string.h>
15728 +#include <linux/sched.h>
15729 #include <asm/asm.h>
15730 #include <asm/page.h>
15731 #include <asm/smap.h>
15732 @@ -29,7 +30,12 @@
15733
15734 #define get_ds() (KERNEL_DS)
15735 #define get_fs() (current_thread_info()->addr_limit)
15736 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15737 +void __set_fs(mm_segment_t x);
15738 +void set_fs(mm_segment_t x);
15739 +#else
15740 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15741 +#endif
15742
15743 #define segment_eq(a, b) ((a).seg == (b).seg)
15744
15745 @@ -77,8 +83,33 @@
15746 * checks that the pointer is in the user space range - after calling
15747 * this function, memory access functions may still return -EFAULT.
15748 */
15749 -#define access_ok(type, addr, size) \
15750 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15751 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15752 +#define access_ok(type, addr, size) \
15753 +({ \
15754 + long __size = size; \
15755 + unsigned long __addr = (unsigned long)addr; \
15756 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15757 + unsigned long __end_ao = __addr + __size - 1; \
15758 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15759 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15760 + while(__addr_ao <= __end_ao) { \
15761 + char __c_ao; \
15762 + __addr_ao += PAGE_SIZE; \
15763 + if (__size > PAGE_SIZE) \
15764 + cond_resched(); \
15765 + if (__get_user(__c_ao, (char __user *)__addr)) \
15766 + break; \
15767 + if (type != VERIFY_WRITE) { \
15768 + __addr = __addr_ao; \
15769 + continue; \
15770 + } \
15771 + if (__put_user(__c_ao, (char __user *)__addr)) \
15772 + break; \
15773 + __addr = __addr_ao; \
15774 + } \
15775 + } \
15776 + __ret_ao; \
15777 +})
15778
15779 /*
15780 * The exception table consists of pairs of addresses relative to the
15781 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15782 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15783 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15784
15785 -
15786 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15787 +#define __copyuser_seg "gs;"
15788 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15789 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15790 +#else
15791 +#define __copyuser_seg
15792 +#define __COPYUSER_SET_ES
15793 +#define __COPYUSER_RESTORE_ES
15794 +#endif
15795
15796 #ifdef CONFIG_X86_32
15797 #define __put_user_asm_u64(x, addr, err, errret) \
15798 asm volatile(ASM_STAC "\n" \
15799 - "1: movl %%eax,0(%2)\n" \
15800 - "2: movl %%edx,4(%2)\n" \
15801 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15802 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15803 "3: " ASM_CLAC "\n" \
15804 ".section .fixup,\"ax\"\n" \
15805 "4: movl %3,%0\n" \
15806 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15807
15808 #define __put_user_asm_ex_u64(x, addr) \
15809 asm volatile(ASM_STAC "\n" \
15810 - "1: movl %%eax,0(%1)\n" \
15811 - "2: movl %%edx,4(%1)\n" \
15812 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15813 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15814 "3: " ASM_CLAC "\n" \
15815 _ASM_EXTABLE_EX(1b, 2b) \
15816 _ASM_EXTABLE_EX(2b, 3b) \
15817 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15818 __typeof__(*(ptr)) __pu_val; \
15819 __chk_user_ptr(ptr); \
15820 might_fault(); \
15821 - __pu_val = x; \
15822 + __pu_val = (x); \
15823 switch (sizeof(*(ptr))) { \
15824 case 1: \
15825 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15826 @@ -345,7 +384,7 @@ do { \
15827
15828 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15829 asm volatile(ASM_STAC "\n" \
15830 - "1: mov"itype" %2,%"rtype"1\n" \
15831 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15832 "2: " ASM_CLAC "\n" \
15833 ".section .fixup,\"ax\"\n" \
15834 "3: mov %3,%0\n" \
15835 @@ -353,7 +392,7 @@ do { \
15836 " jmp 2b\n" \
15837 ".previous\n" \
15838 _ASM_EXTABLE(1b, 3b) \
15839 - : "=r" (err), ltype(x) \
15840 + : "=r" (err), ltype (x) \
15841 : "m" (__m(addr)), "i" (errret), "0" (err))
15842
15843 #define __get_user_size_ex(x, ptr, size) \
15844 @@ -378,7 +417,7 @@ do { \
15845 } while (0)
15846
15847 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15848 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15849 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15850 "2:\n" \
15851 _ASM_EXTABLE_EX(1b, 2b) \
15852 : ltype(x) : "m" (__m(addr)))
15853 @@ -395,13 +434,24 @@ do { \
15854 int __gu_err; \
15855 unsigned long __gu_val; \
15856 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15857 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15858 + (x) = (__typeof__(*(ptr)))__gu_val; \
15859 __gu_err; \
15860 })
15861
15862 /* FIXME: this hack is definitely wrong -AK */
15863 struct __large_struct { unsigned long buf[100]; };
15864 -#define __m(x) (*(struct __large_struct __user *)(x))
15865 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15866 +#define ____m(x) \
15867 +({ \
15868 + unsigned long ____x = (unsigned long)(x); \
15869 + if (____x < pax_user_shadow_base) \
15870 + ____x += pax_user_shadow_base; \
15871 + (typeof(x))____x; \
15872 +})
15873 +#else
15874 +#define ____m(x) (x)
15875 +#endif
15876 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15877
15878 /*
15879 * Tell gcc we read from memory instead of writing: this is because
15880 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15881 */
15882 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15883 asm volatile(ASM_STAC "\n" \
15884 - "1: mov"itype" %"rtype"1,%2\n" \
15885 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15886 "2: " ASM_CLAC "\n" \
15887 ".section .fixup,\"ax\"\n" \
15888 "3: mov %3,%0\n" \
15889 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15890 ".previous\n" \
15891 _ASM_EXTABLE(1b, 3b) \
15892 : "=r"(err) \
15893 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15894 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15895
15896 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15897 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15898 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15899 "2:\n" \
15900 _ASM_EXTABLE_EX(1b, 2b) \
15901 : : ltype(x), "m" (__m(addr)))
15902 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15903 * On error, the variable @x is set to zero.
15904 */
15905
15906 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15907 +#define __get_user(x, ptr) get_user((x), (ptr))
15908 +#else
15909 #define __get_user(x, ptr) \
15910 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15911 +#endif
15912
15913 /**
15914 * __put_user: - Write a simple value into user space, with less checking.
15915 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15916 * Returns zero on success, or -EFAULT on error.
15917 */
15918
15919 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15920 +#define __put_user(x, ptr) put_user((x), (ptr))
15921 +#else
15922 #define __put_user(x, ptr) \
15923 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15924 +#endif
15925
15926 #define __get_user_unaligned __get_user
15927 #define __put_user_unaligned __put_user
15928 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15929 #define get_user_ex(x, ptr) do { \
15930 unsigned long __gue_val; \
15931 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15932 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15933 + (x) = (__typeof__(*(ptr)))__gue_val; \
15934 } while (0)
15935
15936 #define put_user_try uaccess_try
15937 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15938 extern __must_check long strlen_user(const char __user *str);
15939 extern __must_check long strnlen_user(const char __user *str, long n);
15940
15941 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15942 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15943 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15944 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15945
15946 /*
15947 * movsl can be slow when source and dest are not both 8-byte aligned
15948 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15949 index 7f760a9..04b1c65 100644
15950 --- a/arch/x86/include/asm/uaccess_32.h
15951 +++ b/arch/x86/include/asm/uaccess_32.h
15952 @@ -11,15 +11,15 @@
15953 #include <asm/page.h>
15954
15955 unsigned long __must_check __copy_to_user_ll
15956 - (void __user *to, const void *from, unsigned long n);
15957 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15958 unsigned long __must_check __copy_from_user_ll
15959 - (void *to, const void __user *from, unsigned long n);
15960 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15961 unsigned long __must_check __copy_from_user_ll_nozero
15962 - (void *to, const void __user *from, unsigned long n);
15963 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15964 unsigned long __must_check __copy_from_user_ll_nocache
15965 - (void *to, const void __user *from, unsigned long n);
15966 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15967 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15968 - (void *to, const void __user *from, unsigned long n);
15969 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15970
15971 /**
15972 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15973 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15974 static __always_inline unsigned long __must_check
15975 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15976 {
15977 + if ((long)n < 0)
15978 + return n;
15979 +
15980 + check_object_size(from, n, true);
15981 +
15982 if (__builtin_constant_p(n)) {
15983 unsigned long ret;
15984
15985 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15986 __copy_to_user(void __user *to, const void *from, unsigned long n)
15987 {
15988 might_fault();
15989 +
15990 return __copy_to_user_inatomic(to, from, n);
15991 }
15992
15993 static __always_inline unsigned long
15994 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15995 {
15996 + if ((long)n < 0)
15997 + return n;
15998 +
15999 /* Avoid zeroing the tail if the copy fails..
16000 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16001 * but as the zeroing behaviour is only significant when n is not
16002 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16003 __copy_from_user(void *to, const void __user *from, unsigned long n)
16004 {
16005 might_fault();
16006 +
16007 + if ((long)n < 0)
16008 + return n;
16009 +
16010 + check_object_size(to, n, false);
16011 +
16012 if (__builtin_constant_p(n)) {
16013 unsigned long ret;
16014
16015 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16016 const void __user *from, unsigned long n)
16017 {
16018 might_fault();
16019 +
16020 + if ((long)n < 0)
16021 + return n;
16022 +
16023 if (__builtin_constant_p(n)) {
16024 unsigned long ret;
16025
16026 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16027 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16028 unsigned long n)
16029 {
16030 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16031 + if ((long)n < 0)
16032 + return n;
16033 +
16034 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16035 }
16036
16037 -unsigned long __must_check copy_to_user(void __user *to,
16038 - const void *from, unsigned long n);
16039 -unsigned long __must_check _copy_from_user(void *to,
16040 - const void __user *from,
16041 - unsigned long n);
16042 -
16043 +extern void copy_to_user_overflow(void)
16044 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16045 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16046 +#else
16047 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16048 +#endif
16049 +;
16050
16051 extern void copy_from_user_overflow(void)
16052 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16053 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16054 #endif
16055 ;
16056
16057 -static inline unsigned long __must_check copy_from_user(void *to,
16058 - const void __user *from,
16059 - unsigned long n)
16060 +/**
16061 + * copy_to_user: - Copy a block of data into user space.
16062 + * @to: Destination address, in user space.
16063 + * @from: Source address, in kernel space.
16064 + * @n: Number of bytes to copy.
16065 + *
16066 + * Context: User context only. This function may sleep.
16067 + *
16068 + * Copy data from kernel space to user space.
16069 + *
16070 + * Returns number of bytes that could not be copied.
16071 + * On success, this will be zero.
16072 + */
16073 +static inline unsigned long __must_check
16074 +copy_to_user(void __user *to, const void *from, unsigned long n)
16075 {
16076 - int sz = __compiletime_object_size(to);
16077 + size_t sz = __compiletime_object_size(from);
16078
16079 - if (likely(sz == -1 || sz >= n))
16080 - n = _copy_from_user(to, from, n);
16081 - else
16082 + if (unlikely(sz != (size_t)-1 && sz < n))
16083 + copy_to_user_overflow();
16084 + else if (access_ok(VERIFY_WRITE, to, n))
16085 + n = __copy_to_user(to, from, n);
16086 + return n;
16087 +}
16088 +
16089 +/**
16090 + * copy_from_user: - Copy a block of data from user space.
16091 + * @to: Destination address, in kernel space.
16092 + * @from: Source address, in user space.
16093 + * @n: Number of bytes to copy.
16094 + *
16095 + * Context: User context only. This function may sleep.
16096 + *
16097 + * Copy data from user space to kernel space.
16098 + *
16099 + * Returns number of bytes that could not be copied.
16100 + * On success, this will be zero.
16101 + *
16102 + * If some data could not be copied, this function will pad the copied
16103 + * data to the requested size using zero bytes.
16104 + */
16105 +static inline unsigned long __must_check
16106 +copy_from_user(void *to, const void __user *from, unsigned long n)
16107 +{
16108 + size_t sz = __compiletime_object_size(to);
16109 +
16110 + check_object_size(to, n, false);
16111 +
16112 + if (unlikely(sz != (size_t)-1 && sz < n))
16113 copy_from_user_overflow();
16114 -
16115 + else if (access_ok(VERIFY_READ, from, n))
16116 + n = __copy_from_user(to, from, n);
16117 + else if ((long)n > 0)
16118 + memset(to, 0, n);
16119 return n;
16120 }
16121
16122 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16123 index 142810c..1f2a0a7 100644
16124 --- a/arch/x86/include/asm/uaccess_64.h
16125 +++ b/arch/x86/include/asm/uaccess_64.h
16126 @@ -10,6 +10,9 @@
16127 #include <asm/alternative.h>
16128 #include <asm/cpufeature.h>
16129 #include <asm/page.h>
16130 +#include <asm/pgtable.h>
16131 +
16132 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16133
16134 /*
16135 * Copy To/From Userspace
16136 @@ -17,13 +20,13 @@
16137
16138 /* Handles exceptions in both to and from, but doesn't do access_ok */
16139 __must_check unsigned long
16140 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16141 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16142 __must_check unsigned long
16143 -copy_user_generic_string(void *to, const void *from, unsigned len);
16144 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16145 __must_check unsigned long
16146 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16147 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16148
16149 -static __always_inline __must_check unsigned long
16150 +static __always_inline __must_check __size_overflow(3) unsigned long
16151 copy_user_generic(void *to, const void *from, unsigned len)
16152 {
16153 unsigned ret;
16154 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16155 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16156 "=d" (len)),
16157 "1" (to), "2" (from), "3" (len)
16158 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16159 + : "memory", "rcx", "r8", "r9", "r11");
16160 return ret;
16161 }
16162
16163 +static __always_inline __must_check unsigned long
16164 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16165 +static __always_inline __must_check unsigned long
16166 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16167 __must_check unsigned long
16168 -_copy_to_user(void __user *to, const void *from, unsigned len);
16169 -__must_check unsigned long
16170 -_copy_from_user(void *to, const void __user *from, unsigned len);
16171 -__must_check unsigned long
16172 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16173 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16174 +
16175 +extern void copy_to_user_overflow(void)
16176 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16177 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16178 +#else
16179 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16180 +#endif
16181 +;
16182 +
16183 +extern void copy_from_user_overflow(void)
16184 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16185 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16186 +#else
16187 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16188 +#endif
16189 +;
16190
16191 static inline unsigned long __must_check copy_from_user(void *to,
16192 const void __user *from,
16193 unsigned long n)
16194 {
16195 - int sz = __compiletime_object_size(to);
16196 -
16197 might_fault();
16198 - if (likely(sz == -1 || sz >= n))
16199 - n = _copy_from_user(to, from, n);
16200 -#ifdef CONFIG_DEBUG_VM
16201 - else
16202 - WARN(1, "Buffer overflow detected!\n");
16203 -#endif
16204 +
16205 + check_object_size(to, n, false);
16206 +
16207 + if (access_ok(VERIFY_READ, from, n))
16208 + n = __copy_from_user(to, from, n);
16209 + else if (n < INT_MAX)
16210 + memset(to, 0, n);
16211 return n;
16212 }
16213
16214 static __always_inline __must_check
16215 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16216 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16217 {
16218 might_fault();
16219
16220 - return _copy_to_user(dst, src, size);
16221 + if (access_ok(VERIFY_WRITE, dst, size))
16222 + size = __copy_to_user(dst, src, size);
16223 + return size;
16224 }
16225
16226 static __always_inline __must_check
16227 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16228 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16229 {
16230 - int ret = 0;
16231 + size_t sz = __compiletime_object_size(dst);
16232 + unsigned ret = 0;
16233
16234 might_fault();
16235 +
16236 + if (size > INT_MAX)
16237 + return size;
16238 +
16239 + check_object_size(dst, size, false);
16240 +
16241 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16242 + if (!__access_ok(VERIFY_READ, src, size))
16243 + return size;
16244 +#endif
16245 +
16246 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16247 + copy_from_user_overflow();
16248 + return size;
16249 + }
16250 +
16251 if (!__builtin_constant_p(size))
16252 - return copy_user_generic(dst, (__force void *)src, size);
16253 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16254 switch (size) {
16255 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16256 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16257 ret, "b", "b", "=q", 1);
16258 return ret;
16259 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16260 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16261 ret, "w", "w", "=r", 2);
16262 return ret;
16263 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16264 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16265 ret, "l", "k", "=r", 4);
16266 return ret;
16267 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16268 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16269 ret, "q", "", "=r", 8);
16270 return ret;
16271 case 10:
16272 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16273 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16274 ret, "q", "", "=r", 10);
16275 if (unlikely(ret))
16276 return ret;
16277 __get_user_asm(*(u16 *)(8 + (char *)dst),
16278 - (u16 __user *)(8 + (char __user *)src),
16279 + (const u16 __user *)(8 + (const char __user *)src),
16280 ret, "w", "w", "=r", 2);
16281 return ret;
16282 case 16:
16283 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16284 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16285 ret, "q", "", "=r", 16);
16286 if (unlikely(ret))
16287 return ret;
16288 __get_user_asm(*(u64 *)(8 + (char *)dst),
16289 - (u64 __user *)(8 + (char __user *)src),
16290 + (const u64 __user *)(8 + (const char __user *)src),
16291 ret, "q", "", "=r", 8);
16292 return ret;
16293 default:
16294 - return copy_user_generic(dst, (__force void *)src, size);
16295 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16296 }
16297 }
16298
16299 static __always_inline __must_check
16300 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16301 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16302 {
16303 - int ret = 0;
16304 + size_t sz = __compiletime_object_size(src);
16305 + unsigned ret = 0;
16306
16307 might_fault();
16308 +
16309 + if (size > INT_MAX)
16310 + return size;
16311 +
16312 + check_object_size(src, size, true);
16313 +
16314 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16315 + if (!__access_ok(VERIFY_WRITE, dst, size))
16316 + return size;
16317 +#endif
16318 +
16319 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16320 + copy_to_user_overflow();
16321 + return size;
16322 + }
16323 +
16324 if (!__builtin_constant_p(size))
16325 - return copy_user_generic((__force void *)dst, src, size);
16326 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16327 switch (size) {
16328 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16329 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16330 ret, "b", "b", "iq", 1);
16331 return ret;
16332 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16333 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16334 ret, "w", "w", "ir", 2);
16335 return ret;
16336 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16337 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16338 ret, "l", "k", "ir", 4);
16339 return ret;
16340 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16341 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16342 ret, "q", "", "er", 8);
16343 return ret;
16344 case 10:
16345 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16346 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16347 ret, "q", "", "er", 10);
16348 if (unlikely(ret))
16349 return ret;
16350 asm("":::"memory");
16351 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16352 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16353 ret, "w", "w", "ir", 2);
16354 return ret;
16355 case 16:
16356 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16357 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16358 ret, "q", "", "er", 16);
16359 if (unlikely(ret))
16360 return ret;
16361 asm("":::"memory");
16362 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16363 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16364 ret, "q", "", "er", 8);
16365 return ret;
16366 default:
16367 - return copy_user_generic((__force void *)dst, src, size);
16368 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16369 }
16370 }
16371
16372 static __always_inline __must_check
16373 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16374 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16375 {
16376 - int ret = 0;
16377 + unsigned ret = 0;
16378
16379 might_fault();
16380 +
16381 + if (size > INT_MAX)
16382 + return size;
16383 +
16384 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16385 + if (!__access_ok(VERIFY_READ, src, size))
16386 + return size;
16387 + if (!__access_ok(VERIFY_WRITE, dst, size))
16388 + return size;
16389 +#endif
16390 +
16391 if (!__builtin_constant_p(size))
16392 - return copy_user_generic((__force void *)dst,
16393 - (__force void *)src, size);
16394 + return copy_user_generic((__force_kernel void *)____m(dst),
16395 + (__force_kernel const void *)____m(src), size);
16396 switch (size) {
16397 case 1: {
16398 u8 tmp;
16399 - __get_user_asm(tmp, (u8 __user *)src,
16400 + __get_user_asm(tmp, (const u8 __user *)src,
16401 ret, "b", "b", "=q", 1);
16402 if (likely(!ret))
16403 __put_user_asm(tmp, (u8 __user *)dst,
16404 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16405 }
16406 case 2: {
16407 u16 tmp;
16408 - __get_user_asm(tmp, (u16 __user *)src,
16409 + __get_user_asm(tmp, (const u16 __user *)src,
16410 ret, "w", "w", "=r", 2);
16411 if (likely(!ret))
16412 __put_user_asm(tmp, (u16 __user *)dst,
16413 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16414
16415 case 4: {
16416 u32 tmp;
16417 - __get_user_asm(tmp, (u32 __user *)src,
16418 + __get_user_asm(tmp, (const u32 __user *)src,
16419 ret, "l", "k", "=r", 4);
16420 if (likely(!ret))
16421 __put_user_asm(tmp, (u32 __user *)dst,
16422 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16423 }
16424 case 8: {
16425 u64 tmp;
16426 - __get_user_asm(tmp, (u64 __user *)src,
16427 + __get_user_asm(tmp, (const u64 __user *)src,
16428 ret, "q", "", "=r", 8);
16429 if (likely(!ret))
16430 __put_user_asm(tmp, (u64 __user *)dst,
16431 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16432 return ret;
16433 }
16434 default:
16435 - return copy_user_generic((__force void *)dst,
16436 - (__force void *)src, size);
16437 + return copy_user_generic((__force_kernel void *)____m(dst),
16438 + (__force_kernel const void *)____m(src), size);
16439 }
16440 }
16441
16442 static __must_check __always_inline int
16443 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16444 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16445 {
16446 - return copy_user_generic(dst, (__force const void *)src, size);
16447 + if (size > INT_MAX)
16448 + return size;
16449 +
16450 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16451 + if (!__access_ok(VERIFY_READ, src, size))
16452 + return size;
16453 +#endif
16454 +
16455 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16456 }
16457
16458 -static __must_check __always_inline int
16459 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16460 +static __must_check __always_inline unsigned long
16461 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16462 {
16463 - return copy_user_generic((__force void *)dst, src, size);
16464 + if (size > INT_MAX)
16465 + return size;
16466 +
16467 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16468 + if (!__access_ok(VERIFY_WRITE, dst, size))
16469 + return size;
16470 +#endif
16471 +
16472 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16473 }
16474
16475 -extern long __copy_user_nocache(void *dst, const void __user *src,
16476 - unsigned size, int zerorest);
16477 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16478 + unsigned long size, int zerorest) __size_overflow(3);
16479
16480 -static inline int
16481 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16482 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16483 {
16484 might_sleep();
16485 +
16486 + if (size > INT_MAX)
16487 + return size;
16488 +
16489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16490 + if (!__access_ok(VERIFY_READ, src, size))
16491 + return size;
16492 +#endif
16493 +
16494 return __copy_user_nocache(dst, src, size, 1);
16495 }
16496
16497 -static inline int
16498 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16499 - unsigned size)
16500 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16501 + unsigned long size)
16502 {
16503 + if (size > INT_MAX)
16504 + return size;
16505 +
16506 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16507 + if (!__access_ok(VERIFY_READ, src, size))
16508 + return size;
16509 +#endif
16510 +
16511 return __copy_user_nocache(dst, src, size, 0);
16512 }
16513
16514 -unsigned long
16515 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16516 +extern unsigned long
16517 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16518
16519 #endif /* _ASM_X86_UACCESS_64_H */
16520 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16521 index 5b238981..77fdd78 100644
16522 --- a/arch/x86/include/asm/word-at-a-time.h
16523 +++ b/arch/x86/include/asm/word-at-a-time.h
16524 @@ -11,7 +11,7 @@
16525 * and shift, for example.
16526 */
16527 struct word_at_a_time {
16528 - const unsigned long one_bits, high_bits;
16529 + unsigned long one_bits, high_bits;
16530 };
16531
16532 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16533 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16534 index d8d9922..bf6cecb 100644
16535 --- a/arch/x86/include/asm/x86_init.h
16536 +++ b/arch/x86/include/asm/x86_init.h
16537 @@ -129,7 +129,7 @@ struct x86_init_ops {
16538 struct x86_init_timers timers;
16539 struct x86_init_iommu iommu;
16540 struct x86_init_pci pci;
16541 -};
16542 +} __no_const;
16543
16544 /**
16545 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16546 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16547 void (*setup_percpu_clockev)(void);
16548 void (*early_percpu_clock_init)(void);
16549 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16550 -};
16551 +} __no_const;
16552
16553 /**
16554 * struct x86_platform_ops - platform specific runtime functions
16555 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16556 void (*save_sched_clock_state)(void);
16557 void (*restore_sched_clock_state)(void);
16558 void (*apic_post_init)(void);
16559 -};
16560 +} __no_const;
16561
16562 struct pci_dev;
16563 struct msi_msg;
16564 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16565 void (*teardown_msi_irqs)(struct pci_dev *dev);
16566 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16567 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16568 -};
16569 +} __no_const;
16570
16571 struct IO_APIC_route_entry;
16572 struct io_apic_irq_attr;
16573 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16574 unsigned int destination, int vector,
16575 struct io_apic_irq_attr *attr);
16576 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16577 -};
16578 +} __no_const;
16579
16580 extern struct x86_init_ops x86_init;
16581 extern struct x86_cpuinit_ops x86_cpuinit;
16582 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16583 index 0415cda..b43d877 100644
16584 --- a/arch/x86/include/asm/xsave.h
16585 +++ b/arch/x86/include/asm/xsave.h
16586 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16587 return -EFAULT;
16588
16589 __asm__ __volatile__(ASM_STAC "\n"
16590 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16591 + "1:"
16592 + __copyuser_seg
16593 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16594 "2: " ASM_CLAC "\n"
16595 ".section .fixup,\"ax\"\n"
16596 "3: movl $-1,%[err]\n"
16597 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16598 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16599 {
16600 int err;
16601 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16602 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16603 u32 lmask = mask;
16604 u32 hmask = mask >> 32;
16605
16606 __asm__ __volatile__(ASM_STAC "\n"
16607 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16608 + "1:"
16609 + __copyuser_seg
16610 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16611 "2: " ASM_CLAC "\n"
16612 ".section .fixup,\"ax\"\n"
16613 "3: movl $-1,%[err]\n"
16614 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16615 index bbae024..e1528f9 100644
16616 --- a/arch/x86/include/uapi/asm/e820.h
16617 +++ b/arch/x86/include/uapi/asm/e820.h
16618 @@ -63,7 +63,7 @@ struct e820map {
16619 #define ISA_START_ADDRESS 0xa0000
16620 #define ISA_END_ADDRESS 0x100000
16621
16622 -#define BIOS_BEGIN 0x000a0000
16623 +#define BIOS_BEGIN 0x000c0000
16624 #define BIOS_END 0x00100000
16625
16626 #define BIOS_ROM_BASE 0xffe00000
16627 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16628 index 7bd3bd3..5dac791 100644
16629 --- a/arch/x86/kernel/Makefile
16630 +++ b/arch/x86/kernel/Makefile
16631 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16632 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16633 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16634 obj-y += probe_roms.o
16635 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16636 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16637 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16638 obj-y += syscall_$(BITS).o
16639 obj-$(CONFIG_X86_64) += vsyscall_64.o
16640 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16641 index 230c8ea..f915130 100644
16642 --- a/arch/x86/kernel/acpi/boot.c
16643 +++ b/arch/x86/kernel/acpi/boot.c
16644 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16645 * If your system is blacklisted here, but you find that acpi=force
16646 * works for you, please contact linux-acpi@vger.kernel.org
16647 */
16648 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16649 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16650 /*
16651 * Boxes that need ACPI disabled
16652 */
16653 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16654 };
16655
16656 /* second table for DMI checks that should run after early-quirks */
16657 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16658 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16659 /*
16660 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16661 * which includes some code which overrides all temperature
16662 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16663 index ec94e11..7fbbec0 100644
16664 --- a/arch/x86/kernel/acpi/sleep.c
16665 +++ b/arch/x86/kernel/acpi/sleep.c
16666 @@ -88,8 +88,12 @@ int acpi_suspend_lowlevel(void)
16667 #else /* CONFIG_64BIT */
16668 #ifdef CONFIG_SMP
16669 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16670 +
16671 + pax_open_kernel();
16672 early_gdt_descr.address =
16673 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16674 + pax_close_kernel();
16675 +
16676 initial_gs = per_cpu_offset(smp_processor_id());
16677 #endif
16678 initial_code = (unsigned long)wakeup_long64;
16679 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16680 index d1daa66..59fecba 100644
16681 --- a/arch/x86/kernel/acpi/wakeup_32.S
16682 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16683 @@ -29,13 +29,11 @@ wakeup_pmode_return:
16684 # and restore the stack ... but you need gdt for this to work
16685 movl saved_context_esp, %esp
16686
16687 - movl %cs:saved_magic, %eax
16688 - cmpl $0x12345678, %eax
16689 + cmpl $0x12345678, saved_magic
16690 jne bogus_magic
16691
16692 # jump to place where we left off
16693 - movl saved_eip, %eax
16694 - jmp *%eax
16695 + jmp *(saved_eip)
16696
16697 bogus_magic:
16698 jmp bogus_magic
16699 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16700 index c15cf9a..0e63558 100644
16701 --- a/arch/x86/kernel/alternative.c
16702 +++ b/arch/x86/kernel/alternative.c
16703 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16704 */
16705 for (a = start; a < end; a++) {
16706 instr = (u8 *)&a->instr_offset + a->instr_offset;
16707 +
16708 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16709 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16710 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16711 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16712 +#endif
16713 +
16714 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16715 BUG_ON(a->replacementlen > a->instrlen);
16716 BUG_ON(a->instrlen > sizeof(insnbuf));
16717 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16718 for (poff = start; poff < end; poff++) {
16719 u8 *ptr = (u8 *)poff + *poff;
16720
16721 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16722 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16723 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16724 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16725 +#endif
16726 +
16727 if (!*poff || ptr < text || ptr >= text_end)
16728 continue;
16729 /* turn DS segment override prefix into lock prefix */
16730 - if (*ptr == 0x3e)
16731 + if (*ktla_ktva(ptr) == 0x3e)
16732 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16733 }
16734 mutex_unlock(&text_mutex);
16735 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16736 for (poff = start; poff < end; poff++) {
16737 u8 *ptr = (u8 *)poff + *poff;
16738
16739 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16740 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16741 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16742 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16743 +#endif
16744 +
16745 if (!*poff || ptr < text || ptr >= text_end)
16746 continue;
16747 /* turn lock prefix into DS segment override prefix */
16748 - if (*ptr == 0xf0)
16749 + if (*ktla_ktva(ptr) == 0xf0)
16750 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16751 }
16752 mutex_unlock(&text_mutex);
16753 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16754
16755 BUG_ON(p->len > MAX_PATCH_LEN);
16756 /* prep the buffer with the original instructions */
16757 - memcpy(insnbuf, p->instr, p->len);
16758 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16759 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16760 (unsigned long)p->instr, p->len);
16761
16762 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16763 if (!uniproc_patched || num_possible_cpus() == 1)
16764 free_init_pages("SMP alternatives",
16765 (unsigned long)__smp_locks,
16766 - (unsigned long)__smp_locks_end);
16767 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16768 #endif
16769
16770 apply_paravirt(__parainstructions, __parainstructions_end);
16771 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16772 * instructions. And on the local CPU you need to be protected again NMI or MCE
16773 * handlers seeing an inconsistent instruction while you patch.
16774 */
16775 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16776 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16777 size_t len)
16778 {
16779 unsigned long flags;
16780 local_irq_save(flags);
16781 - memcpy(addr, opcode, len);
16782 +
16783 + pax_open_kernel();
16784 + memcpy(ktla_ktva(addr), opcode, len);
16785 sync_core();
16786 + pax_close_kernel();
16787 +
16788 local_irq_restore(flags);
16789 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16790 that causes hangs on some VIA CPUs. */
16791 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16792 */
16793 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16794 {
16795 - unsigned long flags;
16796 - char *vaddr;
16797 + unsigned char *vaddr = ktla_ktva(addr);
16798 struct page *pages[2];
16799 - int i;
16800 + size_t i;
16801
16802 if (!core_kernel_text((unsigned long)addr)) {
16803 - pages[0] = vmalloc_to_page(addr);
16804 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16805 + pages[0] = vmalloc_to_page(vaddr);
16806 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16807 } else {
16808 - pages[0] = virt_to_page(addr);
16809 + pages[0] = virt_to_page(vaddr);
16810 WARN_ON(!PageReserved(pages[0]));
16811 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16812 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16813 }
16814 BUG_ON(!pages[0]);
16815 - local_irq_save(flags);
16816 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16817 - if (pages[1])
16818 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16819 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16820 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16821 - clear_fixmap(FIX_TEXT_POKE0);
16822 - if (pages[1])
16823 - clear_fixmap(FIX_TEXT_POKE1);
16824 - local_flush_tlb();
16825 - sync_core();
16826 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16827 - that causes hangs on some VIA CPUs. */
16828 + text_poke_early(addr, opcode, len);
16829 for (i = 0; i < len; i++)
16830 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16831 - local_irq_restore(flags);
16832 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16833 return addr;
16834 }
16835
16836 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16837 index 904611b..004dde6 100644
16838 --- a/arch/x86/kernel/apic/apic.c
16839 +++ b/arch/x86/kernel/apic/apic.c
16840 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16841 /*
16842 * Debug level, exported for io_apic.c
16843 */
16844 -unsigned int apic_verbosity;
16845 +int apic_verbosity;
16846
16847 int pic_mode;
16848
16849 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16850 apic_write(APIC_ESR, 0);
16851 v1 = apic_read(APIC_ESR);
16852 ack_APIC_irq();
16853 - atomic_inc(&irq_err_count);
16854 + atomic_inc_unchecked(&irq_err_count);
16855
16856 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16857 smp_processor_id(), v0 , v1);
16858 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16859 index 00c77cf..2dc6a2d 100644
16860 --- a/arch/x86/kernel/apic/apic_flat_64.c
16861 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16862 @@ -157,7 +157,7 @@ static int flat_probe(void)
16863 return 1;
16864 }
16865
16866 -static struct apic apic_flat = {
16867 +static struct apic apic_flat __read_only = {
16868 .name = "flat",
16869 .probe = flat_probe,
16870 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16871 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16872 return 0;
16873 }
16874
16875 -static struct apic apic_physflat = {
16876 +static struct apic apic_physflat __read_only = {
16877
16878 .name = "physical flat",
16879 .probe = physflat_probe,
16880 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16881 index e145f28..2752888 100644
16882 --- a/arch/x86/kernel/apic/apic_noop.c
16883 +++ b/arch/x86/kernel/apic/apic_noop.c
16884 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16885 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16886 }
16887
16888 -struct apic apic_noop = {
16889 +struct apic apic_noop __read_only = {
16890 .name = "noop",
16891 .probe = noop_probe,
16892 .acpi_madt_oem_check = NULL,
16893 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16894 index d50e364..543bee3 100644
16895 --- a/arch/x86/kernel/apic/bigsmp_32.c
16896 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16897 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16898 return dmi_bigsmp;
16899 }
16900
16901 -static struct apic apic_bigsmp = {
16902 +static struct apic apic_bigsmp __read_only = {
16903
16904 .name = "bigsmp",
16905 .probe = probe_bigsmp,
16906 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16907 index 0874799..a7a7892 100644
16908 --- a/arch/x86/kernel/apic/es7000_32.c
16909 +++ b/arch/x86/kernel/apic/es7000_32.c
16910 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16911 return ret && es7000_apic_is_cluster();
16912 }
16913
16914 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16915 -static struct apic __refdata apic_es7000_cluster = {
16916 +static struct apic apic_es7000_cluster __read_only = {
16917
16918 .name = "es7000",
16919 .probe = probe_es7000,
16920 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16921 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16922 };
16923
16924 -static struct apic __refdata apic_es7000 = {
16925 +static struct apic apic_es7000 __read_only = {
16926
16927 .name = "es7000",
16928 .probe = probe_es7000,
16929 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16930 index 9ed796c..e930fe4 100644
16931 --- a/arch/x86/kernel/apic/io_apic.c
16932 +++ b/arch/x86/kernel/apic/io_apic.c
16933 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16934 }
16935 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16936
16937 -void lock_vector_lock(void)
16938 +void lock_vector_lock(void) __acquires(vector_lock)
16939 {
16940 /* Used to the online set of cpus does not change
16941 * during assign_irq_vector.
16942 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16943 raw_spin_lock(&vector_lock);
16944 }
16945
16946 -void unlock_vector_lock(void)
16947 +void unlock_vector_lock(void) __releases(vector_lock)
16948 {
16949 raw_spin_unlock(&vector_lock);
16950 }
16951 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16952 ack_APIC_irq();
16953 }
16954
16955 -atomic_t irq_mis_count;
16956 +atomic_unchecked_t irq_mis_count;
16957
16958 #ifdef CONFIG_GENERIC_PENDING_IRQ
16959 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16960 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16961 * at the cpu.
16962 */
16963 if (!(v & (1 << (i & 0x1f)))) {
16964 - atomic_inc(&irq_mis_count);
16965 + atomic_inc_unchecked(&irq_mis_count);
16966
16967 eoi_ioapic_irq(irq, cfg);
16968 }
16969 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16970 index d661ee9..791fd33 100644
16971 --- a/arch/x86/kernel/apic/numaq_32.c
16972 +++ b/arch/x86/kernel/apic/numaq_32.c
16973 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16974 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16975 }
16976
16977 -/* Use __refdata to keep false positive warning calm. */
16978 -static struct apic __refdata apic_numaq = {
16979 +static struct apic apic_numaq __read_only = {
16980
16981 .name = "NUMAQ",
16982 .probe = probe_numaq,
16983 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16984 index eb35ef9..f184a21 100644
16985 --- a/arch/x86/kernel/apic/probe_32.c
16986 +++ b/arch/x86/kernel/apic/probe_32.c
16987 @@ -72,7 +72,7 @@ static int probe_default(void)
16988 return 1;
16989 }
16990
16991 -static struct apic apic_default = {
16992 +static struct apic apic_default __read_only = {
16993
16994 .name = "default",
16995 .probe = probe_default,
16996 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16997 index 77c95c0..434f8a4 100644
16998 --- a/arch/x86/kernel/apic/summit_32.c
16999 +++ b/arch/x86/kernel/apic/summit_32.c
17000 @@ -486,7 +486,7 @@ void setup_summit(void)
17001 }
17002 #endif
17003
17004 -static struct apic apic_summit = {
17005 +static struct apic apic_summit __read_only = {
17006
17007 .name = "summit",
17008 .probe = probe_summit,
17009 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17010 index c88baa4..757aee1 100644
17011 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17012 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17013 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17014 return notifier_from_errno(err);
17015 }
17016
17017 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17018 +static struct notifier_block x2apic_cpu_notifier = {
17019 .notifier_call = update_clusterinfo,
17020 };
17021
17022 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17023 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17024 }
17025
17026 -static struct apic apic_x2apic_cluster = {
17027 +static struct apic apic_x2apic_cluster __read_only = {
17028
17029 .name = "cluster x2apic",
17030 .probe = x2apic_cluster_probe,
17031 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17032 index 562a76d..a003c0f 100644
17033 --- a/arch/x86/kernel/apic/x2apic_phys.c
17034 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17035 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17036 return apic == &apic_x2apic_phys;
17037 }
17038
17039 -static struct apic apic_x2apic_phys = {
17040 +static struct apic apic_x2apic_phys __read_only = {
17041
17042 .name = "physical x2apic",
17043 .probe = x2apic_phys_probe,
17044 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17045 index 794f6eb..67e1db2 100644
17046 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17047 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17048 @@ -342,7 +342,7 @@ static int uv_probe(void)
17049 return apic == &apic_x2apic_uv_x;
17050 }
17051
17052 -static struct apic __refdata apic_x2apic_uv_x = {
17053 +static struct apic apic_x2apic_uv_x __read_only = {
17054
17055 .name = "UV large system",
17056 .probe = uv_probe,
17057 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17058 index 53a4e27..038760a 100644
17059 --- a/arch/x86/kernel/apm_32.c
17060 +++ b/arch/x86/kernel/apm_32.c
17061 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
17062 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17063 * even though they are called in protected mode.
17064 */
17065 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17066 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17067 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17068
17069 static const char driver_version[] = "1.16ac"; /* no spaces */
17070 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
17071 BUG_ON(cpu != 0);
17072 gdt = get_cpu_gdt_table(cpu);
17073 save_desc_40 = gdt[0x40 / 8];
17074 +
17075 + pax_open_kernel();
17076 gdt[0x40 / 8] = bad_bios_desc;
17077 + pax_close_kernel();
17078
17079 apm_irq_save(flags);
17080 APM_DO_SAVE_SEGS;
17081 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
17082 &call->esi);
17083 APM_DO_RESTORE_SEGS;
17084 apm_irq_restore(flags);
17085 +
17086 + pax_open_kernel();
17087 gdt[0x40 / 8] = save_desc_40;
17088 + pax_close_kernel();
17089 +
17090 put_cpu();
17091
17092 return call->eax & 0xff;
17093 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
17094 BUG_ON(cpu != 0);
17095 gdt = get_cpu_gdt_table(cpu);
17096 save_desc_40 = gdt[0x40 / 8];
17097 +
17098 + pax_open_kernel();
17099 gdt[0x40 / 8] = bad_bios_desc;
17100 + pax_close_kernel();
17101
17102 apm_irq_save(flags);
17103 APM_DO_SAVE_SEGS;
17104 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
17105 &call->eax);
17106 APM_DO_RESTORE_SEGS;
17107 apm_irq_restore(flags);
17108 +
17109 + pax_open_kernel();
17110 gdt[0x40 / 8] = save_desc_40;
17111 + pax_close_kernel();
17112 +
17113 put_cpu();
17114 return error;
17115 }
17116 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
17117 * code to that CPU.
17118 */
17119 gdt = get_cpu_gdt_table(0);
17120 +
17121 + pax_open_kernel();
17122 set_desc_base(&gdt[APM_CS >> 3],
17123 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17124 set_desc_base(&gdt[APM_CS_16 >> 3],
17125 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17126 set_desc_base(&gdt[APM_DS >> 3],
17127 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17128 + pax_close_kernel();
17129
17130 proc_create("apm", 0, NULL, &apm_file_ops);
17131
17132 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17133 index 2861082..6d4718e 100644
17134 --- a/arch/x86/kernel/asm-offsets.c
17135 +++ b/arch/x86/kernel/asm-offsets.c
17136 @@ -33,6 +33,8 @@ void common(void) {
17137 OFFSET(TI_status, thread_info, status);
17138 OFFSET(TI_addr_limit, thread_info, addr_limit);
17139 OFFSET(TI_preempt_count, thread_info, preempt_count);
17140 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17141 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17142
17143 BLANK();
17144 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17145 @@ -53,8 +55,26 @@ void common(void) {
17146 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17147 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17148 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17149 +
17150 +#ifdef CONFIG_PAX_KERNEXEC
17151 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17152 #endif
17153
17154 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17155 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17156 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17157 +#ifdef CONFIG_X86_64
17158 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17159 +#endif
17160 +#endif
17161 +
17162 +#endif
17163 +
17164 + BLANK();
17165 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17166 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17167 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17168 +
17169 #ifdef CONFIG_XEN
17170 BLANK();
17171 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17172 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17173 index e7c798b..2b2019b 100644
17174 --- a/arch/x86/kernel/asm-offsets_64.c
17175 +++ b/arch/x86/kernel/asm-offsets_64.c
17176 @@ -77,6 +77,7 @@ int main(void)
17177 BLANK();
17178 #undef ENTRY
17179
17180 + DEFINE(TSS_size, sizeof(struct tss_struct));
17181 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17182 BLANK();
17183
17184 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17185 index b0684e4..22ccfd7 100644
17186 --- a/arch/x86/kernel/cpu/Makefile
17187 +++ b/arch/x86/kernel/cpu/Makefile
17188 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17189 CFLAGS_REMOVE_perf_event.o = -pg
17190 endif
17191
17192 -# Make sure load_percpu_segment has no stackprotector
17193 -nostackp := $(call cc-option, -fno-stack-protector)
17194 -CFLAGS_common.o := $(nostackp)
17195 -
17196 obj-y := intel_cacheinfo.o scattered.o topology.o
17197 obj-y += proc.o capflags.o powerflags.o common.o
17198 obj-y += rdrand.o
17199 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17200 index 5013a48..0782c53 100644
17201 --- a/arch/x86/kernel/cpu/amd.c
17202 +++ b/arch/x86/kernel/cpu/amd.c
17203 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17204 unsigned int size)
17205 {
17206 /* AMD errata T13 (order #21922) */
17207 - if ((c->x86 == 6)) {
17208 + if (c->x86 == 6) {
17209 /* Duron Rev A0 */
17210 if (c->x86_model == 3 && c->x86_mask == 0)
17211 size = 64;
17212 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17213 index 22018f7..bc6f5e3 100644
17214 --- a/arch/x86/kernel/cpu/common.c
17215 +++ b/arch/x86/kernel/cpu/common.c
17216 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17217
17218 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17219
17220 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17221 -#ifdef CONFIG_X86_64
17222 - /*
17223 - * We need valid kernel segments for data and code in long mode too
17224 - * IRET will check the segment types kkeil 2000/10/28
17225 - * Also sysret mandates a special GDT layout
17226 - *
17227 - * TLS descriptors are currently at a different place compared to i386.
17228 - * Hopefully nobody expects them at a fixed place (Wine?)
17229 - */
17230 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17231 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17232 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17233 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17234 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17235 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17236 -#else
17237 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17238 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17239 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17240 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17241 - /*
17242 - * Segments used for calling PnP BIOS have byte granularity.
17243 - * They code segments and data segments have fixed 64k limits,
17244 - * the transfer segment sizes are set at run time.
17245 - */
17246 - /* 32-bit code */
17247 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17248 - /* 16-bit code */
17249 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17250 - /* 16-bit data */
17251 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17252 - /* 16-bit data */
17253 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17254 - /* 16-bit data */
17255 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17256 - /*
17257 - * The APM segments have byte granularity and their bases
17258 - * are set at run time. All have 64k limits.
17259 - */
17260 - /* 32-bit code */
17261 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17262 - /* 16-bit code */
17263 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17264 - /* data */
17265 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17266 -
17267 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17268 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17269 - GDT_STACK_CANARY_INIT
17270 -#endif
17271 -} };
17272 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17273 -
17274 static int __init x86_xsave_setup(char *s)
17275 {
17276 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17277 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17278 {
17279 struct desc_ptr gdt_descr;
17280
17281 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17282 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17283 gdt_descr.size = GDT_SIZE - 1;
17284 load_gdt(&gdt_descr);
17285 /* Reload the per-cpu base */
17286 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17287 /* Filter out anything that depends on CPUID levels we don't have */
17288 filter_cpuid_features(c, true);
17289
17290 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17291 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17292 +#endif
17293 +
17294 /* If the model name is still unset, do table lookup. */
17295 if (!c->x86_model_id[0]) {
17296 const char *p;
17297 @@ -1069,10 +1019,12 @@ static __init int setup_disablecpuid(char *arg)
17298 }
17299 __setup("clearcpuid=", setup_disablecpuid);
17300
17301 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17302 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17303 +
17304 #ifdef CONFIG_X86_64
17305 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17306 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17307 - (unsigned long) nmi_idt_table };
17308 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17309
17310 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17311 irq_stack_union) __aligned(PAGE_SIZE);
17312 @@ -1086,7 +1038,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17313 EXPORT_PER_CPU_SYMBOL(current_task);
17314
17315 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17316 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17317 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17318 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17319
17320 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17321 @@ -1231,7 +1183,7 @@ void __cpuinit cpu_init(void)
17322 load_ucode_ap();
17323
17324 cpu = stack_smp_processor_id();
17325 - t = &per_cpu(init_tss, cpu);
17326 + t = init_tss + cpu;
17327 oist = &per_cpu(orig_ist, cpu);
17328
17329 #ifdef CONFIG_NUMA
17330 @@ -1257,7 +1209,7 @@ void __cpuinit cpu_init(void)
17331 switch_to_new_gdt(cpu);
17332 loadsegment(fs, 0);
17333
17334 - load_idt((const struct desc_ptr *)&idt_descr);
17335 + load_idt(&idt_descr);
17336
17337 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17338 syscall_init();
17339 @@ -1266,7 +1218,6 @@ void __cpuinit cpu_init(void)
17340 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17341 barrier();
17342
17343 - x86_configure_nx();
17344 enable_x2apic();
17345
17346 /*
17347 @@ -1318,7 +1269,7 @@ void __cpuinit cpu_init(void)
17348 {
17349 int cpu = smp_processor_id();
17350 struct task_struct *curr = current;
17351 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17352 + struct tss_struct *t = init_tss + cpu;
17353 struct thread_struct *thread = &curr->thread;
17354
17355 show_ucode_info_early();
17356 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17357 index 7c6f7d5..8cac382 100644
17358 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17359 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17360 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17361 };
17362
17363 #ifdef CONFIG_AMD_NB
17364 +static struct attribute *default_attrs_amd_nb[] = {
17365 + &type.attr,
17366 + &level.attr,
17367 + &coherency_line_size.attr,
17368 + &physical_line_partition.attr,
17369 + &ways_of_associativity.attr,
17370 + &number_of_sets.attr,
17371 + &size.attr,
17372 + &shared_cpu_map.attr,
17373 + &shared_cpu_list.attr,
17374 + NULL,
17375 + NULL,
17376 + NULL,
17377 + NULL
17378 +};
17379 +
17380 static struct attribute ** __cpuinit amd_l3_attrs(void)
17381 {
17382 static struct attribute **attrs;
17383 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17384
17385 n = ARRAY_SIZE(default_attrs);
17386
17387 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17388 - n += 2;
17389 -
17390 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17391 - n += 1;
17392 -
17393 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17394 - if (attrs == NULL)
17395 - return attrs = default_attrs;
17396 -
17397 - for (n = 0; default_attrs[n]; n++)
17398 - attrs[n] = default_attrs[n];
17399 + attrs = default_attrs_amd_nb;
17400
17401 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17402 attrs[n++] = &cache_disable_0.attr;
17403 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17404 .default_attrs = default_attrs,
17405 };
17406
17407 +#ifdef CONFIG_AMD_NB
17408 +static struct kobj_type ktype_cache_amd_nb = {
17409 + .sysfs_ops = &sysfs_ops,
17410 + .default_attrs = default_attrs_amd_nb,
17411 +};
17412 +#endif
17413 +
17414 static struct kobj_type ktype_percpu_entry = {
17415 .sysfs_ops = &sysfs_ops,
17416 };
17417 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17418 return retval;
17419 }
17420
17421 +#ifdef CONFIG_AMD_NB
17422 + amd_l3_attrs();
17423 +#endif
17424 +
17425 for (i = 0; i < num_cache_leaves; i++) {
17426 + struct kobj_type *ktype;
17427 +
17428 this_object = INDEX_KOBJECT_PTR(cpu, i);
17429 this_object->cpu = cpu;
17430 this_object->index = i;
17431
17432 this_leaf = CPUID4_INFO_IDX(cpu, i);
17433
17434 - ktype_cache.default_attrs = default_attrs;
17435 + ktype = &ktype_cache;
17436 #ifdef CONFIG_AMD_NB
17437 if (this_leaf->base.nb)
17438 - ktype_cache.default_attrs = amd_l3_attrs();
17439 + ktype = &ktype_cache_amd_nb;
17440 #endif
17441 retval = kobject_init_and_add(&(this_object->kobj),
17442 - &ktype_cache,
17443 + ktype,
17444 per_cpu(ici_cache_kobject, cpu),
17445 "index%1lu", i);
17446 if (unlikely(retval)) {
17447 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17448 return NOTIFY_OK;
17449 }
17450
17451 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17452 +static struct notifier_block cacheinfo_cpu_notifier = {
17453 .notifier_call = cacheinfo_cpu_callback,
17454 };
17455
17456 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17457 index 9239504..b2471ce 100644
17458 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17459 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17460 @@ -45,6 +45,7 @@
17461 #include <asm/processor.h>
17462 #include <asm/mce.h>
17463 #include <asm/msr.h>
17464 +#include <asm/local.h>
17465
17466 #include "mce-internal.h"
17467
17468 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17469 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17470 m->cs, m->ip);
17471
17472 - if (m->cs == __KERNEL_CS)
17473 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17474 print_symbol("{%s}", m->ip);
17475 pr_cont("\n");
17476 }
17477 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17478
17479 #define PANIC_TIMEOUT 5 /* 5 seconds */
17480
17481 -static atomic_t mce_paniced;
17482 +static atomic_unchecked_t mce_paniced;
17483
17484 static int fake_panic;
17485 -static atomic_t mce_fake_paniced;
17486 +static atomic_unchecked_t mce_fake_paniced;
17487
17488 /* Panic in progress. Enable interrupts and wait for final IPI */
17489 static void wait_for_panic(void)
17490 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17491 /*
17492 * Make sure only one CPU runs in machine check panic
17493 */
17494 - if (atomic_inc_return(&mce_paniced) > 1)
17495 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17496 wait_for_panic();
17497 barrier();
17498
17499 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17500 console_verbose();
17501 } else {
17502 /* Don't log too much for fake panic */
17503 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17504 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17505 return;
17506 }
17507 /* First print corrected ones that are still unlogged */
17508 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17509 if (!fake_panic) {
17510 if (panic_timeout == 0)
17511 panic_timeout = mca_cfg.panic_timeout;
17512 - panic(msg);
17513 + panic("%s", msg);
17514 } else
17515 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17516 }
17517 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17518 * might have been modified by someone else.
17519 */
17520 rmb();
17521 - if (atomic_read(&mce_paniced))
17522 + if (atomic_read_unchecked(&mce_paniced))
17523 wait_for_panic();
17524 if (!mca_cfg.monarch_timeout)
17525 goto out;
17526 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17527 }
17528
17529 /* Call the installed machine check handler for this CPU setup. */
17530 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17531 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17532 unexpected_machine_check;
17533
17534 /*
17535 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17536 return;
17537 }
17538
17539 + pax_open_kernel();
17540 machine_check_vector = do_machine_check;
17541 + pax_close_kernel();
17542
17543 __mcheck_cpu_init_generic();
17544 __mcheck_cpu_init_vendor(c);
17545 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17546 */
17547
17548 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17549 -static int mce_chrdev_open_count; /* #times opened */
17550 +static local_t mce_chrdev_open_count; /* #times opened */
17551 static int mce_chrdev_open_exclu; /* already open exclusive? */
17552
17553 static int mce_chrdev_open(struct inode *inode, struct file *file)
17554 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17555 spin_lock(&mce_chrdev_state_lock);
17556
17557 if (mce_chrdev_open_exclu ||
17558 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17559 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17560 spin_unlock(&mce_chrdev_state_lock);
17561
17562 return -EBUSY;
17563 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17564
17565 if (file->f_flags & O_EXCL)
17566 mce_chrdev_open_exclu = 1;
17567 - mce_chrdev_open_count++;
17568 + local_inc(&mce_chrdev_open_count);
17569
17570 spin_unlock(&mce_chrdev_state_lock);
17571
17572 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17573 {
17574 spin_lock(&mce_chrdev_state_lock);
17575
17576 - mce_chrdev_open_count--;
17577 + local_dec(&mce_chrdev_open_count);
17578 mce_chrdev_open_exclu = 0;
17579
17580 spin_unlock(&mce_chrdev_state_lock);
17581 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17582 return NOTIFY_OK;
17583 }
17584
17585 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17586 +static struct notifier_block mce_cpu_notifier = {
17587 .notifier_call = mce_cpu_callback,
17588 };
17589
17590 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17591
17592 for (i = 0; i < mca_cfg.banks; i++) {
17593 struct mce_bank *b = &mce_banks[i];
17594 - struct device_attribute *a = &b->attr;
17595 + device_attribute_no_const *a = &b->attr;
17596
17597 sysfs_attr_init(&a->attr);
17598 a->attr.name = b->attrname;
17599 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17600 static void mce_reset(void)
17601 {
17602 cpu_missing = 0;
17603 - atomic_set(&mce_fake_paniced, 0);
17604 + atomic_set_unchecked(&mce_fake_paniced, 0);
17605 atomic_set(&mce_executing, 0);
17606 atomic_set(&mce_callin, 0);
17607 atomic_set(&global_nwo, 0);
17608 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17609 index 1c044b1..37a2a43 100644
17610 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17611 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17612 @@ -11,6 +11,7 @@
17613 #include <asm/processor.h>
17614 #include <asm/mce.h>
17615 #include <asm/msr.h>
17616 +#include <asm/pgtable.h>
17617
17618 /* By default disabled */
17619 int mce_p5_enabled __read_mostly;
17620 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17621 if (!cpu_has(c, X86_FEATURE_MCE))
17622 return;
17623
17624 + pax_open_kernel();
17625 machine_check_vector = pentium_machine_check;
17626 + pax_close_kernel();
17627 /* Make sure the vector pointer is visible before we enable MCEs: */
17628 wmb();
17629
17630 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17631 index 47a1870..8c019a7 100644
17632 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17633 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17634 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17635 return notifier_from_errno(err);
17636 }
17637
17638 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17639 +static struct notifier_block thermal_throttle_cpu_notifier =
17640 {
17641 .notifier_call = thermal_throttle_cpu_callback,
17642 };
17643 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17644 index e9a701a..35317d6 100644
17645 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17646 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17647 @@ -10,6 +10,7 @@
17648 #include <asm/processor.h>
17649 #include <asm/mce.h>
17650 #include <asm/msr.h>
17651 +#include <asm/pgtable.h>
17652
17653 /* Machine check handler for WinChip C6: */
17654 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17655 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17656 {
17657 u32 lo, hi;
17658
17659 + pax_open_kernel();
17660 machine_check_vector = winchip_machine_check;
17661 + pax_close_kernel();
17662 /* Make sure the vector pointer is visible before we enable MCEs: */
17663 wmb();
17664
17665 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17666 index ca22b73..9987afe 100644
17667 --- a/arch/x86/kernel/cpu/mtrr/main.c
17668 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17669 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17670 u64 size_or_mask, size_and_mask;
17671 static bool mtrr_aps_delayed_init;
17672
17673 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17674 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17675
17676 const struct mtrr_ops *mtrr_if;
17677
17678 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17679 index df5e41f..816c719 100644
17680 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17681 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17682 @@ -25,7 +25,7 @@ struct mtrr_ops {
17683 int (*validate_add_page)(unsigned long base, unsigned long size,
17684 unsigned int type);
17685 int (*have_wrcomb)(void);
17686 -};
17687 +} __do_const;
17688
17689 extern int generic_get_free_region(unsigned long base, unsigned long size,
17690 int replace_reg);
17691 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17692 index 1025f3c..824f677 100644
17693 --- a/arch/x86/kernel/cpu/perf_event.c
17694 +++ b/arch/x86/kernel/cpu/perf_event.c
17695 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
17696 pr_info("no hardware sampling interrupt available.\n");
17697 }
17698
17699 -static struct attribute_group x86_pmu_format_group = {
17700 +static attribute_group_no_const x86_pmu_format_group = {
17701 .name = "format",
17702 .attrs = NULL,
17703 };
17704 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
17705 NULL,
17706 };
17707
17708 -static struct attribute_group x86_pmu_events_group = {
17709 +static attribute_group_no_const x86_pmu_events_group = {
17710 .name = "events",
17711 .attrs = events_attr,
17712 };
17713 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
17714 if (idx > GDT_ENTRIES)
17715 return 0;
17716
17717 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17718 + desc = get_cpu_gdt_table(smp_processor_id());
17719 }
17720
17721 return get_desc_base(desc + idx);
17722 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17723 break;
17724
17725 perf_callchain_store(entry, frame.return_address);
17726 - fp = frame.next_frame;
17727 + fp = (const void __force_user *)frame.next_frame;
17728 }
17729 }
17730
17731 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17732 index a9e2207..d70c83a 100644
17733 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17734 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17735 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
17736 * v2 and above have a perf capabilities MSR
17737 */
17738 if (version > 1) {
17739 - u64 capabilities;
17740 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17741
17742 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17743 - x86_pmu.intel_cap.capabilities = capabilities;
17744 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17745 + x86_pmu.intel_cap.capabilities = capabilities;
17746 }
17747
17748 intel_ds_init();
17749 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17750 index 52441a2..f94fae8 100644
17751 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17752 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17753 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17754 static int __init uncore_type_init(struct intel_uncore_type *type)
17755 {
17756 struct intel_uncore_pmu *pmus;
17757 - struct attribute_group *attr_group;
17758 + attribute_group_no_const *attr_group;
17759 struct attribute **attrs;
17760 int i, j;
17761
17762 @@ -3518,7 +3518,7 @@ static int
17763 return NOTIFY_OK;
17764 }
17765
17766 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17767 +static struct notifier_block uncore_cpu_nb = {
17768 .notifier_call = uncore_cpu_notifier,
17769 /*
17770 * to migrate uncore events, our notifier should be executed
17771 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17772 index f952891..4722ad4 100644
17773 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17774 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17775 @@ -488,7 +488,7 @@ struct intel_uncore_box {
17776 struct uncore_event_desc {
17777 struct kobj_attribute attr;
17778 const char *config;
17779 -};
17780 +} __do_const;
17781
17782 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17783 { \
17784 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17785 index 1e4dbcf..b9a34c2 100644
17786 --- a/arch/x86/kernel/cpuid.c
17787 +++ b/arch/x86/kernel/cpuid.c
17788 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17789 return notifier_from_errno(err);
17790 }
17791
17792 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17793 +static struct notifier_block cpuid_class_cpu_notifier =
17794 {
17795 .notifier_call = cpuid_class_cpu_callback,
17796 };
17797 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17798 index 74467fe..18793d5 100644
17799 --- a/arch/x86/kernel/crash.c
17800 +++ b/arch/x86/kernel/crash.c
17801 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17802 {
17803 #ifdef CONFIG_X86_32
17804 struct pt_regs fixed_regs;
17805 -#endif
17806
17807 -#ifdef CONFIG_X86_32
17808 - if (!user_mode_vm(regs)) {
17809 + if (!user_mode(regs)) {
17810 crash_fixup_ss_esp(&fixed_regs, regs);
17811 regs = &fixed_regs;
17812 }
17813 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17814 index afa64ad..dce67dd 100644
17815 --- a/arch/x86/kernel/crash_dump_64.c
17816 +++ b/arch/x86/kernel/crash_dump_64.c
17817 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17818 return -ENOMEM;
17819
17820 if (userbuf) {
17821 - if (copy_to_user(buf, vaddr + offset, csize)) {
17822 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17823 iounmap(vaddr);
17824 return -EFAULT;
17825 }
17826 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17827 index 155a13f..1672b9b 100644
17828 --- a/arch/x86/kernel/doublefault_32.c
17829 +++ b/arch/x86/kernel/doublefault_32.c
17830 @@ -11,7 +11,7 @@
17831
17832 #define DOUBLEFAULT_STACKSIZE (1024)
17833 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17834 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17835 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17836
17837 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17838
17839 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17840 unsigned long gdt, tss;
17841
17842 native_store_gdt(&gdt_desc);
17843 - gdt = gdt_desc.address;
17844 + gdt = (unsigned long)gdt_desc.address;
17845
17846 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17847
17848 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17849 /* 0x2 bit is always set */
17850 .flags = X86_EFLAGS_SF | 0x2,
17851 .sp = STACK_START,
17852 - .es = __USER_DS,
17853 + .es = __KERNEL_DS,
17854 .cs = __KERNEL_CS,
17855 .ss = __KERNEL_DS,
17856 - .ds = __USER_DS,
17857 + .ds = __KERNEL_DS,
17858 .fs = __KERNEL_PERCPU,
17859
17860 .__cr3 = __pa_nodebug(swapper_pg_dir),
17861 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17862 index deb6421..76bbc12 100644
17863 --- a/arch/x86/kernel/dumpstack.c
17864 +++ b/arch/x86/kernel/dumpstack.c
17865 @@ -2,6 +2,9 @@
17866 * Copyright (C) 1991, 1992 Linus Torvalds
17867 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17868 */
17869 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17870 +#define __INCLUDED_BY_HIDESYM 1
17871 +#endif
17872 #include <linux/kallsyms.h>
17873 #include <linux/kprobes.h>
17874 #include <linux/uaccess.h>
17875 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17876 static void
17877 print_ftrace_graph_addr(unsigned long addr, void *data,
17878 const struct stacktrace_ops *ops,
17879 - struct thread_info *tinfo, int *graph)
17880 + struct task_struct *task, int *graph)
17881 {
17882 - struct task_struct *task;
17883 unsigned long ret_addr;
17884 int index;
17885
17886 if (addr != (unsigned long)return_to_handler)
17887 return;
17888
17889 - task = tinfo->task;
17890 index = task->curr_ret_stack;
17891
17892 if (!task->ret_stack || index < *graph)
17893 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17894 static inline void
17895 print_ftrace_graph_addr(unsigned long addr, void *data,
17896 const struct stacktrace_ops *ops,
17897 - struct thread_info *tinfo, int *graph)
17898 + struct task_struct *task, int *graph)
17899 { }
17900 #endif
17901
17902 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17903 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17904 */
17905
17906 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17907 - void *p, unsigned int size, void *end)
17908 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17909 {
17910 - void *t = tinfo;
17911 if (end) {
17912 if (p < end && p >= (end-THREAD_SIZE))
17913 return 1;
17914 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17915 }
17916
17917 unsigned long
17918 -print_context_stack(struct thread_info *tinfo,
17919 +print_context_stack(struct task_struct *task, void *stack_start,
17920 unsigned long *stack, unsigned long bp,
17921 const struct stacktrace_ops *ops, void *data,
17922 unsigned long *end, int *graph)
17923 {
17924 struct stack_frame *frame = (struct stack_frame *)bp;
17925
17926 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17927 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17928 unsigned long addr;
17929
17930 addr = *stack;
17931 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17932 } else {
17933 ops->address(data, addr, 0);
17934 }
17935 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17936 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17937 }
17938 stack++;
17939 }
17940 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17941 EXPORT_SYMBOL_GPL(print_context_stack);
17942
17943 unsigned long
17944 -print_context_stack_bp(struct thread_info *tinfo,
17945 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17946 unsigned long *stack, unsigned long bp,
17947 const struct stacktrace_ops *ops, void *data,
17948 unsigned long *end, int *graph)
17949 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17950 struct stack_frame *frame = (struct stack_frame *)bp;
17951 unsigned long *ret_addr = &frame->return_address;
17952
17953 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17954 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17955 unsigned long addr = *ret_addr;
17956
17957 if (!__kernel_text_address(addr))
17958 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17959 ops->address(data, addr, 1);
17960 frame = frame->next_frame;
17961 ret_addr = &frame->return_address;
17962 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17963 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17964 }
17965
17966 return (unsigned long)frame;
17967 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
17968 static void print_trace_address(void *data, unsigned long addr, int reliable)
17969 {
17970 touch_nmi_watchdog();
17971 - printk(data);
17972 + printk("%s", (char *)data);
17973 printk_address(addr, reliable);
17974 }
17975
17976 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
17977 }
17978 EXPORT_SYMBOL_GPL(oops_begin);
17979
17980 +extern void gr_handle_kernel_exploit(void);
17981 +
17982 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17983 {
17984 if (regs && kexec_should_crash(current))
17985 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17986 panic("Fatal exception in interrupt");
17987 if (panic_on_oops)
17988 panic("Fatal exception");
17989 - do_exit(signr);
17990 +
17991 + gr_handle_kernel_exploit();
17992 +
17993 + do_group_exit(signr);
17994 }
17995
17996 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17997 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17998 print_modules();
17999 show_regs(regs);
18000 #ifdef CONFIG_X86_32
18001 - if (user_mode_vm(regs)) {
18002 + if (user_mode(regs)) {
18003 sp = regs->sp;
18004 ss = regs->ss & 0xffff;
18005 } else {
18006 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18007 unsigned long flags = oops_begin();
18008 int sig = SIGSEGV;
18009
18010 - if (!user_mode_vm(regs))
18011 + if (!user_mode(regs))
18012 report_bug(regs->ip, regs);
18013
18014 if (__die(str, regs, err))
18015 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18016 index f2a1770..540657f 100644
18017 --- a/arch/x86/kernel/dumpstack_32.c
18018 +++ b/arch/x86/kernel/dumpstack_32.c
18019 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18020 bp = stack_frame(task, regs);
18021
18022 for (;;) {
18023 - struct thread_info *context;
18024 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18025
18026 - context = (struct thread_info *)
18027 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18028 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18029 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18030
18031 - stack = (unsigned long *)context->previous_esp;
18032 - if (!stack)
18033 + if (stack_start == task_stack_page(task))
18034 break;
18035 + stack = *(unsigned long **)stack_start;
18036 if (ops->stack(data, "IRQ") < 0)
18037 break;
18038 touch_nmi_watchdog();
18039 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
18040 int i;
18041
18042 show_regs_print_info(KERN_EMERG);
18043 - __show_regs(regs, !user_mode_vm(regs));
18044 + __show_regs(regs, !user_mode(regs));
18045
18046 /*
18047 * When in-kernel, we also print out the stack and code at the
18048 * time of the fault..
18049 */
18050 - if (!user_mode_vm(regs)) {
18051 + if (!user_mode(regs)) {
18052 unsigned int code_prologue = code_bytes * 43 / 64;
18053 unsigned int code_len = code_bytes;
18054 unsigned char c;
18055 u8 *ip;
18056 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18057
18058 pr_emerg("Stack:\n");
18059 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18060
18061 pr_emerg("Code:");
18062
18063 - ip = (u8 *)regs->ip - code_prologue;
18064 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18065 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18066 /* try starting at IP */
18067 - ip = (u8 *)regs->ip;
18068 + ip = (u8 *)regs->ip + cs_base;
18069 code_len = code_len - code_prologue + 1;
18070 }
18071 for (i = 0; i < code_len; i++, ip++) {
18072 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
18073 pr_cont(" Bad EIP value.");
18074 break;
18075 }
18076 - if (ip == (u8 *)regs->ip)
18077 + if (ip == (u8 *)regs->ip + cs_base)
18078 pr_cont(" <%02x>", c);
18079 else
18080 pr_cont(" %02x", c);
18081 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
18082 {
18083 unsigned short ud2;
18084
18085 + ip = ktla_ktva(ip);
18086 if (ip < PAGE_OFFSET)
18087 return 0;
18088 if (probe_kernel_address((unsigned short *)ip, ud2))
18089 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
18090
18091 return ud2 == 0x0b0f;
18092 }
18093 +
18094 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18095 +void pax_check_alloca(unsigned long size)
18096 +{
18097 + unsigned long sp = (unsigned long)&sp, stack_left;
18098 +
18099 + /* all kernel stacks are of the same size */
18100 + stack_left = sp & (THREAD_SIZE - 1);
18101 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18102 +}
18103 +EXPORT_SYMBOL(pax_check_alloca);
18104 +#endif
18105 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18106 index addb207..99635fa 100644
18107 --- a/arch/x86/kernel/dumpstack_64.c
18108 +++ b/arch/x86/kernel/dumpstack_64.c
18109 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18110 unsigned long *irq_stack_end =
18111 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18112 unsigned used = 0;
18113 - struct thread_info *tinfo;
18114 int graph = 0;
18115 unsigned long dummy;
18116 + void *stack_start;
18117
18118 if (!task)
18119 task = current;
18120 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18121 * current stack address. If the stacks consist of nested
18122 * exceptions
18123 */
18124 - tinfo = task_thread_info(task);
18125 for (;;) {
18126 char *id;
18127 unsigned long *estack_end;
18128 +
18129 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18130 &used, &id);
18131
18132 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18133 if (ops->stack(data, id) < 0)
18134 break;
18135
18136 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18137 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18138 data, estack_end, &graph);
18139 ops->stack(data, "<EOE>");
18140 /*
18141 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18142 * second-to-last pointer (index -2 to end) in the
18143 * exception stack:
18144 */
18145 + if ((u16)estack_end[-1] != __KERNEL_DS)
18146 + goto out;
18147 stack = (unsigned long *) estack_end[-2];
18148 continue;
18149 }
18150 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18151 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18152 if (ops->stack(data, "IRQ") < 0)
18153 break;
18154 - bp = ops->walk_stack(tinfo, stack, bp,
18155 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18156 ops, data, irq_stack_end, &graph);
18157 /*
18158 * We link to the next stack (which would be
18159 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18160 /*
18161 * This handles the process stack:
18162 */
18163 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18164 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18165 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18166 +out:
18167 put_cpu();
18168 }
18169 EXPORT_SYMBOL(dump_trace);
18170 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
18171
18172 return ud2 == 0x0b0f;
18173 }
18174 +
18175 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18176 +void pax_check_alloca(unsigned long size)
18177 +{
18178 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18179 + unsigned cpu, used;
18180 + char *id;
18181 +
18182 + /* check the process stack first */
18183 + stack_start = (unsigned long)task_stack_page(current);
18184 + stack_end = stack_start + THREAD_SIZE;
18185 + if (likely(stack_start <= sp && sp < stack_end)) {
18186 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18187 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18188 + return;
18189 + }
18190 +
18191 + cpu = get_cpu();
18192 +
18193 + /* check the irq stacks */
18194 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18195 + stack_start = stack_end - IRQ_STACK_SIZE;
18196 + if (stack_start <= sp && sp < stack_end) {
18197 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18198 + put_cpu();
18199 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18200 + return;
18201 + }
18202 +
18203 + /* check the exception stacks */
18204 + used = 0;
18205 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18206 + stack_start = stack_end - EXCEPTION_STKSZ;
18207 + if (stack_end && stack_start <= sp && sp < stack_end) {
18208 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18209 + put_cpu();
18210 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18211 + return;
18212 + }
18213 +
18214 + put_cpu();
18215 +
18216 + /* unknown stack */
18217 + BUG();
18218 +}
18219 +EXPORT_SYMBOL(pax_check_alloca);
18220 +#endif
18221 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18222 index d32abea..74daf4f 100644
18223 --- a/arch/x86/kernel/e820.c
18224 +++ b/arch/x86/kernel/e820.c
18225 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18226
18227 static void early_panic(char *msg)
18228 {
18229 - early_printk(msg);
18230 - panic(msg);
18231 + early_printk("%s", msg);
18232 + panic("%s", msg);
18233 }
18234
18235 static int userdef __initdata;
18236 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18237 index d15f575..d692043 100644
18238 --- a/arch/x86/kernel/early_printk.c
18239 +++ b/arch/x86/kernel/early_printk.c
18240 @@ -7,6 +7,7 @@
18241 #include <linux/pci_regs.h>
18242 #include <linux/pci_ids.h>
18243 #include <linux/errno.h>
18244 +#include <linux/sched.h>
18245 #include <asm/io.h>
18246 #include <asm/processor.h>
18247 #include <asm/fcntl.h>
18248 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18249 index 8f3e2de..caecc4e 100644
18250 --- a/arch/x86/kernel/entry_32.S
18251 +++ b/arch/x86/kernel/entry_32.S
18252 @@ -177,13 +177,153 @@
18253 /*CFI_REL_OFFSET gs, PT_GS*/
18254 .endm
18255 .macro SET_KERNEL_GS reg
18256 +
18257 +#ifdef CONFIG_CC_STACKPROTECTOR
18258 movl $(__KERNEL_STACK_CANARY), \reg
18259 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18260 + movl $(__USER_DS), \reg
18261 +#else
18262 + xorl \reg, \reg
18263 +#endif
18264 +
18265 movl \reg, %gs
18266 .endm
18267
18268 #endif /* CONFIG_X86_32_LAZY_GS */
18269
18270 -.macro SAVE_ALL
18271 +.macro pax_enter_kernel
18272 +#ifdef CONFIG_PAX_KERNEXEC
18273 + call pax_enter_kernel
18274 +#endif
18275 +.endm
18276 +
18277 +.macro pax_exit_kernel
18278 +#ifdef CONFIG_PAX_KERNEXEC
18279 + call pax_exit_kernel
18280 +#endif
18281 +.endm
18282 +
18283 +#ifdef CONFIG_PAX_KERNEXEC
18284 +ENTRY(pax_enter_kernel)
18285 +#ifdef CONFIG_PARAVIRT
18286 + pushl %eax
18287 + pushl %ecx
18288 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18289 + mov %eax, %esi
18290 +#else
18291 + mov %cr0, %esi
18292 +#endif
18293 + bts $16, %esi
18294 + jnc 1f
18295 + mov %cs, %esi
18296 + cmp $__KERNEL_CS, %esi
18297 + jz 3f
18298 + ljmp $__KERNEL_CS, $3f
18299 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18300 +2:
18301 +#ifdef CONFIG_PARAVIRT
18302 + mov %esi, %eax
18303 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18304 +#else
18305 + mov %esi, %cr0
18306 +#endif
18307 +3:
18308 +#ifdef CONFIG_PARAVIRT
18309 + popl %ecx
18310 + popl %eax
18311 +#endif
18312 + ret
18313 +ENDPROC(pax_enter_kernel)
18314 +
18315 +ENTRY(pax_exit_kernel)
18316 +#ifdef CONFIG_PARAVIRT
18317 + pushl %eax
18318 + pushl %ecx
18319 +#endif
18320 + mov %cs, %esi
18321 + cmp $__KERNEXEC_KERNEL_CS, %esi
18322 + jnz 2f
18323 +#ifdef CONFIG_PARAVIRT
18324 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18325 + mov %eax, %esi
18326 +#else
18327 + mov %cr0, %esi
18328 +#endif
18329 + btr $16, %esi
18330 + ljmp $__KERNEL_CS, $1f
18331 +1:
18332 +#ifdef CONFIG_PARAVIRT
18333 + mov %esi, %eax
18334 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18335 +#else
18336 + mov %esi, %cr0
18337 +#endif
18338 +2:
18339 +#ifdef CONFIG_PARAVIRT
18340 + popl %ecx
18341 + popl %eax
18342 +#endif
18343 + ret
18344 +ENDPROC(pax_exit_kernel)
18345 +#endif
18346 +
18347 + .macro pax_erase_kstack
18348 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18349 + call pax_erase_kstack
18350 +#endif
18351 + .endm
18352 +
18353 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18354 +/*
18355 + * ebp: thread_info
18356 + */
18357 +ENTRY(pax_erase_kstack)
18358 + pushl %edi
18359 + pushl %ecx
18360 + pushl %eax
18361 +
18362 + mov TI_lowest_stack(%ebp), %edi
18363 + mov $-0xBEEF, %eax
18364 + std
18365 +
18366 +1: mov %edi, %ecx
18367 + and $THREAD_SIZE_asm - 1, %ecx
18368 + shr $2, %ecx
18369 + repne scasl
18370 + jecxz 2f
18371 +
18372 + cmp $2*16, %ecx
18373 + jc 2f
18374 +
18375 + mov $2*16, %ecx
18376 + repe scasl
18377 + jecxz 2f
18378 + jne 1b
18379 +
18380 +2: cld
18381 + mov %esp, %ecx
18382 + sub %edi, %ecx
18383 +
18384 + cmp $THREAD_SIZE_asm, %ecx
18385 + jb 3f
18386 + ud2
18387 +3:
18388 +
18389 + shr $2, %ecx
18390 + rep stosl
18391 +
18392 + mov TI_task_thread_sp0(%ebp), %edi
18393 + sub $128, %edi
18394 + mov %edi, TI_lowest_stack(%ebp)
18395 +
18396 + popl %eax
18397 + popl %ecx
18398 + popl %edi
18399 + ret
18400 +ENDPROC(pax_erase_kstack)
18401 +#endif
18402 +
18403 +.macro __SAVE_ALL _DS
18404 cld
18405 PUSH_GS
18406 pushl_cfi %fs
18407 @@ -206,7 +346,7 @@
18408 CFI_REL_OFFSET ecx, 0
18409 pushl_cfi %ebx
18410 CFI_REL_OFFSET ebx, 0
18411 - movl $(__USER_DS), %edx
18412 + movl $\_DS, %edx
18413 movl %edx, %ds
18414 movl %edx, %es
18415 movl $(__KERNEL_PERCPU), %edx
18416 @@ -214,6 +354,15 @@
18417 SET_KERNEL_GS %edx
18418 .endm
18419
18420 +.macro SAVE_ALL
18421 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18422 + __SAVE_ALL __KERNEL_DS
18423 + pax_enter_kernel
18424 +#else
18425 + __SAVE_ALL __USER_DS
18426 +#endif
18427 +.endm
18428 +
18429 .macro RESTORE_INT_REGS
18430 popl_cfi %ebx
18431 CFI_RESTORE ebx
18432 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18433 popfl_cfi
18434 jmp syscall_exit
18435 CFI_ENDPROC
18436 -END(ret_from_fork)
18437 +ENDPROC(ret_from_fork)
18438
18439 ENTRY(ret_from_kernel_thread)
18440 CFI_STARTPROC
18441 @@ -344,7 +493,15 @@ ret_from_intr:
18442 andl $SEGMENT_RPL_MASK, %eax
18443 #endif
18444 cmpl $USER_RPL, %eax
18445 +
18446 +#ifdef CONFIG_PAX_KERNEXEC
18447 + jae resume_userspace
18448 +
18449 + pax_exit_kernel
18450 + jmp resume_kernel
18451 +#else
18452 jb resume_kernel # not returning to v8086 or userspace
18453 +#endif
18454
18455 ENTRY(resume_userspace)
18456 LOCKDEP_SYS_EXIT
18457 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18458 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18459 # int/exception return?
18460 jne work_pending
18461 - jmp restore_all
18462 -END(ret_from_exception)
18463 + jmp restore_all_pax
18464 +ENDPROC(ret_from_exception)
18465
18466 #ifdef CONFIG_PREEMPT
18467 ENTRY(resume_kernel)
18468 @@ -372,7 +529,7 @@ need_resched:
18469 jz restore_all
18470 call preempt_schedule_irq
18471 jmp need_resched
18472 -END(resume_kernel)
18473 +ENDPROC(resume_kernel)
18474 #endif
18475 CFI_ENDPROC
18476 /*
18477 @@ -406,30 +563,45 @@ sysenter_past_esp:
18478 /*CFI_REL_OFFSET cs, 0*/
18479 /*
18480 * Push current_thread_info()->sysenter_return to the stack.
18481 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18482 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18483 */
18484 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18485 + pushl_cfi $0
18486 CFI_REL_OFFSET eip, 0
18487
18488 pushl_cfi %eax
18489 SAVE_ALL
18490 + GET_THREAD_INFO(%ebp)
18491 + movl TI_sysenter_return(%ebp),%ebp
18492 + movl %ebp,PT_EIP(%esp)
18493 ENABLE_INTERRUPTS(CLBR_NONE)
18494
18495 /*
18496 * Load the potential sixth argument from user stack.
18497 * Careful about security.
18498 */
18499 + movl PT_OLDESP(%esp),%ebp
18500 +
18501 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18502 + mov PT_OLDSS(%esp),%ds
18503 +1: movl %ds:(%ebp),%ebp
18504 + push %ss
18505 + pop %ds
18506 +#else
18507 cmpl $__PAGE_OFFSET-3,%ebp
18508 jae syscall_fault
18509 ASM_STAC
18510 1: movl (%ebp),%ebp
18511 ASM_CLAC
18512 +#endif
18513 +
18514 movl %ebp,PT_EBP(%esp)
18515 _ASM_EXTABLE(1b,syscall_fault)
18516
18517 GET_THREAD_INFO(%ebp)
18518
18519 +#ifdef CONFIG_PAX_RANDKSTACK
18520 + pax_erase_kstack
18521 +#endif
18522 +
18523 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18524 jnz sysenter_audit
18525 sysenter_do_call:
18526 @@ -444,12 +616,24 @@ sysenter_do_call:
18527 testl $_TIF_ALLWORK_MASK, %ecx
18528 jne sysexit_audit
18529 sysenter_exit:
18530 +
18531 +#ifdef CONFIG_PAX_RANDKSTACK
18532 + pushl_cfi %eax
18533 + movl %esp, %eax
18534 + call pax_randomize_kstack
18535 + popl_cfi %eax
18536 +#endif
18537 +
18538 + pax_erase_kstack
18539 +
18540 /* if something modifies registers it must also disable sysexit */
18541 movl PT_EIP(%esp), %edx
18542 movl PT_OLDESP(%esp), %ecx
18543 xorl %ebp,%ebp
18544 TRACE_IRQS_ON
18545 1: mov PT_FS(%esp), %fs
18546 +2: mov PT_DS(%esp), %ds
18547 +3: mov PT_ES(%esp), %es
18548 PTGS_TO_GS
18549 ENABLE_INTERRUPTS_SYSEXIT
18550
18551 @@ -466,6 +650,9 @@ sysenter_audit:
18552 movl %eax,%edx /* 2nd arg: syscall number */
18553 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18554 call __audit_syscall_entry
18555 +
18556 + pax_erase_kstack
18557 +
18558 pushl_cfi %ebx
18559 movl PT_EAX(%esp),%eax /* reload syscall number */
18560 jmp sysenter_do_call
18561 @@ -491,10 +678,16 @@ sysexit_audit:
18562
18563 CFI_ENDPROC
18564 .pushsection .fixup,"ax"
18565 -2: movl $0,PT_FS(%esp)
18566 +4: movl $0,PT_FS(%esp)
18567 + jmp 1b
18568 +5: movl $0,PT_DS(%esp)
18569 + jmp 1b
18570 +6: movl $0,PT_ES(%esp)
18571 jmp 1b
18572 .popsection
18573 - _ASM_EXTABLE(1b,2b)
18574 + _ASM_EXTABLE(1b,4b)
18575 + _ASM_EXTABLE(2b,5b)
18576 + _ASM_EXTABLE(3b,6b)
18577 PTGS_TO_GS_EX
18578 ENDPROC(ia32_sysenter_target)
18579
18580 @@ -509,6 +702,11 @@ ENTRY(system_call)
18581 pushl_cfi %eax # save orig_eax
18582 SAVE_ALL
18583 GET_THREAD_INFO(%ebp)
18584 +
18585 +#ifdef CONFIG_PAX_RANDKSTACK
18586 + pax_erase_kstack
18587 +#endif
18588 +
18589 # system call tracing in operation / emulation
18590 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18591 jnz syscall_trace_entry
18592 @@ -527,6 +725,15 @@ syscall_exit:
18593 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18594 jne syscall_exit_work
18595
18596 +restore_all_pax:
18597 +
18598 +#ifdef CONFIG_PAX_RANDKSTACK
18599 + movl %esp, %eax
18600 + call pax_randomize_kstack
18601 +#endif
18602 +
18603 + pax_erase_kstack
18604 +
18605 restore_all:
18606 TRACE_IRQS_IRET
18607 restore_all_notrace:
18608 @@ -583,14 +790,34 @@ ldt_ss:
18609 * compensating for the offset by changing to the ESPFIX segment with
18610 * a base address that matches for the difference.
18611 */
18612 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18613 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18614 mov %esp, %edx /* load kernel esp */
18615 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18616 mov %dx, %ax /* eax: new kernel esp */
18617 sub %eax, %edx /* offset (low word is 0) */
18618 +#ifdef CONFIG_SMP
18619 + movl PER_CPU_VAR(cpu_number), %ebx
18620 + shll $PAGE_SHIFT_asm, %ebx
18621 + addl $cpu_gdt_table, %ebx
18622 +#else
18623 + movl $cpu_gdt_table, %ebx
18624 +#endif
18625 shr $16, %edx
18626 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18627 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18628 +
18629 +#ifdef CONFIG_PAX_KERNEXEC
18630 + mov %cr0, %esi
18631 + btr $16, %esi
18632 + mov %esi, %cr0
18633 +#endif
18634 +
18635 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18636 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18637 +
18638 +#ifdef CONFIG_PAX_KERNEXEC
18639 + bts $16, %esi
18640 + mov %esi, %cr0
18641 +#endif
18642 +
18643 pushl_cfi $__ESPFIX_SS
18644 pushl_cfi %eax /* new kernel esp */
18645 /* Disable interrupts, but do not irqtrace this section: we
18646 @@ -619,20 +846,18 @@ work_resched:
18647 movl TI_flags(%ebp), %ecx
18648 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18649 # than syscall tracing?
18650 - jz restore_all
18651 + jz restore_all_pax
18652 testb $_TIF_NEED_RESCHED, %cl
18653 jnz work_resched
18654
18655 work_notifysig: # deal with pending signals and
18656 # notify-resume requests
18657 + movl %esp, %eax
18658 #ifdef CONFIG_VM86
18659 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18660 - movl %esp, %eax
18661 jne work_notifysig_v86 # returning to kernel-space or
18662 # vm86-space
18663 1:
18664 -#else
18665 - movl %esp, %eax
18666 #endif
18667 TRACE_IRQS_ON
18668 ENABLE_INTERRUPTS(CLBR_NONE)
18669 @@ -653,7 +878,7 @@ work_notifysig_v86:
18670 movl %eax, %esp
18671 jmp 1b
18672 #endif
18673 -END(work_pending)
18674 +ENDPROC(work_pending)
18675
18676 # perform syscall exit tracing
18677 ALIGN
18678 @@ -661,11 +886,14 @@ syscall_trace_entry:
18679 movl $-ENOSYS,PT_EAX(%esp)
18680 movl %esp, %eax
18681 call syscall_trace_enter
18682 +
18683 + pax_erase_kstack
18684 +
18685 /* What it returned is what we'll actually use. */
18686 cmpl $(NR_syscalls), %eax
18687 jnae syscall_call
18688 jmp syscall_exit
18689 -END(syscall_trace_entry)
18690 +ENDPROC(syscall_trace_entry)
18691
18692 # perform syscall exit tracing
18693 ALIGN
18694 @@ -678,21 +906,25 @@ syscall_exit_work:
18695 movl %esp, %eax
18696 call syscall_trace_leave
18697 jmp resume_userspace
18698 -END(syscall_exit_work)
18699 +ENDPROC(syscall_exit_work)
18700 CFI_ENDPROC
18701
18702 RING0_INT_FRAME # can't unwind into user space anyway
18703 syscall_fault:
18704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18705 + push %ss
18706 + pop %ds
18707 +#endif
18708 ASM_CLAC
18709 GET_THREAD_INFO(%ebp)
18710 movl $-EFAULT,PT_EAX(%esp)
18711 jmp resume_userspace
18712 -END(syscall_fault)
18713 +ENDPROC(syscall_fault)
18714
18715 syscall_badsys:
18716 movl $-ENOSYS,PT_EAX(%esp)
18717 jmp resume_userspace
18718 -END(syscall_badsys)
18719 +ENDPROC(syscall_badsys)
18720 CFI_ENDPROC
18721 /*
18722 * End of kprobes section
18723 @@ -708,8 +940,15 @@ END(syscall_badsys)
18724 * normal stack and adjusts ESP with the matching offset.
18725 */
18726 /* fixup the stack */
18727 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18728 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18729 +#ifdef CONFIG_SMP
18730 + movl PER_CPU_VAR(cpu_number), %ebx
18731 + shll $PAGE_SHIFT_asm, %ebx
18732 + addl $cpu_gdt_table, %ebx
18733 +#else
18734 + movl $cpu_gdt_table, %ebx
18735 +#endif
18736 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18737 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18738 shl $16, %eax
18739 addl %esp, %eax /* the adjusted stack pointer */
18740 pushl_cfi $__KERNEL_DS
18741 @@ -762,7 +1001,7 @@ vector=vector+1
18742 .endr
18743 2: jmp common_interrupt
18744 .endr
18745 -END(irq_entries_start)
18746 +ENDPROC(irq_entries_start)
18747
18748 .previous
18749 END(interrupt)
18750 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18751 pushl_cfi $do_coprocessor_error
18752 jmp error_code
18753 CFI_ENDPROC
18754 -END(coprocessor_error)
18755 +ENDPROC(coprocessor_error)
18756
18757 ENTRY(simd_coprocessor_error)
18758 RING0_INT_FRAME
18759 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18760 #endif
18761 jmp error_code
18762 CFI_ENDPROC
18763 -END(simd_coprocessor_error)
18764 +ENDPROC(simd_coprocessor_error)
18765
18766 ENTRY(device_not_available)
18767 RING0_INT_FRAME
18768 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18769 pushl_cfi $do_device_not_available
18770 jmp error_code
18771 CFI_ENDPROC
18772 -END(device_not_available)
18773 +ENDPROC(device_not_available)
18774
18775 #ifdef CONFIG_PARAVIRT
18776 ENTRY(native_iret)
18777 iret
18778 _ASM_EXTABLE(native_iret, iret_exc)
18779 -END(native_iret)
18780 +ENDPROC(native_iret)
18781
18782 ENTRY(native_irq_enable_sysexit)
18783 sti
18784 sysexit
18785 -END(native_irq_enable_sysexit)
18786 +ENDPROC(native_irq_enable_sysexit)
18787 #endif
18788
18789 ENTRY(overflow)
18790 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18791 pushl_cfi $do_overflow
18792 jmp error_code
18793 CFI_ENDPROC
18794 -END(overflow)
18795 +ENDPROC(overflow)
18796
18797 ENTRY(bounds)
18798 RING0_INT_FRAME
18799 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18800 pushl_cfi $do_bounds
18801 jmp error_code
18802 CFI_ENDPROC
18803 -END(bounds)
18804 +ENDPROC(bounds)
18805
18806 ENTRY(invalid_op)
18807 RING0_INT_FRAME
18808 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18809 pushl_cfi $do_invalid_op
18810 jmp error_code
18811 CFI_ENDPROC
18812 -END(invalid_op)
18813 +ENDPROC(invalid_op)
18814
18815 ENTRY(coprocessor_segment_overrun)
18816 RING0_INT_FRAME
18817 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18818 pushl_cfi $do_coprocessor_segment_overrun
18819 jmp error_code
18820 CFI_ENDPROC
18821 -END(coprocessor_segment_overrun)
18822 +ENDPROC(coprocessor_segment_overrun)
18823
18824 ENTRY(invalid_TSS)
18825 RING0_EC_FRAME
18826 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18827 pushl_cfi $do_invalid_TSS
18828 jmp error_code
18829 CFI_ENDPROC
18830 -END(invalid_TSS)
18831 +ENDPROC(invalid_TSS)
18832
18833 ENTRY(segment_not_present)
18834 RING0_EC_FRAME
18835 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18836 pushl_cfi $do_segment_not_present
18837 jmp error_code
18838 CFI_ENDPROC
18839 -END(segment_not_present)
18840 +ENDPROC(segment_not_present)
18841
18842 ENTRY(stack_segment)
18843 RING0_EC_FRAME
18844 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18845 pushl_cfi $do_stack_segment
18846 jmp error_code
18847 CFI_ENDPROC
18848 -END(stack_segment)
18849 +ENDPROC(stack_segment)
18850
18851 ENTRY(alignment_check)
18852 RING0_EC_FRAME
18853 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18854 pushl_cfi $do_alignment_check
18855 jmp error_code
18856 CFI_ENDPROC
18857 -END(alignment_check)
18858 +ENDPROC(alignment_check)
18859
18860 ENTRY(divide_error)
18861 RING0_INT_FRAME
18862 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18863 pushl_cfi $do_divide_error
18864 jmp error_code
18865 CFI_ENDPROC
18866 -END(divide_error)
18867 +ENDPROC(divide_error)
18868
18869 #ifdef CONFIG_X86_MCE
18870 ENTRY(machine_check)
18871 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18872 pushl_cfi machine_check_vector
18873 jmp error_code
18874 CFI_ENDPROC
18875 -END(machine_check)
18876 +ENDPROC(machine_check)
18877 #endif
18878
18879 ENTRY(spurious_interrupt_bug)
18880 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18881 pushl_cfi $do_spurious_interrupt_bug
18882 jmp error_code
18883 CFI_ENDPROC
18884 -END(spurious_interrupt_bug)
18885 +ENDPROC(spurious_interrupt_bug)
18886 /*
18887 * End of kprobes section
18888 */
18889 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18890
18891 ENTRY(mcount)
18892 ret
18893 -END(mcount)
18894 +ENDPROC(mcount)
18895
18896 ENTRY(ftrace_caller)
18897 cmpl $0, function_trace_stop
18898 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18899 .globl ftrace_stub
18900 ftrace_stub:
18901 ret
18902 -END(ftrace_caller)
18903 +ENDPROC(ftrace_caller)
18904
18905 ENTRY(ftrace_regs_caller)
18906 pushf /* push flags before compare (in cs location) */
18907 @@ -1197,7 +1436,7 @@ trace:
18908 popl %ecx
18909 popl %eax
18910 jmp ftrace_stub
18911 -END(mcount)
18912 +ENDPROC(mcount)
18913 #endif /* CONFIG_DYNAMIC_FTRACE */
18914 #endif /* CONFIG_FUNCTION_TRACER */
18915
18916 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18917 popl %ecx
18918 popl %eax
18919 ret
18920 -END(ftrace_graph_caller)
18921 +ENDPROC(ftrace_graph_caller)
18922
18923 .globl return_to_handler
18924 return_to_handler:
18925 @@ -1271,15 +1510,18 @@ error_code:
18926 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18927 REG_TO_PTGS %ecx
18928 SET_KERNEL_GS %ecx
18929 - movl $(__USER_DS), %ecx
18930 + movl $(__KERNEL_DS), %ecx
18931 movl %ecx, %ds
18932 movl %ecx, %es
18933 +
18934 + pax_enter_kernel
18935 +
18936 TRACE_IRQS_OFF
18937 movl %esp,%eax # pt_regs pointer
18938 call *%edi
18939 jmp ret_from_exception
18940 CFI_ENDPROC
18941 -END(page_fault)
18942 +ENDPROC(page_fault)
18943
18944 /*
18945 * Debug traps and NMI can happen at the one SYSENTER instruction
18946 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18947 call do_debug
18948 jmp ret_from_exception
18949 CFI_ENDPROC
18950 -END(debug)
18951 +ENDPROC(debug)
18952
18953 /*
18954 * NMI is doubly nasty. It can happen _while_ we're handling
18955 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18956 xorl %edx,%edx # zero error code
18957 movl %esp,%eax # pt_regs pointer
18958 call do_nmi
18959 +
18960 + pax_exit_kernel
18961 +
18962 jmp restore_all_notrace
18963 CFI_ENDPROC
18964
18965 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18966 FIXUP_ESPFIX_STACK # %eax == %esp
18967 xorl %edx,%edx # zero error code
18968 call do_nmi
18969 +
18970 + pax_exit_kernel
18971 +
18972 RESTORE_REGS
18973 lss 12+4(%esp), %esp # back to espfix stack
18974 CFI_ADJUST_CFA_OFFSET -24
18975 jmp irq_return
18976 CFI_ENDPROC
18977 -END(nmi)
18978 +ENDPROC(nmi)
18979
18980 ENTRY(int3)
18981 RING0_INT_FRAME
18982 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18983 call do_int3
18984 jmp ret_from_exception
18985 CFI_ENDPROC
18986 -END(int3)
18987 +ENDPROC(int3)
18988
18989 ENTRY(general_protection)
18990 RING0_EC_FRAME
18991 pushl_cfi $do_general_protection
18992 jmp error_code
18993 CFI_ENDPROC
18994 -END(general_protection)
18995 +ENDPROC(general_protection)
18996
18997 #ifdef CONFIG_KVM_GUEST
18998 ENTRY(async_page_fault)
18999 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
19000 pushl_cfi $do_async_page_fault
19001 jmp error_code
19002 CFI_ENDPROC
19003 -END(async_page_fault)
19004 +ENDPROC(async_page_fault)
19005 #endif
19006
19007 /*
19008 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19009 index 7272089..6204f9c5 100644
19010 --- a/arch/x86/kernel/entry_64.S
19011 +++ b/arch/x86/kernel/entry_64.S
19012 @@ -59,6 +59,8 @@
19013 #include <asm/context_tracking.h>
19014 #include <asm/smap.h>
19015 #include <linux/err.h>
19016 +#include <asm/pgtable.h>
19017 +#include <asm/alternative-asm.h>
19018
19019 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19020 #include <linux/elf-em.h>
19021 @@ -80,8 +82,9 @@
19022 #ifdef CONFIG_DYNAMIC_FTRACE
19023
19024 ENTRY(function_hook)
19025 + pax_force_retaddr
19026 retq
19027 -END(function_hook)
19028 +ENDPROC(function_hook)
19029
19030 /* skip is set if stack has been adjusted */
19031 .macro ftrace_caller_setup skip=0
19032 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19033 #endif
19034
19035 GLOBAL(ftrace_stub)
19036 + pax_force_retaddr
19037 retq
19038 -END(ftrace_caller)
19039 +ENDPROC(ftrace_caller)
19040
19041 ENTRY(ftrace_regs_caller)
19042 /* Save the current flags before compare (in SS location)*/
19043 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19044 popfq
19045 jmp ftrace_stub
19046
19047 -END(ftrace_regs_caller)
19048 +ENDPROC(ftrace_regs_caller)
19049
19050
19051 #else /* ! CONFIG_DYNAMIC_FTRACE */
19052 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19053 #endif
19054
19055 GLOBAL(ftrace_stub)
19056 + pax_force_retaddr
19057 retq
19058
19059 trace:
19060 @@ -225,12 +230,13 @@ trace:
19061 #endif
19062 subq $MCOUNT_INSN_SIZE, %rdi
19063
19064 + pax_force_fptr ftrace_trace_function
19065 call *ftrace_trace_function
19066
19067 MCOUNT_RESTORE_FRAME
19068
19069 jmp ftrace_stub
19070 -END(function_hook)
19071 +ENDPROC(function_hook)
19072 #endif /* CONFIG_DYNAMIC_FTRACE */
19073 #endif /* CONFIG_FUNCTION_TRACER */
19074
19075 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19076
19077 MCOUNT_RESTORE_FRAME
19078
19079 + pax_force_retaddr
19080 retq
19081 -END(ftrace_graph_caller)
19082 +ENDPROC(ftrace_graph_caller)
19083
19084 GLOBAL(return_to_handler)
19085 subq $24, %rsp
19086 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19087 movq 8(%rsp), %rdx
19088 movq (%rsp), %rax
19089 addq $24, %rsp
19090 + pax_force_fptr %rdi
19091 jmp *%rdi
19092 +ENDPROC(return_to_handler)
19093 #endif
19094
19095
19096 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19097 ENDPROC(native_usergs_sysret64)
19098 #endif /* CONFIG_PARAVIRT */
19099
19100 + .macro ljmpq sel, off
19101 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19102 + .byte 0x48; ljmp *1234f(%rip)
19103 + .pushsection .rodata
19104 + .align 16
19105 + 1234: .quad \off; .word \sel
19106 + .popsection
19107 +#else
19108 + pushq $\sel
19109 + pushq $\off
19110 + lretq
19111 +#endif
19112 + .endm
19113 +
19114 + .macro pax_enter_kernel
19115 + pax_set_fptr_mask
19116 +#ifdef CONFIG_PAX_KERNEXEC
19117 + call pax_enter_kernel
19118 +#endif
19119 + .endm
19120 +
19121 + .macro pax_exit_kernel
19122 +#ifdef CONFIG_PAX_KERNEXEC
19123 + call pax_exit_kernel
19124 +#endif
19125 + .endm
19126 +
19127 +#ifdef CONFIG_PAX_KERNEXEC
19128 +ENTRY(pax_enter_kernel)
19129 + pushq %rdi
19130 +
19131 +#ifdef CONFIG_PARAVIRT
19132 + PV_SAVE_REGS(CLBR_RDI)
19133 +#endif
19134 +
19135 + GET_CR0_INTO_RDI
19136 + bts $16,%rdi
19137 + jnc 3f
19138 + mov %cs,%edi
19139 + cmp $__KERNEL_CS,%edi
19140 + jnz 2f
19141 +1:
19142 +
19143 +#ifdef CONFIG_PARAVIRT
19144 + PV_RESTORE_REGS(CLBR_RDI)
19145 +#endif
19146 +
19147 + popq %rdi
19148 + pax_force_retaddr
19149 + retq
19150 +
19151 +2: ljmpq __KERNEL_CS,1b
19152 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19153 +4: SET_RDI_INTO_CR0
19154 + jmp 1b
19155 +ENDPROC(pax_enter_kernel)
19156 +
19157 +ENTRY(pax_exit_kernel)
19158 + pushq %rdi
19159 +
19160 +#ifdef CONFIG_PARAVIRT
19161 + PV_SAVE_REGS(CLBR_RDI)
19162 +#endif
19163 +
19164 + mov %cs,%rdi
19165 + cmp $__KERNEXEC_KERNEL_CS,%edi
19166 + jz 2f
19167 + GET_CR0_INTO_RDI
19168 + bts $16,%rdi
19169 + jnc 4f
19170 +1:
19171 +
19172 +#ifdef CONFIG_PARAVIRT
19173 + PV_RESTORE_REGS(CLBR_RDI);
19174 +#endif
19175 +
19176 + popq %rdi
19177 + pax_force_retaddr
19178 + retq
19179 +
19180 +2: GET_CR0_INTO_RDI
19181 + btr $16,%rdi
19182 + jnc 4f
19183 + ljmpq __KERNEL_CS,3f
19184 +3: SET_RDI_INTO_CR0
19185 + jmp 1b
19186 +4: ud2
19187 + jmp 4b
19188 +ENDPROC(pax_exit_kernel)
19189 +#endif
19190 +
19191 + .macro pax_enter_kernel_user
19192 + pax_set_fptr_mask
19193 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19194 + call pax_enter_kernel_user
19195 +#endif
19196 + .endm
19197 +
19198 + .macro pax_exit_kernel_user
19199 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19200 + call pax_exit_kernel_user
19201 +#endif
19202 +#ifdef CONFIG_PAX_RANDKSTACK
19203 + pushq %rax
19204 + pushq %r11
19205 + call pax_randomize_kstack
19206 + popq %r11
19207 + popq %rax
19208 +#endif
19209 + .endm
19210 +
19211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19212 +ENTRY(pax_enter_kernel_user)
19213 + pushq %rdi
19214 + pushq %rbx
19215 +
19216 +#ifdef CONFIG_PARAVIRT
19217 + PV_SAVE_REGS(CLBR_RDI)
19218 +#endif
19219 +
19220 + GET_CR3_INTO_RDI
19221 + mov %rdi,%rbx
19222 + add $__START_KERNEL_map,%rbx
19223 + sub phys_base(%rip),%rbx
19224 +
19225 +#ifdef CONFIG_PARAVIRT
19226 + cmpl $0, pv_info+PARAVIRT_enabled
19227 + jz 1f
19228 + pushq %rdi
19229 + i = 0
19230 + .rept USER_PGD_PTRS
19231 + mov i*8(%rbx),%rsi
19232 + mov $0,%sil
19233 + lea i*8(%rbx),%rdi
19234 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19235 + i = i + 1
19236 + .endr
19237 + popq %rdi
19238 + jmp 2f
19239 +1:
19240 +#endif
19241 +
19242 + i = 0
19243 + .rept USER_PGD_PTRS
19244 + movb $0,i*8(%rbx)
19245 + i = i + 1
19246 + .endr
19247 +
19248 +#ifdef CONFIG_PARAVIRT
19249 +2:
19250 +#endif
19251 + SET_RDI_INTO_CR3
19252 +
19253 +#ifdef CONFIG_PAX_KERNEXEC
19254 + GET_CR0_INTO_RDI
19255 + bts $16,%rdi
19256 + SET_RDI_INTO_CR0
19257 +#endif
19258 +
19259 +#ifdef CONFIG_PARAVIRT
19260 + PV_RESTORE_REGS(CLBR_RDI)
19261 +#endif
19262 +
19263 + popq %rbx
19264 + popq %rdi
19265 + pax_force_retaddr
19266 + retq
19267 +ENDPROC(pax_enter_kernel_user)
19268 +
19269 +ENTRY(pax_exit_kernel_user)
19270 + pushq %rdi
19271 + pushq %rbx
19272 +
19273 +#ifdef CONFIG_PARAVIRT
19274 + PV_SAVE_REGS(CLBR_RDI)
19275 +#endif
19276 +
19277 +#ifdef CONFIG_PAX_KERNEXEC
19278 + GET_CR0_INTO_RDI
19279 + btr $16,%rdi
19280 + jnc 3f
19281 + SET_RDI_INTO_CR0
19282 +#endif
19283 +
19284 + GET_CR3_INTO_RDI
19285 + mov %rdi,%rbx
19286 + add $__START_KERNEL_map,%rbx
19287 + sub phys_base(%rip),%rbx
19288 +
19289 +#ifdef CONFIG_PARAVIRT
19290 + cmpl $0, pv_info+PARAVIRT_enabled
19291 + jz 1f
19292 + i = 0
19293 + .rept USER_PGD_PTRS
19294 + mov i*8(%rbx),%rsi
19295 + mov $0x67,%sil
19296 + lea i*8(%rbx),%rdi
19297 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19298 + i = i + 1
19299 + .endr
19300 + jmp 2f
19301 +1:
19302 +#endif
19303 +
19304 + i = 0
19305 + .rept USER_PGD_PTRS
19306 + movb $0x67,i*8(%rbx)
19307 + i = i + 1
19308 + .endr
19309 +
19310 +#ifdef CONFIG_PARAVIRT
19311 +2: PV_RESTORE_REGS(CLBR_RDI)
19312 +#endif
19313 +
19314 + popq %rbx
19315 + popq %rdi
19316 + pax_force_retaddr
19317 + retq
19318 +3: ud2
19319 + jmp 3b
19320 +ENDPROC(pax_exit_kernel_user)
19321 +#endif
19322 +
19323 + .macro pax_enter_kernel_nmi
19324 + pax_set_fptr_mask
19325 +
19326 +#ifdef CONFIG_PAX_KERNEXEC
19327 + GET_CR0_INTO_RDI
19328 + bts $16,%rdi
19329 + jc 110f
19330 + SET_RDI_INTO_CR0
19331 + or $2,%ebx
19332 +110:
19333 +#endif
19334 + .endm
19335 +
19336 + .macro pax_exit_kernel_nmi
19337 +#ifdef CONFIG_PAX_KERNEXEC
19338 + btr $1,%ebx
19339 + jnc 110f
19340 + GET_CR0_INTO_RDI
19341 + btr $16,%rdi
19342 + SET_RDI_INTO_CR0
19343 +110:
19344 +#endif
19345 + .endm
19346 +
19347 + .macro pax_erase_kstack
19348 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19349 + call pax_erase_kstack
19350 +#endif
19351 + .endm
19352 +
19353 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19354 +ENTRY(pax_erase_kstack)
19355 + pushq %rdi
19356 + pushq %rcx
19357 + pushq %rax
19358 + pushq %r11
19359 +
19360 + GET_THREAD_INFO(%r11)
19361 + mov TI_lowest_stack(%r11), %rdi
19362 + mov $-0xBEEF, %rax
19363 + std
19364 +
19365 +1: mov %edi, %ecx
19366 + and $THREAD_SIZE_asm - 1, %ecx
19367 + shr $3, %ecx
19368 + repne scasq
19369 + jecxz 2f
19370 +
19371 + cmp $2*8, %ecx
19372 + jc 2f
19373 +
19374 + mov $2*8, %ecx
19375 + repe scasq
19376 + jecxz 2f
19377 + jne 1b
19378 +
19379 +2: cld
19380 + mov %esp, %ecx
19381 + sub %edi, %ecx
19382 +
19383 + cmp $THREAD_SIZE_asm, %rcx
19384 + jb 3f
19385 + ud2
19386 +3:
19387 +
19388 + shr $3, %ecx
19389 + rep stosq
19390 +
19391 + mov TI_task_thread_sp0(%r11), %rdi
19392 + sub $256, %rdi
19393 + mov %rdi, TI_lowest_stack(%r11)
19394 +
19395 + popq %r11
19396 + popq %rax
19397 + popq %rcx
19398 + popq %rdi
19399 + pax_force_retaddr
19400 + ret
19401 +ENDPROC(pax_erase_kstack)
19402 +#endif
19403
19404 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19405 #ifdef CONFIG_TRACE_IRQFLAGS
19406 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19407 .endm
19408
19409 .macro UNFAKE_STACK_FRAME
19410 - addq $8*6, %rsp
19411 - CFI_ADJUST_CFA_OFFSET -(6*8)
19412 + addq $8*6 + ARG_SKIP, %rsp
19413 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19414 .endm
19415
19416 /*
19417 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19418 movq %rsp, %rsi
19419
19420 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19421 - testl $3, CS-RBP(%rsi)
19422 + testb $3, CS-RBP(%rsi)
19423 je 1f
19424 SWAPGS
19425 /*
19426 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19427 movq_cfi r15, R15+16
19428 movq %r11, 8(%rsp) /* return address */
19429 FIXUP_TOP_OF_STACK %r11, 16
19430 + pax_force_retaddr
19431 ret
19432 CFI_ENDPROC
19433 -END(save_rest)
19434 +ENDPROC(save_rest)
19435
19436 /* save complete stack frame */
19437 .pushsection .kprobes.text, "ax"
19438 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19439 js 1f /* negative -> in kernel */
19440 SWAPGS
19441 xorl %ebx,%ebx
19442 -1: ret
19443 +1: pax_force_retaddr_bts
19444 + ret
19445 CFI_ENDPROC
19446 -END(save_paranoid)
19447 +ENDPROC(save_paranoid)
19448 .popsection
19449
19450 /*
19451 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19452
19453 RESTORE_REST
19454
19455 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19456 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19457 jz 1f
19458
19459 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19460 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19461 RESTORE_REST
19462 jmp int_ret_from_sys_call
19463 CFI_ENDPROC
19464 -END(ret_from_fork)
19465 +ENDPROC(ret_from_fork)
19466
19467 /*
19468 * System call entry. Up to 6 arguments in registers are supported.
19469 @@ -608,7 +922,7 @@ END(ret_from_fork)
19470 ENTRY(system_call)
19471 CFI_STARTPROC simple
19472 CFI_SIGNAL_FRAME
19473 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19474 + CFI_DEF_CFA rsp,0
19475 CFI_REGISTER rip,rcx
19476 /*CFI_REGISTER rflags,r11*/
19477 SWAPGS_UNSAFE_STACK
19478 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19479
19480 movq %rsp,PER_CPU_VAR(old_rsp)
19481 movq PER_CPU_VAR(kernel_stack),%rsp
19482 + SAVE_ARGS 8*6,0
19483 + pax_enter_kernel_user
19484 +
19485 +#ifdef CONFIG_PAX_RANDKSTACK
19486 + pax_erase_kstack
19487 +#endif
19488 +
19489 /*
19490 * No need to follow this irqs off/on section - it's straight
19491 * and short:
19492 */
19493 ENABLE_INTERRUPTS(CLBR_NONE)
19494 - SAVE_ARGS 8,0
19495 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19496 movq %rcx,RIP-ARGOFFSET(%rsp)
19497 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19498 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19499 + GET_THREAD_INFO(%rcx)
19500 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19501 jnz tracesys
19502 system_call_fastpath:
19503 #if __SYSCALL_MASK == ~0
19504 @@ -640,7 +961,7 @@ system_call_fastpath:
19505 cmpl $__NR_syscall_max,%eax
19506 #endif
19507 ja badsys
19508 - movq %r10,%rcx
19509 + movq R10-ARGOFFSET(%rsp),%rcx
19510 call *sys_call_table(,%rax,8) # XXX: rip relative
19511 movq %rax,RAX-ARGOFFSET(%rsp)
19512 /*
19513 @@ -654,10 +975,13 @@ sysret_check:
19514 LOCKDEP_SYS_EXIT
19515 DISABLE_INTERRUPTS(CLBR_NONE)
19516 TRACE_IRQS_OFF
19517 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19518 + GET_THREAD_INFO(%rcx)
19519 + movl TI_flags(%rcx),%edx
19520 andl %edi,%edx
19521 jnz sysret_careful
19522 CFI_REMEMBER_STATE
19523 + pax_exit_kernel_user
19524 + pax_erase_kstack
19525 /*
19526 * sysretq will re-enable interrupts:
19527 */
19528 @@ -709,14 +1033,18 @@ badsys:
19529 * jump back to the normal fast path.
19530 */
19531 auditsys:
19532 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19533 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19534 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19535 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19536 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19537 movq %rax,%rsi /* 2nd arg: syscall number */
19538 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19539 call __audit_syscall_entry
19540 +
19541 + pax_erase_kstack
19542 +
19543 LOAD_ARGS 0 /* reload call-clobbered registers */
19544 + pax_set_fptr_mask
19545 jmp system_call_fastpath
19546
19547 /*
19548 @@ -737,7 +1065,7 @@ sysret_audit:
19549 /* Do syscall tracing */
19550 tracesys:
19551 #ifdef CONFIG_AUDITSYSCALL
19552 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19553 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19554 jz auditsys
19555 #endif
19556 SAVE_REST
19557 @@ -745,12 +1073,16 @@ tracesys:
19558 FIXUP_TOP_OF_STACK %rdi
19559 movq %rsp,%rdi
19560 call syscall_trace_enter
19561 +
19562 + pax_erase_kstack
19563 +
19564 /*
19565 * Reload arg registers from stack in case ptrace changed them.
19566 * We don't reload %rax because syscall_trace_enter() returned
19567 * the value it wants us to use in the table lookup.
19568 */
19569 LOAD_ARGS ARGOFFSET, 1
19570 + pax_set_fptr_mask
19571 RESTORE_REST
19572 #if __SYSCALL_MASK == ~0
19573 cmpq $__NR_syscall_max,%rax
19574 @@ -759,7 +1091,7 @@ tracesys:
19575 cmpl $__NR_syscall_max,%eax
19576 #endif
19577 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19578 - movq %r10,%rcx /* fixup for C */
19579 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19580 call *sys_call_table(,%rax,8)
19581 movq %rax,RAX-ARGOFFSET(%rsp)
19582 /* Use IRET because user could have changed frame */
19583 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19584 andl %edi,%edx
19585 jnz int_careful
19586 andl $~TS_COMPAT,TI_status(%rcx)
19587 - jmp retint_swapgs
19588 + pax_exit_kernel_user
19589 + pax_erase_kstack
19590 + jmp retint_swapgs_pax
19591
19592 /* Either reschedule or signal or syscall exit tracking needed. */
19593 /* First do a reschedule test. */
19594 @@ -826,7 +1160,7 @@ int_restore_rest:
19595 TRACE_IRQS_OFF
19596 jmp int_with_check
19597 CFI_ENDPROC
19598 -END(system_call)
19599 +ENDPROC(system_call)
19600
19601 .macro FORK_LIKE func
19602 ENTRY(stub_\func)
19603 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19604 DEFAULT_FRAME 0 8 /* offset 8: return address */
19605 call sys_\func
19606 RESTORE_TOP_OF_STACK %r11, 8
19607 + pax_force_retaddr
19608 ret $REST_SKIP /* pop extended registers */
19609 CFI_ENDPROC
19610 -END(stub_\func)
19611 +ENDPROC(stub_\func)
19612 .endm
19613
19614 .macro FIXED_FRAME label,func
19615 @@ -851,9 +1186,10 @@ ENTRY(\label)
19616 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19617 call \func
19618 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19619 + pax_force_retaddr
19620 ret
19621 CFI_ENDPROC
19622 -END(\label)
19623 +ENDPROC(\label)
19624 .endm
19625
19626 FORK_LIKE clone
19627 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19628 movq_cfi_restore R12+8, r12
19629 movq_cfi_restore RBP+8, rbp
19630 movq_cfi_restore RBX+8, rbx
19631 + pax_force_retaddr
19632 ret $REST_SKIP /* pop extended registers */
19633 CFI_ENDPROC
19634 -END(ptregscall_common)
19635 +ENDPROC(ptregscall_common)
19636
19637 ENTRY(stub_execve)
19638 CFI_STARTPROC
19639 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19640 RESTORE_REST
19641 jmp int_ret_from_sys_call
19642 CFI_ENDPROC
19643 -END(stub_execve)
19644 +ENDPROC(stub_execve)
19645
19646 /*
19647 * sigreturn is special because it needs to restore all registers on return.
19648 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19649 RESTORE_REST
19650 jmp int_ret_from_sys_call
19651 CFI_ENDPROC
19652 -END(stub_rt_sigreturn)
19653 +ENDPROC(stub_rt_sigreturn)
19654
19655 #ifdef CONFIG_X86_X32_ABI
19656 ENTRY(stub_x32_rt_sigreturn)
19657 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19658 RESTORE_REST
19659 jmp int_ret_from_sys_call
19660 CFI_ENDPROC
19661 -END(stub_x32_rt_sigreturn)
19662 +ENDPROC(stub_x32_rt_sigreturn)
19663
19664 ENTRY(stub_x32_execve)
19665 CFI_STARTPROC
19666 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19667 RESTORE_REST
19668 jmp int_ret_from_sys_call
19669 CFI_ENDPROC
19670 -END(stub_x32_execve)
19671 +ENDPROC(stub_x32_execve)
19672
19673 #endif
19674
19675 @@ -967,7 +1304,7 @@ vector=vector+1
19676 2: jmp common_interrupt
19677 .endr
19678 CFI_ENDPROC
19679 -END(irq_entries_start)
19680 +ENDPROC(irq_entries_start)
19681
19682 .previous
19683 END(interrupt)
19684 @@ -987,6 +1324,16 @@ END(interrupt)
19685 subq $ORIG_RAX-RBP, %rsp
19686 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19687 SAVE_ARGS_IRQ
19688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19689 + testb $3, CS(%rdi)
19690 + jnz 1f
19691 + pax_enter_kernel
19692 + jmp 2f
19693 +1: pax_enter_kernel_user
19694 +2:
19695 +#else
19696 + pax_enter_kernel
19697 +#endif
19698 call \func
19699 .endm
19700
19701 @@ -1019,7 +1366,7 @@ ret_from_intr:
19702
19703 exit_intr:
19704 GET_THREAD_INFO(%rcx)
19705 - testl $3,CS-ARGOFFSET(%rsp)
19706 + testb $3,CS-ARGOFFSET(%rsp)
19707 je retint_kernel
19708
19709 /* Interrupt came from user space */
19710 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19711 * The iretq could re-enable interrupts:
19712 */
19713 DISABLE_INTERRUPTS(CLBR_ANY)
19714 + pax_exit_kernel_user
19715 +retint_swapgs_pax:
19716 TRACE_IRQS_IRETQ
19717 SWAPGS
19718 jmp restore_args
19719
19720 retint_restore_args: /* return to kernel space */
19721 DISABLE_INTERRUPTS(CLBR_ANY)
19722 + pax_exit_kernel
19723 + pax_force_retaddr (RIP-ARGOFFSET)
19724 /*
19725 * The iretq could re-enable interrupts:
19726 */
19727 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19728 #endif
19729
19730 CFI_ENDPROC
19731 -END(common_interrupt)
19732 +ENDPROC(common_interrupt)
19733 /*
19734 * End of kprobes section
19735 */
19736 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19737 interrupt \do_sym
19738 jmp ret_from_intr
19739 CFI_ENDPROC
19740 -END(\sym)
19741 +ENDPROC(\sym)
19742 .endm
19743
19744 #ifdef CONFIG_SMP
19745 @@ -1208,12 +1559,22 @@ ENTRY(\sym)
19746 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19747 call error_entry
19748 DEFAULT_FRAME 0
19749 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19750 + testb $3, CS(%rsp)
19751 + jnz 1f
19752 + pax_enter_kernel
19753 + jmp 2f
19754 +1: pax_enter_kernel_user
19755 +2:
19756 +#else
19757 + pax_enter_kernel
19758 +#endif
19759 movq %rsp,%rdi /* pt_regs pointer */
19760 xorl %esi,%esi /* no error code */
19761 call \do_sym
19762 jmp error_exit /* %ebx: no swapgs flag */
19763 CFI_ENDPROC
19764 -END(\sym)
19765 +ENDPROC(\sym)
19766 .endm
19767
19768 .macro paranoidzeroentry sym do_sym
19769 @@ -1226,15 +1587,25 @@ ENTRY(\sym)
19770 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19771 call save_paranoid
19772 TRACE_IRQS_OFF
19773 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19774 + testb $3, CS(%rsp)
19775 + jnz 1f
19776 + pax_enter_kernel
19777 + jmp 2f
19778 +1: pax_enter_kernel_user
19779 +2:
19780 +#else
19781 + pax_enter_kernel
19782 +#endif
19783 movq %rsp,%rdi /* pt_regs pointer */
19784 xorl %esi,%esi /* no error code */
19785 call \do_sym
19786 jmp paranoid_exit /* %ebx: no swapgs flag */
19787 CFI_ENDPROC
19788 -END(\sym)
19789 +ENDPROC(\sym)
19790 .endm
19791
19792 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19793 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19794 .macro paranoidzeroentry_ist sym do_sym ist
19795 ENTRY(\sym)
19796 INTR_FRAME
19797 @@ -1245,14 +1616,30 @@ ENTRY(\sym)
19798 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19799 call save_paranoid
19800 TRACE_IRQS_OFF_DEBUG
19801 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19802 + testb $3, CS(%rsp)
19803 + jnz 1f
19804 + pax_enter_kernel
19805 + jmp 2f
19806 +1: pax_enter_kernel_user
19807 +2:
19808 +#else
19809 + pax_enter_kernel
19810 +#endif
19811 movq %rsp,%rdi /* pt_regs pointer */
19812 xorl %esi,%esi /* no error code */
19813 +#ifdef CONFIG_SMP
19814 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19815 + lea init_tss(%r12), %r12
19816 +#else
19817 + lea init_tss(%rip), %r12
19818 +#endif
19819 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19820 call \do_sym
19821 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19822 jmp paranoid_exit /* %ebx: no swapgs flag */
19823 CFI_ENDPROC
19824 -END(\sym)
19825 +ENDPROC(\sym)
19826 .endm
19827
19828 .macro errorentry sym do_sym
19829 @@ -1264,13 +1651,23 @@ ENTRY(\sym)
19830 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19831 call error_entry
19832 DEFAULT_FRAME 0
19833 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19834 + testb $3, CS(%rsp)
19835 + jnz 1f
19836 + pax_enter_kernel
19837 + jmp 2f
19838 +1: pax_enter_kernel_user
19839 +2:
19840 +#else
19841 + pax_enter_kernel
19842 +#endif
19843 movq %rsp,%rdi /* pt_regs pointer */
19844 movq ORIG_RAX(%rsp),%rsi /* get error code */
19845 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19846 call \do_sym
19847 jmp error_exit /* %ebx: no swapgs flag */
19848 CFI_ENDPROC
19849 -END(\sym)
19850 +ENDPROC(\sym)
19851 .endm
19852
19853 /* error code is on the stack already */
19854 @@ -1284,13 +1681,23 @@ ENTRY(\sym)
19855 call save_paranoid
19856 DEFAULT_FRAME 0
19857 TRACE_IRQS_OFF
19858 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19859 + testb $3, CS(%rsp)
19860 + jnz 1f
19861 + pax_enter_kernel
19862 + jmp 2f
19863 +1: pax_enter_kernel_user
19864 +2:
19865 +#else
19866 + pax_enter_kernel
19867 +#endif
19868 movq %rsp,%rdi /* pt_regs pointer */
19869 movq ORIG_RAX(%rsp),%rsi /* get error code */
19870 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19871 call \do_sym
19872 jmp paranoid_exit /* %ebx: no swapgs flag */
19873 CFI_ENDPROC
19874 -END(\sym)
19875 +ENDPROC(\sym)
19876 .endm
19877
19878 zeroentry divide_error do_divide_error
19879 @@ -1320,9 +1727,10 @@ gs_change:
19880 2: mfence /* workaround */
19881 SWAPGS
19882 popfq_cfi
19883 + pax_force_retaddr
19884 ret
19885 CFI_ENDPROC
19886 -END(native_load_gs_index)
19887 +ENDPROC(native_load_gs_index)
19888
19889 _ASM_EXTABLE(gs_change,bad_gs)
19890 .section .fixup,"ax"
19891 @@ -1350,9 +1758,10 @@ ENTRY(call_softirq)
19892 CFI_DEF_CFA_REGISTER rsp
19893 CFI_ADJUST_CFA_OFFSET -8
19894 decl PER_CPU_VAR(irq_count)
19895 + pax_force_retaddr
19896 ret
19897 CFI_ENDPROC
19898 -END(call_softirq)
19899 +ENDPROC(call_softirq)
19900
19901 #ifdef CONFIG_XEN
19902 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19903 @@ -1390,7 +1799,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19904 decl PER_CPU_VAR(irq_count)
19905 jmp error_exit
19906 CFI_ENDPROC
19907 -END(xen_do_hypervisor_callback)
19908 +ENDPROC(xen_do_hypervisor_callback)
19909
19910 /*
19911 * Hypervisor uses this for application faults while it executes.
19912 @@ -1449,7 +1858,7 @@ ENTRY(xen_failsafe_callback)
19913 SAVE_ALL
19914 jmp error_exit
19915 CFI_ENDPROC
19916 -END(xen_failsafe_callback)
19917 +ENDPROC(xen_failsafe_callback)
19918
19919 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19920 xen_hvm_callback_vector xen_evtchn_do_upcall
19921 @@ -1501,18 +1910,33 @@ ENTRY(paranoid_exit)
19922 DEFAULT_FRAME
19923 DISABLE_INTERRUPTS(CLBR_NONE)
19924 TRACE_IRQS_OFF_DEBUG
19925 - testl %ebx,%ebx /* swapgs needed? */
19926 + testl $1,%ebx /* swapgs needed? */
19927 jnz paranoid_restore
19928 - testl $3,CS(%rsp)
19929 + testb $3,CS(%rsp)
19930 jnz paranoid_userspace
19931 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19932 + pax_exit_kernel
19933 + TRACE_IRQS_IRETQ 0
19934 + SWAPGS_UNSAFE_STACK
19935 + RESTORE_ALL 8
19936 + pax_force_retaddr_bts
19937 + jmp irq_return
19938 +#endif
19939 paranoid_swapgs:
19940 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19941 + pax_exit_kernel_user
19942 +#else
19943 + pax_exit_kernel
19944 +#endif
19945 TRACE_IRQS_IRETQ 0
19946 SWAPGS_UNSAFE_STACK
19947 RESTORE_ALL 8
19948 jmp irq_return
19949 paranoid_restore:
19950 + pax_exit_kernel
19951 TRACE_IRQS_IRETQ_DEBUG 0
19952 RESTORE_ALL 8
19953 + pax_force_retaddr_bts
19954 jmp irq_return
19955 paranoid_userspace:
19956 GET_THREAD_INFO(%rcx)
19957 @@ -1541,7 +1965,7 @@ paranoid_schedule:
19958 TRACE_IRQS_OFF
19959 jmp paranoid_userspace
19960 CFI_ENDPROC
19961 -END(paranoid_exit)
19962 +ENDPROC(paranoid_exit)
19963
19964 /*
19965 * Exception entry point. This expects an error code/orig_rax on the stack.
19966 @@ -1568,12 +1992,13 @@ ENTRY(error_entry)
19967 movq_cfi r14, R14+8
19968 movq_cfi r15, R15+8
19969 xorl %ebx,%ebx
19970 - testl $3,CS+8(%rsp)
19971 + testb $3,CS+8(%rsp)
19972 je error_kernelspace
19973 error_swapgs:
19974 SWAPGS
19975 error_sti:
19976 TRACE_IRQS_OFF
19977 + pax_force_retaddr_bts
19978 ret
19979
19980 /*
19981 @@ -1600,7 +2025,7 @@ bstep_iret:
19982 movq %rcx,RIP+8(%rsp)
19983 jmp error_swapgs
19984 CFI_ENDPROC
19985 -END(error_entry)
19986 +ENDPROC(error_entry)
19987
19988
19989 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19990 @@ -1611,7 +2036,7 @@ ENTRY(error_exit)
19991 DISABLE_INTERRUPTS(CLBR_NONE)
19992 TRACE_IRQS_OFF
19993 GET_THREAD_INFO(%rcx)
19994 - testl %eax,%eax
19995 + testl $1,%eax
19996 jne retint_kernel
19997 LOCKDEP_SYS_EXIT_IRQ
19998 movl TI_flags(%rcx),%edx
19999 @@ -1620,7 +2045,7 @@ ENTRY(error_exit)
20000 jnz retint_careful
20001 jmp retint_swapgs
20002 CFI_ENDPROC
20003 -END(error_exit)
20004 +ENDPROC(error_exit)
20005
20006 /*
20007 * Test if a given stack is an NMI stack or not.
20008 @@ -1678,9 +2103,11 @@ ENTRY(nmi)
20009 * If %cs was not the kernel segment, then the NMI triggered in user
20010 * space, which means it is definitely not nested.
20011 */
20012 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20013 + je 1f
20014 cmpl $__KERNEL_CS, 16(%rsp)
20015 jne first_nmi
20016 -
20017 +1:
20018 /*
20019 * Check the special variable on the stack to see if NMIs are
20020 * executing.
20021 @@ -1714,8 +2141,7 @@ nested_nmi:
20022
20023 1:
20024 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20025 - leaq -1*8(%rsp), %rdx
20026 - movq %rdx, %rsp
20027 + subq $8, %rsp
20028 CFI_ADJUST_CFA_OFFSET 1*8
20029 leaq -10*8(%rsp), %rdx
20030 pushq_cfi $__KERNEL_DS
20031 @@ -1733,6 +2159,7 @@ nested_nmi_out:
20032 CFI_RESTORE rdx
20033
20034 /* No need to check faults here */
20035 +# pax_force_retaddr_bts
20036 INTERRUPT_RETURN
20037
20038 CFI_RESTORE_STATE
20039 @@ -1849,6 +2276,8 @@ end_repeat_nmi:
20040 */
20041 movq %cr2, %r12
20042
20043 + pax_enter_kernel_nmi
20044 +
20045 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20046 movq %rsp,%rdi
20047 movq $-1,%rsi
20048 @@ -1861,26 +2290,31 @@ end_repeat_nmi:
20049 movq %r12, %cr2
20050 1:
20051
20052 - testl %ebx,%ebx /* swapgs needed? */
20053 + testl $1,%ebx /* swapgs needed? */
20054 jnz nmi_restore
20055 nmi_swapgs:
20056 SWAPGS_UNSAFE_STACK
20057 nmi_restore:
20058 + pax_exit_kernel_nmi
20059 /* Pop the extra iret frame at once */
20060 RESTORE_ALL 6*8
20061 + testb $3, 8(%rsp)
20062 + jnz 1f
20063 + pax_force_retaddr_bts
20064 +1:
20065
20066 /* Clear the NMI executing stack variable */
20067 movq $0, 5*8(%rsp)
20068 jmp irq_return
20069 CFI_ENDPROC
20070 -END(nmi)
20071 +ENDPROC(nmi)
20072
20073 ENTRY(ignore_sysret)
20074 CFI_STARTPROC
20075 mov $-ENOSYS,%eax
20076 sysret
20077 CFI_ENDPROC
20078 -END(ignore_sysret)
20079 +ENDPROC(ignore_sysret)
20080
20081 /*
20082 * End of kprobes section
20083 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20084 index 42a392a..fbbd930 100644
20085 --- a/arch/x86/kernel/ftrace.c
20086 +++ b/arch/x86/kernel/ftrace.c
20087 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20088 {
20089 unsigned char replaced[MCOUNT_INSN_SIZE];
20090
20091 + ip = ktla_ktva(ip);
20092 +
20093 /*
20094 * Note: Due to modules and __init, code can
20095 * disappear and change, we need to protect against faulting
20096 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20097 unsigned char old[MCOUNT_INSN_SIZE], *new;
20098 int ret;
20099
20100 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20101 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20102 new = ftrace_call_replace(ip, (unsigned long)func);
20103
20104 /* See comment above by declaration of modifying_ftrace_code */
20105 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20106 /* Also update the regs callback function */
20107 if (!ret) {
20108 ip = (unsigned long)(&ftrace_regs_call);
20109 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20110 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20111 new = ftrace_call_replace(ip, (unsigned long)func);
20112 ret = ftrace_modify_code(ip, old, new);
20113 }
20114 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20115 * kernel identity mapping to modify code.
20116 */
20117 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20118 - ip = (unsigned long)__va(__pa_symbol(ip));
20119 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20120
20121 return probe_kernel_write((void *)ip, val, size);
20122 }
20123 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20124 unsigned char replaced[MCOUNT_INSN_SIZE];
20125 unsigned char brk = BREAKPOINT_INSTRUCTION;
20126
20127 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20128 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20129 return -EFAULT;
20130
20131 /* Make sure it is what we expect it to be */
20132 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20133 return ret;
20134
20135 fail_update:
20136 - probe_kernel_write((void *)ip, &old_code[0], 1);
20137 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20138 goto out;
20139 }
20140
20141 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20142 {
20143 unsigned char code[MCOUNT_INSN_SIZE];
20144
20145 + ip = ktla_ktva(ip);
20146 +
20147 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20148 return -EFAULT;
20149
20150 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20151 index 55b6761..a6456fc 100644
20152 --- a/arch/x86/kernel/head64.c
20153 +++ b/arch/x86/kernel/head64.c
20154 @@ -67,12 +67,12 @@ again:
20155 pgd = *pgd_p;
20156
20157 /*
20158 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
20159 - * critical -- __PAGE_OFFSET would point us back into the dynamic
20160 + * The use of __early_va rather than __va here is critical:
20161 + * __va would point us back into the dynamic
20162 * range and we might end up looping forever...
20163 */
20164 if (pgd)
20165 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20166 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
20167 else {
20168 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20169 reset_early_page_tables();
20170 @@ -82,13 +82,13 @@ again:
20171 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
20172 for (i = 0; i < PTRS_PER_PUD; i++)
20173 pud_p[i] = 0;
20174 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20175 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
20176 }
20177 pud_p += pud_index(address);
20178 pud = *pud_p;
20179
20180 if (pud)
20181 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20182 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
20183 else {
20184 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20185 reset_early_page_tables();
20186 @@ -98,7 +98,7 @@ again:
20187 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
20188 for (i = 0; i < PTRS_PER_PMD; i++)
20189 pmd_p[i] = 0;
20190 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20191 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
20192 }
20193 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
20194 pmd_p[pmd_index(address)] = pmd;
20195 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20196 if (console_loglevel == 10)
20197 early_printk("Kernel alive\n");
20198
20199 - clear_page(init_level4_pgt);
20200 /* set init_level4_pgt kernel high mapping*/
20201 init_level4_pgt[511] = early_level4_pgt[511];
20202
20203 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20204 index 73afd11..d1670f5 100644
20205 --- a/arch/x86/kernel/head_32.S
20206 +++ b/arch/x86/kernel/head_32.S
20207 @@ -26,6 +26,12 @@
20208 /* Physical address */
20209 #define pa(X) ((X) - __PAGE_OFFSET)
20210
20211 +#ifdef CONFIG_PAX_KERNEXEC
20212 +#define ta(X) (X)
20213 +#else
20214 +#define ta(X) ((X) - __PAGE_OFFSET)
20215 +#endif
20216 +
20217 /*
20218 * References to members of the new_cpu_data structure.
20219 */
20220 @@ -55,11 +61,7 @@
20221 * and small than max_low_pfn, otherwise will waste some page table entries
20222 */
20223
20224 -#if PTRS_PER_PMD > 1
20225 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20226 -#else
20227 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20228 -#endif
20229 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20230
20231 /* Number of possible pages in the lowmem region */
20232 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20233 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20234 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20235
20236 /*
20237 + * Real beginning of normal "text" segment
20238 + */
20239 +ENTRY(stext)
20240 +ENTRY(_stext)
20241 +
20242 +/*
20243 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20244 * %esi points to the real-mode code as a 32-bit pointer.
20245 * CS and DS must be 4 GB flat segments, but we don't depend on
20246 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20247 * can.
20248 */
20249 __HEAD
20250 +
20251 +#ifdef CONFIG_PAX_KERNEXEC
20252 + jmp startup_32
20253 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20254 +.fill PAGE_SIZE-5,1,0xcc
20255 +#endif
20256 +
20257 ENTRY(startup_32)
20258 movl pa(stack_start),%ecx
20259
20260 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20261 2:
20262 leal -__PAGE_OFFSET(%ecx),%esp
20263
20264 +#ifdef CONFIG_SMP
20265 + movl $pa(cpu_gdt_table),%edi
20266 + movl $__per_cpu_load,%eax
20267 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20268 + rorl $16,%eax
20269 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20270 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20271 + movl $__per_cpu_end - 1,%eax
20272 + subl $__per_cpu_start,%eax
20273 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20274 +#endif
20275 +
20276 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20277 + movl $NR_CPUS,%ecx
20278 + movl $pa(cpu_gdt_table),%edi
20279 +1:
20280 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20281 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20282 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20283 + addl $PAGE_SIZE_asm,%edi
20284 + loop 1b
20285 +#endif
20286 +
20287 +#ifdef CONFIG_PAX_KERNEXEC
20288 + movl $pa(boot_gdt),%edi
20289 + movl $__LOAD_PHYSICAL_ADDR,%eax
20290 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20291 + rorl $16,%eax
20292 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20293 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20294 + rorl $16,%eax
20295 +
20296 + ljmp $(__BOOT_CS),$1f
20297 +1:
20298 +
20299 + movl $NR_CPUS,%ecx
20300 + movl $pa(cpu_gdt_table),%edi
20301 + addl $__PAGE_OFFSET,%eax
20302 +1:
20303 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20304 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20305 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20306 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20307 + rorl $16,%eax
20308 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20309 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20310 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20311 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20312 + rorl $16,%eax
20313 + addl $PAGE_SIZE_asm,%edi
20314 + loop 1b
20315 +#endif
20316 +
20317 /*
20318 * Clear BSS first so that there are no surprises...
20319 */
20320 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20321 movl %eax, pa(max_pfn_mapped)
20322
20323 /* Do early initialization of the fixmap area */
20324 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20325 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20326 +#ifdef CONFIG_COMPAT_VDSO
20327 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20328 +#else
20329 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20330 +#endif
20331 #else /* Not PAE */
20332
20333 page_pde_offset = (__PAGE_OFFSET >> 20);
20334 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20335 movl %eax, pa(max_pfn_mapped)
20336
20337 /* Do early initialization of the fixmap area */
20338 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20339 - movl %eax,pa(initial_page_table+0xffc)
20340 +#ifdef CONFIG_COMPAT_VDSO
20341 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20342 +#else
20343 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20344 +#endif
20345 #endif
20346
20347 #ifdef CONFIG_PARAVIRT
20348 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20349 cmpl $num_subarch_entries, %eax
20350 jae bad_subarch
20351
20352 - movl pa(subarch_entries)(,%eax,4), %eax
20353 - subl $__PAGE_OFFSET, %eax
20354 - jmp *%eax
20355 + jmp *pa(subarch_entries)(,%eax,4)
20356
20357 bad_subarch:
20358 WEAK(lguest_entry)
20359 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20360 __INITDATA
20361
20362 subarch_entries:
20363 - .long default_entry /* normal x86/PC */
20364 - .long lguest_entry /* lguest hypervisor */
20365 - .long xen_entry /* Xen hypervisor */
20366 - .long default_entry /* Moorestown MID */
20367 + .long ta(default_entry) /* normal x86/PC */
20368 + .long ta(lguest_entry) /* lguest hypervisor */
20369 + .long ta(xen_entry) /* Xen hypervisor */
20370 + .long ta(default_entry) /* Moorestown MID */
20371 num_subarch_entries = (. - subarch_entries) / 4
20372 .previous
20373 #else
20374 @@ -355,6 +427,7 @@ default_entry:
20375 movl pa(mmu_cr4_features),%eax
20376 movl %eax,%cr4
20377
20378 +#ifdef CONFIG_X86_PAE
20379 testb $X86_CR4_PAE, %al # check if PAE is enabled
20380 jz enable_paging
20381
20382 @@ -383,6 +456,9 @@ default_entry:
20383 /* Make changes effective */
20384 wrmsr
20385
20386 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20387 +#endif
20388 +
20389 enable_paging:
20390
20391 /*
20392 @@ -451,14 +527,20 @@ is486:
20393 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20394 movl %eax,%ss # after changing gdt.
20395
20396 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20397 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20398 movl %eax,%ds
20399 movl %eax,%es
20400
20401 movl $(__KERNEL_PERCPU), %eax
20402 movl %eax,%fs # set this cpu's percpu
20403
20404 +#ifdef CONFIG_CC_STACKPROTECTOR
20405 movl $(__KERNEL_STACK_CANARY),%eax
20406 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20407 + movl $(__USER_DS),%eax
20408 +#else
20409 + xorl %eax,%eax
20410 +#endif
20411 movl %eax,%gs
20412
20413 xorl %eax,%eax # Clear LDT
20414 @@ -534,8 +616,11 @@ setup_once:
20415 * relocation. Manually set base address in stack canary
20416 * segment descriptor.
20417 */
20418 - movl $gdt_page,%eax
20419 + movl $cpu_gdt_table,%eax
20420 movl $stack_canary,%ecx
20421 +#ifdef CONFIG_SMP
20422 + addl $__per_cpu_load,%ecx
20423 +#endif
20424 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20425 shrl $16, %ecx
20426 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20427 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20428 /* This is global to keep gas from relaxing the jumps */
20429 ENTRY(early_idt_handler)
20430 cld
20431 - cmpl $2,%ss:early_recursion_flag
20432 + cmpl $1,%ss:early_recursion_flag
20433 je hlt_loop
20434 incl %ss:early_recursion_flag
20435
20436 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20437 pushl (20+6*4)(%esp) /* trapno */
20438 pushl $fault_msg
20439 call printk
20440 -#endif
20441 call dump_stack
20442 +#endif
20443 hlt_loop:
20444 hlt
20445 jmp hlt_loop
20446 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20447 /* This is the default interrupt "handler" :-) */
20448 ALIGN
20449 ignore_int:
20450 - cld
20451 #ifdef CONFIG_PRINTK
20452 + cmpl $2,%ss:early_recursion_flag
20453 + je hlt_loop
20454 + incl %ss:early_recursion_flag
20455 + cld
20456 pushl %eax
20457 pushl %ecx
20458 pushl %edx
20459 @@ -634,9 +722,6 @@ ignore_int:
20460 movl $(__KERNEL_DS),%eax
20461 movl %eax,%ds
20462 movl %eax,%es
20463 - cmpl $2,early_recursion_flag
20464 - je hlt_loop
20465 - incl early_recursion_flag
20466 pushl 16(%esp)
20467 pushl 24(%esp)
20468 pushl 32(%esp)
20469 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20470 /*
20471 * BSS section
20472 */
20473 -__PAGE_ALIGNED_BSS
20474 - .align PAGE_SIZE
20475 #ifdef CONFIG_X86_PAE
20476 +.section .initial_pg_pmd,"a",@progbits
20477 initial_pg_pmd:
20478 .fill 1024*KPMDS,4,0
20479 #else
20480 +.section .initial_page_table,"a",@progbits
20481 ENTRY(initial_page_table)
20482 .fill 1024,4,0
20483 #endif
20484 +.section .initial_pg_fixmap,"a",@progbits
20485 initial_pg_fixmap:
20486 .fill 1024,4,0
20487 +.section .empty_zero_page,"a",@progbits
20488 ENTRY(empty_zero_page)
20489 .fill 4096,1,0
20490 +.section .swapper_pg_dir,"a",@progbits
20491 ENTRY(swapper_pg_dir)
20492 +#ifdef CONFIG_X86_PAE
20493 + .fill 4,8,0
20494 +#else
20495 .fill 1024,4,0
20496 +#endif
20497 +
20498 +/*
20499 + * The IDT has to be page-aligned to simplify the Pentium
20500 + * F0 0F bug workaround.. We have a special link segment
20501 + * for this.
20502 + */
20503 +.section .idt,"a",@progbits
20504 +ENTRY(idt_table)
20505 + .fill 256,8,0
20506
20507 /*
20508 * This starts the data section.
20509 */
20510 #ifdef CONFIG_X86_PAE
20511 -__PAGE_ALIGNED_DATA
20512 - /* Page-aligned for the benefit of paravirt? */
20513 - .align PAGE_SIZE
20514 +.section .initial_page_table,"a",@progbits
20515 ENTRY(initial_page_table)
20516 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20517 # if KPMDS == 3
20518 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20519 # error "Kernel PMDs should be 1, 2 or 3"
20520 # endif
20521 .align PAGE_SIZE /* needs to be page-sized too */
20522 +
20523 +#ifdef CONFIG_PAX_PER_CPU_PGD
20524 +ENTRY(cpu_pgd)
20525 + .rept NR_CPUS
20526 + .fill 4,8,0
20527 + .endr
20528 +#endif
20529 +
20530 #endif
20531
20532 .data
20533 .balign 4
20534 ENTRY(stack_start)
20535 - .long init_thread_union+THREAD_SIZE
20536 + .long init_thread_union+THREAD_SIZE-8
20537
20538 __INITRODATA
20539 int_msg:
20540 @@ -744,7 +851,7 @@ fault_msg:
20541 * segment size, and 32-bit linear address value:
20542 */
20543
20544 - .data
20545 +.section .rodata,"a",@progbits
20546 .globl boot_gdt_descr
20547 .globl idt_descr
20548
20549 @@ -753,7 +860,7 @@ fault_msg:
20550 .word 0 # 32 bit align gdt_desc.address
20551 boot_gdt_descr:
20552 .word __BOOT_DS+7
20553 - .long boot_gdt - __PAGE_OFFSET
20554 + .long pa(boot_gdt)
20555
20556 .word 0 # 32-bit align idt_desc.address
20557 idt_descr:
20558 @@ -764,7 +871,7 @@ idt_descr:
20559 .word 0 # 32 bit align gdt_desc.address
20560 ENTRY(early_gdt_descr)
20561 .word GDT_ENTRIES*8-1
20562 - .long gdt_page /* Overwritten for secondary CPUs */
20563 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20564
20565 /*
20566 * The boot_gdt must mirror the equivalent in setup.S and is
20567 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20568 .align L1_CACHE_BYTES
20569 ENTRY(boot_gdt)
20570 .fill GDT_ENTRY_BOOT_CS,8,0
20571 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20572 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20573 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20574 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20575 +
20576 + .align PAGE_SIZE_asm
20577 +ENTRY(cpu_gdt_table)
20578 + .rept NR_CPUS
20579 + .quad 0x0000000000000000 /* NULL descriptor */
20580 + .quad 0x0000000000000000 /* 0x0b reserved */
20581 + .quad 0x0000000000000000 /* 0x13 reserved */
20582 + .quad 0x0000000000000000 /* 0x1b reserved */
20583 +
20584 +#ifdef CONFIG_PAX_KERNEXEC
20585 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20586 +#else
20587 + .quad 0x0000000000000000 /* 0x20 unused */
20588 +#endif
20589 +
20590 + .quad 0x0000000000000000 /* 0x28 unused */
20591 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20592 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20593 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20594 + .quad 0x0000000000000000 /* 0x4b reserved */
20595 + .quad 0x0000000000000000 /* 0x53 reserved */
20596 + .quad 0x0000000000000000 /* 0x5b reserved */
20597 +
20598 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20599 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20600 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20601 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20602 +
20603 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20604 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20605 +
20606 + /*
20607 + * Segments used for calling PnP BIOS have byte granularity.
20608 + * The code segments and data segments have fixed 64k limits,
20609 + * the transfer segment sizes are set at run time.
20610 + */
20611 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20612 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20613 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20614 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20615 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20616 +
20617 + /*
20618 + * The APM segments have byte granularity and their bases
20619 + * are set at run time. All have 64k limits.
20620 + */
20621 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20622 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20623 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20624 +
20625 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20626 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20627 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20628 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20629 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20630 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20631 +
20632 + /* Be sure this is zeroed to avoid false validations in Xen */
20633 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20634 + .endr
20635 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20636 index a836860..bdeb7a5 100644
20637 --- a/arch/x86/kernel/head_64.S
20638 +++ b/arch/x86/kernel/head_64.S
20639 @@ -20,6 +20,8 @@
20640 #include <asm/processor-flags.h>
20641 #include <asm/percpu.h>
20642 #include <asm/nops.h>
20643 +#include <asm/cpufeature.h>
20644 +#include <asm/alternative-asm.h>
20645
20646 #ifdef CONFIG_PARAVIRT
20647 #include <asm/asm-offsets.h>
20648 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20649 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20650 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20651 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20652 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20653 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20654 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20655 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20656 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20657 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20658
20659 .text
20660 __HEAD
20661 @@ -89,11 +97,23 @@ startup_64:
20662 * Fixup the physical addresses in the page table
20663 */
20664 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20665 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20666 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20667 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20668 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20669 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20670
20671 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20672 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20673 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
20674 +#ifndef CONFIG_XEN
20675 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
20676 +#endif
20677
20678 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20679 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20680 +
20681 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20682 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
20683 +
20684 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20685
20686 /*
20687 * Set up the identity mapping for the switchover. These
20688 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
20689 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20690 1:
20691
20692 - /* Enable PAE mode and PGE */
20693 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20694 + /* Enable PAE mode and PSE/PGE */
20695 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20696 movq %rcx, %cr4
20697
20698 /* Setup early boot stage 4 level pagetables. */
20699 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
20700 movl $MSR_EFER, %ecx
20701 rdmsr
20702 btsl $_EFER_SCE, %eax /* Enable System Call */
20703 - btl $20,%edi /* No Execute supported? */
20704 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20705 jnc 1f
20706 btsl $_EFER_NX, %eax
20707 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20708 + leaq init_level4_pgt(%rip), %rdi
20709 +#ifndef CONFIG_EFI
20710 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20711 +#endif
20712 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20713 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20714 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20715 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20716 1: wrmsr /* Make changes effective */
20717
20718 /* Setup cr0 */
20719 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
20720 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20721 * address given in m16:64.
20722 */
20723 + pax_set_fptr_mask
20724 movq initial_code(%rip),%rax
20725 pushq $0 # fake return address to stop unwinder
20726 pushq $__KERNEL_CS # set correct cs
20727 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
20728 call dump_stack
20729 #ifdef CONFIG_KALLSYMS
20730 leaq early_idt_ripmsg(%rip),%rdi
20731 - movq 40(%rsp),%rsi # %rip again
20732 + movq 88(%rsp),%rsi # %rip again
20733 call __print_symbol
20734 #endif
20735 #endif /* EARLY_PRINTK */
20736 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
20737 early_recursion_flag:
20738 .long 0
20739
20740 + .section .rodata,"a",@progbits
20741 #ifdef CONFIG_EARLY_PRINTK
20742 early_idt_msg:
20743 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20744 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
20745 NEXT_PAGE(early_dynamic_pgts)
20746 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
20747
20748 - .data
20749 + .section .rodata,"a",@progbits
20750
20751 -#ifndef CONFIG_XEN
20752 NEXT_PAGE(init_level4_pgt)
20753 - .fill 512,8,0
20754 -#else
20755 -NEXT_PAGE(init_level4_pgt)
20756 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20757 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20758 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20759 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20760 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20761 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20762 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20763 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20764 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20765 .org init_level4_pgt + L4_START_KERNEL*8, 0
20766 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20767 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20768
20769 +#ifdef CONFIG_PAX_PER_CPU_PGD
20770 +NEXT_PAGE(cpu_pgd)
20771 + .rept NR_CPUS
20772 + .fill 512,8,0
20773 + .endr
20774 +#endif
20775 +
20776 NEXT_PAGE(level3_ident_pgt)
20777 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20778 +#ifdef CONFIG_XEN
20779 .fill 511, 8, 0
20780 +#else
20781 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20782 + .fill 510,8,0
20783 +#endif
20784 +
20785 +NEXT_PAGE(level3_vmalloc_start_pgt)
20786 + .fill 512,8,0
20787 +
20788 +NEXT_PAGE(level3_vmalloc_end_pgt)
20789 + .fill 512,8,0
20790 +
20791 +NEXT_PAGE(level3_vmemmap_pgt)
20792 + .fill L3_VMEMMAP_START,8,0
20793 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20794 +
20795 NEXT_PAGE(level2_ident_pgt)
20796 - /* Since I easily can, map the first 1G.
20797 + /* Since I easily can, map the first 2G.
20798 * Don't set NX because code runs from these pages.
20799 */
20800 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20801 -#endif
20802 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20803
20804 NEXT_PAGE(level3_kernel_pgt)
20805 .fill L3_START_KERNEL,8,0
20806 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
20807 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20808 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20809
20810 +NEXT_PAGE(level2_vmemmap_pgt)
20811 + .fill 512,8,0
20812 +
20813 NEXT_PAGE(level2_kernel_pgt)
20814 /*
20815 * 512 MB kernel mapping. We spend a full page on this pagetable
20816 @@ -488,39 +544,64 @@ NEXT_PAGE(level2_kernel_pgt)
20817 KERNEL_IMAGE_SIZE/PMD_SIZE)
20818
20819 NEXT_PAGE(level2_fixmap_pgt)
20820 - .fill 506,8,0
20821 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20822 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20823 - .fill 5,8,0
20824 + .fill 507,8,0
20825 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20826 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20827 + .fill 4,8,0
20828
20829 -NEXT_PAGE(level1_fixmap_pgt)
20830 +NEXT_PAGE(level1_vsyscall_pgt)
20831 .fill 512,8,0
20832
20833 #undef PMDS
20834
20835 - .data
20836 + .align PAGE_SIZE
20837 +ENTRY(cpu_gdt_table)
20838 + .rept NR_CPUS
20839 + .quad 0x0000000000000000 /* NULL descriptor */
20840 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20841 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20842 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20843 + .quad 0x00cffb000000ffff /* __USER32_CS */
20844 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20845 + .quad 0x00affb000000ffff /* __USER_CS */
20846 +
20847 +#ifdef CONFIG_PAX_KERNEXEC
20848 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20849 +#else
20850 + .quad 0x0 /* unused */
20851 +#endif
20852 +
20853 + .quad 0,0 /* TSS */
20854 + .quad 0,0 /* LDT */
20855 + .quad 0,0,0 /* three TLS descriptors */
20856 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20857 + /* asm/segment.h:GDT_ENTRIES must match this */
20858 +
20859 + /* zero the remaining page */
20860 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20861 + .endr
20862 +
20863 .align 16
20864 .globl early_gdt_descr
20865 early_gdt_descr:
20866 .word GDT_ENTRIES*8-1
20867 early_gdt_descr_base:
20868 - .quad INIT_PER_CPU_VAR(gdt_page)
20869 + .quad cpu_gdt_table
20870
20871 ENTRY(phys_base)
20872 /* This must match the first entry in level2_kernel_pgt */
20873 .quad 0x0000000000000000
20874
20875 #include "../../x86/xen/xen-head.S"
20876 -
20877 - .section .bss, "aw", @nobits
20878 +
20879 + .section .rodata,"a",@progbits
20880 +NEXT_PAGE(empty_zero_page)
20881 + .skip PAGE_SIZE
20882 +
20883 .align PAGE_SIZE
20884 ENTRY(idt_table)
20885 - .skip IDT_ENTRIES * 16
20886 + .fill 512,8,0
20887
20888 .align L1_CACHE_BYTES
20889 ENTRY(nmi_idt_table)
20890 - .skip IDT_ENTRIES * 16
20891 -
20892 - __PAGE_ALIGNED_BSS
20893 -NEXT_PAGE(empty_zero_page)
20894 - .skip PAGE_SIZE
20895 + .fill 512,8,0
20896 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20897 index 0fa6912..37fce70 100644
20898 --- a/arch/x86/kernel/i386_ksyms_32.c
20899 +++ b/arch/x86/kernel/i386_ksyms_32.c
20900 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20901 EXPORT_SYMBOL(cmpxchg8b_emu);
20902 #endif
20903
20904 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20905 +
20906 /* Networking helper routines. */
20907 EXPORT_SYMBOL(csum_partial_copy_generic);
20908 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20909 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20910
20911 EXPORT_SYMBOL(__get_user_1);
20912 EXPORT_SYMBOL(__get_user_2);
20913 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20914
20915 EXPORT_SYMBOL(csum_partial);
20916 EXPORT_SYMBOL(empty_zero_page);
20917 +
20918 +#ifdef CONFIG_PAX_KERNEXEC
20919 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20920 +#endif
20921 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20922 index cb33909..1163b40 100644
20923 --- a/arch/x86/kernel/i387.c
20924 +++ b/arch/x86/kernel/i387.c
20925 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20926 static inline bool interrupted_user_mode(void)
20927 {
20928 struct pt_regs *regs = get_irq_regs();
20929 - return regs && user_mode_vm(regs);
20930 + return regs && user_mode(regs);
20931 }
20932
20933 /*
20934 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20935 index 9a5c460..84868423 100644
20936 --- a/arch/x86/kernel/i8259.c
20937 +++ b/arch/x86/kernel/i8259.c
20938 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20939 static void make_8259A_irq(unsigned int irq)
20940 {
20941 disable_irq_nosync(irq);
20942 - io_apic_irqs &= ~(1<<irq);
20943 + io_apic_irqs &= ~(1UL<<irq);
20944 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20945 i8259A_chip.name);
20946 enable_irq(irq);
20947 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20948 "spurious 8259A interrupt: IRQ%d.\n", irq);
20949 spurious_irq_mask |= irqmask;
20950 }
20951 - atomic_inc(&irq_err_count);
20952 + atomic_inc_unchecked(&irq_err_count);
20953 /*
20954 * Theoretically we do not have to handle this IRQ,
20955 * but in Linux this does not cause problems and is
20956 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20957 /* (slave's support for AEOI in flat mode is to be investigated) */
20958 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20959
20960 + pax_open_kernel();
20961 if (auto_eoi)
20962 /*
20963 * In AEOI mode we just have to mask the interrupt
20964 * when acking.
20965 */
20966 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20967 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20968 else
20969 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20970 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20971 + pax_close_kernel();
20972
20973 udelay(100); /* wait for 8259A to initialize */
20974
20975 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20976 index a979b5b..1d6db75 100644
20977 --- a/arch/x86/kernel/io_delay.c
20978 +++ b/arch/x86/kernel/io_delay.c
20979 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20980 * Quirk table for systems that misbehave (lock up, etc.) if port
20981 * 0x80 is used:
20982 */
20983 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20984 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20985 {
20986 .callback = dmi_io_delay_0xed_port,
20987 .ident = "Compaq Presario V6000",
20988 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20989 index 4ddaf66..6292f4e 100644
20990 --- a/arch/x86/kernel/ioport.c
20991 +++ b/arch/x86/kernel/ioport.c
20992 @@ -6,6 +6,7 @@
20993 #include <linux/sched.h>
20994 #include <linux/kernel.h>
20995 #include <linux/capability.h>
20996 +#include <linux/security.h>
20997 #include <linux/errno.h>
20998 #include <linux/types.h>
20999 #include <linux/ioport.h>
21000 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21001
21002 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21003 return -EINVAL;
21004 +#ifdef CONFIG_GRKERNSEC_IO
21005 + if (turn_on && grsec_disable_privio) {
21006 + gr_handle_ioperm();
21007 + return -EPERM;
21008 + }
21009 +#endif
21010 if (turn_on && !capable(CAP_SYS_RAWIO))
21011 return -EPERM;
21012
21013 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21014 * because the ->io_bitmap_max value must match the bitmap
21015 * contents:
21016 */
21017 - tss = &per_cpu(init_tss, get_cpu());
21018 + tss = init_tss + get_cpu();
21019
21020 if (turn_on)
21021 bitmap_clear(t->io_bitmap_ptr, from, num);
21022 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
21023 return -EINVAL;
21024 /* Trying to gain more privileges? */
21025 if (level > old) {
21026 +#ifdef CONFIG_GRKERNSEC_IO
21027 + if (grsec_disable_privio) {
21028 + gr_handle_iopl();
21029 + return -EPERM;
21030 + }
21031 +#endif
21032 if (!capable(CAP_SYS_RAWIO))
21033 return -EPERM;
21034 }
21035 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21036 index ac0631d..ff7cb62 100644
21037 --- a/arch/x86/kernel/irq.c
21038 +++ b/arch/x86/kernel/irq.c
21039 @@ -18,7 +18,7 @@
21040 #include <asm/mce.h>
21041 #include <asm/hw_irq.h>
21042
21043 -atomic_t irq_err_count;
21044 +atomic_unchecked_t irq_err_count;
21045
21046 /* Function pointer for generic interrupt vector handling */
21047 void (*x86_platform_ipi_callback)(void) = NULL;
21048 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21049 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21050 seq_printf(p, " Machine check polls\n");
21051 #endif
21052 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21053 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21054 #if defined(CONFIG_X86_IO_APIC)
21055 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21056 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21057 #endif
21058 return 0;
21059 }
21060 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21061
21062 u64 arch_irq_stat(void)
21063 {
21064 - u64 sum = atomic_read(&irq_err_count);
21065 + u64 sum = atomic_read_unchecked(&irq_err_count);
21066 return sum;
21067 }
21068
21069 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21070 index 344faf8..355f60d 100644
21071 --- a/arch/x86/kernel/irq_32.c
21072 +++ b/arch/x86/kernel/irq_32.c
21073 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21074 __asm__ __volatile__("andl %%esp,%0" :
21075 "=r" (sp) : "0" (THREAD_SIZE - 1));
21076
21077 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21078 + return sp < STACK_WARN;
21079 }
21080
21081 static void print_stack_overflow(void)
21082 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21083 * per-CPU IRQ handling contexts (thread information and stack)
21084 */
21085 union irq_ctx {
21086 - struct thread_info tinfo;
21087 - u32 stack[THREAD_SIZE/sizeof(u32)];
21088 + unsigned long previous_esp;
21089 + u32 stack[THREAD_SIZE/sizeof(u32)];
21090 } __attribute__((aligned(THREAD_SIZE)));
21091
21092 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21093 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21094 static inline int
21095 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21096 {
21097 - union irq_ctx *curctx, *irqctx;
21098 + union irq_ctx *irqctx;
21099 u32 *isp, arg1, arg2;
21100
21101 - curctx = (union irq_ctx *) current_thread_info();
21102 irqctx = __this_cpu_read(hardirq_ctx);
21103
21104 /*
21105 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21106 * handler) we can't do that and just have to keep using the
21107 * current stack (which is the irq stack already after all)
21108 */
21109 - if (unlikely(curctx == irqctx))
21110 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21111 return 0;
21112
21113 /* build the stack frame on the IRQ stack */
21114 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21115 - irqctx->tinfo.task = curctx->tinfo.task;
21116 - irqctx->tinfo.previous_esp = current_stack_pointer;
21117 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21118 + irqctx->previous_esp = current_stack_pointer;
21119
21120 - /* Copy the preempt_count so that the [soft]irq checks work. */
21121 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21122 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21123 + __set_fs(MAKE_MM_SEG(0));
21124 +#endif
21125
21126 if (unlikely(overflow))
21127 call_on_stack(print_stack_overflow, isp);
21128 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21129 : "0" (irq), "1" (desc), "2" (isp),
21130 "D" (desc->handle_irq)
21131 : "memory", "cc", "ecx");
21132 +
21133 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21134 + __set_fs(current_thread_info()->addr_limit);
21135 +#endif
21136 +
21137 return 1;
21138 }
21139
21140 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21141 */
21142 void __cpuinit irq_ctx_init(int cpu)
21143 {
21144 - union irq_ctx *irqctx;
21145 -
21146 if (per_cpu(hardirq_ctx, cpu))
21147 return;
21148
21149 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21150 - THREADINFO_GFP,
21151 - THREAD_SIZE_ORDER));
21152 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21153 - irqctx->tinfo.cpu = cpu;
21154 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21155 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21156 -
21157 - per_cpu(hardirq_ctx, cpu) = irqctx;
21158 -
21159 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21160 - THREADINFO_GFP,
21161 - THREAD_SIZE_ORDER));
21162 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21163 - irqctx->tinfo.cpu = cpu;
21164 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21165 -
21166 - per_cpu(softirq_ctx, cpu) = irqctx;
21167 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21168 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21169 +
21170 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21171 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21172
21173 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21174 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21175 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21176 asmlinkage void do_softirq(void)
21177 {
21178 unsigned long flags;
21179 - struct thread_info *curctx;
21180 union irq_ctx *irqctx;
21181 u32 *isp;
21182
21183 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21184 local_irq_save(flags);
21185
21186 if (local_softirq_pending()) {
21187 - curctx = current_thread_info();
21188 irqctx = __this_cpu_read(softirq_ctx);
21189 - irqctx->tinfo.task = curctx->task;
21190 - irqctx->tinfo.previous_esp = current_stack_pointer;
21191 + irqctx->previous_esp = current_stack_pointer;
21192
21193 /* build the stack frame on the softirq stack */
21194 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21195 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21196 +
21197 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21198 + __set_fs(MAKE_MM_SEG(0));
21199 +#endif
21200
21201 call_on_stack(__do_softirq, isp);
21202 +
21203 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21204 + __set_fs(current_thread_info()->addr_limit);
21205 +#endif
21206 +
21207 /*
21208 * Shouldn't happen, we returned above if in_interrupt():
21209 */
21210 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21211 if (unlikely(!desc))
21212 return false;
21213
21214 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21215 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21216 if (unlikely(overflow))
21217 print_stack_overflow();
21218 desc->handle_irq(irq, desc);
21219 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21220 index d04d3ec..ea4b374 100644
21221 --- a/arch/x86/kernel/irq_64.c
21222 +++ b/arch/x86/kernel/irq_64.c
21223 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21224 u64 estack_top, estack_bottom;
21225 u64 curbase = (u64)task_stack_page(current);
21226
21227 - if (user_mode_vm(regs))
21228 + if (user_mode(regs))
21229 return;
21230
21231 if (regs->sp >= curbase + sizeof(struct thread_info) +
21232 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21233 index dc1404b..bbc43e7 100644
21234 --- a/arch/x86/kernel/kdebugfs.c
21235 +++ b/arch/x86/kernel/kdebugfs.c
21236 @@ -27,7 +27,7 @@ struct setup_data_node {
21237 u32 len;
21238 };
21239
21240 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21241 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21242 size_t count, loff_t *ppos)
21243 {
21244 struct setup_data_node *node = file->private_data;
21245 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21246 index 836f832..a8bda67 100644
21247 --- a/arch/x86/kernel/kgdb.c
21248 +++ b/arch/x86/kernel/kgdb.c
21249 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21250 #ifdef CONFIG_X86_32
21251 switch (regno) {
21252 case GDB_SS:
21253 - if (!user_mode_vm(regs))
21254 + if (!user_mode(regs))
21255 *(unsigned long *)mem = __KERNEL_DS;
21256 break;
21257 case GDB_SP:
21258 - if (!user_mode_vm(regs))
21259 + if (!user_mode(regs))
21260 *(unsigned long *)mem = kernel_stack_pointer(regs);
21261 break;
21262 case GDB_GS:
21263 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21264 bp->attr.bp_addr = breakinfo[breakno].addr;
21265 bp->attr.bp_len = breakinfo[breakno].len;
21266 bp->attr.bp_type = breakinfo[breakno].type;
21267 - info->address = breakinfo[breakno].addr;
21268 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21269 + info->address = ktla_ktva(breakinfo[breakno].addr);
21270 + else
21271 + info->address = breakinfo[breakno].addr;
21272 info->len = breakinfo[breakno].len;
21273 info->type = breakinfo[breakno].type;
21274 val = arch_install_hw_breakpoint(bp);
21275 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21276 case 'k':
21277 /* clear the trace bit */
21278 linux_regs->flags &= ~X86_EFLAGS_TF;
21279 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21280 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21281
21282 /* set the trace bit if we're stepping */
21283 if (remcomInBuffer[0] == 's') {
21284 linux_regs->flags |= X86_EFLAGS_TF;
21285 - atomic_set(&kgdb_cpu_doing_single_step,
21286 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21287 raw_smp_processor_id());
21288 }
21289
21290 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21291
21292 switch (cmd) {
21293 case DIE_DEBUG:
21294 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21295 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21296 if (user_mode(regs))
21297 return single_step_cont(regs, args);
21298 break;
21299 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21300 #endif /* CONFIG_DEBUG_RODATA */
21301
21302 bpt->type = BP_BREAKPOINT;
21303 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21304 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21305 BREAK_INSTR_SIZE);
21306 if (err)
21307 return err;
21308 - err = probe_kernel_write((char *)bpt->bpt_addr,
21309 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21310 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21311 #ifdef CONFIG_DEBUG_RODATA
21312 if (!err)
21313 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21314 return -EBUSY;
21315 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21316 BREAK_INSTR_SIZE);
21317 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21318 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21319 if (err)
21320 return err;
21321 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21322 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21323 if (mutex_is_locked(&text_mutex))
21324 goto knl_write;
21325 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21326 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21327 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21328 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21329 goto knl_write;
21330 return err;
21331 knl_write:
21332 #endif /* CONFIG_DEBUG_RODATA */
21333 - return probe_kernel_write((char *)bpt->bpt_addr,
21334 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21335 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21336 }
21337
21338 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21339 index 211bce4..6e2580a 100644
21340 --- a/arch/x86/kernel/kprobes/core.c
21341 +++ b/arch/x86/kernel/kprobes/core.c
21342 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21343 s32 raddr;
21344 } __packed *insn;
21345
21346 - insn = (struct __arch_relative_insn *)from;
21347 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21348 +
21349 + pax_open_kernel();
21350 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21351 insn->op = op;
21352 + pax_close_kernel();
21353 }
21354
21355 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21356 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21357 kprobe_opcode_t opcode;
21358 kprobe_opcode_t *orig_opcodes = opcodes;
21359
21360 - if (search_exception_tables((unsigned long)opcodes))
21361 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21362 return 0; /* Page fault may occur on this address. */
21363
21364 retry:
21365 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21366 * for the first byte, we can recover the original instruction
21367 * from it and kp->opcode.
21368 */
21369 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21370 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21371 buf[0] = kp->opcode;
21372 - return (unsigned long)buf;
21373 + return ktva_ktla((unsigned long)buf);
21374 }
21375
21376 /*
21377 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21378 /* Another subsystem puts a breakpoint, failed to recover */
21379 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21380 return 0;
21381 + pax_open_kernel();
21382 memcpy(dest, insn.kaddr, insn.length);
21383 + pax_close_kernel();
21384
21385 #ifdef CONFIG_X86_64
21386 if (insn_rip_relative(&insn)) {
21387 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21388 return 0;
21389 }
21390 disp = (u8 *) dest + insn_offset_displacement(&insn);
21391 + pax_open_kernel();
21392 *(s32 *) disp = (s32) newdisp;
21393 + pax_close_kernel();
21394 }
21395 #endif
21396 return insn.length;
21397 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21398 * nor set current_kprobe, because it doesn't use single
21399 * stepping.
21400 */
21401 - regs->ip = (unsigned long)p->ainsn.insn;
21402 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21403 preempt_enable_no_resched();
21404 return;
21405 }
21406 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21407 regs->flags &= ~X86_EFLAGS_IF;
21408 /* single step inline if the instruction is an int3 */
21409 if (p->opcode == BREAKPOINT_INSTRUCTION)
21410 - regs->ip = (unsigned long)p->addr;
21411 + regs->ip = ktla_ktva((unsigned long)p->addr);
21412 else
21413 - regs->ip = (unsigned long)p->ainsn.insn;
21414 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21415 }
21416
21417 /*
21418 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21419 setup_singlestep(p, regs, kcb, 0);
21420 return 1;
21421 }
21422 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21423 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21424 /*
21425 * The breakpoint instruction was removed right
21426 * after we hit it. Another cpu has removed
21427 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21428 " movq %rax, 152(%rsp)\n"
21429 RESTORE_REGS_STRING
21430 " popfq\n"
21431 +#ifdef KERNEXEC_PLUGIN
21432 + " btsq $63,(%rsp)\n"
21433 +#endif
21434 #else
21435 " pushf\n"
21436 SAVE_REGS_STRING
21437 @@ -779,7 +789,7 @@ static void __kprobes
21438 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21439 {
21440 unsigned long *tos = stack_addr(regs);
21441 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21442 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21443 unsigned long orig_ip = (unsigned long)p->addr;
21444 kprobe_opcode_t *insn = p->ainsn.insn;
21445
21446 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21447 struct die_args *args = data;
21448 int ret = NOTIFY_DONE;
21449
21450 - if (args->regs && user_mode_vm(args->regs))
21451 + if (args->regs && user_mode(args->regs))
21452 return ret;
21453
21454 switch (val) {
21455 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21456 index 76dc6f0..66bdfc3 100644
21457 --- a/arch/x86/kernel/kprobes/opt.c
21458 +++ b/arch/x86/kernel/kprobes/opt.c
21459 @@ -79,6 +79,7 @@ found:
21460 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21461 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21462 {
21463 + pax_open_kernel();
21464 #ifdef CONFIG_X86_64
21465 *addr++ = 0x48;
21466 *addr++ = 0xbf;
21467 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21468 *addr++ = 0xb8;
21469 #endif
21470 *(unsigned long *)addr = val;
21471 + pax_close_kernel();
21472 }
21473
21474 static void __used __kprobes kprobes_optinsn_template_holder(void)
21475 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21476 * Verify if the address gap is in 2GB range, because this uses
21477 * a relative jump.
21478 */
21479 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21480 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21481 if (abs(rel) > 0x7fffffff)
21482 return -ERANGE;
21483
21484 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21485 op->optinsn.size = ret;
21486
21487 /* Copy arch-dep-instance from template */
21488 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21489 + pax_open_kernel();
21490 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21491 + pax_close_kernel();
21492
21493 /* Set probe information */
21494 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21495
21496 /* Set probe function call */
21497 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21498 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21499
21500 /* Set returning jmp instruction at the tail of out-of-line buffer */
21501 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21502 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21503 (u8 *)op->kp.addr + op->optinsn.size);
21504
21505 flush_icache_range((unsigned long) buf,
21506 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21507 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21508
21509 /* Backup instructions which will be replaced by jump address */
21510 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21511 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21512 RELATIVE_ADDR_SIZE);
21513
21514 insn_buf[0] = RELATIVEJUMP_OPCODE;
21515 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21516 /* This kprobe is really able to run optimized path. */
21517 op = container_of(p, struct optimized_kprobe, kp);
21518 /* Detour through copied instructions */
21519 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21520 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21521 if (!reenter)
21522 reset_current_kprobe();
21523 preempt_enable_no_resched();
21524 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21525 index cd6d9a5..16245a4 100644
21526 --- a/arch/x86/kernel/kvm.c
21527 +++ b/arch/x86/kernel/kvm.c
21528 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21529 return NOTIFY_OK;
21530 }
21531
21532 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21533 +static struct notifier_block kvm_cpu_notifier = {
21534 .notifier_call = kvm_cpu_notify,
21535 };
21536 #endif
21537 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21538 index ebc9873..1b9724b 100644
21539 --- a/arch/x86/kernel/ldt.c
21540 +++ b/arch/x86/kernel/ldt.c
21541 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21542 if (reload) {
21543 #ifdef CONFIG_SMP
21544 preempt_disable();
21545 - load_LDT(pc);
21546 + load_LDT_nolock(pc);
21547 if (!cpumask_equal(mm_cpumask(current->mm),
21548 cpumask_of(smp_processor_id())))
21549 smp_call_function(flush_ldt, current->mm, 1);
21550 preempt_enable();
21551 #else
21552 - load_LDT(pc);
21553 + load_LDT_nolock(pc);
21554 #endif
21555 }
21556 if (oldsize) {
21557 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21558 return err;
21559
21560 for (i = 0; i < old->size; i++)
21561 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21562 + write_ldt_entry(new->ldt, i, old->ldt + i);
21563 return 0;
21564 }
21565
21566 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21567 retval = copy_ldt(&mm->context, &old_mm->context);
21568 mutex_unlock(&old_mm->context.lock);
21569 }
21570 +
21571 + if (tsk == current) {
21572 + mm->context.vdso = 0;
21573 +
21574 +#ifdef CONFIG_X86_32
21575 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21576 + mm->context.user_cs_base = 0UL;
21577 + mm->context.user_cs_limit = ~0UL;
21578 +
21579 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21580 + cpus_clear(mm->context.cpu_user_cs_mask);
21581 +#endif
21582 +
21583 +#endif
21584 +#endif
21585 +
21586 + }
21587 +
21588 return retval;
21589 }
21590
21591 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21592 }
21593 }
21594
21595 +#ifdef CONFIG_PAX_SEGMEXEC
21596 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21597 + error = -EINVAL;
21598 + goto out_unlock;
21599 + }
21600 +#endif
21601 +
21602 fill_ldt(&ldt, &ldt_info);
21603 if (oldmode)
21604 ldt.avl = 0;
21605 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21606 index 5b19e4d..6476a76 100644
21607 --- a/arch/x86/kernel/machine_kexec_32.c
21608 +++ b/arch/x86/kernel/machine_kexec_32.c
21609 @@ -26,7 +26,7 @@
21610 #include <asm/cacheflush.h>
21611 #include <asm/debugreg.h>
21612
21613 -static void set_idt(void *newidt, __u16 limit)
21614 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21615 {
21616 struct desc_ptr curidt;
21617
21618 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21619 }
21620
21621
21622 -static void set_gdt(void *newgdt, __u16 limit)
21623 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21624 {
21625 struct desc_ptr curgdt;
21626
21627 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21628 }
21629
21630 control_page = page_address(image->control_code_page);
21631 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21632 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21633
21634 relocate_kernel_ptr = control_page;
21635 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21636 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21637 index 22db92b..d546bec 100644
21638 --- a/arch/x86/kernel/microcode_core.c
21639 +++ b/arch/x86/kernel/microcode_core.c
21640 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21641 return NOTIFY_OK;
21642 }
21643
21644 -static struct notifier_block __refdata mc_cpu_notifier = {
21645 +static struct notifier_block mc_cpu_notifier = {
21646 .notifier_call = mc_cpu_callback,
21647 };
21648
21649 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21650 index 5fb2ceb..3ae90bb 100644
21651 --- a/arch/x86/kernel/microcode_intel.c
21652 +++ b/arch/x86/kernel/microcode_intel.c
21653 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21654
21655 static int get_ucode_user(void *to, const void *from, size_t n)
21656 {
21657 - return copy_from_user(to, from, n);
21658 + return copy_from_user(to, (const void __force_user *)from, n);
21659 }
21660
21661 static enum ucode_state
21662 request_microcode_user(int cpu, const void __user *buf, size_t size)
21663 {
21664 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21665 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21666 }
21667
21668 static void microcode_fini_cpu(int cpu)
21669 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21670 index 216a4d7..228255a 100644
21671 --- a/arch/x86/kernel/module.c
21672 +++ b/arch/x86/kernel/module.c
21673 @@ -43,15 +43,60 @@ do { \
21674 } while (0)
21675 #endif
21676
21677 -void *module_alloc(unsigned long size)
21678 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21679 {
21680 - if (PAGE_ALIGN(size) > MODULES_LEN)
21681 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21682 return NULL;
21683 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21684 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21685 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21686 -1, __builtin_return_address(0));
21687 }
21688
21689 +void *module_alloc(unsigned long size)
21690 +{
21691 +
21692 +#ifdef CONFIG_PAX_KERNEXEC
21693 + return __module_alloc(size, PAGE_KERNEL);
21694 +#else
21695 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21696 +#endif
21697 +
21698 +}
21699 +
21700 +#ifdef CONFIG_PAX_KERNEXEC
21701 +#ifdef CONFIG_X86_32
21702 +void *module_alloc_exec(unsigned long size)
21703 +{
21704 + struct vm_struct *area;
21705 +
21706 + if (size == 0)
21707 + return NULL;
21708 +
21709 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21710 + return area ? area->addr : NULL;
21711 +}
21712 +EXPORT_SYMBOL(module_alloc_exec);
21713 +
21714 +void module_free_exec(struct module *mod, void *module_region)
21715 +{
21716 + vunmap(module_region);
21717 +}
21718 +EXPORT_SYMBOL(module_free_exec);
21719 +#else
21720 +void module_free_exec(struct module *mod, void *module_region)
21721 +{
21722 + module_free(mod, module_region);
21723 +}
21724 +EXPORT_SYMBOL(module_free_exec);
21725 +
21726 +void *module_alloc_exec(unsigned long size)
21727 +{
21728 + return __module_alloc(size, PAGE_KERNEL_RX);
21729 +}
21730 +EXPORT_SYMBOL(module_alloc_exec);
21731 +#endif
21732 +#endif
21733 +
21734 #ifdef CONFIG_X86_32
21735 int apply_relocate(Elf32_Shdr *sechdrs,
21736 const char *strtab,
21737 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21738 unsigned int i;
21739 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21740 Elf32_Sym *sym;
21741 - uint32_t *location;
21742 + uint32_t *plocation, location;
21743
21744 DEBUGP("Applying relocate section %u to %u\n",
21745 relsec, sechdrs[relsec].sh_info);
21746 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21747 /* This is where to make the change */
21748 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21749 - + rel[i].r_offset;
21750 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21751 + location = (uint32_t)plocation;
21752 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21753 + plocation = ktla_ktva((void *)plocation);
21754 /* This is the symbol it is referring to. Note that all
21755 undefined symbols have been resolved. */
21756 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21757 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21758 switch (ELF32_R_TYPE(rel[i].r_info)) {
21759 case R_386_32:
21760 /* We add the value into the location given */
21761 - *location += sym->st_value;
21762 + pax_open_kernel();
21763 + *plocation += sym->st_value;
21764 + pax_close_kernel();
21765 break;
21766 case R_386_PC32:
21767 /* Add the value, subtract its position */
21768 - *location += sym->st_value - (uint32_t)location;
21769 + pax_open_kernel();
21770 + *plocation += sym->st_value - location;
21771 + pax_close_kernel();
21772 break;
21773 default:
21774 pr_err("%s: Unknown relocation: %u\n",
21775 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21776 case R_X86_64_NONE:
21777 break;
21778 case R_X86_64_64:
21779 + pax_open_kernel();
21780 *(u64 *)loc = val;
21781 + pax_close_kernel();
21782 break;
21783 case R_X86_64_32:
21784 + pax_open_kernel();
21785 *(u32 *)loc = val;
21786 + pax_close_kernel();
21787 if (val != *(u32 *)loc)
21788 goto overflow;
21789 break;
21790 case R_X86_64_32S:
21791 + pax_open_kernel();
21792 *(s32 *)loc = val;
21793 + pax_close_kernel();
21794 if ((s64)val != *(s32 *)loc)
21795 goto overflow;
21796 break;
21797 case R_X86_64_PC32:
21798 val -= (u64)loc;
21799 + pax_open_kernel();
21800 *(u32 *)loc = val;
21801 + pax_close_kernel();
21802 +
21803 #if 0
21804 if ((s64)val != *(s32 *)loc)
21805 goto overflow;
21806 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21807 index ce13049..e2e9c3c 100644
21808 --- a/arch/x86/kernel/msr.c
21809 +++ b/arch/x86/kernel/msr.c
21810 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21811 return notifier_from_errno(err);
21812 }
21813
21814 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21815 +static struct notifier_block msr_class_cpu_notifier = {
21816 .notifier_call = msr_class_cpu_callback,
21817 };
21818
21819 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21820 index 6030805..2d33f21 100644
21821 --- a/arch/x86/kernel/nmi.c
21822 +++ b/arch/x86/kernel/nmi.c
21823 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21824 return handled;
21825 }
21826
21827 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21828 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21829 {
21830 struct nmi_desc *desc = nmi_to_desc(type);
21831 unsigned long flags;
21832 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21833 * event confuses some handlers (kdump uses this flag)
21834 */
21835 if (action->flags & NMI_FLAG_FIRST)
21836 - list_add_rcu(&action->list, &desc->head);
21837 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21838 else
21839 - list_add_tail_rcu(&action->list, &desc->head);
21840 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21841
21842 spin_unlock_irqrestore(&desc->lock, flags);
21843 return 0;
21844 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21845 if (!strcmp(n->name, name)) {
21846 WARN(in_nmi(),
21847 "Trying to free NMI (%s) from NMI context!\n", n->name);
21848 - list_del_rcu(&n->list);
21849 + pax_list_del_rcu((struct list_head *)&n->list);
21850 break;
21851 }
21852 }
21853 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21854 dotraplinkage notrace __kprobes void
21855 do_nmi(struct pt_regs *regs, long error_code)
21856 {
21857 +
21858 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21859 + if (!user_mode(regs)) {
21860 + unsigned long cs = regs->cs & 0xFFFF;
21861 + unsigned long ip = ktva_ktla(regs->ip);
21862 +
21863 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21864 + regs->ip = ip;
21865 + }
21866 +#endif
21867 +
21868 nmi_nesting_preprocess(regs);
21869
21870 nmi_enter();
21871 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21872 index 6d9582e..f746287 100644
21873 --- a/arch/x86/kernel/nmi_selftest.c
21874 +++ b/arch/x86/kernel/nmi_selftest.c
21875 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21876 {
21877 /* trap all the unknown NMIs we may generate */
21878 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21879 - __initdata);
21880 + __initconst);
21881 }
21882
21883 static void __init cleanup_nmi_testsuite(void)
21884 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21885 unsigned long timeout;
21886
21887 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21888 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21889 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21890 nmi_fail = FAILURE;
21891 return;
21892 }
21893 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21894 index 676b8c7..870ba04 100644
21895 --- a/arch/x86/kernel/paravirt-spinlocks.c
21896 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21897 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21898 arch_spin_lock(lock);
21899 }
21900
21901 -struct pv_lock_ops pv_lock_ops = {
21902 +struct pv_lock_ops pv_lock_ops __read_only = {
21903 #ifdef CONFIG_SMP
21904 .spin_is_locked = __ticket_spin_is_locked,
21905 .spin_is_contended = __ticket_spin_is_contended,
21906 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21907 index cd6de64..27c6af0 100644
21908 --- a/arch/x86/kernel/paravirt.c
21909 +++ b/arch/x86/kernel/paravirt.c
21910 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21911 {
21912 return x;
21913 }
21914 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21915 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21916 +#endif
21917
21918 void __init default_banner(void)
21919 {
21920 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21921 if (opfunc == NULL)
21922 /* If there's no function, patch it with a ud2a (BUG) */
21923 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21924 - else if (opfunc == _paravirt_nop)
21925 + else if (opfunc == (void *)_paravirt_nop)
21926 /* If the operation is a nop, then nop the callsite */
21927 ret = paravirt_patch_nop();
21928
21929 /* identity functions just return their single argument */
21930 - else if (opfunc == _paravirt_ident_32)
21931 + else if (opfunc == (void *)_paravirt_ident_32)
21932 ret = paravirt_patch_ident_32(insnbuf, len);
21933 - else if (opfunc == _paravirt_ident_64)
21934 + else if (opfunc == (void *)_paravirt_ident_64)
21935 ret = paravirt_patch_ident_64(insnbuf, len);
21936 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21937 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21938 + ret = paravirt_patch_ident_64(insnbuf, len);
21939 +#endif
21940
21941 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21942 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21943 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21944 if (insn_len > len || start == NULL)
21945 insn_len = len;
21946 else
21947 - memcpy(insnbuf, start, insn_len);
21948 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21949
21950 return insn_len;
21951 }
21952 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21953 return this_cpu_read(paravirt_lazy_mode);
21954 }
21955
21956 -struct pv_info pv_info = {
21957 +struct pv_info pv_info __read_only = {
21958 .name = "bare hardware",
21959 .paravirt_enabled = 0,
21960 .kernel_rpl = 0,
21961 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21962 #endif
21963 };
21964
21965 -struct pv_init_ops pv_init_ops = {
21966 +struct pv_init_ops pv_init_ops __read_only = {
21967 .patch = native_patch,
21968 };
21969
21970 -struct pv_time_ops pv_time_ops = {
21971 +struct pv_time_ops pv_time_ops __read_only = {
21972 .sched_clock = native_sched_clock,
21973 .steal_clock = native_steal_clock,
21974 };
21975
21976 -struct pv_irq_ops pv_irq_ops = {
21977 +struct pv_irq_ops pv_irq_ops __read_only = {
21978 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21979 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21980 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21981 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21982 #endif
21983 };
21984
21985 -struct pv_cpu_ops pv_cpu_ops = {
21986 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21987 .cpuid = native_cpuid,
21988 .get_debugreg = native_get_debugreg,
21989 .set_debugreg = native_set_debugreg,
21990 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21991 .end_context_switch = paravirt_nop,
21992 };
21993
21994 -struct pv_apic_ops pv_apic_ops = {
21995 +struct pv_apic_ops pv_apic_ops __read_only= {
21996 #ifdef CONFIG_X86_LOCAL_APIC
21997 .startup_ipi_hook = paravirt_nop,
21998 #endif
21999 };
22000
22001 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22002 +#ifdef CONFIG_X86_32
22003 +#ifdef CONFIG_X86_PAE
22004 +/* 64-bit pagetable entries */
22005 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22006 +#else
22007 /* 32-bit pagetable entries */
22008 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22009 +#endif
22010 #else
22011 /* 64-bit pagetable entries */
22012 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22013 #endif
22014
22015 -struct pv_mmu_ops pv_mmu_ops = {
22016 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22017
22018 .read_cr2 = native_read_cr2,
22019 .write_cr2 = native_write_cr2,
22020 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22021 .make_pud = PTE_IDENT,
22022
22023 .set_pgd = native_set_pgd,
22024 + .set_pgd_batched = native_set_pgd_batched,
22025 #endif
22026 #endif /* PAGETABLE_LEVELS >= 3 */
22027
22028 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22029 },
22030
22031 .set_fixmap = native_set_fixmap,
22032 +
22033 +#ifdef CONFIG_PAX_KERNEXEC
22034 + .pax_open_kernel = native_pax_open_kernel,
22035 + .pax_close_kernel = native_pax_close_kernel,
22036 +#endif
22037 +
22038 };
22039
22040 EXPORT_SYMBOL_GPL(pv_time_ops);
22041 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
22042 index 299d493..2ccb0ee 100644
22043 --- a/arch/x86/kernel/pci-calgary_64.c
22044 +++ b/arch/x86/kernel/pci-calgary_64.c
22045 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
22046 tce_space = be64_to_cpu(readq(target));
22047 tce_space = tce_space & TAR_SW_BITS;
22048
22049 - tce_space = tce_space & (~specified_table_size);
22050 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22051 info->tce_space = (u64 *)__va(tce_space);
22052 }
22053 }
22054 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22055 index 35ccf75..7a15747 100644
22056 --- a/arch/x86/kernel/pci-iommu_table.c
22057 +++ b/arch/x86/kernel/pci-iommu_table.c
22058 @@ -2,7 +2,7 @@
22059 #include <asm/iommu_table.h>
22060 #include <linux/string.h>
22061 #include <linux/kallsyms.h>
22062 -
22063 +#include <linux/sched.h>
22064
22065 #define DEBUG 1
22066
22067 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22068 index 6c483ba..d10ce2f 100644
22069 --- a/arch/x86/kernel/pci-swiotlb.c
22070 +++ b/arch/x86/kernel/pci-swiotlb.c
22071 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22072 void *vaddr, dma_addr_t dma_addr,
22073 struct dma_attrs *attrs)
22074 {
22075 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22076 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22077 }
22078
22079 static struct dma_map_ops swiotlb_dma_ops = {
22080 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22081 index 81a5f5e..20f8b58 100644
22082 --- a/arch/x86/kernel/process.c
22083 +++ b/arch/x86/kernel/process.c
22084 @@ -36,7 +36,8 @@
22085 * section. Since TSS's are completely CPU-local, we want them
22086 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22087 */
22088 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22089 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22090 +EXPORT_SYMBOL(init_tss);
22091
22092 #ifdef CONFIG_X86_64
22093 static DEFINE_PER_CPU(unsigned char, is_idle);
22094 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22095 task_xstate_cachep =
22096 kmem_cache_create("task_xstate", xstate_size,
22097 __alignof__(union thread_xstate),
22098 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22099 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22100 }
22101
22102 /*
22103 @@ -105,7 +106,7 @@ void exit_thread(void)
22104 unsigned long *bp = t->io_bitmap_ptr;
22105
22106 if (bp) {
22107 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22108 + struct tss_struct *tss = init_tss + get_cpu();
22109
22110 t->io_bitmap_ptr = NULL;
22111 clear_thread_flag(TIF_IO_BITMAP);
22112 @@ -125,6 +126,9 @@ void flush_thread(void)
22113 {
22114 struct task_struct *tsk = current;
22115
22116 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22117 + loadsegment(gs, 0);
22118 +#endif
22119 flush_ptrace_hw_breakpoint(tsk);
22120 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22121 drop_init_fpu(tsk);
22122 @@ -271,7 +275,7 @@ static void __exit_idle(void)
22123 void exit_idle(void)
22124 {
22125 /* idle loop has pid 0 */
22126 - if (current->pid)
22127 + if (task_pid_nr(current))
22128 return;
22129 __exit_idle();
22130 }
22131 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
22132 return ret;
22133 }
22134 #endif
22135 -void stop_this_cpu(void *dummy)
22136 +__noreturn void stop_this_cpu(void *dummy)
22137 {
22138 local_irq_disable();
22139 /*
22140 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
22141 }
22142 early_param("idle", idle_setup);
22143
22144 -unsigned long arch_align_stack(unsigned long sp)
22145 +#ifdef CONFIG_PAX_RANDKSTACK
22146 +void pax_randomize_kstack(struct pt_regs *regs)
22147 {
22148 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22149 - sp -= get_random_int() % 8192;
22150 - return sp & ~0xf;
22151 -}
22152 + struct thread_struct *thread = &current->thread;
22153 + unsigned long time;
22154
22155 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22156 -{
22157 - unsigned long range_end = mm->brk + 0x02000000;
22158 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22159 -}
22160 + if (!randomize_va_space)
22161 + return;
22162 +
22163 + if (v8086_mode(regs))
22164 + return;
22165
22166 + rdtscl(time);
22167 +
22168 + /* P4 seems to return a 0 LSB, ignore it */
22169 +#ifdef CONFIG_MPENTIUM4
22170 + time &= 0x3EUL;
22171 + time <<= 2;
22172 +#elif defined(CONFIG_X86_64)
22173 + time &= 0xFUL;
22174 + time <<= 4;
22175 +#else
22176 + time &= 0x1FUL;
22177 + time <<= 3;
22178 +#endif
22179 +
22180 + thread->sp0 ^= time;
22181 + load_sp0(init_tss + smp_processor_id(), thread);
22182 +
22183 +#ifdef CONFIG_X86_64
22184 + this_cpu_write(kernel_stack, thread->sp0);
22185 +#endif
22186 +}
22187 +#endif
22188 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22189 index 7305f7d..22f73d6 100644
22190 --- a/arch/x86/kernel/process_32.c
22191 +++ b/arch/x86/kernel/process_32.c
22192 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22193 unsigned long thread_saved_pc(struct task_struct *tsk)
22194 {
22195 return ((unsigned long *)tsk->thread.sp)[3];
22196 +//XXX return tsk->thread.eip;
22197 }
22198
22199 void __show_regs(struct pt_regs *regs, int all)
22200 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
22201 unsigned long sp;
22202 unsigned short ss, gs;
22203
22204 - if (user_mode_vm(regs)) {
22205 + if (user_mode(regs)) {
22206 sp = regs->sp;
22207 ss = regs->ss & 0xffff;
22208 - gs = get_user_gs(regs);
22209 } else {
22210 sp = kernel_stack_pointer(regs);
22211 savesegment(ss, ss);
22212 - savesegment(gs, gs);
22213 }
22214 + gs = get_user_gs(regs);
22215
22216 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22217 (u16)regs->cs, regs->ip, regs->flags,
22218 - smp_processor_id());
22219 + raw_smp_processor_id());
22220 print_symbol("EIP is at %s\n", regs->ip);
22221
22222 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22223 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
22224 int copy_thread(unsigned long clone_flags, unsigned long sp,
22225 unsigned long arg, struct task_struct *p)
22226 {
22227 - struct pt_regs *childregs = task_pt_regs(p);
22228 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22229 struct task_struct *tsk;
22230 int err;
22231
22232 p->thread.sp = (unsigned long) childregs;
22233 p->thread.sp0 = (unsigned long) (childregs+1);
22234 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22235
22236 if (unlikely(p->flags & PF_KTHREAD)) {
22237 /* kernel thread */
22238 memset(childregs, 0, sizeof(struct pt_regs));
22239 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22240 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22241 - childregs->ds = __USER_DS;
22242 - childregs->es = __USER_DS;
22243 + savesegment(gs, childregs->gs);
22244 + childregs->ds = __KERNEL_DS;
22245 + childregs->es = __KERNEL_DS;
22246 childregs->fs = __KERNEL_PERCPU;
22247 childregs->bx = sp; /* function */
22248 childregs->bp = arg;
22249 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22250 struct thread_struct *prev = &prev_p->thread,
22251 *next = &next_p->thread;
22252 int cpu = smp_processor_id();
22253 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22254 + struct tss_struct *tss = init_tss + cpu;
22255 fpu_switch_t fpu;
22256
22257 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22258 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22259 */
22260 lazy_save_gs(prev->gs);
22261
22262 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22263 + __set_fs(task_thread_info(next_p)->addr_limit);
22264 +#endif
22265 +
22266 /*
22267 * Load the per-thread Thread-Local Storage descriptor.
22268 */
22269 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22270 */
22271 arch_end_context_switch(next_p);
22272
22273 + this_cpu_write(current_task, next_p);
22274 + this_cpu_write(current_tinfo, &next_p->tinfo);
22275 +
22276 /*
22277 * Restore %gs if needed (which is common)
22278 */
22279 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22280
22281 switch_fpu_finish(next_p, fpu);
22282
22283 - this_cpu_write(current_task, next_p);
22284 -
22285 return prev_p;
22286 }
22287
22288 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
22289 } while (count++ < 16);
22290 return 0;
22291 }
22292 -
22293 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22294 index 355ae06..4530766 100644
22295 --- a/arch/x86/kernel/process_64.c
22296 +++ b/arch/x86/kernel/process_64.c
22297 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22298 struct pt_regs *childregs;
22299 struct task_struct *me = current;
22300
22301 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22302 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22303 childregs = task_pt_regs(p);
22304 p->thread.sp = (unsigned long) childregs;
22305 p->thread.usersp = me->thread.usersp;
22306 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22307 set_tsk_thread_flag(p, TIF_FORK);
22308 p->fpu_counter = 0;
22309 p->thread.io_bitmap_ptr = NULL;
22310 @@ -273,7 +274,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22311 struct thread_struct *prev = &prev_p->thread;
22312 struct thread_struct *next = &next_p->thread;
22313 int cpu = smp_processor_id();
22314 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22315 + struct tss_struct *tss = init_tss + cpu;
22316 unsigned fsindex, gsindex;
22317 fpu_switch_t fpu;
22318
22319 @@ -355,10 +356,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22320 prev->usersp = this_cpu_read(old_rsp);
22321 this_cpu_write(old_rsp, next->usersp);
22322 this_cpu_write(current_task, next_p);
22323 + this_cpu_write(current_tinfo, &next_p->tinfo);
22324
22325 - this_cpu_write(kernel_stack,
22326 - (unsigned long)task_stack_page(next_p) +
22327 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22328 + this_cpu_write(kernel_stack, next->sp0);
22329
22330 /*
22331 * Now maybe reload the debug registers and handle I/O bitmaps
22332 @@ -427,12 +427,11 @@ unsigned long get_wchan(struct task_struct *p)
22333 if (!p || p == current || p->state == TASK_RUNNING)
22334 return 0;
22335 stack = (unsigned long)task_stack_page(p);
22336 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22337 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22338 return 0;
22339 fp = *(u64 *)(p->thread.sp);
22340 do {
22341 - if (fp < (unsigned long)stack ||
22342 - fp >= (unsigned long)stack+THREAD_SIZE)
22343 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22344 return 0;
22345 ip = *(u64 *)(fp+8);
22346 if (!in_sched_functions(ip))
22347 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22348 index 29a8120..a50b5ee 100644
22349 --- a/arch/x86/kernel/ptrace.c
22350 +++ b/arch/x86/kernel/ptrace.c
22351 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22352 {
22353 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22354 unsigned long sp = (unsigned long)&regs->sp;
22355 - struct thread_info *tinfo;
22356
22357 - if (context == (sp & ~(THREAD_SIZE - 1)))
22358 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22359 return sp;
22360
22361 - tinfo = (struct thread_info *)context;
22362 - if (tinfo->previous_esp)
22363 - return tinfo->previous_esp;
22364 + sp = *(unsigned long *)context;
22365 + if (sp)
22366 + return sp;
22367
22368 return (unsigned long)regs;
22369 }
22370 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22371 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22372 {
22373 int i;
22374 - int dr7 = 0;
22375 + unsigned long dr7 = 0;
22376 struct arch_hw_breakpoint *info;
22377
22378 for (i = 0; i < HBP_NUM; i++) {
22379 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22380 unsigned long addr, unsigned long data)
22381 {
22382 int ret;
22383 - unsigned long __user *datap = (unsigned long __user *)data;
22384 + unsigned long __user *datap = (__force unsigned long __user *)data;
22385
22386 switch (request) {
22387 /* read the word at location addr in the USER area. */
22388 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22389 if ((int) addr < 0)
22390 return -EIO;
22391 ret = do_get_thread_area(child, addr,
22392 - (struct user_desc __user *)data);
22393 + (__force struct user_desc __user *) data);
22394 break;
22395
22396 case PTRACE_SET_THREAD_AREA:
22397 if ((int) addr < 0)
22398 return -EIO;
22399 ret = do_set_thread_area(child, addr,
22400 - (struct user_desc __user *)data, 0);
22401 + (__force struct user_desc __user *) data, 0);
22402 break;
22403 #endif
22404
22405 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22406
22407 #ifdef CONFIG_X86_64
22408
22409 -static struct user_regset x86_64_regsets[] __read_mostly = {
22410 +static user_regset_no_const x86_64_regsets[] __read_only = {
22411 [REGSET_GENERAL] = {
22412 .core_note_type = NT_PRSTATUS,
22413 .n = sizeof(struct user_regs_struct) / sizeof(long),
22414 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22415 #endif /* CONFIG_X86_64 */
22416
22417 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22418 -static struct user_regset x86_32_regsets[] __read_mostly = {
22419 +static user_regset_no_const x86_32_regsets[] __read_only = {
22420 [REGSET_GENERAL] = {
22421 .core_note_type = NT_PRSTATUS,
22422 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22423 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22424 */
22425 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22426
22427 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22428 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22429 {
22430 #ifdef CONFIG_X86_64
22431 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22432 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22433 memset(info, 0, sizeof(*info));
22434 info->si_signo = SIGTRAP;
22435 info->si_code = si_code;
22436 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22437 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22438 }
22439
22440 void user_single_step_siginfo(struct task_struct *tsk,
22441 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22442 # define IS_IA32 0
22443 #endif
22444
22445 +#ifdef CONFIG_GRKERNSEC_SETXID
22446 +extern void gr_delayed_cred_worker(void);
22447 +#endif
22448 +
22449 /*
22450 * We must return the syscall number to actually look up in the table.
22451 * This can be -1L to skip running any syscall at all.
22452 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22453
22454 user_exit();
22455
22456 +#ifdef CONFIG_GRKERNSEC_SETXID
22457 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22458 + gr_delayed_cred_worker();
22459 +#endif
22460 +
22461 /*
22462 * If we stepped into a sysenter/syscall insn, it trapped in
22463 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22464 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22465 */
22466 user_exit();
22467
22468 +#ifdef CONFIG_GRKERNSEC_SETXID
22469 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22470 + gr_delayed_cred_worker();
22471 +#endif
22472 +
22473 audit_syscall_exit(regs);
22474
22475 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22476 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22477 index 2cb9470..ff1fd80 100644
22478 --- a/arch/x86/kernel/pvclock.c
22479 +++ b/arch/x86/kernel/pvclock.c
22480 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22481 return pv_tsc_khz;
22482 }
22483
22484 -static atomic64_t last_value = ATOMIC64_INIT(0);
22485 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22486
22487 void pvclock_resume(void)
22488 {
22489 - atomic64_set(&last_value, 0);
22490 + atomic64_set_unchecked(&last_value, 0);
22491 }
22492
22493 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22494 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22495 * updating at the same time, and one of them could be slightly behind,
22496 * making the assumption that last_value always go forward fail to hold.
22497 */
22498 - last = atomic64_read(&last_value);
22499 + last = atomic64_read_unchecked(&last_value);
22500 do {
22501 if (ret < last)
22502 return last;
22503 - last = atomic64_cmpxchg(&last_value, last, ret);
22504 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22505 } while (unlikely(last != ret));
22506
22507 return ret;
22508 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22509 index 76fa1e9..abf09ea 100644
22510 --- a/arch/x86/kernel/reboot.c
22511 +++ b/arch/x86/kernel/reboot.c
22512 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22513 EXPORT_SYMBOL(pm_power_off);
22514
22515 static const struct desc_ptr no_idt = {};
22516 -static int reboot_mode;
22517 +static unsigned short reboot_mode;
22518 enum reboot_type reboot_type = BOOT_ACPI;
22519 int reboot_force;
22520
22521 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22522
22523 void __noreturn machine_real_restart(unsigned int type)
22524 {
22525 +
22526 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22527 + struct desc_struct *gdt;
22528 +#endif
22529 +
22530 local_irq_disable();
22531
22532 /*
22533 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22534
22535 /* Jump to the identity-mapped low memory code */
22536 #ifdef CONFIG_X86_32
22537 - asm volatile("jmpl *%0" : :
22538 +
22539 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22540 + gdt = get_cpu_gdt_table(smp_processor_id());
22541 + pax_open_kernel();
22542 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22543 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22544 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22545 + loadsegment(ds, __KERNEL_DS);
22546 + loadsegment(es, __KERNEL_DS);
22547 + loadsegment(ss, __KERNEL_DS);
22548 +#endif
22549 +#ifdef CONFIG_PAX_KERNEXEC
22550 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22551 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22552 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22553 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22554 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22555 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22556 +#endif
22557 + pax_close_kernel();
22558 +#endif
22559 +
22560 + asm volatile("ljmpl *%0" : :
22561 "rm" (real_mode_header->machine_real_restart_asm),
22562 "a" (type));
22563 #else
22564 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22565 * try to force a triple fault and then cycle between hitting the keyboard
22566 * controller and doing that
22567 */
22568 -static void native_machine_emergency_restart(void)
22569 +static void __noreturn native_machine_emergency_restart(void)
22570 {
22571 int i;
22572 int attempt = 0;
22573 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22574 #endif
22575 }
22576
22577 -static void __machine_emergency_restart(int emergency)
22578 +static void __noreturn __machine_emergency_restart(int emergency)
22579 {
22580 reboot_emergency = emergency;
22581 machine_ops.emergency_restart();
22582 }
22583
22584 -static void native_machine_restart(char *__unused)
22585 +static void __noreturn native_machine_restart(char *__unused)
22586 {
22587 pr_notice("machine restart\n");
22588
22589 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22590 __machine_emergency_restart(0);
22591 }
22592
22593 -static void native_machine_halt(void)
22594 +static void __noreturn native_machine_halt(void)
22595 {
22596 /* Stop other cpus and apics */
22597 machine_shutdown();
22598 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22599 stop_this_cpu(NULL);
22600 }
22601
22602 -static void native_machine_power_off(void)
22603 +static void __noreturn native_machine_power_off(void)
22604 {
22605 if (pm_power_off) {
22606 if (!reboot_force)
22607 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22608 }
22609 /* A fallback in case there is no PM info available */
22610 tboot_shutdown(TB_SHUTDOWN_HALT);
22611 + unreachable();
22612 }
22613
22614 -struct machine_ops machine_ops = {
22615 +struct machine_ops machine_ops __read_only = {
22616 .power_off = native_machine_power_off,
22617 .shutdown = native_machine_shutdown,
22618 .emergency_restart = native_machine_emergency_restart,
22619 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
22620 index c8e41e9..64049ef 100644
22621 --- a/arch/x86/kernel/reboot_fixups_32.c
22622 +++ b/arch/x86/kernel/reboot_fixups_32.c
22623 @@ -57,7 +57,7 @@ struct device_fixup {
22624 unsigned int vendor;
22625 unsigned int device;
22626 void (*reboot_fixup)(struct pci_dev *);
22627 -};
22628 +} __do_const;
22629
22630 /*
22631 * PCI ids solely used for fixups_table go here
22632 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22633 index f2bb9c9..bed145d7 100644
22634 --- a/arch/x86/kernel/relocate_kernel_64.S
22635 +++ b/arch/x86/kernel/relocate_kernel_64.S
22636 @@ -11,6 +11,7 @@
22637 #include <asm/kexec.h>
22638 #include <asm/processor-flags.h>
22639 #include <asm/pgtable_types.h>
22640 +#include <asm/alternative-asm.h>
22641
22642 /*
22643 * Must be relocatable PIC code callable as a C function
22644 @@ -167,6 +168,7 @@ identity_mapped:
22645 xorq %r14, %r14
22646 xorq %r15, %r15
22647
22648 + pax_force_retaddr 0, 1
22649 ret
22650
22651 1:
22652 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22653 index 56f7fcf..fa229f4 100644
22654 --- a/arch/x86/kernel/setup.c
22655 +++ b/arch/x86/kernel/setup.c
22656 @@ -110,6 +110,7 @@
22657 #include <asm/mce.h>
22658 #include <asm/alternative.h>
22659 #include <asm/prom.h>
22660 +#include <asm/boot.h>
22661
22662 /*
22663 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22664 @@ -444,7 +445,7 @@ static void __init parse_setup_data(void)
22665
22666 switch (data->type) {
22667 case SETUP_E820_EXT:
22668 - parse_e820_ext(data);
22669 + parse_e820_ext((struct setup_data __force_kernel *)data);
22670 break;
22671 case SETUP_DTB:
22672 add_dtb(pa_data);
22673 @@ -771,7 +772,7 @@ static void __init trim_bios_range(void)
22674 * area (640->1Mb) as ram even though it is not.
22675 * take them out.
22676 */
22677 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22678 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22679
22680 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22681 }
22682 @@ -779,7 +780,7 @@ static void __init trim_bios_range(void)
22683 /* called before trim_bios_range() to spare extra sanitize */
22684 static void __init e820_add_kernel_range(void)
22685 {
22686 - u64 start = __pa_symbol(_text);
22687 + u64 start = __pa_symbol(ktla_ktva(_text));
22688 u64 size = __pa_symbol(_end) - start;
22689
22690 /*
22691 @@ -841,8 +842,12 @@ static void __init trim_low_memory_range(void)
22692
22693 void __init setup_arch(char **cmdline_p)
22694 {
22695 +#ifdef CONFIG_X86_32
22696 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22697 +#else
22698 memblock_reserve(__pa_symbol(_text),
22699 (unsigned long)__bss_stop - (unsigned long)_text);
22700 +#endif
22701
22702 early_reserve_initrd();
22703
22704 @@ -934,14 +939,14 @@ void __init setup_arch(char **cmdline_p)
22705
22706 if (!boot_params.hdr.root_flags)
22707 root_mountflags &= ~MS_RDONLY;
22708 - init_mm.start_code = (unsigned long) _text;
22709 - init_mm.end_code = (unsigned long) _etext;
22710 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22711 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22712 init_mm.end_data = (unsigned long) _edata;
22713 init_mm.brk = _brk_end;
22714
22715 - code_resource.start = __pa_symbol(_text);
22716 - code_resource.end = __pa_symbol(_etext)-1;
22717 - data_resource.start = __pa_symbol(_etext);
22718 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22719 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22720 + data_resource.start = __pa_symbol(_sdata);
22721 data_resource.end = __pa_symbol(_edata)-1;
22722 bss_resource.start = __pa_symbol(__bss_start);
22723 bss_resource.end = __pa_symbol(__bss_stop)-1;
22724 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22725 index 5cdff03..80fa283 100644
22726 --- a/arch/x86/kernel/setup_percpu.c
22727 +++ b/arch/x86/kernel/setup_percpu.c
22728 @@ -21,19 +21,17 @@
22729 #include <asm/cpu.h>
22730 #include <asm/stackprotector.h>
22731
22732 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22733 +#ifdef CONFIG_SMP
22734 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22735 EXPORT_PER_CPU_SYMBOL(cpu_number);
22736 +#endif
22737
22738 -#ifdef CONFIG_X86_64
22739 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22740 -#else
22741 -#define BOOT_PERCPU_OFFSET 0
22742 -#endif
22743
22744 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22745 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22746
22747 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22748 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22749 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22750 };
22751 EXPORT_SYMBOL(__per_cpu_offset);
22752 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22753 {
22754 #ifdef CONFIG_NEED_MULTIPLE_NODES
22755 pg_data_t *last = NULL;
22756 - unsigned int cpu;
22757 + int cpu;
22758
22759 for_each_possible_cpu(cpu) {
22760 int node = early_cpu_to_node(cpu);
22761 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22762 {
22763 #ifdef CONFIG_X86_32
22764 struct desc_struct gdt;
22765 + unsigned long base = per_cpu_offset(cpu);
22766
22767 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22768 - 0x2 | DESCTYPE_S, 0x8);
22769 - gdt.s = 1;
22770 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22771 + 0x83 | DESCTYPE_S, 0xC);
22772 write_gdt_entry(get_cpu_gdt_table(cpu),
22773 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22774 #endif
22775 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22776 /* alrighty, percpu areas up and running */
22777 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22778 for_each_possible_cpu(cpu) {
22779 +#ifdef CONFIG_CC_STACKPROTECTOR
22780 +#ifdef CONFIG_X86_32
22781 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22782 +#endif
22783 +#endif
22784 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22785 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22786 per_cpu(cpu_number, cpu) = cpu;
22787 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22788 */
22789 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22790 #endif
22791 +#ifdef CONFIG_CC_STACKPROTECTOR
22792 +#ifdef CONFIG_X86_32
22793 + if (!cpu)
22794 + per_cpu(stack_canary.canary, cpu) = canary;
22795 +#endif
22796 +#endif
22797 /*
22798 * Up to this point, the boot CPU has been using .init.data
22799 * area. Reload any changed state for the boot CPU.
22800 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22801 index 6956299..f20beae 100644
22802 --- a/arch/x86/kernel/signal.c
22803 +++ b/arch/x86/kernel/signal.c
22804 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22805 * Align the stack pointer according to the i386 ABI,
22806 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22807 */
22808 - sp = ((sp + 4) & -16ul) - 4;
22809 + sp = ((sp - 12) & -16ul) - 4;
22810 #else /* !CONFIG_X86_32 */
22811 sp = round_down(sp, 16) - 8;
22812 #endif
22813 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22814 }
22815
22816 if (current->mm->context.vdso)
22817 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22818 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22819 else
22820 - restorer = &frame->retcode;
22821 + restorer = (void __user *)&frame->retcode;
22822 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22823 restorer = ksig->ka.sa.sa_restorer;
22824
22825 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22826 * reasons and because gdb uses it as a signature to notice
22827 * signal handler stack frames.
22828 */
22829 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22830 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22831
22832 if (err)
22833 return -EFAULT;
22834 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22835 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22836
22837 /* Set up to return from userspace. */
22838 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22839 + if (current->mm->context.vdso)
22840 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22841 + else
22842 + restorer = (void __user *)&frame->retcode;
22843 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22844 restorer = ksig->ka.sa.sa_restorer;
22845 put_user_ex(restorer, &frame->pretcode);
22846 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22847 * reasons and because gdb uses it as a signature to notice
22848 * signal handler stack frames.
22849 */
22850 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22851 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22852 } put_user_catch(err);
22853
22854 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22855 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22856 {
22857 int usig = signr_convert(ksig->sig);
22858 sigset_t *set = sigmask_to_save();
22859 - compat_sigset_t *cset = (compat_sigset_t *) set;
22860 + sigset_t sigcopy;
22861 + compat_sigset_t *cset;
22862 +
22863 + sigcopy = *set;
22864 +
22865 + cset = (compat_sigset_t *) &sigcopy;
22866
22867 /* Set up the stack frame */
22868 if (is_ia32_frame()) {
22869 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22870 } else if (is_x32_frame()) {
22871 return x32_setup_rt_frame(ksig, cset, regs);
22872 } else {
22873 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22874 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22875 }
22876 }
22877
22878 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22879 index 48d2b7d..90d328a 100644
22880 --- a/arch/x86/kernel/smp.c
22881 +++ b/arch/x86/kernel/smp.c
22882 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22883
22884 __setup("nonmi_ipi", nonmi_ipi_setup);
22885
22886 -struct smp_ops smp_ops = {
22887 +struct smp_ops smp_ops __read_only = {
22888 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22889 .smp_prepare_cpus = native_smp_prepare_cpus,
22890 .smp_cpus_done = native_smp_cpus_done,
22891 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22892 index bfd348e..4816ad8 100644
22893 --- a/arch/x86/kernel/smpboot.c
22894 +++ b/arch/x86/kernel/smpboot.c
22895 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22896 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22897 (THREAD_SIZE + task_stack_page(idle))) - 1);
22898 per_cpu(current_task, cpu) = idle;
22899 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22900
22901 #ifdef CONFIG_X86_32
22902 /* Stack for startup_32 can be just as for start_secondary onwards */
22903 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22904 #else
22905 clear_tsk_thread_flag(idle, TIF_FORK);
22906 initial_gs = per_cpu_offset(cpu);
22907 - per_cpu(kernel_stack, cpu) =
22908 - (unsigned long)task_stack_page(idle) -
22909 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22910 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22911 #endif
22912 +
22913 + pax_open_kernel();
22914 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22915 + pax_close_kernel();
22916 +
22917 initial_code = (unsigned long)start_secondary;
22918 stack_start = idle->thread.sp;
22919
22920 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22921 /* the FPU context is blank, nobody can own it */
22922 __cpu_disable_lazy_restore(cpu);
22923
22924 +#ifdef CONFIG_PAX_PER_CPU_PGD
22925 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22926 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22927 + KERNEL_PGD_PTRS);
22928 +#endif
22929 +
22930 + /* the FPU context is blank, nobody can own it */
22931 + __cpu_disable_lazy_restore(cpu);
22932 +
22933 err = do_boot_cpu(apicid, cpu, tidle);
22934 if (err) {
22935 pr_debug("do_boot_cpu failed %d\n", err);
22936 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22937 index 9b4d51d..5d28b58 100644
22938 --- a/arch/x86/kernel/step.c
22939 +++ b/arch/x86/kernel/step.c
22940 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22941 struct desc_struct *desc;
22942 unsigned long base;
22943
22944 - seg &= ~7UL;
22945 + seg >>= 3;
22946
22947 mutex_lock(&child->mm->context.lock);
22948 - if (unlikely((seg >> 3) >= child->mm->context.size))
22949 + if (unlikely(seg >= child->mm->context.size))
22950 addr = -1L; /* bogus selector, access would fault */
22951 else {
22952 desc = child->mm->context.ldt + seg;
22953 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22954 addr += base;
22955 }
22956 mutex_unlock(&child->mm->context.lock);
22957 - }
22958 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22959 + addr = ktla_ktva(addr);
22960
22961 return addr;
22962 }
22963 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22964 unsigned char opcode[15];
22965 unsigned long addr = convert_ip_to_linear(child, regs);
22966
22967 + if (addr == -EINVAL)
22968 + return 0;
22969 +
22970 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22971 for (i = 0; i < copied; i++) {
22972 switch (opcode[i]) {
22973 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22974 new file mode 100644
22975 index 0000000..5877189
22976 --- /dev/null
22977 +++ b/arch/x86/kernel/sys_i386_32.c
22978 @@ -0,0 +1,189 @@
22979 +/*
22980 + * This file contains various random system calls that
22981 + * have a non-standard calling sequence on the Linux/i386
22982 + * platform.
22983 + */
22984 +
22985 +#include <linux/errno.h>
22986 +#include <linux/sched.h>
22987 +#include <linux/mm.h>
22988 +#include <linux/fs.h>
22989 +#include <linux/smp.h>
22990 +#include <linux/sem.h>
22991 +#include <linux/msg.h>
22992 +#include <linux/shm.h>
22993 +#include <linux/stat.h>
22994 +#include <linux/syscalls.h>
22995 +#include <linux/mman.h>
22996 +#include <linux/file.h>
22997 +#include <linux/utsname.h>
22998 +#include <linux/ipc.h>
22999 +#include <linux/elf.h>
23000 +
23001 +#include <linux/uaccess.h>
23002 +#include <linux/unistd.h>
23003 +
23004 +#include <asm/syscalls.h>
23005 +
23006 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23007 +{
23008 + unsigned long pax_task_size = TASK_SIZE;
23009 +
23010 +#ifdef CONFIG_PAX_SEGMEXEC
23011 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23012 + pax_task_size = SEGMEXEC_TASK_SIZE;
23013 +#endif
23014 +
23015 + if (flags & MAP_FIXED)
23016 + if (len > pax_task_size || addr > pax_task_size - len)
23017 + return -EINVAL;
23018 +
23019 + return 0;
23020 +}
23021 +
23022 +/*
23023 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
23024 + */
23025 +static unsigned long get_align_mask(void)
23026 +{
23027 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
23028 + return 0;
23029 +
23030 + if (!(current->flags & PF_RANDOMIZE))
23031 + return 0;
23032 +
23033 + return va_align.mask;
23034 +}
23035 +
23036 +unsigned long
23037 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23038 + unsigned long len, unsigned long pgoff, unsigned long flags)
23039 +{
23040 + struct mm_struct *mm = current->mm;
23041 + struct vm_area_struct *vma;
23042 + unsigned long pax_task_size = TASK_SIZE;
23043 + struct vm_unmapped_area_info info;
23044 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23045 +
23046 +#ifdef CONFIG_PAX_SEGMEXEC
23047 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23048 + pax_task_size = SEGMEXEC_TASK_SIZE;
23049 +#endif
23050 +
23051 + pax_task_size -= PAGE_SIZE;
23052 +
23053 + if (len > pax_task_size)
23054 + return -ENOMEM;
23055 +
23056 + if (flags & MAP_FIXED)
23057 + return addr;
23058 +
23059 +#ifdef CONFIG_PAX_RANDMMAP
23060 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23061 +#endif
23062 +
23063 + if (addr) {
23064 + addr = PAGE_ALIGN(addr);
23065 + if (pax_task_size - len >= addr) {
23066 + vma = find_vma(mm, addr);
23067 + if (check_heap_stack_gap(vma, addr, len, offset))
23068 + return addr;
23069 + }
23070 + }
23071 +
23072 + info.flags = 0;
23073 + info.length = len;
23074 + info.align_mask = filp ? get_align_mask() : 0;
23075 + info.align_offset = pgoff << PAGE_SHIFT;
23076 + info.threadstack_offset = offset;
23077 +
23078 +#ifdef CONFIG_PAX_PAGEEXEC
23079 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
23080 + info.low_limit = 0x00110000UL;
23081 + info.high_limit = mm->start_code;
23082 +
23083 +#ifdef CONFIG_PAX_RANDMMAP
23084 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23085 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
23086 +#endif
23087 +
23088 + if (info.low_limit < info.high_limit) {
23089 + addr = vm_unmapped_area(&info);
23090 + if (!IS_ERR_VALUE(addr))
23091 + return addr;
23092 + }
23093 + } else
23094 +#endif
23095 +
23096 + info.low_limit = mm->mmap_base;
23097 + info.high_limit = pax_task_size;
23098 +
23099 + return vm_unmapped_area(&info);
23100 +}
23101 +
23102 +unsigned long
23103 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23104 + const unsigned long len, const unsigned long pgoff,
23105 + const unsigned long flags)
23106 +{
23107 + struct vm_area_struct *vma;
23108 + struct mm_struct *mm = current->mm;
23109 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23110 + struct vm_unmapped_area_info info;
23111 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23112 +
23113 +#ifdef CONFIG_PAX_SEGMEXEC
23114 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23115 + pax_task_size = SEGMEXEC_TASK_SIZE;
23116 +#endif
23117 +
23118 + pax_task_size -= PAGE_SIZE;
23119 +
23120 + /* requested length too big for entire address space */
23121 + if (len > pax_task_size)
23122 + return -ENOMEM;
23123 +
23124 + if (flags & MAP_FIXED)
23125 + return addr;
23126 +
23127 +#ifdef CONFIG_PAX_PAGEEXEC
23128 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23129 + goto bottomup;
23130 +#endif
23131 +
23132 +#ifdef CONFIG_PAX_RANDMMAP
23133 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23134 +#endif
23135 +
23136 + /* requesting a specific address */
23137 + if (addr) {
23138 + addr = PAGE_ALIGN(addr);
23139 + if (pax_task_size - len >= addr) {
23140 + vma = find_vma(mm, addr);
23141 + if (check_heap_stack_gap(vma, addr, len, offset))
23142 + return addr;
23143 + }
23144 + }
23145 +
23146 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23147 + info.length = len;
23148 + info.low_limit = PAGE_SIZE;
23149 + info.high_limit = mm->mmap_base;
23150 + info.align_mask = filp ? get_align_mask() : 0;
23151 + info.align_offset = pgoff << PAGE_SHIFT;
23152 + info.threadstack_offset = offset;
23153 +
23154 + addr = vm_unmapped_area(&info);
23155 + if (!(addr & ~PAGE_MASK))
23156 + return addr;
23157 + VM_BUG_ON(addr != -ENOMEM);
23158 +
23159 +bottomup:
23160 + /*
23161 + * A failed mmap() very likely causes application failure,
23162 + * so fall back to the bottom-up function here. This scenario
23163 + * can happen with large stack limits and large mmap()
23164 + * allocations.
23165 + */
23166 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23167 +}
23168 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23169 index dbded5a..ace2781 100644
23170 --- a/arch/x86/kernel/sys_x86_64.c
23171 +++ b/arch/x86/kernel/sys_x86_64.c
23172 @@ -81,8 +81,8 @@ out:
23173 return error;
23174 }
23175
23176 -static void find_start_end(unsigned long flags, unsigned long *begin,
23177 - unsigned long *end)
23178 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23179 + unsigned long *begin, unsigned long *end)
23180 {
23181 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23182 unsigned long new_begin;
23183 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23184 *begin = new_begin;
23185 }
23186 } else {
23187 - *begin = TASK_UNMAPPED_BASE;
23188 + *begin = mm->mmap_base;
23189 *end = TASK_SIZE;
23190 }
23191 }
23192 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23193 struct vm_area_struct *vma;
23194 struct vm_unmapped_area_info info;
23195 unsigned long begin, end;
23196 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23197
23198 if (flags & MAP_FIXED)
23199 return addr;
23200
23201 - find_start_end(flags, &begin, &end);
23202 + find_start_end(mm, flags, &begin, &end);
23203
23204 if (len > end)
23205 return -ENOMEM;
23206
23207 +#ifdef CONFIG_PAX_RANDMMAP
23208 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23209 +#endif
23210 +
23211 if (addr) {
23212 addr = PAGE_ALIGN(addr);
23213 vma = find_vma(mm, addr);
23214 - if (end - len >= addr &&
23215 - (!vma || addr + len <= vma->vm_start))
23216 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23217 return addr;
23218 }
23219
23220 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23221 info.high_limit = end;
23222 info.align_mask = filp ? get_align_mask() : 0;
23223 info.align_offset = pgoff << PAGE_SHIFT;
23224 + info.threadstack_offset = offset;
23225 return vm_unmapped_area(&info);
23226 }
23227
23228 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23229 struct mm_struct *mm = current->mm;
23230 unsigned long addr = addr0;
23231 struct vm_unmapped_area_info info;
23232 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23233
23234 /* requested length too big for entire address space */
23235 if (len > TASK_SIZE)
23236 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23237 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23238 goto bottomup;
23239
23240 +#ifdef CONFIG_PAX_RANDMMAP
23241 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23242 +#endif
23243 +
23244 /* requesting a specific address */
23245 if (addr) {
23246 addr = PAGE_ALIGN(addr);
23247 vma = find_vma(mm, addr);
23248 - if (TASK_SIZE - len >= addr &&
23249 - (!vma || addr + len <= vma->vm_start))
23250 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23251 return addr;
23252 }
23253
23254 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23255 info.high_limit = mm->mmap_base;
23256 info.align_mask = filp ? get_align_mask() : 0;
23257 info.align_offset = pgoff << PAGE_SHIFT;
23258 + info.threadstack_offset = offset;
23259 addr = vm_unmapped_area(&info);
23260 if (!(addr & ~PAGE_MASK))
23261 return addr;
23262 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23263 index f84fe00..f41d9f1 100644
23264 --- a/arch/x86/kernel/tboot.c
23265 +++ b/arch/x86/kernel/tboot.c
23266 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23267
23268 void tboot_shutdown(u32 shutdown_type)
23269 {
23270 - void (*shutdown)(void);
23271 + void (* __noreturn shutdown)(void);
23272
23273 if (!tboot_enabled())
23274 return;
23275 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23276
23277 switch_to_tboot_pt();
23278
23279 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23280 + shutdown = (void *)tboot->shutdown_entry;
23281 shutdown();
23282
23283 /* should not reach here */
23284 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23285 return 0;
23286 }
23287
23288 -static atomic_t ap_wfs_count;
23289 +static atomic_unchecked_t ap_wfs_count;
23290
23291 static int tboot_wait_for_aps(int num_aps)
23292 {
23293 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23294 {
23295 switch (action) {
23296 case CPU_DYING:
23297 - atomic_inc(&ap_wfs_count);
23298 + atomic_inc_unchecked(&ap_wfs_count);
23299 if (num_online_cpus() == 1)
23300 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23301 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23302 return NOTIFY_BAD;
23303 break;
23304 }
23305 return NOTIFY_OK;
23306 }
23307
23308 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23309 +static struct notifier_block tboot_cpu_notifier =
23310 {
23311 .notifier_call = tboot_cpu_callback,
23312 };
23313 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23314
23315 tboot_create_trampoline();
23316
23317 - atomic_set(&ap_wfs_count, 0);
23318 + atomic_set_unchecked(&ap_wfs_count, 0);
23319 register_hotcpu_notifier(&tboot_cpu_notifier);
23320
23321 acpi_os_set_prepare_sleep(&tboot_sleep);
23322 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23323 index 24d3c91..d06b473 100644
23324 --- a/arch/x86/kernel/time.c
23325 +++ b/arch/x86/kernel/time.c
23326 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23327 {
23328 unsigned long pc = instruction_pointer(regs);
23329
23330 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23331 + if (!user_mode(regs) && in_lock_functions(pc)) {
23332 #ifdef CONFIG_FRAME_POINTER
23333 - return *(unsigned long *)(regs->bp + sizeof(long));
23334 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23335 #else
23336 unsigned long *sp =
23337 (unsigned long *)kernel_stack_pointer(regs);
23338 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23339 * or above a saved flags. Eflags has bits 22-31 zero,
23340 * kernel addresses don't.
23341 */
23342 +
23343 +#ifdef CONFIG_PAX_KERNEXEC
23344 + return ktla_ktva(sp[0]);
23345 +#else
23346 if (sp[0] >> 22)
23347 return sp[0];
23348 if (sp[1] >> 22)
23349 return sp[1];
23350 #endif
23351 +
23352 +#endif
23353 }
23354 return pc;
23355 }
23356 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23357 index f7fec09..9991981 100644
23358 --- a/arch/x86/kernel/tls.c
23359 +++ b/arch/x86/kernel/tls.c
23360 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23361 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23362 return -EINVAL;
23363
23364 +#ifdef CONFIG_PAX_SEGMEXEC
23365 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23366 + return -EINVAL;
23367 +#endif
23368 +
23369 set_tls_desc(p, idx, &info, 1);
23370
23371 return 0;
23372 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23373
23374 if (kbuf)
23375 info = kbuf;
23376 - else if (__copy_from_user(infobuf, ubuf, count))
23377 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23378 return -EFAULT;
23379 else
23380 info = infobuf;
23381 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23382 index 772e2a8..bad5bf6 100644
23383 --- a/arch/x86/kernel/traps.c
23384 +++ b/arch/x86/kernel/traps.c
23385 @@ -68,12 +68,6 @@
23386 #include <asm/setup.h>
23387
23388 asmlinkage int system_call(void);
23389 -
23390 -/*
23391 - * The IDT has to be page-aligned to simplify the Pentium
23392 - * F0 0F bug workaround.
23393 - */
23394 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23395 #endif
23396
23397 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23398 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23399 }
23400
23401 static int __kprobes
23402 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23403 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23404 struct pt_regs *regs, long error_code)
23405 {
23406 #ifdef CONFIG_X86_32
23407 - if (regs->flags & X86_VM_MASK) {
23408 + if (v8086_mode(regs)) {
23409 /*
23410 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23411 * On nmi (interrupt 2), do_trap should not be called.
23412 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23413 return -1;
23414 }
23415 #endif
23416 - if (!user_mode(regs)) {
23417 + if (!user_mode_novm(regs)) {
23418 if (!fixup_exception(regs)) {
23419 tsk->thread.error_code = error_code;
23420 tsk->thread.trap_nr = trapnr;
23421 +
23422 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23423 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23424 + str = "PAX: suspicious stack segment fault";
23425 +#endif
23426 +
23427 die(str, regs, error_code);
23428 }
23429 +
23430 +#ifdef CONFIG_PAX_REFCOUNT
23431 + if (trapnr == 4)
23432 + pax_report_refcount_overflow(regs);
23433 +#endif
23434 +
23435 return 0;
23436 }
23437
23438 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23439 }
23440
23441 static void __kprobes
23442 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23443 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23444 long error_code, siginfo_t *info)
23445 {
23446 struct task_struct *tsk = current;
23447 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23448 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23449 printk_ratelimit()) {
23450 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23451 - tsk->comm, tsk->pid, str,
23452 + tsk->comm, task_pid_nr(tsk), str,
23453 regs->ip, regs->sp, error_code);
23454 print_vma_addr(" in ", regs->ip);
23455 pr_cont("\n");
23456 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23457 conditional_sti(regs);
23458
23459 #ifdef CONFIG_X86_32
23460 - if (regs->flags & X86_VM_MASK) {
23461 + if (v8086_mode(regs)) {
23462 local_irq_enable();
23463 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23464 goto exit;
23465 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23466 #endif
23467
23468 tsk = current;
23469 - if (!user_mode(regs)) {
23470 + if (!user_mode_novm(regs)) {
23471 if (fixup_exception(regs))
23472 goto exit;
23473
23474 tsk->thread.error_code = error_code;
23475 tsk->thread.trap_nr = X86_TRAP_GP;
23476 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23477 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23478 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23479 +
23480 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23481 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23482 + die("PAX: suspicious general protection fault", regs, error_code);
23483 + else
23484 +#endif
23485 +
23486 die("general protection fault", regs, error_code);
23487 + }
23488 goto exit;
23489 }
23490
23491 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23492 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23493 + struct mm_struct *mm = tsk->mm;
23494 + unsigned long limit;
23495 +
23496 + down_write(&mm->mmap_sem);
23497 + limit = mm->context.user_cs_limit;
23498 + if (limit < TASK_SIZE) {
23499 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23500 + up_write(&mm->mmap_sem);
23501 + return;
23502 + }
23503 + up_write(&mm->mmap_sem);
23504 + }
23505 +#endif
23506 +
23507 tsk->thread.error_code = error_code;
23508 tsk->thread.trap_nr = X86_TRAP_GP;
23509
23510 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23511 /* It's safe to allow irq's after DR6 has been saved */
23512 preempt_conditional_sti(regs);
23513
23514 - if (regs->flags & X86_VM_MASK) {
23515 + if (v8086_mode(regs)) {
23516 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23517 X86_TRAP_DB);
23518 preempt_conditional_cli(regs);
23519 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23520 * We already checked v86 mode above, so we can check for kernel mode
23521 * by just checking the CPL of CS.
23522 */
23523 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23524 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23525 tsk->thread.debugreg6 &= ~DR_STEP;
23526 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23527 regs->flags &= ~X86_EFLAGS_TF;
23528 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23529 return;
23530 conditional_sti(regs);
23531
23532 - if (!user_mode_vm(regs))
23533 + if (!user_mode(regs))
23534 {
23535 if (!fixup_exception(regs)) {
23536 task->thread.error_code = error_code;
23537 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23538 index 2ed8459..7cf329f 100644
23539 --- a/arch/x86/kernel/uprobes.c
23540 +++ b/arch/x86/kernel/uprobes.c
23541 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23542 int ret = NOTIFY_DONE;
23543
23544 /* We are only interested in userspace traps */
23545 - if (regs && !user_mode_vm(regs))
23546 + if (regs && !user_mode(regs))
23547 return NOTIFY_DONE;
23548
23549 switch (val) {
23550 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
23551
23552 if (ncopied != rasize) {
23553 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
23554 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
23555 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
23556
23557 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
23558 }
23559 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23560 index b9242ba..50c5edd 100644
23561 --- a/arch/x86/kernel/verify_cpu.S
23562 +++ b/arch/x86/kernel/verify_cpu.S
23563 @@ -20,6 +20,7 @@
23564 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23565 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23566 * arch/x86/kernel/head_32.S: processor startup
23567 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23568 *
23569 * verify_cpu, returns the status of longmode and SSE in register %eax.
23570 * 0: Success 1: Failure
23571 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23572 index e8edcf5..27f9344 100644
23573 --- a/arch/x86/kernel/vm86_32.c
23574 +++ b/arch/x86/kernel/vm86_32.c
23575 @@ -44,6 +44,7 @@
23576 #include <linux/ptrace.h>
23577 #include <linux/audit.h>
23578 #include <linux/stddef.h>
23579 +#include <linux/grsecurity.h>
23580
23581 #include <asm/uaccess.h>
23582 #include <asm/io.h>
23583 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23584 do_exit(SIGSEGV);
23585 }
23586
23587 - tss = &per_cpu(init_tss, get_cpu());
23588 + tss = init_tss + get_cpu();
23589 current->thread.sp0 = current->thread.saved_sp0;
23590 current->thread.sysenter_cs = __KERNEL_CS;
23591 load_sp0(tss, &current->thread);
23592 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23593
23594 if (tsk->thread.saved_sp0)
23595 return -EPERM;
23596 +
23597 +#ifdef CONFIG_GRKERNSEC_VM86
23598 + if (!capable(CAP_SYS_RAWIO)) {
23599 + gr_handle_vm86();
23600 + return -EPERM;
23601 + }
23602 +#endif
23603 +
23604 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23605 offsetof(struct kernel_vm86_struct, vm86plus) -
23606 sizeof(info.regs));
23607 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23608 int tmp;
23609 struct vm86plus_struct __user *v86;
23610
23611 +#ifdef CONFIG_GRKERNSEC_VM86
23612 + if (!capable(CAP_SYS_RAWIO)) {
23613 + gr_handle_vm86();
23614 + return -EPERM;
23615 + }
23616 +#endif
23617 +
23618 tsk = current;
23619 switch (cmd) {
23620 case VM86_REQUEST_IRQ:
23621 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23622 tsk->thread.saved_fs = info->regs32->fs;
23623 tsk->thread.saved_gs = get_user_gs(info->regs32);
23624
23625 - tss = &per_cpu(init_tss, get_cpu());
23626 + tss = init_tss + get_cpu();
23627 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23628 if (cpu_has_sep)
23629 tsk->thread.sysenter_cs = 0;
23630 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23631 goto cannot_handle;
23632 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23633 goto cannot_handle;
23634 - intr_ptr = (unsigned long __user *) (i << 2);
23635 + intr_ptr = (__force unsigned long __user *) (i << 2);
23636 if (get_user(segoffs, intr_ptr))
23637 goto cannot_handle;
23638 if ((segoffs >> 16) == BIOSSEG)
23639 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23640 index 10c4f30..57377c2 100644
23641 --- a/arch/x86/kernel/vmlinux.lds.S
23642 +++ b/arch/x86/kernel/vmlinux.lds.S
23643 @@ -26,6 +26,13 @@
23644 #include <asm/page_types.h>
23645 #include <asm/cache.h>
23646 #include <asm/boot.h>
23647 +#include <asm/segment.h>
23648 +
23649 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23650 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23651 +#else
23652 +#define __KERNEL_TEXT_OFFSET 0
23653 +#endif
23654
23655 #undef i386 /* in case the preprocessor is a 32bit one */
23656
23657 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23658
23659 PHDRS {
23660 text PT_LOAD FLAGS(5); /* R_E */
23661 +#ifdef CONFIG_X86_32
23662 + module PT_LOAD FLAGS(5); /* R_E */
23663 +#endif
23664 +#ifdef CONFIG_XEN
23665 + rodata PT_LOAD FLAGS(5); /* R_E */
23666 +#else
23667 + rodata PT_LOAD FLAGS(4); /* R__ */
23668 +#endif
23669 data PT_LOAD FLAGS(6); /* RW_ */
23670 -#ifdef CONFIG_X86_64
23671 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23672 #ifdef CONFIG_SMP
23673 percpu PT_LOAD FLAGS(6); /* RW_ */
23674 #endif
23675 + text.init PT_LOAD FLAGS(5); /* R_E */
23676 + text.exit PT_LOAD FLAGS(5); /* R_E */
23677 init PT_LOAD FLAGS(7); /* RWE */
23678 -#endif
23679 note PT_NOTE FLAGS(0); /* ___ */
23680 }
23681
23682 SECTIONS
23683 {
23684 #ifdef CONFIG_X86_32
23685 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23686 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23687 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23688 #else
23689 - . = __START_KERNEL;
23690 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23691 + . = __START_KERNEL;
23692 #endif
23693
23694 /* Text and read-only data */
23695 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23696 - _text = .;
23697 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23698 /* bootstrapping code */
23699 +#ifdef CONFIG_X86_32
23700 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23701 +#else
23702 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23703 +#endif
23704 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23705 + _text = .;
23706 HEAD_TEXT
23707 . = ALIGN(8);
23708 _stext = .;
23709 @@ -104,13 +124,48 @@ SECTIONS
23710 IRQENTRY_TEXT
23711 *(.fixup)
23712 *(.gnu.warning)
23713 - /* End of text section */
23714 - _etext = .;
23715 } :text = 0x9090
23716
23717 - NOTES :text :note
23718 + . += __KERNEL_TEXT_OFFSET;
23719
23720 - EXCEPTION_TABLE(16) :text = 0x9090
23721 +#ifdef CONFIG_X86_32
23722 + . = ALIGN(PAGE_SIZE);
23723 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23724 +
23725 +#ifdef CONFIG_PAX_KERNEXEC
23726 + MODULES_EXEC_VADDR = .;
23727 + BYTE(0)
23728 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23729 + . = ALIGN(HPAGE_SIZE) - 1;
23730 + MODULES_EXEC_END = .;
23731 +#endif
23732 +
23733 + } :module
23734 +#endif
23735 +
23736 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23737 + /* End of text section */
23738 + BYTE(0)
23739 + _etext = . - __KERNEL_TEXT_OFFSET;
23740 + }
23741 +
23742 +#ifdef CONFIG_X86_32
23743 + . = ALIGN(PAGE_SIZE);
23744 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23745 + *(.idt)
23746 + . = ALIGN(PAGE_SIZE);
23747 + *(.empty_zero_page)
23748 + *(.initial_pg_fixmap)
23749 + *(.initial_pg_pmd)
23750 + *(.initial_page_table)
23751 + *(.swapper_pg_dir)
23752 + } :rodata
23753 +#endif
23754 +
23755 + . = ALIGN(PAGE_SIZE);
23756 + NOTES :rodata :note
23757 +
23758 + EXCEPTION_TABLE(16) :rodata
23759
23760 #if defined(CONFIG_DEBUG_RODATA)
23761 /* .text should occupy whole number of pages */
23762 @@ -122,16 +177,20 @@ SECTIONS
23763
23764 /* Data */
23765 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23766 +
23767 +#ifdef CONFIG_PAX_KERNEXEC
23768 + . = ALIGN(HPAGE_SIZE);
23769 +#else
23770 + . = ALIGN(PAGE_SIZE);
23771 +#endif
23772 +
23773 /* Start of data section */
23774 _sdata = .;
23775
23776 /* init_task */
23777 INIT_TASK_DATA(THREAD_SIZE)
23778
23779 -#ifdef CONFIG_X86_32
23780 - /* 32 bit has nosave before _edata */
23781 NOSAVE_DATA
23782 -#endif
23783
23784 PAGE_ALIGNED_DATA(PAGE_SIZE)
23785
23786 @@ -172,12 +231,19 @@ SECTIONS
23787 #endif /* CONFIG_X86_64 */
23788
23789 /* Init code and data - will be freed after init */
23790 - . = ALIGN(PAGE_SIZE);
23791 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23792 + BYTE(0)
23793 +
23794 +#ifdef CONFIG_PAX_KERNEXEC
23795 + . = ALIGN(HPAGE_SIZE);
23796 +#else
23797 + . = ALIGN(PAGE_SIZE);
23798 +#endif
23799 +
23800 __init_begin = .; /* paired with __init_end */
23801 - }
23802 + } :init.begin
23803
23804 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23805 +#ifdef CONFIG_SMP
23806 /*
23807 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23808 * output PHDR, so the next output section - .init.text - should
23809 @@ -186,12 +252,27 @@ SECTIONS
23810 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23811 #endif
23812
23813 - INIT_TEXT_SECTION(PAGE_SIZE)
23814 -#ifdef CONFIG_X86_64
23815 - :init
23816 -#endif
23817 + . = ALIGN(PAGE_SIZE);
23818 + init_begin = .;
23819 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23820 + VMLINUX_SYMBOL(_sinittext) = .;
23821 + INIT_TEXT
23822 + VMLINUX_SYMBOL(_einittext) = .;
23823 + . = ALIGN(PAGE_SIZE);
23824 + } :text.init
23825
23826 - INIT_DATA_SECTION(16)
23827 + /*
23828 + * .exit.text is discard at runtime, not link time, to deal with
23829 + * references from .altinstructions and .eh_frame
23830 + */
23831 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23832 + EXIT_TEXT
23833 + . = ALIGN(16);
23834 + } :text.exit
23835 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23836 +
23837 + . = ALIGN(PAGE_SIZE);
23838 + INIT_DATA_SECTION(16) :init
23839
23840 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23841 __x86_cpu_dev_start = .;
23842 @@ -253,19 +334,12 @@ SECTIONS
23843 }
23844
23845 . = ALIGN(8);
23846 - /*
23847 - * .exit.text is discard at runtime, not link time, to deal with
23848 - * references from .altinstructions and .eh_frame
23849 - */
23850 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23851 - EXIT_TEXT
23852 - }
23853
23854 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23855 EXIT_DATA
23856 }
23857
23858 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23859 +#ifndef CONFIG_SMP
23860 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23861 #endif
23862
23863 @@ -284,16 +358,10 @@ SECTIONS
23864 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23865 __smp_locks = .;
23866 *(.smp_locks)
23867 - . = ALIGN(PAGE_SIZE);
23868 __smp_locks_end = .;
23869 + . = ALIGN(PAGE_SIZE);
23870 }
23871
23872 -#ifdef CONFIG_X86_64
23873 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23874 - NOSAVE_DATA
23875 - }
23876 -#endif
23877 -
23878 /* BSS */
23879 . = ALIGN(PAGE_SIZE);
23880 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23881 @@ -309,6 +377,7 @@ SECTIONS
23882 __brk_base = .;
23883 . += 64 * 1024; /* 64k alignment slop space */
23884 *(.brk_reservation) /* areas brk users have reserved */
23885 + . = ALIGN(HPAGE_SIZE);
23886 __brk_limit = .;
23887 }
23888
23889 @@ -335,13 +404,12 @@ SECTIONS
23890 * for the boot processor.
23891 */
23892 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23893 -INIT_PER_CPU(gdt_page);
23894 INIT_PER_CPU(irq_stack_union);
23895
23896 /*
23897 * Build-time check on the image size:
23898 */
23899 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23900 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23901 "kernel image bigger than KERNEL_IMAGE_SIZE");
23902
23903 #ifdef CONFIG_SMP
23904 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23905 index 9a907a6..f83f921 100644
23906 --- a/arch/x86/kernel/vsyscall_64.c
23907 +++ b/arch/x86/kernel/vsyscall_64.c
23908 @@ -56,15 +56,13 @@
23909 DEFINE_VVAR(int, vgetcpu_mode);
23910 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23911
23912 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23913 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23914
23915 static int __init vsyscall_setup(char *str)
23916 {
23917 if (str) {
23918 if (!strcmp("emulate", str))
23919 vsyscall_mode = EMULATE;
23920 - else if (!strcmp("native", str))
23921 - vsyscall_mode = NATIVE;
23922 else if (!strcmp("none", str))
23923 vsyscall_mode = NONE;
23924 else
23925 @@ -323,8 +321,7 @@ do_ret:
23926 return true;
23927
23928 sigsegv:
23929 - force_sig(SIGSEGV, current);
23930 - return true;
23931 + do_group_exit(SIGKILL);
23932 }
23933
23934 /*
23935 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23936 extern char __vvar_page;
23937 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23938
23939 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23940 - vsyscall_mode == NATIVE
23941 - ? PAGE_KERNEL_VSYSCALL
23942 - : PAGE_KERNEL_VVAR);
23943 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23944 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23945 (unsigned long)VSYSCALL_START);
23946
23947 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23948 index b014d94..6d6ca7b 100644
23949 --- a/arch/x86/kernel/x8664_ksyms_64.c
23950 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23951 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23952 EXPORT_SYMBOL(copy_user_generic_unrolled);
23953 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23954 EXPORT_SYMBOL(__copy_user_nocache);
23955 -EXPORT_SYMBOL(_copy_from_user);
23956 -EXPORT_SYMBOL(_copy_to_user);
23957
23958 EXPORT_SYMBOL(copy_page);
23959 EXPORT_SYMBOL(clear_page);
23960 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23961 index 45a14db..075bb9b 100644
23962 --- a/arch/x86/kernel/x86_init.c
23963 +++ b/arch/x86/kernel/x86_init.c
23964 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23965 },
23966 };
23967
23968 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23969 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23970 .early_percpu_clock_init = x86_init_noop,
23971 .setup_percpu_clockev = setup_secondary_APIC_clock,
23972 };
23973 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23974 static void default_nmi_init(void) { };
23975 static int default_i8042_detect(void) { return 1; };
23976
23977 -struct x86_platform_ops x86_platform = {
23978 +struct x86_platform_ops x86_platform __read_only = {
23979 .calibrate_tsc = native_calibrate_tsc,
23980 .get_wallclock = mach_get_cmos_time,
23981 .set_wallclock = mach_set_rtc_mmss,
23982 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23983 };
23984
23985 EXPORT_SYMBOL_GPL(x86_platform);
23986 -struct x86_msi_ops x86_msi = {
23987 +struct x86_msi_ops x86_msi __read_only = {
23988 .setup_msi_irqs = native_setup_msi_irqs,
23989 .compose_msi_msg = native_compose_msi_msg,
23990 .teardown_msi_irq = native_teardown_msi_irq,
23991 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23992 .setup_hpet_msi = default_setup_hpet_msi,
23993 };
23994
23995 -struct x86_io_apic_ops x86_io_apic_ops = {
23996 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23997 .init = native_io_apic_init_mappings,
23998 .read = native_io_apic_read,
23999 .write = native_io_apic_write,
24000 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24001 index ada87a3..afea76d 100644
24002 --- a/arch/x86/kernel/xsave.c
24003 +++ b/arch/x86/kernel/xsave.c
24004 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24005 {
24006 int err;
24007
24008 + buf = (struct xsave_struct __user *)____m(buf);
24009 if (use_xsave())
24010 err = xsave_user(buf);
24011 else if (use_fxsr())
24012 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24013 */
24014 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24015 {
24016 + buf = (void __user *)____m(buf);
24017 if (use_xsave()) {
24018 if ((unsigned long)buf % 64 || fx_only) {
24019 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24020 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24021 index a20ecb5..d0e2194 100644
24022 --- a/arch/x86/kvm/cpuid.c
24023 +++ b/arch/x86/kvm/cpuid.c
24024 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24025 struct kvm_cpuid2 *cpuid,
24026 struct kvm_cpuid_entry2 __user *entries)
24027 {
24028 - int r;
24029 + int r, i;
24030
24031 r = -E2BIG;
24032 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24033 goto out;
24034 r = -EFAULT;
24035 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24036 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24037 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24038 goto out;
24039 + for (i = 0; i < cpuid->nent; ++i) {
24040 + struct kvm_cpuid_entry2 cpuid_entry;
24041 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24042 + goto out;
24043 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24044 + }
24045 vcpu->arch.cpuid_nent = cpuid->nent;
24046 kvm_apic_set_version(vcpu);
24047 kvm_x86_ops->cpuid_update(vcpu);
24048 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24049 struct kvm_cpuid2 *cpuid,
24050 struct kvm_cpuid_entry2 __user *entries)
24051 {
24052 - int r;
24053 + int r, i;
24054
24055 r = -E2BIG;
24056 if (cpuid->nent < vcpu->arch.cpuid_nent)
24057 goto out;
24058 r = -EFAULT;
24059 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24060 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24061 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24062 goto out;
24063 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24064 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24065 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24066 + goto out;
24067 + }
24068 return 0;
24069
24070 out:
24071 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24072 index 5953dce..f11a7d2 100644
24073 --- a/arch/x86/kvm/emulate.c
24074 +++ b/arch/x86/kvm/emulate.c
24075 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24076
24077 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24078 do { \
24079 + unsigned long _tmp; \
24080 __asm__ __volatile__ ( \
24081 _PRE_EFLAGS("0", "4", "2") \
24082 _op _suffix " %"_x"3,%1; " \
24083 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24084 /* Raw emulation: instruction has two explicit operands. */
24085 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24086 do { \
24087 - unsigned long _tmp; \
24088 - \
24089 switch ((ctxt)->dst.bytes) { \
24090 case 2: \
24091 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24092 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24093
24094 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24095 do { \
24096 - unsigned long _tmp; \
24097 switch ((ctxt)->dst.bytes) { \
24098 case 1: \
24099 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24100 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24101 index 0eee2c8..94a32c3 100644
24102 --- a/arch/x86/kvm/lapic.c
24103 +++ b/arch/x86/kvm/lapic.c
24104 @@ -55,7 +55,7 @@
24105 #define APIC_BUS_CYCLE_NS 1
24106
24107 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24108 -#define apic_debug(fmt, arg...)
24109 +#define apic_debug(fmt, arg...) do {} while (0)
24110
24111 #define APIC_LVT_NUM 6
24112 /* 14 is the version for Xeon and Pentium 8.4.8*/
24113 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24114 index da20860..d19fdf5 100644
24115 --- a/arch/x86/kvm/paging_tmpl.h
24116 +++ b/arch/x86/kvm/paging_tmpl.h
24117 @@ -208,7 +208,7 @@ retry_walk:
24118 if (unlikely(kvm_is_error_hva(host_addr)))
24119 goto error;
24120
24121 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24122 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24123 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24124 goto error;
24125 walker->ptep_user[walker->level - 1] = ptep_user;
24126 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24127 index a14a6ea..dc86cf0 100644
24128 --- a/arch/x86/kvm/svm.c
24129 +++ b/arch/x86/kvm/svm.c
24130 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24131 int cpu = raw_smp_processor_id();
24132
24133 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24134 +
24135 + pax_open_kernel();
24136 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24137 + pax_close_kernel();
24138 +
24139 load_TR_desc();
24140 }
24141
24142 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24143 #endif
24144 #endif
24145
24146 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24147 + __set_fs(current_thread_info()->addr_limit);
24148 +#endif
24149 +
24150 reload_tss(vcpu);
24151
24152 local_irq_disable();
24153 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24154 index 5402c94..c3bdeee 100644
24155 --- a/arch/x86/kvm/vmx.c
24156 +++ b/arch/x86/kvm/vmx.c
24157 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24158 #endif
24159 }
24160
24161 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24162 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24163 {
24164 vmcs_writel(field, vmcs_readl(field) & ~mask);
24165 }
24166
24167 -static void vmcs_set_bits(unsigned long field, u32 mask)
24168 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24169 {
24170 vmcs_writel(field, vmcs_readl(field) | mask);
24171 }
24172 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
24173 struct desc_struct *descs;
24174
24175 descs = (void *)gdt->address;
24176 +
24177 + pax_open_kernel();
24178 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24179 + pax_close_kernel();
24180 +
24181 load_TR_desc();
24182 }
24183
24184 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24185 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24186 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24187
24188 +#ifdef CONFIG_PAX_PER_CPU_PGD
24189 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24190 +#endif
24191 +
24192 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24193 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24194 vmx->loaded_vmcs->cpu = cpu;
24195 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
24196 if (!cpu_has_vmx_flexpriority())
24197 flexpriority_enabled = 0;
24198
24199 - if (!cpu_has_vmx_tpr_shadow())
24200 - kvm_x86_ops->update_cr8_intercept = NULL;
24201 + if (!cpu_has_vmx_tpr_shadow()) {
24202 + pax_open_kernel();
24203 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24204 + pax_close_kernel();
24205 + }
24206
24207 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24208 kvm_disable_largepages();
24209 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
24210 if (!cpu_has_vmx_apicv())
24211 enable_apicv = 0;
24212
24213 + pax_open_kernel();
24214 if (enable_apicv)
24215 - kvm_x86_ops->update_cr8_intercept = NULL;
24216 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24217 else {
24218 - kvm_x86_ops->hwapic_irr_update = NULL;
24219 - kvm_x86_ops->deliver_posted_interrupt = NULL;
24220 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24221 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24222 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
24223 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24224 }
24225 + pax_close_kernel();
24226
24227 if (nested)
24228 nested_vmx_setup_ctls_msrs();
24229 @@ -4076,7 +4089,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24230
24231 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24232 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24233 +
24234 +#ifndef CONFIG_PAX_PER_CPU_PGD
24235 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24236 +#endif
24237
24238 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24239 #ifdef CONFIG_X86_64
24240 @@ -4098,7 +4114,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24241 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24242 vmx->host_idt_base = dt.address;
24243
24244 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24245 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24246
24247 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24248 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24249 @@ -7030,6 +7046,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24250 "jmp 2f \n\t"
24251 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24252 "2: "
24253 +
24254 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24255 + "ljmp %[cs],$3f\n\t"
24256 + "3: "
24257 +#endif
24258 +
24259 /* Save guest registers, load host registers, keep flags */
24260 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24261 "pop %0 \n\t"
24262 @@ -7082,6 +7104,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24263 #endif
24264 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24265 [wordsize]"i"(sizeof(ulong))
24266 +
24267 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24268 + ,[cs]"i"(__KERNEL_CS)
24269 +#endif
24270 +
24271 : "cc", "memory"
24272 #ifdef CONFIG_X86_64
24273 , "rax", "rbx", "rdi", "rsi"
24274 @@ -7095,7 +7122,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24275 if (debugctlmsr)
24276 update_debugctlmsr(debugctlmsr);
24277
24278 -#ifndef CONFIG_X86_64
24279 +#ifdef CONFIG_X86_32
24280 /*
24281 * The sysexit path does not restore ds/es, so we must set them to
24282 * a reasonable value ourselves.
24283 @@ -7104,8 +7131,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24284 * may be executed in interrupt context, which saves and restore segments
24285 * around it, nullifying its effect.
24286 */
24287 - loadsegment(ds, __USER_DS);
24288 - loadsegment(es, __USER_DS);
24289 + loadsegment(ds, __KERNEL_DS);
24290 + loadsegment(es, __KERNEL_DS);
24291 + loadsegment(ss, __KERNEL_DS);
24292 +
24293 +#ifdef CONFIG_PAX_KERNEXEC
24294 + loadsegment(fs, __KERNEL_PERCPU);
24295 +#endif
24296 +
24297 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24298 + __set_fs(current_thread_info()->addr_limit);
24299 +#endif
24300 +
24301 #endif
24302
24303 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24304 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24305 index e8ba99c..ee9d7d9 100644
24306 --- a/arch/x86/kvm/x86.c
24307 +++ b/arch/x86/kvm/x86.c
24308 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24309 {
24310 struct kvm *kvm = vcpu->kvm;
24311 int lm = is_long_mode(vcpu);
24312 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24313 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24314 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24315 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24316 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24317 : kvm->arch.xen_hvm_config.blob_size_32;
24318 u32 page_num = data & ~PAGE_MASK;
24319 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24320 if (n < msr_list.nmsrs)
24321 goto out;
24322 r = -EFAULT;
24323 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24324 + goto out;
24325 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24326 num_msrs_to_save * sizeof(u32)))
24327 goto out;
24328 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24329 };
24330 #endif
24331
24332 -int kvm_arch_init(void *opaque)
24333 +int kvm_arch_init(const void *opaque)
24334 {
24335 int r;
24336 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24337 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24338 index 7114c63..a1018fc 100644
24339 --- a/arch/x86/lguest/boot.c
24340 +++ b/arch/x86/lguest/boot.c
24341 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24342 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24343 * Launcher to reboot us.
24344 */
24345 -static void lguest_restart(char *reason)
24346 +static __noreturn void lguest_restart(char *reason)
24347 {
24348 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24349 + BUG();
24350 }
24351
24352 /*G:050
24353 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24354 index 00933d5..3a64af9 100644
24355 --- a/arch/x86/lib/atomic64_386_32.S
24356 +++ b/arch/x86/lib/atomic64_386_32.S
24357 @@ -48,6 +48,10 @@ BEGIN(read)
24358 movl (v), %eax
24359 movl 4(v), %edx
24360 RET_ENDP
24361 +BEGIN(read_unchecked)
24362 + movl (v), %eax
24363 + movl 4(v), %edx
24364 +RET_ENDP
24365 #undef v
24366
24367 #define v %esi
24368 @@ -55,6 +59,10 @@ BEGIN(set)
24369 movl %ebx, (v)
24370 movl %ecx, 4(v)
24371 RET_ENDP
24372 +BEGIN(set_unchecked)
24373 + movl %ebx, (v)
24374 + movl %ecx, 4(v)
24375 +RET_ENDP
24376 #undef v
24377
24378 #define v %esi
24379 @@ -70,6 +78,20 @@ RET_ENDP
24380 BEGIN(add)
24381 addl %eax, (v)
24382 adcl %edx, 4(v)
24383 +
24384 +#ifdef CONFIG_PAX_REFCOUNT
24385 + jno 0f
24386 + subl %eax, (v)
24387 + sbbl %edx, 4(v)
24388 + int $4
24389 +0:
24390 + _ASM_EXTABLE(0b, 0b)
24391 +#endif
24392 +
24393 +RET_ENDP
24394 +BEGIN(add_unchecked)
24395 + addl %eax, (v)
24396 + adcl %edx, 4(v)
24397 RET_ENDP
24398 #undef v
24399
24400 @@ -77,6 +99,24 @@ RET_ENDP
24401 BEGIN(add_return)
24402 addl (v), %eax
24403 adcl 4(v), %edx
24404 +
24405 +#ifdef CONFIG_PAX_REFCOUNT
24406 + into
24407 +1234:
24408 + _ASM_EXTABLE(1234b, 2f)
24409 +#endif
24410 +
24411 + movl %eax, (v)
24412 + movl %edx, 4(v)
24413 +
24414 +#ifdef CONFIG_PAX_REFCOUNT
24415 +2:
24416 +#endif
24417 +
24418 +RET_ENDP
24419 +BEGIN(add_return_unchecked)
24420 + addl (v), %eax
24421 + adcl 4(v), %edx
24422 movl %eax, (v)
24423 movl %edx, 4(v)
24424 RET_ENDP
24425 @@ -86,6 +126,20 @@ RET_ENDP
24426 BEGIN(sub)
24427 subl %eax, (v)
24428 sbbl %edx, 4(v)
24429 +
24430 +#ifdef CONFIG_PAX_REFCOUNT
24431 + jno 0f
24432 + addl %eax, (v)
24433 + adcl %edx, 4(v)
24434 + int $4
24435 +0:
24436 + _ASM_EXTABLE(0b, 0b)
24437 +#endif
24438 +
24439 +RET_ENDP
24440 +BEGIN(sub_unchecked)
24441 + subl %eax, (v)
24442 + sbbl %edx, 4(v)
24443 RET_ENDP
24444 #undef v
24445
24446 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24447 sbbl $0, %edx
24448 addl (v), %eax
24449 adcl 4(v), %edx
24450 +
24451 +#ifdef CONFIG_PAX_REFCOUNT
24452 + into
24453 +1234:
24454 + _ASM_EXTABLE(1234b, 2f)
24455 +#endif
24456 +
24457 + movl %eax, (v)
24458 + movl %edx, 4(v)
24459 +
24460 +#ifdef CONFIG_PAX_REFCOUNT
24461 +2:
24462 +#endif
24463 +
24464 +RET_ENDP
24465 +BEGIN(sub_return_unchecked)
24466 + negl %edx
24467 + negl %eax
24468 + sbbl $0, %edx
24469 + addl (v), %eax
24470 + adcl 4(v), %edx
24471 movl %eax, (v)
24472 movl %edx, 4(v)
24473 RET_ENDP
24474 @@ -105,6 +180,20 @@ RET_ENDP
24475 BEGIN(inc)
24476 addl $1, (v)
24477 adcl $0, 4(v)
24478 +
24479 +#ifdef CONFIG_PAX_REFCOUNT
24480 + jno 0f
24481 + subl $1, (v)
24482 + sbbl $0, 4(v)
24483 + int $4
24484 +0:
24485 + _ASM_EXTABLE(0b, 0b)
24486 +#endif
24487 +
24488 +RET_ENDP
24489 +BEGIN(inc_unchecked)
24490 + addl $1, (v)
24491 + adcl $0, 4(v)
24492 RET_ENDP
24493 #undef v
24494
24495 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24496 movl 4(v), %edx
24497 addl $1, %eax
24498 adcl $0, %edx
24499 +
24500 +#ifdef CONFIG_PAX_REFCOUNT
24501 + into
24502 +1234:
24503 + _ASM_EXTABLE(1234b, 2f)
24504 +#endif
24505 +
24506 + movl %eax, (v)
24507 + movl %edx, 4(v)
24508 +
24509 +#ifdef CONFIG_PAX_REFCOUNT
24510 +2:
24511 +#endif
24512 +
24513 +RET_ENDP
24514 +BEGIN(inc_return_unchecked)
24515 + movl (v), %eax
24516 + movl 4(v), %edx
24517 + addl $1, %eax
24518 + adcl $0, %edx
24519 movl %eax, (v)
24520 movl %edx, 4(v)
24521 RET_ENDP
24522 @@ -123,6 +232,20 @@ RET_ENDP
24523 BEGIN(dec)
24524 subl $1, (v)
24525 sbbl $0, 4(v)
24526 +
24527 +#ifdef CONFIG_PAX_REFCOUNT
24528 + jno 0f
24529 + addl $1, (v)
24530 + adcl $0, 4(v)
24531 + int $4
24532 +0:
24533 + _ASM_EXTABLE(0b, 0b)
24534 +#endif
24535 +
24536 +RET_ENDP
24537 +BEGIN(dec_unchecked)
24538 + subl $1, (v)
24539 + sbbl $0, 4(v)
24540 RET_ENDP
24541 #undef v
24542
24543 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24544 movl 4(v), %edx
24545 subl $1, %eax
24546 sbbl $0, %edx
24547 +
24548 +#ifdef CONFIG_PAX_REFCOUNT
24549 + into
24550 +1234:
24551 + _ASM_EXTABLE(1234b, 2f)
24552 +#endif
24553 +
24554 + movl %eax, (v)
24555 + movl %edx, 4(v)
24556 +
24557 +#ifdef CONFIG_PAX_REFCOUNT
24558 +2:
24559 +#endif
24560 +
24561 +RET_ENDP
24562 +BEGIN(dec_return_unchecked)
24563 + movl (v), %eax
24564 + movl 4(v), %edx
24565 + subl $1, %eax
24566 + sbbl $0, %edx
24567 movl %eax, (v)
24568 movl %edx, 4(v)
24569 RET_ENDP
24570 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24571 adcl %edx, %edi
24572 addl (v), %eax
24573 adcl 4(v), %edx
24574 +
24575 +#ifdef CONFIG_PAX_REFCOUNT
24576 + into
24577 +1234:
24578 + _ASM_EXTABLE(1234b, 2f)
24579 +#endif
24580 +
24581 cmpl %eax, %ecx
24582 je 3f
24583 1:
24584 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24585 1:
24586 addl $1, %eax
24587 adcl $0, %edx
24588 +
24589 +#ifdef CONFIG_PAX_REFCOUNT
24590 + into
24591 +1234:
24592 + _ASM_EXTABLE(1234b, 2f)
24593 +#endif
24594 +
24595 movl %eax, (v)
24596 movl %edx, 4(v)
24597 movl $1, %eax
24598 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24599 movl 4(v), %edx
24600 subl $1, %eax
24601 sbbl $0, %edx
24602 +
24603 +#ifdef CONFIG_PAX_REFCOUNT
24604 + into
24605 +1234:
24606 + _ASM_EXTABLE(1234b, 1f)
24607 +#endif
24608 +
24609 js 1f
24610 movl %eax, (v)
24611 movl %edx, 4(v)
24612 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24613 index f5cc9eb..51fa319 100644
24614 --- a/arch/x86/lib/atomic64_cx8_32.S
24615 +++ b/arch/x86/lib/atomic64_cx8_32.S
24616 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24617 CFI_STARTPROC
24618
24619 read64 %ecx
24620 + pax_force_retaddr
24621 ret
24622 CFI_ENDPROC
24623 ENDPROC(atomic64_read_cx8)
24624
24625 +ENTRY(atomic64_read_unchecked_cx8)
24626 + CFI_STARTPROC
24627 +
24628 + read64 %ecx
24629 + pax_force_retaddr
24630 + ret
24631 + CFI_ENDPROC
24632 +ENDPROC(atomic64_read_unchecked_cx8)
24633 +
24634 ENTRY(atomic64_set_cx8)
24635 CFI_STARTPROC
24636
24637 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24638 cmpxchg8b (%esi)
24639 jne 1b
24640
24641 + pax_force_retaddr
24642 ret
24643 CFI_ENDPROC
24644 ENDPROC(atomic64_set_cx8)
24645
24646 +ENTRY(atomic64_set_unchecked_cx8)
24647 + CFI_STARTPROC
24648 +
24649 +1:
24650 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24651 + * are atomic on 586 and newer */
24652 + cmpxchg8b (%esi)
24653 + jne 1b
24654 +
24655 + pax_force_retaddr
24656 + ret
24657 + CFI_ENDPROC
24658 +ENDPROC(atomic64_set_unchecked_cx8)
24659 +
24660 ENTRY(atomic64_xchg_cx8)
24661 CFI_STARTPROC
24662
24663 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24664 cmpxchg8b (%esi)
24665 jne 1b
24666
24667 + pax_force_retaddr
24668 ret
24669 CFI_ENDPROC
24670 ENDPROC(atomic64_xchg_cx8)
24671
24672 -.macro addsub_return func ins insc
24673 -ENTRY(atomic64_\func\()_return_cx8)
24674 +.macro addsub_return func ins insc unchecked=""
24675 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24676 CFI_STARTPROC
24677 SAVE ebp
24678 SAVE ebx
24679 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24680 movl %edx, %ecx
24681 \ins\()l %esi, %ebx
24682 \insc\()l %edi, %ecx
24683 +
24684 +.ifb \unchecked
24685 +#ifdef CONFIG_PAX_REFCOUNT
24686 + into
24687 +2:
24688 + _ASM_EXTABLE(2b, 3f)
24689 +#endif
24690 +.endif
24691 +
24692 LOCK_PREFIX
24693 cmpxchg8b (%ebp)
24694 jne 1b
24695 -
24696 -10:
24697 movl %ebx, %eax
24698 movl %ecx, %edx
24699 +
24700 +.ifb \unchecked
24701 +#ifdef CONFIG_PAX_REFCOUNT
24702 +3:
24703 +#endif
24704 +.endif
24705 +
24706 RESTORE edi
24707 RESTORE esi
24708 RESTORE ebx
24709 RESTORE ebp
24710 + pax_force_retaddr
24711 ret
24712 CFI_ENDPROC
24713 -ENDPROC(atomic64_\func\()_return_cx8)
24714 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24715 .endm
24716
24717 addsub_return add add adc
24718 addsub_return sub sub sbb
24719 +addsub_return add add adc _unchecked
24720 +addsub_return sub sub sbb _unchecked
24721
24722 -.macro incdec_return func ins insc
24723 -ENTRY(atomic64_\func\()_return_cx8)
24724 +.macro incdec_return func ins insc unchecked=""
24725 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24726 CFI_STARTPROC
24727 SAVE ebx
24728
24729 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24730 movl %edx, %ecx
24731 \ins\()l $1, %ebx
24732 \insc\()l $0, %ecx
24733 +
24734 +.ifb \unchecked
24735 +#ifdef CONFIG_PAX_REFCOUNT
24736 + into
24737 +2:
24738 + _ASM_EXTABLE(2b, 3f)
24739 +#endif
24740 +.endif
24741 +
24742 LOCK_PREFIX
24743 cmpxchg8b (%esi)
24744 jne 1b
24745
24746 -10:
24747 movl %ebx, %eax
24748 movl %ecx, %edx
24749 +
24750 +.ifb \unchecked
24751 +#ifdef CONFIG_PAX_REFCOUNT
24752 +3:
24753 +#endif
24754 +.endif
24755 +
24756 RESTORE ebx
24757 + pax_force_retaddr
24758 ret
24759 CFI_ENDPROC
24760 -ENDPROC(atomic64_\func\()_return_cx8)
24761 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24762 .endm
24763
24764 incdec_return inc add adc
24765 incdec_return dec sub sbb
24766 +incdec_return inc add adc _unchecked
24767 +incdec_return dec sub sbb _unchecked
24768
24769 ENTRY(atomic64_dec_if_positive_cx8)
24770 CFI_STARTPROC
24771 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24772 movl %edx, %ecx
24773 subl $1, %ebx
24774 sbb $0, %ecx
24775 +
24776 +#ifdef CONFIG_PAX_REFCOUNT
24777 + into
24778 +1234:
24779 + _ASM_EXTABLE(1234b, 2f)
24780 +#endif
24781 +
24782 js 2f
24783 LOCK_PREFIX
24784 cmpxchg8b (%esi)
24785 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24786 movl %ebx, %eax
24787 movl %ecx, %edx
24788 RESTORE ebx
24789 + pax_force_retaddr
24790 ret
24791 CFI_ENDPROC
24792 ENDPROC(atomic64_dec_if_positive_cx8)
24793 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24794 movl %edx, %ecx
24795 addl %ebp, %ebx
24796 adcl %edi, %ecx
24797 +
24798 +#ifdef CONFIG_PAX_REFCOUNT
24799 + into
24800 +1234:
24801 + _ASM_EXTABLE(1234b, 3f)
24802 +#endif
24803 +
24804 LOCK_PREFIX
24805 cmpxchg8b (%esi)
24806 jne 1b
24807 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24808 CFI_ADJUST_CFA_OFFSET -8
24809 RESTORE ebx
24810 RESTORE ebp
24811 + pax_force_retaddr
24812 ret
24813 4:
24814 cmpl %edx, 4(%esp)
24815 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24816 xorl %ecx, %ecx
24817 addl $1, %ebx
24818 adcl %edx, %ecx
24819 +
24820 +#ifdef CONFIG_PAX_REFCOUNT
24821 + into
24822 +1234:
24823 + _ASM_EXTABLE(1234b, 3f)
24824 +#endif
24825 +
24826 LOCK_PREFIX
24827 cmpxchg8b (%esi)
24828 jne 1b
24829 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24830 movl $1, %eax
24831 3:
24832 RESTORE ebx
24833 + pax_force_retaddr
24834 ret
24835 CFI_ENDPROC
24836 ENDPROC(atomic64_inc_not_zero_cx8)
24837 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24838 index e78b8ee..7e173a8 100644
24839 --- a/arch/x86/lib/checksum_32.S
24840 +++ b/arch/x86/lib/checksum_32.S
24841 @@ -29,7 +29,8 @@
24842 #include <asm/dwarf2.h>
24843 #include <asm/errno.h>
24844 #include <asm/asm.h>
24845 -
24846 +#include <asm/segment.h>
24847 +
24848 /*
24849 * computes a partial checksum, e.g. for TCP/UDP fragments
24850 */
24851 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24852
24853 #define ARGBASE 16
24854 #define FP 12
24855 -
24856 -ENTRY(csum_partial_copy_generic)
24857 +
24858 +ENTRY(csum_partial_copy_generic_to_user)
24859 CFI_STARTPROC
24860 +
24861 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24862 + pushl_cfi %gs
24863 + popl_cfi %es
24864 + jmp csum_partial_copy_generic
24865 +#endif
24866 +
24867 +ENTRY(csum_partial_copy_generic_from_user)
24868 +
24869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24870 + pushl_cfi %gs
24871 + popl_cfi %ds
24872 +#endif
24873 +
24874 +ENTRY(csum_partial_copy_generic)
24875 subl $4,%esp
24876 CFI_ADJUST_CFA_OFFSET 4
24877 pushl_cfi %edi
24878 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24879 jmp 4f
24880 SRC(1: movw (%esi), %bx )
24881 addl $2, %esi
24882 -DST( movw %bx, (%edi) )
24883 +DST( movw %bx, %es:(%edi) )
24884 addl $2, %edi
24885 addw %bx, %ax
24886 adcl $0, %eax
24887 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24888 SRC(1: movl (%esi), %ebx )
24889 SRC( movl 4(%esi), %edx )
24890 adcl %ebx, %eax
24891 -DST( movl %ebx, (%edi) )
24892 +DST( movl %ebx, %es:(%edi) )
24893 adcl %edx, %eax
24894 -DST( movl %edx, 4(%edi) )
24895 +DST( movl %edx, %es:4(%edi) )
24896
24897 SRC( movl 8(%esi), %ebx )
24898 SRC( movl 12(%esi), %edx )
24899 adcl %ebx, %eax
24900 -DST( movl %ebx, 8(%edi) )
24901 +DST( movl %ebx, %es:8(%edi) )
24902 adcl %edx, %eax
24903 -DST( movl %edx, 12(%edi) )
24904 +DST( movl %edx, %es:12(%edi) )
24905
24906 SRC( movl 16(%esi), %ebx )
24907 SRC( movl 20(%esi), %edx )
24908 adcl %ebx, %eax
24909 -DST( movl %ebx, 16(%edi) )
24910 +DST( movl %ebx, %es:16(%edi) )
24911 adcl %edx, %eax
24912 -DST( movl %edx, 20(%edi) )
24913 +DST( movl %edx, %es:20(%edi) )
24914
24915 SRC( movl 24(%esi), %ebx )
24916 SRC( movl 28(%esi), %edx )
24917 adcl %ebx, %eax
24918 -DST( movl %ebx, 24(%edi) )
24919 +DST( movl %ebx, %es:24(%edi) )
24920 adcl %edx, %eax
24921 -DST( movl %edx, 28(%edi) )
24922 +DST( movl %edx, %es:28(%edi) )
24923
24924 lea 32(%esi), %esi
24925 lea 32(%edi), %edi
24926 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24927 shrl $2, %edx # This clears CF
24928 SRC(3: movl (%esi), %ebx )
24929 adcl %ebx, %eax
24930 -DST( movl %ebx, (%edi) )
24931 +DST( movl %ebx, %es:(%edi) )
24932 lea 4(%esi), %esi
24933 lea 4(%edi), %edi
24934 dec %edx
24935 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24936 jb 5f
24937 SRC( movw (%esi), %cx )
24938 leal 2(%esi), %esi
24939 -DST( movw %cx, (%edi) )
24940 +DST( movw %cx, %es:(%edi) )
24941 leal 2(%edi), %edi
24942 je 6f
24943 shll $16,%ecx
24944 SRC(5: movb (%esi), %cl )
24945 -DST( movb %cl, (%edi) )
24946 +DST( movb %cl, %es:(%edi) )
24947 6: addl %ecx, %eax
24948 adcl $0, %eax
24949 7:
24950 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24951
24952 6001:
24953 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24954 - movl $-EFAULT, (%ebx)
24955 + movl $-EFAULT, %ss:(%ebx)
24956
24957 # zero the complete destination - computing the rest
24958 # is too much work
24959 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24960
24961 6002:
24962 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24963 - movl $-EFAULT,(%ebx)
24964 + movl $-EFAULT,%ss:(%ebx)
24965 jmp 5000b
24966
24967 .previous
24968
24969 + pushl_cfi %ss
24970 + popl_cfi %ds
24971 + pushl_cfi %ss
24972 + popl_cfi %es
24973 popl_cfi %ebx
24974 CFI_RESTORE ebx
24975 popl_cfi %esi
24976 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24977 popl_cfi %ecx # equivalent to addl $4,%esp
24978 ret
24979 CFI_ENDPROC
24980 -ENDPROC(csum_partial_copy_generic)
24981 +ENDPROC(csum_partial_copy_generic_to_user)
24982
24983 #else
24984
24985 /* Version for PentiumII/PPro */
24986
24987 #define ROUND1(x) \
24988 + nop; nop; nop; \
24989 SRC(movl x(%esi), %ebx ) ; \
24990 addl %ebx, %eax ; \
24991 - DST(movl %ebx, x(%edi) ) ;
24992 + DST(movl %ebx, %es:x(%edi)) ;
24993
24994 #define ROUND(x) \
24995 + nop; nop; nop; \
24996 SRC(movl x(%esi), %ebx ) ; \
24997 adcl %ebx, %eax ; \
24998 - DST(movl %ebx, x(%edi) ) ;
24999 + DST(movl %ebx, %es:x(%edi)) ;
25000
25001 #define ARGBASE 12
25002 -
25003 -ENTRY(csum_partial_copy_generic)
25004 +
25005 +ENTRY(csum_partial_copy_generic_to_user)
25006 CFI_STARTPROC
25007 +
25008 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25009 + pushl_cfi %gs
25010 + popl_cfi %es
25011 + jmp csum_partial_copy_generic
25012 +#endif
25013 +
25014 +ENTRY(csum_partial_copy_generic_from_user)
25015 +
25016 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25017 + pushl_cfi %gs
25018 + popl_cfi %ds
25019 +#endif
25020 +
25021 +ENTRY(csum_partial_copy_generic)
25022 pushl_cfi %ebx
25023 CFI_REL_OFFSET ebx, 0
25024 pushl_cfi %edi
25025 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25026 subl %ebx, %edi
25027 lea -1(%esi),%edx
25028 andl $-32,%edx
25029 - lea 3f(%ebx,%ebx), %ebx
25030 + lea 3f(%ebx,%ebx,2), %ebx
25031 testl %esi, %esi
25032 jmp *%ebx
25033 1: addl $64,%esi
25034 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25035 jb 5f
25036 SRC( movw (%esi), %dx )
25037 leal 2(%esi), %esi
25038 -DST( movw %dx, (%edi) )
25039 +DST( movw %dx, %es:(%edi) )
25040 leal 2(%edi), %edi
25041 je 6f
25042 shll $16,%edx
25043 5:
25044 SRC( movb (%esi), %dl )
25045 -DST( movb %dl, (%edi) )
25046 +DST( movb %dl, %es:(%edi) )
25047 6: addl %edx, %eax
25048 adcl $0, %eax
25049 7:
25050 .section .fixup, "ax"
25051 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25052 - movl $-EFAULT, (%ebx)
25053 + movl $-EFAULT, %ss:(%ebx)
25054 # zero the complete destination (computing the rest is too much work)
25055 movl ARGBASE+8(%esp),%edi # dst
25056 movl ARGBASE+12(%esp),%ecx # len
25057 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25058 rep; stosb
25059 jmp 7b
25060 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25061 - movl $-EFAULT, (%ebx)
25062 + movl $-EFAULT, %ss:(%ebx)
25063 jmp 7b
25064 .previous
25065
25066 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25067 + pushl_cfi %ss
25068 + popl_cfi %ds
25069 + pushl_cfi %ss
25070 + popl_cfi %es
25071 +#endif
25072 +
25073 popl_cfi %esi
25074 CFI_RESTORE esi
25075 popl_cfi %edi
25076 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25077 CFI_RESTORE ebx
25078 ret
25079 CFI_ENDPROC
25080 -ENDPROC(csum_partial_copy_generic)
25081 +ENDPROC(csum_partial_copy_generic_to_user)
25082
25083 #undef ROUND
25084 #undef ROUND1
25085 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25086 index f2145cf..cea889d 100644
25087 --- a/arch/x86/lib/clear_page_64.S
25088 +++ b/arch/x86/lib/clear_page_64.S
25089 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25090 movl $4096/8,%ecx
25091 xorl %eax,%eax
25092 rep stosq
25093 + pax_force_retaddr
25094 ret
25095 CFI_ENDPROC
25096 ENDPROC(clear_page_c)
25097 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25098 movl $4096,%ecx
25099 xorl %eax,%eax
25100 rep stosb
25101 + pax_force_retaddr
25102 ret
25103 CFI_ENDPROC
25104 ENDPROC(clear_page_c_e)
25105 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25106 leaq 64(%rdi),%rdi
25107 jnz .Lloop
25108 nop
25109 + pax_force_retaddr
25110 ret
25111 CFI_ENDPROC
25112 .Lclear_page_end:
25113 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25114
25115 #include <asm/cpufeature.h>
25116
25117 - .section .altinstr_replacement,"ax"
25118 + .section .altinstr_replacement,"a"
25119 1: .byte 0xeb /* jmp <disp8> */
25120 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25121 2: .byte 0xeb /* jmp <disp8> */
25122 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25123 index 1e572c5..2a162cd 100644
25124 --- a/arch/x86/lib/cmpxchg16b_emu.S
25125 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25126 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25127
25128 popf
25129 mov $1, %al
25130 + pax_force_retaddr
25131 ret
25132
25133 not_same:
25134 popf
25135 xor %al,%al
25136 + pax_force_retaddr
25137 ret
25138
25139 CFI_ENDPROC
25140 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25141 index 176cca6..1166c50 100644
25142 --- a/arch/x86/lib/copy_page_64.S
25143 +++ b/arch/x86/lib/copy_page_64.S
25144 @@ -9,6 +9,7 @@ copy_page_rep:
25145 CFI_STARTPROC
25146 movl $4096/8, %ecx
25147 rep movsq
25148 + pax_force_retaddr
25149 ret
25150 CFI_ENDPROC
25151 ENDPROC(copy_page_rep)
25152 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25153
25154 ENTRY(copy_page)
25155 CFI_STARTPROC
25156 - subq $2*8, %rsp
25157 - CFI_ADJUST_CFA_OFFSET 2*8
25158 + subq $3*8, %rsp
25159 + CFI_ADJUST_CFA_OFFSET 3*8
25160 movq %rbx, (%rsp)
25161 CFI_REL_OFFSET rbx, 0
25162 movq %r12, 1*8(%rsp)
25163 CFI_REL_OFFSET r12, 1*8
25164 + movq %r13, 2*8(%rsp)
25165 + CFI_REL_OFFSET r13, 2*8
25166
25167 movl $(4096/64)-5, %ecx
25168 .p2align 4
25169 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25170 movq 0x8*2(%rsi), %rdx
25171 movq 0x8*3(%rsi), %r8
25172 movq 0x8*4(%rsi), %r9
25173 - movq 0x8*5(%rsi), %r10
25174 + movq 0x8*5(%rsi), %r13
25175 movq 0x8*6(%rsi), %r11
25176 movq 0x8*7(%rsi), %r12
25177
25178 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25179 movq %rdx, 0x8*2(%rdi)
25180 movq %r8, 0x8*3(%rdi)
25181 movq %r9, 0x8*4(%rdi)
25182 - movq %r10, 0x8*5(%rdi)
25183 + movq %r13, 0x8*5(%rdi)
25184 movq %r11, 0x8*6(%rdi)
25185 movq %r12, 0x8*7(%rdi)
25186
25187 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25188 movq 0x8*2(%rsi), %rdx
25189 movq 0x8*3(%rsi), %r8
25190 movq 0x8*4(%rsi), %r9
25191 - movq 0x8*5(%rsi), %r10
25192 + movq 0x8*5(%rsi), %r13
25193 movq 0x8*6(%rsi), %r11
25194 movq 0x8*7(%rsi), %r12
25195
25196 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25197 movq %rdx, 0x8*2(%rdi)
25198 movq %r8, 0x8*3(%rdi)
25199 movq %r9, 0x8*4(%rdi)
25200 - movq %r10, 0x8*5(%rdi)
25201 + movq %r13, 0x8*5(%rdi)
25202 movq %r11, 0x8*6(%rdi)
25203 movq %r12, 0x8*7(%rdi)
25204
25205 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25206 CFI_RESTORE rbx
25207 movq 1*8(%rsp), %r12
25208 CFI_RESTORE r12
25209 - addq $2*8, %rsp
25210 - CFI_ADJUST_CFA_OFFSET -2*8
25211 + movq 2*8(%rsp), %r13
25212 + CFI_RESTORE r13
25213 + addq $3*8, %rsp
25214 + CFI_ADJUST_CFA_OFFSET -3*8
25215 + pax_force_retaddr
25216 ret
25217 .Lcopy_page_end:
25218 CFI_ENDPROC
25219 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25220
25221 #include <asm/cpufeature.h>
25222
25223 - .section .altinstr_replacement,"ax"
25224 + .section .altinstr_replacement,"a"
25225 1: .byte 0xeb /* jmp <disp8> */
25226 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25227 2:
25228 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25229 index a30ca15..d25fab6 100644
25230 --- a/arch/x86/lib/copy_user_64.S
25231 +++ b/arch/x86/lib/copy_user_64.S
25232 @@ -18,6 +18,7 @@
25233 #include <asm/alternative-asm.h>
25234 #include <asm/asm.h>
25235 #include <asm/smap.h>
25236 +#include <asm/pgtable.h>
25237
25238 /*
25239 * By placing feature2 after feature1 in altinstructions section, we logically
25240 @@ -31,7 +32,7 @@
25241 .byte 0xe9 /* 32bit jump */
25242 .long \orig-1f /* by default jump to orig */
25243 1:
25244 - .section .altinstr_replacement,"ax"
25245 + .section .altinstr_replacement,"a"
25246 2: .byte 0xe9 /* near jump with 32bit immediate */
25247 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25248 3: .byte 0xe9 /* near jump with 32bit immediate */
25249 @@ -70,47 +71,20 @@
25250 #endif
25251 .endm
25252
25253 -/* Standard copy_to_user with segment limit checking */
25254 -ENTRY(_copy_to_user)
25255 - CFI_STARTPROC
25256 - GET_THREAD_INFO(%rax)
25257 - movq %rdi,%rcx
25258 - addq %rdx,%rcx
25259 - jc bad_to_user
25260 - cmpq TI_addr_limit(%rax),%rcx
25261 - ja bad_to_user
25262 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25263 - copy_user_generic_unrolled,copy_user_generic_string, \
25264 - copy_user_enhanced_fast_string
25265 - CFI_ENDPROC
25266 -ENDPROC(_copy_to_user)
25267 -
25268 -/* Standard copy_from_user with segment limit checking */
25269 -ENTRY(_copy_from_user)
25270 - CFI_STARTPROC
25271 - GET_THREAD_INFO(%rax)
25272 - movq %rsi,%rcx
25273 - addq %rdx,%rcx
25274 - jc bad_from_user
25275 - cmpq TI_addr_limit(%rax),%rcx
25276 - ja bad_from_user
25277 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25278 - copy_user_generic_unrolled,copy_user_generic_string, \
25279 - copy_user_enhanced_fast_string
25280 - CFI_ENDPROC
25281 -ENDPROC(_copy_from_user)
25282 -
25283 .section .fixup,"ax"
25284 /* must zero dest */
25285 ENTRY(bad_from_user)
25286 bad_from_user:
25287 CFI_STARTPROC
25288 + testl %edx,%edx
25289 + js bad_to_user
25290 movl %edx,%ecx
25291 xorl %eax,%eax
25292 rep
25293 stosb
25294 bad_to_user:
25295 movl %edx,%eax
25296 + pax_force_retaddr
25297 ret
25298 CFI_ENDPROC
25299 ENDPROC(bad_from_user)
25300 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25301 jz 17f
25302 1: movq (%rsi),%r8
25303 2: movq 1*8(%rsi),%r9
25304 -3: movq 2*8(%rsi),%r10
25305 +3: movq 2*8(%rsi),%rax
25306 4: movq 3*8(%rsi),%r11
25307 5: movq %r8,(%rdi)
25308 6: movq %r9,1*8(%rdi)
25309 -7: movq %r10,2*8(%rdi)
25310 +7: movq %rax,2*8(%rdi)
25311 8: movq %r11,3*8(%rdi)
25312 9: movq 4*8(%rsi),%r8
25313 10: movq 5*8(%rsi),%r9
25314 -11: movq 6*8(%rsi),%r10
25315 +11: movq 6*8(%rsi),%rax
25316 12: movq 7*8(%rsi),%r11
25317 13: movq %r8,4*8(%rdi)
25318 14: movq %r9,5*8(%rdi)
25319 -15: movq %r10,6*8(%rdi)
25320 +15: movq %rax,6*8(%rdi)
25321 16: movq %r11,7*8(%rdi)
25322 leaq 64(%rsi),%rsi
25323 leaq 64(%rdi),%rdi
25324 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25325 jnz 21b
25326 23: xor %eax,%eax
25327 ASM_CLAC
25328 + pax_force_retaddr
25329 ret
25330
25331 .section .fixup,"ax"
25332 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25333 movsb
25334 4: xorl %eax,%eax
25335 ASM_CLAC
25336 + pax_force_retaddr
25337 ret
25338
25339 .section .fixup,"ax"
25340 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25341 movsb
25342 2: xorl %eax,%eax
25343 ASM_CLAC
25344 + pax_force_retaddr
25345 ret
25346
25347 .section .fixup,"ax"
25348 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25349 index 6a4f43c..f08b4a2 100644
25350 --- a/arch/x86/lib/copy_user_nocache_64.S
25351 +++ b/arch/x86/lib/copy_user_nocache_64.S
25352 @@ -8,6 +8,7 @@
25353
25354 #include <linux/linkage.h>
25355 #include <asm/dwarf2.h>
25356 +#include <asm/alternative-asm.h>
25357
25358 #define FIX_ALIGNMENT 1
25359
25360 @@ -16,6 +17,7 @@
25361 #include <asm/thread_info.h>
25362 #include <asm/asm.h>
25363 #include <asm/smap.h>
25364 +#include <asm/pgtable.h>
25365
25366 .macro ALIGN_DESTINATION
25367 #ifdef FIX_ALIGNMENT
25368 @@ -49,6 +51,15 @@
25369 */
25370 ENTRY(__copy_user_nocache)
25371 CFI_STARTPROC
25372 +
25373 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25374 + mov pax_user_shadow_base,%rcx
25375 + cmp %rcx,%rsi
25376 + jae 1f
25377 + add %rcx,%rsi
25378 +1:
25379 +#endif
25380 +
25381 ASM_STAC
25382 cmpl $8,%edx
25383 jb 20f /* less then 8 bytes, go to byte copy loop */
25384 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25385 jz 17f
25386 1: movq (%rsi),%r8
25387 2: movq 1*8(%rsi),%r9
25388 -3: movq 2*8(%rsi),%r10
25389 +3: movq 2*8(%rsi),%rax
25390 4: movq 3*8(%rsi),%r11
25391 5: movnti %r8,(%rdi)
25392 6: movnti %r9,1*8(%rdi)
25393 -7: movnti %r10,2*8(%rdi)
25394 +7: movnti %rax,2*8(%rdi)
25395 8: movnti %r11,3*8(%rdi)
25396 9: movq 4*8(%rsi),%r8
25397 10: movq 5*8(%rsi),%r9
25398 -11: movq 6*8(%rsi),%r10
25399 +11: movq 6*8(%rsi),%rax
25400 12: movq 7*8(%rsi),%r11
25401 13: movnti %r8,4*8(%rdi)
25402 14: movnti %r9,5*8(%rdi)
25403 -15: movnti %r10,6*8(%rdi)
25404 +15: movnti %rax,6*8(%rdi)
25405 16: movnti %r11,7*8(%rdi)
25406 leaq 64(%rsi),%rsi
25407 leaq 64(%rdi),%rdi
25408 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25409 23: xorl %eax,%eax
25410 ASM_CLAC
25411 sfence
25412 + pax_force_retaddr
25413 ret
25414
25415 .section .fixup,"ax"
25416 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25417 index 2419d5f..953ee51 100644
25418 --- a/arch/x86/lib/csum-copy_64.S
25419 +++ b/arch/x86/lib/csum-copy_64.S
25420 @@ -9,6 +9,7 @@
25421 #include <asm/dwarf2.h>
25422 #include <asm/errno.h>
25423 #include <asm/asm.h>
25424 +#include <asm/alternative-asm.h>
25425
25426 /*
25427 * Checksum copy with exception handling.
25428 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25429 CFI_RESTORE rbp
25430 addq $7*8, %rsp
25431 CFI_ADJUST_CFA_OFFSET -7*8
25432 + pax_force_retaddr 0, 1
25433 ret
25434 CFI_RESTORE_STATE
25435
25436 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25437 index 25b7ae8..169fafc 100644
25438 --- a/arch/x86/lib/csum-wrappers_64.c
25439 +++ b/arch/x86/lib/csum-wrappers_64.c
25440 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25441 len -= 2;
25442 }
25443 }
25444 - isum = csum_partial_copy_generic((__force const void *)src,
25445 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25446 dst, len, isum, errp, NULL);
25447 if (unlikely(*errp))
25448 goto out_err;
25449 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25450 }
25451
25452 *errp = 0;
25453 - return csum_partial_copy_generic(src, (void __force *)dst,
25454 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25455 len, isum, NULL, errp);
25456 }
25457 EXPORT_SYMBOL(csum_partial_copy_to_user);
25458 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25459 index a451235..1daa956 100644
25460 --- a/arch/x86/lib/getuser.S
25461 +++ b/arch/x86/lib/getuser.S
25462 @@ -33,17 +33,40 @@
25463 #include <asm/thread_info.h>
25464 #include <asm/asm.h>
25465 #include <asm/smap.h>
25466 +#include <asm/segment.h>
25467 +#include <asm/pgtable.h>
25468 +#include <asm/alternative-asm.h>
25469 +
25470 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25471 +#define __copyuser_seg gs;
25472 +#else
25473 +#define __copyuser_seg
25474 +#endif
25475
25476 .text
25477 ENTRY(__get_user_1)
25478 CFI_STARTPROC
25479 +
25480 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25481 GET_THREAD_INFO(%_ASM_DX)
25482 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25483 jae bad_get_user
25484 ASM_STAC
25485 -1: movzbl (%_ASM_AX),%edx
25486 +
25487 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25488 + mov pax_user_shadow_base,%_ASM_DX
25489 + cmp %_ASM_DX,%_ASM_AX
25490 + jae 1234f
25491 + add %_ASM_DX,%_ASM_AX
25492 +1234:
25493 +#endif
25494 +
25495 +#endif
25496 +
25497 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25498 xor %eax,%eax
25499 ASM_CLAC
25500 + pax_force_retaddr
25501 ret
25502 CFI_ENDPROC
25503 ENDPROC(__get_user_1)
25504 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25505 ENTRY(__get_user_2)
25506 CFI_STARTPROC
25507 add $1,%_ASM_AX
25508 +
25509 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25510 jc bad_get_user
25511 GET_THREAD_INFO(%_ASM_DX)
25512 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25513 jae bad_get_user
25514 ASM_STAC
25515 -2: movzwl -1(%_ASM_AX),%edx
25516 +
25517 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25518 + mov pax_user_shadow_base,%_ASM_DX
25519 + cmp %_ASM_DX,%_ASM_AX
25520 + jae 1234f
25521 + add %_ASM_DX,%_ASM_AX
25522 +1234:
25523 +#endif
25524 +
25525 +#endif
25526 +
25527 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25528 xor %eax,%eax
25529 ASM_CLAC
25530 + pax_force_retaddr
25531 ret
25532 CFI_ENDPROC
25533 ENDPROC(__get_user_2)
25534 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25535 ENTRY(__get_user_4)
25536 CFI_STARTPROC
25537 add $3,%_ASM_AX
25538 +
25539 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25540 jc bad_get_user
25541 GET_THREAD_INFO(%_ASM_DX)
25542 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25543 jae bad_get_user
25544 ASM_STAC
25545 -3: movl -3(%_ASM_AX),%edx
25546 +
25547 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25548 + mov pax_user_shadow_base,%_ASM_DX
25549 + cmp %_ASM_DX,%_ASM_AX
25550 + jae 1234f
25551 + add %_ASM_DX,%_ASM_AX
25552 +1234:
25553 +#endif
25554 +
25555 +#endif
25556 +
25557 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25558 xor %eax,%eax
25559 ASM_CLAC
25560 + pax_force_retaddr
25561 ret
25562 CFI_ENDPROC
25563 ENDPROC(__get_user_4)
25564 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25565 GET_THREAD_INFO(%_ASM_DX)
25566 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25567 jae bad_get_user
25568 +
25569 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25570 + mov pax_user_shadow_base,%_ASM_DX
25571 + cmp %_ASM_DX,%_ASM_AX
25572 + jae 1234f
25573 + add %_ASM_DX,%_ASM_AX
25574 +1234:
25575 +#endif
25576 +
25577 ASM_STAC
25578 4: movq -7(%_ASM_AX),%rdx
25579 xor %eax,%eax
25580 ASM_CLAC
25581 + pax_force_retaddr
25582 ret
25583 #else
25584 add $7,%_ASM_AX
25585 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
25586 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25587 jae bad_get_user_8
25588 ASM_STAC
25589 -4: movl -7(%_ASM_AX),%edx
25590 -5: movl -3(%_ASM_AX),%ecx
25591 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
25592 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
25593 xor %eax,%eax
25594 ASM_CLAC
25595 + pax_force_retaddr
25596 ret
25597 #endif
25598 CFI_ENDPROC
25599 @@ -113,6 +175,7 @@ bad_get_user:
25600 xor %edx,%edx
25601 mov $(-EFAULT),%_ASM_AX
25602 ASM_CLAC
25603 + pax_force_retaddr
25604 ret
25605 CFI_ENDPROC
25606 END(bad_get_user)
25607 @@ -124,6 +187,7 @@ bad_get_user_8:
25608 xor %ecx,%ecx
25609 mov $(-EFAULT),%_ASM_AX
25610 ASM_CLAC
25611 + pax_force_retaddr
25612 ret
25613 CFI_ENDPROC
25614 END(bad_get_user_8)
25615 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25616 index 54fcffe..7be149e 100644
25617 --- a/arch/x86/lib/insn.c
25618 +++ b/arch/x86/lib/insn.c
25619 @@ -20,8 +20,10 @@
25620
25621 #ifdef __KERNEL__
25622 #include <linux/string.h>
25623 +#include <asm/pgtable_types.h>
25624 #else
25625 #include <string.h>
25626 +#define ktla_ktva(addr) addr
25627 #endif
25628 #include <asm/inat.h>
25629 #include <asm/insn.h>
25630 @@ -53,8 +55,8 @@
25631 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25632 {
25633 memset(insn, 0, sizeof(*insn));
25634 - insn->kaddr = kaddr;
25635 - insn->next_byte = kaddr;
25636 + insn->kaddr = ktla_ktva(kaddr);
25637 + insn->next_byte = ktla_ktva(kaddr);
25638 insn->x86_64 = x86_64 ? 1 : 0;
25639 insn->opnd_bytes = 4;
25640 if (x86_64)
25641 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25642 index 05a95e7..326f2fa 100644
25643 --- a/arch/x86/lib/iomap_copy_64.S
25644 +++ b/arch/x86/lib/iomap_copy_64.S
25645 @@ -17,6 +17,7 @@
25646
25647 #include <linux/linkage.h>
25648 #include <asm/dwarf2.h>
25649 +#include <asm/alternative-asm.h>
25650
25651 /*
25652 * override generic version in lib/iomap_copy.c
25653 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25654 CFI_STARTPROC
25655 movl %edx,%ecx
25656 rep movsd
25657 + pax_force_retaddr
25658 ret
25659 CFI_ENDPROC
25660 ENDPROC(__iowrite32_copy)
25661 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25662 index 56313a3..aa84a79 100644
25663 --- a/arch/x86/lib/memcpy_64.S
25664 +++ b/arch/x86/lib/memcpy_64.S
25665 @@ -33,6 +33,7 @@
25666 rep movsq
25667 movl %edx, %ecx
25668 rep movsb
25669 + pax_force_retaddr
25670 ret
25671 .Lmemcpy_e:
25672 .previous
25673 @@ -49,6 +50,7 @@
25674 movq %rdi, %rax
25675 movq %rdx, %rcx
25676 rep movsb
25677 + pax_force_retaddr
25678 ret
25679 .Lmemcpy_e_e:
25680 .previous
25681 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25682 */
25683 movq 0*8(%rsi), %r8
25684 movq 1*8(%rsi), %r9
25685 - movq 2*8(%rsi), %r10
25686 + movq 2*8(%rsi), %rcx
25687 movq 3*8(%rsi), %r11
25688 leaq 4*8(%rsi), %rsi
25689
25690 movq %r8, 0*8(%rdi)
25691 movq %r9, 1*8(%rdi)
25692 - movq %r10, 2*8(%rdi)
25693 + movq %rcx, 2*8(%rdi)
25694 movq %r11, 3*8(%rdi)
25695 leaq 4*8(%rdi), %rdi
25696 jae .Lcopy_forward_loop
25697 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25698 subq $0x20, %rdx
25699 movq -1*8(%rsi), %r8
25700 movq -2*8(%rsi), %r9
25701 - movq -3*8(%rsi), %r10
25702 + movq -3*8(%rsi), %rcx
25703 movq -4*8(%rsi), %r11
25704 leaq -4*8(%rsi), %rsi
25705 movq %r8, -1*8(%rdi)
25706 movq %r9, -2*8(%rdi)
25707 - movq %r10, -3*8(%rdi)
25708 + movq %rcx, -3*8(%rdi)
25709 movq %r11, -4*8(%rdi)
25710 leaq -4*8(%rdi), %rdi
25711 jae .Lcopy_backward_loop
25712 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25713 */
25714 movq 0*8(%rsi), %r8
25715 movq 1*8(%rsi), %r9
25716 - movq -2*8(%rsi, %rdx), %r10
25717 + movq -2*8(%rsi, %rdx), %rcx
25718 movq -1*8(%rsi, %rdx), %r11
25719 movq %r8, 0*8(%rdi)
25720 movq %r9, 1*8(%rdi)
25721 - movq %r10, -2*8(%rdi, %rdx)
25722 + movq %rcx, -2*8(%rdi, %rdx)
25723 movq %r11, -1*8(%rdi, %rdx)
25724 + pax_force_retaddr
25725 retq
25726 .p2align 4
25727 .Lless_16bytes:
25728 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25729 movq -1*8(%rsi, %rdx), %r9
25730 movq %r8, 0*8(%rdi)
25731 movq %r9, -1*8(%rdi, %rdx)
25732 + pax_force_retaddr
25733 retq
25734 .p2align 4
25735 .Lless_8bytes:
25736 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25737 movl -4(%rsi, %rdx), %r8d
25738 movl %ecx, (%rdi)
25739 movl %r8d, -4(%rdi, %rdx)
25740 + pax_force_retaddr
25741 retq
25742 .p2align 4
25743 .Lless_3bytes:
25744 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25745 movb %cl, (%rdi)
25746
25747 .Lend:
25748 + pax_force_retaddr
25749 retq
25750 CFI_ENDPROC
25751 ENDPROC(memcpy)
25752 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25753 index 65268a6..c9518d1 100644
25754 --- a/arch/x86/lib/memmove_64.S
25755 +++ b/arch/x86/lib/memmove_64.S
25756 @@ -61,13 +61,13 @@ ENTRY(memmove)
25757 5:
25758 sub $0x20, %rdx
25759 movq 0*8(%rsi), %r11
25760 - movq 1*8(%rsi), %r10
25761 + movq 1*8(%rsi), %rcx
25762 movq 2*8(%rsi), %r9
25763 movq 3*8(%rsi), %r8
25764 leaq 4*8(%rsi), %rsi
25765
25766 movq %r11, 0*8(%rdi)
25767 - movq %r10, 1*8(%rdi)
25768 + movq %rcx, 1*8(%rdi)
25769 movq %r9, 2*8(%rdi)
25770 movq %r8, 3*8(%rdi)
25771 leaq 4*8(%rdi), %rdi
25772 @@ -81,10 +81,10 @@ ENTRY(memmove)
25773 4:
25774 movq %rdx, %rcx
25775 movq -8(%rsi, %rdx), %r11
25776 - lea -8(%rdi, %rdx), %r10
25777 + lea -8(%rdi, %rdx), %r9
25778 shrq $3, %rcx
25779 rep movsq
25780 - movq %r11, (%r10)
25781 + movq %r11, (%r9)
25782 jmp 13f
25783 .Lmemmove_end_forward:
25784
25785 @@ -95,14 +95,14 @@ ENTRY(memmove)
25786 7:
25787 movq %rdx, %rcx
25788 movq (%rsi), %r11
25789 - movq %rdi, %r10
25790 + movq %rdi, %r9
25791 leaq -8(%rsi, %rdx), %rsi
25792 leaq -8(%rdi, %rdx), %rdi
25793 shrq $3, %rcx
25794 std
25795 rep movsq
25796 cld
25797 - movq %r11, (%r10)
25798 + movq %r11, (%r9)
25799 jmp 13f
25800
25801 /*
25802 @@ -127,13 +127,13 @@ ENTRY(memmove)
25803 8:
25804 subq $0x20, %rdx
25805 movq -1*8(%rsi), %r11
25806 - movq -2*8(%rsi), %r10
25807 + movq -2*8(%rsi), %rcx
25808 movq -3*8(%rsi), %r9
25809 movq -4*8(%rsi), %r8
25810 leaq -4*8(%rsi), %rsi
25811
25812 movq %r11, -1*8(%rdi)
25813 - movq %r10, -2*8(%rdi)
25814 + movq %rcx, -2*8(%rdi)
25815 movq %r9, -3*8(%rdi)
25816 movq %r8, -4*8(%rdi)
25817 leaq -4*8(%rdi), %rdi
25818 @@ -151,11 +151,11 @@ ENTRY(memmove)
25819 * Move data from 16 bytes to 31 bytes.
25820 */
25821 movq 0*8(%rsi), %r11
25822 - movq 1*8(%rsi), %r10
25823 + movq 1*8(%rsi), %rcx
25824 movq -2*8(%rsi, %rdx), %r9
25825 movq -1*8(%rsi, %rdx), %r8
25826 movq %r11, 0*8(%rdi)
25827 - movq %r10, 1*8(%rdi)
25828 + movq %rcx, 1*8(%rdi)
25829 movq %r9, -2*8(%rdi, %rdx)
25830 movq %r8, -1*8(%rdi, %rdx)
25831 jmp 13f
25832 @@ -167,9 +167,9 @@ ENTRY(memmove)
25833 * Move data from 8 bytes to 15 bytes.
25834 */
25835 movq 0*8(%rsi), %r11
25836 - movq -1*8(%rsi, %rdx), %r10
25837 + movq -1*8(%rsi, %rdx), %r9
25838 movq %r11, 0*8(%rdi)
25839 - movq %r10, -1*8(%rdi, %rdx)
25840 + movq %r9, -1*8(%rdi, %rdx)
25841 jmp 13f
25842 10:
25843 cmpq $4, %rdx
25844 @@ -178,9 +178,9 @@ ENTRY(memmove)
25845 * Move data from 4 bytes to 7 bytes.
25846 */
25847 movl (%rsi), %r11d
25848 - movl -4(%rsi, %rdx), %r10d
25849 + movl -4(%rsi, %rdx), %r9d
25850 movl %r11d, (%rdi)
25851 - movl %r10d, -4(%rdi, %rdx)
25852 + movl %r9d, -4(%rdi, %rdx)
25853 jmp 13f
25854 11:
25855 cmp $2, %rdx
25856 @@ -189,9 +189,9 @@ ENTRY(memmove)
25857 * Move data from 2 bytes to 3 bytes.
25858 */
25859 movw (%rsi), %r11w
25860 - movw -2(%rsi, %rdx), %r10w
25861 + movw -2(%rsi, %rdx), %r9w
25862 movw %r11w, (%rdi)
25863 - movw %r10w, -2(%rdi, %rdx)
25864 + movw %r9w, -2(%rdi, %rdx)
25865 jmp 13f
25866 12:
25867 cmp $1, %rdx
25868 @@ -202,6 +202,7 @@ ENTRY(memmove)
25869 movb (%rsi), %r11b
25870 movb %r11b, (%rdi)
25871 13:
25872 + pax_force_retaddr
25873 retq
25874 CFI_ENDPROC
25875
25876 @@ -210,6 +211,7 @@ ENTRY(memmove)
25877 /* Forward moving data. */
25878 movq %rdx, %rcx
25879 rep movsb
25880 + pax_force_retaddr
25881 retq
25882 .Lmemmove_end_forward_efs:
25883 .previous
25884 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25885 index 2dcb380..963660a 100644
25886 --- a/arch/x86/lib/memset_64.S
25887 +++ b/arch/x86/lib/memset_64.S
25888 @@ -30,6 +30,7 @@
25889 movl %edx,%ecx
25890 rep stosb
25891 movq %r9,%rax
25892 + pax_force_retaddr
25893 ret
25894 .Lmemset_e:
25895 .previous
25896 @@ -52,6 +53,7 @@
25897 movq %rdx,%rcx
25898 rep stosb
25899 movq %r9,%rax
25900 + pax_force_retaddr
25901 ret
25902 .Lmemset_e_e:
25903 .previous
25904 @@ -59,7 +61,7 @@
25905 ENTRY(memset)
25906 ENTRY(__memset)
25907 CFI_STARTPROC
25908 - movq %rdi,%r10
25909 + movq %rdi,%r11
25910
25911 /* expand byte value */
25912 movzbl %sil,%ecx
25913 @@ -117,7 +119,8 @@ ENTRY(__memset)
25914 jnz .Lloop_1
25915
25916 .Lende:
25917 - movq %r10,%rax
25918 + movq %r11,%rax
25919 + pax_force_retaddr
25920 ret
25921
25922 CFI_RESTORE_STATE
25923 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25924 index c9f2d9b..e7fd2c0 100644
25925 --- a/arch/x86/lib/mmx_32.c
25926 +++ b/arch/x86/lib/mmx_32.c
25927 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25928 {
25929 void *p;
25930 int i;
25931 + unsigned long cr0;
25932
25933 if (unlikely(in_interrupt()))
25934 return __memcpy(to, from, len);
25935 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25936 kernel_fpu_begin();
25937
25938 __asm__ __volatile__ (
25939 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25940 - " prefetch 64(%0)\n"
25941 - " prefetch 128(%0)\n"
25942 - " prefetch 192(%0)\n"
25943 - " prefetch 256(%0)\n"
25944 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25945 + " prefetch 64(%1)\n"
25946 + " prefetch 128(%1)\n"
25947 + " prefetch 192(%1)\n"
25948 + " prefetch 256(%1)\n"
25949 "2: \n"
25950 ".section .fixup, \"ax\"\n"
25951 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25952 + "3: \n"
25953 +
25954 +#ifdef CONFIG_PAX_KERNEXEC
25955 + " movl %%cr0, %0\n"
25956 + " movl %0, %%eax\n"
25957 + " andl $0xFFFEFFFF, %%eax\n"
25958 + " movl %%eax, %%cr0\n"
25959 +#endif
25960 +
25961 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25962 +
25963 +#ifdef CONFIG_PAX_KERNEXEC
25964 + " movl %0, %%cr0\n"
25965 +#endif
25966 +
25967 " jmp 2b\n"
25968 ".previous\n"
25969 _ASM_EXTABLE(1b, 3b)
25970 - : : "r" (from));
25971 + : "=&r" (cr0) : "r" (from) : "ax");
25972
25973 for ( ; i > 5; i--) {
25974 __asm__ __volatile__ (
25975 - "1: prefetch 320(%0)\n"
25976 - "2: movq (%0), %%mm0\n"
25977 - " movq 8(%0), %%mm1\n"
25978 - " movq 16(%0), %%mm2\n"
25979 - " movq 24(%0), %%mm3\n"
25980 - " movq %%mm0, (%1)\n"
25981 - " movq %%mm1, 8(%1)\n"
25982 - " movq %%mm2, 16(%1)\n"
25983 - " movq %%mm3, 24(%1)\n"
25984 - " movq 32(%0), %%mm0\n"
25985 - " movq 40(%0), %%mm1\n"
25986 - " movq 48(%0), %%mm2\n"
25987 - " movq 56(%0), %%mm3\n"
25988 - " movq %%mm0, 32(%1)\n"
25989 - " movq %%mm1, 40(%1)\n"
25990 - " movq %%mm2, 48(%1)\n"
25991 - " movq %%mm3, 56(%1)\n"
25992 + "1: prefetch 320(%1)\n"
25993 + "2: movq (%1), %%mm0\n"
25994 + " movq 8(%1), %%mm1\n"
25995 + " movq 16(%1), %%mm2\n"
25996 + " movq 24(%1), %%mm3\n"
25997 + " movq %%mm0, (%2)\n"
25998 + " movq %%mm1, 8(%2)\n"
25999 + " movq %%mm2, 16(%2)\n"
26000 + " movq %%mm3, 24(%2)\n"
26001 + " movq 32(%1), %%mm0\n"
26002 + " movq 40(%1), %%mm1\n"
26003 + " movq 48(%1), %%mm2\n"
26004 + " movq 56(%1), %%mm3\n"
26005 + " movq %%mm0, 32(%2)\n"
26006 + " movq %%mm1, 40(%2)\n"
26007 + " movq %%mm2, 48(%2)\n"
26008 + " movq %%mm3, 56(%2)\n"
26009 ".section .fixup, \"ax\"\n"
26010 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26011 + "3:\n"
26012 +
26013 +#ifdef CONFIG_PAX_KERNEXEC
26014 + " movl %%cr0, %0\n"
26015 + " movl %0, %%eax\n"
26016 + " andl $0xFFFEFFFF, %%eax\n"
26017 + " movl %%eax, %%cr0\n"
26018 +#endif
26019 +
26020 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26021 +
26022 +#ifdef CONFIG_PAX_KERNEXEC
26023 + " movl %0, %%cr0\n"
26024 +#endif
26025 +
26026 " jmp 2b\n"
26027 ".previous\n"
26028 _ASM_EXTABLE(1b, 3b)
26029 - : : "r" (from), "r" (to) : "memory");
26030 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26031
26032 from += 64;
26033 to += 64;
26034 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26035 static void fast_copy_page(void *to, void *from)
26036 {
26037 int i;
26038 + unsigned long cr0;
26039
26040 kernel_fpu_begin();
26041
26042 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26043 * but that is for later. -AV
26044 */
26045 __asm__ __volatile__(
26046 - "1: prefetch (%0)\n"
26047 - " prefetch 64(%0)\n"
26048 - " prefetch 128(%0)\n"
26049 - " prefetch 192(%0)\n"
26050 - " prefetch 256(%0)\n"
26051 + "1: prefetch (%1)\n"
26052 + " prefetch 64(%1)\n"
26053 + " prefetch 128(%1)\n"
26054 + " prefetch 192(%1)\n"
26055 + " prefetch 256(%1)\n"
26056 "2: \n"
26057 ".section .fixup, \"ax\"\n"
26058 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26059 + "3: \n"
26060 +
26061 +#ifdef CONFIG_PAX_KERNEXEC
26062 + " movl %%cr0, %0\n"
26063 + " movl %0, %%eax\n"
26064 + " andl $0xFFFEFFFF, %%eax\n"
26065 + " movl %%eax, %%cr0\n"
26066 +#endif
26067 +
26068 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26069 +
26070 +#ifdef CONFIG_PAX_KERNEXEC
26071 + " movl %0, %%cr0\n"
26072 +#endif
26073 +
26074 " jmp 2b\n"
26075 ".previous\n"
26076 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26077 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26078
26079 for (i = 0; i < (4096-320)/64; i++) {
26080 __asm__ __volatile__ (
26081 - "1: prefetch 320(%0)\n"
26082 - "2: movq (%0), %%mm0\n"
26083 - " movntq %%mm0, (%1)\n"
26084 - " movq 8(%0), %%mm1\n"
26085 - " movntq %%mm1, 8(%1)\n"
26086 - " movq 16(%0), %%mm2\n"
26087 - " movntq %%mm2, 16(%1)\n"
26088 - " movq 24(%0), %%mm3\n"
26089 - " movntq %%mm3, 24(%1)\n"
26090 - " movq 32(%0), %%mm4\n"
26091 - " movntq %%mm4, 32(%1)\n"
26092 - " movq 40(%0), %%mm5\n"
26093 - " movntq %%mm5, 40(%1)\n"
26094 - " movq 48(%0), %%mm6\n"
26095 - " movntq %%mm6, 48(%1)\n"
26096 - " movq 56(%0), %%mm7\n"
26097 - " movntq %%mm7, 56(%1)\n"
26098 + "1: prefetch 320(%1)\n"
26099 + "2: movq (%1), %%mm0\n"
26100 + " movntq %%mm0, (%2)\n"
26101 + " movq 8(%1), %%mm1\n"
26102 + " movntq %%mm1, 8(%2)\n"
26103 + " movq 16(%1), %%mm2\n"
26104 + " movntq %%mm2, 16(%2)\n"
26105 + " movq 24(%1), %%mm3\n"
26106 + " movntq %%mm3, 24(%2)\n"
26107 + " movq 32(%1), %%mm4\n"
26108 + " movntq %%mm4, 32(%2)\n"
26109 + " movq 40(%1), %%mm5\n"
26110 + " movntq %%mm5, 40(%2)\n"
26111 + " movq 48(%1), %%mm6\n"
26112 + " movntq %%mm6, 48(%2)\n"
26113 + " movq 56(%1), %%mm7\n"
26114 + " movntq %%mm7, 56(%2)\n"
26115 ".section .fixup, \"ax\"\n"
26116 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26117 + "3:\n"
26118 +
26119 +#ifdef CONFIG_PAX_KERNEXEC
26120 + " movl %%cr0, %0\n"
26121 + " movl %0, %%eax\n"
26122 + " andl $0xFFFEFFFF, %%eax\n"
26123 + " movl %%eax, %%cr0\n"
26124 +#endif
26125 +
26126 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26127 +
26128 +#ifdef CONFIG_PAX_KERNEXEC
26129 + " movl %0, %%cr0\n"
26130 +#endif
26131 +
26132 " jmp 2b\n"
26133 ".previous\n"
26134 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26135 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26136
26137 from += 64;
26138 to += 64;
26139 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26140 static void fast_copy_page(void *to, void *from)
26141 {
26142 int i;
26143 + unsigned long cr0;
26144
26145 kernel_fpu_begin();
26146
26147 __asm__ __volatile__ (
26148 - "1: prefetch (%0)\n"
26149 - " prefetch 64(%0)\n"
26150 - " prefetch 128(%0)\n"
26151 - " prefetch 192(%0)\n"
26152 - " prefetch 256(%0)\n"
26153 + "1: prefetch (%1)\n"
26154 + " prefetch 64(%1)\n"
26155 + " prefetch 128(%1)\n"
26156 + " prefetch 192(%1)\n"
26157 + " prefetch 256(%1)\n"
26158 "2: \n"
26159 ".section .fixup, \"ax\"\n"
26160 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26161 + "3: \n"
26162 +
26163 +#ifdef CONFIG_PAX_KERNEXEC
26164 + " movl %%cr0, %0\n"
26165 + " movl %0, %%eax\n"
26166 + " andl $0xFFFEFFFF, %%eax\n"
26167 + " movl %%eax, %%cr0\n"
26168 +#endif
26169 +
26170 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26171 +
26172 +#ifdef CONFIG_PAX_KERNEXEC
26173 + " movl %0, %%cr0\n"
26174 +#endif
26175 +
26176 " jmp 2b\n"
26177 ".previous\n"
26178 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26179 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26180
26181 for (i = 0; i < 4096/64; i++) {
26182 __asm__ __volatile__ (
26183 - "1: prefetch 320(%0)\n"
26184 - "2: movq (%0), %%mm0\n"
26185 - " movq 8(%0), %%mm1\n"
26186 - " movq 16(%0), %%mm2\n"
26187 - " movq 24(%0), %%mm3\n"
26188 - " movq %%mm0, (%1)\n"
26189 - " movq %%mm1, 8(%1)\n"
26190 - " movq %%mm2, 16(%1)\n"
26191 - " movq %%mm3, 24(%1)\n"
26192 - " movq 32(%0), %%mm0\n"
26193 - " movq 40(%0), %%mm1\n"
26194 - " movq 48(%0), %%mm2\n"
26195 - " movq 56(%0), %%mm3\n"
26196 - " movq %%mm0, 32(%1)\n"
26197 - " movq %%mm1, 40(%1)\n"
26198 - " movq %%mm2, 48(%1)\n"
26199 - " movq %%mm3, 56(%1)\n"
26200 + "1: prefetch 320(%1)\n"
26201 + "2: movq (%1), %%mm0\n"
26202 + " movq 8(%1), %%mm1\n"
26203 + " movq 16(%1), %%mm2\n"
26204 + " movq 24(%1), %%mm3\n"
26205 + " movq %%mm0, (%2)\n"
26206 + " movq %%mm1, 8(%2)\n"
26207 + " movq %%mm2, 16(%2)\n"
26208 + " movq %%mm3, 24(%2)\n"
26209 + " movq 32(%1), %%mm0\n"
26210 + " movq 40(%1), %%mm1\n"
26211 + " movq 48(%1), %%mm2\n"
26212 + " movq 56(%1), %%mm3\n"
26213 + " movq %%mm0, 32(%2)\n"
26214 + " movq %%mm1, 40(%2)\n"
26215 + " movq %%mm2, 48(%2)\n"
26216 + " movq %%mm3, 56(%2)\n"
26217 ".section .fixup, \"ax\"\n"
26218 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26219 + "3:\n"
26220 +
26221 +#ifdef CONFIG_PAX_KERNEXEC
26222 + " movl %%cr0, %0\n"
26223 + " movl %0, %%eax\n"
26224 + " andl $0xFFFEFFFF, %%eax\n"
26225 + " movl %%eax, %%cr0\n"
26226 +#endif
26227 +
26228 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26229 +
26230 +#ifdef CONFIG_PAX_KERNEXEC
26231 + " movl %0, %%cr0\n"
26232 +#endif
26233 +
26234 " jmp 2b\n"
26235 ".previous\n"
26236 _ASM_EXTABLE(1b, 3b)
26237 - : : "r" (from), "r" (to) : "memory");
26238 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26239
26240 from += 64;
26241 to += 64;
26242 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26243 index f6d13ee..aca5f0b 100644
26244 --- a/arch/x86/lib/msr-reg.S
26245 +++ b/arch/x86/lib/msr-reg.S
26246 @@ -3,6 +3,7 @@
26247 #include <asm/dwarf2.h>
26248 #include <asm/asm.h>
26249 #include <asm/msr.h>
26250 +#include <asm/alternative-asm.h>
26251
26252 #ifdef CONFIG_X86_64
26253 /*
26254 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26255 CFI_STARTPROC
26256 pushq_cfi %rbx
26257 pushq_cfi %rbp
26258 - movq %rdi, %r10 /* Save pointer */
26259 + movq %rdi, %r9 /* Save pointer */
26260 xorl %r11d, %r11d /* Return value */
26261 movl (%rdi), %eax
26262 movl 4(%rdi), %ecx
26263 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26264 movl 28(%rdi), %edi
26265 CFI_REMEMBER_STATE
26266 1: \op
26267 -2: movl %eax, (%r10)
26268 +2: movl %eax, (%r9)
26269 movl %r11d, %eax /* Return value */
26270 - movl %ecx, 4(%r10)
26271 - movl %edx, 8(%r10)
26272 - movl %ebx, 12(%r10)
26273 - movl %ebp, 20(%r10)
26274 - movl %esi, 24(%r10)
26275 - movl %edi, 28(%r10)
26276 + movl %ecx, 4(%r9)
26277 + movl %edx, 8(%r9)
26278 + movl %ebx, 12(%r9)
26279 + movl %ebp, 20(%r9)
26280 + movl %esi, 24(%r9)
26281 + movl %edi, 28(%r9)
26282 popq_cfi %rbp
26283 popq_cfi %rbx
26284 + pax_force_retaddr
26285 ret
26286 3:
26287 CFI_RESTORE_STATE
26288 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26289 index fc6ba17..d4d989d 100644
26290 --- a/arch/x86/lib/putuser.S
26291 +++ b/arch/x86/lib/putuser.S
26292 @@ -16,7 +16,9 @@
26293 #include <asm/errno.h>
26294 #include <asm/asm.h>
26295 #include <asm/smap.h>
26296 -
26297 +#include <asm/segment.h>
26298 +#include <asm/pgtable.h>
26299 +#include <asm/alternative-asm.h>
26300
26301 /*
26302 * __put_user_X
26303 @@ -30,57 +32,125 @@
26304 * as they get called from within inline assembly.
26305 */
26306
26307 -#define ENTER CFI_STARTPROC ; \
26308 - GET_THREAD_INFO(%_ASM_BX)
26309 -#define EXIT ASM_CLAC ; \
26310 - ret ; \
26311 +#define ENTER CFI_STARTPROC
26312 +#define EXIT ASM_CLAC ; \
26313 + pax_force_retaddr ; \
26314 + ret ; \
26315 CFI_ENDPROC
26316
26317 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26318 +#define _DEST %_ASM_CX,%_ASM_BX
26319 +#else
26320 +#define _DEST %_ASM_CX
26321 +#endif
26322 +
26323 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26324 +#define __copyuser_seg gs;
26325 +#else
26326 +#define __copyuser_seg
26327 +#endif
26328 +
26329 .text
26330 ENTRY(__put_user_1)
26331 ENTER
26332 +
26333 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26334 + GET_THREAD_INFO(%_ASM_BX)
26335 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26336 jae bad_put_user
26337 ASM_STAC
26338 -1: movb %al,(%_ASM_CX)
26339 +
26340 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26341 + mov pax_user_shadow_base,%_ASM_BX
26342 + cmp %_ASM_BX,%_ASM_CX
26343 + jb 1234f
26344 + xor %ebx,%ebx
26345 +1234:
26346 +#endif
26347 +
26348 +#endif
26349 +
26350 +1: __copyuser_seg movb %al,(_DEST)
26351 xor %eax,%eax
26352 EXIT
26353 ENDPROC(__put_user_1)
26354
26355 ENTRY(__put_user_2)
26356 ENTER
26357 +
26358 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26359 + GET_THREAD_INFO(%_ASM_BX)
26360 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26361 sub $1,%_ASM_BX
26362 cmp %_ASM_BX,%_ASM_CX
26363 jae bad_put_user
26364 ASM_STAC
26365 -2: movw %ax,(%_ASM_CX)
26366 +
26367 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26368 + mov pax_user_shadow_base,%_ASM_BX
26369 + cmp %_ASM_BX,%_ASM_CX
26370 + jb 1234f
26371 + xor %ebx,%ebx
26372 +1234:
26373 +#endif
26374 +
26375 +#endif
26376 +
26377 +2: __copyuser_seg movw %ax,(_DEST)
26378 xor %eax,%eax
26379 EXIT
26380 ENDPROC(__put_user_2)
26381
26382 ENTRY(__put_user_4)
26383 ENTER
26384 +
26385 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26386 + GET_THREAD_INFO(%_ASM_BX)
26387 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26388 sub $3,%_ASM_BX
26389 cmp %_ASM_BX,%_ASM_CX
26390 jae bad_put_user
26391 ASM_STAC
26392 -3: movl %eax,(%_ASM_CX)
26393 +
26394 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26395 + mov pax_user_shadow_base,%_ASM_BX
26396 + cmp %_ASM_BX,%_ASM_CX
26397 + jb 1234f
26398 + xor %ebx,%ebx
26399 +1234:
26400 +#endif
26401 +
26402 +#endif
26403 +
26404 +3: __copyuser_seg movl %eax,(_DEST)
26405 xor %eax,%eax
26406 EXIT
26407 ENDPROC(__put_user_4)
26408
26409 ENTRY(__put_user_8)
26410 ENTER
26411 +
26412 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26413 + GET_THREAD_INFO(%_ASM_BX)
26414 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26415 sub $7,%_ASM_BX
26416 cmp %_ASM_BX,%_ASM_CX
26417 jae bad_put_user
26418 ASM_STAC
26419 -4: mov %_ASM_AX,(%_ASM_CX)
26420 +
26421 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26422 + mov pax_user_shadow_base,%_ASM_BX
26423 + cmp %_ASM_BX,%_ASM_CX
26424 + jb 1234f
26425 + xor %ebx,%ebx
26426 +1234:
26427 +#endif
26428 +
26429 +#endif
26430 +
26431 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26432 #ifdef CONFIG_X86_32
26433 -5: movl %edx,4(%_ASM_CX)
26434 +5: __copyuser_seg movl %edx,4(_DEST)
26435 #endif
26436 xor %eax,%eax
26437 EXIT
26438 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26439 index 1cad221..de671ee 100644
26440 --- a/arch/x86/lib/rwlock.S
26441 +++ b/arch/x86/lib/rwlock.S
26442 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26443 FRAME
26444 0: LOCK_PREFIX
26445 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26446 +
26447 +#ifdef CONFIG_PAX_REFCOUNT
26448 + jno 1234f
26449 + LOCK_PREFIX
26450 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26451 + int $4
26452 +1234:
26453 + _ASM_EXTABLE(1234b, 1234b)
26454 +#endif
26455 +
26456 1: rep; nop
26457 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26458 jne 1b
26459 LOCK_PREFIX
26460 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26461 +
26462 +#ifdef CONFIG_PAX_REFCOUNT
26463 + jno 1234f
26464 + LOCK_PREFIX
26465 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26466 + int $4
26467 +1234:
26468 + _ASM_EXTABLE(1234b, 1234b)
26469 +#endif
26470 +
26471 jnz 0b
26472 ENDFRAME
26473 + pax_force_retaddr
26474 ret
26475 CFI_ENDPROC
26476 END(__write_lock_failed)
26477 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26478 FRAME
26479 0: LOCK_PREFIX
26480 READ_LOCK_SIZE(inc) (%__lock_ptr)
26481 +
26482 +#ifdef CONFIG_PAX_REFCOUNT
26483 + jno 1234f
26484 + LOCK_PREFIX
26485 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26486 + int $4
26487 +1234:
26488 + _ASM_EXTABLE(1234b, 1234b)
26489 +#endif
26490 +
26491 1: rep; nop
26492 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26493 js 1b
26494 LOCK_PREFIX
26495 READ_LOCK_SIZE(dec) (%__lock_ptr)
26496 +
26497 +#ifdef CONFIG_PAX_REFCOUNT
26498 + jno 1234f
26499 + LOCK_PREFIX
26500 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26501 + int $4
26502 +1234:
26503 + _ASM_EXTABLE(1234b, 1234b)
26504 +#endif
26505 +
26506 js 0b
26507 ENDFRAME
26508 + pax_force_retaddr
26509 ret
26510 CFI_ENDPROC
26511 END(__read_lock_failed)
26512 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26513 index 5dff5f0..cadebf4 100644
26514 --- a/arch/x86/lib/rwsem.S
26515 +++ b/arch/x86/lib/rwsem.S
26516 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26517 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26518 CFI_RESTORE __ASM_REG(dx)
26519 restore_common_regs
26520 + pax_force_retaddr
26521 ret
26522 CFI_ENDPROC
26523 ENDPROC(call_rwsem_down_read_failed)
26524 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26525 movq %rax,%rdi
26526 call rwsem_down_write_failed
26527 restore_common_regs
26528 + pax_force_retaddr
26529 ret
26530 CFI_ENDPROC
26531 ENDPROC(call_rwsem_down_write_failed)
26532 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26533 movq %rax,%rdi
26534 call rwsem_wake
26535 restore_common_regs
26536 -1: ret
26537 +1: pax_force_retaddr
26538 + ret
26539 CFI_ENDPROC
26540 ENDPROC(call_rwsem_wake)
26541
26542 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26543 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26544 CFI_RESTORE __ASM_REG(dx)
26545 restore_common_regs
26546 + pax_force_retaddr
26547 ret
26548 CFI_ENDPROC
26549 ENDPROC(call_rwsem_downgrade_wake)
26550 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26551 index a63efd6..ccecad8 100644
26552 --- a/arch/x86/lib/thunk_64.S
26553 +++ b/arch/x86/lib/thunk_64.S
26554 @@ -8,6 +8,7 @@
26555 #include <linux/linkage.h>
26556 #include <asm/dwarf2.h>
26557 #include <asm/calling.h>
26558 +#include <asm/alternative-asm.h>
26559
26560 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26561 .macro THUNK name, func, put_ret_addr_in_rdi=0
26562 @@ -41,5 +42,6 @@
26563 SAVE_ARGS
26564 restore:
26565 RESTORE_ARGS
26566 + pax_force_retaddr
26567 ret
26568 CFI_ENDPROC
26569 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26570 index 3eb18ac..6890bc3 100644
26571 --- a/arch/x86/lib/usercopy_32.c
26572 +++ b/arch/x86/lib/usercopy_32.c
26573 @@ -42,11 +42,13 @@ do { \
26574 int __d0; \
26575 might_fault(); \
26576 __asm__ __volatile__( \
26577 + __COPYUSER_SET_ES \
26578 ASM_STAC "\n" \
26579 "0: rep; stosl\n" \
26580 " movl %2,%0\n" \
26581 "1: rep; stosb\n" \
26582 "2: " ASM_CLAC "\n" \
26583 + __COPYUSER_RESTORE_ES \
26584 ".section .fixup,\"ax\"\n" \
26585 "3: lea 0(%2,%0,4),%0\n" \
26586 " jmp 2b\n" \
26587 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26588
26589 #ifdef CONFIG_X86_INTEL_USERCOPY
26590 static unsigned long
26591 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26592 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26593 {
26594 int d0, d1;
26595 __asm__ __volatile__(
26596 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26597 " .align 2,0x90\n"
26598 "3: movl 0(%4), %%eax\n"
26599 "4: movl 4(%4), %%edx\n"
26600 - "5: movl %%eax, 0(%3)\n"
26601 - "6: movl %%edx, 4(%3)\n"
26602 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26603 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26604 "7: movl 8(%4), %%eax\n"
26605 "8: movl 12(%4),%%edx\n"
26606 - "9: movl %%eax, 8(%3)\n"
26607 - "10: movl %%edx, 12(%3)\n"
26608 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26609 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26610 "11: movl 16(%4), %%eax\n"
26611 "12: movl 20(%4), %%edx\n"
26612 - "13: movl %%eax, 16(%3)\n"
26613 - "14: movl %%edx, 20(%3)\n"
26614 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26615 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26616 "15: movl 24(%4), %%eax\n"
26617 "16: movl 28(%4), %%edx\n"
26618 - "17: movl %%eax, 24(%3)\n"
26619 - "18: movl %%edx, 28(%3)\n"
26620 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26621 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26622 "19: movl 32(%4), %%eax\n"
26623 "20: movl 36(%4), %%edx\n"
26624 - "21: movl %%eax, 32(%3)\n"
26625 - "22: movl %%edx, 36(%3)\n"
26626 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26627 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26628 "23: movl 40(%4), %%eax\n"
26629 "24: movl 44(%4), %%edx\n"
26630 - "25: movl %%eax, 40(%3)\n"
26631 - "26: movl %%edx, 44(%3)\n"
26632 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26633 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26634 "27: movl 48(%4), %%eax\n"
26635 "28: movl 52(%4), %%edx\n"
26636 - "29: movl %%eax, 48(%3)\n"
26637 - "30: movl %%edx, 52(%3)\n"
26638 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26639 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26640 "31: movl 56(%4), %%eax\n"
26641 "32: movl 60(%4), %%edx\n"
26642 - "33: movl %%eax, 56(%3)\n"
26643 - "34: movl %%edx, 60(%3)\n"
26644 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26645 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26646 " addl $-64, %0\n"
26647 " addl $64, %4\n"
26648 " addl $64, %3\n"
26649 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26650 " shrl $2, %0\n"
26651 " andl $3, %%eax\n"
26652 " cld\n"
26653 + __COPYUSER_SET_ES
26654 "99: rep; movsl\n"
26655 "36: movl %%eax, %0\n"
26656 "37: rep; movsb\n"
26657 "100:\n"
26658 + __COPYUSER_RESTORE_ES
26659 ".section .fixup,\"ax\"\n"
26660 "101: lea 0(%%eax,%0,4),%0\n"
26661 " jmp 100b\n"
26662 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26663 }
26664
26665 static unsigned long
26666 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26667 +{
26668 + int d0, d1;
26669 + __asm__ __volatile__(
26670 + " .align 2,0x90\n"
26671 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26672 + " cmpl $67, %0\n"
26673 + " jbe 3f\n"
26674 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26675 + " .align 2,0x90\n"
26676 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26677 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26678 + "5: movl %%eax, 0(%3)\n"
26679 + "6: movl %%edx, 4(%3)\n"
26680 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26681 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26682 + "9: movl %%eax, 8(%3)\n"
26683 + "10: movl %%edx, 12(%3)\n"
26684 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26685 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26686 + "13: movl %%eax, 16(%3)\n"
26687 + "14: movl %%edx, 20(%3)\n"
26688 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26689 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26690 + "17: movl %%eax, 24(%3)\n"
26691 + "18: movl %%edx, 28(%3)\n"
26692 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26693 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26694 + "21: movl %%eax, 32(%3)\n"
26695 + "22: movl %%edx, 36(%3)\n"
26696 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26697 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26698 + "25: movl %%eax, 40(%3)\n"
26699 + "26: movl %%edx, 44(%3)\n"
26700 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26701 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26702 + "29: movl %%eax, 48(%3)\n"
26703 + "30: movl %%edx, 52(%3)\n"
26704 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26705 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26706 + "33: movl %%eax, 56(%3)\n"
26707 + "34: movl %%edx, 60(%3)\n"
26708 + " addl $-64, %0\n"
26709 + " addl $64, %4\n"
26710 + " addl $64, %3\n"
26711 + " cmpl $63, %0\n"
26712 + " ja 1b\n"
26713 + "35: movl %0, %%eax\n"
26714 + " shrl $2, %0\n"
26715 + " andl $3, %%eax\n"
26716 + " cld\n"
26717 + "99: rep; "__copyuser_seg" movsl\n"
26718 + "36: movl %%eax, %0\n"
26719 + "37: rep; "__copyuser_seg" movsb\n"
26720 + "100:\n"
26721 + ".section .fixup,\"ax\"\n"
26722 + "101: lea 0(%%eax,%0,4),%0\n"
26723 + " jmp 100b\n"
26724 + ".previous\n"
26725 + _ASM_EXTABLE(1b,100b)
26726 + _ASM_EXTABLE(2b,100b)
26727 + _ASM_EXTABLE(3b,100b)
26728 + _ASM_EXTABLE(4b,100b)
26729 + _ASM_EXTABLE(5b,100b)
26730 + _ASM_EXTABLE(6b,100b)
26731 + _ASM_EXTABLE(7b,100b)
26732 + _ASM_EXTABLE(8b,100b)
26733 + _ASM_EXTABLE(9b,100b)
26734 + _ASM_EXTABLE(10b,100b)
26735 + _ASM_EXTABLE(11b,100b)
26736 + _ASM_EXTABLE(12b,100b)
26737 + _ASM_EXTABLE(13b,100b)
26738 + _ASM_EXTABLE(14b,100b)
26739 + _ASM_EXTABLE(15b,100b)
26740 + _ASM_EXTABLE(16b,100b)
26741 + _ASM_EXTABLE(17b,100b)
26742 + _ASM_EXTABLE(18b,100b)
26743 + _ASM_EXTABLE(19b,100b)
26744 + _ASM_EXTABLE(20b,100b)
26745 + _ASM_EXTABLE(21b,100b)
26746 + _ASM_EXTABLE(22b,100b)
26747 + _ASM_EXTABLE(23b,100b)
26748 + _ASM_EXTABLE(24b,100b)
26749 + _ASM_EXTABLE(25b,100b)
26750 + _ASM_EXTABLE(26b,100b)
26751 + _ASM_EXTABLE(27b,100b)
26752 + _ASM_EXTABLE(28b,100b)
26753 + _ASM_EXTABLE(29b,100b)
26754 + _ASM_EXTABLE(30b,100b)
26755 + _ASM_EXTABLE(31b,100b)
26756 + _ASM_EXTABLE(32b,100b)
26757 + _ASM_EXTABLE(33b,100b)
26758 + _ASM_EXTABLE(34b,100b)
26759 + _ASM_EXTABLE(35b,100b)
26760 + _ASM_EXTABLE(36b,100b)
26761 + _ASM_EXTABLE(37b,100b)
26762 + _ASM_EXTABLE(99b,101b)
26763 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26764 + : "1"(to), "2"(from), "0"(size)
26765 + : "eax", "edx", "memory");
26766 + return size;
26767 +}
26768 +
26769 +static unsigned long __size_overflow(3)
26770 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26771 {
26772 int d0, d1;
26773 __asm__ __volatile__(
26774 " .align 2,0x90\n"
26775 - "0: movl 32(%4), %%eax\n"
26776 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26777 " cmpl $67, %0\n"
26778 " jbe 2f\n"
26779 - "1: movl 64(%4), %%eax\n"
26780 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26781 " .align 2,0x90\n"
26782 - "2: movl 0(%4), %%eax\n"
26783 - "21: movl 4(%4), %%edx\n"
26784 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26785 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26786 " movl %%eax, 0(%3)\n"
26787 " movl %%edx, 4(%3)\n"
26788 - "3: movl 8(%4), %%eax\n"
26789 - "31: movl 12(%4),%%edx\n"
26790 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26791 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26792 " movl %%eax, 8(%3)\n"
26793 " movl %%edx, 12(%3)\n"
26794 - "4: movl 16(%4), %%eax\n"
26795 - "41: movl 20(%4), %%edx\n"
26796 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26797 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26798 " movl %%eax, 16(%3)\n"
26799 " movl %%edx, 20(%3)\n"
26800 - "10: movl 24(%4), %%eax\n"
26801 - "51: movl 28(%4), %%edx\n"
26802 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26803 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26804 " movl %%eax, 24(%3)\n"
26805 " movl %%edx, 28(%3)\n"
26806 - "11: movl 32(%4), %%eax\n"
26807 - "61: movl 36(%4), %%edx\n"
26808 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26809 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26810 " movl %%eax, 32(%3)\n"
26811 " movl %%edx, 36(%3)\n"
26812 - "12: movl 40(%4), %%eax\n"
26813 - "71: movl 44(%4), %%edx\n"
26814 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26815 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26816 " movl %%eax, 40(%3)\n"
26817 " movl %%edx, 44(%3)\n"
26818 - "13: movl 48(%4), %%eax\n"
26819 - "81: movl 52(%4), %%edx\n"
26820 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26821 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26822 " movl %%eax, 48(%3)\n"
26823 " movl %%edx, 52(%3)\n"
26824 - "14: movl 56(%4), %%eax\n"
26825 - "91: movl 60(%4), %%edx\n"
26826 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26827 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26828 " movl %%eax, 56(%3)\n"
26829 " movl %%edx, 60(%3)\n"
26830 " addl $-64, %0\n"
26831 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26832 " shrl $2, %0\n"
26833 " andl $3, %%eax\n"
26834 " cld\n"
26835 - "6: rep; movsl\n"
26836 + "6: rep; "__copyuser_seg" movsl\n"
26837 " movl %%eax,%0\n"
26838 - "7: rep; movsb\n"
26839 + "7: rep; "__copyuser_seg" movsb\n"
26840 "8:\n"
26841 ".section .fixup,\"ax\"\n"
26842 "9: lea 0(%%eax,%0,4),%0\n"
26843 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26844 * hyoshiok@miraclelinux.com
26845 */
26846
26847 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26848 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26849 const void __user *from, unsigned long size)
26850 {
26851 int d0, d1;
26852
26853 __asm__ __volatile__(
26854 " .align 2,0x90\n"
26855 - "0: movl 32(%4), %%eax\n"
26856 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26857 " cmpl $67, %0\n"
26858 " jbe 2f\n"
26859 - "1: movl 64(%4), %%eax\n"
26860 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26861 " .align 2,0x90\n"
26862 - "2: movl 0(%4), %%eax\n"
26863 - "21: movl 4(%4), %%edx\n"
26864 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26865 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26866 " movnti %%eax, 0(%3)\n"
26867 " movnti %%edx, 4(%3)\n"
26868 - "3: movl 8(%4), %%eax\n"
26869 - "31: movl 12(%4),%%edx\n"
26870 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26871 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26872 " movnti %%eax, 8(%3)\n"
26873 " movnti %%edx, 12(%3)\n"
26874 - "4: movl 16(%4), %%eax\n"
26875 - "41: movl 20(%4), %%edx\n"
26876 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26877 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26878 " movnti %%eax, 16(%3)\n"
26879 " movnti %%edx, 20(%3)\n"
26880 - "10: movl 24(%4), %%eax\n"
26881 - "51: movl 28(%4), %%edx\n"
26882 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26883 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26884 " movnti %%eax, 24(%3)\n"
26885 " movnti %%edx, 28(%3)\n"
26886 - "11: movl 32(%4), %%eax\n"
26887 - "61: movl 36(%4), %%edx\n"
26888 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26889 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26890 " movnti %%eax, 32(%3)\n"
26891 " movnti %%edx, 36(%3)\n"
26892 - "12: movl 40(%4), %%eax\n"
26893 - "71: movl 44(%4), %%edx\n"
26894 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26895 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26896 " movnti %%eax, 40(%3)\n"
26897 " movnti %%edx, 44(%3)\n"
26898 - "13: movl 48(%4), %%eax\n"
26899 - "81: movl 52(%4), %%edx\n"
26900 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26901 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26902 " movnti %%eax, 48(%3)\n"
26903 " movnti %%edx, 52(%3)\n"
26904 - "14: movl 56(%4), %%eax\n"
26905 - "91: movl 60(%4), %%edx\n"
26906 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26907 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26908 " movnti %%eax, 56(%3)\n"
26909 " movnti %%edx, 60(%3)\n"
26910 " addl $-64, %0\n"
26911 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26912 " shrl $2, %0\n"
26913 " andl $3, %%eax\n"
26914 " cld\n"
26915 - "6: rep; movsl\n"
26916 + "6: rep; "__copyuser_seg" movsl\n"
26917 " movl %%eax,%0\n"
26918 - "7: rep; movsb\n"
26919 + "7: rep; "__copyuser_seg" movsb\n"
26920 "8:\n"
26921 ".section .fixup,\"ax\"\n"
26922 "9: lea 0(%%eax,%0,4),%0\n"
26923 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26924 return size;
26925 }
26926
26927 -static unsigned long __copy_user_intel_nocache(void *to,
26928 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26929 const void __user *from, unsigned long size)
26930 {
26931 int d0, d1;
26932
26933 __asm__ __volatile__(
26934 " .align 2,0x90\n"
26935 - "0: movl 32(%4), %%eax\n"
26936 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26937 " cmpl $67, %0\n"
26938 " jbe 2f\n"
26939 - "1: movl 64(%4), %%eax\n"
26940 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26941 " .align 2,0x90\n"
26942 - "2: movl 0(%4), %%eax\n"
26943 - "21: movl 4(%4), %%edx\n"
26944 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26945 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26946 " movnti %%eax, 0(%3)\n"
26947 " movnti %%edx, 4(%3)\n"
26948 - "3: movl 8(%4), %%eax\n"
26949 - "31: movl 12(%4),%%edx\n"
26950 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26951 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26952 " movnti %%eax, 8(%3)\n"
26953 " movnti %%edx, 12(%3)\n"
26954 - "4: movl 16(%4), %%eax\n"
26955 - "41: movl 20(%4), %%edx\n"
26956 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26957 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26958 " movnti %%eax, 16(%3)\n"
26959 " movnti %%edx, 20(%3)\n"
26960 - "10: movl 24(%4), %%eax\n"
26961 - "51: movl 28(%4), %%edx\n"
26962 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26963 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26964 " movnti %%eax, 24(%3)\n"
26965 " movnti %%edx, 28(%3)\n"
26966 - "11: movl 32(%4), %%eax\n"
26967 - "61: movl 36(%4), %%edx\n"
26968 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26969 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26970 " movnti %%eax, 32(%3)\n"
26971 " movnti %%edx, 36(%3)\n"
26972 - "12: movl 40(%4), %%eax\n"
26973 - "71: movl 44(%4), %%edx\n"
26974 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26975 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26976 " movnti %%eax, 40(%3)\n"
26977 " movnti %%edx, 44(%3)\n"
26978 - "13: movl 48(%4), %%eax\n"
26979 - "81: movl 52(%4), %%edx\n"
26980 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26981 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26982 " movnti %%eax, 48(%3)\n"
26983 " movnti %%edx, 52(%3)\n"
26984 - "14: movl 56(%4), %%eax\n"
26985 - "91: movl 60(%4), %%edx\n"
26986 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26987 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26988 " movnti %%eax, 56(%3)\n"
26989 " movnti %%edx, 60(%3)\n"
26990 " addl $-64, %0\n"
26991 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26992 " shrl $2, %0\n"
26993 " andl $3, %%eax\n"
26994 " cld\n"
26995 - "6: rep; movsl\n"
26996 + "6: rep; "__copyuser_seg" movsl\n"
26997 " movl %%eax,%0\n"
26998 - "7: rep; movsb\n"
26999 + "7: rep; "__copyuser_seg" movsb\n"
27000 "8:\n"
27001 ".section .fixup,\"ax\"\n"
27002 "9: lea 0(%%eax,%0,4),%0\n"
27003 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27004 */
27005 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27006 unsigned long size);
27007 -unsigned long __copy_user_intel(void __user *to, const void *from,
27008 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27009 + unsigned long size);
27010 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27011 unsigned long size);
27012 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27013 const void __user *from, unsigned long size);
27014 #endif /* CONFIG_X86_INTEL_USERCOPY */
27015
27016 /* Generic arbitrary sized copy. */
27017 -#define __copy_user(to, from, size) \
27018 +#define __copy_user(to, from, size, prefix, set, restore) \
27019 do { \
27020 int __d0, __d1, __d2; \
27021 __asm__ __volatile__( \
27022 + set \
27023 " cmp $7,%0\n" \
27024 " jbe 1f\n" \
27025 " movl %1,%0\n" \
27026 " negl %0\n" \
27027 " andl $7,%0\n" \
27028 " subl %0,%3\n" \
27029 - "4: rep; movsb\n" \
27030 + "4: rep; "prefix"movsb\n" \
27031 " movl %3,%0\n" \
27032 " shrl $2,%0\n" \
27033 " andl $3,%3\n" \
27034 " .align 2,0x90\n" \
27035 - "0: rep; movsl\n" \
27036 + "0: rep; "prefix"movsl\n" \
27037 " movl %3,%0\n" \
27038 - "1: rep; movsb\n" \
27039 + "1: rep; "prefix"movsb\n" \
27040 "2:\n" \
27041 + restore \
27042 ".section .fixup,\"ax\"\n" \
27043 "5: addl %3,%0\n" \
27044 " jmp 2b\n" \
27045 @@ -538,14 +650,14 @@ do { \
27046 " negl %0\n" \
27047 " andl $7,%0\n" \
27048 " subl %0,%3\n" \
27049 - "4: rep; movsb\n" \
27050 + "4: rep; "__copyuser_seg"movsb\n" \
27051 " movl %3,%0\n" \
27052 " shrl $2,%0\n" \
27053 " andl $3,%3\n" \
27054 " .align 2,0x90\n" \
27055 - "0: rep; movsl\n" \
27056 + "0: rep; "__copyuser_seg"movsl\n" \
27057 " movl %3,%0\n" \
27058 - "1: rep; movsb\n" \
27059 + "1: rep; "__copyuser_seg"movsb\n" \
27060 "2:\n" \
27061 ".section .fixup,\"ax\"\n" \
27062 "5: addl %3,%0\n" \
27063 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27064 {
27065 stac();
27066 if (movsl_is_ok(to, from, n))
27067 - __copy_user(to, from, n);
27068 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27069 else
27070 - n = __copy_user_intel(to, from, n);
27071 + n = __generic_copy_to_user_intel(to, from, n);
27072 clac();
27073 return n;
27074 }
27075 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27076 {
27077 stac();
27078 if (movsl_is_ok(to, from, n))
27079 - __copy_user(to, from, n);
27080 + __copy_user(to, from, n, __copyuser_seg, "", "");
27081 else
27082 - n = __copy_user_intel((void __user *)to,
27083 - (const void *)from, n);
27084 + n = __generic_copy_from_user_intel(to, from, n);
27085 clac();
27086 return n;
27087 }
27088 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27089 if (n > 64 && cpu_has_xmm2)
27090 n = __copy_user_intel_nocache(to, from, n);
27091 else
27092 - __copy_user(to, from, n);
27093 + __copy_user(to, from, n, __copyuser_seg, "", "");
27094 #else
27095 - __copy_user(to, from, n);
27096 + __copy_user(to, from, n, __copyuser_seg, "", "");
27097 #endif
27098 clac();
27099 return n;
27100 }
27101 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27102
27103 -/**
27104 - * copy_to_user: - Copy a block of data into user space.
27105 - * @to: Destination address, in user space.
27106 - * @from: Source address, in kernel space.
27107 - * @n: Number of bytes to copy.
27108 - *
27109 - * Context: User context only. This function may sleep.
27110 - *
27111 - * Copy data from kernel space to user space.
27112 - *
27113 - * Returns number of bytes that could not be copied.
27114 - * On success, this will be zero.
27115 - */
27116 -unsigned long
27117 -copy_to_user(void __user *to, const void *from, unsigned long n)
27118 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27119 +void __set_fs(mm_segment_t x)
27120 {
27121 - if (access_ok(VERIFY_WRITE, to, n))
27122 - n = __copy_to_user(to, from, n);
27123 - return n;
27124 + switch (x.seg) {
27125 + case 0:
27126 + loadsegment(gs, 0);
27127 + break;
27128 + case TASK_SIZE_MAX:
27129 + loadsegment(gs, __USER_DS);
27130 + break;
27131 + case -1UL:
27132 + loadsegment(gs, __KERNEL_DS);
27133 + break;
27134 + default:
27135 + BUG();
27136 + }
27137 }
27138 -EXPORT_SYMBOL(copy_to_user);
27139 +EXPORT_SYMBOL(__set_fs);
27140
27141 -/**
27142 - * copy_from_user: - Copy a block of data from user space.
27143 - * @to: Destination address, in kernel space.
27144 - * @from: Source address, in user space.
27145 - * @n: Number of bytes to copy.
27146 - *
27147 - * Context: User context only. This function may sleep.
27148 - *
27149 - * Copy data from user space to kernel space.
27150 - *
27151 - * Returns number of bytes that could not be copied.
27152 - * On success, this will be zero.
27153 - *
27154 - * If some data could not be copied, this function will pad the copied
27155 - * data to the requested size using zero bytes.
27156 - */
27157 -unsigned long
27158 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27159 +void set_fs(mm_segment_t x)
27160 {
27161 - if (access_ok(VERIFY_READ, from, n))
27162 - n = __copy_from_user(to, from, n);
27163 - else
27164 - memset(to, 0, n);
27165 - return n;
27166 + current_thread_info()->addr_limit = x;
27167 + __set_fs(x);
27168 }
27169 -EXPORT_SYMBOL(_copy_from_user);
27170 +EXPORT_SYMBOL(set_fs);
27171 +#endif
27172 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27173 index 906fea3..5646695 100644
27174 --- a/arch/x86/lib/usercopy_64.c
27175 +++ b/arch/x86/lib/usercopy_64.c
27176 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27177 _ASM_EXTABLE(0b,3b)
27178 _ASM_EXTABLE(1b,2b)
27179 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27180 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27181 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27182 [zero] "r" (0UL), [eight] "r" (8UL));
27183 clac();
27184 return size;
27185 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27186 }
27187 EXPORT_SYMBOL(clear_user);
27188
27189 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27190 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27191 {
27192 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27193 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27194 - }
27195 - return len;
27196 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27197 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27198 + return len;
27199 }
27200 EXPORT_SYMBOL(copy_in_user);
27201
27202 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27203 * it is not necessary to optimize tail handling.
27204 */
27205 unsigned long
27206 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27207 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27208 {
27209 char c;
27210 unsigned zero_len;
27211 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27212 index 903ec1e..c4166b2 100644
27213 --- a/arch/x86/mm/extable.c
27214 +++ b/arch/x86/mm/extable.c
27215 @@ -6,12 +6,24 @@
27216 static inline unsigned long
27217 ex_insn_addr(const struct exception_table_entry *x)
27218 {
27219 - return (unsigned long)&x->insn + x->insn;
27220 + unsigned long reloc = 0;
27221 +
27222 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27223 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27224 +#endif
27225 +
27226 + return (unsigned long)&x->insn + x->insn + reloc;
27227 }
27228 static inline unsigned long
27229 ex_fixup_addr(const struct exception_table_entry *x)
27230 {
27231 - return (unsigned long)&x->fixup + x->fixup;
27232 + unsigned long reloc = 0;
27233 +
27234 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27235 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27236 +#endif
27237 +
27238 + return (unsigned long)&x->fixup + x->fixup + reloc;
27239 }
27240
27241 int fixup_exception(struct pt_regs *regs)
27242 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27243 unsigned long new_ip;
27244
27245 #ifdef CONFIG_PNPBIOS
27246 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27247 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27248 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27249 extern u32 pnp_bios_is_utter_crap;
27250 pnp_bios_is_utter_crap = 1;
27251 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27252 i += 4;
27253 p->fixup -= i;
27254 i += 4;
27255 +
27256 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27257 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27258 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27259 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27260 +#endif
27261 +
27262 }
27263 }
27264
27265 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27266 index 654be4a..d36985f 100644
27267 --- a/arch/x86/mm/fault.c
27268 +++ b/arch/x86/mm/fault.c
27269 @@ -14,11 +14,18 @@
27270 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27271 #include <linux/prefetch.h> /* prefetchw */
27272 #include <linux/context_tracking.h> /* exception_enter(), ... */
27273 +#include <linux/unistd.h>
27274 +#include <linux/compiler.h>
27275
27276 #include <asm/traps.h> /* dotraplinkage, ... */
27277 #include <asm/pgalloc.h> /* pgd_*(), ... */
27278 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27279 #include <asm/fixmap.h> /* VSYSCALL_START */
27280 +#include <asm/tlbflush.h>
27281 +
27282 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27283 +#include <asm/stacktrace.h>
27284 +#endif
27285
27286 /*
27287 * Page fault error code bits:
27288 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27289 int ret = 0;
27290
27291 /* kprobe_running() needs smp_processor_id() */
27292 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27293 + if (kprobes_built_in() && !user_mode(regs)) {
27294 preempt_disable();
27295 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27296 ret = 1;
27297 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27298 return !instr_lo || (instr_lo>>1) == 1;
27299 case 0x00:
27300 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27301 - if (probe_kernel_address(instr, opcode))
27302 + if (user_mode(regs)) {
27303 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27304 + return 0;
27305 + } else if (probe_kernel_address(instr, opcode))
27306 return 0;
27307
27308 *prefetch = (instr_lo == 0xF) &&
27309 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27310 while (instr < max_instr) {
27311 unsigned char opcode;
27312
27313 - if (probe_kernel_address(instr, opcode))
27314 + if (user_mode(regs)) {
27315 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27316 + break;
27317 + } else if (probe_kernel_address(instr, opcode))
27318 break;
27319
27320 instr++;
27321 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27322 force_sig_info(si_signo, &info, tsk);
27323 }
27324
27325 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27326 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27327 +#endif
27328 +
27329 +#ifdef CONFIG_PAX_EMUTRAMP
27330 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27331 +#endif
27332 +
27333 +#ifdef CONFIG_PAX_PAGEEXEC
27334 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27335 +{
27336 + pgd_t *pgd;
27337 + pud_t *pud;
27338 + pmd_t *pmd;
27339 +
27340 + pgd = pgd_offset(mm, address);
27341 + if (!pgd_present(*pgd))
27342 + return NULL;
27343 + pud = pud_offset(pgd, address);
27344 + if (!pud_present(*pud))
27345 + return NULL;
27346 + pmd = pmd_offset(pud, address);
27347 + if (!pmd_present(*pmd))
27348 + return NULL;
27349 + return pmd;
27350 +}
27351 +#endif
27352 +
27353 DEFINE_SPINLOCK(pgd_lock);
27354 LIST_HEAD(pgd_list);
27355
27356 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27357 for (address = VMALLOC_START & PMD_MASK;
27358 address >= TASK_SIZE && address < FIXADDR_TOP;
27359 address += PMD_SIZE) {
27360 +
27361 +#ifdef CONFIG_PAX_PER_CPU_PGD
27362 + unsigned long cpu;
27363 +#else
27364 struct page *page;
27365 +#endif
27366
27367 spin_lock(&pgd_lock);
27368 +
27369 +#ifdef CONFIG_PAX_PER_CPU_PGD
27370 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27371 + pgd_t *pgd = get_cpu_pgd(cpu);
27372 + pmd_t *ret;
27373 +#else
27374 list_for_each_entry(page, &pgd_list, lru) {
27375 + pgd_t *pgd;
27376 spinlock_t *pgt_lock;
27377 pmd_t *ret;
27378
27379 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27380 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27381
27382 spin_lock(pgt_lock);
27383 - ret = vmalloc_sync_one(page_address(page), address);
27384 + pgd = page_address(page);
27385 +#endif
27386 +
27387 + ret = vmalloc_sync_one(pgd, address);
27388 +
27389 +#ifndef CONFIG_PAX_PER_CPU_PGD
27390 spin_unlock(pgt_lock);
27391 +#endif
27392
27393 if (!ret)
27394 break;
27395 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27396 * an interrupt in the middle of a task switch..
27397 */
27398 pgd_paddr = read_cr3();
27399 +
27400 +#ifdef CONFIG_PAX_PER_CPU_PGD
27401 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27402 +#endif
27403 +
27404 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27405 if (!pmd_k)
27406 return -1;
27407 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27408 * happen within a race in page table update. In the later
27409 * case just flush:
27410 */
27411 +
27412 +#ifdef CONFIG_PAX_PER_CPU_PGD
27413 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27414 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27415 +#else
27416 pgd = pgd_offset(current->active_mm, address);
27417 +#endif
27418 +
27419 pgd_ref = pgd_offset_k(address);
27420 if (pgd_none(*pgd_ref))
27421 return -1;
27422 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27423 static int is_errata100(struct pt_regs *regs, unsigned long address)
27424 {
27425 #ifdef CONFIG_X86_64
27426 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27427 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27428 return 1;
27429 #endif
27430 return 0;
27431 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27432 }
27433
27434 static const char nx_warning[] = KERN_CRIT
27435 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27436 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27437
27438 static void
27439 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27440 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27441 if (!oops_may_print())
27442 return;
27443
27444 - if (error_code & PF_INSTR) {
27445 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27446 unsigned int level;
27447
27448 pte_t *pte = lookup_address(address, &level);
27449
27450 if (pte && pte_present(*pte) && !pte_exec(*pte))
27451 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27452 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27453 }
27454
27455 +#ifdef CONFIG_PAX_KERNEXEC
27456 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27457 + if (current->signal->curr_ip)
27458 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27459 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27460 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27461 + else
27462 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27463 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27464 + }
27465 +#endif
27466 +
27467 printk(KERN_ALERT "BUG: unable to handle kernel ");
27468 if (address < PAGE_SIZE)
27469 printk(KERN_CONT "NULL pointer dereference");
27470 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27471 return;
27472 }
27473 #endif
27474 +
27475 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27476 + if (pax_is_fetch_fault(regs, error_code, address)) {
27477 +
27478 +#ifdef CONFIG_PAX_EMUTRAMP
27479 + switch (pax_handle_fetch_fault(regs)) {
27480 + case 2:
27481 + return;
27482 + }
27483 +#endif
27484 +
27485 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27486 + do_group_exit(SIGKILL);
27487 + }
27488 +#endif
27489 +
27490 /* Kernel addresses are always protection faults: */
27491 if (address >= TASK_SIZE)
27492 error_code |= PF_PROT;
27493 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27494 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27495 printk(KERN_ERR
27496 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27497 - tsk->comm, tsk->pid, address);
27498 + tsk->comm, task_pid_nr(tsk), address);
27499 code = BUS_MCEERR_AR;
27500 }
27501 #endif
27502 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27503 return 1;
27504 }
27505
27506 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27507 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27508 +{
27509 + pte_t *pte;
27510 + pmd_t *pmd;
27511 + spinlock_t *ptl;
27512 + unsigned char pte_mask;
27513 +
27514 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27515 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27516 + return 0;
27517 +
27518 + /* PaX: it's our fault, let's handle it if we can */
27519 +
27520 + /* PaX: take a look at read faults before acquiring any locks */
27521 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27522 + /* instruction fetch attempt from a protected page in user mode */
27523 + up_read(&mm->mmap_sem);
27524 +
27525 +#ifdef CONFIG_PAX_EMUTRAMP
27526 + switch (pax_handle_fetch_fault(regs)) {
27527 + case 2:
27528 + return 1;
27529 + }
27530 +#endif
27531 +
27532 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27533 + do_group_exit(SIGKILL);
27534 + }
27535 +
27536 + pmd = pax_get_pmd(mm, address);
27537 + if (unlikely(!pmd))
27538 + return 0;
27539 +
27540 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27541 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27542 + pte_unmap_unlock(pte, ptl);
27543 + return 0;
27544 + }
27545 +
27546 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27547 + /* write attempt to a protected page in user mode */
27548 + pte_unmap_unlock(pte, ptl);
27549 + return 0;
27550 + }
27551 +
27552 +#ifdef CONFIG_SMP
27553 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27554 +#else
27555 + if (likely(address > get_limit(regs->cs)))
27556 +#endif
27557 + {
27558 + set_pte(pte, pte_mkread(*pte));
27559 + __flush_tlb_one(address);
27560 + pte_unmap_unlock(pte, ptl);
27561 + up_read(&mm->mmap_sem);
27562 + return 1;
27563 + }
27564 +
27565 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27566 +
27567 + /*
27568 + * PaX: fill DTLB with user rights and retry
27569 + */
27570 + __asm__ __volatile__ (
27571 + "orb %2,(%1)\n"
27572 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27573 +/*
27574 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27575 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27576 + * page fault when examined during a TLB load attempt. this is true not only
27577 + * for PTEs holding a non-present entry but also present entries that will
27578 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27579 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27580 + * for our target pages since their PTEs are simply not in the TLBs at all.
27581 +
27582 + * the best thing in omitting it is that we gain around 15-20% speed in the
27583 + * fast path of the page fault handler and can get rid of tracing since we
27584 + * can no longer flush unintended entries.
27585 + */
27586 + "invlpg (%0)\n"
27587 +#endif
27588 + __copyuser_seg"testb $0,(%0)\n"
27589 + "xorb %3,(%1)\n"
27590 + :
27591 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27592 + : "memory", "cc");
27593 + pte_unmap_unlock(pte, ptl);
27594 + up_read(&mm->mmap_sem);
27595 + return 1;
27596 +}
27597 +#endif
27598 +
27599 /*
27600 * Handle a spurious fault caused by a stale TLB entry.
27601 *
27602 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27603 static inline int
27604 access_error(unsigned long error_code, struct vm_area_struct *vma)
27605 {
27606 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27607 + return 1;
27608 +
27609 if (error_code & PF_WRITE) {
27610 /* write, present and write, not present: */
27611 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27612 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27613 if (error_code & PF_USER)
27614 return false;
27615
27616 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27617 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27618 return false;
27619
27620 return true;
27621 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27622 {
27623 struct vm_area_struct *vma;
27624 struct task_struct *tsk;
27625 - unsigned long address;
27626 struct mm_struct *mm;
27627 int fault;
27628 int write = error_code & PF_WRITE;
27629 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27630 (write ? FAULT_FLAG_WRITE : 0);
27631
27632 - tsk = current;
27633 - mm = tsk->mm;
27634 -
27635 /* Get the faulting address: */
27636 - address = read_cr2();
27637 + unsigned long address = read_cr2();
27638 +
27639 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27640 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27641 + if (!search_exception_tables(regs->ip)) {
27642 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27643 + bad_area_nosemaphore(regs, error_code, address);
27644 + return;
27645 + }
27646 + if (address < pax_user_shadow_base) {
27647 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27648 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27649 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27650 + } else
27651 + address -= pax_user_shadow_base;
27652 + }
27653 +#endif
27654 +
27655 + tsk = current;
27656 + mm = tsk->mm;
27657
27658 /*
27659 * Detect and handle instructions that would cause a page fault for
27660 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27661 * User-mode registers count as a user access even for any
27662 * potential system fault or CPU buglet:
27663 */
27664 - if (user_mode_vm(regs)) {
27665 + if (user_mode(regs)) {
27666 local_irq_enable();
27667 error_code |= PF_USER;
27668 } else {
27669 @@ -1142,6 +1352,11 @@ retry:
27670 might_sleep();
27671 }
27672
27673 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27674 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27675 + return;
27676 +#endif
27677 +
27678 vma = find_vma(mm, address);
27679 if (unlikely(!vma)) {
27680 bad_area(regs, error_code, address);
27681 @@ -1153,18 +1368,24 @@ retry:
27682 bad_area(regs, error_code, address);
27683 return;
27684 }
27685 - if (error_code & PF_USER) {
27686 - /*
27687 - * Accessing the stack below %sp is always a bug.
27688 - * The large cushion allows instructions like enter
27689 - * and pusha to work. ("enter $65535, $31" pushes
27690 - * 32 pointers and then decrements %sp by 65535.)
27691 - */
27692 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27693 - bad_area(regs, error_code, address);
27694 - return;
27695 - }
27696 + /*
27697 + * Accessing the stack below %sp is always a bug.
27698 + * The large cushion allows instructions like enter
27699 + * and pusha to work. ("enter $65535, $31" pushes
27700 + * 32 pointers and then decrements %sp by 65535.)
27701 + */
27702 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27703 + bad_area(regs, error_code, address);
27704 + return;
27705 }
27706 +
27707 +#ifdef CONFIG_PAX_SEGMEXEC
27708 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27709 + bad_area(regs, error_code, address);
27710 + return;
27711 + }
27712 +#endif
27713 +
27714 if (unlikely(expand_stack(vma, address))) {
27715 bad_area(regs, error_code, address);
27716 return;
27717 @@ -1230,3 +1451,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27718 __do_page_fault(regs, error_code);
27719 exception_exit(prev_state);
27720 }
27721 +
27722 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27723 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27724 +{
27725 + struct mm_struct *mm = current->mm;
27726 + unsigned long ip = regs->ip;
27727 +
27728 + if (v8086_mode(regs))
27729 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27730 +
27731 +#ifdef CONFIG_PAX_PAGEEXEC
27732 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27733 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27734 + return true;
27735 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27736 + return true;
27737 + return false;
27738 + }
27739 +#endif
27740 +
27741 +#ifdef CONFIG_PAX_SEGMEXEC
27742 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27743 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27744 + return true;
27745 + return false;
27746 + }
27747 +#endif
27748 +
27749 + return false;
27750 +}
27751 +#endif
27752 +
27753 +#ifdef CONFIG_PAX_EMUTRAMP
27754 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27755 +{
27756 + int err;
27757 +
27758 + do { /* PaX: libffi trampoline emulation */
27759 + unsigned char mov, jmp;
27760 + unsigned int addr1, addr2;
27761 +
27762 +#ifdef CONFIG_X86_64
27763 + if ((regs->ip + 9) >> 32)
27764 + break;
27765 +#endif
27766 +
27767 + err = get_user(mov, (unsigned char __user *)regs->ip);
27768 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27769 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27770 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27771 +
27772 + if (err)
27773 + break;
27774 +
27775 + if (mov == 0xB8 && jmp == 0xE9) {
27776 + regs->ax = addr1;
27777 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27778 + return 2;
27779 + }
27780 + } while (0);
27781 +
27782 + do { /* PaX: gcc trampoline emulation #1 */
27783 + unsigned char mov1, mov2;
27784 + unsigned short jmp;
27785 + unsigned int addr1, addr2;
27786 +
27787 +#ifdef CONFIG_X86_64
27788 + if ((regs->ip + 11) >> 32)
27789 + break;
27790 +#endif
27791 +
27792 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27793 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27794 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27795 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27796 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27797 +
27798 + if (err)
27799 + break;
27800 +
27801 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27802 + regs->cx = addr1;
27803 + regs->ax = addr2;
27804 + regs->ip = addr2;
27805 + return 2;
27806 + }
27807 + } while (0);
27808 +
27809 + do { /* PaX: gcc trampoline emulation #2 */
27810 + unsigned char mov, jmp;
27811 + unsigned int addr1, addr2;
27812 +
27813 +#ifdef CONFIG_X86_64
27814 + if ((regs->ip + 9) >> 32)
27815 + break;
27816 +#endif
27817 +
27818 + err = get_user(mov, (unsigned char __user *)regs->ip);
27819 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27820 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27821 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27822 +
27823 + if (err)
27824 + break;
27825 +
27826 + if (mov == 0xB9 && jmp == 0xE9) {
27827 + regs->cx = addr1;
27828 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27829 + return 2;
27830 + }
27831 + } while (0);
27832 +
27833 + return 1; /* PaX in action */
27834 +}
27835 +
27836 +#ifdef CONFIG_X86_64
27837 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27838 +{
27839 + int err;
27840 +
27841 + do { /* PaX: libffi trampoline emulation */
27842 + unsigned short mov1, mov2, jmp1;
27843 + unsigned char stcclc, jmp2;
27844 + unsigned long addr1, addr2;
27845 +
27846 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27847 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27848 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27849 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27850 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27851 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27852 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27853 +
27854 + if (err)
27855 + break;
27856 +
27857 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27858 + regs->r11 = addr1;
27859 + regs->r10 = addr2;
27860 + if (stcclc == 0xF8)
27861 + regs->flags &= ~X86_EFLAGS_CF;
27862 + else
27863 + regs->flags |= X86_EFLAGS_CF;
27864 + regs->ip = addr1;
27865 + return 2;
27866 + }
27867 + } while (0);
27868 +
27869 + do { /* PaX: gcc trampoline emulation #1 */
27870 + unsigned short mov1, mov2, jmp1;
27871 + unsigned char jmp2;
27872 + unsigned int addr1;
27873 + unsigned long addr2;
27874 +
27875 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27876 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27877 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27878 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27879 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27880 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27881 +
27882 + if (err)
27883 + break;
27884 +
27885 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27886 + regs->r11 = addr1;
27887 + regs->r10 = addr2;
27888 + regs->ip = addr1;
27889 + return 2;
27890 + }
27891 + } while (0);
27892 +
27893 + do { /* PaX: gcc trampoline emulation #2 */
27894 + unsigned short mov1, mov2, jmp1;
27895 + unsigned char jmp2;
27896 + unsigned long addr1, addr2;
27897 +
27898 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27899 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27900 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27901 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27902 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27903 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27904 +
27905 + if (err)
27906 + break;
27907 +
27908 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27909 + regs->r11 = addr1;
27910 + regs->r10 = addr2;
27911 + regs->ip = addr1;
27912 + return 2;
27913 + }
27914 + } while (0);
27915 +
27916 + return 1; /* PaX in action */
27917 +}
27918 +#endif
27919 +
27920 +/*
27921 + * PaX: decide what to do with offenders (regs->ip = fault address)
27922 + *
27923 + * returns 1 when task should be killed
27924 + * 2 when gcc trampoline was detected
27925 + */
27926 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27927 +{
27928 + if (v8086_mode(regs))
27929 + return 1;
27930 +
27931 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27932 + return 1;
27933 +
27934 +#ifdef CONFIG_X86_32
27935 + return pax_handle_fetch_fault_32(regs);
27936 +#else
27937 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27938 + return pax_handle_fetch_fault_32(regs);
27939 + else
27940 + return pax_handle_fetch_fault_64(regs);
27941 +#endif
27942 +}
27943 +#endif
27944 +
27945 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27946 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27947 +{
27948 + long i;
27949 +
27950 + printk(KERN_ERR "PAX: bytes at PC: ");
27951 + for (i = 0; i < 20; i++) {
27952 + unsigned char c;
27953 + if (get_user(c, (unsigned char __force_user *)pc+i))
27954 + printk(KERN_CONT "?? ");
27955 + else
27956 + printk(KERN_CONT "%02x ", c);
27957 + }
27958 + printk("\n");
27959 +
27960 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27961 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27962 + unsigned long c;
27963 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27964 +#ifdef CONFIG_X86_32
27965 + printk(KERN_CONT "???????? ");
27966 +#else
27967 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27968 + printk(KERN_CONT "???????? ???????? ");
27969 + else
27970 + printk(KERN_CONT "???????????????? ");
27971 +#endif
27972 + } else {
27973 +#ifdef CONFIG_X86_64
27974 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27975 + printk(KERN_CONT "%08x ", (unsigned int)c);
27976 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27977 + } else
27978 +#endif
27979 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27980 + }
27981 + }
27982 + printk("\n");
27983 +}
27984 +#endif
27985 +
27986 +/**
27987 + * probe_kernel_write(): safely attempt to write to a location
27988 + * @dst: address to write to
27989 + * @src: pointer to the data that shall be written
27990 + * @size: size of the data chunk
27991 + *
27992 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27993 + * happens, handle that and return -EFAULT.
27994 + */
27995 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27996 +{
27997 + long ret;
27998 + mm_segment_t old_fs = get_fs();
27999 +
28000 + set_fs(KERNEL_DS);
28001 + pagefault_disable();
28002 + pax_open_kernel();
28003 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28004 + pax_close_kernel();
28005 + pagefault_enable();
28006 + set_fs(old_fs);
28007 +
28008 + return ret ? -EFAULT : 0;
28009 +}
28010 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28011 index dd74e46..7d26398 100644
28012 --- a/arch/x86/mm/gup.c
28013 +++ b/arch/x86/mm/gup.c
28014 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28015 addr = start;
28016 len = (unsigned long) nr_pages << PAGE_SHIFT;
28017 end = start + len;
28018 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28019 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28020 (void __user *)start, len)))
28021 return 0;
28022
28023 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28024 index 252b8f5..4dcfdc1 100644
28025 --- a/arch/x86/mm/highmem_32.c
28026 +++ b/arch/x86/mm/highmem_32.c
28027 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28028 idx = type + KM_TYPE_NR*smp_processor_id();
28029 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28030 BUG_ON(!pte_none(*(kmap_pte-idx)));
28031 +
28032 + pax_open_kernel();
28033 set_pte(kmap_pte-idx, mk_pte(page, prot));
28034 + pax_close_kernel();
28035 +
28036 arch_flush_lazy_mmu_mode();
28037
28038 return (void *)vaddr;
28039 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28040 index ae1aa71..d9bea75 100644
28041 --- a/arch/x86/mm/hugetlbpage.c
28042 +++ b/arch/x86/mm/hugetlbpage.c
28043 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
28044 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
28045 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28046 unsigned long addr, unsigned long len,
28047 - unsigned long pgoff, unsigned long flags)
28048 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28049 {
28050 struct hstate *h = hstate_file(file);
28051 struct vm_unmapped_area_info info;
28052 -
28053 +
28054 info.flags = 0;
28055 info.length = len;
28056 info.low_limit = TASK_UNMAPPED_BASE;
28057 +
28058 +#ifdef CONFIG_PAX_RANDMMAP
28059 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28060 + info.low_limit += current->mm->delta_mmap;
28061 +#endif
28062 +
28063 info.high_limit = TASK_SIZE;
28064 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28065 info.align_offset = 0;
28066 + info.threadstack_offset = offset;
28067 return vm_unmapped_area(&info);
28068 }
28069
28070 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28071 unsigned long addr0, unsigned long len,
28072 - unsigned long pgoff, unsigned long flags)
28073 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28074 {
28075 struct hstate *h = hstate_file(file);
28076 struct vm_unmapped_area_info info;
28077 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28078 info.high_limit = current->mm->mmap_base;
28079 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28080 info.align_offset = 0;
28081 + info.threadstack_offset = offset;
28082 addr = vm_unmapped_area(&info);
28083
28084 /*
28085 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28086 VM_BUG_ON(addr != -ENOMEM);
28087 info.flags = 0;
28088 info.low_limit = TASK_UNMAPPED_BASE;
28089 +
28090 +#ifdef CONFIG_PAX_RANDMMAP
28091 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28092 + info.low_limit += current->mm->delta_mmap;
28093 +#endif
28094 +
28095 info.high_limit = TASK_SIZE;
28096 addr = vm_unmapped_area(&info);
28097 }
28098 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28099 struct hstate *h = hstate_file(file);
28100 struct mm_struct *mm = current->mm;
28101 struct vm_area_struct *vma;
28102 + unsigned long pax_task_size = TASK_SIZE;
28103 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28104
28105 if (len & ~huge_page_mask(h))
28106 return -EINVAL;
28107 - if (len > TASK_SIZE)
28108 +
28109 +#ifdef CONFIG_PAX_SEGMEXEC
28110 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28111 + pax_task_size = SEGMEXEC_TASK_SIZE;
28112 +#endif
28113 +
28114 + pax_task_size -= PAGE_SIZE;
28115 +
28116 + if (len > pax_task_size)
28117 return -ENOMEM;
28118
28119 if (flags & MAP_FIXED) {
28120 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28121 return addr;
28122 }
28123
28124 +#ifdef CONFIG_PAX_RANDMMAP
28125 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28126 +#endif
28127 +
28128 if (addr) {
28129 addr = ALIGN(addr, huge_page_size(h));
28130 vma = find_vma(mm, addr);
28131 - if (TASK_SIZE - len >= addr &&
28132 - (!vma || addr + len <= vma->vm_start))
28133 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28134 return addr;
28135 }
28136 if (mm->get_unmapped_area == arch_get_unmapped_area)
28137 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28138 - pgoff, flags);
28139 + pgoff, flags, offset);
28140 else
28141 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28142 - pgoff, flags);
28143 + pgoff, flags, offset);
28144 }
28145
28146 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28147 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28148 index 1f34e92..d252637 100644
28149 --- a/arch/x86/mm/init.c
28150 +++ b/arch/x86/mm/init.c
28151 @@ -4,6 +4,7 @@
28152 #include <linux/swap.h>
28153 #include <linux/memblock.h>
28154 #include <linux/bootmem.h> /* for max_low_pfn */
28155 +#include <linux/tboot.h>
28156
28157 #include <asm/cacheflush.h>
28158 #include <asm/e820.h>
28159 @@ -17,6 +18,8 @@
28160 #include <asm/proto.h>
28161 #include <asm/dma.h> /* for MAX_DMA_PFN */
28162 #include <asm/microcode.h>
28163 +#include <asm/desc.h>
28164 +#include <asm/bios_ebda.h>
28165
28166 #include "mm_internal.h"
28167
28168 @@ -465,7 +468,15 @@ void __init init_mem_mapping(void)
28169 early_ioremap_page_table_range_init();
28170 #endif
28171
28172 +#ifdef CONFIG_PAX_PER_CPU_PGD
28173 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28174 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28175 + KERNEL_PGD_PTRS);
28176 + load_cr3(get_cpu_pgd(0));
28177 +#else
28178 load_cr3(swapper_pg_dir);
28179 +#endif
28180 +
28181 __flush_tlb_all();
28182
28183 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
28184 @@ -481,10 +492,40 @@ void __init init_mem_mapping(void)
28185 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28186 * mmio resources as well as potential bios/acpi data regions.
28187 */
28188 +
28189 +#ifdef CONFIG_GRKERNSEC_KMEM
28190 +static unsigned int ebda_start __read_only;
28191 +static unsigned int ebda_end __read_only;
28192 +#endif
28193 +
28194 int devmem_is_allowed(unsigned long pagenr)
28195 {
28196 - if (pagenr < 256)
28197 +#ifdef CONFIG_GRKERNSEC_KMEM
28198 + /* allow BDA */
28199 + if (!pagenr)
28200 return 1;
28201 + /* allow EBDA */
28202 + if (pagenr >= ebda_start && pagenr < ebda_end)
28203 + return 1;
28204 + /* if tboot is in use, allow access to its hardcoded serial log range */
28205 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28206 + return 1;
28207 +#else
28208 + if (!pagenr)
28209 + return 1;
28210 +#ifdef CONFIG_VM86
28211 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28212 + return 1;
28213 +#endif
28214 +#endif
28215 +
28216 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28217 + return 1;
28218 +#ifdef CONFIG_GRKERNSEC_KMEM
28219 + /* throw out everything else below 1MB */
28220 + if (pagenr <= 256)
28221 + return 0;
28222 +#endif
28223 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28224 return 0;
28225 if (!page_is_ram(pagenr))
28226 @@ -538,8 +579,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28227 #endif
28228 }
28229
28230 +#ifdef CONFIG_GRKERNSEC_KMEM
28231 +static inline void gr_init_ebda(void)
28232 +{
28233 + unsigned int ebda_addr;
28234 + unsigned int ebda_size = 0;
28235 +
28236 + ebda_addr = get_bios_ebda();
28237 + if (ebda_addr) {
28238 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28239 + ebda_size <<= 10;
28240 + }
28241 + if (ebda_addr && ebda_size) {
28242 + ebda_start = ebda_addr >> PAGE_SHIFT;
28243 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28244 + } else {
28245 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28246 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28247 + }
28248 +}
28249 +#else
28250 +static inline void gr_init_ebda(void) { }
28251 +#endif
28252 +
28253 void free_initmem(void)
28254 {
28255 +#ifdef CONFIG_PAX_KERNEXEC
28256 +#ifdef CONFIG_X86_32
28257 + /* PaX: limit KERNEL_CS to actual size */
28258 + unsigned long addr, limit;
28259 + struct desc_struct d;
28260 + int cpu;
28261 +#else
28262 + pgd_t *pgd;
28263 + pud_t *pud;
28264 + pmd_t *pmd;
28265 + unsigned long addr, end;
28266 +#endif
28267 +#endif
28268 +
28269 + gr_init_ebda();
28270 +
28271 +#ifdef CONFIG_PAX_KERNEXEC
28272 +#ifdef CONFIG_X86_32
28273 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28274 + limit = (limit - 1UL) >> PAGE_SHIFT;
28275 +
28276 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28277 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28278 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28279 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28280 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28281 + }
28282 +
28283 + /* PaX: make KERNEL_CS read-only */
28284 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28285 + if (!paravirt_enabled())
28286 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28287 +/*
28288 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28289 + pgd = pgd_offset_k(addr);
28290 + pud = pud_offset(pgd, addr);
28291 + pmd = pmd_offset(pud, addr);
28292 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28293 + }
28294 +*/
28295 +#ifdef CONFIG_X86_PAE
28296 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28297 +/*
28298 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28299 + pgd = pgd_offset_k(addr);
28300 + pud = pud_offset(pgd, addr);
28301 + pmd = pmd_offset(pud, addr);
28302 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28303 + }
28304 +*/
28305 +#endif
28306 +
28307 +#ifdef CONFIG_MODULES
28308 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28309 +#endif
28310 +
28311 +#else
28312 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28313 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28314 + pgd = pgd_offset_k(addr);
28315 + pud = pud_offset(pgd, addr);
28316 + pmd = pmd_offset(pud, addr);
28317 + if (!pmd_present(*pmd))
28318 + continue;
28319 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28320 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28321 + else
28322 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28323 + }
28324 +
28325 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28326 + end = addr + KERNEL_IMAGE_SIZE;
28327 + for (; addr < end; addr += PMD_SIZE) {
28328 + pgd = pgd_offset_k(addr);
28329 + pud = pud_offset(pgd, addr);
28330 + pmd = pmd_offset(pud, addr);
28331 + if (!pmd_present(*pmd))
28332 + continue;
28333 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28334 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28335 + }
28336 +#endif
28337 +
28338 + flush_tlb_all();
28339 +#endif
28340 +
28341 free_init_pages("unused kernel memory",
28342 (unsigned long)(&__init_begin),
28343 (unsigned long)(&__init_end));
28344 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28345 index 3ac7e31..89611b7 100644
28346 --- a/arch/x86/mm/init_32.c
28347 +++ b/arch/x86/mm/init_32.c
28348 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28349 bool __read_mostly __vmalloc_start_set = false;
28350
28351 /*
28352 - * Creates a middle page table and puts a pointer to it in the
28353 - * given global directory entry. This only returns the gd entry
28354 - * in non-PAE compilation mode, since the middle layer is folded.
28355 - */
28356 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28357 -{
28358 - pud_t *pud;
28359 - pmd_t *pmd_table;
28360 -
28361 -#ifdef CONFIG_X86_PAE
28362 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28363 - pmd_table = (pmd_t *)alloc_low_page();
28364 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28365 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28366 - pud = pud_offset(pgd, 0);
28367 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28368 -
28369 - return pmd_table;
28370 - }
28371 -#endif
28372 - pud = pud_offset(pgd, 0);
28373 - pmd_table = pmd_offset(pud, 0);
28374 -
28375 - return pmd_table;
28376 -}
28377 -
28378 -/*
28379 * Create a page table and place a pointer to it in a middle page
28380 * directory entry:
28381 */
28382 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28383 pte_t *page_table = (pte_t *)alloc_low_page();
28384
28385 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28386 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28387 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28388 +#else
28389 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28390 +#endif
28391 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28392 }
28393
28394 return pte_offset_kernel(pmd, 0);
28395 }
28396
28397 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28398 +{
28399 + pud_t *pud;
28400 + pmd_t *pmd_table;
28401 +
28402 + pud = pud_offset(pgd, 0);
28403 + pmd_table = pmd_offset(pud, 0);
28404 +
28405 + return pmd_table;
28406 +}
28407 +
28408 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28409 {
28410 int pgd_idx = pgd_index(vaddr);
28411 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28412 int pgd_idx, pmd_idx;
28413 unsigned long vaddr;
28414 pgd_t *pgd;
28415 + pud_t *pud;
28416 pmd_t *pmd;
28417 pte_t *pte = NULL;
28418 unsigned long count = page_table_range_init_count(start, end);
28419 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28420 pgd = pgd_base + pgd_idx;
28421
28422 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28423 - pmd = one_md_table_init(pgd);
28424 - pmd = pmd + pmd_index(vaddr);
28425 + pud = pud_offset(pgd, vaddr);
28426 + pmd = pmd_offset(pud, vaddr);
28427 +
28428 +#ifdef CONFIG_X86_PAE
28429 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28430 +#endif
28431 +
28432 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28433 pmd++, pmd_idx++) {
28434 pte = page_table_kmap_check(one_page_table_init(pmd),
28435 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28436 }
28437 }
28438
28439 -static inline int is_kernel_text(unsigned long addr)
28440 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28441 {
28442 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28443 - return 1;
28444 - return 0;
28445 + if ((start > ktla_ktva((unsigned long)_etext) ||
28446 + end <= ktla_ktva((unsigned long)_stext)) &&
28447 + (start > ktla_ktva((unsigned long)_einittext) ||
28448 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28449 +
28450 +#ifdef CONFIG_ACPI_SLEEP
28451 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28452 +#endif
28453 +
28454 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28455 + return 0;
28456 + return 1;
28457 }
28458
28459 /*
28460 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28461 unsigned long last_map_addr = end;
28462 unsigned long start_pfn, end_pfn;
28463 pgd_t *pgd_base = swapper_pg_dir;
28464 - int pgd_idx, pmd_idx, pte_ofs;
28465 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28466 unsigned long pfn;
28467 pgd_t *pgd;
28468 + pud_t *pud;
28469 pmd_t *pmd;
28470 pte_t *pte;
28471 unsigned pages_2m, pages_4k;
28472 @@ -291,8 +295,13 @@ repeat:
28473 pfn = start_pfn;
28474 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28475 pgd = pgd_base + pgd_idx;
28476 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28477 - pmd = one_md_table_init(pgd);
28478 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28479 + pud = pud_offset(pgd, 0);
28480 + pmd = pmd_offset(pud, 0);
28481 +
28482 +#ifdef CONFIG_X86_PAE
28483 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28484 +#endif
28485
28486 if (pfn >= end_pfn)
28487 continue;
28488 @@ -304,14 +313,13 @@ repeat:
28489 #endif
28490 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28491 pmd++, pmd_idx++) {
28492 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28493 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28494
28495 /*
28496 * Map with big pages if possible, otherwise
28497 * create normal page tables:
28498 */
28499 if (use_pse) {
28500 - unsigned int addr2;
28501 pgprot_t prot = PAGE_KERNEL_LARGE;
28502 /*
28503 * first pass will use the same initial
28504 @@ -322,11 +330,7 @@ repeat:
28505 _PAGE_PSE);
28506
28507 pfn &= PMD_MASK >> PAGE_SHIFT;
28508 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28509 - PAGE_OFFSET + PAGE_SIZE-1;
28510 -
28511 - if (is_kernel_text(addr) ||
28512 - is_kernel_text(addr2))
28513 + if (is_kernel_text(address, address + PMD_SIZE))
28514 prot = PAGE_KERNEL_LARGE_EXEC;
28515
28516 pages_2m++;
28517 @@ -343,7 +347,7 @@ repeat:
28518 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28519 pte += pte_ofs;
28520 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28521 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28522 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28523 pgprot_t prot = PAGE_KERNEL;
28524 /*
28525 * first pass will use the same initial
28526 @@ -351,7 +355,7 @@ repeat:
28527 */
28528 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28529
28530 - if (is_kernel_text(addr))
28531 + if (is_kernel_text(address, address + PAGE_SIZE))
28532 prot = PAGE_KERNEL_EXEC;
28533
28534 pages_4k++;
28535 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
28536
28537 pud = pud_offset(pgd, va);
28538 pmd = pmd_offset(pud, va);
28539 - if (!pmd_present(*pmd))
28540 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28541 break;
28542
28543 /* should not be large page here */
28544 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
28545
28546 static void __init pagetable_init(void)
28547 {
28548 - pgd_t *pgd_base = swapper_pg_dir;
28549 -
28550 - permanent_kmaps_init(pgd_base);
28551 + permanent_kmaps_init(swapper_pg_dir);
28552 }
28553
28554 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28555 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28556 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28557
28558 /* user-defined highmem size */
28559 @@ -772,7 +774,7 @@ void __init mem_init(void)
28560 after_bootmem = 1;
28561
28562 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28563 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28564 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28565 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28566
28567 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28568 @@ -813,10 +815,10 @@ void __init mem_init(void)
28569 ((unsigned long)&__init_end -
28570 (unsigned long)&__init_begin) >> 10,
28571
28572 - (unsigned long)&_etext, (unsigned long)&_edata,
28573 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28574 + (unsigned long)&_sdata, (unsigned long)&_edata,
28575 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28576
28577 - (unsigned long)&_text, (unsigned long)&_etext,
28578 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28579 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28580
28581 /*
28582 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
28583 if (!kernel_set_to_readonly)
28584 return;
28585
28586 + start = ktla_ktva(start);
28587 pr_debug("Set kernel text: %lx - %lx for read write\n",
28588 start, start+size);
28589
28590 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
28591 if (!kernel_set_to_readonly)
28592 return;
28593
28594 + start = ktla_ktva(start);
28595 pr_debug("Set kernel text: %lx - %lx for read only\n",
28596 start, start+size);
28597
28598 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
28599 unsigned long start = PFN_ALIGN(_text);
28600 unsigned long size = PFN_ALIGN(_etext) - start;
28601
28602 + start = ktla_ktva(start);
28603 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28604 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28605 size >> 10);
28606 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28607 index bb00c46..f31d2f0 100644
28608 --- a/arch/x86/mm/init_64.c
28609 +++ b/arch/x86/mm/init_64.c
28610 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28611 * around without checking the pgd every time.
28612 */
28613
28614 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28615 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28616 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28617
28618 int force_personality32;
28619 @@ -184,12 +184,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28620
28621 for (address = start; address <= end; address += PGDIR_SIZE) {
28622 const pgd_t *pgd_ref = pgd_offset_k(address);
28623 +
28624 +#ifdef CONFIG_PAX_PER_CPU_PGD
28625 + unsigned long cpu;
28626 +#else
28627 struct page *page;
28628 +#endif
28629
28630 if (pgd_none(*pgd_ref))
28631 continue;
28632
28633 spin_lock(&pgd_lock);
28634 +
28635 +#ifdef CONFIG_PAX_PER_CPU_PGD
28636 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28637 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28638 +#else
28639 list_for_each_entry(page, &pgd_list, lru) {
28640 pgd_t *pgd;
28641 spinlock_t *pgt_lock;
28642 @@ -198,6 +208,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28643 /* the pgt_lock only for Xen */
28644 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28645 spin_lock(pgt_lock);
28646 +#endif
28647
28648 if (pgd_none(*pgd))
28649 set_pgd(pgd, *pgd_ref);
28650 @@ -205,7 +216,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28651 BUG_ON(pgd_page_vaddr(*pgd)
28652 != pgd_page_vaddr(*pgd_ref));
28653
28654 +#ifndef CONFIG_PAX_PER_CPU_PGD
28655 spin_unlock(pgt_lock);
28656 +#endif
28657 +
28658 }
28659 spin_unlock(&pgd_lock);
28660 }
28661 @@ -238,7 +252,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28662 {
28663 if (pgd_none(*pgd)) {
28664 pud_t *pud = (pud_t *)spp_getpage();
28665 - pgd_populate(&init_mm, pgd, pud);
28666 + pgd_populate_kernel(&init_mm, pgd, pud);
28667 if (pud != pud_offset(pgd, 0))
28668 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28669 pud, pud_offset(pgd, 0));
28670 @@ -250,7 +264,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28671 {
28672 if (pud_none(*pud)) {
28673 pmd_t *pmd = (pmd_t *) spp_getpage();
28674 - pud_populate(&init_mm, pud, pmd);
28675 + pud_populate_kernel(&init_mm, pud, pmd);
28676 if (pmd != pmd_offset(pud, 0))
28677 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28678 pmd, pmd_offset(pud, 0));
28679 @@ -279,7 +293,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28680 pmd = fill_pmd(pud, vaddr);
28681 pte = fill_pte(pmd, vaddr);
28682
28683 + pax_open_kernel();
28684 set_pte(pte, new_pte);
28685 + pax_close_kernel();
28686
28687 /*
28688 * It's enough to flush this one mapping.
28689 @@ -338,14 +354,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28690 pgd = pgd_offset_k((unsigned long)__va(phys));
28691 if (pgd_none(*pgd)) {
28692 pud = (pud_t *) spp_getpage();
28693 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28694 - _PAGE_USER));
28695 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28696 }
28697 pud = pud_offset(pgd, (unsigned long)__va(phys));
28698 if (pud_none(*pud)) {
28699 pmd = (pmd_t *) spp_getpage();
28700 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28701 - _PAGE_USER));
28702 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28703 }
28704 pmd = pmd_offset(pud, phys);
28705 BUG_ON(!pmd_none(*pmd));
28706 @@ -586,7 +600,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28707 prot);
28708
28709 spin_lock(&init_mm.page_table_lock);
28710 - pud_populate(&init_mm, pud, pmd);
28711 + pud_populate_kernel(&init_mm, pud, pmd);
28712 spin_unlock(&init_mm.page_table_lock);
28713 }
28714 __flush_tlb_all();
28715 @@ -627,7 +641,7 @@ kernel_physical_mapping_init(unsigned long start,
28716 page_size_mask);
28717
28718 spin_lock(&init_mm.page_table_lock);
28719 - pgd_populate(&init_mm, pgd, pud);
28720 + pgd_populate_kernel(&init_mm, pgd, pud);
28721 spin_unlock(&init_mm.page_table_lock);
28722 pgd_changed = true;
28723 }
28724 @@ -1221,8 +1235,8 @@ int kern_addr_valid(unsigned long addr)
28725 static struct vm_area_struct gate_vma = {
28726 .vm_start = VSYSCALL_START,
28727 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28728 - .vm_page_prot = PAGE_READONLY_EXEC,
28729 - .vm_flags = VM_READ | VM_EXEC
28730 + .vm_page_prot = PAGE_READONLY,
28731 + .vm_flags = VM_READ
28732 };
28733
28734 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28735 @@ -1256,7 +1270,7 @@ int in_gate_area_no_mm(unsigned long addr)
28736
28737 const char *arch_vma_name(struct vm_area_struct *vma)
28738 {
28739 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28740 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28741 return "[vdso]";
28742 if (vma == &gate_vma)
28743 return "[vsyscall]";
28744 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28745 index 7b179b4..6bd17777 100644
28746 --- a/arch/x86/mm/iomap_32.c
28747 +++ b/arch/x86/mm/iomap_32.c
28748 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28749 type = kmap_atomic_idx_push();
28750 idx = type + KM_TYPE_NR * smp_processor_id();
28751 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28752 +
28753 + pax_open_kernel();
28754 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28755 + pax_close_kernel();
28756 +
28757 arch_flush_lazy_mmu_mode();
28758
28759 return (void *)vaddr;
28760 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28761 index 9a1e658..da003f3 100644
28762 --- a/arch/x86/mm/ioremap.c
28763 +++ b/arch/x86/mm/ioremap.c
28764 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28765 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28766 int is_ram = page_is_ram(pfn);
28767
28768 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28769 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28770 return NULL;
28771 WARN_ON_ONCE(is_ram);
28772 }
28773 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28774 *
28775 * Caller must ensure there is only one unmapping for the same pointer.
28776 */
28777 -void iounmap(volatile void __iomem *addr)
28778 +void iounmap(const volatile void __iomem *addr)
28779 {
28780 struct vm_struct *p, *o;
28781
28782 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28783
28784 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28785 if (page_is_ram(start >> PAGE_SHIFT))
28786 +#ifdef CONFIG_HIGHMEM
28787 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28788 +#endif
28789 return __va(phys);
28790
28791 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28792 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28793 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28794 {
28795 if (page_is_ram(phys >> PAGE_SHIFT))
28796 +#ifdef CONFIG_HIGHMEM
28797 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28798 +#endif
28799 return;
28800
28801 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28802 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
28803 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28804
28805 static __initdata int after_paging_init;
28806 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28807 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28808
28809 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28810 {
28811 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
28812 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28813
28814 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28815 - memset(bm_pte, 0, sizeof(bm_pte));
28816 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28817 + pmd_populate_user(&init_mm, pmd, bm_pte);
28818
28819 /*
28820 * The boot-ioremap range spans multiple pmds, for which
28821 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28822 index d87dd6d..bf3fa66 100644
28823 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28824 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28825 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28826 * memory (e.g. tracked pages)? For now, we need this to avoid
28827 * invoking kmemcheck for PnP BIOS calls.
28828 */
28829 - if (regs->flags & X86_VM_MASK)
28830 + if (v8086_mode(regs))
28831 return false;
28832 - if (regs->cs != __KERNEL_CS)
28833 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28834 return false;
28835
28836 pte = kmemcheck_pte_lookup(address);
28837 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28838 index 845df68..1d8d29f 100644
28839 --- a/arch/x86/mm/mmap.c
28840 +++ b/arch/x86/mm/mmap.c
28841 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28842 * Leave an at least ~128 MB hole with possible stack randomization.
28843 */
28844 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28845 -#define MAX_GAP (TASK_SIZE/6*5)
28846 +#define MAX_GAP (pax_task_size/6*5)
28847
28848 static int mmap_is_legacy(void)
28849 {
28850 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28851 return rnd << PAGE_SHIFT;
28852 }
28853
28854 -static unsigned long mmap_base(void)
28855 +static unsigned long mmap_base(struct mm_struct *mm)
28856 {
28857 unsigned long gap = rlimit(RLIMIT_STACK);
28858 + unsigned long pax_task_size = TASK_SIZE;
28859 +
28860 +#ifdef CONFIG_PAX_SEGMEXEC
28861 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28862 + pax_task_size = SEGMEXEC_TASK_SIZE;
28863 +#endif
28864
28865 if (gap < MIN_GAP)
28866 gap = MIN_GAP;
28867 else if (gap > MAX_GAP)
28868 gap = MAX_GAP;
28869
28870 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28871 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28872 }
28873
28874 /*
28875 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28876 * does, but not when emulating X86_32
28877 */
28878 -static unsigned long mmap_legacy_base(void)
28879 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28880 {
28881 - if (mmap_is_ia32())
28882 + if (mmap_is_ia32()) {
28883 +
28884 +#ifdef CONFIG_PAX_SEGMEXEC
28885 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28886 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28887 + else
28888 +#endif
28889 +
28890 return TASK_UNMAPPED_BASE;
28891 - else
28892 + } else
28893 return TASK_UNMAPPED_BASE + mmap_rnd();
28894 }
28895
28896 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28897 void arch_pick_mmap_layout(struct mm_struct *mm)
28898 {
28899 if (mmap_is_legacy()) {
28900 - mm->mmap_base = mmap_legacy_base();
28901 + mm->mmap_base = mmap_legacy_base(mm);
28902 +
28903 +#ifdef CONFIG_PAX_RANDMMAP
28904 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28905 + mm->mmap_base += mm->delta_mmap;
28906 +#endif
28907 +
28908 mm->get_unmapped_area = arch_get_unmapped_area;
28909 mm->unmap_area = arch_unmap_area;
28910 } else {
28911 - mm->mmap_base = mmap_base();
28912 + mm->mmap_base = mmap_base(mm);
28913 +
28914 +#ifdef CONFIG_PAX_RANDMMAP
28915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28916 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28917 +#endif
28918 +
28919 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28920 mm->unmap_area = arch_unmap_area_topdown;
28921 }
28922 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28923 index dc0b727..f612039 100644
28924 --- a/arch/x86/mm/mmio-mod.c
28925 +++ b/arch/x86/mm/mmio-mod.c
28926 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28927 break;
28928 default:
28929 {
28930 - unsigned char *ip = (unsigned char *)instptr;
28931 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28932 my_trace->opcode = MMIO_UNKNOWN_OP;
28933 my_trace->width = 0;
28934 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28935 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28936 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28937 void __iomem *addr)
28938 {
28939 - static atomic_t next_id;
28940 + static atomic_unchecked_t next_id;
28941 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28942 /* These are page-unaligned. */
28943 struct mmiotrace_map map = {
28944 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28945 .private = trace
28946 },
28947 .phys = offset,
28948 - .id = atomic_inc_return(&next_id)
28949 + .id = atomic_inc_return_unchecked(&next_id)
28950 };
28951 map.map_id = trace->id;
28952
28953 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28954 ioremap_trace_core(offset, size, addr);
28955 }
28956
28957 -static void iounmap_trace_core(volatile void __iomem *addr)
28958 +static void iounmap_trace_core(const volatile void __iomem *addr)
28959 {
28960 struct mmiotrace_map map = {
28961 .phys = 0,
28962 @@ -328,7 +328,7 @@ not_enabled:
28963 }
28964 }
28965
28966 -void mmiotrace_iounmap(volatile void __iomem *addr)
28967 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28968 {
28969 might_sleep();
28970 if (is_enabled()) /* recheck and proper locking in *_core() */
28971 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28972 index a71c4e2..301ae44 100644
28973 --- a/arch/x86/mm/numa.c
28974 +++ b/arch/x86/mm/numa.c
28975 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28976 return true;
28977 }
28978
28979 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28980 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28981 {
28982 unsigned long uninitialized_var(pfn_align);
28983 int i, nid;
28984 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28985 index d0b1773..4c3327c 100644
28986 --- a/arch/x86/mm/pageattr-test.c
28987 +++ b/arch/x86/mm/pageattr-test.c
28988 @@ -36,7 +36,7 @@ enum {
28989
28990 static int pte_testbit(pte_t pte)
28991 {
28992 - return pte_flags(pte) & _PAGE_UNUSED1;
28993 + return pte_flags(pte) & _PAGE_CPA_TEST;
28994 }
28995
28996 struct split_state {
28997 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28998 index bb32480..aef8278 100644
28999 --- a/arch/x86/mm/pageattr.c
29000 +++ b/arch/x86/mm/pageattr.c
29001 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29002 */
29003 #ifdef CONFIG_PCI_BIOS
29004 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29005 - pgprot_val(forbidden) |= _PAGE_NX;
29006 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29007 #endif
29008
29009 /*
29010 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29011 * Does not cover __inittext since that is gone later on. On
29012 * 64bit we do not enforce !NX on the low mapping
29013 */
29014 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29015 - pgprot_val(forbidden) |= _PAGE_NX;
29016 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29017 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29018
29019 +#ifdef CONFIG_DEBUG_RODATA
29020 /*
29021 * The .rodata section needs to be read-only. Using the pfn
29022 * catches all aliases.
29023 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29024 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
29025 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
29026 pgprot_val(forbidden) |= _PAGE_RW;
29027 +#endif
29028
29029 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29030 /*
29031 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29032 }
29033 #endif
29034
29035 +#ifdef CONFIG_PAX_KERNEXEC
29036 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29037 + pgprot_val(forbidden) |= _PAGE_RW;
29038 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29039 + }
29040 +#endif
29041 +
29042 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29043
29044 return prot;
29045 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
29046 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29047 {
29048 /* change init_mm */
29049 + pax_open_kernel();
29050 set_pte_atomic(kpte, pte);
29051 +
29052 #ifdef CONFIG_X86_32
29053 if (!SHARED_KERNEL_PMD) {
29054 +
29055 +#ifdef CONFIG_PAX_PER_CPU_PGD
29056 + unsigned long cpu;
29057 +#else
29058 struct page *page;
29059 +#endif
29060
29061 +#ifdef CONFIG_PAX_PER_CPU_PGD
29062 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29063 + pgd_t *pgd = get_cpu_pgd(cpu);
29064 +#else
29065 list_for_each_entry(page, &pgd_list, lru) {
29066 - pgd_t *pgd;
29067 + pgd_t *pgd = (pgd_t *)page_address(page);
29068 +#endif
29069 +
29070 pud_t *pud;
29071 pmd_t *pmd;
29072
29073 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29074 + pgd += pgd_index(address);
29075 pud = pud_offset(pgd, address);
29076 pmd = pmd_offset(pud, address);
29077 set_pte_atomic((pte_t *)pmd, pte);
29078 }
29079 }
29080 #endif
29081 + pax_close_kernel();
29082 }
29083
29084 static int
29085 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29086 index 6574388..87e9bef 100644
29087 --- a/arch/x86/mm/pat.c
29088 +++ b/arch/x86/mm/pat.c
29089 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29090
29091 if (!entry) {
29092 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29093 - current->comm, current->pid, start, end - 1);
29094 + current->comm, task_pid_nr(current), start, end - 1);
29095 return -EINVAL;
29096 }
29097
29098 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29099
29100 while (cursor < to) {
29101 if (!devmem_is_allowed(pfn)) {
29102 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29103 - current->comm, from, to - 1);
29104 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29105 + current->comm, from, to - 1, cursor);
29106 return 0;
29107 }
29108 cursor += PAGE_SIZE;
29109 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29110 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29111 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29112 "for [mem %#010Lx-%#010Lx]\n",
29113 - current->comm, current->pid,
29114 + current->comm, task_pid_nr(current),
29115 cattr_name(flags),
29116 base, (unsigned long long)(base + size-1));
29117 return -EINVAL;
29118 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29119 flags = lookup_memtype(paddr);
29120 if (want_flags != flags) {
29121 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29122 - current->comm, current->pid,
29123 + current->comm, task_pid_nr(current),
29124 cattr_name(want_flags),
29125 (unsigned long long)paddr,
29126 (unsigned long long)(paddr + size - 1),
29127 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29128 free_memtype(paddr, paddr + size);
29129 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29130 " for [mem %#010Lx-%#010Lx], got %s\n",
29131 - current->comm, current->pid,
29132 + current->comm, task_pid_nr(current),
29133 cattr_name(want_flags),
29134 (unsigned long long)paddr,
29135 (unsigned long long)(paddr + size - 1),
29136 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
29137 index 415f6c4..d319983 100644
29138 --- a/arch/x86/mm/pat_rbtree.c
29139 +++ b/arch/x86/mm/pat_rbtree.c
29140 @@ -160,7 +160,7 @@ success:
29141
29142 failure:
29143 printk(KERN_INFO "%s:%d conflicting memory types "
29144 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
29145 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
29146 end, cattr_name(found_type), cattr_name(match->type));
29147 return -EBUSY;
29148 }
29149 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29150 index 9f0614d..92ae64a 100644
29151 --- a/arch/x86/mm/pf_in.c
29152 +++ b/arch/x86/mm/pf_in.c
29153 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29154 int i;
29155 enum reason_type rv = OTHERS;
29156
29157 - p = (unsigned char *)ins_addr;
29158 + p = (unsigned char *)ktla_ktva(ins_addr);
29159 p += skip_prefix(p, &prf);
29160 p += get_opcode(p, &opcode);
29161
29162 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29163 struct prefix_bits prf;
29164 int i;
29165
29166 - p = (unsigned char *)ins_addr;
29167 + p = (unsigned char *)ktla_ktva(ins_addr);
29168 p += skip_prefix(p, &prf);
29169 p += get_opcode(p, &opcode);
29170
29171 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29172 struct prefix_bits prf;
29173 int i;
29174
29175 - p = (unsigned char *)ins_addr;
29176 + p = (unsigned char *)ktla_ktva(ins_addr);
29177 p += skip_prefix(p, &prf);
29178 p += get_opcode(p, &opcode);
29179
29180 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29181 struct prefix_bits prf;
29182 int i;
29183
29184 - p = (unsigned char *)ins_addr;
29185 + p = (unsigned char *)ktla_ktva(ins_addr);
29186 p += skip_prefix(p, &prf);
29187 p += get_opcode(p, &opcode);
29188 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29189 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29190 struct prefix_bits prf;
29191 int i;
29192
29193 - p = (unsigned char *)ins_addr;
29194 + p = (unsigned char *)ktla_ktva(ins_addr);
29195 p += skip_prefix(p, &prf);
29196 p += get_opcode(p, &opcode);
29197 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29198 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29199 index 17fda6a..489c74a 100644
29200 --- a/arch/x86/mm/pgtable.c
29201 +++ b/arch/x86/mm/pgtable.c
29202 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29203 list_del(&page->lru);
29204 }
29205
29206 -#define UNSHARED_PTRS_PER_PGD \
29207 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29208 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29209 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29210
29211 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29212 +{
29213 + unsigned int count = USER_PGD_PTRS;
29214
29215 + while (count--)
29216 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29217 +}
29218 +#endif
29219 +
29220 +#ifdef CONFIG_PAX_PER_CPU_PGD
29221 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29222 +{
29223 + unsigned int count = USER_PGD_PTRS;
29224 +
29225 + while (count--) {
29226 + pgd_t pgd;
29227 +
29228 +#ifdef CONFIG_X86_64
29229 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29230 +#else
29231 + pgd = *src++;
29232 +#endif
29233 +
29234 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29235 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29236 +#endif
29237 +
29238 + *dst++ = pgd;
29239 + }
29240 +
29241 +}
29242 +#endif
29243 +
29244 +#ifdef CONFIG_X86_64
29245 +#define pxd_t pud_t
29246 +#define pyd_t pgd_t
29247 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29248 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29249 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29250 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29251 +#define PYD_SIZE PGDIR_SIZE
29252 +#else
29253 +#define pxd_t pmd_t
29254 +#define pyd_t pud_t
29255 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29256 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29257 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29258 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29259 +#define PYD_SIZE PUD_SIZE
29260 +#endif
29261 +
29262 +#ifdef CONFIG_PAX_PER_CPU_PGD
29263 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29264 +static inline void pgd_dtor(pgd_t *pgd) {}
29265 +#else
29266 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29267 {
29268 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29269 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29270 pgd_list_del(pgd);
29271 spin_unlock(&pgd_lock);
29272 }
29273 +#endif
29274
29275 /*
29276 * List of all pgd's needed for non-PAE so it can invalidate entries
29277 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29278 * -- nyc
29279 */
29280
29281 -#ifdef CONFIG_X86_PAE
29282 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29283 /*
29284 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29285 * updating the top-level pagetable entries to guarantee the
29286 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29287 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29288 * and initialize the kernel pmds here.
29289 */
29290 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29291 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29292
29293 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29294 {
29295 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29296 */
29297 flush_tlb_mm(mm);
29298 }
29299 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29300 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29301 #else /* !CONFIG_X86_PAE */
29302
29303 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29304 -#define PREALLOCATED_PMDS 0
29305 +#define PREALLOCATED_PXDS 0
29306
29307 #endif /* CONFIG_X86_PAE */
29308
29309 -static void free_pmds(pmd_t *pmds[])
29310 +static void free_pxds(pxd_t *pxds[])
29311 {
29312 int i;
29313
29314 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29315 - if (pmds[i])
29316 - free_page((unsigned long)pmds[i]);
29317 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29318 + if (pxds[i])
29319 + free_page((unsigned long)pxds[i]);
29320 }
29321
29322 -static int preallocate_pmds(pmd_t *pmds[])
29323 +static int preallocate_pxds(pxd_t *pxds[])
29324 {
29325 int i;
29326 bool failed = false;
29327
29328 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29329 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29330 - if (pmd == NULL)
29331 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29332 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29333 + if (pxd == NULL)
29334 failed = true;
29335 - pmds[i] = pmd;
29336 + pxds[i] = pxd;
29337 }
29338
29339 if (failed) {
29340 - free_pmds(pmds);
29341 + free_pxds(pxds);
29342 return -ENOMEM;
29343 }
29344
29345 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29346 * preallocate which never got a corresponding vma will need to be
29347 * freed manually.
29348 */
29349 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29350 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29351 {
29352 int i;
29353
29354 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29355 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29356 pgd_t pgd = pgdp[i];
29357
29358 if (pgd_val(pgd) != 0) {
29359 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29360 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29361
29362 - pgdp[i] = native_make_pgd(0);
29363 + set_pgd(pgdp + i, native_make_pgd(0));
29364
29365 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29366 - pmd_free(mm, pmd);
29367 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29368 + pxd_free(mm, pxd);
29369 }
29370 }
29371 }
29372
29373 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29374 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29375 {
29376 - pud_t *pud;
29377 + pyd_t *pyd;
29378 unsigned long addr;
29379 int i;
29380
29381 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29382 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29383 return;
29384
29385 - pud = pud_offset(pgd, 0);
29386 +#ifdef CONFIG_X86_64
29387 + pyd = pyd_offset(mm, 0L);
29388 +#else
29389 + pyd = pyd_offset(pgd, 0L);
29390 +#endif
29391
29392 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29393 - i++, pud++, addr += PUD_SIZE) {
29394 - pmd_t *pmd = pmds[i];
29395 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29396 + i++, pyd++, addr += PYD_SIZE) {
29397 + pxd_t *pxd = pxds[i];
29398
29399 if (i >= KERNEL_PGD_BOUNDARY)
29400 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29401 - sizeof(pmd_t) * PTRS_PER_PMD);
29402 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29403 + sizeof(pxd_t) * PTRS_PER_PMD);
29404
29405 - pud_populate(mm, pud, pmd);
29406 + pyd_populate(mm, pyd, pxd);
29407 }
29408 }
29409
29410 pgd_t *pgd_alloc(struct mm_struct *mm)
29411 {
29412 pgd_t *pgd;
29413 - pmd_t *pmds[PREALLOCATED_PMDS];
29414 + pxd_t *pxds[PREALLOCATED_PXDS];
29415
29416 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29417
29418 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29419
29420 mm->pgd = pgd;
29421
29422 - if (preallocate_pmds(pmds) != 0)
29423 + if (preallocate_pxds(pxds) != 0)
29424 goto out_free_pgd;
29425
29426 if (paravirt_pgd_alloc(mm) != 0)
29427 - goto out_free_pmds;
29428 + goto out_free_pxds;
29429
29430 /*
29431 * Make sure that pre-populating the pmds is atomic with
29432 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29433 spin_lock(&pgd_lock);
29434
29435 pgd_ctor(mm, pgd);
29436 - pgd_prepopulate_pmd(mm, pgd, pmds);
29437 + pgd_prepopulate_pxd(mm, pgd, pxds);
29438
29439 spin_unlock(&pgd_lock);
29440
29441 return pgd;
29442
29443 -out_free_pmds:
29444 - free_pmds(pmds);
29445 +out_free_pxds:
29446 + free_pxds(pxds);
29447 out_free_pgd:
29448 free_page((unsigned long)pgd);
29449 out:
29450 @@ -302,7 +363,7 @@ out:
29451
29452 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29453 {
29454 - pgd_mop_up_pmds(mm, pgd);
29455 + pgd_mop_up_pxds(mm, pgd);
29456 pgd_dtor(pgd);
29457 paravirt_pgd_free(mm, pgd);
29458 free_page((unsigned long)pgd);
29459 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29460 index a69bcb8..19068ab 100644
29461 --- a/arch/x86/mm/pgtable_32.c
29462 +++ b/arch/x86/mm/pgtable_32.c
29463 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29464 return;
29465 }
29466 pte = pte_offset_kernel(pmd, vaddr);
29467 +
29468 + pax_open_kernel();
29469 if (pte_val(pteval))
29470 set_pte_at(&init_mm, vaddr, pte, pteval);
29471 else
29472 pte_clear(&init_mm, vaddr, pte);
29473 + pax_close_kernel();
29474
29475 /*
29476 * It's enough to flush this one mapping.
29477 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29478 index e666cbb..61788c45 100644
29479 --- a/arch/x86/mm/physaddr.c
29480 +++ b/arch/x86/mm/physaddr.c
29481 @@ -10,7 +10,7 @@
29482 #ifdef CONFIG_X86_64
29483
29484 #ifdef CONFIG_DEBUG_VIRTUAL
29485 -unsigned long __phys_addr(unsigned long x)
29486 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29487 {
29488 unsigned long y = x - __START_KERNEL_map;
29489
29490 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29491 #else
29492
29493 #ifdef CONFIG_DEBUG_VIRTUAL
29494 -unsigned long __phys_addr(unsigned long x)
29495 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29496 {
29497 unsigned long phys_addr = x - PAGE_OFFSET;
29498 /* VMALLOC_* aren't constants */
29499 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29500 index 410531d..0f16030 100644
29501 --- a/arch/x86/mm/setup_nx.c
29502 +++ b/arch/x86/mm/setup_nx.c
29503 @@ -5,8 +5,10 @@
29504 #include <asm/pgtable.h>
29505 #include <asm/proto.h>
29506
29507 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29508 static int disable_nx __cpuinitdata;
29509
29510 +#ifndef CONFIG_PAX_PAGEEXEC
29511 /*
29512 * noexec = on|off
29513 *
29514 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29515 return 0;
29516 }
29517 early_param("noexec", noexec_setup);
29518 +#endif
29519 +
29520 +#endif
29521
29522 void __cpuinit x86_configure_nx(void)
29523 {
29524 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29525 if (cpu_has_nx && !disable_nx)
29526 __supported_pte_mask |= _PAGE_NX;
29527 else
29528 +#endif
29529 __supported_pte_mask &= ~_PAGE_NX;
29530 }
29531
29532 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29533 index 282375f..e03a98f 100644
29534 --- a/arch/x86/mm/tlb.c
29535 +++ b/arch/x86/mm/tlb.c
29536 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29537 BUG();
29538 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29539 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29540 +
29541 +#ifndef CONFIG_PAX_PER_CPU_PGD
29542 load_cr3(swapper_pg_dir);
29543 +#endif
29544 +
29545 }
29546 }
29547 EXPORT_SYMBOL_GPL(leave_mm);
29548 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29549 index 877b9a1..a8ecf42 100644
29550 --- a/arch/x86/net/bpf_jit.S
29551 +++ b/arch/x86/net/bpf_jit.S
29552 @@ -9,6 +9,7 @@
29553 */
29554 #include <linux/linkage.h>
29555 #include <asm/dwarf2.h>
29556 +#include <asm/alternative-asm.h>
29557
29558 /*
29559 * Calling convention :
29560 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29561 jle bpf_slow_path_word
29562 mov (SKBDATA,%rsi),%eax
29563 bswap %eax /* ntohl() */
29564 + pax_force_retaddr
29565 ret
29566
29567 sk_load_half:
29568 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29569 jle bpf_slow_path_half
29570 movzwl (SKBDATA,%rsi),%eax
29571 rol $8,%ax # ntohs()
29572 + pax_force_retaddr
29573 ret
29574
29575 sk_load_byte:
29576 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29577 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29578 jle bpf_slow_path_byte
29579 movzbl (SKBDATA,%rsi),%eax
29580 + pax_force_retaddr
29581 ret
29582
29583 /**
29584 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29585 movzbl (SKBDATA,%rsi),%ebx
29586 and $15,%bl
29587 shl $2,%bl
29588 + pax_force_retaddr
29589 ret
29590
29591 /* rsi contains offset and can be scratched */
29592 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29593 js bpf_error
29594 mov -12(%rbp),%eax
29595 bswap %eax
29596 + pax_force_retaddr
29597 ret
29598
29599 bpf_slow_path_half:
29600 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29601 mov -12(%rbp),%ax
29602 rol $8,%ax
29603 movzwl %ax,%eax
29604 + pax_force_retaddr
29605 ret
29606
29607 bpf_slow_path_byte:
29608 bpf_slow_path_common(1)
29609 js bpf_error
29610 movzbl -12(%rbp),%eax
29611 + pax_force_retaddr
29612 ret
29613
29614 bpf_slow_path_byte_msh:
29615 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29616 and $15,%al
29617 shl $2,%al
29618 xchg %eax,%ebx
29619 + pax_force_retaddr
29620 ret
29621
29622 #define sk_negative_common(SIZE) \
29623 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29624 sk_negative_common(4)
29625 mov (%rax), %eax
29626 bswap %eax
29627 + pax_force_retaddr
29628 ret
29629
29630 bpf_slow_path_half_neg:
29631 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29632 mov (%rax),%ax
29633 rol $8,%ax
29634 movzwl %ax,%eax
29635 + pax_force_retaddr
29636 ret
29637
29638 bpf_slow_path_byte_neg:
29639 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29640 .globl sk_load_byte_negative_offset
29641 sk_negative_common(1)
29642 movzbl (%rax), %eax
29643 + pax_force_retaddr
29644 ret
29645
29646 bpf_slow_path_byte_msh_neg:
29647 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29648 and $15,%al
29649 shl $2,%al
29650 xchg %eax,%ebx
29651 + pax_force_retaddr
29652 ret
29653
29654 bpf_error:
29655 @@ -197,4 +210,5 @@ bpf_error:
29656 xor %eax,%eax
29657 mov -8(%rbp),%rbx
29658 leaveq
29659 + pax_force_retaddr
29660 ret
29661 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29662 index f66b540..3e88dfb 100644
29663 --- a/arch/x86/net/bpf_jit_comp.c
29664 +++ b/arch/x86/net/bpf_jit_comp.c
29665 @@ -12,6 +12,7 @@
29666 #include <linux/netdevice.h>
29667 #include <linux/filter.h>
29668 #include <linux/if_vlan.h>
29669 +#include <linux/random.h>
29670
29671 /*
29672 * Conventions :
29673 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29674 return ptr + len;
29675 }
29676
29677 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29678 +#define MAX_INSTR_CODE_SIZE 96
29679 +#else
29680 +#define MAX_INSTR_CODE_SIZE 64
29681 +#endif
29682 +
29683 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29684
29685 #define EMIT1(b1) EMIT(b1, 1)
29686 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29687 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29688 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29689 +
29690 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29691 +/* original constant will appear in ecx */
29692 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29693 +do { \
29694 + /* mov ecx, randkey */ \
29695 + EMIT1(0xb9); \
29696 + EMIT(_key, 4); \
29697 + /* xor ecx, randkey ^ off */ \
29698 + EMIT2(0x81, 0xf1); \
29699 + EMIT((_key) ^ (_off), 4); \
29700 +} while (0)
29701 +
29702 +#define EMIT1_off32(b1, _off) \
29703 +do { \
29704 + switch (b1) { \
29705 + case 0x05: /* add eax, imm32 */ \
29706 + case 0x2d: /* sub eax, imm32 */ \
29707 + case 0x25: /* and eax, imm32 */ \
29708 + case 0x0d: /* or eax, imm32 */ \
29709 + case 0xb8: /* mov eax, imm32 */ \
29710 + case 0x35: /* xor eax, imm32 */ \
29711 + case 0x3d: /* cmp eax, imm32 */ \
29712 + case 0xa9: /* test eax, imm32 */ \
29713 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29714 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29715 + break; \
29716 + case 0xbb: /* mov ebx, imm32 */ \
29717 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29718 + /* mov ebx, ecx */ \
29719 + EMIT2(0x89, 0xcb); \
29720 + break; \
29721 + case 0xbe: /* mov esi, imm32 */ \
29722 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29723 + /* mov esi, ecx */ \
29724 + EMIT2(0x89, 0xce); \
29725 + break; \
29726 + case 0xe8: /* call rel imm32, always to known funcs */ \
29727 + EMIT1(b1); \
29728 + EMIT(_off, 4); \
29729 + break; \
29730 + case 0xe9: /* jmp rel imm32 */ \
29731 + EMIT1(b1); \
29732 + EMIT(_off, 4); \
29733 + /* prevent fall-through, we're not called if off = 0 */ \
29734 + EMIT(0xcccccccc, 4); \
29735 + EMIT(0xcccccccc, 4); \
29736 + break; \
29737 + default: \
29738 + BUILD_BUG(); \
29739 + } \
29740 +} while (0)
29741 +
29742 +#define EMIT2_off32(b1, b2, _off) \
29743 +do { \
29744 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29745 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29746 + EMIT(randkey, 4); \
29747 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29748 + EMIT((_off) - randkey, 4); \
29749 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29750 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29751 + /* imul eax, ecx */ \
29752 + EMIT3(0x0f, 0xaf, 0xc1); \
29753 + } else { \
29754 + BUILD_BUG(); \
29755 + } \
29756 +} while (0)
29757 +#else
29758 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29759 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29760 +#endif
29761
29762 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29763 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29764 @@ -90,6 +168,24 @@ do { \
29765 #define X86_JBE 0x76
29766 #define X86_JA 0x77
29767
29768 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29769 +#define APPEND_FLOW_VERIFY() \
29770 +do { \
29771 + /* mov ecx, randkey */ \
29772 + EMIT1(0xb9); \
29773 + EMIT(randkey, 4); \
29774 + /* cmp ecx, randkey */ \
29775 + EMIT2(0x81, 0xf9); \
29776 + EMIT(randkey, 4); \
29777 + /* jz after 8 int 3s */ \
29778 + EMIT2(0x74, 0x08); \
29779 + EMIT(0xcccccccc, 4); \
29780 + EMIT(0xcccccccc, 4); \
29781 +} while (0)
29782 +#else
29783 +#define APPEND_FLOW_VERIFY() do { } while (0)
29784 +#endif
29785 +
29786 #define EMIT_COND_JMP(op, offset) \
29787 do { \
29788 if (is_near(offset)) \
29789 @@ -97,6 +193,7 @@ do { \
29790 else { \
29791 EMIT2(0x0f, op + 0x10); \
29792 EMIT(offset, 4); /* jxx .+off32 */ \
29793 + APPEND_FLOW_VERIFY(); \
29794 } \
29795 } while (0)
29796
29797 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29798 set_fs(old_fs);
29799 }
29800
29801 +struct bpf_jit_work {
29802 + struct work_struct work;
29803 + void *image;
29804 +};
29805 +
29806 #define CHOOSE_LOAD_FUNC(K, func) \
29807 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29808
29809 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29810
29811 void bpf_jit_compile(struct sk_filter *fp)
29812 {
29813 - u8 temp[64];
29814 + u8 temp[MAX_INSTR_CODE_SIZE];
29815 u8 *prog;
29816 unsigned int proglen, oldproglen = 0;
29817 int ilen, i;
29818 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29819 unsigned int *addrs;
29820 const struct sock_filter *filter = fp->insns;
29821 int flen = fp->len;
29822 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29823 + unsigned int randkey;
29824 +#endif
29825
29826 if (!bpf_jit_enable)
29827 return;
29828 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29829 if (addrs == NULL)
29830 return;
29831
29832 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29833 + if (!fp->work)
29834 + goto out;
29835 +
29836 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29837 + randkey = get_random_int();
29838 +#endif
29839 +
29840 /* Before first pass, make a rough estimation of addrs[]
29841 - * each bpf instruction is translated to less than 64 bytes
29842 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29843 */
29844 for (proglen = 0, i = 0; i < flen; i++) {
29845 - proglen += 64;
29846 + proglen += MAX_INSTR_CODE_SIZE;
29847 addrs[i] = proglen;
29848 }
29849 cleanup_addr = proglen; /* epilogue address */
29850 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29851 case BPF_S_ALU_MUL_K: /* A *= K */
29852 if (is_imm8(K))
29853 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29854 - else {
29855 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29856 - EMIT(K, 4);
29857 - }
29858 + else
29859 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29860 break;
29861 case BPF_S_ALU_DIV_X: /* A /= X; */
29862 seen |= SEEN_XREG;
29863 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29864 break;
29865 case BPF_S_ALU_MOD_K: /* A %= K; */
29866 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29867 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29868 + DILUTE_CONST_SEQUENCE(K, randkey);
29869 +#else
29870 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29871 +#endif
29872 EMIT2(0xf7, 0xf1); /* div %ecx */
29873 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29874 break;
29875 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29876 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29877 + DILUTE_CONST_SEQUENCE(K, randkey);
29878 + // imul rax, rcx
29879 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29880 +#else
29881 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29882 EMIT(K, 4);
29883 +#endif
29884 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29885 break;
29886 case BPF_S_ALU_AND_X:
29887 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29888 if (is_imm8(K)) {
29889 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29890 } else {
29891 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29892 - EMIT(K, 4);
29893 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29894 }
29895 } else {
29896 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29897 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29898 break;
29899 default:
29900 /* hmm, too complex filter, give up with jit compiler */
29901 - goto out;
29902 + goto error;
29903 }
29904 ilen = prog - temp;
29905 if (image) {
29906 if (unlikely(proglen + ilen > oldproglen)) {
29907 pr_err("bpb_jit_compile fatal error\n");
29908 - kfree(addrs);
29909 - module_free(NULL, image);
29910 - return;
29911 + module_free_exec(NULL, image);
29912 + goto error;
29913 }
29914 + pax_open_kernel();
29915 memcpy(image + proglen, temp, ilen);
29916 + pax_close_kernel();
29917 }
29918 proglen += ilen;
29919 addrs[i] = proglen;
29920 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29921 break;
29922 }
29923 if (proglen == oldproglen) {
29924 - image = module_alloc(max_t(unsigned int,
29925 - proglen,
29926 - sizeof(struct work_struct)));
29927 + image = module_alloc_exec(proglen);
29928 if (!image)
29929 - goto out;
29930 + goto error;
29931 }
29932 oldproglen = proglen;
29933 }
29934 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29935 if (image) {
29936 bpf_flush_icache(image, image + proglen);
29937 fp->bpf_func = (void *)image;
29938 - }
29939 + } else
29940 +error:
29941 + kfree(fp->work);
29942 +
29943 out:
29944 kfree(addrs);
29945 return;
29946 @@ -740,18 +862,20 @@ out:
29947
29948 static void jit_free_defer(struct work_struct *arg)
29949 {
29950 - module_free(NULL, arg);
29951 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29952 + kfree(arg);
29953 }
29954
29955 /* run from softirq, we must use a work_struct to call
29956 - * module_free() from process context
29957 + * module_free_exec() from process context
29958 */
29959 void bpf_jit_free(struct sk_filter *fp)
29960 {
29961 if (fp->bpf_func != sk_run_filter) {
29962 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29963 + struct work_struct *work = &fp->work->work;
29964
29965 INIT_WORK(work, jit_free_defer);
29966 + fp->work->image = fp->bpf_func;
29967 schedule_work(work);
29968 }
29969 }
29970 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29971 index d6aa6e8..266395a 100644
29972 --- a/arch/x86/oprofile/backtrace.c
29973 +++ b/arch/x86/oprofile/backtrace.c
29974 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29975 struct stack_frame_ia32 *fp;
29976 unsigned long bytes;
29977
29978 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29979 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29980 if (bytes != sizeof(bufhead))
29981 return NULL;
29982
29983 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29984 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29985
29986 oprofile_add_trace(bufhead[0].return_address);
29987
29988 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29989 struct stack_frame bufhead[2];
29990 unsigned long bytes;
29991
29992 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29993 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29994 if (bytes != sizeof(bufhead))
29995 return NULL;
29996
29997 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29998 {
29999 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30000
30001 - if (!user_mode_vm(regs)) {
30002 + if (!user_mode(regs)) {
30003 unsigned long stack = kernel_stack_pointer(regs);
30004 if (depth)
30005 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30006 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30007 index 48768df..ba9143c 100644
30008 --- a/arch/x86/oprofile/nmi_int.c
30009 +++ b/arch/x86/oprofile/nmi_int.c
30010 @@ -23,6 +23,7 @@
30011 #include <asm/nmi.h>
30012 #include <asm/msr.h>
30013 #include <asm/apic.h>
30014 +#include <asm/pgtable.h>
30015
30016 #include "op_counter.h"
30017 #include "op_x86_model.h"
30018 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30019 if (ret)
30020 return ret;
30021
30022 - if (!model->num_virt_counters)
30023 - model->num_virt_counters = model->num_counters;
30024 + if (!model->num_virt_counters) {
30025 + pax_open_kernel();
30026 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30027 + pax_close_kernel();
30028 + }
30029
30030 mux_init(ops);
30031
30032 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30033 index b2b9443..be58856 100644
30034 --- a/arch/x86/oprofile/op_model_amd.c
30035 +++ b/arch/x86/oprofile/op_model_amd.c
30036 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30037 num_counters = AMD64_NUM_COUNTERS;
30038 }
30039
30040 - op_amd_spec.num_counters = num_counters;
30041 - op_amd_spec.num_controls = num_counters;
30042 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30043 + pax_open_kernel();
30044 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30045 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30046 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30047 + pax_close_kernel();
30048
30049 return 0;
30050 }
30051 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30052 index d90528e..0127e2b 100644
30053 --- a/arch/x86/oprofile/op_model_ppro.c
30054 +++ b/arch/x86/oprofile/op_model_ppro.c
30055 @@ -19,6 +19,7 @@
30056 #include <asm/msr.h>
30057 #include <asm/apic.h>
30058 #include <asm/nmi.h>
30059 +#include <asm/pgtable.h>
30060
30061 #include "op_x86_model.h"
30062 #include "op_counter.h"
30063 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30064
30065 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30066
30067 - op_arch_perfmon_spec.num_counters = num_counters;
30068 - op_arch_perfmon_spec.num_controls = num_counters;
30069 + pax_open_kernel();
30070 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30071 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30072 + pax_close_kernel();
30073 }
30074
30075 static int arch_perfmon_init(struct oprofile_operations *ignore)
30076 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30077 index 71e8a67..6a313bb 100644
30078 --- a/arch/x86/oprofile/op_x86_model.h
30079 +++ b/arch/x86/oprofile/op_x86_model.h
30080 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30081 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30082 struct op_msrs const * const msrs);
30083 #endif
30084 -};
30085 +} __do_const;
30086
30087 struct op_counter_config;
30088
30089 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30090 index e9e6ed5..e47ae67 100644
30091 --- a/arch/x86/pci/amd_bus.c
30092 +++ b/arch/x86/pci/amd_bus.c
30093 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30094 return NOTIFY_OK;
30095 }
30096
30097 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30098 +static struct notifier_block amd_cpu_notifier = {
30099 .notifier_call = amd_cpu_notify,
30100 };
30101
30102 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30103 index 372e9b8..e775a6c 100644
30104 --- a/arch/x86/pci/irq.c
30105 +++ b/arch/x86/pci/irq.c
30106 @@ -50,7 +50,7 @@ struct irq_router {
30107 struct irq_router_handler {
30108 u16 vendor;
30109 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30110 -};
30111 +} __do_const;
30112
30113 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30114 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30115 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30116 return 0;
30117 }
30118
30119 -static __initdata struct irq_router_handler pirq_routers[] = {
30120 +static __initconst const struct irq_router_handler pirq_routers[] = {
30121 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30122 { PCI_VENDOR_ID_AL, ali_router_probe },
30123 { PCI_VENDOR_ID_ITE, ite_router_probe },
30124 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30125 static void __init pirq_find_router(struct irq_router *r)
30126 {
30127 struct irq_routing_table *rt = pirq_table;
30128 - struct irq_router_handler *h;
30129 + const struct irq_router_handler *h;
30130
30131 #ifdef CONFIG_PCI_BIOS
30132 if (!rt->signature) {
30133 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30134 return 0;
30135 }
30136
30137 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30138 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30139 {
30140 .callback = fix_broken_hp_bios_irq9,
30141 .ident = "HP Pavilion N5400 Series Laptop",
30142 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30143 index 6eb18c4..20d83de 100644
30144 --- a/arch/x86/pci/mrst.c
30145 +++ b/arch/x86/pci/mrst.c
30146 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30147 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30148 pci_mmcfg_late_init();
30149 pcibios_enable_irq = mrst_pci_irq_enable;
30150 - pci_root_ops = pci_mrst_ops;
30151 + pax_open_kernel();
30152 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30153 + pax_close_kernel();
30154 pci_soc_mode = 1;
30155 /* Continue with standard init */
30156 return 1;
30157 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30158 index c77b24a..c979855 100644
30159 --- a/arch/x86/pci/pcbios.c
30160 +++ b/arch/x86/pci/pcbios.c
30161 @@ -79,7 +79,7 @@ union bios32 {
30162 static struct {
30163 unsigned long address;
30164 unsigned short segment;
30165 -} bios32_indirect = { 0, __KERNEL_CS };
30166 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30167
30168 /*
30169 * Returns the entry point for the given service, NULL on error
30170 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30171 unsigned long length; /* %ecx */
30172 unsigned long entry; /* %edx */
30173 unsigned long flags;
30174 + struct desc_struct d, *gdt;
30175
30176 local_irq_save(flags);
30177 - __asm__("lcall *(%%edi); cld"
30178 +
30179 + gdt = get_cpu_gdt_table(smp_processor_id());
30180 +
30181 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30182 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30183 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30184 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30185 +
30186 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30187 : "=a" (return_code),
30188 "=b" (address),
30189 "=c" (length),
30190 "=d" (entry)
30191 : "0" (service),
30192 "1" (0),
30193 - "D" (&bios32_indirect));
30194 + "D" (&bios32_indirect),
30195 + "r"(__PCIBIOS_DS)
30196 + : "memory");
30197 +
30198 + pax_open_kernel();
30199 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30200 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30201 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30202 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30203 + pax_close_kernel();
30204 +
30205 local_irq_restore(flags);
30206
30207 switch (return_code) {
30208 - case 0:
30209 - return address + entry;
30210 - case 0x80: /* Not present */
30211 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30212 - return 0;
30213 - default: /* Shouldn't happen */
30214 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30215 - service, return_code);
30216 + case 0: {
30217 + int cpu;
30218 + unsigned char flags;
30219 +
30220 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30221 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30222 + printk(KERN_WARNING "bios32_service: not valid\n");
30223 return 0;
30224 + }
30225 + address = address + PAGE_OFFSET;
30226 + length += 16UL; /* some BIOSs underreport this... */
30227 + flags = 4;
30228 + if (length >= 64*1024*1024) {
30229 + length >>= PAGE_SHIFT;
30230 + flags |= 8;
30231 + }
30232 +
30233 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30234 + gdt = get_cpu_gdt_table(cpu);
30235 + pack_descriptor(&d, address, length, 0x9b, flags);
30236 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30237 + pack_descriptor(&d, address, length, 0x93, flags);
30238 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30239 + }
30240 + return entry;
30241 + }
30242 + case 0x80: /* Not present */
30243 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30244 + return 0;
30245 + default: /* Shouldn't happen */
30246 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30247 + service, return_code);
30248 + return 0;
30249 }
30250 }
30251
30252 static struct {
30253 unsigned long address;
30254 unsigned short segment;
30255 -} pci_indirect = { 0, __KERNEL_CS };
30256 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30257
30258 -static int pci_bios_present;
30259 +static int pci_bios_present __read_only;
30260
30261 static int check_pcibios(void)
30262 {
30263 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30264 unsigned long flags, pcibios_entry;
30265
30266 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30267 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30268 + pci_indirect.address = pcibios_entry;
30269
30270 local_irq_save(flags);
30271 - __asm__(
30272 - "lcall *(%%edi); cld\n\t"
30273 + __asm__("movw %w6, %%ds\n\t"
30274 + "lcall *%%ss:(%%edi); cld\n\t"
30275 + "push %%ss\n\t"
30276 + "pop %%ds\n\t"
30277 "jc 1f\n\t"
30278 "xor %%ah, %%ah\n"
30279 "1:"
30280 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30281 "=b" (ebx),
30282 "=c" (ecx)
30283 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30284 - "D" (&pci_indirect)
30285 + "D" (&pci_indirect),
30286 + "r" (__PCIBIOS_DS)
30287 : "memory");
30288 local_irq_restore(flags);
30289
30290 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30291
30292 switch (len) {
30293 case 1:
30294 - __asm__("lcall *(%%esi); cld\n\t"
30295 + __asm__("movw %w6, %%ds\n\t"
30296 + "lcall *%%ss:(%%esi); cld\n\t"
30297 + "push %%ss\n\t"
30298 + "pop %%ds\n\t"
30299 "jc 1f\n\t"
30300 "xor %%ah, %%ah\n"
30301 "1:"
30302 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30303 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30304 "b" (bx),
30305 "D" ((long)reg),
30306 - "S" (&pci_indirect));
30307 + "S" (&pci_indirect),
30308 + "r" (__PCIBIOS_DS));
30309 /*
30310 * Zero-extend the result beyond 8 bits, do not trust the
30311 * BIOS having done it:
30312 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30313 *value &= 0xff;
30314 break;
30315 case 2:
30316 - __asm__("lcall *(%%esi); cld\n\t"
30317 + __asm__("movw %w6, %%ds\n\t"
30318 + "lcall *%%ss:(%%esi); cld\n\t"
30319 + "push %%ss\n\t"
30320 + "pop %%ds\n\t"
30321 "jc 1f\n\t"
30322 "xor %%ah, %%ah\n"
30323 "1:"
30324 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30325 : "1" (PCIBIOS_READ_CONFIG_WORD),
30326 "b" (bx),
30327 "D" ((long)reg),
30328 - "S" (&pci_indirect));
30329 + "S" (&pci_indirect),
30330 + "r" (__PCIBIOS_DS));
30331 /*
30332 * Zero-extend the result beyond 16 bits, do not trust the
30333 * BIOS having done it:
30334 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30335 *value &= 0xffff;
30336 break;
30337 case 4:
30338 - __asm__("lcall *(%%esi); cld\n\t"
30339 + __asm__("movw %w6, %%ds\n\t"
30340 + "lcall *%%ss:(%%esi); cld\n\t"
30341 + "push %%ss\n\t"
30342 + "pop %%ds\n\t"
30343 "jc 1f\n\t"
30344 "xor %%ah, %%ah\n"
30345 "1:"
30346 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30347 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30348 "b" (bx),
30349 "D" ((long)reg),
30350 - "S" (&pci_indirect));
30351 + "S" (&pci_indirect),
30352 + "r" (__PCIBIOS_DS));
30353 break;
30354 }
30355
30356 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30357
30358 switch (len) {
30359 case 1:
30360 - __asm__("lcall *(%%esi); cld\n\t"
30361 + __asm__("movw %w6, %%ds\n\t"
30362 + "lcall *%%ss:(%%esi); cld\n\t"
30363 + "push %%ss\n\t"
30364 + "pop %%ds\n\t"
30365 "jc 1f\n\t"
30366 "xor %%ah, %%ah\n"
30367 "1:"
30368 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30369 "c" (value),
30370 "b" (bx),
30371 "D" ((long)reg),
30372 - "S" (&pci_indirect));
30373 + "S" (&pci_indirect),
30374 + "r" (__PCIBIOS_DS));
30375 break;
30376 case 2:
30377 - __asm__("lcall *(%%esi); cld\n\t"
30378 + __asm__("movw %w6, %%ds\n\t"
30379 + "lcall *%%ss:(%%esi); cld\n\t"
30380 + "push %%ss\n\t"
30381 + "pop %%ds\n\t"
30382 "jc 1f\n\t"
30383 "xor %%ah, %%ah\n"
30384 "1:"
30385 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30386 "c" (value),
30387 "b" (bx),
30388 "D" ((long)reg),
30389 - "S" (&pci_indirect));
30390 + "S" (&pci_indirect),
30391 + "r" (__PCIBIOS_DS));
30392 break;
30393 case 4:
30394 - __asm__("lcall *(%%esi); cld\n\t"
30395 + __asm__("movw %w6, %%ds\n\t"
30396 + "lcall *%%ss:(%%esi); cld\n\t"
30397 + "push %%ss\n\t"
30398 + "pop %%ds\n\t"
30399 "jc 1f\n\t"
30400 "xor %%ah, %%ah\n"
30401 "1:"
30402 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30403 "c" (value),
30404 "b" (bx),
30405 "D" ((long)reg),
30406 - "S" (&pci_indirect));
30407 + "S" (&pci_indirect),
30408 + "r" (__PCIBIOS_DS));
30409 break;
30410 }
30411
30412 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30413
30414 DBG("PCI: Fetching IRQ routing table... ");
30415 __asm__("push %%es\n\t"
30416 + "movw %w8, %%ds\n\t"
30417 "push %%ds\n\t"
30418 "pop %%es\n\t"
30419 - "lcall *(%%esi); cld\n\t"
30420 + "lcall *%%ss:(%%esi); cld\n\t"
30421 "pop %%es\n\t"
30422 + "push %%ss\n\t"
30423 + "pop %%ds\n"
30424 "jc 1f\n\t"
30425 "xor %%ah, %%ah\n"
30426 "1:"
30427 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30428 "1" (0),
30429 "D" ((long) &opt),
30430 "S" (&pci_indirect),
30431 - "m" (opt)
30432 + "m" (opt),
30433 + "r" (__PCIBIOS_DS)
30434 : "memory");
30435 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30436 if (ret & 0xff00)
30437 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30438 {
30439 int ret;
30440
30441 - __asm__("lcall *(%%esi); cld\n\t"
30442 + __asm__("movw %w5, %%ds\n\t"
30443 + "lcall *%%ss:(%%esi); cld\n\t"
30444 + "push %%ss\n\t"
30445 + "pop %%ds\n"
30446 "jc 1f\n\t"
30447 "xor %%ah, %%ah\n"
30448 "1:"
30449 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30450 : "0" (PCIBIOS_SET_PCI_HW_INT),
30451 "b" ((dev->bus->number << 8) | dev->devfn),
30452 "c" ((irq << 8) | (pin + 10)),
30453 - "S" (&pci_indirect));
30454 + "S" (&pci_indirect),
30455 + "r" (__PCIBIOS_DS));
30456 return !(ret & 0xff00);
30457 }
30458 EXPORT_SYMBOL(pcibios_set_irq_routing);
30459 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30460 index 40e4469..0592924 100644
30461 --- a/arch/x86/platform/efi/efi_32.c
30462 +++ b/arch/x86/platform/efi/efi_32.c
30463 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30464 {
30465 struct desc_ptr gdt_descr;
30466
30467 +#ifdef CONFIG_PAX_KERNEXEC
30468 + struct desc_struct d;
30469 +#endif
30470 +
30471 local_irq_save(efi_rt_eflags);
30472
30473 load_cr3(initial_page_table);
30474 __flush_tlb_all();
30475
30476 +#ifdef CONFIG_PAX_KERNEXEC
30477 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30478 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30479 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30480 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30481 +#endif
30482 +
30483 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30484 gdt_descr.size = GDT_SIZE - 1;
30485 load_gdt(&gdt_descr);
30486 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
30487 {
30488 struct desc_ptr gdt_descr;
30489
30490 +#ifdef CONFIG_PAX_KERNEXEC
30491 + struct desc_struct d;
30492 +
30493 + memset(&d, 0, sizeof d);
30494 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30495 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30496 +#endif
30497 +
30498 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30499 gdt_descr.size = GDT_SIZE - 1;
30500 load_gdt(&gdt_descr);
30501
30502 +#ifdef CONFIG_PAX_PER_CPU_PGD
30503 + load_cr3(get_cpu_pgd(smp_processor_id()));
30504 +#else
30505 load_cr3(swapper_pg_dir);
30506 +#endif
30507 +
30508 __flush_tlb_all();
30509
30510 local_irq_restore(efi_rt_eflags);
30511 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
30512 index 39a0e7f1..ecc2f1e 100644
30513 --- a/arch/x86/platform/efi/efi_64.c
30514 +++ b/arch/x86/platform/efi/efi_64.c
30515 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
30516 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
30517 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
30518 }
30519 +
30520 +#ifdef CONFIG_PAX_PER_CPU_PGD
30521 + load_cr3(swapper_pg_dir);
30522 +#endif
30523 +
30524 __flush_tlb_all();
30525 }
30526
30527 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
30528 for (pgd = 0; pgd < n_pgds; pgd++)
30529 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
30530 kfree(save_pgd);
30531 +
30532 +#ifdef CONFIG_PAX_PER_CPU_PGD
30533 + load_cr3(get_cpu_pgd(smp_processor_id()));
30534 +#endif
30535 +
30536 __flush_tlb_all();
30537 local_irq_restore(efi_flags);
30538 early_code_mapping_set_exec(0);
30539 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30540 index fbe66e6..eae5e38 100644
30541 --- a/arch/x86/platform/efi/efi_stub_32.S
30542 +++ b/arch/x86/platform/efi/efi_stub_32.S
30543 @@ -6,7 +6,9 @@
30544 */
30545
30546 #include <linux/linkage.h>
30547 +#include <linux/init.h>
30548 #include <asm/page_types.h>
30549 +#include <asm/segment.h>
30550
30551 /*
30552 * efi_call_phys(void *, ...) is a function with variable parameters.
30553 @@ -20,7 +22,7 @@
30554 * service functions will comply with gcc calling convention, too.
30555 */
30556
30557 -.text
30558 +__INIT
30559 ENTRY(efi_call_phys)
30560 /*
30561 * 0. The function can only be called in Linux kernel. So CS has been
30562 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30563 * The mapping of lower virtual memory has been created in prelog and
30564 * epilog.
30565 */
30566 - movl $1f, %edx
30567 - subl $__PAGE_OFFSET, %edx
30568 - jmp *%edx
30569 +#ifdef CONFIG_PAX_KERNEXEC
30570 + movl $(__KERNEXEC_EFI_DS), %edx
30571 + mov %edx, %ds
30572 + mov %edx, %es
30573 + mov %edx, %ss
30574 + addl $2f,(1f)
30575 + ljmp *(1f)
30576 +
30577 +__INITDATA
30578 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30579 +.previous
30580 +
30581 +2:
30582 + subl $2b,(1b)
30583 +#else
30584 + jmp 1f-__PAGE_OFFSET
30585 1:
30586 +#endif
30587
30588 /*
30589 * 2. Now on the top of stack is the return
30590 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30591 * parameter 2, ..., param n. To make things easy, we save the return
30592 * address of efi_call_phys in a global variable.
30593 */
30594 - popl %edx
30595 - movl %edx, saved_return_addr
30596 - /* get the function pointer into ECX*/
30597 - popl %ecx
30598 - movl %ecx, efi_rt_function_ptr
30599 - movl $2f, %edx
30600 - subl $__PAGE_OFFSET, %edx
30601 - pushl %edx
30602 + popl (saved_return_addr)
30603 + popl (efi_rt_function_ptr)
30604
30605 /*
30606 * 3. Clear PG bit in %CR0.
30607 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30608 /*
30609 * 5. Call the physical function.
30610 */
30611 - jmp *%ecx
30612 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30613
30614 -2:
30615 /*
30616 * 6. After EFI runtime service returns, control will return to
30617 * following instruction. We'd better readjust stack pointer first.
30618 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30619 movl %cr0, %edx
30620 orl $0x80000000, %edx
30621 movl %edx, %cr0
30622 - jmp 1f
30623 -1:
30624 +
30625 /*
30626 * 8. Now restore the virtual mode from flat mode by
30627 * adding EIP with PAGE_OFFSET.
30628 */
30629 - movl $1f, %edx
30630 - jmp *%edx
30631 +#ifdef CONFIG_PAX_KERNEXEC
30632 + movl $(__KERNEL_DS), %edx
30633 + mov %edx, %ds
30634 + mov %edx, %es
30635 + mov %edx, %ss
30636 + ljmp $(__KERNEL_CS),$1f
30637 +#else
30638 + jmp 1f+__PAGE_OFFSET
30639 +#endif
30640 1:
30641
30642 /*
30643 * 9. Balance the stack. And because EAX contain the return value,
30644 * we'd better not clobber it.
30645 */
30646 - leal efi_rt_function_ptr, %edx
30647 - movl (%edx), %ecx
30648 - pushl %ecx
30649 + pushl (efi_rt_function_ptr)
30650
30651 /*
30652 - * 10. Push the saved return address onto the stack and return.
30653 + * 10. Return to the saved return address.
30654 */
30655 - leal saved_return_addr, %edx
30656 - movl (%edx), %ecx
30657 - pushl %ecx
30658 - ret
30659 + jmpl *(saved_return_addr)
30660 ENDPROC(efi_call_phys)
30661 .previous
30662
30663 -.data
30664 +__INITDATA
30665 saved_return_addr:
30666 .long 0
30667 efi_rt_function_ptr:
30668 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30669 index 4c07cca..2c8427d 100644
30670 --- a/arch/x86/platform/efi/efi_stub_64.S
30671 +++ b/arch/x86/platform/efi/efi_stub_64.S
30672 @@ -7,6 +7,7 @@
30673 */
30674
30675 #include <linux/linkage.h>
30676 +#include <asm/alternative-asm.h>
30677
30678 #define SAVE_XMM \
30679 mov %rsp, %rax; \
30680 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30681 call *%rdi
30682 addq $32, %rsp
30683 RESTORE_XMM
30684 + pax_force_retaddr 0, 1
30685 ret
30686 ENDPROC(efi_call0)
30687
30688 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30689 call *%rdi
30690 addq $32, %rsp
30691 RESTORE_XMM
30692 + pax_force_retaddr 0, 1
30693 ret
30694 ENDPROC(efi_call1)
30695
30696 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30697 call *%rdi
30698 addq $32, %rsp
30699 RESTORE_XMM
30700 + pax_force_retaddr 0, 1
30701 ret
30702 ENDPROC(efi_call2)
30703
30704 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30705 call *%rdi
30706 addq $32, %rsp
30707 RESTORE_XMM
30708 + pax_force_retaddr 0, 1
30709 ret
30710 ENDPROC(efi_call3)
30711
30712 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30713 call *%rdi
30714 addq $32, %rsp
30715 RESTORE_XMM
30716 + pax_force_retaddr 0, 1
30717 ret
30718 ENDPROC(efi_call4)
30719
30720 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30721 call *%rdi
30722 addq $48, %rsp
30723 RESTORE_XMM
30724 + pax_force_retaddr 0, 1
30725 ret
30726 ENDPROC(efi_call5)
30727
30728 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30729 call *%rdi
30730 addq $48, %rsp
30731 RESTORE_XMM
30732 + pax_force_retaddr 0, 1
30733 ret
30734 ENDPROC(efi_call6)
30735 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30736 index a0a0a43..a48e233 100644
30737 --- a/arch/x86/platform/mrst/mrst.c
30738 +++ b/arch/x86/platform/mrst/mrst.c
30739 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30740 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30741 int sfi_mrtc_num;
30742
30743 -static void mrst_power_off(void)
30744 +static __noreturn void mrst_power_off(void)
30745 {
30746 + BUG();
30747 }
30748
30749 -static void mrst_reboot(void)
30750 +static __noreturn void mrst_reboot(void)
30751 {
30752 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30753 + BUG();
30754 }
30755
30756 /* parse all the mtimer info to a static mtimer array */
30757 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30758 index d6ee929..3637cb5 100644
30759 --- a/arch/x86/platform/olpc/olpc_dt.c
30760 +++ b/arch/x86/platform/olpc/olpc_dt.c
30761 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30762 return res;
30763 }
30764
30765 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30766 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30767 .nextprop = olpc_dt_nextprop,
30768 .getproplen = olpc_dt_getproplen,
30769 .getproperty = olpc_dt_getproperty,
30770 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30771 index 1cf5b30..fd45732 100644
30772 --- a/arch/x86/power/cpu.c
30773 +++ b/arch/x86/power/cpu.c
30774 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
30775 static void fix_processor_context(void)
30776 {
30777 int cpu = smp_processor_id();
30778 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30779 -#ifdef CONFIG_X86_64
30780 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
30781 - tss_desc tss;
30782 -#endif
30783 + struct tss_struct *t = init_tss + cpu;
30784 +
30785 set_tss_desc(cpu, t); /*
30786 * This just modifies memory; should not be
30787 * necessary. But... This is necessary, because
30788 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
30789 */
30790
30791 #ifdef CONFIG_X86_64
30792 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
30793 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
30794 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
30795 -
30796 syscall_init(); /* This sets MSR_*STAR and related */
30797 #endif
30798 load_TR_desc(); /* This does ltr */
30799 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30800 index a44f457..9140171 100644
30801 --- a/arch/x86/realmode/init.c
30802 +++ b/arch/x86/realmode/init.c
30803 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30804 __va(real_mode_header->trampoline_header);
30805
30806 #ifdef CONFIG_X86_32
30807 - trampoline_header->start = __pa_symbol(startup_32_smp);
30808 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30809 +
30810 +#ifdef CONFIG_PAX_KERNEXEC
30811 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30812 +#endif
30813 +
30814 + trampoline_header->boot_cs = __BOOT_CS;
30815 trampoline_header->gdt_limit = __BOOT_DS + 7;
30816 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30817 #else
30818 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30819 *trampoline_cr4_features = read_cr4();
30820
30821 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30822 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30823 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30824 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30825 #endif
30826 }
30827 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30828 index 8869287..d577672 100644
30829 --- a/arch/x86/realmode/rm/Makefile
30830 +++ b/arch/x86/realmode/rm/Makefile
30831 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30832 $(call cc-option, -fno-unit-at-a-time)) \
30833 $(call cc-option, -fno-stack-protector) \
30834 $(call cc-option, -mpreferred-stack-boundary=2)
30835 +ifdef CONSTIFY_PLUGIN
30836 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30837 +endif
30838 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30839 GCOV_PROFILE := n
30840 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30841 index a28221d..93c40f1 100644
30842 --- a/arch/x86/realmode/rm/header.S
30843 +++ b/arch/x86/realmode/rm/header.S
30844 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30845 #endif
30846 /* APM/BIOS reboot */
30847 .long pa_machine_real_restart_asm
30848 -#ifdef CONFIG_X86_64
30849 +#ifdef CONFIG_X86_32
30850 + .long __KERNEL_CS
30851 +#else
30852 .long __KERNEL32_CS
30853 #endif
30854 END(real_mode_header)
30855 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30856 index c1b2791..f9e31c7 100644
30857 --- a/arch/x86/realmode/rm/trampoline_32.S
30858 +++ b/arch/x86/realmode/rm/trampoline_32.S
30859 @@ -25,6 +25,12 @@
30860 #include <asm/page_types.h>
30861 #include "realmode.h"
30862
30863 +#ifdef CONFIG_PAX_KERNEXEC
30864 +#define ta(X) (X)
30865 +#else
30866 +#define ta(X) (pa_ ## X)
30867 +#endif
30868 +
30869 .text
30870 .code16
30871
30872 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30873
30874 cli # We should be safe anyway
30875
30876 - movl tr_start, %eax # where we need to go
30877 -
30878 movl $0xA5A5A5A5, trampoline_status
30879 # write marker for master knows we're running
30880
30881 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30882 movw $1, %dx # protected mode (PE) bit
30883 lmsw %dx # into protected mode
30884
30885 - ljmpl $__BOOT_CS, $pa_startup_32
30886 + ljmpl *(trampoline_header)
30887
30888 .section ".text32","ax"
30889 .code32
30890 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30891 .balign 8
30892 GLOBAL(trampoline_header)
30893 tr_start: .space 4
30894 - tr_gdt_pad: .space 2
30895 + tr_boot_cs: .space 2
30896 tr_gdt: .space 6
30897 END(trampoline_header)
30898
30899 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30900 index bb360dc..3e5945f 100644
30901 --- a/arch/x86/realmode/rm/trampoline_64.S
30902 +++ b/arch/x86/realmode/rm/trampoline_64.S
30903 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30904 wrmsr
30905
30906 # Enable paging and in turn activate Long Mode
30907 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30908 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30909 movl %eax, %cr0
30910
30911 /*
30912 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
30913 index e812034..c747134 100644
30914 --- a/arch/x86/tools/Makefile
30915 +++ b/arch/x86/tools/Makefile
30916 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
30917
30918 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
30919
30920 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
30921 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
30922 hostprogs-y += relocs
30923 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
30924 relocs: $(obj)/relocs
30925 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30926 index f7bab68..b6d9886 100644
30927 --- a/arch/x86/tools/relocs.c
30928 +++ b/arch/x86/tools/relocs.c
30929 @@ -1,5 +1,7 @@
30930 /* This is included from relocs_32/64.c */
30931
30932 +#include "../../../include/generated/autoconf.h"
30933 +
30934 #define ElfW(type) _ElfW(ELF_BITS, type)
30935 #define _ElfW(bits, type) __ElfW(bits, type)
30936 #define __ElfW(bits, type) Elf##bits##_##type
30937 @@ -11,6 +13,7 @@
30938 #define Elf_Sym ElfW(Sym)
30939
30940 static Elf_Ehdr ehdr;
30941 +static Elf_Phdr *phdr;
30942
30943 struct relocs {
30944 uint32_t *offset;
30945 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
30946 }
30947 }
30948
30949 +static void read_phdrs(FILE *fp)
30950 +{
30951 + unsigned int i;
30952 +
30953 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
30954 + if (!phdr) {
30955 + die("Unable to allocate %d program headers\n",
30956 + ehdr.e_phnum);
30957 + }
30958 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30959 + die("Seek to %d failed: %s\n",
30960 + ehdr.e_phoff, strerror(errno));
30961 + }
30962 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30963 + die("Cannot read ELF program headers: %s\n",
30964 + strerror(errno));
30965 + }
30966 + for(i = 0; i < ehdr.e_phnum; i++) {
30967 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
30968 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
30969 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
30970 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
30971 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
30972 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
30973 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
30974 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
30975 + }
30976 +
30977 +}
30978 +
30979 static void read_shdrs(FILE *fp)
30980 {
30981 - int i;
30982 + unsigned int i;
30983 Elf_Shdr shdr;
30984
30985 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30986 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
30987
30988 static void read_strtabs(FILE *fp)
30989 {
30990 - int i;
30991 + unsigned int i;
30992 for (i = 0; i < ehdr.e_shnum; i++) {
30993 struct section *sec = &secs[i];
30994 if (sec->shdr.sh_type != SHT_STRTAB) {
30995 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
30996
30997 static void read_symtabs(FILE *fp)
30998 {
30999 - int i,j;
31000 + unsigned int i,j;
31001 for (i = 0; i < ehdr.e_shnum; i++) {
31002 struct section *sec = &secs[i];
31003 if (sec->shdr.sh_type != SHT_SYMTAB) {
31004 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
31005 }
31006
31007
31008 -static void read_relocs(FILE *fp)
31009 +static void read_relocs(FILE *fp, int use_real_mode)
31010 {
31011 - int i,j;
31012 + unsigned int i,j;
31013 + uint32_t base;
31014 +
31015 for (i = 0; i < ehdr.e_shnum; i++) {
31016 struct section *sec = &secs[i];
31017 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31018 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
31019 die("Cannot read symbol table: %s\n",
31020 strerror(errno));
31021 }
31022 + base = 0;
31023 +
31024 +#ifdef CONFIG_X86_32
31025 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31026 + if (phdr[j].p_type != PT_LOAD )
31027 + continue;
31028 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
31029 + continue;
31030 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31031 + break;
31032 + }
31033 +#endif
31034 +
31035 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
31036 Elf_Rel *rel = &sec->reltab[j];
31037 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
31038 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
31039 rel->r_info = elf_xword_to_cpu(rel->r_info);
31040 #if (SHT_REL_TYPE == SHT_RELA)
31041 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
31042 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
31043
31044 static void print_absolute_symbols(void)
31045 {
31046 - int i;
31047 + unsigned int i;
31048 const char *format;
31049
31050 if (ELF_BITS == 64)
31051 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
31052 for (i = 0; i < ehdr.e_shnum; i++) {
31053 struct section *sec = &secs[i];
31054 char *sym_strtab;
31055 - int j;
31056 + unsigned int j;
31057
31058 if (sec->shdr.sh_type != SHT_SYMTAB) {
31059 continue;
31060 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
31061
31062 static void print_absolute_relocs(void)
31063 {
31064 - int i, printed = 0;
31065 + unsigned int i, printed = 0;
31066 const char *format;
31067
31068 if (ELF_BITS == 64)
31069 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
31070 struct section *sec_applies, *sec_symtab;
31071 char *sym_strtab;
31072 Elf_Sym *sh_symtab;
31073 - int j;
31074 + unsigned int j;
31075 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31076 continue;
31077 }
31078 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
31079 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
31080 Elf_Sym *sym, const char *symname))
31081 {
31082 - int i;
31083 + unsigned int i;
31084 /* Walk through the relocations */
31085 for (i = 0; i < ehdr.e_shnum; i++) {
31086 char *sym_strtab;
31087 Elf_Sym *sh_symtab;
31088 struct section *sec_applies, *sec_symtab;
31089 - int j;
31090 + unsigned int j;
31091 struct section *sec = &secs[i];
31092
31093 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31094 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31095 {
31096 unsigned r_type = ELF32_R_TYPE(rel->r_info);
31097 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
31098 + char *sym_strtab = sec->link->link->strtab;
31099 +
31100 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31101 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31102 + return 0;
31103 +
31104 +#ifdef CONFIG_PAX_KERNEXEC
31105 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31106 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31107 + return 0;
31108 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31109 + return 0;
31110 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31111 + return 0;
31112 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31113 + return 0;
31114 +#endif
31115
31116 switch (r_type) {
31117 case R_386_NONE:
31118 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
31119
31120 static void emit_relocs(int as_text, int use_real_mode)
31121 {
31122 - int i;
31123 + unsigned int i;
31124 int (*write_reloc)(uint32_t, FILE *) = write32;
31125 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31126 const char *symname);
31127 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
31128 {
31129 regex_init(use_real_mode);
31130 read_ehdr(fp);
31131 + read_phdrs(fp);
31132 read_shdrs(fp);
31133 read_strtabs(fp);
31134 read_symtabs(fp);
31135 - read_relocs(fp);
31136 + read_relocs(fp, use_real_mode);
31137 if (ELF_BITS == 64)
31138 percpu_init();
31139 if (show_absolute_syms) {
31140 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
31141 index 80ffa5b..a33bd15 100644
31142 --- a/arch/x86/um/tls_32.c
31143 +++ b/arch/x86/um/tls_32.c
31144 @@ -260,7 +260,7 @@ out:
31145 if (unlikely(task == current &&
31146 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
31147 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
31148 - "without flushed TLS.", current->pid);
31149 + "without flushed TLS.", task_pid_nr(current));
31150 }
31151
31152 return 0;
31153 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31154 index fd14be1..e3c79c0 100644
31155 --- a/arch/x86/vdso/Makefile
31156 +++ b/arch/x86/vdso/Makefile
31157 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31158 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31159 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31160
31161 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31162 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31163 GCOV_PROFILE := n
31164
31165 #
31166 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31167 index 0faad64..39ef157 100644
31168 --- a/arch/x86/vdso/vdso32-setup.c
31169 +++ b/arch/x86/vdso/vdso32-setup.c
31170 @@ -25,6 +25,7 @@
31171 #include <asm/tlbflush.h>
31172 #include <asm/vdso.h>
31173 #include <asm/proto.h>
31174 +#include <asm/mman.h>
31175
31176 enum {
31177 VDSO_DISABLED = 0,
31178 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31179 void enable_sep_cpu(void)
31180 {
31181 int cpu = get_cpu();
31182 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31183 + struct tss_struct *tss = init_tss + cpu;
31184
31185 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31186 put_cpu();
31187 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31188 gate_vma.vm_start = FIXADDR_USER_START;
31189 gate_vma.vm_end = FIXADDR_USER_END;
31190 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31191 - gate_vma.vm_page_prot = __P101;
31192 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31193
31194 return 0;
31195 }
31196 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31197 if (compat)
31198 addr = VDSO_HIGH_BASE;
31199 else {
31200 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31201 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31202 if (IS_ERR_VALUE(addr)) {
31203 ret = addr;
31204 goto up_fail;
31205 }
31206 }
31207
31208 - current->mm->context.vdso = (void *)addr;
31209 + current->mm->context.vdso = addr;
31210
31211 if (compat_uses_vma || !compat) {
31212 /*
31213 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31214 }
31215
31216 current_thread_info()->sysenter_return =
31217 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31218 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31219
31220 up_fail:
31221 if (ret)
31222 - current->mm->context.vdso = NULL;
31223 + current->mm->context.vdso = 0;
31224
31225 up_write(&mm->mmap_sem);
31226
31227 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31228
31229 const char *arch_vma_name(struct vm_area_struct *vma)
31230 {
31231 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31232 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31233 return "[vdso]";
31234 +
31235 +#ifdef CONFIG_PAX_SEGMEXEC
31236 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31237 + return "[vdso]";
31238 +#endif
31239 +
31240 return NULL;
31241 }
31242
31243 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31244 * Check to see if the corresponding task was created in compat vdso
31245 * mode.
31246 */
31247 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31248 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31249 return &gate_vma;
31250 return NULL;
31251 }
31252 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31253 index 431e875..cbb23f3 100644
31254 --- a/arch/x86/vdso/vma.c
31255 +++ b/arch/x86/vdso/vma.c
31256 @@ -16,8 +16,6 @@
31257 #include <asm/vdso.h>
31258 #include <asm/page.h>
31259
31260 -unsigned int __read_mostly vdso_enabled = 1;
31261 -
31262 extern char vdso_start[], vdso_end[];
31263 extern unsigned short vdso_sync_cpuid;
31264
31265 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31266 * unaligned here as a result of stack start randomization.
31267 */
31268 addr = PAGE_ALIGN(addr);
31269 - addr = align_vdso_addr(addr);
31270
31271 return addr;
31272 }
31273 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31274 unsigned size)
31275 {
31276 struct mm_struct *mm = current->mm;
31277 - unsigned long addr;
31278 + unsigned long addr = 0;
31279 int ret;
31280
31281 - if (!vdso_enabled)
31282 - return 0;
31283 -
31284 down_write(&mm->mmap_sem);
31285 +
31286 +#ifdef CONFIG_PAX_RANDMMAP
31287 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31288 +#endif
31289 +
31290 addr = vdso_addr(mm->start_stack, size);
31291 + addr = align_vdso_addr(addr);
31292 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31293 if (IS_ERR_VALUE(addr)) {
31294 ret = addr;
31295 goto up_fail;
31296 }
31297
31298 - current->mm->context.vdso = (void *)addr;
31299 + mm->context.vdso = addr;
31300
31301 ret = install_special_mapping(mm, addr, size,
31302 VM_READ|VM_EXEC|
31303 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31304 pages);
31305 - if (ret) {
31306 - current->mm->context.vdso = NULL;
31307 - goto up_fail;
31308 - }
31309 + if (ret)
31310 + mm->context.vdso = 0;
31311
31312 up_fail:
31313 up_write(&mm->mmap_sem);
31314 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31315 vdsox32_size);
31316 }
31317 #endif
31318 -
31319 -static __init int vdso_setup(char *s)
31320 -{
31321 - vdso_enabled = simple_strtoul(s, NULL, 0);
31322 - return 0;
31323 -}
31324 -__setup("vdso=", vdso_setup);
31325 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31326 index a492be2..08678da 100644
31327 --- a/arch/x86/xen/enlighten.c
31328 +++ b/arch/x86/xen/enlighten.c
31329 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31330
31331 struct shared_info xen_dummy_shared_info;
31332
31333 -void *xen_initial_gdt;
31334 -
31335 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31336 __read_mostly int xen_have_vector_callback;
31337 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31338 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31339 {
31340 unsigned long va = dtr->address;
31341 unsigned int size = dtr->size + 1;
31342 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31343 - unsigned long frames[pages];
31344 + unsigned long frames[65536 / PAGE_SIZE];
31345 int f;
31346
31347 /*
31348 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31349 {
31350 unsigned long va = dtr->address;
31351 unsigned int size = dtr->size + 1;
31352 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31353 - unsigned long frames[pages];
31354 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31355 int f;
31356
31357 /*
31358 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31359 * 8-byte entries, or 16 4k pages..
31360 */
31361
31362 - BUG_ON(size > 65536);
31363 + BUG_ON(size > GDT_SIZE);
31364 BUG_ON(va & ~PAGE_MASK);
31365
31366 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31367 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31368 return 0;
31369 }
31370
31371 -static void set_xen_basic_apic_ops(void)
31372 +static void __init set_xen_basic_apic_ops(void)
31373 {
31374 apic->read = xen_apic_read;
31375 apic->write = xen_apic_write;
31376 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31377 #endif
31378 };
31379
31380 -static void xen_reboot(int reason)
31381 +static __noreturn void xen_reboot(int reason)
31382 {
31383 struct sched_shutdown r = { .reason = reason };
31384
31385 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31386 - BUG();
31387 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31388 + BUG();
31389 }
31390
31391 -static void xen_restart(char *msg)
31392 +static __noreturn void xen_restart(char *msg)
31393 {
31394 xen_reboot(SHUTDOWN_reboot);
31395 }
31396
31397 -static void xen_emergency_restart(void)
31398 +static __noreturn void xen_emergency_restart(void)
31399 {
31400 xen_reboot(SHUTDOWN_reboot);
31401 }
31402
31403 -static void xen_machine_halt(void)
31404 +static __noreturn void xen_machine_halt(void)
31405 {
31406 xen_reboot(SHUTDOWN_poweroff);
31407 }
31408
31409 -static void xen_machine_power_off(void)
31410 +static __noreturn void xen_machine_power_off(void)
31411 {
31412 if (pm_power_off)
31413 pm_power_off();
31414 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
31415 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31416
31417 /* Work out if we support NX */
31418 - x86_configure_nx();
31419 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31420 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31421 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31422 + unsigned l, h;
31423 +
31424 + __supported_pte_mask |= _PAGE_NX;
31425 + rdmsr(MSR_EFER, l, h);
31426 + l |= EFER_NX;
31427 + wrmsr(MSR_EFER, l, h);
31428 + }
31429 +#endif
31430
31431 xen_setup_features();
31432
31433 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
31434
31435 machine_ops = xen_machine_ops;
31436
31437 - /*
31438 - * The only reliable way to retain the initial address of the
31439 - * percpu gdt_page is to remember it here, so we can go and
31440 - * mark it RW later, when the initial percpu area is freed.
31441 - */
31442 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31443 -
31444 xen_smp_init();
31445
31446 #ifdef CONFIG_ACPI_NUMA
31447 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31448 return NOTIFY_OK;
31449 }
31450
31451 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31452 +static struct notifier_block xen_hvm_cpu_notifier = {
31453 .notifier_call = xen_hvm_cpu_notify,
31454 };
31455
31456 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31457 index fdc3ba2..3daee39 100644
31458 --- a/arch/x86/xen/mmu.c
31459 +++ b/arch/x86/xen/mmu.c
31460 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31461 /* L3_k[510] -> level2_kernel_pgt
31462 * L3_i[511] -> level2_fixmap_pgt */
31463 convert_pfn_mfn(level3_kernel_pgt);
31464 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31465 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31466 + convert_pfn_mfn(level3_vmemmap_pgt);
31467
31468 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31469 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31470 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31471 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31472 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31473 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31474 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31475 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31476 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31477 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31478 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31479 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31480 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31481 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31482
31483 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
31484 pv_mmu_ops.set_pud = xen_set_pud;
31485 #if PAGETABLE_LEVELS == 4
31486 pv_mmu_ops.set_pgd = xen_set_pgd;
31487 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31488 #endif
31489
31490 /* This will work as long as patching hasn't happened yet
31491 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31492 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31493 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31494 .set_pgd = xen_set_pgd_hyper,
31495 + .set_pgd_batched = xen_set_pgd_hyper,
31496
31497 .alloc_pud = xen_alloc_pmd_init,
31498 .release_pud = xen_release_pmd_init,
31499 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31500 index d99cae8..18401e1 100644
31501 --- a/arch/x86/xen/smp.c
31502 +++ b/arch/x86/xen/smp.c
31503 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31504 {
31505 BUG_ON(smp_processor_id() != 0);
31506 native_smp_prepare_boot_cpu();
31507 -
31508 - /* We've switched to the "real" per-cpu gdt, so make sure the
31509 - old memory can be recycled */
31510 - make_lowmem_page_readwrite(xen_initial_gdt);
31511 -
31512 xen_filter_cpu_maps();
31513 xen_setup_vcpu_info_placement();
31514 }
31515 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31516 ctxt->user_regs.ss = __KERNEL_DS;
31517 #ifdef CONFIG_X86_32
31518 ctxt->user_regs.fs = __KERNEL_PERCPU;
31519 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31520 + savesegment(gs, ctxt->user_regs.gs);
31521 #else
31522 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31523 #endif
31524 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31525
31526 {
31527 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31528 - ctxt->user_regs.ds = __USER_DS;
31529 - ctxt->user_regs.es = __USER_DS;
31530 + ctxt->user_regs.ds = __KERNEL_DS;
31531 + ctxt->user_regs.es = __KERNEL_DS;
31532
31533 xen_copy_trap_info(ctxt->trap_ctxt);
31534
31535 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31536 int rc;
31537
31538 per_cpu(current_task, cpu) = idle;
31539 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31540 #ifdef CONFIG_X86_32
31541 irq_ctx_init(cpu);
31542 #else
31543 clear_tsk_thread_flag(idle, TIF_FORK);
31544 - per_cpu(kernel_stack, cpu) =
31545 - (unsigned long)task_stack_page(idle) -
31546 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31547 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31548 #endif
31549 xen_setup_runstate_info(cpu);
31550 xen_setup_timer(cpu);
31551 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31552
31553 void __init xen_smp_init(void)
31554 {
31555 - smp_ops = xen_smp_ops;
31556 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31557 xen_fill_possible_map();
31558 xen_init_spinlocks();
31559 }
31560 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31561 index 33ca6e4..0ded929 100644
31562 --- a/arch/x86/xen/xen-asm_32.S
31563 +++ b/arch/x86/xen/xen-asm_32.S
31564 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31565 ESP_OFFSET=4 # bytes pushed onto stack
31566
31567 /*
31568 - * Store vcpu_info pointer for easy access. Do it this way to
31569 - * avoid having to reload %fs
31570 + * Store vcpu_info pointer for easy access.
31571 */
31572 #ifdef CONFIG_SMP
31573 - GET_THREAD_INFO(%eax)
31574 - movl %ss:TI_cpu(%eax), %eax
31575 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31576 - mov %ss:xen_vcpu(%eax), %eax
31577 + push %fs
31578 + mov $(__KERNEL_PERCPU), %eax
31579 + mov %eax, %fs
31580 + mov PER_CPU_VAR(xen_vcpu), %eax
31581 + pop %fs
31582 #else
31583 movl %ss:xen_vcpu, %eax
31584 #endif
31585 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31586 index 7faed58..ba4427c 100644
31587 --- a/arch/x86/xen/xen-head.S
31588 +++ b/arch/x86/xen/xen-head.S
31589 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31590 #ifdef CONFIG_X86_32
31591 mov %esi,xen_start_info
31592 mov $init_thread_union+THREAD_SIZE,%esp
31593 +#ifdef CONFIG_SMP
31594 + movl $cpu_gdt_table,%edi
31595 + movl $__per_cpu_load,%eax
31596 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31597 + rorl $16,%eax
31598 + movb %al,__KERNEL_PERCPU + 4(%edi)
31599 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31600 + movl $__per_cpu_end - 1,%eax
31601 + subl $__per_cpu_start,%eax
31602 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31603 +#endif
31604 #else
31605 mov %rsi,xen_start_info
31606 mov $init_thread_union+THREAD_SIZE,%rsp
31607 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31608 index a95b417..b6dbd0b 100644
31609 --- a/arch/x86/xen/xen-ops.h
31610 +++ b/arch/x86/xen/xen-ops.h
31611 @@ -10,8 +10,6 @@
31612 extern const char xen_hypervisor_callback[];
31613 extern const char xen_failsafe_callback[];
31614
31615 -extern void *xen_initial_gdt;
31616 -
31617 struct trap_info;
31618 void xen_copy_trap_info(struct trap_info *traps);
31619
31620 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31621 index 525bd3d..ef888b1 100644
31622 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31623 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31624 @@ -119,9 +119,9 @@
31625 ----------------------------------------------------------------------*/
31626
31627 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31628 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31629 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31630 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31631 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31632
31633 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31634 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31635 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31636 index 2f33760..835e50a 100644
31637 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31638 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31639 @@ -11,6 +11,7 @@
31640 #ifndef _XTENSA_CORE_H
31641 #define _XTENSA_CORE_H
31642
31643 +#include <linux/const.h>
31644
31645 /****************************************************************************
31646 Parameters Useful for Any Code, USER or PRIVILEGED
31647 @@ -112,9 +113,9 @@
31648 ----------------------------------------------------------------------*/
31649
31650 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31651 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31652 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31653 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31654 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31655
31656 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31657 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31658 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31659 index af00795..2bb8105 100644
31660 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31661 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31662 @@ -11,6 +11,7 @@
31663 #ifndef _XTENSA_CORE_CONFIGURATION_H
31664 #define _XTENSA_CORE_CONFIGURATION_H
31665
31666 +#include <linux/const.h>
31667
31668 /****************************************************************************
31669 Parameters Useful for Any Code, USER or PRIVILEGED
31670 @@ -118,9 +119,9 @@
31671 ----------------------------------------------------------------------*/
31672
31673 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31674 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31675 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31676 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31677 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31678
31679 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31680 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31681 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31682 index 58916af..eb9dbcf6 100644
31683 --- a/block/blk-iopoll.c
31684 +++ b/block/blk-iopoll.c
31685 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31686 }
31687 EXPORT_SYMBOL(blk_iopoll_complete);
31688
31689 -static void blk_iopoll_softirq(struct softirq_action *h)
31690 +static void blk_iopoll_softirq(void)
31691 {
31692 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31693 int rearm = 0, budget = blk_iopoll_budget;
31694 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31695 return NOTIFY_OK;
31696 }
31697
31698 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31699 +static struct notifier_block blk_iopoll_cpu_notifier = {
31700 .notifier_call = blk_iopoll_cpu_notify,
31701 };
31702
31703 diff --git a/block/blk-map.c b/block/blk-map.c
31704 index 623e1cd..ca1e109 100644
31705 --- a/block/blk-map.c
31706 +++ b/block/blk-map.c
31707 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31708 if (!len || !kbuf)
31709 return -EINVAL;
31710
31711 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31712 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31713 if (do_copy)
31714 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31715 else
31716 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31717 index 467c8de..f3628c5 100644
31718 --- a/block/blk-softirq.c
31719 +++ b/block/blk-softirq.c
31720 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31721 * Softirq action handler - move entries to local list and loop over them
31722 * while passing them to the queue registered handler.
31723 */
31724 -static void blk_done_softirq(struct softirq_action *h)
31725 +static void blk_done_softirq(void)
31726 {
31727 struct list_head *cpu_list, local_list;
31728
31729 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31730 return NOTIFY_OK;
31731 }
31732
31733 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31734 +static struct notifier_block blk_cpu_notifier = {
31735 .notifier_call = blk_cpu_notify,
31736 };
31737
31738 diff --git a/block/bsg.c b/block/bsg.c
31739 index 420a5a9..23834aa 100644
31740 --- a/block/bsg.c
31741 +++ b/block/bsg.c
31742 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31743 struct sg_io_v4 *hdr, struct bsg_device *bd,
31744 fmode_t has_write_perm)
31745 {
31746 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31747 + unsigned char *cmdptr;
31748 +
31749 if (hdr->request_len > BLK_MAX_CDB) {
31750 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31751 if (!rq->cmd)
31752 return -ENOMEM;
31753 - }
31754 + cmdptr = rq->cmd;
31755 + } else
31756 + cmdptr = tmpcmd;
31757
31758 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31759 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31760 hdr->request_len))
31761 return -EFAULT;
31762
31763 + if (cmdptr != rq->cmd)
31764 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31765 +
31766 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31767 if (blk_verify_command(rq->cmd, has_write_perm))
31768 return -EPERM;
31769 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31770 index 7c668c8..db3521c 100644
31771 --- a/block/compat_ioctl.c
31772 +++ b/block/compat_ioctl.c
31773 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31774 err |= __get_user(f->spec1, &uf->spec1);
31775 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31776 err |= __get_user(name, &uf->name);
31777 - f->name = compat_ptr(name);
31778 + f->name = (void __force_kernel *)compat_ptr(name);
31779 if (err) {
31780 err = -EFAULT;
31781 goto out;
31782 diff --git a/block/genhd.c b/block/genhd.c
31783 index cdeb527..10aa34db 100644
31784 --- a/block/genhd.c
31785 +++ b/block/genhd.c
31786 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31787
31788 /*
31789 * Register device numbers dev..(dev+range-1)
31790 - * range must be nonzero
31791 + * Noop if @range is zero.
31792 * The hash chain is sorted on range, so that subranges can override.
31793 */
31794 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31795 struct kobject *(*probe)(dev_t, int *, void *),
31796 int (*lock)(dev_t, void *), void *data)
31797 {
31798 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31799 + if (range)
31800 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31801 }
31802
31803 EXPORT_SYMBOL(blk_register_region);
31804
31805 +/* undo blk_register_region(), noop if @range is zero */
31806 void blk_unregister_region(dev_t devt, unsigned long range)
31807 {
31808 - kobj_unmap(bdev_map, devt, range);
31809 + if (range)
31810 + kobj_unmap(bdev_map, devt, range);
31811 }
31812
31813 EXPORT_SYMBOL(blk_unregister_region);
31814 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31815 index c85fc89..51e690b 100644
31816 --- a/block/partitions/efi.c
31817 +++ b/block/partitions/efi.c
31818 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31819 if (!gpt)
31820 return NULL;
31821
31822 + if (!le32_to_cpu(gpt->num_partition_entries))
31823 + return NULL;
31824 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31825 + if (!pte)
31826 + return NULL;
31827 +
31828 count = le32_to_cpu(gpt->num_partition_entries) *
31829 le32_to_cpu(gpt->sizeof_partition_entry);
31830 - if (!count)
31831 - return NULL;
31832 - pte = kmalloc(count, GFP_KERNEL);
31833 - if (!pte)
31834 - return NULL;
31835 -
31836 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31837 (u8 *) pte,
31838 count) < count) {
31839 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31840 index a5ffcc9..3cedc9c 100644
31841 --- a/block/scsi_ioctl.c
31842 +++ b/block/scsi_ioctl.c
31843 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
31844 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31845 struct sg_io_hdr *hdr, fmode_t mode)
31846 {
31847 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31848 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31849 + unsigned char *cmdptr;
31850 +
31851 + if (rq->cmd != rq->__cmd)
31852 + cmdptr = rq->cmd;
31853 + else
31854 + cmdptr = tmpcmd;
31855 +
31856 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31857 return -EFAULT;
31858 +
31859 + if (cmdptr != rq->cmd)
31860 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31861 +
31862 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31863 return -EPERM;
31864
31865 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31866 int err;
31867 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31868 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31869 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31870 + unsigned char *cmdptr;
31871
31872 if (!sic)
31873 return -EINVAL;
31874 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31875 */
31876 err = -EFAULT;
31877 rq->cmd_len = cmdlen;
31878 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31879 +
31880 + if (rq->cmd != rq->__cmd)
31881 + cmdptr = rq->cmd;
31882 + else
31883 + cmdptr = tmpcmd;
31884 +
31885 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31886 goto error;
31887
31888 + if (rq->cmd != cmdptr)
31889 + memcpy(rq->cmd, cmdptr, cmdlen);
31890 +
31891 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31892 goto error;
31893
31894 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31895 index 7bdd61b..afec999 100644
31896 --- a/crypto/cryptd.c
31897 +++ b/crypto/cryptd.c
31898 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31899
31900 struct cryptd_blkcipher_request_ctx {
31901 crypto_completion_t complete;
31902 -};
31903 +} __no_const;
31904
31905 struct cryptd_hash_ctx {
31906 struct crypto_shash *child;
31907 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31908
31909 struct cryptd_aead_request_ctx {
31910 crypto_completion_t complete;
31911 -};
31912 +} __no_const;
31913
31914 static void cryptd_queue_worker(struct work_struct *work);
31915
31916 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31917 index b2c99dc..476c9fb 100644
31918 --- a/crypto/pcrypt.c
31919 +++ b/crypto/pcrypt.c
31920 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31921 int ret;
31922
31923 pinst->kobj.kset = pcrypt_kset;
31924 - ret = kobject_add(&pinst->kobj, NULL, name);
31925 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31926 if (!ret)
31927 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31928
31929 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31930
31931 get_online_cpus();
31932
31933 - pcrypt->wq = alloc_workqueue(name,
31934 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31935 + pcrypt->wq = alloc_workqueue("%s",
31936 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31937 if (!pcrypt->wq)
31938 goto err;
31939
31940 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31941 index f220d64..d359ad6 100644
31942 --- a/drivers/acpi/apei/apei-internal.h
31943 +++ b/drivers/acpi/apei/apei-internal.h
31944 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31945 struct apei_exec_ins_type {
31946 u32 flags;
31947 apei_exec_ins_func_t run;
31948 -};
31949 +} __do_const;
31950
31951 struct apei_exec_context {
31952 u32 ip;
31953 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31954 index 33dc6a0..4b24b47 100644
31955 --- a/drivers/acpi/apei/cper.c
31956 +++ b/drivers/acpi/apei/cper.c
31957 @@ -39,12 +39,12 @@
31958 */
31959 u64 cper_next_record_id(void)
31960 {
31961 - static atomic64_t seq;
31962 + static atomic64_unchecked_t seq;
31963
31964 - if (!atomic64_read(&seq))
31965 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31966 + if (!atomic64_read_unchecked(&seq))
31967 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31968
31969 - return atomic64_inc_return(&seq);
31970 + return atomic64_inc_return_unchecked(&seq);
31971 }
31972 EXPORT_SYMBOL_GPL(cper_next_record_id);
31973
31974 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31975 index be60399..778b33e8 100644
31976 --- a/drivers/acpi/bgrt.c
31977 +++ b/drivers/acpi/bgrt.c
31978 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31979 return -ENODEV;
31980
31981 sysfs_bin_attr_init(&image_attr);
31982 - image_attr.private = bgrt_image;
31983 - image_attr.size = bgrt_image_size;
31984 + pax_open_kernel();
31985 + *(void **)&image_attr.private = bgrt_image;
31986 + *(size_t *)&image_attr.size = bgrt_image_size;
31987 + pax_close_kernel();
31988
31989 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31990 if (!bgrt_kobj)
31991 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31992 index cb96296..b81293b 100644
31993 --- a/drivers/acpi/blacklist.c
31994 +++ b/drivers/acpi/blacklist.c
31995 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31996 u32 is_critical_error;
31997 };
31998
31999 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32000 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32001
32002 /*
32003 * POLICY: If *anything* doesn't work, put it on the blacklist.
32004 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32005 return 0;
32006 }
32007
32008 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32009 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32010 {
32011 .callback = dmi_disable_osi_vista,
32012 .ident = "Fujitsu Siemens",
32013 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32014 index 7586544..636a2f0 100644
32015 --- a/drivers/acpi/ec_sys.c
32016 +++ b/drivers/acpi/ec_sys.c
32017 @@ -12,6 +12,7 @@
32018 #include <linux/acpi.h>
32019 #include <linux/debugfs.h>
32020 #include <linux/module.h>
32021 +#include <linux/uaccess.h>
32022 #include "internal.h"
32023
32024 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32025 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32026 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32027 */
32028 unsigned int size = EC_SPACE_SIZE;
32029 - u8 *data = (u8 *) buf;
32030 + u8 data;
32031 loff_t init_off = *off;
32032 int err = 0;
32033
32034 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32035 size = count;
32036
32037 while (size) {
32038 - err = ec_read(*off, &data[*off - init_off]);
32039 + err = ec_read(*off, &data);
32040 if (err)
32041 return err;
32042 + if (put_user(data, &buf[*off - init_off]))
32043 + return -EFAULT;
32044 *off += 1;
32045 size--;
32046 }
32047 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32048
32049 unsigned int size = count;
32050 loff_t init_off = *off;
32051 - u8 *data = (u8 *) buf;
32052 int err = 0;
32053
32054 if (*off >= EC_SPACE_SIZE)
32055 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32056 }
32057
32058 while (size) {
32059 - u8 byte_write = data[*off - init_off];
32060 + u8 byte_write;
32061 + if (get_user(byte_write, &buf[*off - init_off]))
32062 + return -EFAULT;
32063 err = ec_write(*off, byte_write);
32064 if (err)
32065 return err;
32066 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32067 index eb133c7..f571552 100644
32068 --- a/drivers/acpi/processor_idle.c
32069 +++ b/drivers/acpi/processor_idle.c
32070 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32071 {
32072 int i, count = CPUIDLE_DRIVER_STATE_START;
32073 struct acpi_processor_cx *cx;
32074 - struct cpuidle_state *state;
32075 + cpuidle_state_no_const *state;
32076 struct cpuidle_driver *drv = &acpi_idle_driver;
32077
32078 if (!pr->flags.power_setup_done)
32079 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32080 index fcae5fa..e9f71ea 100644
32081 --- a/drivers/acpi/sysfs.c
32082 +++ b/drivers/acpi/sysfs.c
32083 @@ -423,11 +423,11 @@ static u32 num_counters;
32084 static struct attribute **all_attrs;
32085 static u32 acpi_gpe_count;
32086
32087 -static struct attribute_group interrupt_stats_attr_group = {
32088 +static attribute_group_no_const interrupt_stats_attr_group = {
32089 .name = "interrupts",
32090 };
32091
32092 -static struct kobj_attribute *counter_attrs;
32093 +static kobj_attribute_no_const *counter_attrs;
32094
32095 static void delete_gpe_attr_array(void)
32096 {
32097 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32098 index 7b9bdd8..37638ca 100644
32099 --- a/drivers/ata/libahci.c
32100 +++ b/drivers/ata/libahci.c
32101 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32102 }
32103 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32104
32105 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32106 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32107 struct ata_taskfile *tf, int is_cmd, u16 flags,
32108 unsigned long timeout_msec)
32109 {
32110 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32111 index adf002a..39bb8f9 100644
32112 --- a/drivers/ata/libata-core.c
32113 +++ b/drivers/ata/libata-core.c
32114 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32115 struct ata_port *ap;
32116 unsigned int tag;
32117
32118 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32119 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32120 ap = qc->ap;
32121
32122 qc->flags = 0;
32123 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32124 struct ata_port *ap;
32125 struct ata_link *link;
32126
32127 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32128 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32129 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32130 ap = qc->ap;
32131 link = qc->dev->link;
32132 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32133 return;
32134
32135 spin_lock(&lock);
32136 + pax_open_kernel();
32137
32138 for (cur = ops->inherits; cur; cur = cur->inherits) {
32139 void **inherit = (void **)cur;
32140 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32141 if (IS_ERR(*pp))
32142 *pp = NULL;
32143
32144 - ops->inherits = NULL;
32145 + *(struct ata_port_operations **)&ops->inherits = NULL;
32146
32147 + pax_close_kernel();
32148 spin_unlock(&lock);
32149 }
32150
32151 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32152 index 7638121..357a965 100644
32153 --- a/drivers/ata/pata_arasan_cf.c
32154 +++ b/drivers/ata/pata_arasan_cf.c
32155 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32156 /* Handle platform specific quirks */
32157 if (quirk) {
32158 if (quirk & CF_BROKEN_PIO) {
32159 - ap->ops->set_piomode = NULL;
32160 + pax_open_kernel();
32161 + *(void **)&ap->ops->set_piomode = NULL;
32162 + pax_close_kernel();
32163 ap->pio_mask = 0;
32164 }
32165 if (quirk & CF_BROKEN_MWDMA)
32166 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32167 index f9b983a..887b9d8 100644
32168 --- a/drivers/atm/adummy.c
32169 +++ b/drivers/atm/adummy.c
32170 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32171 vcc->pop(vcc, skb);
32172 else
32173 dev_kfree_skb_any(skb);
32174 - atomic_inc(&vcc->stats->tx);
32175 + atomic_inc_unchecked(&vcc->stats->tx);
32176
32177 return 0;
32178 }
32179 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32180 index 77a7480d..05cde58 100644
32181 --- a/drivers/atm/ambassador.c
32182 +++ b/drivers/atm/ambassador.c
32183 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32184 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32185
32186 // VC layer stats
32187 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32188 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32189
32190 // free the descriptor
32191 kfree (tx_descr);
32192 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32193 dump_skb ("<<<", vc, skb);
32194
32195 // VC layer stats
32196 - atomic_inc(&atm_vcc->stats->rx);
32197 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32198 __net_timestamp(skb);
32199 // end of our responsibility
32200 atm_vcc->push (atm_vcc, skb);
32201 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32202 } else {
32203 PRINTK (KERN_INFO, "dropped over-size frame");
32204 // should we count this?
32205 - atomic_inc(&atm_vcc->stats->rx_drop);
32206 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32207 }
32208
32209 } else {
32210 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32211 }
32212
32213 if (check_area (skb->data, skb->len)) {
32214 - atomic_inc(&atm_vcc->stats->tx_err);
32215 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32216 return -ENOMEM; // ?
32217 }
32218
32219 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32220 index 0e3f8f9..765a7a5 100644
32221 --- a/drivers/atm/atmtcp.c
32222 +++ b/drivers/atm/atmtcp.c
32223 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32224 if (vcc->pop) vcc->pop(vcc,skb);
32225 else dev_kfree_skb(skb);
32226 if (dev_data) return 0;
32227 - atomic_inc(&vcc->stats->tx_err);
32228 + atomic_inc_unchecked(&vcc->stats->tx_err);
32229 return -ENOLINK;
32230 }
32231 size = skb->len+sizeof(struct atmtcp_hdr);
32232 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32233 if (!new_skb) {
32234 if (vcc->pop) vcc->pop(vcc,skb);
32235 else dev_kfree_skb(skb);
32236 - atomic_inc(&vcc->stats->tx_err);
32237 + atomic_inc_unchecked(&vcc->stats->tx_err);
32238 return -ENOBUFS;
32239 }
32240 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32241 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32242 if (vcc->pop) vcc->pop(vcc,skb);
32243 else dev_kfree_skb(skb);
32244 out_vcc->push(out_vcc,new_skb);
32245 - atomic_inc(&vcc->stats->tx);
32246 - atomic_inc(&out_vcc->stats->rx);
32247 + atomic_inc_unchecked(&vcc->stats->tx);
32248 + atomic_inc_unchecked(&out_vcc->stats->rx);
32249 return 0;
32250 }
32251
32252 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32253 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32254 read_unlock(&vcc_sklist_lock);
32255 if (!out_vcc) {
32256 - atomic_inc(&vcc->stats->tx_err);
32257 + atomic_inc_unchecked(&vcc->stats->tx_err);
32258 goto done;
32259 }
32260 skb_pull(skb,sizeof(struct atmtcp_hdr));
32261 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32262 __net_timestamp(new_skb);
32263 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32264 out_vcc->push(out_vcc,new_skb);
32265 - atomic_inc(&vcc->stats->tx);
32266 - atomic_inc(&out_vcc->stats->rx);
32267 + atomic_inc_unchecked(&vcc->stats->tx);
32268 + atomic_inc_unchecked(&out_vcc->stats->rx);
32269 done:
32270 if (vcc->pop) vcc->pop(vcc,skb);
32271 else dev_kfree_skb(skb);
32272 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32273 index b1955ba..b179940 100644
32274 --- a/drivers/atm/eni.c
32275 +++ b/drivers/atm/eni.c
32276 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32277 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32278 vcc->dev->number);
32279 length = 0;
32280 - atomic_inc(&vcc->stats->rx_err);
32281 + atomic_inc_unchecked(&vcc->stats->rx_err);
32282 }
32283 else {
32284 length = ATM_CELL_SIZE-1; /* no HEC */
32285 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32286 size);
32287 }
32288 eff = length = 0;
32289 - atomic_inc(&vcc->stats->rx_err);
32290 + atomic_inc_unchecked(&vcc->stats->rx_err);
32291 }
32292 else {
32293 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32294 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32295 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32296 vcc->dev->number,vcc->vci,length,size << 2,descr);
32297 length = eff = 0;
32298 - atomic_inc(&vcc->stats->rx_err);
32299 + atomic_inc_unchecked(&vcc->stats->rx_err);
32300 }
32301 }
32302 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32303 @@ -767,7 +767,7 @@ rx_dequeued++;
32304 vcc->push(vcc,skb);
32305 pushed++;
32306 }
32307 - atomic_inc(&vcc->stats->rx);
32308 + atomic_inc_unchecked(&vcc->stats->rx);
32309 }
32310 wake_up(&eni_dev->rx_wait);
32311 }
32312 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32313 PCI_DMA_TODEVICE);
32314 if (vcc->pop) vcc->pop(vcc,skb);
32315 else dev_kfree_skb_irq(skb);
32316 - atomic_inc(&vcc->stats->tx);
32317 + atomic_inc_unchecked(&vcc->stats->tx);
32318 wake_up(&eni_dev->tx_wait);
32319 dma_complete++;
32320 }
32321 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32322 index b41c948..a002b17 100644
32323 --- a/drivers/atm/firestream.c
32324 +++ b/drivers/atm/firestream.c
32325 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32326 }
32327 }
32328
32329 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32330 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32331
32332 fs_dprintk (FS_DEBUG_TXMEM, "i");
32333 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32334 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32335 #endif
32336 skb_put (skb, qe->p1 & 0xffff);
32337 ATM_SKB(skb)->vcc = atm_vcc;
32338 - atomic_inc(&atm_vcc->stats->rx);
32339 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32340 __net_timestamp(skb);
32341 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32342 atm_vcc->push (atm_vcc, skb);
32343 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32344 kfree (pe);
32345 }
32346 if (atm_vcc)
32347 - atomic_inc(&atm_vcc->stats->rx_drop);
32348 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32349 break;
32350 case 0x1f: /* Reassembly abort: no buffers. */
32351 /* Silently increment error counter. */
32352 if (atm_vcc)
32353 - atomic_inc(&atm_vcc->stats->rx_drop);
32354 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32355 break;
32356 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32357 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32358 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32359 index 204814e..cede831 100644
32360 --- a/drivers/atm/fore200e.c
32361 +++ b/drivers/atm/fore200e.c
32362 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32363 #endif
32364 /* check error condition */
32365 if (*entry->status & STATUS_ERROR)
32366 - atomic_inc(&vcc->stats->tx_err);
32367 + atomic_inc_unchecked(&vcc->stats->tx_err);
32368 else
32369 - atomic_inc(&vcc->stats->tx);
32370 + atomic_inc_unchecked(&vcc->stats->tx);
32371 }
32372 }
32373
32374 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32375 if (skb == NULL) {
32376 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32377
32378 - atomic_inc(&vcc->stats->rx_drop);
32379 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32380 return -ENOMEM;
32381 }
32382
32383 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32384
32385 dev_kfree_skb_any(skb);
32386
32387 - atomic_inc(&vcc->stats->rx_drop);
32388 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32389 return -ENOMEM;
32390 }
32391
32392 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32393
32394 vcc->push(vcc, skb);
32395 - atomic_inc(&vcc->stats->rx);
32396 + atomic_inc_unchecked(&vcc->stats->rx);
32397
32398 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32399
32400 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32401 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32402 fore200e->atm_dev->number,
32403 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32404 - atomic_inc(&vcc->stats->rx_err);
32405 + atomic_inc_unchecked(&vcc->stats->rx_err);
32406 }
32407 }
32408
32409 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32410 goto retry_here;
32411 }
32412
32413 - atomic_inc(&vcc->stats->tx_err);
32414 + atomic_inc_unchecked(&vcc->stats->tx_err);
32415
32416 fore200e->tx_sat++;
32417 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32418 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32419 index 507362a..a845e57 100644
32420 --- a/drivers/atm/he.c
32421 +++ b/drivers/atm/he.c
32422 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32423
32424 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32425 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32426 - atomic_inc(&vcc->stats->rx_drop);
32427 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32428 goto return_host_buffers;
32429 }
32430
32431 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32432 RBRQ_LEN_ERR(he_dev->rbrq_head)
32433 ? "LEN_ERR" : "",
32434 vcc->vpi, vcc->vci);
32435 - atomic_inc(&vcc->stats->rx_err);
32436 + atomic_inc_unchecked(&vcc->stats->rx_err);
32437 goto return_host_buffers;
32438 }
32439
32440 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32441 vcc->push(vcc, skb);
32442 spin_lock(&he_dev->global_lock);
32443
32444 - atomic_inc(&vcc->stats->rx);
32445 + atomic_inc_unchecked(&vcc->stats->rx);
32446
32447 return_host_buffers:
32448 ++pdus_assembled;
32449 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32450 tpd->vcc->pop(tpd->vcc, tpd->skb);
32451 else
32452 dev_kfree_skb_any(tpd->skb);
32453 - atomic_inc(&tpd->vcc->stats->tx_err);
32454 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32455 }
32456 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32457 return;
32458 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32459 vcc->pop(vcc, skb);
32460 else
32461 dev_kfree_skb_any(skb);
32462 - atomic_inc(&vcc->stats->tx_err);
32463 + atomic_inc_unchecked(&vcc->stats->tx_err);
32464 return -EINVAL;
32465 }
32466
32467 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32468 vcc->pop(vcc, skb);
32469 else
32470 dev_kfree_skb_any(skb);
32471 - atomic_inc(&vcc->stats->tx_err);
32472 + atomic_inc_unchecked(&vcc->stats->tx_err);
32473 return -EINVAL;
32474 }
32475 #endif
32476 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32477 vcc->pop(vcc, skb);
32478 else
32479 dev_kfree_skb_any(skb);
32480 - atomic_inc(&vcc->stats->tx_err);
32481 + atomic_inc_unchecked(&vcc->stats->tx_err);
32482 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32483 return -ENOMEM;
32484 }
32485 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32486 vcc->pop(vcc, skb);
32487 else
32488 dev_kfree_skb_any(skb);
32489 - atomic_inc(&vcc->stats->tx_err);
32490 + atomic_inc_unchecked(&vcc->stats->tx_err);
32491 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32492 return -ENOMEM;
32493 }
32494 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32495 __enqueue_tpd(he_dev, tpd, cid);
32496 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32497
32498 - atomic_inc(&vcc->stats->tx);
32499 + atomic_inc_unchecked(&vcc->stats->tx);
32500
32501 return 0;
32502 }
32503 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32504 index 1dc0519..1aadaf7 100644
32505 --- a/drivers/atm/horizon.c
32506 +++ b/drivers/atm/horizon.c
32507 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32508 {
32509 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32510 // VC layer stats
32511 - atomic_inc(&vcc->stats->rx);
32512 + atomic_inc_unchecked(&vcc->stats->rx);
32513 __net_timestamp(skb);
32514 // end of our responsibility
32515 vcc->push (vcc, skb);
32516 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32517 dev->tx_iovec = NULL;
32518
32519 // VC layer stats
32520 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32521 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32522
32523 // free the skb
32524 hrz_kfree_skb (skb);
32525 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32526 index 272f009..a18ba55 100644
32527 --- a/drivers/atm/idt77252.c
32528 +++ b/drivers/atm/idt77252.c
32529 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32530 else
32531 dev_kfree_skb(skb);
32532
32533 - atomic_inc(&vcc->stats->tx);
32534 + atomic_inc_unchecked(&vcc->stats->tx);
32535 }
32536
32537 atomic_dec(&scq->used);
32538 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32539 if ((sb = dev_alloc_skb(64)) == NULL) {
32540 printk("%s: Can't allocate buffers for aal0.\n",
32541 card->name);
32542 - atomic_add(i, &vcc->stats->rx_drop);
32543 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32544 break;
32545 }
32546 if (!atm_charge(vcc, sb->truesize)) {
32547 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32548 card->name);
32549 - atomic_add(i - 1, &vcc->stats->rx_drop);
32550 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32551 dev_kfree_skb(sb);
32552 break;
32553 }
32554 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32555 ATM_SKB(sb)->vcc = vcc;
32556 __net_timestamp(sb);
32557 vcc->push(vcc, sb);
32558 - atomic_inc(&vcc->stats->rx);
32559 + atomic_inc_unchecked(&vcc->stats->rx);
32560
32561 cell += ATM_CELL_PAYLOAD;
32562 }
32563 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32564 "(CDC: %08x)\n",
32565 card->name, len, rpp->len, readl(SAR_REG_CDC));
32566 recycle_rx_pool_skb(card, rpp);
32567 - atomic_inc(&vcc->stats->rx_err);
32568 + atomic_inc_unchecked(&vcc->stats->rx_err);
32569 return;
32570 }
32571 if (stat & SAR_RSQE_CRC) {
32572 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32573 recycle_rx_pool_skb(card, rpp);
32574 - atomic_inc(&vcc->stats->rx_err);
32575 + atomic_inc_unchecked(&vcc->stats->rx_err);
32576 return;
32577 }
32578 if (skb_queue_len(&rpp->queue) > 1) {
32579 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32580 RXPRINTK("%s: Can't alloc RX skb.\n",
32581 card->name);
32582 recycle_rx_pool_skb(card, rpp);
32583 - atomic_inc(&vcc->stats->rx_err);
32584 + atomic_inc_unchecked(&vcc->stats->rx_err);
32585 return;
32586 }
32587 if (!atm_charge(vcc, skb->truesize)) {
32588 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32589 __net_timestamp(skb);
32590
32591 vcc->push(vcc, skb);
32592 - atomic_inc(&vcc->stats->rx);
32593 + atomic_inc_unchecked(&vcc->stats->rx);
32594
32595 return;
32596 }
32597 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32598 __net_timestamp(skb);
32599
32600 vcc->push(vcc, skb);
32601 - atomic_inc(&vcc->stats->rx);
32602 + atomic_inc_unchecked(&vcc->stats->rx);
32603
32604 if (skb->truesize > SAR_FB_SIZE_3)
32605 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32606 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32607 if (vcc->qos.aal != ATM_AAL0) {
32608 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32609 card->name, vpi, vci);
32610 - atomic_inc(&vcc->stats->rx_drop);
32611 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32612 goto drop;
32613 }
32614
32615 if ((sb = dev_alloc_skb(64)) == NULL) {
32616 printk("%s: Can't allocate buffers for AAL0.\n",
32617 card->name);
32618 - atomic_inc(&vcc->stats->rx_err);
32619 + atomic_inc_unchecked(&vcc->stats->rx_err);
32620 goto drop;
32621 }
32622
32623 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32624 ATM_SKB(sb)->vcc = vcc;
32625 __net_timestamp(sb);
32626 vcc->push(vcc, sb);
32627 - atomic_inc(&vcc->stats->rx);
32628 + atomic_inc_unchecked(&vcc->stats->rx);
32629
32630 drop:
32631 skb_pull(queue, 64);
32632 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32633
32634 if (vc == NULL) {
32635 printk("%s: NULL connection in send().\n", card->name);
32636 - atomic_inc(&vcc->stats->tx_err);
32637 + atomic_inc_unchecked(&vcc->stats->tx_err);
32638 dev_kfree_skb(skb);
32639 return -EINVAL;
32640 }
32641 if (!test_bit(VCF_TX, &vc->flags)) {
32642 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32643 - atomic_inc(&vcc->stats->tx_err);
32644 + atomic_inc_unchecked(&vcc->stats->tx_err);
32645 dev_kfree_skb(skb);
32646 return -EINVAL;
32647 }
32648 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32649 break;
32650 default:
32651 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32652 - atomic_inc(&vcc->stats->tx_err);
32653 + atomic_inc_unchecked(&vcc->stats->tx_err);
32654 dev_kfree_skb(skb);
32655 return -EINVAL;
32656 }
32657
32658 if (skb_shinfo(skb)->nr_frags != 0) {
32659 printk("%s: No scatter-gather yet.\n", card->name);
32660 - atomic_inc(&vcc->stats->tx_err);
32661 + atomic_inc_unchecked(&vcc->stats->tx_err);
32662 dev_kfree_skb(skb);
32663 return -EINVAL;
32664 }
32665 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32666
32667 err = queue_skb(card, vc, skb, oam);
32668 if (err) {
32669 - atomic_inc(&vcc->stats->tx_err);
32670 + atomic_inc_unchecked(&vcc->stats->tx_err);
32671 dev_kfree_skb(skb);
32672 return err;
32673 }
32674 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32675 skb = dev_alloc_skb(64);
32676 if (!skb) {
32677 printk("%s: Out of memory in send_oam().\n", card->name);
32678 - atomic_inc(&vcc->stats->tx_err);
32679 + atomic_inc_unchecked(&vcc->stats->tx_err);
32680 return -ENOMEM;
32681 }
32682 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32683 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32684 index 4217f29..88f547a 100644
32685 --- a/drivers/atm/iphase.c
32686 +++ b/drivers/atm/iphase.c
32687 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32688 status = (u_short) (buf_desc_ptr->desc_mode);
32689 if (status & (RX_CER | RX_PTE | RX_OFL))
32690 {
32691 - atomic_inc(&vcc->stats->rx_err);
32692 + atomic_inc_unchecked(&vcc->stats->rx_err);
32693 IF_ERR(printk("IA: bad packet, dropping it");)
32694 if (status & RX_CER) {
32695 IF_ERR(printk(" cause: packet CRC error\n");)
32696 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32697 len = dma_addr - buf_addr;
32698 if (len > iadev->rx_buf_sz) {
32699 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32700 - atomic_inc(&vcc->stats->rx_err);
32701 + atomic_inc_unchecked(&vcc->stats->rx_err);
32702 goto out_free_desc;
32703 }
32704
32705 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32706 ia_vcc = INPH_IA_VCC(vcc);
32707 if (ia_vcc == NULL)
32708 {
32709 - atomic_inc(&vcc->stats->rx_err);
32710 + atomic_inc_unchecked(&vcc->stats->rx_err);
32711 atm_return(vcc, skb->truesize);
32712 dev_kfree_skb_any(skb);
32713 goto INCR_DLE;
32714 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32715 if ((length > iadev->rx_buf_sz) || (length >
32716 (skb->len - sizeof(struct cpcs_trailer))))
32717 {
32718 - atomic_inc(&vcc->stats->rx_err);
32719 + atomic_inc_unchecked(&vcc->stats->rx_err);
32720 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32721 length, skb->len);)
32722 atm_return(vcc, skb->truesize);
32723 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32724
32725 IF_RX(printk("rx_dle_intr: skb push");)
32726 vcc->push(vcc,skb);
32727 - atomic_inc(&vcc->stats->rx);
32728 + atomic_inc_unchecked(&vcc->stats->rx);
32729 iadev->rx_pkt_cnt++;
32730 }
32731 INCR_DLE:
32732 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32733 {
32734 struct k_sonet_stats *stats;
32735 stats = &PRIV(_ia_dev[board])->sonet_stats;
32736 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32737 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32738 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32739 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32740 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32741 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32742 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32743 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32744 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32745 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32746 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32747 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32748 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32749 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32750 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32751 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32752 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32753 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32754 }
32755 ia_cmds.status = 0;
32756 break;
32757 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32758 if ((desc == 0) || (desc > iadev->num_tx_desc))
32759 {
32760 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32761 - atomic_inc(&vcc->stats->tx);
32762 + atomic_inc_unchecked(&vcc->stats->tx);
32763 if (vcc->pop)
32764 vcc->pop(vcc, skb);
32765 else
32766 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32767 ATM_DESC(skb) = vcc->vci;
32768 skb_queue_tail(&iadev->tx_dma_q, skb);
32769
32770 - atomic_inc(&vcc->stats->tx);
32771 + atomic_inc_unchecked(&vcc->stats->tx);
32772 iadev->tx_pkt_cnt++;
32773 /* Increment transaction counter */
32774 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32775
32776 #if 0
32777 /* add flow control logic */
32778 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32779 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32780 if (iavcc->vc_desc_cnt > 10) {
32781 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32782 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32783 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32784 index fa7d701..1e404c7 100644
32785 --- a/drivers/atm/lanai.c
32786 +++ b/drivers/atm/lanai.c
32787 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32788 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32789 lanai_endtx(lanai, lvcc);
32790 lanai_free_skb(lvcc->tx.atmvcc, skb);
32791 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32792 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32793 }
32794
32795 /* Try to fill the buffer - don't call unless there is backlog */
32796 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32797 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32798 __net_timestamp(skb);
32799 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32800 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32801 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32802 out:
32803 lvcc->rx.buf.ptr = end;
32804 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32805 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32806 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32807 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32808 lanai->stats.service_rxnotaal5++;
32809 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32810 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32811 return 0;
32812 }
32813 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32814 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32815 int bytes;
32816 read_unlock(&vcc_sklist_lock);
32817 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32818 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32819 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32820 lvcc->stats.x.aal5.service_trash++;
32821 bytes = (SERVICE_GET_END(s) * 16) -
32822 (((unsigned long) lvcc->rx.buf.ptr) -
32823 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32824 }
32825 if (s & SERVICE_STREAM) {
32826 read_unlock(&vcc_sklist_lock);
32827 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32828 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32829 lvcc->stats.x.aal5.service_stream++;
32830 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32831 "PDU on VCI %d!\n", lanai->number, vci);
32832 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32833 return 0;
32834 }
32835 DPRINTK("got rx crc error on vci %d\n", vci);
32836 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32837 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32838 lvcc->stats.x.aal5.service_rxcrc++;
32839 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32840 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32841 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32842 index 6587dc2..149833d 100644
32843 --- a/drivers/atm/nicstar.c
32844 +++ b/drivers/atm/nicstar.c
32845 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32846 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32847 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32848 card->index);
32849 - atomic_inc(&vcc->stats->tx_err);
32850 + atomic_inc_unchecked(&vcc->stats->tx_err);
32851 dev_kfree_skb_any(skb);
32852 return -EINVAL;
32853 }
32854 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32855 if (!vc->tx) {
32856 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32857 card->index);
32858 - atomic_inc(&vcc->stats->tx_err);
32859 + atomic_inc_unchecked(&vcc->stats->tx_err);
32860 dev_kfree_skb_any(skb);
32861 return -EINVAL;
32862 }
32863 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32864 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32865 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32866 card->index);
32867 - atomic_inc(&vcc->stats->tx_err);
32868 + atomic_inc_unchecked(&vcc->stats->tx_err);
32869 dev_kfree_skb_any(skb);
32870 return -EINVAL;
32871 }
32872
32873 if (skb_shinfo(skb)->nr_frags != 0) {
32874 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32875 - atomic_inc(&vcc->stats->tx_err);
32876 + atomic_inc_unchecked(&vcc->stats->tx_err);
32877 dev_kfree_skb_any(skb);
32878 return -EINVAL;
32879 }
32880 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32881 }
32882
32883 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32884 - atomic_inc(&vcc->stats->tx_err);
32885 + atomic_inc_unchecked(&vcc->stats->tx_err);
32886 dev_kfree_skb_any(skb);
32887 return -EIO;
32888 }
32889 - atomic_inc(&vcc->stats->tx);
32890 + atomic_inc_unchecked(&vcc->stats->tx);
32891
32892 return 0;
32893 }
32894 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32895 printk
32896 ("nicstar%d: Can't allocate buffers for aal0.\n",
32897 card->index);
32898 - atomic_add(i, &vcc->stats->rx_drop);
32899 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32900 break;
32901 }
32902 if (!atm_charge(vcc, sb->truesize)) {
32903 RXPRINTK
32904 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32905 card->index);
32906 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32907 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32908 dev_kfree_skb_any(sb);
32909 break;
32910 }
32911 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32912 ATM_SKB(sb)->vcc = vcc;
32913 __net_timestamp(sb);
32914 vcc->push(vcc, sb);
32915 - atomic_inc(&vcc->stats->rx);
32916 + atomic_inc_unchecked(&vcc->stats->rx);
32917 cell += ATM_CELL_PAYLOAD;
32918 }
32919
32920 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32921 if (iovb == NULL) {
32922 printk("nicstar%d: Out of iovec buffers.\n",
32923 card->index);
32924 - atomic_inc(&vcc->stats->rx_drop);
32925 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32926 recycle_rx_buf(card, skb);
32927 return;
32928 }
32929 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32930 small or large buffer itself. */
32931 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32932 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32933 - atomic_inc(&vcc->stats->rx_err);
32934 + atomic_inc_unchecked(&vcc->stats->rx_err);
32935 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32936 NS_MAX_IOVECS);
32937 NS_PRV_IOVCNT(iovb) = 0;
32938 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32939 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32940 card->index);
32941 which_list(card, skb);
32942 - atomic_inc(&vcc->stats->rx_err);
32943 + atomic_inc_unchecked(&vcc->stats->rx_err);
32944 recycle_rx_buf(card, skb);
32945 vc->rx_iov = NULL;
32946 recycle_iov_buf(card, iovb);
32947 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32948 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32949 card->index);
32950 which_list(card, skb);
32951 - atomic_inc(&vcc->stats->rx_err);
32952 + atomic_inc_unchecked(&vcc->stats->rx_err);
32953 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32954 NS_PRV_IOVCNT(iovb));
32955 vc->rx_iov = NULL;
32956 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32957 printk(" - PDU size mismatch.\n");
32958 else
32959 printk(".\n");
32960 - atomic_inc(&vcc->stats->rx_err);
32961 + atomic_inc_unchecked(&vcc->stats->rx_err);
32962 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32963 NS_PRV_IOVCNT(iovb));
32964 vc->rx_iov = NULL;
32965 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32966 /* skb points to a small buffer */
32967 if (!atm_charge(vcc, skb->truesize)) {
32968 push_rxbufs(card, skb);
32969 - atomic_inc(&vcc->stats->rx_drop);
32970 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32971 } else {
32972 skb_put(skb, len);
32973 dequeue_sm_buf(card, skb);
32974 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32975 ATM_SKB(skb)->vcc = vcc;
32976 __net_timestamp(skb);
32977 vcc->push(vcc, skb);
32978 - atomic_inc(&vcc->stats->rx);
32979 + atomic_inc_unchecked(&vcc->stats->rx);
32980 }
32981 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32982 struct sk_buff *sb;
32983 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32984 if (len <= NS_SMBUFSIZE) {
32985 if (!atm_charge(vcc, sb->truesize)) {
32986 push_rxbufs(card, sb);
32987 - atomic_inc(&vcc->stats->rx_drop);
32988 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32989 } else {
32990 skb_put(sb, len);
32991 dequeue_sm_buf(card, sb);
32992 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32993 ATM_SKB(sb)->vcc = vcc;
32994 __net_timestamp(sb);
32995 vcc->push(vcc, sb);
32996 - atomic_inc(&vcc->stats->rx);
32997 + atomic_inc_unchecked(&vcc->stats->rx);
32998 }
32999
33000 push_rxbufs(card, skb);
33001 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33002
33003 if (!atm_charge(vcc, skb->truesize)) {
33004 push_rxbufs(card, skb);
33005 - atomic_inc(&vcc->stats->rx_drop);
33006 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33007 } else {
33008 dequeue_lg_buf(card, skb);
33009 #ifdef NS_USE_DESTRUCTORS
33010 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33011 ATM_SKB(skb)->vcc = vcc;
33012 __net_timestamp(skb);
33013 vcc->push(vcc, skb);
33014 - atomic_inc(&vcc->stats->rx);
33015 + atomic_inc_unchecked(&vcc->stats->rx);
33016 }
33017
33018 push_rxbufs(card, sb);
33019 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33020 printk
33021 ("nicstar%d: Out of huge buffers.\n",
33022 card->index);
33023 - atomic_inc(&vcc->stats->rx_drop);
33024 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33025 recycle_iovec_rx_bufs(card,
33026 (struct iovec *)
33027 iovb->data,
33028 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33029 card->hbpool.count++;
33030 } else
33031 dev_kfree_skb_any(hb);
33032 - atomic_inc(&vcc->stats->rx_drop);
33033 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33034 } else {
33035 /* Copy the small buffer to the huge buffer */
33036 sb = (struct sk_buff *)iov->iov_base;
33037 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33038 #endif /* NS_USE_DESTRUCTORS */
33039 __net_timestamp(hb);
33040 vcc->push(vcc, hb);
33041 - atomic_inc(&vcc->stats->rx);
33042 + atomic_inc_unchecked(&vcc->stats->rx);
33043 }
33044 }
33045
33046 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33047 index 32784d1..4a8434a 100644
33048 --- a/drivers/atm/solos-pci.c
33049 +++ b/drivers/atm/solos-pci.c
33050 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33051 }
33052 atm_charge(vcc, skb->truesize);
33053 vcc->push(vcc, skb);
33054 - atomic_inc(&vcc->stats->rx);
33055 + atomic_inc_unchecked(&vcc->stats->rx);
33056 break;
33057
33058 case PKT_STATUS:
33059 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33060 vcc = SKB_CB(oldskb)->vcc;
33061
33062 if (vcc) {
33063 - atomic_inc(&vcc->stats->tx);
33064 + atomic_inc_unchecked(&vcc->stats->tx);
33065 solos_pop(vcc, oldskb);
33066 } else {
33067 dev_kfree_skb_irq(oldskb);
33068 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33069 index 0215934..ce9f5b1 100644
33070 --- a/drivers/atm/suni.c
33071 +++ b/drivers/atm/suni.c
33072 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33073
33074
33075 #define ADD_LIMITED(s,v) \
33076 - atomic_add((v),&stats->s); \
33077 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33078 + atomic_add_unchecked((v),&stats->s); \
33079 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33080
33081
33082 static void suni_hz(unsigned long from_timer)
33083 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33084 index 5120a96..e2572bd 100644
33085 --- a/drivers/atm/uPD98402.c
33086 +++ b/drivers/atm/uPD98402.c
33087 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33088 struct sonet_stats tmp;
33089 int error = 0;
33090
33091 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33092 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33093 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33094 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33095 if (zero && !error) {
33096 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33097
33098
33099 #define ADD_LIMITED(s,v) \
33100 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33101 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33102 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33103 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33104 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33105 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33106
33107
33108 static void stat_event(struct atm_dev *dev)
33109 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33110 if (reason & uPD98402_INT_PFM) stat_event(dev);
33111 if (reason & uPD98402_INT_PCO) {
33112 (void) GET(PCOCR); /* clear interrupt cause */
33113 - atomic_add(GET(HECCT),
33114 + atomic_add_unchecked(GET(HECCT),
33115 &PRIV(dev)->sonet_stats.uncorr_hcs);
33116 }
33117 if ((reason & uPD98402_INT_RFO) &&
33118 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33119 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33120 uPD98402_INT_LOS),PIMR); /* enable them */
33121 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33122 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33123 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33124 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33125 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33126 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33127 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33128 return 0;
33129 }
33130
33131 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33132 index 969c3c2..9b72956 100644
33133 --- a/drivers/atm/zatm.c
33134 +++ b/drivers/atm/zatm.c
33135 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33136 }
33137 if (!size) {
33138 dev_kfree_skb_irq(skb);
33139 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33140 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33141 continue;
33142 }
33143 if (!atm_charge(vcc,skb->truesize)) {
33144 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33145 skb->len = size;
33146 ATM_SKB(skb)->vcc = vcc;
33147 vcc->push(vcc,skb);
33148 - atomic_inc(&vcc->stats->rx);
33149 + atomic_inc_unchecked(&vcc->stats->rx);
33150 }
33151 zout(pos & 0xffff,MTA(mbx));
33152 #if 0 /* probably a stupid idea */
33153 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33154 skb_queue_head(&zatm_vcc->backlog,skb);
33155 break;
33156 }
33157 - atomic_inc(&vcc->stats->tx);
33158 + atomic_inc_unchecked(&vcc->stats->tx);
33159 wake_up(&zatm_vcc->tx_wait);
33160 }
33161
33162 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33163 index d78b204..ecc1929 100644
33164 --- a/drivers/base/attribute_container.c
33165 +++ b/drivers/base/attribute_container.c
33166 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33167 ic->classdev.parent = get_device(dev);
33168 ic->classdev.class = cont->class;
33169 cont->class->dev_release = attribute_container_release;
33170 - dev_set_name(&ic->classdev, dev_name(dev));
33171 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33172 if (fn)
33173 fn(cont, dev, &ic->classdev);
33174 else
33175 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33176 index d414331..b4dd4ba 100644
33177 --- a/drivers/base/bus.c
33178 +++ b/drivers/base/bus.c
33179 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33180 return -EINVAL;
33181
33182 mutex_lock(&subsys->p->mutex);
33183 - list_add_tail(&sif->node, &subsys->p->interfaces);
33184 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33185 if (sif->add_dev) {
33186 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33187 while ((dev = subsys_dev_iter_next(&iter)))
33188 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33189 subsys = sif->subsys;
33190
33191 mutex_lock(&subsys->p->mutex);
33192 - list_del_init(&sif->node);
33193 + pax_list_del_init((struct list_head *)&sif->node);
33194 if (sif->remove_dev) {
33195 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33196 while ((dev = subsys_dev_iter_next(&iter)))
33197 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33198 index 7413d06..79155fa 100644
33199 --- a/drivers/base/devtmpfs.c
33200 +++ b/drivers/base/devtmpfs.c
33201 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
33202 if (!thread)
33203 return 0;
33204
33205 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33206 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33207 if (err)
33208 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33209 else
33210 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
33211 *err = sys_unshare(CLONE_NEWNS);
33212 if (*err)
33213 goto out;
33214 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33215 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33216 if (*err)
33217 goto out;
33218 - sys_chdir("/.."); /* will traverse into overmounted root */
33219 - sys_chroot(".");
33220 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33221 + sys_chroot((char __force_user *)".");
33222 complete(&setup_done);
33223 while (1) {
33224 spin_lock(&req_lock);
33225 diff --git a/drivers/base/node.c b/drivers/base/node.c
33226 index 7616a77c..8f57f51 100644
33227 --- a/drivers/base/node.c
33228 +++ b/drivers/base/node.c
33229 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33230 struct node_attr {
33231 struct device_attribute attr;
33232 enum node_states state;
33233 -};
33234 +} __do_const;
33235
33236 static ssize_t show_node_state(struct device *dev,
33237 struct device_attribute *attr, char *buf)
33238 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33239 index 7072404..76dcebd 100644
33240 --- a/drivers/base/power/domain.c
33241 +++ b/drivers/base/power/domain.c
33242 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33243 {
33244 struct cpuidle_driver *cpuidle_drv;
33245 struct gpd_cpu_data *cpu_data;
33246 - struct cpuidle_state *idle_state;
33247 + cpuidle_state_no_const *idle_state;
33248 int ret = 0;
33249
33250 if (IS_ERR_OR_NULL(genpd) || state < 0)
33251 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33252 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33253 {
33254 struct gpd_cpu_data *cpu_data;
33255 - struct cpuidle_state *idle_state;
33256 + cpuidle_state_no_const *idle_state;
33257 int ret = 0;
33258
33259 if (IS_ERR_OR_NULL(genpd))
33260 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33261 index a53ebd2..8f73eeb 100644
33262 --- a/drivers/base/power/sysfs.c
33263 +++ b/drivers/base/power/sysfs.c
33264 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33265 return -EIO;
33266 }
33267 }
33268 - return sprintf(buf, p);
33269 + return sprintf(buf, "%s", p);
33270 }
33271
33272 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33273 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33274 index 79715e7..df06b3b 100644
33275 --- a/drivers/base/power/wakeup.c
33276 +++ b/drivers/base/power/wakeup.c
33277 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33278 * They need to be modified together atomically, so it's better to use one
33279 * atomic variable to hold them both.
33280 */
33281 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33282 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33283
33284 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33285 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33286
33287 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33288 {
33289 - unsigned int comb = atomic_read(&combined_event_count);
33290 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33291
33292 *cnt = (comb >> IN_PROGRESS_BITS);
33293 *inpr = comb & MAX_IN_PROGRESS;
33294 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33295 ws->start_prevent_time = ws->last_time;
33296
33297 /* Increment the counter of events in progress. */
33298 - cec = atomic_inc_return(&combined_event_count);
33299 + cec = atomic_inc_return_unchecked(&combined_event_count);
33300
33301 trace_wakeup_source_activate(ws->name, cec);
33302 }
33303 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33304 * Increment the counter of registered wakeup events and decrement the
33305 * couter of wakeup events in progress simultaneously.
33306 */
33307 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33308 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33309 trace_wakeup_source_deactivate(ws->name, cec);
33310
33311 split_counters(&cnt, &inpr);
33312 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33313 index e8d11b6..7b1b36f 100644
33314 --- a/drivers/base/syscore.c
33315 +++ b/drivers/base/syscore.c
33316 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33317 void register_syscore_ops(struct syscore_ops *ops)
33318 {
33319 mutex_lock(&syscore_ops_lock);
33320 - list_add_tail(&ops->node, &syscore_ops_list);
33321 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33322 mutex_unlock(&syscore_ops_lock);
33323 }
33324 EXPORT_SYMBOL_GPL(register_syscore_ops);
33325 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33326 void unregister_syscore_ops(struct syscore_ops *ops)
33327 {
33328 mutex_lock(&syscore_ops_lock);
33329 - list_del(&ops->node);
33330 + pax_list_del((struct list_head *)&ops->node);
33331 mutex_unlock(&syscore_ops_lock);
33332 }
33333 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33334 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33335 index 62b6c2c..4a11354 100644
33336 --- a/drivers/block/cciss.c
33337 +++ b/drivers/block/cciss.c
33338 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33339 int err;
33340 u32 cp;
33341
33342 + memset(&arg64, 0, sizeof(arg64));
33343 +
33344 err = 0;
33345 err |=
33346 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33347 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
33348 while (!list_empty(&h->reqQ)) {
33349 c = list_entry(h->reqQ.next, CommandList_struct, list);
33350 /* can't do anything if fifo is full */
33351 - if ((h->access.fifo_full(h))) {
33352 + if ((h->access->fifo_full(h))) {
33353 dev_warn(&h->pdev->dev, "fifo full\n");
33354 break;
33355 }
33356 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
33357 h->Qdepth--;
33358
33359 /* Tell the controller execute command */
33360 - h->access.submit_command(h, c);
33361 + h->access->submit_command(h, c);
33362
33363 /* Put job onto the completed Q */
33364 addQ(&h->cmpQ, c);
33365 @@ -3446,17 +3448,17 @@ startio:
33366
33367 static inline unsigned long get_next_completion(ctlr_info_t *h)
33368 {
33369 - return h->access.command_completed(h);
33370 + return h->access->command_completed(h);
33371 }
33372
33373 static inline int interrupt_pending(ctlr_info_t *h)
33374 {
33375 - return h->access.intr_pending(h);
33376 + return h->access->intr_pending(h);
33377 }
33378
33379 static inline long interrupt_not_for_us(ctlr_info_t *h)
33380 {
33381 - return ((h->access.intr_pending(h) == 0) ||
33382 + return ((h->access->intr_pending(h) == 0) ||
33383 (h->interrupts_enabled == 0));
33384 }
33385
33386 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
33387 u32 a;
33388
33389 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33390 - return h->access.command_completed(h);
33391 + return h->access->command_completed(h);
33392
33393 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33394 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33395 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33396 trans_support & CFGTBL_Trans_use_short_tags);
33397
33398 /* Change the access methods to the performant access methods */
33399 - h->access = SA5_performant_access;
33400 + h->access = &SA5_performant_access;
33401 h->transMethod = CFGTBL_Trans_Performant;
33402
33403 return;
33404 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33405 if (prod_index < 0)
33406 return -ENODEV;
33407 h->product_name = products[prod_index].product_name;
33408 - h->access = *(products[prod_index].access);
33409 + h->access = products[prod_index].access;
33410
33411 if (cciss_board_disabled(h)) {
33412 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33413 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
33414 }
33415
33416 /* make sure the board interrupts are off */
33417 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33418 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33419 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33420 if (rc)
33421 goto clean2;
33422 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
33423 * fake ones to scoop up any residual completions.
33424 */
33425 spin_lock_irqsave(&h->lock, flags);
33426 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33427 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33428 spin_unlock_irqrestore(&h->lock, flags);
33429 free_irq(h->intr[h->intr_mode], h);
33430 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33431 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
33432 dev_info(&h->pdev->dev, "Board READY.\n");
33433 dev_info(&h->pdev->dev,
33434 "Waiting for stale completions to drain.\n");
33435 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33436 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33437 msleep(10000);
33438 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33439 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33440
33441 rc = controller_reset_failed(h->cfgtable);
33442 if (rc)
33443 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
33444 cciss_scsi_setup(h);
33445
33446 /* Turn the interrupts on so we can service requests */
33447 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33448 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33449
33450 /* Get the firmware version */
33451 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33452 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33453 kfree(flush_buf);
33454 if (return_code != IO_OK)
33455 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33456 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33457 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33458 free_irq(h->intr[h->intr_mode], h);
33459 }
33460
33461 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33462 index 7fda30e..eb5dfe0 100644
33463 --- a/drivers/block/cciss.h
33464 +++ b/drivers/block/cciss.h
33465 @@ -101,7 +101,7 @@ struct ctlr_info
33466 /* information about each logical volume */
33467 drive_info_struct *drv[CISS_MAX_LUN];
33468
33469 - struct access_method access;
33470 + struct access_method *access;
33471
33472 /* queue and queue Info */
33473 struct list_head reqQ;
33474 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33475 index 639d26b..fd6ad1f 100644
33476 --- a/drivers/block/cpqarray.c
33477 +++ b/drivers/block/cpqarray.c
33478 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33479 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33480 goto Enomem4;
33481 }
33482 - hba[i]->access.set_intr_mask(hba[i], 0);
33483 + hba[i]->access->set_intr_mask(hba[i], 0);
33484 if (request_irq(hba[i]->intr, do_ida_intr,
33485 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33486 {
33487 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33488 add_timer(&hba[i]->timer);
33489
33490 /* Enable IRQ now that spinlock and rate limit timer are set up */
33491 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33492 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33493
33494 for(j=0; j<NWD; j++) {
33495 struct gendisk *disk = ida_gendisk[i][j];
33496 @@ -694,7 +694,7 @@ DBGINFO(
33497 for(i=0; i<NR_PRODUCTS; i++) {
33498 if (board_id == products[i].board_id) {
33499 c->product_name = products[i].product_name;
33500 - c->access = *(products[i].access);
33501 + c->access = products[i].access;
33502 break;
33503 }
33504 }
33505 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33506 hba[ctlr]->intr = intr;
33507 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33508 hba[ctlr]->product_name = products[j].product_name;
33509 - hba[ctlr]->access = *(products[j].access);
33510 + hba[ctlr]->access = products[j].access;
33511 hba[ctlr]->ctlr = ctlr;
33512 hba[ctlr]->board_id = board_id;
33513 hba[ctlr]->pci_dev = NULL; /* not PCI */
33514 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
33515
33516 while((c = h->reqQ) != NULL) {
33517 /* Can't do anything if we're busy */
33518 - if (h->access.fifo_full(h) == 0)
33519 + if (h->access->fifo_full(h) == 0)
33520 return;
33521
33522 /* Get the first entry from the request Q */
33523 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
33524 h->Qdepth--;
33525
33526 /* Tell the controller to do our bidding */
33527 - h->access.submit_command(h, c);
33528 + h->access->submit_command(h, c);
33529
33530 /* Get onto the completion Q */
33531 addQ(&h->cmpQ, c);
33532 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33533 unsigned long flags;
33534 __u32 a,a1;
33535
33536 - istat = h->access.intr_pending(h);
33537 + istat = h->access->intr_pending(h);
33538 /* Is this interrupt for us? */
33539 if (istat == 0)
33540 return IRQ_NONE;
33541 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33542 */
33543 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33544 if (istat & FIFO_NOT_EMPTY) {
33545 - while((a = h->access.command_completed(h))) {
33546 + while((a = h->access->command_completed(h))) {
33547 a1 = a; a &= ~3;
33548 if ((c = h->cmpQ) == NULL)
33549 {
33550 @@ -1193,6 +1193,7 @@ out_passthru:
33551 ida_pci_info_struct pciinfo;
33552
33553 if (!arg) return -EINVAL;
33554 + memset(&pciinfo, 0, sizeof(pciinfo));
33555 pciinfo.bus = host->pci_dev->bus->number;
33556 pciinfo.dev_fn = host->pci_dev->devfn;
33557 pciinfo.board_id = host->board_id;
33558 @@ -1447,11 +1448,11 @@ static int sendcmd(
33559 /*
33560 * Disable interrupt
33561 */
33562 - info_p->access.set_intr_mask(info_p, 0);
33563 + info_p->access->set_intr_mask(info_p, 0);
33564 /* Make sure there is room in the command FIFO */
33565 /* Actually it should be completely empty at this time. */
33566 for (i = 200000; i > 0; i--) {
33567 - temp = info_p->access.fifo_full(info_p);
33568 + temp = info_p->access->fifo_full(info_p);
33569 if (temp != 0) {
33570 break;
33571 }
33572 @@ -1464,7 +1465,7 @@ DBG(
33573 /*
33574 * Send the cmd
33575 */
33576 - info_p->access.submit_command(info_p, c);
33577 + info_p->access->submit_command(info_p, c);
33578 complete = pollcomplete(ctlr);
33579
33580 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33581 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33582 * we check the new geometry. Then turn interrupts back on when
33583 * we're done.
33584 */
33585 - host->access.set_intr_mask(host, 0);
33586 + host->access->set_intr_mask(host, 0);
33587 getgeometry(ctlr);
33588 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33589 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33590
33591 for(i=0; i<NWD; i++) {
33592 struct gendisk *disk = ida_gendisk[ctlr][i];
33593 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
33594 /* Wait (up to 2 seconds) for a command to complete */
33595
33596 for (i = 200000; i > 0; i--) {
33597 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33598 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33599 if (done == 0) {
33600 udelay(10); /* a short fixed delay */
33601 } else
33602 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33603 index be73e9d..7fbf140 100644
33604 --- a/drivers/block/cpqarray.h
33605 +++ b/drivers/block/cpqarray.h
33606 @@ -99,7 +99,7 @@ struct ctlr_info {
33607 drv_info_t drv[NWD];
33608 struct proc_dir_entry *proc;
33609
33610 - struct access_method access;
33611 + struct access_method *access;
33612
33613 cmdlist_t *reqQ;
33614 cmdlist_t *cmpQ;
33615 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33616 index f943aac..99bfd19 100644
33617 --- a/drivers/block/drbd/drbd_int.h
33618 +++ b/drivers/block/drbd/drbd_int.h
33619 @@ -582,7 +582,7 @@ struct drbd_epoch {
33620 struct drbd_tconn *tconn;
33621 struct list_head list;
33622 unsigned int barrier_nr;
33623 - atomic_t epoch_size; /* increased on every request added. */
33624 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33625 atomic_t active; /* increased on every req. added, and dec on every finished. */
33626 unsigned long flags;
33627 };
33628 @@ -1021,7 +1021,7 @@ struct drbd_conf {
33629 unsigned int al_tr_number;
33630 int al_tr_cycle;
33631 wait_queue_head_t seq_wait;
33632 - atomic_t packet_seq;
33633 + atomic_unchecked_t packet_seq;
33634 unsigned int peer_seq;
33635 spinlock_t peer_seq_lock;
33636 unsigned int minor;
33637 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33638 char __user *uoptval;
33639 int err;
33640
33641 - uoptval = (char __user __force *)optval;
33642 + uoptval = (char __force_user *)optval;
33643
33644 set_fs(KERNEL_DS);
33645 if (level == SOL_SOCKET)
33646 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33647 index a5dca6a..bb27967 100644
33648 --- a/drivers/block/drbd/drbd_main.c
33649 +++ b/drivers/block/drbd/drbd_main.c
33650 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33651 p->sector = sector;
33652 p->block_id = block_id;
33653 p->blksize = blksize;
33654 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33655 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33656 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33657 }
33658
33659 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33660 return -EIO;
33661 p->sector = cpu_to_be64(req->i.sector);
33662 p->block_id = (unsigned long)req;
33663 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33664 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33665 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33666 if (mdev->state.conn >= C_SYNC_SOURCE &&
33667 mdev->state.conn <= C_PAUSED_SYNC_T)
33668 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33669 {
33670 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33671
33672 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33673 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33674 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33675 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33676 kfree(tconn->current_epoch);
33677
33678 idr_destroy(&tconn->volumes);
33679 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33680 index 4222aff..1f79506 100644
33681 --- a/drivers/block/drbd/drbd_receiver.c
33682 +++ b/drivers/block/drbd/drbd_receiver.c
33683 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
33684 {
33685 int err;
33686
33687 - atomic_set(&mdev->packet_seq, 0);
33688 + atomic_set_unchecked(&mdev->packet_seq, 0);
33689 mdev->peer_seq = 0;
33690
33691 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33692 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33693 do {
33694 next_epoch = NULL;
33695
33696 - epoch_size = atomic_read(&epoch->epoch_size);
33697 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33698
33699 switch (ev & ~EV_CLEANUP) {
33700 case EV_PUT:
33701 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33702 rv = FE_DESTROYED;
33703 } else {
33704 epoch->flags = 0;
33705 - atomic_set(&epoch->epoch_size, 0);
33706 + atomic_set_unchecked(&epoch->epoch_size, 0);
33707 /* atomic_set(&epoch->active, 0); is already zero */
33708 if (rv == FE_STILL_LIVE)
33709 rv = FE_RECYCLED;
33710 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33711 conn_wait_active_ee_empty(tconn);
33712 drbd_flush(tconn);
33713
33714 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33715 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33716 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33717 if (epoch)
33718 break;
33719 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33720 }
33721
33722 epoch->flags = 0;
33723 - atomic_set(&epoch->epoch_size, 0);
33724 + atomic_set_unchecked(&epoch->epoch_size, 0);
33725 atomic_set(&epoch->active, 0);
33726
33727 spin_lock(&tconn->epoch_lock);
33728 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33729 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33730 list_add(&epoch->list, &tconn->current_epoch->list);
33731 tconn->current_epoch = epoch;
33732 tconn->epochs++;
33733 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33734
33735 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33736 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33737 - atomic_inc(&tconn->current_epoch->epoch_size);
33738 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33739 err2 = drbd_drain_block(mdev, pi->size);
33740 if (!err)
33741 err = err2;
33742 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33743
33744 spin_lock(&tconn->epoch_lock);
33745 peer_req->epoch = tconn->current_epoch;
33746 - atomic_inc(&peer_req->epoch->epoch_size);
33747 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33748 atomic_inc(&peer_req->epoch->active);
33749 spin_unlock(&tconn->epoch_lock);
33750
33751 @@ -4347,7 +4347,7 @@ struct data_cmd {
33752 int expect_payload;
33753 size_t pkt_size;
33754 int (*fn)(struct drbd_tconn *, struct packet_info *);
33755 -};
33756 +} __do_const;
33757
33758 static struct data_cmd drbd_cmd_handler[] = {
33759 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33760 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33761 if (!list_empty(&tconn->current_epoch->list))
33762 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33763 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33764 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33765 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33766 tconn->send.seen_any_write_yet = false;
33767
33768 conn_info(tconn, "Connection closed\n");
33769 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33770 struct asender_cmd {
33771 size_t pkt_size;
33772 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33773 -};
33774 +} __do_const;
33775
33776 static struct asender_cmd asender_tbl[] = {
33777 [P_PING] = { 0, got_Ping },
33778 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33779 index d92d50f..a7e9d97 100644
33780 --- a/drivers/block/loop.c
33781 +++ b/drivers/block/loop.c
33782 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
33783
33784 file_start_write(file);
33785 set_fs(get_ds());
33786 - bw = file->f_op->write(file, buf, len, &pos);
33787 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33788 set_fs(old_fs);
33789 file_end_write(file);
33790 if (likely(bw == len))
33791 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33792 index f5d0ea1..c62380a 100644
33793 --- a/drivers/block/pktcdvd.c
33794 +++ b/drivers/block/pktcdvd.c
33795 @@ -84,7 +84,7 @@
33796 #define MAX_SPEED 0xffff
33797
33798 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
33799 - ~(sector_t)((pd)->settings.size - 1))
33800 + ~(sector_t)((pd)->settings.size - 1UL))
33801
33802 static DEFINE_MUTEX(pktcdvd_mutex);
33803 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33804 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33805 index 8a3aff7..d7538c2 100644
33806 --- a/drivers/cdrom/cdrom.c
33807 +++ b/drivers/cdrom/cdrom.c
33808 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33809 ENSURE(reset, CDC_RESET);
33810 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33811 cdi->mc_flags = 0;
33812 - cdo->n_minors = 0;
33813 cdi->options = CDO_USE_FFLAGS;
33814
33815 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33816 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33817 else
33818 cdi->cdda_method = CDDA_OLD;
33819
33820 - if (!cdo->generic_packet)
33821 - cdo->generic_packet = cdrom_dummy_generic_packet;
33822 + if (!cdo->generic_packet) {
33823 + pax_open_kernel();
33824 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33825 + pax_close_kernel();
33826 + }
33827
33828 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33829 mutex_lock(&cdrom_mutex);
33830 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33831 if (cdi->exit)
33832 cdi->exit(cdi);
33833
33834 - cdi->ops->n_minors--;
33835 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33836 }
33837
33838 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33839 */
33840 nr = nframes;
33841 do {
33842 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33843 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33844 if (cgc.buffer)
33845 break;
33846
33847 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33848 struct cdrom_device_info *cdi;
33849 int ret;
33850
33851 - ret = scnprintf(info + *pos, max_size - *pos, header);
33852 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33853 if (!ret)
33854 return 1;
33855
33856 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33857 index 4afcb65..a68a32d 100644
33858 --- a/drivers/cdrom/gdrom.c
33859 +++ b/drivers/cdrom/gdrom.c
33860 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33861 .audio_ioctl = gdrom_audio_ioctl,
33862 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33863 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33864 - .n_minors = 1,
33865 };
33866
33867 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33868 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33869 index 3bb6fa3..34013fb 100644
33870 --- a/drivers/char/Kconfig
33871 +++ b/drivers/char/Kconfig
33872 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33873
33874 config DEVKMEM
33875 bool "/dev/kmem virtual device support"
33876 - default y
33877 + default n
33878 + depends on !GRKERNSEC_KMEM
33879 help
33880 Say Y here if you want to support the /dev/kmem device. The
33881 /dev/kmem device is rarely used, but can be used for certain
33882 @@ -582,6 +583,7 @@ config DEVPORT
33883 bool
33884 depends on !M68K
33885 depends on ISA || PCI
33886 + depends on !GRKERNSEC_KMEM
33887 default y
33888
33889 source "drivers/s390/char/Kconfig"
33890 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33891 index a48e05b..6bac831 100644
33892 --- a/drivers/char/agp/compat_ioctl.c
33893 +++ b/drivers/char/agp/compat_ioctl.c
33894 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33895 return -ENOMEM;
33896 }
33897
33898 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33899 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33900 sizeof(*usegment) * ureserve.seg_count)) {
33901 kfree(usegment);
33902 kfree(ksegment);
33903 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33904 index 2e04433..771f2cc 100644
33905 --- a/drivers/char/agp/frontend.c
33906 +++ b/drivers/char/agp/frontend.c
33907 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33908 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33909 return -EFAULT;
33910
33911 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33912 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33913 return -EFAULT;
33914
33915 client = agp_find_client_by_pid(reserve.pid);
33916 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33917 if (segment == NULL)
33918 return -ENOMEM;
33919
33920 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33921 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33922 sizeof(struct agp_segment) * reserve.seg_count)) {
33923 kfree(segment);
33924 return -EFAULT;
33925 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33926 index 4f94375..413694e 100644
33927 --- a/drivers/char/genrtc.c
33928 +++ b/drivers/char/genrtc.c
33929 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
33930 switch (cmd) {
33931
33932 case RTC_PLL_GET:
33933 + memset(&pll, 0, sizeof(pll));
33934 if (get_rtc_pll(&pll))
33935 return -EINVAL;
33936 else
33937 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33938 index d784650..e8bfd69 100644
33939 --- a/drivers/char/hpet.c
33940 +++ b/drivers/char/hpet.c
33941 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33942 }
33943
33944 static int
33945 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33946 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33947 struct hpet_info *info)
33948 {
33949 struct hpet_timer __iomem *timer;
33950 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33951 index 86fe45c..c0ea948 100644
33952 --- a/drivers/char/hw_random/intel-rng.c
33953 +++ b/drivers/char/hw_random/intel-rng.c
33954 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33955
33956 if (no_fwh_detect)
33957 return -ENODEV;
33958 - printk(warning);
33959 + printk("%s", warning);
33960 return -EBUSY;
33961 }
33962
33963 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33964 index 4445fa1..7c6de37 100644
33965 --- a/drivers/char/ipmi/ipmi_msghandler.c
33966 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33967 @@ -420,7 +420,7 @@ struct ipmi_smi {
33968 struct proc_dir_entry *proc_dir;
33969 char proc_dir_name[10];
33970
33971 - atomic_t stats[IPMI_NUM_STATS];
33972 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33973
33974 /*
33975 * run_to_completion duplicate of smb_info, smi_info
33976 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33977
33978
33979 #define ipmi_inc_stat(intf, stat) \
33980 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33981 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33982 #define ipmi_get_stat(intf, stat) \
33983 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33984 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33985
33986 static int is_lan_addr(struct ipmi_addr *addr)
33987 {
33988 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33989 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33990 init_waitqueue_head(&intf->waitq);
33991 for (i = 0; i < IPMI_NUM_STATS; i++)
33992 - atomic_set(&intf->stats[i], 0);
33993 + atomic_set_unchecked(&intf->stats[i], 0);
33994
33995 intf->proc_dir = NULL;
33996
33997 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33998 index af4b23f..79806fc 100644
33999 --- a/drivers/char/ipmi/ipmi_si_intf.c
34000 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34001 @@ -275,7 +275,7 @@ struct smi_info {
34002 unsigned char slave_addr;
34003
34004 /* Counters and things for the proc filesystem. */
34005 - atomic_t stats[SI_NUM_STATS];
34006 + atomic_unchecked_t stats[SI_NUM_STATS];
34007
34008 struct task_struct *thread;
34009
34010 @@ -284,9 +284,9 @@ struct smi_info {
34011 };
34012
34013 #define smi_inc_stat(smi, stat) \
34014 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34015 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34016 #define smi_get_stat(smi, stat) \
34017 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34018 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34019
34020 #define SI_MAX_PARMS 4
34021
34022 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
34023 atomic_set(&new_smi->req_events, 0);
34024 new_smi->run_to_completion = 0;
34025 for (i = 0; i < SI_NUM_STATS; i++)
34026 - atomic_set(&new_smi->stats[i], 0);
34027 + atomic_set_unchecked(&new_smi->stats[i], 0);
34028
34029 new_smi->interrupt_disabled = 1;
34030 atomic_set(&new_smi->stop_operation, 0);
34031 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34032 index 1ccbe94..6ad651a 100644
34033 --- a/drivers/char/mem.c
34034 +++ b/drivers/char/mem.c
34035 @@ -18,6 +18,7 @@
34036 #include <linux/raw.h>
34037 #include <linux/tty.h>
34038 #include <linux/capability.h>
34039 +#include <linux/security.h>
34040 #include <linux/ptrace.h>
34041 #include <linux/device.h>
34042 #include <linux/highmem.h>
34043 @@ -38,6 +39,10 @@
34044
34045 #define DEVPORT_MINOR 4
34046
34047 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34048 +extern const struct file_operations grsec_fops;
34049 +#endif
34050 +
34051 static inline unsigned long size_inside_page(unsigned long start,
34052 unsigned long size)
34053 {
34054 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34055
34056 while (cursor < to) {
34057 if (!devmem_is_allowed(pfn)) {
34058 +#ifdef CONFIG_GRKERNSEC_KMEM
34059 + gr_handle_mem_readwrite(from, to);
34060 +#else
34061 printk(KERN_INFO
34062 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34063 current->comm, from, to);
34064 +#endif
34065 return 0;
34066 }
34067 cursor += PAGE_SIZE;
34068 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34069 }
34070 return 1;
34071 }
34072 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34073 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34074 +{
34075 + return 0;
34076 +}
34077 #else
34078 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34079 {
34080 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34081
34082 while (count > 0) {
34083 unsigned long remaining;
34084 + char *temp;
34085
34086 sz = size_inside_page(p, count);
34087
34088 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34089 if (!ptr)
34090 return -EFAULT;
34091
34092 - remaining = copy_to_user(buf, ptr, sz);
34093 +#ifdef CONFIG_PAX_USERCOPY
34094 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34095 + if (!temp) {
34096 + unxlate_dev_mem_ptr(p, ptr);
34097 + return -ENOMEM;
34098 + }
34099 + memcpy(temp, ptr, sz);
34100 +#else
34101 + temp = ptr;
34102 +#endif
34103 +
34104 + remaining = copy_to_user(buf, temp, sz);
34105 +
34106 +#ifdef CONFIG_PAX_USERCOPY
34107 + kfree(temp);
34108 +#endif
34109 +
34110 unxlate_dev_mem_ptr(p, ptr);
34111 if (remaining)
34112 return -EFAULT;
34113 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34114 else
34115 csize = count;
34116
34117 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34118 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34119 if (rc < 0)
34120 return rc;
34121 buf += csize;
34122 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34123 size_t count, loff_t *ppos)
34124 {
34125 unsigned long p = *ppos;
34126 - ssize_t low_count, read, sz;
34127 + ssize_t low_count, read, sz, err = 0;
34128 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34129 - int err = 0;
34130
34131 read = 0;
34132 if (p < (unsigned long) high_memory) {
34133 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34134 }
34135 #endif
34136 while (low_count > 0) {
34137 + char *temp;
34138 +
34139 sz = size_inside_page(p, low_count);
34140
34141 /*
34142 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34143 */
34144 kbuf = xlate_dev_kmem_ptr((char *)p);
34145
34146 - if (copy_to_user(buf, kbuf, sz))
34147 +#ifdef CONFIG_PAX_USERCOPY
34148 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34149 + if (!temp)
34150 + return -ENOMEM;
34151 + memcpy(temp, kbuf, sz);
34152 +#else
34153 + temp = kbuf;
34154 +#endif
34155 +
34156 + err = copy_to_user(buf, temp, sz);
34157 +
34158 +#ifdef CONFIG_PAX_USERCOPY
34159 + kfree(temp);
34160 +#endif
34161 +
34162 + if (err)
34163 return -EFAULT;
34164 buf += sz;
34165 p += sz;
34166 @@ -869,6 +916,9 @@ static const struct memdev {
34167 #ifdef CONFIG_CRASH_DUMP
34168 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34169 #endif
34170 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34171 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34172 +#endif
34173 };
34174
34175 static int memory_open(struct inode *inode, struct file *filp)
34176 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
34177 continue;
34178
34179 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34180 - NULL, devlist[minor].name);
34181 + NULL, "%s", devlist[minor].name);
34182 }
34183
34184 return tty_init();
34185 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34186 index c689697..04e6d6a2 100644
34187 --- a/drivers/char/mwave/tp3780i.c
34188 +++ b/drivers/char/mwave/tp3780i.c
34189 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34190 PRINTK_2(TRACE_TP3780I,
34191 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34192
34193 + memset(pAbilities, 0, sizeof(*pAbilities));
34194 /* fill out standard constant fields */
34195 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34196 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34197 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34198 index 9df78e2..01ba9ae 100644
34199 --- a/drivers/char/nvram.c
34200 +++ b/drivers/char/nvram.c
34201 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34202
34203 spin_unlock_irq(&rtc_lock);
34204
34205 - if (copy_to_user(buf, contents, tmp - contents))
34206 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34207 return -EFAULT;
34208
34209 *ppos = i;
34210 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34211 index 5c5cc00..ac9edb7 100644
34212 --- a/drivers/char/pcmcia/synclink_cs.c
34213 +++ b/drivers/char/pcmcia/synclink_cs.c
34214 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34215
34216 if (debug_level >= DEBUG_LEVEL_INFO)
34217 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34218 - __FILE__, __LINE__, info->device_name, port->count);
34219 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34220
34221 - WARN_ON(!port->count);
34222 + WARN_ON(!atomic_read(&port->count));
34223
34224 if (tty_port_close_start(port, tty, filp) == 0)
34225 goto cleanup;
34226 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34227 cleanup:
34228 if (debug_level >= DEBUG_LEVEL_INFO)
34229 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34230 - tty->driver->name, port->count);
34231 + tty->driver->name, atomic_read(&port->count));
34232 }
34233
34234 /* Wait until the transmitter is empty.
34235 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34236
34237 if (debug_level >= DEBUG_LEVEL_INFO)
34238 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34239 - __FILE__, __LINE__, tty->driver->name, port->count);
34240 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34241
34242 /* If port is closing, signal caller to try again */
34243 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34244 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34245 goto cleanup;
34246 }
34247 spin_lock(&port->lock);
34248 - port->count++;
34249 + atomic_inc(&port->count);
34250 spin_unlock(&port->lock);
34251 spin_unlock_irqrestore(&info->netlock, flags);
34252
34253 - if (port->count == 1) {
34254 + if (atomic_read(&port->count) == 1) {
34255 /* 1st open on this device, init hardware */
34256 retval = startup(info, tty);
34257 if (retval < 0)
34258 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34259 unsigned short new_crctype;
34260
34261 /* return error if TTY interface open */
34262 - if (info->port.count)
34263 + if (atomic_read(&info->port.count))
34264 return -EBUSY;
34265
34266 switch (encoding)
34267 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34268
34269 /* arbitrate between network and tty opens */
34270 spin_lock_irqsave(&info->netlock, flags);
34271 - if (info->port.count != 0 || info->netcount != 0) {
34272 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34273 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34274 spin_unlock_irqrestore(&info->netlock, flags);
34275 return -EBUSY;
34276 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34277 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34278
34279 /* return error if TTY interface open */
34280 - if (info->port.count)
34281 + if (atomic_read(&info->port.count))
34282 return -EBUSY;
34283
34284 if (cmd != SIOCWANDEV)
34285 diff --git a/drivers/char/random.c b/drivers/char/random.c
34286 index 35487e8..dac8bd1 100644
34287 --- a/drivers/char/random.c
34288 +++ b/drivers/char/random.c
34289 @@ -272,8 +272,13 @@
34290 /*
34291 * Configuration information
34292 */
34293 +#ifdef CONFIG_GRKERNSEC_RANDNET
34294 +#define INPUT_POOL_WORDS 512
34295 +#define OUTPUT_POOL_WORDS 128
34296 +#else
34297 #define INPUT_POOL_WORDS 128
34298 #define OUTPUT_POOL_WORDS 32
34299 +#endif
34300 #define SEC_XFER_SIZE 512
34301 #define EXTRACT_SIZE 10
34302
34303 @@ -313,10 +318,17 @@ static struct poolinfo {
34304 int poolwords;
34305 int tap1, tap2, tap3, tap4, tap5;
34306 } poolinfo_table[] = {
34307 +#ifdef CONFIG_GRKERNSEC_RANDNET
34308 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34309 + { 512, 411, 308, 208, 104, 1 },
34310 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34311 + { 128, 103, 76, 51, 25, 1 },
34312 +#else
34313 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34314 { 128, 103, 76, 51, 25, 1 },
34315 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34316 { 32, 26, 20, 14, 7, 1 },
34317 +#endif
34318 #if 0
34319 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34320 { 2048, 1638, 1231, 819, 411, 1 },
34321 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34322 input_rotate += i ? 7 : 14;
34323 }
34324
34325 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34326 - ACCESS_ONCE(r->add_ptr) = i;
34327 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34328 + ACCESS_ONCE_RW(r->add_ptr) = i;
34329 smp_wmb();
34330
34331 if (out)
34332 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34333
34334 extract_buf(r, tmp);
34335 i = min_t(int, nbytes, EXTRACT_SIZE);
34336 - if (copy_to_user(buf, tmp, i)) {
34337 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34338 ret = -EFAULT;
34339 break;
34340 }
34341 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34342 #include <linux/sysctl.h>
34343
34344 static int min_read_thresh = 8, min_write_thresh;
34345 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34346 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34347 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34348 static char sysctl_bootid[16];
34349
34350 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34351 static int proc_do_uuid(ctl_table *table, int write,
34352 void __user *buffer, size_t *lenp, loff_t *ppos)
34353 {
34354 - ctl_table fake_table;
34355 + ctl_table_no_const fake_table;
34356 unsigned char buf[64], tmp_uuid[16], *uuid;
34357
34358 uuid = table->data;
34359 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34360 index bf2349db..5456d53 100644
34361 --- a/drivers/char/sonypi.c
34362 +++ b/drivers/char/sonypi.c
34363 @@ -54,6 +54,7 @@
34364
34365 #include <asm/uaccess.h>
34366 #include <asm/io.h>
34367 +#include <asm/local.h>
34368
34369 #include <linux/sonypi.h>
34370
34371 @@ -490,7 +491,7 @@ static struct sonypi_device {
34372 spinlock_t fifo_lock;
34373 wait_queue_head_t fifo_proc_list;
34374 struct fasync_struct *fifo_async;
34375 - int open_count;
34376 + local_t open_count;
34377 int model;
34378 struct input_dev *input_jog_dev;
34379 struct input_dev *input_key_dev;
34380 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34381 static int sonypi_misc_release(struct inode *inode, struct file *file)
34382 {
34383 mutex_lock(&sonypi_device.lock);
34384 - sonypi_device.open_count--;
34385 + local_dec(&sonypi_device.open_count);
34386 mutex_unlock(&sonypi_device.lock);
34387 return 0;
34388 }
34389 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34390 {
34391 mutex_lock(&sonypi_device.lock);
34392 /* Flush input queue on first open */
34393 - if (!sonypi_device.open_count)
34394 + if (!local_read(&sonypi_device.open_count))
34395 kfifo_reset(&sonypi_device.fifo);
34396 - sonypi_device.open_count++;
34397 + local_inc(&sonypi_device.open_count);
34398 mutex_unlock(&sonypi_device.lock);
34399
34400 return 0;
34401 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34402 index 64420b3..5c40b56 100644
34403 --- a/drivers/char/tpm/tpm_acpi.c
34404 +++ b/drivers/char/tpm/tpm_acpi.c
34405 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34406 virt = acpi_os_map_memory(start, len);
34407 if (!virt) {
34408 kfree(log->bios_event_log);
34409 + log->bios_event_log = NULL;
34410 printk("%s: ERROR - Unable to map memory\n", __func__);
34411 return -EIO;
34412 }
34413
34414 - memcpy_fromio(log->bios_event_log, virt, len);
34415 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34416
34417 acpi_os_unmap_memory(virt, len);
34418 return 0;
34419 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34420 index 84ddc55..1d32f1e 100644
34421 --- a/drivers/char/tpm/tpm_eventlog.c
34422 +++ b/drivers/char/tpm/tpm_eventlog.c
34423 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34424 event = addr;
34425
34426 if ((event->event_type == 0 && event->event_size == 0) ||
34427 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34428 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34429 return NULL;
34430
34431 return addr;
34432 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34433 return NULL;
34434
34435 if ((event->event_type == 0 && event->event_size == 0) ||
34436 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34437 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34438 return NULL;
34439
34440 (*pos)++;
34441 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34442 int i;
34443
34444 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34445 - seq_putc(m, data[i]);
34446 + if (!seq_putc(m, data[i]))
34447 + return -EFAULT;
34448
34449 return 0;
34450 }
34451 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34452 index 1b456fe..2510242 100644
34453 --- a/drivers/char/virtio_console.c
34454 +++ b/drivers/char/virtio_console.c
34455 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34456 if (to_user) {
34457 ssize_t ret;
34458
34459 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34460 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34461 if (ret)
34462 return -EFAULT;
34463 } else {
34464 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34465 if (!port_has_data(port) && !port->host_connected)
34466 return 0;
34467
34468 - return fill_readbuf(port, ubuf, count, true);
34469 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34470 }
34471
34472 static int wait_port_writable(struct port *port, bool nonblock)
34473 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
34474 index a33f46f..a720eed 100644
34475 --- a/drivers/clk/clk-composite.c
34476 +++ b/drivers/clk/clk-composite.c
34477 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
34478 struct clk *clk;
34479 struct clk_init_data init;
34480 struct clk_composite *composite;
34481 - struct clk_ops *clk_composite_ops;
34482 + clk_ops_no_const *clk_composite_ops;
34483
34484 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
34485 if (!composite) {
34486 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
34487 index bd11315..7f87098 100644
34488 --- a/drivers/clk/socfpga/clk.c
34489 +++ b/drivers/clk/socfpga/clk.c
34490 @@ -22,6 +22,7 @@
34491 #include <linux/clk-provider.h>
34492 #include <linux/io.h>
34493 #include <linux/of.h>
34494 +#include <asm/pgtable.h>
34495
34496 /* Clock Manager offsets */
34497 #define CLKMGR_CTRL 0x0
34498 @@ -135,8 +136,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
34499 if (strcmp(clk_name, "main_pll") || strcmp(clk_name, "periph_pll") ||
34500 strcmp(clk_name, "sdram_pll")) {
34501 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
34502 - clk_pll_ops.enable = clk_gate_ops.enable;
34503 - clk_pll_ops.disable = clk_gate_ops.disable;
34504 + pax_open_kernel();
34505 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
34506 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
34507 + pax_close_kernel();
34508 }
34509
34510 clk = clk_register(NULL, &socfpga_clk->hw.hw);
34511 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34512 index a2b2541..bc1e7ff 100644
34513 --- a/drivers/clocksource/arm_arch_timer.c
34514 +++ b/drivers/clocksource/arm_arch_timer.c
34515 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34516 return NOTIFY_OK;
34517 }
34518
34519 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34520 +static struct notifier_block arch_timer_cpu_nb = {
34521 .notifier_call = arch_timer_cpu_notify,
34522 };
34523
34524 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34525 index ade7513..069445f 100644
34526 --- a/drivers/clocksource/metag_generic.c
34527 +++ b/drivers/clocksource/metag_generic.c
34528 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34529 return NOTIFY_OK;
34530 }
34531
34532 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34533 +static struct notifier_block arch_timer_cpu_nb = {
34534 .notifier_call = arch_timer_cpu_notify,
34535 };
34536
34537 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34538 index edc089e..bc7c0bc 100644
34539 --- a/drivers/cpufreq/acpi-cpufreq.c
34540 +++ b/drivers/cpufreq/acpi-cpufreq.c
34541 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34542 return sprintf(buf, "%u\n", boost_enabled);
34543 }
34544
34545 -static struct global_attr global_boost = __ATTR(boost, 0644,
34546 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34547 show_global_boost,
34548 store_global_boost);
34549
34550 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34551 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34552 per_cpu(acfreq_data, cpu) = data;
34553
34554 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34555 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34556 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34557 + pax_open_kernel();
34558 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34559 + pax_close_kernel();
34560 + }
34561
34562 result = acpi_processor_register_performance(data->acpi_data, cpu);
34563 if (result)
34564 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34565 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34566 break;
34567 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34568 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34569 + pax_open_kernel();
34570 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34571 + pax_close_kernel();
34572 policy->cur = get_cur_freq_on_cpu(cpu);
34573 break;
34574 default:
34575 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34576 acpi_processor_notify_smm(THIS_MODULE);
34577
34578 /* Check for APERF/MPERF support in hardware */
34579 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34580 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34581 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34582 + pax_open_kernel();
34583 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34584 + pax_close_kernel();
34585 + }
34586
34587 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34588 for (i = 0; i < perf->state_count; i++)
34589 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34590 index 178fe7a..5ee8501 100644
34591 --- a/drivers/cpufreq/cpufreq.c
34592 +++ b/drivers/cpufreq/cpufreq.c
34593 @@ -1853,7 +1853,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34594 return NOTIFY_OK;
34595 }
34596
34597 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34598 +static struct notifier_block cpufreq_cpu_notifier = {
34599 .notifier_call = cpufreq_cpu_callback,
34600 };
34601
34602 @@ -1885,8 +1885,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34603
34604 pr_debug("trying to register driver %s\n", driver_data->name);
34605
34606 - if (driver_data->setpolicy)
34607 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34608 + if (driver_data->setpolicy) {
34609 + pax_open_kernel();
34610 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34611 + pax_close_kernel();
34612 + }
34613
34614 write_lock_irqsave(&cpufreq_driver_lock, flags);
34615 if (cpufreq_driver) {
34616 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34617 index 5af40ad..ddf907b 100644
34618 --- a/drivers/cpufreq/cpufreq_governor.c
34619 +++ b/drivers/cpufreq/cpufreq_governor.c
34620 @@ -235,7 +235,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34621 struct dbs_data *dbs_data;
34622 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34623 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34624 - struct od_ops *od_ops = NULL;
34625 + const struct od_ops *od_ops = NULL;
34626 struct od_dbs_tuners *od_tuners = NULL;
34627 struct cs_dbs_tuners *cs_tuners = NULL;
34628 struct cpu_dbs_common_info *cpu_cdbs;
34629 @@ -298,7 +298,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34630
34631 if ((cdata->governor == GOV_CONSERVATIVE) &&
34632 (!policy->governor->initialized)) {
34633 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34634 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34635
34636 cpufreq_register_notifier(cs_ops->notifier_block,
34637 CPUFREQ_TRANSITION_NOTIFIER);
34638 @@ -315,7 +315,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34639
34640 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
34641 (policy->governor->initialized == 1)) {
34642 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34643 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34644
34645 cpufreq_unregister_notifier(cs_ops->notifier_block,
34646 CPUFREQ_TRANSITION_NOTIFIER);
34647 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34648 index e16a961..0e68927 100644
34649 --- a/drivers/cpufreq/cpufreq_governor.h
34650 +++ b/drivers/cpufreq/cpufreq_governor.h
34651 @@ -204,7 +204,7 @@ struct common_dbs_data {
34652 void (*exit)(struct dbs_data *dbs_data);
34653
34654 /* Governor specific ops, see below */
34655 - void *gov_ops;
34656 + const void *gov_ops;
34657 };
34658
34659 /* Governer Per policy data */
34660 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
34661 index 93eb5cb..f8ab572 100644
34662 --- a/drivers/cpufreq/cpufreq_ondemand.c
34663 +++ b/drivers/cpufreq/cpufreq_ondemand.c
34664 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
34665 (struct cpufreq_policy *, unsigned int, unsigned int),
34666 unsigned int powersave_bias)
34667 {
34668 - od_ops.powersave_bias_target = f;
34669 + pax_open_kernel();
34670 + *(void **)&od_ops.powersave_bias_target = f;
34671 + pax_close_kernel();
34672 od_set_powersave_bias(powersave_bias);
34673 }
34674 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
34675
34676 void od_unregister_powersave_bias_handler(void)
34677 {
34678 - od_ops.powersave_bias_target = generic_powersave_bias_target;
34679 + pax_open_kernel();
34680 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
34681 + pax_close_kernel();
34682 od_set_powersave_bias(0);
34683 }
34684 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
34685 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34686 index bfd6273..e39dd63 100644
34687 --- a/drivers/cpufreq/cpufreq_stats.c
34688 +++ b/drivers/cpufreq/cpufreq_stats.c
34689 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34690 }
34691
34692 /* priority=1 so this will get called before cpufreq_remove_dev */
34693 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34694 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34695 .notifier_call = cpufreq_stat_cpu_callback,
34696 .priority = 1,
34697 };
34698 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34699 index 421ef37..e708530c 100644
34700 --- a/drivers/cpufreq/p4-clockmod.c
34701 +++ b/drivers/cpufreq/p4-clockmod.c
34702 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34703 case 0x0F: /* Core Duo */
34704 case 0x16: /* Celeron Core */
34705 case 0x1C: /* Atom */
34706 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34707 + pax_open_kernel();
34708 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34709 + pax_close_kernel();
34710 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34711 case 0x0D: /* Pentium M (Dothan) */
34712 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34713 + pax_open_kernel();
34714 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34715 + pax_close_kernel();
34716 /* fall through */
34717 case 0x09: /* Pentium M (Banias) */
34718 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34719 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34720
34721 /* on P-4s, the TSC runs with constant frequency independent whether
34722 * throttling is active or not. */
34723 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34724 + pax_open_kernel();
34725 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34726 + pax_close_kernel();
34727
34728 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34729 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34730 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
34731 index c71ee14..7c2e183 100644
34732 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
34733 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
34734 @@ -18,14 +18,12 @@
34735 #include <asm/head.h>
34736 #include <asm/timer.h>
34737
34738 -static struct cpufreq_driver *cpufreq_us3_driver;
34739 -
34740 struct us3_freq_percpu_info {
34741 struct cpufreq_frequency_table table[4];
34742 };
34743
34744 /* Indexed by cpu number. */
34745 -static struct us3_freq_percpu_info *us3_freq_table;
34746 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
34747
34748 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
34749 * in the Safari config register.
34750 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
34751
34752 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
34753 {
34754 - if (cpufreq_us3_driver)
34755 - us3_set_cpu_divider_index(policy, 0);
34756 + us3_set_cpu_divider_index(policy->cpu, 0);
34757
34758 return 0;
34759 }
34760
34761 +static int __init us3_freq_init(void);
34762 +static void __exit us3_freq_exit(void);
34763 +
34764 +static struct cpufreq_driver cpufreq_us3_driver = {
34765 + .init = us3_freq_cpu_init,
34766 + .verify = us3_freq_verify,
34767 + .target = us3_freq_target,
34768 + .get = us3_freq_get,
34769 + .exit = us3_freq_cpu_exit,
34770 + .owner = THIS_MODULE,
34771 + .name = "UltraSPARC-III",
34772 +
34773 +};
34774 +
34775 static int __init us3_freq_init(void)
34776 {
34777 unsigned long manuf, impl, ver;
34778 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
34779 (impl == CHEETAH_IMPL ||
34780 impl == CHEETAH_PLUS_IMPL ||
34781 impl == JAGUAR_IMPL ||
34782 - impl == PANTHER_IMPL)) {
34783 - struct cpufreq_driver *driver;
34784 -
34785 - ret = -ENOMEM;
34786 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
34787 - if (!driver)
34788 - goto err_out;
34789 -
34790 - us3_freq_table = kzalloc(
34791 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
34792 - GFP_KERNEL);
34793 - if (!us3_freq_table)
34794 - goto err_out;
34795 -
34796 - driver->init = us3_freq_cpu_init;
34797 - driver->verify = us3_freq_verify;
34798 - driver->target = us3_freq_target;
34799 - driver->get = us3_freq_get;
34800 - driver->exit = us3_freq_cpu_exit;
34801 - driver->owner = THIS_MODULE,
34802 - strcpy(driver->name, "UltraSPARC-III");
34803 -
34804 - cpufreq_us3_driver = driver;
34805 - ret = cpufreq_register_driver(driver);
34806 - if (ret)
34807 - goto err_out;
34808 -
34809 - return 0;
34810 -
34811 -err_out:
34812 - if (driver) {
34813 - kfree(driver);
34814 - cpufreq_us3_driver = NULL;
34815 - }
34816 - kfree(us3_freq_table);
34817 - us3_freq_table = NULL;
34818 - return ret;
34819 - }
34820 + impl == PANTHER_IMPL))
34821 + return cpufreq_register_driver(&cpufreq_us3_driver);
34822
34823 return -ENODEV;
34824 }
34825
34826 static void __exit us3_freq_exit(void)
34827 {
34828 - if (cpufreq_us3_driver) {
34829 - cpufreq_unregister_driver(cpufreq_us3_driver);
34830 - kfree(cpufreq_us3_driver);
34831 - cpufreq_us3_driver = NULL;
34832 - kfree(us3_freq_table);
34833 - us3_freq_table = NULL;
34834 - }
34835 + cpufreq_unregister_driver(&cpufreq_us3_driver);
34836 }
34837
34838 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
34839 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34840 index 618e6f4..e89d915 100644
34841 --- a/drivers/cpufreq/speedstep-centrino.c
34842 +++ b/drivers/cpufreq/speedstep-centrino.c
34843 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34844 !cpu_has(cpu, X86_FEATURE_EST))
34845 return -ENODEV;
34846
34847 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34848 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34849 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34850 + pax_open_kernel();
34851 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34852 + pax_close_kernel();
34853 + }
34854
34855 if (policy->cpu != 0)
34856 return -ENODEV;
34857 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34858 index c3a93fe..e808f24 100644
34859 --- a/drivers/cpuidle/cpuidle.c
34860 +++ b/drivers/cpuidle/cpuidle.c
34861 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
34862
34863 static void poll_idle_init(struct cpuidle_driver *drv)
34864 {
34865 - struct cpuidle_state *state = &drv->states[0];
34866 + cpuidle_state_no_const *state = &drv->states[0];
34867
34868 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34869 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34870 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34871 index ea2f8e7..70ac501 100644
34872 --- a/drivers/cpuidle/governor.c
34873 +++ b/drivers/cpuidle/governor.c
34874 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34875 mutex_lock(&cpuidle_lock);
34876 if (__cpuidle_find_governor(gov->name) == NULL) {
34877 ret = 0;
34878 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34879 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34880 if (!cpuidle_curr_governor ||
34881 cpuidle_curr_governor->rating < gov->rating)
34882 cpuidle_switch_governor(gov);
34883 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34884 new_gov = cpuidle_replace_governor(gov->rating);
34885 cpuidle_switch_governor(new_gov);
34886 }
34887 - list_del(&gov->governor_list);
34888 + pax_list_del((struct list_head *)&gov->governor_list);
34889 mutex_unlock(&cpuidle_lock);
34890 }
34891
34892 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34893 index 428754a..8bdf9cc 100644
34894 --- a/drivers/cpuidle/sysfs.c
34895 +++ b/drivers/cpuidle/sysfs.c
34896 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34897 NULL
34898 };
34899
34900 -static struct attribute_group cpuidle_attr_group = {
34901 +static attribute_group_no_const cpuidle_attr_group = {
34902 .attrs = cpuidle_default_attrs,
34903 .name = "cpuidle",
34904 };
34905 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34906 index 3b36797..db0b0c0 100644
34907 --- a/drivers/devfreq/devfreq.c
34908 +++ b/drivers/devfreq/devfreq.c
34909 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34910 GFP_KERNEL);
34911 devfreq->last_stat_updated = jiffies;
34912
34913 - dev_set_name(&devfreq->dev, dev_name(dev));
34914 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34915 err = device_register(&devfreq->dev);
34916 if (err) {
34917 put_device(&devfreq->dev);
34918 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34919 goto err_out;
34920 }
34921
34922 - list_add(&governor->node, &devfreq_governor_list);
34923 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34924
34925 list_for_each_entry(devfreq, &devfreq_list, node) {
34926 int ret = 0;
34927 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34928 }
34929 }
34930
34931 - list_del(&governor->node);
34932 + pax_list_del((struct list_head *)&governor->node);
34933 err_out:
34934 mutex_unlock(&devfreq_list_lock);
34935
34936 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34937 index b70709b..1d8d02a 100644
34938 --- a/drivers/dma/sh/shdma.c
34939 +++ b/drivers/dma/sh/shdma.c
34940 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34941 return ret;
34942 }
34943
34944 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34945 +static struct notifier_block sh_dmae_nmi_notifier = {
34946 .notifier_call = sh_dmae_nmi_handler,
34947
34948 /* Run before NMI debug handler and KGDB */
34949 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34950 index c4d700a..0b57abd 100644
34951 --- a/drivers/edac/edac_mc_sysfs.c
34952 +++ b/drivers/edac/edac_mc_sysfs.c
34953 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
34954 struct dev_ch_attribute {
34955 struct device_attribute attr;
34956 int channel;
34957 -};
34958 +} __do_const;
34959
34960 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34961 struct dev_ch_attribute dev_attr_legacy_##_name = \
34962 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34963 }
34964
34965 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34966 + pax_open_kernel();
34967 if (mci->get_sdram_scrub_rate) {
34968 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34969 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34970 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34971 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34972 }
34973 if (mci->set_sdram_scrub_rate) {
34974 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34975 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34976 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34977 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34978 }
34979 + pax_close_kernel();
34980 err = device_create_file(&mci->dev,
34981 &dev_attr_sdram_scrub_rate);
34982 if (err) {
34983 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34984 index e8658e4..22746d6 100644
34985 --- a/drivers/edac/edac_pci_sysfs.c
34986 +++ b/drivers/edac/edac_pci_sysfs.c
34987 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34988 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34989 static int edac_pci_poll_msec = 1000; /* one second workq period */
34990
34991 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34992 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34993 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34994 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34995
34996 static struct kobject *edac_pci_top_main_kobj;
34997 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34998 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34999 void *value;
35000 ssize_t(*show) (void *, char *);
35001 ssize_t(*store) (void *, const char *, size_t);
35002 -};
35003 +} __do_const;
35004
35005 /* Set of show/store abstract level functions for PCI Parity object */
35006 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
35007 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35008 edac_printk(KERN_CRIT, EDAC_PCI,
35009 "Signaled System Error on %s\n",
35010 pci_name(dev));
35011 - atomic_inc(&pci_nonparity_count);
35012 + atomic_inc_unchecked(&pci_nonparity_count);
35013 }
35014
35015 if (status & (PCI_STATUS_PARITY)) {
35016 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35017 "Master Data Parity Error on %s\n",
35018 pci_name(dev));
35019
35020 - atomic_inc(&pci_parity_count);
35021 + atomic_inc_unchecked(&pci_parity_count);
35022 }
35023
35024 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35025 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35026 "Detected Parity Error on %s\n",
35027 pci_name(dev));
35028
35029 - atomic_inc(&pci_parity_count);
35030 + atomic_inc_unchecked(&pci_parity_count);
35031 }
35032 }
35033
35034 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35035 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
35036 "Signaled System Error on %s\n",
35037 pci_name(dev));
35038 - atomic_inc(&pci_nonparity_count);
35039 + atomic_inc_unchecked(&pci_nonparity_count);
35040 }
35041
35042 if (status & (PCI_STATUS_PARITY)) {
35043 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35044 "Master Data Parity Error on "
35045 "%s\n", pci_name(dev));
35046
35047 - atomic_inc(&pci_parity_count);
35048 + atomic_inc_unchecked(&pci_parity_count);
35049 }
35050
35051 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35052 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35053 "Detected Parity Error on %s\n",
35054 pci_name(dev));
35055
35056 - atomic_inc(&pci_parity_count);
35057 + atomic_inc_unchecked(&pci_parity_count);
35058 }
35059 }
35060 }
35061 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
35062 if (!check_pci_errors)
35063 return;
35064
35065 - before_count = atomic_read(&pci_parity_count);
35066 + before_count = atomic_read_unchecked(&pci_parity_count);
35067
35068 /* scan all PCI devices looking for a Parity Error on devices and
35069 * bridges.
35070 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
35071 /* Only if operator has selected panic on PCI Error */
35072 if (edac_pci_get_panic_on_pe()) {
35073 /* If the count is different 'after' from 'before' */
35074 - if (before_count != atomic_read(&pci_parity_count))
35075 + if (before_count != atomic_read_unchecked(&pci_parity_count))
35076 panic("EDAC: PCI Parity Error");
35077 }
35078 }
35079 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
35080 index 51b7e3a..aa8a3e8 100644
35081 --- a/drivers/edac/mce_amd.h
35082 +++ b/drivers/edac/mce_amd.h
35083 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
35084 bool (*mc0_mce)(u16, u8);
35085 bool (*mc1_mce)(u16, u8);
35086 bool (*mc2_mce)(u16, u8);
35087 -};
35088 +} __no_const;
35089
35090 void amd_report_gart_errors(bool);
35091 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
35092 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
35093 index 57ea7f4..789e3c3 100644
35094 --- a/drivers/firewire/core-card.c
35095 +++ b/drivers/firewire/core-card.c
35096 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
35097
35098 void fw_core_remove_card(struct fw_card *card)
35099 {
35100 - struct fw_card_driver dummy_driver = dummy_driver_template;
35101 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
35102
35103 card->driver->update_phy_reg(card, 4,
35104 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
35105 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
35106 index 664a6ff..af13580 100644
35107 --- a/drivers/firewire/core-device.c
35108 +++ b/drivers/firewire/core-device.c
35109 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35110 struct config_rom_attribute {
35111 struct device_attribute attr;
35112 u32 key;
35113 -};
35114 +} __do_const;
35115
35116 static ssize_t show_immediate(struct device *dev,
35117 struct device_attribute *dattr, char *buf)
35118 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35119 index 28a94c7..58da63a 100644
35120 --- a/drivers/firewire/core-transaction.c
35121 +++ b/drivers/firewire/core-transaction.c
35122 @@ -38,6 +38,7 @@
35123 #include <linux/timer.h>
35124 #include <linux/types.h>
35125 #include <linux/workqueue.h>
35126 +#include <linux/sched.h>
35127
35128 #include <asm/byteorder.h>
35129
35130 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35131 index 515a42c..5ecf3ba 100644
35132 --- a/drivers/firewire/core.h
35133 +++ b/drivers/firewire/core.h
35134 @@ -111,6 +111,7 @@ struct fw_card_driver {
35135
35136 int (*stop_iso)(struct fw_iso_context *ctx);
35137 };
35138 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35139
35140 void fw_card_initialize(struct fw_card *card,
35141 const struct fw_card_driver *driver, struct device *device);
35142 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35143 index 94a58a0..f5eba42 100644
35144 --- a/drivers/firmware/dmi-id.c
35145 +++ b/drivers/firmware/dmi-id.c
35146 @@ -16,7 +16,7 @@
35147 struct dmi_device_attribute{
35148 struct device_attribute dev_attr;
35149 int field;
35150 -};
35151 +} __do_const;
35152 #define to_dmi_dev_attr(_dev_attr) \
35153 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35154
35155 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35156 index b95159b..841ae55 100644
35157 --- a/drivers/firmware/dmi_scan.c
35158 +++ b/drivers/firmware/dmi_scan.c
35159 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
35160 }
35161 }
35162 else {
35163 - /*
35164 - * no iounmap() for that ioremap(); it would be a no-op, but
35165 - * it's so early in setup that sucker gets confused into doing
35166 - * what it shouldn't if we actually call it.
35167 - */
35168 p = dmi_ioremap(0xF0000, 0x10000);
35169 if (p == NULL)
35170 goto error;
35171 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35172 if (buf == NULL)
35173 return -1;
35174
35175 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35176 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35177
35178 iounmap(buf);
35179 return 0;
35180 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
35181 index 5145fa3..0d3babd 100644
35182 --- a/drivers/firmware/efi/efi.c
35183 +++ b/drivers/firmware/efi/efi.c
35184 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
35185 };
35186
35187 static struct efivars generic_efivars;
35188 -static struct efivar_operations generic_ops;
35189 +static efivar_operations_no_const generic_ops __read_only;
35190
35191 static int generic_ops_register(void)
35192 {
35193 - generic_ops.get_variable = efi.get_variable;
35194 - generic_ops.set_variable = efi.set_variable;
35195 - generic_ops.get_next_variable = efi.get_next_variable;
35196 - generic_ops.query_variable_store = efi_query_variable_store;
35197 + pax_open_kernel();
35198 + *(void **)&generic_ops.get_variable = efi.get_variable;
35199 + *(void **)&generic_ops.set_variable = efi.set_variable;
35200 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
35201 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
35202 + pax_close_kernel();
35203
35204 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
35205 }
35206 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
35207 index 8bd1bb6..c48b0c6 100644
35208 --- a/drivers/firmware/efi/efivars.c
35209 +++ b/drivers/firmware/efi/efivars.c
35210 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
35211 static int
35212 create_efivars_bin_attributes(void)
35213 {
35214 - struct bin_attribute *attr;
35215 + bin_attribute_no_const *attr;
35216 int error;
35217
35218 /* new_var */
35219 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35220 index 2a90ba6..07f3733 100644
35221 --- a/drivers/firmware/google/memconsole.c
35222 +++ b/drivers/firmware/google/memconsole.c
35223 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35224 if (!found_memconsole())
35225 return -ENODEV;
35226
35227 - memconsole_bin_attr.size = memconsole_length;
35228 + pax_open_kernel();
35229 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35230 + pax_close_kernel();
35231
35232 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35233
35234 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35235 index e16d932..f0206ef 100644
35236 --- a/drivers/gpio/gpio-ich.c
35237 +++ b/drivers/gpio/gpio-ich.c
35238 @@ -69,7 +69,7 @@ struct ichx_desc {
35239 /* Some chipsets have quirks, let these use their own request/get */
35240 int (*request)(struct gpio_chip *chip, unsigned offset);
35241 int (*get)(struct gpio_chip *chip, unsigned offset);
35242 -};
35243 +} __do_const;
35244
35245 static struct {
35246 spinlock_t lock;
35247 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35248 index 9902732..64b62dd 100644
35249 --- a/drivers/gpio/gpio-vr41xx.c
35250 +++ b/drivers/gpio/gpio-vr41xx.c
35251 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35252 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35253 maskl, pendl, maskh, pendh);
35254
35255 - atomic_inc(&irq_err_count);
35256 + atomic_inc_unchecked(&irq_err_count);
35257
35258 return -EINVAL;
35259 }
35260 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35261 index ed1334e..ee0dd42 100644
35262 --- a/drivers/gpu/drm/drm_crtc_helper.c
35263 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35264 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35265 struct drm_crtc *tmp;
35266 int crtc_mask = 1;
35267
35268 - WARN(!crtc, "checking null crtc?\n");
35269 + BUG_ON(!crtc);
35270
35271 dev = crtc->dev;
35272
35273 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35274 index 9cc247f..36aa285 100644
35275 --- a/drivers/gpu/drm/drm_drv.c
35276 +++ b/drivers/gpu/drm/drm_drv.c
35277 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
35278 /**
35279 * Copy and IOCTL return string to user space
35280 */
35281 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35282 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35283 {
35284 int len;
35285
35286 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
35287 struct drm_file *file_priv = filp->private_data;
35288 struct drm_device *dev;
35289 const struct drm_ioctl_desc *ioctl = NULL;
35290 - drm_ioctl_t *func;
35291 + drm_ioctl_no_const_t func;
35292 unsigned int nr = DRM_IOCTL_NR(cmd);
35293 int retcode = -EINVAL;
35294 char stack_kdata[128];
35295 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35296 return -ENODEV;
35297
35298 atomic_inc(&dev->ioctl_count);
35299 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35300 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35301 ++file_priv->ioctl_count;
35302
35303 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
35304 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35305 index 429e07d..e681a2c 100644
35306 --- a/drivers/gpu/drm/drm_fops.c
35307 +++ b/drivers/gpu/drm/drm_fops.c
35308 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35309 }
35310
35311 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35312 - atomic_set(&dev->counts[i], 0);
35313 + atomic_set_unchecked(&dev->counts[i], 0);
35314
35315 dev->sigdata.lock = NULL;
35316
35317 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35318 if (drm_device_is_unplugged(dev))
35319 return -ENODEV;
35320
35321 - if (!dev->open_count++)
35322 + if (local_inc_return(&dev->open_count) == 1)
35323 need_setup = 1;
35324 mutex_lock(&dev->struct_mutex);
35325 old_imapping = inode->i_mapping;
35326 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35327 retcode = drm_open_helper(inode, filp, dev);
35328 if (retcode)
35329 goto err_undo;
35330 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35331 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35332 if (need_setup) {
35333 retcode = drm_setup(dev);
35334 if (retcode)
35335 @@ -166,7 +166,7 @@ err_undo:
35336 iput(container_of(dev->dev_mapping, struct inode, i_data));
35337 dev->dev_mapping = old_mapping;
35338 mutex_unlock(&dev->struct_mutex);
35339 - dev->open_count--;
35340 + local_dec(&dev->open_count);
35341 return retcode;
35342 }
35343 EXPORT_SYMBOL(drm_open);
35344 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35345
35346 mutex_lock(&drm_global_mutex);
35347
35348 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35349 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35350
35351 if (dev->driver->preclose)
35352 dev->driver->preclose(dev, file_priv);
35353 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35354 * Begin inline drm_release
35355 */
35356
35357 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35358 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35359 task_pid_nr(current),
35360 (long)old_encode_dev(file_priv->minor->device),
35361 - dev->open_count);
35362 + local_read(&dev->open_count));
35363
35364 /* Release any auth tokens that might point to this file_priv,
35365 (do that under the drm_global_mutex) */
35366 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35367 * End inline drm_release
35368 */
35369
35370 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35371 - if (!--dev->open_count) {
35372 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35373 + if (local_dec_and_test(&dev->open_count)) {
35374 if (atomic_read(&dev->ioctl_count)) {
35375 DRM_ERROR("Device busy: %d\n",
35376 atomic_read(&dev->ioctl_count));
35377 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35378 index f731116..629842c 100644
35379 --- a/drivers/gpu/drm/drm_global.c
35380 +++ b/drivers/gpu/drm/drm_global.c
35381 @@ -36,7 +36,7 @@
35382 struct drm_global_item {
35383 struct mutex mutex;
35384 void *object;
35385 - int refcount;
35386 + atomic_t refcount;
35387 };
35388
35389 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35390 @@ -49,7 +49,7 @@ void drm_global_init(void)
35391 struct drm_global_item *item = &glob[i];
35392 mutex_init(&item->mutex);
35393 item->object = NULL;
35394 - item->refcount = 0;
35395 + atomic_set(&item->refcount, 0);
35396 }
35397 }
35398
35399 @@ -59,7 +59,7 @@ void drm_global_release(void)
35400 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35401 struct drm_global_item *item = &glob[i];
35402 BUG_ON(item->object != NULL);
35403 - BUG_ON(item->refcount != 0);
35404 + BUG_ON(atomic_read(&item->refcount) != 0);
35405 }
35406 }
35407
35408 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35409 void *object;
35410
35411 mutex_lock(&item->mutex);
35412 - if (item->refcount == 0) {
35413 + if (atomic_read(&item->refcount) == 0) {
35414 item->object = kzalloc(ref->size, GFP_KERNEL);
35415 if (unlikely(item->object == NULL)) {
35416 ret = -ENOMEM;
35417 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35418 goto out_err;
35419
35420 }
35421 - ++item->refcount;
35422 + atomic_inc(&item->refcount);
35423 ref->object = item->object;
35424 object = item->object;
35425 mutex_unlock(&item->mutex);
35426 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35427 struct drm_global_item *item = &glob[ref->global_type];
35428
35429 mutex_lock(&item->mutex);
35430 - BUG_ON(item->refcount == 0);
35431 + BUG_ON(atomic_read(&item->refcount) == 0);
35432 BUG_ON(ref->object != item->object);
35433 - if (--item->refcount == 0) {
35434 + if (atomic_dec_and_test(&item->refcount)) {
35435 ref->release(ref);
35436 item->object = NULL;
35437 }
35438 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35439 index d4b20ce..77a8d41 100644
35440 --- a/drivers/gpu/drm/drm_info.c
35441 +++ b/drivers/gpu/drm/drm_info.c
35442 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35443 struct drm_local_map *map;
35444 struct drm_map_list *r_list;
35445
35446 - /* Hardcoded from _DRM_FRAME_BUFFER,
35447 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35448 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35449 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35450 + static const char * const types[] = {
35451 + [_DRM_FRAME_BUFFER] = "FB",
35452 + [_DRM_REGISTERS] = "REG",
35453 + [_DRM_SHM] = "SHM",
35454 + [_DRM_AGP] = "AGP",
35455 + [_DRM_SCATTER_GATHER] = "SG",
35456 + [_DRM_CONSISTENT] = "PCI",
35457 + [_DRM_GEM] = "GEM" };
35458 const char *type;
35459 int i;
35460
35461 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35462 map = r_list->map;
35463 if (!map)
35464 continue;
35465 - if (map->type < 0 || map->type > 5)
35466 + if (map->type >= ARRAY_SIZE(types))
35467 type = "??";
35468 else
35469 type = types[map->type];
35470 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35471 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35472 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35473 vma->vm_flags & VM_IO ? 'i' : '-',
35474 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35475 + 0);
35476 +#else
35477 vma->vm_pgoff);
35478 +#endif
35479
35480 #if defined(__i386__)
35481 pgprot = pgprot_val(vma->vm_page_prot);
35482 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35483 index 2f4c434..dd12cd2 100644
35484 --- a/drivers/gpu/drm/drm_ioc32.c
35485 +++ b/drivers/gpu/drm/drm_ioc32.c
35486 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35487 request = compat_alloc_user_space(nbytes);
35488 if (!access_ok(VERIFY_WRITE, request, nbytes))
35489 return -EFAULT;
35490 - list = (struct drm_buf_desc *) (request + 1);
35491 + list = (struct drm_buf_desc __user *) (request + 1);
35492
35493 if (__put_user(count, &request->count)
35494 || __put_user(list, &request->list))
35495 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35496 request = compat_alloc_user_space(nbytes);
35497 if (!access_ok(VERIFY_WRITE, request, nbytes))
35498 return -EFAULT;
35499 - list = (struct drm_buf_pub *) (request + 1);
35500 + list = (struct drm_buf_pub __user *) (request + 1);
35501
35502 if (__put_user(count, &request->count)
35503 || __put_user(list, &request->list))
35504 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35505 return 0;
35506 }
35507
35508 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35509 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35510 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35511 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35512 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35513 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35514 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35515 {
35516 unsigned int nr = DRM_IOCTL_NR(cmd);
35517 - drm_ioctl_compat_t *fn;
35518 int ret;
35519
35520 /* Assume that ioctls without an explicit compat routine will just
35521 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35522 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35523 return drm_ioctl(filp, cmd, arg);
35524
35525 - fn = drm_compat_ioctls[nr];
35526 -
35527 - if (fn != NULL)
35528 - ret = (*fn) (filp, cmd, arg);
35529 + if (drm_compat_ioctls[nr] != NULL)
35530 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35531 else
35532 ret = drm_ioctl(filp, cmd, arg);
35533
35534 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35535 index e77bd8b..1571b85 100644
35536 --- a/drivers/gpu/drm/drm_ioctl.c
35537 +++ b/drivers/gpu/drm/drm_ioctl.c
35538 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35539 stats->data[i].value =
35540 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35541 else
35542 - stats->data[i].value = atomic_read(&dev->counts[i]);
35543 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35544 stats->data[i].type = dev->types[i];
35545 }
35546
35547 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35548 index d752c96..fe08455 100644
35549 --- a/drivers/gpu/drm/drm_lock.c
35550 +++ b/drivers/gpu/drm/drm_lock.c
35551 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35552 if (drm_lock_take(&master->lock, lock->context)) {
35553 master->lock.file_priv = file_priv;
35554 master->lock.lock_time = jiffies;
35555 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35556 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35557 break; /* Got lock */
35558 }
35559
35560 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35561 return -EINVAL;
35562 }
35563
35564 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35565 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35566
35567 if (drm_lock_free(&master->lock, lock->context)) {
35568 /* FIXME: Should really bail out here. */
35569 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35570 index 16f3ec5..b28f9ca 100644
35571 --- a/drivers/gpu/drm/drm_stub.c
35572 +++ b/drivers/gpu/drm/drm_stub.c
35573 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35574
35575 drm_device_set_unplugged(dev);
35576
35577 - if (dev->open_count == 0) {
35578 + if (local_read(&dev->open_count) == 0) {
35579 drm_put_dev(dev);
35580 }
35581 mutex_unlock(&drm_global_mutex);
35582 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35583 index 0229665..f61329c 100644
35584 --- a/drivers/gpu/drm/drm_sysfs.c
35585 +++ b/drivers/gpu/drm/drm_sysfs.c
35586 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35587 int drm_sysfs_device_add(struct drm_minor *minor)
35588 {
35589 int err;
35590 - char *minor_str;
35591 + const char *minor_str;
35592
35593 minor->kdev.parent = minor->dev->dev;
35594
35595 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35596 index 004ecdf..db1f6e0 100644
35597 --- a/drivers/gpu/drm/i810/i810_dma.c
35598 +++ b/drivers/gpu/drm/i810/i810_dma.c
35599 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35600 dma->buflist[vertex->idx],
35601 vertex->discard, vertex->used);
35602
35603 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35604 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35605 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35606 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35607 sarea_priv->last_enqueue = dev_priv->counter - 1;
35608 sarea_priv->last_dispatch = (int)hw_status[5];
35609
35610 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35611 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35612 mc->last_render);
35613
35614 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35615 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35616 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35617 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35618 sarea_priv->last_enqueue = dev_priv->counter - 1;
35619 sarea_priv->last_dispatch = (int)hw_status[5];
35620
35621 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35622 index 6e0acad..93c8289 100644
35623 --- a/drivers/gpu/drm/i810/i810_drv.h
35624 +++ b/drivers/gpu/drm/i810/i810_drv.h
35625 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35626 int page_flipping;
35627
35628 wait_queue_head_t irq_queue;
35629 - atomic_t irq_received;
35630 - atomic_t irq_emitted;
35631 + atomic_unchecked_t irq_received;
35632 + atomic_unchecked_t irq_emitted;
35633
35634 int front_offset;
35635 } drm_i810_private_t;
35636 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35637 index e913d32..4d9b351 100644
35638 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35639 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35640 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35641 I915_READ(GTIMR));
35642 }
35643 seq_printf(m, "Interrupts received: %d\n",
35644 - atomic_read(&dev_priv->irq_received));
35645 + atomic_read_unchecked(&dev_priv->irq_received));
35646 for_each_ring(ring, dev_priv, i) {
35647 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35648 seq_printf(m,
35649 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35650 index f968590..19115e35 100644
35651 --- a/drivers/gpu/drm/i915/i915_dma.c
35652 +++ b/drivers/gpu/drm/i915/i915_dma.c
35653 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35654 bool can_switch;
35655
35656 spin_lock(&dev->count_lock);
35657 - can_switch = (dev->open_count == 0);
35658 + can_switch = (local_read(&dev->open_count) == 0);
35659 spin_unlock(&dev->count_lock);
35660 return can_switch;
35661 }
35662 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35663 index 47d8b68..52f5d8d 100644
35664 --- a/drivers/gpu/drm/i915/i915_drv.h
35665 +++ b/drivers/gpu/drm/i915/i915_drv.h
35666 @@ -916,7 +916,7 @@ typedef struct drm_i915_private {
35667 drm_dma_handle_t *status_page_dmah;
35668 struct resource mch_res;
35669
35670 - atomic_t irq_received;
35671 + atomic_unchecked_t irq_received;
35672
35673 /* protects the irq masks */
35674 spinlock_t irq_lock;
35675 @@ -1813,7 +1813,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35676 struct drm_i915_private *dev_priv, unsigned port);
35677 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35678 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35679 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35680 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35681 {
35682 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35683 }
35684 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35685 index 117ce38..eefd237 100644
35686 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35687 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35688 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35689
35690 static int
35691 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35692 - int count)
35693 + unsigned int count)
35694 {
35695 - int i;
35696 + unsigned int i;
35697 int relocs_total = 0;
35698 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35699
35700 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35701 index 3c59584..500f2e9 100644
35702 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35703 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35704 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35705 (unsigned long)request);
35706 }
35707
35708 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35709 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35710 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35711 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35712 [DRM_I915_GETPARAM] = compat_i915_getparam,
35713 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35714 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35715 {
35716 unsigned int nr = DRM_IOCTL_NR(cmd);
35717 - drm_ioctl_compat_t *fn = NULL;
35718 int ret;
35719
35720 if (nr < DRM_COMMAND_BASE)
35721 return drm_compat_ioctl(filp, cmd, arg);
35722
35723 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35724 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35725 -
35726 - if (fn != NULL)
35727 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35728 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35729 ret = (*fn) (filp, cmd, arg);
35730 - else
35731 + } else
35732 ret = drm_ioctl(filp, cmd, arg);
35733
35734 return ret;
35735 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35736 index e5e32869..1678f36 100644
35737 --- a/drivers/gpu/drm/i915/i915_irq.c
35738 +++ b/drivers/gpu/drm/i915/i915_irq.c
35739 @@ -670,7 +670,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35740 int pipe;
35741 u32 pipe_stats[I915_MAX_PIPES];
35742
35743 - atomic_inc(&dev_priv->irq_received);
35744 + atomic_inc_unchecked(&dev_priv->irq_received);
35745
35746 while (true) {
35747 iir = I915_READ(VLV_IIR);
35748 @@ -835,7 +835,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35749 irqreturn_t ret = IRQ_NONE;
35750 int i;
35751
35752 - atomic_inc(&dev_priv->irq_received);
35753 + atomic_inc_unchecked(&dev_priv->irq_received);
35754
35755 /* disable master interrupt before clearing iir */
35756 de_ier = I915_READ(DEIER);
35757 @@ -925,7 +925,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35758 int ret = IRQ_NONE;
35759 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35760
35761 - atomic_inc(&dev_priv->irq_received);
35762 + atomic_inc_unchecked(&dev_priv->irq_received);
35763
35764 /* disable master interrupt before clearing iir */
35765 de_ier = I915_READ(DEIER);
35766 @@ -2089,7 +2089,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35767 {
35768 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35769
35770 - atomic_set(&dev_priv->irq_received, 0);
35771 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35772
35773 I915_WRITE(HWSTAM, 0xeffe);
35774
35775 @@ -2124,7 +2124,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35776 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35777 int pipe;
35778
35779 - atomic_set(&dev_priv->irq_received, 0);
35780 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35781
35782 /* VLV magic */
35783 I915_WRITE(VLV_IMR, 0);
35784 @@ -2411,7 +2411,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35785 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35786 int pipe;
35787
35788 - atomic_set(&dev_priv->irq_received, 0);
35789 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35790
35791 for_each_pipe(pipe)
35792 I915_WRITE(PIPESTAT(pipe), 0);
35793 @@ -2490,7 +2490,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35794 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35795 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35796
35797 - atomic_inc(&dev_priv->irq_received);
35798 + atomic_inc_unchecked(&dev_priv->irq_received);
35799
35800 iir = I915_READ16(IIR);
35801 if (iir == 0)
35802 @@ -2565,7 +2565,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35803 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35804 int pipe;
35805
35806 - atomic_set(&dev_priv->irq_received, 0);
35807 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35808
35809 if (I915_HAS_HOTPLUG(dev)) {
35810 I915_WRITE(PORT_HOTPLUG_EN, 0);
35811 @@ -2664,7 +2664,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35812 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35813 int pipe, ret = IRQ_NONE;
35814
35815 - atomic_inc(&dev_priv->irq_received);
35816 + atomic_inc_unchecked(&dev_priv->irq_received);
35817
35818 iir = I915_READ(IIR);
35819 do {
35820 @@ -2791,7 +2791,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35821 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35822 int pipe;
35823
35824 - atomic_set(&dev_priv->irq_received, 0);
35825 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35826
35827 I915_WRITE(PORT_HOTPLUG_EN, 0);
35828 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35829 @@ -2898,7 +2898,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35830 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35831 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35832
35833 - atomic_inc(&dev_priv->irq_received);
35834 + atomic_inc_unchecked(&dev_priv->irq_received);
35835
35836 iir = I915_READ(IIR);
35837
35838 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35839 index e1f4e6e..c94a4b3 100644
35840 --- a/drivers/gpu/drm/i915/intel_display.c
35841 +++ b/drivers/gpu/drm/i915/intel_display.c
35842 @@ -8933,13 +8933,13 @@ struct intel_quirk {
35843 int subsystem_vendor;
35844 int subsystem_device;
35845 void (*hook)(struct drm_device *dev);
35846 -};
35847 +} __do_const;
35848
35849 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35850 struct intel_dmi_quirk {
35851 void (*hook)(struct drm_device *dev);
35852 const struct dmi_system_id (*dmi_id_list)[];
35853 -};
35854 +} __do_const;
35855
35856 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35857 {
35858 @@ -8947,18 +8947,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35859 return 1;
35860 }
35861
35862 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35863 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35864 {
35865 - .dmi_id_list = &(const struct dmi_system_id[]) {
35866 - {
35867 - .callback = intel_dmi_reverse_brightness,
35868 - .ident = "NCR Corporation",
35869 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35870 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35871 - },
35872 - },
35873 - { } /* terminating entry */
35874 + .callback = intel_dmi_reverse_brightness,
35875 + .ident = "NCR Corporation",
35876 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35877 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35878 },
35879 + },
35880 + { } /* terminating entry */
35881 +};
35882 +
35883 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35884 + {
35885 + .dmi_id_list = &intel_dmi_quirks_table,
35886 .hook = quirk_invert_brightness,
35887 },
35888 };
35889 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35890 index 54558a0..2d97005 100644
35891 --- a/drivers/gpu/drm/mga/mga_drv.h
35892 +++ b/drivers/gpu/drm/mga/mga_drv.h
35893 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35894 u32 clear_cmd;
35895 u32 maccess;
35896
35897 - atomic_t vbl_received; /**< Number of vblanks received. */
35898 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35899 wait_queue_head_t fence_queue;
35900 - atomic_t last_fence_retired;
35901 + atomic_unchecked_t last_fence_retired;
35902 u32 next_fence_to_post;
35903
35904 unsigned int fb_cpp;
35905 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35906 index 709e90d..89a1c0d 100644
35907 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35908 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35909 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35910 return 0;
35911 }
35912
35913 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35914 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35915 [DRM_MGA_INIT] = compat_mga_init,
35916 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35917 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35918 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35919 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35920 {
35921 unsigned int nr = DRM_IOCTL_NR(cmd);
35922 - drm_ioctl_compat_t *fn = NULL;
35923 int ret;
35924
35925 if (nr < DRM_COMMAND_BASE)
35926 return drm_compat_ioctl(filp, cmd, arg);
35927
35928 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35929 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35930 -
35931 - if (fn != NULL)
35932 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35933 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35934 ret = (*fn) (filp, cmd, arg);
35935 - else
35936 + } else
35937 ret = drm_ioctl(filp, cmd, arg);
35938
35939 return ret;
35940 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35941 index 598c281..60d590e 100644
35942 --- a/drivers/gpu/drm/mga/mga_irq.c
35943 +++ b/drivers/gpu/drm/mga/mga_irq.c
35944 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35945 if (crtc != 0)
35946 return 0;
35947
35948 - return atomic_read(&dev_priv->vbl_received);
35949 + return atomic_read_unchecked(&dev_priv->vbl_received);
35950 }
35951
35952
35953 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35954 /* VBLANK interrupt */
35955 if (status & MGA_VLINEPEN) {
35956 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35957 - atomic_inc(&dev_priv->vbl_received);
35958 + atomic_inc_unchecked(&dev_priv->vbl_received);
35959 drm_handle_vblank(dev, 0);
35960 handled = 1;
35961 }
35962 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35963 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35964 MGA_WRITE(MGA_PRIMEND, prim_end);
35965
35966 - atomic_inc(&dev_priv->last_fence_retired);
35967 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35968 DRM_WAKEUP(&dev_priv->fence_queue);
35969 handled = 1;
35970 }
35971 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35972 * using fences.
35973 */
35974 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35975 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35976 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35977 - *sequence) <= (1 << 23)));
35978
35979 *sequence = cur_fence;
35980 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35981 index 6aa2137..fe8dc55 100644
35982 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35983 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35984 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35985 struct bit_table {
35986 const char id;
35987 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35988 -};
35989 +} __no_const;
35990
35991 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35992
35993 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35994 index f2b30f8..d0f9a95 100644
35995 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35996 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35997 @@ -92,7 +92,7 @@ struct nouveau_drm {
35998 struct drm_global_reference mem_global_ref;
35999 struct ttm_bo_global_ref bo_global_ref;
36000 struct ttm_bo_device bdev;
36001 - atomic_t validate_sequence;
36002 + atomic_unchecked_t validate_sequence;
36003 int (*move)(struct nouveau_channel *,
36004 struct ttm_buffer_object *,
36005 struct ttm_mem_reg *, struct ttm_mem_reg *);
36006 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
36007 index b4b4d0c..b7edc15 100644
36008 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
36009 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
36010 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
36011 int ret, i;
36012 struct nouveau_bo *res_bo = NULL;
36013
36014 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
36015 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
36016 retry:
36017 if (++trycnt > 100000) {
36018 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
36019 @@ -359,7 +359,7 @@ retry:
36020 if (ret) {
36021 validate_fini(op, NULL);
36022 if (unlikely(ret == -EAGAIN)) {
36023 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
36024 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
36025 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
36026 sequence);
36027 if (!ret)
36028 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36029 index 08214bc..9208577 100644
36030 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36031 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36032 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
36033 unsigned long arg)
36034 {
36035 unsigned int nr = DRM_IOCTL_NR(cmd);
36036 - drm_ioctl_compat_t *fn = NULL;
36037 + drm_ioctl_compat_t fn = NULL;
36038 int ret;
36039
36040 if (nr < DRM_COMMAND_BASE)
36041 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
36042 index 25d3495..d81aaf6 100644
36043 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
36044 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
36045 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
36046 bool can_switch;
36047
36048 spin_lock(&dev->count_lock);
36049 - can_switch = (dev->open_count == 0);
36050 + can_switch = (local_read(&dev->open_count) == 0);
36051 spin_unlock(&dev->count_lock);
36052 return can_switch;
36053 }
36054 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
36055 index 489cb8c..0b8d0d3 100644
36056 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
36057 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
36058 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
36059 }
36060 }
36061
36062 -static struct vm_operations_struct qxl_ttm_vm_ops;
36063 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
36064 static const struct vm_operations_struct *ttm_vm_ops;
36065
36066 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36067 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
36068 return r;
36069 if (unlikely(ttm_vm_ops == NULL)) {
36070 ttm_vm_ops = vma->vm_ops;
36071 + pax_open_kernel();
36072 qxl_ttm_vm_ops = *ttm_vm_ops;
36073 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
36074 + pax_close_kernel();
36075 }
36076 vma->vm_ops = &qxl_ttm_vm_ops;
36077 return 0;
36078 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
36079 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
36080 {
36081 #if defined(CONFIG_DEBUG_FS)
36082 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
36083 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
36084 - unsigned i;
36085 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
36086 + {
36087 + .name = "qxl_mem_mm",
36088 + .show = &qxl_mm_dump_table,
36089 + },
36090 + {
36091 + .name = "qxl_surf_mm",
36092 + .show = &qxl_mm_dump_table,
36093 + }
36094 + };
36095
36096 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
36097 - if (i == 0)
36098 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
36099 - else
36100 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
36101 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
36102 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
36103 - qxl_mem_types_list[i].driver_features = 0;
36104 - if (i == 0)
36105 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36106 - else
36107 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36108 + pax_open_kernel();
36109 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36110 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36111 + pax_close_kernel();
36112
36113 - }
36114 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
36115 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
36116 #else
36117 return 0;
36118 #endif
36119 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
36120 index d4660cf..70dbe65 100644
36121 --- a/drivers/gpu/drm/r128/r128_cce.c
36122 +++ b/drivers/gpu/drm/r128/r128_cce.c
36123 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
36124
36125 /* GH: Simple idle check.
36126 */
36127 - atomic_set(&dev_priv->idle_count, 0);
36128 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36129
36130 /* We don't support anything other than bus-mastering ring mode,
36131 * but the ring can be in either AGP or PCI space for the ring
36132 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
36133 index 930c71b..499aded 100644
36134 --- a/drivers/gpu/drm/r128/r128_drv.h
36135 +++ b/drivers/gpu/drm/r128/r128_drv.h
36136 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36137 int is_pci;
36138 unsigned long cce_buffers_offset;
36139
36140 - atomic_t idle_count;
36141 + atomic_unchecked_t idle_count;
36142
36143 int page_flipping;
36144 int current_page;
36145 u32 crtc_offset;
36146 u32 crtc_offset_cntl;
36147
36148 - atomic_t vbl_received;
36149 + atomic_unchecked_t vbl_received;
36150
36151 u32 color_fmt;
36152 unsigned int front_offset;
36153 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36154 index a954c54..9cc595c 100644
36155 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36156 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36157 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36158 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36159 }
36160
36161 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36162 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36163 [DRM_R128_INIT] = compat_r128_init,
36164 [DRM_R128_DEPTH] = compat_r128_depth,
36165 [DRM_R128_STIPPLE] = compat_r128_stipple,
36166 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36167 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36168 {
36169 unsigned int nr = DRM_IOCTL_NR(cmd);
36170 - drm_ioctl_compat_t *fn = NULL;
36171 int ret;
36172
36173 if (nr < DRM_COMMAND_BASE)
36174 return drm_compat_ioctl(filp, cmd, arg);
36175
36176 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36177 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36178 -
36179 - if (fn != NULL)
36180 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36181 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36182 ret = (*fn) (filp, cmd, arg);
36183 - else
36184 + } else
36185 ret = drm_ioctl(filp, cmd, arg);
36186
36187 return ret;
36188 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36189 index 2ea4f09..d391371 100644
36190 --- a/drivers/gpu/drm/r128/r128_irq.c
36191 +++ b/drivers/gpu/drm/r128/r128_irq.c
36192 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36193 if (crtc != 0)
36194 return 0;
36195
36196 - return atomic_read(&dev_priv->vbl_received);
36197 + return atomic_read_unchecked(&dev_priv->vbl_received);
36198 }
36199
36200 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36201 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36202 /* VBLANK interrupt */
36203 if (status & R128_CRTC_VBLANK_INT) {
36204 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36205 - atomic_inc(&dev_priv->vbl_received);
36206 + atomic_inc_unchecked(&dev_priv->vbl_received);
36207 drm_handle_vblank(dev, 0);
36208 return IRQ_HANDLED;
36209 }
36210 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36211 index 19bb7e6..de7e2a2 100644
36212 --- a/drivers/gpu/drm/r128/r128_state.c
36213 +++ b/drivers/gpu/drm/r128/r128_state.c
36214 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36215
36216 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36217 {
36218 - if (atomic_read(&dev_priv->idle_count) == 0)
36219 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36220 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36221 else
36222 - atomic_set(&dev_priv->idle_count, 0);
36223 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36224 }
36225
36226 #endif
36227 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36228 index 5a82b6b..9e69c73 100644
36229 --- a/drivers/gpu/drm/radeon/mkregtable.c
36230 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36231 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36232 regex_t mask_rex;
36233 regmatch_t match[4];
36234 char buf[1024];
36235 - size_t end;
36236 + long end;
36237 int len;
36238 int done = 0;
36239 int r;
36240 unsigned o;
36241 struct offset *offset;
36242 char last_reg_s[10];
36243 - int last_reg;
36244 + unsigned long last_reg;
36245
36246 if (regcomp
36247 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36248 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36249 index b0dc0b6..a9bfe9c 100644
36250 --- a/drivers/gpu/drm/radeon/radeon_device.c
36251 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36252 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36253 bool can_switch;
36254
36255 spin_lock(&dev->count_lock);
36256 - can_switch = (dev->open_count == 0);
36257 + can_switch = (local_read(&dev->open_count) == 0);
36258 spin_unlock(&dev->count_lock);
36259 return can_switch;
36260 }
36261 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36262 index b369d42..8dd04eb 100644
36263 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36264 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36265 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
36266
36267 /* SW interrupt */
36268 wait_queue_head_t swi_queue;
36269 - atomic_t swi_emitted;
36270 + atomic_unchecked_t swi_emitted;
36271 int vblank_crtc;
36272 uint32_t irq_enable_reg;
36273 uint32_t r500_disp_irq_reg;
36274 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36275 index c180df8..5fd8186 100644
36276 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36277 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36278 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36279 request = compat_alloc_user_space(sizeof(*request));
36280 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36281 || __put_user(req32.param, &request->param)
36282 - || __put_user((void __user *)(unsigned long)req32.value,
36283 + || __put_user((unsigned long)req32.value,
36284 &request->value))
36285 return -EFAULT;
36286
36287 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36288 #define compat_radeon_cp_setparam NULL
36289 #endif /* X86_64 || IA64 */
36290
36291 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36292 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36293 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36294 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36295 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36296 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36297 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36298 {
36299 unsigned int nr = DRM_IOCTL_NR(cmd);
36300 - drm_ioctl_compat_t *fn = NULL;
36301 int ret;
36302
36303 if (nr < DRM_COMMAND_BASE)
36304 return drm_compat_ioctl(filp, cmd, arg);
36305
36306 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36307 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36308 -
36309 - if (fn != NULL)
36310 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36311 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36312 ret = (*fn) (filp, cmd, arg);
36313 - else
36314 + } else
36315 ret = drm_ioctl(filp, cmd, arg);
36316
36317 return ret;
36318 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36319 index 8d68e97..9dcfed8 100644
36320 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36321 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36322 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36323 unsigned int ret;
36324 RING_LOCALS;
36325
36326 - atomic_inc(&dev_priv->swi_emitted);
36327 - ret = atomic_read(&dev_priv->swi_emitted);
36328 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36329 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36330
36331 BEGIN_RING(4);
36332 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36333 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36334 drm_radeon_private_t *dev_priv =
36335 (drm_radeon_private_t *) dev->dev_private;
36336
36337 - atomic_set(&dev_priv->swi_emitted, 0);
36338 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36339 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36340
36341 dev->max_vblank_count = 0x001fffff;
36342 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36343 index 4d20910..6726b6d 100644
36344 --- a/drivers/gpu/drm/radeon/radeon_state.c
36345 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36346 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36347 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36348 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36349
36350 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36351 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36352 sarea_priv->nbox * sizeof(depth_boxes[0])))
36353 return -EFAULT;
36354
36355 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36356 {
36357 drm_radeon_private_t *dev_priv = dev->dev_private;
36358 drm_radeon_getparam_t *param = data;
36359 - int value;
36360 + int value = 0;
36361
36362 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36363
36364 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36365 index 6c0ce89..57a2529 100644
36366 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36367 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36368 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36369 man->size = size >> PAGE_SHIFT;
36370 }
36371
36372 -static struct vm_operations_struct radeon_ttm_vm_ops;
36373 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36374 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36375
36376 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36377 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36378 }
36379 if (unlikely(ttm_vm_ops == NULL)) {
36380 ttm_vm_ops = vma->vm_ops;
36381 + pax_open_kernel();
36382 radeon_ttm_vm_ops = *ttm_vm_ops;
36383 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36384 + pax_close_kernel();
36385 }
36386 vma->vm_ops = &radeon_ttm_vm_ops;
36387 return 0;
36388 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
36389 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36390 {
36391 #if defined(CONFIG_DEBUG_FS)
36392 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
36393 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
36394 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
36395 + {
36396 + .name = "radeon_vram_mm",
36397 + .show = &radeon_mm_dump_table,
36398 + },
36399 + {
36400 + .name = "radeon_gtt_mm",
36401 + .show = &radeon_mm_dump_table,
36402 + },
36403 + {
36404 + .name = "ttm_page_pool",
36405 + .show = &ttm_page_alloc_debugfs,
36406 + },
36407 + {
36408 + .name = "ttm_dma_page_pool",
36409 + .show = &ttm_dma_page_alloc_debugfs,
36410 + },
36411 + };
36412 unsigned i;
36413
36414 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
36415 - if (i == 0)
36416 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36417 - else
36418 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36419 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36420 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36421 - radeon_mem_types_list[i].driver_features = 0;
36422 - if (i == 0)
36423 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36424 - else
36425 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36426 -
36427 - }
36428 - /* Add ttm page pool to debugfs */
36429 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36430 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36431 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36432 - radeon_mem_types_list[i].driver_features = 0;
36433 - radeon_mem_types_list[i++].data = NULL;
36434 + pax_open_kernel();
36435 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36436 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36437 + pax_close_kernel();
36438 #ifdef CONFIG_SWIOTLB
36439 - if (swiotlb_nr_tbl()) {
36440 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36441 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36442 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36443 - radeon_mem_types_list[i].driver_features = 0;
36444 - radeon_mem_types_list[i++].data = NULL;
36445 - }
36446 + if (swiotlb_nr_tbl())
36447 + i++;
36448 #endif
36449 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36450
36451 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36452 index 55880d5..9e95342 100644
36453 --- a/drivers/gpu/drm/radeon/rs690.c
36454 +++ b/drivers/gpu/drm/radeon/rs690.c
36455 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36456 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36457 rdev->pm.sideport_bandwidth.full)
36458 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36459 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36460 + read_delay_latency.full = dfixed_const(800 * 1000);
36461 read_delay_latency.full = dfixed_div(read_delay_latency,
36462 rdev->pm.igp_sideport_mclk);
36463 + a.full = dfixed_const(370);
36464 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36465 } else {
36466 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36467 rdev->pm.k8_bandwidth.full)
36468 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36469 index dbc2def..0a9f710 100644
36470 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36471 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36472 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36473 zone->glob = glob;
36474 glob->zone_kernel = zone;
36475 ret = kobject_init_and_add(
36476 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36477 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36478 if (unlikely(ret != 0)) {
36479 kobject_put(&zone->kobj);
36480 return ret;
36481 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36482 zone->glob = glob;
36483 glob->zone_dma32 = zone;
36484 ret = kobject_init_and_add(
36485 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36486 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36487 if (unlikely(ret != 0)) {
36488 kobject_put(&zone->kobj);
36489 return ret;
36490 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36491 index bd2a3b4..122d9ad 100644
36492 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36493 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36494 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36495 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36496 struct shrink_control *sc)
36497 {
36498 - static atomic_t start_pool = ATOMIC_INIT(0);
36499 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36500 unsigned i;
36501 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36502 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36503 struct ttm_page_pool *pool;
36504 int shrink_pages = sc->nr_to_scan;
36505
36506 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36507 index dc0c065..58a0782 100644
36508 --- a/drivers/gpu/drm/udl/udl_fb.c
36509 +++ b/drivers/gpu/drm/udl/udl_fb.c
36510 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36511 fb_deferred_io_cleanup(info);
36512 kfree(info->fbdefio);
36513 info->fbdefio = NULL;
36514 - info->fbops->fb_mmap = udl_fb_mmap;
36515 }
36516
36517 pr_warn("released /dev/fb%d user=%d count=%d\n",
36518 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36519 index 893a650..6190d3b 100644
36520 --- a/drivers/gpu/drm/via/via_drv.h
36521 +++ b/drivers/gpu/drm/via/via_drv.h
36522 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36523 typedef uint32_t maskarray_t[5];
36524
36525 typedef struct drm_via_irq {
36526 - atomic_t irq_received;
36527 + atomic_unchecked_t irq_received;
36528 uint32_t pending_mask;
36529 uint32_t enable_mask;
36530 wait_queue_head_t irq_queue;
36531 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36532 struct timeval last_vblank;
36533 int last_vblank_valid;
36534 unsigned usec_per_vblank;
36535 - atomic_t vbl_received;
36536 + atomic_unchecked_t vbl_received;
36537 drm_via_state_t hc_state;
36538 char pci_buf[VIA_PCI_BUF_SIZE];
36539 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36540 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36541 index ac98964..5dbf512 100644
36542 --- a/drivers/gpu/drm/via/via_irq.c
36543 +++ b/drivers/gpu/drm/via/via_irq.c
36544 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36545 if (crtc != 0)
36546 return 0;
36547
36548 - return atomic_read(&dev_priv->vbl_received);
36549 + return atomic_read_unchecked(&dev_priv->vbl_received);
36550 }
36551
36552 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36553 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36554
36555 status = VIA_READ(VIA_REG_INTERRUPT);
36556 if (status & VIA_IRQ_VBLANK_PENDING) {
36557 - atomic_inc(&dev_priv->vbl_received);
36558 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36559 + atomic_inc_unchecked(&dev_priv->vbl_received);
36560 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36561 do_gettimeofday(&cur_vblank);
36562 if (dev_priv->last_vblank_valid) {
36563 dev_priv->usec_per_vblank =
36564 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36565 dev_priv->last_vblank = cur_vblank;
36566 dev_priv->last_vblank_valid = 1;
36567 }
36568 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36569 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36570 DRM_DEBUG("US per vblank is: %u\n",
36571 dev_priv->usec_per_vblank);
36572 }
36573 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36574
36575 for (i = 0; i < dev_priv->num_irqs; ++i) {
36576 if (status & cur_irq->pending_mask) {
36577 - atomic_inc(&cur_irq->irq_received);
36578 + atomic_inc_unchecked(&cur_irq->irq_received);
36579 DRM_WAKEUP(&cur_irq->irq_queue);
36580 handled = 1;
36581 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36582 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36583 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36584 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36585 masks[irq][4]));
36586 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36587 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36588 } else {
36589 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36590 (((cur_irq_sequence =
36591 - atomic_read(&cur_irq->irq_received)) -
36592 + atomic_read_unchecked(&cur_irq->irq_received)) -
36593 *sequence) <= (1 << 23)));
36594 }
36595 *sequence = cur_irq_sequence;
36596 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36597 }
36598
36599 for (i = 0; i < dev_priv->num_irqs; ++i) {
36600 - atomic_set(&cur_irq->irq_received, 0);
36601 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36602 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36603 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36604 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36605 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36606 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36607 case VIA_IRQ_RELATIVE:
36608 irqwait->request.sequence +=
36609 - atomic_read(&cur_irq->irq_received);
36610 + atomic_read_unchecked(&cur_irq->irq_received);
36611 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36612 case VIA_IRQ_ABSOLUTE:
36613 break;
36614 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36615 index 13aeda7..4a952d1 100644
36616 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36617 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36618 @@ -290,7 +290,7 @@ struct vmw_private {
36619 * Fencing and IRQs.
36620 */
36621
36622 - atomic_t marker_seq;
36623 + atomic_unchecked_t marker_seq;
36624 wait_queue_head_t fence_queue;
36625 wait_queue_head_t fifo_queue;
36626 int fence_queue_waiters; /* Protected by hw_mutex */
36627 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36628 index 3eb1486..0a47ee9 100644
36629 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36630 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36631 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36632 (unsigned int) min,
36633 (unsigned int) fifo->capabilities);
36634
36635 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36636 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36637 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36638 vmw_marker_queue_init(&fifo->marker_queue);
36639 return vmw_fifo_send_fence(dev_priv, &dummy);
36640 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36641 if (reserveable)
36642 iowrite32(bytes, fifo_mem +
36643 SVGA_FIFO_RESERVED);
36644 - return fifo_mem + (next_cmd >> 2);
36645 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36646 } else {
36647 need_bounce = true;
36648 }
36649 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36650
36651 fm = vmw_fifo_reserve(dev_priv, bytes);
36652 if (unlikely(fm == NULL)) {
36653 - *seqno = atomic_read(&dev_priv->marker_seq);
36654 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36655 ret = -ENOMEM;
36656 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36657 false, 3*HZ);
36658 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36659 }
36660
36661 do {
36662 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36663 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36664 } while (*seqno == 0);
36665
36666 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36667 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36668 index c509d40..3b640c3 100644
36669 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36670 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36671 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36672 int ret;
36673
36674 num_clips = arg->num_clips;
36675 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36676 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36677
36678 if (unlikely(num_clips == 0))
36679 return 0;
36680 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36681 int ret;
36682
36683 num_clips = arg->num_clips;
36684 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36685 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36686
36687 if (unlikely(num_clips == 0))
36688 return 0;
36689 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36690 index 4640adb..e1384ed 100644
36691 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36692 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36693 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36694 * emitted. Then the fence is stale and signaled.
36695 */
36696
36697 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36698 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36699 > VMW_FENCE_WRAP);
36700
36701 return ret;
36702 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36703
36704 if (fifo_idle)
36705 down_read(&fifo_state->rwsem);
36706 - signal_seq = atomic_read(&dev_priv->marker_seq);
36707 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36708 ret = 0;
36709
36710 for (;;) {
36711 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36712 index 8a8725c2..afed796 100644
36713 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36714 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36715 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36716 while (!vmw_lag_lt(queue, us)) {
36717 spin_lock(&queue->lock);
36718 if (list_empty(&queue->head))
36719 - seqno = atomic_read(&dev_priv->marker_seq);
36720 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36721 else {
36722 marker = list_first_entry(&queue->head,
36723 struct vmw_marker, head);
36724 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
36725 index 8c04943..4370ed9 100644
36726 --- a/drivers/gpu/host1x/drm/dc.c
36727 +++ b/drivers/gpu/host1x/drm/dc.c
36728 @@ -999,7 +999,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
36729 }
36730
36731 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
36732 - dc->debugfs_files[i].data = dc;
36733 + *(void **)&dc->debugfs_files[i].data = dc;
36734
36735 err = drm_debugfs_create_files(dc->debugfs_files,
36736 ARRAY_SIZE(debugfs_files),
36737 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36738 index 402f486..f862d7e 100644
36739 --- a/drivers/hid/hid-core.c
36740 +++ b/drivers/hid/hid-core.c
36741 @@ -2275,7 +2275,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36742
36743 int hid_add_device(struct hid_device *hdev)
36744 {
36745 - static atomic_t id = ATOMIC_INIT(0);
36746 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36747 int ret;
36748
36749 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36750 @@ -2309,7 +2309,7 @@ int hid_add_device(struct hid_device *hdev)
36751 /* XXX hack, any other cleaner solution after the driver core
36752 * is converted to allow more than 20 bytes as the device name? */
36753 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36754 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36755 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36756
36757 hid_debug_register(hdev, dev_name(&hdev->dev));
36758 ret = device_add(&hdev->dev);
36759 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36760 index 90124ff..3761764 100644
36761 --- a/drivers/hid/hid-wiimote-debug.c
36762 +++ b/drivers/hid/hid-wiimote-debug.c
36763 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36764 else if (size == 0)
36765 return -EIO;
36766
36767 - if (copy_to_user(u, buf, size))
36768 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36769 return -EFAULT;
36770
36771 *off += size;
36772 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36773 index 0b122f8..b1d8160 100644
36774 --- a/drivers/hv/channel.c
36775 +++ b/drivers/hv/channel.c
36776 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36777 int ret = 0;
36778 int t;
36779
36780 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36781 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36782 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36783 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36784
36785 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36786 if (ret)
36787 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36788 index ae49237..380d4c9 100644
36789 --- a/drivers/hv/hv.c
36790 +++ b/drivers/hv/hv.c
36791 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36792 u64 output_address = (output) ? virt_to_phys(output) : 0;
36793 u32 output_address_hi = output_address >> 32;
36794 u32 output_address_lo = output_address & 0xFFFFFFFF;
36795 - void *hypercall_page = hv_context.hypercall_page;
36796 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36797
36798 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36799 "=a"(hv_status_lo) : "d" (control_hi),
36800 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36801 index 12f2f9e..679603c 100644
36802 --- a/drivers/hv/hyperv_vmbus.h
36803 +++ b/drivers/hv/hyperv_vmbus.h
36804 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36805 struct vmbus_connection {
36806 enum vmbus_connect_state conn_state;
36807
36808 - atomic_t next_gpadl_handle;
36809 + atomic_unchecked_t next_gpadl_handle;
36810
36811 /*
36812 * Represents channel interrupts. Each bit position represents a
36813 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36814 index 4004e54..c2de226 100644
36815 --- a/drivers/hv/vmbus_drv.c
36816 +++ b/drivers/hv/vmbus_drv.c
36817 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36818 {
36819 int ret = 0;
36820
36821 - static atomic_t device_num = ATOMIC_INIT(0);
36822 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36823
36824 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36825 - atomic_inc_return(&device_num));
36826 + atomic_inc_return_unchecked(&device_num));
36827
36828 child_device_obj->device.bus = &hv_bus;
36829 child_device_obj->device.parent = &hv_acpi_dev->dev;
36830 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36831 index 6351aba..dc4aaf4 100644
36832 --- a/drivers/hwmon/acpi_power_meter.c
36833 +++ b/drivers/hwmon/acpi_power_meter.c
36834 @@ -117,7 +117,7 @@ struct sensor_template {
36835 struct device_attribute *devattr,
36836 const char *buf, size_t count);
36837 int index;
36838 -};
36839 +} __do_const;
36840
36841 /* Averaging interval */
36842 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36843 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36844 struct sensor_template *attrs)
36845 {
36846 struct device *dev = &resource->acpi_dev->dev;
36847 - struct sensor_device_attribute *sensors =
36848 + sensor_device_attribute_no_const *sensors =
36849 &resource->sensors[resource->num_sensors];
36850 int res = 0;
36851
36852 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36853 index 62c2e32..8f2859a 100644
36854 --- a/drivers/hwmon/applesmc.c
36855 +++ b/drivers/hwmon/applesmc.c
36856 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36857 {
36858 struct applesmc_node_group *grp;
36859 struct applesmc_dev_attr *node;
36860 - struct attribute *attr;
36861 + attribute_no_const *attr;
36862 int ret, i;
36863
36864 for (grp = groups; grp->format; grp++) {
36865 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36866 index b25c643..a13460d 100644
36867 --- a/drivers/hwmon/asus_atk0110.c
36868 +++ b/drivers/hwmon/asus_atk0110.c
36869 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36870 struct atk_sensor_data {
36871 struct list_head list;
36872 struct atk_data *data;
36873 - struct device_attribute label_attr;
36874 - struct device_attribute input_attr;
36875 - struct device_attribute limit1_attr;
36876 - struct device_attribute limit2_attr;
36877 + device_attribute_no_const label_attr;
36878 + device_attribute_no_const input_attr;
36879 + device_attribute_no_const limit1_attr;
36880 + device_attribute_no_const limit2_attr;
36881 char label_attr_name[ATTR_NAME_SIZE];
36882 char input_attr_name[ATTR_NAME_SIZE];
36883 char limit1_attr_name[ATTR_NAME_SIZE];
36884 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36885 static struct device_attribute atk_name_attr =
36886 __ATTR(name, 0444, atk_name_show, NULL);
36887
36888 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36889 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36890 sysfs_show_func show)
36891 {
36892 sysfs_attr_init(&attr->attr);
36893 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36894 index 658ce3a..0d0c2f3 100644
36895 --- a/drivers/hwmon/coretemp.c
36896 +++ b/drivers/hwmon/coretemp.c
36897 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36898 return NOTIFY_OK;
36899 }
36900
36901 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36902 +static struct notifier_block coretemp_cpu_notifier = {
36903 .notifier_call = coretemp_cpu_callback,
36904 };
36905
36906 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36907 index 1429f6e..ee03d59 100644
36908 --- a/drivers/hwmon/ibmaem.c
36909 +++ b/drivers/hwmon/ibmaem.c
36910 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
36911 struct aem_rw_sensor_template *rw)
36912 {
36913 struct device *dev = &data->pdev->dev;
36914 - struct sensor_device_attribute *sensors = data->sensors;
36915 + sensor_device_attribute_no_const *sensors = data->sensors;
36916 int err;
36917
36918 /* Set up read-only sensors */
36919 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
36920 index 52b77af..aed1ddf 100644
36921 --- a/drivers/hwmon/iio_hwmon.c
36922 +++ b/drivers/hwmon/iio_hwmon.c
36923 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
36924 {
36925 struct device *dev = &pdev->dev;
36926 struct iio_hwmon_state *st;
36927 - struct sensor_device_attribute *a;
36928 + sensor_device_attribute_no_const *a;
36929 int ret, i;
36930 int in_i = 1, temp_i = 1, curr_i = 1;
36931 enum iio_chan_type type;
36932 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36933 index 9add6092..ee7ba3f 100644
36934 --- a/drivers/hwmon/pmbus/pmbus_core.c
36935 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36936 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36937 return 0;
36938 }
36939
36940 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36941 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36942 const char *name,
36943 umode_t mode,
36944 ssize_t (*show)(struct device *dev,
36945 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36946 dev_attr->store = store;
36947 }
36948
36949 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36950 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36951 const char *name,
36952 umode_t mode,
36953 ssize_t (*show)(struct device *dev,
36954 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36955 u16 reg, u8 mask)
36956 {
36957 struct pmbus_boolean *boolean;
36958 - struct sensor_device_attribute *a;
36959 + sensor_device_attribute_no_const *a;
36960
36961 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36962 if (!boolean)
36963 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36964 bool update, bool readonly)
36965 {
36966 struct pmbus_sensor *sensor;
36967 - struct device_attribute *a;
36968 + device_attribute_no_const *a;
36969
36970 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36971 if (!sensor)
36972 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36973 const char *lstring, int index)
36974 {
36975 struct pmbus_label *label;
36976 - struct device_attribute *a;
36977 + device_attribute_no_const *a;
36978
36979 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36980 if (!label)
36981 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36982 index 2507f90..1645765 100644
36983 --- a/drivers/hwmon/sht15.c
36984 +++ b/drivers/hwmon/sht15.c
36985 @@ -169,7 +169,7 @@ struct sht15_data {
36986 int supply_uv;
36987 bool supply_uv_valid;
36988 struct work_struct update_supply_work;
36989 - atomic_t interrupt_handled;
36990 + atomic_unchecked_t interrupt_handled;
36991 };
36992
36993 /**
36994 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36995 ret = gpio_direction_input(data->pdata->gpio_data);
36996 if (ret)
36997 return ret;
36998 - atomic_set(&data->interrupt_handled, 0);
36999 + atomic_set_unchecked(&data->interrupt_handled, 0);
37000
37001 enable_irq(gpio_to_irq(data->pdata->gpio_data));
37002 if (gpio_get_value(data->pdata->gpio_data) == 0) {
37003 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
37004 /* Only relevant if the interrupt hasn't occurred. */
37005 - if (!atomic_read(&data->interrupt_handled))
37006 + if (!atomic_read_unchecked(&data->interrupt_handled))
37007 schedule_work(&data->read_work);
37008 }
37009 ret = wait_event_timeout(data->wait_queue,
37010 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
37011
37012 /* First disable the interrupt */
37013 disable_irq_nosync(irq);
37014 - atomic_inc(&data->interrupt_handled);
37015 + atomic_inc_unchecked(&data->interrupt_handled);
37016 /* Then schedule a reading work struct */
37017 if (data->state != SHT15_READING_NOTHING)
37018 schedule_work(&data->read_work);
37019 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
37020 * If not, then start the interrupt again - care here as could
37021 * have gone low in meantime so verify it hasn't!
37022 */
37023 - atomic_set(&data->interrupt_handled, 0);
37024 + atomic_set_unchecked(&data->interrupt_handled, 0);
37025 enable_irq(gpio_to_irq(data->pdata->gpio_data));
37026 /* If still not occurred or another handler was scheduled */
37027 if (gpio_get_value(data->pdata->gpio_data)
37028 - || atomic_read(&data->interrupt_handled))
37029 + || atomic_read_unchecked(&data->interrupt_handled))
37030 return;
37031 }
37032
37033 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
37034 index 76f157b..9c0db1b 100644
37035 --- a/drivers/hwmon/via-cputemp.c
37036 +++ b/drivers/hwmon/via-cputemp.c
37037 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
37038 return NOTIFY_OK;
37039 }
37040
37041 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
37042 +static struct notifier_block via_cputemp_cpu_notifier = {
37043 .notifier_call = via_cputemp_cpu_callback,
37044 };
37045
37046 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
37047 index 07f01ac..d79ad3d 100644
37048 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
37049 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
37050 @@ -43,7 +43,7 @@
37051 extern struct i2c_adapter amd756_smbus;
37052
37053 static struct i2c_adapter *s4882_adapter;
37054 -static struct i2c_algorithm *s4882_algo;
37055 +static i2c_algorithm_no_const *s4882_algo;
37056
37057 /* Wrapper access functions for multiplexed SMBus */
37058 static DEFINE_MUTEX(amd756_lock);
37059 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
37060 index 2ca268d..c6acbdf 100644
37061 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
37062 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
37063 @@ -41,7 +41,7 @@
37064 extern struct i2c_adapter *nforce2_smbus;
37065
37066 static struct i2c_adapter *s4985_adapter;
37067 -static struct i2c_algorithm *s4985_algo;
37068 +static i2c_algorithm_no_const *s4985_algo;
37069
37070 /* Wrapper access functions for multiplexed SMBus */
37071 static DEFINE_MUTEX(nforce2_lock);
37072 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
37073 index c3ccdea..5b3dc1a 100644
37074 --- a/drivers/i2c/i2c-dev.c
37075 +++ b/drivers/i2c/i2c-dev.c
37076 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
37077 break;
37078 }
37079
37080 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
37081 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
37082 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
37083 if (IS_ERR(rdwr_pa[i].buf)) {
37084 res = PTR_ERR(rdwr_pa[i].buf);
37085 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
37086 index 2ff6204..218c16e 100644
37087 --- a/drivers/ide/ide-cd.c
37088 +++ b/drivers/ide/ide-cd.c
37089 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
37090 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
37091 if ((unsigned long)buf & alignment
37092 || blk_rq_bytes(rq) & q->dma_pad_mask
37093 - || object_is_on_stack(buf))
37094 + || object_starts_on_stack(buf))
37095 drive->dma = 0;
37096 }
37097 }
37098 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
37099 index e145931..08bfc59 100644
37100 --- a/drivers/iio/industrialio-core.c
37101 +++ b/drivers/iio/industrialio-core.c
37102 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
37103 }
37104
37105 static
37106 -int __iio_device_attr_init(struct device_attribute *dev_attr,
37107 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
37108 const char *postfix,
37109 struct iio_chan_spec const *chan,
37110 ssize_t (*readfunc)(struct device *dev,
37111 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
37112 index 784b97c..c9ceadf 100644
37113 --- a/drivers/infiniband/core/cm.c
37114 +++ b/drivers/infiniband/core/cm.c
37115 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
37116
37117 struct cm_counter_group {
37118 struct kobject obj;
37119 - atomic_long_t counter[CM_ATTR_COUNT];
37120 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
37121 };
37122
37123 struct cm_counter_attribute {
37124 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
37125 struct ib_mad_send_buf *msg = NULL;
37126 int ret;
37127
37128 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37129 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37130 counter[CM_REQ_COUNTER]);
37131
37132 /* Quick state check to discard duplicate REQs. */
37133 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
37134 if (!cm_id_priv)
37135 return;
37136
37137 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37138 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37139 counter[CM_REP_COUNTER]);
37140 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
37141 if (ret)
37142 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
37143 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
37144 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
37145 spin_unlock_irq(&cm_id_priv->lock);
37146 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37147 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37148 counter[CM_RTU_COUNTER]);
37149 goto out;
37150 }
37151 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
37152 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
37153 dreq_msg->local_comm_id);
37154 if (!cm_id_priv) {
37155 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37156 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37157 counter[CM_DREQ_COUNTER]);
37158 cm_issue_drep(work->port, work->mad_recv_wc);
37159 return -EINVAL;
37160 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
37161 case IB_CM_MRA_REP_RCVD:
37162 break;
37163 case IB_CM_TIMEWAIT:
37164 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37165 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37166 counter[CM_DREQ_COUNTER]);
37167 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37168 goto unlock;
37169 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
37170 cm_free_msg(msg);
37171 goto deref;
37172 case IB_CM_DREQ_RCVD:
37173 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37174 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37175 counter[CM_DREQ_COUNTER]);
37176 goto unlock;
37177 default:
37178 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
37179 ib_modify_mad(cm_id_priv->av.port->mad_agent,
37180 cm_id_priv->msg, timeout)) {
37181 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
37182 - atomic_long_inc(&work->port->
37183 + atomic_long_inc_unchecked(&work->port->
37184 counter_group[CM_RECV_DUPLICATES].
37185 counter[CM_MRA_COUNTER]);
37186 goto out;
37187 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
37188 break;
37189 case IB_CM_MRA_REQ_RCVD:
37190 case IB_CM_MRA_REP_RCVD:
37191 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37192 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37193 counter[CM_MRA_COUNTER]);
37194 /* fall through */
37195 default:
37196 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
37197 case IB_CM_LAP_IDLE:
37198 break;
37199 case IB_CM_MRA_LAP_SENT:
37200 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37201 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37202 counter[CM_LAP_COUNTER]);
37203 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37204 goto unlock;
37205 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
37206 cm_free_msg(msg);
37207 goto deref;
37208 case IB_CM_LAP_RCVD:
37209 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37210 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37211 counter[CM_LAP_COUNTER]);
37212 goto unlock;
37213 default:
37214 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
37215 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
37216 if (cur_cm_id_priv) {
37217 spin_unlock_irq(&cm.lock);
37218 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37219 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37220 counter[CM_SIDR_REQ_COUNTER]);
37221 goto out; /* Duplicate message. */
37222 }
37223 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
37224 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
37225 msg->retries = 1;
37226
37227 - atomic_long_add(1 + msg->retries,
37228 + atomic_long_add_unchecked(1 + msg->retries,
37229 &port->counter_group[CM_XMIT].counter[attr_index]);
37230 if (msg->retries)
37231 - atomic_long_add(msg->retries,
37232 + atomic_long_add_unchecked(msg->retries,
37233 &port->counter_group[CM_XMIT_RETRIES].
37234 counter[attr_index]);
37235
37236 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
37237 }
37238
37239 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
37240 - atomic_long_inc(&port->counter_group[CM_RECV].
37241 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
37242 counter[attr_id - CM_ATTR_ID_OFFSET]);
37243
37244 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
37245 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
37246 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
37247
37248 return sprintf(buf, "%ld\n",
37249 - atomic_long_read(&group->counter[cm_attr->index]));
37250 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
37251 }
37252
37253 static const struct sysfs_ops cm_counter_ops = {
37254 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
37255 index 9f5ad7c..588cd84 100644
37256 --- a/drivers/infiniband/core/fmr_pool.c
37257 +++ b/drivers/infiniband/core/fmr_pool.c
37258 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
37259
37260 struct task_struct *thread;
37261
37262 - atomic_t req_ser;
37263 - atomic_t flush_ser;
37264 + atomic_unchecked_t req_ser;
37265 + atomic_unchecked_t flush_ser;
37266
37267 wait_queue_head_t force_wait;
37268 };
37269 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37270 struct ib_fmr_pool *pool = pool_ptr;
37271
37272 do {
37273 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37274 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37275 ib_fmr_batch_release(pool);
37276
37277 - atomic_inc(&pool->flush_ser);
37278 + atomic_inc_unchecked(&pool->flush_ser);
37279 wake_up_interruptible(&pool->force_wait);
37280
37281 if (pool->flush_function)
37282 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37283 }
37284
37285 set_current_state(TASK_INTERRUPTIBLE);
37286 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37287 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37288 !kthread_should_stop())
37289 schedule();
37290 __set_current_state(TASK_RUNNING);
37291 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37292 pool->dirty_watermark = params->dirty_watermark;
37293 pool->dirty_len = 0;
37294 spin_lock_init(&pool->pool_lock);
37295 - atomic_set(&pool->req_ser, 0);
37296 - atomic_set(&pool->flush_ser, 0);
37297 + atomic_set_unchecked(&pool->req_ser, 0);
37298 + atomic_set_unchecked(&pool->flush_ser, 0);
37299 init_waitqueue_head(&pool->force_wait);
37300
37301 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37302 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37303 }
37304 spin_unlock_irq(&pool->pool_lock);
37305
37306 - serial = atomic_inc_return(&pool->req_ser);
37307 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37308 wake_up_process(pool->thread);
37309
37310 if (wait_event_interruptible(pool->force_wait,
37311 - atomic_read(&pool->flush_ser) - serial >= 0))
37312 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37313 return -EINTR;
37314
37315 return 0;
37316 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37317 } else {
37318 list_add_tail(&fmr->list, &pool->dirty_list);
37319 if (++pool->dirty_len >= pool->dirty_watermark) {
37320 - atomic_inc(&pool->req_ser);
37321 + atomic_inc_unchecked(&pool->req_ser);
37322 wake_up_process(pool->thread);
37323 }
37324 }
37325 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37326 index 4cb8eb2..146bf60 100644
37327 --- a/drivers/infiniband/hw/cxgb4/mem.c
37328 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37329 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37330 int err;
37331 struct fw_ri_tpte tpt;
37332 u32 stag_idx;
37333 - static atomic_t key;
37334 + static atomic_unchecked_t key;
37335
37336 if (c4iw_fatal_error(rdev))
37337 return -EIO;
37338 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37339 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37340 rdev->stats.stag.max = rdev->stats.stag.cur;
37341 mutex_unlock(&rdev->stats.lock);
37342 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37343 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37344 }
37345 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37346 __func__, stag_state, type, pdid, stag_idx);
37347 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37348 index 79b3dbc..96e5fcc 100644
37349 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37350 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37351 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37352 struct ib_atomic_eth *ateth;
37353 struct ipath_ack_entry *e;
37354 u64 vaddr;
37355 - atomic64_t *maddr;
37356 + atomic64_unchecked_t *maddr;
37357 u64 sdata;
37358 u32 rkey;
37359 u8 next;
37360 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37361 IB_ACCESS_REMOTE_ATOMIC)))
37362 goto nack_acc_unlck;
37363 /* Perform atomic OP and save result. */
37364 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37365 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37366 sdata = be64_to_cpu(ateth->swap_data);
37367 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37368 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37369 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37370 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37371 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37372 be64_to_cpu(ateth->compare_data),
37373 sdata);
37374 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37375 index 1f95bba..9530f87 100644
37376 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37377 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37378 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37379 unsigned long flags;
37380 struct ib_wc wc;
37381 u64 sdata;
37382 - atomic64_t *maddr;
37383 + atomic64_unchecked_t *maddr;
37384 enum ib_wc_status send_status;
37385
37386 /*
37387 @@ -382,11 +382,11 @@ again:
37388 IB_ACCESS_REMOTE_ATOMIC)))
37389 goto acc_err;
37390 /* Perform atomic OP and save result. */
37391 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37392 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37393 sdata = wqe->wr.wr.atomic.compare_add;
37394 *(u64 *) sqp->s_sge.sge.vaddr =
37395 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37396 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37397 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37398 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37399 sdata, wqe->wr.wr.atomic.swap);
37400 goto send_comp;
37401 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37402 index 9d3e5c1..d9afe4a 100644
37403 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37404 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37405 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37406 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37407 }
37408
37409 -int mthca_QUERY_FW(struct mthca_dev *dev)
37410 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37411 {
37412 struct mthca_mailbox *mailbox;
37413 u32 *outbox;
37414 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37415 index ed9a989..e0c5871 100644
37416 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37417 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37418 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37419 return key;
37420 }
37421
37422 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37423 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37424 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37425 {
37426 struct mthca_mailbox *mailbox;
37427 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37428 index 4291410..d2ab1fb 100644
37429 --- a/drivers/infiniband/hw/nes/nes.c
37430 +++ b/drivers/infiniband/hw/nes/nes.c
37431 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37432 LIST_HEAD(nes_adapter_list);
37433 static LIST_HEAD(nes_dev_list);
37434
37435 -atomic_t qps_destroyed;
37436 +atomic_unchecked_t qps_destroyed;
37437
37438 static unsigned int ee_flsh_adapter;
37439 static unsigned int sysfs_nonidx_addr;
37440 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37441 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37442 struct nes_adapter *nesadapter = nesdev->nesadapter;
37443
37444 - atomic_inc(&qps_destroyed);
37445 + atomic_inc_unchecked(&qps_destroyed);
37446
37447 /* Free the control structures */
37448
37449 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37450 index 33cc589..3bd6538 100644
37451 --- a/drivers/infiniband/hw/nes/nes.h
37452 +++ b/drivers/infiniband/hw/nes/nes.h
37453 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37454 extern unsigned int wqm_quanta;
37455 extern struct list_head nes_adapter_list;
37456
37457 -extern atomic_t cm_connects;
37458 -extern atomic_t cm_accepts;
37459 -extern atomic_t cm_disconnects;
37460 -extern atomic_t cm_closes;
37461 -extern atomic_t cm_connecteds;
37462 -extern atomic_t cm_connect_reqs;
37463 -extern atomic_t cm_rejects;
37464 -extern atomic_t mod_qp_timouts;
37465 -extern atomic_t qps_created;
37466 -extern atomic_t qps_destroyed;
37467 -extern atomic_t sw_qps_destroyed;
37468 +extern atomic_unchecked_t cm_connects;
37469 +extern atomic_unchecked_t cm_accepts;
37470 +extern atomic_unchecked_t cm_disconnects;
37471 +extern atomic_unchecked_t cm_closes;
37472 +extern atomic_unchecked_t cm_connecteds;
37473 +extern atomic_unchecked_t cm_connect_reqs;
37474 +extern atomic_unchecked_t cm_rejects;
37475 +extern atomic_unchecked_t mod_qp_timouts;
37476 +extern atomic_unchecked_t qps_created;
37477 +extern atomic_unchecked_t qps_destroyed;
37478 +extern atomic_unchecked_t sw_qps_destroyed;
37479 extern u32 mh_detected;
37480 extern u32 mh_pauses_sent;
37481 extern u32 cm_packets_sent;
37482 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37483 extern u32 cm_packets_received;
37484 extern u32 cm_packets_dropped;
37485 extern u32 cm_packets_retrans;
37486 -extern atomic_t cm_listens_created;
37487 -extern atomic_t cm_listens_destroyed;
37488 +extern atomic_unchecked_t cm_listens_created;
37489 +extern atomic_unchecked_t cm_listens_destroyed;
37490 extern u32 cm_backlog_drops;
37491 -extern atomic_t cm_loopbacks;
37492 -extern atomic_t cm_nodes_created;
37493 -extern atomic_t cm_nodes_destroyed;
37494 -extern atomic_t cm_accel_dropped_pkts;
37495 -extern atomic_t cm_resets_recvd;
37496 -extern atomic_t pau_qps_created;
37497 -extern atomic_t pau_qps_destroyed;
37498 +extern atomic_unchecked_t cm_loopbacks;
37499 +extern atomic_unchecked_t cm_nodes_created;
37500 +extern atomic_unchecked_t cm_nodes_destroyed;
37501 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37502 +extern atomic_unchecked_t cm_resets_recvd;
37503 +extern atomic_unchecked_t pau_qps_created;
37504 +extern atomic_unchecked_t pau_qps_destroyed;
37505
37506 extern u32 int_mod_timer_init;
37507 extern u32 int_mod_cq_depth_256;
37508 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37509 index 24b9f1a..00fd004 100644
37510 --- a/drivers/infiniband/hw/nes/nes_cm.c
37511 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37512 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37513 u32 cm_packets_retrans;
37514 u32 cm_packets_created;
37515 u32 cm_packets_received;
37516 -atomic_t cm_listens_created;
37517 -atomic_t cm_listens_destroyed;
37518 +atomic_unchecked_t cm_listens_created;
37519 +atomic_unchecked_t cm_listens_destroyed;
37520 u32 cm_backlog_drops;
37521 -atomic_t cm_loopbacks;
37522 -atomic_t cm_nodes_created;
37523 -atomic_t cm_nodes_destroyed;
37524 -atomic_t cm_accel_dropped_pkts;
37525 -atomic_t cm_resets_recvd;
37526 +atomic_unchecked_t cm_loopbacks;
37527 +atomic_unchecked_t cm_nodes_created;
37528 +atomic_unchecked_t cm_nodes_destroyed;
37529 +atomic_unchecked_t cm_accel_dropped_pkts;
37530 +atomic_unchecked_t cm_resets_recvd;
37531
37532 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37533 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37534 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37535
37536 static struct nes_cm_core *g_cm_core;
37537
37538 -atomic_t cm_connects;
37539 -atomic_t cm_accepts;
37540 -atomic_t cm_disconnects;
37541 -atomic_t cm_closes;
37542 -atomic_t cm_connecteds;
37543 -atomic_t cm_connect_reqs;
37544 -atomic_t cm_rejects;
37545 +atomic_unchecked_t cm_connects;
37546 +atomic_unchecked_t cm_accepts;
37547 +atomic_unchecked_t cm_disconnects;
37548 +atomic_unchecked_t cm_closes;
37549 +atomic_unchecked_t cm_connecteds;
37550 +atomic_unchecked_t cm_connect_reqs;
37551 +atomic_unchecked_t cm_rejects;
37552
37553 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37554 {
37555 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37556 kfree(listener);
37557 listener = NULL;
37558 ret = 0;
37559 - atomic_inc(&cm_listens_destroyed);
37560 + atomic_inc_unchecked(&cm_listens_destroyed);
37561 } else {
37562 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37563 }
37564 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37565 cm_node->rem_mac);
37566
37567 add_hte_node(cm_core, cm_node);
37568 - atomic_inc(&cm_nodes_created);
37569 + atomic_inc_unchecked(&cm_nodes_created);
37570
37571 return cm_node;
37572 }
37573 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37574 }
37575
37576 atomic_dec(&cm_core->node_cnt);
37577 - atomic_inc(&cm_nodes_destroyed);
37578 + atomic_inc_unchecked(&cm_nodes_destroyed);
37579 nesqp = cm_node->nesqp;
37580 if (nesqp) {
37581 nesqp->cm_node = NULL;
37582 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37583
37584 static void drop_packet(struct sk_buff *skb)
37585 {
37586 - atomic_inc(&cm_accel_dropped_pkts);
37587 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37588 dev_kfree_skb_any(skb);
37589 }
37590
37591 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37592 {
37593
37594 int reset = 0; /* whether to send reset in case of err.. */
37595 - atomic_inc(&cm_resets_recvd);
37596 + atomic_inc_unchecked(&cm_resets_recvd);
37597 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37598 " refcnt=%d\n", cm_node, cm_node->state,
37599 atomic_read(&cm_node->ref_count));
37600 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37601 rem_ref_cm_node(cm_node->cm_core, cm_node);
37602 return NULL;
37603 }
37604 - atomic_inc(&cm_loopbacks);
37605 + atomic_inc_unchecked(&cm_loopbacks);
37606 loopbackremotenode->loopbackpartner = cm_node;
37607 loopbackremotenode->tcp_cntxt.rcv_wscale =
37608 NES_CM_DEFAULT_RCV_WND_SCALE;
37609 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37610 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37611 else {
37612 rem_ref_cm_node(cm_core, cm_node);
37613 - atomic_inc(&cm_accel_dropped_pkts);
37614 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37615 dev_kfree_skb_any(skb);
37616 }
37617 break;
37618 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37619
37620 if ((cm_id) && (cm_id->event_handler)) {
37621 if (issue_disconn) {
37622 - atomic_inc(&cm_disconnects);
37623 + atomic_inc_unchecked(&cm_disconnects);
37624 cm_event.event = IW_CM_EVENT_DISCONNECT;
37625 cm_event.status = disconn_status;
37626 cm_event.local_addr = cm_id->local_addr;
37627 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37628 }
37629
37630 if (issue_close) {
37631 - atomic_inc(&cm_closes);
37632 + atomic_inc_unchecked(&cm_closes);
37633 nes_disconnect(nesqp, 1);
37634
37635 cm_id->provider_data = nesqp;
37636 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37637
37638 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37639 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37640 - atomic_inc(&cm_accepts);
37641 + atomic_inc_unchecked(&cm_accepts);
37642
37643 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37644 netdev_refcnt_read(nesvnic->netdev));
37645 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37646 struct nes_cm_core *cm_core;
37647 u8 *start_buff;
37648
37649 - atomic_inc(&cm_rejects);
37650 + atomic_inc_unchecked(&cm_rejects);
37651 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37652 loopback = cm_node->loopbackpartner;
37653 cm_core = cm_node->cm_core;
37654 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37655 ntohl(cm_id->local_addr.sin_addr.s_addr),
37656 ntohs(cm_id->local_addr.sin_port));
37657
37658 - atomic_inc(&cm_connects);
37659 + atomic_inc_unchecked(&cm_connects);
37660 nesqp->active_conn = 1;
37661
37662 /* cache the cm_id in the qp */
37663 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37664 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37665 return err;
37666 }
37667 - atomic_inc(&cm_listens_created);
37668 + atomic_inc_unchecked(&cm_listens_created);
37669 }
37670
37671 cm_id->add_ref(cm_id);
37672 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37673
37674 if (nesqp->destroyed)
37675 return;
37676 - atomic_inc(&cm_connecteds);
37677 + atomic_inc_unchecked(&cm_connecteds);
37678 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37679 " local port 0x%04X. jiffies = %lu.\n",
37680 nesqp->hwqp.qp_id,
37681 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37682
37683 cm_id->add_ref(cm_id);
37684 ret = cm_id->event_handler(cm_id, &cm_event);
37685 - atomic_inc(&cm_closes);
37686 + atomic_inc_unchecked(&cm_closes);
37687 cm_event.event = IW_CM_EVENT_CLOSE;
37688 cm_event.status = 0;
37689 cm_event.provider_data = cm_id->provider_data;
37690 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37691 return;
37692 cm_id = cm_node->cm_id;
37693
37694 - atomic_inc(&cm_connect_reqs);
37695 + atomic_inc_unchecked(&cm_connect_reqs);
37696 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37697 cm_node, cm_id, jiffies);
37698
37699 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37700 return;
37701 cm_id = cm_node->cm_id;
37702
37703 - atomic_inc(&cm_connect_reqs);
37704 + atomic_inc_unchecked(&cm_connect_reqs);
37705 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37706 cm_node, cm_id, jiffies);
37707
37708 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37709 index 4166452..fc952c3 100644
37710 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37711 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37712 @@ -40,8 +40,8 @@
37713 #include "nes.h"
37714 #include "nes_mgt.h"
37715
37716 -atomic_t pau_qps_created;
37717 -atomic_t pau_qps_destroyed;
37718 +atomic_unchecked_t pau_qps_created;
37719 +atomic_unchecked_t pau_qps_destroyed;
37720
37721 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37722 {
37723 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37724 {
37725 struct sk_buff *skb;
37726 unsigned long flags;
37727 - atomic_inc(&pau_qps_destroyed);
37728 + atomic_inc_unchecked(&pau_qps_destroyed);
37729
37730 /* Free packets that have not yet been forwarded */
37731 /* Lock is acquired by skb_dequeue when removing the skb */
37732 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37733 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37734 skb_queue_head_init(&nesqp->pau_list);
37735 spin_lock_init(&nesqp->pau_lock);
37736 - atomic_inc(&pau_qps_created);
37737 + atomic_inc_unchecked(&pau_qps_created);
37738 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37739 }
37740
37741 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37742 index 49eb511..a774366 100644
37743 --- a/drivers/infiniband/hw/nes/nes_nic.c
37744 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37745 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37746 target_stat_values[++index] = mh_detected;
37747 target_stat_values[++index] = mh_pauses_sent;
37748 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37749 - target_stat_values[++index] = atomic_read(&cm_connects);
37750 - target_stat_values[++index] = atomic_read(&cm_accepts);
37751 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37752 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37753 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37754 - target_stat_values[++index] = atomic_read(&cm_rejects);
37755 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37756 - target_stat_values[++index] = atomic_read(&qps_created);
37757 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37758 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37759 - target_stat_values[++index] = atomic_read(&cm_closes);
37760 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37761 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37762 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37763 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37764 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37765 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37766 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37767 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37768 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37769 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37770 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37771 target_stat_values[++index] = cm_packets_sent;
37772 target_stat_values[++index] = cm_packets_bounced;
37773 target_stat_values[++index] = cm_packets_created;
37774 target_stat_values[++index] = cm_packets_received;
37775 target_stat_values[++index] = cm_packets_dropped;
37776 target_stat_values[++index] = cm_packets_retrans;
37777 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37778 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37779 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37780 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37781 target_stat_values[++index] = cm_backlog_drops;
37782 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37783 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37784 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37785 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37786 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37787 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37788 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37789 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37790 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37791 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37792 target_stat_values[++index] = nesadapter->free_4kpbl;
37793 target_stat_values[++index] = nesadapter->free_256pbl;
37794 target_stat_values[++index] = int_mod_timer_init;
37795 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37796 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37797 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37798 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37799 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37800 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37801 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37802 }
37803
37804 /**
37805 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37806 index 8f67fe2..8960859 100644
37807 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37808 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37809 @@ -46,9 +46,9 @@
37810
37811 #include <rdma/ib_umem.h>
37812
37813 -atomic_t mod_qp_timouts;
37814 -atomic_t qps_created;
37815 -atomic_t sw_qps_destroyed;
37816 +atomic_unchecked_t mod_qp_timouts;
37817 +atomic_unchecked_t qps_created;
37818 +atomic_unchecked_t sw_qps_destroyed;
37819
37820 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37821
37822 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37823 if (init_attr->create_flags)
37824 return ERR_PTR(-EINVAL);
37825
37826 - atomic_inc(&qps_created);
37827 + atomic_inc_unchecked(&qps_created);
37828 switch (init_attr->qp_type) {
37829 case IB_QPT_RC:
37830 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37831 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37832 struct iw_cm_event cm_event;
37833 int ret = 0;
37834
37835 - atomic_inc(&sw_qps_destroyed);
37836 + atomic_inc_unchecked(&sw_qps_destroyed);
37837 nesqp->destroyed = 1;
37838
37839 /* Blow away the connection if it exists. */
37840 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37841 index 4d11575..3e890e5 100644
37842 --- a/drivers/infiniband/hw/qib/qib.h
37843 +++ b/drivers/infiniband/hw/qib/qib.h
37844 @@ -51,6 +51,7 @@
37845 #include <linux/completion.h>
37846 #include <linux/kref.h>
37847 #include <linux/sched.h>
37848 +#include <linux/slab.h>
37849
37850 #include "qib_common.h"
37851 #include "qib_verbs.h"
37852 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37853 index da739d9..da1c7f4 100644
37854 --- a/drivers/input/gameport/gameport.c
37855 +++ b/drivers/input/gameport/gameport.c
37856 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37857 */
37858 static void gameport_init_port(struct gameport *gameport)
37859 {
37860 - static atomic_t gameport_no = ATOMIC_INIT(0);
37861 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37862
37863 __module_get(THIS_MODULE);
37864
37865 mutex_init(&gameport->drv_mutex);
37866 device_initialize(&gameport->dev);
37867 dev_set_name(&gameport->dev, "gameport%lu",
37868 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37869 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37870 gameport->dev.bus = &gameport_bus;
37871 gameport->dev.release = gameport_release_port;
37872 if (gameport->parent)
37873 diff --git a/drivers/input/input.c b/drivers/input/input.c
37874 index c044699..174d71a 100644
37875 --- a/drivers/input/input.c
37876 +++ b/drivers/input/input.c
37877 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37878 */
37879 int input_register_device(struct input_dev *dev)
37880 {
37881 - static atomic_t input_no = ATOMIC_INIT(0);
37882 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37883 struct input_devres *devres = NULL;
37884 struct input_handler *handler;
37885 unsigned int packet_size;
37886 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37887 dev->setkeycode = input_default_setkeycode;
37888
37889 dev_set_name(&dev->dev, "input%ld",
37890 - (unsigned long) atomic_inc_return(&input_no) - 1);
37891 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37892
37893 error = device_add(&dev->dev);
37894 if (error)
37895 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37896 index 04c69af..5f92d00 100644
37897 --- a/drivers/input/joystick/sidewinder.c
37898 +++ b/drivers/input/joystick/sidewinder.c
37899 @@ -30,6 +30,7 @@
37900 #include <linux/kernel.h>
37901 #include <linux/module.h>
37902 #include <linux/slab.h>
37903 +#include <linux/sched.h>
37904 #include <linux/init.h>
37905 #include <linux/input.h>
37906 #include <linux/gameport.h>
37907 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37908 index fa061d4..4a6957c 100644
37909 --- a/drivers/input/joystick/xpad.c
37910 +++ b/drivers/input/joystick/xpad.c
37911 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37912
37913 static int xpad_led_probe(struct usb_xpad *xpad)
37914 {
37915 - static atomic_t led_seq = ATOMIC_INIT(0);
37916 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37917 long led_no;
37918 struct xpad_led *led;
37919 struct led_classdev *led_cdev;
37920 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37921 if (!led)
37922 return -ENOMEM;
37923
37924 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37925 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37926
37927 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37928 led->xpad = xpad;
37929 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37930 index 2f0b39d..7370f13 100644
37931 --- a/drivers/input/mouse/psmouse.h
37932 +++ b/drivers/input/mouse/psmouse.h
37933 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37934 ssize_t (*set)(struct psmouse *psmouse, void *data,
37935 const char *buf, size_t count);
37936 bool protect;
37937 -};
37938 +} __do_const;
37939 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37940
37941 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37942 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37943 index 4c842c3..590b0bf 100644
37944 --- a/drivers/input/mousedev.c
37945 +++ b/drivers/input/mousedev.c
37946 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37947
37948 spin_unlock_irq(&client->packet_lock);
37949
37950 - if (copy_to_user(buffer, data, count))
37951 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37952 return -EFAULT;
37953
37954 return count;
37955 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37956 index 25fc597..558bf3b3 100644
37957 --- a/drivers/input/serio/serio.c
37958 +++ b/drivers/input/serio/serio.c
37959 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37960 */
37961 static void serio_init_port(struct serio *serio)
37962 {
37963 - static atomic_t serio_no = ATOMIC_INIT(0);
37964 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37965
37966 __module_get(THIS_MODULE);
37967
37968 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37969 mutex_init(&serio->drv_mutex);
37970 device_initialize(&serio->dev);
37971 dev_set_name(&serio->dev, "serio%ld",
37972 - (long)atomic_inc_return(&serio_no) - 1);
37973 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37974 serio->dev.bus = &serio_bus;
37975 serio->dev.release = serio_release_port;
37976 serio->dev.groups = serio_device_attr_groups;
37977 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37978 index d8f98b1..f62a640 100644
37979 --- a/drivers/iommu/iommu.c
37980 +++ b/drivers/iommu/iommu.c
37981 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
37982 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37983 {
37984 bus_register_notifier(bus, &iommu_bus_nb);
37985 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37986 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37987 }
37988
37989 /**
37990 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37991 index dcfea4e..f4226b2 100644
37992 --- a/drivers/iommu/irq_remapping.c
37993 +++ b/drivers/iommu/irq_remapping.c
37994 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37995 void panic_if_irq_remap(const char *msg)
37996 {
37997 if (irq_remapping_enabled)
37998 - panic(msg);
37999 + panic("%s", msg);
38000 }
38001
38002 static void ir_ack_apic_edge(struct irq_data *data)
38003 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
38004
38005 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
38006 {
38007 - chip->irq_print_chip = ir_print_prefix;
38008 - chip->irq_ack = ir_ack_apic_edge;
38009 - chip->irq_eoi = ir_ack_apic_level;
38010 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
38011 + pax_open_kernel();
38012 + *(void **)&chip->irq_print_chip = ir_print_prefix;
38013 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
38014 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
38015 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
38016 + pax_close_kernel();
38017 }
38018
38019 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
38020 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
38021 index 19ceaa6..3625818 100644
38022 --- a/drivers/irqchip/irq-gic.c
38023 +++ b/drivers/irqchip/irq-gic.c
38024 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
38025 * Supported arch specific GIC irq extension.
38026 * Default make them NULL.
38027 */
38028 -struct irq_chip gic_arch_extn = {
38029 +irq_chip_no_const gic_arch_extn = {
38030 .irq_eoi = NULL,
38031 .irq_mask = NULL,
38032 .irq_unmask = NULL,
38033 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
38034 chained_irq_exit(chip, desc);
38035 }
38036
38037 -static struct irq_chip gic_chip = {
38038 +static irq_chip_no_const gic_chip __read_only = {
38039 .name = "GIC",
38040 .irq_mask = gic_mask_irq,
38041 .irq_unmask = gic_unmask_irq,
38042 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
38043 index ac6f72b..81150f2 100644
38044 --- a/drivers/isdn/capi/capi.c
38045 +++ b/drivers/isdn/capi/capi.c
38046 @@ -81,8 +81,8 @@ struct capiminor {
38047
38048 struct capi20_appl *ap;
38049 u32 ncci;
38050 - atomic_t datahandle;
38051 - atomic_t msgid;
38052 + atomic_unchecked_t datahandle;
38053 + atomic_unchecked_t msgid;
38054
38055 struct tty_port port;
38056 int ttyinstop;
38057 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
38058 capimsg_setu16(s, 2, mp->ap->applid);
38059 capimsg_setu8 (s, 4, CAPI_DATA_B3);
38060 capimsg_setu8 (s, 5, CAPI_RESP);
38061 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
38062 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
38063 capimsg_setu32(s, 8, mp->ncci);
38064 capimsg_setu16(s, 12, datahandle);
38065 }
38066 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
38067 mp->outbytes -= len;
38068 spin_unlock_bh(&mp->outlock);
38069
38070 - datahandle = atomic_inc_return(&mp->datahandle);
38071 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
38072 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
38073 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38074 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38075 capimsg_setu16(skb->data, 2, mp->ap->applid);
38076 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
38077 capimsg_setu8 (skb->data, 5, CAPI_REQ);
38078 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
38079 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
38080 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
38081 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
38082 capimsg_setu16(skb->data, 16, len); /* Data length */
38083 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
38084 index 600c79b..3752bab 100644
38085 --- a/drivers/isdn/gigaset/interface.c
38086 +++ b/drivers/isdn/gigaset/interface.c
38087 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
38088 }
38089 tty->driver_data = cs;
38090
38091 - ++cs->port.count;
38092 + atomic_inc(&cs->port.count);
38093
38094 - if (cs->port.count == 1) {
38095 + if (atomic_read(&cs->port.count) == 1) {
38096 tty_port_tty_set(&cs->port, tty);
38097 cs->port.low_latency = 1;
38098 }
38099 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
38100
38101 if (!cs->connected)
38102 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
38103 - else if (!cs->port.count)
38104 + else if (!atomic_read(&cs->port.count))
38105 dev_warn(cs->dev, "%s: device not opened\n", __func__);
38106 - else if (!--cs->port.count)
38107 + else if (!atomic_dec_return(&cs->port.count))
38108 tty_port_tty_set(&cs->port, NULL);
38109
38110 mutex_unlock(&cs->mutex);
38111 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
38112 index 4d9b195..455075c 100644
38113 --- a/drivers/isdn/hardware/avm/b1.c
38114 +++ b/drivers/isdn/hardware/avm/b1.c
38115 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
38116 }
38117 if (left) {
38118 if (t4file->user) {
38119 - if (copy_from_user(buf, dp, left))
38120 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38121 return -EFAULT;
38122 } else {
38123 memcpy(buf, dp, left);
38124 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
38125 }
38126 if (left) {
38127 if (config->user) {
38128 - if (copy_from_user(buf, dp, left))
38129 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38130 return -EFAULT;
38131 } else {
38132 memcpy(buf, dp, left);
38133 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
38134 index 3c5f249..5fac4d0 100644
38135 --- a/drivers/isdn/i4l/isdn_tty.c
38136 +++ b/drivers/isdn/i4l/isdn_tty.c
38137 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
38138
38139 #ifdef ISDN_DEBUG_MODEM_OPEN
38140 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
38141 - port->count);
38142 + atomic_read(&port->count));
38143 #endif
38144 - port->count++;
38145 + atomic_inc(&port->count);
38146 port->tty = tty;
38147 /*
38148 * Start up serial port
38149 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38150 #endif
38151 return;
38152 }
38153 - if ((tty->count == 1) && (port->count != 1)) {
38154 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
38155 /*
38156 * Uh, oh. tty->count is 1, which means that the tty
38157 * structure will be freed. Info->count should always
38158 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38159 * serial port won't be shutdown.
38160 */
38161 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
38162 - "info->count is %d\n", port->count);
38163 - port->count = 1;
38164 + "info->count is %d\n", atomic_read(&port->count));
38165 + atomic_set(&port->count, 1);
38166 }
38167 - if (--port->count < 0) {
38168 + if (atomic_dec_return(&port->count) < 0) {
38169 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
38170 - info->line, port->count);
38171 - port->count = 0;
38172 + info->line, atomic_read(&port->count));
38173 + atomic_set(&port->count, 0);
38174 }
38175 - if (port->count) {
38176 + if (atomic_read(&port->count)) {
38177 #ifdef ISDN_DEBUG_MODEM_OPEN
38178 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
38179 #endif
38180 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
38181 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
38182 return;
38183 isdn_tty_shutdown(info);
38184 - port->count = 0;
38185 + atomic_set(&port->count, 0);
38186 port->flags &= ~ASYNC_NORMAL_ACTIVE;
38187 port->tty = NULL;
38188 wake_up_interruptible(&port->open_wait);
38189 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
38190 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
38191 modem_info *info = &dev->mdm.info[i];
38192
38193 - if (info->port.count == 0)
38194 + if (atomic_read(&info->port.count) == 0)
38195 continue;
38196 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
38197 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
38198 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
38199 index e74df7c..03a03ba 100644
38200 --- a/drivers/isdn/icn/icn.c
38201 +++ b/drivers/isdn/icn/icn.c
38202 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
38203 if (count > len)
38204 count = len;
38205 if (user) {
38206 - if (copy_from_user(msg, buf, count))
38207 + if (count > sizeof msg || copy_from_user(msg, buf, count))
38208 return -EFAULT;
38209 } else
38210 memcpy(msg, buf, count);
38211 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
38212 index 6a8405d..0bd1c7e 100644
38213 --- a/drivers/leds/leds-clevo-mail.c
38214 +++ b/drivers/leds/leds-clevo-mail.c
38215 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
38216 * detected as working, but in reality it is not) as low as
38217 * possible.
38218 */
38219 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
38220 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
38221 {
38222 .callback = clevo_mail_led_dmi_callback,
38223 .ident = "Clevo D410J",
38224 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
38225 index 64e204e..c6bf189 100644
38226 --- a/drivers/leds/leds-ss4200.c
38227 +++ b/drivers/leds/leds-ss4200.c
38228 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
38229 * detected as working, but in reality it is not) as low as
38230 * possible.
38231 */
38232 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
38233 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
38234 {
38235 .callback = ss4200_led_dmi_callback,
38236 .ident = "Intel SS4200-E",
38237 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
38238 index 0bf1e4e..b4bf44e 100644
38239 --- a/drivers/lguest/core.c
38240 +++ b/drivers/lguest/core.c
38241 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
38242 * The end address needs +1 because __get_vm_area allocates an
38243 * extra guard page, so we need space for that.
38244 */
38245 +
38246 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
38247 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38248 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
38249 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38250 +#else
38251 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38252 VM_ALLOC, switcher_addr, switcher_addr
38253 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38254 +#endif
38255 +
38256 if (!switcher_vma) {
38257 err = -ENOMEM;
38258 printk("lguest: could not map switcher pages high\n");
38259 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
38260 * Now the Switcher is mapped at the right address, we can't fail!
38261 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
38262 */
38263 - memcpy(switcher_vma->addr, start_switcher_text,
38264 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
38265 end_switcher_text - start_switcher_text);
38266
38267 printk(KERN_INFO "lguest: mapped switcher at %p\n",
38268 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
38269 index 5b9ac32..2ef4f26 100644
38270 --- a/drivers/lguest/page_tables.c
38271 +++ b/drivers/lguest/page_tables.c
38272 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
38273 /*:*/
38274
38275 #ifdef CONFIG_X86_PAE
38276 -static void release_pmd(pmd_t *spmd)
38277 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
38278 {
38279 /* If the entry's not present, there's nothing to release. */
38280 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38281 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38282 index f0a3347..f6608b2 100644
38283 --- a/drivers/lguest/x86/core.c
38284 +++ b/drivers/lguest/x86/core.c
38285 @@ -59,7 +59,7 @@ static struct {
38286 /* Offset from where switcher.S was compiled to where we've copied it */
38287 static unsigned long switcher_offset(void)
38288 {
38289 - return switcher_addr - (unsigned long)start_switcher_text;
38290 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
38291 }
38292
38293 /* This cpu's struct lguest_pages (after the Switcher text page) */
38294 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38295 * These copies are pretty cheap, so we do them unconditionally: */
38296 /* Save the current Host top-level page directory.
38297 */
38298 +
38299 +#ifdef CONFIG_PAX_PER_CPU_PGD
38300 + pages->state.host_cr3 = read_cr3();
38301 +#else
38302 pages->state.host_cr3 = __pa(current->mm->pgd);
38303 +#endif
38304 +
38305 /*
38306 * Set up the Guest's page tables to see this CPU's pages (and no
38307 * other CPU's pages).
38308 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
38309 * compiled-in switcher code and the high-mapped copy we just made.
38310 */
38311 for (i = 0; i < IDT_ENTRIES; i++)
38312 - default_idt_entries[i] += switcher_offset();
38313 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38314
38315 /*
38316 * Set up the Switcher's per-cpu areas.
38317 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
38318 * it will be undisturbed when we switch. To change %cs and jump we
38319 * need this structure to feed to Intel's "lcall" instruction.
38320 */
38321 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38322 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38323 lguest_entry.segment = LGUEST_CS;
38324
38325 /*
38326 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38327 index 40634b0..4f5855e 100644
38328 --- a/drivers/lguest/x86/switcher_32.S
38329 +++ b/drivers/lguest/x86/switcher_32.S
38330 @@ -87,6 +87,7 @@
38331 #include <asm/page.h>
38332 #include <asm/segment.h>
38333 #include <asm/lguest.h>
38334 +#include <asm/processor-flags.h>
38335
38336 // We mark the start of the code to copy
38337 // It's placed in .text tho it's never run here
38338 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38339 // Changes type when we load it: damn Intel!
38340 // For after we switch over our page tables
38341 // That entry will be read-only: we'd crash.
38342 +
38343 +#ifdef CONFIG_PAX_KERNEXEC
38344 + mov %cr0, %edx
38345 + xor $X86_CR0_WP, %edx
38346 + mov %edx, %cr0
38347 +#endif
38348 +
38349 movl $(GDT_ENTRY_TSS*8), %edx
38350 ltr %dx
38351
38352 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38353 // Let's clear it again for our return.
38354 // The GDT descriptor of the Host
38355 // Points to the table after two "size" bytes
38356 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38357 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38358 // Clear "used" from type field (byte 5, bit 2)
38359 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38360 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38361 +
38362 +#ifdef CONFIG_PAX_KERNEXEC
38363 + mov %cr0, %eax
38364 + xor $X86_CR0_WP, %eax
38365 + mov %eax, %cr0
38366 +#endif
38367
38368 // Once our page table's switched, the Guest is live!
38369 // The Host fades as we run this final step.
38370 @@ -295,13 +309,12 @@ deliver_to_host:
38371 // I consulted gcc, and it gave
38372 // These instructions, which I gladly credit:
38373 leal (%edx,%ebx,8), %eax
38374 - movzwl (%eax),%edx
38375 - movl 4(%eax), %eax
38376 - xorw %ax, %ax
38377 - orl %eax, %edx
38378 + movl 4(%eax), %edx
38379 + movw (%eax), %dx
38380 // Now the address of the handler's in %edx
38381 // We call it now: its "iret" drops us home.
38382 - jmp *%edx
38383 + ljmp $__KERNEL_CS, $1f
38384 +1: jmp *%edx
38385
38386 // Every interrupt can come to us here
38387 // But we must truly tell each apart.
38388 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
38389 index 0003992..854bbce 100644
38390 --- a/drivers/md/bcache/closure.h
38391 +++ b/drivers/md/bcache/closure.h
38392 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
38393 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
38394 struct workqueue_struct *wq)
38395 {
38396 - BUG_ON(object_is_on_stack(cl));
38397 + BUG_ON(object_starts_on_stack(cl));
38398 closure_set_ip(cl);
38399 cl->fn = fn;
38400 cl->wq = wq;
38401 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38402 index 5a2c754..0fa55db 100644
38403 --- a/drivers/md/bitmap.c
38404 +++ b/drivers/md/bitmap.c
38405 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38406 chunk_kb ? "KB" : "B");
38407 if (bitmap->storage.file) {
38408 seq_printf(seq, ", file: ");
38409 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38410 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38411 }
38412
38413 seq_printf(seq, "\n");
38414 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38415 index 81a79b7..87a0f73 100644
38416 --- a/drivers/md/dm-ioctl.c
38417 +++ b/drivers/md/dm-ioctl.c
38418 @@ -1697,7 +1697,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38419 cmd == DM_LIST_VERSIONS_CMD)
38420 return 0;
38421
38422 - if ((cmd == DM_DEV_CREATE_CMD)) {
38423 + if (cmd == DM_DEV_CREATE_CMD) {
38424 if (!*param->name) {
38425 DMWARN("name not supplied when creating device");
38426 return -EINVAL;
38427 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38428 index 699b5be..eac0a15 100644
38429 --- a/drivers/md/dm-raid1.c
38430 +++ b/drivers/md/dm-raid1.c
38431 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38432
38433 struct mirror {
38434 struct mirror_set *ms;
38435 - atomic_t error_count;
38436 + atomic_unchecked_t error_count;
38437 unsigned long error_type;
38438 struct dm_dev *dev;
38439 sector_t offset;
38440 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38441 struct mirror *m;
38442
38443 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38444 - if (!atomic_read(&m->error_count))
38445 + if (!atomic_read_unchecked(&m->error_count))
38446 return m;
38447
38448 return NULL;
38449 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38450 * simple way to tell if a device has encountered
38451 * errors.
38452 */
38453 - atomic_inc(&m->error_count);
38454 + atomic_inc_unchecked(&m->error_count);
38455
38456 if (test_and_set_bit(error_type, &m->error_type))
38457 return;
38458 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38459 struct mirror *m = get_default_mirror(ms);
38460
38461 do {
38462 - if (likely(!atomic_read(&m->error_count)))
38463 + if (likely(!atomic_read_unchecked(&m->error_count)))
38464 return m;
38465
38466 if (m-- == ms->mirror)
38467 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38468 {
38469 struct mirror *default_mirror = get_default_mirror(m->ms);
38470
38471 - return !atomic_read(&default_mirror->error_count);
38472 + return !atomic_read_unchecked(&default_mirror->error_count);
38473 }
38474
38475 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38476 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38477 */
38478 if (likely(region_in_sync(ms, region, 1)))
38479 m = choose_mirror(ms, bio->bi_sector);
38480 - else if (m && atomic_read(&m->error_count))
38481 + else if (m && atomic_read_unchecked(&m->error_count))
38482 m = NULL;
38483
38484 if (likely(m))
38485 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38486 }
38487
38488 ms->mirror[mirror].ms = ms;
38489 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38490 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38491 ms->mirror[mirror].error_type = 0;
38492 ms->mirror[mirror].offset = offset;
38493
38494 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38495 */
38496 static char device_status_char(struct mirror *m)
38497 {
38498 - if (!atomic_read(&(m->error_count)))
38499 + if (!atomic_read_unchecked(&(m->error_count)))
38500 return 'A';
38501
38502 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38503 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38504 index d907ca6..cfb8384 100644
38505 --- a/drivers/md/dm-stripe.c
38506 +++ b/drivers/md/dm-stripe.c
38507 @@ -20,7 +20,7 @@ struct stripe {
38508 struct dm_dev *dev;
38509 sector_t physical_start;
38510
38511 - atomic_t error_count;
38512 + atomic_unchecked_t error_count;
38513 };
38514
38515 struct stripe_c {
38516 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38517 kfree(sc);
38518 return r;
38519 }
38520 - atomic_set(&(sc->stripe[i].error_count), 0);
38521 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38522 }
38523
38524 ti->private = sc;
38525 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38526 DMEMIT("%d ", sc->stripes);
38527 for (i = 0; i < sc->stripes; i++) {
38528 DMEMIT("%s ", sc->stripe[i].dev->name);
38529 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38530 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38531 'D' : 'A';
38532 }
38533 buffer[i] = '\0';
38534 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38535 */
38536 for (i = 0; i < sc->stripes; i++)
38537 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38538 - atomic_inc(&(sc->stripe[i].error_count));
38539 - if (atomic_read(&(sc->stripe[i].error_count)) <
38540 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38541 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38542 DM_IO_ERROR_THRESHOLD)
38543 schedule_work(&sc->trigger_event);
38544 }
38545 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38546 index 1ff252a..ee384c1 100644
38547 --- a/drivers/md/dm-table.c
38548 +++ b/drivers/md/dm-table.c
38549 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38550 if (!dev_size)
38551 return 0;
38552
38553 - if ((start >= dev_size) || (start + len > dev_size)) {
38554 + if ((start >= dev_size) || (len > dev_size - start)) {
38555 DMWARN("%s: %s too small for target: "
38556 "start=%llu, len=%llu, dev_size=%llu",
38557 dm_device_name(ti->table->md), bdevname(bdev, b),
38558 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38559 index 60bce43..9b997d0 100644
38560 --- a/drivers/md/dm-thin-metadata.c
38561 +++ b/drivers/md/dm-thin-metadata.c
38562 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38563 {
38564 pmd->info.tm = pmd->tm;
38565 pmd->info.levels = 2;
38566 - pmd->info.value_type.context = pmd->data_sm;
38567 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38568 pmd->info.value_type.size = sizeof(__le64);
38569 pmd->info.value_type.inc = data_block_inc;
38570 pmd->info.value_type.dec = data_block_dec;
38571 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38572
38573 pmd->bl_info.tm = pmd->tm;
38574 pmd->bl_info.levels = 1;
38575 - pmd->bl_info.value_type.context = pmd->data_sm;
38576 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38577 pmd->bl_info.value_type.size = sizeof(__le64);
38578 pmd->bl_info.value_type.inc = data_block_inc;
38579 pmd->bl_info.value_type.dec = data_block_dec;
38580 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38581 index 33f2010..23fb84c 100644
38582 --- a/drivers/md/dm.c
38583 +++ b/drivers/md/dm.c
38584 @@ -169,9 +169,9 @@ struct mapped_device {
38585 /*
38586 * Event handling.
38587 */
38588 - atomic_t event_nr;
38589 + atomic_unchecked_t event_nr;
38590 wait_queue_head_t eventq;
38591 - atomic_t uevent_seq;
38592 + atomic_unchecked_t uevent_seq;
38593 struct list_head uevent_list;
38594 spinlock_t uevent_lock; /* Protect access to uevent_list */
38595
38596 @@ -1884,8 +1884,8 @@ static struct mapped_device *alloc_dev(int minor)
38597 rwlock_init(&md->map_lock);
38598 atomic_set(&md->holders, 1);
38599 atomic_set(&md->open_count, 0);
38600 - atomic_set(&md->event_nr, 0);
38601 - atomic_set(&md->uevent_seq, 0);
38602 + atomic_set_unchecked(&md->event_nr, 0);
38603 + atomic_set_unchecked(&md->uevent_seq, 0);
38604 INIT_LIST_HEAD(&md->uevent_list);
38605 spin_lock_init(&md->uevent_lock);
38606
38607 @@ -2033,7 +2033,7 @@ static void event_callback(void *context)
38608
38609 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38610
38611 - atomic_inc(&md->event_nr);
38612 + atomic_inc_unchecked(&md->event_nr);
38613 wake_up(&md->eventq);
38614 }
38615
38616 @@ -2690,18 +2690,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38617
38618 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38619 {
38620 - return atomic_add_return(1, &md->uevent_seq);
38621 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38622 }
38623
38624 uint32_t dm_get_event_nr(struct mapped_device *md)
38625 {
38626 - return atomic_read(&md->event_nr);
38627 + return atomic_read_unchecked(&md->event_nr);
38628 }
38629
38630 int dm_wait_event(struct mapped_device *md, int event_nr)
38631 {
38632 return wait_event_interruptible(md->eventq,
38633 - (event_nr != atomic_read(&md->event_nr)));
38634 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38635 }
38636
38637 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38638 diff --git a/drivers/md/md.c b/drivers/md/md.c
38639 index 51f0345..c77810e 100644
38640 --- a/drivers/md/md.c
38641 +++ b/drivers/md/md.c
38642 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38643 * start build, activate spare
38644 */
38645 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38646 -static atomic_t md_event_count;
38647 +static atomic_unchecked_t md_event_count;
38648 void md_new_event(struct mddev *mddev)
38649 {
38650 - atomic_inc(&md_event_count);
38651 + atomic_inc_unchecked(&md_event_count);
38652 wake_up(&md_event_waiters);
38653 }
38654 EXPORT_SYMBOL_GPL(md_new_event);
38655 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38656 */
38657 static void md_new_event_inintr(struct mddev *mddev)
38658 {
38659 - atomic_inc(&md_event_count);
38660 + atomic_inc_unchecked(&md_event_count);
38661 wake_up(&md_event_waiters);
38662 }
38663
38664 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38665 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38666 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38667 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38668 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38669 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38670
38671 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38672 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38673 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38674 else
38675 sb->resync_offset = cpu_to_le64(0);
38676
38677 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38678 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38679
38680 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38681 sb->size = cpu_to_le64(mddev->dev_sectors);
38682 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38683 static ssize_t
38684 errors_show(struct md_rdev *rdev, char *page)
38685 {
38686 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38687 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38688 }
38689
38690 static ssize_t
38691 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38692 char *e;
38693 unsigned long n = simple_strtoul(buf, &e, 10);
38694 if (*buf && (*e == 0 || *e == '\n')) {
38695 - atomic_set(&rdev->corrected_errors, n);
38696 + atomic_set_unchecked(&rdev->corrected_errors, n);
38697 return len;
38698 }
38699 return -EINVAL;
38700 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
38701 rdev->sb_loaded = 0;
38702 rdev->bb_page = NULL;
38703 atomic_set(&rdev->nr_pending, 0);
38704 - atomic_set(&rdev->read_errors, 0);
38705 - atomic_set(&rdev->corrected_errors, 0);
38706 + atomic_set_unchecked(&rdev->read_errors, 0);
38707 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38708
38709 INIT_LIST_HEAD(&rdev->same_set);
38710 init_waitqueue_head(&rdev->blocked_wait);
38711 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38712
38713 spin_unlock(&pers_lock);
38714 seq_printf(seq, "\n");
38715 - seq->poll_event = atomic_read(&md_event_count);
38716 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38717 return 0;
38718 }
38719 if (v == (void*)2) {
38720 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38721 return error;
38722
38723 seq = file->private_data;
38724 - seq->poll_event = atomic_read(&md_event_count);
38725 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38726 return error;
38727 }
38728
38729 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38730 /* always allow read */
38731 mask = POLLIN | POLLRDNORM;
38732
38733 - if (seq->poll_event != atomic_read(&md_event_count))
38734 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38735 mask |= POLLERR | POLLPRI;
38736 return mask;
38737 }
38738 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38739 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38740 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38741 (int)part_stat_read(&disk->part0, sectors[1]) -
38742 - atomic_read(&disk->sync_io);
38743 + atomic_read_unchecked(&disk->sync_io);
38744 /* sync IO will cause sync_io to increase before the disk_stats
38745 * as sync_io is counted when a request starts, and
38746 * disk_stats is counted when it completes.
38747 diff --git a/drivers/md/md.h b/drivers/md/md.h
38748 index 653f992b6..6af6c40 100644
38749 --- a/drivers/md/md.h
38750 +++ b/drivers/md/md.h
38751 @@ -94,13 +94,13 @@ struct md_rdev {
38752 * only maintained for arrays that
38753 * support hot removal
38754 */
38755 - atomic_t read_errors; /* number of consecutive read errors that
38756 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38757 * we have tried to ignore.
38758 */
38759 struct timespec last_read_error; /* monotonic time since our
38760 * last read error
38761 */
38762 - atomic_t corrected_errors; /* number of corrected read errors,
38763 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38764 * for reporting to userspace and storing
38765 * in superblock.
38766 */
38767 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38768
38769 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38770 {
38771 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38772 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38773 }
38774
38775 struct md_personality
38776 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38777 index 3e6d115..ffecdeb 100644
38778 --- a/drivers/md/persistent-data/dm-space-map.h
38779 +++ b/drivers/md/persistent-data/dm-space-map.h
38780 @@ -71,6 +71,7 @@ struct dm_space_map {
38781 dm_sm_threshold_fn fn,
38782 void *context);
38783 };
38784 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38785
38786 /*----------------------------------------------------------------*/
38787
38788 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38789 index 6f48244..7d29145 100644
38790 --- a/drivers/md/raid1.c
38791 +++ b/drivers/md/raid1.c
38792 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38793 if (r1_sync_page_io(rdev, sect, s,
38794 bio->bi_io_vec[idx].bv_page,
38795 READ) != 0)
38796 - atomic_add(s, &rdev->corrected_errors);
38797 + atomic_add_unchecked(s, &rdev->corrected_errors);
38798 }
38799 sectors -= s;
38800 sect += s;
38801 @@ -2049,7 +2049,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38802 test_bit(In_sync, &rdev->flags)) {
38803 if (r1_sync_page_io(rdev, sect, s,
38804 conf->tmppage, READ)) {
38805 - atomic_add(s, &rdev->corrected_errors);
38806 + atomic_add_unchecked(s, &rdev->corrected_errors);
38807 printk(KERN_INFO
38808 "md/raid1:%s: read error corrected "
38809 "(%d sectors at %llu on %s)\n",
38810 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38811 index 081bb33..3c4b287 100644
38812 --- a/drivers/md/raid10.c
38813 +++ b/drivers/md/raid10.c
38814 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
38815 /* The write handler will notice the lack of
38816 * R10BIO_Uptodate and record any errors etc
38817 */
38818 - atomic_add(r10_bio->sectors,
38819 + atomic_add_unchecked(r10_bio->sectors,
38820 &conf->mirrors[d].rdev->corrected_errors);
38821
38822 /* for reconstruct, we always reschedule after a read.
38823 @@ -2298,7 +2298,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38824 {
38825 struct timespec cur_time_mon;
38826 unsigned long hours_since_last;
38827 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38828 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38829
38830 ktime_get_ts(&cur_time_mon);
38831
38832 @@ -2320,9 +2320,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38833 * overflowing the shift of read_errors by hours_since_last.
38834 */
38835 if (hours_since_last >= 8 * sizeof(read_errors))
38836 - atomic_set(&rdev->read_errors, 0);
38837 + atomic_set_unchecked(&rdev->read_errors, 0);
38838 else
38839 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38840 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38841 }
38842
38843 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38844 @@ -2376,8 +2376,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38845 return;
38846
38847 check_decay_read_errors(mddev, rdev);
38848 - atomic_inc(&rdev->read_errors);
38849 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38850 + atomic_inc_unchecked(&rdev->read_errors);
38851 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38852 char b[BDEVNAME_SIZE];
38853 bdevname(rdev->bdev, b);
38854
38855 @@ -2385,7 +2385,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38856 "md/raid10:%s: %s: Raid device exceeded "
38857 "read_error threshold [cur %d:max %d]\n",
38858 mdname(mddev), b,
38859 - atomic_read(&rdev->read_errors), max_read_errors);
38860 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38861 printk(KERN_NOTICE
38862 "md/raid10:%s: %s: Failing raid device\n",
38863 mdname(mddev), b);
38864 @@ -2540,7 +2540,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38865 sect +
38866 choose_data_offset(r10_bio, rdev)),
38867 bdevname(rdev->bdev, b));
38868 - atomic_add(s, &rdev->corrected_errors);
38869 + atomic_add_unchecked(s, &rdev->corrected_errors);
38870 }
38871
38872 rdev_dec_pending(rdev, mddev);
38873 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38874 index a35b846..e295c6d 100644
38875 --- a/drivers/md/raid5.c
38876 +++ b/drivers/md/raid5.c
38877 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38878 mdname(conf->mddev), STRIPE_SECTORS,
38879 (unsigned long long)s,
38880 bdevname(rdev->bdev, b));
38881 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38882 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38883 clear_bit(R5_ReadError, &sh->dev[i].flags);
38884 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38885 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38886 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38887
38888 - if (atomic_read(&rdev->read_errors))
38889 - atomic_set(&rdev->read_errors, 0);
38890 + if (atomic_read_unchecked(&rdev->read_errors))
38891 + atomic_set_unchecked(&rdev->read_errors, 0);
38892 } else {
38893 const char *bdn = bdevname(rdev->bdev, b);
38894 int retry = 0;
38895 int set_bad = 0;
38896
38897 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38898 - atomic_inc(&rdev->read_errors);
38899 + atomic_inc_unchecked(&rdev->read_errors);
38900 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38901 printk_ratelimited(
38902 KERN_WARNING
38903 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38904 mdname(conf->mddev),
38905 (unsigned long long)s,
38906 bdn);
38907 - } else if (atomic_read(&rdev->read_errors)
38908 + } else if (atomic_read_unchecked(&rdev->read_errors)
38909 > conf->max_nr_stripes)
38910 printk(KERN_WARNING
38911 "md/raid:%s: Too many read errors, failing device %s.\n",
38912 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38913 index 401ef64..836e563 100644
38914 --- a/drivers/media/dvb-core/dvbdev.c
38915 +++ b/drivers/media/dvb-core/dvbdev.c
38916 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38917 const struct dvb_device *template, void *priv, int type)
38918 {
38919 struct dvb_device *dvbdev;
38920 - struct file_operations *dvbdevfops;
38921 + file_operations_no_const *dvbdevfops;
38922 struct device *clsdev;
38923 int minor;
38924 int id;
38925 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38926 index 9b6c3bb..baeb5c7 100644
38927 --- a/drivers/media/dvb-frontends/dib3000.h
38928 +++ b/drivers/media/dvb-frontends/dib3000.h
38929 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38930 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38931 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38932 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38933 -};
38934 +} __no_const;
38935
38936 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38937 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38938 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38939 index c7a9be1..683f6f8 100644
38940 --- a/drivers/media/pci/cx88/cx88-video.c
38941 +++ b/drivers/media/pci/cx88/cx88-video.c
38942 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38943
38944 /* ------------------------------------------------------------------ */
38945
38946 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38947 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38948 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38949 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38950 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38951 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38952
38953 module_param_array(video_nr, int, NULL, 0444);
38954 module_param_array(vbi_nr, int, NULL, 0444);
38955 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38956 index d338b19..aae4f9e 100644
38957 --- a/drivers/media/platform/omap/omap_vout.c
38958 +++ b/drivers/media/platform/omap/omap_vout.c
38959 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38960 OMAP_VIDEO2,
38961 };
38962
38963 -static struct videobuf_queue_ops video_vbq_ops;
38964 /* Variables configurable through module params*/
38965 static u32 video1_numbuffers = 3;
38966 static u32 video2_numbuffers = 3;
38967 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
38968 {
38969 struct videobuf_queue *q;
38970 struct omap_vout_device *vout = NULL;
38971 + static struct videobuf_queue_ops video_vbq_ops = {
38972 + .buf_setup = omap_vout_buffer_setup,
38973 + .buf_prepare = omap_vout_buffer_prepare,
38974 + .buf_release = omap_vout_buffer_release,
38975 + .buf_queue = omap_vout_buffer_queue,
38976 + };
38977
38978 vout = video_drvdata(file);
38979 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38980 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
38981 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38982
38983 q = &vout->vbq;
38984 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38985 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38986 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38987 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38988 spin_lock_init(&vout->vbq_lock);
38989
38990 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38991 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38992 index 04e6490..2df65bf 100644
38993 --- a/drivers/media/platform/s5p-tv/mixer.h
38994 +++ b/drivers/media/platform/s5p-tv/mixer.h
38995 @@ -156,7 +156,7 @@ struct mxr_layer {
38996 /** layer index (unique identifier) */
38997 int idx;
38998 /** callbacks for layer methods */
38999 - struct mxr_layer_ops ops;
39000 + struct mxr_layer_ops *ops;
39001 /** format array */
39002 const struct mxr_format **fmt_array;
39003 /** size of format array */
39004 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
39005 index b93a21f..2535195 100644
39006 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
39007 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
39008 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
39009 {
39010 struct mxr_layer *layer;
39011 int ret;
39012 - struct mxr_layer_ops ops = {
39013 + static struct mxr_layer_ops ops = {
39014 .release = mxr_graph_layer_release,
39015 .buffer_set = mxr_graph_buffer_set,
39016 .stream_set = mxr_graph_stream_set,
39017 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
39018 index b713403..53cb5ad 100644
39019 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
39020 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
39021 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
39022 layer->update_buf = next;
39023 }
39024
39025 - layer->ops.buffer_set(layer, layer->update_buf);
39026 + layer->ops->buffer_set(layer, layer->update_buf);
39027
39028 if (done && done != layer->shadow_buf)
39029 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
39030 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
39031 index ef0efdf..8c78eb6 100644
39032 --- a/drivers/media/platform/s5p-tv/mixer_video.c
39033 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
39034 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
39035 layer->geo.src.height = layer->geo.src.full_height;
39036
39037 mxr_geometry_dump(mdev, &layer->geo);
39038 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39039 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39040 mxr_geometry_dump(mdev, &layer->geo);
39041 }
39042
39043 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
39044 layer->geo.dst.full_width = mbus_fmt.width;
39045 layer->geo.dst.full_height = mbus_fmt.height;
39046 layer->geo.dst.field = mbus_fmt.field;
39047 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39048 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39049
39050 mxr_geometry_dump(mdev, &layer->geo);
39051 }
39052 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
39053 /* set source size to highest accepted value */
39054 geo->src.full_width = max(geo->dst.full_width, pix->width);
39055 geo->src.full_height = max(geo->dst.full_height, pix->height);
39056 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39057 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39058 mxr_geometry_dump(mdev, &layer->geo);
39059 /* set cropping to total visible screen */
39060 geo->src.width = pix->width;
39061 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
39062 geo->src.x_offset = 0;
39063 geo->src.y_offset = 0;
39064 /* assure consistency of geometry */
39065 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39066 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39067 mxr_geometry_dump(mdev, &layer->geo);
39068 /* set full size to lowest possible value */
39069 geo->src.full_width = 0;
39070 geo->src.full_height = 0;
39071 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39072 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39073 mxr_geometry_dump(mdev, &layer->geo);
39074
39075 /* returning results */
39076 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
39077 target->width = s->r.width;
39078 target->height = s->r.height;
39079
39080 - layer->ops.fix_geometry(layer, stage, s->flags);
39081 + layer->ops->fix_geometry(layer, stage, s->flags);
39082
39083 /* retrieve update selection rectangle */
39084 res.left = target->x_offset;
39085 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
39086 mxr_output_get(mdev);
39087
39088 mxr_layer_update_output(layer);
39089 - layer->ops.format_set(layer);
39090 + layer->ops->format_set(layer);
39091 /* enabling layer in hardware */
39092 spin_lock_irqsave(&layer->enq_slock, flags);
39093 layer->state = MXR_LAYER_STREAMING;
39094 spin_unlock_irqrestore(&layer->enq_slock, flags);
39095
39096 - layer->ops.stream_set(layer, MXR_ENABLE);
39097 + layer->ops->stream_set(layer, MXR_ENABLE);
39098 mxr_streamer_get(mdev);
39099
39100 return 0;
39101 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
39102 spin_unlock_irqrestore(&layer->enq_slock, flags);
39103
39104 /* disabling layer in hardware */
39105 - layer->ops.stream_set(layer, MXR_DISABLE);
39106 + layer->ops->stream_set(layer, MXR_DISABLE);
39107 /* remove one streamer */
39108 mxr_streamer_put(mdev);
39109 /* allow changes in output configuration */
39110 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
39111
39112 void mxr_layer_release(struct mxr_layer *layer)
39113 {
39114 - if (layer->ops.release)
39115 - layer->ops.release(layer);
39116 + if (layer->ops->release)
39117 + layer->ops->release(layer);
39118 }
39119
39120 void mxr_base_layer_release(struct mxr_layer *layer)
39121 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
39122
39123 layer->mdev = mdev;
39124 layer->idx = idx;
39125 - layer->ops = *ops;
39126 + layer->ops = ops;
39127
39128 spin_lock_init(&layer->enq_slock);
39129 INIT_LIST_HEAD(&layer->enq_list);
39130 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39131 index 3d13a63..da31bf1 100644
39132 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39133 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39134 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
39135 {
39136 struct mxr_layer *layer;
39137 int ret;
39138 - struct mxr_layer_ops ops = {
39139 + static struct mxr_layer_ops ops = {
39140 .release = mxr_vp_layer_release,
39141 .buffer_set = mxr_vp_buffer_set,
39142 .stream_set = mxr_vp_stream_set,
39143 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
39144 index 545c04c..a14bded 100644
39145 --- a/drivers/media/radio/radio-cadet.c
39146 +++ b/drivers/media/radio/radio-cadet.c
39147 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39148 unsigned char readbuf[RDS_BUFFER];
39149 int i = 0;
39150
39151 + if (count > RDS_BUFFER)
39152 + return -EFAULT;
39153 mutex_lock(&dev->lock);
39154 if (dev->rdsstat == 0)
39155 cadet_start_rds(dev);
39156 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39157 while (i < count && dev->rdsin != dev->rdsout)
39158 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
39159
39160 - if (i && copy_to_user(data, readbuf, i))
39161 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
39162 i = -EFAULT;
39163 unlock:
39164 mutex_unlock(&dev->lock);
39165 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
39166 index 3940bb0..fb3952a 100644
39167 --- a/drivers/media/usb/dvb-usb/cxusb.c
39168 +++ b/drivers/media/usb/dvb-usb/cxusb.c
39169 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
39170
39171 struct dib0700_adapter_state {
39172 int (*set_param_save) (struct dvb_frontend *);
39173 -};
39174 +} __no_const;
39175
39176 static int dib7070_set_param_override(struct dvb_frontend *fe)
39177 {
39178 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
39179 index 6e237b6..dc25556 100644
39180 --- a/drivers/media/usb/dvb-usb/dw2102.c
39181 +++ b/drivers/media/usb/dvb-usb/dw2102.c
39182 @@ -118,7 +118,7 @@ struct su3000_state {
39183
39184 struct s6x0_state {
39185 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
39186 -};
39187 +} __no_const;
39188
39189 /* debug */
39190 static int dvb_usb_dw2102_debug;
39191 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39192 index f129551..ecf6514 100644
39193 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39194 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39195 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
39196 __u32 reserved;
39197 };
39198
39199 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39200 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39201 enum v4l2_memory memory)
39202 {
39203 void __user *up_pln;
39204 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39205 return 0;
39206 }
39207
39208 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39209 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39210 enum v4l2_memory memory)
39211 {
39212 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
39213 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
39214 put_user(kp->start_block, &up->start_block) ||
39215 put_user(kp->blocks, &up->blocks) ||
39216 put_user(tmp, &up->edid) ||
39217 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
39218 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
39219 return -EFAULT;
39220 return 0;
39221 }
39222 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
39223 index 7658586..1079260 100644
39224 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
39225 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
39226 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
39227 struct file *file, void *fh, void *p);
39228 } u;
39229 void (*debug)(const void *arg, bool write_only);
39230 -};
39231 +} __do_const;
39232 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
39233
39234 /* This control needs a priority check */
39235 #define INFO_FL_PRIO (1 << 0)
39236 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
39237 struct video_device *vfd = video_devdata(file);
39238 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
39239 bool write_only = false;
39240 - struct v4l2_ioctl_info default_info;
39241 + v4l2_ioctl_info_no_const default_info;
39242 const struct v4l2_ioctl_info *info;
39243 void *fh = file->private_data;
39244 struct v4l2_fh *vfh = NULL;
39245 @@ -2251,7 +2252,7 @@ done:
39246 }
39247
39248 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39249 - void * __user *user_ptr, void ***kernel_ptr)
39250 + void __user **user_ptr, void ***kernel_ptr)
39251 {
39252 int ret = 0;
39253
39254 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39255 ret = -EINVAL;
39256 break;
39257 }
39258 - *user_ptr = (void __user *)buf->m.planes;
39259 + *user_ptr = (void __force_user *)buf->m.planes;
39260 *kernel_ptr = (void *)&buf->m.planes;
39261 *array_size = sizeof(struct v4l2_plane) * buf->length;
39262 ret = 1;
39263 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39264 ret = -EINVAL;
39265 break;
39266 }
39267 - *user_ptr = (void __user *)ctrls->controls;
39268 + *user_ptr = (void __force_user *)ctrls->controls;
39269 *kernel_ptr = (void *)&ctrls->controls;
39270 *array_size = sizeof(struct v4l2_ext_control)
39271 * ctrls->count;
39272 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39273 index 767ff4d..c69d259 100644
39274 --- a/drivers/message/fusion/mptbase.c
39275 +++ b/drivers/message/fusion/mptbase.c
39276 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39277 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39278 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39279
39280 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39281 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39282 +#else
39283 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39284 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39285 +#endif
39286 +
39287 /*
39288 * Rounding UP to nearest 4-kB boundary here...
39289 */
39290 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39291 ioc->facts.GlobalCredits);
39292
39293 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39294 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39295 + NULL, NULL);
39296 +#else
39297 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39298 +#endif
39299 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39300 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39301 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39302 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39303 index dd239bd..689c4f7 100644
39304 --- a/drivers/message/fusion/mptsas.c
39305 +++ b/drivers/message/fusion/mptsas.c
39306 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39307 return 0;
39308 }
39309
39310 +static inline void
39311 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39312 +{
39313 + if (phy_info->port_details) {
39314 + phy_info->port_details->rphy = rphy;
39315 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39316 + ioc->name, rphy));
39317 + }
39318 +
39319 + if (rphy) {
39320 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39321 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39322 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39323 + ioc->name, rphy, rphy->dev.release));
39324 + }
39325 +}
39326 +
39327 /* no mutex */
39328 static void
39329 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39330 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39331 return NULL;
39332 }
39333
39334 -static inline void
39335 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39336 -{
39337 - if (phy_info->port_details) {
39338 - phy_info->port_details->rphy = rphy;
39339 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39340 - ioc->name, rphy));
39341 - }
39342 -
39343 - if (rphy) {
39344 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39345 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39346 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39347 - ioc->name, rphy, rphy->dev.release));
39348 - }
39349 -}
39350 -
39351 static inline struct sas_port *
39352 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39353 {
39354 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39355 index 727819c..ad74694 100644
39356 --- a/drivers/message/fusion/mptscsih.c
39357 +++ b/drivers/message/fusion/mptscsih.c
39358 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39359
39360 h = shost_priv(SChost);
39361
39362 - if (h) {
39363 - if (h->info_kbuf == NULL)
39364 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39365 - return h->info_kbuf;
39366 - h->info_kbuf[0] = '\0';
39367 + if (!h)
39368 + return NULL;
39369
39370 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39371 - h->info_kbuf[size-1] = '\0';
39372 - }
39373 + if (h->info_kbuf == NULL)
39374 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39375 + return h->info_kbuf;
39376 + h->info_kbuf[0] = '\0';
39377 +
39378 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39379 + h->info_kbuf[size-1] = '\0';
39380
39381 return h->info_kbuf;
39382 }
39383 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39384 index b7d87cd..9890039 100644
39385 --- a/drivers/message/i2o/i2o_proc.c
39386 +++ b/drivers/message/i2o/i2o_proc.c
39387 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39388 "Array Controller Device"
39389 };
39390
39391 -static char *chtostr(char *tmp, u8 *chars, int n)
39392 -{
39393 - tmp[0] = 0;
39394 - return strncat(tmp, (char *)chars, n);
39395 -}
39396 -
39397 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39398 char *group)
39399 {
39400 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39401 } *result;
39402
39403 i2o_exec_execute_ddm_table ddm_table;
39404 - char tmp[28 + 1];
39405
39406 result = kmalloc(sizeof(*result), GFP_KERNEL);
39407 if (!result)
39408 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39409
39410 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39411 seq_printf(seq, "%-#8x", ddm_table.module_id);
39412 - seq_printf(seq, "%-29s",
39413 - chtostr(tmp, ddm_table.module_name_version, 28));
39414 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39415 seq_printf(seq, "%9d ", ddm_table.data_size);
39416 seq_printf(seq, "%8d", ddm_table.code_size);
39417
39418 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39419
39420 i2o_driver_result_table *result;
39421 i2o_driver_store_table *dst;
39422 - char tmp[28 + 1];
39423
39424 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39425 if (result == NULL)
39426 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39427
39428 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39429 seq_printf(seq, "%-#8x", dst->module_id);
39430 - seq_printf(seq, "%-29s",
39431 - chtostr(tmp, dst->module_name_version, 28));
39432 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39433 + seq_printf(seq, "%-.28s", dst->module_name_version);
39434 + seq_printf(seq, "%-.8s", dst->date);
39435 seq_printf(seq, "%8d ", dst->module_size);
39436 seq_printf(seq, "%8d ", dst->mpb_size);
39437 seq_printf(seq, "0x%04x", dst->module_flags);
39438 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39439 // == (allow) 512d bytes (max)
39440 static u16 *work16 = (u16 *) work32;
39441 int token;
39442 - char tmp[16 + 1];
39443
39444 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39445
39446 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39447 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39448 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39449 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39450 - seq_printf(seq, "Vendor info : %s\n",
39451 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39452 - seq_printf(seq, "Product info : %s\n",
39453 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39454 - seq_printf(seq, "Description : %s\n",
39455 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39456 - seq_printf(seq, "Product rev. : %s\n",
39457 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39458 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39459 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39460 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39461 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39462
39463 seq_printf(seq, "Serial number : ");
39464 print_serial_number(seq, (u8 *) (work32 + 16),
39465 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39466 u8 pad[256]; // allow up to 256 byte (max) serial number
39467 } result;
39468
39469 - char tmp[24 + 1];
39470 -
39471 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39472
39473 if (token < 0) {
39474 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39475 }
39476
39477 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39478 - seq_printf(seq, "Module name : %s\n",
39479 - chtostr(tmp, result.module_name, 24));
39480 - seq_printf(seq, "Module revision : %s\n",
39481 - chtostr(tmp, result.module_rev, 8));
39482 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39483 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39484
39485 seq_printf(seq, "Serial number : ");
39486 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39487 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39488 u8 instance_number[4];
39489 } result;
39490
39491 - char tmp[64 + 1];
39492 -
39493 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39494
39495 if (token < 0) {
39496 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39497 return 0;
39498 }
39499
39500 - seq_printf(seq, "Device name : %s\n",
39501 - chtostr(tmp, result.device_name, 64));
39502 - seq_printf(seq, "Service name : %s\n",
39503 - chtostr(tmp, result.service_name, 64));
39504 - seq_printf(seq, "Physical name : %s\n",
39505 - chtostr(tmp, result.physical_location, 64));
39506 - seq_printf(seq, "Instance number : %s\n",
39507 - chtostr(tmp, result.instance_number, 4));
39508 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39509 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39510 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39511 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39512
39513 return 0;
39514 }
39515 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39516 index a8c08f3..155fe3d 100644
39517 --- a/drivers/message/i2o/iop.c
39518 +++ b/drivers/message/i2o/iop.c
39519 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39520
39521 spin_lock_irqsave(&c->context_list_lock, flags);
39522
39523 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39524 - atomic_inc(&c->context_list_counter);
39525 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39526 + atomic_inc_unchecked(&c->context_list_counter);
39527
39528 - entry->context = atomic_read(&c->context_list_counter);
39529 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39530
39531 list_add(&entry->list, &c->context_list);
39532
39533 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39534
39535 #if BITS_PER_LONG == 64
39536 spin_lock_init(&c->context_list_lock);
39537 - atomic_set(&c->context_list_counter, 0);
39538 + atomic_set_unchecked(&c->context_list_counter, 0);
39539 INIT_LIST_HEAD(&c->context_list);
39540 #endif
39541
39542 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39543 index 45ece11..8efa218 100644
39544 --- a/drivers/mfd/janz-cmodio.c
39545 +++ b/drivers/mfd/janz-cmodio.c
39546 @@ -13,6 +13,7 @@
39547
39548 #include <linux/kernel.h>
39549 #include <linux/module.h>
39550 +#include <linux/slab.h>
39551 #include <linux/init.h>
39552 #include <linux/pci.h>
39553 #include <linux/interrupt.h>
39554 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39555 index a5f9888..1c0ed56 100644
39556 --- a/drivers/mfd/twl4030-irq.c
39557 +++ b/drivers/mfd/twl4030-irq.c
39558 @@ -35,6 +35,7 @@
39559 #include <linux/of.h>
39560 #include <linux/irqdomain.h>
39561 #include <linux/i2c/twl.h>
39562 +#include <asm/pgtable.h>
39563
39564 #include "twl-core.h"
39565
39566 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39567 * Install an irq handler for each of the SIH modules;
39568 * clone dummy irq_chip since PIH can't *do* anything
39569 */
39570 - twl4030_irq_chip = dummy_irq_chip;
39571 - twl4030_irq_chip.name = "twl4030";
39572 + pax_open_kernel();
39573 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39574 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39575
39576 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39577 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39578 + pax_close_kernel();
39579
39580 for (i = irq_base; i < irq_end; i++) {
39581 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39582 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39583 index 277a8db..0e0b754 100644
39584 --- a/drivers/mfd/twl6030-irq.c
39585 +++ b/drivers/mfd/twl6030-irq.c
39586 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39587 * install an irq handler for each of the modules;
39588 * clone dummy irq_chip since PIH can't *do* anything
39589 */
39590 - twl6030_irq_chip = dummy_irq_chip;
39591 - twl6030_irq_chip.name = "twl6030";
39592 - twl6030_irq_chip.irq_set_type = NULL;
39593 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39594 + pax_open_kernel();
39595 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39596 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39597 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39598 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39599 + pax_close_kernel();
39600
39601 for (i = irq_base; i < irq_end; i++) {
39602 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39603 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39604 index f32550a..e3e52a2 100644
39605 --- a/drivers/misc/c2port/core.c
39606 +++ b/drivers/misc/c2port/core.c
39607 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39608 mutex_init(&c2dev->mutex);
39609
39610 /* Create binary file */
39611 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39612 + pax_open_kernel();
39613 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39614 + pax_close_kernel();
39615 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39616 if (unlikely(ret))
39617 goto error_device_create_bin_file;
39618 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39619 index 36f5d52..32311c3 100644
39620 --- a/drivers/misc/kgdbts.c
39621 +++ b/drivers/misc/kgdbts.c
39622 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39623 char before[BREAK_INSTR_SIZE];
39624 char after[BREAK_INSTR_SIZE];
39625
39626 - probe_kernel_read(before, (char *)kgdbts_break_test,
39627 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39628 BREAK_INSTR_SIZE);
39629 init_simple_test();
39630 ts.tst = plant_and_detach_test;
39631 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39632 /* Activate test with initial breakpoint */
39633 if (!is_early)
39634 kgdb_breakpoint();
39635 - probe_kernel_read(after, (char *)kgdbts_break_test,
39636 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39637 BREAK_INSTR_SIZE);
39638 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39639 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39640 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39641 index 4cd4a3d..b48cbc7 100644
39642 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39643 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39644 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39645 * the lid is closed. This leads to interrupts as soon as a little move
39646 * is done.
39647 */
39648 - atomic_inc(&lis3->count);
39649 + atomic_inc_unchecked(&lis3->count);
39650
39651 wake_up_interruptible(&lis3->misc_wait);
39652 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39653 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39654 if (lis3->pm_dev)
39655 pm_runtime_get_sync(lis3->pm_dev);
39656
39657 - atomic_set(&lis3->count, 0);
39658 + atomic_set_unchecked(&lis3->count, 0);
39659 return 0;
39660 }
39661
39662 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39663 add_wait_queue(&lis3->misc_wait, &wait);
39664 while (true) {
39665 set_current_state(TASK_INTERRUPTIBLE);
39666 - data = atomic_xchg(&lis3->count, 0);
39667 + data = atomic_xchg_unchecked(&lis3->count, 0);
39668 if (data)
39669 break;
39670
39671 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39672 struct lis3lv02d, miscdev);
39673
39674 poll_wait(file, &lis3->misc_wait, wait);
39675 - if (atomic_read(&lis3->count))
39676 + if (atomic_read_unchecked(&lis3->count))
39677 return POLLIN | POLLRDNORM;
39678 return 0;
39679 }
39680 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39681 index c439c82..1f20f57 100644
39682 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39683 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39684 @@ -297,7 +297,7 @@ struct lis3lv02d {
39685 struct input_polled_dev *idev; /* input device */
39686 struct platform_device *pdev; /* platform device */
39687 struct regulator_bulk_data regulators[2];
39688 - atomic_t count; /* interrupt count after last read */
39689 + atomic_unchecked_t count; /* interrupt count after last read */
39690 union axis_conversion ac; /* hw -> logical axis */
39691 int mapped_btns[3];
39692
39693 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39694 index 2f30bad..c4c13d0 100644
39695 --- a/drivers/misc/sgi-gru/gruhandles.c
39696 +++ b/drivers/misc/sgi-gru/gruhandles.c
39697 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39698 unsigned long nsec;
39699
39700 nsec = CLKS2NSEC(clks);
39701 - atomic_long_inc(&mcs_op_statistics[op].count);
39702 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39703 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39704 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39705 if (mcs_op_statistics[op].max < nsec)
39706 mcs_op_statistics[op].max = nsec;
39707 }
39708 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39709 index 797d796..ae8f01e 100644
39710 --- a/drivers/misc/sgi-gru/gruprocfs.c
39711 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39712 @@ -32,9 +32,9 @@
39713
39714 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39715
39716 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39717 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39718 {
39719 - unsigned long val = atomic_long_read(v);
39720 + unsigned long val = atomic_long_read_unchecked(v);
39721
39722 seq_printf(s, "%16lu %s\n", val, id);
39723 }
39724 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39725
39726 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39727 for (op = 0; op < mcsop_last; op++) {
39728 - count = atomic_long_read(&mcs_op_statistics[op].count);
39729 - total = atomic_long_read(&mcs_op_statistics[op].total);
39730 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39731 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39732 max = mcs_op_statistics[op].max;
39733 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39734 count ? total / count : 0, max);
39735 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39736 index 5c3ce24..4915ccb 100644
39737 --- a/drivers/misc/sgi-gru/grutables.h
39738 +++ b/drivers/misc/sgi-gru/grutables.h
39739 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39740 * GRU statistics.
39741 */
39742 struct gru_stats_s {
39743 - atomic_long_t vdata_alloc;
39744 - atomic_long_t vdata_free;
39745 - atomic_long_t gts_alloc;
39746 - atomic_long_t gts_free;
39747 - atomic_long_t gms_alloc;
39748 - atomic_long_t gms_free;
39749 - atomic_long_t gts_double_allocate;
39750 - atomic_long_t assign_context;
39751 - atomic_long_t assign_context_failed;
39752 - atomic_long_t free_context;
39753 - atomic_long_t load_user_context;
39754 - atomic_long_t load_kernel_context;
39755 - atomic_long_t lock_kernel_context;
39756 - atomic_long_t unlock_kernel_context;
39757 - atomic_long_t steal_user_context;
39758 - atomic_long_t steal_kernel_context;
39759 - atomic_long_t steal_context_failed;
39760 - atomic_long_t nopfn;
39761 - atomic_long_t asid_new;
39762 - atomic_long_t asid_next;
39763 - atomic_long_t asid_wrap;
39764 - atomic_long_t asid_reuse;
39765 - atomic_long_t intr;
39766 - atomic_long_t intr_cbr;
39767 - atomic_long_t intr_tfh;
39768 - atomic_long_t intr_spurious;
39769 - atomic_long_t intr_mm_lock_failed;
39770 - atomic_long_t call_os;
39771 - atomic_long_t call_os_wait_queue;
39772 - atomic_long_t user_flush_tlb;
39773 - atomic_long_t user_unload_context;
39774 - atomic_long_t user_exception;
39775 - atomic_long_t set_context_option;
39776 - atomic_long_t check_context_retarget_intr;
39777 - atomic_long_t check_context_unload;
39778 - atomic_long_t tlb_dropin;
39779 - atomic_long_t tlb_preload_page;
39780 - atomic_long_t tlb_dropin_fail_no_asid;
39781 - atomic_long_t tlb_dropin_fail_upm;
39782 - atomic_long_t tlb_dropin_fail_invalid;
39783 - atomic_long_t tlb_dropin_fail_range_active;
39784 - atomic_long_t tlb_dropin_fail_idle;
39785 - atomic_long_t tlb_dropin_fail_fmm;
39786 - atomic_long_t tlb_dropin_fail_no_exception;
39787 - atomic_long_t tfh_stale_on_fault;
39788 - atomic_long_t mmu_invalidate_range;
39789 - atomic_long_t mmu_invalidate_page;
39790 - atomic_long_t flush_tlb;
39791 - atomic_long_t flush_tlb_gru;
39792 - atomic_long_t flush_tlb_gru_tgh;
39793 - atomic_long_t flush_tlb_gru_zero_asid;
39794 + atomic_long_unchecked_t vdata_alloc;
39795 + atomic_long_unchecked_t vdata_free;
39796 + atomic_long_unchecked_t gts_alloc;
39797 + atomic_long_unchecked_t gts_free;
39798 + atomic_long_unchecked_t gms_alloc;
39799 + atomic_long_unchecked_t gms_free;
39800 + atomic_long_unchecked_t gts_double_allocate;
39801 + atomic_long_unchecked_t assign_context;
39802 + atomic_long_unchecked_t assign_context_failed;
39803 + atomic_long_unchecked_t free_context;
39804 + atomic_long_unchecked_t load_user_context;
39805 + atomic_long_unchecked_t load_kernel_context;
39806 + atomic_long_unchecked_t lock_kernel_context;
39807 + atomic_long_unchecked_t unlock_kernel_context;
39808 + atomic_long_unchecked_t steal_user_context;
39809 + atomic_long_unchecked_t steal_kernel_context;
39810 + atomic_long_unchecked_t steal_context_failed;
39811 + atomic_long_unchecked_t nopfn;
39812 + atomic_long_unchecked_t asid_new;
39813 + atomic_long_unchecked_t asid_next;
39814 + atomic_long_unchecked_t asid_wrap;
39815 + atomic_long_unchecked_t asid_reuse;
39816 + atomic_long_unchecked_t intr;
39817 + atomic_long_unchecked_t intr_cbr;
39818 + atomic_long_unchecked_t intr_tfh;
39819 + atomic_long_unchecked_t intr_spurious;
39820 + atomic_long_unchecked_t intr_mm_lock_failed;
39821 + atomic_long_unchecked_t call_os;
39822 + atomic_long_unchecked_t call_os_wait_queue;
39823 + atomic_long_unchecked_t user_flush_tlb;
39824 + atomic_long_unchecked_t user_unload_context;
39825 + atomic_long_unchecked_t user_exception;
39826 + atomic_long_unchecked_t set_context_option;
39827 + atomic_long_unchecked_t check_context_retarget_intr;
39828 + atomic_long_unchecked_t check_context_unload;
39829 + atomic_long_unchecked_t tlb_dropin;
39830 + atomic_long_unchecked_t tlb_preload_page;
39831 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39832 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39833 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39834 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39835 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39836 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39837 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39838 + atomic_long_unchecked_t tfh_stale_on_fault;
39839 + atomic_long_unchecked_t mmu_invalidate_range;
39840 + atomic_long_unchecked_t mmu_invalidate_page;
39841 + atomic_long_unchecked_t flush_tlb;
39842 + atomic_long_unchecked_t flush_tlb_gru;
39843 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39844 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39845
39846 - atomic_long_t copy_gpa;
39847 - atomic_long_t read_gpa;
39848 + atomic_long_unchecked_t copy_gpa;
39849 + atomic_long_unchecked_t read_gpa;
39850
39851 - atomic_long_t mesq_receive;
39852 - atomic_long_t mesq_receive_none;
39853 - atomic_long_t mesq_send;
39854 - atomic_long_t mesq_send_failed;
39855 - atomic_long_t mesq_noop;
39856 - atomic_long_t mesq_send_unexpected_error;
39857 - atomic_long_t mesq_send_lb_overflow;
39858 - atomic_long_t mesq_send_qlimit_reached;
39859 - atomic_long_t mesq_send_amo_nacked;
39860 - atomic_long_t mesq_send_put_nacked;
39861 - atomic_long_t mesq_page_overflow;
39862 - atomic_long_t mesq_qf_locked;
39863 - atomic_long_t mesq_qf_noop_not_full;
39864 - atomic_long_t mesq_qf_switch_head_failed;
39865 - atomic_long_t mesq_qf_unexpected_error;
39866 - atomic_long_t mesq_noop_unexpected_error;
39867 - atomic_long_t mesq_noop_lb_overflow;
39868 - atomic_long_t mesq_noop_qlimit_reached;
39869 - atomic_long_t mesq_noop_amo_nacked;
39870 - atomic_long_t mesq_noop_put_nacked;
39871 - atomic_long_t mesq_noop_page_overflow;
39872 + atomic_long_unchecked_t mesq_receive;
39873 + atomic_long_unchecked_t mesq_receive_none;
39874 + atomic_long_unchecked_t mesq_send;
39875 + atomic_long_unchecked_t mesq_send_failed;
39876 + atomic_long_unchecked_t mesq_noop;
39877 + atomic_long_unchecked_t mesq_send_unexpected_error;
39878 + atomic_long_unchecked_t mesq_send_lb_overflow;
39879 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39880 + atomic_long_unchecked_t mesq_send_amo_nacked;
39881 + atomic_long_unchecked_t mesq_send_put_nacked;
39882 + atomic_long_unchecked_t mesq_page_overflow;
39883 + atomic_long_unchecked_t mesq_qf_locked;
39884 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39885 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39886 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39887 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39888 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39889 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39890 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39891 + atomic_long_unchecked_t mesq_noop_put_nacked;
39892 + atomic_long_unchecked_t mesq_noop_page_overflow;
39893
39894 };
39895
39896 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39897 tghop_invalidate, mcsop_last};
39898
39899 struct mcs_op_statistic {
39900 - atomic_long_t count;
39901 - atomic_long_t total;
39902 + atomic_long_unchecked_t count;
39903 + atomic_long_unchecked_t total;
39904 unsigned long max;
39905 };
39906
39907 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39908
39909 #define STAT(id) do { \
39910 if (gru_options & OPT_STATS) \
39911 - atomic_long_inc(&gru_stats.id); \
39912 + atomic_long_inc_unchecked(&gru_stats.id); \
39913 } while (0)
39914
39915 #ifdef CONFIG_SGI_GRU_DEBUG
39916 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39917 index c862cd4..0d176fe 100644
39918 --- a/drivers/misc/sgi-xp/xp.h
39919 +++ b/drivers/misc/sgi-xp/xp.h
39920 @@ -288,7 +288,7 @@ struct xpc_interface {
39921 xpc_notify_func, void *);
39922 void (*received) (short, int, void *);
39923 enum xp_retval (*partid_to_nasids) (short, void *);
39924 -};
39925 +} __no_const;
39926
39927 extern struct xpc_interface xpc_interface;
39928
39929 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39930 index b94d5f7..7f494c5 100644
39931 --- a/drivers/misc/sgi-xp/xpc.h
39932 +++ b/drivers/misc/sgi-xp/xpc.h
39933 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39934 void (*received_payload) (struct xpc_channel *, void *);
39935 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39936 };
39937 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39938
39939 /* struct xpc_partition act_state values (for XPC HB) */
39940
39941 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39942 /* found in xpc_main.c */
39943 extern struct device *xpc_part;
39944 extern struct device *xpc_chan;
39945 -extern struct xpc_arch_operations xpc_arch_ops;
39946 +extern xpc_arch_operations_no_const xpc_arch_ops;
39947 extern int xpc_disengage_timelimit;
39948 extern int xpc_disengage_timedout;
39949 extern int xpc_activate_IRQ_rcvd;
39950 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39951 index d971817..33bdca5 100644
39952 --- a/drivers/misc/sgi-xp/xpc_main.c
39953 +++ b/drivers/misc/sgi-xp/xpc_main.c
39954 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39955 .notifier_call = xpc_system_die,
39956 };
39957
39958 -struct xpc_arch_operations xpc_arch_ops;
39959 +xpc_arch_operations_no_const xpc_arch_ops;
39960
39961 /*
39962 * Timer function to enforce the timelimit on the partition disengage.
39963 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39964
39965 if (((die_args->trapnr == X86_TRAP_MF) ||
39966 (die_args->trapnr == X86_TRAP_XF)) &&
39967 - !user_mode_vm(die_args->regs))
39968 + !user_mode(die_args->regs))
39969 xpc_die_deactivate();
39970
39971 break;
39972 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39973 index 49f04bc..65660c2 100644
39974 --- a/drivers/mmc/core/mmc_ops.c
39975 +++ b/drivers/mmc/core/mmc_ops.c
39976 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39977 void *data_buf;
39978 int is_on_stack;
39979
39980 - is_on_stack = object_is_on_stack(buf);
39981 + is_on_stack = object_starts_on_stack(buf);
39982 if (is_on_stack) {
39983 /*
39984 * dma onto stack is unsafe/nonportable, but callers to this
39985 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39986 index 0b74189..818358f 100644
39987 --- a/drivers/mmc/host/dw_mmc.h
39988 +++ b/drivers/mmc/host/dw_mmc.h
39989 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
39990 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
39991 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
39992 int (*parse_dt)(struct dw_mci *host);
39993 -};
39994 +} __do_const;
39995 #endif /* _DW_MMC_H_ */
39996 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39997 index c6f6246..60760a8 100644
39998 --- a/drivers/mmc/host/sdhci-s3c.c
39999 +++ b/drivers/mmc/host/sdhci-s3c.c
40000 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
40001 * we can use overriding functions instead of default.
40002 */
40003 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
40004 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
40005 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
40006 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
40007 + pax_open_kernel();
40008 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
40009 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
40010 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
40011 + pax_close_kernel();
40012 }
40013
40014 /* It supports additional host capabilities if needed */
40015 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
40016 index 0c8bb6b..6f35deb 100644
40017 --- a/drivers/mtd/nand/denali.c
40018 +++ b/drivers/mtd/nand/denali.c
40019 @@ -24,6 +24,7 @@
40020 #include <linux/slab.h>
40021 #include <linux/mtd/mtd.h>
40022 #include <linux/module.h>
40023 +#include <linux/slab.h>
40024
40025 #include "denali.h"
40026
40027 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
40028 index 51b9d6a..52af9a7 100644
40029 --- a/drivers/mtd/nftlmount.c
40030 +++ b/drivers/mtd/nftlmount.c
40031 @@ -24,6 +24,7 @@
40032 #include <asm/errno.h>
40033 #include <linux/delay.h>
40034 #include <linux/slab.h>
40035 +#include <linux/sched.h>
40036 #include <linux/mtd/mtd.h>
40037 #include <linux/mtd/nand.h>
40038 #include <linux/mtd/nftl.h>
40039 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
40040 index f9d5615..99dd95f 100644
40041 --- a/drivers/mtd/sm_ftl.c
40042 +++ b/drivers/mtd/sm_ftl.c
40043 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
40044 #define SM_CIS_VENDOR_OFFSET 0x59
40045 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
40046 {
40047 - struct attribute_group *attr_group;
40048 + attribute_group_no_const *attr_group;
40049 struct attribute **attributes;
40050 struct sm_sysfs_attribute *vendor_attribute;
40051
40052 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
40053 index f975696..4597e21 100644
40054 --- a/drivers/net/bonding/bond_main.c
40055 +++ b/drivers/net/bonding/bond_main.c
40056 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
40057 return tx_queues;
40058 }
40059
40060 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
40061 +static struct rtnl_link_ops bond_link_ops = {
40062 .kind = "bond",
40063 .priv_size = sizeof(struct bonding),
40064 .setup = bond_setup,
40065 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
40066
40067 bond_destroy_debugfs();
40068
40069 - rtnl_link_unregister(&bond_link_ops);
40070 unregister_pernet_subsys(&bond_net_ops);
40071 + rtnl_link_unregister(&bond_link_ops);
40072
40073 #ifdef CONFIG_NET_POLL_CONTROLLER
40074 /*
40075 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
40076 index e1d2643..7f4133b 100644
40077 --- a/drivers/net/ethernet/8390/ax88796.c
40078 +++ b/drivers/net/ethernet/8390/ax88796.c
40079 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
40080 if (ax->plat->reg_offsets)
40081 ei_local->reg_offset = ax->plat->reg_offsets;
40082 else {
40083 + resource_size_t _mem_size = mem_size;
40084 + do_div(_mem_size, 0x18);
40085 ei_local->reg_offset = ax->reg_offsets;
40086 for (ret = 0; ret < 0x18; ret++)
40087 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
40088 + ax->reg_offsets[ret] = _mem_size * ret;
40089 }
40090
40091 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
40092 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40093 index 151675d..0139a9d 100644
40094 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40095 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40096 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
40097 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
40098 {
40099 /* RX_MODE controlling object */
40100 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
40101 + bnx2x_init_rx_mode_obj(bp);
40102
40103 /* multicast configuration controlling object */
40104 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
40105 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40106 index ce1a916..10b52b0 100644
40107 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40108 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40109 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
40110 struct bnx2x *bp = netdev_priv(dev);
40111
40112 /* Use the ethtool_dump "flag" field as the dump preset index */
40113 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
40114 + return -EINVAL;
40115 +
40116 bp->dump_preset_idx = val->flag;
40117 return 0;
40118 }
40119 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
40120 struct bnx2x *bp = netdev_priv(dev);
40121 struct dump_header dump_hdr = {0};
40122
40123 - memset(p, 0, dump->len);
40124 -
40125 /* Disable parity attentions as long as following dump may
40126 * cause false alarms by reading never written registers. We
40127 * will re-enable parity attentions right after the dump.
40128 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40129 index b4c9dea..2a9927f 100644
40130 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40131 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40132 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
40133 bp->min_msix_vec_cnt = 2;
40134 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
40135
40136 + bp->dump_preset_idx = 1;
40137 +
40138 return rc;
40139 }
40140
40141 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40142 index 32a9609..0b1c53a 100644
40143 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40144 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40145 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
40146 return rc;
40147 }
40148
40149 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40150 - struct bnx2x_rx_mode_obj *o)
40151 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
40152 {
40153 if (CHIP_IS_E1x(bp)) {
40154 - o->wait_comp = bnx2x_empty_rx_mode_wait;
40155 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
40156 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
40157 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
40158 } else {
40159 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
40160 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
40161 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
40162 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
40163 }
40164 }
40165
40166 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40167 index 43c00bc..dd1d03d 100644
40168 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40169 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40170 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
40171
40172 /********************* RX MODE ****************/
40173
40174 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40175 - struct bnx2x_rx_mode_obj *o);
40176 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
40177
40178 /**
40179 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
40180 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
40181 index ff6e30e..87e8452 100644
40182 --- a/drivers/net/ethernet/broadcom/tg3.h
40183 +++ b/drivers/net/ethernet/broadcom/tg3.h
40184 @@ -147,6 +147,7 @@
40185 #define CHIPREV_ID_5750_A0 0x4000
40186 #define CHIPREV_ID_5750_A1 0x4001
40187 #define CHIPREV_ID_5750_A3 0x4003
40188 +#define CHIPREV_ID_5750_C1 0x4201
40189 #define CHIPREV_ID_5750_C2 0x4202
40190 #define CHIPREV_ID_5752_A0_HW 0x5000
40191 #define CHIPREV_ID_5752_A0 0x6000
40192 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40193 index 71497e8..b650951 100644
40194 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40195 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40196 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
40197 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
40198 t3_read_reg(adapter, A_PCIE_PEX_ERR));
40199
40200 + rtnl_lock();
40201 t3_resume_ports(adapter);
40202 + rtnl_unlock();
40203 }
40204
40205 static const struct pci_error_handlers t3_err_handler = {
40206 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40207 index 8cffcdf..aadf043 100644
40208 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40209 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40210 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
40211 */
40212 struct l2t_skb_cb {
40213 arp_failure_handler_func arp_failure_handler;
40214 -};
40215 +} __no_const;
40216
40217 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
40218
40219 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
40220 index 4c83003..2a2a5b9 100644
40221 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
40222 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
40223 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40224 for (i=0; i<ETH_ALEN; i++) {
40225 tmp.addr[i] = dev->dev_addr[i];
40226 }
40227 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40228 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40229 break;
40230
40231 case DE4X5_SET_HWADDR: /* Set the hardware address */
40232 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40233 spin_lock_irqsave(&lp->lock, flags);
40234 memcpy(&statbuf, &lp->pktStats, ioc->len);
40235 spin_unlock_irqrestore(&lp->lock, flags);
40236 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
40237 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
40238 return -EFAULT;
40239 break;
40240 }
40241 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
40242 index 6e43426..1bd8365 100644
40243 --- a/drivers/net/ethernet/emulex/benet/be_main.c
40244 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
40245 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
40246
40247 if (wrapped)
40248 newacc += 65536;
40249 - ACCESS_ONCE(*acc) = newacc;
40250 + ACCESS_ONCE_RW(*acc) = newacc;
40251 }
40252
40253 void populate_erx_stats(struct be_adapter *adapter,
40254 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
40255 index 21b85fb..b49e5fc 100644
40256 --- a/drivers/net/ethernet/faraday/ftgmac100.c
40257 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
40258 @@ -31,6 +31,8 @@
40259 #include <linux/netdevice.h>
40260 #include <linux/phy.h>
40261 #include <linux/platform_device.h>
40262 +#include <linux/interrupt.h>
40263 +#include <linux/irqreturn.h>
40264 #include <net/ip.h>
40265
40266 #include "ftgmac100.h"
40267 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
40268 index a6eda8d..935d273 100644
40269 --- a/drivers/net/ethernet/faraday/ftmac100.c
40270 +++ b/drivers/net/ethernet/faraday/ftmac100.c
40271 @@ -31,6 +31,8 @@
40272 #include <linux/module.h>
40273 #include <linux/netdevice.h>
40274 #include <linux/platform_device.h>
40275 +#include <linux/interrupt.h>
40276 +#include <linux/irqreturn.h>
40277
40278 #include "ftmac100.h"
40279
40280 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40281 index 331987d..3be1135 100644
40282 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40283 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40284 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40285 }
40286
40287 /* update the base incval used to calculate frequency adjustment */
40288 - ACCESS_ONCE(adapter->base_incval) = incval;
40289 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40290 smp_mb();
40291
40292 /* need lock to prevent incorrect read while modifying cyclecounter */
40293 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40294 index fbe5363..266b4e3 100644
40295 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40296 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40297 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40298 struct __vxge_hw_fifo *fifo;
40299 struct vxge_hw_fifo_config *config;
40300 u32 txdl_size, txdl_per_memblock;
40301 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40302 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40303 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40304 + };
40305 +
40306 struct __vxge_hw_virtualpath *vpath;
40307
40308 if ((vp == NULL) || (attr == NULL)) {
40309 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40310 goto exit;
40311 }
40312
40313 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40314 -
40315 fifo->mempool =
40316 __vxge_hw_mempool_create(vpath->hldev,
40317 fifo->config->memblock_size,
40318 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40319 index 5e7fb1d..f8d1810 100644
40320 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40321 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40322 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
40323 op_mode = QLC_83XX_DEFAULT_OPMODE;
40324
40325 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
40326 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40327 + pax_open_kernel();
40328 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40329 + pax_close_kernel();
40330 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40331 } else {
40332 return -EIO;
40333 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40334 index b0c3de9..fc5857e 100644
40335 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40336 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40337 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
40338 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
40339 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40340 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40341 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40342 + pax_open_kernel();
40343 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40344 + pax_close_kernel();
40345 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40346 ahw->op_mode = QLCNIC_PRIV_FUNC;
40347 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40348 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40349 + pax_open_kernel();
40350 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40351 + pax_close_kernel();
40352 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40353 ahw->op_mode = QLCNIC_MGMT_FUNC;
40354 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40355 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40356 + pax_open_kernel();
40357 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40358 + pax_close_kernel();
40359 } else {
40360 return -EIO;
40361 }
40362 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
40363 index 6acf82b..14b097e 100644
40364 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
40365 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
40366 @@ -206,10 +206,10 @@ int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *adapter)
40367 if (err) {
40368 dev_info(&adapter->pdev->dev,
40369 "Failed to set driver version in firmware\n");
40370 - return -EIO;
40371 + err = -EIO;
40372 }
40373 -
40374 - return 0;
40375 + qlcnic_free_mbx_args(&cmd);
40376 + return err;
40377 }
40378
40379 int
40380 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
40381 index d3f8797..82a03d3 100644
40382 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
40383 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
40384 @@ -262,7 +262,7 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr,
40385
40386 mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
40387 mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
40388 - memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
40389 + memcpy(mac_req->mac_addr, uaddr, ETH_ALEN);
40390
40391 vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
40392 vlan_req->vlan_id = cpu_to_le16(vlan_id);
40393 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40394 index 393f961..d343034 100644
40395 --- a/drivers/net/ethernet/realtek/r8169.c
40396 +++ b/drivers/net/ethernet/realtek/r8169.c
40397 @@ -753,22 +753,22 @@ struct rtl8169_private {
40398 struct mdio_ops {
40399 void (*write)(struct rtl8169_private *, int, int);
40400 int (*read)(struct rtl8169_private *, int);
40401 - } mdio_ops;
40402 + } __no_const mdio_ops;
40403
40404 struct pll_power_ops {
40405 void (*down)(struct rtl8169_private *);
40406 void (*up)(struct rtl8169_private *);
40407 - } pll_power_ops;
40408 + } __no_const pll_power_ops;
40409
40410 struct jumbo_ops {
40411 void (*enable)(struct rtl8169_private *);
40412 void (*disable)(struct rtl8169_private *);
40413 - } jumbo_ops;
40414 + } __no_const jumbo_ops;
40415
40416 struct csi_ops {
40417 void (*write)(struct rtl8169_private *, int, int);
40418 u32 (*read)(struct rtl8169_private *, int);
40419 - } csi_ops;
40420 + } __no_const csi_ops;
40421
40422 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40423 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40424 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40425 index 9a95abf..36df7f9 100644
40426 --- a/drivers/net/ethernet/sfc/ptp.c
40427 +++ b/drivers/net/ethernet/sfc/ptp.c
40428 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40429 (u32)((u64)ptp->start.dma_addr >> 32));
40430
40431 /* Clear flag that signals MC ready */
40432 - ACCESS_ONCE(*start) = 0;
40433 + ACCESS_ONCE_RW(*start) = 0;
40434 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40435 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40436
40437 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40438 index 50617c5..b13724c 100644
40439 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40440 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40441 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40442
40443 writel(value, ioaddr + MMC_CNTRL);
40444
40445 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40446 - MMC_CNTRL, value);
40447 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40448 +// MMC_CNTRL, value);
40449 }
40450
40451 /* To mask all all interrupts.*/
40452 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40453 index e6fe0d8..2b7d752 100644
40454 --- a/drivers/net/hyperv/hyperv_net.h
40455 +++ b/drivers/net/hyperv/hyperv_net.h
40456 @@ -101,7 +101,7 @@ struct rndis_device {
40457
40458 enum rndis_device_state state;
40459 bool link_state;
40460 - atomic_t new_req_id;
40461 + atomic_unchecked_t new_req_id;
40462
40463 spinlock_t request_lock;
40464 struct list_head req_list;
40465 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40466 index 0775f0a..d4fb316 100644
40467 --- a/drivers/net/hyperv/rndis_filter.c
40468 +++ b/drivers/net/hyperv/rndis_filter.c
40469 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40470 * template
40471 */
40472 set = &rndis_msg->msg.set_req;
40473 - set->req_id = atomic_inc_return(&dev->new_req_id);
40474 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40475
40476 /* Add to the request list */
40477 spin_lock_irqsave(&dev->request_lock, flags);
40478 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40479
40480 /* Setup the rndis set */
40481 halt = &request->request_msg.msg.halt_req;
40482 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40483 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40484
40485 /* Ignore return since this msg is optional. */
40486 rndis_filter_send_request(dev, request);
40487 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40488 index bf0d55e..82bcfbd1 100644
40489 --- a/drivers/net/ieee802154/fakehard.c
40490 +++ b/drivers/net/ieee802154/fakehard.c
40491 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40492 phy->transmit_power = 0xbf;
40493
40494 dev->netdev_ops = &fake_ops;
40495 - dev->ml_priv = &fake_mlme;
40496 + dev->ml_priv = (void *)&fake_mlme;
40497
40498 priv = netdev_priv(dev);
40499 priv->phy = phy;
40500 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40501 index 6e91931..2b0ebe7 100644
40502 --- a/drivers/net/macvlan.c
40503 +++ b/drivers/net/macvlan.c
40504 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40505 int macvlan_link_register(struct rtnl_link_ops *ops)
40506 {
40507 /* common fields */
40508 - ops->priv_size = sizeof(struct macvlan_dev);
40509 - ops->validate = macvlan_validate;
40510 - ops->maxtype = IFLA_MACVLAN_MAX;
40511 - ops->policy = macvlan_policy;
40512 - ops->changelink = macvlan_changelink;
40513 - ops->get_size = macvlan_get_size;
40514 - ops->fill_info = macvlan_fill_info;
40515 + pax_open_kernel();
40516 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40517 + *(void **)&ops->validate = macvlan_validate;
40518 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40519 + *(const void **)&ops->policy = macvlan_policy;
40520 + *(void **)&ops->changelink = macvlan_changelink;
40521 + *(void **)&ops->get_size = macvlan_get_size;
40522 + *(void **)&ops->fill_info = macvlan_fill_info;
40523 + pax_close_kernel();
40524
40525 return rtnl_link_register(ops);
40526 };
40527 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40528 return NOTIFY_DONE;
40529 }
40530
40531 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40532 +static struct notifier_block macvlan_notifier_block = {
40533 .notifier_call = macvlan_device_event,
40534 };
40535
40536 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40537 index 523d6b2..5e16aa1 100644
40538 --- a/drivers/net/macvtap.c
40539 +++ b/drivers/net/macvtap.c
40540 @@ -1110,7 +1110,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40541 return NOTIFY_DONE;
40542 }
40543
40544 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40545 +static struct notifier_block macvtap_notifier_block = {
40546 .notifier_call = macvtap_device_event,
40547 };
40548
40549 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40550 index daec9b0..6428fcb 100644
40551 --- a/drivers/net/phy/mdio-bitbang.c
40552 +++ b/drivers/net/phy/mdio-bitbang.c
40553 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40554 struct mdiobb_ctrl *ctrl = bus->priv;
40555
40556 module_put(ctrl->ops->owner);
40557 + mdiobus_unregister(bus);
40558 mdiobus_free(bus);
40559 }
40560 EXPORT_SYMBOL(free_mdio_bitbang);
40561 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40562 index 72ff14b..11d442d 100644
40563 --- a/drivers/net/ppp/ppp_generic.c
40564 +++ b/drivers/net/ppp/ppp_generic.c
40565 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40566 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40567 struct ppp_stats stats;
40568 struct ppp_comp_stats cstats;
40569 - char *vers;
40570
40571 switch (cmd) {
40572 case SIOCGPPPSTATS:
40573 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40574 break;
40575
40576 case SIOCGPPPVER:
40577 - vers = PPP_VERSION;
40578 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40579 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40580 break;
40581 err = 0;
40582 break;
40583 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40584 index 1252d9c..80e660b 100644
40585 --- a/drivers/net/slip/slhc.c
40586 +++ b/drivers/net/slip/slhc.c
40587 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40588 register struct tcphdr *thp;
40589 register struct iphdr *ip;
40590 register struct cstate *cs;
40591 - int len, hdrlen;
40592 + long len, hdrlen;
40593 unsigned char *cp = icp;
40594
40595 /* We've got a compressed packet; read the change byte */
40596 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40597 index b305105..8ead6df 100644
40598 --- a/drivers/net/team/team.c
40599 +++ b/drivers/net/team/team.c
40600 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
40601 return NOTIFY_DONE;
40602 }
40603
40604 -static struct notifier_block team_notifier_block __read_mostly = {
40605 +static struct notifier_block team_notifier_block = {
40606 .notifier_call = team_device_event,
40607 };
40608
40609 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40610 index 2491eb2..694b2ec 100644
40611 --- a/drivers/net/tun.c
40612 +++ b/drivers/net/tun.c
40613 @@ -1869,7 +1869,7 @@ unlock:
40614 }
40615
40616 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40617 - unsigned long arg, int ifreq_len)
40618 + unsigned long arg, size_t ifreq_len)
40619 {
40620 struct tun_file *tfile = file->private_data;
40621 struct tun_struct *tun;
40622 @@ -1881,6 +1881,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40623 int vnet_hdr_sz;
40624 int ret;
40625
40626 + if (ifreq_len > sizeof ifr)
40627 + return -EFAULT;
40628 +
40629 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40630 if (copy_from_user(&ifr, argp, ifreq_len))
40631 return -EFAULT;
40632 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40633 index cba1d46..f703766 100644
40634 --- a/drivers/net/usb/hso.c
40635 +++ b/drivers/net/usb/hso.c
40636 @@ -71,7 +71,7 @@
40637 #include <asm/byteorder.h>
40638 #include <linux/serial_core.h>
40639 #include <linux/serial.h>
40640 -
40641 +#include <asm/local.h>
40642
40643 #define MOD_AUTHOR "Option Wireless"
40644 #define MOD_DESCRIPTION "USB High Speed Option driver"
40645 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40646 struct urb *urb;
40647
40648 urb = serial->rx_urb[0];
40649 - if (serial->port.count > 0) {
40650 + if (atomic_read(&serial->port.count) > 0) {
40651 count = put_rxbuf_data(urb, serial);
40652 if (count == -1)
40653 return;
40654 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40655 DUMP1(urb->transfer_buffer, urb->actual_length);
40656
40657 /* Anyone listening? */
40658 - if (serial->port.count == 0)
40659 + if (atomic_read(&serial->port.count) == 0)
40660 return;
40661
40662 if (status == 0) {
40663 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40664 tty_port_tty_set(&serial->port, tty);
40665
40666 /* check for port already opened, if not set the termios */
40667 - serial->port.count++;
40668 - if (serial->port.count == 1) {
40669 + if (atomic_inc_return(&serial->port.count) == 1) {
40670 serial->rx_state = RX_IDLE;
40671 /* Force default termio settings */
40672 _hso_serial_set_termios(tty, NULL);
40673 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40674 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40675 if (result) {
40676 hso_stop_serial_device(serial->parent);
40677 - serial->port.count--;
40678 + atomic_dec(&serial->port.count);
40679 kref_put(&serial->parent->ref, hso_serial_ref_free);
40680 }
40681 } else {
40682 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40683
40684 /* reset the rts and dtr */
40685 /* do the actual close */
40686 - serial->port.count--;
40687 + atomic_dec(&serial->port.count);
40688
40689 - if (serial->port.count <= 0) {
40690 - serial->port.count = 0;
40691 + if (atomic_read(&serial->port.count) <= 0) {
40692 + atomic_set(&serial->port.count, 0);
40693 tty_port_tty_set(&serial->port, NULL);
40694 if (!usb_gone)
40695 hso_stop_serial_device(serial->parent);
40696 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40697
40698 /* the actual setup */
40699 spin_lock_irqsave(&serial->serial_lock, flags);
40700 - if (serial->port.count)
40701 + if (atomic_read(&serial->port.count))
40702 _hso_serial_set_termios(tty, old);
40703 else
40704 tty->termios = *old;
40705 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40706 D1("Pending read interrupt on port %d\n", i);
40707 spin_lock(&serial->serial_lock);
40708 if (serial->rx_state == RX_IDLE &&
40709 - serial->port.count > 0) {
40710 + atomic_read(&serial->port.count) > 0) {
40711 /* Setup and send a ctrl req read on
40712 * port i */
40713 if (!serial->rx_urb_filled[0]) {
40714 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
40715 /* Start all serial ports */
40716 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40717 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40718 - if (dev2ser(serial_table[i])->port.count) {
40719 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40720 result =
40721 hso_start_serial_device(serial_table[i], GFP_NOIO);
40722 hso_kick_transmit(dev2ser(serial_table[i]));
40723 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40724 index 57325f3..36b181f 100644
40725 --- a/drivers/net/vxlan.c
40726 +++ b/drivers/net/vxlan.c
40727 @@ -1579,7 +1579,7 @@ nla_put_failure:
40728 return -EMSGSIZE;
40729 }
40730
40731 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40732 +static struct rtnl_link_ops vxlan_link_ops = {
40733 .kind = "vxlan",
40734 .maxtype = IFLA_VXLAN_MAX,
40735 .policy = vxlan_policy,
40736 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40737 index 34c8a33..3261fdc 100644
40738 --- a/drivers/net/wireless/at76c50x-usb.c
40739 +++ b/drivers/net/wireless/at76c50x-usb.c
40740 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40741 }
40742
40743 /* Convert timeout from the DFU status to jiffies */
40744 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40745 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40746 {
40747 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40748 | (s->poll_timeout[1] << 8)
40749 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40750 index 8d78253..bebbb68 100644
40751 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40752 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40753 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40754 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40755 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40756
40757 - ACCESS_ONCE(ads->ds_link) = i->link;
40758 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40759 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40760 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40761
40762 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40763 ctl6 = SM(i->keytype, AR_EncrType);
40764 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40765
40766 if ((i->is_first || i->is_last) &&
40767 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40768 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40769 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40770 | set11nTries(i->rates, 1)
40771 | set11nTries(i->rates, 2)
40772 | set11nTries(i->rates, 3)
40773 | (i->dur_update ? AR_DurUpdateEna : 0)
40774 | SM(0, AR_BurstDur);
40775
40776 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40777 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40778 | set11nRate(i->rates, 1)
40779 | set11nRate(i->rates, 2)
40780 | set11nRate(i->rates, 3);
40781 } else {
40782 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40783 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40784 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40785 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40786 }
40787
40788 if (!i->is_first) {
40789 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40790 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40791 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40792 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40793 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40794 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40795 return;
40796 }
40797
40798 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40799 break;
40800 }
40801
40802 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40803 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40804 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40805 | SM(i->txpower, AR_XmitPower)
40806 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40807 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40808 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40809 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40810
40811 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40812 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40813 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40814 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40815
40816 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40817 return;
40818
40819 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40820 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40821 | set11nPktDurRTSCTS(i->rates, 1);
40822
40823 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40824 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40825 | set11nPktDurRTSCTS(i->rates, 3);
40826
40827 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40828 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40829 | set11nRateFlags(i->rates, 1)
40830 | set11nRateFlags(i->rates, 2)
40831 | set11nRateFlags(i->rates, 3)
40832 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40833 index 301bf72..3f5654f 100644
40834 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40835 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40836 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40837 (i->qcu << AR_TxQcuNum_S) | desc_len;
40838
40839 checksum += val;
40840 - ACCESS_ONCE(ads->info) = val;
40841 + ACCESS_ONCE_RW(ads->info) = val;
40842
40843 checksum += i->link;
40844 - ACCESS_ONCE(ads->link) = i->link;
40845 + ACCESS_ONCE_RW(ads->link) = i->link;
40846
40847 checksum += i->buf_addr[0];
40848 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40849 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40850 checksum += i->buf_addr[1];
40851 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40852 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40853 checksum += i->buf_addr[2];
40854 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40855 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40856 checksum += i->buf_addr[3];
40857 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40858 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40859
40860 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40861 - ACCESS_ONCE(ads->ctl3) = val;
40862 + ACCESS_ONCE_RW(ads->ctl3) = val;
40863 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40864 - ACCESS_ONCE(ads->ctl5) = val;
40865 + ACCESS_ONCE_RW(ads->ctl5) = val;
40866 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40867 - ACCESS_ONCE(ads->ctl7) = val;
40868 + ACCESS_ONCE_RW(ads->ctl7) = val;
40869 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40870 - ACCESS_ONCE(ads->ctl9) = val;
40871 + ACCESS_ONCE_RW(ads->ctl9) = val;
40872
40873 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40874 - ACCESS_ONCE(ads->ctl10) = checksum;
40875 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40876
40877 if (i->is_first || i->is_last) {
40878 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40879 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40880 | set11nTries(i->rates, 1)
40881 | set11nTries(i->rates, 2)
40882 | set11nTries(i->rates, 3)
40883 | (i->dur_update ? AR_DurUpdateEna : 0)
40884 | SM(0, AR_BurstDur);
40885
40886 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40887 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40888 | set11nRate(i->rates, 1)
40889 | set11nRate(i->rates, 2)
40890 | set11nRate(i->rates, 3);
40891 } else {
40892 - ACCESS_ONCE(ads->ctl13) = 0;
40893 - ACCESS_ONCE(ads->ctl14) = 0;
40894 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40895 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40896 }
40897
40898 ads->ctl20 = 0;
40899 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40900
40901 ctl17 = SM(i->keytype, AR_EncrType);
40902 if (!i->is_first) {
40903 - ACCESS_ONCE(ads->ctl11) = 0;
40904 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40905 - ACCESS_ONCE(ads->ctl15) = 0;
40906 - ACCESS_ONCE(ads->ctl16) = 0;
40907 - ACCESS_ONCE(ads->ctl17) = ctl17;
40908 - ACCESS_ONCE(ads->ctl18) = 0;
40909 - ACCESS_ONCE(ads->ctl19) = 0;
40910 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40911 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40912 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40913 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40914 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40915 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40916 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40917 return;
40918 }
40919
40920 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40921 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40922 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40923 | SM(i->txpower, AR_XmitPower)
40924 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40925 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40926 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40927 ctl12 |= SM(val, AR_PAPRDChainMask);
40928
40929 - ACCESS_ONCE(ads->ctl12) = ctl12;
40930 - ACCESS_ONCE(ads->ctl17) = ctl17;
40931 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40932 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40933
40934 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40935 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40936 | set11nPktDurRTSCTS(i->rates, 1);
40937
40938 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40939 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40940 | set11nPktDurRTSCTS(i->rates, 3);
40941
40942 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40943 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40944 | set11nRateFlags(i->rates, 1)
40945 | set11nRateFlags(i->rates, 2)
40946 | set11nRateFlags(i->rates, 3)
40947 | SM(i->rtscts_rate, AR_RTSCTSRate);
40948
40949 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40950 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40951 }
40952
40953 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40954 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40955 index ae30343..a117806 100644
40956 --- a/drivers/net/wireless/ath/ath9k/hw.h
40957 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40958 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
40959
40960 /* ANI */
40961 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40962 -};
40963 +} __no_const;
40964
40965 /**
40966 * struct ath_spec_scan - parameters for Atheros spectral scan
40967 @@ -721,7 +721,7 @@ struct ath_hw_ops {
40968 struct ath_spec_scan *param);
40969 void (*spectral_scan_trigger)(struct ath_hw *ah);
40970 void (*spectral_scan_wait)(struct ath_hw *ah);
40971 -};
40972 +} __no_const;
40973
40974 struct ath_nf_limits {
40975 s16 max;
40976 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40977 index b37a582..680835d 100644
40978 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40979 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40980 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40981 */
40982 if (il3945_mod_params.disable_hw_scan) {
40983 D_INFO("Disabling hw_scan\n");
40984 - il3945_mac_ops.hw_scan = NULL;
40985 + pax_open_kernel();
40986 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40987 + pax_close_kernel();
40988 }
40989
40990 D_INFO("*** LOAD DRIVER ***\n");
40991 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40992 index d532948..e0d8bb1 100644
40993 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40994 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40995 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40996 {
40997 struct iwl_priv *priv = file->private_data;
40998 char buf[64];
40999 - int buf_size;
41000 + size_t buf_size;
41001 u32 offset, len;
41002
41003 memset(buf, 0, sizeof(buf));
41004 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
41005 struct iwl_priv *priv = file->private_data;
41006
41007 char buf[8];
41008 - int buf_size;
41009 + size_t buf_size;
41010 u32 reset_flag;
41011
41012 memset(buf, 0, sizeof(buf));
41013 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
41014 {
41015 struct iwl_priv *priv = file->private_data;
41016 char buf[8];
41017 - int buf_size;
41018 + size_t buf_size;
41019 int ht40;
41020
41021 memset(buf, 0, sizeof(buf));
41022 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
41023 {
41024 struct iwl_priv *priv = file->private_data;
41025 char buf[8];
41026 - int buf_size;
41027 + size_t buf_size;
41028 int value;
41029
41030 memset(buf, 0, sizeof(buf));
41031 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
41032 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
41033 DEBUGFS_READ_FILE_OPS(current_sleep_command);
41034
41035 -static const char *fmt_value = " %-30s %10u\n";
41036 -static const char *fmt_hex = " %-30s 0x%02X\n";
41037 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
41038 -static const char *fmt_header =
41039 +static const char fmt_value[] = " %-30s %10u\n";
41040 +static const char fmt_hex[] = " %-30s 0x%02X\n";
41041 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
41042 +static const char fmt_header[] =
41043 "%-32s current cumulative delta max\n";
41044
41045 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
41046 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
41047 {
41048 struct iwl_priv *priv = file->private_data;
41049 char buf[8];
41050 - int buf_size;
41051 + size_t buf_size;
41052 int clear;
41053
41054 memset(buf, 0, sizeof(buf));
41055 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
41056 {
41057 struct iwl_priv *priv = file->private_data;
41058 char buf[8];
41059 - int buf_size;
41060 + size_t buf_size;
41061 int trace;
41062
41063 memset(buf, 0, sizeof(buf));
41064 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
41065 {
41066 struct iwl_priv *priv = file->private_data;
41067 char buf[8];
41068 - int buf_size;
41069 + size_t buf_size;
41070 int missed;
41071
41072 memset(buf, 0, sizeof(buf));
41073 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
41074
41075 struct iwl_priv *priv = file->private_data;
41076 char buf[8];
41077 - int buf_size;
41078 + size_t buf_size;
41079 int plcp;
41080
41081 memset(buf, 0, sizeof(buf));
41082 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
41083
41084 struct iwl_priv *priv = file->private_data;
41085 char buf[8];
41086 - int buf_size;
41087 + size_t buf_size;
41088 int flush;
41089
41090 memset(buf, 0, sizeof(buf));
41091 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
41092
41093 struct iwl_priv *priv = file->private_data;
41094 char buf[8];
41095 - int buf_size;
41096 + size_t buf_size;
41097 int rts;
41098
41099 if (!priv->cfg->ht_params)
41100 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
41101 {
41102 struct iwl_priv *priv = file->private_data;
41103 char buf[8];
41104 - int buf_size;
41105 + size_t buf_size;
41106
41107 memset(buf, 0, sizeof(buf));
41108 buf_size = min(count, sizeof(buf) - 1);
41109 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
41110 struct iwl_priv *priv = file->private_data;
41111 u32 event_log_flag;
41112 char buf[8];
41113 - int buf_size;
41114 + size_t buf_size;
41115
41116 /* check that the interface is up */
41117 if (!iwl_is_ready(priv))
41118 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
41119 struct iwl_priv *priv = file->private_data;
41120 char buf[8];
41121 u32 calib_disabled;
41122 - int buf_size;
41123 + size_t buf_size;
41124
41125 memset(buf, 0, sizeof(buf));
41126 buf_size = min(count, sizeof(buf) - 1);
41127 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
41128 index 50ba0a4..29424e7 100644
41129 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
41130 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
41131 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
41132 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
41133
41134 char buf[8];
41135 - int buf_size;
41136 + size_t buf_size;
41137 u32 reset_flag;
41138
41139 memset(buf, 0, sizeof(buf));
41140 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
41141 {
41142 struct iwl_trans *trans = file->private_data;
41143 char buf[8];
41144 - int buf_size;
41145 + size_t buf_size;
41146 int csr;
41147
41148 memset(buf, 0, sizeof(buf));
41149 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
41150 index cb34c78..9fec0dc 100644
41151 --- a/drivers/net/wireless/mac80211_hwsim.c
41152 +++ b/drivers/net/wireless/mac80211_hwsim.c
41153 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
41154
41155 if (channels > 1) {
41156 hwsim_if_comb.num_different_channels = channels;
41157 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41158 - mac80211_hwsim_ops.cancel_hw_scan =
41159 - mac80211_hwsim_cancel_hw_scan;
41160 - mac80211_hwsim_ops.sw_scan_start = NULL;
41161 - mac80211_hwsim_ops.sw_scan_complete = NULL;
41162 - mac80211_hwsim_ops.remain_on_channel =
41163 - mac80211_hwsim_roc;
41164 - mac80211_hwsim_ops.cancel_remain_on_channel =
41165 - mac80211_hwsim_croc;
41166 - mac80211_hwsim_ops.add_chanctx =
41167 - mac80211_hwsim_add_chanctx;
41168 - mac80211_hwsim_ops.remove_chanctx =
41169 - mac80211_hwsim_remove_chanctx;
41170 - mac80211_hwsim_ops.change_chanctx =
41171 - mac80211_hwsim_change_chanctx;
41172 - mac80211_hwsim_ops.assign_vif_chanctx =
41173 - mac80211_hwsim_assign_vif_chanctx;
41174 - mac80211_hwsim_ops.unassign_vif_chanctx =
41175 - mac80211_hwsim_unassign_vif_chanctx;
41176 + pax_open_kernel();
41177 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41178 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
41179 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
41180 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
41181 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
41182 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
41183 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
41184 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
41185 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
41186 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
41187 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
41188 + pax_close_kernel();
41189 }
41190
41191 spin_lock_init(&hwsim_radio_lock);
41192 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
41193 index 8169a85..7fa3b47 100644
41194 --- a/drivers/net/wireless/rndis_wlan.c
41195 +++ b/drivers/net/wireless/rndis_wlan.c
41196 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
41197
41198 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
41199
41200 - if (rts_threshold < 0 || rts_threshold > 2347)
41201 + if (rts_threshold > 2347)
41202 rts_threshold = 2347;
41203
41204 tmp = cpu_to_le32(rts_threshold);
41205 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
41206 index 7510723..5ba37f5 100644
41207 --- a/drivers/net/wireless/rt2x00/rt2x00.h
41208 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
41209 @@ -386,7 +386,7 @@ struct rt2x00_intf {
41210 * for hardware which doesn't support hardware
41211 * sequence counting.
41212 */
41213 - atomic_t seqno;
41214 + atomic_unchecked_t seqno;
41215 };
41216
41217 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
41218 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
41219 index 2c12311..7b77f24 100644
41220 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
41221 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
41222 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
41223 * sequence counter given by mac80211.
41224 */
41225 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
41226 - seqno = atomic_add_return(0x10, &intf->seqno);
41227 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
41228 else
41229 - seqno = atomic_read(&intf->seqno);
41230 + seqno = atomic_read_unchecked(&intf->seqno);
41231
41232 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
41233 hdr->seq_ctrl |= cpu_to_le16(seqno);
41234 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
41235 index e2b3d9c..67a5184 100644
41236 --- a/drivers/net/wireless/ti/wl1251/sdio.c
41237 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
41238 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
41239
41240 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
41241
41242 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41243 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41244 + pax_open_kernel();
41245 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41246 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41247 + pax_close_kernel();
41248
41249 wl1251_info("using dedicated interrupt line");
41250 } else {
41251 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41252 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41253 + pax_open_kernel();
41254 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41255 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41256 + pax_close_kernel();
41257
41258 wl1251_info("using SDIO interrupt");
41259 }
41260 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41261 index 1c627da..69f7d17 100644
41262 --- a/drivers/net/wireless/ti/wl12xx/main.c
41263 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41264 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41265 sizeof(wl->conf.mem));
41266
41267 /* read data preparation is only needed by wl127x */
41268 - wl->ops->prepare_read = wl127x_prepare_read;
41269 + pax_open_kernel();
41270 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41271 + pax_close_kernel();
41272
41273 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41274 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41275 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41276 sizeof(wl->conf.mem));
41277
41278 /* read data preparation is only needed by wl127x */
41279 - wl->ops->prepare_read = wl127x_prepare_read;
41280 + pax_open_kernel();
41281 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41282 + pax_close_kernel();
41283
41284 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41285 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41286 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41287 index 9fa692d..b31fee0 100644
41288 --- a/drivers/net/wireless/ti/wl18xx/main.c
41289 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41290 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41291 }
41292
41293 if (!checksum_param) {
41294 - wl18xx_ops.set_rx_csum = NULL;
41295 - wl18xx_ops.init_vif = NULL;
41296 + pax_open_kernel();
41297 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41298 + *(void **)&wl18xx_ops.init_vif = NULL;
41299 + pax_close_kernel();
41300 }
41301
41302 /* Enable 11a Band only if we have 5G antennas */
41303 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41304 index 7ef0b4a..ff65c28 100644
41305 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41306 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41307 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41308 {
41309 struct zd_usb *usb = urb->context;
41310 struct zd_usb_interrupt *intr = &usb->intr;
41311 - int len;
41312 + unsigned int len;
41313 u16 int_num;
41314
41315 ZD_ASSERT(in_interrupt());
41316 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41317 index d93b2b6..ae50401 100644
41318 --- a/drivers/oprofile/buffer_sync.c
41319 +++ b/drivers/oprofile/buffer_sync.c
41320 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41321 if (cookie == NO_COOKIE)
41322 offset = pc;
41323 if (cookie == INVALID_COOKIE) {
41324 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41325 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41326 offset = pc;
41327 }
41328 if (cookie != last_cookie) {
41329 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41330 /* add userspace sample */
41331
41332 if (!mm) {
41333 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41334 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41335 return 0;
41336 }
41337
41338 cookie = lookup_dcookie(mm, s->eip, &offset);
41339
41340 if (cookie == INVALID_COOKIE) {
41341 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41342 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41343 return 0;
41344 }
41345
41346 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41347 /* ignore backtraces if failed to add a sample */
41348 if (state == sb_bt_start) {
41349 state = sb_bt_ignore;
41350 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41351 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41352 }
41353 }
41354 release_mm(mm);
41355 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41356 index c0cc4e7..44d4e54 100644
41357 --- a/drivers/oprofile/event_buffer.c
41358 +++ b/drivers/oprofile/event_buffer.c
41359 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41360 }
41361
41362 if (buffer_pos == buffer_size) {
41363 - atomic_inc(&oprofile_stats.event_lost_overflow);
41364 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41365 return;
41366 }
41367
41368 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41369 index ed2c3ec..deda85a 100644
41370 --- a/drivers/oprofile/oprof.c
41371 +++ b/drivers/oprofile/oprof.c
41372 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41373 if (oprofile_ops.switch_events())
41374 return;
41375
41376 - atomic_inc(&oprofile_stats.multiplex_counter);
41377 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41378 start_switch_worker();
41379 }
41380
41381 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41382 index 84a208d..d61b0a1 100644
41383 --- a/drivers/oprofile/oprofile_files.c
41384 +++ b/drivers/oprofile/oprofile_files.c
41385 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41386
41387 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41388
41389 -static ssize_t timeout_read(struct file *file, char __user *buf,
41390 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41391 size_t count, loff_t *offset)
41392 {
41393 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41394 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41395 index 917d28e..d62d981 100644
41396 --- a/drivers/oprofile/oprofile_stats.c
41397 +++ b/drivers/oprofile/oprofile_stats.c
41398 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41399 cpu_buf->sample_invalid_eip = 0;
41400 }
41401
41402 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41403 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41404 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41405 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41406 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41407 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41408 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41409 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41410 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41411 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41412 }
41413
41414
41415 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41416 index 38b6fc0..b5cbfce 100644
41417 --- a/drivers/oprofile/oprofile_stats.h
41418 +++ b/drivers/oprofile/oprofile_stats.h
41419 @@ -13,11 +13,11 @@
41420 #include <linux/atomic.h>
41421
41422 struct oprofile_stat_struct {
41423 - atomic_t sample_lost_no_mm;
41424 - atomic_t sample_lost_no_mapping;
41425 - atomic_t bt_lost_no_mapping;
41426 - atomic_t event_lost_overflow;
41427 - atomic_t multiplex_counter;
41428 + atomic_unchecked_t sample_lost_no_mm;
41429 + atomic_unchecked_t sample_lost_no_mapping;
41430 + atomic_unchecked_t bt_lost_no_mapping;
41431 + atomic_unchecked_t event_lost_overflow;
41432 + atomic_unchecked_t multiplex_counter;
41433 };
41434
41435 extern struct oprofile_stat_struct oprofile_stats;
41436 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41437 index 7c12d9c..558bf3bb 100644
41438 --- a/drivers/oprofile/oprofilefs.c
41439 +++ b/drivers/oprofile/oprofilefs.c
41440 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41441
41442
41443 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41444 - char const *name, atomic_t *val)
41445 + char const *name, atomic_unchecked_t *val)
41446 {
41447 return __oprofilefs_create_file(sb, root, name,
41448 &atomic_ro_fops, 0444, val);
41449 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41450 index 93404f7..4a313d8 100644
41451 --- a/drivers/oprofile/timer_int.c
41452 +++ b/drivers/oprofile/timer_int.c
41453 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41454 return NOTIFY_OK;
41455 }
41456
41457 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41458 +static struct notifier_block oprofile_cpu_notifier = {
41459 .notifier_call = oprofile_cpu_notify,
41460 };
41461
41462 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41463 index 92ed045..62d39bd7 100644
41464 --- a/drivers/parport/procfs.c
41465 +++ b/drivers/parport/procfs.c
41466 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41467
41468 *ppos += len;
41469
41470 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41471 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41472 }
41473
41474 #ifdef CONFIG_PARPORT_1284
41475 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41476
41477 *ppos += len;
41478
41479 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41480 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41481 }
41482 #endif /* IEEE1284.3 support. */
41483
41484 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41485 index c35e8ad..fc33beb 100644
41486 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41487 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41488 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41489 goto init_cleanup;
41490 }
41491
41492 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41493 + pax_open_kernel();
41494 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41495 + pax_close_kernel();
41496 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41497
41498 return retval;
41499 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41500 index a6a71c4..c91097b 100644
41501 --- a/drivers/pci/hotplug/cpcihp_generic.c
41502 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41503 @@ -73,7 +73,6 @@ static u16 port;
41504 static unsigned int enum_bit;
41505 static u8 enum_mask;
41506
41507 -static struct cpci_hp_controller_ops generic_hpc_ops;
41508 static struct cpci_hp_controller generic_hpc;
41509
41510 static int __init validate_parameters(void)
41511 @@ -139,6 +138,10 @@ static int query_enum(void)
41512 return ((value & enum_mask) == enum_mask);
41513 }
41514
41515 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41516 + .query_enum = query_enum,
41517 +};
41518 +
41519 static int __init cpcihp_generic_init(void)
41520 {
41521 int status;
41522 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41523 pci_dev_put(dev);
41524
41525 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41526 - generic_hpc_ops.query_enum = query_enum;
41527 generic_hpc.ops = &generic_hpc_ops;
41528
41529 status = cpci_hp_register_controller(&generic_hpc);
41530 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41531 index 449b4bb..257e2e8 100644
41532 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41533 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41534 @@ -59,7 +59,6 @@
41535 /* local variables */
41536 static bool debug;
41537 static bool poll;
41538 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41539 static struct cpci_hp_controller zt5550_hpc;
41540
41541 /* Primary cPCI bus bridge device */
41542 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41543 return 0;
41544 }
41545
41546 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41547 + .query_enum = zt5550_hc_query_enum,
41548 +};
41549 +
41550 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41551 {
41552 int status;
41553 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41554 dbg("returned from zt5550_hc_config");
41555
41556 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41557 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41558 zt5550_hpc.ops = &zt5550_hpc_ops;
41559 if(!poll) {
41560 zt5550_hpc.irq = hc_dev->irq;
41561 zt5550_hpc.irq_flags = IRQF_SHARED;
41562 zt5550_hpc.dev_id = hc_dev;
41563
41564 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41565 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41566 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41567 + pax_open_kernel();
41568 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41569 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41570 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41571 + pax_open_kernel();
41572 } else {
41573 info("using ENUM# polling mode");
41574 }
41575 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41576 index 76ba8a1..20ca857 100644
41577 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41578 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41579 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41580
41581 void compaq_nvram_init (void __iomem *rom_start)
41582 {
41583 +
41584 +#ifndef CONFIG_PAX_KERNEXEC
41585 if (rom_start) {
41586 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41587 }
41588 +#endif
41589 +
41590 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41591
41592 /* initialize our int15 lock */
41593 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41594 index ec20f74..c1d961e 100644
41595 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41596 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41597 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41598 return -EINVAL;
41599 }
41600
41601 - slot->ops->owner = owner;
41602 - slot->ops->mod_name = mod_name;
41603 + pax_open_kernel();
41604 + *(struct module **)&slot->ops->owner = owner;
41605 + *(const char **)&slot->ops->mod_name = mod_name;
41606 + pax_close_kernel();
41607
41608 mutex_lock(&pci_hp_mutex);
41609 /*
41610 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41611 index 7d72c5e..edce02c 100644
41612 --- a/drivers/pci/hotplug/pciehp_core.c
41613 +++ b/drivers/pci/hotplug/pciehp_core.c
41614 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41615 struct slot *slot = ctrl->slot;
41616 struct hotplug_slot *hotplug = NULL;
41617 struct hotplug_slot_info *info = NULL;
41618 - struct hotplug_slot_ops *ops = NULL;
41619 + hotplug_slot_ops_no_const *ops = NULL;
41620 char name[SLOT_NAME_SIZE];
41621 int retval = -ENOMEM;
41622
41623 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41624 index 5b4a9d9..cd5ac1f 100644
41625 --- a/drivers/pci/pci-sysfs.c
41626 +++ b/drivers/pci/pci-sysfs.c
41627 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41628 {
41629 /* allocate attribute structure, piggyback attribute name */
41630 int name_len = write_combine ? 13 : 10;
41631 - struct bin_attribute *res_attr;
41632 + bin_attribute_no_const *res_attr;
41633 int retval;
41634
41635 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41636 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41637 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41638 {
41639 int retval;
41640 - struct bin_attribute *attr;
41641 + bin_attribute_no_const *attr;
41642
41643 /* If the device has VPD, try to expose it in sysfs. */
41644 if (dev->vpd) {
41645 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41646 {
41647 int retval;
41648 int rom_size = 0;
41649 - struct bin_attribute *attr;
41650 + bin_attribute_no_const *attr;
41651
41652 if (!sysfs_initialized)
41653 return -EACCES;
41654 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41655 index d1182c4..2a138ec 100644
41656 --- a/drivers/pci/pci.h
41657 +++ b/drivers/pci/pci.h
41658 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
41659 struct pci_vpd {
41660 unsigned int len;
41661 const struct pci_vpd_ops *ops;
41662 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41663 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41664 };
41665
41666 int pci_vpd_pci22_init(struct pci_dev *dev);
41667 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41668 index d320df6..ca9a8f6 100644
41669 --- a/drivers/pci/pcie/aspm.c
41670 +++ b/drivers/pci/pcie/aspm.c
41671 @@ -27,9 +27,9 @@
41672 #define MODULE_PARAM_PREFIX "pcie_aspm."
41673
41674 /* Note: those are not register definitions */
41675 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41676 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41677 -#define ASPM_STATE_L1 (4) /* L1 state */
41678 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41679 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41680 +#define ASPM_STATE_L1 (4U) /* L1 state */
41681 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41682 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41683
41684 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41685 index ea37072..10e58e56 100644
41686 --- a/drivers/pci/probe.c
41687 +++ b/drivers/pci/probe.c
41688 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41689 struct pci_bus_region region;
41690 bool bar_too_big = false, bar_disabled = false;
41691
41692 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41693 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41694
41695 /* No printks while decoding is disabled! */
41696 if (!dev->mmio_always_on) {
41697 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41698 index 0812608..b04018c4 100644
41699 --- a/drivers/pci/proc.c
41700 +++ b/drivers/pci/proc.c
41701 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41702 static int __init pci_proc_init(void)
41703 {
41704 struct pci_dev *dev = NULL;
41705 +
41706 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41707 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41708 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41709 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41710 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41711 +#endif
41712 +#else
41713 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41714 +#endif
41715 proc_create("devices", 0, proc_bus_pci_dir,
41716 &proc_bus_pci_dev_operations);
41717 proc_initialized = 1;
41718 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41719 index 3e5b4497..dcdfb70 100644
41720 --- a/drivers/platform/x86/chromeos_laptop.c
41721 +++ b/drivers/platform/x86/chromeos_laptop.c
41722 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41723 return 0;
41724 }
41725
41726 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41727 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41728 {
41729 .ident = "Samsung Series 5 550 - Touchpad",
41730 .matches = {
41731 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41732 index 6b22938..bc9700e 100644
41733 --- a/drivers/platform/x86/msi-laptop.c
41734 +++ b/drivers/platform/x86/msi-laptop.c
41735 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41736
41737 if (!quirks->ec_read_only) {
41738 /* allow userland write sysfs file */
41739 - dev_attr_bluetooth.store = store_bluetooth;
41740 - dev_attr_wlan.store = store_wlan;
41741 - dev_attr_threeg.store = store_threeg;
41742 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41743 - dev_attr_wlan.attr.mode |= S_IWUSR;
41744 - dev_attr_threeg.attr.mode |= S_IWUSR;
41745 + pax_open_kernel();
41746 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41747 + *(void **)&dev_attr_wlan.store = store_wlan;
41748 + *(void **)&dev_attr_threeg.store = store_threeg;
41749 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41750 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41751 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41752 + pax_close_kernel();
41753 }
41754
41755 /* disable hardware control by fn key */
41756 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41757 index 2ac045f..39c443d 100644
41758 --- a/drivers/platform/x86/sony-laptop.c
41759 +++ b/drivers/platform/x86/sony-laptop.c
41760 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41761 }
41762
41763 /* High speed charging function */
41764 -static struct device_attribute *hsc_handle;
41765 +static device_attribute_no_const *hsc_handle;
41766
41767 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41768 struct device_attribute *attr,
41769 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41770 index 54d31c0..3f896d3 100644
41771 --- a/drivers/platform/x86/thinkpad_acpi.c
41772 +++ b/drivers/platform/x86/thinkpad_acpi.c
41773 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41774 return 0;
41775 }
41776
41777 -void static hotkey_mask_warn_incomplete_mask(void)
41778 +static void hotkey_mask_warn_incomplete_mask(void)
41779 {
41780 /* log only what the user can fix... */
41781 const u32 wantedmask = hotkey_driver_mask &
41782 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41783 }
41784 }
41785
41786 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41787 - struct tp_nvram_state *newn,
41788 - const u32 event_mask)
41789 -{
41790 -
41791 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41792 do { \
41793 if ((event_mask & (1 << __scancode)) && \
41794 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41795 tpacpi_hotkey_send_key(__scancode); \
41796 } while (0)
41797
41798 - void issue_volchange(const unsigned int oldvol,
41799 - const unsigned int newvol)
41800 - {
41801 - unsigned int i = oldvol;
41802 +static void issue_volchange(const unsigned int oldvol,
41803 + const unsigned int newvol,
41804 + const u32 event_mask)
41805 +{
41806 + unsigned int i = oldvol;
41807
41808 - while (i > newvol) {
41809 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41810 - i--;
41811 - }
41812 - while (i < newvol) {
41813 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41814 - i++;
41815 - }
41816 + while (i > newvol) {
41817 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41818 + i--;
41819 }
41820 + while (i < newvol) {
41821 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41822 + i++;
41823 + }
41824 +}
41825
41826 - void issue_brightnesschange(const unsigned int oldbrt,
41827 - const unsigned int newbrt)
41828 - {
41829 - unsigned int i = oldbrt;
41830 +static void issue_brightnesschange(const unsigned int oldbrt,
41831 + const unsigned int newbrt,
41832 + const u32 event_mask)
41833 +{
41834 + unsigned int i = oldbrt;
41835
41836 - while (i > newbrt) {
41837 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41838 - i--;
41839 - }
41840 - while (i < newbrt) {
41841 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41842 - i++;
41843 - }
41844 + while (i > newbrt) {
41845 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41846 + i--;
41847 + }
41848 + while (i < newbrt) {
41849 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41850 + i++;
41851 }
41852 +}
41853
41854 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41855 + struct tp_nvram_state *newn,
41856 + const u32 event_mask)
41857 +{
41858 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41859 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41860 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41861 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41862 oldn->volume_level != newn->volume_level) {
41863 /* recently muted, or repeated mute keypress, or
41864 * multiple presses ending in mute */
41865 - issue_volchange(oldn->volume_level, newn->volume_level);
41866 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41867 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41868 }
41869 } else {
41870 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41871 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41872 }
41873 if (oldn->volume_level != newn->volume_level) {
41874 - issue_volchange(oldn->volume_level, newn->volume_level);
41875 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41876 } else if (oldn->volume_toggle != newn->volume_toggle) {
41877 /* repeated vol up/down keypress at end of scale ? */
41878 if (newn->volume_level == 0)
41879 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41880 /* handle brightness */
41881 if (oldn->brightness_level != newn->brightness_level) {
41882 issue_brightnesschange(oldn->brightness_level,
41883 - newn->brightness_level);
41884 + newn->brightness_level,
41885 + event_mask);
41886 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41887 /* repeated key presses that didn't change state */
41888 if (newn->brightness_level == 0)
41889 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41890 && !tp_features.bright_unkfw)
41891 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41892 }
41893 +}
41894
41895 #undef TPACPI_COMPARE_KEY
41896 #undef TPACPI_MAY_SEND_KEY
41897 -}
41898
41899 /*
41900 * Polling driver
41901 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41902 index 769d265..a3a05ca 100644
41903 --- a/drivers/pnp/pnpbios/bioscalls.c
41904 +++ b/drivers/pnp/pnpbios/bioscalls.c
41905 @@ -58,7 +58,7 @@ do { \
41906 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41907 } while(0)
41908
41909 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41910 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41911 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41912
41913 /*
41914 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41915
41916 cpu = get_cpu();
41917 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41918 +
41919 + pax_open_kernel();
41920 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41921 + pax_close_kernel();
41922
41923 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41924 spin_lock_irqsave(&pnp_bios_lock, flags);
41925 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41926 :"memory");
41927 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41928
41929 + pax_open_kernel();
41930 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41931 + pax_close_kernel();
41932 +
41933 put_cpu();
41934
41935 /* If we get here and this is set then the PnP BIOS faulted on us. */
41936 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41937 return status;
41938 }
41939
41940 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41941 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41942 {
41943 int i;
41944
41945 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41946 pnp_bios_callpoint.offset = header->fields.pm16offset;
41947 pnp_bios_callpoint.segment = PNP_CS16;
41948
41949 + pax_open_kernel();
41950 +
41951 for_each_possible_cpu(i) {
41952 struct desc_struct *gdt = get_cpu_gdt_table(i);
41953 if (!gdt)
41954 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41955 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41956 (unsigned long)__va(header->fields.pm16dseg));
41957 }
41958 +
41959 + pax_close_kernel();
41960 }
41961 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41962 index 3e6db1c..1fbbdae 100644
41963 --- a/drivers/pnp/resource.c
41964 +++ b/drivers/pnp/resource.c
41965 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41966 return 1;
41967
41968 /* check if the resource is valid */
41969 - if (*irq < 0 || *irq > 15)
41970 + if (*irq > 15)
41971 return 0;
41972
41973 /* check if the resource is reserved */
41974 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41975 return 1;
41976
41977 /* check if the resource is valid */
41978 - if (*dma < 0 || *dma == 4 || *dma > 7)
41979 + if (*dma == 4 || *dma > 7)
41980 return 0;
41981
41982 /* check if the resource is reserved */
41983 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41984 index 0c52e2a..3421ab7 100644
41985 --- a/drivers/power/pda_power.c
41986 +++ b/drivers/power/pda_power.c
41987 @@ -37,7 +37,11 @@ static int polling;
41988
41989 #if IS_ENABLED(CONFIG_USB_PHY)
41990 static struct usb_phy *transceiver;
41991 -static struct notifier_block otg_nb;
41992 +static int otg_handle_notification(struct notifier_block *nb,
41993 + unsigned long event, void *unused);
41994 +static struct notifier_block otg_nb = {
41995 + .notifier_call = otg_handle_notification
41996 +};
41997 #endif
41998
41999 static struct regulator *ac_draw;
42000 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
42001
42002 #if IS_ENABLED(CONFIG_USB_PHY)
42003 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
42004 - otg_nb.notifier_call = otg_handle_notification;
42005 ret = usb_register_notifier(transceiver, &otg_nb);
42006 if (ret) {
42007 dev_err(dev, "failure to register otg notifier\n");
42008 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
42009 index cc439fd..8fa30df 100644
42010 --- a/drivers/power/power_supply.h
42011 +++ b/drivers/power/power_supply.h
42012 @@ -16,12 +16,12 @@ struct power_supply;
42013
42014 #ifdef CONFIG_SYSFS
42015
42016 -extern void power_supply_init_attrs(struct device_type *dev_type);
42017 +extern void power_supply_init_attrs(void);
42018 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
42019
42020 #else
42021
42022 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
42023 +static inline void power_supply_init_attrs(void) {}
42024 #define power_supply_uevent NULL
42025
42026 #endif /* CONFIG_SYSFS */
42027 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
42028 index 1c517c3..ffa2f17 100644
42029 --- a/drivers/power/power_supply_core.c
42030 +++ b/drivers/power/power_supply_core.c
42031 @@ -24,7 +24,10 @@
42032 struct class *power_supply_class;
42033 EXPORT_SYMBOL_GPL(power_supply_class);
42034
42035 -static struct device_type power_supply_dev_type;
42036 +extern const struct attribute_group *power_supply_attr_groups[];
42037 +static struct device_type power_supply_dev_type = {
42038 + .groups = power_supply_attr_groups,
42039 +};
42040
42041 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
42042 struct power_supply *supply)
42043 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
42044 return PTR_ERR(power_supply_class);
42045
42046 power_supply_class->dev_uevent = power_supply_uevent;
42047 - power_supply_init_attrs(&power_supply_dev_type);
42048 + power_supply_init_attrs();
42049
42050 return 0;
42051 }
42052 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
42053 index 29178f7..c65f324 100644
42054 --- a/drivers/power/power_supply_sysfs.c
42055 +++ b/drivers/power/power_supply_sysfs.c
42056 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
42057 .is_visible = power_supply_attr_is_visible,
42058 };
42059
42060 -static const struct attribute_group *power_supply_attr_groups[] = {
42061 +const struct attribute_group *power_supply_attr_groups[] = {
42062 &power_supply_attr_group,
42063 NULL,
42064 };
42065
42066 -void power_supply_init_attrs(struct device_type *dev_type)
42067 +void power_supply_init_attrs(void)
42068 {
42069 int i;
42070
42071 - dev_type->groups = power_supply_attr_groups;
42072 -
42073 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
42074 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
42075 }
42076 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
42077 index d428ef9..fdc0357 100644
42078 --- a/drivers/regulator/max8660.c
42079 +++ b/drivers/regulator/max8660.c
42080 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
42081 max8660->shadow_regs[MAX8660_OVER1] = 5;
42082 } else {
42083 /* Otherwise devices can be toggled via software */
42084 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
42085 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
42086 + pax_open_kernel();
42087 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
42088 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
42089 + pax_close_kernel();
42090 }
42091
42092 /*
42093 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
42094 index adb1414..c13e0ce 100644
42095 --- a/drivers/regulator/max8973-regulator.c
42096 +++ b/drivers/regulator/max8973-regulator.c
42097 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
42098 if (!pdata->enable_ext_control) {
42099 max->desc.enable_reg = MAX8973_VOUT;
42100 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
42101 - max8973_dcdc_ops.enable = regulator_enable_regmap;
42102 - max8973_dcdc_ops.disable = regulator_disable_regmap;
42103 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
42104 + pax_open_kernel();
42105 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
42106 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
42107 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
42108 + pax_close_kernel();
42109 }
42110
42111 max->enable_external_control = pdata->enable_ext_control;
42112 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
42113 index b716283..3cc4349 100644
42114 --- a/drivers/regulator/mc13892-regulator.c
42115 +++ b/drivers/regulator/mc13892-regulator.c
42116 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
42117 }
42118 mc13xxx_unlock(mc13892);
42119
42120 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42121 + pax_open_kernel();
42122 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42123 = mc13892_vcam_set_mode;
42124 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42125 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42126 = mc13892_vcam_get_mode;
42127 + pax_close_kernel();
42128
42129 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
42130 ARRAY_SIZE(mc13892_regulators));
42131 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
42132 index f1cb706..4c7832a 100644
42133 --- a/drivers/rtc/rtc-cmos.c
42134 +++ b/drivers/rtc/rtc-cmos.c
42135 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
42136 hpet_rtc_timer_init();
42137
42138 /* export at least the first block of NVRAM */
42139 - nvram.size = address_space - NVRAM_OFFSET;
42140 + pax_open_kernel();
42141 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
42142 + pax_close_kernel();
42143 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
42144 if (retval < 0) {
42145 dev_dbg(dev, "can't create nvram file? %d\n", retval);
42146 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
42147 index d049393..bb20be0 100644
42148 --- a/drivers/rtc/rtc-dev.c
42149 +++ b/drivers/rtc/rtc-dev.c
42150 @@ -16,6 +16,7 @@
42151 #include <linux/module.h>
42152 #include <linux/rtc.h>
42153 #include <linux/sched.h>
42154 +#include <linux/grsecurity.h>
42155 #include "rtc-core.h"
42156
42157 static dev_t rtc_devt;
42158 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
42159 if (copy_from_user(&tm, uarg, sizeof(tm)))
42160 return -EFAULT;
42161
42162 + gr_log_timechange();
42163 +
42164 return rtc_set_time(rtc, &tm);
42165
42166 case RTC_PIE_ON:
42167 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
42168 index b53992a..776df84 100644
42169 --- a/drivers/rtc/rtc-ds1307.c
42170 +++ b/drivers/rtc/rtc-ds1307.c
42171 @@ -107,7 +107,7 @@ struct ds1307 {
42172 u8 offset; /* register's offset */
42173 u8 regs[11];
42174 u16 nvram_offset;
42175 - struct bin_attribute *nvram;
42176 + bin_attribute_no_const *nvram;
42177 enum ds_type type;
42178 unsigned long flags;
42179 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
42180 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
42181 index 130f29a..6179d03 100644
42182 --- a/drivers/rtc/rtc-m48t59.c
42183 +++ b/drivers/rtc/rtc-m48t59.c
42184 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
42185 goto out;
42186 }
42187
42188 - m48t59_nvram_attr.size = pdata->offset;
42189 + pax_open_kernel();
42190 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
42191 + pax_close_kernel();
42192
42193 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
42194 if (ret) {
42195 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
42196 index e693af6..2e525b6 100644
42197 --- a/drivers/scsi/bfa/bfa_fcpim.h
42198 +++ b/drivers/scsi/bfa/bfa_fcpim.h
42199 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
42200
42201 struct bfa_itn_s {
42202 bfa_isr_func_t isr;
42203 -};
42204 +} __no_const;
42205
42206 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
42207 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
42208 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
42209 index 23a90e7..9cf04ee 100644
42210 --- a/drivers/scsi/bfa/bfa_ioc.h
42211 +++ b/drivers/scsi/bfa/bfa_ioc.h
42212 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
42213 bfa_ioc_disable_cbfn_t disable_cbfn;
42214 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
42215 bfa_ioc_reset_cbfn_t reset_cbfn;
42216 -};
42217 +} __no_const;
42218
42219 /*
42220 * IOC event notification mechanism.
42221 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
42222 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
42223 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
42224 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
42225 -};
42226 +} __no_const;
42227
42228 /*
42229 * Queue element to wait for room in request queue. FIFO order is
42230 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42231 index df0c3c7..b00e1d0 100644
42232 --- a/drivers/scsi/hosts.c
42233 +++ b/drivers/scsi/hosts.c
42234 @@ -42,7 +42,7 @@
42235 #include "scsi_logging.h"
42236
42237
42238 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42239 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42240
42241
42242 static void scsi_host_cls_release(struct device *dev)
42243 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42244 * subtract one because we increment first then return, but we need to
42245 * know what the next host number was before increment
42246 */
42247 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42248 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42249 shost->dma_channel = 0xff;
42250
42251 /* These three are default values which can be overridden */
42252 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42253 index 7f4f790..b75b92a 100644
42254 --- a/drivers/scsi/hpsa.c
42255 +++ b/drivers/scsi/hpsa.c
42256 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42257 unsigned long flags;
42258
42259 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42260 - return h->access.command_completed(h, q);
42261 + return h->access->command_completed(h, q);
42262
42263 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42264 a = rq->head[rq->current_entry];
42265 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
42266 while (!list_empty(&h->reqQ)) {
42267 c = list_entry(h->reqQ.next, struct CommandList, list);
42268 /* can't do anything if fifo is full */
42269 - if ((h->access.fifo_full(h))) {
42270 + if ((h->access->fifo_full(h))) {
42271 dev_warn(&h->pdev->dev, "fifo full\n");
42272 break;
42273 }
42274 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42275
42276 /* Tell the controller execute command */
42277 spin_unlock_irqrestore(&h->lock, flags);
42278 - h->access.submit_command(h, c);
42279 + h->access->submit_command(h, c);
42280 spin_lock_irqsave(&h->lock, flags);
42281 }
42282 spin_unlock_irqrestore(&h->lock, flags);
42283 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42284
42285 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42286 {
42287 - return h->access.command_completed(h, q);
42288 + return h->access->command_completed(h, q);
42289 }
42290
42291 static inline bool interrupt_pending(struct ctlr_info *h)
42292 {
42293 - return h->access.intr_pending(h);
42294 + return h->access->intr_pending(h);
42295 }
42296
42297 static inline long interrupt_not_for_us(struct ctlr_info *h)
42298 {
42299 - return (h->access.intr_pending(h) == 0) ||
42300 + return (h->access->intr_pending(h) == 0) ||
42301 (h->interrupts_enabled == 0);
42302 }
42303
42304 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42305 if (prod_index < 0)
42306 return -ENODEV;
42307 h->product_name = products[prod_index].product_name;
42308 - h->access = *(products[prod_index].access);
42309 + h->access = products[prod_index].access;
42310
42311 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42312 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42313 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42314
42315 assert_spin_locked(&lockup_detector_lock);
42316 remove_ctlr_from_lockup_detector_list(h);
42317 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42318 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42319 spin_lock_irqsave(&h->lock, flags);
42320 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42321 spin_unlock_irqrestore(&h->lock, flags);
42322 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42323 }
42324
42325 /* make sure the board interrupts are off */
42326 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42327 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42328
42329 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42330 goto clean2;
42331 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42332 * fake ones to scoop up any residual completions.
42333 */
42334 spin_lock_irqsave(&h->lock, flags);
42335 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42336 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42337 spin_unlock_irqrestore(&h->lock, flags);
42338 free_irqs(h);
42339 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42340 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42341 dev_info(&h->pdev->dev, "Board READY.\n");
42342 dev_info(&h->pdev->dev,
42343 "Waiting for stale completions to drain.\n");
42344 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42345 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42346 msleep(10000);
42347 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42348 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42349
42350 rc = controller_reset_failed(h->cfgtable);
42351 if (rc)
42352 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42353 }
42354
42355 /* Turn the interrupts on so we can service requests */
42356 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42357 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42358
42359 hpsa_hba_inquiry(h);
42360 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42361 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42362 * To write all data in the battery backed cache to disks
42363 */
42364 hpsa_flush_cache(h);
42365 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42366 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42367 hpsa_free_irqs_and_disable_msix(h);
42368 }
42369
42370 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42371 return;
42372 }
42373 /* Change the access methods to the performant access methods */
42374 - h->access = SA5_performant_access;
42375 + h->access = &SA5_performant_access;
42376 h->transMethod = CFGTBL_Trans_Performant;
42377 }
42378
42379 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42380 index 9816479..c5d4e97 100644
42381 --- a/drivers/scsi/hpsa.h
42382 +++ b/drivers/scsi/hpsa.h
42383 @@ -79,7 +79,7 @@ struct ctlr_info {
42384 unsigned int msix_vector;
42385 unsigned int msi_vector;
42386 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42387 - struct access_method access;
42388 + struct access_method *access;
42389
42390 /* queue and queue Info */
42391 struct list_head reqQ;
42392 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42393 index 8b928c6..9c76300 100644
42394 --- a/drivers/scsi/libfc/fc_exch.c
42395 +++ b/drivers/scsi/libfc/fc_exch.c
42396 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42397 u16 pool_max_index;
42398
42399 struct {
42400 - atomic_t no_free_exch;
42401 - atomic_t no_free_exch_xid;
42402 - atomic_t xid_not_found;
42403 - atomic_t xid_busy;
42404 - atomic_t seq_not_found;
42405 - atomic_t non_bls_resp;
42406 + atomic_unchecked_t no_free_exch;
42407 + atomic_unchecked_t no_free_exch_xid;
42408 + atomic_unchecked_t xid_not_found;
42409 + atomic_unchecked_t xid_busy;
42410 + atomic_unchecked_t seq_not_found;
42411 + atomic_unchecked_t non_bls_resp;
42412 } stats;
42413 };
42414
42415 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42416 /* allocate memory for exchange */
42417 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42418 if (!ep) {
42419 - atomic_inc(&mp->stats.no_free_exch);
42420 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42421 goto out;
42422 }
42423 memset(ep, 0, sizeof(*ep));
42424 @@ -797,7 +797,7 @@ out:
42425 return ep;
42426 err:
42427 spin_unlock_bh(&pool->lock);
42428 - atomic_inc(&mp->stats.no_free_exch_xid);
42429 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42430 mempool_free(ep, mp->ep_pool);
42431 return NULL;
42432 }
42433 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42434 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42435 ep = fc_exch_find(mp, xid);
42436 if (!ep) {
42437 - atomic_inc(&mp->stats.xid_not_found);
42438 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42439 reject = FC_RJT_OX_ID;
42440 goto out;
42441 }
42442 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42443 ep = fc_exch_find(mp, xid);
42444 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42445 if (ep) {
42446 - atomic_inc(&mp->stats.xid_busy);
42447 + atomic_inc_unchecked(&mp->stats.xid_busy);
42448 reject = FC_RJT_RX_ID;
42449 goto rel;
42450 }
42451 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42452 }
42453 xid = ep->xid; /* get our XID */
42454 } else if (!ep) {
42455 - atomic_inc(&mp->stats.xid_not_found);
42456 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42457 reject = FC_RJT_RX_ID; /* XID not found */
42458 goto out;
42459 }
42460 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42461 } else {
42462 sp = &ep->seq;
42463 if (sp->id != fh->fh_seq_id) {
42464 - atomic_inc(&mp->stats.seq_not_found);
42465 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42466 if (f_ctl & FC_FC_END_SEQ) {
42467 /*
42468 * Update sequence_id based on incoming last
42469 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42470
42471 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42472 if (!ep) {
42473 - atomic_inc(&mp->stats.xid_not_found);
42474 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42475 goto out;
42476 }
42477 if (ep->esb_stat & ESB_ST_COMPLETE) {
42478 - atomic_inc(&mp->stats.xid_not_found);
42479 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42480 goto rel;
42481 }
42482 if (ep->rxid == FC_XID_UNKNOWN)
42483 ep->rxid = ntohs(fh->fh_rx_id);
42484 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42485 - atomic_inc(&mp->stats.xid_not_found);
42486 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42487 goto rel;
42488 }
42489 if (ep->did != ntoh24(fh->fh_s_id) &&
42490 ep->did != FC_FID_FLOGI) {
42491 - atomic_inc(&mp->stats.xid_not_found);
42492 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42493 goto rel;
42494 }
42495 sof = fr_sof(fp);
42496 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42497 sp->ssb_stat |= SSB_ST_RESP;
42498 sp->id = fh->fh_seq_id;
42499 } else if (sp->id != fh->fh_seq_id) {
42500 - atomic_inc(&mp->stats.seq_not_found);
42501 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42502 goto rel;
42503 }
42504
42505 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42506 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42507
42508 if (!sp)
42509 - atomic_inc(&mp->stats.xid_not_found);
42510 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42511 else
42512 - atomic_inc(&mp->stats.non_bls_resp);
42513 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42514
42515 fc_frame_free(fp);
42516 }
42517 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42518
42519 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42520 mp = ema->mp;
42521 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42522 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42523 st->fc_no_free_exch_xid +=
42524 - atomic_read(&mp->stats.no_free_exch_xid);
42525 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42526 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42527 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42528 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42529 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42530 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42531 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42532 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42533 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42534 }
42535 }
42536 EXPORT_SYMBOL(fc_exch_update_stats);
42537 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42538 index 161c98e..6d563b3 100644
42539 --- a/drivers/scsi/libsas/sas_ata.c
42540 +++ b/drivers/scsi/libsas/sas_ata.c
42541 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42542 .postreset = ata_std_postreset,
42543 .error_handler = ata_std_error_handler,
42544 .post_internal_cmd = sas_ata_post_internal,
42545 - .qc_defer = ata_std_qc_defer,
42546 + .qc_defer = ata_std_qc_defer,
42547 .qc_prep = ata_noop_qc_prep,
42548 .qc_issue = sas_ata_qc_issue,
42549 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42550 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42551 index bcc56ca..6f4174a 100644
42552 --- a/drivers/scsi/lpfc/lpfc.h
42553 +++ b/drivers/scsi/lpfc/lpfc.h
42554 @@ -431,7 +431,7 @@ struct lpfc_vport {
42555 struct dentry *debug_nodelist;
42556 struct dentry *vport_debugfs_root;
42557 struct lpfc_debugfs_trc *disc_trc;
42558 - atomic_t disc_trc_cnt;
42559 + atomic_unchecked_t disc_trc_cnt;
42560 #endif
42561 uint8_t stat_data_enabled;
42562 uint8_t stat_data_blocked;
42563 @@ -865,8 +865,8 @@ struct lpfc_hba {
42564 struct timer_list fabric_block_timer;
42565 unsigned long bit_flags;
42566 #define FABRIC_COMANDS_BLOCKED 0
42567 - atomic_t num_rsrc_err;
42568 - atomic_t num_cmd_success;
42569 + atomic_unchecked_t num_rsrc_err;
42570 + atomic_unchecked_t num_cmd_success;
42571 unsigned long last_rsrc_error_time;
42572 unsigned long last_ramp_down_time;
42573 unsigned long last_ramp_up_time;
42574 @@ -902,7 +902,7 @@ struct lpfc_hba {
42575
42576 struct dentry *debug_slow_ring_trc;
42577 struct lpfc_debugfs_trc *slow_ring_trc;
42578 - atomic_t slow_ring_trc_cnt;
42579 + atomic_unchecked_t slow_ring_trc_cnt;
42580 /* iDiag debugfs sub-directory */
42581 struct dentry *idiag_root;
42582 struct dentry *idiag_pci_cfg;
42583 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42584 index f525ecb..32549a4 100644
42585 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42586 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42587 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42588
42589 #include <linux/debugfs.h>
42590
42591 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42592 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42593 static unsigned long lpfc_debugfs_start_time = 0L;
42594
42595 /* iDiag */
42596 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42597 lpfc_debugfs_enable = 0;
42598
42599 len = 0;
42600 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42601 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42602 (lpfc_debugfs_max_disc_trc - 1);
42603 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42604 dtp = vport->disc_trc + i;
42605 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42606 lpfc_debugfs_enable = 0;
42607
42608 len = 0;
42609 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42610 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42611 (lpfc_debugfs_max_slow_ring_trc - 1);
42612 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42613 dtp = phba->slow_ring_trc + i;
42614 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42615 !vport || !vport->disc_trc)
42616 return;
42617
42618 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42619 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42620 (lpfc_debugfs_max_disc_trc - 1);
42621 dtp = vport->disc_trc + index;
42622 dtp->fmt = fmt;
42623 dtp->data1 = data1;
42624 dtp->data2 = data2;
42625 dtp->data3 = data3;
42626 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42627 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42628 dtp->jif = jiffies;
42629 #endif
42630 return;
42631 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42632 !phba || !phba->slow_ring_trc)
42633 return;
42634
42635 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42636 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42637 (lpfc_debugfs_max_slow_ring_trc - 1);
42638 dtp = phba->slow_ring_trc + index;
42639 dtp->fmt = fmt;
42640 dtp->data1 = data1;
42641 dtp->data2 = data2;
42642 dtp->data3 = data3;
42643 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42644 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42645 dtp->jif = jiffies;
42646 #endif
42647 return;
42648 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42649 "slow_ring buffer\n");
42650 goto debug_failed;
42651 }
42652 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42653 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42654 memset(phba->slow_ring_trc, 0,
42655 (sizeof(struct lpfc_debugfs_trc) *
42656 lpfc_debugfs_max_slow_ring_trc));
42657 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42658 "buffer\n");
42659 goto debug_failed;
42660 }
42661 - atomic_set(&vport->disc_trc_cnt, 0);
42662 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42663
42664 snprintf(name, sizeof(name), "discovery_trace");
42665 vport->debug_disc_trc =
42666 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42667 index cb465b2..2e7b25f 100644
42668 --- a/drivers/scsi/lpfc/lpfc_init.c
42669 +++ b/drivers/scsi/lpfc/lpfc_init.c
42670 @@ -10950,8 +10950,10 @@ lpfc_init(void)
42671 "misc_register returned with status %d", error);
42672
42673 if (lpfc_enable_npiv) {
42674 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42675 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42676 + pax_open_kernel();
42677 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42678 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42679 + pax_close_kernel();
42680 }
42681 lpfc_transport_template =
42682 fc_attach_transport(&lpfc_transport_functions);
42683 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42684 index 8523b278e..ce1d812 100644
42685 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42686 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42687 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42688 uint32_t evt_posted;
42689
42690 spin_lock_irqsave(&phba->hbalock, flags);
42691 - atomic_inc(&phba->num_rsrc_err);
42692 + atomic_inc_unchecked(&phba->num_rsrc_err);
42693 phba->last_rsrc_error_time = jiffies;
42694
42695 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42696 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42697 unsigned long flags;
42698 struct lpfc_hba *phba = vport->phba;
42699 uint32_t evt_posted;
42700 - atomic_inc(&phba->num_cmd_success);
42701 + atomic_inc_unchecked(&phba->num_cmd_success);
42702
42703 if (vport->cfg_lun_queue_depth <= queue_depth)
42704 return;
42705 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42706 unsigned long num_rsrc_err, num_cmd_success;
42707 int i;
42708
42709 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42710 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42711 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42712 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42713
42714 /*
42715 * The error and success command counters are global per
42716 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42717 }
42718 }
42719 lpfc_destroy_vport_work_array(phba, vports);
42720 - atomic_set(&phba->num_rsrc_err, 0);
42721 - atomic_set(&phba->num_cmd_success, 0);
42722 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42723 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42724 }
42725
42726 /**
42727 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42728 }
42729 }
42730 lpfc_destroy_vport_work_array(phba, vports);
42731 - atomic_set(&phba->num_rsrc_err, 0);
42732 - atomic_set(&phba->num_cmd_success, 0);
42733 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42734 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42735 }
42736
42737 /**
42738 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42739 index 8e1b737..50ff510 100644
42740 --- a/drivers/scsi/pmcraid.c
42741 +++ b/drivers/scsi/pmcraid.c
42742 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42743 res->scsi_dev = scsi_dev;
42744 scsi_dev->hostdata = res;
42745 res->change_detected = 0;
42746 - atomic_set(&res->read_failures, 0);
42747 - atomic_set(&res->write_failures, 0);
42748 + atomic_set_unchecked(&res->read_failures, 0);
42749 + atomic_set_unchecked(&res->write_failures, 0);
42750 rc = 0;
42751 }
42752 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42753 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42754
42755 /* If this was a SCSI read/write command keep count of errors */
42756 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42757 - atomic_inc(&res->read_failures);
42758 + atomic_inc_unchecked(&res->read_failures);
42759 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42760 - atomic_inc(&res->write_failures);
42761 + atomic_inc_unchecked(&res->write_failures);
42762
42763 if (!RES_IS_GSCSI(res->cfg_entry) &&
42764 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42765 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42766 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42767 * hrrq_id assigned here in queuecommand
42768 */
42769 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42770 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42771 pinstance->num_hrrq;
42772 cmd->cmd_done = pmcraid_io_done;
42773
42774 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
42775 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42776 * hrrq_id assigned here in queuecommand
42777 */
42778 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42779 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42780 pinstance->num_hrrq;
42781
42782 if (request_size) {
42783 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42784
42785 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42786 /* add resources only after host is added into system */
42787 - if (!atomic_read(&pinstance->expose_resources))
42788 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42789 return;
42790
42791 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42792 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42793 init_waitqueue_head(&pinstance->reset_wait_q);
42794
42795 atomic_set(&pinstance->outstanding_cmds, 0);
42796 - atomic_set(&pinstance->last_message_id, 0);
42797 - atomic_set(&pinstance->expose_resources, 0);
42798 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42799 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42800
42801 INIT_LIST_HEAD(&pinstance->free_res_q);
42802 INIT_LIST_HEAD(&pinstance->used_res_q);
42803 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42804 /* Schedule worker thread to handle CCN and take care of adding and
42805 * removing devices to OS
42806 */
42807 - atomic_set(&pinstance->expose_resources, 1);
42808 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42809 schedule_work(&pinstance->worker_q);
42810 return rc;
42811
42812 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42813 index e1d150f..6c6df44 100644
42814 --- a/drivers/scsi/pmcraid.h
42815 +++ b/drivers/scsi/pmcraid.h
42816 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42817 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42818
42819 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42820 - atomic_t last_message_id;
42821 + atomic_unchecked_t last_message_id;
42822
42823 /* configuration table */
42824 struct pmcraid_config_table *cfg_table;
42825 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42826 atomic_t outstanding_cmds;
42827
42828 /* should add/delete resources to mid-layer now ?*/
42829 - atomic_t expose_resources;
42830 + atomic_unchecked_t expose_resources;
42831
42832
42833
42834 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42835 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42836 };
42837 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42838 - atomic_t read_failures; /* count of failed READ commands */
42839 - atomic_t write_failures; /* count of failed WRITE commands */
42840 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42841 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42842
42843 /* To indicate add/delete/modify during CCN */
42844 u8 change_detected;
42845 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42846 index bf60c63..74d4dce 100644
42847 --- a/drivers/scsi/qla2xxx/qla_attr.c
42848 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42849 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42850 return 0;
42851 }
42852
42853 -struct fc_function_template qla2xxx_transport_functions = {
42854 +fc_function_template_no_const qla2xxx_transport_functions = {
42855
42856 .show_host_node_name = 1,
42857 .show_host_port_name = 1,
42858 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42859 .bsg_timeout = qla24xx_bsg_timeout,
42860 };
42861
42862 -struct fc_function_template qla2xxx_transport_vport_functions = {
42863 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42864
42865 .show_host_node_name = 1,
42866 .show_host_port_name = 1,
42867 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42868 index 026bfde..90c4018 100644
42869 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42870 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42871 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42872 struct device_attribute;
42873 extern struct device_attribute *qla2x00_host_attrs[];
42874 struct fc_function_template;
42875 -extern struct fc_function_template qla2xxx_transport_functions;
42876 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42877 +extern fc_function_template_no_const qla2xxx_transport_functions;
42878 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42879 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42880 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42881 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42882 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42883 index ad72c1d..afc9a98 100644
42884 --- a/drivers/scsi/qla2xxx/qla_os.c
42885 +++ b/drivers/scsi/qla2xxx/qla_os.c
42886 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42887 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42888 /* Ok, a 64bit DMA mask is applicable. */
42889 ha->flags.enable_64bit_addressing = 1;
42890 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42891 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42892 + pax_open_kernel();
42893 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42894 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42895 + pax_close_kernel();
42896 return;
42897 }
42898 }
42899 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42900 index ddf16a8..80f4dd0 100644
42901 --- a/drivers/scsi/qla4xxx/ql4_def.h
42902 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42903 @@ -291,7 +291,7 @@ struct ddb_entry {
42904 * (4000 only) */
42905 atomic_t relogin_timer; /* Max Time to wait for
42906 * relogin to complete */
42907 - atomic_t relogin_retry_count; /* Num of times relogin has been
42908 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42909 * retried */
42910 uint32_t default_time2wait; /* Default Min time between
42911 * relogins (+aens) */
42912 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42913 index 4d231c1..2892c37 100644
42914 --- a/drivers/scsi/qla4xxx/ql4_os.c
42915 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42916 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42917 */
42918 if (!iscsi_is_session_online(cls_sess)) {
42919 /* Reset retry relogin timer */
42920 - atomic_inc(&ddb_entry->relogin_retry_count);
42921 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42922 DEBUG2(ql4_printk(KERN_INFO, ha,
42923 "%s: index[%d] relogin timed out-retrying"
42924 " relogin (%d), retry (%d)\n", __func__,
42925 ddb_entry->fw_ddb_index,
42926 - atomic_read(&ddb_entry->relogin_retry_count),
42927 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42928 ddb_entry->default_time2wait + 4));
42929 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42930 atomic_set(&ddb_entry->retry_relogin_timer,
42931 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42932
42933 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42934 atomic_set(&ddb_entry->relogin_timer, 0);
42935 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42936 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42937 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42938 ddb_entry->default_relogin_timeout =
42939 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42940 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42941 index 3b1ea34..1583a72 100644
42942 --- a/drivers/scsi/scsi.c
42943 +++ b/drivers/scsi/scsi.c
42944 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42945 unsigned long timeout;
42946 int rtn = 0;
42947
42948 - atomic_inc(&cmd->device->iorequest_cnt);
42949 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42950
42951 /* check if the device is still usable */
42952 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42953 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42954 index 86d5220..f22c51a 100644
42955 --- a/drivers/scsi/scsi_lib.c
42956 +++ b/drivers/scsi/scsi_lib.c
42957 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42958 shost = sdev->host;
42959 scsi_init_cmd_errh(cmd);
42960 cmd->result = DID_NO_CONNECT << 16;
42961 - atomic_inc(&cmd->device->iorequest_cnt);
42962 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42963
42964 /*
42965 * SCSI request completion path will do scsi_device_unbusy(),
42966 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
42967
42968 INIT_LIST_HEAD(&cmd->eh_entry);
42969
42970 - atomic_inc(&cmd->device->iodone_cnt);
42971 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42972 if (cmd->result)
42973 - atomic_inc(&cmd->device->ioerr_cnt);
42974 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42975
42976 disposition = scsi_decide_disposition(cmd);
42977 if (disposition != SUCCESS &&
42978 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42979 index 931a7d9..0c2a754 100644
42980 --- a/drivers/scsi/scsi_sysfs.c
42981 +++ b/drivers/scsi/scsi_sysfs.c
42982 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42983 char *buf) \
42984 { \
42985 struct scsi_device *sdev = to_scsi_device(dev); \
42986 - unsigned long long count = atomic_read(&sdev->field); \
42987 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42988 return snprintf(buf, 20, "0x%llx\n", count); \
42989 } \
42990 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42991 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42992 index 84a1fdf..693b0d6 100644
42993 --- a/drivers/scsi/scsi_tgt_lib.c
42994 +++ b/drivers/scsi/scsi_tgt_lib.c
42995 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42996 int err;
42997
42998 dprintk("%lx %u\n", uaddr, len);
42999 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
43000 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
43001 if (err) {
43002 /*
43003 * TODO: need to fixup sg_tablesize, max_segment_size,
43004 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
43005 index e106c27..11a380e 100644
43006 --- a/drivers/scsi/scsi_transport_fc.c
43007 +++ b/drivers/scsi/scsi_transport_fc.c
43008 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
43009 * Netlink Infrastructure
43010 */
43011
43012 -static atomic_t fc_event_seq;
43013 +static atomic_unchecked_t fc_event_seq;
43014
43015 /**
43016 * fc_get_event_number - Obtain the next sequential FC event number
43017 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
43018 u32
43019 fc_get_event_number(void)
43020 {
43021 - return atomic_add_return(1, &fc_event_seq);
43022 + return atomic_add_return_unchecked(1, &fc_event_seq);
43023 }
43024 EXPORT_SYMBOL(fc_get_event_number);
43025
43026 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
43027 {
43028 int error;
43029
43030 - atomic_set(&fc_event_seq, 0);
43031 + atomic_set_unchecked(&fc_event_seq, 0);
43032
43033 error = transport_class_register(&fc_host_class);
43034 if (error)
43035 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
43036 char *cp;
43037
43038 *val = simple_strtoul(buf, &cp, 0);
43039 - if ((*cp && (*cp != '\n')) || (*val < 0))
43040 + if (*cp && (*cp != '\n'))
43041 return -EINVAL;
43042 /*
43043 * Check for overflow; dev_loss_tmo is u32
43044 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
43045 index 133926b..903000d 100644
43046 --- a/drivers/scsi/scsi_transport_iscsi.c
43047 +++ b/drivers/scsi/scsi_transport_iscsi.c
43048 @@ -80,7 +80,7 @@ struct iscsi_internal {
43049 struct transport_container session_cont;
43050 };
43051
43052 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
43053 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
43054 static struct workqueue_struct *iscsi_eh_timer_workq;
43055
43056 static DEFINE_IDA(iscsi_sess_ida);
43057 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
43058 int err;
43059
43060 ihost = shost->shost_data;
43061 - session->sid = atomic_add_return(1, &iscsi_session_nr);
43062 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
43063
43064 if (target_id == ISCSI_MAX_TARGET) {
43065 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
43066 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
43067 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
43068 ISCSI_TRANSPORT_VERSION);
43069
43070 - atomic_set(&iscsi_session_nr, 0);
43071 + atomic_set_unchecked(&iscsi_session_nr, 0);
43072
43073 err = class_register(&iscsi_transport_class);
43074 if (err)
43075 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
43076 index f379c7f..e8fc69c 100644
43077 --- a/drivers/scsi/scsi_transport_srp.c
43078 +++ b/drivers/scsi/scsi_transport_srp.c
43079 @@ -33,7 +33,7 @@
43080 #include "scsi_transport_srp_internal.h"
43081
43082 struct srp_host_attrs {
43083 - atomic_t next_port_id;
43084 + atomic_unchecked_t next_port_id;
43085 };
43086 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
43087
43088 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
43089 struct Scsi_Host *shost = dev_to_shost(dev);
43090 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
43091
43092 - atomic_set(&srp_host->next_port_id, 0);
43093 + atomic_set_unchecked(&srp_host->next_port_id, 0);
43094 return 0;
43095 }
43096
43097 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
43098 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
43099 rport->roles = ids->roles;
43100
43101 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
43102 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
43103 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
43104
43105 transport_setup_device(&rport->dev);
43106 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
43107 index 610417e..1544fa9 100644
43108 --- a/drivers/scsi/sd.c
43109 +++ b/drivers/scsi/sd.c
43110 @@ -2928,7 +2928,7 @@ static int sd_probe(struct device *dev)
43111 sdkp->disk = gd;
43112 sdkp->index = index;
43113 atomic_set(&sdkp->openers, 0);
43114 - atomic_set(&sdkp->device->ioerr_cnt, 0);
43115 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
43116
43117 if (!sdp->request_queue->rq_timeout) {
43118 if (sdp->type != TYPE_MOD)
43119 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
43120 index df5e961..df6b97f 100644
43121 --- a/drivers/scsi/sg.c
43122 +++ b/drivers/scsi/sg.c
43123 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
43124 sdp->disk->disk_name,
43125 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
43126 NULL,
43127 - (char *)arg);
43128 + (char __user *)arg);
43129 case BLKTRACESTART:
43130 return blk_trace_startstop(sdp->device->request_queue, 1);
43131 case BLKTRACESTOP:
43132 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
43133 index 32b7bb1..2f1c4bd 100644
43134 --- a/drivers/spi/spi.c
43135 +++ b/drivers/spi/spi.c
43136 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
43137 EXPORT_SYMBOL_GPL(spi_bus_unlock);
43138
43139 /* portable code must never pass more than 32 bytes */
43140 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
43141 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
43142
43143 static u8 *buf;
43144
43145 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
43146 index 3675020..e80d92c 100644
43147 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
43148 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
43149 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
43150
43151 static int solo_sysfs_init(struct solo_dev *solo_dev)
43152 {
43153 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
43154 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
43155 struct device *dev = &solo_dev->dev;
43156 const char *driver;
43157 int i;
43158 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
43159 index 34afc16..ffe44dd 100644
43160 --- a/drivers/staging/octeon/ethernet-rx.c
43161 +++ b/drivers/staging/octeon/ethernet-rx.c
43162 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43163 /* Increment RX stats for virtual ports */
43164 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
43165 #ifdef CONFIG_64BIT
43166 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
43167 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
43168 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
43169 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
43170 #else
43171 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
43172 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
43173 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
43174 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
43175 #endif
43176 }
43177 netif_receive_skb(skb);
43178 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43179 dev->name);
43180 */
43181 #ifdef CONFIG_64BIT
43182 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
43183 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43184 #else
43185 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
43186 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
43187 #endif
43188 dev_kfree_skb_irq(skb);
43189 }
43190 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
43191 index c3a90e7..023619a 100644
43192 --- a/drivers/staging/octeon/ethernet.c
43193 +++ b/drivers/staging/octeon/ethernet.c
43194 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
43195 * since the RX tasklet also increments it.
43196 */
43197 #ifdef CONFIG_64BIT
43198 - atomic64_add(rx_status.dropped_packets,
43199 - (atomic64_t *)&priv->stats.rx_dropped);
43200 + atomic64_add_unchecked(rx_status.dropped_packets,
43201 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43202 #else
43203 - atomic_add(rx_status.dropped_packets,
43204 - (atomic_t *)&priv->stats.rx_dropped);
43205 + atomic_add_unchecked(rx_status.dropped_packets,
43206 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
43207 #endif
43208 }
43209
43210 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43211 index dc23395..cf7e9b1 100644
43212 --- a/drivers/staging/rtl8712/rtl871x_io.h
43213 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43214 @@ -108,7 +108,7 @@ struct _io_ops {
43215 u8 *pmem);
43216 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43217 u8 *pmem);
43218 -};
43219 +} __no_const;
43220
43221 struct io_req {
43222 struct list_head list;
43223 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43224 index 1f5088b..0e59820 100644
43225 --- a/drivers/staging/sbe-2t3e3/netdev.c
43226 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43227 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43228 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43229
43230 if (rlen)
43231 - if (copy_to_user(data, &resp, rlen))
43232 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43233 return -EFAULT;
43234
43235 return 0;
43236 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43237 index a863a98..d272795 100644
43238 --- a/drivers/staging/usbip/vhci.h
43239 +++ b/drivers/staging/usbip/vhci.h
43240 @@ -83,7 +83,7 @@ struct vhci_hcd {
43241 unsigned resuming:1;
43242 unsigned long re_timeout;
43243
43244 - atomic_t seqnum;
43245 + atomic_unchecked_t seqnum;
43246
43247 /*
43248 * NOTE:
43249 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43250 index d7974cb..d78076b 100644
43251 --- a/drivers/staging/usbip/vhci_hcd.c
43252 +++ b/drivers/staging/usbip/vhci_hcd.c
43253 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
43254
43255 spin_lock(&vdev->priv_lock);
43256
43257 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43258 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43259 if (priv->seqnum == 0xffff)
43260 dev_info(&urb->dev->dev, "seqnum max\n");
43261
43262 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43263 return -ENOMEM;
43264 }
43265
43266 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43267 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43268 if (unlink->seqnum == 0xffff)
43269 pr_info("seqnum max\n");
43270
43271 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43272 vdev->rhport = rhport;
43273 }
43274
43275 - atomic_set(&vhci->seqnum, 0);
43276 + atomic_set_unchecked(&vhci->seqnum, 0);
43277 spin_lock_init(&vhci->lock);
43278
43279 hcd->power_budget = 0; /* no limit */
43280 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43281 index d07fcb5..358e1e1 100644
43282 --- a/drivers/staging/usbip/vhci_rx.c
43283 +++ b/drivers/staging/usbip/vhci_rx.c
43284 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43285 if (!urb) {
43286 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43287 pr_info("max seqnum %d\n",
43288 - atomic_read(&the_controller->seqnum));
43289 + atomic_read_unchecked(&the_controller->seqnum));
43290 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43291 return;
43292 }
43293 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43294 index 8417c2f..ef5ebd6 100644
43295 --- a/drivers/staging/vt6655/hostap.c
43296 +++ b/drivers/staging/vt6655/hostap.c
43297 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
43298 *
43299 */
43300
43301 +static net_device_ops_no_const apdev_netdev_ops;
43302 +
43303 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43304 {
43305 PSDevice apdev_priv;
43306 struct net_device *dev = pDevice->dev;
43307 int ret;
43308 - const struct net_device_ops apdev_netdev_ops = {
43309 - .ndo_start_xmit = pDevice->tx_80211,
43310 - };
43311
43312 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43313
43314 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43315 *apdev_priv = *pDevice;
43316 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43317
43318 + /* only half broken now */
43319 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43320 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43321
43322 pDevice->apdev->type = ARPHRD_IEEE80211;
43323 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43324 index c699a30..b90a5fd 100644
43325 --- a/drivers/staging/vt6656/hostap.c
43326 +++ b/drivers/staging/vt6656/hostap.c
43327 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43328 *
43329 */
43330
43331 +static net_device_ops_no_const apdev_netdev_ops;
43332 +
43333 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43334 {
43335 struct vnt_private *apdev_priv;
43336 struct net_device *dev = pDevice->dev;
43337 int ret;
43338 - const struct net_device_ops apdev_netdev_ops = {
43339 - .ndo_start_xmit = pDevice->tx_80211,
43340 - };
43341
43342 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43343
43344 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43345 *apdev_priv = *pDevice;
43346 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43347
43348 + /* only half broken now */
43349 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43350 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43351
43352 pDevice->apdev->type = ARPHRD_IEEE80211;
43353 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43354 index d7e51e4..d07eaab 100644
43355 --- a/drivers/staging/zcache/tmem.c
43356 +++ b/drivers/staging/zcache/tmem.c
43357 @@ -51,7 +51,7 @@
43358 * A tmem host implementation must use this function to register callbacks
43359 * for memory allocation.
43360 */
43361 -static struct tmem_hostops tmem_hostops;
43362 +static tmem_hostops_no_const tmem_hostops;
43363
43364 static void tmem_objnode_tree_init(void);
43365
43366 @@ -65,7 +65,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43367 * A tmem host implementation must use this function to register
43368 * callbacks for a page-accessible memory (PAM) implementation.
43369 */
43370 -static struct tmem_pamops tmem_pamops;
43371 +static tmem_pamops_no_const tmem_pamops;
43372
43373 void tmem_register_pamops(struct tmem_pamops *m)
43374 {
43375 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43376 index d128ce2..a43980c 100644
43377 --- a/drivers/staging/zcache/tmem.h
43378 +++ b/drivers/staging/zcache/tmem.h
43379 @@ -226,6 +226,7 @@ struct tmem_pamops {
43380 int (*replace_in_obj)(void *, struct tmem_obj *);
43381 #endif
43382 };
43383 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43384 extern void tmem_register_pamops(struct tmem_pamops *m);
43385
43386 /* memory allocation methods provided by the host implementation */
43387 @@ -235,6 +236,7 @@ struct tmem_hostops {
43388 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43389 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43390 };
43391 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43392 extern void tmem_register_hostops(struct tmem_hostops *m);
43393
43394 /* core tmem accessor functions */
43395 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43396 index 4630481..c26782a 100644
43397 --- a/drivers/target/target_core_device.c
43398 +++ b/drivers/target/target_core_device.c
43399 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43400 spin_lock_init(&dev->se_port_lock);
43401 spin_lock_init(&dev->se_tmr_lock);
43402 spin_lock_init(&dev->qf_cmd_lock);
43403 - atomic_set(&dev->dev_ordered_id, 0);
43404 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43405 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43406 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43407 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43408 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43409 index 21e3158..43c6004 100644
43410 --- a/drivers/target/target_core_transport.c
43411 +++ b/drivers/target/target_core_transport.c
43412 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43413 * Used to determine when ORDERED commands should go from
43414 * Dormant to Active status.
43415 */
43416 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43417 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43418 smp_mb__after_atomic_inc();
43419 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43420 cmd->se_ordered_id, cmd->sam_task_attr,
43421 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43422 index 33f83fe..d80f8e1 100644
43423 --- a/drivers/tty/cyclades.c
43424 +++ b/drivers/tty/cyclades.c
43425 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43426 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43427 info->port.count);
43428 #endif
43429 - info->port.count++;
43430 + atomic_inc(&info->port.count);
43431 #ifdef CY_DEBUG_COUNT
43432 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43433 - current->pid, info->port.count);
43434 + current->pid, atomic_read(&info->port.count));
43435 #endif
43436
43437 /*
43438 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43439 for (j = 0; j < cy_card[i].nports; j++) {
43440 info = &cy_card[i].ports[j];
43441
43442 - if (info->port.count) {
43443 + if (atomic_read(&info->port.count)) {
43444 /* XXX is the ldisc num worth this? */
43445 struct tty_struct *tty;
43446 struct tty_ldisc *ld;
43447 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43448 index eb255e8..f637a57 100644
43449 --- a/drivers/tty/hvc/hvc_console.c
43450 +++ b/drivers/tty/hvc/hvc_console.c
43451 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43452
43453 spin_lock_irqsave(&hp->port.lock, flags);
43454 /* Check and then increment for fast path open. */
43455 - if (hp->port.count++ > 0) {
43456 + if (atomic_inc_return(&hp->port.count) > 1) {
43457 spin_unlock_irqrestore(&hp->port.lock, flags);
43458 hvc_kick();
43459 return 0;
43460 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43461
43462 spin_lock_irqsave(&hp->port.lock, flags);
43463
43464 - if (--hp->port.count == 0) {
43465 + if (atomic_dec_return(&hp->port.count) == 0) {
43466 spin_unlock_irqrestore(&hp->port.lock, flags);
43467 /* We are done with the tty pointer now. */
43468 tty_port_tty_set(&hp->port, NULL);
43469 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43470 */
43471 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43472 } else {
43473 - if (hp->port.count < 0)
43474 + if (atomic_read(&hp->port.count) < 0)
43475 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43476 - hp->vtermno, hp->port.count);
43477 + hp->vtermno, atomic_read(&hp->port.count));
43478 spin_unlock_irqrestore(&hp->port.lock, flags);
43479 }
43480 }
43481 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43482 * open->hangup case this can be called after the final close so prevent
43483 * that from happening for now.
43484 */
43485 - if (hp->port.count <= 0) {
43486 + if (atomic_read(&hp->port.count) <= 0) {
43487 spin_unlock_irqrestore(&hp->port.lock, flags);
43488 return;
43489 }
43490
43491 - hp->port.count = 0;
43492 + atomic_set(&hp->port.count, 0);
43493 spin_unlock_irqrestore(&hp->port.lock, flags);
43494 tty_port_tty_set(&hp->port, NULL);
43495
43496 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43497 return -EPIPE;
43498
43499 /* FIXME what's this (unprotected) check for? */
43500 - if (hp->port.count <= 0)
43501 + if (atomic_read(&hp->port.count) <= 0)
43502 return -EIO;
43503
43504 spin_lock_irqsave(&hp->lock, flags);
43505 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43506 index 81e939e..95ead10 100644
43507 --- a/drivers/tty/hvc/hvcs.c
43508 +++ b/drivers/tty/hvc/hvcs.c
43509 @@ -83,6 +83,7 @@
43510 #include <asm/hvcserver.h>
43511 #include <asm/uaccess.h>
43512 #include <asm/vio.h>
43513 +#include <asm/local.h>
43514
43515 /*
43516 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43517 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43518
43519 spin_lock_irqsave(&hvcsd->lock, flags);
43520
43521 - if (hvcsd->port.count > 0) {
43522 + if (atomic_read(&hvcsd->port.count) > 0) {
43523 spin_unlock_irqrestore(&hvcsd->lock, flags);
43524 printk(KERN_INFO "HVCS: vterm state unchanged. "
43525 "The hvcs device node is still in use.\n");
43526 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43527 }
43528 }
43529
43530 - hvcsd->port.count = 0;
43531 + atomic_set(&hvcsd->port.count, 0);
43532 hvcsd->port.tty = tty;
43533 tty->driver_data = hvcsd;
43534
43535 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43536 unsigned long flags;
43537
43538 spin_lock_irqsave(&hvcsd->lock, flags);
43539 - hvcsd->port.count++;
43540 + atomic_inc(&hvcsd->port.count);
43541 hvcsd->todo_mask |= HVCS_SCHED_READ;
43542 spin_unlock_irqrestore(&hvcsd->lock, flags);
43543
43544 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43545 hvcsd = tty->driver_data;
43546
43547 spin_lock_irqsave(&hvcsd->lock, flags);
43548 - if (--hvcsd->port.count == 0) {
43549 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43550
43551 vio_disable_interrupts(hvcsd->vdev);
43552
43553 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43554
43555 free_irq(irq, hvcsd);
43556 return;
43557 - } else if (hvcsd->port.count < 0) {
43558 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43559 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43560 " is missmanaged.\n",
43561 - hvcsd->vdev->unit_address, hvcsd->port.count);
43562 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43563 }
43564
43565 spin_unlock_irqrestore(&hvcsd->lock, flags);
43566 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43567
43568 spin_lock_irqsave(&hvcsd->lock, flags);
43569 /* Preserve this so that we know how many kref refs to put */
43570 - temp_open_count = hvcsd->port.count;
43571 + temp_open_count = atomic_read(&hvcsd->port.count);
43572
43573 /*
43574 * Don't kref put inside the spinlock because the destruction
43575 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43576 tty->driver_data = NULL;
43577 hvcsd->port.tty = NULL;
43578
43579 - hvcsd->port.count = 0;
43580 + atomic_set(&hvcsd->port.count, 0);
43581
43582 /* This will drop any buffered data on the floor which is OK in a hangup
43583 * scenario. */
43584 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43585 * the middle of a write operation? This is a crummy place to do this
43586 * but we want to keep it all in the spinlock.
43587 */
43588 - if (hvcsd->port.count <= 0) {
43589 + if (atomic_read(&hvcsd->port.count) <= 0) {
43590 spin_unlock_irqrestore(&hvcsd->lock, flags);
43591 return -ENODEV;
43592 }
43593 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43594 {
43595 struct hvcs_struct *hvcsd = tty->driver_data;
43596
43597 - if (!hvcsd || hvcsd->port.count <= 0)
43598 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43599 return 0;
43600
43601 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43602 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43603 index 8fd72ff..34a0bed 100644
43604 --- a/drivers/tty/ipwireless/tty.c
43605 +++ b/drivers/tty/ipwireless/tty.c
43606 @@ -29,6 +29,7 @@
43607 #include <linux/tty_driver.h>
43608 #include <linux/tty_flip.h>
43609 #include <linux/uaccess.h>
43610 +#include <asm/local.h>
43611
43612 #include "tty.h"
43613 #include "network.h"
43614 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43615 mutex_unlock(&tty->ipw_tty_mutex);
43616 return -ENODEV;
43617 }
43618 - if (tty->port.count == 0)
43619 + if (atomic_read(&tty->port.count) == 0)
43620 tty->tx_bytes_queued = 0;
43621
43622 - tty->port.count++;
43623 + atomic_inc(&tty->port.count);
43624
43625 tty->port.tty = linux_tty;
43626 linux_tty->driver_data = tty;
43627 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43628
43629 static void do_ipw_close(struct ipw_tty *tty)
43630 {
43631 - tty->port.count--;
43632 -
43633 - if (tty->port.count == 0) {
43634 + if (atomic_dec_return(&tty->port.count) == 0) {
43635 struct tty_struct *linux_tty = tty->port.tty;
43636
43637 if (linux_tty != NULL) {
43638 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43639 return;
43640
43641 mutex_lock(&tty->ipw_tty_mutex);
43642 - if (tty->port.count == 0) {
43643 + if (atomic_read(&tty->port.count) == 0) {
43644 mutex_unlock(&tty->ipw_tty_mutex);
43645 return;
43646 }
43647 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43648
43649 mutex_lock(&tty->ipw_tty_mutex);
43650
43651 - if (!tty->port.count) {
43652 + if (!atomic_read(&tty->port.count)) {
43653 mutex_unlock(&tty->ipw_tty_mutex);
43654 return;
43655 }
43656 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43657 return -ENODEV;
43658
43659 mutex_lock(&tty->ipw_tty_mutex);
43660 - if (!tty->port.count) {
43661 + if (!atomic_read(&tty->port.count)) {
43662 mutex_unlock(&tty->ipw_tty_mutex);
43663 return -EINVAL;
43664 }
43665 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43666 if (!tty)
43667 return -ENODEV;
43668
43669 - if (!tty->port.count)
43670 + if (!atomic_read(&tty->port.count))
43671 return -EINVAL;
43672
43673 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43674 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43675 if (!tty)
43676 return 0;
43677
43678 - if (!tty->port.count)
43679 + if (!atomic_read(&tty->port.count))
43680 return 0;
43681
43682 return tty->tx_bytes_queued;
43683 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43684 if (!tty)
43685 return -ENODEV;
43686
43687 - if (!tty->port.count)
43688 + if (!atomic_read(&tty->port.count))
43689 return -EINVAL;
43690
43691 return get_control_lines(tty);
43692 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43693 if (!tty)
43694 return -ENODEV;
43695
43696 - if (!tty->port.count)
43697 + if (!atomic_read(&tty->port.count))
43698 return -EINVAL;
43699
43700 return set_control_lines(tty, set, clear);
43701 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43702 if (!tty)
43703 return -ENODEV;
43704
43705 - if (!tty->port.count)
43706 + if (!atomic_read(&tty->port.count))
43707 return -EINVAL;
43708
43709 /* FIXME: Exactly how is the tty object locked here .. */
43710 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43711 * are gone */
43712 mutex_lock(&ttyj->ipw_tty_mutex);
43713 }
43714 - while (ttyj->port.count)
43715 + while (atomic_read(&ttyj->port.count))
43716 do_ipw_close(ttyj);
43717 ipwireless_disassociate_network_ttys(network,
43718 ttyj->channel_idx);
43719 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43720 index 1deaca4..c8582d4 100644
43721 --- a/drivers/tty/moxa.c
43722 +++ b/drivers/tty/moxa.c
43723 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43724 }
43725
43726 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43727 - ch->port.count++;
43728 + atomic_inc(&ch->port.count);
43729 tty->driver_data = ch;
43730 tty_port_tty_set(&ch->port, tty);
43731 mutex_lock(&ch->port.mutex);
43732 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43733 index 6422390..49003ac8 100644
43734 --- a/drivers/tty/n_gsm.c
43735 +++ b/drivers/tty/n_gsm.c
43736 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43737 spin_lock_init(&dlci->lock);
43738 mutex_init(&dlci->mutex);
43739 dlci->fifo = &dlci->_fifo;
43740 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43741 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43742 kfree(dlci);
43743 return NULL;
43744 }
43745 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43746 struct gsm_dlci *dlci = tty->driver_data;
43747 struct tty_port *port = &dlci->port;
43748
43749 - port->count++;
43750 + atomic_inc(&port->count);
43751 dlci_get(dlci);
43752 dlci_get(dlci->gsm->dlci[0]);
43753 mux_get(dlci->gsm);
43754 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43755 index 6c7fe90..9241dab 100644
43756 --- a/drivers/tty/n_tty.c
43757 +++ b/drivers/tty/n_tty.c
43758 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43759 {
43760 *ops = tty_ldisc_N_TTY;
43761 ops->owner = NULL;
43762 - ops->refcount = ops->flags = 0;
43763 + atomic_set(&ops->refcount, 0);
43764 + ops->flags = 0;
43765 }
43766 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43767 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43768 index abfd990..5ab5da9 100644
43769 --- a/drivers/tty/pty.c
43770 +++ b/drivers/tty/pty.c
43771 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
43772 panic("Couldn't register Unix98 pts driver");
43773
43774 /* Now create the /dev/ptmx special device */
43775 + pax_open_kernel();
43776 tty_default_fops(&ptmx_fops);
43777 - ptmx_fops.open = ptmx_open;
43778 + *(void **)&ptmx_fops.open = ptmx_open;
43779 + pax_close_kernel();
43780
43781 cdev_init(&ptmx_cdev, &ptmx_fops);
43782 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43783 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43784 index 354564e..fe50d9a 100644
43785 --- a/drivers/tty/rocket.c
43786 +++ b/drivers/tty/rocket.c
43787 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43788 tty->driver_data = info;
43789 tty_port_tty_set(port, tty);
43790
43791 - if (port->count++ == 0) {
43792 + if (atomic_inc_return(&port->count) == 1) {
43793 atomic_inc(&rp_num_ports_open);
43794
43795 #ifdef ROCKET_DEBUG_OPEN
43796 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43797 #endif
43798 }
43799 #ifdef ROCKET_DEBUG_OPEN
43800 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43801 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43802 #endif
43803
43804 /*
43805 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
43806 spin_unlock_irqrestore(&info->port.lock, flags);
43807 return;
43808 }
43809 - if (info->port.count)
43810 + if (atomic_read(&info->port.count))
43811 atomic_dec(&rp_num_ports_open);
43812 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43813 spin_unlock_irqrestore(&info->port.lock, flags);
43814 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43815 index 1002054..dd644a8 100644
43816 --- a/drivers/tty/serial/kgdboc.c
43817 +++ b/drivers/tty/serial/kgdboc.c
43818 @@ -24,8 +24,9 @@
43819 #define MAX_CONFIG_LEN 40
43820
43821 static struct kgdb_io kgdboc_io_ops;
43822 +static struct kgdb_io kgdboc_io_ops_console;
43823
43824 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43825 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43826 static int configured = -1;
43827
43828 static char config[MAX_CONFIG_LEN];
43829 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43830 kgdboc_unregister_kbd();
43831 if (configured == 1)
43832 kgdb_unregister_io_module(&kgdboc_io_ops);
43833 + else if (configured == 2)
43834 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43835 }
43836
43837 static int configure_kgdboc(void)
43838 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43839 int err;
43840 char *cptr = config;
43841 struct console *cons;
43842 + int is_console = 0;
43843
43844 err = kgdboc_option_setup(config);
43845 if (err || !strlen(config) || isspace(config[0]))
43846 goto noconfig;
43847
43848 err = -ENODEV;
43849 - kgdboc_io_ops.is_console = 0;
43850 kgdb_tty_driver = NULL;
43851
43852 kgdboc_use_kms = 0;
43853 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43854 int idx;
43855 if (cons->device && cons->device(cons, &idx) == p &&
43856 idx == tty_line) {
43857 - kgdboc_io_ops.is_console = 1;
43858 + is_console = 1;
43859 break;
43860 }
43861 cons = cons->next;
43862 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43863 kgdb_tty_line = tty_line;
43864
43865 do_register:
43866 - err = kgdb_register_io_module(&kgdboc_io_ops);
43867 + if (is_console) {
43868 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43869 + configured = 2;
43870 + } else {
43871 + err = kgdb_register_io_module(&kgdboc_io_ops);
43872 + configured = 1;
43873 + }
43874 if (err)
43875 goto noconfig;
43876
43877 @@ -205,8 +214,6 @@ do_register:
43878 if (err)
43879 goto nmi_con_failed;
43880
43881 - configured = 1;
43882 -
43883 return 0;
43884
43885 nmi_con_failed:
43886 @@ -223,7 +230,7 @@ noconfig:
43887 static int __init init_kgdboc(void)
43888 {
43889 /* Already configured? */
43890 - if (configured == 1)
43891 + if (configured >= 1)
43892 return 0;
43893
43894 return configure_kgdboc();
43895 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43896 if (config[len - 1] == '\n')
43897 config[len - 1] = '\0';
43898
43899 - if (configured == 1)
43900 + if (configured >= 1)
43901 cleanup_kgdboc();
43902
43903 /* Go and configure with the new params. */
43904 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43905 .post_exception = kgdboc_post_exp_handler,
43906 };
43907
43908 +static struct kgdb_io kgdboc_io_ops_console = {
43909 + .name = "kgdboc",
43910 + .read_char = kgdboc_get_char,
43911 + .write_char = kgdboc_put_char,
43912 + .pre_exception = kgdboc_pre_exp_handler,
43913 + .post_exception = kgdboc_post_exp_handler,
43914 + .is_console = 1
43915 +};
43916 +
43917 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43918 /* This is only available if kgdboc is a built in for early debugging */
43919 static int __init kgdboc_early_init(char *opt)
43920 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43921 index 0c8a9fa..234a95f 100644
43922 --- a/drivers/tty/serial/samsung.c
43923 +++ b/drivers/tty/serial/samsung.c
43924 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43925 }
43926 }
43927
43928 +static int s3c64xx_serial_startup(struct uart_port *port);
43929 static int s3c24xx_serial_startup(struct uart_port *port)
43930 {
43931 struct s3c24xx_uart_port *ourport = to_ourport(port);
43932 int ret;
43933
43934 + /* Startup sequence is different for s3c64xx and higher SoC's */
43935 + if (s3c24xx_serial_has_interrupt_mask(port))
43936 + return s3c64xx_serial_startup(port);
43937 +
43938 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43939 port->mapbase, port->membase);
43940
43941 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43942 /* setup info for port */
43943 port->dev = &platdev->dev;
43944
43945 - /* Startup sequence is different for s3c64xx and higher SoC's */
43946 - if (s3c24xx_serial_has_interrupt_mask(port))
43947 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43948 -
43949 port->uartclk = 1;
43950
43951 if (cfg->uart_flags & UPF_CONS_FLOW) {
43952 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43953 index f87dbfd..42ad4b1 100644
43954 --- a/drivers/tty/serial/serial_core.c
43955 +++ b/drivers/tty/serial/serial_core.c
43956 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43957 uart_flush_buffer(tty);
43958 uart_shutdown(tty, state);
43959 spin_lock_irqsave(&port->lock, flags);
43960 - port->count = 0;
43961 + atomic_set(&port->count, 0);
43962 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43963 spin_unlock_irqrestore(&port->lock, flags);
43964 tty_port_tty_set(port, NULL);
43965 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43966 goto end;
43967 }
43968
43969 - port->count++;
43970 + atomic_inc(&port->count);
43971 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43972 retval = -ENXIO;
43973 goto err_dec_count;
43974 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43975 /*
43976 * Make sure the device is in D0 state.
43977 */
43978 - if (port->count == 1)
43979 + if (atomic_read(&port->count) == 1)
43980 uart_change_pm(state, UART_PM_STATE_ON);
43981
43982 /*
43983 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43984 end:
43985 return retval;
43986 err_dec_count:
43987 - port->count--;
43988 + atomic_inc(&port->count);
43989 mutex_unlock(&port->mutex);
43990 goto end;
43991 }
43992 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43993 index 8eaf1ab..85c030d 100644
43994 --- a/drivers/tty/synclink.c
43995 +++ b/drivers/tty/synclink.c
43996 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43997
43998 if (debug_level >= DEBUG_LEVEL_INFO)
43999 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
44000 - __FILE__,__LINE__, info->device_name, info->port.count);
44001 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44002
44003 if (tty_port_close_start(&info->port, tty, filp) == 0)
44004 goto cleanup;
44005 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
44006 cleanup:
44007 if (debug_level >= DEBUG_LEVEL_INFO)
44008 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
44009 - tty->driver->name, info->port.count);
44010 + tty->driver->name, atomic_read(&info->port.count));
44011
44012 } /* end of mgsl_close() */
44013
44014 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
44015
44016 mgsl_flush_buffer(tty);
44017 shutdown(info);
44018 -
44019 - info->port.count = 0;
44020 +
44021 + atomic_set(&info->port.count, 0);
44022 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44023 info->port.tty = NULL;
44024
44025 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44026
44027 if (debug_level >= DEBUG_LEVEL_INFO)
44028 printk("%s(%d):block_til_ready before block on %s count=%d\n",
44029 - __FILE__,__LINE__, tty->driver->name, port->count );
44030 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44031
44032 spin_lock_irqsave(&info->irq_spinlock, flags);
44033 if (!tty_hung_up_p(filp)) {
44034 extra_count = true;
44035 - port->count--;
44036 + atomic_dec(&port->count);
44037 }
44038 spin_unlock_irqrestore(&info->irq_spinlock, flags);
44039 port->blocked_open++;
44040 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44041
44042 if (debug_level >= DEBUG_LEVEL_INFO)
44043 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
44044 - __FILE__,__LINE__, tty->driver->name, port->count );
44045 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44046
44047 tty_unlock(tty);
44048 schedule();
44049 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44050
44051 /* FIXME: Racy on hangup during close wait */
44052 if (extra_count)
44053 - port->count++;
44054 + atomic_inc(&port->count);
44055 port->blocked_open--;
44056
44057 if (debug_level >= DEBUG_LEVEL_INFO)
44058 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
44059 - __FILE__,__LINE__, tty->driver->name, port->count );
44060 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44061
44062 if (!retval)
44063 port->flags |= ASYNC_NORMAL_ACTIVE;
44064 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44065
44066 if (debug_level >= DEBUG_LEVEL_INFO)
44067 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44068 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44069 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44070
44071 /* If port is closing, signal caller to try again */
44072 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44073 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44074 spin_unlock_irqrestore(&info->netlock, flags);
44075 goto cleanup;
44076 }
44077 - info->port.count++;
44078 + atomic_inc(&info->port.count);
44079 spin_unlock_irqrestore(&info->netlock, flags);
44080
44081 - if (info->port.count == 1) {
44082 + if (atomic_read(&info->port.count) == 1) {
44083 /* 1st open on this device, init hardware */
44084 retval = startup(info);
44085 if (retval < 0)
44086 @@ -3446,8 +3446,8 @@ cleanup:
44087 if (retval) {
44088 if (tty->count == 1)
44089 info->port.tty = NULL; /* tty layer will release tty struct */
44090 - if(info->port.count)
44091 - info->port.count--;
44092 + if (atomic_read(&info->port.count))
44093 + atomic_dec(&info->port.count);
44094 }
44095
44096 return retval;
44097 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44098 unsigned short new_crctype;
44099
44100 /* return error if TTY interface open */
44101 - if (info->port.count)
44102 + if (atomic_read(&info->port.count))
44103 return -EBUSY;
44104
44105 switch (encoding)
44106 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
44107
44108 /* arbitrate between network and tty opens */
44109 spin_lock_irqsave(&info->netlock, flags);
44110 - if (info->port.count != 0 || info->netcount != 0) {
44111 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44112 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44113 spin_unlock_irqrestore(&info->netlock, flags);
44114 return -EBUSY;
44115 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44116 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44117
44118 /* return error if TTY interface open */
44119 - if (info->port.count)
44120 + if (atomic_read(&info->port.count))
44121 return -EBUSY;
44122
44123 if (cmd != SIOCWANDEV)
44124 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44125 index 1abf946..1ee34fc 100644
44126 --- a/drivers/tty/synclink_gt.c
44127 +++ b/drivers/tty/synclink_gt.c
44128 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44129 tty->driver_data = info;
44130 info->port.tty = tty;
44131
44132 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44133 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44134
44135 /* If port is closing, signal caller to try again */
44136 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44137 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44138 mutex_unlock(&info->port.mutex);
44139 goto cleanup;
44140 }
44141 - info->port.count++;
44142 + atomic_inc(&info->port.count);
44143 spin_unlock_irqrestore(&info->netlock, flags);
44144
44145 - if (info->port.count == 1) {
44146 + if (atomic_read(&info->port.count) == 1) {
44147 /* 1st open on this device, init hardware */
44148 retval = startup(info);
44149 if (retval < 0) {
44150 @@ -715,8 +715,8 @@ cleanup:
44151 if (retval) {
44152 if (tty->count == 1)
44153 info->port.tty = NULL; /* tty layer will release tty struct */
44154 - if(info->port.count)
44155 - info->port.count--;
44156 + if(atomic_read(&info->port.count))
44157 + atomic_dec(&info->port.count);
44158 }
44159
44160 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44161 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44162
44163 if (sanity_check(info, tty->name, "close"))
44164 return;
44165 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44166 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44167
44168 if (tty_port_close_start(&info->port, tty, filp) == 0)
44169 goto cleanup;
44170 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44171 tty_port_close_end(&info->port, tty);
44172 info->port.tty = NULL;
44173 cleanup:
44174 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44175 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44176 }
44177
44178 static void hangup(struct tty_struct *tty)
44179 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
44180 shutdown(info);
44181
44182 spin_lock_irqsave(&info->port.lock, flags);
44183 - info->port.count = 0;
44184 + atomic_set(&info->port.count, 0);
44185 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44186 info->port.tty = NULL;
44187 spin_unlock_irqrestore(&info->port.lock, flags);
44188 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44189 unsigned short new_crctype;
44190
44191 /* return error if TTY interface open */
44192 - if (info->port.count)
44193 + if (atomic_read(&info->port.count))
44194 return -EBUSY;
44195
44196 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44197 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
44198
44199 /* arbitrate between network and tty opens */
44200 spin_lock_irqsave(&info->netlock, flags);
44201 - if (info->port.count != 0 || info->netcount != 0) {
44202 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44203 DBGINFO(("%s hdlc_open busy\n", dev->name));
44204 spin_unlock_irqrestore(&info->netlock, flags);
44205 return -EBUSY;
44206 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44207 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44208
44209 /* return error if TTY interface open */
44210 - if (info->port.count)
44211 + if (atomic_read(&info->port.count))
44212 return -EBUSY;
44213
44214 if (cmd != SIOCWANDEV)
44215 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44216 if (port == NULL)
44217 continue;
44218 spin_lock(&port->lock);
44219 - if ((port->port.count || port->netcount) &&
44220 + if ((atomic_read(&port->port.count) || port->netcount) &&
44221 port->pending_bh && !port->bh_running &&
44222 !port->bh_requested) {
44223 DBGISR(("%s bh queued\n", port->device_name));
44224 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44225 spin_lock_irqsave(&info->lock, flags);
44226 if (!tty_hung_up_p(filp)) {
44227 extra_count = true;
44228 - port->count--;
44229 + atomic_dec(&port->count);
44230 }
44231 spin_unlock_irqrestore(&info->lock, flags);
44232 port->blocked_open++;
44233 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44234 remove_wait_queue(&port->open_wait, &wait);
44235
44236 if (extra_count)
44237 - port->count++;
44238 + atomic_inc(&port->count);
44239 port->blocked_open--;
44240
44241 if (!retval)
44242 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44243 index ff17138..e38b41e 100644
44244 --- a/drivers/tty/synclinkmp.c
44245 +++ b/drivers/tty/synclinkmp.c
44246 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44247
44248 if (debug_level >= DEBUG_LEVEL_INFO)
44249 printk("%s(%d):%s open(), old ref count = %d\n",
44250 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44251 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44252
44253 /* If port is closing, signal caller to try again */
44254 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44255 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44256 spin_unlock_irqrestore(&info->netlock, flags);
44257 goto cleanup;
44258 }
44259 - info->port.count++;
44260 + atomic_inc(&info->port.count);
44261 spin_unlock_irqrestore(&info->netlock, flags);
44262
44263 - if (info->port.count == 1) {
44264 + if (atomic_read(&info->port.count) == 1) {
44265 /* 1st open on this device, init hardware */
44266 retval = startup(info);
44267 if (retval < 0)
44268 @@ -796,8 +796,8 @@ cleanup:
44269 if (retval) {
44270 if (tty->count == 1)
44271 info->port.tty = NULL; /* tty layer will release tty struct */
44272 - if(info->port.count)
44273 - info->port.count--;
44274 + if(atomic_read(&info->port.count))
44275 + atomic_dec(&info->port.count);
44276 }
44277
44278 return retval;
44279 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44280
44281 if (debug_level >= DEBUG_LEVEL_INFO)
44282 printk("%s(%d):%s close() entry, count=%d\n",
44283 - __FILE__,__LINE__, info->device_name, info->port.count);
44284 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44285
44286 if (tty_port_close_start(&info->port, tty, filp) == 0)
44287 goto cleanup;
44288 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44289 cleanup:
44290 if (debug_level >= DEBUG_LEVEL_INFO)
44291 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44292 - tty->driver->name, info->port.count);
44293 + tty->driver->name, atomic_read(&info->port.count));
44294 }
44295
44296 /* Called by tty_hangup() when a hangup is signaled.
44297 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44298 shutdown(info);
44299
44300 spin_lock_irqsave(&info->port.lock, flags);
44301 - info->port.count = 0;
44302 + atomic_set(&info->port.count, 0);
44303 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44304 info->port.tty = NULL;
44305 spin_unlock_irqrestore(&info->port.lock, flags);
44306 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44307 unsigned short new_crctype;
44308
44309 /* return error if TTY interface open */
44310 - if (info->port.count)
44311 + if (atomic_read(&info->port.count))
44312 return -EBUSY;
44313
44314 switch (encoding)
44315 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44316
44317 /* arbitrate between network and tty opens */
44318 spin_lock_irqsave(&info->netlock, flags);
44319 - if (info->port.count != 0 || info->netcount != 0) {
44320 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44321 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44322 spin_unlock_irqrestore(&info->netlock, flags);
44323 return -EBUSY;
44324 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44325 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44326
44327 /* return error if TTY interface open */
44328 - if (info->port.count)
44329 + if (atomic_read(&info->port.count))
44330 return -EBUSY;
44331
44332 if (cmd != SIOCWANDEV)
44333 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44334 * do not request bottom half processing if the
44335 * device is not open in a normal mode.
44336 */
44337 - if ( port && (port->port.count || port->netcount) &&
44338 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44339 port->pending_bh && !port->bh_running &&
44340 !port->bh_requested ) {
44341 if ( debug_level >= DEBUG_LEVEL_ISR )
44342 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44343
44344 if (debug_level >= DEBUG_LEVEL_INFO)
44345 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44346 - __FILE__,__LINE__, tty->driver->name, port->count );
44347 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44348
44349 spin_lock_irqsave(&info->lock, flags);
44350 if (!tty_hung_up_p(filp)) {
44351 extra_count = true;
44352 - port->count--;
44353 + atomic_dec(&port->count);
44354 }
44355 spin_unlock_irqrestore(&info->lock, flags);
44356 port->blocked_open++;
44357 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44358
44359 if (debug_level >= DEBUG_LEVEL_INFO)
44360 printk("%s(%d):%s block_til_ready() count=%d\n",
44361 - __FILE__,__LINE__, tty->driver->name, port->count );
44362 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44363
44364 tty_unlock(tty);
44365 schedule();
44366 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44367 remove_wait_queue(&port->open_wait, &wait);
44368
44369 if (extra_count)
44370 - port->count++;
44371 + atomic_inc(&port->count);
44372 port->blocked_open--;
44373
44374 if (debug_level >= DEBUG_LEVEL_INFO)
44375 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44376 - __FILE__,__LINE__, tty->driver->name, port->count );
44377 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44378
44379 if (!retval)
44380 port->flags |= ASYNC_NORMAL_ACTIVE;
44381 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44382 index b51c154..17d55d1 100644
44383 --- a/drivers/tty/sysrq.c
44384 +++ b/drivers/tty/sysrq.c
44385 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44386 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44387 size_t count, loff_t *ppos)
44388 {
44389 - if (count) {
44390 + if (count && capable(CAP_SYS_ADMIN)) {
44391 char c;
44392
44393 if (get_user(c, buf))
44394 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44395 index 4476682..d77e748 100644
44396 --- a/drivers/tty/tty_io.c
44397 +++ b/drivers/tty/tty_io.c
44398 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44399
44400 void tty_default_fops(struct file_operations *fops)
44401 {
44402 - *fops = tty_fops;
44403 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44404 }
44405
44406 /*
44407 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44408 index 1afe192..73d2c20 100644
44409 --- a/drivers/tty/tty_ldisc.c
44410 +++ b/drivers/tty/tty_ldisc.c
44411 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44412 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44413 tty_ldiscs[disc] = new_ldisc;
44414 new_ldisc->num = disc;
44415 - new_ldisc->refcount = 0;
44416 + atomic_set(&new_ldisc->refcount, 0);
44417 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44418
44419 return ret;
44420 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
44421 return -EINVAL;
44422
44423 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44424 - if (tty_ldiscs[disc]->refcount)
44425 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44426 ret = -EBUSY;
44427 else
44428 tty_ldiscs[disc] = NULL;
44429 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44430 if (ldops) {
44431 ret = ERR_PTR(-EAGAIN);
44432 if (try_module_get(ldops->owner)) {
44433 - ldops->refcount++;
44434 + atomic_inc(&ldops->refcount);
44435 ret = ldops;
44436 }
44437 }
44438 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44439 unsigned long flags;
44440
44441 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44442 - ldops->refcount--;
44443 + atomic_dec(&ldops->refcount);
44444 module_put(ldops->owner);
44445 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44446 }
44447 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
44448 /* unreleased reader reference(s) will cause this WARN */
44449 WARN_ON(!atomic_dec_and_test(&ld->users));
44450
44451 - ld->ops->refcount--;
44452 + atomic_dec(&ld->ops->refcount);
44453 module_put(ld->ops->owner);
44454 kfree(ld);
44455 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44456 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44457 index f597e88..b7f68ed 100644
44458 --- a/drivers/tty/tty_port.c
44459 +++ b/drivers/tty/tty_port.c
44460 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
44461 unsigned long flags;
44462
44463 spin_lock_irqsave(&port->lock, flags);
44464 - port->count = 0;
44465 + atomic_set(&port->count, 0);
44466 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44467 tty = port->tty;
44468 if (tty)
44469 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44470 /* The port lock protects the port counts */
44471 spin_lock_irqsave(&port->lock, flags);
44472 if (!tty_hung_up_p(filp))
44473 - port->count--;
44474 + atomic_dec(&port->count);
44475 port->blocked_open++;
44476 spin_unlock_irqrestore(&port->lock, flags);
44477
44478 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44479 we must not mess that up further */
44480 spin_lock_irqsave(&port->lock, flags);
44481 if (!tty_hung_up_p(filp))
44482 - port->count++;
44483 + atomic_inc(&port->count);
44484 port->blocked_open--;
44485 if (retval == 0)
44486 port->flags |= ASYNC_NORMAL_ACTIVE;
44487 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
44488 return 0;
44489 }
44490
44491 - if (tty->count == 1 && port->count != 1) {
44492 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44493 printk(KERN_WARNING
44494 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44495 - port->count);
44496 - port->count = 1;
44497 + atomic_read(&port->count));
44498 + atomic_set(&port->count, 1);
44499 }
44500 - if (--port->count < 0) {
44501 + if (atomic_dec_return(&port->count) < 0) {
44502 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44503 - port->count);
44504 - port->count = 0;
44505 + atomic_read(&port->count));
44506 + atomic_set(&port->count, 0);
44507 }
44508
44509 - if (port->count) {
44510 + if (atomic_read(&port->count)) {
44511 spin_unlock_irqrestore(&port->lock, flags);
44512 if (port->ops->drop)
44513 port->ops->drop(port);
44514 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44515 {
44516 spin_lock_irq(&port->lock);
44517 if (!tty_hung_up_p(filp))
44518 - ++port->count;
44519 + atomic_inc(&port->count);
44520 spin_unlock_irq(&port->lock);
44521 tty_port_tty_set(port, tty);
44522
44523 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44524 index a9af1b9a..1e08e7f 100644
44525 --- a/drivers/tty/vt/keyboard.c
44526 +++ b/drivers/tty/vt/keyboard.c
44527 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44528 kbd->kbdmode == VC_OFF) &&
44529 value != KVAL(K_SAK))
44530 return; /* SAK is allowed even in raw mode */
44531 +
44532 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44533 + {
44534 + void *func = fn_handler[value];
44535 + if (func == fn_show_state || func == fn_show_ptregs ||
44536 + func == fn_show_mem)
44537 + return;
44538 + }
44539 +#endif
44540 +
44541 fn_handler[value](vc);
44542 }
44543
44544 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44545 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44546 return -EFAULT;
44547
44548 - if (!capable(CAP_SYS_TTY_CONFIG))
44549 - perm = 0;
44550 -
44551 switch (cmd) {
44552 case KDGKBENT:
44553 /* Ensure another thread doesn't free it under us */
44554 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44555 spin_unlock_irqrestore(&kbd_event_lock, flags);
44556 return put_user(val, &user_kbe->kb_value);
44557 case KDSKBENT:
44558 + if (!capable(CAP_SYS_TTY_CONFIG))
44559 + perm = 0;
44560 +
44561 if (!perm)
44562 return -EPERM;
44563 if (!i && v == K_NOSUCHMAP) {
44564 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44565 int i, j, k;
44566 int ret;
44567
44568 - if (!capable(CAP_SYS_TTY_CONFIG))
44569 - perm = 0;
44570 -
44571 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44572 if (!kbs) {
44573 ret = -ENOMEM;
44574 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44575 kfree(kbs);
44576 return ((p && *p) ? -EOVERFLOW : 0);
44577 case KDSKBSENT:
44578 + if (!capable(CAP_SYS_TTY_CONFIG))
44579 + perm = 0;
44580 +
44581 if (!perm) {
44582 ret = -EPERM;
44583 goto reterr;
44584 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44585 index b645c47..a55c182 100644
44586 --- a/drivers/uio/uio.c
44587 +++ b/drivers/uio/uio.c
44588 @@ -25,6 +25,7 @@
44589 #include <linux/kobject.h>
44590 #include <linux/cdev.h>
44591 #include <linux/uio_driver.h>
44592 +#include <asm/local.h>
44593
44594 #define UIO_MAX_DEVICES (1U << MINORBITS)
44595
44596 @@ -32,10 +33,10 @@ struct uio_device {
44597 struct module *owner;
44598 struct device *dev;
44599 int minor;
44600 - atomic_t event;
44601 + atomic_unchecked_t event;
44602 struct fasync_struct *async_queue;
44603 wait_queue_head_t wait;
44604 - int vma_count;
44605 + local_t vma_count;
44606 struct uio_info *info;
44607 struct kobject *map_dir;
44608 struct kobject *portio_dir;
44609 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44610 struct device_attribute *attr, char *buf)
44611 {
44612 struct uio_device *idev = dev_get_drvdata(dev);
44613 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44614 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44615 }
44616
44617 static struct device_attribute uio_class_attributes[] = {
44618 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
44619 {
44620 struct uio_device *idev = info->uio_dev;
44621
44622 - atomic_inc(&idev->event);
44623 + atomic_inc_unchecked(&idev->event);
44624 wake_up_interruptible(&idev->wait);
44625 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44626 }
44627 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44628 }
44629
44630 listener->dev = idev;
44631 - listener->event_count = atomic_read(&idev->event);
44632 + listener->event_count = atomic_read_unchecked(&idev->event);
44633 filep->private_data = listener;
44634
44635 if (idev->info->open) {
44636 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44637 return -EIO;
44638
44639 poll_wait(filep, &idev->wait, wait);
44640 - if (listener->event_count != atomic_read(&idev->event))
44641 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44642 return POLLIN | POLLRDNORM;
44643 return 0;
44644 }
44645 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44646 do {
44647 set_current_state(TASK_INTERRUPTIBLE);
44648
44649 - event_count = atomic_read(&idev->event);
44650 + event_count = atomic_read_unchecked(&idev->event);
44651 if (event_count != listener->event_count) {
44652 if (copy_to_user(buf, &event_count, count))
44653 retval = -EFAULT;
44654 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44655 static void uio_vma_open(struct vm_area_struct *vma)
44656 {
44657 struct uio_device *idev = vma->vm_private_data;
44658 - idev->vma_count++;
44659 + local_inc(&idev->vma_count);
44660 }
44661
44662 static void uio_vma_close(struct vm_area_struct *vma)
44663 {
44664 struct uio_device *idev = vma->vm_private_data;
44665 - idev->vma_count--;
44666 + local_dec(&idev->vma_count);
44667 }
44668
44669 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44670 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
44671 idev->owner = owner;
44672 idev->info = info;
44673 init_waitqueue_head(&idev->wait);
44674 - atomic_set(&idev->event, 0);
44675 + atomic_set_unchecked(&idev->event, 0);
44676
44677 ret = uio_get_minor(idev);
44678 if (ret)
44679 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44680 index 8a7eb77..c00402f 100644
44681 --- a/drivers/usb/atm/cxacru.c
44682 +++ b/drivers/usb/atm/cxacru.c
44683 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44684 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44685 if (ret < 2)
44686 return -EINVAL;
44687 - if (index < 0 || index > 0x7f)
44688 + if (index > 0x7f)
44689 return -EINVAL;
44690 pos += tmp;
44691
44692 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44693 index d3527dd..26effa2 100644
44694 --- a/drivers/usb/atm/usbatm.c
44695 +++ b/drivers/usb/atm/usbatm.c
44696 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44697 if (printk_ratelimit())
44698 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44699 __func__, vpi, vci);
44700 - atomic_inc(&vcc->stats->rx_err);
44701 + atomic_inc_unchecked(&vcc->stats->rx_err);
44702 return;
44703 }
44704
44705 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44706 if (length > ATM_MAX_AAL5_PDU) {
44707 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44708 __func__, length, vcc);
44709 - atomic_inc(&vcc->stats->rx_err);
44710 + atomic_inc_unchecked(&vcc->stats->rx_err);
44711 goto out;
44712 }
44713
44714 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44715 if (sarb->len < pdu_length) {
44716 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44717 __func__, pdu_length, sarb->len, vcc);
44718 - atomic_inc(&vcc->stats->rx_err);
44719 + atomic_inc_unchecked(&vcc->stats->rx_err);
44720 goto out;
44721 }
44722
44723 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44724 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44725 __func__, vcc);
44726 - atomic_inc(&vcc->stats->rx_err);
44727 + atomic_inc_unchecked(&vcc->stats->rx_err);
44728 goto out;
44729 }
44730
44731 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44732 if (printk_ratelimit())
44733 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44734 __func__, length);
44735 - atomic_inc(&vcc->stats->rx_drop);
44736 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44737 goto out;
44738 }
44739
44740 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44741
44742 vcc->push(vcc, skb);
44743
44744 - atomic_inc(&vcc->stats->rx);
44745 + atomic_inc_unchecked(&vcc->stats->rx);
44746 out:
44747 skb_trim(sarb, 0);
44748 }
44749 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44750 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44751
44752 usbatm_pop(vcc, skb);
44753 - atomic_inc(&vcc->stats->tx);
44754 + atomic_inc_unchecked(&vcc->stats->tx);
44755
44756 skb = skb_dequeue(&instance->sndqueue);
44757 }
44758 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44759 if (!left--)
44760 return sprintf(page,
44761 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44762 - atomic_read(&atm_dev->stats.aal5.tx),
44763 - atomic_read(&atm_dev->stats.aal5.tx_err),
44764 - atomic_read(&atm_dev->stats.aal5.rx),
44765 - atomic_read(&atm_dev->stats.aal5.rx_err),
44766 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44767 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44768 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44769 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44770 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44771 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44772
44773 if (!left--) {
44774 if (instance->disconnected)
44775 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44776 index 2a3bbdf..91d72cf 100644
44777 --- a/drivers/usb/core/devices.c
44778 +++ b/drivers/usb/core/devices.c
44779 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44780 * time it gets called.
44781 */
44782 static struct device_connect_event {
44783 - atomic_t count;
44784 + atomic_unchecked_t count;
44785 wait_queue_head_t wait;
44786 } device_event = {
44787 .count = ATOMIC_INIT(1),
44788 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44789
44790 void usbfs_conn_disc_event(void)
44791 {
44792 - atomic_add(2, &device_event.count);
44793 + atomic_add_unchecked(2, &device_event.count);
44794 wake_up(&device_event.wait);
44795 }
44796
44797 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44798
44799 poll_wait(file, &device_event.wait, wait);
44800
44801 - event_count = atomic_read(&device_event.count);
44802 + event_count = atomic_read_unchecked(&device_event.count);
44803 if (file->f_version != event_count) {
44804 file->f_version = event_count;
44805 return POLLIN | POLLRDNORM;
44806 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44807 index d53547d..6a22d02 100644
44808 --- a/drivers/usb/core/hcd.c
44809 +++ b/drivers/usb/core/hcd.c
44810 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44811 */
44812 usb_get_urb(urb);
44813 atomic_inc(&urb->use_count);
44814 - atomic_inc(&urb->dev->urbnum);
44815 + atomic_inc_unchecked(&urb->dev->urbnum);
44816 usbmon_urb_submit(&hcd->self, urb);
44817
44818 /* NOTE requirements on root-hub callers (usbfs and the hub
44819 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44820 urb->hcpriv = NULL;
44821 INIT_LIST_HEAD(&urb->urb_list);
44822 atomic_dec(&urb->use_count);
44823 - atomic_dec(&urb->dev->urbnum);
44824 + atomic_dec_unchecked(&urb->dev->urbnum);
44825 if (atomic_read(&urb->reject))
44826 wake_up(&usb_kill_urb_queue);
44827 usb_put_urb(urb);
44828 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44829 index 444d30e..f15c850 100644
44830 --- a/drivers/usb/core/message.c
44831 +++ b/drivers/usb/core/message.c
44832 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44833 * method can wait for it to complete. Since you don't have a handle on the
44834 * URB used, you can't cancel the request.
44835 */
44836 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44837 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44838 __u8 requesttype, __u16 value, __u16 index, void *data,
44839 __u16 size, int timeout)
44840 {
44841 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44842 index aa38db4..0a08682 100644
44843 --- a/drivers/usb/core/sysfs.c
44844 +++ b/drivers/usb/core/sysfs.c
44845 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44846 struct usb_device *udev;
44847
44848 udev = to_usb_device(dev);
44849 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44850 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44851 }
44852 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44853
44854 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44855 index b10da72..43aa0b2 100644
44856 --- a/drivers/usb/core/usb.c
44857 +++ b/drivers/usb/core/usb.c
44858 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44859 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44860 dev->state = USB_STATE_ATTACHED;
44861 dev->lpm_disable_count = 1;
44862 - atomic_set(&dev->urbnum, 0);
44863 + atomic_set_unchecked(&dev->urbnum, 0);
44864
44865 INIT_LIST_HEAD(&dev->ep0.urb_list);
44866 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44867 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44868 index 5e29dde..eca992f 100644
44869 --- a/drivers/usb/early/ehci-dbgp.c
44870 +++ b/drivers/usb/early/ehci-dbgp.c
44871 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44872
44873 #ifdef CONFIG_KGDB
44874 static struct kgdb_io kgdbdbgp_io_ops;
44875 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44876 +static struct kgdb_io kgdbdbgp_io_ops_console;
44877 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44878 #else
44879 #define dbgp_kgdb_mode (0)
44880 #endif
44881 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44882 .write_char = kgdbdbgp_write_char,
44883 };
44884
44885 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44886 + .name = "kgdbdbgp",
44887 + .read_char = kgdbdbgp_read_char,
44888 + .write_char = kgdbdbgp_write_char,
44889 + .is_console = 1
44890 +};
44891 +
44892 static int kgdbdbgp_wait_time;
44893
44894 static int __init kgdbdbgp_parse_config(char *str)
44895 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44896 ptr++;
44897 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44898 }
44899 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44900 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44901 + if (early_dbgp_console.index != -1)
44902 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44903 + else
44904 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44905
44906 return 0;
44907 }
44908 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44909 index b369292..9f3ba40 100644
44910 --- a/drivers/usb/gadget/u_serial.c
44911 +++ b/drivers/usb/gadget/u_serial.c
44912 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44913 spin_lock_irq(&port->port_lock);
44914
44915 /* already open? Great. */
44916 - if (port->port.count) {
44917 + if (atomic_read(&port->port.count)) {
44918 status = 0;
44919 - port->port.count++;
44920 + atomic_inc(&port->port.count);
44921
44922 /* currently opening/closing? wait ... */
44923 } else if (port->openclose) {
44924 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44925 tty->driver_data = port;
44926 port->port.tty = tty;
44927
44928 - port->port.count = 1;
44929 + atomic_set(&port->port.count, 1);
44930 port->openclose = false;
44931
44932 /* if connected, start the I/O stream */
44933 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44934
44935 spin_lock_irq(&port->port_lock);
44936
44937 - if (port->port.count != 1) {
44938 - if (port->port.count == 0)
44939 + if (atomic_read(&port->port.count) != 1) {
44940 + if (atomic_read(&port->port.count) == 0)
44941 WARN_ON(1);
44942 else
44943 - --port->port.count;
44944 + atomic_dec(&port->port.count);
44945 goto exit;
44946 }
44947
44948 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44949 * and sleep if necessary
44950 */
44951 port->openclose = true;
44952 - port->port.count = 0;
44953 + atomic_set(&port->port.count, 0);
44954
44955 gser = port->port_usb;
44956 if (gser && gser->disconnect)
44957 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44958 int cond;
44959
44960 spin_lock_irq(&port->port_lock);
44961 - cond = (port->port.count == 0) && !port->openclose;
44962 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44963 spin_unlock_irq(&port->port_lock);
44964 return cond;
44965 }
44966 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44967 /* if it's already open, start I/O ... and notify the serial
44968 * protocol about open/close status (connect/disconnect).
44969 */
44970 - if (port->port.count) {
44971 + if (atomic_read(&port->port.count)) {
44972 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44973 gs_start_io(port);
44974 if (gser->connect)
44975 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44976
44977 port->port_usb = NULL;
44978 gser->ioport = NULL;
44979 - if (port->port.count > 0 || port->openclose) {
44980 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44981 wake_up_interruptible(&port->drain_wait);
44982 if (port->port.tty)
44983 tty_hangup(port->port.tty);
44984 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44985
44986 /* finally, free any unused/unusable I/O buffers */
44987 spin_lock_irqsave(&port->port_lock, flags);
44988 - if (port->port.count == 0 && !port->openclose)
44989 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44990 gs_buf_free(&port->port_write_buf);
44991 gs_free_requests(gser->out, &port->read_pool, NULL);
44992 gs_free_requests(gser->out, &port->read_queue, NULL);
44993 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44994 index 5f3bcd3..bfca43f 100644
44995 --- a/drivers/usb/serial/console.c
44996 +++ b/drivers/usb/serial/console.c
44997 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44998
44999 info->port = port;
45000
45001 - ++port->port.count;
45002 + atomic_inc(&port->port.count);
45003 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
45004 if (serial->type->set_termios) {
45005 /*
45006 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
45007 }
45008 /* Now that any required fake tty operations are completed restore
45009 * the tty port count */
45010 - --port->port.count;
45011 + atomic_dec(&port->port.count);
45012 /* The console is special in terms of closing the device so
45013 * indicate this port is now acting as a system console. */
45014 port->port.console = 1;
45015 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
45016 free_tty:
45017 kfree(tty);
45018 reset_open_count:
45019 - port->port.count = 0;
45020 + atomic_set(&port->port.count, 0);
45021 usb_autopm_put_interface(serial->interface);
45022 error_get_interface:
45023 usb_serial_put(serial);
45024 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
45025 index 75f70f0..d467e1a 100644
45026 --- a/drivers/usb/storage/usb.h
45027 +++ b/drivers/usb/storage/usb.h
45028 @@ -63,7 +63,7 @@ struct us_unusual_dev {
45029 __u8 useProtocol;
45030 __u8 useTransport;
45031 int (*initFunction)(struct us_data *);
45032 -};
45033 +} __do_const;
45034
45035
45036 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
45037 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
45038 index d6bea3e..60b250e 100644
45039 --- a/drivers/usb/wusbcore/wa-hc.h
45040 +++ b/drivers/usb/wusbcore/wa-hc.h
45041 @@ -192,7 +192,7 @@ struct wahc {
45042 struct list_head xfer_delayed_list;
45043 spinlock_t xfer_list_lock;
45044 struct work_struct xfer_work;
45045 - atomic_t xfer_id_count;
45046 + atomic_unchecked_t xfer_id_count;
45047 };
45048
45049
45050 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
45051 INIT_LIST_HEAD(&wa->xfer_delayed_list);
45052 spin_lock_init(&wa->xfer_list_lock);
45053 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45054 - atomic_set(&wa->xfer_id_count, 1);
45055 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45056 }
45057
45058 /**
45059 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45060 index 6ef94bc..1b41265 100644
45061 --- a/drivers/usb/wusbcore/wa-xfer.c
45062 +++ b/drivers/usb/wusbcore/wa-xfer.c
45063 @@ -296,7 +296,7 @@ out:
45064 */
45065 static void wa_xfer_id_init(struct wa_xfer *xfer)
45066 {
45067 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45068 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45069 }
45070
45071 /*
45072 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
45073 index 5174eba..86e764a 100644
45074 --- a/drivers/vhost/vringh.c
45075 +++ b/drivers/vhost/vringh.c
45076 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
45077
45078 static inline int putu16_kern(u16 *p, u16 val)
45079 {
45080 - ACCESS_ONCE(*p) = val;
45081 + ACCESS_ONCE_RW(*p) = val;
45082 return 0;
45083 }
45084
45085 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45086 index 8c55011..eed4ae1a 100644
45087 --- a/drivers/video/aty/aty128fb.c
45088 +++ b/drivers/video/aty/aty128fb.c
45089 @@ -149,7 +149,7 @@ enum {
45090 };
45091
45092 /* Must match above enum */
45093 -static char * const r128_family[] = {
45094 +static const char * const r128_family[] = {
45095 "AGP",
45096 "PCI",
45097 "PRO AGP",
45098 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45099 index 4f27fdc..d3537e6 100644
45100 --- a/drivers/video/aty/atyfb_base.c
45101 +++ b/drivers/video/aty/atyfb_base.c
45102 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45103 par->accel_flags = var->accel_flags; /* hack */
45104
45105 if (var->accel_flags) {
45106 - info->fbops->fb_sync = atyfb_sync;
45107 + pax_open_kernel();
45108 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45109 + pax_close_kernel();
45110 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45111 } else {
45112 - info->fbops->fb_sync = NULL;
45113 + pax_open_kernel();
45114 + *(void **)&info->fbops->fb_sync = NULL;
45115 + pax_close_kernel();
45116 info->flags |= FBINFO_HWACCEL_DISABLED;
45117 }
45118
45119 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45120 index 95ec042..e6affdd 100644
45121 --- a/drivers/video/aty/mach64_cursor.c
45122 +++ b/drivers/video/aty/mach64_cursor.c
45123 @@ -7,6 +7,7 @@
45124 #include <linux/string.h>
45125
45126 #include <asm/io.h>
45127 +#include <asm/pgtable.h>
45128
45129 #ifdef __sparc__
45130 #include <asm/fbio.h>
45131 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45132 info->sprite.buf_align = 16; /* and 64 lines tall. */
45133 info->sprite.flags = FB_PIXMAP_IO;
45134
45135 - info->fbops->fb_cursor = atyfb_cursor;
45136 + pax_open_kernel();
45137 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45138 + pax_close_kernel();
45139
45140 return 0;
45141 }
45142 diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
45143 index c74e7aa..e3c2790 100644
45144 --- a/drivers/video/backlight/backlight.c
45145 +++ b/drivers/video/backlight/backlight.c
45146 @@ -304,7 +304,7 @@ struct backlight_device *backlight_device_register(const char *name,
45147 new_bd->dev.class = backlight_class;
45148 new_bd->dev.parent = parent;
45149 new_bd->dev.release = bl_device_release;
45150 - dev_set_name(&new_bd->dev, name);
45151 + dev_set_name(&new_bd->dev, "%s", name);
45152 dev_set_drvdata(&new_bd->dev, devdata);
45153
45154 /* Set default properties */
45155 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45156 index bca6ccc..252107e 100644
45157 --- a/drivers/video/backlight/kb3886_bl.c
45158 +++ b/drivers/video/backlight/kb3886_bl.c
45159 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45160 static unsigned long kb3886bl_flags;
45161 #define KB3886BL_SUSPENDED 0x01
45162
45163 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45164 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45165 {
45166 .ident = "Sahara Touch-iT",
45167 .matches = {
45168 diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
45169 index 34fb6bd..3649fd9 100644
45170 --- a/drivers/video/backlight/lcd.c
45171 +++ b/drivers/video/backlight/lcd.c
45172 @@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
45173 new_ld->dev.class = lcd_class;
45174 new_ld->dev.parent = parent;
45175 new_ld->dev.release = lcd_device_release;
45176 - dev_set_name(&new_ld->dev, name);
45177 + dev_set_name(&new_ld->dev, "%s", name);
45178 dev_set_drvdata(&new_ld->dev, devdata);
45179
45180 rc = device_register(&new_ld->dev);
45181 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45182 index 900aa4e..6d49418 100644
45183 --- a/drivers/video/fb_defio.c
45184 +++ b/drivers/video/fb_defio.c
45185 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45186
45187 BUG_ON(!fbdefio);
45188 mutex_init(&fbdefio->lock);
45189 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45190 + pax_open_kernel();
45191 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45192 + pax_close_kernel();
45193 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45194 INIT_LIST_HEAD(&fbdefio->pagelist);
45195 if (fbdefio->delay == 0) /* set a default of 1 s */
45196 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45197 page->mapping = NULL;
45198 }
45199
45200 - info->fbops->fb_mmap = NULL;
45201 + *(void **)&info->fbops->fb_mmap = NULL;
45202 mutex_destroy(&fbdefio->lock);
45203 }
45204 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45205 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45206 index 5c3960d..15cf8fc 100644
45207 --- a/drivers/video/fbcmap.c
45208 +++ b/drivers/video/fbcmap.c
45209 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45210 rc = -ENODEV;
45211 goto out;
45212 }
45213 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45214 - !info->fbops->fb_setcmap)) {
45215 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45216 rc = -EINVAL;
45217 goto out1;
45218 }
45219 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45220 index 098bfc6..796841d 100644
45221 --- a/drivers/video/fbmem.c
45222 +++ b/drivers/video/fbmem.c
45223 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45224 image->dx += image->width + 8;
45225 }
45226 } else if (rotate == FB_ROTATE_UD) {
45227 - for (x = 0; x < num && image->dx >= 0; x++) {
45228 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45229 info->fbops->fb_imageblit(info, image);
45230 image->dx -= image->width + 8;
45231 }
45232 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45233 image->dy += image->height + 8;
45234 }
45235 } else if (rotate == FB_ROTATE_CCW) {
45236 - for (x = 0; x < num && image->dy >= 0; x++) {
45237 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45238 info->fbops->fb_imageblit(info, image);
45239 image->dy -= image->height + 8;
45240 }
45241 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45242 return -EFAULT;
45243 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45244 return -EINVAL;
45245 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45246 + if (con2fb.framebuffer >= FB_MAX)
45247 return -EINVAL;
45248 if (!registered_fb[con2fb.framebuffer])
45249 request_module("fb%d", con2fb.framebuffer);
45250 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45251 index 7672d2e..b56437f 100644
45252 --- a/drivers/video/i810/i810_accel.c
45253 +++ b/drivers/video/i810/i810_accel.c
45254 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45255 }
45256 }
45257 printk("ringbuffer lockup!!!\n");
45258 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45259 i810_report_error(mmio);
45260 par->dev_flags |= LOCKUP;
45261 info->pixmap.scan_align = 1;
45262 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45263 index 3c14e43..eafa544 100644
45264 --- a/drivers/video/logo/logo_linux_clut224.ppm
45265 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45266 @@ -1,1604 +1,1123 @@
45267 P3
45268 -# Standard 224-color Linux logo
45269 80 80
45270 255
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 6 6 6 6 6 6 10 10 10 10 10 10
45281 - 10 10 10 6 6 6 6 6 6 6 6 6
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 6 6 6 10 10 10 14 14 14
45300 - 22 22 22 26 26 26 30 30 30 34 34 34
45301 - 30 30 30 30 30 30 26 26 26 18 18 18
45302 - 14 14 14 10 10 10 6 6 6 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 1 0 0 1 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 6 6 6 14 14 14 26 26 26 42 42 42
45320 - 54 54 54 66 66 66 78 78 78 78 78 78
45321 - 78 78 78 74 74 74 66 66 66 54 54 54
45322 - 42 42 42 26 26 26 18 18 18 10 10 10
45323 - 6 6 6 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 0 0 0 0 0 0 0 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 1 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 10 10 10
45339 - 22 22 22 42 42 42 66 66 66 86 86 86
45340 - 66 66 66 38 38 38 38 38 38 22 22 22
45341 - 26 26 26 34 34 34 54 54 54 66 66 66
45342 - 86 86 86 70 70 70 46 46 46 26 26 26
45343 - 14 14 14 6 6 6 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 1 0 0 1 0 0 1 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 10 10 10 26 26 26
45359 - 50 50 50 82 82 82 58 58 58 6 6 6
45360 - 2 2 6 2 2 6 2 2 6 2 2 6
45361 - 2 2 6 2 2 6 2 2 6 2 2 6
45362 - 6 6 6 54 54 54 86 86 86 66 66 66
45363 - 38 38 38 18 18 18 6 6 6 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 6 6 6 22 22 22 50 50 50
45379 - 78 78 78 34 34 34 2 2 6 2 2 6
45380 - 2 2 6 2 2 6 2 2 6 2 2 6
45381 - 2 2 6 2 2 6 2 2 6 2 2 6
45382 - 2 2 6 2 2 6 6 6 6 70 70 70
45383 - 78 78 78 46 46 46 22 22 22 6 6 6
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 1 0 0 1 0 0 1 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 6 6 6 18 18 18 42 42 42 82 82 82
45399 - 26 26 26 2 2 6 2 2 6 2 2 6
45400 - 2 2 6 2 2 6 2 2 6 2 2 6
45401 - 2 2 6 2 2 6 2 2 6 14 14 14
45402 - 46 46 46 34 34 34 6 6 6 2 2 6
45403 - 42 42 42 78 78 78 42 42 42 18 18 18
45404 - 6 6 6 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 0 0 0 0 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 1 0 0 0 0 0 1 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 10 10 10 30 30 30 66 66 66 58 58 58
45419 - 2 2 6 2 2 6 2 2 6 2 2 6
45420 - 2 2 6 2 2 6 2 2 6 2 2 6
45421 - 2 2 6 2 2 6 2 2 6 26 26 26
45422 - 86 86 86 101 101 101 46 46 46 10 10 10
45423 - 2 2 6 58 58 58 70 70 70 34 34 34
45424 - 10 10 10 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 0 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 1 0 0 1 0 0 1 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 0 0 0
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 14 14 14 42 42 42 86 86 86 10 10 10
45439 - 2 2 6 2 2 6 2 2 6 2 2 6
45440 - 2 2 6 2 2 6 2 2 6 2 2 6
45441 - 2 2 6 2 2 6 2 2 6 30 30 30
45442 - 94 94 94 94 94 94 58 58 58 26 26 26
45443 - 2 2 6 6 6 6 78 78 78 54 54 54
45444 - 22 22 22 6 6 6 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 0 0 0 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 0 0 0
45456 - 0 0 0 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 6 6 6
45458 - 22 22 22 62 62 62 62 62 62 2 2 6
45459 - 2 2 6 2 2 6 2 2 6 2 2 6
45460 - 2 2 6 2 2 6 2 2 6 2 2 6
45461 - 2 2 6 2 2 6 2 2 6 26 26 26
45462 - 54 54 54 38 38 38 18 18 18 10 10 10
45463 - 2 2 6 2 2 6 34 34 34 82 82 82
45464 - 38 38 38 14 14 14 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 0 0 0 0 0 0 0 0 0 0
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
45470 - 0 0 0 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 1 0 0 1 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 6 6 6
45478 - 30 30 30 78 78 78 30 30 30 2 2 6
45479 - 2 2 6 2 2 6 2 2 6 2 2 6
45480 - 2 2 6 2 2 6 2 2 6 2 2 6
45481 - 2 2 6 2 2 6 2 2 6 10 10 10
45482 - 10 10 10 2 2 6 2 2 6 2 2 6
45483 - 2 2 6 2 2 6 2 2 6 78 78 78
45484 - 50 50 50 18 18 18 6 6 6 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 0 0 0 0 0 0 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 1 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 10 10 10
45498 - 38 38 38 86 86 86 14 14 14 2 2 6
45499 - 2 2 6 2 2 6 2 2 6 2 2 6
45500 - 2 2 6 2 2 6 2 2 6 2 2 6
45501 - 2 2 6 2 2 6 2 2 6 2 2 6
45502 - 2 2 6 2 2 6 2 2 6 2 2 6
45503 - 2 2 6 2 2 6 2 2 6 54 54 54
45504 - 66 66 66 26 26 26 6 6 6 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 1 0 0 1 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 14 14 14
45518 - 42 42 42 82 82 82 2 2 6 2 2 6
45519 - 2 2 6 6 6 6 10 10 10 2 2 6
45520 - 2 2 6 2 2 6 2 2 6 2 2 6
45521 - 2 2 6 2 2 6 2 2 6 6 6 6
45522 - 14 14 14 10 10 10 2 2 6 2 2 6
45523 - 2 2 6 2 2 6 2 2 6 18 18 18
45524 - 82 82 82 34 34 34 10 10 10 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 0 0 0
45528 - 0 0 0 0 0 0 0 0 0 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 0 0 0 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 1 0 0 0 0 0 0 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 0 0 0
45535 - 0 0 0 0 0 0 0 0 0 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 14 14 14
45538 - 46 46 46 86 86 86 2 2 6 2 2 6
45539 - 6 6 6 6 6 6 22 22 22 34 34 34
45540 - 6 6 6 2 2 6 2 2 6 2 2 6
45541 - 2 2 6 2 2 6 18 18 18 34 34 34
45542 - 10 10 10 50 50 50 22 22 22 2 2 6
45543 - 2 2 6 2 2 6 2 2 6 10 10 10
45544 - 86 86 86 42 42 42 14 14 14 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 1 0 0 1 0 0 1 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 14 14 14
45558 - 46 46 46 86 86 86 2 2 6 2 2 6
45559 - 38 38 38 116 116 116 94 94 94 22 22 22
45560 - 22 22 22 2 2 6 2 2 6 2 2 6
45561 - 14 14 14 86 86 86 138 138 138 162 162 162
45562 -154 154 154 38 38 38 26 26 26 6 6 6
45563 - 2 2 6 2 2 6 2 2 6 2 2 6
45564 - 86 86 86 46 46 46 14 14 14 0 0 0
45565 - 0 0 0 0 0 0 0 0 0 0 0 0
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 0 0 0
45568 - 0 0 0 0 0 0 0 0 0 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 0 0 0 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 0 0 0
45575 - 0 0 0 0 0 0 0 0 0 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 14 14 14
45578 - 46 46 46 86 86 86 2 2 6 14 14 14
45579 -134 134 134 198 198 198 195 195 195 116 116 116
45580 - 10 10 10 2 2 6 2 2 6 6 6 6
45581 -101 98 89 187 187 187 210 210 210 218 218 218
45582 -214 214 214 134 134 134 14 14 14 6 6 6
45583 - 2 2 6 2 2 6 2 2 6 2 2 6
45584 - 86 86 86 50 50 50 18 18 18 6 6 6
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 0 0 0
45588 - 0 0 0 0 0 0 0 0 0 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 1 0 0 0
45592 - 0 0 1 0 0 1 0 0 1 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 14 14 14
45598 - 46 46 46 86 86 86 2 2 6 54 54 54
45599 -218 218 218 195 195 195 226 226 226 246 246 246
45600 - 58 58 58 2 2 6 2 2 6 30 30 30
45601 -210 210 210 253 253 253 174 174 174 123 123 123
45602 -221 221 221 234 234 234 74 74 74 2 2 6
45603 - 2 2 6 2 2 6 2 2 6 2 2 6
45604 - 70 70 70 58 58 58 22 22 22 6 6 6
45605 - 0 0 0 0 0 0 0 0 0 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 0 0 0
45608 - 0 0 0 0 0 0 0 0 0 0 0 0
45609 - 0 0 0 0 0 0 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 14 14 14
45618 - 46 46 46 82 82 82 2 2 6 106 106 106
45619 -170 170 170 26 26 26 86 86 86 226 226 226
45620 -123 123 123 10 10 10 14 14 14 46 46 46
45621 -231 231 231 190 190 190 6 6 6 70 70 70
45622 - 90 90 90 238 238 238 158 158 158 2 2 6
45623 - 2 2 6 2 2 6 2 2 6 2 2 6
45624 - 70 70 70 58 58 58 22 22 22 6 6 6
45625 - 0 0 0 0 0 0 0 0 0 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 0 0 0
45628 - 0 0 0 0 0 0 0 0 0 0 0 0
45629 - 0 0 0 0 0 0 0 0 0 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 1 0 0 0
45632 - 0 0 1 0 0 1 0 0 1 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 14 14 14
45638 - 42 42 42 86 86 86 6 6 6 116 116 116
45639 -106 106 106 6 6 6 70 70 70 149 149 149
45640 -128 128 128 18 18 18 38 38 38 54 54 54
45641 -221 221 221 106 106 106 2 2 6 14 14 14
45642 - 46 46 46 190 190 190 198 198 198 2 2 6
45643 - 2 2 6 2 2 6 2 2 6 2 2 6
45644 - 74 74 74 62 62 62 22 22 22 6 6 6
45645 - 0 0 0 0 0 0 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 0 0 0
45648 - 0 0 0 0 0 0 0 0 0 0 0 0
45649 - 0 0 0 0 0 0 0 0 0 0 0 0
45650 - 0 0 0 0 0 0 0 0 0 0 0 0
45651 - 0 0 0 0 0 0 0 0 1 0 0 0
45652 - 0 0 1 0 0 0 0 0 1 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 0 0 0
45655 - 0 0 0 0 0 0 0 0 0 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 14 14 14
45658 - 42 42 42 94 94 94 14 14 14 101 101 101
45659 -128 128 128 2 2 6 18 18 18 116 116 116
45660 -118 98 46 121 92 8 121 92 8 98 78 10
45661 -162 162 162 106 106 106 2 2 6 2 2 6
45662 - 2 2 6 195 195 195 195 195 195 6 6 6
45663 - 2 2 6 2 2 6 2 2 6 2 2 6
45664 - 74 74 74 62 62 62 22 22 22 6 6 6
45665 - 0 0 0 0 0 0 0 0 0 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 0 0 0
45668 - 0 0 0 0 0 0 0 0 0 0 0 0
45669 - 0 0 0 0 0 0 0 0 0 0 0 0
45670 - 0 0 0 0 0 0 0 0 0 0 0 0
45671 - 0 0 0 0 0 0 0 0 1 0 0 1
45672 - 0 0 1 0 0 0 0 0 1 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 0 0 0
45675 - 0 0 0 0 0 0 0 0 0 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 10 10 10
45678 - 38 38 38 90 90 90 14 14 14 58 58 58
45679 -210 210 210 26 26 26 54 38 6 154 114 10
45680 -226 170 11 236 186 11 225 175 15 184 144 12
45681 -215 174 15 175 146 61 37 26 9 2 2 6
45682 - 70 70 70 246 246 246 138 138 138 2 2 6
45683 - 2 2 6 2 2 6 2 2 6 2 2 6
45684 - 70 70 70 66 66 66 26 26 26 6 6 6
45685 - 0 0 0 0 0 0 0 0 0 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 0 0 0 0 0 0 0 0 0
45690 - 0 0 0 0 0 0 0 0 0 0 0 0
45691 - 0 0 0 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 10 10 10
45698 - 38 38 38 86 86 86 14 14 14 10 10 10
45699 -195 195 195 188 164 115 192 133 9 225 175 15
45700 -239 182 13 234 190 10 232 195 16 232 200 30
45701 -245 207 45 241 208 19 232 195 16 184 144 12
45702 -218 194 134 211 206 186 42 42 42 2 2 6
45703 - 2 2 6 2 2 6 2 2 6 2 2 6
45704 - 50 50 50 74 74 74 30 30 30 6 6 6
45705 - 0 0 0 0 0 0 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 0 0 0 0 0 0 0 0 0 0 0 0
45711 - 0 0 0 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 10 10 10
45718 - 34 34 34 86 86 86 14 14 14 2 2 6
45719 -121 87 25 192 133 9 219 162 10 239 182 13
45720 -236 186 11 232 195 16 241 208 19 244 214 54
45721 -246 218 60 246 218 38 246 215 20 241 208 19
45722 -241 208 19 226 184 13 121 87 25 2 2 6
45723 - 2 2 6 2 2 6 2 2 6 2 2 6
45724 - 50 50 50 82 82 82 34 34 34 10 10 10
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 0 0 0 0 0 0
45735 - 0 0 0 0 0 0 0 0 0 0 0 0
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 10 10 10
45738 - 34 34 34 82 82 82 30 30 30 61 42 6
45739 -180 123 7 206 145 10 230 174 11 239 182 13
45740 -234 190 10 238 202 15 241 208 19 246 218 74
45741 -246 218 38 246 215 20 246 215 20 246 215 20
45742 -226 184 13 215 174 15 184 144 12 6 6 6
45743 - 2 2 6 2 2 6 2 2 6 2 2 6
45744 - 26 26 26 94 94 94 42 42 42 14 14 14
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 0 0 0
45754 - 0 0 0 0 0 0 0 0 0 0 0 0
45755 - 0 0 0 0 0 0 0 0 0 0 0 0
45756 - 0 0 0 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 0 0 0 10 10 10
45758 - 30 30 30 78 78 78 50 50 50 104 69 6
45759 -192 133 9 216 158 10 236 178 12 236 186 11
45760 -232 195 16 241 208 19 244 214 54 245 215 43
45761 -246 215 20 246 215 20 241 208 19 198 155 10
45762 -200 144 11 216 158 10 156 118 10 2 2 6
45763 - 2 2 6 2 2 6 2 2 6 2 2 6
45764 - 6 6 6 90 90 90 54 54 54 18 18 18
45765 - 6 6 6 0 0 0 0 0 0 0 0 0
45766 - 0 0 0 0 0 0 0 0 0 0 0 0
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 0 0 0 0 0 0 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 10 10 10
45778 - 30 30 30 78 78 78 46 46 46 22 22 22
45779 -137 92 6 210 162 10 239 182 13 238 190 10
45780 -238 202 15 241 208 19 246 215 20 246 215 20
45781 -241 208 19 203 166 17 185 133 11 210 150 10
45782 -216 158 10 210 150 10 102 78 10 2 2 6
45783 - 6 6 6 54 54 54 14 14 14 2 2 6
45784 - 2 2 6 62 62 62 74 74 74 30 30 30
45785 - 10 10 10 0 0 0 0 0 0 0 0 0
45786 - 0 0 0 0 0 0 0 0 0 0 0 0
45787 - 0 0 0 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 0 0 0 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 10 10 10
45798 - 34 34 34 78 78 78 50 50 50 6 6 6
45799 - 94 70 30 139 102 15 190 146 13 226 184 13
45800 -232 200 30 232 195 16 215 174 15 190 146 13
45801 -168 122 10 192 133 9 210 150 10 213 154 11
45802 -202 150 34 182 157 106 101 98 89 2 2 6
45803 - 2 2 6 78 78 78 116 116 116 58 58 58
45804 - 2 2 6 22 22 22 90 90 90 46 46 46
45805 - 18 18 18 6 6 6 0 0 0 0 0 0
45806 - 0 0 0 0 0 0 0 0 0 0 0 0
45807 - 0 0 0 0 0 0 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 0 0 0 0 0 0
45816 - 0 0 0 0 0 0 0 0 0 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 10 10 10
45818 - 38 38 38 86 86 86 50 50 50 6 6 6
45819 -128 128 128 174 154 114 156 107 11 168 122 10
45820 -198 155 10 184 144 12 197 138 11 200 144 11
45821 -206 145 10 206 145 10 197 138 11 188 164 115
45822 -195 195 195 198 198 198 174 174 174 14 14 14
45823 - 2 2 6 22 22 22 116 116 116 116 116 116
45824 - 22 22 22 2 2 6 74 74 74 70 70 70
45825 - 30 30 30 10 10 10 0 0 0 0 0 0
45826 - 0 0 0 0 0 0 0 0 0 0 0 0
45827 - 0 0 0 0 0 0 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 0 0 0 0 0 0
45836 - 0 0 0 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 6 6 6 18 18 18
45838 - 50 50 50 101 101 101 26 26 26 10 10 10
45839 -138 138 138 190 190 190 174 154 114 156 107 11
45840 -197 138 11 200 144 11 197 138 11 192 133 9
45841 -180 123 7 190 142 34 190 178 144 187 187 187
45842 -202 202 202 221 221 221 214 214 214 66 66 66
45843 - 2 2 6 2 2 6 50 50 50 62 62 62
45844 - 6 6 6 2 2 6 10 10 10 90 90 90
45845 - 50 50 50 18 18 18 6 6 6 0 0 0
45846 - 0 0 0 0 0 0 0 0 0 0 0 0
45847 - 0 0 0 0 0 0 0 0 0 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 0 0 0 0 0 0 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 10 10 10 34 34 34
45858 - 74 74 74 74 74 74 2 2 6 6 6 6
45859 -144 144 144 198 198 198 190 190 190 178 166 146
45860 -154 121 60 156 107 11 156 107 11 168 124 44
45861 -174 154 114 187 187 187 190 190 190 210 210 210
45862 -246 246 246 253 253 253 253 253 253 182 182 182
45863 - 6 6 6 2 2 6 2 2 6 2 2 6
45864 - 2 2 6 2 2 6 2 2 6 62 62 62
45865 - 74 74 74 34 34 34 14 14 14 0 0 0
45866 - 0 0 0 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 10 10 10 22 22 22 54 54 54
45878 - 94 94 94 18 18 18 2 2 6 46 46 46
45879 -234 234 234 221 221 221 190 190 190 190 190 190
45880 -190 190 190 187 187 187 187 187 187 190 190 190
45881 -190 190 190 195 195 195 214 214 214 242 242 242
45882 -253 253 253 253 253 253 253 253 253 253 253 253
45883 - 82 82 82 2 2 6 2 2 6 2 2 6
45884 - 2 2 6 2 2 6 2 2 6 14 14 14
45885 - 86 86 86 54 54 54 22 22 22 6 6 6
45886 - 0 0 0 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
45895 - 0 0 0 0 0 0 0 0 0 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 6 6 6 18 18 18 46 46 46 90 90 90
45898 - 46 46 46 18 18 18 6 6 6 182 182 182
45899 -253 253 253 246 246 246 206 206 206 190 190 190
45900 -190 190 190 190 190 190 190 190 190 190 190 190
45901 -206 206 206 231 231 231 250 250 250 253 253 253
45902 -253 253 253 253 253 253 253 253 253 253 253 253
45903 -202 202 202 14 14 14 2 2 6 2 2 6
45904 - 2 2 6 2 2 6 2 2 6 2 2 6
45905 - 42 42 42 86 86 86 42 42 42 18 18 18
45906 - 6 6 6 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 6 6 6
45917 - 14 14 14 38 38 38 74 74 74 66 66 66
45918 - 2 2 6 6 6 6 90 90 90 250 250 250
45919 -253 253 253 253 253 253 238 238 238 198 198 198
45920 -190 190 190 190 190 190 195 195 195 221 221 221
45921 -246 246 246 253 253 253 253 253 253 253 253 253
45922 -253 253 253 253 253 253 253 253 253 253 253 253
45923 -253 253 253 82 82 82 2 2 6 2 2 6
45924 - 2 2 6 2 2 6 2 2 6 2 2 6
45925 - 2 2 6 78 78 78 70 70 70 34 34 34
45926 - 14 14 14 6 6 6 0 0 0 0 0 0
45927 - 0 0 0 0 0 0 0 0 0 0 0 0
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 0 0 0 0 0 0 0 0 0 0 0 0
45935 - 0 0 0 0 0 0 0 0 0 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 14 14 14
45937 - 34 34 34 66 66 66 78 78 78 6 6 6
45938 - 2 2 6 18 18 18 218 218 218 253 253 253
45939 -253 253 253 253 253 253 253 253 253 246 246 246
45940 -226 226 226 231 231 231 246 246 246 253 253 253
45941 -253 253 253 253 253 253 253 253 253 253 253 253
45942 -253 253 253 253 253 253 253 253 253 253 253 253
45943 -253 253 253 178 178 178 2 2 6 2 2 6
45944 - 2 2 6 2 2 6 2 2 6 2 2 6
45945 - 2 2 6 18 18 18 90 90 90 62 62 62
45946 - 30 30 30 10 10 10 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 0 0 0
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 0 0 0 0 0 0 0 0 0 0 0 0
45955 - 0 0 0 0 0 0 0 0 0 0 0 0
45956 - 0 0 0 0 0 0 10 10 10 26 26 26
45957 - 58 58 58 90 90 90 18 18 18 2 2 6
45958 - 2 2 6 110 110 110 253 253 253 253 253 253
45959 -253 253 253 253 253 253 253 253 253 253 253 253
45960 -250 250 250 253 253 253 253 253 253 253 253 253
45961 -253 253 253 253 253 253 253 253 253 253 253 253
45962 -253 253 253 253 253 253 253 253 253 253 253 253
45963 -253 253 253 231 231 231 18 18 18 2 2 6
45964 - 2 2 6 2 2 6 2 2 6 2 2 6
45965 - 2 2 6 2 2 6 18 18 18 94 94 94
45966 - 54 54 54 26 26 26 10 10 10 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 0 0 0 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 0 0 0
45974 - 0 0 0 0 0 0 0 0 0 0 0 0
45975 - 0 0 0 0 0 0 0 0 0 0 0 0
45976 - 0 0 0 6 6 6 22 22 22 50 50 50
45977 - 90 90 90 26 26 26 2 2 6 2 2 6
45978 - 14 14 14 195 195 195 250 250 250 253 253 253
45979 -253 253 253 253 253 253 253 253 253 253 253 253
45980 -253 253 253 253 253 253 253 253 253 253 253 253
45981 -253 253 253 253 253 253 253 253 253 253 253 253
45982 -253 253 253 253 253 253 253 253 253 253 253 253
45983 -250 250 250 242 242 242 54 54 54 2 2 6
45984 - 2 2 6 2 2 6 2 2 6 2 2 6
45985 - 2 2 6 2 2 6 2 2 6 38 38 38
45986 - 86 86 86 50 50 50 22 22 22 6 6 6
45987 - 0 0 0 0 0 0 0 0 0 0 0 0
45988 - 0 0 0 0 0 0 0 0 0 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 0 0 0
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 0 0 0 0 0 0 0 0 0 0 0 0
45992 - 0 0 0 0 0 0 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 0 0 0
45994 - 0 0 0 0 0 0 0 0 0 0 0 0
45995 - 0 0 0 0 0 0 0 0 0 0 0 0
45996 - 6 6 6 14 14 14 38 38 38 82 82 82
45997 - 34 34 34 2 2 6 2 2 6 2 2 6
45998 - 42 42 42 195 195 195 246 246 246 253 253 253
45999 -253 253 253 253 253 253 253 253 253 250 250 250
46000 -242 242 242 242 242 242 250 250 250 253 253 253
46001 -253 253 253 253 253 253 253 253 253 253 253 253
46002 -253 253 253 250 250 250 246 246 246 238 238 238
46003 -226 226 226 231 231 231 101 101 101 6 6 6
46004 - 2 2 6 2 2 6 2 2 6 2 2 6
46005 - 2 2 6 2 2 6 2 2 6 2 2 6
46006 - 38 38 38 82 82 82 42 42 42 14 14 14
46007 - 6 6 6 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 0 0 0
46011 - 0 0 0 0 0 0 0 0 0 0 0 0
46012 - 0 0 0 0 0 0 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 0 0 0 0 0 0
46014 - 0 0 0 0 0 0 0 0 0 0 0 0
46015 - 0 0 0 0 0 0 0 0 0 0 0 0
46016 - 10 10 10 26 26 26 62 62 62 66 66 66
46017 - 2 2 6 2 2 6 2 2 6 6 6 6
46018 - 70 70 70 170 170 170 206 206 206 234 234 234
46019 -246 246 246 250 250 250 250 250 250 238 238 238
46020 -226 226 226 231 231 231 238 238 238 250 250 250
46021 -250 250 250 250 250 250 246 246 246 231 231 231
46022 -214 214 214 206 206 206 202 202 202 202 202 202
46023 -198 198 198 202 202 202 182 182 182 18 18 18
46024 - 2 2 6 2 2 6 2 2 6 2 2 6
46025 - 2 2 6 2 2 6 2 2 6 2 2 6
46026 - 2 2 6 62 62 62 66 66 66 30 30 30
46027 - 10 10 10 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 0 0 0 0 0 0 0 0 0 0 0 0
46032 - 0 0 0 0 0 0 0 0 0 0 0 0
46033 - 0 0 0 0 0 0 0 0 0 0 0 0
46034 - 0 0 0 0 0 0 0 0 0 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 0 0 0
46036 - 14 14 14 42 42 42 82 82 82 18 18 18
46037 - 2 2 6 2 2 6 2 2 6 10 10 10
46038 - 94 94 94 182 182 182 218 218 218 242 242 242
46039 -250 250 250 253 253 253 253 253 253 250 250 250
46040 -234 234 234 253 253 253 253 253 253 253 253 253
46041 -253 253 253 253 253 253 253 253 253 246 246 246
46042 -238 238 238 226 226 226 210 210 210 202 202 202
46043 -195 195 195 195 195 195 210 210 210 158 158 158
46044 - 6 6 6 14 14 14 50 50 50 14 14 14
46045 - 2 2 6 2 2 6 2 2 6 2 2 6
46046 - 2 2 6 6 6 6 86 86 86 46 46 46
46047 - 18 18 18 6 6 6 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 0 0 0 0 0 0 0 0 0
46052 - 0 0 0 0 0 0 0 0 0 0 0 0
46053 - 0 0 0 0 0 0 0 0 0 0 0 0
46054 - 0 0 0 0 0 0 0 0 0 0 0 0
46055 - 0 0 0 0 0 0 0 0 0 6 6 6
46056 - 22 22 22 54 54 54 70 70 70 2 2 6
46057 - 2 2 6 10 10 10 2 2 6 22 22 22
46058 -166 166 166 231 231 231 250 250 250 253 253 253
46059 -253 253 253 253 253 253 253 253 253 250 250 250
46060 -242 242 242 253 253 253 253 253 253 253 253 253
46061 -253 253 253 253 253 253 253 253 253 253 253 253
46062 -253 253 253 253 253 253 253 253 253 246 246 246
46063 -231 231 231 206 206 206 198 198 198 226 226 226
46064 - 94 94 94 2 2 6 6 6 6 38 38 38
46065 - 30 30 30 2 2 6 2 2 6 2 2 6
46066 - 2 2 6 2 2 6 62 62 62 66 66 66
46067 - 26 26 26 10 10 10 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 0 0 0 0 0 0 0 0 0
46072 - 0 0 0 0 0 0 0 0 0 0 0 0
46073 - 0 0 0 0 0 0 0 0 0 0 0 0
46074 - 0 0 0 0 0 0 0 0 0 0 0 0
46075 - 0 0 0 0 0 0 0 0 0 10 10 10
46076 - 30 30 30 74 74 74 50 50 50 2 2 6
46077 - 26 26 26 26 26 26 2 2 6 106 106 106
46078 -238 238 238 253 253 253 253 253 253 253 253 253
46079 -253 253 253 253 253 253 253 253 253 253 253 253
46080 -253 253 253 253 253 253 253 253 253 253 253 253
46081 -253 253 253 253 253 253 253 253 253 253 253 253
46082 -253 253 253 253 253 253 253 253 253 253 253 253
46083 -253 253 253 246 246 246 218 218 218 202 202 202
46084 -210 210 210 14 14 14 2 2 6 2 2 6
46085 - 30 30 30 22 22 22 2 2 6 2 2 6
46086 - 2 2 6 2 2 6 18 18 18 86 86 86
46087 - 42 42 42 14 14 14 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 0 0 0
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 0 0 0
46091 - 0 0 0 0 0 0 0 0 0 0 0 0
46092 - 0 0 0 0 0 0 0 0 0 0 0 0
46093 - 0 0 0 0 0 0 0 0 0 0 0 0
46094 - 0 0 0 0 0 0 0 0 0 0 0 0
46095 - 0 0 0 0 0 0 0 0 0 14 14 14
46096 - 42 42 42 90 90 90 22 22 22 2 2 6
46097 - 42 42 42 2 2 6 18 18 18 218 218 218
46098 -253 253 253 253 253 253 253 253 253 253 253 253
46099 -253 253 253 253 253 253 253 253 253 253 253 253
46100 -253 253 253 253 253 253 253 253 253 253 253 253
46101 -253 253 253 253 253 253 253 253 253 253 253 253
46102 -253 253 253 253 253 253 253 253 253 253 253 253
46103 -253 253 253 253 253 253 250 250 250 221 221 221
46104 -218 218 218 101 101 101 2 2 6 14 14 14
46105 - 18 18 18 38 38 38 10 10 10 2 2 6
46106 - 2 2 6 2 2 6 2 2 6 78 78 78
46107 - 58 58 58 22 22 22 6 6 6 0 0 0
46108 - 0 0 0 0 0 0 0 0 0 0 0 0
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 0 0 0
46111 - 0 0 0 0 0 0 0 0 0 0 0 0
46112 - 0 0 0 0 0 0 0 0 0 0 0 0
46113 - 0 0 0 0 0 0 0 0 0 0 0 0
46114 - 0 0 0 0 0 0 0 0 0 0 0 0
46115 - 0 0 0 0 0 0 6 6 6 18 18 18
46116 - 54 54 54 82 82 82 2 2 6 26 26 26
46117 - 22 22 22 2 2 6 123 123 123 253 253 253
46118 -253 253 253 253 253 253 253 253 253 253 253 253
46119 -253 253 253 253 253 253 253 253 253 253 253 253
46120 -253 253 253 253 253 253 253 253 253 253 253 253
46121 -253 253 253 253 253 253 253 253 253 253 253 253
46122 -253 253 253 253 253 253 253 253 253 253 253 253
46123 -253 253 253 253 253 253 253 253 253 250 250 250
46124 -238 238 238 198 198 198 6 6 6 38 38 38
46125 - 58 58 58 26 26 26 38 38 38 2 2 6
46126 - 2 2 6 2 2 6 2 2 6 46 46 46
46127 - 78 78 78 30 30 30 10 10 10 0 0 0
46128 - 0 0 0 0 0 0 0 0 0 0 0 0
46129 - 0 0 0 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 0 0 0
46131 - 0 0 0 0 0 0 0 0 0 0 0 0
46132 - 0 0 0 0 0 0 0 0 0 0 0 0
46133 - 0 0 0 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 10 10 10 30 30 30
46136 - 74 74 74 58 58 58 2 2 6 42 42 42
46137 - 2 2 6 22 22 22 231 231 231 253 253 253
46138 -253 253 253 253 253 253 253 253 253 253 253 253
46139 -253 253 253 253 253 253 253 253 253 250 250 250
46140 -253 253 253 253 253 253 253 253 253 253 253 253
46141 -253 253 253 253 253 253 253 253 253 253 253 253
46142 -253 253 253 253 253 253 253 253 253 253 253 253
46143 -253 253 253 253 253 253 253 253 253 253 253 253
46144 -253 253 253 246 246 246 46 46 46 38 38 38
46145 - 42 42 42 14 14 14 38 38 38 14 14 14
46146 - 2 2 6 2 2 6 2 2 6 6 6 6
46147 - 86 86 86 46 46 46 14 14 14 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 0 0 0
46149 - 0 0 0 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 0 0 0
46151 - 0 0 0 0 0 0 0 0 0 0 0 0
46152 - 0 0 0 0 0 0 0 0 0 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 6 6 6 14 14 14 42 42 42
46156 - 90 90 90 18 18 18 18 18 18 26 26 26
46157 - 2 2 6 116 116 116 253 253 253 253 253 253
46158 -253 253 253 253 253 253 253 253 253 253 253 253
46159 -253 253 253 253 253 253 250 250 250 238 238 238
46160 -253 253 253 253 253 253 253 253 253 253 253 253
46161 -253 253 253 253 253 253 253 253 253 253 253 253
46162 -253 253 253 253 253 253 253 253 253 253 253 253
46163 -253 253 253 253 253 253 253 253 253 253 253 253
46164 -253 253 253 253 253 253 94 94 94 6 6 6
46165 - 2 2 6 2 2 6 10 10 10 34 34 34
46166 - 2 2 6 2 2 6 2 2 6 2 2 6
46167 - 74 74 74 58 58 58 22 22 22 6 6 6
46168 - 0 0 0 0 0 0 0 0 0 0 0 0
46169 - 0 0 0 0 0 0 0 0 0 0 0 0
46170 - 0 0 0 0 0 0 0 0 0 0 0 0
46171 - 0 0 0 0 0 0 0 0 0 0 0 0
46172 - 0 0 0 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 10 10 10 26 26 26 66 66 66
46176 - 82 82 82 2 2 6 38 38 38 6 6 6
46177 - 14 14 14 210 210 210 253 253 253 253 253 253
46178 -253 253 253 253 253 253 253 253 253 253 253 253
46179 -253 253 253 253 253 253 246 246 246 242 242 242
46180 -253 253 253 253 253 253 253 253 253 253 253 253
46181 -253 253 253 253 253 253 253 253 253 253 253 253
46182 -253 253 253 253 253 253 253 253 253 253 253 253
46183 -253 253 253 253 253 253 253 253 253 253 253 253
46184 -253 253 253 253 253 253 144 144 144 2 2 6
46185 - 2 2 6 2 2 6 2 2 6 46 46 46
46186 - 2 2 6 2 2 6 2 2 6 2 2 6
46187 - 42 42 42 74 74 74 30 30 30 10 10 10
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 0 0 0 0 0 0
46191 - 0 0 0 0 0 0 0 0 0 0 0 0
46192 - 0 0 0 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 6 6 6 14 14 14 42 42 42 90 90 90
46196 - 26 26 26 6 6 6 42 42 42 2 2 6
46197 - 74 74 74 250 250 250 253 253 253 253 253 253
46198 -253 253 253 253 253 253 253 253 253 253 253 253
46199 -253 253 253 253 253 253 242 242 242 242 242 242
46200 -253 253 253 253 253 253 253 253 253 253 253 253
46201 -253 253 253 253 253 253 253 253 253 253 253 253
46202 -253 253 253 253 253 253 253 253 253 253 253 253
46203 -253 253 253 253 253 253 253 253 253 253 253 253
46204 -253 253 253 253 253 253 182 182 182 2 2 6
46205 - 2 2 6 2 2 6 2 2 6 46 46 46
46206 - 2 2 6 2 2 6 2 2 6 2 2 6
46207 - 10 10 10 86 86 86 38 38 38 10 10 10
46208 - 0 0 0 0 0 0 0 0 0 0 0 0
46209 - 0 0 0 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 0 0 0 0 0 0
46211 - 0 0 0 0 0 0 0 0 0 0 0 0
46212 - 0 0 0 0 0 0 0 0 0 0 0 0
46213 - 0 0 0 0 0 0 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 10 10 10 26 26 26 66 66 66 82 82 82
46216 - 2 2 6 22 22 22 18 18 18 2 2 6
46217 -149 149 149 253 253 253 253 253 253 253 253 253
46218 -253 253 253 253 253 253 253 253 253 253 253 253
46219 -253 253 253 253 253 253 234 234 234 242 242 242
46220 -253 253 253 253 253 253 253 253 253 253 253 253
46221 -253 253 253 253 253 253 253 253 253 253 253 253
46222 -253 253 253 253 253 253 253 253 253 253 253 253
46223 -253 253 253 253 253 253 253 253 253 253 253 253
46224 -253 253 253 253 253 253 206 206 206 2 2 6
46225 - 2 2 6 2 2 6 2 2 6 38 38 38
46226 - 2 2 6 2 2 6 2 2 6 2 2 6
46227 - 6 6 6 86 86 86 46 46 46 14 14 14
46228 - 0 0 0 0 0 0 0 0 0 0 0 0
46229 - 0 0 0 0 0 0 0 0 0 0 0 0
46230 - 0 0 0 0 0 0 0 0 0 0 0 0
46231 - 0 0 0 0 0 0 0 0 0 0 0 0
46232 - 0 0 0 0 0 0 0 0 0 0 0 0
46233 - 0 0 0 0 0 0 0 0 0 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 6 6 6
46235 - 18 18 18 46 46 46 86 86 86 18 18 18
46236 - 2 2 6 34 34 34 10 10 10 6 6 6
46237 -210 210 210 253 253 253 253 253 253 253 253 253
46238 -253 253 253 253 253 253 253 253 253 253 253 253
46239 -253 253 253 253 253 253 234 234 234 242 242 242
46240 -253 253 253 253 253 253 253 253 253 253 253 253
46241 -253 253 253 253 253 253 253 253 253 253 253 253
46242 -253 253 253 253 253 253 253 253 253 253 253 253
46243 -253 253 253 253 253 253 253 253 253 253 253 253
46244 -253 253 253 253 253 253 221 221 221 6 6 6
46245 - 2 2 6 2 2 6 6 6 6 30 30 30
46246 - 2 2 6 2 2 6 2 2 6 2 2 6
46247 - 2 2 6 82 82 82 54 54 54 18 18 18
46248 - 6 6 6 0 0 0 0 0 0 0 0 0
46249 - 0 0 0 0 0 0 0 0 0 0 0 0
46250 - 0 0 0 0 0 0 0 0 0 0 0 0
46251 - 0 0 0 0 0 0 0 0 0 0 0 0
46252 - 0 0 0 0 0 0 0 0 0 0 0 0
46253 - 0 0 0 0 0 0 0 0 0 0 0 0
46254 - 0 0 0 0 0 0 0 0 0 10 10 10
46255 - 26 26 26 66 66 66 62 62 62 2 2 6
46256 - 2 2 6 38 38 38 10 10 10 26 26 26
46257 -238 238 238 253 253 253 253 253 253 253 253 253
46258 -253 253 253 253 253 253 253 253 253 253 253 253
46259 -253 253 253 253 253 253 231 231 231 238 238 238
46260 -253 253 253 253 253 253 253 253 253 253 253 253
46261 -253 253 253 253 253 253 253 253 253 253 253 253
46262 -253 253 253 253 253 253 253 253 253 253 253 253
46263 -253 253 253 253 253 253 253 253 253 253 253 253
46264 -253 253 253 253 253 253 231 231 231 6 6 6
46265 - 2 2 6 2 2 6 10 10 10 30 30 30
46266 - 2 2 6 2 2 6 2 2 6 2 2 6
46267 - 2 2 6 66 66 66 58 58 58 22 22 22
46268 - 6 6 6 0 0 0 0 0 0 0 0 0
46269 - 0 0 0 0 0 0 0 0 0 0 0 0
46270 - 0 0 0 0 0 0 0 0 0 0 0 0
46271 - 0 0 0 0 0 0 0 0 0 0 0 0
46272 - 0 0 0 0 0 0 0 0 0 0 0 0
46273 - 0 0 0 0 0 0 0 0 0 0 0 0
46274 - 0 0 0 0 0 0 0 0 0 10 10 10
46275 - 38 38 38 78 78 78 6 6 6 2 2 6
46276 - 2 2 6 46 46 46 14 14 14 42 42 42
46277 -246 246 246 253 253 253 253 253 253 253 253 253
46278 -253 253 253 253 253 253 253 253 253 253 253 253
46279 -253 253 253 253 253 253 231 231 231 242 242 242
46280 -253 253 253 253 253 253 253 253 253 253 253 253
46281 -253 253 253 253 253 253 253 253 253 253 253 253
46282 -253 253 253 253 253 253 253 253 253 253 253 253
46283 -253 253 253 253 253 253 253 253 253 253 253 253
46284 -253 253 253 253 253 253 234 234 234 10 10 10
46285 - 2 2 6 2 2 6 22 22 22 14 14 14
46286 - 2 2 6 2 2 6 2 2 6 2 2 6
46287 - 2 2 6 66 66 66 62 62 62 22 22 22
46288 - 6 6 6 0 0 0 0 0 0 0 0 0
46289 - 0 0 0 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 0 0 0 0 0 0
46291 - 0 0 0 0 0 0 0 0 0 0 0 0
46292 - 0 0 0 0 0 0 0 0 0 0 0 0
46293 - 0 0 0 0 0 0 0 0 0 0 0 0
46294 - 0 0 0 0 0 0 6 6 6 18 18 18
46295 - 50 50 50 74 74 74 2 2 6 2 2 6
46296 - 14 14 14 70 70 70 34 34 34 62 62 62
46297 -250 250 250 253 253 253 253 253 253 253 253 253
46298 -253 253 253 253 253 253 253 253 253 253 253 253
46299 -253 253 253 253 253 253 231 231 231 246 246 246
46300 -253 253 253 253 253 253 253 253 253 253 253 253
46301 -253 253 253 253 253 253 253 253 253 253 253 253
46302 -253 253 253 253 253 253 253 253 253 253 253 253
46303 -253 253 253 253 253 253 253 253 253 253 253 253
46304 -253 253 253 253 253 253 234 234 234 14 14 14
46305 - 2 2 6 2 2 6 30 30 30 2 2 6
46306 - 2 2 6 2 2 6 2 2 6 2 2 6
46307 - 2 2 6 66 66 66 62 62 62 22 22 22
46308 - 6 6 6 0 0 0 0 0 0 0 0 0
46309 - 0 0 0 0 0 0 0 0 0 0 0 0
46310 - 0 0 0 0 0 0 0 0 0 0 0 0
46311 - 0 0 0 0 0 0 0 0 0 0 0 0
46312 - 0 0 0 0 0 0 0 0 0 0 0 0
46313 - 0 0 0 0 0 0 0 0 0 0 0 0
46314 - 0 0 0 0 0 0 6 6 6 18 18 18
46315 - 54 54 54 62 62 62 2 2 6 2 2 6
46316 - 2 2 6 30 30 30 46 46 46 70 70 70
46317 -250 250 250 253 253 253 253 253 253 253 253 253
46318 -253 253 253 253 253 253 253 253 253 253 253 253
46319 -253 253 253 253 253 253 231 231 231 246 246 246
46320 -253 253 253 253 253 253 253 253 253 253 253 253
46321 -253 253 253 253 253 253 253 253 253 253 253 253
46322 -253 253 253 253 253 253 253 253 253 253 253 253
46323 -253 253 253 253 253 253 253 253 253 253 253 253
46324 -253 253 253 253 253 253 226 226 226 10 10 10
46325 - 2 2 6 6 6 6 30 30 30 2 2 6
46326 - 2 2 6 2 2 6 2 2 6 2 2 6
46327 - 2 2 6 66 66 66 58 58 58 22 22 22
46328 - 6 6 6 0 0 0 0 0 0 0 0 0
46329 - 0 0 0 0 0 0 0 0 0 0 0 0
46330 - 0 0 0 0 0 0 0 0 0 0 0 0
46331 - 0 0 0 0 0 0 0 0 0 0 0 0
46332 - 0 0 0 0 0 0 0 0 0 0 0 0
46333 - 0 0 0 0 0 0 0 0 0 0 0 0
46334 - 0 0 0 0 0 0 6 6 6 22 22 22
46335 - 58 58 58 62 62 62 2 2 6 2 2 6
46336 - 2 2 6 2 2 6 30 30 30 78 78 78
46337 -250 250 250 253 253 253 253 253 253 253 253 253
46338 -253 253 253 253 253 253 253 253 253 253 253 253
46339 -253 253 253 253 253 253 231 231 231 246 246 246
46340 -253 253 253 253 253 253 253 253 253 253 253 253
46341 -253 253 253 253 253 253 253 253 253 253 253 253
46342 -253 253 253 253 253 253 253 253 253 253 253 253
46343 -253 253 253 253 253 253 253 253 253 253 253 253
46344 -253 253 253 253 253 253 206 206 206 2 2 6
46345 - 22 22 22 34 34 34 18 14 6 22 22 22
46346 - 26 26 26 18 18 18 6 6 6 2 2 6
46347 - 2 2 6 82 82 82 54 54 54 18 18 18
46348 - 6 6 6 0 0 0 0 0 0 0 0 0
46349 - 0 0 0 0 0 0 0 0 0 0 0 0
46350 - 0 0 0 0 0 0 0 0 0 0 0 0
46351 - 0 0 0 0 0 0 0 0 0 0 0 0
46352 - 0 0 0 0 0 0 0 0 0 0 0 0
46353 - 0 0 0 0 0 0 0 0 0 0 0 0
46354 - 0 0 0 0 0 0 6 6 6 26 26 26
46355 - 62 62 62 106 106 106 74 54 14 185 133 11
46356 -210 162 10 121 92 8 6 6 6 62 62 62
46357 -238 238 238 253 253 253 253 253 253 253 253 253
46358 -253 253 253 253 253 253 253 253 253 253 253 253
46359 -253 253 253 253 253 253 231 231 231 246 246 246
46360 -253 253 253 253 253 253 253 253 253 253 253 253
46361 -253 253 253 253 253 253 253 253 253 253 253 253
46362 -253 253 253 253 253 253 253 253 253 253 253 253
46363 -253 253 253 253 253 253 253 253 253 253 253 253
46364 -253 253 253 253 253 253 158 158 158 18 18 18
46365 - 14 14 14 2 2 6 2 2 6 2 2 6
46366 - 6 6 6 18 18 18 66 66 66 38 38 38
46367 - 6 6 6 94 94 94 50 50 50 18 18 18
46368 - 6 6 6 0 0 0 0 0 0 0 0 0
46369 - 0 0 0 0 0 0 0 0 0 0 0 0
46370 - 0 0 0 0 0 0 0 0 0 0 0 0
46371 - 0 0 0 0 0 0 0 0 0 0 0 0
46372 - 0 0 0 0 0 0 0 0 0 0 0 0
46373 - 0 0 0 0 0 0 0 0 0 6 6 6
46374 - 10 10 10 10 10 10 18 18 18 38 38 38
46375 - 78 78 78 142 134 106 216 158 10 242 186 14
46376 -246 190 14 246 190 14 156 118 10 10 10 10
46377 - 90 90 90 238 238 238 253 253 253 253 253 253
46378 -253 253 253 253 253 253 253 253 253 253 253 253
46379 -253 253 253 253 253 253 231 231 231 250 250 250
46380 -253 253 253 253 253 253 253 253 253 253 253 253
46381 -253 253 253 253 253 253 253 253 253 253 253 253
46382 -253 253 253 253 253 253 253 253 253 253 253 253
46383 -253 253 253 253 253 253 253 253 253 246 230 190
46384 -238 204 91 238 204 91 181 142 44 37 26 9
46385 - 2 2 6 2 2 6 2 2 6 2 2 6
46386 - 2 2 6 2 2 6 38 38 38 46 46 46
46387 - 26 26 26 106 106 106 54 54 54 18 18 18
46388 - 6 6 6 0 0 0 0 0 0 0 0 0
46389 - 0 0 0 0 0 0 0 0 0 0 0 0
46390 - 0 0 0 0 0 0 0 0 0 0 0 0
46391 - 0 0 0 0 0 0 0 0 0 0 0 0
46392 - 0 0 0 0 0 0 0 0 0 0 0 0
46393 - 0 0 0 6 6 6 14 14 14 22 22 22
46394 - 30 30 30 38 38 38 50 50 50 70 70 70
46395 -106 106 106 190 142 34 226 170 11 242 186 14
46396 -246 190 14 246 190 14 246 190 14 154 114 10
46397 - 6 6 6 74 74 74 226 226 226 253 253 253
46398 -253 253 253 253 253 253 253 253 253 253 253 253
46399 -253 253 253 253 253 253 231 231 231 250 250 250
46400 -253 253 253 253 253 253 253 253 253 253 253 253
46401 -253 253 253 253 253 253 253 253 253 253 253 253
46402 -253 253 253 253 253 253 253 253 253 253 253 253
46403 -253 253 253 253 253 253 253 253 253 228 184 62
46404 -241 196 14 241 208 19 232 195 16 38 30 10
46405 - 2 2 6 2 2 6 2 2 6 2 2 6
46406 - 2 2 6 6 6 6 30 30 30 26 26 26
46407 -203 166 17 154 142 90 66 66 66 26 26 26
46408 - 6 6 6 0 0 0 0 0 0 0 0 0
46409 - 0 0 0 0 0 0 0 0 0 0 0 0
46410 - 0 0 0 0 0 0 0 0 0 0 0 0
46411 - 0 0 0 0 0 0 0 0 0 0 0 0
46412 - 0 0 0 0 0 0 0 0 0 0 0 0
46413 - 6 6 6 18 18 18 38 38 38 58 58 58
46414 - 78 78 78 86 86 86 101 101 101 123 123 123
46415 -175 146 61 210 150 10 234 174 13 246 186 14
46416 -246 190 14 246 190 14 246 190 14 238 190 10
46417 -102 78 10 2 2 6 46 46 46 198 198 198
46418 -253 253 253 253 253 253 253 253 253 253 253 253
46419 -253 253 253 253 253 253 234 234 234 242 242 242
46420 -253 253 253 253 253 253 253 253 253 253 253 253
46421 -253 253 253 253 253 253 253 253 253 253 253 253
46422 -253 253 253 253 253 253 253 253 253 253 253 253
46423 -253 253 253 253 253 253 253 253 253 224 178 62
46424 -242 186 14 241 196 14 210 166 10 22 18 6
46425 - 2 2 6 2 2 6 2 2 6 2 2 6
46426 - 2 2 6 2 2 6 6 6 6 121 92 8
46427 -238 202 15 232 195 16 82 82 82 34 34 34
46428 - 10 10 10 0 0 0 0 0 0 0 0 0
46429 - 0 0 0 0 0 0 0 0 0 0 0 0
46430 - 0 0 0 0 0 0 0 0 0 0 0 0
46431 - 0 0 0 0 0 0 0 0 0 0 0 0
46432 - 0 0 0 0 0 0 0 0 0 0 0 0
46433 - 14 14 14 38 38 38 70 70 70 154 122 46
46434 -190 142 34 200 144 11 197 138 11 197 138 11
46435 -213 154 11 226 170 11 242 186 14 246 190 14
46436 -246 190 14 246 190 14 246 190 14 246 190 14
46437 -225 175 15 46 32 6 2 2 6 22 22 22
46438 -158 158 158 250 250 250 253 253 253 253 253 253
46439 -253 253 253 253 253 253 253 253 253 253 253 253
46440 -253 253 253 253 253 253 253 253 253 253 253 253
46441 -253 253 253 253 253 253 253 253 253 253 253 253
46442 -253 253 253 253 253 253 253 253 253 253 253 253
46443 -253 253 253 250 250 250 242 242 242 224 178 62
46444 -239 182 13 236 186 11 213 154 11 46 32 6
46445 - 2 2 6 2 2 6 2 2 6 2 2 6
46446 - 2 2 6 2 2 6 61 42 6 225 175 15
46447 -238 190 10 236 186 11 112 100 78 42 42 42
46448 - 14 14 14 0 0 0 0 0 0 0 0 0
46449 - 0 0 0 0 0 0 0 0 0 0 0 0
46450 - 0 0 0 0 0 0 0 0 0 0 0 0
46451 - 0 0 0 0 0 0 0 0 0 0 0 0
46452 - 0 0 0 0 0 0 0 0 0 6 6 6
46453 - 22 22 22 54 54 54 154 122 46 213 154 11
46454 -226 170 11 230 174 11 226 170 11 226 170 11
46455 -236 178 12 242 186 14 246 190 14 246 190 14
46456 -246 190 14 246 190 14 246 190 14 246 190 14
46457 -241 196 14 184 144 12 10 10 10 2 2 6
46458 - 6 6 6 116 116 116 242 242 242 253 253 253
46459 -253 253 253 253 253 253 253 253 253 253 253 253
46460 -253 253 253 253 253 253 253 253 253 253 253 253
46461 -253 253 253 253 253 253 253 253 253 253 253 253
46462 -253 253 253 253 253 253 253 253 253 253 253 253
46463 -253 253 253 231 231 231 198 198 198 214 170 54
46464 -236 178 12 236 178 12 210 150 10 137 92 6
46465 - 18 14 6 2 2 6 2 2 6 2 2 6
46466 - 6 6 6 70 47 6 200 144 11 236 178 12
46467 -239 182 13 239 182 13 124 112 88 58 58 58
46468 - 22 22 22 6 6 6 0 0 0 0 0 0
46469 - 0 0 0 0 0 0 0 0 0 0 0 0
46470 - 0 0 0 0 0 0 0 0 0 0 0 0
46471 - 0 0 0 0 0 0 0 0 0 0 0 0
46472 - 0 0 0 0 0 0 0 0 0 10 10 10
46473 - 30 30 30 70 70 70 180 133 36 226 170 11
46474 -239 182 13 242 186 14 242 186 14 246 186 14
46475 -246 190 14 246 190 14 246 190 14 246 190 14
46476 -246 190 14 246 190 14 246 190 14 246 190 14
46477 -246 190 14 232 195 16 98 70 6 2 2 6
46478 - 2 2 6 2 2 6 66 66 66 221 221 221
46479 -253 253 253 253 253 253 253 253 253 253 253 253
46480 -253 253 253 253 253 253 253 253 253 253 253 253
46481 -253 253 253 253 253 253 253 253 253 253 253 253
46482 -253 253 253 253 253 253 253 253 253 253 253 253
46483 -253 253 253 206 206 206 198 198 198 214 166 58
46484 -230 174 11 230 174 11 216 158 10 192 133 9
46485 -163 110 8 116 81 8 102 78 10 116 81 8
46486 -167 114 7 197 138 11 226 170 11 239 182 13
46487 -242 186 14 242 186 14 162 146 94 78 78 78
46488 - 34 34 34 14 14 14 6 6 6 0 0 0
46489 - 0 0 0 0 0 0 0 0 0 0 0 0
46490 - 0 0 0 0 0 0 0 0 0 0 0 0
46491 - 0 0 0 0 0 0 0 0 0 0 0 0
46492 - 0 0 0 0 0 0 0 0 0 6 6 6
46493 - 30 30 30 78 78 78 190 142 34 226 170 11
46494 -239 182 13 246 190 14 246 190 14 246 190 14
46495 -246 190 14 246 190 14 246 190 14 246 190 14
46496 -246 190 14 246 190 14 246 190 14 246 190 14
46497 -246 190 14 241 196 14 203 166 17 22 18 6
46498 - 2 2 6 2 2 6 2 2 6 38 38 38
46499 -218 218 218 253 253 253 253 253 253 253 253 253
46500 -253 253 253 253 253 253 253 253 253 253 253 253
46501 -253 253 253 253 253 253 253 253 253 253 253 253
46502 -253 253 253 253 253 253 253 253 253 253 253 253
46503 -250 250 250 206 206 206 198 198 198 202 162 69
46504 -226 170 11 236 178 12 224 166 10 210 150 10
46505 -200 144 11 197 138 11 192 133 9 197 138 11
46506 -210 150 10 226 170 11 242 186 14 246 190 14
46507 -246 190 14 246 186 14 225 175 15 124 112 88
46508 - 62 62 62 30 30 30 14 14 14 6 6 6
46509 - 0 0 0 0 0 0 0 0 0 0 0 0
46510 - 0 0 0 0 0 0 0 0 0 0 0 0
46511 - 0 0 0 0 0 0 0 0 0 0 0 0
46512 - 0 0 0 0 0 0 0 0 0 10 10 10
46513 - 30 30 30 78 78 78 174 135 50 224 166 10
46514 -239 182 13 246 190 14 246 190 14 246 190 14
46515 -246 190 14 246 190 14 246 190 14 246 190 14
46516 -246 190 14 246 190 14 246 190 14 246 190 14
46517 -246 190 14 246 190 14 241 196 14 139 102 15
46518 - 2 2 6 2 2 6 2 2 6 2 2 6
46519 - 78 78 78 250 250 250 253 253 253 253 253 253
46520 -253 253 253 253 253 253 253 253 253 253 253 253
46521 -253 253 253 253 253 253 253 253 253 253 253 253
46522 -253 253 253 253 253 253 253 253 253 253 253 253
46523 -250 250 250 214 214 214 198 198 198 190 150 46
46524 -219 162 10 236 178 12 234 174 13 224 166 10
46525 -216 158 10 213 154 11 213 154 11 216 158 10
46526 -226 170 11 239 182 13 246 190 14 246 190 14
46527 -246 190 14 246 190 14 242 186 14 206 162 42
46528 -101 101 101 58 58 58 30 30 30 14 14 14
46529 - 6 6 6 0 0 0 0 0 0 0 0 0
46530 - 0 0 0 0 0 0 0 0 0 0 0 0
46531 - 0 0 0 0 0 0 0 0 0 0 0 0
46532 - 0 0 0 0 0 0 0 0 0 10 10 10
46533 - 30 30 30 74 74 74 174 135 50 216 158 10
46534 -236 178 12 246 190 14 246 190 14 246 190 14
46535 -246 190 14 246 190 14 246 190 14 246 190 14
46536 -246 190 14 246 190 14 246 190 14 246 190 14
46537 -246 190 14 246 190 14 241 196 14 226 184 13
46538 - 61 42 6 2 2 6 2 2 6 2 2 6
46539 - 22 22 22 238 238 238 253 253 253 253 253 253
46540 -253 253 253 253 253 253 253 253 253 253 253 253
46541 -253 253 253 253 253 253 253 253 253 253 253 253
46542 -253 253 253 253 253 253 253 253 253 253 253 253
46543 -253 253 253 226 226 226 187 187 187 180 133 36
46544 -216 158 10 236 178 12 239 182 13 236 178 12
46545 -230 174 11 226 170 11 226 170 11 230 174 11
46546 -236 178 12 242 186 14 246 190 14 246 190 14
46547 -246 190 14 246 190 14 246 186 14 239 182 13
46548 -206 162 42 106 106 106 66 66 66 34 34 34
46549 - 14 14 14 6 6 6 0 0 0 0 0 0
46550 - 0 0 0 0 0 0 0 0 0 0 0 0
46551 - 0 0 0 0 0 0 0 0 0 0 0 0
46552 - 0 0 0 0 0 0 0 0 0 6 6 6
46553 - 26 26 26 70 70 70 163 133 67 213 154 11
46554 -236 178 12 246 190 14 246 190 14 246 190 14
46555 -246 190 14 246 190 14 246 190 14 246 190 14
46556 -246 190 14 246 190 14 246 190 14 246 190 14
46557 -246 190 14 246 190 14 246 190 14 241 196 14
46558 -190 146 13 18 14 6 2 2 6 2 2 6
46559 - 46 46 46 246 246 246 253 253 253 253 253 253
46560 -253 253 253 253 253 253 253 253 253 253 253 253
46561 -253 253 253 253 253 253 253 253 253 253 253 253
46562 -253 253 253 253 253 253 253 253 253 253 253 253
46563 -253 253 253 221 221 221 86 86 86 156 107 11
46564 -216 158 10 236 178 12 242 186 14 246 186 14
46565 -242 186 14 239 182 13 239 182 13 242 186 14
46566 -242 186 14 246 186 14 246 190 14 246 190 14
46567 -246 190 14 246 190 14 246 190 14 246 190 14
46568 -242 186 14 225 175 15 142 122 72 66 66 66
46569 - 30 30 30 10 10 10 0 0 0 0 0 0
46570 - 0 0 0 0 0 0 0 0 0 0 0 0
46571 - 0 0 0 0 0 0 0 0 0 0 0 0
46572 - 0 0 0 0 0 0 0 0 0 6 6 6
46573 - 26 26 26 70 70 70 163 133 67 210 150 10
46574 -236 178 12 246 190 14 246 190 14 246 190 14
46575 -246 190 14 246 190 14 246 190 14 246 190 14
46576 -246 190 14 246 190 14 246 190 14 246 190 14
46577 -246 190 14 246 190 14 246 190 14 246 190 14
46578 -232 195 16 121 92 8 34 34 34 106 106 106
46579 -221 221 221 253 253 253 253 253 253 253 253 253
46580 -253 253 253 253 253 253 253 253 253 253 253 253
46581 -253 253 253 253 253 253 253 253 253 253 253 253
46582 -253 253 253 253 253 253 253 253 253 253 253 253
46583 -242 242 242 82 82 82 18 14 6 163 110 8
46584 -216 158 10 236 178 12 242 186 14 246 190 14
46585 -246 190 14 246 190 14 246 190 14 246 190 14
46586 -246 190 14 246 190 14 246 190 14 246 190 14
46587 -246 190 14 246 190 14 246 190 14 246 190 14
46588 -246 190 14 246 190 14 242 186 14 163 133 67
46589 - 46 46 46 18 18 18 6 6 6 0 0 0
46590 - 0 0 0 0 0 0 0 0 0 0 0 0
46591 - 0 0 0 0 0 0 0 0 0 0 0 0
46592 - 0 0 0 0 0 0 0 0 0 10 10 10
46593 - 30 30 30 78 78 78 163 133 67 210 150 10
46594 -236 178 12 246 186 14 246 190 14 246 190 14
46595 -246 190 14 246 190 14 246 190 14 246 190 14
46596 -246 190 14 246 190 14 246 190 14 246 190 14
46597 -246 190 14 246 190 14 246 190 14 246 190 14
46598 -241 196 14 215 174 15 190 178 144 253 253 253
46599 -253 253 253 253 253 253 253 253 253 253 253 253
46600 -253 253 253 253 253 253 253 253 253 253 253 253
46601 -253 253 253 253 253 253 253 253 253 253 253 253
46602 -253 253 253 253 253 253 253 253 253 218 218 218
46603 - 58 58 58 2 2 6 22 18 6 167 114 7
46604 -216 158 10 236 178 12 246 186 14 246 190 14
46605 -246 190 14 246 190 14 246 190 14 246 190 14
46606 -246 190 14 246 190 14 246 190 14 246 190 14
46607 -246 190 14 246 190 14 246 190 14 246 190 14
46608 -246 190 14 246 186 14 242 186 14 190 150 46
46609 - 54 54 54 22 22 22 6 6 6 0 0 0
46610 - 0 0 0 0 0 0 0 0 0 0 0 0
46611 - 0 0 0 0 0 0 0 0 0 0 0 0
46612 - 0 0 0 0 0 0 0 0 0 14 14 14
46613 - 38 38 38 86 86 86 180 133 36 213 154 11
46614 -236 178 12 246 186 14 246 190 14 246 190 14
46615 -246 190 14 246 190 14 246 190 14 246 190 14
46616 -246 190 14 246 190 14 246 190 14 246 190 14
46617 -246 190 14 246 190 14 246 190 14 246 190 14
46618 -246 190 14 232 195 16 190 146 13 214 214 214
46619 -253 253 253 253 253 253 253 253 253 253 253 253
46620 -253 253 253 253 253 253 253 253 253 253 253 253
46621 -253 253 253 253 253 253 253 253 253 253 253 253
46622 -253 253 253 250 250 250 170 170 170 26 26 26
46623 - 2 2 6 2 2 6 37 26 9 163 110 8
46624 -219 162 10 239 182 13 246 186 14 246 190 14
46625 -246 190 14 246 190 14 246 190 14 246 190 14
46626 -246 190 14 246 190 14 246 190 14 246 190 14
46627 -246 190 14 246 190 14 246 190 14 246 190 14
46628 -246 186 14 236 178 12 224 166 10 142 122 72
46629 - 46 46 46 18 18 18 6 6 6 0 0 0
46630 - 0 0 0 0 0 0 0 0 0 0 0 0
46631 - 0 0 0 0 0 0 0 0 0 0 0 0
46632 - 0 0 0 0 0 0 6 6 6 18 18 18
46633 - 50 50 50 109 106 95 192 133 9 224 166 10
46634 -242 186 14 246 190 14 246 190 14 246 190 14
46635 -246 190 14 246 190 14 246 190 14 246 190 14
46636 -246 190 14 246 190 14 246 190 14 246 190 14
46637 -246 190 14 246 190 14 246 190 14 246 190 14
46638 -242 186 14 226 184 13 210 162 10 142 110 46
46639 -226 226 226 253 253 253 253 253 253 253 253 253
46640 -253 253 253 253 253 253 253 253 253 253 253 253
46641 -253 253 253 253 253 253 253 253 253 253 253 253
46642 -198 198 198 66 66 66 2 2 6 2 2 6
46643 - 2 2 6 2 2 6 50 34 6 156 107 11
46644 -219 162 10 239 182 13 246 186 14 246 190 14
46645 -246 190 14 246 190 14 246 190 14 246 190 14
46646 -246 190 14 246 190 14 246 190 14 246 190 14
46647 -246 190 14 246 190 14 246 190 14 242 186 14
46648 -234 174 13 213 154 11 154 122 46 66 66 66
46649 - 30 30 30 10 10 10 0 0 0 0 0 0
46650 - 0 0 0 0 0 0 0 0 0 0 0 0
46651 - 0 0 0 0 0 0 0 0 0 0 0 0
46652 - 0 0 0 0 0 0 6 6 6 22 22 22
46653 - 58 58 58 154 121 60 206 145 10 234 174 13
46654 -242 186 14 246 186 14 246 190 14 246 190 14
46655 -246 190 14 246 190 14 246 190 14 246 190 14
46656 -246 190 14 246 190 14 246 190 14 246 190 14
46657 -246 190 14 246 190 14 246 190 14 246 190 14
46658 -246 186 14 236 178 12 210 162 10 163 110 8
46659 - 61 42 6 138 138 138 218 218 218 250 250 250
46660 -253 253 253 253 253 253 253 253 253 250 250 250
46661 -242 242 242 210 210 210 144 144 144 66 66 66
46662 - 6 6 6 2 2 6 2 2 6 2 2 6
46663 - 2 2 6 2 2 6 61 42 6 163 110 8
46664 -216 158 10 236 178 12 246 190 14 246 190 14
46665 -246 190 14 246 190 14 246 190 14 246 190 14
46666 -246 190 14 246 190 14 246 190 14 246 190 14
46667 -246 190 14 239 182 13 230 174 11 216 158 10
46668 -190 142 34 124 112 88 70 70 70 38 38 38
46669 - 18 18 18 6 6 6 0 0 0 0 0 0
46670 - 0 0 0 0 0 0 0 0 0 0 0 0
46671 - 0 0 0 0 0 0 0 0 0 0 0 0
46672 - 0 0 0 0 0 0 6 6 6 22 22 22
46673 - 62 62 62 168 124 44 206 145 10 224 166 10
46674 -236 178 12 239 182 13 242 186 14 242 186 14
46675 -246 186 14 246 190 14 246 190 14 246 190 14
46676 -246 190 14 246 190 14 246 190 14 246 190 14
46677 -246 190 14 246 190 14 246 190 14 246 190 14
46678 -246 190 14 236 178 12 216 158 10 175 118 6
46679 - 80 54 7 2 2 6 6 6 6 30 30 30
46680 - 54 54 54 62 62 62 50 50 50 38 38 38
46681 - 14 14 14 2 2 6 2 2 6 2 2 6
46682 - 2 2 6 2 2 6 2 2 6 2 2 6
46683 - 2 2 6 6 6 6 80 54 7 167 114 7
46684 -213 154 11 236 178 12 246 190 14 246 190 14
46685 -246 190 14 246 190 14 246 190 14 246 190 14
46686 -246 190 14 242 186 14 239 182 13 239 182 13
46687 -230 174 11 210 150 10 174 135 50 124 112 88
46688 - 82 82 82 54 54 54 34 34 34 18 18 18
46689 - 6 6 6 0 0 0 0 0 0 0 0 0
46690 - 0 0 0 0 0 0 0 0 0 0 0 0
46691 - 0 0 0 0 0 0 0 0 0 0 0 0
46692 - 0 0 0 0 0 0 6 6 6 18 18 18
46693 - 50 50 50 158 118 36 192 133 9 200 144 11
46694 -216 158 10 219 162 10 224 166 10 226 170 11
46695 -230 174 11 236 178 12 239 182 13 239 182 13
46696 -242 186 14 246 186 14 246 190 14 246 190 14
46697 -246 190 14 246 190 14 246 190 14 246 190 14
46698 -246 186 14 230 174 11 210 150 10 163 110 8
46699 -104 69 6 10 10 10 2 2 6 2 2 6
46700 - 2 2 6 2 2 6 2 2 6 2 2 6
46701 - 2 2 6 2 2 6 2 2 6 2 2 6
46702 - 2 2 6 2 2 6 2 2 6 2 2 6
46703 - 2 2 6 6 6 6 91 60 6 167 114 7
46704 -206 145 10 230 174 11 242 186 14 246 190 14
46705 -246 190 14 246 190 14 246 186 14 242 186 14
46706 -239 182 13 230 174 11 224 166 10 213 154 11
46707 -180 133 36 124 112 88 86 86 86 58 58 58
46708 - 38 38 38 22 22 22 10 10 10 6 6 6
46709 - 0 0 0 0 0 0 0 0 0 0 0 0
46710 - 0 0 0 0 0 0 0 0 0 0 0 0
46711 - 0 0 0 0 0 0 0 0 0 0 0 0
46712 - 0 0 0 0 0 0 0 0 0 14 14 14
46713 - 34 34 34 70 70 70 138 110 50 158 118 36
46714 -167 114 7 180 123 7 192 133 9 197 138 11
46715 -200 144 11 206 145 10 213 154 11 219 162 10
46716 -224 166 10 230 174 11 239 182 13 242 186 14
46717 -246 186 14 246 186 14 246 186 14 246 186 14
46718 -239 182 13 216 158 10 185 133 11 152 99 6
46719 -104 69 6 18 14 6 2 2 6 2 2 6
46720 - 2 2 6 2 2 6 2 2 6 2 2 6
46721 - 2 2 6 2 2 6 2 2 6 2 2 6
46722 - 2 2 6 2 2 6 2 2 6 2 2 6
46723 - 2 2 6 6 6 6 80 54 7 152 99 6
46724 -192 133 9 219 162 10 236 178 12 239 182 13
46725 -246 186 14 242 186 14 239 182 13 236 178 12
46726 -224 166 10 206 145 10 192 133 9 154 121 60
46727 - 94 94 94 62 62 62 42 42 42 22 22 22
46728 - 14 14 14 6 6 6 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 0 0 0 0 0 0 0 0 0 0 0 0
46731 - 0 0 0 0 0 0 0 0 0 0 0 0
46732 - 0 0 0 0 0 0 0 0 0 6 6 6
46733 - 18 18 18 34 34 34 58 58 58 78 78 78
46734 -101 98 89 124 112 88 142 110 46 156 107 11
46735 -163 110 8 167 114 7 175 118 6 180 123 7
46736 -185 133 11 197 138 11 210 150 10 219 162 10
46737 -226 170 11 236 178 12 236 178 12 234 174 13
46738 -219 162 10 197 138 11 163 110 8 130 83 6
46739 - 91 60 6 10 10 10 2 2 6 2 2 6
46740 - 18 18 18 38 38 38 38 38 38 38 38 38
46741 - 38 38 38 38 38 38 38 38 38 38 38 38
46742 - 38 38 38 38 38 38 26 26 26 2 2 6
46743 - 2 2 6 6 6 6 70 47 6 137 92 6
46744 -175 118 6 200 144 11 219 162 10 230 174 11
46745 -234 174 13 230 174 11 219 162 10 210 150 10
46746 -192 133 9 163 110 8 124 112 88 82 82 82
46747 - 50 50 50 30 30 30 14 14 14 6 6 6
46748 - 0 0 0 0 0 0 0 0 0 0 0 0
46749 - 0 0 0 0 0 0 0 0 0 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 0 0 0 0 0 0 0 0 0
46752 - 0 0 0 0 0 0 0 0 0 0 0 0
46753 - 6 6 6 14 14 14 22 22 22 34 34 34
46754 - 42 42 42 58 58 58 74 74 74 86 86 86
46755 -101 98 89 122 102 70 130 98 46 121 87 25
46756 -137 92 6 152 99 6 163 110 8 180 123 7
46757 -185 133 11 197 138 11 206 145 10 200 144 11
46758 -180 123 7 156 107 11 130 83 6 104 69 6
46759 - 50 34 6 54 54 54 110 110 110 101 98 89
46760 - 86 86 86 82 82 82 78 78 78 78 78 78
46761 - 78 78 78 78 78 78 78 78 78 78 78 78
46762 - 78 78 78 82 82 82 86 86 86 94 94 94
46763 -106 106 106 101 101 101 86 66 34 124 80 6
46764 -156 107 11 180 123 7 192 133 9 200 144 11
46765 -206 145 10 200 144 11 192 133 9 175 118 6
46766 -139 102 15 109 106 95 70 70 70 42 42 42
46767 - 22 22 22 10 10 10 0 0 0 0 0 0
46768 - 0 0 0 0 0 0 0 0 0 0 0 0
46769 - 0 0 0 0 0 0 0 0 0 0 0 0
46770 - 0 0 0 0 0 0 0 0 0 0 0 0
46771 - 0 0 0 0 0 0 0 0 0 0 0 0
46772 - 0 0 0 0 0 0 0 0 0 0 0 0
46773 - 0 0 0 0 0 0 6 6 6 10 10 10
46774 - 14 14 14 22 22 22 30 30 30 38 38 38
46775 - 50 50 50 62 62 62 74 74 74 90 90 90
46776 -101 98 89 112 100 78 121 87 25 124 80 6
46777 -137 92 6 152 99 6 152 99 6 152 99 6
46778 -138 86 6 124 80 6 98 70 6 86 66 30
46779 -101 98 89 82 82 82 58 58 58 46 46 46
46780 - 38 38 38 34 34 34 34 34 34 34 34 34
46781 - 34 34 34 34 34 34 34 34 34 34 34 34
46782 - 34 34 34 34 34 34 38 38 38 42 42 42
46783 - 54 54 54 82 82 82 94 86 76 91 60 6
46784 -134 86 6 156 107 11 167 114 7 175 118 6
46785 -175 118 6 167 114 7 152 99 6 121 87 25
46786 -101 98 89 62 62 62 34 34 34 18 18 18
46787 - 6 6 6 0 0 0 0 0 0 0 0 0
46788 - 0 0 0 0 0 0 0 0 0 0 0 0
46789 - 0 0 0 0 0 0 0 0 0 0 0 0
46790 - 0 0 0 0 0 0 0 0 0 0 0 0
46791 - 0 0 0 0 0 0 0 0 0 0 0 0
46792 - 0 0 0 0 0 0 0 0 0 0 0 0
46793 - 0 0 0 0 0 0 0 0 0 0 0 0
46794 - 0 0 0 6 6 6 6 6 6 10 10 10
46795 - 18 18 18 22 22 22 30 30 30 42 42 42
46796 - 50 50 50 66 66 66 86 86 86 101 98 89
46797 -106 86 58 98 70 6 104 69 6 104 69 6
46798 -104 69 6 91 60 6 82 62 34 90 90 90
46799 - 62 62 62 38 38 38 22 22 22 14 14 14
46800 - 10 10 10 10 10 10 10 10 10 10 10 10
46801 - 10 10 10 10 10 10 6 6 6 10 10 10
46802 - 10 10 10 10 10 10 10 10 10 14 14 14
46803 - 22 22 22 42 42 42 70 70 70 89 81 66
46804 - 80 54 7 104 69 6 124 80 6 137 92 6
46805 -134 86 6 116 81 8 100 82 52 86 86 86
46806 - 58 58 58 30 30 30 14 14 14 6 6 6
46807 - 0 0 0 0 0 0 0 0 0 0 0 0
46808 - 0 0 0 0 0 0 0 0 0 0 0 0
46809 - 0 0 0 0 0 0 0 0 0 0 0 0
46810 - 0 0 0 0 0 0 0 0 0 0 0 0
46811 - 0 0 0 0 0 0 0 0 0 0 0 0
46812 - 0 0 0 0 0 0 0 0 0 0 0 0
46813 - 0 0 0 0 0 0 0 0 0 0 0 0
46814 - 0 0 0 0 0 0 0 0 0 0 0 0
46815 - 0 0 0 6 6 6 10 10 10 14 14 14
46816 - 18 18 18 26 26 26 38 38 38 54 54 54
46817 - 70 70 70 86 86 86 94 86 76 89 81 66
46818 - 89 81 66 86 86 86 74 74 74 50 50 50
46819 - 30 30 30 14 14 14 6 6 6 0 0 0
46820 - 0 0 0 0 0 0 0 0 0 0 0 0
46821 - 0 0 0 0 0 0 0 0 0 0 0 0
46822 - 0 0 0 0 0 0 0 0 0 0 0 0
46823 - 6 6 6 18 18 18 34 34 34 58 58 58
46824 - 82 82 82 89 81 66 89 81 66 89 81 66
46825 - 94 86 66 94 86 76 74 74 74 50 50 50
46826 - 26 26 26 14 14 14 6 6 6 0 0 0
46827 - 0 0 0 0 0 0 0 0 0 0 0 0
46828 - 0 0 0 0 0 0 0 0 0 0 0 0
46829 - 0 0 0 0 0 0 0 0 0 0 0 0
46830 - 0 0 0 0 0 0 0 0 0 0 0 0
46831 - 0 0 0 0 0 0 0 0 0 0 0 0
46832 - 0 0 0 0 0 0 0 0 0 0 0 0
46833 - 0 0 0 0 0 0 0 0 0 0 0 0
46834 - 0 0 0 0 0 0 0 0 0 0 0 0
46835 - 0 0 0 0 0 0 0 0 0 0 0 0
46836 - 6 6 6 6 6 6 14 14 14 18 18 18
46837 - 30 30 30 38 38 38 46 46 46 54 54 54
46838 - 50 50 50 42 42 42 30 30 30 18 18 18
46839 - 10 10 10 0 0 0 0 0 0 0 0 0
46840 - 0 0 0 0 0 0 0 0 0 0 0 0
46841 - 0 0 0 0 0 0 0 0 0 0 0 0
46842 - 0 0 0 0 0 0 0 0 0 0 0 0
46843 - 0 0 0 6 6 6 14 14 14 26 26 26
46844 - 38 38 38 50 50 50 58 58 58 58 58 58
46845 - 54 54 54 42 42 42 30 30 30 18 18 18
46846 - 10 10 10 0 0 0 0 0 0 0 0 0
46847 - 0 0 0 0 0 0 0 0 0 0 0 0
46848 - 0 0 0 0 0 0 0 0 0 0 0 0
46849 - 0 0 0 0 0 0 0 0 0 0 0 0
46850 - 0 0 0 0 0 0 0 0 0 0 0 0
46851 - 0 0 0 0 0 0 0 0 0 0 0 0
46852 - 0 0 0 0 0 0 0 0 0 0 0 0
46853 - 0 0 0 0 0 0 0 0 0 0 0 0
46854 - 0 0 0 0 0 0 0 0 0 0 0 0
46855 - 0 0 0 0 0 0 0 0 0 0 0 0
46856 - 0 0 0 0 0 0 0 0 0 6 6 6
46857 - 6 6 6 10 10 10 14 14 14 18 18 18
46858 - 18 18 18 14 14 14 10 10 10 6 6 6
46859 - 0 0 0 0 0 0 0 0 0 0 0 0
46860 - 0 0 0 0 0 0 0 0 0 0 0 0
46861 - 0 0 0 0 0 0 0 0 0 0 0 0
46862 - 0 0 0 0 0 0 0 0 0 0 0 0
46863 - 0 0 0 0 0 0 0 0 0 6 6 6
46864 - 14 14 14 18 18 18 22 22 22 22 22 22
46865 - 18 18 18 14 14 14 10 10 10 6 6 6
46866 - 0 0 0 0 0 0 0 0 0 0 0 0
46867 - 0 0 0 0 0 0 0 0 0 0 0 0
46868 - 0 0 0 0 0 0 0 0 0 0 0 0
46869 - 0 0 0 0 0 0 0 0 0 0 0 0
46870 - 0 0 0 0 0 0 0 0 0 0 0 0
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46926 +4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46940 +4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46954 +4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46959 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46960 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46964 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46965 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46966 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46968 +4 4 4 4 4 4
46969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46973 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46974 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46975 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46978 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46979 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46980 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46981 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46982 +4 4 4 4 4 4
46983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46987 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46988 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46989 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46992 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46993 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46994 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46995 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46996 +4 4 4 4 4 4
46997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47000 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
47001 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
47002 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
47003 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47005 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47006 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
47007 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
47008 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
47009 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
47010 +4 4 4 4 4 4
47011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47014 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
47015 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
47016 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
47017 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
47018 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47019 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
47020 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
47021 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
47022 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
47023 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
47024 +4 4 4 4 4 4
47025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47028 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
47029 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
47030 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
47031 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
47032 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47033 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
47034 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
47035 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
47036 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
47037 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
47038 +4 4 4 4 4 4
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
47042 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
47043 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
47044 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
47045 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
47046 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
47047 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
47048 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
47049 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
47050 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
47051 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
47052 +4 4 4 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47055 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
47056 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
47057 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
47058 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
47059 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
47060 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
47061 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
47062 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
47063 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
47064 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
47065 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
47066 +4 4 4 4 4 4
47067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47069 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
47070 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
47071 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
47072 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
47073 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
47074 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
47075 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
47076 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
47077 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
47078 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
47079 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47080 +4 4 4 4 4 4
47081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47083 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
47084 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
47085 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
47086 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
47087 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
47088 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
47089 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
47090 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
47091 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47092 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47093 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
47094 +4 4 4 4 4 4
47095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47096 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
47097 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47098 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47099 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47100 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47101 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47102 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47103 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47104 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47105 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47106 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47107 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47108 +4 4 4 4 4 4
47109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47110 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47111 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47112 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47113 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47114 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47115 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47116 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47117 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47118 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47119 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47120 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47121 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47122 +0 0 0 4 4 4
47123 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47124 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47125 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47126 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47127 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47128 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47129 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47130 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47131 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47132 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47133 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47134 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47135 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47136 +2 0 0 0 0 0
47137 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47138 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47139 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47140 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47141 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47142 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47143 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47144 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47145 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47146 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47147 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47148 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47149 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47150 +37 38 37 0 0 0
47151 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47152 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47153 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47154 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47155 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47156 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47157 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47158 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47159 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47160 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47161 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47162 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47163 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47164 +85 115 134 4 0 0
47165 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47166 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47167 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47168 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47169 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47170 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47171 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47172 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47173 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47174 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47175 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47176 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47177 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47178 +60 73 81 4 0 0
47179 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47180 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47181 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47182 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47183 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47184 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47185 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47186 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47187 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47188 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47189 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47190 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47191 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47192 +16 19 21 4 0 0
47193 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47194 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47195 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47196 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47197 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47198 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47199 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47200 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47201 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47202 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47203 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47204 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47205 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47206 +4 0 0 4 3 3
47207 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47208 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47209 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47211 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47212 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47213 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47214 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47215 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47216 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47217 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47218 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47219 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47220 +3 2 2 4 4 4
47221 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47222 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47223 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47224 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47225 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47226 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47227 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47228 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47229 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47230 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47231 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47232 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47233 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47234 +4 4 4 4 4 4
47235 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47236 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47237 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47238 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47239 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47240 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47241 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47242 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47243 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47244 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47245 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47246 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47247 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47248 +4 4 4 4 4 4
47249 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47250 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47251 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47252 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47253 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47254 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47255 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47256 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47257 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47258 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47259 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47260 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47261 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47262 +5 5 5 5 5 5
47263 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47264 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47265 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47266 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47267 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47268 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47269 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47270 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47271 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47272 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47273 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47274 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47275 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47276 +5 5 5 4 4 4
47277 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47278 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47279 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47280 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47281 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47282 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47283 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47284 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47285 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47286 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47287 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47288 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47290 +4 4 4 4 4 4
47291 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47292 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47293 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47294 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47295 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47296 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47297 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47298 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47299 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47300 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47301 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47302 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47304 +4 4 4 4 4 4
47305 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47306 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47307 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47308 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47309 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47310 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47311 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47312 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47313 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47314 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47315 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47318 +4 4 4 4 4 4
47319 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47320 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47321 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47322 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47323 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47324 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47325 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47326 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47327 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47328 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47329 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47332 +4 4 4 4 4 4
47333 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47334 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47335 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47336 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47337 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47338 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47339 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47340 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47341 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47342 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47343 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47346 +4 4 4 4 4 4
47347 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47348 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47349 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47350 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47351 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47352 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47353 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47354 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47355 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47356 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47357 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47360 +4 4 4 4 4 4
47361 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47362 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47363 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47364 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47365 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47366 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47367 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47368 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47369 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47370 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47371 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 4 4 4 4
47375 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47376 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47377 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47378 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47379 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47380 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47381 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47382 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47383 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47384 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47385 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47388 +4 4 4 4 4 4
47389 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47390 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47391 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47392 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47393 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47394 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47395 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47396 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47397 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47398 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47399 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47402 +4 4 4 4 4 4
47403 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47404 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47405 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47406 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47407 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47408 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47409 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47410 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47411 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47412 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47413 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47416 +4 4 4 4 4 4
47417 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47418 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47419 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47420 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47421 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47422 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47423 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47424 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47425 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47426 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47427 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47430 +4 4 4 4 4 4
47431 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47432 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47433 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47434 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47435 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47436 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47437 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47438 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47439 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47440 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47441 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47444 +4 4 4 4 4 4
47445 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47446 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47447 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47448 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47449 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47450 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47451 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47452 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47453 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47454 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47455 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47458 +4 4 4 4 4 4
47459 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47460 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47461 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47462 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47463 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47464 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47465 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47466 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47467 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47468 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47469 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47472 +4 4 4 4 4 4
47473 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47474 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47475 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47476 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47477 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47478 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47479 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47480 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47481 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47482 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47483 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47486 +4 4 4 4 4 4
47487 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47488 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47489 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47490 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47491 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47492 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47493 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47494 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47495 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47496 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47497 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47500 +4 4 4 4 4 4
47501 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47502 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47503 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47504 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47505 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47506 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47507 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47508 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47509 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47510 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47511 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47514 +4 4 4 4 4 4
47515 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47516 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47517 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47518 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47519 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47520 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47521 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47522 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47523 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47524 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47525 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47528 +4 4 4 4 4 4
47529 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47530 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47531 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47532 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47533 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47534 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47535 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47536 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47537 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47538 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47539 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47542 +4 4 4 4 4 4
47543 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47544 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47545 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47546 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47547 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47548 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47549 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47550 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47551 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47552 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47553 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47556 +4 4 4 4 4 4
47557 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47558 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47559 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47560 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47561 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47562 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47563 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47564 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47565 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47566 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47567 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47570 +4 4 4 4 4 4
47571 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47572 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47573 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47574 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47575 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47576 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47577 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47578 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47579 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47580 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47581 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47584 +4 4 4 4 4 4
47585 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47586 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47587 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47588 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47589 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47590 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47591 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47592 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47593 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47594 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47595 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47598 +4 4 4 4 4 4
47599 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47600 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47601 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47602 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47603 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47604 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47605 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47606 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47607 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47608 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47609 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47612 +4 4 4 4 4 4
47613 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47614 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47615 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47617 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47618 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47619 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47620 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47621 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47622 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47623 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47626 +4 4 4 4 4 4
47627 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47628 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47629 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47630 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47631 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47632 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47633 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47634 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47635 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47636 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47637 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47640 +4 4 4 4 4 4
47641 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47642 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47643 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47644 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47645 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47646 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47647 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47648 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47649 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47650 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47651 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47654 +4 4 4 4 4 4
47655 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47656 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47657 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47658 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47659 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47660 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47661 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47662 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47663 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47664 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47665 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47668 +4 4 4 4 4 4
47669 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47670 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47671 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47672 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47673 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47674 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47675 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47676 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47677 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47678 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47679 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47682 +4 4 4 4 4 4
47683 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47684 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47685 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47686 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47687 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47688 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47689 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47690 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47691 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47692 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47696 +4 4 4 4 4 4
47697 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47698 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47699 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47700 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47701 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47702 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47703 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47704 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47705 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47706 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47710 +4 4 4 4 4 4
47711 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47712 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47713 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47714 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47715 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47716 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47717 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47718 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47719 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47720 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47724 +4 4 4 4 4 4
47725 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47726 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47727 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47728 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47729 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47730 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47731 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47732 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47733 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47734 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47738 +4 4 4 4 4 4
47739 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47740 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47741 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47742 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47743 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47744 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47745 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47746 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47747 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47752 +4 4 4 4 4 4
47753 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47754 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47755 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47756 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47757 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47758 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47759 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47760 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47761 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47766 +4 4 4 4 4 4
47767 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47768 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47769 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47770 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47771 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47772 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47773 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47774 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47775 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47780 +4 4 4 4 4 4
47781 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47782 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47783 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47784 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47785 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47786 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47787 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47788 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47794 +4 4 4 4 4 4
47795 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47796 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47797 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47798 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47799 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47800 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47801 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47802 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47808 +4 4 4 4 4 4
47809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47810 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47811 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47812 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47813 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47814 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47815 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47816 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47822 +4 4 4 4 4 4
47823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47824 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47825 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47826 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47827 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47828 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47829 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47830 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47836 +4 4 4 4 4 4
47837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47839 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47840 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47841 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47842 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47843 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47844 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47850 +4 4 4 4 4 4
47851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47853 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47854 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47855 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47856 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47857 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47858 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47864 +4 4 4 4 4 4
47865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47868 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47869 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47870 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47871 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47878 +4 4 4 4 4 4
47879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47882 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47883 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47884 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47885 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47892 +4 4 4 4 4 4
47893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47896 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47897 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47898 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47899 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47906 +4 4 4 4 4 4
47907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47910 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47911 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47912 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47913 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47920 +4 4 4 4 4 4
47921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47925 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47926 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47927 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47934 +4 4 4 4 4 4
47935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47939 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47940 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47941 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47948 +4 4 4 4 4 4
47949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47953 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47954 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47955 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47962 +4 4 4 4 4 4
47963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47967 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47968 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47976 +4 4 4 4 4 4
47977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47981 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47982 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47990 +4 4 4 4 4 4
47991 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47992 index fe92eed..106e085 100644
47993 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47994 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47995 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47996 struct mb862xxfb_par *par = info->par;
47997
47998 if (info->var.bits_per_pixel == 32) {
47999 - info->fbops->fb_fillrect = cfb_fillrect;
48000 - info->fbops->fb_copyarea = cfb_copyarea;
48001 - info->fbops->fb_imageblit = cfb_imageblit;
48002 + pax_open_kernel();
48003 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
48004 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
48005 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
48006 + pax_close_kernel();
48007 } else {
48008 outreg(disp, GC_L0EM, 3);
48009 - info->fbops->fb_fillrect = mb86290fb_fillrect;
48010 - info->fbops->fb_copyarea = mb86290fb_copyarea;
48011 - info->fbops->fb_imageblit = mb86290fb_imageblit;
48012 + pax_open_kernel();
48013 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
48014 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
48015 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
48016 + pax_close_kernel();
48017 }
48018 outreg(draw, GDC_REG_DRAW_BASE, 0);
48019 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
48020 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
48021 index ff22871..b129bed 100644
48022 --- a/drivers/video/nvidia/nvidia.c
48023 +++ b/drivers/video/nvidia/nvidia.c
48024 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
48025 info->fix.line_length = (info->var.xres_virtual *
48026 info->var.bits_per_pixel) >> 3;
48027 if (info->var.accel_flags) {
48028 - info->fbops->fb_imageblit = nvidiafb_imageblit;
48029 - info->fbops->fb_fillrect = nvidiafb_fillrect;
48030 - info->fbops->fb_copyarea = nvidiafb_copyarea;
48031 - info->fbops->fb_sync = nvidiafb_sync;
48032 + pax_open_kernel();
48033 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
48034 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
48035 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
48036 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
48037 + pax_close_kernel();
48038 info->pixmap.scan_align = 4;
48039 info->flags &= ~FBINFO_HWACCEL_DISABLED;
48040 info->flags |= FBINFO_READS_FAST;
48041 NVResetGraphics(info);
48042 } else {
48043 - info->fbops->fb_imageblit = cfb_imageblit;
48044 - info->fbops->fb_fillrect = cfb_fillrect;
48045 - info->fbops->fb_copyarea = cfb_copyarea;
48046 - info->fbops->fb_sync = NULL;
48047 + pax_open_kernel();
48048 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
48049 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
48050 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
48051 + *(void **)&info->fbops->fb_sync = NULL;
48052 + pax_close_kernel();
48053 info->pixmap.scan_align = 1;
48054 info->flags |= FBINFO_HWACCEL_DISABLED;
48055 info->flags &= ~FBINFO_READS_FAST;
48056 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
48057 info->pixmap.size = 8 * 1024;
48058 info->pixmap.flags = FB_PIXMAP_SYSTEM;
48059
48060 - if (!hwcur)
48061 - info->fbops->fb_cursor = NULL;
48062 + if (!hwcur) {
48063 + pax_open_kernel();
48064 + *(void **)&info->fbops->fb_cursor = NULL;
48065 + pax_close_kernel();
48066 + }
48067
48068 info->var.accel_flags = (!noaccel);
48069
48070 diff --git a/drivers/video/output.c b/drivers/video/output.c
48071 index 0d6f2cd..6285b97 100644
48072 --- a/drivers/video/output.c
48073 +++ b/drivers/video/output.c
48074 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
48075 new_dev->props = op;
48076 new_dev->dev.class = &video_output_class;
48077 new_dev->dev.parent = dev;
48078 - dev_set_name(&new_dev->dev, name);
48079 + dev_set_name(&new_dev->dev, "%s", name);
48080 dev_set_drvdata(&new_dev->dev, devdata);
48081 ret_code = device_register(&new_dev->dev);
48082 if (ret_code) {
48083 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
48084 index 05c2dc3..ea1f391 100644
48085 --- a/drivers/video/s1d13xxxfb.c
48086 +++ b/drivers/video/s1d13xxxfb.c
48087 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
48088
48089 switch(prod_id) {
48090 case S1D13506_PROD_ID: /* activate acceleration */
48091 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48092 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48093 + pax_open_kernel();
48094 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48095 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48096 + pax_close_kernel();
48097 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
48098 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
48099 break;
48100 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
48101 index b2b33fc..f9f4658 100644
48102 --- a/drivers/video/smscufx.c
48103 +++ b/drivers/video/smscufx.c
48104 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48105 fb_deferred_io_cleanup(info);
48106 kfree(info->fbdefio);
48107 info->fbdefio = NULL;
48108 - info->fbops->fb_mmap = ufx_ops_mmap;
48109 + pax_open_kernel();
48110 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48111 + pax_close_kernel();
48112 }
48113
48114 pr_debug("released /dev/fb%d user=%d count=%d",
48115 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48116 index ec03e72..f578436 100644
48117 --- a/drivers/video/udlfb.c
48118 +++ b/drivers/video/udlfb.c
48119 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48120 dlfb_urb_completion(urb);
48121
48122 error:
48123 - atomic_add(bytes_sent, &dev->bytes_sent);
48124 - atomic_add(bytes_identical, &dev->bytes_identical);
48125 - atomic_add(width*height*2, &dev->bytes_rendered);
48126 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48127 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48128 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48129 end_cycles = get_cycles();
48130 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48131 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48132 >> 10)), /* Kcycles */
48133 &dev->cpu_kcycles_used);
48134
48135 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48136 dlfb_urb_completion(urb);
48137
48138 error:
48139 - atomic_add(bytes_sent, &dev->bytes_sent);
48140 - atomic_add(bytes_identical, &dev->bytes_identical);
48141 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48142 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48143 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48144 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48145 end_cycles = get_cycles();
48146 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48147 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48148 >> 10)), /* Kcycles */
48149 &dev->cpu_kcycles_used);
48150 }
48151 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48152 fb_deferred_io_cleanup(info);
48153 kfree(info->fbdefio);
48154 info->fbdefio = NULL;
48155 - info->fbops->fb_mmap = dlfb_ops_mmap;
48156 + pax_open_kernel();
48157 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48158 + pax_close_kernel();
48159 }
48160
48161 pr_warn("released /dev/fb%d user=%d count=%d\n",
48162 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48163 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48164 struct dlfb_data *dev = fb_info->par;
48165 return snprintf(buf, PAGE_SIZE, "%u\n",
48166 - atomic_read(&dev->bytes_rendered));
48167 + atomic_read_unchecked(&dev->bytes_rendered));
48168 }
48169
48170 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48171 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48172 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48173 struct dlfb_data *dev = fb_info->par;
48174 return snprintf(buf, PAGE_SIZE, "%u\n",
48175 - atomic_read(&dev->bytes_identical));
48176 + atomic_read_unchecked(&dev->bytes_identical));
48177 }
48178
48179 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48180 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48181 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48182 struct dlfb_data *dev = fb_info->par;
48183 return snprintf(buf, PAGE_SIZE, "%u\n",
48184 - atomic_read(&dev->bytes_sent));
48185 + atomic_read_unchecked(&dev->bytes_sent));
48186 }
48187
48188 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48189 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48190 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48191 struct dlfb_data *dev = fb_info->par;
48192 return snprintf(buf, PAGE_SIZE, "%u\n",
48193 - atomic_read(&dev->cpu_kcycles_used));
48194 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48195 }
48196
48197 static ssize_t edid_show(
48198 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48199 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48200 struct dlfb_data *dev = fb_info->par;
48201
48202 - atomic_set(&dev->bytes_rendered, 0);
48203 - atomic_set(&dev->bytes_identical, 0);
48204 - atomic_set(&dev->bytes_sent, 0);
48205 - atomic_set(&dev->cpu_kcycles_used, 0);
48206 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48207 + atomic_set_unchecked(&dev->bytes_identical, 0);
48208 + atomic_set_unchecked(&dev->bytes_sent, 0);
48209 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48210
48211 return count;
48212 }
48213 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48214 index e328a61..1b08ecb 100644
48215 --- a/drivers/video/uvesafb.c
48216 +++ b/drivers/video/uvesafb.c
48217 @@ -19,6 +19,7 @@
48218 #include <linux/io.h>
48219 #include <linux/mutex.h>
48220 #include <linux/slab.h>
48221 +#include <linux/moduleloader.h>
48222 #include <video/edid.h>
48223 #include <video/uvesafb.h>
48224 #ifdef CONFIG_X86
48225 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48226 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48227 par->pmi_setpal = par->ypan = 0;
48228 } else {
48229 +
48230 +#ifdef CONFIG_PAX_KERNEXEC
48231 +#ifdef CONFIG_MODULES
48232 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48233 +#endif
48234 + if (!par->pmi_code) {
48235 + par->pmi_setpal = par->ypan = 0;
48236 + return 0;
48237 + }
48238 +#endif
48239 +
48240 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48241 + task->t.regs.edi);
48242 +
48243 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48244 + pax_open_kernel();
48245 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48246 + pax_close_kernel();
48247 +
48248 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48249 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48250 +#else
48251 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48252 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48253 +#endif
48254 +
48255 printk(KERN_INFO "uvesafb: protected mode interface info at "
48256 "%04x:%04x\n",
48257 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48258 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48259 par->ypan = ypan;
48260
48261 if (par->pmi_setpal || par->ypan) {
48262 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48263 if (__supported_pte_mask & _PAGE_NX) {
48264 par->pmi_setpal = par->ypan = 0;
48265 printk(KERN_WARNING "uvesafb: NX protection is actively."
48266 "We have better not to use the PMI.\n");
48267 - } else {
48268 + } else
48269 +#endif
48270 uvesafb_vbe_getpmi(task, par);
48271 - }
48272 }
48273 #else
48274 /* The protected mode interface is not available on non-x86. */
48275 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48276 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48277
48278 /* Disable blanking if the user requested so. */
48279 - if (!blank)
48280 - info->fbops->fb_blank = NULL;
48281 + if (!blank) {
48282 + pax_open_kernel();
48283 + *(void **)&info->fbops->fb_blank = NULL;
48284 + pax_close_kernel();
48285 + }
48286
48287 /*
48288 * Find out how much IO memory is required for the mode with
48289 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48290 info->flags = FBINFO_FLAG_DEFAULT |
48291 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48292
48293 - if (!par->ypan)
48294 - info->fbops->fb_pan_display = NULL;
48295 + if (!par->ypan) {
48296 + pax_open_kernel();
48297 + *(void **)&info->fbops->fb_pan_display = NULL;
48298 + pax_close_kernel();
48299 + }
48300 }
48301
48302 static void uvesafb_init_mtrr(struct fb_info *info)
48303 @@ -1836,6 +1866,11 @@ out:
48304 if (par->vbe_modes)
48305 kfree(par->vbe_modes);
48306
48307 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48308 + if (par->pmi_code)
48309 + module_free_exec(NULL, par->pmi_code);
48310 +#endif
48311 +
48312 framebuffer_release(info);
48313 return err;
48314 }
48315 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48316 kfree(par->vbe_state_orig);
48317 if (par->vbe_state_saved)
48318 kfree(par->vbe_state_saved);
48319 +
48320 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48321 + if (par->pmi_code)
48322 + module_free_exec(NULL, par->pmi_code);
48323 +#endif
48324 +
48325 }
48326
48327 framebuffer_release(info);
48328 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48329 index 501b340..d80aa17 100644
48330 --- a/drivers/video/vesafb.c
48331 +++ b/drivers/video/vesafb.c
48332 @@ -9,6 +9,7 @@
48333 */
48334
48335 #include <linux/module.h>
48336 +#include <linux/moduleloader.h>
48337 #include <linux/kernel.h>
48338 #include <linux/errno.h>
48339 #include <linux/string.h>
48340 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48341 static int vram_total __initdata; /* Set total amount of memory */
48342 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48343 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48344 -static void (*pmi_start)(void) __read_mostly;
48345 -static void (*pmi_pal) (void) __read_mostly;
48346 +static void (*pmi_start)(void) __read_only;
48347 +static void (*pmi_pal) (void) __read_only;
48348 static int depth __read_mostly;
48349 static int vga_compat __read_mostly;
48350 /* --------------------------------------------------------------------- */
48351 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48352 unsigned int size_vmode;
48353 unsigned int size_remap;
48354 unsigned int size_total;
48355 + void *pmi_code = NULL;
48356
48357 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48358 return -ENODEV;
48359 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48360 size_remap = size_total;
48361 vesafb_fix.smem_len = size_remap;
48362
48363 -#ifndef __i386__
48364 - screen_info.vesapm_seg = 0;
48365 -#endif
48366 -
48367 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48368 printk(KERN_WARNING
48369 "vesafb: cannot reserve video memory at 0x%lx\n",
48370 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48371 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48372 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48373
48374 +#ifdef __i386__
48375 +
48376 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48377 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48378 + if (!pmi_code)
48379 +#elif !defined(CONFIG_PAX_KERNEXEC)
48380 + if (0)
48381 +#endif
48382 +
48383 +#endif
48384 + screen_info.vesapm_seg = 0;
48385 +
48386 if (screen_info.vesapm_seg) {
48387 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48388 - screen_info.vesapm_seg,screen_info.vesapm_off);
48389 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48390 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48391 }
48392
48393 if (screen_info.vesapm_seg < 0xc000)
48394 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48395
48396 if (ypan || pmi_setpal) {
48397 unsigned short *pmi_base;
48398 +
48399 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48400 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48401 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48402 +
48403 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48404 + pax_open_kernel();
48405 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48406 +#else
48407 + pmi_code = pmi_base;
48408 +#endif
48409 +
48410 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48411 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48412 +
48413 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48414 + pmi_start = ktva_ktla(pmi_start);
48415 + pmi_pal = ktva_ktla(pmi_pal);
48416 + pax_close_kernel();
48417 +#endif
48418 +
48419 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48420 if (pmi_base[3]) {
48421 printk(KERN_INFO "vesafb: pmi: ports = ");
48422 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48423 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48424 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48425
48426 - if (!ypan)
48427 - info->fbops->fb_pan_display = NULL;
48428 + if (!ypan) {
48429 + pax_open_kernel();
48430 + *(void **)&info->fbops->fb_pan_display = NULL;
48431 + pax_close_kernel();
48432 + }
48433
48434 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48435 err = -ENOMEM;
48436 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48437 info->node, info->fix.id);
48438 return 0;
48439 err:
48440 +
48441 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48442 + module_free_exec(NULL, pmi_code);
48443 +#endif
48444 +
48445 if (info->screen_base)
48446 iounmap(info->screen_base);
48447 framebuffer_release(info);
48448 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48449 index 88714ae..16c2e11 100644
48450 --- a/drivers/video/via/via_clock.h
48451 +++ b/drivers/video/via/via_clock.h
48452 @@ -56,7 +56,7 @@ struct via_clock {
48453
48454 void (*set_engine_pll_state)(u8 state);
48455 void (*set_engine_pll)(struct via_pll_config config);
48456 -};
48457 +} __no_const;
48458
48459
48460 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48461 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48462 index fef20db..d28b1ab 100644
48463 --- a/drivers/xen/xenfs/xenstored.c
48464 +++ b/drivers/xen/xenfs/xenstored.c
48465 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48466 static int xsd_kva_open(struct inode *inode, struct file *file)
48467 {
48468 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48469 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48470 + NULL);
48471 +#else
48472 xen_store_interface);
48473 +#endif
48474 +
48475 if (!file->private_data)
48476 return -ENOMEM;
48477 return 0;
48478 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48479 index 055562c..fdfb10d 100644
48480 --- a/fs/9p/vfs_addr.c
48481 +++ b/fs/9p/vfs_addr.c
48482 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48483
48484 retval = v9fs_file_write_internal(inode,
48485 v9inode->writeback_fid,
48486 - (__force const char __user *)buffer,
48487 + (const char __force_user *)buffer,
48488 len, &offset, 0);
48489 if (retval > 0)
48490 retval = 0;
48491 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48492 index d86edc8..40ff2fb 100644
48493 --- a/fs/9p/vfs_inode.c
48494 +++ b/fs/9p/vfs_inode.c
48495 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48496 void
48497 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48498 {
48499 - char *s = nd_get_link(nd);
48500 + const char *s = nd_get_link(nd);
48501
48502 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48503 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48504 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48505 index 370b24c..ff0be7b 100644
48506 --- a/fs/Kconfig.binfmt
48507 +++ b/fs/Kconfig.binfmt
48508 @@ -103,7 +103,7 @@ config HAVE_AOUT
48509
48510 config BINFMT_AOUT
48511 tristate "Kernel support for a.out and ECOFF binaries"
48512 - depends on HAVE_AOUT
48513 + depends on HAVE_AOUT && BROKEN
48514 ---help---
48515 A.out (Assembler.OUTput) is a set of formats for libraries and
48516 executables used in the earliest versions of UNIX. Linux used
48517 diff --git a/fs/aio.c b/fs/aio.c
48518 index 2bbcacf..8614116 100644
48519 --- a/fs/aio.c
48520 +++ b/fs/aio.c
48521 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48522 size += sizeof(struct io_event) * nr_events;
48523 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48524
48525 - if (nr_pages < 0)
48526 + if (nr_pages <= 0)
48527 return -EINVAL;
48528
48529 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48530 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
48531 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48532 {
48533 ssize_t ret;
48534 + struct iovec iovstack;
48535
48536 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48537
48538 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48539 if (compat)
48540 ret = compat_rw_copy_check_uvector(rw,
48541 (struct compat_iovec __user *)kiocb->ki_buf,
48542 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48543 + kiocb->ki_nr_segs, 1, &iovstack,
48544 &kiocb->ki_iovec);
48545 else
48546 #endif
48547 ret = rw_copy_check_uvector(rw,
48548 (struct iovec __user *)kiocb->ki_buf,
48549 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48550 + kiocb->ki_nr_segs, 1, &iovstack,
48551 &kiocb->ki_iovec);
48552 if (ret < 0)
48553 return ret;
48554
48555 + if (kiocb->ki_iovec == &iovstack) {
48556 + kiocb->ki_inline_vec = iovstack;
48557 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48558 + }
48559 +
48560 /* ki_nbytes now reflect bytes instead of segs */
48561 kiocb->ki_nbytes = ret;
48562 return 0;
48563 diff --git a/fs/attr.c b/fs/attr.c
48564 index 1449adb..a2038c2 100644
48565 --- a/fs/attr.c
48566 +++ b/fs/attr.c
48567 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48568 unsigned long limit;
48569
48570 limit = rlimit(RLIMIT_FSIZE);
48571 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48572 if (limit != RLIM_INFINITY && offset > limit)
48573 goto out_sig;
48574 if (offset > inode->i_sb->s_maxbytes)
48575 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48576 index 3db70da..7aeec5b 100644
48577 --- a/fs/autofs4/waitq.c
48578 +++ b/fs/autofs4/waitq.c
48579 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48580 {
48581 unsigned long sigpipe, flags;
48582 mm_segment_t fs;
48583 - const char *data = (const char *)addr;
48584 + const char __user *data = (const char __force_user *)addr;
48585 ssize_t wr = 0;
48586
48587 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48588 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48589 return 1;
48590 }
48591
48592 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48593 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48594 +#endif
48595 +
48596 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48597 enum autofs_notify notify)
48598 {
48599 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48600
48601 /* If this is a direct mount request create a dummy name */
48602 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48603 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48604 + /* this name does get written to userland via autofs4_write() */
48605 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48606 +#else
48607 qstr.len = sprintf(name, "%p", dentry);
48608 +#endif
48609 else {
48610 qstr.len = autofs4_getpath(sbi, dentry, &name);
48611 if (!qstr.len) {
48612 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48613 index 2722387..c8dd2a7 100644
48614 --- a/fs/befs/endian.h
48615 +++ b/fs/befs/endian.h
48616 @@ -11,7 +11,7 @@
48617
48618 #include <asm/byteorder.h>
48619
48620 -static inline u64
48621 +static inline u64 __intentional_overflow(-1)
48622 fs64_to_cpu(const struct super_block *sb, fs64 n)
48623 {
48624 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48625 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48626 return (__force fs64)cpu_to_be64(n);
48627 }
48628
48629 -static inline u32
48630 +static inline u32 __intentional_overflow(-1)
48631 fs32_to_cpu(const struct super_block *sb, fs32 n)
48632 {
48633 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48634 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48635 index f95dddc..b1e2c1c 100644
48636 --- a/fs/befs/linuxvfs.c
48637 +++ b/fs/befs/linuxvfs.c
48638 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48639 {
48640 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48641 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48642 - char *link = nd_get_link(nd);
48643 + const char *link = nd_get_link(nd);
48644 if (!IS_ERR(link))
48645 kfree(link);
48646 }
48647 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48648 index bce8769..7fc7544 100644
48649 --- a/fs/binfmt_aout.c
48650 +++ b/fs/binfmt_aout.c
48651 @@ -16,6 +16,7 @@
48652 #include <linux/string.h>
48653 #include <linux/fs.h>
48654 #include <linux/file.h>
48655 +#include <linux/security.h>
48656 #include <linux/stat.h>
48657 #include <linux/fcntl.h>
48658 #include <linux/ptrace.h>
48659 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48660 #endif
48661 # define START_STACK(u) ((void __user *)u.start_stack)
48662
48663 + memset(&dump, 0, sizeof(dump));
48664 +
48665 fs = get_fs();
48666 set_fs(KERNEL_DS);
48667 has_dumped = 1;
48668 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48669
48670 /* If the size of the dump file exceeds the rlimit, then see what would happen
48671 if we wrote the stack, but not the data area. */
48672 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48673 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48674 dump.u_dsize = 0;
48675
48676 /* Make sure we have enough room to write the stack and data areas. */
48677 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48678 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48679 dump.u_ssize = 0;
48680
48681 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48682 rlim = rlimit(RLIMIT_DATA);
48683 if (rlim >= RLIM_INFINITY)
48684 rlim = ~0;
48685 +
48686 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48687 if (ex.a_data + ex.a_bss > rlim)
48688 return -ENOMEM;
48689
48690 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48691
48692 install_exec_creds(bprm);
48693
48694 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48695 + current->mm->pax_flags = 0UL;
48696 +#endif
48697 +
48698 +#ifdef CONFIG_PAX_PAGEEXEC
48699 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48700 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48701 +
48702 +#ifdef CONFIG_PAX_EMUTRAMP
48703 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48704 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48705 +#endif
48706 +
48707 +#ifdef CONFIG_PAX_MPROTECT
48708 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48709 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48710 +#endif
48711 +
48712 + }
48713 +#endif
48714 +
48715 if (N_MAGIC(ex) == OMAGIC) {
48716 unsigned long text_addr, map_size;
48717 loff_t pos;
48718 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48719 }
48720
48721 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48722 - PROT_READ | PROT_WRITE | PROT_EXEC,
48723 + PROT_READ | PROT_WRITE,
48724 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48725 fd_offset + ex.a_text);
48726 if (error != N_DATADDR(ex)) {
48727 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48728 index f8a0b0e..6f036ed 100644
48729 --- a/fs/binfmt_elf.c
48730 +++ b/fs/binfmt_elf.c
48731 @@ -34,6 +34,7 @@
48732 #include <linux/utsname.h>
48733 #include <linux/coredump.h>
48734 #include <linux/sched.h>
48735 +#include <linux/xattr.h>
48736 #include <asm/uaccess.h>
48737 #include <asm/param.h>
48738 #include <asm/page.h>
48739 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
48740 #define elf_core_dump NULL
48741 #endif
48742
48743 +#ifdef CONFIG_PAX_MPROTECT
48744 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48745 +#endif
48746 +
48747 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
48748 +static void elf_handle_mmap(struct file *file);
48749 +#endif
48750 +
48751 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48752 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48753 #else
48754 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
48755 .load_binary = load_elf_binary,
48756 .load_shlib = load_elf_library,
48757 .core_dump = elf_core_dump,
48758 +
48759 +#ifdef CONFIG_PAX_MPROTECT
48760 + .handle_mprotect= elf_handle_mprotect,
48761 +#endif
48762 +
48763 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
48764 + .handle_mmap = elf_handle_mmap,
48765 +#endif
48766 +
48767 .min_coredump = ELF_EXEC_PAGESIZE,
48768 };
48769
48770 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
48771
48772 static int set_brk(unsigned long start, unsigned long end)
48773 {
48774 + unsigned long e = end;
48775 +
48776 start = ELF_PAGEALIGN(start);
48777 end = ELF_PAGEALIGN(end);
48778 if (end > start) {
48779 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
48780 if (BAD_ADDR(addr))
48781 return addr;
48782 }
48783 - current->mm->start_brk = current->mm->brk = end;
48784 + current->mm->start_brk = current->mm->brk = e;
48785 return 0;
48786 }
48787
48788 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48789 elf_addr_t __user *u_rand_bytes;
48790 const char *k_platform = ELF_PLATFORM;
48791 const char *k_base_platform = ELF_BASE_PLATFORM;
48792 - unsigned char k_rand_bytes[16];
48793 + u32 k_rand_bytes[4];
48794 int items;
48795 elf_addr_t *elf_info;
48796 int ei_index = 0;
48797 const struct cred *cred = current_cred();
48798 struct vm_area_struct *vma;
48799 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48800
48801 /*
48802 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48803 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48804 * Generate 16 random bytes for userspace PRNG seeding.
48805 */
48806 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48807 - u_rand_bytes = (elf_addr_t __user *)
48808 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48809 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
48810 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
48811 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
48812 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
48813 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48814 + u_rand_bytes = (elf_addr_t __user *) p;
48815 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48816 return -EFAULT;
48817
48818 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48819 return -EFAULT;
48820 current->mm->env_end = p;
48821
48822 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48823 +
48824 /* Put the elf_info on the stack in the right place. */
48825 sp = (elf_addr_t __user *)envp + 1;
48826 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48827 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48828 return -EFAULT;
48829 return 0;
48830 }
48831 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48832 an ELF header */
48833
48834 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48835 - struct file *interpreter, unsigned long *interp_map_addr,
48836 - unsigned long no_base)
48837 + struct file *interpreter, unsigned long no_base)
48838 {
48839 struct elf_phdr *elf_phdata;
48840 struct elf_phdr *eppnt;
48841 - unsigned long load_addr = 0;
48842 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48843 int load_addr_set = 0;
48844 unsigned long last_bss = 0, elf_bss = 0;
48845 - unsigned long error = ~0UL;
48846 + unsigned long error = -EINVAL;
48847 unsigned long total_size;
48848 int retval, i, size;
48849
48850 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48851 goto out_close;
48852 }
48853
48854 +#ifdef CONFIG_PAX_SEGMEXEC
48855 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48856 + pax_task_size = SEGMEXEC_TASK_SIZE;
48857 +#endif
48858 +
48859 eppnt = elf_phdata;
48860 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48861 if (eppnt->p_type == PT_LOAD) {
48862 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48863 map_addr = elf_map(interpreter, load_addr + vaddr,
48864 eppnt, elf_prot, elf_type, total_size);
48865 total_size = 0;
48866 - if (!*interp_map_addr)
48867 - *interp_map_addr = map_addr;
48868 error = map_addr;
48869 if (BAD_ADDR(map_addr))
48870 goto out_close;
48871 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48872 k = load_addr + eppnt->p_vaddr;
48873 if (BAD_ADDR(k) ||
48874 eppnt->p_filesz > eppnt->p_memsz ||
48875 - eppnt->p_memsz > TASK_SIZE ||
48876 - TASK_SIZE - eppnt->p_memsz < k) {
48877 + eppnt->p_memsz > pax_task_size ||
48878 + pax_task_size - eppnt->p_memsz < k) {
48879 error = -ENOMEM;
48880 goto out_close;
48881 }
48882 @@ -538,6 +567,315 @@ out:
48883 return error;
48884 }
48885
48886 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48887 +#ifdef CONFIG_PAX_SOFTMODE
48888 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48889 +{
48890 + unsigned long pax_flags = 0UL;
48891 +
48892 +#ifdef CONFIG_PAX_PAGEEXEC
48893 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48894 + pax_flags |= MF_PAX_PAGEEXEC;
48895 +#endif
48896 +
48897 +#ifdef CONFIG_PAX_SEGMEXEC
48898 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48899 + pax_flags |= MF_PAX_SEGMEXEC;
48900 +#endif
48901 +
48902 +#ifdef CONFIG_PAX_EMUTRAMP
48903 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48904 + pax_flags |= MF_PAX_EMUTRAMP;
48905 +#endif
48906 +
48907 +#ifdef CONFIG_PAX_MPROTECT
48908 + if (elf_phdata->p_flags & PF_MPROTECT)
48909 + pax_flags |= MF_PAX_MPROTECT;
48910 +#endif
48911 +
48912 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48913 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48914 + pax_flags |= MF_PAX_RANDMMAP;
48915 +#endif
48916 +
48917 + return pax_flags;
48918 +}
48919 +#endif
48920 +
48921 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48922 +{
48923 + unsigned long pax_flags = 0UL;
48924 +
48925 +#ifdef CONFIG_PAX_PAGEEXEC
48926 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48927 + pax_flags |= MF_PAX_PAGEEXEC;
48928 +#endif
48929 +
48930 +#ifdef CONFIG_PAX_SEGMEXEC
48931 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48932 + pax_flags |= MF_PAX_SEGMEXEC;
48933 +#endif
48934 +
48935 +#ifdef CONFIG_PAX_EMUTRAMP
48936 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48937 + pax_flags |= MF_PAX_EMUTRAMP;
48938 +#endif
48939 +
48940 +#ifdef CONFIG_PAX_MPROTECT
48941 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48942 + pax_flags |= MF_PAX_MPROTECT;
48943 +#endif
48944 +
48945 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48946 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48947 + pax_flags |= MF_PAX_RANDMMAP;
48948 +#endif
48949 +
48950 + return pax_flags;
48951 +}
48952 +#endif
48953 +
48954 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48955 +#ifdef CONFIG_PAX_SOFTMODE
48956 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48957 +{
48958 + unsigned long pax_flags = 0UL;
48959 +
48960 +#ifdef CONFIG_PAX_PAGEEXEC
48961 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48962 + pax_flags |= MF_PAX_PAGEEXEC;
48963 +#endif
48964 +
48965 +#ifdef CONFIG_PAX_SEGMEXEC
48966 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48967 + pax_flags |= MF_PAX_SEGMEXEC;
48968 +#endif
48969 +
48970 +#ifdef CONFIG_PAX_EMUTRAMP
48971 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48972 + pax_flags |= MF_PAX_EMUTRAMP;
48973 +#endif
48974 +
48975 +#ifdef CONFIG_PAX_MPROTECT
48976 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48977 + pax_flags |= MF_PAX_MPROTECT;
48978 +#endif
48979 +
48980 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48981 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48982 + pax_flags |= MF_PAX_RANDMMAP;
48983 +#endif
48984 +
48985 + return pax_flags;
48986 +}
48987 +#endif
48988 +
48989 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48990 +{
48991 + unsigned long pax_flags = 0UL;
48992 +
48993 +#ifdef CONFIG_PAX_PAGEEXEC
48994 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48995 + pax_flags |= MF_PAX_PAGEEXEC;
48996 +#endif
48997 +
48998 +#ifdef CONFIG_PAX_SEGMEXEC
48999 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
49000 + pax_flags |= MF_PAX_SEGMEXEC;
49001 +#endif
49002 +
49003 +#ifdef CONFIG_PAX_EMUTRAMP
49004 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
49005 + pax_flags |= MF_PAX_EMUTRAMP;
49006 +#endif
49007 +
49008 +#ifdef CONFIG_PAX_MPROTECT
49009 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
49010 + pax_flags |= MF_PAX_MPROTECT;
49011 +#endif
49012 +
49013 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
49014 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
49015 + pax_flags |= MF_PAX_RANDMMAP;
49016 +#endif
49017 +
49018 + return pax_flags;
49019 +}
49020 +#endif
49021 +
49022 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49023 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
49024 +{
49025 + unsigned long pax_flags = 0UL;
49026 +
49027 +#ifdef CONFIG_PAX_EI_PAX
49028 +
49029 +#ifdef CONFIG_PAX_PAGEEXEC
49030 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
49031 + pax_flags |= MF_PAX_PAGEEXEC;
49032 +#endif
49033 +
49034 +#ifdef CONFIG_PAX_SEGMEXEC
49035 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
49036 + pax_flags |= MF_PAX_SEGMEXEC;
49037 +#endif
49038 +
49039 +#ifdef CONFIG_PAX_EMUTRAMP
49040 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
49041 + pax_flags |= MF_PAX_EMUTRAMP;
49042 +#endif
49043 +
49044 +#ifdef CONFIG_PAX_MPROTECT
49045 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
49046 + pax_flags |= MF_PAX_MPROTECT;
49047 +#endif
49048 +
49049 +#ifdef CONFIG_PAX_ASLR
49050 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
49051 + pax_flags |= MF_PAX_RANDMMAP;
49052 +#endif
49053 +
49054 +#else
49055 +
49056 +#ifdef CONFIG_PAX_PAGEEXEC
49057 + pax_flags |= MF_PAX_PAGEEXEC;
49058 +#endif
49059 +
49060 +#ifdef CONFIG_PAX_SEGMEXEC
49061 + pax_flags |= MF_PAX_SEGMEXEC;
49062 +#endif
49063 +
49064 +#ifdef CONFIG_PAX_MPROTECT
49065 + pax_flags |= MF_PAX_MPROTECT;
49066 +#endif
49067 +
49068 +#ifdef CONFIG_PAX_RANDMMAP
49069 + if (randomize_va_space)
49070 + pax_flags |= MF_PAX_RANDMMAP;
49071 +#endif
49072 +
49073 +#endif
49074 +
49075 + return pax_flags;
49076 +}
49077 +
49078 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
49079 +{
49080 +
49081 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
49082 + unsigned long i;
49083 +
49084 + for (i = 0UL; i < elf_ex->e_phnum; i++)
49085 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
49086 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
49087 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
49088 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
49089 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
49090 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
49091 + return ~0UL;
49092 +
49093 +#ifdef CONFIG_PAX_SOFTMODE
49094 + if (pax_softmode)
49095 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
49096 + else
49097 +#endif
49098 +
49099 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
49100 + break;
49101 + }
49102 +#endif
49103 +
49104 + return ~0UL;
49105 +}
49106 +
49107 +static unsigned long pax_parse_xattr_pax(struct file * const file)
49108 +{
49109 +
49110 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49111 + ssize_t xattr_size, i;
49112 + unsigned char xattr_value[sizeof("pemrs") - 1];
49113 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49114 +
49115 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
49116 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
49117 + return ~0UL;
49118 +
49119 + for (i = 0; i < xattr_size; i++)
49120 + switch (xattr_value[i]) {
49121 + default:
49122 + return ~0UL;
49123 +
49124 +#define parse_flag(option1, option2, flag) \
49125 + case option1: \
49126 + if (pax_flags_hardmode & MF_PAX_##flag) \
49127 + return ~0UL; \
49128 + pax_flags_hardmode |= MF_PAX_##flag; \
49129 + break; \
49130 + case option2: \
49131 + if (pax_flags_softmode & MF_PAX_##flag) \
49132 + return ~0UL; \
49133 + pax_flags_softmode |= MF_PAX_##flag; \
49134 + break;
49135 +
49136 + parse_flag('p', 'P', PAGEEXEC);
49137 + parse_flag('e', 'E', EMUTRAMP);
49138 + parse_flag('m', 'M', MPROTECT);
49139 + parse_flag('r', 'R', RANDMMAP);
49140 + parse_flag('s', 'S', SEGMEXEC);
49141 +
49142 +#undef parse_flag
49143 + }
49144 +
49145 + if (pax_flags_hardmode & pax_flags_softmode)
49146 + return ~0UL;
49147 +
49148 +#ifdef CONFIG_PAX_SOFTMODE
49149 + if (pax_softmode)
49150 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49151 + else
49152 +#endif
49153 +
49154 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49155 +#else
49156 + return ~0UL;
49157 +#endif
49158 +
49159 +}
49160 +
49161 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49162 +{
49163 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49164 +
49165 + pax_flags = pax_parse_ei_pax(elf_ex);
49166 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49167 + xattr_pax_flags = pax_parse_xattr_pax(file);
49168 +
49169 + if (pt_pax_flags == ~0UL)
49170 + pt_pax_flags = xattr_pax_flags;
49171 + else if (xattr_pax_flags == ~0UL)
49172 + xattr_pax_flags = pt_pax_flags;
49173 + if (pt_pax_flags != xattr_pax_flags)
49174 + return -EINVAL;
49175 + if (pt_pax_flags != ~0UL)
49176 + pax_flags = pt_pax_flags;
49177 +
49178 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49179 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49180 + if ((__supported_pte_mask & _PAGE_NX))
49181 + pax_flags &= ~MF_PAX_SEGMEXEC;
49182 + else
49183 + pax_flags &= ~MF_PAX_PAGEEXEC;
49184 + }
49185 +#endif
49186 +
49187 + if (0 > pax_check_flags(&pax_flags))
49188 + return -EINVAL;
49189 +
49190 + current->mm->pax_flags = pax_flags;
49191 + return 0;
49192 +}
49193 +#endif
49194 +
49195 /*
49196 * These are the functions used to load ELF style executables and shared
49197 * libraries. There is no binary dependent code anywhere else.
49198 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49199 {
49200 unsigned int random_variable = 0;
49201
49202 +#ifdef CONFIG_PAX_RANDUSTACK
49203 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49204 + return stack_top - current->mm->delta_stack;
49205 +#endif
49206 +
49207 if ((current->flags & PF_RANDOMIZE) &&
49208 !(current->personality & ADDR_NO_RANDOMIZE)) {
49209 random_variable = get_random_int() & STACK_RND_MASK;
49210 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49211 unsigned long load_addr = 0, load_bias = 0;
49212 int load_addr_set = 0;
49213 char * elf_interpreter = NULL;
49214 - unsigned long error;
49215 + unsigned long error = 0;
49216 struct elf_phdr *elf_ppnt, *elf_phdata;
49217 unsigned long elf_bss, elf_brk;
49218 int retval, i;
49219 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49220 unsigned long start_code, end_code, start_data, end_data;
49221 unsigned long reloc_func_desc __maybe_unused = 0;
49222 int executable_stack = EXSTACK_DEFAULT;
49223 - unsigned long def_flags = 0;
49224 struct pt_regs *regs = current_pt_regs();
49225 struct {
49226 struct elfhdr elf_ex;
49227 struct elfhdr interp_elf_ex;
49228 } *loc;
49229 + unsigned long pax_task_size = TASK_SIZE;
49230
49231 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49232 if (!loc) {
49233 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49234 goto out_free_dentry;
49235
49236 /* OK, This is the point of no return */
49237 - current->mm->def_flags = def_flags;
49238 +
49239 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49240 + current->mm->pax_flags = 0UL;
49241 +#endif
49242 +
49243 +#ifdef CONFIG_PAX_DLRESOLVE
49244 + current->mm->call_dl_resolve = 0UL;
49245 +#endif
49246 +
49247 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49248 + current->mm->call_syscall = 0UL;
49249 +#endif
49250 +
49251 +#ifdef CONFIG_PAX_ASLR
49252 + current->mm->delta_mmap = 0UL;
49253 + current->mm->delta_stack = 0UL;
49254 +#endif
49255 +
49256 + current->mm->def_flags = 0;
49257 +
49258 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49259 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49260 + send_sig(SIGKILL, current, 0);
49261 + goto out_free_dentry;
49262 + }
49263 +#endif
49264 +
49265 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49266 + pax_set_initial_flags(bprm);
49267 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49268 + if (pax_set_initial_flags_func)
49269 + (pax_set_initial_flags_func)(bprm);
49270 +#endif
49271 +
49272 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49273 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49274 + current->mm->context.user_cs_limit = PAGE_SIZE;
49275 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49276 + }
49277 +#endif
49278 +
49279 +#ifdef CONFIG_PAX_SEGMEXEC
49280 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49281 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49282 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49283 + pax_task_size = SEGMEXEC_TASK_SIZE;
49284 + current->mm->def_flags |= VM_NOHUGEPAGE;
49285 + }
49286 +#endif
49287 +
49288 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49289 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49290 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49291 + put_cpu();
49292 + }
49293 +#endif
49294
49295 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49296 may depend on the personality. */
49297 SET_PERSONALITY(loc->elf_ex);
49298 +
49299 +#ifdef CONFIG_PAX_ASLR
49300 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49301 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49302 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49303 + }
49304 +#endif
49305 +
49306 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49307 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49308 + executable_stack = EXSTACK_DISABLE_X;
49309 + current->personality &= ~READ_IMPLIES_EXEC;
49310 + } else
49311 +#endif
49312 +
49313 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49314 current->personality |= READ_IMPLIES_EXEC;
49315
49316 @@ -819,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49317 #else
49318 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49319 #endif
49320 +
49321 +#ifdef CONFIG_PAX_RANDMMAP
49322 + /* PaX: randomize base address at the default exe base if requested */
49323 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49324 +#ifdef CONFIG_SPARC64
49325 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49326 +#else
49327 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49328 +#endif
49329 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49330 + elf_flags |= MAP_FIXED;
49331 + }
49332 +#endif
49333 +
49334 }
49335
49336 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49337 @@ -851,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49338 * allowed task size. Note that p_filesz must always be
49339 * <= p_memsz so it is only necessary to check p_memsz.
49340 */
49341 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49342 - elf_ppnt->p_memsz > TASK_SIZE ||
49343 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49344 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49345 + elf_ppnt->p_memsz > pax_task_size ||
49346 + pax_task_size - elf_ppnt->p_memsz < k) {
49347 /* set_brk can never work. Avoid overflows. */
49348 send_sig(SIGKILL, current, 0);
49349 retval = -EINVAL;
49350 @@ -892,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49351 goto out_free_dentry;
49352 }
49353 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49354 - send_sig(SIGSEGV, current, 0);
49355 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49356 - goto out_free_dentry;
49357 + /*
49358 + * This bss-zeroing can fail if the ELF
49359 + * file specifies odd protections. So
49360 + * we don't check the return value
49361 + */
49362 }
49363
49364 +#ifdef CONFIG_PAX_RANDMMAP
49365 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49366 + unsigned long start, size, flags;
49367 + vm_flags_t vm_flags;
49368 +
49369 + start = ELF_PAGEALIGN(elf_brk);
49370 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49371 + flags = MAP_FIXED | MAP_PRIVATE;
49372 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49373 +
49374 + down_write(&current->mm->mmap_sem);
49375 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49376 + retval = -ENOMEM;
49377 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49378 +// if (current->personality & ADDR_NO_RANDOMIZE)
49379 +// vm_flags |= VM_READ | VM_MAYREAD;
49380 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49381 + retval = IS_ERR_VALUE(start) ? start : 0;
49382 + }
49383 + up_write(&current->mm->mmap_sem);
49384 + if (retval == 0)
49385 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49386 + if (retval < 0) {
49387 + send_sig(SIGKILL, current, 0);
49388 + goto out_free_dentry;
49389 + }
49390 + }
49391 +#endif
49392 +
49393 if (elf_interpreter) {
49394 - unsigned long interp_map_addr = 0;
49395 -
49396 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49397 interpreter,
49398 - &interp_map_addr,
49399 load_bias);
49400 if (!IS_ERR((void *)elf_entry)) {
49401 /*
49402 @@ -1124,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49403 * Decide what to dump of a segment, part, all or none.
49404 */
49405 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49406 - unsigned long mm_flags)
49407 + unsigned long mm_flags, long signr)
49408 {
49409 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49410
49411 @@ -1162,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49412 if (vma->vm_file == NULL)
49413 return 0;
49414
49415 - if (FILTER(MAPPED_PRIVATE))
49416 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49417 goto whole;
49418
49419 /*
49420 @@ -1387,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49421 {
49422 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49423 int i = 0;
49424 - do
49425 + do {
49426 i += 2;
49427 - while (auxv[i - 2] != AT_NULL);
49428 + } while (auxv[i - 2] != AT_NULL);
49429 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49430 }
49431
49432 @@ -1398,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49433 {
49434 mm_segment_t old_fs = get_fs();
49435 set_fs(KERNEL_DS);
49436 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49437 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49438 set_fs(old_fs);
49439 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49440 }
49441 @@ -2019,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49442 }
49443
49444 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49445 - unsigned long mm_flags)
49446 + struct coredump_params *cprm)
49447 {
49448 struct vm_area_struct *vma;
49449 size_t size = 0;
49450
49451 for (vma = first_vma(current, gate_vma); vma != NULL;
49452 vma = next_vma(vma, gate_vma))
49453 - size += vma_dump_size(vma, mm_flags);
49454 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49455 return size;
49456 }
49457
49458 @@ -2119,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49459
49460 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49461
49462 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49463 + offset += elf_core_vma_data_size(gate_vma, cprm);
49464 offset += elf_core_extra_data_size();
49465 e_shoff = offset;
49466
49467 @@ -2133,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49468 offset = dataoff;
49469
49470 size += sizeof(*elf);
49471 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49472 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49473 goto end_coredump;
49474
49475 size += sizeof(*phdr4note);
49476 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49477 if (size > cprm->limit
49478 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49479 goto end_coredump;
49480 @@ -2150,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49481 phdr.p_offset = offset;
49482 phdr.p_vaddr = vma->vm_start;
49483 phdr.p_paddr = 0;
49484 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49485 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49486 phdr.p_memsz = vma->vm_end - vma->vm_start;
49487 offset += phdr.p_filesz;
49488 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49489 @@ -2161,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49490 phdr.p_align = ELF_EXEC_PAGESIZE;
49491
49492 size += sizeof(phdr);
49493 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49494 if (size > cprm->limit
49495 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49496 goto end_coredump;
49497 @@ -2185,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49498 unsigned long addr;
49499 unsigned long end;
49500
49501 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49502 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49503
49504 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49505 struct page *page;
49506 @@ -2194,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49507 page = get_dump_page(addr);
49508 if (page) {
49509 void *kaddr = kmap(page);
49510 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49511 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49512 !dump_write(cprm->file, kaddr,
49513 PAGE_SIZE);
49514 @@ -2211,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49515
49516 if (e_phnum == PN_XNUM) {
49517 size += sizeof(*shdr4extnum);
49518 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49519 if (size > cprm->limit
49520 || !dump_write(cprm->file, shdr4extnum,
49521 sizeof(*shdr4extnum)))
49522 @@ -2231,6 +2691,167 @@ out:
49523
49524 #endif /* CONFIG_ELF_CORE */
49525
49526 +#ifdef CONFIG_PAX_MPROTECT
49527 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49528 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49529 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49530 + *
49531 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49532 + * basis because we want to allow the common case and not the special ones.
49533 + */
49534 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49535 +{
49536 + struct elfhdr elf_h;
49537 + struct elf_phdr elf_p;
49538 + unsigned long i;
49539 + unsigned long oldflags;
49540 + bool is_textrel_rw, is_textrel_rx, is_relro;
49541 +
49542 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
49543 + return;
49544 +
49545 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49546 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49547 +
49548 +#ifdef CONFIG_PAX_ELFRELOCS
49549 + /* possible TEXTREL */
49550 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49551 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
49552 +#else
49553 + is_textrel_rw = false;
49554 + is_textrel_rx = false;
49555 +#endif
49556 +
49557 + /* possible RELRO */
49558 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49559 +
49560 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49561 + return;
49562 +
49563 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49564 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49565 +
49566 +#ifdef CONFIG_PAX_ETEXECRELOCS
49567 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49568 +#else
49569 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49570 +#endif
49571 +
49572 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49573 + !elf_check_arch(&elf_h) ||
49574 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49575 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49576 + return;
49577 +
49578 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49579 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49580 + return;
49581 + switch (elf_p.p_type) {
49582 + case PT_DYNAMIC:
49583 + if (!is_textrel_rw && !is_textrel_rx)
49584 + continue;
49585 + i = 0UL;
49586 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49587 + elf_dyn dyn;
49588 +
49589 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49590 + break;
49591 + if (dyn.d_tag == DT_NULL)
49592 + break;
49593 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49594 + gr_log_textrel(vma);
49595 + if (is_textrel_rw)
49596 + vma->vm_flags |= VM_MAYWRITE;
49597 + else
49598 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49599 + vma->vm_flags &= ~VM_MAYWRITE;
49600 + break;
49601 + }
49602 + i++;
49603 + }
49604 + is_textrel_rw = false;
49605 + is_textrel_rx = false;
49606 + continue;
49607 +
49608 + case PT_GNU_RELRO:
49609 + if (!is_relro)
49610 + continue;
49611 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49612 + vma->vm_flags &= ~VM_MAYWRITE;
49613 + is_relro = false;
49614 + continue;
49615 +
49616 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
49617 + case PT_PAX_FLAGS: {
49618 + const char *msg_mprotect = "", *msg_emutramp = "";
49619 + char *buffer_lib, *buffer_exe;
49620 +
49621 + if (elf_p.p_flags & PF_NOMPROTECT)
49622 + msg_mprotect = "MPROTECT disabled";
49623 +
49624 +#ifdef CONFIG_PAX_EMUTRAMP
49625 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
49626 + msg_emutramp = "EMUTRAMP enabled";
49627 +#endif
49628 +
49629 + if (!msg_mprotect[0] && !msg_emutramp[0])
49630 + continue;
49631 +
49632 + if (!printk_ratelimit())
49633 + continue;
49634 +
49635 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
49636 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
49637 + if (buffer_lib && buffer_exe) {
49638 + char *path_lib, *path_exe;
49639 +
49640 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
49641 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
49642 +
49643 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
49644 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
49645 +
49646 + }
49647 + free_page((unsigned long)buffer_exe);
49648 + free_page((unsigned long)buffer_lib);
49649 + continue;
49650 + }
49651 +#endif
49652 +
49653 + }
49654 + }
49655 +}
49656 +#endif
49657 +
49658 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
49659 +
49660 +extern int grsec_enable_log_rwxmaps;
49661 +
49662 +static void elf_handle_mmap(struct file *file)
49663 +{
49664 + struct elfhdr elf_h;
49665 + struct elf_phdr elf_p;
49666 + unsigned long i;
49667 +
49668 + if (!grsec_enable_log_rwxmaps)
49669 + return;
49670 +
49671 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49672 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49673 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
49674 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49675 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49676 + return;
49677 +
49678 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49679 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49680 + return;
49681 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
49682 + gr_log_ptgnustack(file);
49683 + }
49684 +}
49685 +#endif
49686 +
49687 static int __init init_elf_binfmt(void)
49688 {
49689 register_binfmt(&elf_format);
49690 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49691 index d50bbe5..af3b649 100644
49692 --- a/fs/binfmt_flat.c
49693 +++ b/fs/binfmt_flat.c
49694 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49695 realdatastart = (unsigned long) -ENOMEM;
49696 printk("Unable to allocate RAM for process data, errno %d\n",
49697 (int)-realdatastart);
49698 + down_write(&current->mm->mmap_sem);
49699 vm_munmap(textpos, text_len);
49700 + up_write(&current->mm->mmap_sem);
49701 ret = realdatastart;
49702 goto err;
49703 }
49704 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49705 }
49706 if (IS_ERR_VALUE(result)) {
49707 printk("Unable to read data+bss, errno %d\n", (int)-result);
49708 + down_write(&current->mm->mmap_sem);
49709 vm_munmap(textpos, text_len);
49710 vm_munmap(realdatastart, len);
49711 + up_write(&current->mm->mmap_sem);
49712 ret = result;
49713 goto err;
49714 }
49715 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49716 }
49717 if (IS_ERR_VALUE(result)) {
49718 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49719 + down_write(&current->mm->mmap_sem);
49720 vm_munmap(textpos, text_len + data_len + extra +
49721 MAX_SHARED_LIBS * sizeof(unsigned long));
49722 + up_write(&current->mm->mmap_sem);
49723 ret = result;
49724 goto err;
49725 }
49726 diff --git a/fs/bio.c b/fs/bio.c
49727 index 94bbc04..6fe78a4 100644
49728 --- a/fs/bio.c
49729 +++ b/fs/bio.c
49730 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49731 /*
49732 * Overflow, abort
49733 */
49734 - if (end < start)
49735 + if (end < start || end - start > INT_MAX - nr_pages)
49736 return ERR_PTR(-EINVAL);
49737
49738 nr_pages += end - start;
49739 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49740 /*
49741 * Overflow, abort
49742 */
49743 - if (end < start)
49744 + if (end < start || end - start > INT_MAX - nr_pages)
49745 return ERR_PTR(-EINVAL);
49746
49747 nr_pages += end - start;
49748 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49749 const int read = bio_data_dir(bio) == READ;
49750 struct bio_map_data *bmd = bio->bi_private;
49751 int i;
49752 - char *p = bmd->sgvecs[0].iov_base;
49753 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49754
49755 bio_for_each_segment_all(bvec, bio, i) {
49756 char *addr = page_address(bvec->bv_page);
49757 diff --git a/fs/block_dev.c b/fs/block_dev.c
49758 index 85f5c85..d6f0b1a 100644
49759 --- a/fs/block_dev.c
49760 +++ b/fs/block_dev.c
49761 @@ -658,7 +658,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49762 else if (bdev->bd_contains == bdev)
49763 return true; /* is a whole device which isn't held */
49764
49765 - else if (whole->bd_holder == bd_may_claim)
49766 + else if (whole->bd_holder == (void *)bd_may_claim)
49767 return true; /* is a partition of a device that is being partitioned */
49768 else if (whole->bd_holder != NULL)
49769 return false; /* is a partition of a held device */
49770 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49771 index 7fb054b..ad36c67 100644
49772 --- a/fs/btrfs/ctree.c
49773 +++ b/fs/btrfs/ctree.c
49774 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49775 free_extent_buffer(buf);
49776 add_root_to_dirty_list(root);
49777 } else {
49778 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49779 - parent_start = parent->start;
49780 - else
49781 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49782 + if (parent)
49783 + parent_start = parent->start;
49784 + else
49785 + parent_start = 0;
49786 + } else
49787 parent_start = 0;
49788
49789 WARN_ON(trans->transid != btrfs_header_generation(parent));
49790 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49791 index 0f81d67..0ad55fe 100644
49792 --- a/fs/btrfs/ioctl.c
49793 +++ b/fs/btrfs/ioctl.c
49794 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49795 for (i = 0; i < num_types; i++) {
49796 struct btrfs_space_info *tmp;
49797
49798 + /* Don't copy in more than we allocated */
49799 if (!slot_count)
49800 break;
49801
49802 + slot_count--;
49803 +
49804 info = NULL;
49805 rcu_read_lock();
49806 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49807 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49808 memcpy(dest, &space, sizeof(space));
49809 dest++;
49810 space_args.total_spaces++;
49811 - slot_count--;
49812 }
49813 - if (!slot_count)
49814 - break;
49815 }
49816 up_read(&info->groups_sem);
49817 }
49818 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49819 index f0857e0..e7023c5 100644
49820 --- a/fs/btrfs/super.c
49821 +++ b/fs/btrfs/super.c
49822 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49823 function, line, errstr);
49824 return;
49825 }
49826 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49827 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49828 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49829 }
49830 /*
49831 diff --git a/fs/buffer.c b/fs/buffer.c
49832 index d2a4d1b..df798ca 100644
49833 --- a/fs/buffer.c
49834 +++ b/fs/buffer.c
49835 @@ -3367,7 +3367,7 @@ void __init buffer_init(void)
49836 bh_cachep = kmem_cache_create("buffer_head",
49837 sizeof(struct buffer_head), 0,
49838 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
49839 - SLAB_MEM_SPREAD),
49840 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
49841 NULL);
49842
49843 /*
49844 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49845 index 622f469..e8d2d55 100644
49846 --- a/fs/cachefiles/bind.c
49847 +++ b/fs/cachefiles/bind.c
49848 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49849 args);
49850
49851 /* start by checking things over */
49852 - ASSERT(cache->fstop_percent >= 0 &&
49853 - cache->fstop_percent < cache->fcull_percent &&
49854 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49855 cache->fcull_percent < cache->frun_percent &&
49856 cache->frun_percent < 100);
49857
49858 - ASSERT(cache->bstop_percent >= 0 &&
49859 - cache->bstop_percent < cache->bcull_percent &&
49860 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49861 cache->bcull_percent < cache->brun_percent &&
49862 cache->brun_percent < 100);
49863
49864 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49865 index 0a1467b..6a53245 100644
49866 --- a/fs/cachefiles/daemon.c
49867 +++ b/fs/cachefiles/daemon.c
49868 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49869 if (n > buflen)
49870 return -EMSGSIZE;
49871
49872 - if (copy_to_user(_buffer, buffer, n) != 0)
49873 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49874 return -EFAULT;
49875
49876 return n;
49877 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49878 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49879 return -EIO;
49880
49881 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49882 + if (datalen > PAGE_SIZE - 1)
49883 return -EOPNOTSUPP;
49884
49885 /* drag the command string into the kernel so we can parse it */
49886 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49887 if (args[0] != '%' || args[1] != '\0')
49888 return -EINVAL;
49889
49890 - if (fstop < 0 || fstop >= cache->fcull_percent)
49891 + if (fstop >= cache->fcull_percent)
49892 return cachefiles_daemon_range_error(cache, args);
49893
49894 cache->fstop_percent = fstop;
49895 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49896 if (args[0] != '%' || args[1] != '\0')
49897 return -EINVAL;
49898
49899 - if (bstop < 0 || bstop >= cache->bcull_percent)
49900 + if (bstop >= cache->bcull_percent)
49901 return cachefiles_daemon_range_error(cache, args);
49902
49903 cache->bstop_percent = bstop;
49904 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49905 index 4938251..7e01445 100644
49906 --- a/fs/cachefiles/internal.h
49907 +++ b/fs/cachefiles/internal.h
49908 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49909 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49910 struct rb_root active_nodes; /* active nodes (can't be culled) */
49911 rwlock_t active_lock; /* lock for active_nodes */
49912 - atomic_t gravecounter; /* graveyard uniquifier */
49913 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49914 unsigned frun_percent; /* when to stop culling (% files) */
49915 unsigned fcull_percent; /* when to start culling (% files) */
49916 unsigned fstop_percent; /* when to stop allocating (% files) */
49917 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49918 * proc.c
49919 */
49920 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49921 -extern atomic_t cachefiles_lookup_histogram[HZ];
49922 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49923 -extern atomic_t cachefiles_create_histogram[HZ];
49924 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49925 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49926 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49927
49928 extern int __init cachefiles_proc_init(void);
49929 extern void cachefiles_proc_cleanup(void);
49930 static inline
49931 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49932 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49933 {
49934 unsigned long jif = jiffies - start_jif;
49935 if (jif >= HZ)
49936 jif = HZ - 1;
49937 - atomic_inc(&histogram[jif]);
49938 + atomic_inc_unchecked(&histogram[jif]);
49939 }
49940
49941 #else
49942 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49943 index 8c01c5fc..15f982e 100644
49944 --- a/fs/cachefiles/namei.c
49945 +++ b/fs/cachefiles/namei.c
49946 @@ -317,7 +317,7 @@ try_again:
49947 /* first step is to make up a grave dentry in the graveyard */
49948 sprintf(nbuffer, "%08x%08x",
49949 (uint32_t) get_seconds(),
49950 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49951 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49952
49953 /* do the multiway lock magic */
49954 trap = lock_rename(cache->graveyard, dir);
49955 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49956 index eccd339..4c1d995 100644
49957 --- a/fs/cachefiles/proc.c
49958 +++ b/fs/cachefiles/proc.c
49959 @@ -14,9 +14,9 @@
49960 #include <linux/seq_file.h>
49961 #include "internal.h"
49962
49963 -atomic_t cachefiles_lookup_histogram[HZ];
49964 -atomic_t cachefiles_mkdir_histogram[HZ];
49965 -atomic_t cachefiles_create_histogram[HZ];
49966 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49967 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49968 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49969
49970 /*
49971 * display the latency histogram
49972 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49973 return 0;
49974 default:
49975 index = (unsigned long) v - 3;
49976 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49977 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49978 - z = atomic_read(&cachefiles_create_histogram[index]);
49979 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49980 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49981 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49982 if (x == 0 && y == 0 && z == 0)
49983 return 0;
49984
49985 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49986 index 317f9ee..3d24511 100644
49987 --- a/fs/cachefiles/rdwr.c
49988 +++ b/fs/cachefiles/rdwr.c
49989 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49990 old_fs = get_fs();
49991 set_fs(KERNEL_DS);
49992 ret = file->f_op->write(
49993 - file, (const void __user *) data, len, &pos);
49994 + file, (const void __force_user *) data, len, &pos);
49995 set_fs(old_fs);
49996 kunmap(page);
49997 file_end_write(file);
49998 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49999 index f02d82b..2632cf86 100644
50000 --- a/fs/ceph/dir.c
50001 +++ b/fs/ceph/dir.c
50002 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
50003 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
50004 struct ceph_mds_client *mdsc = fsc->mdsc;
50005 unsigned frag = fpos_frag(filp->f_pos);
50006 - int off = fpos_off(filp->f_pos);
50007 + unsigned int off = fpos_off(filp->f_pos);
50008 int err;
50009 u32 ftype;
50010 struct ceph_mds_reply_info_parsed *rinfo;
50011 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
50012 index d597483..747901b 100644
50013 --- a/fs/cifs/cifs_debug.c
50014 +++ b/fs/cifs/cifs_debug.c
50015 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
50016
50017 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
50018 #ifdef CONFIG_CIFS_STATS2
50019 - atomic_set(&totBufAllocCount, 0);
50020 - atomic_set(&totSmBufAllocCount, 0);
50021 + atomic_set_unchecked(&totBufAllocCount, 0);
50022 + atomic_set_unchecked(&totSmBufAllocCount, 0);
50023 #endif /* CONFIG_CIFS_STATS2 */
50024 spin_lock(&cifs_tcp_ses_lock);
50025 list_for_each(tmp1, &cifs_tcp_ses_list) {
50026 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
50027 tcon = list_entry(tmp3,
50028 struct cifs_tcon,
50029 tcon_list);
50030 - atomic_set(&tcon->num_smbs_sent, 0);
50031 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
50032 if (server->ops->clear_stats)
50033 server->ops->clear_stats(tcon);
50034 }
50035 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
50036 smBufAllocCount.counter, cifs_min_small);
50037 #ifdef CONFIG_CIFS_STATS2
50038 seq_printf(m, "Total Large %d Small %d Allocations\n",
50039 - atomic_read(&totBufAllocCount),
50040 - atomic_read(&totSmBufAllocCount));
50041 + atomic_read_unchecked(&totBufAllocCount),
50042 + atomic_read_unchecked(&totSmBufAllocCount));
50043 #endif /* CONFIG_CIFS_STATS2 */
50044
50045 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
50046 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
50047 if (tcon->need_reconnect)
50048 seq_puts(m, "\tDISCONNECTED ");
50049 seq_printf(m, "\nSMBs: %d",
50050 - atomic_read(&tcon->num_smbs_sent));
50051 + atomic_read_unchecked(&tcon->num_smbs_sent));
50052 if (server->ops->print_stats)
50053 server->ops->print_stats(m, tcon);
50054 }
50055 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
50056 index 3752b9f..8db5569 100644
50057 --- a/fs/cifs/cifsfs.c
50058 +++ b/fs/cifs/cifsfs.c
50059 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
50060 */
50061 cifs_req_cachep = kmem_cache_create("cifs_request",
50062 CIFSMaxBufSize + max_hdr_size, 0,
50063 - SLAB_HWCACHE_ALIGN, NULL);
50064 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
50065 if (cifs_req_cachep == NULL)
50066 return -ENOMEM;
50067
50068 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
50069 efficient to alloc 1 per page off the slab compared to 17K (5page)
50070 alloc of large cifs buffers even when page debugging is on */
50071 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
50072 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
50073 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
50074 NULL);
50075 if (cifs_sm_req_cachep == NULL) {
50076 mempool_destroy(cifs_req_poolp);
50077 @@ -1147,8 +1147,8 @@ init_cifs(void)
50078 atomic_set(&bufAllocCount, 0);
50079 atomic_set(&smBufAllocCount, 0);
50080 #ifdef CONFIG_CIFS_STATS2
50081 - atomic_set(&totBufAllocCount, 0);
50082 - atomic_set(&totSmBufAllocCount, 0);
50083 + atomic_set_unchecked(&totBufAllocCount, 0);
50084 + atomic_set_unchecked(&totSmBufAllocCount, 0);
50085 #endif /* CONFIG_CIFS_STATS2 */
50086
50087 atomic_set(&midCount, 0);
50088 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
50089 index 4f07f6f..55de8ce 100644
50090 --- a/fs/cifs/cifsglob.h
50091 +++ b/fs/cifs/cifsglob.h
50092 @@ -751,35 +751,35 @@ struct cifs_tcon {
50093 __u16 Flags; /* optional support bits */
50094 enum statusEnum tidStatus;
50095 #ifdef CONFIG_CIFS_STATS
50096 - atomic_t num_smbs_sent;
50097 + atomic_unchecked_t num_smbs_sent;
50098 union {
50099 struct {
50100 - atomic_t num_writes;
50101 - atomic_t num_reads;
50102 - atomic_t num_flushes;
50103 - atomic_t num_oplock_brks;
50104 - atomic_t num_opens;
50105 - atomic_t num_closes;
50106 - atomic_t num_deletes;
50107 - atomic_t num_mkdirs;
50108 - atomic_t num_posixopens;
50109 - atomic_t num_posixmkdirs;
50110 - atomic_t num_rmdirs;
50111 - atomic_t num_renames;
50112 - atomic_t num_t2renames;
50113 - atomic_t num_ffirst;
50114 - atomic_t num_fnext;
50115 - atomic_t num_fclose;
50116 - atomic_t num_hardlinks;
50117 - atomic_t num_symlinks;
50118 - atomic_t num_locks;
50119 - atomic_t num_acl_get;
50120 - atomic_t num_acl_set;
50121 + atomic_unchecked_t num_writes;
50122 + atomic_unchecked_t num_reads;
50123 + atomic_unchecked_t num_flushes;
50124 + atomic_unchecked_t num_oplock_brks;
50125 + atomic_unchecked_t num_opens;
50126 + atomic_unchecked_t num_closes;
50127 + atomic_unchecked_t num_deletes;
50128 + atomic_unchecked_t num_mkdirs;
50129 + atomic_unchecked_t num_posixopens;
50130 + atomic_unchecked_t num_posixmkdirs;
50131 + atomic_unchecked_t num_rmdirs;
50132 + atomic_unchecked_t num_renames;
50133 + atomic_unchecked_t num_t2renames;
50134 + atomic_unchecked_t num_ffirst;
50135 + atomic_unchecked_t num_fnext;
50136 + atomic_unchecked_t num_fclose;
50137 + atomic_unchecked_t num_hardlinks;
50138 + atomic_unchecked_t num_symlinks;
50139 + atomic_unchecked_t num_locks;
50140 + atomic_unchecked_t num_acl_get;
50141 + atomic_unchecked_t num_acl_set;
50142 } cifs_stats;
50143 #ifdef CONFIG_CIFS_SMB2
50144 struct {
50145 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50146 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50147 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50148 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50149 } smb2_stats;
50150 #endif /* CONFIG_CIFS_SMB2 */
50151 } stats;
50152 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
50153 }
50154
50155 #ifdef CONFIG_CIFS_STATS
50156 -#define cifs_stats_inc atomic_inc
50157 +#define cifs_stats_inc atomic_inc_unchecked
50158
50159 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
50160 unsigned int bytes)
50161 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
50162 /* Various Debug counters */
50163 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
50164 #ifdef CONFIG_CIFS_STATS2
50165 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
50166 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
50167 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
50168 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
50169 #endif
50170 GLOBAL_EXTERN atomic_t smBufAllocCount;
50171 GLOBAL_EXTERN atomic_t midCount;
50172 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50173 index b83c3f5..6437caa 100644
50174 --- a/fs/cifs/link.c
50175 +++ b/fs/cifs/link.c
50176 @@ -616,7 +616,7 @@ symlink_exit:
50177
50178 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50179 {
50180 - char *p = nd_get_link(nd);
50181 + const char *p = nd_get_link(nd);
50182 if (!IS_ERR(p))
50183 kfree(p);
50184 }
50185 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50186 index 1bec014..f329411 100644
50187 --- a/fs/cifs/misc.c
50188 +++ b/fs/cifs/misc.c
50189 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50190 memset(ret_buf, 0, buf_size + 3);
50191 atomic_inc(&bufAllocCount);
50192 #ifdef CONFIG_CIFS_STATS2
50193 - atomic_inc(&totBufAllocCount);
50194 + atomic_inc_unchecked(&totBufAllocCount);
50195 #endif /* CONFIG_CIFS_STATS2 */
50196 }
50197
50198 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50199 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50200 atomic_inc(&smBufAllocCount);
50201 #ifdef CONFIG_CIFS_STATS2
50202 - atomic_inc(&totSmBufAllocCount);
50203 + atomic_inc_unchecked(&totSmBufAllocCount);
50204 #endif /* CONFIG_CIFS_STATS2 */
50205
50206 }
50207 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50208 index 3efdb9d..e845a5e 100644
50209 --- a/fs/cifs/smb1ops.c
50210 +++ b/fs/cifs/smb1ops.c
50211 @@ -591,27 +591,27 @@ static void
50212 cifs_clear_stats(struct cifs_tcon *tcon)
50213 {
50214 #ifdef CONFIG_CIFS_STATS
50215 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50216 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50217 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50218 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50219 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50220 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50221 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50222 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50223 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50224 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50225 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50226 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50227 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50228 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50229 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50230 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50231 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50232 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50233 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50234 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50235 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50236 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50237 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50238 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50239 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50240 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50241 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50242 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50243 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50244 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50245 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50246 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50247 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50248 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50249 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50250 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50251 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50252 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50253 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50254 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50255 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50256 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50257 #endif
50258 }
50259
50260 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50261 {
50262 #ifdef CONFIG_CIFS_STATS
50263 seq_printf(m, " Oplocks breaks: %d",
50264 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50265 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50266 seq_printf(m, "\nReads: %d Bytes: %llu",
50267 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50268 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50269 (long long)(tcon->bytes_read));
50270 seq_printf(m, "\nWrites: %d Bytes: %llu",
50271 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50272 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50273 (long long)(tcon->bytes_written));
50274 seq_printf(m, "\nFlushes: %d",
50275 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50276 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50277 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50278 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50279 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50280 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50281 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50282 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50283 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50284 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50285 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50286 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50287 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50288 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50289 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50290 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50291 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50292 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50293 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50294 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50295 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50296 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50297 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50298 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50299 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50300 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50301 seq_printf(m, "\nRenames: %d T2 Renames %d",
50302 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50303 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50304 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50305 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50306 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50307 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50308 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50309 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50310 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50311 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50312 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50313 #endif
50314 }
50315
50316 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50317 index f2e76f3..c44fac7 100644
50318 --- a/fs/cifs/smb2ops.c
50319 +++ b/fs/cifs/smb2ops.c
50320 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50321 #ifdef CONFIG_CIFS_STATS
50322 int i;
50323 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50324 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50325 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50326 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50327 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50328 }
50329 #endif
50330 }
50331 @@ -284,66 +284,66 @@ static void
50332 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50333 {
50334 #ifdef CONFIG_CIFS_STATS
50335 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50336 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50337 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50338 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50339 seq_printf(m, "\nNegotiates: %d sent %d failed",
50340 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50341 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50342 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50343 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50344 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50345 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50346 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50347 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50348 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50349 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50350 seq_printf(m, "\nLogoffs: %d sent %d failed",
50351 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50352 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50353 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50354 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50355 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50356 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50357 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50358 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50359 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50360 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50361 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50362 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50363 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50364 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50365 seq_printf(m, "\nCreates: %d sent %d failed",
50366 - atomic_read(&sent[SMB2_CREATE_HE]),
50367 - atomic_read(&failed[SMB2_CREATE_HE]));
50368 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50369 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50370 seq_printf(m, "\nCloses: %d sent %d failed",
50371 - atomic_read(&sent[SMB2_CLOSE_HE]),
50372 - atomic_read(&failed[SMB2_CLOSE_HE]));
50373 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50374 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50375 seq_printf(m, "\nFlushes: %d sent %d failed",
50376 - atomic_read(&sent[SMB2_FLUSH_HE]),
50377 - atomic_read(&failed[SMB2_FLUSH_HE]));
50378 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50379 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50380 seq_printf(m, "\nReads: %d sent %d failed",
50381 - atomic_read(&sent[SMB2_READ_HE]),
50382 - atomic_read(&failed[SMB2_READ_HE]));
50383 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50384 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50385 seq_printf(m, "\nWrites: %d sent %d failed",
50386 - atomic_read(&sent[SMB2_WRITE_HE]),
50387 - atomic_read(&failed[SMB2_WRITE_HE]));
50388 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50389 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50390 seq_printf(m, "\nLocks: %d sent %d failed",
50391 - atomic_read(&sent[SMB2_LOCK_HE]),
50392 - atomic_read(&failed[SMB2_LOCK_HE]));
50393 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50394 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50395 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50396 - atomic_read(&sent[SMB2_IOCTL_HE]),
50397 - atomic_read(&failed[SMB2_IOCTL_HE]));
50398 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50399 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50400 seq_printf(m, "\nCancels: %d sent %d failed",
50401 - atomic_read(&sent[SMB2_CANCEL_HE]),
50402 - atomic_read(&failed[SMB2_CANCEL_HE]));
50403 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50404 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50405 seq_printf(m, "\nEchos: %d sent %d failed",
50406 - atomic_read(&sent[SMB2_ECHO_HE]),
50407 - atomic_read(&failed[SMB2_ECHO_HE]));
50408 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50409 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50410 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50411 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50412 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50413 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50414 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50415 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50416 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50417 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50418 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50419 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50420 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50421 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50422 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50423 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50424 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50425 seq_printf(m, "\nSetInfos: %d sent %d failed",
50426 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50427 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50428 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50429 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50430 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50431 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50432 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50433 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50434 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50435 #endif
50436 }
50437
50438 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50439 index 2b95ce2..d079d75 100644
50440 --- a/fs/cifs/smb2pdu.c
50441 +++ b/fs/cifs/smb2pdu.c
50442 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50443 default:
50444 cifs_dbg(VFS, "info level %u isn't supported\n",
50445 srch_inf->info_level);
50446 - rc = -EINVAL;
50447 - goto qdir_exit;
50448 + return -EINVAL;
50449 }
50450
50451 req->FileIndex = cpu_to_le32(index);
50452 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50453 index 1da168c..8bc7ff6 100644
50454 --- a/fs/coda/cache.c
50455 +++ b/fs/coda/cache.c
50456 @@ -24,7 +24,7 @@
50457 #include "coda_linux.h"
50458 #include "coda_cache.h"
50459
50460 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50461 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50462
50463 /* replace or extend an acl cache hit */
50464 void coda_cache_enter(struct inode *inode, int mask)
50465 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50466 struct coda_inode_info *cii = ITOC(inode);
50467
50468 spin_lock(&cii->c_lock);
50469 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50470 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50471 if (!uid_eq(cii->c_uid, current_fsuid())) {
50472 cii->c_uid = current_fsuid();
50473 cii->c_cached_perm = mask;
50474 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50475 {
50476 struct coda_inode_info *cii = ITOC(inode);
50477 spin_lock(&cii->c_lock);
50478 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50479 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50480 spin_unlock(&cii->c_lock);
50481 }
50482
50483 /* remove all acl caches */
50484 void coda_cache_clear_all(struct super_block *sb)
50485 {
50486 - atomic_inc(&permission_epoch);
50487 + atomic_inc_unchecked(&permission_epoch);
50488 }
50489
50490
50491 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50492 spin_lock(&cii->c_lock);
50493 hit = (mask & cii->c_cached_perm) == mask &&
50494 uid_eq(cii->c_uid, current_fsuid()) &&
50495 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50496 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50497 spin_unlock(&cii->c_lock);
50498
50499 return hit;
50500 diff --git a/fs/compat.c b/fs/compat.c
50501 index fc3b55d..7b568ae 100644
50502 --- a/fs/compat.c
50503 +++ b/fs/compat.c
50504 @@ -54,7 +54,7 @@
50505 #include <asm/ioctls.h>
50506 #include "internal.h"
50507
50508 -int compat_log = 1;
50509 +int compat_log = 0;
50510
50511 int compat_printk(const char *fmt, ...)
50512 {
50513 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50514
50515 set_fs(KERNEL_DS);
50516 /* The __user pointer cast is valid because of the set_fs() */
50517 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50518 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50519 set_fs(oldfs);
50520 /* truncating is ok because it's a user address */
50521 if (!ret)
50522 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50523 goto out;
50524
50525 ret = -EINVAL;
50526 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50527 + if (nr_segs > UIO_MAXIOV)
50528 goto out;
50529 if (nr_segs > fast_segs) {
50530 ret = -ENOMEM;
50531 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
50532
50533 struct compat_readdir_callback {
50534 struct compat_old_linux_dirent __user *dirent;
50535 + struct file * file;
50536 int result;
50537 };
50538
50539 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50540 buf->result = -EOVERFLOW;
50541 return -EOVERFLOW;
50542 }
50543 +
50544 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50545 + return 0;
50546 +
50547 buf->result++;
50548 dirent = buf->dirent;
50549 if (!access_ok(VERIFY_WRITE, dirent,
50550 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50551
50552 buf.result = 0;
50553 buf.dirent = dirent;
50554 + buf.file = f.file;
50555
50556 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50557 if (buf.result)
50558 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
50559 struct compat_getdents_callback {
50560 struct compat_linux_dirent __user *current_dir;
50561 struct compat_linux_dirent __user *previous;
50562 + struct file * file;
50563 int count;
50564 int error;
50565 };
50566 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50567 buf->error = -EOVERFLOW;
50568 return -EOVERFLOW;
50569 }
50570 +
50571 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50572 + return 0;
50573 +
50574 dirent = buf->previous;
50575 if (dirent) {
50576 if (__put_user(offset, &dirent->d_off))
50577 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50578 buf.previous = NULL;
50579 buf.count = count;
50580 buf.error = 0;
50581 + buf.file = f.file;
50582
50583 error = vfs_readdir(f.file, compat_filldir, &buf);
50584 if (error >= 0)
50585 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50586 struct compat_getdents_callback64 {
50587 struct linux_dirent64 __user *current_dir;
50588 struct linux_dirent64 __user *previous;
50589 + struct file * file;
50590 int count;
50591 int error;
50592 };
50593 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50594 buf->error = -EINVAL; /* only used if we fail.. */
50595 if (reclen > buf->count)
50596 return -EINVAL;
50597 +
50598 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50599 + return 0;
50600 +
50601 dirent = buf->previous;
50602
50603 if (dirent) {
50604 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50605 buf.previous = NULL;
50606 buf.count = count;
50607 buf.error = 0;
50608 + buf.file = f.file;
50609
50610 error = vfs_readdir(f.file, compat_filldir64, &buf);
50611 if (error >= 0)
50612 error = buf.error;
50613 lastdirent = buf.previous;
50614 if (lastdirent) {
50615 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50616 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50617 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50618 error = -EFAULT;
50619 else
50620 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50621 index a81147e..20bf2b5 100644
50622 --- a/fs/compat_binfmt_elf.c
50623 +++ b/fs/compat_binfmt_elf.c
50624 @@ -30,11 +30,13 @@
50625 #undef elf_phdr
50626 #undef elf_shdr
50627 #undef elf_note
50628 +#undef elf_dyn
50629 #undef elf_addr_t
50630 #define elfhdr elf32_hdr
50631 #define elf_phdr elf32_phdr
50632 #define elf_shdr elf32_shdr
50633 #define elf_note elf32_note
50634 +#define elf_dyn Elf32_Dyn
50635 #define elf_addr_t Elf32_Addr
50636
50637 /*
50638 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50639 index 996cdc5..15e2f33 100644
50640 --- a/fs/compat_ioctl.c
50641 +++ b/fs/compat_ioctl.c
50642 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50643 return -EFAULT;
50644 if (__get_user(udata, &ss32->iomem_base))
50645 return -EFAULT;
50646 - ss.iomem_base = compat_ptr(udata);
50647 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50648 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50649 __get_user(ss.port_high, &ss32->port_high))
50650 return -EFAULT;
50651 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50652 for (i = 0; i < nmsgs; i++) {
50653 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50654 return -EFAULT;
50655 - if (get_user(datap, &umsgs[i].buf) ||
50656 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50657 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50658 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50659 return -EFAULT;
50660 }
50661 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50662 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
50663 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50664 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50665 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50666 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50667 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50668 return -EFAULT;
50669
50670 return ioctl_preallocate(file, p);
50671 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50672 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50673 {
50674 unsigned int a, b;
50675 - a = *(unsigned int *)p;
50676 - b = *(unsigned int *)q;
50677 + a = *(const unsigned int *)p;
50678 + b = *(const unsigned int *)q;
50679 if (a > b)
50680 return 1;
50681 if (a < b)
50682 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50683 index 7aabc6a..34c1197 100644
50684 --- a/fs/configfs/dir.c
50685 +++ b/fs/configfs/dir.c
50686 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50687 }
50688 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50689 struct configfs_dirent *next;
50690 - const char * name;
50691 + const unsigned char * name;
50692 + char d_name[sizeof(next->s_dentry->d_iname)];
50693 int len;
50694 struct inode *inode = NULL;
50695
50696 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50697 continue;
50698
50699 name = configfs_get_name(next);
50700 - len = strlen(name);
50701 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50702 + len = next->s_dentry->d_name.len;
50703 + memcpy(d_name, name, len);
50704 + name = d_name;
50705 + } else
50706 + len = strlen(name);
50707
50708 /*
50709 * We'll have a dentry and an inode for
50710 diff --git a/fs/coredump.c b/fs/coredump.c
50711 index dafafba..10b3b27 100644
50712 --- a/fs/coredump.c
50713 +++ b/fs/coredump.c
50714 @@ -52,7 +52,7 @@ struct core_name {
50715 char *corename;
50716 int used, size;
50717 };
50718 -static atomic_t call_count = ATOMIC_INIT(1);
50719 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50720
50721 /* The maximal length of core_pattern is also specified in sysctl.c */
50722
50723 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50724 {
50725 char *old_corename = cn->corename;
50726
50727 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50728 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50729 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50730
50731 if (!cn->corename) {
50732 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50733 int pid_in_pattern = 0;
50734 int err = 0;
50735
50736 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50737 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50738 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50739 cn->used = 0;
50740
50741 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
50742 struct pipe_inode_info *pipe = file->private_data;
50743
50744 pipe_lock(pipe);
50745 - pipe->readers++;
50746 - pipe->writers--;
50747 + atomic_inc(&pipe->readers);
50748 + atomic_dec(&pipe->writers);
50749 wake_up_interruptible_sync(&pipe->wait);
50750 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50751 pipe_unlock(pipe);
50752 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
50753 * We actually want wait_event_freezable() but then we need
50754 * to clear TIF_SIGPENDING and improve dump_interrupted().
50755 */
50756 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
50757 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
50758
50759 pipe_lock(pipe);
50760 - pipe->readers--;
50761 - pipe->writers++;
50762 + atomic_dec(&pipe->readers);
50763 + atomic_inc(&pipe->writers);
50764 pipe_unlock(pipe);
50765 }
50766
50767 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
50768 struct files_struct *displaced;
50769 bool need_nonrelative = false;
50770 bool core_dumped = false;
50771 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50772 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50773 + long signr = siginfo->si_signo;
50774 struct coredump_params cprm = {
50775 .siginfo = siginfo,
50776 .regs = signal_pt_regs(),
50777 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
50778 .mm_flags = mm->flags,
50779 };
50780
50781 - audit_core_dumps(siginfo->si_signo);
50782 + audit_core_dumps(signr);
50783 +
50784 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50785 + gr_handle_brute_attach(cprm.mm_flags);
50786
50787 binfmt = mm->binfmt;
50788 if (!binfmt || !binfmt->core_dump)
50789 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
50790 need_nonrelative = true;
50791 }
50792
50793 - retval = coredump_wait(siginfo->si_signo, &core_state);
50794 + retval = coredump_wait(signr, &core_state);
50795 if (retval < 0)
50796 goto fail_creds;
50797
50798 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
50799 }
50800 cprm.limit = RLIM_INFINITY;
50801
50802 - dump_count = atomic_inc_return(&core_dump_count);
50803 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50804 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50805 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50806 task_tgid_vnr(current), current->comm);
50807 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
50808 } else {
50809 struct inode *inode;
50810
50811 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50812 +
50813 if (cprm.limit < binfmt->min_coredump)
50814 goto fail_unlock;
50815
50816 @@ -666,7 +672,7 @@ close_fail:
50817 filp_close(cprm.file, NULL);
50818 fail_dropcount:
50819 if (ispipe)
50820 - atomic_dec(&core_dump_count);
50821 + atomic_dec_unchecked(&core_dump_count);
50822 fail_unlock:
50823 kfree(cn.corename);
50824 fail_corename:
50825 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
50826 {
50827 return !dump_interrupted() &&
50828 access_ok(VERIFY_READ, addr, nr) &&
50829 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50830 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50831 }
50832 EXPORT_SYMBOL(dump_write);
50833
50834 diff --git a/fs/dcache.c b/fs/dcache.c
50835 index f09b908..04b9690 100644
50836 --- a/fs/dcache.c
50837 +++ b/fs/dcache.c
50838 @@ -3086,7 +3086,8 @@ void __init vfs_caches_init(unsigned long mempages)
50839 mempages -= reserve;
50840
50841 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50842 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50843 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
50844 + SLAB_NO_SANITIZE, NULL);
50845
50846 dcache_init();
50847 inode_init();
50848 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50849 index 4888cb3..e0f7cf8 100644
50850 --- a/fs/debugfs/inode.c
50851 +++ b/fs/debugfs/inode.c
50852 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50853 */
50854 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50855 {
50856 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50857 + return __create_file(name, S_IFDIR | S_IRWXU,
50858 +#else
50859 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50860 +#endif
50861 parent, NULL, NULL);
50862 }
50863 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50864 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50865 index 5eab400..810a3f5 100644
50866 --- a/fs/ecryptfs/inode.c
50867 +++ b/fs/ecryptfs/inode.c
50868 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50869 old_fs = get_fs();
50870 set_fs(get_ds());
50871 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50872 - (char __user *)lower_buf,
50873 + (char __force_user *)lower_buf,
50874 PATH_MAX);
50875 set_fs(old_fs);
50876 if (rc < 0)
50877 @@ -706,7 +706,7 @@ out:
50878 static void
50879 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50880 {
50881 - char *buf = nd_get_link(nd);
50882 + const char *buf = nd_get_link(nd);
50883 if (!IS_ERR(buf)) {
50884 /* Free the char* */
50885 kfree(buf);
50886 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50887 index e4141f2..d8263e8 100644
50888 --- a/fs/ecryptfs/miscdev.c
50889 +++ b/fs/ecryptfs/miscdev.c
50890 @@ -304,7 +304,7 @@ check_list:
50891 goto out_unlock_msg_ctx;
50892 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50893 if (msg_ctx->msg) {
50894 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50895 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50896 goto out_unlock_msg_ctx;
50897 i += packet_length_size;
50898 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50899 diff --git a/fs/exec.c b/fs/exec.c
50900 index ffd7a81..d95acf6 100644
50901 --- a/fs/exec.c
50902 +++ b/fs/exec.c
50903 @@ -55,8 +55,20 @@
50904 #include <linux/pipe_fs_i.h>
50905 #include <linux/oom.h>
50906 #include <linux/compat.h>
50907 +#include <linux/random.h>
50908 +#include <linux/seq_file.h>
50909 +#include <linux/coredump.h>
50910 +#include <linux/mman.h>
50911 +
50912 +#ifdef CONFIG_PAX_REFCOUNT
50913 +#include <linux/kallsyms.h>
50914 +#include <linux/kdebug.h>
50915 +#endif
50916 +
50917 +#include <trace/events/fs.h>
50918
50919 #include <asm/uaccess.h>
50920 +#include <asm/sections.h>
50921 #include <asm/mmu_context.h>
50922 #include <asm/tlb.h>
50923
50924 @@ -66,17 +78,32 @@
50925
50926 #include <trace/events/sched.h>
50927
50928 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50929 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50930 +{
50931 + pr_warn_once("PAX: PAX_HAVE_ACL_FLAGS was enabled without providing the pax_set_initial_flags callback, this is probably not what you wanted.\n");
50932 +}
50933 +#endif
50934 +
50935 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50936 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50937 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50938 +#endif
50939 +
50940 int suid_dumpable = 0;
50941
50942 static LIST_HEAD(formats);
50943 static DEFINE_RWLOCK(binfmt_lock);
50944
50945 +extern int gr_process_kernel_exec_ban(void);
50946 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
50947 +
50948 void __register_binfmt(struct linux_binfmt * fmt, int insert)
50949 {
50950 BUG_ON(!fmt);
50951 write_lock(&binfmt_lock);
50952 - insert ? list_add(&fmt->lh, &formats) :
50953 - list_add_tail(&fmt->lh, &formats);
50954 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50955 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50956 write_unlock(&binfmt_lock);
50957 }
50958
50959 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
50960 void unregister_binfmt(struct linux_binfmt * fmt)
50961 {
50962 write_lock(&binfmt_lock);
50963 - list_del(&fmt->lh);
50964 + pax_list_del((struct list_head *)&fmt->lh);
50965 write_unlock(&binfmt_lock);
50966 }
50967
50968 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50969 int write)
50970 {
50971 struct page *page;
50972 - int ret;
50973
50974 -#ifdef CONFIG_STACK_GROWSUP
50975 - if (write) {
50976 - ret = expand_downwards(bprm->vma, pos);
50977 - if (ret < 0)
50978 - return NULL;
50979 - }
50980 -#endif
50981 - ret = get_user_pages(current, bprm->mm, pos,
50982 - 1, write, 1, &page, NULL);
50983 - if (ret <= 0)
50984 + if (0 > expand_downwards(bprm->vma, pos))
50985 + return NULL;
50986 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50987 return NULL;
50988
50989 if (write) {
50990 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50991 if (size <= ARG_MAX)
50992 return page;
50993
50994 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50995 + // only allow 512KB for argv+env on suid/sgid binaries
50996 + // to prevent easy ASLR exhaustion
50997 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50998 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50999 + (size > (512 * 1024))) {
51000 + put_page(page);
51001 + return NULL;
51002 + }
51003 +#endif
51004 +
51005 /*
51006 * Limit to 1/4-th the stack size for the argv+env strings.
51007 * This ensures that:
51008 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
51009 vma->vm_end = STACK_TOP_MAX;
51010 vma->vm_start = vma->vm_end - PAGE_SIZE;
51011 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
51012 +
51013 +#ifdef CONFIG_PAX_SEGMEXEC
51014 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
51015 +#endif
51016 +
51017 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
51018 INIT_LIST_HEAD(&vma->anon_vma_chain);
51019
51020 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
51021 mm->stack_vm = mm->total_vm = 1;
51022 up_write(&mm->mmap_sem);
51023 bprm->p = vma->vm_end - sizeof(void *);
51024 +
51025 +#ifdef CONFIG_PAX_RANDUSTACK
51026 + if (randomize_va_space)
51027 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
51028 +#endif
51029 +
51030 return 0;
51031 err:
51032 up_write(&mm->mmap_sem);
51033 @@ -396,7 +437,7 @@ struct user_arg_ptr {
51034 } ptr;
51035 };
51036
51037 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51038 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51039 {
51040 const char __user *native;
51041
51042 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51043 compat_uptr_t compat;
51044
51045 if (get_user(compat, argv.ptr.compat + nr))
51046 - return ERR_PTR(-EFAULT);
51047 + return (const char __force_user *)ERR_PTR(-EFAULT);
51048
51049 return compat_ptr(compat);
51050 }
51051 #endif
51052
51053 if (get_user(native, argv.ptr.native + nr))
51054 - return ERR_PTR(-EFAULT);
51055 + return (const char __force_user *)ERR_PTR(-EFAULT);
51056
51057 return native;
51058 }
51059 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
51060 if (!p)
51061 break;
51062
51063 - if (IS_ERR(p))
51064 + if (IS_ERR((const char __force_kernel *)p))
51065 return -EFAULT;
51066
51067 if (i >= max)
51068 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
51069
51070 ret = -EFAULT;
51071 str = get_user_arg_ptr(argv, argc);
51072 - if (IS_ERR(str))
51073 + if (IS_ERR((const char __force_kernel *)str))
51074 goto out;
51075
51076 len = strnlen_user(str, MAX_ARG_STRLEN);
51077 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
51078 int r;
51079 mm_segment_t oldfs = get_fs();
51080 struct user_arg_ptr argv = {
51081 - .ptr.native = (const char __user *const __user *)__argv,
51082 + .ptr.native = (const char __force_user * const __force_user *)__argv,
51083 };
51084
51085 set_fs(KERNEL_DS);
51086 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51087 unsigned long new_end = old_end - shift;
51088 struct mmu_gather tlb;
51089
51090 - BUG_ON(new_start > new_end);
51091 + if (new_start >= new_end || new_start < mmap_min_addr)
51092 + return -ENOMEM;
51093
51094 /*
51095 * ensure there are no vmas between where we want to go
51096 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51097 if (vma != find_vma(mm, new_start))
51098 return -EFAULT;
51099
51100 +#ifdef CONFIG_PAX_SEGMEXEC
51101 + BUG_ON(pax_find_mirror_vma(vma));
51102 +#endif
51103 +
51104 /*
51105 * cover the whole range: [new_start, old_end)
51106 */
51107 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51108 stack_top = arch_align_stack(stack_top);
51109 stack_top = PAGE_ALIGN(stack_top);
51110
51111 - if (unlikely(stack_top < mmap_min_addr) ||
51112 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51113 - return -ENOMEM;
51114 -
51115 stack_shift = vma->vm_end - stack_top;
51116
51117 bprm->p -= stack_shift;
51118 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51119 bprm->exec -= stack_shift;
51120
51121 down_write(&mm->mmap_sem);
51122 +
51123 + /* Move stack pages down in memory. */
51124 + if (stack_shift) {
51125 + ret = shift_arg_pages(vma, stack_shift);
51126 + if (ret)
51127 + goto out_unlock;
51128 + }
51129 +
51130 vm_flags = VM_STACK_FLAGS;
51131
51132 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51133 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51134 + vm_flags &= ~VM_EXEC;
51135 +
51136 +#ifdef CONFIG_PAX_MPROTECT
51137 + if (mm->pax_flags & MF_PAX_MPROTECT)
51138 + vm_flags &= ~VM_MAYEXEC;
51139 +#endif
51140 +
51141 + }
51142 +#endif
51143 +
51144 /*
51145 * Adjust stack execute permissions; explicitly enable for
51146 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51147 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51148 goto out_unlock;
51149 BUG_ON(prev != vma);
51150
51151 - /* Move stack pages down in memory. */
51152 - if (stack_shift) {
51153 - ret = shift_arg_pages(vma, stack_shift);
51154 - if (ret)
51155 - goto out_unlock;
51156 - }
51157 -
51158 /* mprotect_fixup is overkill to remove the temporary stack flags */
51159 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51160
51161 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51162 #endif
51163 current->mm->start_stack = bprm->p;
51164 ret = expand_stack(vma, stack_base);
51165 +
51166 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51167 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51168 + unsigned long size;
51169 + vm_flags_t vm_flags;
51170 +
51171 + size = STACK_TOP - vma->vm_end;
51172 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51173 +
51174 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
51175 +
51176 +#ifdef CONFIG_X86
51177 + if (!ret) {
51178 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51179 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
51180 + }
51181 +#endif
51182 +
51183 + }
51184 +#endif
51185 +
51186 if (ret)
51187 ret = -EFAULT;
51188
51189 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
51190
51191 fsnotify_open(file);
51192
51193 + trace_open_exec(name);
51194 +
51195 err = deny_write_access(file);
51196 if (err)
51197 goto exit;
51198 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
51199 old_fs = get_fs();
51200 set_fs(get_ds());
51201 /* The cast to a user pointer is valid due to the set_fs() */
51202 - result = vfs_read(file, (void __user *)addr, count, &pos);
51203 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51204 set_fs(old_fs);
51205 return result;
51206 }
51207 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51208 }
51209 rcu_read_unlock();
51210
51211 - if (p->fs->users > n_fs) {
51212 + if (atomic_read(&p->fs->users) > n_fs) {
51213 bprm->unsafe |= LSM_UNSAFE_SHARE;
51214 } else {
51215 res = -EAGAIN;
51216 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51217
51218 EXPORT_SYMBOL(search_binary_handler);
51219
51220 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51221 +static DEFINE_PER_CPU(u64, exec_counter);
51222 +static int __init init_exec_counters(void)
51223 +{
51224 + unsigned int cpu;
51225 +
51226 + for_each_possible_cpu(cpu) {
51227 + per_cpu(exec_counter, cpu) = (u64)cpu;
51228 + }
51229 +
51230 + return 0;
51231 +}
51232 +early_initcall(init_exec_counters);
51233 +static inline void increment_exec_counter(void)
51234 +{
51235 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51236 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51237 +}
51238 +#else
51239 +static inline void increment_exec_counter(void) {}
51240 +#endif
51241 +
51242 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51243 + struct user_arg_ptr argv);
51244 +
51245 /*
51246 * sys_execve() executes a new program.
51247 */
51248 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
51249 struct user_arg_ptr argv,
51250 struct user_arg_ptr envp)
51251 {
51252 +#ifdef CONFIG_GRKERNSEC
51253 + struct file *old_exec_file;
51254 + struct acl_subject_label *old_acl;
51255 + struct rlimit old_rlim[RLIM_NLIMITS];
51256 +#endif
51257 struct linux_binprm *bprm;
51258 struct file *file;
51259 struct files_struct *displaced;
51260 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
51261 int retval;
51262 const struct cred *cred = current_cred();
51263
51264 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
51265 +
51266 /*
51267 * We move the actual failure in case of RLIMIT_NPROC excess from
51268 * set*uid() to execve() because too many poorly written programs
51269 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
51270 if (IS_ERR(file))
51271 goto out_unmark;
51272
51273 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51274 + retval = -EPERM;
51275 + goto out_file;
51276 + }
51277 +
51278 sched_exec();
51279
51280 bprm->file = file;
51281 bprm->filename = filename;
51282 bprm->interp = filename;
51283
51284 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
51285 + retval = -EACCES;
51286 + goto out_file;
51287 + }
51288 +
51289 retval = bprm_mm_init(bprm);
51290 if (retval)
51291 goto out_file;
51292 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
51293 if (retval < 0)
51294 goto out;
51295
51296 +#ifdef CONFIG_GRKERNSEC
51297 + old_acl = current->acl;
51298 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51299 + old_exec_file = current->exec_file;
51300 + get_file(file);
51301 + current->exec_file = file;
51302 +#endif
51303 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51304 + /* limit suid stack to 8MB
51305 + * we saved the old limits above and will restore them if this exec fails
51306 + */
51307 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51308 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51309 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51310 +#endif
51311 +
51312 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
51313 + retval = -EPERM;
51314 + goto out_fail;
51315 + }
51316 +
51317 + if (!gr_tpe_allow(file)) {
51318 + retval = -EACCES;
51319 + goto out_fail;
51320 + }
51321 +
51322 + if (gr_check_crash_exec(file)) {
51323 + retval = -EACCES;
51324 + goto out_fail;
51325 + }
51326 +
51327 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
51328 + bprm->unsafe);
51329 + if (retval < 0)
51330 + goto out_fail;
51331 +
51332 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51333 if (retval < 0)
51334 - goto out;
51335 + goto out_fail;
51336
51337 bprm->exec = bprm->p;
51338 retval = copy_strings(bprm->envc, envp, bprm);
51339 if (retval < 0)
51340 - goto out;
51341 + goto out_fail;
51342
51343 retval = copy_strings(bprm->argc, argv, bprm);
51344 if (retval < 0)
51345 - goto out;
51346 + goto out_fail;
51347 +
51348 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
51349 +
51350 + gr_handle_exec_args(bprm, argv);
51351
51352 retval = search_binary_handler(bprm);
51353 if (retval < 0)
51354 - goto out;
51355 + goto out_fail;
51356 +#ifdef CONFIG_GRKERNSEC
51357 + if (old_exec_file)
51358 + fput(old_exec_file);
51359 +#endif
51360
51361 /* execve succeeded */
51362 +
51363 + increment_exec_counter();
51364 current->fs->in_exec = 0;
51365 current->in_execve = 0;
51366 acct_update_integrals(current);
51367 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
51368 put_files_struct(displaced);
51369 return retval;
51370
51371 +out_fail:
51372 +#ifdef CONFIG_GRKERNSEC
51373 + current->acl = old_acl;
51374 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51375 + fput(current->exec_file);
51376 + current->exec_file = old_exec_file;
51377 +#endif
51378 +
51379 out:
51380 if (bprm->mm) {
51381 acct_arg_size(bprm, 0);
51382 @@ -1701,3 +1875,285 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51383 return error;
51384 }
51385 #endif
51386 +
51387 +int pax_check_flags(unsigned long *flags)
51388 +{
51389 + int retval = 0;
51390 +
51391 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51392 + if (*flags & MF_PAX_SEGMEXEC)
51393 + {
51394 + *flags &= ~MF_PAX_SEGMEXEC;
51395 + retval = -EINVAL;
51396 + }
51397 +#endif
51398 +
51399 + if ((*flags & MF_PAX_PAGEEXEC)
51400 +
51401 +#ifdef CONFIG_PAX_PAGEEXEC
51402 + && (*flags & MF_PAX_SEGMEXEC)
51403 +#endif
51404 +
51405 + )
51406 + {
51407 + *flags &= ~MF_PAX_PAGEEXEC;
51408 + retval = -EINVAL;
51409 + }
51410 +
51411 + if ((*flags & MF_PAX_MPROTECT)
51412 +
51413 +#ifdef CONFIG_PAX_MPROTECT
51414 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51415 +#endif
51416 +
51417 + )
51418 + {
51419 + *flags &= ~MF_PAX_MPROTECT;
51420 + retval = -EINVAL;
51421 + }
51422 +
51423 + if ((*flags & MF_PAX_EMUTRAMP)
51424 +
51425 +#ifdef CONFIG_PAX_EMUTRAMP
51426 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51427 +#endif
51428 +
51429 + )
51430 + {
51431 + *flags &= ~MF_PAX_EMUTRAMP;
51432 + retval = -EINVAL;
51433 + }
51434 +
51435 + return retval;
51436 +}
51437 +
51438 +EXPORT_SYMBOL(pax_check_flags);
51439 +
51440 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51441 +char *pax_get_path(const struct path *path, char *buf, int buflen)
51442 +{
51443 + char *pathname = d_path(path, buf, buflen);
51444 +
51445 + if (IS_ERR(pathname))
51446 + goto toolong;
51447 +
51448 + pathname = mangle_path(buf, pathname, "\t\n\\");
51449 + if (!pathname)
51450 + goto toolong;
51451 +
51452 + *pathname = 0;
51453 + return buf;
51454 +
51455 +toolong:
51456 + return "<path too long>";
51457 +}
51458 +EXPORT_SYMBOL(pax_get_path);
51459 +
51460 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51461 +{
51462 + struct task_struct *tsk = current;
51463 + struct mm_struct *mm = current->mm;
51464 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51465 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51466 + char *path_exec = NULL;
51467 + char *path_fault = NULL;
51468 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51469 + siginfo_t info = { };
51470 +
51471 + if (buffer_exec && buffer_fault) {
51472 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51473 +
51474 + down_read(&mm->mmap_sem);
51475 + vma = mm->mmap;
51476 + while (vma && (!vma_exec || !vma_fault)) {
51477 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51478 + vma_exec = vma;
51479 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51480 + vma_fault = vma;
51481 + vma = vma->vm_next;
51482 + }
51483 + if (vma_exec)
51484 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51485 + if (vma_fault) {
51486 + start = vma_fault->vm_start;
51487 + end = vma_fault->vm_end;
51488 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51489 + if (vma_fault->vm_file)
51490 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51491 + else if (pc >= mm->start_brk && pc < mm->brk)
51492 + path_fault = "<heap>";
51493 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
51494 + path_fault = "<stack>";
51495 + else
51496 + path_fault = "<anonymous mapping>";
51497 + }
51498 + up_read(&mm->mmap_sem);
51499 + }
51500 + if (tsk->signal->curr_ip)
51501 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51502 + else
51503 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51504 + printk(KERN_ERR "PAX: terminating task: %s(%s):%d, uid/euid: %u/%u, PC: %p, SP: %p\n", path_exec, tsk->comm, task_pid_nr(tsk),
51505 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51506 + free_page((unsigned long)buffer_exec);
51507 + free_page((unsigned long)buffer_fault);
51508 + pax_report_insns(regs, pc, sp);
51509 + info.si_signo = SIGKILL;
51510 + info.si_errno = 0;
51511 + info.si_code = SI_KERNEL;
51512 + info.si_pid = 0;
51513 + info.si_uid = 0;
51514 + do_coredump(&info);
51515 +}
51516 +#endif
51517 +
51518 +#ifdef CONFIG_PAX_REFCOUNT
51519 +void pax_report_refcount_overflow(struct pt_regs *regs)
51520 +{
51521 + if (current->signal->curr_ip)
51522 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51523 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51524 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51525 + else
51526 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51527 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51528 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51529 + show_regs(regs);
51530 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51531 +}
51532 +#endif
51533 +
51534 +#ifdef CONFIG_PAX_USERCOPY
51535 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51536 +static noinline int check_stack_object(const void *obj, unsigned long len)
51537 +{
51538 + const void * const stack = task_stack_page(current);
51539 + const void * const stackend = stack + THREAD_SIZE;
51540 +
51541 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51542 + const void *frame = NULL;
51543 + const void *oldframe;
51544 +#endif
51545 +
51546 + if (obj + len < obj)
51547 + return -1;
51548 +
51549 + if (obj + len <= stack || stackend <= obj)
51550 + return 0;
51551 +
51552 + if (obj < stack || stackend < obj + len)
51553 + return -1;
51554 +
51555 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51556 + oldframe = __builtin_frame_address(1);
51557 + if (oldframe)
51558 + frame = __builtin_frame_address(2);
51559 + /*
51560 + low ----------------------------------------------> high
51561 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51562 + ^----------------^
51563 + allow copies only within here
51564 + */
51565 + while (stack <= frame && frame < stackend) {
51566 + /* if obj + len extends past the last frame, this
51567 + check won't pass and the next frame will be 0,
51568 + causing us to bail out and correctly report
51569 + the copy as invalid
51570 + */
51571 + if (obj + len <= frame)
51572 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51573 + oldframe = frame;
51574 + frame = *(const void * const *)frame;
51575 + }
51576 + return -1;
51577 +#else
51578 + return 1;
51579 +#endif
51580 +}
51581 +
51582 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51583 +{
51584 + if (current->signal->curr_ip)
51585 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51586 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51587 + else
51588 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51589 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51590 + dump_stack();
51591 + gr_handle_kernel_exploit();
51592 + do_group_exit(SIGKILL);
51593 +}
51594 +#endif
51595 +
51596 +#ifdef CONFIG_PAX_USERCOPY
51597 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51598 +{
51599 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51600 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51601 +#ifdef CONFIG_MODULES
51602 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51603 +#else
51604 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51605 +#endif
51606 +
51607 +#else
51608 + unsigned long textlow = (unsigned long)_stext;
51609 + unsigned long texthigh = (unsigned long)_etext;
51610 +#endif
51611 +
51612 + if (high <= textlow || low > texthigh)
51613 + return false;
51614 + else
51615 + return true;
51616 +}
51617 +#endif
51618 +
51619 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51620 +{
51621 +
51622 +#ifdef CONFIG_PAX_USERCOPY
51623 + const char *type;
51624 +
51625 + if (!n)
51626 + return;
51627 +
51628 + type = check_heap_object(ptr, n);
51629 + if (!type) {
51630 + int ret = check_stack_object(ptr, n);
51631 + if (ret == 1 || ret == 2)
51632 + return;
51633 + if (ret == 0) {
51634 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51635 + type = "<kernel text>";
51636 + else
51637 + return;
51638 + } else
51639 + type = "<process stack>";
51640 + }
51641 +
51642 + pax_report_usercopy(ptr, n, to_user, type);
51643 +#endif
51644 +
51645 +}
51646 +EXPORT_SYMBOL(__check_object_size);
51647 +
51648 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51649 +void pax_track_stack(void)
51650 +{
51651 + unsigned long sp = (unsigned long)&sp;
51652 + if (sp < current_thread_info()->lowest_stack &&
51653 + sp > (unsigned long)task_stack_page(current))
51654 + current_thread_info()->lowest_stack = sp;
51655 +}
51656 +EXPORT_SYMBOL(pax_track_stack);
51657 +#endif
51658 +
51659 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51660 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51661 +{
51662 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51663 + dump_stack();
51664 + do_group_exit(SIGKILL);
51665 +}
51666 +EXPORT_SYMBOL(report_size_overflow);
51667 +#endif
51668 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51669 index 9f9992b..8b59411 100644
51670 --- a/fs/ext2/balloc.c
51671 +++ b/fs/ext2/balloc.c
51672 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51673
51674 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51675 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51676 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51677 + if (free_blocks < root_blocks + 1 &&
51678 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51679 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51680 - !in_group_p (sbi->s_resgid))) {
51681 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51682 return 0;
51683 }
51684 return 1;
51685 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51686 index 22548f5..41521d8 100644
51687 --- a/fs/ext3/balloc.c
51688 +++ b/fs/ext3/balloc.c
51689 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51690
51691 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51692 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51693 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51694 + if (free_blocks < root_blocks + 1 &&
51695 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51696 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51697 - !in_group_p (sbi->s_resgid))) {
51698 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51699 return 0;
51700 }
51701 return 1;
51702 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51703 index 3742e4c..69a797f 100644
51704 --- a/fs/ext4/balloc.c
51705 +++ b/fs/ext4/balloc.c
51706 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51707 /* Hm, nope. Are (enough) root reserved clusters available? */
51708 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51709 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51710 - capable(CAP_SYS_RESOURCE) ||
51711 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51712 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51713 + capable_nolog(CAP_SYS_RESOURCE)) {
51714
51715 if (free_clusters >= (nclusters + dirty_clusters +
51716 resv_clusters))
51717 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51718 index 5aae3d1..b5da7f8 100644
51719 --- a/fs/ext4/ext4.h
51720 +++ b/fs/ext4/ext4.h
51721 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
51722 unsigned long s_mb_last_start;
51723
51724 /* stats for buddy allocator */
51725 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51726 - atomic_t s_bal_success; /* we found long enough chunks */
51727 - atomic_t s_bal_allocated; /* in blocks */
51728 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51729 - atomic_t s_bal_goals; /* goal hits */
51730 - atomic_t s_bal_breaks; /* too long searches */
51731 - atomic_t s_bal_2orders; /* 2^order hits */
51732 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51733 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51734 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51735 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51736 + atomic_unchecked_t s_bal_goals; /* goal hits */
51737 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51738 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51739 spinlock_t s_bal_lock;
51740 unsigned long s_mb_buddies_generated;
51741 unsigned long long s_mb_generation_time;
51742 - atomic_t s_mb_lost_chunks;
51743 - atomic_t s_mb_preallocated;
51744 - atomic_t s_mb_discarded;
51745 + atomic_unchecked_t s_mb_lost_chunks;
51746 + atomic_unchecked_t s_mb_preallocated;
51747 + atomic_unchecked_t s_mb_discarded;
51748 atomic_t s_lock_busy;
51749
51750 /* locality groups */
51751 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51752 index 59c6750..a549154 100644
51753 --- a/fs/ext4/mballoc.c
51754 +++ b/fs/ext4/mballoc.c
51755 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51756 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51757
51758 if (EXT4_SB(sb)->s_mb_stats)
51759 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51760 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51761
51762 break;
51763 }
51764 @@ -2170,7 +2170,7 @@ repeat:
51765 ac->ac_status = AC_STATUS_CONTINUE;
51766 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51767 cr = 3;
51768 - atomic_inc(&sbi->s_mb_lost_chunks);
51769 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51770 goto repeat;
51771 }
51772 }
51773 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
51774 if (sbi->s_mb_stats) {
51775 ext4_msg(sb, KERN_INFO,
51776 "mballoc: %u blocks %u reqs (%u success)",
51777 - atomic_read(&sbi->s_bal_allocated),
51778 - atomic_read(&sbi->s_bal_reqs),
51779 - atomic_read(&sbi->s_bal_success));
51780 + atomic_read_unchecked(&sbi->s_bal_allocated),
51781 + atomic_read_unchecked(&sbi->s_bal_reqs),
51782 + atomic_read_unchecked(&sbi->s_bal_success));
51783 ext4_msg(sb, KERN_INFO,
51784 "mballoc: %u extents scanned, %u goal hits, "
51785 "%u 2^N hits, %u breaks, %u lost",
51786 - atomic_read(&sbi->s_bal_ex_scanned),
51787 - atomic_read(&sbi->s_bal_goals),
51788 - atomic_read(&sbi->s_bal_2orders),
51789 - atomic_read(&sbi->s_bal_breaks),
51790 - atomic_read(&sbi->s_mb_lost_chunks));
51791 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51792 + atomic_read_unchecked(&sbi->s_bal_goals),
51793 + atomic_read_unchecked(&sbi->s_bal_2orders),
51794 + atomic_read_unchecked(&sbi->s_bal_breaks),
51795 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51796 ext4_msg(sb, KERN_INFO,
51797 "mballoc: %lu generated and it took %Lu",
51798 sbi->s_mb_buddies_generated,
51799 sbi->s_mb_generation_time);
51800 ext4_msg(sb, KERN_INFO,
51801 "mballoc: %u preallocated, %u discarded",
51802 - atomic_read(&sbi->s_mb_preallocated),
51803 - atomic_read(&sbi->s_mb_discarded));
51804 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51805 + atomic_read_unchecked(&sbi->s_mb_discarded));
51806 }
51807
51808 free_percpu(sbi->s_locality_groups);
51809 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51810 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51811
51812 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51813 - atomic_inc(&sbi->s_bal_reqs);
51814 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51815 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51816 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51817 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51818 - atomic_inc(&sbi->s_bal_success);
51819 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51820 + atomic_inc_unchecked(&sbi->s_bal_success);
51821 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51822 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51823 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51824 - atomic_inc(&sbi->s_bal_goals);
51825 + atomic_inc_unchecked(&sbi->s_bal_goals);
51826 if (ac->ac_found > sbi->s_mb_max_to_scan)
51827 - atomic_inc(&sbi->s_bal_breaks);
51828 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51829 }
51830
51831 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51832 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51833 trace_ext4_mb_new_inode_pa(ac, pa);
51834
51835 ext4_mb_use_inode_pa(ac, pa);
51836 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51837 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51838
51839 ei = EXT4_I(ac->ac_inode);
51840 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51841 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51842 trace_ext4_mb_new_group_pa(ac, pa);
51843
51844 ext4_mb_use_group_pa(ac, pa);
51845 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51846 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51847
51848 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51849 lg = ac->ac_lg;
51850 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51851 * from the bitmap and continue.
51852 */
51853 }
51854 - atomic_add(free, &sbi->s_mb_discarded);
51855 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51856
51857 return err;
51858 }
51859 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51860 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51861 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51862 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51863 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51864 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51865 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51866
51867 return 0;
51868 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51869 index 214461e..3614c89 100644
51870 --- a/fs/ext4/mmp.c
51871 +++ b/fs/ext4/mmp.c
51872 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51873 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51874 const char *function, unsigned int line, const char *msg)
51875 {
51876 - __ext4_warning(sb, function, line, msg);
51877 + __ext4_warning(sb, function, line, "%s", msg);
51878 __ext4_warning(sb, function, line,
51879 "MMP failure info: last update time: %llu, last update "
51880 "node: %s, last update device: %s\n",
51881 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51882 index 49d3c01..9579efd 100644
51883 --- a/fs/ext4/resize.c
51884 +++ b/fs/ext4/resize.c
51885 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51886 ext4_fsblk_t end = start + input->blocks_count;
51887 ext4_group_t group = input->group;
51888 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51889 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51890 - ext4_fsblk_t metaend = start + overhead;
51891 + unsigned overhead;
51892 + ext4_fsblk_t metaend;
51893 struct buffer_head *bh = NULL;
51894 ext4_grpblk_t free_blocks_count, offset;
51895 int err = -EINVAL;
51896
51897 + if (group != sbi->s_groups_count) {
51898 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51899 + input->group, sbi->s_groups_count);
51900 + return -EINVAL;
51901 + }
51902 +
51903 + overhead = ext4_group_overhead_blocks(sb, group);
51904 + metaend = start + overhead;
51905 input->free_blocks_count = free_blocks_count =
51906 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51907
51908 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51909 free_blocks_count, input->reserved_blocks);
51910
51911 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51912 - if (group != sbi->s_groups_count)
51913 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51914 - input->group, sbi->s_groups_count);
51915 - else if (offset != 0)
51916 + if (offset != 0)
51917 ext4_warning(sb, "Last group not full");
51918 else if (input->reserved_blocks > input->blocks_count / 5)
51919 ext4_warning(sb, "Reserved blocks too high (%u)",
51920 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51921 index 6681c03..d88cd33 100644
51922 --- a/fs/ext4/super.c
51923 +++ b/fs/ext4/super.c
51924 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51925 }
51926
51927 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51928 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51929 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51930 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51931
51932 #ifdef CONFIG_QUOTA
51933 @@ -2372,7 +2372,7 @@ struct ext4_attr {
51934 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51935 const char *, size_t);
51936 int offset;
51937 -};
51938 +} __do_const;
51939
51940 static int parse_strtoull(const char *buf,
51941 unsigned long long max, unsigned long long *value)
51942 diff --git a/fs/fcntl.c b/fs/fcntl.c
51943 index 6599222..e7bf0de 100644
51944 --- a/fs/fcntl.c
51945 +++ b/fs/fcntl.c
51946 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51947 if (err)
51948 return err;
51949
51950 + if (gr_handle_chroot_fowner(pid, type))
51951 + return -ENOENT;
51952 + if (gr_check_protected_task_fowner(pid, type))
51953 + return -EACCES;
51954 +
51955 f_modown(filp, pid, type, force);
51956 return 0;
51957 }
51958 diff --git a/fs/fhandle.c b/fs/fhandle.c
51959 index 999ff5c..41f4109 100644
51960 --- a/fs/fhandle.c
51961 +++ b/fs/fhandle.c
51962 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51963 } else
51964 retval = 0;
51965 /* copy the mount id */
51966 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51967 - sizeof(*mnt_id)) ||
51968 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51969 copy_to_user(ufh, handle,
51970 sizeof(struct file_handle) + handle_bytes))
51971 retval = -EFAULT;
51972 diff --git a/fs/file.c b/fs/file.c
51973 index 4a78f98..9447397 100644
51974 --- a/fs/file.c
51975 +++ b/fs/file.c
51976 @@ -16,6 +16,7 @@
51977 #include <linux/slab.h>
51978 #include <linux/vmalloc.h>
51979 #include <linux/file.h>
51980 +#include <linux/security.h>
51981 #include <linux/fdtable.h>
51982 #include <linux/bitops.h>
51983 #include <linux/interrupt.h>
51984 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51985 if (!file)
51986 return __close_fd(files, fd);
51987
51988 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51989 if (fd >= rlimit(RLIMIT_NOFILE))
51990 return -EBADF;
51991
51992 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51993 if (unlikely(oldfd == newfd))
51994 return -EINVAL;
51995
51996 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51997 if (newfd >= rlimit(RLIMIT_NOFILE))
51998 return -EBADF;
51999
52000 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
52001 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
52002 {
52003 int err;
52004 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
52005 if (from >= rlimit(RLIMIT_NOFILE))
52006 return -EINVAL;
52007 err = alloc_fd(from, flags);
52008 diff --git a/fs/filesystems.c b/fs/filesystems.c
52009 index 92567d9..fcd8cbf 100644
52010 --- a/fs/filesystems.c
52011 +++ b/fs/filesystems.c
52012 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
52013 int len = dot ? dot - name : strlen(name);
52014
52015 fs = __get_fs_type(name, len);
52016 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
52017 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
52018 +#else
52019 if (!fs && (request_module("fs-%.*s", len, name) == 0))
52020 +#endif
52021 fs = __get_fs_type(name, len);
52022
52023 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
52024 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
52025 index d8ac61d..79a36f0 100644
52026 --- a/fs/fs_struct.c
52027 +++ b/fs/fs_struct.c
52028 @@ -4,6 +4,7 @@
52029 #include <linux/path.h>
52030 #include <linux/slab.h>
52031 #include <linux/fs_struct.h>
52032 +#include <linux/grsecurity.h>
52033 #include "internal.h"
52034
52035 /*
52036 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
52037 write_seqcount_begin(&fs->seq);
52038 old_root = fs->root;
52039 fs->root = *path;
52040 + gr_set_chroot_entries(current, path);
52041 write_seqcount_end(&fs->seq);
52042 spin_unlock(&fs->lock);
52043 if (old_root.dentry)
52044 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
52045 int hits = 0;
52046 spin_lock(&fs->lock);
52047 write_seqcount_begin(&fs->seq);
52048 + /* this root replacement is only done by pivot_root,
52049 + leave grsec's chroot tagging alone for this task
52050 + so that a pivoted root isn't treated as a chroot
52051 + */
52052 hits += replace_path(&fs->root, old_root, new_root);
52053 hits += replace_path(&fs->pwd, old_root, new_root);
52054 write_seqcount_end(&fs->seq);
52055 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
52056 task_lock(tsk);
52057 spin_lock(&fs->lock);
52058 tsk->fs = NULL;
52059 - kill = !--fs->users;
52060 + gr_clear_chroot_entries(tsk);
52061 + kill = !atomic_dec_return(&fs->users);
52062 spin_unlock(&fs->lock);
52063 task_unlock(tsk);
52064 if (kill)
52065 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52066 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
52067 /* We don't need to lock fs - think why ;-) */
52068 if (fs) {
52069 - fs->users = 1;
52070 + atomic_set(&fs->users, 1);
52071 fs->in_exec = 0;
52072 spin_lock_init(&fs->lock);
52073 seqcount_init(&fs->seq);
52074 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52075 spin_lock(&old->lock);
52076 fs->root = old->root;
52077 path_get(&fs->root);
52078 + /* instead of calling gr_set_chroot_entries here,
52079 + we call it from every caller of this function
52080 + */
52081 fs->pwd = old->pwd;
52082 path_get(&fs->pwd);
52083 spin_unlock(&old->lock);
52084 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
52085
52086 task_lock(current);
52087 spin_lock(&fs->lock);
52088 - kill = !--fs->users;
52089 + kill = !atomic_dec_return(&fs->users);
52090 current->fs = new_fs;
52091 + gr_set_chroot_entries(current, &new_fs->root);
52092 spin_unlock(&fs->lock);
52093 task_unlock(current);
52094
52095 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52096
52097 int current_umask(void)
52098 {
52099 - return current->fs->umask;
52100 + return current->fs->umask | gr_acl_umask();
52101 }
52102 EXPORT_SYMBOL(current_umask);
52103
52104 /* to be mentioned only in INIT_TASK */
52105 struct fs_struct init_fs = {
52106 - .users = 1,
52107 + .users = ATOMIC_INIT(1),
52108 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52109 .seq = SEQCNT_ZERO,
52110 .umask = 0022,
52111 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52112 index e2cba1f..17a25bb 100644
52113 --- a/fs/fscache/cookie.c
52114 +++ b/fs/fscache/cookie.c
52115 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52116 parent ? (char *) parent->def->name : "<no-parent>",
52117 def->name, netfs_data);
52118
52119 - fscache_stat(&fscache_n_acquires);
52120 + fscache_stat_unchecked(&fscache_n_acquires);
52121
52122 /* if there's no parent cookie, then we don't create one here either */
52123 if (!parent) {
52124 - fscache_stat(&fscache_n_acquires_null);
52125 + fscache_stat_unchecked(&fscache_n_acquires_null);
52126 _leave(" [no parent]");
52127 return NULL;
52128 }
52129 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52130 /* allocate and initialise a cookie */
52131 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52132 if (!cookie) {
52133 - fscache_stat(&fscache_n_acquires_oom);
52134 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52135 _leave(" [ENOMEM]");
52136 return NULL;
52137 }
52138 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52139
52140 switch (cookie->def->type) {
52141 case FSCACHE_COOKIE_TYPE_INDEX:
52142 - fscache_stat(&fscache_n_cookie_index);
52143 + fscache_stat_unchecked(&fscache_n_cookie_index);
52144 break;
52145 case FSCACHE_COOKIE_TYPE_DATAFILE:
52146 - fscache_stat(&fscache_n_cookie_data);
52147 + fscache_stat_unchecked(&fscache_n_cookie_data);
52148 break;
52149 default:
52150 - fscache_stat(&fscache_n_cookie_special);
52151 + fscache_stat_unchecked(&fscache_n_cookie_special);
52152 break;
52153 }
52154
52155 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52156 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52157 atomic_dec(&parent->n_children);
52158 __fscache_cookie_put(cookie);
52159 - fscache_stat(&fscache_n_acquires_nobufs);
52160 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52161 _leave(" = NULL");
52162 return NULL;
52163 }
52164 }
52165
52166 - fscache_stat(&fscache_n_acquires_ok);
52167 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52168 _leave(" = %p", cookie);
52169 return cookie;
52170 }
52171 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52172 cache = fscache_select_cache_for_object(cookie->parent);
52173 if (!cache) {
52174 up_read(&fscache_addremove_sem);
52175 - fscache_stat(&fscache_n_acquires_no_cache);
52176 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52177 _leave(" = -ENOMEDIUM [no cache]");
52178 return -ENOMEDIUM;
52179 }
52180 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52181 object = cache->ops->alloc_object(cache, cookie);
52182 fscache_stat_d(&fscache_n_cop_alloc_object);
52183 if (IS_ERR(object)) {
52184 - fscache_stat(&fscache_n_object_no_alloc);
52185 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52186 ret = PTR_ERR(object);
52187 goto error;
52188 }
52189
52190 - fscache_stat(&fscache_n_object_alloc);
52191 + fscache_stat_unchecked(&fscache_n_object_alloc);
52192
52193 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52194
52195 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52196
52197 _enter("{%s}", cookie->def->name);
52198
52199 - fscache_stat(&fscache_n_invalidates);
52200 + fscache_stat_unchecked(&fscache_n_invalidates);
52201
52202 /* Only permit invalidation of data files. Invalidating an index will
52203 * require the caller to release all its attachments to the tree rooted
52204 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52205 {
52206 struct fscache_object *object;
52207
52208 - fscache_stat(&fscache_n_updates);
52209 + fscache_stat_unchecked(&fscache_n_updates);
52210
52211 if (!cookie) {
52212 - fscache_stat(&fscache_n_updates_null);
52213 + fscache_stat_unchecked(&fscache_n_updates_null);
52214 _leave(" [no cookie]");
52215 return;
52216 }
52217 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52218 struct fscache_object *object;
52219 unsigned long event;
52220
52221 - fscache_stat(&fscache_n_relinquishes);
52222 + fscache_stat_unchecked(&fscache_n_relinquishes);
52223 if (retire)
52224 - fscache_stat(&fscache_n_relinquishes_retire);
52225 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52226
52227 if (!cookie) {
52228 - fscache_stat(&fscache_n_relinquishes_null);
52229 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52230 _leave(" [no cookie]");
52231 return;
52232 }
52233 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52234
52235 /* wait for the cookie to finish being instantiated (or to fail) */
52236 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52237 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52238 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52239 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52240 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52241 }
52242 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52243 index ee38fef..0a326d4 100644
52244 --- a/fs/fscache/internal.h
52245 +++ b/fs/fscache/internal.h
52246 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52247 * stats.c
52248 */
52249 #ifdef CONFIG_FSCACHE_STATS
52250 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52251 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52252 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52253 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52254
52255 -extern atomic_t fscache_n_op_pend;
52256 -extern atomic_t fscache_n_op_run;
52257 -extern atomic_t fscache_n_op_enqueue;
52258 -extern atomic_t fscache_n_op_deferred_release;
52259 -extern atomic_t fscache_n_op_release;
52260 -extern atomic_t fscache_n_op_gc;
52261 -extern atomic_t fscache_n_op_cancelled;
52262 -extern atomic_t fscache_n_op_rejected;
52263 +extern atomic_unchecked_t fscache_n_op_pend;
52264 +extern atomic_unchecked_t fscache_n_op_run;
52265 +extern atomic_unchecked_t fscache_n_op_enqueue;
52266 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52267 +extern atomic_unchecked_t fscache_n_op_release;
52268 +extern atomic_unchecked_t fscache_n_op_gc;
52269 +extern atomic_unchecked_t fscache_n_op_cancelled;
52270 +extern atomic_unchecked_t fscache_n_op_rejected;
52271
52272 -extern atomic_t fscache_n_attr_changed;
52273 -extern atomic_t fscache_n_attr_changed_ok;
52274 -extern atomic_t fscache_n_attr_changed_nobufs;
52275 -extern atomic_t fscache_n_attr_changed_nomem;
52276 -extern atomic_t fscache_n_attr_changed_calls;
52277 +extern atomic_unchecked_t fscache_n_attr_changed;
52278 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52279 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52280 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52281 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52282
52283 -extern atomic_t fscache_n_allocs;
52284 -extern atomic_t fscache_n_allocs_ok;
52285 -extern atomic_t fscache_n_allocs_wait;
52286 -extern atomic_t fscache_n_allocs_nobufs;
52287 -extern atomic_t fscache_n_allocs_intr;
52288 -extern atomic_t fscache_n_allocs_object_dead;
52289 -extern atomic_t fscache_n_alloc_ops;
52290 -extern atomic_t fscache_n_alloc_op_waits;
52291 +extern atomic_unchecked_t fscache_n_allocs;
52292 +extern atomic_unchecked_t fscache_n_allocs_ok;
52293 +extern atomic_unchecked_t fscache_n_allocs_wait;
52294 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52295 +extern atomic_unchecked_t fscache_n_allocs_intr;
52296 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52297 +extern atomic_unchecked_t fscache_n_alloc_ops;
52298 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52299
52300 -extern atomic_t fscache_n_retrievals;
52301 -extern atomic_t fscache_n_retrievals_ok;
52302 -extern atomic_t fscache_n_retrievals_wait;
52303 -extern atomic_t fscache_n_retrievals_nodata;
52304 -extern atomic_t fscache_n_retrievals_nobufs;
52305 -extern atomic_t fscache_n_retrievals_intr;
52306 -extern atomic_t fscache_n_retrievals_nomem;
52307 -extern atomic_t fscache_n_retrievals_object_dead;
52308 -extern atomic_t fscache_n_retrieval_ops;
52309 -extern atomic_t fscache_n_retrieval_op_waits;
52310 +extern atomic_unchecked_t fscache_n_retrievals;
52311 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52312 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52313 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52314 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52315 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52316 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52317 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52318 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52319 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52320
52321 -extern atomic_t fscache_n_stores;
52322 -extern atomic_t fscache_n_stores_ok;
52323 -extern atomic_t fscache_n_stores_again;
52324 -extern atomic_t fscache_n_stores_nobufs;
52325 -extern atomic_t fscache_n_stores_oom;
52326 -extern atomic_t fscache_n_store_ops;
52327 -extern atomic_t fscache_n_store_calls;
52328 -extern atomic_t fscache_n_store_pages;
52329 -extern atomic_t fscache_n_store_radix_deletes;
52330 -extern atomic_t fscache_n_store_pages_over_limit;
52331 +extern atomic_unchecked_t fscache_n_stores;
52332 +extern atomic_unchecked_t fscache_n_stores_ok;
52333 +extern atomic_unchecked_t fscache_n_stores_again;
52334 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52335 +extern atomic_unchecked_t fscache_n_stores_oom;
52336 +extern atomic_unchecked_t fscache_n_store_ops;
52337 +extern atomic_unchecked_t fscache_n_store_calls;
52338 +extern atomic_unchecked_t fscache_n_store_pages;
52339 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52340 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52341
52342 -extern atomic_t fscache_n_store_vmscan_not_storing;
52343 -extern atomic_t fscache_n_store_vmscan_gone;
52344 -extern atomic_t fscache_n_store_vmscan_busy;
52345 -extern atomic_t fscache_n_store_vmscan_cancelled;
52346 -extern atomic_t fscache_n_store_vmscan_wait;
52347 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52348 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52349 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52350 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52351 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52352
52353 -extern atomic_t fscache_n_marks;
52354 -extern atomic_t fscache_n_uncaches;
52355 +extern atomic_unchecked_t fscache_n_marks;
52356 +extern atomic_unchecked_t fscache_n_uncaches;
52357
52358 -extern atomic_t fscache_n_acquires;
52359 -extern atomic_t fscache_n_acquires_null;
52360 -extern atomic_t fscache_n_acquires_no_cache;
52361 -extern atomic_t fscache_n_acquires_ok;
52362 -extern atomic_t fscache_n_acquires_nobufs;
52363 -extern atomic_t fscache_n_acquires_oom;
52364 +extern atomic_unchecked_t fscache_n_acquires;
52365 +extern atomic_unchecked_t fscache_n_acquires_null;
52366 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52367 +extern atomic_unchecked_t fscache_n_acquires_ok;
52368 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52369 +extern atomic_unchecked_t fscache_n_acquires_oom;
52370
52371 -extern atomic_t fscache_n_invalidates;
52372 -extern atomic_t fscache_n_invalidates_run;
52373 +extern atomic_unchecked_t fscache_n_invalidates;
52374 +extern atomic_unchecked_t fscache_n_invalidates_run;
52375
52376 -extern atomic_t fscache_n_updates;
52377 -extern atomic_t fscache_n_updates_null;
52378 -extern atomic_t fscache_n_updates_run;
52379 +extern atomic_unchecked_t fscache_n_updates;
52380 +extern atomic_unchecked_t fscache_n_updates_null;
52381 +extern atomic_unchecked_t fscache_n_updates_run;
52382
52383 -extern atomic_t fscache_n_relinquishes;
52384 -extern atomic_t fscache_n_relinquishes_null;
52385 -extern atomic_t fscache_n_relinquishes_waitcrt;
52386 -extern atomic_t fscache_n_relinquishes_retire;
52387 +extern atomic_unchecked_t fscache_n_relinquishes;
52388 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52389 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52390 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52391
52392 -extern atomic_t fscache_n_cookie_index;
52393 -extern atomic_t fscache_n_cookie_data;
52394 -extern atomic_t fscache_n_cookie_special;
52395 +extern atomic_unchecked_t fscache_n_cookie_index;
52396 +extern atomic_unchecked_t fscache_n_cookie_data;
52397 +extern atomic_unchecked_t fscache_n_cookie_special;
52398
52399 -extern atomic_t fscache_n_object_alloc;
52400 -extern atomic_t fscache_n_object_no_alloc;
52401 -extern atomic_t fscache_n_object_lookups;
52402 -extern atomic_t fscache_n_object_lookups_negative;
52403 -extern atomic_t fscache_n_object_lookups_positive;
52404 -extern atomic_t fscache_n_object_lookups_timed_out;
52405 -extern atomic_t fscache_n_object_created;
52406 -extern atomic_t fscache_n_object_avail;
52407 -extern atomic_t fscache_n_object_dead;
52408 +extern atomic_unchecked_t fscache_n_object_alloc;
52409 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52410 +extern atomic_unchecked_t fscache_n_object_lookups;
52411 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52412 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52413 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52414 +extern atomic_unchecked_t fscache_n_object_created;
52415 +extern atomic_unchecked_t fscache_n_object_avail;
52416 +extern atomic_unchecked_t fscache_n_object_dead;
52417
52418 -extern atomic_t fscache_n_checkaux_none;
52419 -extern atomic_t fscache_n_checkaux_okay;
52420 -extern atomic_t fscache_n_checkaux_update;
52421 -extern atomic_t fscache_n_checkaux_obsolete;
52422 +extern atomic_unchecked_t fscache_n_checkaux_none;
52423 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52424 +extern atomic_unchecked_t fscache_n_checkaux_update;
52425 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52426
52427 extern atomic_t fscache_n_cop_alloc_object;
52428 extern atomic_t fscache_n_cop_lookup_object;
52429 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52430 atomic_inc(stat);
52431 }
52432
52433 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52434 +{
52435 + atomic_inc_unchecked(stat);
52436 +}
52437 +
52438 static inline void fscache_stat_d(atomic_t *stat)
52439 {
52440 atomic_dec(stat);
52441 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52442
52443 #define __fscache_stat(stat) (NULL)
52444 #define fscache_stat(stat) do {} while (0)
52445 +#define fscache_stat_unchecked(stat) do {} while (0)
52446 #define fscache_stat_d(stat) do {} while (0)
52447 #endif
52448
52449 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52450 index 50d41c1..10ee117 100644
52451 --- a/fs/fscache/object.c
52452 +++ b/fs/fscache/object.c
52453 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52454 /* Invalidate an object on disk */
52455 case FSCACHE_OBJECT_INVALIDATING:
52456 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52457 - fscache_stat(&fscache_n_invalidates_run);
52458 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52459 fscache_stat(&fscache_n_cop_invalidate_object);
52460 fscache_invalidate_object(object);
52461 fscache_stat_d(&fscache_n_cop_invalidate_object);
52462 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52463 /* update the object metadata on disk */
52464 case FSCACHE_OBJECT_UPDATING:
52465 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52466 - fscache_stat(&fscache_n_updates_run);
52467 + fscache_stat_unchecked(&fscache_n_updates_run);
52468 fscache_stat(&fscache_n_cop_update_object);
52469 object->cache->ops->update_object(object);
52470 fscache_stat_d(&fscache_n_cop_update_object);
52471 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52472 spin_lock(&object->lock);
52473 object->state = FSCACHE_OBJECT_DEAD;
52474 spin_unlock(&object->lock);
52475 - fscache_stat(&fscache_n_object_dead);
52476 + fscache_stat_unchecked(&fscache_n_object_dead);
52477 goto terminal_transit;
52478
52479 /* handle the parent cache of this object being withdrawn from
52480 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52481 spin_lock(&object->lock);
52482 object->state = FSCACHE_OBJECT_DEAD;
52483 spin_unlock(&object->lock);
52484 - fscache_stat(&fscache_n_object_dead);
52485 + fscache_stat_unchecked(&fscache_n_object_dead);
52486 goto terminal_transit;
52487
52488 /* complain about the object being woken up once it is
52489 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52490 parent->cookie->def->name, cookie->def->name,
52491 object->cache->tag->name);
52492
52493 - fscache_stat(&fscache_n_object_lookups);
52494 + fscache_stat_unchecked(&fscache_n_object_lookups);
52495 fscache_stat(&fscache_n_cop_lookup_object);
52496 ret = object->cache->ops->lookup_object(object);
52497 fscache_stat_d(&fscache_n_cop_lookup_object);
52498 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52499 if (ret == -ETIMEDOUT) {
52500 /* probably stuck behind another object, so move this one to
52501 * the back of the queue */
52502 - fscache_stat(&fscache_n_object_lookups_timed_out);
52503 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52504 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52505 }
52506
52507 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52508
52509 spin_lock(&object->lock);
52510 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52511 - fscache_stat(&fscache_n_object_lookups_negative);
52512 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52513
52514 /* transit here to allow write requests to begin stacking up
52515 * and read requests to begin returning ENODATA */
52516 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52517 * result, in which case there may be data available */
52518 spin_lock(&object->lock);
52519 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52520 - fscache_stat(&fscache_n_object_lookups_positive);
52521 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52522
52523 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52524
52525 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52526 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52527 } else {
52528 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52529 - fscache_stat(&fscache_n_object_created);
52530 + fscache_stat_unchecked(&fscache_n_object_created);
52531
52532 object->state = FSCACHE_OBJECT_AVAILABLE;
52533 spin_unlock(&object->lock);
52534 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52535 fscache_enqueue_dependents(object);
52536
52537 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52538 - fscache_stat(&fscache_n_object_avail);
52539 + fscache_stat_unchecked(&fscache_n_object_avail);
52540
52541 _leave("");
52542 }
52543 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52544 enum fscache_checkaux result;
52545
52546 if (!object->cookie->def->check_aux) {
52547 - fscache_stat(&fscache_n_checkaux_none);
52548 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52549 return FSCACHE_CHECKAUX_OKAY;
52550 }
52551
52552 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52553 switch (result) {
52554 /* entry okay as is */
52555 case FSCACHE_CHECKAUX_OKAY:
52556 - fscache_stat(&fscache_n_checkaux_okay);
52557 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52558 break;
52559
52560 /* entry requires update */
52561 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52562 - fscache_stat(&fscache_n_checkaux_update);
52563 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52564 break;
52565
52566 /* entry requires deletion */
52567 case FSCACHE_CHECKAUX_OBSOLETE:
52568 - fscache_stat(&fscache_n_checkaux_obsolete);
52569 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52570 break;
52571
52572 default:
52573 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52574 index 762a9ec..2023284 100644
52575 --- a/fs/fscache/operation.c
52576 +++ b/fs/fscache/operation.c
52577 @@ -17,7 +17,7 @@
52578 #include <linux/slab.h>
52579 #include "internal.h"
52580
52581 -atomic_t fscache_op_debug_id;
52582 +atomic_unchecked_t fscache_op_debug_id;
52583 EXPORT_SYMBOL(fscache_op_debug_id);
52584
52585 /**
52586 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52587 ASSERTCMP(atomic_read(&op->usage), >, 0);
52588 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52589
52590 - fscache_stat(&fscache_n_op_enqueue);
52591 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52592 switch (op->flags & FSCACHE_OP_TYPE) {
52593 case FSCACHE_OP_ASYNC:
52594 _debug("queue async");
52595 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52596 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52597 if (op->processor)
52598 fscache_enqueue_operation(op);
52599 - fscache_stat(&fscache_n_op_run);
52600 + fscache_stat_unchecked(&fscache_n_op_run);
52601 }
52602
52603 /*
52604 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52605 if (object->n_in_progress > 0) {
52606 atomic_inc(&op->usage);
52607 list_add_tail(&op->pend_link, &object->pending_ops);
52608 - fscache_stat(&fscache_n_op_pend);
52609 + fscache_stat_unchecked(&fscache_n_op_pend);
52610 } else if (!list_empty(&object->pending_ops)) {
52611 atomic_inc(&op->usage);
52612 list_add_tail(&op->pend_link, &object->pending_ops);
52613 - fscache_stat(&fscache_n_op_pend);
52614 + fscache_stat_unchecked(&fscache_n_op_pend);
52615 fscache_start_operations(object);
52616 } else {
52617 ASSERTCMP(object->n_in_progress, ==, 0);
52618 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52619 object->n_exclusive++; /* reads and writes must wait */
52620 atomic_inc(&op->usage);
52621 list_add_tail(&op->pend_link, &object->pending_ops);
52622 - fscache_stat(&fscache_n_op_pend);
52623 + fscache_stat_unchecked(&fscache_n_op_pend);
52624 ret = 0;
52625 } else {
52626 /* If we're in any other state, there must have been an I/O
52627 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52628 if (object->n_exclusive > 0) {
52629 atomic_inc(&op->usage);
52630 list_add_tail(&op->pend_link, &object->pending_ops);
52631 - fscache_stat(&fscache_n_op_pend);
52632 + fscache_stat_unchecked(&fscache_n_op_pend);
52633 } else if (!list_empty(&object->pending_ops)) {
52634 atomic_inc(&op->usage);
52635 list_add_tail(&op->pend_link, &object->pending_ops);
52636 - fscache_stat(&fscache_n_op_pend);
52637 + fscache_stat_unchecked(&fscache_n_op_pend);
52638 fscache_start_operations(object);
52639 } else {
52640 ASSERTCMP(object->n_exclusive, ==, 0);
52641 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52642 object->n_ops++;
52643 atomic_inc(&op->usage);
52644 list_add_tail(&op->pend_link, &object->pending_ops);
52645 - fscache_stat(&fscache_n_op_pend);
52646 + fscache_stat_unchecked(&fscache_n_op_pend);
52647 ret = 0;
52648 } else if (object->state == FSCACHE_OBJECT_DYING ||
52649 object->state == FSCACHE_OBJECT_LC_DYING ||
52650 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52651 - fscache_stat(&fscache_n_op_rejected);
52652 + fscache_stat_unchecked(&fscache_n_op_rejected);
52653 op->state = FSCACHE_OP_ST_CANCELLED;
52654 ret = -ENOBUFS;
52655 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52656 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52657 ret = -EBUSY;
52658 if (op->state == FSCACHE_OP_ST_PENDING) {
52659 ASSERT(!list_empty(&op->pend_link));
52660 - fscache_stat(&fscache_n_op_cancelled);
52661 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52662 list_del_init(&op->pend_link);
52663 if (do_cancel)
52664 do_cancel(op);
52665 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52666 while (!list_empty(&object->pending_ops)) {
52667 op = list_entry(object->pending_ops.next,
52668 struct fscache_operation, pend_link);
52669 - fscache_stat(&fscache_n_op_cancelled);
52670 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52671 list_del_init(&op->pend_link);
52672
52673 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52674 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52675 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52676 op->state = FSCACHE_OP_ST_DEAD;
52677
52678 - fscache_stat(&fscache_n_op_release);
52679 + fscache_stat_unchecked(&fscache_n_op_release);
52680
52681 if (op->release) {
52682 op->release(op);
52683 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52684 * lock, and defer it otherwise */
52685 if (!spin_trylock(&object->lock)) {
52686 _debug("defer put");
52687 - fscache_stat(&fscache_n_op_deferred_release);
52688 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52689
52690 cache = object->cache;
52691 spin_lock(&cache->op_gc_list_lock);
52692 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52693
52694 _debug("GC DEFERRED REL OBJ%x OP%x",
52695 object->debug_id, op->debug_id);
52696 - fscache_stat(&fscache_n_op_gc);
52697 + fscache_stat_unchecked(&fscache_n_op_gc);
52698
52699 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52700 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52701 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52702 index ff000e5..c44ec6d 100644
52703 --- a/fs/fscache/page.c
52704 +++ b/fs/fscache/page.c
52705 @@ -61,7 +61,7 @@ try_again:
52706 val = radix_tree_lookup(&cookie->stores, page->index);
52707 if (!val) {
52708 rcu_read_unlock();
52709 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52710 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52711 __fscache_uncache_page(cookie, page);
52712 return true;
52713 }
52714 @@ -91,11 +91,11 @@ try_again:
52715 spin_unlock(&cookie->stores_lock);
52716
52717 if (xpage) {
52718 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52719 - fscache_stat(&fscache_n_store_radix_deletes);
52720 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52721 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52722 ASSERTCMP(xpage, ==, page);
52723 } else {
52724 - fscache_stat(&fscache_n_store_vmscan_gone);
52725 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52726 }
52727
52728 wake_up_bit(&cookie->flags, 0);
52729 @@ -110,11 +110,11 @@ page_busy:
52730 * sleeping on memory allocation, so we may need to impose a timeout
52731 * too. */
52732 if (!(gfp & __GFP_WAIT)) {
52733 - fscache_stat(&fscache_n_store_vmscan_busy);
52734 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52735 return false;
52736 }
52737
52738 - fscache_stat(&fscache_n_store_vmscan_wait);
52739 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52740 __fscache_wait_on_page_write(cookie, page);
52741 gfp &= ~__GFP_WAIT;
52742 goto try_again;
52743 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52744 FSCACHE_COOKIE_STORING_TAG);
52745 if (!radix_tree_tag_get(&cookie->stores, page->index,
52746 FSCACHE_COOKIE_PENDING_TAG)) {
52747 - fscache_stat(&fscache_n_store_radix_deletes);
52748 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52749 xpage = radix_tree_delete(&cookie->stores, page->index);
52750 }
52751 spin_unlock(&cookie->stores_lock);
52752 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52753
52754 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52755
52756 - fscache_stat(&fscache_n_attr_changed_calls);
52757 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52758
52759 if (fscache_object_is_active(object)) {
52760 fscache_stat(&fscache_n_cop_attr_changed);
52761 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52762
52763 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52764
52765 - fscache_stat(&fscache_n_attr_changed);
52766 + fscache_stat_unchecked(&fscache_n_attr_changed);
52767
52768 op = kzalloc(sizeof(*op), GFP_KERNEL);
52769 if (!op) {
52770 - fscache_stat(&fscache_n_attr_changed_nomem);
52771 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52772 _leave(" = -ENOMEM");
52773 return -ENOMEM;
52774 }
52775 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52776 if (fscache_submit_exclusive_op(object, op) < 0)
52777 goto nobufs;
52778 spin_unlock(&cookie->lock);
52779 - fscache_stat(&fscache_n_attr_changed_ok);
52780 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52781 fscache_put_operation(op);
52782 _leave(" = 0");
52783 return 0;
52784 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52785 nobufs:
52786 spin_unlock(&cookie->lock);
52787 kfree(op);
52788 - fscache_stat(&fscache_n_attr_changed_nobufs);
52789 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52790 _leave(" = %d", -ENOBUFS);
52791 return -ENOBUFS;
52792 }
52793 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52794 /* allocate a retrieval operation and attempt to submit it */
52795 op = kzalloc(sizeof(*op), GFP_NOIO);
52796 if (!op) {
52797 - fscache_stat(&fscache_n_retrievals_nomem);
52798 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52799 return NULL;
52800 }
52801
52802 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52803 return 0;
52804 }
52805
52806 - fscache_stat(&fscache_n_retrievals_wait);
52807 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52808
52809 jif = jiffies;
52810 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52811 fscache_wait_bit_interruptible,
52812 TASK_INTERRUPTIBLE) != 0) {
52813 - fscache_stat(&fscache_n_retrievals_intr);
52814 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52815 _leave(" = -ERESTARTSYS");
52816 return -ERESTARTSYS;
52817 }
52818 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52819 */
52820 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52821 struct fscache_retrieval *op,
52822 - atomic_t *stat_op_waits,
52823 - atomic_t *stat_object_dead)
52824 + atomic_unchecked_t *stat_op_waits,
52825 + atomic_unchecked_t *stat_object_dead)
52826 {
52827 int ret;
52828
52829 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52830 goto check_if_dead;
52831
52832 _debug(">>> WT");
52833 - fscache_stat(stat_op_waits);
52834 + fscache_stat_unchecked(stat_op_waits);
52835 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52836 fscache_wait_bit_interruptible,
52837 TASK_INTERRUPTIBLE) != 0) {
52838 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52839
52840 check_if_dead:
52841 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52842 - fscache_stat(stat_object_dead);
52843 + fscache_stat_unchecked(stat_object_dead);
52844 _leave(" = -ENOBUFS [cancelled]");
52845 return -ENOBUFS;
52846 }
52847 if (unlikely(fscache_object_is_dead(object))) {
52848 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52849 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52850 - fscache_stat(stat_object_dead);
52851 + fscache_stat_unchecked(stat_object_dead);
52852 return -ENOBUFS;
52853 }
52854 return 0;
52855 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52856
52857 _enter("%p,%p,,,", cookie, page);
52858
52859 - fscache_stat(&fscache_n_retrievals);
52860 + fscache_stat_unchecked(&fscache_n_retrievals);
52861
52862 if (hlist_empty(&cookie->backing_objects))
52863 goto nobufs;
52864 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52865 goto nobufs_unlock_dec;
52866 spin_unlock(&cookie->lock);
52867
52868 - fscache_stat(&fscache_n_retrieval_ops);
52869 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52870
52871 /* pin the netfs read context in case we need to do the actual netfs
52872 * read because we've encountered a cache read failure */
52873 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52874
52875 error:
52876 if (ret == -ENOMEM)
52877 - fscache_stat(&fscache_n_retrievals_nomem);
52878 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52879 else if (ret == -ERESTARTSYS)
52880 - fscache_stat(&fscache_n_retrievals_intr);
52881 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52882 else if (ret == -ENODATA)
52883 - fscache_stat(&fscache_n_retrievals_nodata);
52884 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52885 else if (ret < 0)
52886 - fscache_stat(&fscache_n_retrievals_nobufs);
52887 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52888 else
52889 - fscache_stat(&fscache_n_retrievals_ok);
52890 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52891
52892 fscache_put_retrieval(op);
52893 _leave(" = %d", ret);
52894 @@ -467,7 +467,7 @@ nobufs_unlock:
52895 spin_unlock(&cookie->lock);
52896 kfree(op);
52897 nobufs:
52898 - fscache_stat(&fscache_n_retrievals_nobufs);
52899 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52900 _leave(" = -ENOBUFS");
52901 return -ENOBUFS;
52902 }
52903 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52904
52905 _enter("%p,,%d,,,", cookie, *nr_pages);
52906
52907 - fscache_stat(&fscache_n_retrievals);
52908 + fscache_stat_unchecked(&fscache_n_retrievals);
52909
52910 if (hlist_empty(&cookie->backing_objects))
52911 goto nobufs;
52912 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52913 goto nobufs_unlock_dec;
52914 spin_unlock(&cookie->lock);
52915
52916 - fscache_stat(&fscache_n_retrieval_ops);
52917 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52918
52919 /* pin the netfs read context in case we need to do the actual netfs
52920 * read because we've encountered a cache read failure */
52921 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52922
52923 error:
52924 if (ret == -ENOMEM)
52925 - fscache_stat(&fscache_n_retrievals_nomem);
52926 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52927 else if (ret == -ERESTARTSYS)
52928 - fscache_stat(&fscache_n_retrievals_intr);
52929 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52930 else if (ret == -ENODATA)
52931 - fscache_stat(&fscache_n_retrievals_nodata);
52932 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52933 else if (ret < 0)
52934 - fscache_stat(&fscache_n_retrievals_nobufs);
52935 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52936 else
52937 - fscache_stat(&fscache_n_retrievals_ok);
52938 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52939
52940 fscache_put_retrieval(op);
52941 _leave(" = %d", ret);
52942 @@ -591,7 +591,7 @@ nobufs_unlock:
52943 spin_unlock(&cookie->lock);
52944 kfree(op);
52945 nobufs:
52946 - fscache_stat(&fscache_n_retrievals_nobufs);
52947 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52948 _leave(" = -ENOBUFS");
52949 return -ENOBUFS;
52950 }
52951 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52952
52953 _enter("%p,%p,,,", cookie, page);
52954
52955 - fscache_stat(&fscache_n_allocs);
52956 + fscache_stat_unchecked(&fscache_n_allocs);
52957
52958 if (hlist_empty(&cookie->backing_objects))
52959 goto nobufs;
52960 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52961 goto nobufs_unlock;
52962 spin_unlock(&cookie->lock);
52963
52964 - fscache_stat(&fscache_n_alloc_ops);
52965 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52966
52967 ret = fscache_wait_for_retrieval_activation(
52968 object, op,
52969 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52970
52971 error:
52972 if (ret == -ERESTARTSYS)
52973 - fscache_stat(&fscache_n_allocs_intr);
52974 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52975 else if (ret < 0)
52976 - fscache_stat(&fscache_n_allocs_nobufs);
52977 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52978 else
52979 - fscache_stat(&fscache_n_allocs_ok);
52980 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52981
52982 fscache_put_retrieval(op);
52983 _leave(" = %d", ret);
52984 @@ -677,7 +677,7 @@ nobufs_unlock:
52985 spin_unlock(&cookie->lock);
52986 kfree(op);
52987 nobufs:
52988 - fscache_stat(&fscache_n_allocs_nobufs);
52989 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52990 _leave(" = -ENOBUFS");
52991 return -ENOBUFS;
52992 }
52993 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52994
52995 spin_lock(&cookie->stores_lock);
52996
52997 - fscache_stat(&fscache_n_store_calls);
52998 + fscache_stat_unchecked(&fscache_n_store_calls);
52999
53000 /* find a page to store */
53001 page = NULL;
53002 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
53003 page = results[0];
53004 _debug("gang %d [%lx]", n, page->index);
53005 if (page->index > op->store_limit) {
53006 - fscache_stat(&fscache_n_store_pages_over_limit);
53007 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
53008 goto superseded;
53009 }
53010
53011 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
53012 spin_unlock(&cookie->stores_lock);
53013 spin_unlock(&object->lock);
53014
53015 - fscache_stat(&fscache_n_store_pages);
53016 + fscache_stat_unchecked(&fscache_n_store_pages);
53017 fscache_stat(&fscache_n_cop_write_page);
53018 ret = object->cache->ops->write_page(op, page);
53019 fscache_stat_d(&fscache_n_cop_write_page);
53020 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53021 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53022 ASSERT(PageFsCache(page));
53023
53024 - fscache_stat(&fscache_n_stores);
53025 + fscache_stat_unchecked(&fscache_n_stores);
53026
53027 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
53028 _leave(" = -ENOBUFS [invalidating]");
53029 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53030 spin_unlock(&cookie->stores_lock);
53031 spin_unlock(&object->lock);
53032
53033 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
53034 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
53035 op->store_limit = object->store_limit;
53036
53037 if (fscache_submit_op(object, &op->op) < 0)
53038 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53039
53040 spin_unlock(&cookie->lock);
53041 radix_tree_preload_end();
53042 - fscache_stat(&fscache_n_store_ops);
53043 - fscache_stat(&fscache_n_stores_ok);
53044 + fscache_stat_unchecked(&fscache_n_store_ops);
53045 + fscache_stat_unchecked(&fscache_n_stores_ok);
53046
53047 /* the work queue now carries its own ref on the object */
53048 fscache_put_operation(&op->op);
53049 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53050 return 0;
53051
53052 already_queued:
53053 - fscache_stat(&fscache_n_stores_again);
53054 + fscache_stat_unchecked(&fscache_n_stores_again);
53055 already_pending:
53056 spin_unlock(&cookie->stores_lock);
53057 spin_unlock(&object->lock);
53058 spin_unlock(&cookie->lock);
53059 radix_tree_preload_end();
53060 kfree(op);
53061 - fscache_stat(&fscache_n_stores_ok);
53062 + fscache_stat_unchecked(&fscache_n_stores_ok);
53063 _leave(" = 0");
53064 return 0;
53065
53066 @@ -959,14 +959,14 @@ nobufs:
53067 spin_unlock(&cookie->lock);
53068 radix_tree_preload_end();
53069 kfree(op);
53070 - fscache_stat(&fscache_n_stores_nobufs);
53071 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
53072 _leave(" = -ENOBUFS");
53073 return -ENOBUFS;
53074
53075 nomem_free:
53076 kfree(op);
53077 nomem:
53078 - fscache_stat(&fscache_n_stores_oom);
53079 + fscache_stat_unchecked(&fscache_n_stores_oom);
53080 _leave(" = -ENOMEM");
53081 return -ENOMEM;
53082 }
53083 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
53084 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53085 ASSERTCMP(page, !=, NULL);
53086
53087 - fscache_stat(&fscache_n_uncaches);
53088 + fscache_stat_unchecked(&fscache_n_uncaches);
53089
53090 /* cache withdrawal may beat us to it */
53091 if (!PageFsCache(page))
53092 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53093 struct fscache_cookie *cookie = op->op.object->cookie;
53094
53095 #ifdef CONFIG_FSCACHE_STATS
53096 - atomic_inc(&fscache_n_marks);
53097 + atomic_inc_unchecked(&fscache_n_marks);
53098 #endif
53099
53100 _debug("- mark %p{%lx}", page, page->index);
53101 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53102 index 40d13c7..ddf52b9 100644
53103 --- a/fs/fscache/stats.c
53104 +++ b/fs/fscache/stats.c
53105 @@ -18,99 +18,99 @@
53106 /*
53107 * operation counters
53108 */
53109 -atomic_t fscache_n_op_pend;
53110 -atomic_t fscache_n_op_run;
53111 -atomic_t fscache_n_op_enqueue;
53112 -atomic_t fscache_n_op_requeue;
53113 -atomic_t fscache_n_op_deferred_release;
53114 -atomic_t fscache_n_op_release;
53115 -atomic_t fscache_n_op_gc;
53116 -atomic_t fscache_n_op_cancelled;
53117 -atomic_t fscache_n_op_rejected;
53118 +atomic_unchecked_t fscache_n_op_pend;
53119 +atomic_unchecked_t fscache_n_op_run;
53120 +atomic_unchecked_t fscache_n_op_enqueue;
53121 +atomic_unchecked_t fscache_n_op_requeue;
53122 +atomic_unchecked_t fscache_n_op_deferred_release;
53123 +atomic_unchecked_t fscache_n_op_release;
53124 +atomic_unchecked_t fscache_n_op_gc;
53125 +atomic_unchecked_t fscache_n_op_cancelled;
53126 +atomic_unchecked_t fscache_n_op_rejected;
53127
53128 -atomic_t fscache_n_attr_changed;
53129 -atomic_t fscache_n_attr_changed_ok;
53130 -atomic_t fscache_n_attr_changed_nobufs;
53131 -atomic_t fscache_n_attr_changed_nomem;
53132 -atomic_t fscache_n_attr_changed_calls;
53133 +atomic_unchecked_t fscache_n_attr_changed;
53134 +atomic_unchecked_t fscache_n_attr_changed_ok;
53135 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53136 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53137 +atomic_unchecked_t fscache_n_attr_changed_calls;
53138
53139 -atomic_t fscache_n_allocs;
53140 -atomic_t fscache_n_allocs_ok;
53141 -atomic_t fscache_n_allocs_wait;
53142 -atomic_t fscache_n_allocs_nobufs;
53143 -atomic_t fscache_n_allocs_intr;
53144 -atomic_t fscache_n_allocs_object_dead;
53145 -atomic_t fscache_n_alloc_ops;
53146 -atomic_t fscache_n_alloc_op_waits;
53147 +atomic_unchecked_t fscache_n_allocs;
53148 +atomic_unchecked_t fscache_n_allocs_ok;
53149 +atomic_unchecked_t fscache_n_allocs_wait;
53150 +atomic_unchecked_t fscache_n_allocs_nobufs;
53151 +atomic_unchecked_t fscache_n_allocs_intr;
53152 +atomic_unchecked_t fscache_n_allocs_object_dead;
53153 +atomic_unchecked_t fscache_n_alloc_ops;
53154 +atomic_unchecked_t fscache_n_alloc_op_waits;
53155
53156 -atomic_t fscache_n_retrievals;
53157 -atomic_t fscache_n_retrievals_ok;
53158 -atomic_t fscache_n_retrievals_wait;
53159 -atomic_t fscache_n_retrievals_nodata;
53160 -atomic_t fscache_n_retrievals_nobufs;
53161 -atomic_t fscache_n_retrievals_intr;
53162 -atomic_t fscache_n_retrievals_nomem;
53163 -atomic_t fscache_n_retrievals_object_dead;
53164 -atomic_t fscache_n_retrieval_ops;
53165 -atomic_t fscache_n_retrieval_op_waits;
53166 +atomic_unchecked_t fscache_n_retrievals;
53167 +atomic_unchecked_t fscache_n_retrievals_ok;
53168 +atomic_unchecked_t fscache_n_retrievals_wait;
53169 +atomic_unchecked_t fscache_n_retrievals_nodata;
53170 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53171 +atomic_unchecked_t fscache_n_retrievals_intr;
53172 +atomic_unchecked_t fscache_n_retrievals_nomem;
53173 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53174 +atomic_unchecked_t fscache_n_retrieval_ops;
53175 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53176
53177 -atomic_t fscache_n_stores;
53178 -atomic_t fscache_n_stores_ok;
53179 -atomic_t fscache_n_stores_again;
53180 -atomic_t fscache_n_stores_nobufs;
53181 -atomic_t fscache_n_stores_oom;
53182 -atomic_t fscache_n_store_ops;
53183 -atomic_t fscache_n_store_calls;
53184 -atomic_t fscache_n_store_pages;
53185 -atomic_t fscache_n_store_radix_deletes;
53186 -atomic_t fscache_n_store_pages_over_limit;
53187 +atomic_unchecked_t fscache_n_stores;
53188 +atomic_unchecked_t fscache_n_stores_ok;
53189 +atomic_unchecked_t fscache_n_stores_again;
53190 +atomic_unchecked_t fscache_n_stores_nobufs;
53191 +atomic_unchecked_t fscache_n_stores_oom;
53192 +atomic_unchecked_t fscache_n_store_ops;
53193 +atomic_unchecked_t fscache_n_store_calls;
53194 +atomic_unchecked_t fscache_n_store_pages;
53195 +atomic_unchecked_t fscache_n_store_radix_deletes;
53196 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53197
53198 -atomic_t fscache_n_store_vmscan_not_storing;
53199 -atomic_t fscache_n_store_vmscan_gone;
53200 -atomic_t fscache_n_store_vmscan_busy;
53201 -atomic_t fscache_n_store_vmscan_cancelled;
53202 -atomic_t fscache_n_store_vmscan_wait;
53203 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53204 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53205 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53206 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53207 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53208
53209 -atomic_t fscache_n_marks;
53210 -atomic_t fscache_n_uncaches;
53211 +atomic_unchecked_t fscache_n_marks;
53212 +atomic_unchecked_t fscache_n_uncaches;
53213
53214 -atomic_t fscache_n_acquires;
53215 -atomic_t fscache_n_acquires_null;
53216 -atomic_t fscache_n_acquires_no_cache;
53217 -atomic_t fscache_n_acquires_ok;
53218 -atomic_t fscache_n_acquires_nobufs;
53219 -atomic_t fscache_n_acquires_oom;
53220 +atomic_unchecked_t fscache_n_acquires;
53221 +atomic_unchecked_t fscache_n_acquires_null;
53222 +atomic_unchecked_t fscache_n_acquires_no_cache;
53223 +atomic_unchecked_t fscache_n_acquires_ok;
53224 +atomic_unchecked_t fscache_n_acquires_nobufs;
53225 +atomic_unchecked_t fscache_n_acquires_oom;
53226
53227 -atomic_t fscache_n_invalidates;
53228 -atomic_t fscache_n_invalidates_run;
53229 +atomic_unchecked_t fscache_n_invalidates;
53230 +atomic_unchecked_t fscache_n_invalidates_run;
53231
53232 -atomic_t fscache_n_updates;
53233 -atomic_t fscache_n_updates_null;
53234 -atomic_t fscache_n_updates_run;
53235 +atomic_unchecked_t fscache_n_updates;
53236 +atomic_unchecked_t fscache_n_updates_null;
53237 +atomic_unchecked_t fscache_n_updates_run;
53238
53239 -atomic_t fscache_n_relinquishes;
53240 -atomic_t fscache_n_relinquishes_null;
53241 -atomic_t fscache_n_relinquishes_waitcrt;
53242 -atomic_t fscache_n_relinquishes_retire;
53243 +atomic_unchecked_t fscache_n_relinquishes;
53244 +atomic_unchecked_t fscache_n_relinquishes_null;
53245 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53246 +atomic_unchecked_t fscache_n_relinquishes_retire;
53247
53248 -atomic_t fscache_n_cookie_index;
53249 -atomic_t fscache_n_cookie_data;
53250 -atomic_t fscache_n_cookie_special;
53251 +atomic_unchecked_t fscache_n_cookie_index;
53252 +atomic_unchecked_t fscache_n_cookie_data;
53253 +atomic_unchecked_t fscache_n_cookie_special;
53254
53255 -atomic_t fscache_n_object_alloc;
53256 -atomic_t fscache_n_object_no_alloc;
53257 -atomic_t fscache_n_object_lookups;
53258 -atomic_t fscache_n_object_lookups_negative;
53259 -atomic_t fscache_n_object_lookups_positive;
53260 -atomic_t fscache_n_object_lookups_timed_out;
53261 -atomic_t fscache_n_object_created;
53262 -atomic_t fscache_n_object_avail;
53263 -atomic_t fscache_n_object_dead;
53264 +atomic_unchecked_t fscache_n_object_alloc;
53265 +atomic_unchecked_t fscache_n_object_no_alloc;
53266 +atomic_unchecked_t fscache_n_object_lookups;
53267 +atomic_unchecked_t fscache_n_object_lookups_negative;
53268 +atomic_unchecked_t fscache_n_object_lookups_positive;
53269 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53270 +atomic_unchecked_t fscache_n_object_created;
53271 +atomic_unchecked_t fscache_n_object_avail;
53272 +atomic_unchecked_t fscache_n_object_dead;
53273
53274 -atomic_t fscache_n_checkaux_none;
53275 -atomic_t fscache_n_checkaux_okay;
53276 -atomic_t fscache_n_checkaux_update;
53277 -atomic_t fscache_n_checkaux_obsolete;
53278 +atomic_unchecked_t fscache_n_checkaux_none;
53279 +atomic_unchecked_t fscache_n_checkaux_okay;
53280 +atomic_unchecked_t fscache_n_checkaux_update;
53281 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53282
53283 atomic_t fscache_n_cop_alloc_object;
53284 atomic_t fscache_n_cop_lookup_object;
53285 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53286 seq_puts(m, "FS-Cache statistics\n");
53287
53288 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53289 - atomic_read(&fscache_n_cookie_index),
53290 - atomic_read(&fscache_n_cookie_data),
53291 - atomic_read(&fscache_n_cookie_special));
53292 + atomic_read_unchecked(&fscache_n_cookie_index),
53293 + atomic_read_unchecked(&fscache_n_cookie_data),
53294 + atomic_read_unchecked(&fscache_n_cookie_special));
53295
53296 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53297 - atomic_read(&fscache_n_object_alloc),
53298 - atomic_read(&fscache_n_object_no_alloc),
53299 - atomic_read(&fscache_n_object_avail),
53300 - atomic_read(&fscache_n_object_dead));
53301 + atomic_read_unchecked(&fscache_n_object_alloc),
53302 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53303 + atomic_read_unchecked(&fscache_n_object_avail),
53304 + atomic_read_unchecked(&fscache_n_object_dead));
53305 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53306 - atomic_read(&fscache_n_checkaux_none),
53307 - atomic_read(&fscache_n_checkaux_okay),
53308 - atomic_read(&fscache_n_checkaux_update),
53309 - atomic_read(&fscache_n_checkaux_obsolete));
53310 + atomic_read_unchecked(&fscache_n_checkaux_none),
53311 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53312 + atomic_read_unchecked(&fscache_n_checkaux_update),
53313 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53314
53315 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53316 - atomic_read(&fscache_n_marks),
53317 - atomic_read(&fscache_n_uncaches));
53318 + atomic_read_unchecked(&fscache_n_marks),
53319 + atomic_read_unchecked(&fscache_n_uncaches));
53320
53321 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53322 " oom=%u\n",
53323 - atomic_read(&fscache_n_acquires),
53324 - atomic_read(&fscache_n_acquires_null),
53325 - atomic_read(&fscache_n_acquires_no_cache),
53326 - atomic_read(&fscache_n_acquires_ok),
53327 - atomic_read(&fscache_n_acquires_nobufs),
53328 - atomic_read(&fscache_n_acquires_oom));
53329 + atomic_read_unchecked(&fscache_n_acquires),
53330 + atomic_read_unchecked(&fscache_n_acquires_null),
53331 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53332 + atomic_read_unchecked(&fscache_n_acquires_ok),
53333 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53334 + atomic_read_unchecked(&fscache_n_acquires_oom));
53335
53336 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53337 - atomic_read(&fscache_n_object_lookups),
53338 - atomic_read(&fscache_n_object_lookups_negative),
53339 - atomic_read(&fscache_n_object_lookups_positive),
53340 - atomic_read(&fscache_n_object_created),
53341 - atomic_read(&fscache_n_object_lookups_timed_out));
53342 + atomic_read_unchecked(&fscache_n_object_lookups),
53343 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53344 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53345 + atomic_read_unchecked(&fscache_n_object_created),
53346 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53347
53348 seq_printf(m, "Invals : n=%u run=%u\n",
53349 - atomic_read(&fscache_n_invalidates),
53350 - atomic_read(&fscache_n_invalidates_run));
53351 + atomic_read_unchecked(&fscache_n_invalidates),
53352 + atomic_read_unchecked(&fscache_n_invalidates_run));
53353
53354 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53355 - atomic_read(&fscache_n_updates),
53356 - atomic_read(&fscache_n_updates_null),
53357 - atomic_read(&fscache_n_updates_run));
53358 + atomic_read_unchecked(&fscache_n_updates),
53359 + atomic_read_unchecked(&fscache_n_updates_null),
53360 + atomic_read_unchecked(&fscache_n_updates_run));
53361
53362 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53363 - atomic_read(&fscache_n_relinquishes),
53364 - atomic_read(&fscache_n_relinquishes_null),
53365 - atomic_read(&fscache_n_relinquishes_waitcrt),
53366 - atomic_read(&fscache_n_relinquishes_retire));
53367 + atomic_read_unchecked(&fscache_n_relinquishes),
53368 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53369 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53370 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53371
53372 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53373 - atomic_read(&fscache_n_attr_changed),
53374 - atomic_read(&fscache_n_attr_changed_ok),
53375 - atomic_read(&fscache_n_attr_changed_nobufs),
53376 - atomic_read(&fscache_n_attr_changed_nomem),
53377 - atomic_read(&fscache_n_attr_changed_calls));
53378 + atomic_read_unchecked(&fscache_n_attr_changed),
53379 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53380 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53381 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53382 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53383
53384 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53385 - atomic_read(&fscache_n_allocs),
53386 - atomic_read(&fscache_n_allocs_ok),
53387 - atomic_read(&fscache_n_allocs_wait),
53388 - atomic_read(&fscache_n_allocs_nobufs),
53389 - atomic_read(&fscache_n_allocs_intr));
53390 + atomic_read_unchecked(&fscache_n_allocs),
53391 + atomic_read_unchecked(&fscache_n_allocs_ok),
53392 + atomic_read_unchecked(&fscache_n_allocs_wait),
53393 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53394 + atomic_read_unchecked(&fscache_n_allocs_intr));
53395 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53396 - atomic_read(&fscache_n_alloc_ops),
53397 - atomic_read(&fscache_n_alloc_op_waits),
53398 - atomic_read(&fscache_n_allocs_object_dead));
53399 + atomic_read_unchecked(&fscache_n_alloc_ops),
53400 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53401 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53402
53403 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53404 " int=%u oom=%u\n",
53405 - atomic_read(&fscache_n_retrievals),
53406 - atomic_read(&fscache_n_retrievals_ok),
53407 - atomic_read(&fscache_n_retrievals_wait),
53408 - atomic_read(&fscache_n_retrievals_nodata),
53409 - atomic_read(&fscache_n_retrievals_nobufs),
53410 - atomic_read(&fscache_n_retrievals_intr),
53411 - atomic_read(&fscache_n_retrievals_nomem));
53412 + atomic_read_unchecked(&fscache_n_retrievals),
53413 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53414 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53415 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53416 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53417 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53418 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53419 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53420 - atomic_read(&fscache_n_retrieval_ops),
53421 - atomic_read(&fscache_n_retrieval_op_waits),
53422 - atomic_read(&fscache_n_retrievals_object_dead));
53423 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53424 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53425 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53426
53427 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53428 - atomic_read(&fscache_n_stores),
53429 - atomic_read(&fscache_n_stores_ok),
53430 - atomic_read(&fscache_n_stores_again),
53431 - atomic_read(&fscache_n_stores_nobufs),
53432 - atomic_read(&fscache_n_stores_oom));
53433 + atomic_read_unchecked(&fscache_n_stores),
53434 + atomic_read_unchecked(&fscache_n_stores_ok),
53435 + atomic_read_unchecked(&fscache_n_stores_again),
53436 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53437 + atomic_read_unchecked(&fscache_n_stores_oom));
53438 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53439 - atomic_read(&fscache_n_store_ops),
53440 - atomic_read(&fscache_n_store_calls),
53441 - atomic_read(&fscache_n_store_pages),
53442 - atomic_read(&fscache_n_store_radix_deletes),
53443 - atomic_read(&fscache_n_store_pages_over_limit));
53444 + atomic_read_unchecked(&fscache_n_store_ops),
53445 + atomic_read_unchecked(&fscache_n_store_calls),
53446 + atomic_read_unchecked(&fscache_n_store_pages),
53447 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53448 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53449
53450 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53451 - atomic_read(&fscache_n_store_vmscan_not_storing),
53452 - atomic_read(&fscache_n_store_vmscan_gone),
53453 - atomic_read(&fscache_n_store_vmscan_busy),
53454 - atomic_read(&fscache_n_store_vmscan_cancelled),
53455 - atomic_read(&fscache_n_store_vmscan_wait));
53456 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53457 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53458 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53459 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53460 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53461
53462 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53463 - atomic_read(&fscache_n_op_pend),
53464 - atomic_read(&fscache_n_op_run),
53465 - atomic_read(&fscache_n_op_enqueue),
53466 - atomic_read(&fscache_n_op_cancelled),
53467 - atomic_read(&fscache_n_op_rejected));
53468 + atomic_read_unchecked(&fscache_n_op_pend),
53469 + atomic_read_unchecked(&fscache_n_op_run),
53470 + atomic_read_unchecked(&fscache_n_op_enqueue),
53471 + atomic_read_unchecked(&fscache_n_op_cancelled),
53472 + atomic_read_unchecked(&fscache_n_op_rejected));
53473 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53474 - atomic_read(&fscache_n_op_deferred_release),
53475 - atomic_read(&fscache_n_op_release),
53476 - atomic_read(&fscache_n_op_gc));
53477 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53478 + atomic_read_unchecked(&fscache_n_op_release),
53479 + atomic_read_unchecked(&fscache_n_op_gc));
53480
53481 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53482 atomic_read(&fscache_n_cop_alloc_object),
53483 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53484 index aef34b1..59bfd7b 100644
53485 --- a/fs/fuse/cuse.c
53486 +++ b/fs/fuse/cuse.c
53487 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
53488 INIT_LIST_HEAD(&cuse_conntbl[i]);
53489
53490 /* inherit and extend fuse_dev_operations */
53491 - cuse_channel_fops = fuse_dev_operations;
53492 - cuse_channel_fops.owner = THIS_MODULE;
53493 - cuse_channel_fops.open = cuse_channel_open;
53494 - cuse_channel_fops.release = cuse_channel_release;
53495 + pax_open_kernel();
53496 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53497 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53498 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53499 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53500 + pax_close_kernel();
53501
53502 cuse_class = class_create(THIS_MODULE, "cuse");
53503 if (IS_ERR(cuse_class))
53504 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53505 index 1d55f94..088da65 100644
53506 --- a/fs/fuse/dev.c
53507 +++ b/fs/fuse/dev.c
53508 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53509 ret = 0;
53510 pipe_lock(pipe);
53511
53512 - if (!pipe->readers) {
53513 + if (!atomic_read(&pipe->readers)) {
53514 send_sig(SIGPIPE, current, 0);
53515 if (!ret)
53516 ret = -EPIPE;
53517 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53518 page_nr++;
53519 ret += buf->len;
53520
53521 - if (pipe->files)
53522 + if (atomic_read(&pipe->files))
53523 do_wakeup = 1;
53524 }
53525
53526 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53527 index 5b12746..b481b03 100644
53528 --- a/fs/fuse/dir.c
53529 +++ b/fs/fuse/dir.c
53530 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
53531 return link;
53532 }
53533
53534 -static void free_link(char *link)
53535 +static void free_link(const char *link)
53536 {
53537 if (!IS_ERR(link))
53538 free_page((unsigned long) link);
53539 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53540 index 62b484e..0f9a140 100644
53541 --- a/fs/gfs2/inode.c
53542 +++ b/fs/gfs2/inode.c
53543 @@ -1441,7 +1441,7 @@ out:
53544
53545 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53546 {
53547 - char *s = nd_get_link(nd);
53548 + const char *s = nd_get_link(nd);
53549 if (!IS_ERR(s))
53550 kfree(s);
53551 }
53552 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53553 index a3f868a..bb308ae 100644
53554 --- a/fs/hugetlbfs/inode.c
53555 +++ b/fs/hugetlbfs/inode.c
53556 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53557 struct mm_struct *mm = current->mm;
53558 struct vm_area_struct *vma;
53559 struct hstate *h = hstate_file(file);
53560 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53561 struct vm_unmapped_area_info info;
53562
53563 if (len & ~huge_page_mask(h))
53564 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53565 return addr;
53566 }
53567
53568 +#ifdef CONFIG_PAX_RANDMMAP
53569 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53570 +#endif
53571 +
53572 if (addr) {
53573 addr = ALIGN(addr, huge_page_size(h));
53574 vma = find_vma(mm, addr);
53575 - if (TASK_SIZE - len >= addr &&
53576 - (!vma || addr + len <= vma->vm_start))
53577 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53578 return addr;
53579 }
53580
53581 info.flags = 0;
53582 info.length = len;
53583 info.low_limit = TASK_UNMAPPED_BASE;
53584 +
53585 +#ifdef CONFIG_PAX_RANDMMAP
53586 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53587 + info.low_limit += mm->delta_mmap;
53588 +#endif
53589 +
53590 info.high_limit = TASK_SIZE;
53591 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53592 info.align_offset = 0;
53593 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53594 };
53595 MODULE_ALIAS_FS("hugetlbfs");
53596
53597 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53598 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53599
53600 static int can_do_hugetlb_shm(void)
53601 {
53602 diff --git a/fs/inode.c b/fs/inode.c
53603 index 00d5fc3..98ce7d7 100644
53604 --- a/fs/inode.c
53605 +++ b/fs/inode.c
53606 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53607
53608 #ifdef CONFIG_SMP
53609 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53610 - static atomic_t shared_last_ino;
53611 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53612 + static atomic_unchecked_t shared_last_ino;
53613 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53614
53615 res = next - LAST_INO_BATCH;
53616 }
53617 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53618 index 4a6cf28..d3a29d3 100644
53619 --- a/fs/jffs2/erase.c
53620 +++ b/fs/jffs2/erase.c
53621 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53622 struct jffs2_unknown_node marker = {
53623 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53624 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53625 - .totlen = cpu_to_je32(c->cleanmarker_size)
53626 + .totlen = cpu_to_je32(c->cleanmarker_size),
53627 + .hdr_crc = cpu_to_je32(0)
53628 };
53629
53630 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53631 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53632 index a6597d6..41b30ec 100644
53633 --- a/fs/jffs2/wbuf.c
53634 +++ b/fs/jffs2/wbuf.c
53635 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53636 {
53637 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53638 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53639 - .totlen = constant_cpu_to_je32(8)
53640 + .totlen = constant_cpu_to_je32(8),
53641 + .hdr_crc = constant_cpu_to_je32(0)
53642 };
53643
53644 /*
53645 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53646 index 788e0a9..8433098 100644
53647 --- a/fs/jfs/super.c
53648 +++ b/fs/jfs/super.c
53649 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
53650
53651 jfs_inode_cachep =
53652 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53653 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53654 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53655 init_once);
53656 if (jfs_inode_cachep == NULL)
53657 return -ENOMEM;
53658 diff --git a/fs/libfs.c b/fs/libfs.c
53659 index 916da8c..1588998 100644
53660 --- a/fs/libfs.c
53661 +++ b/fs/libfs.c
53662 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53663
53664 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53665 struct dentry *next;
53666 + char d_name[sizeof(next->d_iname)];
53667 + const unsigned char *name;
53668 +
53669 next = list_entry(p, struct dentry, d_u.d_child);
53670 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53671 if (!simple_positive(next)) {
53672 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53673
53674 spin_unlock(&next->d_lock);
53675 spin_unlock(&dentry->d_lock);
53676 - if (filldir(dirent, next->d_name.name,
53677 + name = next->d_name.name;
53678 + if (name == next->d_iname) {
53679 + memcpy(d_name, name, next->d_name.len);
53680 + name = d_name;
53681 + }
53682 + if (filldir(dirent, name,
53683 next->d_name.len, filp->f_pos,
53684 next->d_inode->i_ino,
53685 dt_type(next->d_inode)) < 0)
53686 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53687 index 9760ecb..9b838ef 100644
53688 --- a/fs/lockd/clntproc.c
53689 +++ b/fs/lockd/clntproc.c
53690 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53691 /*
53692 * Cookie counter for NLM requests
53693 */
53694 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53695 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53696
53697 void nlmclnt_next_cookie(struct nlm_cookie *c)
53698 {
53699 - u32 cookie = atomic_inc_return(&nlm_cookie);
53700 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53701
53702 memcpy(c->data, &cookie, 4);
53703 c->len=4;
53704 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53705 index a2aa97d..10d6c41 100644
53706 --- a/fs/lockd/svc.c
53707 +++ b/fs/lockd/svc.c
53708 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53709 svc_sock_update_bufs(serv);
53710 serv->sv_maxconn = nlm_max_connections;
53711
53712 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53713 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53714 if (IS_ERR(nlmsvc_task)) {
53715 error = PTR_ERR(nlmsvc_task);
53716 printk(KERN_WARNING
53717 diff --git a/fs/locks.c b/fs/locks.c
53718 index cb424a4..850e4dd 100644
53719 --- a/fs/locks.c
53720 +++ b/fs/locks.c
53721 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53722 return;
53723
53724 if (filp->f_op && filp->f_op->flock) {
53725 - struct file_lock fl = {
53726 + struct file_lock flock = {
53727 .fl_pid = current->tgid,
53728 .fl_file = filp,
53729 .fl_flags = FL_FLOCK,
53730 .fl_type = F_UNLCK,
53731 .fl_end = OFFSET_MAX,
53732 };
53733 - filp->f_op->flock(filp, F_SETLKW, &fl);
53734 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53735 - fl.fl_ops->fl_release_private(&fl);
53736 + filp->f_op->flock(filp, F_SETLKW, &flock);
53737 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53738 + flock.fl_ops->fl_release_private(&flock);
53739 }
53740
53741 lock_flocks();
53742 diff --git a/fs/namei.c b/fs/namei.c
53743 index 9ed9361..2b72db1 100644
53744 --- a/fs/namei.c
53745 +++ b/fs/namei.c
53746 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53747 if (ret != -EACCES)
53748 return ret;
53749
53750 +#ifdef CONFIG_GRKERNSEC
53751 + /* we'll block if we have to log due to a denied capability use */
53752 + if (mask & MAY_NOT_BLOCK)
53753 + return -ECHILD;
53754 +#endif
53755 +
53756 if (S_ISDIR(inode->i_mode)) {
53757 /* DACs are overridable for directories */
53758 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53759 - return 0;
53760 if (!(mask & MAY_WRITE))
53761 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53762 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53763 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53764 return 0;
53765 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53766 + return 0;
53767 return -EACCES;
53768 }
53769 /*
53770 + * Searching includes executable on directories, else just read.
53771 + */
53772 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53773 + if (mask == MAY_READ)
53774 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53775 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53776 + return 0;
53777 +
53778 + /*
53779 * Read/write DACs are always overridable.
53780 * Executable DACs are overridable when there is
53781 * at least one exec bit set.
53782 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53783 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53784 return 0;
53785
53786 - /*
53787 - * Searching includes executable on directories, else just read.
53788 - */
53789 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53790 - if (mask == MAY_READ)
53791 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53792 - return 0;
53793 -
53794 return -EACCES;
53795 }
53796
53797 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53798 {
53799 struct dentry *dentry = link->dentry;
53800 int error;
53801 - char *s;
53802 + const char *s;
53803
53804 BUG_ON(nd->flags & LOOKUP_RCU);
53805
53806 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53807 if (error)
53808 goto out_put_nd_path;
53809
53810 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53811 + dentry->d_inode, dentry, nd->path.mnt)) {
53812 + error = -EACCES;
53813 + goto out_put_nd_path;
53814 + }
53815 +
53816 nd->last_type = LAST_BIND;
53817 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53818 error = PTR_ERR(*p);
53819 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53820 if (res)
53821 break;
53822 res = walk_component(nd, path, LOOKUP_FOLLOW);
53823 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53824 + res = -EACCES;
53825 put_link(nd, &link, cookie);
53826 } while (res > 0);
53827
53828 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53829 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53830 {
53831 unsigned long a, b, adata, bdata, mask, hash, len;
53832 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53833 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53834
53835 hash = a = 0;
53836 len = -sizeof(unsigned long);
53837 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53838 if (err)
53839 break;
53840 err = lookup_last(nd, &path);
53841 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53842 + err = -EACCES;
53843 put_link(nd, &link, cookie);
53844 }
53845 }
53846 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53847 if (!err)
53848 err = complete_walk(nd);
53849
53850 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53851 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53852 + path_put(&nd->path);
53853 + err = -ENOENT;
53854 + }
53855 + }
53856 +
53857 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53858 if (!can_lookup(nd->inode)) {
53859 path_put(&nd->path);
53860 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53861 retval = path_lookupat(dfd, name->name,
53862 flags | LOOKUP_REVAL, nd);
53863
53864 - if (likely(!retval))
53865 + if (likely(!retval)) {
53866 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53867 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53868 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53869 + path_put(&nd->path);
53870 + return -ENOENT;
53871 + }
53872 + }
53873 + }
53874 return retval;
53875 }
53876
53877 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53878 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53879 return -EPERM;
53880
53881 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53882 + return -EPERM;
53883 + if (gr_handle_rawio(inode))
53884 + return -EPERM;
53885 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53886 + return -EACCES;
53887 +
53888 return 0;
53889 }
53890
53891 @@ -2602,7 +2641,7 @@ looked_up:
53892 * cleared otherwise prior to returning.
53893 */
53894 static int lookup_open(struct nameidata *nd, struct path *path,
53895 - struct file *file,
53896 + struct path *link, struct file *file,
53897 const struct open_flags *op,
53898 bool got_write, int *opened)
53899 {
53900 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53901 /* Negative dentry, just create the file */
53902 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53903 umode_t mode = op->mode;
53904 +
53905 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53906 + error = -EACCES;
53907 + goto out_dput;
53908 + }
53909 +
53910 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53911 + error = -EACCES;
53912 + goto out_dput;
53913 + }
53914 +
53915 if (!IS_POSIXACL(dir->d_inode))
53916 mode &= ~current_umask();
53917 /*
53918 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53919 nd->flags & LOOKUP_EXCL);
53920 if (error)
53921 goto out_dput;
53922 + else
53923 + gr_handle_create(dentry, nd->path.mnt);
53924 }
53925 out_no_open:
53926 path->dentry = dentry;
53927 @@ -2672,7 +2724,7 @@ out_dput:
53928 /*
53929 * Handle the last step of open()
53930 */
53931 -static int do_last(struct nameidata *nd, struct path *path,
53932 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53933 struct file *file, const struct open_flags *op,
53934 int *opened, struct filename *name)
53935 {
53936 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53937 error = complete_walk(nd);
53938 if (error)
53939 return error;
53940 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53941 + error = -ENOENT;
53942 + goto out;
53943 + }
53944 audit_inode(name, nd->path.dentry, 0);
53945 if (open_flag & O_CREAT) {
53946 error = -EISDIR;
53947 goto out;
53948 }
53949 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53950 + error = -EACCES;
53951 + goto out;
53952 + }
53953 goto finish_open;
53954 case LAST_BIND:
53955 error = complete_walk(nd);
53956 if (error)
53957 return error;
53958 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53959 + error = -ENOENT;
53960 + goto out;
53961 + }
53962 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53963 + error = -EACCES;
53964 + goto out;
53965 + }
53966 audit_inode(name, dir, 0);
53967 goto finish_open;
53968 }
53969 @@ -2759,7 +2827,7 @@ retry_lookup:
53970 */
53971 }
53972 mutex_lock(&dir->d_inode->i_mutex);
53973 - error = lookup_open(nd, path, file, op, got_write, opened);
53974 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53975 mutex_unlock(&dir->d_inode->i_mutex);
53976
53977 if (error <= 0) {
53978 @@ -2783,11 +2851,28 @@ retry_lookup:
53979 goto finish_open_created;
53980 }
53981
53982 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53983 + error = -ENOENT;
53984 + goto exit_dput;
53985 + }
53986 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53987 + error = -EACCES;
53988 + goto exit_dput;
53989 + }
53990 +
53991 /*
53992 * create/update audit record if it already exists.
53993 */
53994 - if (path->dentry->d_inode)
53995 + if (path->dentry->d_inode) {
53996 + /* only check if O_CREAT is specified, all other checks need to go
53997 + into may_open */
53998 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53999 + error = -EACCES;
54000 + goto exit_dput;
54001 + }
54002 +
54003 audit_inode(name, path->dentry, 0);
54004 + }
54005
54006 /*
54007 * If atomic_open() acquired write access it is dropped now due to
54008 @@ -2828,6 +2913,11 @@ finish_lookup:
54009 }
54010 }
54011 BUG_ON(inode != path->dentry->d_inode);
54012 + /* if we're resolving a symlink to another symlink */
54013 + if (link && gr_handle_symlink_owner(link, inode)) {
54014 + error = -EACCES;
54015 + goto out;
54016 + }
54017 return 1;
54018 }
54019
54020 @@ -2837,7 +2927,6 @@ finish_lookup:
54021 save_parent.dentry = nd->path.dentry;
54022 save_parent.mnt = mntget(path->mnt);
54023 nd->path.dentry = path->dentry;
54024 -
54025 }
54026 nd->inode = inode;
54027 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
54028 @@ -2846,6 +2935,16 @@ finish_lookup:
54029 path_put(&save_parent);
54030 return error;
54031 }
54032 +
54033 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
54034 + error = -ENOENT;
54035 + goto out;
54036 + }
54037 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
54038 + error = -EACCES;
54039 + goto out;
54040 + }
54041 +
54042 error = -EISDIR;
54043 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
54044 goto out;
54045 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54046 if (unlikely(error))
54047 goto out;
54048
54049 - error = do_last(nd, &path, file, op, &opened, pathname);
54050 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
54051 while (unlikely(error > 0)) { /* trailing symlink */
54052 struct path link = path;
54053 void *cookie;
54054 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54055 error = follow_link(&link, nd, &cookie);
54056 if (unlikely(error))
54057 break;
54058 - error = do_last(nd, &path, file, op, &opened, pathname);
54059 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
54060 put_link(nd, &link, cookie);
54061 }
54062 out:
54063 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
54064 goto unlock;
54065
54066 error = -EEXIST;
54067 - if (dentry->d_inode)
54068 + if (dentry->d_inode) {
54069 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
54070 + error = -ENOENT;
54071 + }
54072 goto fail;
54073 + }
54074 /*
54075 * Special case - lookup gave negative, but... we had foo/bar/
54076 * From the vfs_mknod() POV we just have a negative dentry -
54077 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
54078 }
54079 EXPORT_SYMBOL(user_path_create);
54080
54081 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
54082 +{
54083 + struct filename *tmp = getname(pathname);
54084 + struct dentry *res;
54085 + if (IS_ERR(tmp))
54086 + return ERR_CAST(tmp);
54087 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
54088 + if (IS_ERR(res))
54089 + putname(tmp);
54090 + else
54091 + *to = tmp;
54092 + return res;
54093 +}
54094 +
54095 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54096 {
54097 int error = may_create(dir, dentry);
54098 @@ -3177,6 +3294,17 @@ retry:
54099
54100 if (!IS_POSIXACL(path.dentry->d_inode))
54101 mode &= ~current_umask();
54102 +
54103 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54104 + error = -EPERM;
54105 + goto out;
54106 + }
54107 +
54108 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54109 + error = -EACCES;
54110 + goto out;
54111 + }
54112 +
54113 error = security_path_mknod(&path, dentry, mode, dev);
54114 if (error)
54115 goto out;
54116 @@ -3193,6 +3321,8 @@ retry:
54117 break;
54118 }
54119 out:
54120 + if (!error)
54121 + gr_handle_create(dentry, path.mnt);
54122 done_path_create(&path, dentry);
54123 if (retry_estale(error, lookup_flags)) {
54124 lookup_flags |= LOOKUP_REVAL;
54125 @@ -3245,9 +3375,16 @@ retry:
54126
54127 if (!IS_POSIXACL(path.dentry->d_inode))
54128 mode &= ~current_umask();
54129 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54130 + error = -EACCES;
54131 + goto out;
54132 + }
54133 error = security_path_mkdir(&path, dentry, mode);
54134 if (!error)
54135 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54136 + if (!error)
54137 + gr_handle_create(dentry, path.mnt);
54138 +out:
54139 done_path_create(&path, dentry);
54140 if (retry_estale(error, lookup_flags)) {
54141 lookup_flags |= LOOKUP_REVAL;
54142 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54143 struct filename *name;
54144 struct dentry *dentry;
54145 struct nameidata nd;
54146 + ino_t saved_ino = 0;
54147 + dev_t saved_dev = 0;
54148 unsigned int lookup_flags = 0;
54149 retry:
54150 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54151 @@ -3360,10 +3499,21 @@ retry:
54152 error = -ENOENT;
54153 goto exit3;
54154 }
54155 +
54156 + saved_ino = dentry->d_inode->i_ino;
54157 + saved_dev = gr_get_dev_from_dentry(dentry);
54158 +
54159 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54160 + error = -EACCES;
54161 + goto exit3;
54162 + }
54163 +
54164 error = security_path_rmdir(&nd.path, dentry);
54165 if (error)
54166 goto exit3;
54167 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54168 + if (!error && (saved_dev || saved_ino))
54169 + gr_handle_delete(saved_ino, saved_dev);
54170 exit3:
54171 dput(dentry);
54172 exit2:
54173 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54174 struct dentry *dentry;
54175 struct nameidata nd;
54176 struct inode *inode = NULL;
54177 + ino_t saved_ino = 0;
54178 + dev_t saved_dev = 0;
54179 unsigned int lookup_flags = 0;
54180 retry:
54181 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54182 @@ -3455,10 +3607,22 @@ retry:
54183 if (!inode)
54184 goto slashes;
54185 ihold(inode);
54186 +
54187 + if (inode->i_nlink <= 1) {
54188 + saved_ino = inode->i_ino;
54189 + saved_dev = gr_get_dev_from_dentry(dentry);
54190 + }
54191 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54192 + error = -EACCES;
54193 + goto exit2;
54194 + }
54195 +
54196 error = security_path_unlink(&nd.path, dentry);
54197 if (error)
54198 goto exit2;
54199 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54200 + if (!error && (saved_ino || saved_dev))
54201 + gr_handle_delete(saved_ino, saved_dev);
54202 exit2:
54203 dput(dentry);
54204 }
54205 @@ -3536,9 +3700,17 @@ retry:
54206 if (IS_ERR(dentry))
54207 goto out_putname;
54208
54209 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54210 + error = -EACCES;
54211 + goto out;
54212 + }
54213 +
54214 error = security_path_symlink(&path, dentry, from->name);
54215 if (!error)
54216 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54217 + if (!error)
54218 + gr_handle_create(dentry, path.mnt);
54219 +out:
54220 done_path_create(&path, dentry);
54221 if (retry_estale(error, lookup_flags)) {
54222 lookup_flags |= LOOKUP_REVAL;
54223 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54224 {
54225 struct dentry *new_dentry;
54226 struct path old_path, new_path;
54227 + struct filename *to = NULL;
54228 int how = 0;
54229 int error;
54230
54231 @@ -3635,7 +3808,7 @@ retry:
54232 if (error)
54233 return error;
54234
54235 - new_dentry = user_path_create(newdfd, newname, &new_path,
54236 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54237 (how & LOOKUP_REVAL));
54238 error = PTR_ERR(new_dentry);
54239 if (IS_ERR(new_dentry))
54240 @@ -3647,11 +3820,28 @@ retry:
54241 error = may_linkat(&old_path);
54242 if (unlikely(error))
54243 goto out_dput;
54244 +
54245 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54246 + old_path.dentry->d_inode,
54247 + old_path.dentry->d_inode->i_mode, to)) {
54248 + error = -EACCES;
54249 + goto out_dput;
54250 + }
54251 +
54252 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54253 + old_path.dentry, old_path.mnt, to)) {
54254 + error = -EACCES;
54255 + goto out_dput;
54256 + }
54257 +
54258 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54259 if (error)
54260 goto out_dput;
54261 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54262 + if (!error)
54263 + gr_handle_create(new_dentry, new_path.mnt);
54264 out_dput:
54265 + putname(to);
54266 done_path_create(&new_path, new_dentry);
54267 if (retry_estale(error, how)) {
54268 how |= LOOKUP_REVAL;
54269 @@ -3897,12 +4087,21 @@ retry:
54270 if (new_dentry == trap)
54271 goto exit5;
54272
54273 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54274 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54275 + to);
54276 + if (error)
54277 + goto exit5;
54278 +
54279 error = security_path_rename(&oldnd.path, old_dentry,
54280 &newnd.path, new_dentry);
54281 if (error)
54282 goto exit5;
54283 error = vfs_rename(old_dir->d_inode, old_dentry,
54284 new_dir->d_inode, new_dentry);
54285 + if (!error)
54286 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54287 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54288 exit5:
54289 dput(new_dentry);
54290 exit4:
54291 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54292
54293 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54294 {
54295 + char tmpbuf[64];
54296 + const char *newlink;
54297 int len;
54298
54299 len = PTR_ERR(link);
54300 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54301 len = strlen(link);
54302 if (len > (unsigned) buflen)
54303 len = buflen;
54304 - if (copy_to_user(buffer, link, len))
54305 +
54306 + if (len < sizeof(tmpbuf)) {
54307 + memcpy(tmpbuf, link, len);
54308 + newlink = tmpbuf;
54309 + } else
54310 + newlink = link;
54311 +
54312 + if (copy_to_user(buffer, newlink, len))
54313 len = -EFAULT;
54314 out:
54315 return len;
54316 diff --git a/fs/namespace.c b/fs/namespace.c
54317 index 7b1ca9b..6faeccf 100644
54318 --- a/fs/namespace.c
54319 +++ b/fs/namespace.c
54320 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
54321 if (!(sb->s_flags & MS_RDONLY))
54322 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54323 up_write(&sb->s_umount);
54324 +
54325 + gr_log_remount(mnt->mnt_devname, retval);
54326 +
54327 return retval;
54328 }
54329
54330 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
54331 }
54332 br_write_unlock(&vfsmount_lock);
54333 namespace_unlock();
54334 +
54335 + gr_log_unmount(mnt->mnt_devname, retval);
54336 +
54337 return retval;
54338 }
54339
54340 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
54341 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54342 */
54343
54344 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54345 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54346 {
54347 struct path path;
54348 struct mount *mnt;
54349 @@ -1342,7 +1348,7 @@ out:
54350 /*
54351 * The 2.0 compatible umount. No flags.
54352 */
54353 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54354 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54355 {
54356 return sys_umount(name, 0);
54357 }
54358 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54359 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54360 MS_STRICTATIME);
54361
54362 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54363 + retval = -EPERM;
54364 + goto dput_out;
54365 + }
54366 +
54367 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54368 + retval = -EPERM;
54369 + goto dput_out;
54370 + }
54371 +
54372 if (flags & MS_REMOUNT)
54373 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54374 data_page);
54375 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54376 dev_name, data_page);
54377 dput_out:
54378 path_put(&path);
54379 +
54380 + gr_log_mount(dev_name, dir_name, retval);
54381 +
54382 return retval;
54383 }
54384
54385 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54386 }
54387 EXPORT_SYMBOL(mount_subtree);
54388
54389 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54390 - char __user *, type, unsigned long, flags, void __user *, data)
54391 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54392 + const char __user *, type, unsigned long, flags, void __user *, data)
54393 {
54394 int ret;
54395 char *kernel_type;
54396 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54397 if (error)
54398 goto out2;
54399
54400 + if (gr_handle_chroot_pivot()) {
54401 + error = -EPERM;
54402 + goto out2;
54403 + }
54404 +
54405 get_fs_root(current->fs, &root);
54406 old_mp = lock_mount(&old);
54407 error = PTR_ERR(old_mp);
54408 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54409 !nsown_capable(CAP_SYS_ADMIN))
54410 return -EPERM;
54411
54412 - if (fs->users != 1)
54413 + if (atomic_read(&fs->users) != 1)
54414 return -EINVAL;
54415
54416 get_mnt_ns(mnt_ns);
54417 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54418 index cff089a..4c3d57a 100644
54419 --- a/fs/nfs/callback.c
54420 +++ b/fs/nfs/callback.c
54421 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54422 struct svc_rqst *rqstp;
54423 int (*callback_svc)(void *vrqstp);
54424 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54425 - char svc_name[12];
54426 int ret;
54427
54428 nfs_callback_bc_serv(minorversion, xprt, serv);
54429 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54430
54431 svc_sock_update_bufs(serv);
54432
54433 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54434 cb_info->serv = serv;
54435 cb_info->rqst = rqstp;
54436 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54437 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54438 if (IS_ERR(cb_info->task)) {
54439 ret = PTR_ERR(cb_info->task);
54440 svc_exit_thread(cb_info->rqst);
54441 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54442 index a35582c..ebbdcd5 100644
54443 --- a/fs/nfs/callback_xdr.c
54444 +++ b/fs/nfs/callback_xdr.c
54445 @@ -51,7 +51,7 @@ struct callback_op {
54446 callback_decode_arg_t decode_args;
54447 callback_encode_res_t encode_res;
54448 long res_maxsize;
54449 -};
54450 +} __do_const;
54451
54452 static struct callback_op callback_ops[];
54453
54454 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54455 index c1c7a9d..7afa0b8 100644
54456 --- a/fs/nfs/inode.c
54457 +++ b/fs/nfs/inode.c
54458 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54459 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54460 }
54461
54462 -static atomic_long_t nfs_attr_generation_counter;
54463 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54464
54465 static unsigned long nfs_read_attr_generation_counter(void)
54466 {
54467 - return atomic_long_read(&nfs_attr_generation_counter);
54468 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54469 }
54470
54471 unsigned long nfs_inc_attr_generation_counter(void)
54472 {
54473 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54474 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54475 }
54476
54477 void nfs_fattr_init(struct nfs_fattr *fattr)
54478 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54479 index 2c37442..9b9538b 100644
54480 --- a/fs/nfs/nfs4state.c
54481 +++ b/fs/nfs/nfs4state.c
54482 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54483 snprintf(buf, sizeof(buf), "%s-manager",
54484 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54485 rcu_read_unlock();
54486 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54487 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54488 if (IS_ERR(task)) {
54489 printk(KERN_ERR "%s: kthread_run: %ld\n",
54490 __func__, PTR_ERR(task));
54491 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54492 index 27d74a2..c4c2a73 100644
54493 --- a/fs/nfsd/nfs4proc.c
54494 +++ b/fs/nfsd/nfs4proc.c
54495 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
54496 nfsd4op_rsize op_rsize_bop;
54497 stateid_getter op_get_currentstateid;
54498 stateid_setter op_set_currentstateid;
54499 -};
54500 +} __do_const;
54501
54502 static struct nfsd4_operation nfsd4_ops[];
54503
54504 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54505 index 582321a..0224663 100644
54506 --- a/fs/nfsd/nfs4xdr.c
54507 +++ b/fs/nfsd/nfs4xdr.c
54508 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54509
54510 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54511
54512 -static nfsd4_dec nfsd4_dec_ops[] = {
54513 +static const nfsd4_dec nfsd4_dec_ops[] = {
54514 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54515 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54516 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54517 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54518 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54519 };
54520
54521 -static nfsd4_dec nfsd41_dec_ops[] = {
54522 +static const nfsd4_dec nfsd41_dec_ops[] = {
54523 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54524 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54525 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54526 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54527 };
54528
54529 struct nfsd4_minorversion_ops {
54530 - nfsd4_dec *decoders;
54531 + const nfsd4_dec *decoders;
54532 int nops;
54533 };
54534
54535 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54536 index e76244e..9fe8f2f1 100644
54537 --- a/fs/nfsd/nfscache.c
54538 +++ b/fs/nfsd/nfscache.c
54539 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54540 {
54541 struct svc_cacherep *rp = rqstp->rq_cacherep;
54542 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54543 - int len;
54544 + long len;
54545 size_t bufsize = 0;
54546
54547 if (!rp)
54548 return;
54549
54550 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54551 - len >>= 2;
54552 + if (statp) {
54553 + len = (char*)statp - (char*)resv->iov_base;
54554 + len = resv->iov_len - len;
54555 + len >>= 2;
54556 + }
54557
54558 /* Don't cache excessive amounts of data and XDR failures */
54559 if (!statp || len > (256 >> 2)) {
54560 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54561 index baf149a..76b86ad 100644
54562 --- a/fs/nfsd/vfs.c
54563 +++ b/fs/nfsd/vfs.c
54564 @@ -940,7 +940,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54565 } else {
54566 oldfs = get_fs();
54567 set_fs(KERNEL_DS);
54568 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54569 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54570 set_fs(oldfs);
54571 }
54572
54573 @@ -1027,7 +1027,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54574
54575 /* Write the data. */
54576 oldfs = get_fs(); set_fs(KERNEL_DS);
54577 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54578 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54579 set_fs(oldfs);
54580 if (host_err < 0)
54581 goto out_nfserr;
54582 @@ -1573,7 +1573,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54583 */
54584
54585 oldfs = get_fs(); set_fs(KERNEL_DS);
54586 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54587 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54588 set_fs(oldfs);
54589
54590 if (host_err < 0)
54591 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54592 index fea6bd5..8ee9d81 100644
54593 --- a/fs/nls/nls_base.c
54594 +++ b/fs/nls/nls_base.c
54595 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54596
54597 int register_nls(struct nls_table * nls)
54598 {
54599 - struct nls_table ** tmp = &tables;
54600 + struct nls_table *tmp = tables;
54601
54602 if (nls->next)
54603 return -EBUSY;
54604
54605 spin_lock(&nls_lock);
54606 - while (*tmp) {
54607 - if (nls == *tmp) {
54608 + while (tmp) {
54609 + if (nls == tmp) {
54610 spin_unlock(&nls_lock);
54611 return -EBUSY;
54612 }
54613 - tmp = &(*tmp)->next;
54614 + tmp = tmp->next;
54615 }
54616 - nls->next = tables;
54617 + pax_open_kernel();
54618 + *(struct nls_table **)&nls->next = tables;
54619 + pax_close_kernel();
54620 tables = nls;
54621 spin_unlock(&nls_lock);
54622 return 0;
54623 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54624
54625 int unregister_nls(struct nls_table * nls)
54626 {
54627 - struct nls_table ** tmp = &tables;
54628 + struct nls_table * const * tmp = &tables;
54629
54630 spin_lock(&nls_lock);
54631 while (*tmp) {
54632 if (nls == *tmp) {
54633 - *tmp = nls->next;
54634 + pax_open_kernel();
54635 + *(struct nls_table **)tmp = nls->next;
54636 + pax_close_kernel();
54637 spin_unlock(&nls_lock);
54638 return 0;
54639 }
54640 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54641 index 7424929..35f6be5 100644
54642 --- a/fs/nls/nls_euc-jp.c
54643 +++ b/fs/nls/nls_euc-jp.c
54644 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54645 p_nls = load_nls("cp932");
54646
54647 if (p_nls) {
54648 - table.charset2upper = p_nls->charset2upper;
54649 - table.charset2lower = p_nls->charset2lower;
54650 + pax_open_kernel();
54651 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54652 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54653 + pax_close_kernel();
54654 return register_nls(&table);
54655 }
54656
54657 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54658 index e7bc1d7..06bd4bb 100644
54659 --- a/fs/nls/nls_koi8-ru.c
54660 +++ b/fs/nls/nls_koi8-ru.c
54661 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54662 p_nls = load_nls("koi8-u");
54663
54664 if (p_nls) {
54665 - table.charset2upper = p_nls->charset2upper;
54666 - table.charset2lower = p_nls->charset2lower;
54667 + pax_open_kernel();
54668 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54669 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54670 + pax_close_kernel();
54671 return register_nls(&table);
54672 }
54673
54674 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54675 index 6c80083..a1e6299 100644
54676 --- a/fs/notify/fanotify/fanotify_user.c
54677 +++ b/fs/notify/fanotify/fanotify_user.c
54678 @@ -122,6 +122,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54679 metadata->event_len = FAN_EVENT_METADATA_LEN;
54680 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54681 metadata->vers = FANOTIFY_METADATA_VERSION;
54682 + metadata->reserved = 0;
54683 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54684 metadata->pid = pid_vnr(event->tgid);
54685 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54686 @@ -252,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54687
54688 fd = fanotify_event_metadata.fd;
54689 ret = -EFAULT;
54690 - if (copy_to_user(buf, &fanotify_event_metadata,
54691 - fanotify_event_metadata.event_len))
54692 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54693 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54694 goto out_close_fd;
54695
54696 ret = prepare_for_access_response(group, event, fd);
54697 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54698 index 7b51b05..5ea5ef6 100644
54699 --- a/fs/notify/notification.c
54700 +++ b/fs/notify/notification.c
54701 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54702 * get set to 0 so it will never get 'freed'
54703 */
54704 static struct fsnotify_event *q_overflow_event;
54705 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54706 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54707
54708 /**
54709 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54710 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54711 */
54712 u32 fsnotify_get_cookie(void)
54713 {
54714 - return atomic_inc_return(&fsnotify_sync_cookie);
54715 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54716 }
54717 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54718
54719 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54720 index aa411c3..c260a84 100644
54721 --- a/fs/ntfs/dir.c
54722 +++ b/fs/ntfs/dir.c
54723 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54724 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54725 ~(s64)(ndir->itype.index.block_size - 1)));
54726 /* Bounds checks. */
54727 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54728 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54729 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54730 "inode 0x%lx or driver bug.", vdir->i_ino);
54731 goto err_out;
54732 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54733 index c5670b8..01a3656 100644
54734 --- a/fs/ntfs/file.c
54735 +++ b/fs/ntfs/file.c
54736 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54737 #endif /* NTFS_RW */
54738 };
54739
54740 -const struct file_operations ntfs_empty_file_ops = {};
54741 +const struct file_operations ntfs_empty_file_ops __read_only;
54742
54743 -const struct inode_operations ntfs_empty_inode_ops = {};
54744 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54745 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54746 index aebeacd..0dcdd26 100644
54747 --- a/fs/ocfs2/localalloc.c
54748 +++ b/fs/ocfs2/localalloc.c
54749 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54750 goto bail;
54751 }
54752
54753 - atomic_inc(&osb->alloc_stats.moves);
54754 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54755
54756 bail:
54757 if (handle)
54758 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54759 index d355e6e..578d905 100644
54760 --- a/fs/ocfs2/ocfs2.h
54761 +++ b/fs/ocfs2/ocfs2.h
54762 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54763
54764 struct ocfs2_alloc_stats
54765 {
54766 - atomic_t moves;
54767 - atomic_t local_data;
54768 - atomic_t bitmap_data;
54769 - atomic_t bg_allocs;
54770 - atomic_t bg_extends;
54771 + atomic_unchecked_t moves;
54772 + atomic_unchecked_t local_data;
54773 + atomic_unchecked_t bitmap_data;
54774 + atomic_unchecked_t bg_allocs;
54775 + atomic_unchecked_t bg_extends;
54776 };
54777
54778 enum ocfs2_local_alloc_state
54779 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54780 index b7e74b5..19c6536 100644
54781 --- a/fs/ocfs2/suballoc.c
54782 +++ b/fs/ocfs2/suballoc.c
54783 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54784 mlog_errno(status);
54785 goto bail;
54786 }
54787 - atomic_inc(&osb->alloc_stats.bg_extends);
54788 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54789
54790 /* You should never ask for this much metadata */
54791 BUG_ON(bits_wanted >
54792 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54793 mlog_errno(status);
54794 goto bail;
54795 }
54796 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54797 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54798
54799 *suballoc_loc = res.sr_bg_blkno;
54800 *suballoc_bit_start = res.sr_bit_offset;
54801 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54802 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54803 res->sr_bits);
54804
54805 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54806 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54807
54808 BUG_ON(res->sr_bits != 1);
54809
54810 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54811 mlog_errno(status);
54812 goto bail;
54813 }
54814 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54815 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54816
54817 BUG_ON(res.sr_bits != 1);
54818
54819 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54820 cluster_start,
54821 num_clusters);
54822 if (!status)
54823 - atomic_inc(&osb->alloc_stats.local_data);
54824 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54825 } else {
54826 if (min_clusters > (osb->bitmap_cpg - 1)) {
54827 /* The only paths asking for contiguousness
54828 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54829 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54830 res.sr_bg_blkno,
54831 res.sr_bit_offset);
54832 - atomic_inc(&osb->alloc_stats.bitmap_data);
54833 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54834 *num_clusters = res.sr_bits;
54835 }
54836 }
54837 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54838 index 01b8516..579c4df 100644
54839 --- a/fs/ocfs2/super.c
54840 +++ b/fs/ocfs2/super.c
54841 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54842 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54843 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54844 "Stats",
54845 - atomic_read(&osb->alloc_stats.bitmap_data),
54846 - atomic_read(&osb->alloc_stats.local_data),
54847 - atomic_read(&osb->alloc_stats.bg_allocs),
54848 - atomic_read(&osb->alloc_stats.moves),
54849 - atomic_read(&osb->alloc_stats.bg_extends));
54850 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54851 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54852 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54853 + atomic_read_unchecked(&osb->alloc_stats.moves),
54854 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54855
54856 out += snprintf(buf + out, len - out,
54857 "%10s => State: %u Descriptor: %llu Size: %u bits "
54858 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54859 spin_lock_init(&osb->osb_xattr_lock);
54860 ocfs2_init_steal_slots(osb);
54861
54862 - atomic_set(&osb->alloc_stats.moves, 0);
54863 - atomic_set(&osb->alloc_stats.local_data, 0);
54864 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54865 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54866 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54867 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54868 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54869 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54870 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54871 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54872
54873 /* Copy the blockcheck stats from the superblock probe */
54874 osb->osb_ecc_stats = *stats;
54875 diff --git a/fs/open.c b/fs/open.c
54876 index 8c74100..4239c48 100644
54877 --- a/fs/open.c
54878 +++ b/fs/open.c
54879 @@ -32,6 +32,8 @@
54880 #include <linux/dnotify.h>
54881 #include <linux/compat.h>
54882
54883 +#define CREATE_TRACE_POINTS
54884 +#include <trace/events/fs.h>
54885 #include "internal.h"
54886
54887 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54888 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54889 error = locks_verify_truncate(inode, NULL, length);
54890 if (!error)
54891 error = security_path_truncate(path);
54892 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54893 + error = -EACCES;
54894 if (!error)
54895 error = do_truncate(path->dentry, length, 0, NULL);
54896
54897 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54898 error = locks_verify_truncate(inode, f.file, length);
54899 if (!error)
54900 error = security_path_truncate(&f.file->f_path);
54901 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54902 + error = -EACCES;
54903 if (!error)
54904 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54905 sb_end_write(inode->i_sb);
54906 @@ -360,6 +366,9 @@ retry:
54907 if (__mnt_is_readonly(path.mnt))
54908 res = -EROFS;
54909
54910 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54911 + res = -EACCES;
54912 +
54913 out_path_release:
54914 path_put(&path);
54915 if (retry_estale(res, lookup_flags)) {
54916 @@ -391,6 +400,8 @@ retry:
54917 if (error)
54918 goto dput_and_out;
54919
54920 + gr_log_chdir(path.dentry, path.mnt);
54921 +
54922 set_fs_pwd(current->fs, &path);
54923
54924 dput_and_out:
54925 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54926 goto out_putf;
54927
54928 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54929 +
54930 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54931 + error = -EPERM;
54932 +
54933 + if (!error)
54934 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54935 +
54936 if (!error)
54937 set_fs_pwd(current->fs, &f.file->f_path);
54938 out_putf:
54939 @@ -449,7 +467,13 @@ retry:
54940 if (error)
54941 goto dput_and_out;
54942
54943 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54944 + goto dput_and_out;
54945 +
54946 set_fs_root(current->fs, &path);
54947 +
54948 + gr_handle_chroot_chdir(&path);
54949 +
54950 error = 0;
54951 dput_and_out:
54952 path_put(&path);
54953 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
54954 if (error)
54955 return error;
54956 mutex_lock(&inode->i_mutex);
54957 +
54958 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54959 + error = -EACCES;
54960 + goto out_unlock;
54961 + }
54962 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54963 + error = -EACCES;
54964 + goto out_unlock;
54965 + }
54966 +
54967 error = security_path_chmod(path, mode);
54968 if (error)
54969 goto out_unlock;
54970 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54971 uid = make_kuid(current_user_ns(), user);
54972 gid = make_kgid(current_user_ns(), group);
54973
54974 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54975 + return -EACCES;
54976 +
54977 newattrs.ia_valid = ATTR_CTIME;
54978 if (user != (uid_t) -1) {
54979 if (!uid_valid(uid))
54980 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54981 } else {
54982 fsnotify_open(f);
54983 fd_install(fd, f);
54984 + trace_do_sys_open(tmp->name, flags, mode);
54985 }
54986 }
54987 putname(tmp);
54988 diff --git a/fs/pipe.c b/fs/pipe.c
54989 index d2c45e1..009fe1c 100644
54990 --- a/fs/pipe.c
54991 +++ b/fs/pipe.c
54992 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
54993
54994 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
54995 {
54996 - if (pipe->files)
54997 + if (atomic_read(&pipe->files))
54998 mutex_lock_nested(&pipe->mutex, subclass);
54999 }
55000
55001 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
55002
55003 void pipe_unlock(struct pipe_inode_info *pipe)
55004 {
55005 - if (pipe->files)
55006 + if (atomic_read(&pipe->files))
55007 mutex_unlock(&pipe->mutex);
55008 }
55009 EXPORT_SYMBOL(pipe_unlock);
55010 @@ -449,9 +449,9 @@ redo:
55011 }
55012 if (bufs) /* More to do? */
55013 continue;
55014 - if (!pipe->writers)
55015 + if (!atomic_read(&pipe->writers))
55016 break;
55017 - if (!pipe->waiting_writers) {
55018 + if (!atomic_read(&pipe->waiting_writers)) {
55019 /* syscall merging: Usually we must not sleep
55020 * if O_NONBLOCK is set, or if we got some data.
55021 * But if a writer sleeps in kernel space, then
55022 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
55023 ret = 0;
55024 __pipe_lock(pipe);
55025
55026 - if (!pipe->readers) {
55027 + if (!atomic_read(&pipe->readers)) {
55028 send_sig(SIGPIPE, current, 0);
55029 ret = -EPIPE;
55030 goto out;
55031 @@ -562,7 +562,7 @@ redo1:
55032 for (;;) {
55033 int bufs;
55034
55035 - if (!pipe->readers) {
55036 + if (!atomic_read(&pipe->readers)) {
55037 send_sig(SIGPIPE, current, 0);
55038 if (!ret)
55039 ret = -EPIPE;
55040 @@ -653,9 +653,9 @@ redo2:
55041 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55042 do_wakeup = 0;
55043 }
55044 - pipe->waiting_writers++;
55045 + atomic_inc(&pipe->waiting_writers);
55046 pipe_wait(pipe);
55047 - pipe->waiting_writers--;
55048 + atomic_dec(&pipe->waiting_writers);
55049 }
55050 out:
55051 __pipe_unlock(pipe);
55052 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
55053 mask = 0;
55054 if (filp->f_mode & FMODE_READ) {
55055 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
55056 - if (!pipe->writers && filp->f_version != pipe->w_counter)
55057 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
55058 mask |= POLLHUP;
55059 }
55060
55061 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
55062 * Most Unices do not set POLLERR for FIFOs but on Linux they
55063 * behave exactly like pipes for poll().
55064 */
55065 - if (!pipe->readers)
55066 + if (!atomic_read(&pipe->readers))
55067 mask |= POLLERR;
55068 }
55069
55070 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
55071
55072 __pipe_lock(pipe);
55073 if (file->f_mode & FMODE_READ)
55074 - pipe->readers--;
55075 + atomic_dec(&pipe->readers);
55076 if (file->f_mode & FMODE_WRITE)
55077 - pipe->writers--;
55078 + atomic_dec(&pipe->writers);
55079
55080 - if (pipe->readers || pipe->writers) {
55081 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
55082 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
55083 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55084 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
55085 }
55086 spin_lock(&inode->i_lock);
55087 - if (!--pipe->files) {
55088 + if (atomic_dec_and_test(&pipe->files)) {
55089 inode->i_pipe = NULL;
55090 kill = 1;
55091 }
55092 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
55093 kfree(pipe);
55094 }
55095
55096 -static struct vfsmount *pipe_mnt __read_mostly;
55097 +struct vfsmount *pipe_mnt __read_mostly;
55098
55099 /*
55100 * pipefs_dname() is called from d_path().
55101 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
55102 goto fail_iput;
55103
55104 inode->i_pipe = pipe;
55105 - pipe->files = 2;
55106 - pipe->readers = pipe->writers = 1;
55107 + atomic_set(&pipe->files, 2);
55108 + atomic_set(&pipe->readers, 1);
55109 + atomic_set(&pipe->writers, 1);
55110 inode->i_fop = &pipefifo_fops;
55111
55112 /*
55113 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
55114 spin_lock(&inode->i_lock);
55115 if (inode->i_pipe) {
55116 pipe = inode->i_pipe;
55117 - pipe->files++;
55118 + atomic_inc(&pipe->files);
55119 spin_unlock(&inode->i_lock);
55120 } else {
55121 spin_unlock(&inode->i_lock);
55122 pipe = alloc_pipe_info();
55123 if (!pipe)
55124 return -ENOMEM;
55125 - pipe->files = 1;
55126 + atomic_set(&pipe->files, 1);
55127 spin_lock(&inode->i_lock);
55128 if (unlikely(inode->i_pipe)) {
55129 - inode->i_pipe->files++;
55130 + atomic_inc(&inode->i_pipe->files);
55131 spin_unlock(&inode->i_lock);
55132 free_pipe_info(pipe);
55133 pipe = inode->i_pipe;
55134 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
55135 * opened, even when there is no process writing the FIFO.
55136 */
55137 pipe->r_counter++;
55138 - if (pipe->readers++ == 0)
55139 + if (atomic_inc_return(&pipe->readers) == 1)
55140 wake_up_partner(pipe);
55141
55142 - if (!is_pipe && !pipe->writers) {
55143 + if (!is_pipe && !atomic_read(&pipe->writers)) {
55144 if ((filp->f_flags & O_NONBLOCK)) {
55145 /* suppress POLLHUP until we have
55146 * seen a writer */
55147 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
55148 * errno=ENXIO when there is no process reading the FIFO.
55149 */
55150 ret = -ENXIO;
55151 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
55152 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
55153 goto err;
55154
55155 pipe->w_counter++;
55156 - if (!pipe->writers++)
55157 + if (atomic_inc_return(&pipe->writers) == 1)
55158 wake_up_partner(pipe);
55159
55160 - if (!is_pipe && !pipe->readers) {
55161 + if (!is_pipe && !atomic_read(&pipe->readers)) {
55162 if (wait_for_partner(pipe, &pipe->r_counter))
55163 goto err_wr;
55164 }
55165 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
55166 * the process can at least talk to itself.
55167 */
55168
55169 - pipe->readers++;
55170 - pipe->writers++;
55171 + atomic_inc(&pipe->readers);
55172 + atomic_inc(&pipe->writers);
55173 pipe->r_counter++;
55174 pipe->w_counter++;
55175 - if (pipe->readers == 1 || pipe->writers == 1)
55176 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
55177 wake_up_partner(pipe);
55178 break;
55179
55180 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
55181 return 0;
55182
55183 err_rd:
55184 - if (!--pipe->readers)
55185 + if (atomic_dec_and_test(&pipe->readers))
55186 wake_up_interruptible(&pipe->wait);
55187 ret = -ERESTARTSYS;
55188 goto err;
55189
55190 err_wr:
55191 - if (!--pipe->writers)
55192 + if (atomic_dec_and_test(&pipe->writers))
55193 wake_up_interruptible(&pipe->wait);
55194 ret = -ERESTARTSYS;
55195 goto err;
55196
55197 err:
55198 spin_lock(&inode->i_lock);
55199 - if (!--pipe->files) {
55200 + if (atomic_dec_and_test(&pipe->files)) {
55201 inode->i_pipe = NULL;
55202 kill = 1;
55203 }
55204 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55205 index 15af622..0e9f4467 100644
55206 --- a/fs/proc/Kconfig
55207 +++ b/fs/proc/Kconfig
55208 @@ -30,12 +30,12 @@ config PROC_FS
55209
55210 config PROC_KCORE
55211 bool "/proc/kcore support" if !ARM
55212 - depends on PROC_FS && MMU
55213 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55214
55215 config PROC_VMCORE
55216 bool "/proc/vmcore support"
55217 - depends on PROC_FS && CRASH_DUMP
55218 - default y
55219 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55220 + default n
55221 help
55222 Exports the dump image of crashed kernel in ELF format.
55223
55224 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55225 limited in memory.
55226
55227 config PROC_PAGE_MONITOR
55228 - default y
55229 - depends on PROC_FS && MMU
55230 + default n
55231 + depends on PROC_FS && MMU && !GRKERNSEC
55232 bool "Enable /proc page monitoring" if EXPERT
55233 help
55234 Various /proc files exist to monitor process memory utilization:
55235 diff --git a/fs/proc/array.c b/fs/proc/array.c
55236 index cbd0f1b..adec3f0 100644
55237 --- a/fs/proc/array.c
55238 +++ b/fs/proc/array.c
55239 @@ -60,6 +60,7 @@
55240 #include <linux/tty.h>
55241 #include <linux/string.h>
55242 #include <linux/mman.h>
55243 +#include <linux/grsecurity.h>
55244 #include <linux/proc_fs.h>
55245 #include <linux/ioport.h>
55246 #include <linux/uaccess.h>
55247 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55248 seq_putc(m, '\n');
55249 }
55250
55251 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55252 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55253 +{
55254 + if (p->mm)
55255 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55256 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55257 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55258 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55259 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55260 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55261 + else
55262 + seq_printf(m, "PaX:\t-----\n");
55263 +}
55264 +#endif
55265 +
55266 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55267 struct pid *pid, struct task_struct *task)
55268 {
55269 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55270 task_cpus_allowed(m, task);
55271 cpuset_task_status_allowed(m, task);
55272 task_context_switch_counts(m, task);
55273 +
55274 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55275 + task_pax(m, task);
55276 +#endif
55277 +
55278 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55279 + task_grsec_rbac(m, task);
55280 +#endif
55281 +
55282 return 0;
55283 }
55284
55285 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55286 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55287 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55288 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55289 +#endif
55290 +
55291 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55292 struct pid *pid, struct task_struct *task, int whole)
55293 {
55294 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55295 char tcomm[sizeof(task->comm)];
55296 unsigned long flags;
55297
55298 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55299 + if (current->exec_id != m->exec_id) {
55300 + gr_log_badprocpid("stat");
55301 + return 0;
55302 + }
55303 +#endif
55304 +
55305 state = *get_task_state(task);
55306 vsize = eip = esp = 0;
55307 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55308 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55309 gtime = task_gtime(task);
55310 }
55311
55312 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55313 + if (PAX_RAND_FLAGS(mm)) {
55314 + eip = 0;
55315 + esp = 0;
55316 + wchan = 0;
55317 + }
55318 +#endif
55319 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55320 + wchan = 0;
55321 + eip =0;
55322 + esp =0;
55323 +#endif
55324 +
55325 /* scale priority and nice values from timeslices to -20..20 */
55326 /* to make it look like a "normal" Unix priority/nice value */
55327 priority = task_prio(task);
55328 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55329 seq_put_decimal_ull(m, ' ', vsize);
55330 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55331 seq_put_decimal_ull(m, ' ', rsslim);
55332 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55333 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55334 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55335 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55336 +#else
55337 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55338 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55339 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55340 +#endif
55341 seq_put_decimal_ull(m, ' ', esp);
55342 seq_put_decimal_ull(m, ' ', eip);
55343 /* The signal information here is obsolete.
55344 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55345 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55346 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55347
55348 - if (mm && permitted) {
55349 + if (mm && permitted
55350 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55351 + && !PAX_RAND_FLAGS(mm)
55352 +#endif
55353 + ) {
55354 seq_put_decimal_ull(m, ' ', mm->start_data);
55355 seq_put_decimal_ull(m, ' ', mm->end_data);
55356 seq_put_decimal_ull(m, ' ', mm->start_brk);
55357 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55358 struct pid *pid, struct task_struct *task)
55359 {
55360 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55361 - struct mm_struct *mm = get_task_mm(task);
55362 + struct mm_struct *mm;
55363
55364 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55365 + if (current->exec_id != m->exec_id) {
55366 + gr_log_badprocpid("statm");
55367 + return 0;
55368 + }
55369 +#endif
55370 + mm = get_task_mm(task);
55371 if (mm) {
55372 size = task_statm(mm, &shared, &text, &data, &resident);
55373 mmput(mm);
55374 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55375 return 0;
55376 }
55377
55378 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55379 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55380 +{
55381 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55382 +}
55383 +#endif
55384 +
55385 #ifdef CONFIG_CHECKPOINT_RESTORE
55386 static struct pid *
55387 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55388 diff --git a/fs/proc/base.c b/fs/proc/base.c
55389 index c3834da..b402b2b 100644
55390 --- a/fs/proc/base.c
55391 +++ b/fs/proc/base.c
55392 @@ -113,6 +113,14 @@ struct pid_entry {
55393 union proc_op op;
55394 };
55395
55396 +struct getdents_callback {
55397 + struct linux_dirent __user * current_dir;
55398 + struct linux_dirent __user * previous;
55399 + struct file * file;
55400 + int count;
55401 + int error;
55402 +};
55403 +
55404 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55405 .name = (NAME), \
55406 .len = sizeof(NAME) - 1, \
55407 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55408 if (!mm->arg_end)
55409 goto out_mm; /* Shh! No looking before we're done */
55410
55411 + if (gr_acl_handle_procpidmem(task))
55412 + goto out_mm;
55413 +
55414 len = mm->arg_end - mm->arg_start;
55415
55416 if (len > PAGE_SIZE)
55417 @@ -237,12 +248,28 @@ out:
55418 return res;
55419 }
55420
55421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55422 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55423 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55424 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55425 +#endif
55426 +
55427 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55428 {
55429 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55430 int res = PTR_ERR(mm);
55431 if (mm && !IS_ERR(mm)) {
55432 unsigned int nwords = 0;
55433 +
55434 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55435 + /* allow if we're currently ptracing this task */
55436 + if (PAX_RAND_FLAGS(mm) &&
55437 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55438 + mmput(mm);
55439 + return 0;
55440 + }
55441 +#endif
55442 +
55443 do {
55444 nwords += 2;
55445 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55446 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55447 }
55448
55449
55450 -#ifdef CONFIG_KALLSYMS
55451 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55452 /*
55453 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55454 * Returns the resolved symbol. If that fails, simply return the address.
55455 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
55456 mutex_unlock(&task->signal->cred_guard_mutex);
55457 }
55458
55459 -#ifdef CONFIG_STACKTRACE
55460 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55461
55462 #define MAX_STACK_TRACE_DEPTH 64
55463
55464 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55465 return count;
55466 }
55467
55468 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55469 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55470 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55471 {
55472 long nr;
55473 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55474 /************************************************************************/
55475
55476 /* permission checks */
55477 -static int proc_fd_access_allowed(struct inode *inode)
55478 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55479 {
55480 struct task_struct *task;
55481 int allowed = 0;
55482 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55483 */
55484 task = get_proc_task(inode);
55485 if (task) {
55486 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55487 + if (log)
55488 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55489 + else
55490 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55491 put_task_struct(task);
55492 }
55493 return allowed;
55494 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55495 struct task_struct *task,
55496 int hide_pid_min)
55497 {
55498 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55499 + return false;
55500 +
55501 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55502 + rcu_read_lock();
55503 + {
55504 + const struct cred *tmpcred = current_cred();
55505 + const struct cred *cred = __task_cred(task);
55506 +
55507 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55508 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55509 + || in_group_p(grsec_proc_gid)
55510 +#endif
55511 + ) {
55512 + rcu_read_unlock();
55513 + return true;
55514 + }
55515 + }
55516 + rcu_read_unlock();
55517 +
55518 + if (!pid->hide_pid)
55519 + return false;
55520 +#endif
55521 +
55522 if (pid->hide_pid < hide_pid_min)
55523 return true;
55524 if (in_group_p(pid->pid_gid))
55525 return true;
55526 +
55527 return ptrace_may_access(task, PTRACE_MODE_READ);
55528 }
55529
55530 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55531 put_task_struct(task);
55532
55533 if (!has_perms) {
55534 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55535 + {
55536 +#else
55537 if (pid->hide_pid == 2) {
55538 +#endif
55539 /*
55540 * Let's make getdents(), stat(), and open()
55541 * consistent with each other. If a process
55542 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55543 if (!task)
55544 return -ESRCH;
55545
55546 + if (gr_acl_handle_procpidmem(task)) {
55547 + put_task_struct(task);
55548 + return -EPERM;
55549 + }
55550 +
55551 mm = mm_access(task, mode);
55552 put_task_struct(task);
55553
55554 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55555
55556 file->private_data = mm;
55557
55558 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55559 + file->f_version = current->exec_id;
55560 +#endif
55561 +
55562 return 0;
55563 }
55564
55565 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55566 ssize_t copied;
55567 char *page;
55568
55569 +#ifdef CONFIG_GRKERNSEC
55570 + if (write)
55571 + return -EPERM;
55572 +#endif
55573 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55574 + if (file->f_version != current->exec_id) {
55575 + gr_log_badprocpid("mem");
55576 + return 0;
55577 + }
55578 +#endif
55579 +
55580 if (!mm)
55581 return 0;
55582
55583 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55584 goto free;
55585
55586 while (count > 0) {
55587 - int this_len = min_t(int, count, PAGE_SIZE);
55588 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55589
55590 if (write && copy_from_user(page, buf, this_len)) {
55591 copied = -EFAULT;
55592 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55593 if (!mm)
55594 return 0;
55595
55596 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55597 + if (file->f_version != current->exec_id) {
55598 + gr_log_badprocpid("environ");
55599 + return 0;
55600 + }
55601 +#endif
55602 +
55603 page = (char *)__get_free_page(GFP_TEMPORARY);
55604 if (!page)
55605 return -ENOMEM;
55606 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55607 goto free;
55608 while (count > 0) {
55609 size_t this_len, max_len;
55610 - int retval;
55611 + ssize_t retval;
55612
55613 if (src >= (mm->env_end - mm->env_start))
55614 break;
55615 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55616 int error = -EACCES;
55617
55618 /* Are we allowed to snoop on the tasks file descriptors? */
55619 - if (!proc_fd_access_allowed(inode))
55620 + if (!proc_fd_access_allowed(inode, 0))
55621 goto out;
55622
55623 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55624 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55625 struct path path;
55626
55627 /* Are we allowed to snoop on the tasks file descriptors? */
55628 - if (!proc_fd_access_allowed(inode))
55629 - goto out;
55630 + /* logging this is needed for learning on chromium to work properly,
55631 + but we don't want to flood the logs from 'ps' which does a readlink
55632 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55633 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55634 + */
55635 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55636 + if (!proc_fd_access_allowed(inode,0))
55637 + goto out;
55638 + } else {
55639 + if (!proc_fd_access_allowed(inode,1))
55640 + goto out;
55641 + }
55642
55643 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55644 if (error)
55645 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55646 rcu_read_lock();
55647 cred = __task_cred(task);
55648 inode->i_uid = cred->euid;
55649 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55650 + inode->i_gid = grsec_proc_gid;
55651 +#else
55652 inode->i_gid = cred->egid;
55653 +#endif
55654 rcu_read_unlock();
55655 }
55656 security_task_to_inode(task, inode);
55657 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55658 return -ENOENT;
55659 }
55660 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55661 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55662 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55663 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55664 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55665 +#endif
55666 task_dumpable(task)) {
55667 cred = __task_cred(task);
55668 stat->uid = cred->euid;
55669 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55670 + stat->gid = grsec_proc_gid;
55671 +#else
55672 stat->gid = cred->egid;
55673 +#endif
55674 }
55675 }
55676 rcu_read_unlock();
55677 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55678
55679 if (task) {
55680 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55681 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55682 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55683 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55684 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55685 +#endif
55686 task_dumpable(task)) {
55687 rcu_read_lock();
55688 cred = __task_cred(task);
55689 inode->i_uid = cred->euid;
55690 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55691 + inode->i_gid = grsec_proc_gid;
55692 +#else
55693 inode->i_gid = cred->egid;
55694 +#endif
55695 rcu_read_unlock();
55696 } else {
55697 inode->i_uid = GLOBAL_ROOT_UID;
55698 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55699 if (!task)
55700 goto out_no_task;
55701
55702 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55703 + goto out;
55704 +
55705 /*
55706 * Yes, it does not scale. And it should not. Don't add
55707 * new entries into /proc/<tgid>/ without very good reasons.
55708 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
55709 if (!task)
55710 goto out_no_task;
55711
55712 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55713 + goto out;
55714 +
55715 ret = 0;
55716 i = filp->f_pos;
55717 switch (i) {
55718 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55719 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55720 #endif
55721 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55722 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55723 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55724 INF("syscall", S_IRUGO, proc_pid_syscall),
55725 #endif
55726 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55727 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55728 #ifdef CONFIG_SECURITY
55729 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55730 #endif
55731 -#ifdef CONFIG_KALLSYMS
55732 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55733 INF("wchan", S_IRUGO, proc_pid_wchan),
55734 #endif
55735 -#ifdef CONFIG_STACKTRACE
55736 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55737 ONE("stack", S_IRUGO, proc_pid_stack),
55738 #endif
55739 #ifdef CONFIG_SCHEDSTATS
55740 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55741 #ifdef CONFIG_HARDWALL
55742 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55743 #endif
55744 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55745 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55746 +#endif
55747 #ifdef CONFIG_USER_NS
55748 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55749 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55750 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55751 if (!inode)
55752 goto out;
55753
55754 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55755 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55756 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55757 + inode->i_gid = grsec_proc_gid;
55758 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55759 +#else
55760 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55761 +#endif
55762 inode->i_op = &proc_tgid_base_inode_operations;
55763 inode->i_fop = &proc_tgid_base_operations;
55764 inode->i_flags|=S_IMMUTABLE;
55765 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55766 if (!task)
55767 goto out;
55768
55769 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55770 + goto out_put_task;
55771 +
55772 result = proc_pid_instantiate(dir, dentry, task, NULL);
55773 +out_put_task:
55774 put_task_struct(task);
55775 out:
55776 return result;
55777 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55778 static int fake_filldir(void *buf, const char *name, int namelen,
55779 loff_t offset, u64 ino, unsigned d_type)
55780 {
55781 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55782 + __buf->error = -EINVAL;
55783 return 0;
55784 }
55785
55786 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
55787 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55788 #endif
55789 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55790 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55791 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55792 INF("syscall", S_IRUGO, proc_pid_syscall),
55793 #endif
55794 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55795 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
55796 #ifdef CONFIG_SECURITY
55797 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55798 #endif
55799 -#ifdef CONFIG_KALLSYMS
55800 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55801 INF("wchan", S_IRUGO, proc_pid_wchan),
55802 #endif
55803 -#ifdef CONFIG_STACKTRACE
55804 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55805 ONE("stack", S_IRUGO, proc_pid_stack),
55806 #endif
55807 #ifdef CONFIG_SCHEDSTATS
55808 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55809 index 82676e3..5f8518a 100644
55810 --- a/fs/proc/cmdline.c
55811 +++ b/fs/proc/cmdline.c
55812 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55813
55814 static int __init proc_cmdline_init(void)
55815 {
55816 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55817 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55818 +#else
55819 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55820 +#endif
55821 return 0;
55822 }
55823 module_init(proc_cmdline_init);
55824 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55825 index b143471..bb105e5 100644
55826 --- a/fs/proc/devices.c
55827 +++ b/fs/proc/devices.c
55828 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55829
55830 static int __init proc_devices_init(void)
55831 {
55832 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55833 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55834 +#else
55835 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55836 +#endif
55837 return 0;
55838 }
55839 module_init(proc_devices_init);
55840 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55841 index d7a4a28..0201742 100644
55842 --- a/fs/proc/fd.c
55843 +++ b/fs/proc/fd.c
55844 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55845 if (!task)
55846 return -ENOENT;
55847
55848 - files = get_files_struct(task);
55849 + if (!gr_acl_handle_procpidmem(task))
55850 + files = get_files_struct(task);
55851 put_task_struct(task);
55852
55853 if (files) {
55854 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55855 */
55856 int proc_fd_permission(struct inode *inode, int mask)
55857 {
55858 + struct task_struct *task;
55859 int rv = generic_permission(inode, mask);
55860 - if (rv == 0)
55861 - return 0;
55862 +
55863 if (task_pid(current) == proc_pid(inode))
55864 rv = 0;
55865 +
55866 + task = get_proc_task(inode);
55867 + if (task == NULL)
55868 + return rv;
55869 +
55870 + if (gr_acl_handle_procpidmem(task))
55871 + rv = -EACCES;
55872 +
55873 + put_task_struct(task);
55874 +
55875 return rv;
55876 }
55877
55878 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55879 index 073aea6..0630370 100644
55880 --- a/fs/proc/inode.c
55881 +++ b/fs/proc/inode.c
55882 @@ -23,11 +23,17 @@
55883 #include <linux/slab.h>
55884 #include <linux/mount.h>
55885 #include <linux/magic.h>
55886 +#include <linux/grsecurity.h>
55887
55888 #include <asm/uaccess.h>
55889
55890 #include "internal.h"
55891
55892 +#ifdef CONFIG_PROC_SYSCTL
55893 +extern const struct inode_operations proc_sys_inode_operations;
55894 +extern const struct inode_operations proc_sys_dir_operations;
55895 +#endif
55896 +
55897 static void proc_evict_inode(struct inode *inode)
55898 {
55899 struct proc_dir_entry *de;
55900 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
55901 ns = PROC_I(inode)->ns.ns;
55902 if (ns_ops && ns)
55903 ns_ops->put(ns);
55904 +
55905 +#ifdef CONFIG_PROC_SYSCTL
55906 + if (inode->i_op == &proc_sys_inode_operations ||
55907 + inode->i_op == &proc_sys_dir_operations)
55908 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55909 +#endif
55910 +
55911 }
55912
55913 static struct kmem_cache * proc_inode_cachep;
55914 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55915 if (de->mode) {
55916 inode->i_mode = de->mode;
55917 inode->i_uid = de->uid;
55918 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55919 + inode->i_gid = grsec_proc_gid;
55920 +#else
55921 inode->i_gid = de->gid;
55922 +#endif
55923 }
55924 if (de->size)
55925 inode->i_size = de->size;
55926 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55927 index d600fb0..3b495fe 100644
55928 --- a/fs/proc/internal.h
55929 +++ b/fs/proc/internal.h
55930 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
55931 struct pid *, struct task_struct *);
55932 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
55933 struct pid *, struct task_struct *);
55934 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55935 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55936 +#endif
55937
55938 /*
55939 * base.c
55940 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55941 index 0a22194..a9fc8c1 100644
55942 --- a/fs/proc/kcore.c
55943 +++ b/fs/proc/kcore.c
55944 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55945 * the addresses in the elf_phdr on our list.
55946 */
55947 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55948 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55949 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55950 + if (tsz > buflen)
55951 tsz = buflen;
55952 -
55953 +
55954 while (buflen) {
55955 struct kcore_list *m;
55956
55957 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55958 kfree(elf_buf);
55959 } else {
55960 if (kern_addr_valid(start)) {
55961 - unsigned long n;
55962 + char *elf_buf;
55963 + mm_segment_t oldfs;
55964
55965 - n = copy_to_user(buffer, (char *)start, tsz);
55966 - /*
55967 - * We cannot distinguish between fault on source
55968 - * and fault on destination. When this happens
55969 - * we clear too and hope it will trigger the
55970 - * EFAULT again.
55971 - */
55972 - if (n) {
55973 - if (clear_user(buffer + tsz - n,
55974 - n))
55975 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55976 + if (!elf_buf)
55977 + return -ENOMEM;
55978 + oldfs = get_fs();
55979 + set_fs(KERNEL_DS);
55980 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55981 + set_fs(oldfs);
55982 + if (copy_to_user(buffer, elf_buf, tsz)) {
55983 + kfree(elf_buf);
55984 return -EFAULT;
55985 + }
55986 }
55987 + set_fs(oldfs);
55988 + kfree(elf_buf);
55989 } else {
55990 if (clear_user(buffer, tsz))
55991 return -EFAULT;
55992 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55993
55994 static int open_kcore(struct inode *inode, struct file *filp)
55995 {
55996 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55997 + return -EPERM;
55998 +#endif
55999 if (!capable(CAP_SYS_RAWIO))
56000 return -EPERM;
56001 if (kcore_need_update)
56002 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
56003 index 5aa847a..f77c8d4 100644
56004 --- a/fs/proc/meminfo.c
56005 +++ b/fs/proc/meminfo.c
56006 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
56007 vmi.used >> 10,
56008 vmi.largest_chunk >> 10
56009 #ifdef CONFIG_MEMORY_FAILURE
56010 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
56011 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
56012 #endif
56013 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
56014 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
56015 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
56016 index ccfd99b..1b7e255 100644
56017 --- a/fs/proc/nommu.c
56018 +++ b/fs/proc/nommu.c
56019 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
56020 if (len < 1)
56021 len = 1;
56022 seq_printf(m, "%*c", len, ' ');
56023 - seq_path(m, &file->f_path, "");
56024 + seq_path(m, &file->f_path, "\n\\");
56025 }
56026
56027 seq_putc(m, '\n');
56028 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
56029 index 986e832..6e8e859 100644
56030 --- a/fs/proc/proc_net.c
56031 +++ b/fs/proc/proc_net.c
56032 @@ -23,6 +23,7 @@
56033 #include <linux/nsproxy.h>
56034 #include <net/net_namespace.h>
56035 #include <linux/seq_file.h>
56036 +#include <linux/grsecurity.h>
56037
56038 #include "internal.h"
56039
56040 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
56041 struct task_struct *task;
56042 struct nsproxy *ns;
56043 struct net *net = NULL;
56044 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56045 + const struct cred *cred = current_cred();
56046 +#endif
56047 +
56048 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56049 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
56050 + return net;
56051 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56052 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
56053 + return net;
56054 +#endif
56055
56056 rcu_read_lock();
56057 task = pid_task(proc_pid(dir), PIDTYPE_PID);
56058 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
56059 index ac05f33..1e6dc7e 100644
56060 --- a/fs/proc/proc_sysctl.c
56061 +++ b/fs/proc/proc_sysctl.c
56062 @@ -13,11 +13,15 @@
56063 #include <linux/module.h>
56064 #include "internal.h"
56065
56066 +extern int gr_handle_chroot_sysctl(const int op);
56067 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
56068 + const int op);
56069 +
56070 static const struct dentry_operations proc_sys_dentry_operations;
56071 static const struct file_operations proc_sys_file_operations;
56072 -static const struct inode_operations proc_sys_inode_operations;
56073 +const struct inode_operations proc_sys_inode_operations;
56074 static const struct file_operations proc_sys_dir_file_operations;
56075 -static const struct inode_operations proc_sys_dir_operations;
56076 +const struct inode_operations proc_sys_dir_operations;
56077
56078 void proc_sys_poll_notify(struct ctl_table_poll *poll)
56079 {
56080 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
56081
56082 err = NULL;
56083 d_set_d_op(dentry, &proc_sys_dentry_operations);
56084 +
56085 + gr_handle_proc_create(dentry, inode);
56086 +
56087 d_add(dentry, inode);
56088
56089 out:
56090 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56091 struct inode *inode = file_inode(filp);
56092 struct ctl_table_header *head = grab_header(inode);
56093 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
56094 + int op = write ? MAY_WRITE : MAY_READ;
56095 ssize_t error;
56096 size_t res;
56097
56098 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56099 * and won't be until we finish.
56100 */
56101 error = -EPERM;
56102 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
56103 + if (sysctl_perm(head, table, op))
56104 goto out;
56105
56106 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
56107 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56108 if (!table->proc_handler)
56109 goto out;
56110
56111 +#ifdef CONFIG_GRKERNSEC
56112 + error = -EPERM;
56113 + if (gr_handle_chroot_sysctl(op))
56114 + goto out;
56115 + dget(filp->f_path.dentry);
56116 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
56117 + dput(filp->f_path.dentry);
56118 + goto out;
56119 + }
56120 + dput(filp->f_path.dentry);
56121 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
56122 + goto out;
56123 + if (write && !capable(CAP_SYS_ADMIN))
56124 + goto out;
56125 +#endif
56126 +
56127 /* careful: calling conventions are nasty here */
56128 res = count;
56129 error = table->proc_handler(table, write, buf, &res, ppos);
56130 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
56131 return -ENOMEM;
56132 } else {
56133 d_set_d_op(child, &proc_sys_dentry_operations);
56134 +
56135 + gr_handle_proc_create(child, inode);
56136 +
56137 d_add(child, inode);
56138 }
56139 } else {
56140 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
56141 if ((*pos)++ < file->f_pos)
56142 return 0;
56143
56144 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
56145 + return 0;
56146 +
56147 if (unlikely(S_ISLNK(table->mode)))
56148 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
56149 else
56150 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
56151 if (IS_ERR(head))
56152 return PTR_ERR(head);
56153
56154 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
56155 + return -ENOENT;
56156 +
56157 generic_fillattr(inode, stat);
56158 if (table)
56159 stat->mode = (stat->mode & S_IFMT) | table->mode;
56160 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
56161 .llseek = generic_file_llseek,
56162 };
56163
56164 -static const struct inode_operations proc_sys_inode_operations = {
56165 +const struct inode_operations proc_sys_inode_operations = {
56166 .permission = proc_sys_permission,
56167 .setattr = proc_sys_setattr,
56168 .getattr = proc_sys_getattr,
56169 };
56170
56171 -static const struct inode_operations proc_sys_dir_operations = {
56172 +const struct inode_operations proc_sys_dir_operations = {
56173 .lookup = proc_sys_lookup,
56174 .permission = proc_sys_permission,
56175 .setattr = proc_sys_setattr,
56176 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
56177 static struct ctl_dir *new_dir(struct ctl_table_set *set,
56178 const char *name, int namelen)
56179 {
56180 - struct ctl_table *table;
56181 + ctl_table_no_const *table;
56182 struct ctl_dir *new;
56183 struct ctl_node *node;
56184 char *new_name;
56185 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
56186 return NULL;
56187
56188 node = (struct ctl_node *)(new + 1);
56189 - table = (struct ctl_table *)(node + 1);
56190 + table = (ctl_table_no_const *)(node + 1);
56191 new_name = (char *)(table + 2);
56192 memcpy(new_name, name, namelen);
56193 new_name[namelen] = '\0';
56194 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
56195 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
56196 struct ctl_table_root *link_root)
56197 {
56198 - struct ctl_table *link_table, *entry, *link;
56199 + ctl_table_no_const *link_table, *link;
56200 + struct ctl_table *entry;
56201 struct ctl_table_header *links;
56202 struct ctl_node *node;
56203 char *link_name;
56204 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56205 return NULL;
56206
56207 node = (struct ctl_node *)(links + 1);
56208 - link_table = (struct ctl_table *)(node + nr_entries);
56209 + link_table = (ctl_table_no_const *)(node + nr_entries);
56210 link_name = (char *)&link_table[nr_entries + 1];
56211
56212 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56213 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56214 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56215 struct ctl_table *table)
56216 {
56217 - struct ctl_table *ctl_table_arg = NULL;
56218 - struct ctl_table *entry, *files;
56219 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56220 + struct ctl_table *entry;
56221 int nr_files = 0;
56222 int nr_dirs = 0;
56223 int err = -ENOMEM;
56224 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56225 nr_files++;
56226 }
56227
56228 - files = table;
56229 /* If there are mixed files and directories we need a new table */
56230 if (nr_dirs && nr_files) {
56231 - struct ctl_table *new;
56232 + ctl_table_no_const *new;
56233 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56234 GFP_KERNEL);
56235 if (!files)
56236 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56237 /* Register everything except a directory full of subdirectories */
56238 if (nr_files || !nr_dirs) {
56239 struct ctl_table_header *header;
56240 - header = __register_sysctl_table(set, path, files);
56241 + header = __register_sysctl_table(set, path, files ? files : table);
56242 if (!header) {
56243 kfree(ctl_table_arg);
56244 goto out;
56245 diff --git a/fs/proc/root.c b/fs/proc/root.c
56246 index 41a6ea9..23eaa92 100644
56247 --- a/fs/proc/root.c
56248 +++ b/fs/proc/root.c
56249 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
56250 #ifdef CONFIG_PROC_DEVICETREE
56251 proc_device_tree_init();
56252 #endif
56253 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56254 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56255 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56256 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56257 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56258 +#endif
56259 +#else
56260 proc_mkdir("bus", NULL);
56261 +#endif
56262 proc_sys_init();
56263 }
56264
56265 diff --git a/fs/proc/self.c b/fs/proc/self.c
56266 index 6b6a993..807cccc 100644
56267 --- a/fs/proc/self.c
56268 +++ b/fs/proc/self.c
56269 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56270 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56271 void *cookie)
56272 {
56273 - char *s = nd_get_link(nd);
56274 + const char *s = nd_get_link(nd);
56275 if (!IS_ERR(s))
56276 kfree(s);
56277 }
56278 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56279 index 3e636d8..83e3b71 100644
56280 --- a/fs/proc/task_mmu.c
56281 +++ b/fs/proc/task_mmu.c
56282 @@ -11,12 +11,19 @@
56283 #include <linux/rmap.h>
56284 #include <linux/swap.h>
56285 #include <linux/swapops.h>
56286 +#include <linux/grsecurity.h>
56287
56288 #include <asm/elf.h>
56289 #include <asm/uaccess.h>
56290 #include <asm/tlbflush.h>
56291 #include "internal.h"
56292
56293 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56294 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56295 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56296 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56297 +#endif
56298 +
56299 void task_mem(struct seq_file *m, struct mm_struct *mm)
56300 {
56301 unsigned long data, text, lib, swap;
56302 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56303 "VmExe:\t%8lu kB\n"
56304 "VmLib:\t%8lu kB\n"
56305 "VmPTE:\t%8lu kB\n"
56306 - "VmSwap:\t%8lu kB\n",
56307 - hiwater_vm << (PAGE_SHIFT-10),
56308 + "VmSwap:\t%8lu kB\n"
56309 +
56310 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56311 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56312 +#endif
56313 +
56314 + ,hiwater_vm << (PAGE_SHIFT-10),
56315 total_vm << (PAGE_SHIFT-10),
56316 mm->locked_vm << (PAGE_SHIFT-10),
56317 mm->pinned_vm << (PAGE_SHIFT-10),
56318 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56319 data << (PAGE_SHIFT-10),
56320 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56321 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56322 - swap << (PAGE_SHIFT-10));
56323 + swap << (PAGE_SHIFT-10)
56324 +
56325 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56326 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56327 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56328 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56329 +#else
56330 + , mm->context.user_cs_base
56331 + , mm->context.user_cs_limit
56332 +#endif
56333 +#endif
56334 +
56335 + );
56336 }
56337
56338 unsigned long task_vsize(struct mm_struct *mm)
56339 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56340 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56341 }
56342
56343 - /* We don't show the stack guard page in /proc/maps */
56344 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56345 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56346 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56347 +#else
56348 start = vma->vm_start;
56349 - if (stack_guard_page_start(vma, start))
56350 - start += PAGE_SIZE;
56351 end = vma->vm_end;
56352 - if (stack_guard_page_end(vma, end))
56353 - end -= PAGE_SIZE;
56354 +#endif
56355
56356 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56357 start,
56358 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56359 flags & VM_WRITE ? 'w' : '-',
56360 flags & VM_EXEC ? 'x' : '-',
56361 flags & VM_MAYSHARE ? 's' : 'p',
56362 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56363 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56364 +#else
56365 pgoff,
56366 +#endif
56367 MAJOR(dev), MINOR(dev), ino, &len);
56368
56369 /*
56370 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56371 */
56372 if (file) {
56373 pad_len_spaces(m, len);
56374 - seq_path(m, &file->f_path, "\n");
56375 + seq_path(m, &file->f_path, "\n\\");
56376 goto done;
56377 }
56378
56379 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56380 * Thread stack in /proc/PID/task/TID/maps or
56381 * the main process stack.
56382 */
56383 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56384 - vma->vm_end >= mm->start_stack)) {
56385 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56386 + (vma->vm_start <= mm->start_stack &&
56387 + vma->vm_end >= mm->start_stack)) {
56388 name = "[stack]";
56389 } else {
56390 /* Thread stack in /proc/PID/maps */
56391 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56392 struct proc_maps_private *priv = m->private;
56393 struct task_struct *task = priv->task;
56394
56395 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56396 + if (current->exec_id != m->exec_id) {
56397 + gr_log_badprocpid("maps");
56398 + return 0;
56399 + }
56400 +#endif
56401 +
56402 show_map_vma(m, vma, is_pid);
56403
56404 if (m->count < m->size) /* vma is copied successfully */
56405 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56406 .private = &mss,
56407 };
56408
56409 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56410 + if (current->exec_id != m->exec_id) {
56411 + gr_log_badprocpid("smaps");
56412 + return 0;
56413 + }
56414 +#endif
56415 memset(&mss, 0, sizeof mss);
56416 - mss.vma = vma;
56417 - /* mmap_sem is held in m_start */
56418 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56419 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56420 -
56421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56422 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56423 +#endif
56424 + mss.vma = vma;
56425 + /* mmap_sem is held in m_start */
56426 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56427 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56428 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56429 + }
56430 +#endif
56431 show_map_vma(m, vma, is_pid);
56432
56433 seq_printf(m,
56434 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56435 "KernelPageSize: %8lu kB\n"
56436 "MMUPageSize: %8lu kB\n"
56437 "Locked: %8lu kB\n",
56438 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56439 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56440 +#else
56441 (vma->vm_end - vma->vm_start) >> 10,
56442 +#endif
56443 mss.resident >> 10,
56444 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56445 mss.shared_clean >> 10,
56446 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56447 int n;
56448 char buffer[50];
56449
56450 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56451 + if (current->exec_id != m->exec_id) {
56452 + gr_log_badprocpid("numa_maps");
56453 + return 0;
56454 + }
56455 +#endif
56456 +
56457 if (!mm)
56458 return 0;
56459
56460 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56461 mpol_to_str(buffer, sizeof(buffer), pol);
56462 mpol_cond_put(pol);
56463
56464 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56465 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56466 +#else
56467 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56468 +#endif
56469
56470 if (file) {
56471 seq_printf(m, " file=");
56472 - seq_path(m, &file->f_path, "\n\t= ");
56473 + seq_path(m, &file->f_path, "\n\t\\= ");
56474 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56475 seq_printf(m, " heap");
56476 } else {
56477 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56478 index 56123a6..5a2f6ec 100644
56479 --- a/fs/proc/task_nommu.c
56480 +++ b/fs/proc/task_nommu.c
56481 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56482 else
56483 bytes += kobjsize(mm);
56484
56485 - if (current->fs && current->fs->users > 1)
56486 + if (current->fs && atomic_read(&current->fs->users) > 1)
56487 sbytes += kobjsize(current->fs);
56488 else
56489 bytes += kobjsize(current->fs);
56490 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56491
56492 if (file) {
56493 pad_len_spaces(m, len);
56494 - seq_path(m, &file->f_path, "");
56495 + seq_path(m, &file->f_path, "\n\\");
56496 } else if (mm) {
56497 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56498
56499 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56500 index 17f7e08..e4b1529 100644
56501 --- a/fs/proc/vmcore.c
56502 +++ b/fs/proc/vmcore.c
56503 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56504 nr_bytes = count;
56505
56506 /* If pfn is not ram, return zeros for sparse dump files */
56507 - if (pfn_is_ram(pfn) == 0)
56508 - memset(buf, 0, nr_bytes);
56509 - else {
56510 + if (pfn_is_ram(pfn) == 0) {
56511 + if (userbuf) {
56512 + if (clear_user((char __force_user *)buf, nr_bytes))
56513 + return -EFAULT;
56514 + } else
56515 + memset(buf, 0, nr_bytes);
56516 + } else {
56517 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56518 offset, userbuf);
56519 if (tmp < 0)
56520 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56521 if (tsz > nr_bytes)
56522 tsz = nr_bytes;
56523
56524 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56525 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56526 if (tmp < 0)
56527 return tmp;
56528 buflen -= tsz;
56529 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56530 index b00fcc9..e0c6381 100644
56531 --- a/fs/qnx6/qnx6.h
56532 +++ b/fs/qnx6/qnx6.h
56533 @@ -74,7 +74,7 @@ enum {
56534 BYTESEX_BE,
56535 };
56536
56537 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56538 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56539 {
56540 if (sbi->s_bytesex == BYTESEX_LE)
56541 return le64_to_cpu((__force __le64)n);
56542 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56543 return (__force __fs64)cpu_to_be64(n);
56544 }
56545
56546 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56547 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56548 {
56549 if (sbi->s_bytesex == BYTESEX_LE)
56550 return le32_to_cpu((__force __le32)n);
56551 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56552 index 16e8abb..2dcf914 100644
56553 --- a/fs/quota/netlink.c
56554 +++ b/fs/quota/netlink.c
56555 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56556 void quota_send_warning(struct kqid qid, dev_t dev,
56557 const char warntype)
56558 {
56559 - static atomic_t seq;
56560 + static atomic_unchecked_t seq;
56561 struct sk_buff *skb;
56562 void *msg_head;
56563 int ret;
56564 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56565 "VFS: Not enough memory to send quota warning.\n");
56566 return;
56567 }
56568 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56569 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56570 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56571 if (!msg_head) {
56572 printk(KERN_ERR
56573 diff --git a/fs/read_write.c b/fs/read_write.c
56574 index 2cefa41..c7e2fe0 100644
56575 --- a/fs/read_write.c
56576 +++ b/fs/read_write.c
56577 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56578
56579 old_fs = get_fs();
56580 set_fs(get_ds());
56581 - p = (__force const char __user *)buf;
56582 + p = (const char __force_user *)buf;
56583 if (count > MAX_RW_COUNT)
56584 count = MAX_RW_COUNT;
56585 if (file->f_op->write)
56586 diff --git a/fs/readdir.c b/fs/readdir.c
56587 index fee38e0..12fdf47 100644
56588 --- a/fs/readdir.c
56589 +++ b/fs/readdir.c
56590 @@ -17,6 +17,7 @@
56591 #include <linux/security.h>
56592 #include <linux/syscalls.h>
56593 #include <linux/unistd.h>
56594 +#include <linux/namei.h>
56595
56596 #include <asm/uaccess.h>
56597
56598 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56599
56600 struct readdir_callback {
56601 struct old_linux_dirent __user * dirent;
56602 + struct file * file;
56603 int result;
56604 };
56605
56606 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56607 buf->result = -EOVERFLOW;
56608 return -EOVERFLOW;
56609 }
56610 +
56611 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56612 + return 0;
56613 +
56614 buf->result++;
56615 dirent = buf->dirent;
56616 if (!access_ok(VERIFY_WRITE, dirent,
56617 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56618
56619 buf.result = 0;
56620 buf.dirent = dirent;
56621 + buf.file = f.file;
56622
56623 error = vfs_readdir(f.file, fillonedir, &buf);
56624 if (buf.result)
56625 @@ -139,6 +146,7 @@ struct linux_dirent {
56626 struct getdents_callback {
56627 struct linux_dirent __user * current_dir;
56628 struct linux_dirent __user * previous;
56629 + struct file * file;
56630 int count;
56631 int error;
56632 };
56633 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56634 buf->error = -EOVERFLOW;
56635 return -EOVERFLOW;
56636 }
56637 +
56638 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56639 + return 0;
56640 +
56641 dirent = buf->previous;
56642 if (dirent) {
56643 if (__put_user(offset, &dirent->d_off))
56644 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56645 buf.previous = NULL;
56646 buf.count = count;
56647 buf.error = 0;
56648 + buf.file = f.file;
56649
56650 error = vfs_readdir(f.file, filldir, &buf);
56651 if (error >= 0)
56652 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56653 struct getdents_callback64 {
56654 struct linux_dirent64 __user * current_dir;
56655 struct linux_dirent64 __user * previous;
56656 + struct file *file;
56657 int count;
56658 int error;
56659 };
56660 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56661 buf->error = -EINVAL; /* only used if we fail.. */
56662 if (reclen > buf->count)
56663 return -EINVAL;
56664 +
56665 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56666 + return 0;
56667 +
56668 dirent = buf->previous;
56669 if (dirent) {
56670 if (__put_user(offset, &dirent->d_off))
56671 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56672
56673 buf.current_dir = dirent;
56674 buf.previous = NULL;
56675 + buf.file = f.file;
56676 buf.count = count;
56677 buf.error = 0;
56678
56679 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56680 error = buf.error;
56681 lastdirent = buf.previous;
56682 if (lastdirent) {
56683 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56684 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56685 if (__put_user(d_off, &lastdirent->d_off))
56686 error = -EFAULT;
56687 else
56688 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56689 index 2b7882b..1c5ef48 100644
56690 --- a/fs/reiserfs/do_balan.c
56691 +++ b/fs/reiserfs/do_balan.c
56692 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56693 return;
56694 }
56695
56696 - atomic_inc(&(fs_generation(tb->tb_sb)));
56697 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56698 do_balance_starts(tb);
56699
56700 /* balance leaf returns 0 except if combining L R and S into
56701 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56702 index 33532f7..4846ade 100644
56703 --- a/fs/reiserfs/procfs.c
56704 +++ b/fs/reiserfs/procfs.c
56705 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56706 "SMALL_TAILS " : "NO_TAILS ",
56707 replay_only(sb) ? "REPLAY_ONLY " : "",
56708 convert_reiserfs(sb) ? "CONV " : "",
56709 - atomic_read(&r->s_generation_counter),
56710 + atomic_read_unchecked(&r->s_generation_counter),
56711 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56712 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56713 SF(s_good_search_by_key_reada), SF(s_bmaps),
56714 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56715 index 157e474..65a6114 100644
56716 --- a/fs/reiserfs/reiserfs.h
56717 +++ b/fs/reiserfs/reiserfs.h
56718 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56719 /* Comment? -Hans */
56720 wait_queue_head_t s_wait;
56721 /* To be obsoleted soon by per buffer seals.. -Hans */
56722 - atomic_t s_generation_counter; // increased by one every time the
56723 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56724 // tree gets re-balanced
56725 unsigned long s_properties; /* File system properties. Currently holds
56726 on-disk FS format */
56727 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56728 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56729
56730 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56731 -#define get_generation(s) atomic_read (&fs_generation(s))
56732 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56733 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56734 #define __fs_changed(gen,s) (gen != get_generation (s))
56735 #define fs_changed(gen,s) \
56736 diff --git a/fs/select.c b/fs/select.c
56737 index 8c1c96c..a0f9b6d 100644
56738 --- a/fs/select.c
56739 +++ b/fs/select.c
56740 @@ -20,6 +20,7 @@
56741 #include <linux/export.h>
56742 #include <linux/slab.h>
56743 #include <linux/poll.h>
56744 +#include <linux/security.h>
56745 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56746 #include <linux/file.h>
56747 #include <linux/fdtable.h>
56748 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56749 struct poll_list *walk = head;
56750 unsigned long todo = nfds;
56751
56752 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56753 if (nfds > rlimit(RLIMIT_NOFILE))
56754 return -EINVAL;
56755
56756 diff --git a/fs/seq_file.c b/fs/seq_file.c
56757 index 774c1eb..b67582a 100644
56758 --- a/fs/seq_file.c
56759 +++ b/fs/seq_file.c
56760 @@ -10,6 +10,7 @@
56761 #include <linux/seq_file.h>
56762 #include <linux/slab.h>
56763 #include <linux/cred.h>
56764 +#include <linux/sched.h>
56765
56766 #include <asm/uaccess.h>
56767 #include <asm/page.h>
56768 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56769 #ifdef CONFIG_USER_NS
56770 p->user_ns = file->f_cred->user_ns;
56771 #endif
56772 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56773 + p->exec_id = current->exec_id;
56774 +#endif
56775
56776 /*
56777 * Wrappers around seq_open(e.g. swaps_open) need to be
56778 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56779 return 0;
56780 }
56781 if (!m->buf) {
56782 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56783 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56784 if (!m->buf)
56785 return -ENOMEM;
56786 }
56787 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56788 Eoverflow:
56789 m->op->stop(m, p);
56790 kfree(m->buf);
56791 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56792 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56793 return !m->buf ? -ENOMEM : -EAGAIN;
56794 }
56795
56796 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56797
56798 /* grab buffer if we didn't have one */
56799 if (!m->buf) {
56800 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56801 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56802 if (!m->buf)
56803 goto Enomem;
56804 }
56805 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56806 goto Fill;
56807 m->op->stop(m, p);
56808 kfree(m->buf);
56809 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56810 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56811 if (!m->buf)
56812 goto Enomem;
56813 m->count = 0;
56814 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56815 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56816 void *data)
56817 {
56818 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56819 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56820 int res = -ENOMEM;
56821
56822 if (op) {
56823 diff --git a/fs/splice.c b/fs/splice.c
56824 index d37431d..81c3044 100644
56825 --- a/fs/splice.c
56826 +++ b/fs/splice.c
56827 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56828 pipe_lock(pipe);
56829
56830 for (;;) {
56831 - if (!pipe->readers) {
56832 + if (!atomic_read(&pipe->readers)) {
56833 send_sig(SIGPIPE, current, 0);
56834 if (!ret)
56835 ret = -EPIPE;
56836 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56837 page_nr++;
56838 ret += buf->len;
56839
56840 - if (pipe->files)
56841 + if (atomic_read(&pipe->files))
56842 do_wakeup = 1;
56843
56844 if (!--spd->nr_pages)
56845 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56846 do_wakeup = 0;
56847 }
56848
56849 - pipe->waiting_writers++;
56850 + atomic_inc(&pipe->waiting_writers);
56851 pipe_wait(pipe);
56852 - pipe->waiting_writers--;
56853 + atomic_dec(&pipe->waiting_writers);
56854 }
56855
56856 pipe_unlock(pipe);
56857 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56858 old_fs = get_fs();
56859 set_fs(get_ds());
56860 /* The cast to a user pointer is valid due to the set_fs() */
56861 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56862 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56863 set_fs(old_fs);
56864
56865 return res;
56866 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56867 old_fs = get_fs();
56868 set_fs(get_ds());
56869 /* The cast to a user pointer is valid due to the set_fs() */
56870 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56871 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56872 set_fs(old_fs);
56873
56874 return res;
56875 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56876 goto err;
56877
56878 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56879 - vec[i].iov_base = (void __user *) page_address(page);
56880 + vec[i].iov_base = (void __force_user *) page_address(page);
56881 vec[i].iov_len = this_len;
56882 spd.pages[i] = page;
56883 spd.nr_pages++;
56884 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
56885 ops->release(pipe, buf);
56886 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
56887 pipe->nrbufs--;
56888 - if (pipe->files)
56889 + if (atomic_read(&pipe->files))
56890 sd->need_wakeup = true;
56891 }
56892
56893 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56894 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56895 {
56896 while (!pipe->nrbufs) {
56897 - if (!pipe->writers)
56898 + if (!atomic_read(&pipe->writers))
56899 return 0;
56900
56901 - if (!pipe->waiting_writers && sd->num_spliced)
56902 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56903 return 0;
56904
56905 if (sd->flags & SPLICE_F_NONBLOCK)
56906 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56907 * out of the pipe right after the splice_to_pipe(). So set
56908 * PIPE_READERS appropriately.
56909 */
56910 - pipe->readers = 1;
56911 + atomic_set(&pipe->readers, 1);
56912
56913 current->splice_pipe = pipe;
56914 }
56915 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56916 ret = -ERESTARTSYS;
56917 break;
56918 }
56919 - if (!pipe->writers)
56920 + if (!atomic_read(&pipe->writers))
56921 break;
56922 - if (!pipe->waiting_writers) {
56923 + if (!atomic_read(&pipe->waiting_writers)) {
56924 if (flags & SPLICE_F_NONBLOCK) {
56925 ret = -EAGAIN;
56926 break;
56927 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56928 pipe_lock(pipe);
56929
56930 while (pipe->nrbufs >= pipe->buffers) {
56931 - if (!pipe->readers) {
56932 + if (!atomic_read(&pipe->readers)) {
56933 send_sig(SIGPIPE, current, 0);
56934 ret = -EPIPE;
56935 break;
56936 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56937 ret = -ERESTARTSYS;
56938 break;
56939 }
56940 - pipe->waiting_writers++;
56941 + atomic_inc(&pipe->waiting_writers);
56942 pipe_wait(pipe);
56943 - pipe->waiting_writers--;
56944 + atomic_dec(&pipe->waiting_writers);
56945 }
56946
56947 pipe_unlock(pipe);
56948 @@ -1854,14 +1854,14 @@ retry:
56949 pipe_double_lock(ipipe, opipe);
56950
56951 do {
56952 - if (!opipe->readers) {
56953 + if (!atomic_read(&opipe->readers)) {
56954 send_sig(SIGPIPE, current, 0);
56955 if (!ret)
56956 ret = -EPIPE;
56957 break;
56958 }
56959
56960 - if (!ipipe->nrbufs && !ipipe->writers)
56961 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56962 break;
56963
56964 /*
56965 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56966 pipe_double_lock(ipipe, opipe);
56967
56968 do {
56969 - if (!opipe->readers) {
56970 + if (!atomic_read(&opipe->readers)) {
56971 send_sig(SIGPIPE, current, 0);
56972 if (!ret)
56973 ret = -EPIPE;
56974 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56975 * return EAGAIN if we have the potential of some data in the
56976 * future, otherwise just return 0
56977 */
56978 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56979 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56980 ret = -EAGAIN;
56981
56982 pipe_unlock(ipipe);
56983 diff --git a/fs/stat.c b/fs/stat.c
56984 index 04ce1ac..a13dd1e 100644
56985 --- a/fs/stat.c
56986 +++ b/fs/stat.c
56987 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56988 stat->gid = inode->i_gid;
56989 stat->rdev = inode->i_rdev;
56990 stat->size = i_size_read(inode);
56991 - stat->atime = inode->i_atime;
56992 - stat->mtime = inode->i_mtime;
56993 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56994 + stat->atime = inode->i_ctime;
56995 + stat->mtime = inode->i_ctime;
56996 + } else {
56997 + stat->atime = inode->i_atime;
56998 + stat->mtime = inode->i_mtime;
56999 + }
57000 stat->ctime = inode->i_ctime;
57001 stat->blksize = (1 << inode->i_blkbits);
57002 stat->blocks = inode->i_blocks;
57003 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
57004 if (retval)
57005 return retval;
57006
57007 - if (inode->i_op->getattr)
57008 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
57009 + if (inode->i_op->getattr) {
57010 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
57011 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
57012 + stat->atime = stat->ctime;
57013 + stat->mtime = stat->ctime;
57014 + }
57015 + return retval;
57016 + }
57017
57018 generic_fillattr(inode, stat);
57019 return 0;
57020 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
57021 index 15c68f9..36a8b3e 100644
57022 --- a/fs/sysfs/bin.c
57023 +++ b/fs/sysfs/bin.c
57024 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
57025 return ret;
57026 }
57027
57028 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
57029 - void *buf, int len, int write)
57030 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
57031 + void *buf, size_t len, int write)
57032 {
57033 struct file *file = vma->vm_file;
57034 struct bin_buffer *bb = file->private_data;
57035 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
57036 - int ret;
57037 + ssize_t ret;
57038
57039 if (!bb->vm_ops)
57040 return -EINVAL;
57041 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
57042 index e8e0e71..79c28ac5 100644
57043 --- a/fs/sysfs/dir.c
57044 +++ b/fs/sysfs/dir.c
57045 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
57046 *
57047 * Returns 31 bit hash of ns + name (so it fits in an off_t )
57048 */
57049 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
57050 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
57051 {
57052 unsigned long hash = init_name_hash();
57053 unsigned int len = strlen(name);
57054 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
57055 struct sysfs_dirent *sd;
57056 int rc;
57057
57058 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
57059 + const char *parent_name = parent_sd->s_name;
57060 +
57061 + mode = S_IFDIR | S_IRWXU;
57062 +
57063 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
57064 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
57065 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
57066 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
57067 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
57068 +#endif
57069 +
57070 /* allocate */
57071 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
57072 if (!sd)
57073 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
57074 index 602f56d..6853db8 100644
57075 --- a/fs/sysfs/file.c
57076 +++ b/fs/sysfs/file.c
57077 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
57078
57079 struct sysfs_open_dirent {
57080 atomic_t refcnt;
57081 - atomic_t event;
57082 + atomic_unchecked_t event;
57083 wait_queue_head_t poll;
57084 struct list_head buffers; /* goes through sysfs_buffer.list */
57085 };
57086 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
57087 if (!sysfs_get_active(attr_sd))
57088 return -ENODEV;
57089
57090 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
57091 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
57092 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
57093
57094 sysfs_put_active(attr_sd);
57095 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
57096 return -ENOMEM;
57097
57098 atomic_set(&new_od->refcnt, 0);
57099 - atomic_set(&new_od->event, 1);
57100 + atomic_set_unchecked(&new_od->event, 1);
57101 init_waitqueue_head(&new_od->poll);
57102 INIT_LIST_HEAD(&new_od->buffers);
57103 goto retry;
57104 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
57105
57106 sysfs_put_active(attr_sd);
57107
57108 - if (buffer->event != atomic_read(&od->event))
57109 + if (buffer->event != atomic_read_unchecked(&od->event))
57110 goto trigger;
57111
57112 return DEFAULT_POLLMASK;
57113 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
57114
57115 od = sd->s_attr.open;
57116 if (od) {
57117 - atomic_inc(&od->event);
57118 + atomic_inc_unchecked(&od->event);
57119 wake_up_interruptible(&od->poll);
57120 }
57121
57122 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
57123 index 8c940df..25b733e 100644
57124 --- a/fs/sysfs/symlink.c
57125 +++ b/fs/sysfs/symlink.c
57126 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57127
57128 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57129 {
57130 - char *page = nd_get_link(nd);
57131 + const char *page = nd_get_link(nd);
57132 if (!IS_ERR(page))
57133 free_page((unsigned long)page);
57134 }
57135 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
57136 index 69d4889..a810bd4 100644
57137 --- a/fs/sysv/sysv.h
57138 +++ b/fs/sysv/sysv.h
57139 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
57140 #endif
57141 }
57142
57143 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
57144 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
57145 {
57146 if (sbi->s_bytesex == BYTESEX_PDP)
57147 return PDP_swab((__force __u32)n);
57148 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
57149 index e18b988..f1d4ad0f 100644
57150 --- a/fs/ubifs/io.c
57151 +++ b/fs/ubifs/io.c
57152 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
57153 return err;
57154 }
57155
57156 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
57157 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
57158 {
57159 int err;
57160
57161 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
57162 index c175b4d..8f36a16 100644
57163 --- a/fs/udf/misc.c
57164 +++ b/fs/udf/misc.c
57165 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
57166
57167 u8 udf_tag_checksum(const struct tag *t)
57168 {
57169 - u8 *data = (u8 *)t;
57170 + const u8 *data = (const u8 *)t;
57171 u8 checksum = 0;
57172 int i;
57173 for (i = 0; i < sizeof(struct tag); ++i)
57174 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
57175 index 8d974c4..b82f6ec 100644
57176 --- a/fs/ufs/swab.h
57177 +++ b/fs/ufs/swab.h
57178 @@ -22,7 +22,7 @@ enum {
57179 BYTESEX_BE
57180 };
57181
57182 -static inline u64
57183 +static inline u64 __intentional_overflow(-1)
57184 fs64_to_cpu(struct super_block *sbp, __fs64 n)
57185 {
57186 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57187 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
57188 return (__force __fs64)cpu_to_be64(n);
57189 }
57190
57191 -static inline u32
57192 +static inline u32 __intentional_overflow(-1)
57193 fs32_to_cpu(struct super_block *sbp, __fs32 n)
57194 {
57195 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57196 diff --git a/fs/utimes.c b/fs/utimes.c
57197 index f4fb7ec..3fe03c0 100644
57198 --- a/fs/utimes.c
57199 +++ b/fs/utimes.c
57200 @@ -1,6 +1,7 @@
57201 #include <linux/compiler.h>
57202 #include <linux/file.h>
57203 #include <linux/fs.h>
57204 +#include <linux/security.h>
57205 #include <linux/linkage.h>
57206 #include <linux/mount.h>
57207 #include <linux/namei.h>
57208 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
57209 goto mnt_drop_write_and_out;
57210 }
57211 }
57212 +
57213 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
57214 + error = -EACCES;
57215 + goto mnt_drop_write_and_out;
57216 + }
57217 +
57218 mutex_lock(&inode->i_mutex);
57219 error = notify_change(path->dentry, &newattrs);
57220 mutex_unlock(&inode->i_mutex);
57221 diff --git a/fs/xattr.c b/fs/xattr.c
57222 index 3377dff..4d074d9 100644
57223 --- a/fs/xattr.c
57224 +++ b/fs/xattr.c
57225 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
57226 return rc;
57227 }
57228
57229 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
57230 +ssize_t
57231 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
57232 +{
57233 + struct inode *inode = dentry->d_inode;
57234 + ssize_t error;
57235 +
57236 + error = inode_permission(inode, MAY_EXEC);
57237 + if (error)
57238 + return error;
57239 +
57240 + if (inode->i_op->getxattr)
57241 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
57242 + else
57243 + error = -EOPNOTSUPP;
57244 +
57245 + return error;
57246 +}
57247 +EXPORT_SYMBOL(pax_getxattr);
57248 +#endif
57249 +
57250 ssize_t
57251 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
57252 {
57253 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
57254 * Extended attribute SET operations
57255 */
57256 static long
57257 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
57258 +setxattr(struct path *path, const char __user *name, const void __user *value,
57259 size_t size, int flags)
57260 {
57261 int error;
57262 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
57263 posix_acl_fix_xattr_from_user(kvalue, size);
57264 }
57265
57266 - error = vfs_setxattr(d, kname, kvalue, size, flags);
57267 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
57268 + error = -EACCES;
57269 + goto out;
57270 + }
57271 +
57272 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
57273 out:
57274 if (vvalue)
57275 vfree(vvalue);
57276 @@ -377,7 +403,7 @@ retry:
57277 return error;
57278 error = mnt_want_write(path.mnt);
57279 if (!error) {
57280 - error = setxattr(path.dentry, name, value, size, flags);
57281 + error = setxattr(&path, name, value, size, flags);
57282 mnt_drop_write(path.mnt);
57283 }
57284 path_put(&path);
57285 @@ -401,7 +427,7 @@ retry:
57286 return error;
57287 error = mnt_want_write(path.mnt);
57288 if (!error) {
57289 - error = setxattr(path.dentry, name, value, size, flags);
57290 + error = setxattr(&path, name, value, size, flags);
57291 mnt_drop_write(path.mnt);
57292 }
57293 path_put(&path);
57294 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57295 const void __user *,value, size_t, size, int, flags)
57296 {
57297 struct fd f = fdget(fd);
57298 - struct dentry *dentry;
57299 int error = -EBADF;
57300
57301 if (!f.file)
57302 return error;
57303 - dentry = f.file->f_path.dentry;
57304 - audit_inode(NULL, dentry, 0);
57305 + audit_inode(NULL, f.file->f_path.dentry, 0);
57306 error = mnt_want_write_file(f.file);
57307 if (!error) {
57308 - error = setxattr(dentry, name, value, size, flags);
57309 + error = setxattr(&f.file->f_path, name, value, size, flags);
57310 mnt_drop_write_file(f.file);
57311 }
57312 fdput(f);
57313 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57314 index 9fbea87..6b19972 100644
57315 --- a/fs/xattr_acl.c
57316 +++ b/fs/xattr_acl.c
57317 @@ -76,8 +76,8 @@ struct posix_acl *
57318 posix_acl_from_xattr(struct user_namespace *user_ns,
57319 const void *value, size_t size)
57320 {
57321 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57322 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57323 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57324 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57325 int count;
57326 struct posix_acl *acl;
57327 struct posix_acl_entry *acl_e;
57328 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57329 index 8904284..ee0e14b 100644
57330 --- a/fs/xfs/xfs_bmap.c
57331 +++ b/fs/xfs/xfs_bmap.c
57332 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
57333
57334 #else
57335 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
57336 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57337 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
57338 #endif /* DEBUG */
57339
57340 /*
57341 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57342 index 6157424..ac98f6d 100644
57343 --- a/fs/xfs/xfs_dir2_sf.c
57344 +++ b/fs/xfs/xfs_dir2_sf.c
57345 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57346 }
57347
57348 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57349 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57350 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57351 + char name[sfep->namelen];
57352 + memcpy(name, sfep->name, sfep->namelen);
57353 + if (filldir(dirent, name, sfep->namelen,
57354 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57355 + *offset = off & 0x7fffffff;
57356 + return 0;
57357 + }
57358 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57359 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57360 *offset = off & 0x7fffffff;
57361 return 0;
57362 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57363 index 5e99968..45bd327 100644
57364 --- a/fs/xfs/xfs_ioctl.c
57365 +++ b/fs/xfs/xfs_ioctl.c
57366 @@ -127,7 +127,7 @@ xfs_find_handle(
57367 }
57368
57369 error = -EFAULT;
57370 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57371 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57372 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57373 goto out_put;
57374
57375 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57376 index ca9ecaa..60100c7 100644
57377 --- a/fs/xfs/xfs_iops.c
57378 +++ b/fs/xfs/xfs_iops.c
57379 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57380 struct nameidata *nd,
57381 void *p)
57382 {
57383 - char *s = nd_get_link(nd);
57384 + const char *s = nd_get_link(nd);
57385
57386 if (!IS_ERR(s))
57387 kfree(s);
57388 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57389 new file mode 100644
57390 index 0000000..712a85d
57391 --- /dev/null
57392 +++ b/grsecurity/Kconfig
57393 @@ -0,0 +1,1043 @@
57394 +#
57395 +# grecurity configuration
57396 +#
57397 +menu "Memory Protections"
57398 +depends on GRKERNSEC
57399 +
57400 +config GRKERNSEC_KMEM
57401 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57402 + default y if GRKERNSEC_CONFIG_AUTO
57403 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57404 + help
57405 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57406 + be written to or read from to modify or leak the contents of the running
57407 + kernel. /dev/port will also not be allowed to be opened and support
57408 + for /dev/cpu/*/msr will be removed. If you have module
57409 + support disabled, enabling this will close up five ways that are
57410 + currently used to insert malicious code into the running kernel.
57411 +
57412 + Even with all these features enabled, we still highly recommend that
57413 + you use the RBAC system, as it is still possible for an attacker to
57414 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57415 +
57416 + If you are not using XFree86, you may be able to stop this additional
57417 + case by enabling the 'Disable privileged I/O' option. Though nothing
57418 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57419 + but only to video memory, which is the only writing we allow in this
57420 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57421 + not be allowed to mprotect it with PROT_WRITE later.
57422 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57423 + from working.
57424 +
57425 + It is highly recommended that you say Y here if you meet all the
57426 + conditions above.
57427 +
57428 +config GRKERNSEC_VM86
57429 + bool "Restrict VM86 mode"
57430 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57431 + depends on X86_32
57432 +
57433 + help
57434 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57435 + make use of a special execution mode on 32bit x86 processors called
57436 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57437 + video cards and will still work with this option enabled. The purpose
57438 + of the option is to prevent exploitation of emulation errors in
57439 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57440 + Nearly all users should be able to enable this option.
57441 +
57442 +config GRKERNSEC_IO
57443 + bool "Disable privileged I/O"
57444 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57445 + depends on X86
57446 + select RTC_CLASS
57447 + select RTC_INTF_DEV
57448 + select RTC_DRV_CMOS
57449 +
57450 + help
57451 + If you say Y here, all ioperm and iopl calls will return an error.
57452 + Ioperm and iopl can be used to modify the running kernel.
57453 + Unfortunately, some programs need this access to operate properly,
57454 + the most notable of which are XFree86 and hwclock. hwclock can be
57455 + remedied by having RTC support in the kernel, so real-time
57456 + clock support is enabled if this option is enabled, to ensure
57457 + that hwclock operates correctly. XFree86 still will not
57458 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57459 + IF YOU USE XFree86. If you use XFree86 and you still want to
57460 + protect your kernel against modification, use the RBAC system.
57461 +
57462 +config GRKERNSEC_JIT_HARDEN
57463 + bool "Harden BPF JIT against spray attacks"
57464 + default y if GRKERNSEC_CONFIG_AUTO
57465 + depends on BPF_JIT
57466 + help
57467 + If you say Y here, the native code generated by the kernel's Berkeley
57468 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57469 + attacks that attempt to fit attacker-beneficial instructions in
57470 + 32bit immediate fields of JIT-generated native instructions. The
57471 + attacker will generally aim to cause an unintended instruction sequence
57472 + of JIT-generated native code to execute by jumping into the middle of
57473 + a generated instruction. This feature effectively randomizes the 32bit
57474 + immediate constants present in the generated code to thwart such attacks.
57475 +
57476 + If you're using KERNEXEC, it's recommended that you enable this option
57477 + to supplement the hardening of the kernel.
57478 +
57479 +config GRKERNSEC_PERF_HARDEN
57480 + bool "Disable unprivileged PERF_EVENTS usage by default"
57481 + default y if GRKERNSEC_CONFIG_AUTO
57482 + depends on PERF_EVENTS
57483 + help
57484 + If you say Y here, the range of acceptable values for the
57485 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57486 + default to a new value: 3. When the sysctl is set to this value, no
57487 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57488 +
57489 + Though PERF_EVENTS can be used legitimately for performance monitoring
57490 + and low-level application profiling, it is forced on regardless of
57491 + configuration, has been at fault for several vulnerabilities, and
57492 + creates new opportunities for side channels and other information leaks.
57493 +
57494 + This feature puts PERF_EVENTS into a secure default state and permits
57495 + the administrator to change out of it temporarily if unprivileged
57496 + application profiling is needed.
57497 +
57498 +config GRKERNSEC_RAND_THREADSTACK
57499 + bool "Insert random gaps between thread stacks"
57500 + default y if GRKERNSEC_CONFIG_AUTO
57501 + depends on PAX_RANDMMAP && !PPC
57502 + help
57503 + If you say Y here, a random-sized gap will be enforced between allocated
57504 + thread stacks. Glibc's NPTL and other threading libraries that
57505 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57506 + The implementation currently provides 8 bits of entropy for the gap.
57507 +
57508 + Many distributions do not compile threaded remote services with the
57509 + -fstack-check argument to GCC, causing the variable-sized stack-based
57510 + allocator, alloca(), to not probe the stack on allocation. This
57511 + permits an unbounded alloca() to skip over any guard page and potentially
57512 + modify another thread's stack reliably. An enforced random gap
57513 + reduces the reliability of such an attack and increases the chance
57514 + that such a read/write to another thread's stack instead lands in
57515 + an unmapped area, causing a crash and triggering grsecurity's
57516 + anti-bruteforcing logic.
57517 +
57518 +config GRKERNSEC_PROC_MEMMAP
57519 + bool "Harden ASLR against information leaks and entropy reduction"
57520 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57521 + depends on PAX_NOEXEC || PAX_ASLR
57522 + help
57523 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57524 + give no information about the addresses of its mappings if
57525 + PaX features that rely on random addresses are enabled on the task.
57526 + In addition to sanitizing this information and disabling other
57527 + dangerous sources of information, this option causes reads of sensitive
57528 + /proc/<pid> entries where the file descriptor was opened in a different
57529 + task than the one performing the read. Such attempts are logged.
57530 + This option also limits argv/env strings for suid/sgid binaries
57531 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57532 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57533 + binaries to prevent alternative mmap layouts from being abused.
57534 +
57535 + If you use PaX it is essential that you say Y here as it closes up
57536 + several holes that make full ASLR useless locally.
57537 +
57538 +config GRKERNSEC_BRUTE
57539 + bool "Deter exploit bruteforcing"
57540 + default y if GRKERNSEC_CONFIG_AUTO
57541 + help
57542 + If you say Y here, attempts to bruteforce exploits against forking
57543 + daemons such as apache or sshd, as well as against suid/sgid binaries
57544 + will be deterred. When a child of a forking daemon is killed by PaX
57545 + or crashes due to an illegal instruction or other suspicious signal,
57546 + the parent process will be delayed 30 seconds upon every subsequent
57547 + fork until the administrator is able to assess the situation and
57548 + restart the daemon.
57549 + In the suid/sgid case, the attempt is logged, the user has all their
57550 + existing instances of the suid/sgid binary terminated and will
57551 + be unable to execute any suid/sgid binaries for 15 minutes.
57552 +
57553 + It is recommended that you also enable signal logging in the auditing
57554 + section so that logs are generated when a process triggers a suspicious
57555 + signal.
57556 + If the sysctl option is enabled, a sysctl option with name
57557 + "deter_bruteforce" is created.
57558 +
57559 +
57560 +config GRKERNSEC_MODHARDEN
57561 + bool "Harden module auto-loading"
57562 + default y if GRKERNSEC_CONFIG_AUTO
57563 + depends on MODULES
57564 + help
57565 + If you say Y here, module auto-loading in response to use of some
57566 + feature implemented by an unloaded module will be restricted to
57567 + root users. Enabling this option helps defend against attacks
57568 + by unprivileged users who abuse the auto-loading behavior to
57569 + cause a vulnerable module to load that is then exploited.
57570 +
57571 + If this option prevents a legitimate use of auto-loading for a
57572 + non-root user, the administrator can execute modprobe manually
57573 + with the exact name of the module mentioned in the alert log.
57574 + Alternatively, the administrator can add the module to the list
57575 + of modules loaded at boot by modifying init scripts.
57576 +
57577 + Modification of init scripts will most likely be needed on
57578 + Ubuntu servers with encrypted home directory support enabled,
57579 + as the first non-root user logging in will cause the ecb(aes),
57580 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57581 +
57582 +config GRKERNSEC_HIDESYM
57583 + bool "Hide kernel symbols"
57584 + default y if GRKERNSEC_CONFIG_AUTO
57585 + select PAX_USERCOPY_SLABS
57586 + help
57587 + If you say Y here, getting information on loaded modules, and
57588 + displaying all kernel symbols through a syscall will be restricted
57589 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57590 + /proc/kallsyms will be restricted to the root user. The RBAC
57591 + system can hide that entry even from root.
57592 +
57593 + This option also prevents leaking of kernel addresses through
57594 + several /proc entries.
57595 +
57596 + Note that this option is only effective provided the following
57597 + conditions are met:
57598 + 1) The kernel using grsecurity is not precompiled by some distribution
57599 + 2) You have also enabled GRKERNSEC_DMESG
57600 + 3) You are using the RBAC system and hiding other files such as your
57601 + kernel image and System.map. Alternatively, enabling this option
57602 + causes the permissions on /boot, /lib/modules, and the kernel
57603 + source directory to change at compile time to prevent
57604 + reading by non-root users.
57605 + If the above conditions are met, this option will aid in providing a
57606 + useful protection against local kernel exploitation of overflows
57607 + and arbitrary read/write vulnerabilities.
57608 +
57609 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57610 + in addition to this feature.
57611 +
57612 +config GRKERNSEC_KERN_LOCKOUT
57613 + bool "Active kernel exploit response"
57614 + default y if GRKERNSEC_CONFIG_AUTO
57615 + depends on X86 || ARM || PPC || SPARC
57616 + help
57617 + If you say Y here, when a PaX alert is triggered due to suspicious
57618 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57619 + or an OOPS occurs due to bad memory accesses, instead of just
57620 + terminating the offending process (and potentially allowing
57621 + a subsequent exploit from the same user), we will take one of two
57622 + actions:
57623 + If the user was root, we will panic the system
57624 + If the user was non-root, we will log the attempt, terminate
57625 + all processes owned by the user, then prevent them from creating
57626 + any new processes until the system is restarted
57627 + This deters repeated kernel exploitation/bruteforcing attempts
57628 + and is useful for later forensics.
57629 +
57630 +endmenu
57631 +menu "Role Based Access Control Options"
57632 +depends on GRKERNSEC
57633 +
57634 +config GRKERNSEC_RBAC_DEBUG
57635 + bool
57636 +
57637 +config GRKERNSEC_NO_RBAC
57638 + bool "Disable RBAC system"
57639 + help
57640 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57641 + preventing the RBAC system from being enabled. You should only say Y
57642 + here if you have no intention of using the RBAC system, so as to prevent
57643 + an attacker with root access from misusing the RBAC system to hide files
57644 + and processes when loadable module support and /dev/[k]mem have been
57645 + locked down.
57646 +
57647 +config GRKERNSEC_ACL_HIDEKERN
57648 + bool "Hide kernel processes"
57649 + help
57650 + If you say Y here, all kernel threads will be hidden to all
57651 + processes but those whose subject has the "view hidden processes"
57652 + flag.
57653 +
57654 +config GRKERNSEC_ACL_MAXTRIES
57655 + int "Maximum tries before password lockout"
57656 + default 3
57657 + help
57658 + This option enforces the maximum number of times a user can attempt
57659 + to authorize themselves with the grsecurity RBAC system before being
57660 + denied the ability to attempt authorization again for a specified time.
57661 + The lower the number, the harder it will be to brute-force a password.
57662 +
57663 +config GRKERNSEC_ACL_TIMEOUT
57664 + int "Time to wait after max password tries, in seconds"
57665 + default 30
57666 + help
57667 + This option specifies the time the user must wait after attempting to
57668 + authorize to the RBAC system with the maximum number of invalid
57669 + passwords. The higher the number, the harder it will be to brute-force
57670 + a password.
57671 +
57672 +endmenu
57673 +menu "Filesystem Protections"
57674 +depends on GRKERNSEC
57675 +
57676 +config GRKERNSEC_PROC
57677 + bool "Proc restrictions"
57678 + default y if GRKERNSEC_CONFIG_AUTO
57679 + help
57680 + If you say Y here, the permissions of the /proc filesystem
57681 + will be altered to enhance system security and privacy. You MUST
57682 + choose either a user only restriction or a user and group restriction.
57683 + Depending upon the option you choose, you can either restrict users to
57684 + see only the processes they themselves run, or choose a group that can
57685 + view all processes and files normally restricted to root if you choose
57686 + the "restrict to user only" option. NOTE: If you're running identd or
57687 + ntpd as a non-root user, you will have to run it as the group you
57688 + specify here.
57689 +
57690 +config GRKERNSEC_PROC_USER
57691 + bool "Restrict /proc to user only"
57692 + depends on GRKERNSEC_PROC
57693 + help
57694 + If you say Y here, non-root users will only be able to view their own
57695 + processes, and restricts them from viewing network-related information,
57696 + and viewing kernel symbol and module information.
57697 +
57698 +config GRKERNSEC_PROC_USERGROUP
57699 + bool "Allow special group"
57700 + default y if GRKERNSEC_CONFIG_AUTO
57701 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57702 + help
57703 + If you say Y here, you will be able to select a group that will be
57704 + able to view all processes and network-related information. If you've
57705 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57706 + remain hidden. This option is useful if you want to run identd as
57707 + a non-root user. The group you select may also be chosen at boot time
57708 + via "grsec_proc_gid=" on the kernel commandline.
57709 +
57710 +config GRKERNSEC_PROC_GID
57711 + int "GID for special group"
57712 + depends on GRKERNSEC_PROC_USERGROUP
57713 + default 1001
57714 +
57715 +config GRKERNSEC_PROC_ADD
57716 + bool "Additional restrictions"
57717 + default y if GRKERNSEC_CONFIG_AUTO
57718 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57719 + help
57720 + If you say Y here, additional restrictions will be placed on
57721 + /proc that keep normal users from viewing device information and
57722 + slabinfo information that could be useful for exploits.
57723 +
57724 +config GRKERNSEC_LINK
57725 + bool "Linking restrictions"
57726 + default y if GRKERNSEC_CONFIG_AUTO
57727 + help
57728 + If you say Y here, /tmp race exploits will be prevented, since users
57729 + will no longer be able to follow symlinks owned by other users in
57730 + world-writable +t directories (e.g. /tmp), unless the owner of the
57731 + symlink is the owner of the directory. users will also not be
57732 + able to hardlink to files they do not own. If the sysctl option is
57733 + enabled, a sysctl option with name "linking_restrictions" is created.
57734 +
57735 +config GRKERNSEC_SYMLINKOWN
57736 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57737 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57738 + help
57739 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57740 + that prevents it from being used as a security feature. As Apache
57741 + verifies the symlink by performing a stat() against the target of
57742 + the symlink before it is followed, an attacker can setup a symlink
57743 + to point to a same-owned file, then replace the symlink with one
57744 + that targets another user's file just after Apache "validates" the
57745 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57746 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57747 + will be in place for the group you specify. If the sysctl option
57748 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57749 + created.
57750 +
57751 +config GRKERNSEC_SYMLINKOWN_GID
57752 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57753 + depends on GRKERNSEC_SYMLINKOWN
57754 + default 1006
57755 + help
57756 + Setting this GID determines what group kernel-enforced
57757 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57758 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57759 +
57760 +config GRKERNSEC_FIFO
57761 + bool "FIFO restrictions"
57762 + default y if GRKERNSEC_CONFIG_AUTO
57763 + help
57764 + If you say Y here, users will not be able to write to FIFOs they don't
57765 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57766 + the FIFO is the same owner of the directory it's held in. If the sysctl
57767 + option is enabled, a sysctl option with name "fifo_restrictions" is
57768 + created.
57769 +
57770 +config GRKERNSEC_SYSFS_RESTRICT
57771 + bool "Sysfs/debugfs restriction"
57772 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57773 + depends on SYSFS
57774 + help
57775 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57776 + any filesystem normally mounted under it (e.g. debugfs) will be
57777 + mostly accessible only by root. These filesystems generally provide access
57778 + to hardware and debug information that isn't appropriate for unprivileged
57779 + users of the system. Sysfs and debugfs have also become a large source
57780 + of new vulnerabilities, ranging from infoleaks to local compromise.
57781 + There has been very little oversight with an eye toward security involved
57782 + in adding new exporters of information to these filesystems, so their
57783 + use is discouraged.
57784 + For reasons of compatibility, a few directories have been whitelisted
57785 + for access by non-root users:
57786 + /sys/fs/selinux
57787 + /sys/fs/fuse
57788 + /sys/devices/system/cpu
57789 +
57790 +config GRKERNSEC_ROFS
57791 + bool "Runtime read-only mount protection"
57792 + help
57793 + If you say Y here, a sysctl option with name "romount_protect" will
57794 + be created. By setting this option to 1 at runtime, filesystems
57795 + will be protected in the following ways:
57796 + * No new writable mounts will be allowed
57797 + * Existing read-only mounts won't be able to be remounted read/write
57798 + * Write operations will be denied on all block devices
57799 + This option acts independently of grsec_lock: once it is set to 1,
57800 + it cannot be turned off. Therefore, please be mindful of the resulting
57801 + behavior if this option is enabled in an init script on a read-only
57802 + filesystem. This feature is mainly intended for secure embedded systems.
57803 +
57804 +config GRKERNSEC_DEVICE_SIDECHANNEL
57805 + bool "Eliminate stat/notify-based device sidechannels"
57806 + default y if GRKERNSEC_CONFIG_AUTO
57807 + help
57808 + If you say Y here, timing analyses on block or character
57809 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57810 + will be thwarted for unprivileged users. If a process without
57811 + CAP_MKNOD stats such a device, the last access and last modify times
57812 + will match the device's create time. No access or modify events
57813 + will be triggered through inotify/dnotify/fanotify for such devices.
57814 + This feature will prevent attacks that may at a minimum
57815 + allow an attacker to determine the administrator's password length.
57816 +
57817 +config GRKERNSEC_CHROOT
57818 + bool "Chroot jail restrictions"
57819 + default y if GRKERNSEC_CONFIG_AUTO
57820 + help
57821 + If you say Y here, you will be able to choose several options that will
57822 + make breaking out of a chrooted jail much more difficult. If you
57823 + encounter no software incompatibilities with the following options, it
57824 + is recommended that you enable each one.
57825 +
57826 +config GRKERNSEC_CHROOT_MOUNT
57827 + bool "Deny mounts"
57828 + default y if GRKERNSEC_CONFIG_AUTO
57829 + depends on GRKERNSEC_CHROOT
57830 + help
57831 + If you say Y here, processes inside a chroot will not be able to
57832 + mount or remount filesystems. If the sysctl option is enabled, a
57833 + sysctl option with name "chroot_deny_mount" is created.
57834 +
57835 +config GRKERNSEC_CHROOT_DOUBLE
57836 + bool "Deny double-chroots"
57837 + default y if GRKERNSEC_CONFIG_AUTO
57838 + depends on GRKERNSEC_CHROOT
57839 + help
57840 + If you say Y here, processes inside a chroot will not be able to chroot
57841 + again outside the chroot. This is a widely used method of breaking
57842 + out of a chroot jail and should not be allowed. If the sysctl
57843 + option is enabled, a sysctl option with name
57844 + "chroot_deny_chroot" is created.
57845 +
57846 +config GRKERNSEC_CHROOT_PIVOT
57847 + bool "Deny pivot_root in chroot"
57848 + default y if GRKERNSEC_CONFIG_AUTO
57849 + depends on GRKERNSEC_CHROOT
57850 + help
57851 + If you say Y here, processes inside a chroot will not be able to use
57852 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57853 + works similar to chroot in that it changes the root filesystem. This
57854 + function could be misused in a chrooted process to attempt to break out
57855 + of the chroot, and therefore should not be allowed. If the sysctl
57856 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57857 + created.
57858 +
57859 +config GRKERNSEC_CHROOT_CHDIR
57860 + bool "Enforce chdir(\"/\") on all chroots"
57861 + default y if GRKERNSEC_CONFIG_AUTO
57862 + depends on GRKERNSEC_CHROOT
57863 + help
57864 + If you say Y here, the current working directory of all newly-chrooted
57865 + applications will be set to the the root directory of the chroot.
57866 + The man page on chroot(2) states:
57867 + Note that this call does not change the current working
57868 + directory, so that `.' can be outside the tree rooted at
57869 + `/'. In particular, the super-user can escape from a
57870 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57871 +
57872 + It is recommended that you say Y here, since it's not known to break
57873 + any software. If the sysctl option is enabled, a sysctl option with
57874 + name "chroot_enforce_chdir" is created.
57875 +
57876 +config GRKERNSEC_CHROOT_CHMOD
57877 + bool "Deny (f)chmod +s"
57878 + default y if GRKERNSEC_CONFIG_AUTO
57879 + depends on GRKERNSEC_CHROOT
57880 + help
57881 + If you say Y here, processes inside a chroot will not be able to chmod
57882 + or fchmod files to make them have suid or sgid bits. This protects
57883 + against another published method of breaking a chroot. If the sysctl
57884 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57885 + created.
57886 +
57887 +config GRKERNSEC_CHROOT_FCHDIR
57888 + bool "Deny fchdir out of chroot"
57889 + default y if GRKERNSEC_CONFIG_AUTO
57890 + depends on GRKERNSEC_CHROOT
57891 + help
57892 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57893 + to a file descriptor of the chrooting process that points to a directory
57894 + outside the filesystem will be stopped. If the sysctl option
57895 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57896 +
57897 +config GRKERNSEC_CHROOT_MKNOD
57898 + bool "Deny mknod"
57899 + default y if GRKERNSEC_CONFIG_AUTO
57900 + depends on GRKERNSEC_CHROOT
57901 + help
57902 + If you say Y here, processes inside a chroot will not be allowed to
57903 + mknod. The problem with using mknod inside a chroot is that it
57904 + would allow an attacker to create a device entry that is the same
57905 + as one on the physical root of your system, which could range from
57906 + anything from the console device to a device for your harddrive (which
57907 + they could then use to wipe the drive or steal data). It is recommended
57908 + that you say Y here, unless you run into software incompatibilities.
57909 + If the sysctl option is enabled, a sysctl option with name
57910 + "chroot_deny_mknod" is created.
57911 +
57912 +config GRKERNSEC_CHROOT_SHMAT
57913 + bool "Deny shmat() out of chroot"
57914 + default y if GRKERNSEC_CONFIG_AUTO
57915 + depends on GRKERNSEC_CHROOT
57916 + help
57917 + If you say Y here, processes inside a chroot will not be able to attach
57918 + to shared memory segments that were created outside of the chroot jail.
57919 + It is recommended that you say Y here. If the sysctl option is enabled,
57920 + a sysctl option with name "chroot_deny_shmat" is created.
57921 +
57922 +config GRKERNSEC_CHROOT_UNIX
57923 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57924 + default y if GRKERNSEC_CONFIG_AUTO
57925 + depends on GRKERNSEC_CHROOT
57926 + help
57927 + If you say Y here, processes inside a chroot will not be able to
57928 + connect to abstract (meaning not belonging to a filesystem) Unix
57929 + domain sockets that were bound outside of a chroot. It is recommended
57930 + that you say Y here. If the sysctl option is enabled, a sysctl option
57931 + with name "chroot_deny_unix" is created.
57932 +
57933 +config GRKERNSEC_CHROOT_FINDTASK
57934 + bool "Protect outside processes"
57935 + default y if GRKERNSEC_CONFIG_AUTO
57936 + depends on GRKERNSEC_CHROOT
57937 + help
57938 + If you say Y here, processes inside a chroot will not be able to
57939 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57940 + getsid, or view any process outside of the chroot. If the sysctl
57941 + option is enabled, a sysctl option with name "chroot_findtask" is
57942 + created.
57943 +
57944 +config GRKERNSEC_CHROOT_NICE
57945 + bool "Restrict priority changes"
57946 + default y if GRKERNSEC_CONFIG_AUTO
57947 + depends on GRKERNSEC_CHROOT
57948 + help
57949 + If you say Y here, processes inside a chroot will not be able to raise
57950 + the priority of processes in the chroot, or alter the priority of
57951 + processes outside the chroot. This provides more security than simply
57952 + removing CAP_SYS_NICE from the process' capability set. If the
57953 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57954 + is created.
57955 +
57956 +config GRKERNSEC_CHROOT_SYSCTL
57957 + bool "Deny sysctl writes"
57958 + default y if GRKERNSEC_CONFIG_AUTO
57959 + depends on GRKERNSEC_CHROOT
57960 + help
57961 + If you say Y here, an attacker in a chroot will not be able to
57962 + write to sysctl entries, either by sysctl(2) or through a /proc
57963 + interface. It is strongly recommended that you say Y here. If the
57964 + sysctl option is enabled, a sysctl option with name
57965 + "chroot_deny_sysctl" is created.
57966 +
57967 +config GRKERNSEC_CHROOT_CAPS
57968 + bool "Capability restrictions"
57969 + default y if GRKERNSEC_CONFIG_AUTO
57970 + depends on GRKERNSEC_CHROOT
57971 + help
57972 + If you say Y here, the capabilities on all processes within a
57973 + chroot jail will be lowered to stop module insertion, raw i/o,
57974 + system and net admin tasks, rebooting the system, modifying immutable
57975 + files, modifying IPC owned by another, and changing the system time.
57976 + This is left an option because it can break some apps. Disable this
57977 + if your chrooted apps are having problems performing those kinds of
57978 + tasks. If the sysctl option is enabled, a sysctl option with
57979 + name "chroot_caps" is created.
57980 +
57981 +config GRKERNSEC_CHROOT_INITRD
57982 + bool "Exempt initrd tasks from restrictions"
57983 + default y if GRKERNSEC_CONFIG_AUTO
57984 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57985 + help
57986 + If you say Y here, tasks started prior to init will be exempted from
57987 + grsecurity's chroot restrictions. This option is mainly meant to
57988 + resolve Plymouth's performing privileged operations unnecessarily
57989 + in a chroot.
57990 +
57991 +endmenu
57992 +menu "Kernel Auditing"
57993 +depends on GRKERNSEC
57994 +
57995 +config GRKERNSEC_AUDIT_GROUP
57996 + bool "Single group for auditing"
57997 + help
57998 + If you say Y here, the exec and chdir logging features will only operate
57999 + on a group you specify. This option is recommended if you only want to
58000 + watch certain users instead of having a large amount of logs from the
58001 + entire system. If the sysctl option is enabled, a sysctl option with
58002 + name "audit_group" is created.
58003 +
58004 +config GRKERNSEC_AUDIT_GID
58005 + int "GID for auditing"
58006 + depends on GRKERNSEC_AUDIT_GROUP
58007 + default 1007
58008 +
58009 +config GRKERNSEC_EXECLOG
58010 + bool "Exec logging"
58011 + help
58012 + If you say Y here, all execve() calls will be logged (since the
58013 + other exec*() calls are frontends to execve(), all execution
58014 + will be logged). Useful for shell-servers that like to keep track
58015 + of their users. If the sysctl option is enabled, a sysctl option with
58016 + name "exec_logging" is created.
58017 + WARNING: This option when enabled will produce a LOT of logs, especially
58018 + on an active system.
58019 +
58020 +config GRKERNSEC_RESLOG
58021 + bool "Resource logging"
58022 + default y if GRKERNSEC_CONFIG_AUTO
58023 + help
58024 + If you say Y here, all attempts to overstep resource limits will
58025 + be logged with the resource name, the requested size, and the current
58026 + limit. It is highly recommended that you say Y here. If the sysctl
58027 + option is enabled, a sysctl option with name "resource_logging" is
58028 + created. If the RBAC system is enabled, the sysctl value is ignored.
58029 +
58030 +config GRKERNSEC_CHROOT_EXECLOG
58031 + bool "Log execs within chroot"
58032 + help
58033 + If you say Y here, all executions inside a chroot jail will be logged
58034 + to syslog. This can cause a large amount of logs if certain
58035 + applications (eg. djb's daemontools) are installed on the system, and
58036 + is therefore left as an option. If the sysctl option is enabled, a
58037 + sysctl option with name "chroot_execlog" is created.
58038 +
58039 +config GRKERNSEC_AUDIT_PTRACE
58040 + bool "Ptrace logging"
58041 + help
58042 + If you say Y here, all attempts to attach to a process via ptrace
58043 + will be logged. If the sysctl option is enabled, a sysctl option
58044 + with name "audit_ptrace" is created.
58045 +
58046 +config GRKERNSEC_AUDIT_CHDIR
58047 + bool "Chdir logging"
58048 + help
58049 + If you say Y here, all chdir() calls will be logged. If the sysctl
58050 + option is enabled, a sysctl option with name "audit_chdir" is created.
58051 +
58052 +config GRKERNSEC_AUDIT_MOUNT
58053 + bool "(Un)Mount logging"
58054 + help
58055 + If you say Y here, all mounts and unmounts will be logged. If the
58056 + sysctl option is enabled, a sysctl option with name "audit_mount" is
58057 + created.
58058 +
58059 +config GRKERNSEC_SIGNAL
58060 + bool "Signal logging"
58061 + default y if GRKERNSEC_CONFIG_AUTO
58062 + help
58063 + If you say Y here, certain important signals will be logged, such as
58064 + SIGSEGV, which will as a result inform you of when a error in a program
58065 + occurred, which in some cases could mean a possible exploit attempt.
58066 + If the sysctl option is enabled, a sysctl option with name
58067 + "signal_logging" is created.
58068 +
58069 +config GRKERNSEC_FORKFAIL
58070 + bool "Fork failure logging"
58071 + help
58072 + If you say Y here, all failed fork() attempts will be logged.
58073 + This could suggest a fork bomb, or someone attempting to overstep
58074 + their process limit. If the sysctl option is enabled, a sysctl option
58075 + with name "forkfail_logging" is created.
58076 +
58077 +config GRKERNSEC_TIME
58078 + bool "Time change logging"
58079 + default y if GRKERNSEC_CONFIG_AUTO
58080 + help
58081 + If you say Y here, any changes of the system clock will be logged.
58082 + If the sysctl option is enabled, a sysctl option with name
58083 + "timechange_logging" is created.
58084 +
58085 +config GRKERNSEC_PROC_IPADDR
58086 + bool "/proc/<pid>/ipaddr support"
58087 + default y if GRKERNSEC_CONFIG_AUTO
58088 + help
58089 + If you say Y here, a new entry will be added to each /proc/<pid>
58090 + directory that contains the IP address of the person using the task.
58091 + The IP is carried across local TCP and AF_UNIX stream sockets.
58092 + This information can be useful for IDS/IPSes to perform remote response
58093 + to a local attack. The entry is readable by only the owner of the
58094 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
58095 + the RBAC system), and thus does not create privacy concerns.
58096 +
58097 +config GRKERNSEC_RWXMAP_LOG
58098 + bool 'Denied RWX mmap/mprotect logging'
58099 + default y if GRKERNSEC_CONFIG_AUTO
58100 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
58101 + help
58102 + If you say Y here, calls to mmap() and mprotect() with explicit
58103 + usage of PROT_WRITE and PROT_EXEC together will be logged when
58104 + denied by the PAX_MPROTECT feature. This feature will also
58105 + log other problematic scenarios that can occur when PAX_MPROTECT
58106 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
58107 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
58108 + is created.
58109 +
58110 +endmenu
58111 +
58112 +menu "Executable Protections"
58113 +depends on GRKERNSEC
58114 +
58115 +config GRKERNSEC_DMESG
58116 + bool "Dmesg(8) restriction"
58117 + default y if GRKERNSEC_CONFIG_AUTO
58118 + help
58119 + If you say Y here, non-root users will not be able to use dmesg(8)
58120 + to view the contents of the kernel's circular log buffer.
58121 + The kernel's log buffer often contains kernel addresses and other
58122 + identifying information useful to an attacker in fingerprinting a
58123 + system for a targeted exploit.
58124 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
58125 + created.
58126 +
58127 +config GRKERNSEC_HARDEN_PTRACE
58128 + bool "Deter ptrace-based process snooping"
58129 + default y if GRKERNSEC_CONFIG_AUTO
58130 + help
58131 + If you say Y here, TTY sniffers and other malicious monitoring
58132 + programs implemented through ptrace will be defeated. If you
58133 + have been using the RBAC system, this option has already been
58134 + enabled for several years for all users, with the ability to make
58135 + fine-grained exceptions.
58136 +
58137 + This option only affects the ability of non-root users to ptrace
58138 + processes that are not a descendent of the ptracing process.
58139 + This means that strace ./binary and gdb ./binary will still work,
58140 + but attaching to arbitrary processes will not. If the sysctl
58141 + option is enabled, a sysctl option with name "harden_ptrace" is
58142 + created.
58143 +
58144 +config GRKERNSEC_PTRACE_READEXEC
58145 + bool "Require read access to ptrace sensitive binaries"
58146 + default y if GRKERNSEC_CONFIG_AUTO
58147 + help
58148 + If you say Y here, unprivileged users will not be able to ptrace unreadable
58149 + binaries. This option is useful in environments that
58150 + remove the read bits (e.g. file mode 4711) from suid binaries to
58151 + prevent infoleaking of their contents. This option adds
58152 + consistency to the use of that file mode, as the binary could normally
58153 + be read out when run without privileges while ptracing.
58154 +
58155 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
58156 + is created.
58157 +
58158 +config GRKERNSEC_SETXID
58159 + bool "Enforce consistent multithreaded privileges"
58160 + default y if GRKERNSEC_CONFIG_AUTO
58161 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
58162 + help
58163 + If you say Y here, a change from a root uid to a non-root uid
58164 + in a multithreaded application will cause the resulting uids,
58165 + gids, supplementary groups, and capabilities in that thread
58166 + to be propagated to the other threads of the process. In most
58167 + cases this is unnecessary, as glibc will emulate this behavior
58168 + on behalf of the application. Other libcs do not act in the
58169 + same way, allowing the other threads of the process to continue
58170 + running with root privileges. If the sysctl option is enabled,
58171 + a sysctl option with name "consistent_setxid" is created.
58172 +
58173 +config GRKERNSEC_TPE
58174 + bool "Trusted Path Execution (TPE)"
58175 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
58176 + help
58177 + If you say Y here, you will be able to choose a gid to add to the
58178 + supplementary groups of users you want to mark as "untrusted."
58179 + These users will not be able to execute any files that are not in
58180 + root-owned directories writable only by root. If the sysctl option
58181 + is enabled, a sysctl option with name "tpe" is created.
58182 +
58183 +config GRKERNSEC_TPE_ALL
58184 + bool "Partially restrict all non-root users"
58185 + depends on GRKERNSEC_TPE
58186 + help
58187 + If you say Y here, all non-root users will be covered under
58188 + a weaker TPE restriction. This is separate from, and in addition to,
58189 + the main TPE options that you have selected elsewhere. Thus, if a
58190 + "trusted" GID is chosen, this restriction applies to even that GID.
58191 + Under this restriction, all non-root users will only be allowed to
58192 + execute files in directories they own that are not group or
58193 + world-writable, or in directories owned by root and writable only by
58194 + root. If the sysctl option is enabled, a sysctl option with name
58195 + "tpe_restrict_all" is created.
58196 +
58197 +config GRKERNSEC_TPE_INVERT
58198 + bool "Invert GID option"
58199 + depends on GRKERNSEC_TPE
58200 + help
58201 + If you say Y here, the group you specify in the TPE configuration will
58202 + decide what group TPE restrictions will be *disabled* for. This
58203 + option is useful if you want TPE restrictions to be applied to most
58204 + users on the system. If the sysctl option is enabled, a sysctl option
58205 + with name "tpe_invert" is created. Unlike other sysctl options, this
58206 + entry will default to on for backward-compatibility.
58207 +
58208 +config GRKERNSEC_TPE_GID
58209 + int
58210 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
58211 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
58212 +
58213 +config GRKERNSEC_TPE_UNTRUSTED_GID
58214 + int "GID for TPE-untrusted users"
58215 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
58216 + default 1005
58217 + help
58218 + Setting this GID determines what group TPE restrictions will be
58219 + *enabled* for. If the sysctl option is enabled, a sysctl option
58220 + with name "tpe_gid" is created.
58221 +
58222 +config GRKERNSEC_TPE_TRUSTED_GID
58223 + int "GID for TPE-trusted users"
58224 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
58225 + default 1005
58226 + help
58227 + Setting this GID determines what group TPE restrictions will be
58228 + *disabled* for. If the sysctl option is enabled, a sysctl option
58229 + with name "tpe_gid" is created.
58230 +
58231 +endmenu
58232 +menu "Network Protections"
58233 +depends on GRKERNSEC
58234 +
58235 +config GRKERNSEC_RANDNET
58236 + bool "Larger entropy pools"
58237 + default y if GRKERNSEC_CONFIG_AUTO
58238 + help
58239 + If you say Y here, the entropy pools used for many features of Linux
58240 + and grsecurity will be doubled in size. Since several grsecurity
58241 + features use additional randomness, it is recommended that you say Y
58242 + here. Saying Y here has a similar effect as modifying
58243 + /proc/sys/kernel/random/poolsize.
58244 +
58245 +config GRKERNSEC_BLACKHOLE
58246 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
58247 + default y if GRKERNSEC_CONFIG_AUTO
58248 + depends on NET
58249 + help
58250 + If you say Y here, neither TCP resets nor ICMP
58251 + destination-unreachable packets will be sent in response to packets
58252 + sent to ports for which no associated listening process exists.
58253 + This feature supports both IPV4 and IPV6 and exempts the
58254 + loopback interface from blackholing. Enabling this feature
58255 + makes a host more resilient to DoS attacks and reduces network
58256 + visibility against scanners.
58257 +
58258 + The blackhole feature as-implemented is equivalent to the FreeBSD
58259 + blackhole feature, as it prevents RST responses to all packets, not
58260 + just SYNs. Under most application behavior this causes no
58261 + problems, but applications (like haproxy) may not close certain
58262 + connections in a way that cleanly terminates them on the remote
58263 + end, leaving the remote host in LAST_ACK state. Because of this
58264 + side-effect and to prevent intentional LAST_ACK DoSes, this
58265 + feature also adds automatic mitigation against such attacks.
58266 + The mitigation drastically reduces the amount of time a socket
58267 + can spend in LAST_ACK state. If you're using haproxy and not
58268 + all servers it connects to have this option enabled, consider
58269 + disabling this feature on the haproxy host.
58270 +
58271 + If the sysctl option is enabled, two sysctl options with names
58272 + "ip_blackhole" and "lastack_retries" will be created.
58273 + While "ip_blackhole" takes the standard zero/non-zero on/off
58274 + toggle, "lastack_retries" uses the same kinds of values as
58275 + "tcp_retries1" and "tcp_retries2". The default value of 4
58276 + prevents a socket from lasting more than 45 seconds in LAST_ACK
58277 + state.
58278 +
58279 +config GRKERNSEC_NO_SIMULT_CONNECT
58280 + bool "Disable TCP Simultaneous Connect"
58281 + default y if GRKERNSEC_CONFIG_AUTO
58282 + depends on NET
58283 + help
58284 + If you say Y here, a feature by Willy Tarreau will be enabled that
58285 + removes a weakness in Linux's strict implementation of TCP that
58286 + allows two clients to connect to each other without either entering
58287 + a listening state. The weakness allows an attacker to easily prevent
58288 + a client from connecting to a known server provided the source port
58289 + for the connection is guessed correctly.
58290 +
58291 + As the weakness could be used to prevent an antivirus or IPS from
58292 + fetching updates, or prevent an SSL gateway from fetching a CRL,
58293 + it should be eliminated by enabling this option. Though Linux is
58294 + one of few operating systems supporting simultaneous connect, it
58295 + has no legitimate use in practice and is rarely supported by firewalls.
58296 +
58297 +config GRKERNSEC_SOCKET
58298 + bool "Socket restrictions"
58299 + depends on NET
58300 + help
58301 + If you say Y here, you will be able to choose from several options.
58302 + If you assign a GID on your system and add it to the supplementary
58303 + groups of users you want to restrict socket access to, this patch
58304 + will perform up to three things, based on the option(s) you choose.
58305 +
58306 +config GRKERNSEC_SOCKET_ALL
58307 + bool "Deny any sockets to group"
58308 + depends on GRKERNSEC_SOCKET
58309 + help
58310 + If you say Y here, you will be able to choose a GID of whose users will
58311 + be unable to connect to other hosts from your machine or run server
58312 + applications from your machine. If the sysctl option is enabled, a
58313 + sysctl option with name "socket_all" is created.
58314 +
58315 +config GRKERNSEC_SOCKET_ALL_GID
58316 + int "GID to deny all sockets for"
58317 + depends on GRKERNSEC_SOCKET_ALL
58318 + default 1004
58319 + help
58320 + Here you can choose the GID to disable socket access for. Remember to
58321 + add the users you want socket access disabled for to the GID
58322 + specified here. If the sysctl option is enabled, a sysctl option
58323 + with name "socket_all_gid" is created.
58324 +
58325 +config GRKERNSEC_SOCKET_CLIENT
58326 + bool "Deny client sockets to group"
58327 + depends on GRKERNSEC_SOCKET
58328 + help
58329 + If you say Y here, you will be able to choose a GID of whose users will
58330 + be unable to connect to other hosts from your machine, but will be
58331 + able to run servers. If this option is enabled, all users in the group
58332 + you specify will have to use passive mode when initiating ftp transfers
58333 + from the shell on your machine. If the sysctl option is enabled, a
58334 + sysctl option with name "socket_client" is created.
58335 +
58336 +config GRKERNSEC_SOCKET_CLIENT_GID
58337 + int "GID to deny client sockets for"
58338 + depends on GRKERNSEC_SOCKET_CLIENT
58339 + default 1003
58340 + help
58341 + Here you can choose the GID to disable client socket access for.
58342 + Remember to add the users you want client socket access disabled for to
58343 + the GID specified here. If the sysctl option is enabled, a sysctl
58344 + option with name "socket_client_gid" is created.
58345 +
58346 +config GRKERNSEC_SOCKET_SERVER
58347 + bool "Deny server sockets to group"
58348 + depends on GRKERNSEC_SOCKET
58349 + help
58350 + If you say Y here, you will be able to choose a GID of whose users will
58351 + be unable to run server applications from your machine. If the sysctl
58352 + option is enabled, a sysctl option with name "socket_server" is created.
58353 +
58354 +config GRKERNSEC_SOCKET_SERVER_GID
58355 + int "GID to deny server sockets for"
58356 + depends on GRKERNSEC_SOCKET_SERVER
58357 + default 1002
58358 + help
58359 + Here you can choose the GID to disable server socket access for.
58360 + Remember to add the users you want server socket access disabled for to
58361 + the GID specified here. If the sysctl option is enabled, a sysctl
58362 + option with name "socket_server_gid" is created.
58363 +
58364 +endmenu
58365 +menu "Sysctl Support"
58366 +depends on GRKERNSEC && SYSCTL
58367 +
58368 +config GRKERNSEC_SYSCTL
58369 + bool "Sysctl support"
58370 + default y if GRKERNSEC_CONFIG_AUTO
58371 + help
58372 + If you say Y here, you will be able to change the options that
58373 + grsecurity runs with at bootup, without having to recompile your
58374 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58375 + to enable (1) or disable (0) various features. All the sysctl entries
58376 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58377 + All features enabled in the kernel configuration are disabled at boot
58378 + if you do not say Y to the "Turn on features by default" option.
58379 + All options should be set at startup, and the grsec_lock entry should
58380 + be set to a non-zero value after all the options are set.
58381 + *THIS IS EXTREMELY IMPORTANT*
58382 +
58383 +config GRKERNSEC_SYSCTL_DISTRO
58384 + bool "Extra sysctl support for distro makers (READ HELP)"
58385 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58386 + help
58387 + If you say Y here, additional sysctl options will be created
58388 + for features that affect processes running as root. Therefore,
58389 + it is critical when using this option that the grsec_lock entry be
58390 + enabled after boot. Only distros with prebuilt kernel packages
58391 + with this option enabled that can ensure grsec_lock is enabled
58392 + after boot should use this option.
58393 + *Failure to set grsec_lock after boot makes all grsec features
58394 + this option covers useless*
58395 +
58396 + Currently this option creates the following sysctl entries:
58397 + "Disable Privileged I/O": "disable_priv_io"
58398 +
58399 +config GRKERNSEC_SYSCTL_ON
58400 + bool "Turn on features by default"
58401 + default y if GRKERNSEC_CONFIG_AUTO
58402 + depends on GRKERNSEC_SYSCTL
58403 + help
58404 + If you say Y here, instead of having all features enabled in the
58405 + kernel configuration disabled at boot time, the features will be
58406 + enabled at boot time. It is recommended you say Y here unless
58407 + there is some reason you would want all sysctl-tunable features to
58408 + be disabled by default. As mentioned elsewhere, it is important
58409 + to enable the grsec_lock entry once you have finished modifying
58410 + the sysctl entries.
58411 +
58412 +endmenu
58413 +menu "Logging Options"
58414 +depends on GRKERNSEC
58415 +
58416 +config GRKERNSEC_FLOODTIME
58417 + int "Seconds in between log messages (minimum)"
58418 + default 10
58419 + help
58420 + This option allows you to enforce the number of seconds between
58421 + grsecurity log messages. The default should be suitable for most
58422 + people, however, if you choose to change it, choose a value small enough
58423 + to allow informative logs to be produced, but large enough to
58424 + prevent flooding.
58425 +
58426 +config GRKERNSEC_FLOODBURST
58427 + int "Number of messages in a burst (maximum)"
58428 + default 6
58429 + help
58430 + This option allows you to choose the maximum number of messages allowed
58431 + within the flood time interval you chose in a separate option. The
58432 + default should be suitable for most people, however if you find that
58433 + many of your logs are being interpreted as flooding, you may want to
58434 + raise this value.
58435 +
58436 +endmenu
58437 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58438 new file mode 100644
58439 index 0000000..36845aa
58440 --- /dev/null
58441 +++ b/grsecurity/Makefile
58442 @@ -0,0 +1,42 @@
58443 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58444 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58445 +# into an RBAC system
58446 +#
58447 +# All code in this directory and various hooks inserted throughout the kernel
58448 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58449 +# under the GPL v2 or higher
58450 +
58451 +KBUILD_CFLAGS += -Werror
58452 +
58453 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58454 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58455 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58456 +
58457 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58458 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58459 + gracl_learn.o grsec_log.o
58460 +ifdef CONFIG_COMPAT
58461 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
58462 +endif
58463 +
58464 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58465 +
58466 +ifdef CONFIG_NET
58467 +obj-y += grsec_sock.o
58468 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58469 +endif
58470 +
58471 +ifndef CONFIG_GRKERNSEC
58472 +obj-y += grsec_disabled.o
58473 +endif
58474 +
58475 +ifdef CONFIG_GRKERNSEC_HIDESYM
58476 +extra-y := grsec_hidesym.o
58477 +$(obj)/grsec_hidesym.o:
58478 + @-chmod -f 500 /boot
58479 + @-chmod -f 500 /lib/modules
58480 + @-chmod -f 500 /lib64/modules
58481 + @-chmod -f 500 /lib32/modules
58482 + @-chmod -f 700 .
58483 + @echo ' grsec: protected kernel image paths'
58484 +endif
58485 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58486 new file mode 100644
58487 index 0000000..c0793fd
58488 --- /dev/null
58489 +++ b/grsecurity/gracl.c
58490 @@ -0,0 +1,4178 @@
58491 +#include <linux/kernel.h>
58492 +#include <linux/module.h>
58493 +#include <linux/sched.h>
58494 +#include <linux/mm.h>
58495 +#include <linux/file.h>
58496 +#include <linux/fs.h>
58497 +#include <linux/namei.h>
58498 +#include <linux/mount.h>
58499 +#include <linux/tty.h>
58500 +#include <linux/proc_fs.h>
58501 +#include <linux/lglock.h>
58502 +#include <linux/slab.h>
58503 +#include <linux/vmalloc.h>
58504 +#include <linux/types.h>
58505 +#include <linux/sysctl.h>
58506 +#include <linux/netdevice.h>
58507 +#include <linux/ptrace.h>
58508 +#include <linux/gracl.h>
58509 +#include <linux/gralloc.h>
58510 +#include <linux/security.h>
58511 +#include <linux/grinternal.h>
58512 +#include <linux/pid_namespace.h>
58513 +#include <linux/stop_machine.h>
58514 +#include <linux/fdtable.h>
58515 +#include <linux/percpu.h>
58516 +#include <linux/lglock.h>
58517 +#include <linux/hugetlb.h>
58518 +#include <linux/posix-timers.h>
58519 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58520 +#include <linux/magic.h>
58521 +#include <linux/pagemap.h>
58522 +#include "../fs/btrfs/async-thread.h"
58523 +#include "../fs/btrfs/ctree.h"
58524 +#include "../fs/btrfs/btrfs_inode.h"
58525 +#endif
58526 +#include "../fs/mount.h"
58527 +
58528 +#include <asm/uaccess.h>
58529 +#include <asm/errno.h>
58530 +#include <asm/mman.h>
58531 +
58532 +extern struct lglock vfsmount_lock;
58533 +
58534 +static struct acl_role_db acl_role_set;
58535 +static struct name_db name_set;
58536 +static struct inodev_db inodev_set;
58537 +
58538 +/* for keeping track of userspace pointers used for subjects, so we
58539 + can share references in the kernel as well
58540 +*/
58541 +
58542 +static struct path real_root;
58543 +
58544 +static struct acl_subj_map_db subj_map_set;
58545 +
58546 +static struct acl_role_label *default_role;
58547 +
58548 +static struct acl_role_label *role_list;
58549 +
58550 +static u16 acl_sp_role_value;
58551 +
58552 +extern char *gr_shared_page[4];
58553 +static DEFINE_MUTEX(gr_dev_mutex);
58554 +DEFINE_RWLOCK(gr_inode_lock);
58555 +
58556 +struct gr_arg *gr_usermode;
58557 +
58558 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58559 +
58560 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58561 +extern void gr_clear_learn_entries(void);
58562 +
58563 +unsigned char *gr_system_salt;
58564 +unsigned char *gr_system_sum;
58565 +
58566 +static struct sprole_pw **acl_special_roles = NULL;
58567 +static __u16 num_sprole_pws = 0;
58568 +
58569 +static struct acl_role_label *kernel_role = NULL;
58570 +
58571 +static unsigned int gr_auth_attempts = 0;
58572 +static unsigned long gr_auth_expires = 0UL;
58573 +
58574 +#ifdef CONFIG_NET
58575 +extern struct vfsmount *sock_mnt;
58576 +#endif
58577 +
58578 +extern struct vfsmount *pipe_mnt;
58579 +extern struct vfsmount *shm_mnt;
58580 +
58581 +#ifdef CONFIG_HUGETLBFS
58582 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58583 +#endif
58584 +
58585 +static struct acl_object_label *fakefs_obj_rw;
58586 +static struct acl_object_label *fakefs_obj_rwx;
58587 +
58588 +extern int gr_init_uidset(void);
58589 +extern void gr_free_uidset(void);
58590 +extern void gr_remove_uid(uid_t uid);
58591 +extern int gr_find_uid(uid_t uid);
58592 +
58593 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
58594 +{
58595 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
58596 + return -EFAULT;
58597 +
58598 + return 0;
58599 +}
58600 +
58601 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
58602 +{
58603 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
58604 + return -EFAULT;
58605 +
58606 + return 0;
58607 +}
58608 +
58609 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
58610 +{
58611 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
58612 + return -EFAULT;
58613 +
58614 + return 0;
58615 +}
58616 +
58617 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
58618 +{
58619 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
58620 + return -EFAULT;
58621 +
58622 + return 0;
58623 +}
58624 +
58625 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
58626 +{
58627 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
58628 + return -EFAULT;
58629 +
58630 + return 0;
58631 +}
58632 +
58633 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
58634 +{
58635 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
58636 + return -EFAULT;
58637 +
58638 + return 0;
58639 +}
58640 +
58641 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
58642 +{
58643 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
58644 + return -EFAULT;
58645 +
58646 + return 0;
58647 +}
58648 +
58649 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
58650 +{
58651 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
58652 + return -EFAULT;
58653 +
58654 + return 0;
58655 +}
58656 +
58657 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
58658 +{
58659 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
58660 + return -EFAULT;
58661 +
58662 + return 0;
58663 +}
58664 +
58665 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
58666 +{
58667 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
58668 + return -EFAULT;
58669 +
58670 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
58671 + return -EINVAL;
58672 +
58673 + return 0;
58674 +}
58675 +
58676 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
58677 +{
58678 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
58679 + return -EFAULT;
58680 +
58681 + return 0;
58682 +}
58683 +
58684 +static size_t get_gr_arg_wrapper_size_normal(void)
58685 +{
58686 + return sizeof(struct gr_arg_wrapper);
58687 +}
58688 +
58689 +#ifdef CONFIG_COMPAT
58690 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
58691 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
58692 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
58693 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
58694 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
58695 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
58696 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
58697 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
58698 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
58699 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
58700 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
58701 +extern size_t get_gr_arg_wrapper_size_compat(void);
58702 +
58703 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
58704 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
58705 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
58706 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
58707 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
58708 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
58709 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
58710 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
58711 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
58712 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
58713 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
58714 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
58715 +
58716 +#else
58717 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
58718 +#define copy_gr_arg copy_gr_arg_normal
58719 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
58720 +#define copy_acl_object_label copy_acl_object_label_normal
58721 +#define copy_acl_subject_label copy_acl_subject_label_normal
58722 +#define copy_acl_role_label copy_acl_role_label_normal
58723 +#define copy_acl_ip_label copy_acl_ip_label_normal
58724 +#define copy_pointer_from_array copy_pointer_from_array_normal
58725 +#define copy_sprole_pw copy_sprole_pw_normal
58726 +#define copy_role_transition copy_role_transition_normal
58727 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
58728 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
58729 +#endif
58730 +
58731 +__inline__ int
58732 +gr_acl_is_enabled(void)
58733 +{
58734 + return (gr_status & GR_READY);
58735 +}
58736 +
58737 +static inline dev_t __get_dev(const struct dentry *dentry)
58738 +{
58739 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58740 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58741 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58742 + else
58743 +#endif
58744 + return dentry->d_sb->s_dev;
58745 +}
58746 +
58747 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58748 +{
58749 + return __get_dev(dentry);
58750 +}
58751 +
58752 +static char gr_task_roletype_to_char(struct task_struct *task)
58753 +{
58754 + switch (task->role->roletype &
58755 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58756 + GR_ROLE_SPECIAL)) {
58757 + case GR_ROLE_DEFAULT:
58758 + return 'D';
58759 + case GR_ROLE_USER:
58760 + return 'U';
58761 + case GR_ROLE_GROUP:
58762 + return 'G';
58763 + case GR_ROLE_SPECIAL:
58764 + return 'S';
58765 + }
58766 +
58767 + return 'X';
58768 +}
58769 +
58770 +char gr_roletype_to_char(void)
58771 +{
58772 + return gr_task_roletype_to_char(current);
58773 +}
58774 +
58775 +__inline__ int
58776 +gr_acl_tpe_check(void)
58777 +{
58778 + if (unlikely(!(gr_status & GR_READY)))
58779 + return 0;
58780 + if (current->role->roletype & GR_ROLE_TPE)
58781 + return 1;
58782 + else
58783 + return 0;
58784 +}
58785 +
58786 +int
58787 +gr_handle_rawio(const struct inode *inode)
58788 +{
58789 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58790 + if (inode && S_ISBLK(inode->i_mode) &&
58791 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58792 + !capable(CAP_SYS_RAWIO))
58793 + return 1;
58794 +#endif
58795 + return 0;
58796 +}
58797 +
58798 +static int
58799 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58800 +{
58801 + if (likely(lena != lenb))
58802 + return 0;
58803 +
58804 + return !memcmp(a, b, lena);
58805 +}
58806 +
58807 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58808 +{
58809 + *buflen -= namelen;
58810 + if (*buflen < 0)
58811 + return -ENAMETOOLONG;
58812 + *buffer -= namelen;
58813 + memcpy(*buffer, str, namelen);
58814 + return 0;
58815 +}
58816 +
58817 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58818 +{
58819 + return prepend(buffer, buflen, name->name, name->len);
58820 +}
58821 +
58822 +static int prepend_path(const struct path *path, struct path *root,
58823 + char **buffer, int *buflen)
58824 +{
58825 + struct dentry *dentry = path->dentry;
58826 + struct vfsmount *vfsmnt = path->mnt;
58827 + struct mount *mnt = real_mount(vfsmnt);
58828 + bool slash = false;
58829 + int error = 0;
58830 +
58831 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58832 + struct dentry * parent;
58833 +
58834 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58835 + /* Global root? */
58836 + if (!mnt_has_parent(mnt)) {
58837 + goto out;
58838 + }
58839 + dentry = mnt->mnt_mountpoint;
58840 + mnt = mnt->mnt_parent;
58841 + vfsmnt = &mnt->mnt;
58842 + continue;
58843 + }
58844 + parent = dentry->d_parent;
58845 + prefetch(parent);
58846 + spin_lock(&dentry->d_lock);
58847 + error = prepend_name(buffer, buflen, &dentry->d_name);
58848 + spin_unlock(&dentry->d_lock);
58849 + if (!error)
58850 + error = prepend(buffer, buflen, "/", 1);
58851 + if (error)
58852 + break;
58853 +
58854 + slash = true;
58855 + dentry = parent;
58856 + }
58857 +
58858 +out:
58859 + if (!error && !slash)
58860 + error = prepend(buffer, buflen, "/", 1);
58861 +
58862 + return error;
58863 +}
58864 +
58865 +/* this must be called with vfsmount_lock and rename_lock held */
58866 +
58867 +static char *__our_d_path(const struct path *path, struct path *root,
58868 + char *buf, int buflen)
58869 +{
58870 + char *res = buf + buflen;
58871 + int error;
58872 +
58873 + prepend(&res, &buflen, "\0", 1);
58874 + error = prepend_path(path, root, &res, &buflen);
58875 + if (error)
58876 + return ERR_PTR(error);
58877 +
58878 + return res;
58879 +}
58880 +
58881 +static char *
58882 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58883 +{
58884 + char *retval;
58885 +
58886 + retval = __our_d_path(path, root, buf, buflen);
58887 + if (unlikely(IS_ERR(retval)))
58888 + retval = strcpy(buf, "<path too long>");
58889 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58890 + retval[1] = '\0';
58891 +
58892 + return retval;
58893 +}
58894 +
58895 +static char *
58896 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58897 + char *buf, int buflen)
58898 +{
58899 + struct path path;
58900 + char *res;
58901 +
58902 + path.dentry = (struct dentry *)dentry;
58903 + path.mnt = (struct vfsmount *)vfsmnt;
58904 +
58905 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58906 + by the RBAC system */
58907 + res = gen_full_path(&path, &real_root, buf, buflen);
58908 +
58909 + return res;
58910 +}
58911 +
58912 +static char *
58913 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58914 + char *buf, int buflen)
58915 +{
58916 + char *res;
58917 + struct path path;
58918 + struct path root;
58919 + struct task_struct *reaper = init_pid_ns.child_reaper;
58920 +
58921 + path.dentry = (struct dentry *)dentry;
58922 + path.mnt = (struct vfsmount *)vfsmnt;
58923 +
58924 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58925 + get_fs_root(reaper->fs, &root);
58926 +
58927 + br_read_lock(&vfsmount_lock);
58928 + write_seqlock(&rename_lock);
58929 + res = gen_full_path(&path, &root, buf, buflen);
58930 + write_sequnlock(&rename_lock);
58931 + br_read_unlock(&vfsmount_lock);
58932 +
58933 + path_put(&root);
58934 + return res;
58935 +}
58936 +
58937 +static char *
58938 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58939 +{
58940 + char *ret;
58941 + br_read_lock(&vfsmount_lock);
58942 + write_seqlock(&rename_lock);
58943 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58944 + PAGE_SIZE);
58945 + write_sequnlock(&rename_lock);
58946 + br_read_unlock(&vfsmount_lock);
58947 + return ret;
58948 +}
58949 +
58950 +static char *
58951 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58952 +{
58953 + char *ret;
58954 + char *buf;
58955 + int buflen;
58956 +
58957 + br_read_lock(&vfsmount_lock);
58958 + write_seqlock(&rename_lock);
58959 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58960 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58961 + buflen = (int)(ret - buf);
58962 + if (buflen >= 5)
58963 + prepend(&ret, &buflen, "/proc", 5);
58964 + else
58965 + ret = strcpy(buf, "<path too long>");
58966 + write_sequnlock(&rename_lock);
58967 + br_read_unlock(&vfsmount_lock);
58968 + return ret;
58969 +}
58970 +
58971 +char *
58972 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58973 +{
58974 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58975 + PAGE_SIZE);
58976 +}
58977 +
58978 +char *
58979 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58980 +{
58981 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58982 + PAGE_SIZE);
58983 +}
58984 +
58985 +char *
58986 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58987 +{
58988 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58989 + PAGE_SIZE);
58990 +}
58991 +
58992 +char *
58993 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58994 +{
58995 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58996 + PAGE_SIZE);
58997 +}
58998 +
58999 +char *
59000 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
59001 +{
59002 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
59003 + PAGE_SIZE);
59004 +}
59005 +
59006 +__inline__ __u32
59007 +to_gr_audit(const __u32 reqmode)
59008 +{
59009 + /* masks off auditable permission flags, then shifts them to create
59010 + auditing flags, and adds the special case of append auditing if
59011 + we're requesting write */
59012 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
59013 +}
59014 +
59015 +struct acl_subject_label *
59016 +lookup_subject_map(const struct acl_subject_label *userp)
59017 +{
59018 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
59019 + struct subject_map *match;
59020 +
59021 + match = subj_map_set.s_hash[index];
59022 +
59023 + while (match && match->user != userp)
59024 + match = match->next;
59025 +
59026 + if (match != NULL)
59027 + return match->kernel;
59028 + else
59029 + return NULL;
59030 +}
59031 +
59032 +static void
59033 +insert_subj_map_entry(struct subject_map *subjmap)
59034 +{
59035 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
59036 + struct subject_map **curr;
59037 +
59038 + subjmap->prev = NULL;
59039 +
59040 + curr = &subj_map_set.s_hash[index];
59041 + if (*curr != NULL)
59042 + (*curr)->prev = subjmap;
59043 +
59044 + subjmap->next = *curr;
59045 + *curr = subjmap;
59046 +
59047 + return;
59048 +}
59049 +
59050 +static struct acl_role_label *
59051 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
59052 + const gid_t gid)
59053 +{
59054 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
59055 + struct acl_role_label *match;
59056 + struct role_allowed_ip *ipp;
59057 + unsigned int x;
59058 + u32 curr_ip = task->signal->curr_ip;
59059 +
59060 + task->signal->saved_ip = curr_ip;
59061 +
59062 + match = acl_role_set.r_hash[index];
59063 +
59064 + while (match) {
59065 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
59066 + for (x = 0; x < match->domain_child_num; x++) {
59067 + if (match->domain_children[x] == uid)
59068 + goto found;
59069 + }
59070 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
59071 + break;
59072 + match = match->next;
59073 + }
59074 +found:
59075 + if (match == NULL) {
59076 + try_group:
59077 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
59078 + match = acl_role_set.r_hash[index];
59079 +
59080 + while (match) {
59081 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
59082 + for (x = 0; x < match->domain_child_num; x++) {
59083 + if (match->domain_children[x] == gid)
59084 + goto found2;
59085 + }
59086 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
59087 + break;
59088 + match = match->next;
59089 + }
59090 +found2:
59091 + if (match == NULL)
59092 + match = default_role;
59093 + if (match->allowed_ips == NULL)
59094 + return match;
59095 + else {
59096 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
59097 + if (likely
59098 + ((ntohl(curr_ip) & ipp->netmask) ==
59099 + (ntohl(ipp->addr) & ipp->netmask)))
59100 + return match;
59101 + }
59102 + match = default_role;
59103 + }
59104 + } else if (match->allowed_ips == NULL) {
59105 + return match;
59106 + } else {
59107 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
59108 + if (likely
59109 + ((ntohl(curr_ip) & ipp->netmask) ==
59110 + (ntohl(ipp->addr) & ipp->netmask)))
59111 + return match;
59112 + }
59113 + goto try_group;
59114 + }
59115 +
59116 + return match;
59117 +}
59118 +
59119 +struct acl_subject_label *
59120 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
59121 + const struct acl_role_label *role)
59122 +{
59123 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
59124 + struct acl_subject_label *match;
59125 +
59126 + match = role->subj_hash[index];
59127 +
59128 + while (match && (match->inode != ino || match->device != dev ||
59129 + (match->mode & GR_DELETED))) {
59130 + match = match->next;
59131 + }
59132 +
59133 + if (match && !(match->mode & GR_DELETED))
59134 + return match;
59135 + else
59136 + return NULL;
59137 +}
59138 +
59139 +struct acl_subject_label *
59140 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
59141 + const struct acl_role_label *role)
59142 +{
59143 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
59144 + struct acl_subject_label *match;
59145 +
59146 + match = role->subj_hash[index];
59147 +
59148 + while (match && (match->inode != ino || match->device != dev ||
59149 + !(match->mode & GR_DELETED))) {
59150 + match = match->next;
59151 + }
59152 +
59153 + if (match && (match->mode & GR_DELETED))
59154 + return match;
59155 + else
59156 + return NULL;
59157 +}
59158 +
59159 +static struct acl_object_label *
59160 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
59161 + const struct acl_subject_label *subj)
59162 +{
59163 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
59164 + struct acl_object_label *match;
59165 +
59166 + match = subj->obj_hash[index];
59167 +
59168 + while (match && (match->inode != ino || match->device != dev ||
59169 + (match->mode & GR_DELETED))) {
59170 + match = match->next;
59171 + }
59172 +
59173 + if (match && !(match->mode & GR_DELETED))
59174 + return match;
59175 + else
59176 + return NULL;
59177 +}
59178 +
59179 +static struct acl_object_label *
59180 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
59181 + const struct acl_subject_label *subj)
59182 +{
59183 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
59184 + struct acl_object_label *match;
59185 +
59186 + match = subj->obj_hash[index];
59187 +
59188 + while (match && (match->inode != ino || match->device != dev ||
59189 + !(match->mode & GR_DELETED))) {
59190 + match = match->next;
59191 + }
59192 +
59193 + if (match && (match->mode & GR_DELETED))
59194 + return match;
59195 +
59196 + match = subj->obj_hash[index];
59197 +
59198 + while (match && (match->inode != ino || match->device != dev ||
59199 + (match->mode & GR_DELETED))) {
59200 + match = match->next;
59201 + }
59202 +
59203 + if (match && !(match->mode & GR_DELETED))
59204 + return match;
59205 + else
59206 + return NULL;
59207 +}
59208 +
59209 +static struct name_entry *
59210 +lookup_name_entry(const char *name)
59211 +{
59212 + unsigned int len = strlen(name);
59213 + unsigned int key = full_name_hash(name, len);
59214 + unsigned int index = key % name_set.n_size;
59215 + struct name_entry *match;
59216 +
59217 + match = name_set.n_hash[index];
59218 +
59219 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
59220 + match = match->next;
59221 +
59222 + return match;
59223 +}
59224 +
59225 +static struct name_entry *
59226 +lookup_name_entry_create(const char *name)
59227 +{
59228 + unsigned int len = strlen(name);
59229 + unsigned int key = full_name_hash(name, len);
59230 + unsigned int index = key % name_set.n_size;
59231 + struct name_entry *match;
59232 +
59233 + match = name_set.n_hash[index];
59234 +
59235 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
59236 + !match->deleted))
59237 + match = match->next;
59238 +
59239 + if (match && match->deleted)
59240 + return match;
59241 +
59242 + match = name_set.n_hash[index];
59243 +
59244 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
59245 + match->deleted))
59246 + match = match->next;
59247 +
59248 + if (match && !match->deleted)
59249 + return match;
59250 + else
59251 + return NULL;
59252 +}
59253 +
59254 +static struct inodev_entry *
59255 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
59256 +{
59257 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
59258 + struct inodev_entry *match;
59259 +
59260 + match = inodev_set.i_hash[index];
59261 +
59262 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
59263 + match = match->next;
59264 +
59265 + return match;
59266 +}
59267 +
59268 +static void
59269 +insert_inodev_entry(struct inodev_entry *entry)
59270 +{
59271 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
59272 + inodev_set.i_size);
59273 + struct inodev_entry **curr;
59274 +
59275 + entry->prev = NULL;
59276 +
59277 + curr = &inodev_set.i_hash[index];
59278 + if (*curr != NULL)
59279 + (*curr)->prev = entry;
59280 +
59281 + entry->next = *curr;
59282 + *curr = entry;
59283 +
59284 + return;
59285 +}
59286 +
59287 +static void
59288 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
59289 +{
59290 + unsigned int index =
59291 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
59292 + struct acl_role_label **curr;
59293 + struct acl_role_label *tmp, *tmp2;
59294 +
59295 + curr = &acl_role_set.r_hash[index];
59296 +
59297 + /* simple case, slot is empty, just set it to our role */
59298 + if (*curr == NULL) {
59299 + *curr = role;
59300 + } else {
59301 + /* example:
59302 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
59303 + 2 -> 3
59304 + */
59305 + /* first check to see if we can already be reached via this slot */
59306 + tmp = *curr;
59307 + while (tmp && tmp != role)
59308 + tmp = tmp->next;
59309 + if (tmp == role) {
59310 + /* we don't need to add ourselves to this slot's chain */
59311 + return;
59312 + }
59313 + /* we need to add ourselves to this chain, two cases */
59314 + if (role->next == NULL) {
59315 + /* simple case, append the current chain to our role */
59316 + role->next = *curr;
59317 + *curr = role;
59318 + } else {
59319 + /* 1 -> 2 -> 3 -> 4
59320 + 2 -> 3 -> 4
59321 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
59322 + */
59323 + /* trickier case: walk our role's chain until we find
59324 + the role for the start of the current slot's chain */
59325 + tmp = role;
59326 + tmp2 = *curr;
59327 + while (tmp->next && tmp->next != tmp2)
59328 + tmp = tmp->next;
59329 + if (tmp->next == tmp2) {
59330 + /* from example above, we found 3, so just
59331 + replace this slot's chain with ours */
59332 + *curr = role;
59333 + } else {
59334 + /* we didn't find a subset of our role's chain
59335 + in the current slot's chain, so append their
59336 + chain to ours, and set us as the first role in
59337 + the slot's chain
59338 +
59339 + we could fold this case with the case above,
59340 + but making it explicit for clarity
59341 + */
59342 + tmp->next = tmp2;
59343 + *curr = role;
59344 + }
59345 + }
59346 + }
59347 +
59348 + return;
59349 +}
59350 +
59351 +static void
59352 +insert_acl_role_label(struct acl_role_label *role)
59353 +{
59354 + int i;
59355 +
59356 + if (role_list == NULL) {
59357 + role_list = role;
59358 + role->prev = NULL;
59359 + } else {
59360 + role->prev = role_list;
59361 + role_list = role;
59362 + }
59363 +
59364 + /* used for hash chains */
59365 + role->next = NULL;
59366 +
59367 + if (role->roletype & GR_ROLE_DOMAIN) {
59368 + for (i = 0; i < role->domain_child_num; i++)
59369 + __insert_acl_role_label(role, role->domain_children[i]);
59370 + } else
59371 + __insert_acl_role_label(role, role->uidgid);
59372 +}
59373 +
59374 +static int
59375 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
59376 +{
59377 + struct name_entry **curr, *nentry;
59378 + struct inodev_entry *ientry;
59379 + unsigned int len = strlen(name);
59380 + unsigned int key = full_name_hash(name, len);
59381 + unsigned int index = key % name_set.n_size;
59382 +
59383 + curr = &name_set.n_hash[index];
59384 +
59385 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
59386 + curr = &((*curr)->next);
59387 +
59388 + if (*curr != NULL)
59389 + return 1;
59390 +
59391 + nentry = acl_alloc(sizeof (struct name_entry));
59392 + if (nentry == NULL)
59393 + return 0;
59394 + ientry = acl_alloc(sizeof (struct inodev_entry));
59395 + if (ientry == NULL)
59396 + return 0;
59397 + ientry->nentry = nentry;
59398 +
59399 + nentry->key = key;
59400 + nentry->name = name;
59401 + nentry->inode = inode;
59402 + nentry->device = device;
59403 + nentry->len = len;
59404 + nentry->deleted = deleted;
59405 +
59406 + nentry->prev = NULL;
59407 + curr = &name_set.n_hash[index];
59408 + if (*curr != NULL)
59409 + (*curr)->prev = nentry;
59410 + nentry->next = *curr;
59411 + *curr = nentry;
59412 +
59413 + /* insert us into the table searchable by inode/dev */
59414 + insert_inodev_entry(ientry);
59415 +
59416 + return 1;
59417 +}
59418 +
59419 +static void
59420 +insert_acl_obj_label(struct acl_object_label *obj,
59421 + struct acl_subject_label *subj)
59422 +{
59423 + unsigned int index =
59424 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
59425 + struct acl_object_label **curr;
59426 +
59427 +
59428 + obj->prev = NULL;
59429 +
59430 + curr = &subj->obj_hash[index];
59431 + if (*curr != NULL)
59432 + (*curr)->prev = obj;
59433 +
59434 + obj->next = *curr;
59435 + *curr = obj;
59436 +
59437 + return;
59438 +}
59439 +
59440 +static void
59441 +insert_acl_subj_label(struct acl_subject_label *obj,
59442 + struct acl_role_label *role)
59443 +{
59444 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59445 + struct acl_subject_label **curr;
59446 +
59447 + obj->prev = NULL;
59448 +
59449 + curr = &role->subj_hash[index];
59450 + if (*curr != NULL)
59451 + (*curr)->prev = obj;
59452 +
59453 + obj->next = *curr;
59454 + *curr = obj;
59455 +
59456 + return;
59457 +}
59458 +
59459 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59460 +
59461 +static void *
59462 +create_table(__u32 * len, int elementsize)
59463 +{
59464 + unsigned int table_sizes[] = {
59465 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59466 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59467 + 4194301, 8388593, 16777213, 33554393, 67108859
59468 + };
59469 + void *newtable = NULL;
59470 + unsigned int pwr = 0;
59471 +
59472 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59473 + table_sizes[pwr] <= *len)
59474 + pwr++;
59475 +
59476 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59477 + return newtable;
59478 +
59479 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59480 + newtable =
59481 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59482 + else
59483 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59484 +
59485 + *len = table_sizes[pwr];
59486 +
59487 + return newtable;
59488 +}
59489 +
59490 +static int
59491 +init_variables(const struct gr_arg *arg)
59492 +{
59493 + struct task_struct *reaper = init_pid_ns.child_reaper;
59494 + unsigned int stacksize;
59495 +
59496 + subj_map_set.s_size = arg->role_db.num_subjects;
59497 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59498 + name_set.n_size = arg->role_db.num_objects;
59499 + inodev_set.i_size = arg->role_db.num_objects;
59500 +
59501 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59502 + !name_set.n_size || !inodev_set.i_size)
59503 + return 1;
59504 +
59505 + if (!gr_init_uidset())
59506 + return 1;
59507 +
59508 + /* set up the stack that holds allocation info */
59509 +
59510 + stacksize = arg->role_db.num_pointers + 5;
59511 +
59512 + if (!acl_alloc_stack_init(stacksize))
59513 + return 1;
59514 +
59515 + /* grab reference for the real root dentry and vfsmount */
59516 + get_fs_root(reaper->fs, &real_root);
59517 +
59518 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59519 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59520 +#endif
59521 +
59522 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59523 + if (fakefs_obj_rw == NULL)
59524 + return 1;
59525 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59526 +
59527 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59528 + if (fakefs_obj_rwx == NULL)
59529 + return 1;
59530 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59531 +
59532 + subj_map_set.s_hash =
59533 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59534 + acl_role_set.r_hash =
59535 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59536 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59537 + inodev_set.i_hash =
59538 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59539 +
59540 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59541 + !name_set.n_hash || !inodev_set.i_hash)
59542 + return 1;
59543 +
59544 + memset(subj_map_set.s_hash, 0,
59545 + sizeof(struct subject_map *) * subj_map_set.s_size);
59546 + memset(acl_role_set.r_hash, 0,
59547 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59548 + memset(name_set.n_hash, 0,
59549 + sizeof (struct name_entry *) * name_set.n_size);
59550 + memset(inodev_set.i_hash, 0,
59551 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59552 +
59553 + return 0;
59554 +}
59555 +
59556 +/* free information not needed after startup
59557 + currently contains user->kernel pointer mappings for subjects
59558 +*/
59559 +
59560 +static void
59561 +free_init_variables(void)
59562 +{
59563 + __u32 i;
59564 +
59565 + if (subj_map_set.s_hash) {
59566 + for (i = 0; i < subj_map_set.s_size; i++) {
59567 + if (subj_map_set.s_hash[i]) {
59568 + kfree(subj_map_set.s_hash[i]);
59569 + subj_map_set.s_hash[i] = NULL;
59570 + }
59571 + }
59572 +
59573 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59574 + PAGE_SIZE)
59575 + kfree(subj_map_set.s_hash);
59576 + else
59577 + vfree(subj_map_set.s_hash);
59578 + }
59579 +
59580 + return;
59581 +}
59582 +
59583 +static void
59584 +free_variables(void)
59585 +{
59586 + struct acl_subject_label *s;
59587 + struct acl_role_label *r;
59588 + struct task_struct *task, *task2;
59589 + unsigned int x;
59590 +
59591 + gr_clear_learn_entries();
59592 +
59593 + read_lock(&tasklist_lock);
59594 + do_each_thread(task2, task) {
59595 + task->acl_sp_role = 0;
59596 + task->acl_role_id = 0;
59597 + task->acl = NULL;
59598 + task->role = NULL;
59599 + } while_each_thread(task2, task);
59600 + read_unlock(&tasklist_lock);
59601 +
59602 + /* release the reference to the real root dentry and vfsmount */
59603 + path_put(&real_root);
59604 + memset(&real_root, 0, sizeof(real_root));
59605 +
59606 + /* free all object hash tables */
59607 +
59608 + FOR_EACH_ROLE_START(r)
59609 + if (r->subj_hash == NULL)
59610 + goto next_role;
59611 + FOR_EACH_SUBJECT_START(r, s, x)
59612 + if (s->obj_hash == NULL)
59613 + break;
59614 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59615 + kfree(s->obj_hash);
59616 + else
59617 + vfree(s->obj_hash);
59618 + FOR_EACH_SUBJECT_END(s, x)
59619 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59620 + if (s->obj_hash == NULL)
59621 + break;
59622 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59623 + kfree(s->obj_hash);
59624 + else
59625 + vfree(s->obj_hash);
59626 + FOR_EACH_NESTED_SUBJECT_END(s)
59627 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59628 + kfree(r->subj_hash);
59629 + else
59630 + vfree(r->subj_hash);
59631 + r->subj_hash = NULL;
59632 +next_role:
59633 + FOR_EACH_ROLE_END(r)
59634 +
59635 + acl_free_all();
59636 +
59637 + if (acl_role_set.r_hash) {
59638 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59639 + PAGE_SIZE)
59640 + kfree(acl_role_set.r_hash);
59641 + else
59642 + vfree(acl_role_set.r_hash);
59643 + }
59644 + if (name_set.n_hash) {
59645 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59646 + PAGE_SIZE)
59647 + kfree(name_set.n_hash);
59648 + else
59649 + vfree(name_set.n_hash);
59650 + }
59651 +
59652 + if (inodev_set.i_hash) {
59653 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59654 + PAGE_SIZE)
59655 + kfree(inodev_set.i_hash);
59656 + else
59657 + vfree(inodev_set.i_hash);
59658 + }
59659 +
59660 + gr_free_uidset();
59661 +
59662 + memset(&name_set, 0, sizeof (struct name_db));
59663 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59664 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59665 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59666 +
59667 + default_role = NULL;
59668 + kernel_role = NULL;
59669 + role_list = NULL;
59670 +
59671 + return;
59672 +}
59673 +
59674 +static struct acl_subject_label *
59675 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59676 +
59677 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
59678 +{
59679 + unsigned int len = strnlen_user(*name, maxlen);
59680 + char *tmp;
59681 +
59682 + if (!len || len >= maxlen)
59683 + return -EINVAL;
59684 +
59685 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59686 + return -ENOMEM;
59687 +
59688 + if (copy_from_user(tmp, *name, len))
59689 + return -EFAULT;
59690 +
59691 + tmp[len-1] = '\0';
59692 + *name = tmp;
59693 +
59694 + return 0;
59695 +}
59696 +
59697 +static int
59698 +copy_user_glob(struct acl_object_label *obj)
59699 +{
59700 + struct acl_object_label *g_tmp, **guser;
59701 + int error;
59702 +
59703 + if (obj->globbed == NULL)
59704 + return 0;
59705 +
59706 + guser = &obj->globbed;
59707 + while (*guser) {
59708 + g_tmp = (struct acl_object_label *)
59709 + acl_alloc(sizeof (struct acl_object_label));
59710 + if (g_tmp == NULL)
59711 + return -ENOMEM;
59712 +
59713 + if (copy_acl_object_label(g_tmp, *guser))
59714 + return -EFAULT;
59715 +
59716 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
59717 + if (error)
59718 + return error;
59719 +
59720 + *guser = g_tmp;
59721 + guser = &(g_tmp->next);
59722 + }
59723 +
59724 + return 0;
59725 +}
59726 +
59727 +static int
59728 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59729 + struct acl_role_label *role)
59730 +{
59731 + struct acl_object_label *o_tmp;
59732 + int ret;
59733 +
59734 + while (userp) {
59735 + if ((o_tmp = (struct acl_object_label *)
59736 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59737 + return -ENOMEM;
59738 +
59739 + if (copy_acl_object_label(o_tmp, userp))
59740 + return -EFAULT;
59741 +
59742 + userp = o_tmp->prev;
59743 +
59744 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
59745 + if (ret)
59746 + return ret;
59747 +
59748 + insert_acl_obj_label(o_tmp, subj);
59749 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59750 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59751 + return -ENOMEM;
59752 +
59753 + ret = copy_user_glob(o_tmp);
59754 + if (ret)
59755 + return ret;
59756 +
59757 + if (o_tmp->nested) {
59758 + int already_copied;
59759 +
59760 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59761 + if (IS_ERR(o_tmp->nested))
59762 + return PTR_ERR(o_tmp->nested);
59763 +
59764 + /* insert into nested subject list if we haven't copied this one yet
59765 + to prevent duplicate entries */
59766 + if (!already_copied) {
59767 + o_tmp->nested->next = role->hash->first;
59768 + role->hash->first = o_tmp->nested;
59769 + }
59770 + }
59771 + }
59772 +
59773 + return 0;
59774 +}
59775 +
59776 +static __u32
59777 +count_user_subjs(struct acl_subject_label *userp)
59778 +{
59779 + struct acl_subject_label s_tmp;
59780 + __u32 num = 0;
59781 +
59782 + while (userp) {
59783 + if (copy_acl_subject_label(&s_tmp, userp))
59784 + break;
59785 +
59786 + userp = s_tmp.prev;
59787 + }
59788 +
59789 + return num;
59790 +}
59791 +
59792 +static int
59793 +copy_user_allowedips(struct acl_role_label *rolep)
59794 +{
59795 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59796 +
59797 + ruserip = rolep->allowed_ips;
59798 +
59799 + while (ruserip) {
59800 + rlast = rtmp;
59801 +
59802 + if ((rtmp = (struct role_allowed_ip *)
59803 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59804 + return -ENOMEM;
59805 +
59806 + if (copy_role_allowed_ip(rtmp, ruserip))
59807 + return -EFAULT;
59808 +
59809 + ruserip = rtmp->prev;
59810 +
59811 + if (!rlast) {
59812 + rtmp->prev = NULL;
59813 + rolep->allowed_ips = rtmp;
59814 + } else {
59815 + rlast->next = rtmp;
59816 + rtmp->prev = rlast;
59817 + }
59818 +
59819 + if (!ruserip)
59820 + rtmp->next = NULL;
59821 + }
59822 +
59823 + return 0;
59824 +}
59825 +
59826 +static int
59827 +copy_user_transitions(struct acl_role_label *rolep)
59828 +{
59829 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59830 + int error;
59831 +
59832 + rusertp = rolep->transitions;
59833 +
59834 + while (rusertp) {
59835 + rlast = rtmp;
59836 +
59837 + if ((rtmp = (struct role_transition *)
59838 + acl_alloc(sizeof (struct role_transition))) == NULL)
59839 + return -ENOMEM;
59840 +
59841 + if (copy_role_transition(rtmp, rusertp))
59842 + return -EFAULT;
59843 +
59844 + rusertp = rtmp->prev;
59845 +
59846 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
59847 + if (error)
59848 + return error;
59849 +
59850 + if (!rlast) {
59851 + rtmp->prev = NULL;
59852 + rolep->transitions = rtmp;
59853 + } else {
59854 + rlast->next = rtmp;
59855 + rtmp->prev = rlast;
59856 + }
59857 +
59858 + if (!rusertp)
59859 + rtmp->next = NULL;
59860 + }
59861 +
59862 + return 0;
59863 +}
59864 +
59865 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
59866 +{
59867 + struct acl_object_label o_tmp;
59868 + __u32 num = 0;
59869 +
59870 + while (userp) {
59871 + if (copy_acl_object_label(&o_tmp, userp))
59872 + break;
59873 +
59874 + userp = o_tmp.prev;
59875 + num++;
59876 + }
59877 +
59878 + return num;
59879 +}
59880 +
59881 +static struct acl_subject_label *
59882 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59883 +{
59884 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59885 + __u32 num_objs;
59886 + struct acl_ip_label **i_tmp, *i_utmp2;
59887 + struct gr_hash_struct ghash;
59888 + struct subject_map *subjmap;
59889 + unsigned int i_num;
59890 + int err;
59891 +
59892 + if (already_copied != NULL)
59893 + *already_copied = 0;
59894 +
59895 + s_tmp = lookup_subject_map(userp);
59896 +
59897 + /* we've already copied this subject into the kernel, just return
59898 + the reference to it, and don't copy it over again
59899 + */
59900 + if (s_tmp) {
59901 + if (already_copied != NULL)
59902 + *already_copied = 1;
59903 + return(s_tmp);
59904 + }
59905 +
59906 + if ((s_tmp = (struct acl_subject_label *)
59907 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59908 + return ERR_PTR(-ENOMEM);
59909 +
59910 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59911 + if (subjmap == NULL)
59912 + return ERR_PTR(-ENOMEM);
59913 +
59914 + subjmap->user = userp;
59915 + subjmap->kernel = s_tmp;
59916 + insert_subj_map_entry(subjmap);
59917 +
59918 + if (copy_acl_subject_label(s_tmp, userp))
59919 + return ERR_PTR(-EFAULT);
59920 +
59921 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
59922 + if (err)
59923 + return ERR_PTR(err);
59924 +
59925 + if (!strcmp(s_tmp->filename, "/"))
59926 + role->root_label = s_tmp;
59927 +
59928 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
59929 + return ERR_PTR(-EFAULT);
59930 +
59931 + /* copy user and group transition tables */
59932 +
59933 + if (s_tmp->user_trans_num) {
59934 + uid_t *uidlist;
59935 +
59936 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59937 + if (uidlist == NULL)
59938 + return ERR_PTR(-ENOMEM);
59939 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59940 + return ERR_PTR(-EFAULT);
59941 +
59942 + s_tmp->user_transitions = uidlist;
59943 + }
59944 +
59945 + if (s_tmp->group_trans_num) {
59946 + gid_t *gidlist;
59947 +
59948 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59949 + if (gidlist == NULL)
59950 + return ERR_PTR(-ENOMEM);
59951 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59952 + return ERR_PTR(-EFAULT);
59953 +
59954 + s_tmp->group_transitions = gidlist;
59955 + }
59956 +
59957 + /* set up object hash table */
59958 + num_objs = count_user_objs(ghash.first);
59959 +
59960 + s_tmp->obj_hash_size = num_objs;
59961 + s_tmp->obj_hash =
59962 + (struct acl_object_label **)
59963 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59964 +
59965 + if (!s_tmp->obj_hash)
59966 + return ERR_PTR(-ENOMEM);
59967 +
59968 + memset(s_tmp->obj_hash, 0,
59969 + s_tmp->obj_hash_size *
59970 + sizeof (struct acl_object_label *));
59971 +
59972 + /* add in objects */
59973 + err = copy_user_objs(ghash.first, s_tmp, role);
59974 +
59975 + if (err)
59976 + return ERR_PTR(err);
59977 +
59978 + /* set pointer for parent subject */
59979 + if (s_tmp->parent_subject) {
59980 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59981 +
59982 + if (IS_ERR(s_tmp2))
59983 + return s_tmp2;
59984 +
59985 + s_tmp->parent_subject = s_tmp2;
59986 + }
59987 +
59988 + /* add in ip acls */
59989 +
59990 + if (!s_tmp->ip_num) {
59991 + s_tmp->ips = NULL;
59992 + goto insert;
59993 + }
59994 +
59995 + i_tmp =
59996 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59997 + sizeof (struct acl_ip_label *));
59998 +
59999 + if (!i_tmp)
60000 + return ERR_PTR(-ENOMEM);
60001 +
60002 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
60003 + *(i_tmp + i_num) =
60004 + (struct acl_ip_label *)
60005 + acl_alloc(sizeof (struct acl_ip_label));
60006 + if (!*(i_tmp + i_num))
60007 + return ERR_PTR(-ENOMEM);
60008 +
60009 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
60010 + return ERR_PTR(-EFAULT);
60011 +
60012 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
60013 + return ERR_PTR(-EFAULT);
60014 +
60015 + if ((*(i_tmp + i_num))->iface == NULL)
60016 + continue;
60017 +
60018 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
60019 + if (err)
60020 + return ERR_PTR(err);
60021 + }
60022 +
60023 + s_tmp->ips = i_tmp;
60024 +
60025 +insert:
60026 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
60027 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
60028 + return ERR_PTR(-ENOMEM);
60029 +
60030 + return s_tmp;
60031 +}
60032 +
60033 +static int
60034 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
60035 +{
60036 + struct acl_subject_label s_pre;
60037 + struct acl_subject_label * ret;
60038 + int err;
60039 +
60040 + while (userp) {
60041 + if (copy_acl_subject_label(&s_pre, userp))
60042 + return -EFAULT;
60043 +
60044 + ret = do_copy_user_subj(userp, role, NULL);
60045 +
60046 + err = PTR_ERR(ret);
60047 + if (IS_ERR(ret))
60048 + return err;
60049 +
60050 + insert_acl_subj_label(ret, role);
60051 +
60052 + userp = s_pre.prev;
60053 + }
60054 +
60055 + return 0;
60056 +}
60057 +
60058 +static int
60059 +copy_user_acl(struct gr_arg *arg)
60060 +{
60061 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
60062 + struct acl_subject_label *subj_list;
60063 + struct sprole_pw *sptmp;
60064 + struct gr_hash_struct *ghash;
60065 + uid_t *domainlist;
60066 + unsigned int r_num;
60067 + int err = 0;
60068 + __u16 i;
60069 + __u32 num_subjs;
60070 +
60071 + /* we need a default and kernel role */
60072 + if (arg->role_db.num_roles < 2)
60073 + return -EINVAL;
60074 +
60075 + /* copy special role authentication info from userspace */
60076 +
60077 + num_sprole_pws = arg->num_sprole_pws;
60078 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
60079 +
60080 + if (!acl_special_roles && num_sprole_pws)
60081 + return -ENOMEM;
60082 +
60083 + for (i = 0; i < num_sprole_pws; i++) {
60084 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
60085 + if (!sptmp)
60086 + return -ENOMEM;
60087 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
60088 + return -EFAULT;
60089 +
60090 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
60091 + if (err)
60092 + return err;
60093 +
60094 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60095 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
60096 +#endif
60097 +
60098 + acl_special_roles[i] = sptmp;
60099 + }
60100 +
60101 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
60102 +
60103 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
60104 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
60105 +
60106 + if (!r_tmp)
60107 + return -ENOMEM;
60108 +
60109 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
60110 + return -EFAULT;
60111 +
60112 + if (copy_acl_role_label(r_tmp, r_utmp2))
60113 + return -EFAULT;
60114 +
60115 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
60116 + if (err)
60117 + return err;
60118 +
60119 + if (!strcmp(r_tmp->rolename, "default")
60120 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
60121 + default_role = r_tmp;
60122 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
60123 + kernel_role = r_tmp;
60124 + }
60125 +
60126 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
60127 + return -ENOMEM;
60128 +
60129 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
60130 + return -EFAULT;
60131 +
60132 + r_tmp->hash = ghash;
60133 +
60134 + num_subjs = count_user_subjs(r_tmp->hash->first);
60135 +
60136 + r_tmp->subj_hash_size = num_subjs;
60137 + r_tmp->subj_hash =
60138 + (struct acl_subject_label **)
60139 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
60140 +
60141 + if (!r_tmp->subj_hash)
60142 + return -ENOMEM;
60143 +
60144 + err = copy_user_allowedips(r_tmp);
60145 + if (err)
60146 + return err;
60147 +
60148 + /* copy domain info */
60149 + if (r_tmp->domain_children != NULL) {
60150 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
60151 + if (domainlist == NULL)
60152 + return -ENOMEM;
60153 +
60154 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
60155 + return -EFAULT;
60156 +
60157 + r_tmp->domain_children = domainlist;
60158 + }
60159 +
60160 + err = copy_user_transitions(r_tmp);
60161 + if (err)
60162 + return err;
60163 +
60164 + memset(r_tmp->subj_hash, 0,
60165 + r_tmp->subj_hash_size *
60166 + sizeof (struct acl_subject_label *));
60167 +
60168 + /* acquire the list of subjects, then NULL out
60169 + the list prior to parsing the subjects for this role,
60170 + as during this parsing the list is replaced with a list
60171 + of *nested* subjects for the role
60172 + */
60173 + subj_list = r_tmp->hash->first;
60174 +
60175 + /* set nested subject list to null */
60176 + r_tmp->hash->first = NULL;
60177 +
60178 + err = copy_user_subjs(subj_list, r_tmp);
60179 +
60180 + if (err)
60181 + return err;
60182 +
60183 + insert_acl_role_label(r_tmp);
60184 + }
60185 +
60186 + if (default_role == NULL || kernel_role == NULL)
60187 + return -EINVAL;
60188 +
60189 + return err;
60190 +}
60191 +
60192 +static int
60193 +gracl_init(struct gr_arg *args)
60194 +{
60195 + int error = 0;
60196 +
60197 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
60198 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
60199 +
60200 + if (init_variables(args)) {
60201 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
60202 + error = -ENOMEM;
60203 + free_variables();
60204 + goto out;
60205 + }
60206 +
60207 + error = copy_user_acl(args);
60208 + free_init_variables();
60209 + if (error) {
60210 + free_variables();
60211 + goto out;
60212 + }
60213 +
60214 + if ((error = gr_set_acls(0))) {
60215 + free_variables();
60216 + goto out;
60217 + }
60218 +
60219 + pax_open_kernel();
60220 + gr_status |= GR_READY;
60221 + pax_close_kernel();
60222 +
60223 + out:
60224 + return error;
60225 +}
60226 +
60227 +/* derived from glibc fnmatch() 0: match, 1: no match*/
60228 +
60229 +static int
60230 +glob_match(const char *p, const char *n)
60231 +{
60232 + char c;
60233 +
60234 + while ((c = *p++) != '\0') {
60235 + switch (c) {
60236 + case '?':
60237 + if (*n == '\0')
60238 + return 1;
60239 + else if (*n == '/')
60240 + return 1;
60241 + break;
60242 + case '\\':
60243 + if (*n != c)
60244 + return 1;
60245 + break;
60246 + case '*':
60247 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
60248 + if (*n == '/')
60249 + return 1;
60250 + else if (c == '?') {
60251 + if (*n == '\0')
60252 + return 1;
60253 + else
60254 + ++n;
60255 + }
60256 + }
60257 + if (c == '\0') {
60258 + return 0;
60259 + } else {
60260 + const char *endp;
60261 +
60262 + if ((endp = strchr(n, '/')) == NULL)
60263 + endp = n + strlen(n);
60264 +
60265 + if (c == '[') {
60266 + for (--p; n < endp; ++n)
60267 + if (!glob_match(p, n))
60268 + return 0;
60269 + } else if (c == '/') {
60270 + while (*n != '\0' && *n != '/')
60271 + ++n;
60272 + if (*n == '/' && !glob_match(p, n + 1))
60273 + return 0;
60274 + } else {
60275 + for (--p; n < endp; ++n)
60276 + if (*n == c && !glob_match(p, n))
60277 + return 0;
60278 + }
60279 +
60280 + return 1;
60281 + }
60282 + case '[':
60283 + {
60284 + int not;
60285 + char cold;
60286 +
60287 + if (*n == '\0' || *n == '/')
60288 + return 1;
60289 +
60290 + not = (*p == '!' || *p == '^');
60291 + if (not)
60292 + ++p;
60293 +
60294 + c = *p++;
60295 + for (;;) {
60296 + unsigned char fn = (unsigned char)*n;
60297 +
60298 + if (c == '\0')
60299 + return 1;
60300 + else {
60301 + if (c == fn)
60302 + goto matched;
60303 + cold = c;
60304 + c = *p++;
60305 +
60306 + if (c == '-' && *p != ']') {
60307 + unsigned char cend = *p++;
60308 +
60309 + if (cend == '\0')
60310 + return 1;
60311 +
60312 + if (cold <= fn && fn <= cend)
60313 + goto matched;
60314 +
60315 + c = *p++;
60316 + }
60317 + }
60318 +
60319 + if (c == ']')
60320 + break;
60321 + }
60322 + if (!not)
60323 + return 1;
60324 + break;
60325 + matched:
60326 + while (c != ']') {
60327 + if (c == '\0')
60328 + return 1;
60329 +
60330 + c = *p++;
60331 + }
60332 + if (not)
60333 + return 1;
60334 + }
60335 + break;
60336 + default:
60337 + if (c != *n)
60338 + return 1;
60339 + }
60340 +
60341 + ++n;
60342 + }
60343 +
60344 + if (*n == '\0')
60345 + return 0;
60346 +
60347 + if (*n == '/')
60348 + return 0;
60349 +
60350 + return 1;
60351 +}
60352 +
60353 +static struct acl_object_label *
60354 +chk_glob_label(struct acl_object_label *globbed,
60355 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
60356 +{
60357 + struct acl_object_label *tmp;
60358 +
60359 + if (*path == NULL)
60360 + *path = gr_to_filename_nolock(dentry, mnt);
60361 +
60362 + tmp = globbed;
60363 +
60364 + while (tmp) {
60365 + if (!glob_match(tmp->filename, *path))
60366 + return tmp;
60367 + tmp = tmp->next;
60368 + }
60369 +
60370 + return NULL;
60371 +}
60372 +
60373 +static struct acl_object_label *
60374 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60375 + const ino_t curr_ino, const dev_t curr_dev,
60376 + const struct acl_subject_label *subj, char **path, const int checkglob)
60377 +{
60378 + struct acl_subject_label *tmpsubj;
60379 + struct acl_object_label *retval;
60380 + struct acl_object_label *retval2;
60381 +
60382 + tmpsubj = (struct acl_subject_label *) subj;
60383 + read_lock(&gr_inode_lock);
60384 + do {
60385 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60386 + if (retval) {
60387 + if (checkglob && retval->globbed) {
60388 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60389 + if (retval2)
60390 + retval = retval2;
60391 + }
60392 + break;
60393 + }
60394 + } while ((tmpsubj = tmpsubj->parent_subject));
60395 + read_unlock(&gr_inode_lock);
60396 +
60397 + return retval;
60398 +}
60399 +
60400 +static __inline__ struct acl_object_label *
60401 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60402 + struct dentry *curr_dentry,
60403 + const struct acl_subject_label *subj, char **path, const int checkglob)
60404 +{
60405 + int newglob = checkglob;
60406 + ino_t inode;
60407 + dev_t device;
60408 +
60409 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60410 + as we don't want a / * rule to match instead of the / object
60411 + don't do this for create lookups that call this function though, since they're looking up
60412 + on the parent and thus need globbing checks on all paths
60413 + */
60414 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60415 + newglob = GR_NO_GLOB;
60416 +
60417 + spin_lock(&curr_dentry->d_lock);
60418 + inode = curr_dentry->d_inode->i_ino;
60419 + device = __get_dev(curr_dentry);
60420 + spin_unlock(&curr_dentry->d_lock);
60421 +
60422 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60423 +}
60424 +
60425 +#ifdef CONFIG_HUGETLBFS
60426 +static inline bool
60427 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60428 +{
60429 + int i;
60430 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60431 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60432 + return true;
60433 + }
60434 +
60435 + return false;
60436 +}
60437 +#endif
60438 +
60439 +static struct acl_object_label *
60440 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60441 + const struct acl_subject_label *subj, char *path, const int checkglob)
60442 +{
60443 + struct dentry *dentry = (struct dentry *) l_dentry;
60444 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60445 + struct mount *real_mnt = real_mount(mnt);
60446 + struct acl_object_label *retval;
60447 + struct dentry *parent;
60448 +
60449 + br_read_lock(&vfsmount_lock);
60450 + write_seqlock(&rename_lock);
60451 +
60452 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60453 +#ifdef CONFIG_NET
60454 + mnt == sock_mnt ||
60455 +#endif
60456 +#ifdef CONFIG_HUGETLBFS
60457 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60458 +#endif
60459 + /* ignore Eric Biederman */
60460 + IS_PRIVATE(l_dentry->d_inode))) {
60461 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60462 + goto out;
60463 + }
60464 +
60465 + for (;;) {
60466 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60467 + break;
60468 +
60469 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60470 + if (!mnt_has_parent(real_mnt))
60471 + break;
60472 +
60473 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60474 + if (retval != NULL)
60475 + goto out;
60476 +
60477 + dentry = real_mnt->mnt_mountpoint;
60478 + real_mnt = real_mnt->mnt_parent;
60479 + mnt = &real_mnt->mnt;
60480 + continue;
60481 + }
60482 +
60483 + parent = dentry->d_parent;
60484 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60485 + if (retval != NULL)
60486 + goto out;
60487 +
60488 + dentry = parent;
60489 + }
60490 +
60491 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60492 +
60493 + /* real_root is pinned so we don't have to hold a reference */
60494 + if (retval == NULL)
60495 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60496 +out:
60497 + write_sequnlock(&rename_lock);
60498 + br_read_unlock(&vfsmount_lock);
60499 +
60500 + BUG_ON(retval == NULL);
60501 +
60502 + return retval;
60503 +}
60504 +
60505 +static __inline__ struct acl_object_label *
60506 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60507 + const struct acl_subject_label *subj)
60508 +{
60509 + char *path = NULL;
60510 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60511 +}
60512 +
60513 +static __inline__ struct acl_object_label *
60514 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60515 + const struct acl_subject_label *subj)
60516 +{
60517 + char *path = NULL;
60518 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60519 +}
60520 +
60521 +static __inline__ struct acl_object_label *
60522 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60523 + const struct acl_subject_label *subj, char *path)
60524 +{
60525 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60526 +}
60527 +
60528 +static struct acl_subject_label *
60529 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60530 + const struct acl_role_label *role)
60531 +{
60532 + struct dentry *dentry = (struct dentry *) l_dentry;
60533 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60534 + struct mount *real_mnt = real_mount(mnt);
60535 + struct acl_subject_label *retval;
60536 + struct dentry *parent;
60537 +
60538 + br_read_lock(&vfsmount_lock);
60539 + write_seqlock(&rename_lock);
60540 +
60541 + for (;;) {
60542 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60543 + break;
60544 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60545 + if (!mnt_has_parent(real_mnt))
60546 + break;
60547 +
60548 + spin_lock(&dentry->d_lock);
60549 + read_lock(&gr_inode_lock);
60550 + retval =
60551 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60552 + __get_dev(dentry), role);
60553 + read_unlock(&gr_inode_lock);
60554 + spin_unlock(&dentry->d_lock);
60555 + if (retval != NULL)
60556 + goto out;
60557 +
60558 + dentry = real_mnt->mnt_mountpoint;
60559 + real_mnt = real_mnt->mnt_parent;
60560 + mnt = &real_mnt->mnt;
60561 + continue;
60562 + }
60563 +
60564 + spin_lock(&dentry->d_lock);
60565 + read_lock(&gr_inode_lock);
60566 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60567 + __get_dev(dentry), role);
60568 + read_unlock(&gr_inode_lock);
60569 + parent = dentry->d_parent;
60570 + spin_unlock(&dentry->d_lock);
60571 +
60572 + if (retval != NULL)
60573 + goto out;
60574 +
60575 + dentry = parent;
60576 + }
60577 +
60578 + spin_lock(&dentry->d_lock);
60579 + read_lock(&gr_inode_lock);
60580 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60581 + __get_dev(dentry), role);
60582 + read_unlock(&gr_inode_lock);
60583 + spin_unlock(&dentry->d_lock);
60584 +
60585 + if (unlikely(retval == NULL)) {
60586 + /* real_root is pinned, we don't need to hold a reference */
60587 + read_lock(&gr_inode_lock);
60588 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60589 + __get_dev(real_root.dentry), role);
60590 + read_unlock(&gr_inode_lock);
60591 + }
60592 +out:
60593 + write_sequnlock(&rename_lock);
60594 + br_read_unlock(&vfsmount_lock);
60595 +
60596 + BUG_ON(retval == NULL);
60597 +
60598 + return retval;
60599 +}
60600 +
60601 +static void
60602 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60603 +{
60604 + struct task_struct *task = current;
60605 + const struct cred *cred = current_cred();
60606 +
60607 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60608 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60609 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60610 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60611 +
60612 + return;
60613 +}
60614 +
60615 +static void
60616 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60617 +{
60618 + struct task_struct *task = current;
60619 + const struct cred *cred = current_cred();
60620 +
60621 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60622 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60623 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60624 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60625 +
60626 + return;
60627 +}
60628 +
60629 +static void
60630 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60631 +{
60632 + struct task_struct *task = current;
60633 + const struct cred *cred = current_cred();
60634 +
60635 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60636 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60637 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60638 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60639 +
60640 + return;
60641 +}
60642 +
60643 +__u32
60644 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60645 + const struct vfsmount * mnt)
60646 +{
60647 + __u32 retval = mode;
60648 + struct acl_subject_label *curracl;
60649 + struct acl_object_label *currobj;
60650 +
60651 + if (unlikely(!(gr_status & GR_READY)))
60652 + return (mode & ~GR_AUDITS);
60653 +
60654 + curracl = current->acl;
60655 +
60656 + currobj = chk_obj_label(dentry, mnt, curracl);
60657 + retval = currobj->mode & mode;
60658 +
60659 + /* if we're opening a specified transfer file for writing
60660 + (e.g. /dev/initctl), then transfer our role to init
60661 + */
60662 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60663 + current->role->roletype & GR_ROLE_PERSIST)) {
60664 + struct task_struct *task = init_pid_ns.child_reaper;
60665 +
60666 + if (task->role != current->role) {
60667 + task->acl_sp_role = 0;
60668 + task->acl_role_id = current->acl_role_id;
60669 + task->role = current->role;
60670 + rcu_read_lock();
60671 + read_lock(&grsec_exec_file_lock);
60672 + gr_apply_subject_to_task(task);
60673 + read_unlock(&grsec_exec_file_lock);
60674 + rcu_read_unlock();
60675 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60676 + }
60677 + }
60678 +
60679 + if (unlikely
60680 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60681 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60682 + __u32 new_mode = mode;
60683 +
60684 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60685 +
60686 + retval = new_mode;
60687 +
60688 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60689 + new_mode |= GR_INHERIT;
60690 +
60691 + if (!(mode & GR_NOLEARN))
60692 + gr_log_learn(dentry, mnt, new_mode);
60693 + }
60694 +
60695 + return retval;
60696 +}
60697 +
60698 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60699 + const struct dentry *parent,
60700 + const struct vfsmount *mnt)
60701 +{
60702 + struct name_entry *match;
60703 + struct acl_object_label *matchpo;
60704 + struct acl_subject_label *curracl;
60705 + char *path;
60706 +
60707 + if (unlikely(!(gr_status & GR_READY)))
60708 + return NULL;
60709 +
60710 + preempt_disable();
60711 + path = gr_to_filename_rbac(new_dentry, mnt);
60712 + match = lookup_name_entry_create(path);
60713 +
60714 + curracl = current->acl;
60715 +
60716 + if (match) {
60717 + read_lock(&gr_inode_lock);
60718 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60719 + read_unlock(&gr_inode_lock);
60720 +
60721 + if (matchpo) {
60722 + preempt_enable();
60723 + return matchpo;
60724 + }
60725 + }
60726 +
60727 + // lookup parent
60728 +
60729 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60730 +
60731 + preempt_enable();
60732 + return matchpo;
60733 +}
60734 +
60735 +__u32
60736 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60737 + const struct vfsmount * mnt, const __u32 mode)
60738 +{
60739 + struct acl_object_label *matchpo;
60740 + __u32 retval;
60741 +
60742 + if (unlikely(!(gr_status & GR_READY)))
60743 + return (mode & ~GR_AUDITS);
60744 +
60745 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60746 +
60747 + retval = matchpo->mode & mode;
60748 +
60749 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60750 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60751 + __u32 new_mode = mode;
60752 +
60753 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60754 +
60755 + gr_log_learn(new_dentry, mnt, new_mode);
60756 + return new_mode;
60757 + }
60758 +
60759 + return retval;
60760 +}
60761 +
60762 +__u32
60763 +gr_check_link(const struct dentry * new_dentry,
60764 + const struct dentry * parent_dentry,
60765 + const struct vfsmount * parent_mnt,
60766 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60767 +{
60768 + struct acl_object_label *obj;
60769 + __u32 oldmode, newmode;
60770 + __u32 needmode;
60771 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60772 + GR_DELETE | GR_INHERIT;
60773 +
60774 + if (unlikely(!(gr_status & GR_READY)))
60775 + return (GR_CREATE | GR_LINK);
60776 +
60777 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60778 + oldmode = obj->mode;
60779 +
60780 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60781 + newmode = obj->mode;
60782 +
60783 + needmode = newmode & checkmodes;
60784 +
60785 + // old name for hardlink must have at least the permissions of the new name
60786 + if ((oldmode & needmode) != needmode)
60787 + goto bad;
60788 +
60789 + // if old name had restrictions/auditing, make sure the new name does as well
60790 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60791 +
60792 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60793 + if (is_privileged_binary(old_dentry))
60794 + needmode |= GR_SETID;
60795 +
60796 + if ((newmode & needmode) != needmode)
60797 + goto bad;
60798 +
60799 + // enforce minimum permissions
60800 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60801 + return newmode;
60802 +bad:
60803 + needmode = oldmode;
60804 + if (is_privileged_binary(old_dentry))
60805 + needmode |= GR_SETID;
60806 +
60807 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60808 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60809 + return (GR_CREATE | GR_LINK);
60810 + } else if (newmode & GR_SUPPRESS)
60811 + return GR_SUPPRESS;
60812 + else
60813 + return 0;
60814 +}
60815 +
60816 +int
60817 +gr_check_hidden_task(const struct task_struct *task)
60818 +{
60819 + if (unlikely(!(gr_status & GR_READY)))
60820 + return 0;
60821 +
60822 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60823 + return 1;
60824 +
60825 + return 0;
60826 +}
60827 +
60828 +int
60829 +gr_check_protected_task(const struct task_struct *task)
60830 +{
60831 + if (unlikely(!(gr_status & GR_READY) || !task))
60832 + return 0;
60833 +
60834 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60835 + task->acl != current->acl)
60836 + return 1;
60837 +
60838 + return 0;
60839 +}
60840 +
60841 +int
60842 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60843 +{
60844 + struct task_struct *p;
60845 + int ret = 0;
60846 +
60847 + if (unlikely(!(gr_status & GR_READY) || !pid))
60848 + return ret;
60849 +
60850 + read_lock(&tasklist_lock);
60851 + do_each_pid_task(pid, type, p) {
60852 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60853 + p->acl != current->acl) {
60854 + ret = 1;
60855 + goto out;
60856 + }
60857 + } while_each_pid_task(pid, type, p);
60858 +out:
60859 + read_unlock(&tasklist_lock);
60860 +
60861 + return ret;
60862 +}
60863 +
60864 +void
60865 +gr_copy_label(struct task_struct *tsk)
60866 +{
60867 + tsk->signal->used_accept = 0;
60868 + tsk->acl_sp_role = 0;
60869 + tsk->acl_role_id = current->acl_role_id;
60870 + tsk->acl = current->acl;
60871 + tsk->role = current->role;
60872 + tsk->signal->curr_ip = current->signal->curr_ip;
60873 + tsk->signal->saved_ip = current->signal->saved_ip;
60874 + if (current->exec_file)
60875 + get_file(current->exec_file);
60876 + tsk->exec_file = current->exec_file;
60877 + tsk->is_writable = current->is_writable;
60878 + if (unlikely(current->signal->used_accept)) {
60879 + current->signal->curr_ip = 0;
60880 + current->signal->saved_ip = 0;
60881 + }
60882 +
60883 + return;
60884 +}
60885 +
60886 +static void
60887 +gr_set_proc_res(struct task_struct *task)
60888 +{
60889 + struct acl_subject_label *proc;
60890 + unsigned short i;
60891 +
60892 + proc = task->acl;
60893 +
60894 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60895 + return;
60896 +
60897 + for (i = 0; i < RLIM_NLIMITS; i++) {
60898 + if (!(proc->resmask & (1U << i)))
60899 + continue;
60900 +
60901 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60902 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60903 +
60904 + if (i == RLIMIT_CPU)
60905 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60906 + }
60907 +
60908 + return;
60909 +}
60910 +
60911 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
60912 +
60913 +int
60914 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60915 +{
60916 + unsigned int i;
60917 + __u16 num;
60918 + uid_t *uidlist;
60919 + uid_t curuid;
60920 + int realok = 0;
60921 + int effectiveok = 0;
60922 + int fsok = 0;
60923 + uid_t globalreal, globaleffective, globalfs;
60924 +
60925 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
60926 + struct user_struct *user;
60927 +
60928 + if (!uid_valid(real))
60929 + goto skipit;
60930 +
60931 + /* find user based on global namespace */
60932 +
60933 + globalreal = GR_GLOBAL_UID(real);
60934 +
60935 + user = find_user(make_kuid(&init_user_ns, globalreal));
60936 + if (user == NULL)
60937 + goto skipit;
60938 +
60939 + if (gr_process_kernel_setuid_ban(user)) {
60940 + /* for find_user */
60941 + free_uid(user);
60942 + return 1;
60943 + }
60944 +
60945 + /* for find_user */
60946 + free_uid(user);
60947 +
60948 +skipit:
60949 +#endif
60950 +
60951 + if (unlikely(!(gr_status & GR_READY)))
60952 + return 0;
60953 +
60954 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60955 + gr_log_learn_uid_change(real, effective, fs);
60956 +
60957 + num = current->acl->user_trans_num;
60958 + uidlist = current->acl->user_transitions;
60959 +
60960 + if (uidlist == NULL)
60961 + return 0;
60962 +
60963 + if (!uid_valid(real)) {
60964 + realok = 1;
60965 + globalreal = (uid_t)-1;
60966 + } else {
60967 + globalreal = GR_GLOBAL_UID(real);
60968 + }
60969 + if (!uid_valid(effective)) {
60970 + effectiveok = 1;
60971 + globaleffective = (uid_t)-1;
60972 + } else {
60973 + globaleffective = GR_GLOBAL_UID(effective);
60974 + }
60975 + if (!uid_valid(fs)) {
60976 + fsok = 1;
60977 + globalfs = (uid_t)-1;
60978 + } else {
60979 + globalfs = GR_GLOBAL_UID(fs);
60980 + }
60981 +
60982 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60983 + for (i = 0; i < num; i++) {
60984 + curuid = uidlist[i];
60985 + if (globalreal == curuid)
60986 + realok = 1;
60987 + if (globaleffective == curuid)
60988 + effectiveok = 1;
60989 + if (globalfs == curuid)
60990 + fsok = 1;
60991 + }
60992 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60993 + for (i = 0; i < num; i++) {
60994 + curuid = uidlist[i];
60995 + if (globalreal == curuid)
60996 + break;
60997 + if (globaleffective == curuid)
60998 + break;
60999 + if (globalfs == curuid)
61000 + break;
61001 + }
61002 + /* not in deny list */
61003 + if (i == num) {
61004 + realok = 1;
61005 + effectiveok = 1;
61006 + fsok = 1;
61007 + }
61008 + }
61009 +
61010 + if (realok && effectiveok && fsok)
61011 + return 0;
61012 + else {
61013 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
61014 + return 1;
61015 + }
61016 +}
61017 +
61018 +int
61019 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
61020 +{
61021 + unsigned int i;
61022 + __u16 num;
61023 + gid_t *gidlist;
61024 + gid_t curgid;
61025 + int realok = 0;
61026 + int effectiveok = 0;
61027 + int fsok = 0;
61028 + gid_t globalreal, globaleffective, globalfs;
61029 +
61030 + if (unlikely(!(gr_status & GR_READY)))
61031 + return 0;
61032 +
61033 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61034 + gr_log_learn_gid_change(real, effective, fs);
61035 +
61036 + num = current->acl->group_trans_num;
61037 + gidlist = current->acl->group_transitions;
61038 +
61039 + if (gidlist == NULL)
61040 + return 0;
61041 +
61042 + if (!gid_valid(real)) {
61043 + realok = 1;
61044 + globalreal = (gid_t)-1;
61045 + } else {
61046 + globalreal = GR_GLOBAL_GID(real);
61047 + }
61048 + if (!gid_valid(effective)) {
61049 + effectiveok = 1;
61050 + globaleffective = (gid_t)-1;
61051 + } else {
61052 + globaleffective = GR_GLOBAL_GID(effective);
61053 + }
61054 + if (!gid_valid(fs)) {
61055 + fsok = 1;
61056 + globalfs = (gid_t)-1;
61057 + } else {
61058 + globalfs = GR_GLOBAL_GID(fs);
61059 + }
61060 +
61061 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
61062 + for (i = 0; i < num; i++) {
61063 + curgid = gidlist[i];
61064 + if (globalreal == curgid)
61065 + realok = 1;
61066 + if (globaleffective == curgid)
61067 + effectiveok = 1;
61068 + if (globalfs == curgid)
61069 + fsok = 1;
61070 + }
61071 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
61072 + for (i = 0; i < num; i++) {
61073 + curgid = gidlist[i];
61074 + if (globalreal == curgid)
61075 + break;
61076 + if (globaleffective == curgid)
61077 + break;
61078 + if (globalfs == curgid)
61079 + break;
61080 + }
61081 + /* not in deny list */
61082 + if (i == num) {
61083 + realok = 1;
61084 + effectiveok = 1;
61085 + fsok = 1;
61086 + }
61087 + }
61088 +
61089 + if (realok && effectiveok && fsok)
61090 + return 0;
61091 + else {
61092 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
61093 + return 1;
61094 + }
61095 +}
61096 +
61097 +extern int gr_acl_is_capable(const int cap);
61098 +
61099 +void
61100 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
61101 +{
61102 + struct acl_role_label *role = task->role;
61103 + struct acl_subject_label *subj = NULL;
61104 + struct acl_object_label *obj;
61105 + struct file *filp;
61106 + uid_t uid;
61107 + gid_t gid;
61108 +
61109 + if (unlikely(!(gr_status & GR_READY)))
61110 + return;
61111 +
61112 + uid = GR_GLOBAL_UID(kuid);
61113 + gid = GR_GLOBAL_GID(kgid);
61114 +
61115 + filp = task->exec_file;
61116 +
61117 + /* kernel process, we'll give them the kernel role */
61118 + if (unlikely(!filp)) {
61119 + task->role = kernel_role;
61120 + task->acl = kernel_role->root_label;
61121 + return;
61122 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
61123 + role = lookup_acl_role_label(task, uid, gid);
61124 +
61125 + /* don't change the role if we're not a privileged process */
61126 + if (role && task->role != role &&
61127 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
61128 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
61129 + return;
61130 +
61131 + /* perform subject lookup in possibly new role
61132 + we can use this result below in the case where role == task->role
61133 + */
61134 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
61135 +
61136 + /* if we changed uid/gid, but result in the same role
61137 + and are using inheritance, don't lose the inherited subject
61138 + if current subject is other than what normal lookup
61139 + would result in, we arrived via inheritance, don't
61140 + lose subject
61141 + */
61142 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
61143 + (subj == task->acl)))
61144 + task->acl = subj;
61145 +
61146 + task->role = role;
61147 +
61148 + task->is_writable = 0;
61149 +
61150 + /* ignore additional mmap checks for processes that are writable
61151 + by the default ACL */
61152 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61153 + if (unlikely(obj->mode & GR_WRITE))
61154 + task->is_writable = 1;
61155 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61156 + if (unlikely(obj->mode & GR_WRITE))
61157 + task->is_writable = 1;
61158 +
61159 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61160 + printk(KERN_ALERT "Set role label for (%s:%d): role:%s, subject:%s\n", task->comm, task_pid_nr(task), task->role->rolename, task->acl->filename);
61161 +#endif
61162 +
61163 + gr_set_proc_res(task);
61164 +
61165 + return;
61166 +}
61167 +
61168 +int
61169 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
61170 + const int unsafe_flags)
61171 +{
61172 + struct task_struct *task = current;
61173 + struct acl_subject_label *newacl;
61174 + struct acl_object_label *obj;
61175 + __u32 retmode;
61176 +
61177 + if (unlikely(!(gr_status & GR_READY)))
61178 + return 0;
61179 +
61180 + newacl = chk_subj_label(dentry, mnt, task->role);
61181 +
61182 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
61183 + did an exec
61184 + */
61185 + rcu_read_lock();
61186 + read_lock(&tasklist_lock);
61187 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
61188 + (task->parent->acl->mode & GR_POVERRIDE))) {
61189 + read_unlock(&tasklist_lock);
61190 + rcu_read_unlock();
61191 + goto skip_check;
61192 + }
61193 + read_unlock(&tasklist_lock);
61194 + rcu_read_unlock();
61195 +
61196 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
61197 + !(task->role->roletype & GR_ROLE_GOD) &&
61198 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
61199 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
61200 + if (unsafe_flags & LSM_UNSAFE_SHARE)
61201 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
61202 + else
61203 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
61204 + return -EACCES;
61205 + }
61206 +
61207 +skip_check:
61208 +
61209 + obj = chk_obj_label(dentry, mnt, task->acl);
61210 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
61211 +
61212 + if (!(task->acl->mode & GR_INHERITLEARN) &&
61213 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
61214 + if (obj->nested)
61215 + task->acl = obj->nested;
61216 + else
61217 + task->acl = newacl;
61218 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
61219 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
61220 +
61221 + task->is_writable = 0;
61222 +
61223 + /* ignore additional mmap checks for processes that are writable
61224 + by the default ACL */
61225 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
61226 + if (unlikely(obj->mode & GR_WRITE))
61227 + task->is_writable = 1;
61228 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
61229 + if (unlikely(obj->mode & GR_WRITE))
61230 + task->is_writable = 1;
61231 +
61232 + gr_set_proc_res(task);
61233 +
61234 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61235 + printk(KERN_ALERT "Set subject label for (%s:%d): role:%s, subject:%s\n", task->comm, task_pid_nr(task), task->role->rolename, task->acl->filename);
61236 +#endif
61237 + return 0;
61238 +}
61239 +
61240 +/* always called with valid inodev ptr */
61241 +static void
61242 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
61243 +{
61244 + struct acl_object_label *matchpo;
61245 + struct acl_subject_label *matchps;
61246 + struct acl_subject_label *subj;
61247 + struct acl_role_label *role;
61248 + unsigned int x;
61249 +
61250 + FOR_EACH_ROLE_START(role)
61251 + FOR_EACH_SUBJECT_START(role, subj, x)
61252 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
61253 + matchpo->mode |= GR_DELETED;
61254 + FOR_EACH_SUBJECT_END(subj,x)
61255 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61256 + /* nested subjects aren't in the role's subj_hash table */
61257 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
61258 + matchpo->mode |= GR_DELETED;
61259 + FOR_EACH_NESTED_SUBJECT_END(subj)
61260 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
61261 + matchps->mode |= GR_DELETED;
61262 + FOR_EACH_ROLE_END(role)
61263 +
61264 + inodev->nentry->deleted = 1;
61265 +
61266 + return;
61267 +}
61268 +
61269 +void
61270 +gr_handle_delete(const ino_t ino, const dev_t dev)
61271 +{
61272 + struct inodev_entry *inodev;
61273 +
61274 + if (unlikely(!(gr_status & GR_READY)))
61275 + return;
61276 +
61277 + write_lock(&gr_inode_lock);
61278 + inodev = lookup_inodev_entry(ino, dev);
61279 + if (inodev != NULL)
61280 + do_handle_delete(inodev, ino, dev);
61281 + write_unlock(&gr_inode_lock);
61282 +
61283 + return;
61284 +}
61285 +
61286 +static void
61287 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
61288 + const ino_t newinode, const dev_t newdevice,
61289 + struct acl_subject_label *subj)
61290 +{
61291 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
61292 + struct acl_object_label *match;
61293 +
61294 + match = subj->obj_hash[index];
61295 +
61296 + while (match && (match->inode != oldinode ||
61297 + match->device != olddevice ||
61298 + !(match->mode & GR_DELETED)))
61299 + match = match->next;
61300 +
61301 + if (match && (match->inode == oldinode)
61302 + && (match->device == olddevice)
61303 + && (match->mode & GR_DELETED)) {
61304 + if (match->prev == NULL) {
61305 + subj->obj_hash[index] = match->next;
61306 + if (match->next != NULL)
61307 + match->next->prev = NULL;
61308 + } else {
61309 + match->prev->next = match->next;
61310 + if (match->next != NULL)
61311 + match->next->prev = match->prev;
61312 + }
61313 + match->prev = NULL;
61314 + match->next = NULL;
61315 + match->inode = newinode;
61316 + match->device = newdevice;
61317 + match->mode &= ~GR_DELETED;
61318 +
61319 + insert_acl_obj_label(match, subj);
61320 + }
61321 +
61322 + return;
61323 +}
61324 +
61325 +static void
61326 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
61327 + const ino_t newinode, const dev_t newdevice,
61328 + struct acl_role_label *role)
61329 +{
61330 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
61331 + struct acl_subject_label *match;
61332 +
61333 + match = role->subj_hash[index];
61334 +
61335 + while (match && (match->inode != oldinode ||
61336 + match->device != olddevice ||
61337 + !(match->mode & GR_DELETED)))
61338 + match = match->next;
61339 +
61340 + if (match && (match->inode == oldinode)
61341 + && (match->device == olddevice)
61342 + && (match->mode & GR_DELETED)) {
61343 + if (match->prev == NULL) {
61344 + role->subj_hash[index] = match->next;
61345 + if (match->next != NULL)
61346 + match->next->prev = NULL;
61347 + } else {
61348 + match->prev->next = match->next;
61349 + if (match->next != NULL)
61350 + match->next->prev = match->prev;
61351 + }
61352 + match->prev = NULL;
61353 + match->next = NULL;
61354 + match->inode = newinode;
61355 + match->device = newdevice;
61356 + match->mode &= ~GR_DELETED;
61357 +
61358 + insert_acl_subj_label(match, role);
61359 + }
61360 +
61361 + return;
61362 +}
61363 +
61364 +static void
61365 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
61366 + const ino_t newinode, const dev_t newdevice)
61367 +{
61368 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
61369 + struct inodev_entry *match;
61370 +
61371 + match = inodev_set.i_hash[index];
61372 +
61373 + while (match && (match->nentry->inode != oldinode ||
61374 + match->nentry->device != olddevice || !match->nentry->deleted))
61375 + match = match->next;
61376 +
61377 + if (match && (match->nentry->inode == oldinode)
61378 + && (match->nentry->device == olddevice) &&
61379 + match->nentry->deleted) {
61380 + if (match->prev == NULL) {
61381 + inodev_set.i_hash[index] = match->next;
61382 + if (match->next != NULL)
61383 + match->next->prev = NULL;
61384 + } else {
61385 + match->prev->next = match->next;
61386 + if (match->next != NULL)
61387 + match->next->prev = match->prev;
61388 + }
61389 + match->prev = NULL;
61390 + match->next = NULL;
61391 + match->nentry->inode = newinode;
61392 + match->nentry->device = newdevice;
61393 + match->nentry->deleted = 0;
61394 +
61395 + insert_inodev_entry(match);
61396 + }
61397 +
61398 + return;
61399 +}
61400 +
61401 +static void
61402 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61403 +{
61404 + struct acl_subject_label *subj;
61405 + struct acl_role_label *role;
61406 + unsigned int x;
61407 +
61408 + FOR_EACH_ROLE_START(role)
61409 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61410 +
61411 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61412 + if ((subj->inode == ino) && (subj->device == dev)) {
61413 + subj->inode = ino;
61414 + subj->device = dev;
61415 + }
61416 + /* nested subjects aren't in the role's subj_hash table */
61417 + update_acl_obj_label(matchn->inode, matchn->device,
61418 + ino, dev, subj);
61419 + FOR_EACH_NESTED_SUBJECT_END(subj)
61420 + FOR_EACH_SUBJECT_START(role, subj, x)
61421 + update_acl_obj_label(matchn->inode, matchn->device,
61422 + ino, dev, subj);
61423 + FOR_EACH_SUBJECT_END(subj,x)
61424 + FOR_EACH_ROLE_END(role)
61425 +
61426 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61427 +
61428 + return;
61429 +}
61430 +
61431 +static void
61432 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61433 + const struct vfsmount *mnt)
61434 +{
61435 + ino_t ino = dentry->d_inode->i_ino;
61436 + dev_t dev = __get_dev(dentry);
61437 +
61438 + __do_handle_create(matchn, ino, dev);
61439 +
61440 + return;
61441 +}
61442 +
61443 +void
61444 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61445 +{
61446 + struct name_entry *matchn;
61447 +
61448 + if (unlikely(!(gr_status & GR_READY)))
61449 + return;
61450 +
61451 + preempt_disable();
61452 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61453 +
61454 + if (unlikely((unsigned long)matchn)) {
61455 + write_lock(&gr_inode_lock);
61456 + do_handle_create(matchn, dentry, mnt);
61457 + write_unlock(&gr_inode_lock);
61458 + }
61459 + preempt_enable();
61460 +
61461 + return;
61462 +}
61463 +
61464 +void
61465 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61466 +{
61467 + struct name_entry *matchn;
61468 +
61469 + if (unlikely(!(gr_status & GR_READY)))
61470 + return;
61471 +
61472 + preempt_disable();
61473 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61474 +
61475 + if (unlikely((unsigned long)matchn)) {
61476 + write_lock(&gr_inode_lock);
61477 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61478 + write_unlock(&gr_inode_lock);
61479 + }
61480 + preempt_enable();
61481 +
61482 + return;
61483 +}
61484 +
61485 +void
61486 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61487 + struct dentry *old_dentry,
61488 + struct dentry *new_dentry,
61489 + struct vfsmount *mnt, const __u8 replace)
61490 +{
61491 + struct name_entry *matchn;
61492 + struct inodev_entry *inodev;
61493 + struct inode *inode = new_dentry->d_inode;
61494 + ino_t old_ino = old_dentry->d_inode->i_ino;
61495 + dev_t old_dev = __get_dev(old_dentry);
61496 +
61497 + /* vfs_rename swaps the name and parent link for old_dentry and
61498 + new_dentry
61499 + at this point, old_dentry has the new name, parent link, and inode
61500 + for the renamed file
61501 + if a file is being replaced by a rename, new_dentry has the inode
61502 + and name for the replaced file
61503 + */
61504 +
61505 + if (unlikely(!(gr_status & GR_READY)))
61506 + return;
61507 +
61508 + preempt_disable();
61509 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61510 +
61511 + /* we wouldn't have to check d_inode if it weren't for
61512 + NFS silly-renaming
61513 + */
61514 +
61515 + write_lock(&gr_inode_lock);
61516 + if (unlikely(replace && inode)) {
61517 + ino_t new_ino = inode->i_ino;
61518 + dev_t new_dev = __get_dev(new_dentry);
61519 +
61520 + inodev = lookup_inodev_entry(new_ino, new_dev);
61521 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61522 + do_handle_delete(inodev, new_ino, new_dev);
61523 + }
61524 +
61525 + inodev = lookup_inodev_entry(old_ino, old_dev);
61526 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61527 + do_handle_delete(inodev, old_ino, old_dev);
61528 +
61529 + if (unlikely((unsigned long)matchn))
61530 + do_handle_create(matchn, old_dentry, mnt);
61531 +
61532 + write_unlock(&gr_inode_lock);
61533 + preempt_enable();
61534 +
61535 + return;
61536 +}
61537 +
61538 +static int
61539 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61540 + unsigned char **sum)
61541 +{
61542 + struct acl_role_label *r;
61543 + struct role_allowed_ip *ipp;
61544 + struct role_transition *trans;
61545 + unsigned int i;
61546 + int found = 0;
61547 + u32 curr_ip = current->signal->curr_ip;
61548 +
61549 + current->signal->saved_ip = curr_ip;
61550 +
61551 + /* check transition table */
61552 +
61553 + for (trans = current->role->transitions; trans; trans = trans->next) {
61554 + if (!strcmp(rolename, trans->rolename)) {
61555 + found = 1;
61556 + break;
61557 + }
61558 + }
61559 +
61560 + if (!found)
61561 + return 0;
61562 +
61563 + /* handle special roles that do not require authentication
61564 + and check ip */
61565 +
61566 + FOR_EACH_ROLE_START(r)
61567 + if (!strcmp(rolename, r->rolename) &&
61568 + (r->roletype & GR_ROLE_SPECIAL)) {
61569 + found = 0;
61570 + if (r->allowed_ips != NULL) {
61571 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61572 + if ((ntohl(curr_ip) & ipp->netmask) ==
61573 + (ntohl(ipp->addr) & ipp->netmask))
61574 + found = 1;
61575 + }
61576 + } else
61577 + found = 2;
61578 + if (!found)
61579 + return 0;
61580 +
61581 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61582 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61583 + *salt = NULL;
61584 + *sum = NULL;
61585 + return 1;
61586 + }
61587 + }
61588 + FOR_EACH_ROLE_END(r)
61589 +
61590 + for (i = 0; i < num_sprole_pws; i++) {
61591 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61592 + *salt = acl_special_roles[i]->salt;
61593 + *sum = acl_special_roles[i]->sum;
61594 + return 1;
61595 + }
61596 + }
61597 +
61598 + return 0;
61599 +}
61600 +
61601 +static void
61602 +assign_special_role(char *rolename)
61603 +{
61604 + struct acl_object_label *obj;
61605 + struct acl_role_label *r;
61606 + struct acl_role_label *assigned = NULL;
61607 + struct task_struct *tsk;
61608 + struct file *filp;
61609 +
61610 + FOR_EACH_ROLE_START(r)
61611 + if (!strcmp(rolename, r->rolename) &&
61612 + (r->roletype & GR_ROLE_SPECIAL)) {
61613 + assigned = r;
61614 + break;
61615 + }
61616 + FOR_EACH_ROLE_END(r)
61617 +
61618 + if (!assigned)
61619 + return;
61620 +
61621 + read_lock(&tasklist_lock);
61622 + read_lock(&grsec_exec_file_lock);
61623 +
61624 + tsk = current->real_parent;
61625 + if (tsk == NULL)
61626 + goto out_unlock;
61627 +
61628 + filp = tsk->exec_file;
61629 + if (filp == NULL)
61630 + goto out_unlock;
61631 +
61632 + tsk->is_writable = 0;
61633 +
61634 + tsk->acl_sp_role = 1;
61635 + tsk->acl_role_id = ++acl_sp_role_value;
61636 + tsk->role = assigned;
61637 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61638 +
61639 + /* ignore additional mmap checks for processes that are writable
61640 + by the default ACL */
61641 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61642 + if (unlikely(obj->mode & GR_WRITE))
61643 + tsk->is_writable = 1;
61644 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61645 + if (unlikely(obj->mode & GR_WRITE))
61646 + tsk->is_writable = 1;
61647 +
61648 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61649 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename, tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
61650 +#endif
61651 +
61652 +out_unlock:
61653 + read_unlock(&grsec_exec_file_lock);
61654 + read_unlock(&tasklist_lock);
61655 + return;
61656 +}
61657 +
61658 +int gr_check_secure_terminal(struct task_struct *task)
61659 +{
61660 + struct task_struct *p, *p2, *p3;
61661 + struct files_struct *files;
61662 + struct fdtable *fdt;
61663 + struct file *our_file = NULL, *file;
61664 + int i;
61665 +
61666 + if (task->signal->tty == NULL)
61667 + return 1;
61668 +
61669 + files = get_files_struct(task);
61670 + if (files != NULL) {
61671 + rcu_read_lock();
61672 + fdt = files_fdtable(files);
61673 + for (i=0; i < fdt->max_fds; i++) {
61674 + file = fcheck_files(files, i);
61675 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61676 + get_file(file);
61677 + our_file = file;
61678 + }
61679 + }
61680 + rcu_read_unlock();
61681 + put_files_struct(files);
61682 + }
61683 +
61684 + if (our_file == NULL)
61685 + return 1;
61686 +
61687 + read_lock(&tasklist_lock);
61688 + do_each_thread(p2, p) {
61689 + files = get_files_struct(p);
61690 + if (files == NULL ||
61691 + (p->signal && p->signal->tty == task->signal->tty)) {
61692 + if (files != NULL)
61693 + put_files_struct(files);
61694 + continue;
61695 + }
61696 + rcu_read_lock();
61697 + fdt = files_fdtable(files);
61698 + for (i=0; i < fdt->max_fds; i++) {
61699 + file = fcheck_files(files, i);
61700 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61701 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61702 + p3 = task;
61703 + while (task_pid_nr(p3) > 0) {
61704 + if (p3 == p)
61705 + break;
61706 + p3 = p3->real_parent;
61707 + }
61708 + if (p3 == p)
61709 + break;
61710 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61711 + gr_handle_alertkill(p);
61712 + rcu_read_unlock();
61713 + put_files_struct(files);
61714 + read_unlock(&tasklist_lock);
61715 + fput(our_file);
61716 + return 0;
61717 + }
61718 + }
61719 + rcu_read_unlock();
61720 + put_files_struct(files);
61721 + } while_each_thread(p2, p);
61722 + read_unlock(&tasklist_lock);
61723 +
61724 + fput(our_file);
61725 + return 1;
61726 +}
61727 +
61728 +static int gr_rbac_disable(void *unused)
61729 +{
61730 + pax_open_kernel();
61731 + gr_status &= ~GR_READY;
61732 + pax_close_kernel();
61733 +
61734 + return 0;
61735 +}
61736 +
61737 +ssize_t
61738 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
61739 +{
61740 + struct gr_arg_wrapper uwrap;
61741 + unsigned char *sprole_salt = NULL;
61742 + unsigned char *sprole_sum = NULL;
61743 + int error = 0;
61744 + int error2 = 0;
61745 + size_t req_count = 0;
61746 +
61747 + mutex_lock(&gr_dev_mutex);
61748 +
61749 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61750 + error = -EPERM;
61751 + goto out;
61752 + }
61753 +
61754 +#ifdef CONFIG_COMPAT
61755 + pax_open_kernel();
61756 + if (is_compat_task()) {
61757 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
61758 + copy_gr_arg = &copy_gr_arg_compat;
61759 + copy_acl_object_label = &copy_acl_object_label_compat;
61760 + copy_acl_subject_label = &copy_acl_subject_label_compat;
61761 + copy_acl_role_label = &copy_acl_role_label_compat;
61762 + copy_acl_ip_label = &copy_acl_ip_label_compat;
61763 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
61764 + copy_role_transition = &copy_role_transition_compat;
61765 + copy_sprole_pw = &copy_sprole_pw_compat;
61766 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
61767 + copy_pointer_from_array = &copy_pointer_from_array_compat;
61768 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
61769 + } else {
61770 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
61771 + copy_gr_arg = &copy_gr_arg_normal;
61772 + copy_acl_object_label = &copy_acl_object_label_normal;
61773 + copy_acl_subject_label = &copy_acl_subject_label_normal;
61774 + copy_acl_role_label = &copy_acl_role_label_normal;
61775 + copy_acl_ip_label = &copy_acl_ip_label_normal;
61776 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
61777 + copy_role_transition = &copy_role_transition_normal;
61778 + copy_sprole_pw = &copy_sprole_pw_normal;
61779 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
61780 + copy_pointer_from_array = &copy_pointer_from_array_normal;
61781 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
61782 + }
61783 + pax_close_kernel();
61784 +#endif
61785 +
61786 + req_count = get_gr_arg_wrapper_size();
61787 +
61788 + if (count != req_count) {
61789 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
61790 + error = -EINVAL;
61791 + goto out;
61792 + }
61793 +
61794 +
61795 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61796 + gr_auth_expires = 0;
61797 + gr_auth_attempts = 0;
61798 + }
61799 +
61800 + error = copy_gr_arg_wrapper(buf, &uwrap);
61801 + if (error)
61802 + goto out;
61803 +
61804 + error = copy_gr_arg(uwrap.arg, gr_usermode);
61805 + if (error)
61806 + goto out;
61807 +
61808 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61809 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61810 + time_after(gr_auth_expires, get_seconds())) {
61811 + error = -EBUSY;
61812 + goto out;
61813 + }
61814 +
61815 + /* if non-root trying to do anything other than use a special role,
61816 + do not attempt authentication, do not count towards authentication
61817 + locking
61818 + */
61819 +
61820 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61821 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61822 + gr_is_global_nonroot(current_uid())) {
61823 + error = -EPERM;
61824 + goto out;
61825 + }
61826 +
61827 + /* ensure pw and special role name are null terminated */
61828 +
61829 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61830 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61831 +
61832 + /* Okay.
61833 + * We have our enough of the argument structure..(we have yet
61834 + * to copy_from_user the tables themselves) . Copy the tables
61835 + * only if we need them, i.e. for loading operations. */
61836 +
61837 + switch (gr_usermode->mode) {
61838 + case GR_STATUS:
61839 + if (gr_status & GR_READY) {
61840 + error = 1;
61841 + if (!gr_check_secure_terminal(current))
61842 + error = 3;
61843 + } else
61844 + error = 2;
61845 + goto out;
61846 + case GR_SHUTDOWN:
61847 + if ((gr_status & GR_READY)
61848 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61849 + stop_machine(gr_rbac_disable, NULL, NULL);
61850 + free_variables();
61851 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61852 + memset(gr_system_salt, 0, GR_SALT_LEN);
61853 + memset(gr_system_sum, 0, GR_SHA_LEN);
61854 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61855 + } else if (gr_status & GR_READY) {
61856 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61857 + error = -EPERM;
61858 + } else {
61859 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61860 + error = -EAGAIN;
61861 + }
61862 + break;
61863 + case GR_ENABLE:
61864 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61865 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61866 + else {
61867 + if (gr_status & GR_READY)
61868 + error = -EAGAIN;
61869 + else
61870 + error = error2;
61871 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61872 + }
61873 + break;
61874 + case GR_RELOAD:
61875 + if (!(gr_status & GR_READY)) {
61876 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61877 + error = -EAGAIN;
61878 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61879 + stop_machine(gr_rbac_disable, NULL, NULL);
61880 + free_variables();
61881 + error2 = gracl_init(gr_usermode);
61882 + if (!error2)
61883 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61884 + else {
61885 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61886 + error = error2;
61887 + }
61888 + } else {
61889 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61890 + error = -EPERM;
61891 + }
61892 + break;
61893 + case GR_SEGVMOD:
61894 + if (unlikely(!(gr_status & GR_READY))) {
61895 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61896 + error = -EAGAIN;
61897 + break;
61898 + }
61899 +
61900 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61901 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61902 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61903 + struct acl_subject_label *segvacl;
61904 + segvacl =
61905 + lookup_acl_subj_label(gr_usermode->segv_inode,
61906 + gr_usermode->segv_device,
61907 + current->role);
61908 + if (segvacl) {
61909 + segvacl->crashes = 0;
61910 + segvacl->expires = 0;
61911 + }
61912 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61913 + gr_remove_uid(gr_usermode->segv_uid);
61914 + }
61915 + } else {
61916 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61917 + error = -EPERM;
61918 + }
61919 + break;
61920 + case GR_SPROLE:
61921 + case GR_SPROLEPAM:
61922 + if (unlikely(!(gr_status & GR_READY))) {
61923 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61924 + error = -EAGAIN;
61925 + break;
61926 + }
61927 +
61928 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61929 + current->role->expires = 0;
61930 + current->role->auth_attempts = 0;
61931 + }
61932 +
61933 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61934 + time_after(current->role->expires, get_seconds())) {
61935 + error = -EBUSY;
61936 + goto out;
61937 + }
61938 +
61939 + if (lookup_special_role_auth
61940 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61941 + && ((!sprole_salt && !sprole_sum)
61942 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61943 + char *p = "";
61944 + assign_special_role(gr_usermode->sp_role);
61945 + read_lock(&tasklist_lock);
61946 + if (current->real_parent)
61947 + p = current->real_parent->role->rolename;
61948 + read_unlock(&tasklist_lock);
61949 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61950 + p, acl_sp_role_value);
61951 + } else {
61952 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61953 + error = -EPERM;
61954 + if(!(current->role->auth_attempts++))
61955 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61956 +
61957 + goto out;
61958 + }
61959 + break;
61960 + case GR_UNSPROLE:
61961 + if (unlikely(!(gr_status & GR_READY))) {
61962 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61963 + error = -EAGAIN;
61964 + break;
61965 + }
61966 +
61967 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61968 + char *p = "";
61969 + int i = 0;
61970 +
61971 + read_lock(&tasklist_lock);
61972 + if (current->real_parent) {
61973 + p = current->real_parent->role->rolename;
61974 + i = current->real_parent->acl_role_id;
61975 + }
61976 + read_unlock(&tasklist_lock);
61977 +
61978 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61979 + gr_set_acls(1);
61980 + } else {
61981 + error = -EPERM;
61982 + goto out;
61983 + }
61984 + break;
61985 + default:
61986 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61987 + error = -EINVAL;
61988 + break;
61989 + }
61990 +
61991 + if (error != -EPERM)
61992 + goto out;
61993 +
61994 + if(!(gr_auth_attempts++))
61995 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61996 +
61997 + out:
61998 + mutex_unlock(&gr_dev_mutex);
61999 +
62000 + if (!error)
62001 + error = req_count;
62002 +
62003 + return error;
62004 +}
62005 +
62006 +/* must be called with
62007 + rcu_read_lock();
62008 + read_lock(&tasklist_lock);
62009 + read_lock(&grsec_exec_file_lock);
62010 +*/
62011 +int gr_apply_subject_to_task(struct task_struct *task)
62012 +{
62013 + struct acl_object_label *obj;
62014 + char *tmpname;
62015 + struct acl_subject_label *tmpsubj;
62016 + struct file *filp;
62017 + struct name_entry *nmatch;
62018 +
62019 + filp = task->exec_file;
62020 + if (filp == NULL)
62021 + return 0;
62022 +
62023 + /* the following is to apply the correct subject
62024 + on binaries running when the RBAC system
62025 + is enabled, when the binaries have been
62026 + replaced or deleted since their execution
62027 + -----
62028 + when the RBAC system starts, the inode/dev
62029 + from exec_file will be one the RBAC system
62030 + is unaware of. It only knows the inode/dev
62031 + of the present file on disk, or the absence
62032 + of it.
62033 + */
62034 + preempt_disable();
62035 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
62036 +
62037 + nmatch = lookup_name_entry(tmpname);
62038 + preempt_enable();
62039 + tmpsubj = NULL;
62040 + if (nmatch) {
62041 + if (nmatch->deleted)
62042 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
62043 + else
62044 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
62045 + if (tmpsubj != NULL)
62046 + task->acl = tmpsubj;
62047 + }
62048 + if (tmpsubj == NULL)
62049 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
62050 + task->role);
62051 + if (task->acl) {
62052 + task->is_writable = 0;
62053 + /* ignore additional mmap checks for processes that are writable
62054 + by the default ACL */
62055 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62056 + if (unlikely(obj->mode & GR_WRITE))
62057 + task->is_writable = 1;
62058 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
62059 + if (unlikely(obj->mode & GR_WRITE))
62060 + task->is_writable = 1;
62061 +
62062 + gr_set_proc_res(task);
62063 +
62064 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
62065 + printk(KERN_ALERT "gr_set_acls for (%s:%d): role:%s, subject:%s\n", task->comm, task_pid_nr(task), task->role->rolename, task->acl->filename);
62066 +#endif
62067 + } else {
62068 + return 1;
62069 + }
62070 +
62071 + return 0;
62072 +}
62073 +
62074 +int
62075 +gr_set_acls(const int type)
62076 +{
62077 + struct task_struct *task, *task2;
62078 + struct acl_role_label *role = current->role;
62079 + __u16 acl_role_id = current->acl_role_id;
62080 + const struct cred *cred;
62081 + int ret;
62082 +
62083 + rcu_read_lock();
62084 + read_lock(&tasklist_lock);
62085 + read_lock(&grsec_exec_file_lock);
62086 + do_each_thread(task2, task) {
62087 + /* check to see if we're called from the exit handler,
62088 + if so, only replace ACLs that have inherited the admin
62089 + ACL */
62090 +
62091 + if (type && (task->role != role ||
62092 + task->acl_role_id != acl_role_id))
62093 + continue;
62094 +
62095 + task->acl_role_id = 0;
62096 + task->acl_sp_role = 0;
62097 +
62098 + if (task->exec_file) {
62099 + cred = __task_cred(task);
62100 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
62101 + ret = gr_apply_subject_to_task(task);
62102 + if (ret) {
62103 + read_unlock(&grsec_exec_file_lock);
62104 + read_unlock(&tasklist_lock);
62105 + rcu_read_unlock();
62106 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
62107 + return ret;
62108 + }
62109 + } else {
62110 + // it's a kernel process
62111 + task->role = kernel_role;
62112 + task->acl = kernel_role->root_label;
62113 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
62114 + task->acl->mode &= ~GR_PROCFIND;
62115 +#endif
62116 + }
62117 + } while_each_thread(task2, task);
62118 + read_unlock(&grsec_exec_file_lock);
62119 + read_unlock(&tasklist_lock);
62120 + rcu_read_unlock();
62121 +
62122 + return 0;
62123 +}
62124 +
62125 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
62126 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
62127 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
62128 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
62129 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
62130 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
62131 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
62132 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
62133 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
62134 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
62135 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
62136 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
62137 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
62138 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
62139 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
62140 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
62141 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
62142 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
62143 +};
62144 +
62145 +void
62146 +gr_learn_resource(const struct task_struct *task,
62147 + const int res, const unsigned long wanted, const int gt)
62148 +{
62149 + struct acl_subject_label *acl;
62150 + const struct cred *cred;
62151 +
62152 + if (unlikely((gr_status & GR_READY) &&
62153 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
62154 + goto skip_reslog;
62155 +
62156 + gr_log_resource(task, res, wanted, gt);
62157 +skip_reslog:
62158 +
62159 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
62160 + return;
62161 +
62162 + acl = task->acl;
62163 +
62164 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
62165 + !(acl->resmask & (1U << (unsigned short) res))))
62166 + return;
62167 +
62168 + if (wanted >= acl->res[res].rlim_cur) {
62169 + unsigned long res_add;
62170 +
62171 + res_add = wanted + res_learn_bumps[res];
62172 +
62173 + acl->res[res].rlim_cur = res_add;
62174 +
62175 + if (wanted > acl->res[res].rlim_max)
62176 + acl->res[res].rlim_max = res_add;
62177 +
62178 + /* only log the subject filename, since resource logging is supported for
62179 + single-subject learning only */
62180 + rcu_read_lock();
62181 + cred = __task_cred(task);
62182 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62183 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
62184 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
62185 + "", (unsigned long) res, &task->signal->saved_ip);
62186 + rcu_read_unlock();
62187 + }
62188 +
62189 + return;
62190 +}
62191 +EXPORT_SYMBOL(gr_learn_resource);
62192 +#endif
62193 +
62194 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
62195 +void
62196 +pax_set_initial_flags(struct linux_binprm *bprm)
62197 +{
62198 + struct task_struct *task = current;
62199 + struct acl_subject_label *proc;
62200 + unsigned long flags;
62201 +
62202 + if (unlikely(!(gr_status & GR_READY)))
62203 + return;
62204 +
62205 + flags = pax_get_flags(task);
62206 +
62207 + proc = task->acl;
62208 +
62209 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
62210 + flags &= ~MF_PAX_PAGEEXEC;
62211 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
62212 + flags &= ~MF_PAX_SEGMEXEC;
62213 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
62214 + flags &= ~MF_PAX_RANDMMAP;
62215 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
62216 + flags &= ~MF_PAX_EMUTRAMP;
62217 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
62218 + flags &= ~MF_PAX_MPROTECT;
62219 +
62220 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
62221 + flags |= MF_PAX_PAGEEXEC;
62222 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
62223 + flags |= MF_PAX_SEGMEXEC;
62224 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
62225 + flags |= MF_PAX_RANDMMAP;
62226 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
62227 + flags |= MF_PAX_EMUTRAMP;
62228 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
62229 + flags |= MF_PAX_MPROTECT;
62230 +
62231 + pax_set_flags(task, flags);
62232 +
62233 + return;
62234 +}
62235 +#endif
62236 +
62237 +int
62238 +gr_handle_proc_ptrace(struct task_struct *task)
62239 +{
62240 + struct file *filp;
62241 + struct task_struct *tmp = task;
62242 + struct task_struct *curtemp = current;
62243 + __u32 retmode;
62244 +
62245 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62246 + if (unlikely(!(gr_status & GR_READY)))
62247 + return 0;
62248 +#endif
62249 +
62250 + read_lock(&tasklist_lock);
62251 + read_lock(&grsec_exec_file_lock);
62252 + filp = task->exec_file;
62253 +
62254 + while (task_pid_nr(tmp) > 0) {
62255 + if (tmp == curtemp)
62256 + break;
62257 + tmp = tmp->real_parent;
62258 + }
62259 +
62260 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62261 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
62262 + read_unlock(&grsec_exec_file_lock);
62263 + read_unlock(&tasklist_lock);
62264 + return 1;
62265 + }
62266 +
62267 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62268 + if (!(gr_status & GR_READY)) {
62269 + read_unlock(&grsec_exec_file_lock);
62270 + read_unlock(&tasklist_lock);
62271 + return 0;
62272 + }
62273 +#endif
62274 +
62275 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
62276 + read_unlock(&grsec_exec_file_lock);
62277 + read_unlock(&tasklist_lock);
62278 +
62279 + if (retmode & GR_NOPTRACE)
62280 + return 1;
62281 +
62282 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
62283 + && (current->acl != task->acl || (current->acl != current->role->root_label
62284 + && task_pid_nr(current) != task_pid_nr(task))))
62285 + return 1;
62286 +
62287 + return 0;
62288 +}
62289 +
62290 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
62291 +{
62292 + if (unlikely(!(gr_status & GR_READY)))
62293 + return;
62294 +
62295 + if (!(current->role->roletype & GR_ROLE_GOD))
62296 + return;
62297 +
62298 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
62299 + p->role->rolename, gr_task_roletype_to_char(p),
62300 + p->acl->filename);
62301 +}
62302 +
62303 +int
62304 +gr_handle_ptrace(struct task_struct *task, const long request)
62305 +{
62306 + struct task_struct *tmp = task;
62307 + struct task_struct *curtemp = current;
62308 + __u32 retmode;
62309 +
62310 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62311 + if (unlikely(!(gr_status & GR_READY)))
62312 + return 0;
62313 +#endif
62314 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
62315 + read_lock(&tasklist_lock);
62316 + while (task_pid_nr(tmp) > 0) {
62317 + if (tmp == curtemp)
62318 + break;
62319 + tmp = tmp->real_parent;
62320 + }
62321 +
62322 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62323 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
62324 + read_unlock(&tasklist_lock);
62325 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62326 + return 1;
62327 + }
62328 + read_unlock(&tasklist_lock);
62329 + }
62330 +
62331 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62332 + if (!(gr_status & GR_READY))
62333 + return 0;
62334 +#endif
62335 +
62336 + read_lock(&grsec_exec_file_lock);
62337 + if (unlikely(!task->exec_file)) {
62338 + read_unlock(&grsec_exec_file_lock);
62339 + return 0;
62340 + }
62341 +
62342 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
62343 + read_unlock(&grsec_exec_file_lock);
62344 +
62345 + if (retmode & GR_NOPTRACE) {
62346 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62347 + return 1;
62348 + }
62349 +
62350 + if (retmode & GR_PTRACERD) {
62351 + switch (request) {
62352 + case PTRACE_SEIZE:
62353 + case PTRACE_POKETEXT:
62354 + case PTRACE_POKEDATA:
62355 + case PTRACE_POKEUSR:
62356 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
62357 + case PTRACE_SETREGS:
62358 + case PTRACE_SETFPREGS:
62359 +#endif
62360 +#ifdef CONFIG_X86
62361 + case PTRACE_SETFPXREGS:
62362 +#endif
62363 +#ifdef CONFIG_ALTIVEC
62364 + case PTRACE_SETVRREGS:
62365 +#endif
62366 + return 1;
62367 + default:
62368 + return 0;
62369 + }
62370 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
62371 + !(current->role->roletype & GR_ROLE_GOD) &&
62372 + (current->acl != task->acl)) {
62373 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62374 + return 1;
62375 + }
62376 +
62377 + return 0;
62378 +}
62379 +
62380 +static int is_writable_mmap(const struct file *filp)
62381 +{
62382 + struct task_struct *task = current;
62383 + struct acl_object_label *obj, *obj2;
62384 +
62385 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
62386 + !task->is_writable && S_ISREG(filp->f_path.dentry->d_inode->i_mode) && (filp->f_path.mnt != shm_mnt || (filp->f_path.dentry->d_inode->i_nlink > 0))) {
62387 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62388 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
62389 + task->role->root_label);
62390 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
62391 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
62392 + return 1;
62393 + }
62394 + }
62395 + return 0;
62396 +}
62397 +
62398 +int
62399 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
62400 +{
62401 + __u32 mode;
62402 +
62403 + if (unlikely(!file || !(prot & PROT_EXEC)))
62404 + return 1;
62405 +
62406 + if (is_writable_mmap(file))
62407 + return 0;
62408 +
62409 + mode =
62410 + gr_search_file(file->f_path.dentry,
62411 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62412 + file->f_path.mnt);
62413 +
62414 + if (!gr_tpe_allow(file))
62415 + return 0;
62416 +
62417 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62418 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62419 + return 0;
62420 + } else if (unlikely(!(mode & GR_EXEC))) {
62421 + return 0;
62422 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62423 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62424 + return 1;
62425 + }
62426 +
62427 + return 1;
62428 +}
62429 +
62430 +int
62431 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62432 +{
62433 + __u32 mode;
62434 +
62435 + if (unlikely(!file || !(prot & PROT_EXEC)))
62436 + return 1;
62437 +
62438 + if (is_writable_mmap(file))
62439 + return 0;
62440 +
62441 + mode =
62442 + gr_search_file(file->f_path.dentry,
62443 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62444 + file->f_path.mnt);
62445 +
62446 + if (!gr_tpe_allow(file))
62447 + return 0;
62448 +
62449 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62450 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62451 + return 0;
62452 + } else if (unlikely(!(mode & GR_EXEC))) {
62453 + return 0;
62454 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62455 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62456 + return 1;
62457 + }
62458 +
62459 + return 1;
62460 +}
62461 +
62462 +void
62463 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62464 +{
62465 + unsigned long runtime;
62466 + unsigned long cputime;
62467 + unsigned int wday, cday;
62468 + __u8 whr, chr;
62469 + __u8 wmin, cmin;
62470 + __u8 wsec, csec;
62471 + struct timespec timeval;
62472 +
62473 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62474 + !(task->acl->mode & GR_PROCACCT)))
62475 + return;
62476 +
62477 + do_posix_clock_monotonic_gettime(&timeval);
62478 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62479 + wday = runtime / (3600 * 24);
62480 + runtime -= wday * (3600 * 24);
62481 + whr = runtime / 3600;
62482 + runtime -= whr * 3600;
62483 + wmin = runtime / 60;
62484 + runtime -= wmin * 60;
62485 + wsec = runtime;
62486 +
62487 + cputime = (task->utime + task->stime) / HZ;
62488 + cday = cputime / (3600 * 24);
62489 + cputime -= cday * (3600 * 24);
62490 + chr = cputime / 3600;
62491 + cputime -= chr * 3600;
62492 + cmin = cputime / 60;
62493 + cputime -= cmin * 60;
62494 + csec = cputime;
62495 +
62496 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62497 +
62498 + return;
62499 +}
62500 +
62501 +void gr_set_kernel_label(struct task_struct *task)
62502 +{
62503 + if (gr_status & GR_READY) {
62504 + task->role = kernel_role;
62505 + task->acl = kernel_role->root_label;
62506 + }
62507 + return;
62508 +}
62509 +
62510 +#ifdef CONFIG_TASKSTATS
62511 +int gr_is_taskstats_denied(int pid)
62512 +{
62513 + struct task_struct *task;
62514 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62515 + const struct cred *cred;
62516 +#endif
62517 + int ret = 0;
62518 +
62519 + /* restrict taskstats viewing to un-chrooted root users
62520 + who have the 'view' subject flag if the RBAC system is enabled
62521 + */
62522 +
62523 + rcu_read_lock();
62524 + read_lock(&tasklist_lock);
62525 + task = find_task_by_vpid(pid);
62526 + if (task) {
62527 +#ifdef CONFIG_GRKERNSEC_CHROOT
62528 + if (proc_is_chrooted(task))
62529 + ret = -EACCES;
62530 +#endif
62531 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62532 + cred = __task_cred(task);
62533 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62534 + if (gr_is_global_nonroot(cred->uid))
62535 + ret = -EACCES;
62536 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62537 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62538 + ret = -EACCES;
62539 +#endif
62540 +#endif
62541 + if (gr_status & GR_READY) {
62542 + if (!(task->acl->mode & GR_VIEW))
62543 + ret = -EACCES;
62544 + }
62545 + } else
62546 + ret = -ENOENT;
62547 +
62548 + read_unlock(&tasklist_lock);
62549 + rcu_read_unlock();
62550 +
62551 + return ret;
62552 +}
62553 +#endif
62554 +
62555 +/* AUXV entries are filled via a descendant of search_binary_handler
62556 + after we've already applied the subject for the target
62557 +*/
62558 +int gr_acl_enable_at_secure(void)
62559 +{
62560 + if (unlikely(!(gr_status & GR_READY)))
62561 + return 0;
62562 +
62563 + if (current->acl->mode & GR_ATSECURE)
62564 + return 1;
62565 +
62566 + return 0;
62567 +}
62568 +
62569 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62570 +{
62571 + struct task_struct *task = current;
62572 + struct dentry *dentry = file->f_path.dentry;
62573 + struct vfsmount *mnt = file->f_path.mnt;
62574 + struct acl_object_label *obj, *tmp;
62575 + struct acl_subject_label *subj;
62576 + unsigned int bufsize;
62577 + int is_not_root;
62578 + char *path;
62579 + dev_t dev = __get_dev(dentry);
62580 +
62581 + if (unlikely(!(gr_status & GR_READY)))
62582 + return 1;
62583 +
62584 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62585 + return 1;
62586 +
62587 + /* ignore Eric Biederman */
62588 + if (IS_PRIVATE(dentry->d_inode))
62589 + return 1;
62590 +
62591 + subj = task->acl;
62592 + read_lock(&gr_inode_lock);
62593 + do {
62594 + obj = lookup_acl_obj_label(ino, dev, subj);
62595 + if (obj != NULL) {
62596 + read_unlock(&gr_inode_lock);
62597 + return (obj->mode & GR_FIND) ? 1 : 0;
62598 + }
62599 + } while ((subj = subj->parent_subject));
62600 + read_unlock(&gr_inode_lock);
62601 +
62602 + /* this is purely an optimization since we're looking for an object
62603 + for the directory we're doing a readdir on
62604 + if it's possible for any globbed object to match the entry we're
62605 + filling into the directory, then the object we find here will be
62606 + an anchor point with attached globbed objects
62607 + */
62608 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62609 + if (obj->globbed == NULL)
62610 + return (obj->mode & GR_FIND) ? 1 : 0;
62611 +
62612 + is_not_root = ((obj->filename[0] == '/') &&
62613 + (obj->filename[1] == '\0')) ? 0 : 1;
62614 + bufsize = PAGE_SIZE - namelen - is_not_root;
62615 +
62616 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62617 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62618 + return 1;
62619 +
62620 + preempt_disable();
62621 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62622 + bufsize);
62623 +
62624 + bufsize = strlen(path);
62625 +
62626 + /* if base is "/", don't append an additional slash */
62627 + if (is_not_root)
62628 + *(path + bufsize) = '/';
62629 + memcpy(path + bufsize + is_not_root, name, namelen);
62630 + *(path + bufsize + namelen + is_not_root) = '\0';
62631 +
62632 + tmp = obj->globbed;
62633 + while (tmp) {
62634 + if (!glob_match(tmp->filename, path)) {
62635 + preempt_enable();
62636 + return (tmp->mode & GR_FIND) ? 1 : 0;
62637 + }
62638 + tmp = tmp->next;
62639 + }
62640 + preempt_enable();
62641 + return (obj->mode & GR_FIND) ? 1 : 0;
62642 +}
62643 +
62644 +void gr_put_exec_file(struct task_struct *task)
62645 +{
62646 + struct file *filp;
62647 +
62648 + write_lock(&grsec_exec_file_lock);
62649 + filp = task->exec_file;
62650 + task->exec_file = NULL;
62651 + write_unlock(&grsec_exec_file_lock);
62652 +
62653 + if (filp)
62654 + fput(filp);
62655 +
62656 + return;
62657 +}
62658 +
62659 +
62660 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62661 +EXPORT_SYMBOL(gr_acl_is_enabled);
62662 +#endif
62663 +EXPORT_SYMBOL(gr_set_kernel_label);
62664 +#ifdef CONFIG_SECURITY
62665 +EXPORT_SYMBOL(gr_check_user_change);
62666 +EXPORT_SYMBOL(gr_check_group_change);
62667 +#endif
62668 +
62669 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62670 new file mode 100644
62671 index 0000000..34fefda
62672 --- /dev/null
62673 +++ b/grsecurity/gracl_alloc.c
62674 @@ -0,0 +1,105 @@
62675 +#include <linux/kernel.h>
62676 +#include <linux/mm.h>
62677 +#include <linux/slab.h>
62678 +#include <linux/vmalloc.h>
62679 +#include <linux/gracl.h>
62680 +#include <linux/grsecurity.h>
62681 +
62682 +static unsigned long alloc_stack_next = 1;
62683 +static unsigned long alloc_stack_size = 1;
62684 +static void **alloc_stack;
62685 +
62686 +static __inline__ int
62687 +alloc_pop(void)
62688 +{
62689 + if (alloc_stack_next == 1)
62690 + return 0;
62691 +
62692 + kfree(alloc_stack[alloc_stack_next - 2]);
62693 +
62694 + alloc_stack_next--;
62695 +
62696 + return 1;
62697 +}
62698 +
62699 +static __inline__ int
62700 +alloc_push(void *buf)
62701 +{
62702 + if (alloc_stack_next >= alloc_stack_size)
62703 + return 1;
62704 +
62705 + alloc_stack[alloc_stack_next - 1] = buf;
62706 +
62707 + alloc_stack_next++;
62708 +
62709 + return 0;
62710 +}
62711 +
62712 +void *
62713 +acl_alloc(unsigned long len)
62714 +{
62715 + void *ret = NULL;
62716 +
62717 + if (!len || len > PAGE_SIZE)
62718 + goto out;
62719 +
62720 + ret = kmalloc(len, GFP_KERNEL);
62721 +
62722 + if (ret) {
62723 + if (alloc_push(ret)) {
62724 + kfree(ret);
62725 + ret = NULL;
62726 + }
62727 + }
62728 +
62729 +out:
62730 + return ret;
62731 +}
62732 +
62733 +void *
62734 +acl_alloc_num(unsigned long num, unsigned long len)
62735 +{
62736 + if (!len || (num > (PAGE_SIZE / len)))
62737 + return NULL;
62738 +
62739 + return acl_alloc(num * len);
62740 +}
62741 +
62742 +void
62743 +acl_free_all(void)
62744 +{
62745 + if (gr_acl_is_enabled() || !alloc_stack)
62746 + return;
62747 +
62748 + while (alloc_pop()) ;
62749 +
62750 + if (alloc_stack) {
62751 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62752 + kfree(alloc_stack);
62753 + else
62754 + vfree(alloc_stack);
62755 + }
62756 +
62757 + alloc_stack = NULL;
62758 + alloc_stack_size = 1;
62759 + alloc_stack_next = 1;
62760 +
62761 + return;
62762 +}
62763 +
62764 +int
62765 +acl_alloc_stack_init(unsigned long size)
62766 +{
62767 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62768 + alloc_stack =
62769 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62770 + else
62771 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62772 +
62773 + alloc_stack_size = size;
62774 +
62775 + if (!alloc_stack)
62776 + return 0;
62777 + else
62778 + return 1;
62779 +}
62780 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62781 new file mode 100644
62782 index 0000000..bdd51ea
62783 --- /dev/null
62784 +++ b/grsecurity/gracl_cap.c
62785 @@ -0,0 +1,110 @@
62786 +#include <linux/kernel.h>
62787 +#include <linux/module.h>
62788 +#include <linux/sched.h>
62789 +#include <linux/gracl.h>
62790 +#include <linux/grsecurity.h>
62791 +#include <linux/grinternal.h>
62792 +
62793 +extern const char *captab_log[];
62794 +extern int captab_log_entries;
62795 +
62796 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62797 +{
62798 + struct acl_subject_label *curracl;
62799 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62800 + kernel_cap_t cap_audit = __cap_empty_set;
62801 +
62802 + if (!gr_acl_is_enabled())
62803 + return 1;
62804 +
62805 + curracl = task->acl;
62806 +
62807 + cap_drop = curracl->cap_lower;
62808 + cap_mask = curracl->cap_mask;
62809 + cap_audit = curracl->cap_invert_audit;
62810 +
62811 + while ((curracl = curracl->parent_subject)) {
62812 + /* if the cap isn't specified in the current computed mask but is specified in the
62813 + current level subject, and is lowered in the current level subject, then add
62814 + it to the set of dropped capabilities
62815 + otherwise, add the current level subject's mask to the current computed mask
62816 + */
62817 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62818 + cap_raise(cap_mask, cap);
62819 + if (cap_raised(curracl->cap_lower, cap))
62820 + cap_raise(cap_drop, cap);
62821 + if (cap_raised(curracl->cap_invert_audit, cap))
62822 + cap_raise(cap_audit, cap);
62823 + }
62824 + }
62825 +
62826 + if (!cap_raised(cap_drop, cap)) {
62827 + if (cap_raised(cap_audit, cap))
62828 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62829 + return 1;
62830 + }
62831 +
62832 + curracl = task->acl;
62833 +
62834 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62835 + && cap_raised(cred->cap_effective, cap)) {
62836 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62837 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62838 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62839 + gr_to_filename(task->exec_file->f_path.dentry,
62840 + task->exec_file->f_path.mnt) : curracl->filename,
62841 + curracl->filename, 0UL,
62842 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62843 + return 1;
62844 + }
62845 +
62846 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62847 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62848 +
62849 + return 0;
62850 +}
62851 +
62852 +int
62853 +gr_acl_is_capable(const int cap)
62854 +{
62855 + return gr_task_acl_is_capable(current, current_cred(), cap);
62856 +}
62857 +
62858 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62859 +{
62860 + struct acl_subject_label *curracl;
62861 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62862 +
62863 + if (!gr_acl_is_enabled())
62864 + return 1;
62865 +
62866 + curracl = task->acl;
62867 +
62868 + cap_drop = curracl->cap_lower;
62869 + cap_mask = curracl->cap_mask;
62870 +
62871 + while ((curracl = curracl->parent_subject)) {
62872 + /* if the cap isn't specified in the current computed mask but is specified in the
62873 + current level subject, and is lowered in the current level subject, then add
62874 + it to the set of dropped capabilities
62875 + otherwise, add the current level subject's mask to the current computed mask
62876 + */
62877 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62878 + cap_raise(cap_mask, cap);
62879 + if (cap_raised(curracl->cap_lower, cap))
62880 + cap_raise(cap_drop, cap);
62881 + }
62882 + }
62883 +
62884 + if (!cap_raised(cap_drop, cap))
62885 + return 1;
62886 +
62887 + return 0;
62888 +}
62889 +
62890 +int
62891 +gr_acl_is_capable_nolog(const int cap)
62892 +{
62893 + return gr_task_acl_is_capable_nolog(current, cap);
62894 +}
62895 +
62896 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
62897 new file mode 100644
62898 index 0000000..a43dd06
62899 --- /dev/null
62900 +++ b/grsecurity/gracl_compat.c
62901 @@ -0,0 +1,269 @@
62902 +#include <linux/kernel.h>
62903 +#include <linux/gracl.h>
62904 +#include <linux/compat.h>
62905 +#include <linux/gracl_compat.h>
62906 +
62907 +#include <asm/uaccess.h>
62908 +
62909 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
62910 +{
62911 + struct gr_arg_wrapper_compat uwrapcompat;
62912 +
62913 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
62914 + return -EFAULT;
62915 +
62916 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
62917 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
62918 + return -EINVAL;
62919 +
62920 + uwrap->arg = compat_ptr(uwrapcompat.arg);
62921 + uwrap->version = uwrapcompat.version;
62922 + uwrap->size = sizeof(struct gr_arg);
62923 +
62924 + return 0;
62925 +}
62926 +
62927 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
62928 +{
62929 + struct gr_arg_compat argcompat;
62930 +
62931 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
62932 + return -EFAULT;
62933 +
62934 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
62935 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
62936 + arg->role_db.num_roles = argcompat.role_db.num_roles;
62937 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
62938 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
62939 + arg->role_db.num_objects = argcompat.role_db.num_objects;
62940 +
62941 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
62942 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
62943 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
62944 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
62945 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
62946 + arg->segv_device = argcompat.segv_device;
62947 + arg->segv_inode = argcompat.segv_inode;
62948 + arg->segv_uid = argcompat.segv_uid;
62949 + arg->num_sprole_pws = argcompat.num_sprole_pws;
62950 + arg->mode = argcompat.mode;
62951 +
62952 + return 0;
62953 +}
62954 +
62955 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
62956 +{
62957 + struct acl_object_label_compat objcompat;
62958 +
62959 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
62960 + return -EFAULT;
62961 +
62962 + obj->filename = compat_ptr(objcompat.filename);
62963 + obj->inode = objcompat.inode;
62964 + obj->device = objcompat.device;
62965 + obj->mode = objcompat.mode;
62966 +
62967 + obj->nested = compat_ptr(objcompat.nested);
62968 + obj->globbed = compat_ptr(objcompat.globbed);
62969 +
62970 + obj->prev = compat_ptr(objcompat.prev);
62971 + obj->next = compat_ptr(objcompat.next);
62972 +
62973 + return 0;
62974 +}
62975 +
62976 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62977 +{
62978 + unsigned int i;
62979 + struct acl_subject_label_compat subjcompat;
62980 +
62981 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
62982 + return -EFAULT;
62983 +
62984 + subj->filename = compat_ptr(subjcompat.filename);
62985 + subj->inode = subjcompat.inode;
62986 + subj->device = subjcompat.device;
62987 + subj->mode = subjcompat.mode;
62988 + subj->cap_mask = subjcompat.cap_mask;
62989 + subj->cap_lower = subjcompat.cap_lower;
62990 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
62991 +
62992 + for (i = 0; i < GR_NLIMITS; i++) {
62993 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
62994 + subj->res[i].rlim_cur = RLIM_INFINITY;
62995 + else
62996 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
62997 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
62998 + subj->res[i].rlim_max = RLIM_INFINITY;
62999 + else
63000 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
63001 + }
63002 + subj->resmask = subjcompat.resmask;
63003 +
63004 + subj->user_trans_type = subjcompat.user_trans_type;
63005 + subj->group_trans_type = subjcompat.group_trans_type;
63006 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
63007 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
63008 + subj->user_trans_num = subjcompat.user_trans_num;
63009 + subj->group_trans_num = subjcompat.group_trans_num;
63010 +
63011 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
63012 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
63013 + subj->ip_type = subjcompat.ip_type;
63014 + subj->ips = compat_ptr(subjcompat.ips);
63015 + subj->ip_num = subjcompat.ip_num;
63016 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
63017 +
63018 + subj->crashes = subjcompat.crashes;
63019 + subj->expires = subjcompat.expires;
63020 +
63021 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
63022 + subj->hash = compat_ptr(subjcompat.hash);
63023 + subj->prev = compat_ptr(subjcompat.prev);
63024 + subj->next = compat_ptr(subjcompat.next);
63025 +
63026 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
63027 + subj->obj_hash_size = subjcompat.obj_hash_size;
63028 + subj->pax_flags = subjcompat.pax_flags;
63029 +
63030 + return 0;
63031 +}
63032 +
63033 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
63034 +{
63035 + struct acl_role_label_compat rolecompat;
63036 +
63037 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
63038 + return -EFAULT;
63039 +
63040 + role->rolename = compat_ptr(rolecompat.rolename);
63041 + role->uidgid = rolecompat.uidgid;
63042 + role->roletype = rolecompat.roletype;
63043 +
63044 + role->auth_attempts = rolecompat.auth_attempts;
63045 + role->expires = rolecompat.expires;
63046 +
63047 + role->root_label = compat_ptr(rolecompat.root_label);
63048 + role->hash = compat_ptr(rolecompat.hash);
63049 +
63050 + role->prev = compat_ptr(rolecompat.prev);
63051 + role->next = compat_ptr(rolecompat.next);
63052 +
63053 + role->transitions = compat_ptr(rolecompat.transitions);
63054 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
63055 + role->domain_children = compat_ptr(rolecompat.domain_children);
63056 + role->domain_child_num = rolecompat.domain_child_num;
63057 +
63058 + role->umask = rolecompat.umask;
63059 +
63060 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
63061 + role->subj_hash_size = rolecompat.subj_hash_size;
63062 +
63063 + return 0;
63064 +}
63065 +
63066 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
63067 +{
63068 + struct role_allowed_ip_compat roleip_compat;
63069 +
63070 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
63071 + return -EFAULT;
63072 +
63073 + roleip->addr = roleip_compat.addr;
63074 + roleip->netmask = roleip_compat.netmask;
63075 +
63076 + roleip->prev = compat_ptr(roleip_compat.prev);
63077 + roleip->next = compat_ptr(roleip_compat.next);
63078 +
63079 + return 0;
63080 +}
63081 +
63082 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
63083 +{
63084 + struct role_transition_compat trans_compat;
63085 +
63086 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
63087 + return -EFAULT;
63088 +
63089 + trans->rolename = compat_ptr(trans_compat.rolename);
63090 +
63091 + trans->prev = compat_ptr(trans_compat.prev);
63092 + trans->next = compat_ptr(trans_compat.next);
63093 +
63094 + return 0;
63095 +
63096 +}
63097 +
63098 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
63099 +{
63100 + struct gr_hash_struct_compat hash_compat;
63101 +
63102 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
63103 + return -EFAULT;
63104 +
63105 + hash->table = compat_ptr(hash_compat.table);
63106 + hash->nametable = compat_ptr(hash_compat.nametable);
63107 + hash->first = compat_ptr(hash_compat.first);
63108 +
63109 + hash->table_size = hash_compat.table_size;
63110 + hash->used_size = hash_compat.used_size;
63111 +
63112 + hash->type = hash_compat.type;
63113 +
63114 + return 0;
63115 +}
63116 +
63117 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
63118 +{
63119 + compat_uptr_t ptrcompat;
63120 +
63121 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
63122 + return -EFAULT;
63123 +
63124 + *(void **)ptr = compat_ptr(ptrcompat);
63125 +
63126 + return 0;
63127 +}
63128 +
63129 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
63130 +{
63131 + struct acl_ip_label_compat ip_compat;
63132 +
63133 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
63134 + return -EFAULT;
63135 +
63136 + ip->iface = compat_ptr(ip_compat.iface);
63137 + ip->addr = ip_compat.addr;
63138 + ip->netmask = ip_compat.netmask;
63139 + ip->low = ip_compat.low;
63140 + ip->high = ip_compat.high;
63141 + ip->mode = ip_compat.mode;
63142 + ip->type = ip_compat.type;
63143 +
63144 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
63145 +
63146 + ip->prev = compat_ptr(ip_compat.prev);
63147 + ip->next = compat_ptr(ip_compat.next);
63148 +
63149 + return 0;
63150 +}
63151 +
63152 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
63153 +{
63154 + struct sprole_pw_compat pw_compat;
63155 +
63156 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
63157 + return -EFAULT;
63158 +
63159 + pw->rolename = compat_ptr(pw_compat.rolename);
63160 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
63161 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
63162 +
63163 + return 0;
63164 +}
63165 +
63166 +size_t get_gr_arg_wrapper_size_compat(void)
63167 +{
63168 + return sizeof(struct gr_arg_wrapper_compat);
63169 +}
63170 +
63171 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
63172 new file mode 100644
63173 index 0000000..a340c17
63174 --- /dev/null
63175 +++ b/grsecurity/gracl_fs.c
63176 @@ -0,0 +1,431 @@
63177 +#include <linux/kernel.h>
63178 +#include <linux/sched.h>
63179 +#include <linux/types.h>
63180 +#include <linux/fs.h>
63181 +#include <linux/file.h>
63182 +#include <linux/stat.h>
63183 +#include <linux/grsecurity.h>
63184 +#include <linux/grinternal.h>
63185 +#include <linux/gracl.h>
63186 +
63187 +umode_t
63188 +gr_acl_umask(void)
63189 +{
63190 + if (unlikely(!gr_acl_is_enabled()))
63191 + return 0;
63192 +
63193 + return current->role->umask;
63194 +}
63195 +
63196 +__u32
63197 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63198 + const struct vfsmount * mnt)
63199 +{
63200 + __u32 mode;
63201 +
63202 + if (unlikely(!dentry->d_inode))
63203 + return GR_FIND;
63204 +
63205 + mode =
63206 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
63207 +
63208 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
63209 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
63210 + return mode;
63211 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
63212 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
63213 + return 0;
63214 + } else if (unlikely(!(mode & GR_FIND)))
63215 + return 0;
63216 +
63217 + return GR_FIND;
63218 +}
63219 +
63220 +__u32
63221 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63222 + int acc_mode)
63223 +{
63224 + __u32 reqmode = GR_FIND;
63225 + __u32 mode;
63226 +
63227 + if (unlikely(!dentry->d_inode))
63228 + return reqmode;
63229 +
63230 + if (acc_mode & MAY_APPEND)
63231 + reqmode |= GR_APPEND;
63232 + else if (acc_mode & MAY_WRITE)
63233 + reqmode |= GR_WRITE;
63234 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
63235 + reqmode |= GR_READ;
63236 +
63237 + mode =
63238 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
63239 + mnt);
63240 +
63241 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63242 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
63243 + reqmode & GR_READ ? " reading" : "",
63244 + reqmode & GR_WRITE ? " writing" : reqmode &
63245 + GR_APPEND ? " appending" : "");
63246 + return reqmode;
63247 + } else
63248 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63249 + {
63250 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
63251 + reqmode & GR_READ ? " reading" : "",
63252 + reqmode & GR_WRITE ? " writing" : reqmode &
63253 + GR_APPEND ? " appending" : "");
63254 + return 0;
63255 + } else if (unlikely((mode & reqmode) != reqmode))
63256 + return 0;
63257 +
63258 + return reqmode;
63259 +}
63260 +
63261 +__u32
63262 +gr_acl_handle_creat(const struct dentry * dentry,
63263 + const struct dentry * p_dentry,
63264 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63265 + const int imode)
63266 +{
63267 + __u32 reqmode = GR_WRITE | GR_CREATE;
63268 + __u32 mode;
63269 +
63270 + if (acc_mode & MAY_APPEND)
63271 + reqmode |= GR_APPEND;
63272 + // if a directory was required or the directory already exists, then
63273 + // don't count this open as a read
63274 + if ((acc_mode & MAY_READ) &&
63275 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
63276 + reqmode |= GR_READ;
63277 + if ((open_flags & O_CREAT) &&
63278 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
63279 + reqmode |= GR_SETID;
63280 +
63281 + mode =
63282 + gr_check_create(dentry, p_dentry, p_mnt,
63283 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
63284 +
63285 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63286 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
63287 + reqmode & GR_READ ? " reading" : "",
63288 + reqmode & GR_WRITE ? " writing" : reqmode &
63289 + GR_APPEND ? " appending" : "");
63290 + return reqmode;
63291 + } else
63292 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63293 + {
63294 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
63295 + reqmode & GR_READ ? " reading" : "",
63296 + reqmode & GR_WRITE ? " writing" : reqmode &
63297 + GR_APPEND ? " appending" : "");
63298 + return 0;
63299 + } else if (unlikely((mode & reqmode) != reqmode))
63300 + return 0;
63301 +
63302 + return reqmode;
63303 +}
63304 +
63305 +__u32
63306 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
63307 + const int fmode)
63308 +{
63309 + __u32 mode, reqmode = GR_FIND;
63310 +
63311 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
63312 + reqmode |= GR_EXEC;
63313 + if (fmode & S_IWOTH)
63314 + reqmode |= GR_WRITE;
63315 + if (fmode & S_IROTH)
63316 + reqmode |= GR_READ;
63317 +
63318 + mode =
63319 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
63320 + mnt);
63321 +
63322 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63323 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
63324 + reqmode & GR_READ ? " reading" : "",
63325 + reqmode & GR_WRITE ? " writing" : "",
63326 + reqmode & GR_EXEC ? " executing" : "");
63327 + return reqmode;
63328 + } else
63329 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63330 + {
63331 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
63332 + reqmode & GR_READ ? " reading" : "",
63333 + reqmode & GR_WRITE ? " writing" : "",
63334 + reqmode & GR_EXEC ? " executing" : "");
63335 + return 0;
63336 + } else if (unlikely((mode & reqmode) != reqmode))
63337 + return 0;
63338 +
63339 + return reqmode;
63340 +}
63341 +
63342 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
63343 +{
63344 + __u32 mode;
63345 +
63346 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
63347 +
63348 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
63349 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
63350 + return mode;
63351 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
63352 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
63353 + return 0;
63354 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
63355 + return 0;
63356 +
63357 + return (reqmode);
63358 +}
63359 +
63360 +__u32
63361 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63362 +{
63363 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
63364 +}
63365 +
63366 +__u32
63367 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
63368 +{
63369 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
63370 +}
63371 +
63372 +__u32
63373 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
63374 +{
63375 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
63376 +}
63377 +
63378 +__u32
63379 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
63380 +{
63381 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
63382 +}
63383 +
63384 +__u32
63385 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
63386 + umode_t *modeptr)
63387 +{
63388 + umode_t mode;
63389 +
63390 + *modeptr &= ~gr_acl_umask();
63391 + mode = *modeptr;
63392 +
63393 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
63394 + return 1;
63395 +
63396 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
63397 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
63398 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
63399 + GR_CHMOD_ACL_MSG);
63400 + } else {
63401 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
63402 + }
63403 +}
63404 +
63405 +__u32
63406 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
63407 +{
63408 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
63409 +}
63410 +
63411 +__u32
63412 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
63413 +{
63414 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
63415 +}
63416 +
63417 +__u32
63418 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
63419 +{
63420 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
63421 +}
63422 +
63423 +__u32
63424 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
63425 +{
63426 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
63427 + GR_UNIXCONNECT_ACL_MSG);
63428 +}
63429 +
63430 +/* hardlinks require at minimum create and link permission,
63431 + any additional privilege required is based on the
63432 + privilege of the file being linked to
63433 +*/
63434 +__u32
63435 +gr_acl_handle_link(const struct dentry * new_dentry,
63436 + const struct dentry * parent_dentry,
63437 + const struct vfsmount * parent_mnt,
63438 + const struct dentry * old_dentry,
63439 + const struct vfsmount * old_mnt, const struct filename *to)
63440 +{
63441 + __u32 mode;
63442 + __u32 needmode = GR_CREATE | GR_LINK;
63443 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
63444 +
63445 + mode =
63446 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
63447 + old_mnt);
63448 +
63449 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
63450 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
63451 + return mode;
63452 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
63453 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
63454 + return 0;
63455 + } else if (unlikely((mode & needmode) != needmode))
63456 + return 0;
63457 +
63458 + return 1;
63459 +}
63460 +
63461 +__u32
63462 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63463 + const struct dentry * parent_dentry,
63464 + const struct vfsmount * parent_mnt, const struct filename *from)
63465 +{
63466 + __u32 needmode = GR_WRITE | GR_CREATE;
63467 + __u32 mode;
63468 +
63469 + mode =
63470 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
63471 + GR_CREATE | GR_AUDIT_CREATE |
63472 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
63473 +
63474 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
63475 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
63476 + return mode;
63477 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
63478 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
63479 + return 0;
63480 + } else if (unlikely((mode & needmode) != needmode))
63481 + return 0;
63482 +
63483 + return (GR_WRITE | GR_CREATE);
63484 +}
63485 +
63486 +static __u32 generic_fs_create_handler(const struct dentry *new_dentry, const struct dentry *parent_dentry, const struct vfsmount *parent_mnt, __u32 reqmode, const char *fmt)
63487 +{
63488 + __u32 mode;
63489 +
63490 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
63491 +
63492 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
63493 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
63494 + return mode;
63495 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
63496 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
63497 + return 0;
63498 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
63499 + return 0;
63500 +
63501 + return (reqmode);
63502 +}
63503 +
63504 +__u32
63505 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63506 + const struct dentry * parent_dentry,
63507 + const struct vfsmount * parent_mnt,
63508 + const int mode)
63509 +{
63510 + __u32 reqmode = GR_WRITE | GR_CREATE;
63511 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
63512 + reqmode |= GR_SETID;
63513 +
63514 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
63515 + reqmode, GR_MKNOD_ACL_MSG);
63516 +}
63517 +
63518 +__u32
63519 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
63520 + const struct dentry *parent_dentry,
63521 + const struct vfsmount *parent_mnt)
63522 +{
63523 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
63524 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
63525 +}
63526 +
63527 +#define RENAME_CHECK_SUCCESS(old, new) \
63528 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
63529 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
63530 +
63531 +int
63532 +gr_acl_handle_rename(struct dentry *new_dentry,
63533 + struct dentry *parent_dentry,
63534 + const struct vfsmount *parent_mnt,
63535 + struct dentry *old_dentry,
63536 + struct inode *old_parent_inode,
63537 + struct vfsmount *old_mnt, const struct filename *newname)
63538 +{
63539 + __u32 comp1, comp2;
63540 + int error = 0;
63541 +
63542 + if (unlikely(!gr_acl_is_enabled()))
63543 + return 0;
63544 +
63545 + if (!new_dentry->d_inode) {
63546 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
63547 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
63548 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
63549 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
63550 + GR_DELETE | GR_AUDIT_DELETE |
63551 + GR_AUDIT_READ | GR_AUDIT_WRITE |
63552 + GR_SUPPRESS, old_mnt);
63553 + } else {
63554 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
63555 + GR_CREATE | GR_DELETE |
63556 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
63557 + GR_AUDIT_READ | GR_AUDIT_WRITE |
63558 + GR_SUPPRESS, parent_mnt);
63559 + comp2 =
63560 + gr_search_file(old_dentry,
63561 + GR_READ | GR_WRITE | GR_AUDIT_READ |
63562 + GR_DELETE | GR_AUDIT_DELETE |
63563 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
63564 + }
63565 +
63566 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
63567 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
63568 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63569 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
63570 + && !(comp2 & GR_SUPPRESS)) {
63571 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63572 + error = -EACCES;
63573 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
63574 + error = -EACCES;
63575 +
63576 + return error;
63577 +}
63578 +
63579 +void
63580 +gr_acl_handle_exit(void)
63581 +{
63582 + u16 id;
63583 + char *rolename;
63584 +
63585 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
63586 + !(current->role->roletype & GR_ROLE_PERSIST))) {
63587 + id = current->acl_role_id;
63588 + rolename = current->role->rolename;
63589 + gr_set_acls(1);
63590 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
63591 + }
63592 +
63593 + gr_put_exec_file(current);
63594 + return;
63595 +}
63596 +
63597 +int
63598 +gr_acl_handle_procpidmem(const struct task_struct *task)
63599 +{
63600 + if (unlikely(!gr_acl_is_enabled()))
63601 + return 0;
63602 +
63603 + if (task != current && task->acl->mode & GR_PROTPROCFD)
63604 + return -EACCES;
63605 +
63606 + return 0;
63607 +}
63608 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
63609 new file mode 100644
63610 index 0000000..8132048
63611 --- /dev/null
63612 +++ b/grsecurity/gracl_ip.c
63613 @@ -0,0 +1,387 @@
63614 +#include <linux/kernel.h>
63615 +#include <asm/uaccess.h>
63616 +#include <asm/errno.h>
63617 +#include <net/sock.h>
63618 +#include <linux/file.h>
63619 +#include <linux/fs.h>
63620 +#include <linux/net.h>
63621 +#include <linux/in.h>
63622 +#include <linux/skbuff.h>
63623 +#include <linux/ip.h>
63624 +#include <linux/udp.h>
63625 +#include <linux/types.h>
63626 +#include <linux/sched.h>
63627 +#include <linux/netdevice.h>
63628 +#include <linux/inetdevice.h>
63629 +#include <linux/gracl.h>
63630 +#include <linux/grsecurity.h>
63631 +#include <linux/grinternal.h>
63632 +
63633 +#define GR_BIND 0x01
63634 +#define GR_CONNECT 0x02
63635 +#define GR_INVERT 0x04
63636 +#define GR_BINDOVERRIDE 0x08
63637 +#define GR_CONNECTOVERRIDE 0x10
63638 +#define GR_SOCK_FAMILY 0x20
63639 +
63640 +static const char * gr_protocols[IPPROTO_MAX] = {
63641 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
63642 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
63643 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
63644 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
63645 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
63646 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
63647 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
63648 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
63649 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
63650 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
63651 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
63652 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
63653 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
63654 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
63655 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
63656 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
63657 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
63658 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
63659 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
63660 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
63661 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
63662 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
63663 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
63664 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
63665 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
63666 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
63667 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
63668 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
63669 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
63670 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
63671 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
63672 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
63673 + };
63674 +
63675 +static const char * gr_socktypes[SOCK_MAX] = {
63676 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
63677 + "unknown:7", "unknown:8", "unknown:9", "packet"
63678 + };
63679 +
63680 +static const char * gr_sockfamilies[AF_MAX+1] = {
63681 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
63682 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63683 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63684 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63685 + };
63686 +
63687 +const char *
63688 +gr_proto_to_name(unsigned char proto)
63689 +{
63690 + return gr_protocols[proto];
63691 +}
63692 +
63693 +const char *
63694 +gr_socktype_to_name(unsigned char type)
63695 +{
63696 + return gr_socktypes[type];
63697 +}
63698 +
63699 +const char *
63700 +gr_sockfamily_to_name(unsigned char family)
63701 +{
63702 + return gr_sockfamilies[family];
63703 +}
63704 +
63705 +int
63706 +gr_search_socket(const int domain, const int type, const int protocol)
63707 +{
63708 + struct acl_subject_label *curr;
63709 + const struct cred *cred = current_cred();
63710 +
63711 + if (unlikely(!gr_acl_is_enabled()))
63712 + goto exit;
63713 +
63714 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63715 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63716 + goto exit; // let the kernel handle it
63717 +
63718 + curr = current->acl;
63719 +
63720 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63721 + /* the family is allowed, if this is PF_INET allow it only if
63722 + the extra sock type/protocol checks pass */
63723 + if (domain == PF_INET)
63724 + goto inet_check;
63725 + goto exit;
63726 + } else {
63727 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63728 + __u32 fakeip = 0;
63729 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63730 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63731 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63732 + gr_to_filename(current->exec_file->f_path.dentry,
63733 + current->exec_file->f_path.mnt) :
63734 + curr->filename, curr->filename,
63735 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63736 + &current->signal->saved_ip);
63737 + goto exit;
63738 + }
63739 + goto exit_fail;
63740 + }
63741 +
63742 +inet_check:
63743 + /* the rest of this checking is for IPv4 only */
63744 + if (!curr->ips)
63745 + goto exit;
63746 +
63747 + if ((curr->ip_type & (1U << type)) &&
63748 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63749 + goto exit;
63750 +
63751 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63752 + /* we don't place acls on raw sockets , and sometimes
63753 + dgram/ip sockets are opened for ioctl and not
63754 + bind/connect, so we'll fake a bind learn log */
63755 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63756 + __u32 fakeip = 0;
63757 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63758 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63759 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63760 + gr_to_filename(current->exec_file->f_path.dentry,
63761 + current->exec_file->f_path.mnt) :
63762 + curr->filename, curr->filename,
63763 + &fakeip, 0, type,
63764 + protocol, GR_CONNECT, &current->signal->saved_ip);
63765 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63766 + __u32 fakeip = 0;
63767 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63768 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63769 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63770 + gr_to_filename(current->exec_file->f_path.dentry,
63771 + current->exec_file->f_path.mnt) :
63772 + curr->filename, curr->filename,
63773 + &fakeip, 0, type,
63774 + protocol, GR_BIND, &current->signal->saved_ip);
63775 + }
63776 + /* we'll log when they use connect or bind */
63777 + goto exit;
63778 + }
63779 +
63780 +exit_fail:
63781 + if (domain == PF_INET)
63782 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63783 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63784 + else
63785 +#ifndef CONFIG_IPV6
63786 + if (domain != PF_INET6)
63787 +#endif
63788 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63789 + gr_socktype_to_name(type), protocol);
63790 +
63791 + return 0;
63792 +exit:
63793 + return 1;
63794 +}
63795 +
63796 +int check_ip_policy(struct acl_ip_label *ip, __u32 ip_addr, __u16 ip_port, __u8 protocol, const int mode, const int type, __u32 our_addr, __u32 our_netmask)
63797 +{
63798 + if ((ip->mode & mode) &&
63799 + (ip_port >= ip->low) &&
63800 + (ip_port <= ip->high) &&
63801 + ((ntohl(ip_addr) & our_netmask) ==
63802 + (ntohl(our_addr) & our_netmask))
63803 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63804 + && (ip->type & (1U << type))) {
63805 + if (ip->mode & GR_INVERT)
63806 + return 2; // specifically denied
63807 + else
63808 + return 1; // allowed
63809 + }
63810 +
63811 + return 0; // not specifically allowed, may continue parsing
63812 +}
63813 +
63814 +static int
63815 +gr_search_connectbind(const int full_mode, struct sock *sk,
63816 + struct sockaddr_in *addr, const int type)
63817 +{
63818 + char iface[IFNAMSIZ] = {0};
63819 + struct acl_subject_label *curr;
63820 + struct acl_ip_label *ip;
63821 + struct inet_sock *isk;
63822 + struct net_device *dev;
63823 + struct in_device *idev;
63824 + unsigned long i;
63825 + int ret;
63826 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63827 + __u32 ip_addr = 0;
63828 + __u32 our_addr;
63829 + __u32 our_netmask;
63830 + char *p;
63831 + __u16 ip_port = 0;
63832 + const struct cred *cred = current_cred();
63833 +
63834 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63835 + return 0;
63836 +
63837 + curr = current->acl;
63838 + isk = inet_sk(sk);
63839 +
63840 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63841 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63842 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63843 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63844 + struct sockaddr_in saddr;
63845 + int err;
63846 +
63847 + saddr.sin_family = AF_INET;
63848 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63849 + saddr.sin_port = isk->inet_sport;
63850 +
63851 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63852 + if (err)
63853 + return err;
63854 +
63855 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63856 + if (err)
63857 + return err;
63858 + }
63859 +
63860 + if (!curr->ips)
63861 + return 0;
63862 +
63863 + ip_addr = addr->sin_addr.s_addr;
63864 + ip_port = ntohs(addr->sin_port);
63865 +
63866 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63867 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63868 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63869 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63870 + gr_to_filename(current->exec_file->f_path.dentry,
63871 + current->exec_file->f_path.mnt) :
63872 + curr->filename, curr->filename,
63873 + &ip_addr, ip_port, type,
63874 + sk->sk_protocol, mode, &current->signal->saved_ip);
63875 + return 0;
63876 + }
63877 +
63878 + for (i = 0; i < curr->ip_num; i++) {
63879 + ip = *(curr->ips + i);
63880 + if (ip->iface != NULL) {
63881 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63882 + p = strchr(iface, ':');
63883 + if (p != NULL)
63884 + *p = '\0';
63885 + dev = dev_get_by_name(sock_net(sk), iface);
63886 + if (dev == NULL)
63887 + continue;
63888 + idev = in_dev_get(dev);
63889 + if (idev == NULL) {
63890 + dev_put(dev);
63891 + continue;
63892 + }
63893 + rcu_read_lock();
63894 + for_ifa(idev) {
63895 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63896 + our_addr = ifa->ifa_address;
63897 + our_netmask = 0xffffffff;
63898 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63899 + if (ret == 1) {
63900 + rcu_read_unlock();
63901 + in_dev_put(idev);
63902 + dev_put(dev);
63903 + return 0;
63904 + } else if (ret == 2) {
63905 + rcu_read_unlock();
63906 + in_dev_put(idev);
63907 + dev_put(dev);
63908 + goto denied;
63909 + }
63910 + }
63911 + } endfor_ifa(idev);
63912 + rcu_read_unlock();
63913 + in_dev_put(idev);
63914 + dev_put(dev);
63915 + } else {
63916 + our_addr = ip->addr;
63917 + our_netmask = ip->netmask;
63918 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63919 + if (ret == 1)
63920 + return 0;
63921 + else if (ret == 2)
63922 + goto denied;
63923 + }
63924 + }
63925 +
63926 +denied:
63927 + if (mode == GR_BIND)
63928 + gr_log_int5_str2(GR_DONT_AUDIT, GR_BIND_ACL_MSG, &ip_addr, ip_port, gr_socktype_to_name(type), gr_proto_to_name(sk->sk_protocol));
63929 + else if (mode == GR_CONNECT)
63930 + gr_log_int5_str2(GR_DONT_AUDIT, GR_CONNECT_ACL_MSG, &ip_addr, ip_port, gr_socktype_to_name(type), gr_proto_to_name(sk->sk_protocol));
63931 +
63932 + return -EACCES;
63933 +}
63934 +
63935 +int
63936 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63937 +{
63938 + /* always allow disconnection of dgram sockets with connect */
63939 + if (addr->sin_family == AF_UNSPEC)
63940 + return 0;
63941 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63942 +}
63943 +
63944 +int
63945 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63946 +{
63947 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63948 +}
63949 +
63950 +int gr_search_listen(struct socket *sock)
63951 +{
63952 + struct sock *sk = sock->sk;
63953 + struct sockaddr_in addr;
63954 +
63955 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63956 + addr.sin_port = inet_sk(sk)->inet_sport;
63957 +
63958 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63959 +}
63960 +
63961 +int gr_search_accept(struct socket *sock)
63962 +{
63963 + struct sock *sk = sock->sk;
63964 + struct sockaddr_in addr;
63965 +
63966 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63967 + addr.sin_port = inet_sk(sk)->inet_sport;
63968 +
63969 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63970 +}
63971 +
63972 +int
63973 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63974 +{
63975 + if (addr)
63976 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63977 + else {
63978 + struct sockaddr_in sin;
63979 + const struct inet_sock *inet = inet_sk(sk);
63980 +
63981 + sin.sin_addr.s_addr = inet->inet_daddr;
63982 + sin.sin_port = inet->inet_dport;
63983 +
63984 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63985 + }
63986 +}
63987 +
63988 +int
63989 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63990 +{
63991 + struct sockaddr_in sin;
63992 +
63993 + if (unlikely(skb->len < sizeof (struct udphdr)))
63994 + return 0; // skip this packet
63995 +
63996 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63997 + sin.sin_port = udp_hdr(skb)->source;
63998 +
63999 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
64000 +}
64001 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
64002 new file mode 100644
64003 index 0000000..25f54ef
64004 --- /dev/null
64005 +++ b/grsecurity/gracl_learn.c
64006 @@ -0,0 +1,207 @@
64007 +#include <linux/kernel.h>
64008 +#include <linux/mm.h>
64009 +#include <linux/sched.h>
64010 +#include <linux/poll.h>
64011 +#include <linux/string.h>
64012 +#include <linux/file.h>
64013 +#include <linux/types.h>
64014 +#include <linux/vmalloc.h>
64015 +#include <linux/grinternal.h>
64016 +
64017 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
64018 + size_t count, loff_t *ppos);
64019 +extern int gr_acl_is_enabled(void);
64020 +
64021 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
64022 +static int gr_learn_attached;
64023 +
64024 +/* use a 512k buffer */
64025 +#define LEARN_BUFFER_SIZE (512 * 1024)
64026 +
64027 +static DEFINE_SPINLOCK(gr_learn_lock);
64028 +static DEFINE_MUTEX(gr_learn_user_mutex);
64029 +
64030 +/* we need to maintain two buffers, so that the kernel context of grlearn
64031 + uses a semaphore around the userspace copying, and the other kernel contexts
64032 + use a spinlock when copying into the buffer, since they cannot sleep
64033 +*/
64034 +static char *learn_buffer;
64035 +static char *learn_buffer_user;
64036 +static int learn_buffer_len;
64037 +static int learn_buffer_user_len;
64038 +
64039 +static ssize_t
64040 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
64041 +{
64042 + DECLARE_WAITQUEUE(wait, current);
64043 + ssize_t retval = 0;
64044 +
64045 + add_wait_queue(&learn_wait, &wait);
64046 + set_current_state(TASK_INTERRUPTIBLE);
64047 + do {
64048 + mutex_lock(&gr_learn_user_mutex);
64049 + spin_lock(&gr_learn_lock);
64050 + if (learn_buffer_len)
64051 + break;
64052 + spin_unlock(&gr_learn_lock);
64053 + mutex_unlock(&gr_learn_user_mutex);
64054 + if (file->f_flags & O_NONBLOCK) {
64055 + retval = -EAGAIN;
64056 + goto out;
64057 + }
64058 + if (signal_pending(current)) {
64059 + retval = -ERESTARTSYS;
64060 + goto out;
64061 + }
64062 +
64063 + schedule();
64064 + } while (1);
64065 +
64066 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
64067 + learn_buffer_user_len = learn_buffer_len;
64068 + retval = learn_buffer_len;
64069 + learn_buffer_len = 0;
64070 +
64071 + spin_unlock(&gr_learn_lock);
64072 +
64073 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
64074 + retval = -EFAULT;
64075 +
64076 + mutex_unlock(&gr_learn_user_mutex);
64077 +out:
64078 + set_current_state(TASK_RUNNING);
64079 + remove_wait_queue(&learn_wait, &wait);
64080 + return retval;
64081 +}
64082 +
64083 +static unsigned int
64084 +poll_learn(struct file * file, poll_table * wait)
64085 +{
64086 + poll_wait(file, &learn_wait, wait);
64087 +
64088 + if (learn_buffer_len)
64089 + return (POLLIN | POLLRDNORM);
64090 +
64091 + return 0;
64092 +}
64093 +
64094 +void
64095 +gr_clear_learn_entries(void)
64096 +{
64097 + char *tmp;
64098 +
64099 + mutex_lock(&gr_learn_user_mutex);
64100 + spin_lock(&gr_learn_lock);
64101 + tmp = learn_buffer;
64102 + learn_buffer = NULL;
64103 + spin_unlock(&gr_learn_lock);
64104 + if (tmp)
64105 + vfree(tmp);
64106 + if (learn_buffer_user != NULL) {
64107 + vfree(learn_buffer_user);
64108 + learn_buffer_user = NULL;
64109 + }
64110 + learn_buffer_len = 0;
64111 + mutex_unlock(&gr_learn_user_mutex);
64112 +
64113 + return;
64114 +}
64115 +
64116 +void
64117 +gr_add_learn_entry(const char *fmt, ...)
64118 +{
64119 + va_list args;
64120 + unsigned int len;
64121 +
64122 + if (!gr_learn_attached)
64123 + return;
64124 +
64125 + spin_lock(&gr_learn_lock);
64126 +
64127 + /* leave a gap at the end so we know when it's "full" but don't have to
64128 + compute the exact length of the string we're trying to append
64129 + */
64130 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
64131 + spin_unlock(&gr_learn_lock);
64132 + wake_up_interruptible(&learn_wait);
64133 + return;
64134 + }
64135 + if (learn_buffer == NULL) {
64136 + spin_unlock(&gr_learn_lock);
64137 + return;
64138 + }
64139 +
64140 + va_start(args, fmt);
64141 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
64142 + va_end(args);
64143 +
64144 + learn_buffer_len += len + 1;
64145 +
64146 + spin_unlock(&gr_learn_lock);
64147 + wake_up_interruptible(&learn_wait);
64148 +
64149 + return;
64150 +}
64151 +
64152 +static int
64153 +open_learn(struct inode *inode, struct file *file)
64154 +{
64155 + if (file->f_mode & FMODE_READ && gr_learn_attached)
64156 + return -EBUSY;
64157 + if (file->f_mode & FMODE_READ) {
64158 + int retval = 0;
64159 + mutex_lock(&gr_learn_user_mutex);
64160 + if (learn_buffer == NULL)
64161 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
64162 + if (learn_buffer_user == NULL)
64163 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
64164 + if (learn_buffer == NULL) {
64165 + retval = -ENOMEM;
64166 + goto out_error;
64167 + }
64168 + if (learn_buffer_user == NULL) {
64169 + retval = -ENOMEM;
64170 + goto out_error;
64171 + }
64172 + learn_buffer_len = 0;
64173 + learn_buffer_user_len = 0;
64174 + gr_learn_attached = 1;
64175 +out_error:
64176 + mutex_unlock(&gr_learn_user_mutex);
64177 + return retval;
64178 + }
64179 + return 0;
64180 +}
64181 +
64182 +static int
64183 +close_learn(struct inode *inode, struct file *file)
64184 +{
64185 + if (file->f_mode & FMODE_READ) {
64186 + char *tmp = NULL;
64187 + mutex_lock(&gr_learn_user_mutex);
64188 + spin_lock(&gr_learn_lock);
64189 + tmp = learn_buffer;
64190 + learn_buffer = NULL;
64191 + spin_unlock(&gr_learn_lock);
64192 + if (tmp)
64193 + vfree(tmp);
64194 + if (learn_buffer_user != NULL) {
64195 + vfree(learn_buffer_user);
64196 + learn_buffer_user = NULL;
64197 + }
64198 + learn_buffer_len = 0;
64199 + learn_buffer_user_len = 0;
64200 + gr_learn_attached = 0;
64201 + mutex_unlock(&gr_learn_user_mutex);
64202 + }
64203 +
64204 + return 0;
64205 +}
64206 +
64207 +const struct file_operations grsec_fops = {
64208 + .read = read_learn,
64209 + .write = write_grsec_handler,
64210 + .open = open_learn,
64211 + .release = close_learn,
64212 + .poll = poll_learn,
64213 +};
64214 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
64215 new file mode 100644
64216 index 0000000..39645c9
64217 --- /dev/null
64218 +++ b/grsecurity/gracl_res.c
64219 @@ -0,0 +1,68 @@
64220 +#include <linux/kernel.h>
64221 +#include <linux/sched.h>
64222 +#include <linux/gracl.h>
64223 +#include <linux/grinternal.h>
64224 +
64225 +static const char *restab_log[] = {
64226 + [RLIMIT_CPU] = "RLIMIT_CPU",
64227 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
64228 + [RLIMIT_DATA] = "RLIMIT_DATA",
64229 + [RLIMIT_STACK] = "RLIMIT_STACK",
64230 + [RLIMIT_CORE] = "RLIMIT_CORE",
64231 + [RLIMIT_RSS] = "RLIMIT_RSS",
64232 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
64233 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
64234 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
64235 + [RLIMIT_AS] = "RLIMIT_AS",
64236 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
64237 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
64238 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
64239 + [RLIMIT_NICE] = "RLIMIT_NICE",
64240 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
64241 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
64242 + [GR_CRASH_RES] = "RLIMIT_CRASH"
64243 +};
64244 +
64245 +void
64246 +gr_log_resource(const struct task_struct *task,
64247 + const int res, const unsigned long wanted, const int gt)
64248 +{
64249 + const struct cred *cred;
64250 + unsigned long rlim;
64251 +
64252 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
64253 + return;
64254 +
64255 + // not yet supported resource
64256 + if (unlikely(!restab_log[res]))
64257 + return;
64258 +
64259 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
64260 + rlim = task_rlimit_max(task, res);
64261 + else
64262 + rlim = task_rlimit(task, res);
64263 +
64264 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
64265 + return;
64266 +
64267 + rcu_read_lock();
64268 + cred = __task_cred(task);
64269 +
64270 + if (res == RLIMIT_NPROC &&
64271 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
64272 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
64273 + goto out_rcu_unlock;
64274 + else if (res == RLIMIT_MEMLOCK &&
64275 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
64276 + goto out_rcu_unlock;
64277 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
64278 + goto out_rcu_unlock;
64279 + rcu_read_unlock();
64280 +
64281 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
64282 +
64283 + return;
64284 +out_rcu_unlock:
64285 + rcu_read_unlock();
64286 + return;
64287 +}
64288 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
64289 new file mode 100644
64290 index 0000000..3c38bfe
64291 --- /dev/null
64292 +++ b/grsecurity/gracl_segv.c
64293 @@ -0,0 +1,305 @@
64294 +#include <linux/kernel.h>
64295 +#include <linux/mm.h>
64296 +#include <asm/uaccess.h>
64297 +#include <asm/errno.h>
64298 +#include <asm/mman.h>
64299 +#include <net/sock.h>
64300 +#include <linux/file.h>
64301 +#include <linux/fs.h>
64302 +#include <linux/net.h>
64303 +#include <linux/in.h>
64304 +#include <linux/slab.h>
64305 +#include <linux/types.h>
64306 +#include <linux/sched.h>
64307 +#include <linux/timer.h>
64308 +#include <linux/gracl.h>
64309 +#include <linux/grsecurity.h>
64310 +#include <linux/grinternal.h>
64311 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
64312 +#include <linux/magic.h>
64313 +#include <linux/pagemap.h>
64314 +#include "../fs/btrfs/async-thread.h"
64315 +#include "../fs/btrfs/ctree.h"
64316 +#include "../fs/btrfs/btrfs_inode.h"
64317 +#endif
64318 +
64319 +static struct crash_uid *uid_set;
64320 +static unsigned short uid_used;
64321 +static DEFINE_SPINLOCK(gr_uid_lock);
64322 +extern rwlock_t gr_inode_lock;
64323 +extern struct acl_subject_label *
64324 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
64325 + struct acl_role_label *role);
64326 +
64327 +static inline dev_t __get_dev(const struct dentry *dentry)
64328 +{
64329 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
64330 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
64331 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
64332 + else
64333 +#endif
64334 + return dentry->d_sb->s_dev;
64335 +}
64336 +
64337 +int
64338 +gr_init_uidset(void)
64339 +{
64340 + uid_set =
64341 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
64342 + uid_used = 0;
64343 +
64344 + return uid_set ? 1 : 0;
64345 +}
64346 +
64347 +void
64348 +gr_free_uidset(void)
64349 +{
64350 + if (uid_set)
64351 + kfree(uid_set);
64352 +
64353 + return;
64354 +}
64355 +
64356 +int
64357 +gr_find_uid(const uid_t uid)
64358 +{
64359 + struct crash_uid *tmp = uid_set;
64360 + uid_t buid;
64361 + int low = 0, high = uid_used - 1, mid;
64362 +
64363 + while (high >= low) {
64364 + mid = (low + high) >> 1;
64365 + buid = tmp[mid].uid;
64366 + if (buid == uid)
64367 + return mid;
64368 + if (buid > uid)
64369 + high = mid - 1;
64370 + if (buid < uid)
64371 + low = mid + 1;
64372 + }
64373 +
64374 + return -1;
64375 +}
64376 +
64377 +static __inline__ void
64378 +gr_insertsort(void)
64379 +{
64380 + unsigned short i, j;
64381 + struct crash_uid index;
64382 +
64383 + for (i = 1; i < uid_used; i++) {
64384 + index = uid_set[i];
64385 + j = i;
64386 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
64387 + uid_set[j] = uid_set[j - 1];
64388 + j--;
64389 + }
64390 + uid_set[j] = index;
64391 + }
64392 +
64393 + return;
64394 +}
64395 +
64396 +static __inline__ void
64397 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
64398 +{
64399 + int loc;
64400 + uid_t uid = GR_GLOBAL_UID(kuid);
64401 +
64402 + if (uid_used == GR_UIDTABLE_MAX)
64403 + return;
64404 +
64405 + loc = gr_find_uid(uid);
64406 +
64407 + if (loc >= 0) {
64408 + uid_set[loc].expires = expires;
64409 + return;
64410 + }
64411 +
64412 + uid_set[uid_used].uid = uid;
64413 + uid_set[uid_used].expires = expires;
64414 + uid_used++;
64415 +
64416 + gr_insertsort();
64417 +
64418 + return;
64419 +}
64420 +
64421 +void
64422 +gr_remove_uid(const unsigned short loc)
64423 +{
64424 + unsigned short i;
64425 +
64426 + for (i = loc + 1; i < uid_used; i++)
64427 + uid_set[i - 1] = uid_set[i];
64428 +
64429 + uid_used--;
64430 +
64431 + return;
64432 +}
64433 +
64434 +int
64435 +gr_check_crash_uid(const kuid_t kuid)
64436 +{
64437 + int loc;
64438 + int ret = 0;
64439 + uid_t uid;
64440 +
64441 + if (unlikely(!gr_acl_is_enabled()))
64442 + return 0;
64443 +
64444 + uid = GR_GLOBAL_UID(kuid);
64445 +
64446 + spin_lock(&gr_uid_lock);
64447 + loc = gr_find_uid(uid);
64448 +
64449 + if (loc < 0)
64450 + goto out_unlock;
64451 +
64452 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
64453 + gr_remove_uid(loc);
64454 + else
64455 + ret = 1;
64456 +
64457 +out_unlock:
64458 + spin_unlock(&gr_uid_lock);
64459 + return ret;
64460 +}
64461 +
64462 +static __inline__ int
64463 +proc_is_setxid(const struct cred *cred)
64464 +{
64465 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
64466 + !uid_eq(cred->uid, cred->fsuid))
64467 + return 1;
64468 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
64469 + !gid_eq(cred->gid, cred->fsgid))
64470 + return 1;
64471 +
64472 + return 0;
64473 +}
64474 +
64475 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
64476 +
64477 +void
64478 +gr_handle_crash(struct task_struct *task, const int sig)
64479 +{
64480 + struct acl_subject_label *curr;
64481 + struct task_struct *tsk, *tsk2;
64482 + const struct cred *cred;
64483 + const struct cred *cred2;
64484 +
64485 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
64486 + return;
64487 +
64488 + if (unlikely(!gr_acl_is_enabled()))
64489 + return;
64490 +
64491 + curr = task->acl;
64492 +
64493 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
64494 + return;
64495 +
64496 + if (time_before_eq(curr->expires, get_seconds())) {
64497 + curr->expires = 0;
64498 + curr->crashes = 0;
64499 + }
64500 +
64501 + curr->crashes++;
64502 +
64503 + if (!curr->expires)
64504 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
64505 +
64506 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
64507 + time_after(curr->expires, get_seconds())) {
64508 + rcu_read_lock();
64509 + cred = __task_cred(task);
64510 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
64511 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
64512 + spin_lock(&gr_uid_lock);
64513 + gr_insert_uid(cred->uid, curr->expires);
64514 + spin_unlock(&gr_uid_lock);
64515 + curr->expires = 0;
64516 + curr->crashes = 0;
64517 + read_lock(&tasklist_lock);
64518 + do_each_thread(tsk2, tsk) {
64519 + cred2 = __task_cred(tsk);
64520 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
64521 + gr_fake_force_sig(SIGKILL, tsk);
64522 + } while_each_thread(tsk2, tsk);
64523 + read_unlock(&tasklist_lock);
64524 + } else {
64525 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
64526 + read_lock(&tasklist_lock);
64527 + read_lock(&grsec_exec_file_lock);
64528 + do_each_thread(tsk2, tsk) {
64529 + if (likely(tsk != task)) {
64530 + // if this thread has the same subject as the one that triggered
64531 + // RES_CRASH and it's the same binary, kill it
64532 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
64533 + gr_fake_force_sig(SIGKILL, tsk);
64534 + }
64535 + } while_each_thread(tsk2, tsk);
64536 + read_unlock(&grsec_exec_file_lock);
64537 + read_unlock(&tasklist_lock);
64538 + }
64539 + rcu_read_unlock();
64540 + }
64541 +
64542 + return;
64543 +}
64544 +
64545 +int
64546 +gr_check_crash_exec(const struct file *filp)
64547 +{
64548 + struct acl_subject_label *curr;
64549 +
64550 + if (unlikely(!gr_acl_is_enabled()))
64551 + return 0;
64552 +
64553 + read_lock(&gr_inode_lock);
64554 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
64555 + __get_dev(filp->f_path.dentry),
64556 + current->role);
64557 + read_unlock(&gr_inode_lock);
64558 +
64559 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
64560 + (!curr->crashes && !curr->expires))
64561 + return 0;
64562 +
64563 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
64564 + time_after(curr->expires, get_seconds()))
64565 + return 1;
64566 + else if (time_before_eq(curr->expires, get_seconds())) {
64567 + curr->crashes = 0;
64568 + curr->expires = 0;
64569 + }
64570 +
64571 + return 0;
64572 +}
64573 +
64574 +void
64575 +gr_handle_alertkill(struct task_struct *task)
64576 +{
64577 + struct acl_subject_label *curracl;
64578 + __u32 curr_ip;
64579 + struct task_struct *p, *p2;
64580 +
64581 + if (unlikely(!gr_acl_is_enabled()))
64582 + return;
64583 +
64584 + curracl = task->acl;
64585 + curr_ip = task->signal->curr_ip;
64586 +
64587 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
64588 + read_lock(&tasklist_lock);
64589 + do_each_thread(p2, p) {
64590 + if (p->signal->curr_ip == curr_ip)
64591 + gr_fake_force_sig(SIGKILL, p);
64592 + } while_each_thread(p2, p);
64593 + read_unlock(&tasklist_lock);
64594 + } else if (curracl->mode & GR_KILLPROC)
64595 + gr_fake_force_sig(SIGKILL, task);
64596 +
64597 + return;
64598 +}
64599 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
64600 new file mode 100644
64601 index 0000000..98011b0
64602 --- /dev/null
64603 +++ b/grsecurity/gracl_shm.c
64604 @@ -0,0 +1,40 @@
64605 +#include <linux/kernel.h>
64606 +#include <linux/mm.h>
64607 +#include <linux/sched.h>
64608 +#include <linux/file.h>
64609 +#include <linux/ipc.h>
64610 +#include <linux/gracl.h>
64611 +#include <linux/grsecurity.h>
64612 +#include <linux/grinternal.h>
64613 +
64614 +int
64615 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64616 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64617 +{
64618 + struct task_struct *task;
64619 +
64620 + if (!gr_acl_is_enabled())
64621 + return 1;
64622 +
64623 + rcu_read_lock();
64624 + read_lock(&tasklist_lock);
64625 +
64626 + task = find_task_by_vpid(shm_cprid);
64627 +
64628 + if (unlikely(!task))
64629 + task = find_task_by_vpid(shm_lapid);
64630 +
64631 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
64632 + (task_pid_nr(task) == shm_lapid)) &&
64633 + (task->acl->mode & GR_PROTSHM) &&
64634 + (task->acl != current->acl))) {
64635 + read_unlock(&tasklist_lock);
64636 + rcu_read_unlock();
64637 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
64638 + return 0;
64639 + }
64640 + read_unlock(&tasklist_lock);
64641 + rcu_read_unlock();
64642 +
64643 + return 1;
64644 +}
64645 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
64646 new file mode 100644
64647 index 0000000..bc0be01
64648 --- /dev/null
64649 +++ b/grsecurity/grsec_chdir.c
64650 @@ -0,0 +1,19 @@
64651 +#include <linux/kernel.h>
64652 +#include <linux/sched.h>
64653 +#include <linux/fs.h>
64654 +#include <linux/file.h>
64655 +#include <linux/grsecurity.h>
64656 +#include <linux/grinternal.h>
64657 +
64658 +void
64659 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
64660 +{
64661 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64662 + if ((grsec_enable_chdir && grsec_enable_group &&
64663 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
64664 + !grsec_enable_group)) {
64665 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
64666 + }
64667 +#endif
64668 + return;
64669 +}
64670 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
64671 new file mode 100644
64672 index 0000000..bd6e105
64673 --- /dev/null
64674 +++ b/grsecurity/grsec_chroot.c
64675 @@ -0,0 +1,370 @@
64676 +#include <linux/kernel.h>
64677 +#include <linux/module.h>
64678 +#include <linux/sched.h>
64679 +#include <linux/file.h>
64680 +#include <linux/fs.h>
64681 +#include <linux/mount.h>
64682 +#include <linux/types.h>
64683 +#include "../fs/mount.h"
64684 +#include <linux/grsecurity.h>
64685 +#include <linux/grinternal.h>
64686 +
64687 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64688 +static int gr_init_ran;
64689 +#endif
64690 +
64691 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
64692 +{
64693 +#ifdef CONFIG_GRKERNSEC
64694 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64695 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64696 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64697 + && gr_init_ran
64698 +#endif
64699 + )
64700 + task->gr_is_chrooted = 1;
64701 + else {
64702 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64703 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64704 + gr_init_ran = 1;
64705 +#endif
64706 + task->gr_is_chrooted = 0;
64707 + }
64708 +
64709 + task->gr_chroot_dentry = path->dentry;
64710 +#endif
64711 + return;
64712 +}
64713 +
64714 +void gr_clear_chroot_entries(struct task_struct *task)
64715 +{
64716 +#ifdef CONFIG_GRKERNSEC
64717 + task->gr_is_chrooted = 0;
64718 + task->gr_chroot_dentry = NULL;
64719 +#endif
64720 + return;
64721 +}
64722 +
64723 +int
64724 +gr_handle_chroot_unix(const pid_t pid)
64725 +{
64726 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64727 + struct task_struct *p;
64728 +
64729 + if (unlikely(!grsec_enable_chroot_unix))
64730 + return 1;
64731 +
64732 + if (likely(!proc_is_chrooted(current)))
64733 + return 1;
64734 +
64735 + rcu_read_lock();
64736 + read_lock(&tasklist_lock);
64737 + p = find_task_by_vpid_unrestricted(pid);
64738 + if (unlikely(p && !have_same_root(current, p))) {
64739 + read_unlock(&tasklist_lock);
64740 + rcu_read_unlock();
64741 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64742 + return 0;
64743 + }
64744 + read_unlock(&tasklist_lock);
64745 + rcu_read_unlock();
64746 +#endif
64747 + return 1;
64748 +}
64749 +
64750 +int
64751 +gr_handle_chroot_nice(void)
64752 +{
64753 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64754 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64755 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64756 + return -EPERM;
64757 + }
64758 +#endif
64759 + return 0;
64760 +}
64761 +
64762 +int
64763 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64764 +{
64765 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64766 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64767 + && proc_is_chrooted(current)) {
64768 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64769 + return -EACCES;
64770 + }
64771 +#endif
64772 + return 0;
64773 +}
64774 +
64775 +int
64776 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64777 +{
64778 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64779 + struct task_struct *p;
64780 + int ret = 0;
64781 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64782 + return ret;
64783 +
64784 + read_lock(&tasklist_lock);
64785 + do_each_pid_task(pid, type, p) {
64786 + if (!have_same_root(current, p)) {
64787 + ret = 1;
64788 + goto out;
64789 + }
64790 + } while_each_pid_task(pid, type, p);
64791 +out:
64792 + read_unlock(&tasklist_lock);
64793 + return ret;
64794 +#endif
64795 + return 0;
64796 +}
64797 +
64798 +int
64799 +gr_pid_is_chrooted(struct task_struct *p)
64800 +{
64801 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64802 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64803 + return 0;
64804 +
64805 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64806 + !have_same_root(current, p)) {
64807 + return 1;
64808 + }
64809 +#endif
64810 + return 0;
64811 +}
64812 +
64813 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64814 +
64815 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64816 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64817 +{
64818 + struct path path, currentroot;
64819 + int ret = 0;
64820 +
64821 + path.dentry = (struct dentry *)u_dentry;
64822 + path.mnt = (struct vfsmount *)u_mnt;
64823 + get_fs_root(current->fs, &currentroot);
64824 + if (path_is_under(&path, &currentroot))
64825 + ret = 1;
64826 + path_put(&currentroot);
64827 +
64828 + return ret;
64829 +}
64830 +#endif
64831 +
64832 +int
64833 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64834 +{
64835 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64836 + if (!grsec_enable_chroot_fchdir)
64837 + return 1;
64838 +
64839 + if (!proc_is_chrooted(current))
64840 + return 1;
64841 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64842 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64843 + return 0;
64844 + }
64845 +#endif
64846 + return 1;
64847 +}
64848 +
64849 +int
64850 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64851 + const time_t shm_createtime)
64852 +{
64853 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64854 + struct task_struct *p;
64855 + time_t starttime;
64856 +
64857 + if (unlikely(!grsec_enable_chroot_shmat))
64858 + return 1;
64859 +
64860 + if (likely(!proc_is_chrooted(current)))
64861 + return 1;
64862 +
64863 + rcu_read_lock();
64864 + read_lock(&tasklist_lock);
64865 +
64866 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64867 + starttime = p->start_time.tv_sec;
64868 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64869 + if (have_same_root(current, p)) {
64870 + goto allow;
64871 + } else {
64872 + read_unlock(&tasklist_lock);
64873 + rcu_read_unlock();
64874 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64875 + return 0;
64876 + }
64877 + }
64878 + /* creator exited, pid reuse, fall through to next check */
64879 + }
64880 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64881 + if (unlikely(!have_same_root(current, p))) {
64882 + read_unlock(&tasklist_lock);
64883 + rcu_read_unlock();
64884 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64885 + return 0;
64886 + }
64887 + }
64888 +
64889 +allow:
64890 + read_unlock(&tasklist_lock);
64891 + rcu_read_unlock();
64892 +#endif
64893 + return 1;
64894 +}
64895 +
64896 +void
64897 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64898 +{
64899 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64900 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64901 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64902 +#endif
64903 + return;
64904 +}
64905 +
64906 +int
64907 +gr_handle_chroot_mknod(const struct dentry *dentry,
64908 + const struct vfsmount *mnt, const int mode)
64909 +{
64910 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64911 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64912 + proc_is_chrooted(current)) {
64913 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64914 + return -EPERM;
64915 + }
64916 +#endif
64917 + return 0;
64918 +}
64919 +
64920 +int
64921 +gr_handle_chroot_mount(const struct dentry *dentry,
64922 + const struct vfsmount *mnt, const char *dev_name)
64923 +{
64924 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64925 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64926 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64927 + return -EPERM;
64928 + }
64929 +#endif
64930 + return 0;
64931 +}
64932 +
64933 +int
64934 +gr_handle_chroot_pivot(void)
64935 +{
64936 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64937 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64938 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64939 + return -EPERM;
64940 + }
64941 +#endif
64942 + return 0;
64943 +}
64944 +
64945 +int
64946 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64947 +{
64948 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64949 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64950 + !gr_is_outside_chroot(dentry, mnt)) {
64951 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64952 + return -EPERM;
64953 + }
64954 +#endif
64955 + return 0;
64956 +}
64957 +
64958 +extern const char *captab_log[];
64959 +extern int captab_log_entries;
64960 +
64961 +int
64962 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64963 +{
64964 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64965 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64966 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64967 + if (cap_raised(chroot_caps, cap)) {
64968 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64969 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64970 + }
64971 + return 0;
64972 + }
64973 + }
64974 +#endif
64975 + return 1;
64976 +}
64977 +
64978 +int
64979 +gr_chroot_is_capable(const int cap)
64980 +{
64981 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64982 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64983 +#endif
64984 + return 1;
64985 +}
64986 +
64987 +int
64988 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64989 +{
64990 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64991 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64992 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64993 + if (cap_raised(chroot_caps, cap)) {
64994 + return 0;
64995 + }
64996 + }
64997 +#endif
64998 + return 1;
64999 +}
65000 +
65001 +int
65002 +gr_chroot_is_capable_nolog(const int cap)
65003 +{
65004 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65005 + return gr_task_chroot_is_capable_nolog(current, cap);
65006 +#endif
65007 + return 1;
65008 +}
65009 +
65010 +int
65011 +gr_handle_chroot_sysctl(const int op)
65012 +{
65013 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65014 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
65015 + proc_is_chrooted(current))
65016 + return -EACCES;
65017 +#endif
65018 + return 0;
65019 +}
65020 +
65021 +void
65022 +gr_handle_chroot_chdir(const struct path *path)
65023 +{
65024 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65025 + if (grsec_enable_chroot_chdir)
65026 + set_fs_pwd(current->fs, path);
65027 +#endif
65028 + return;
65029 +}
65030 +
65031 +int
65032 +gr_handle_chroot_chmod(const struct dentry *dentry,
65033 + const struct vfsmount *mnt, const int mode)
65034 +{
65035 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65036 + /* allow chmod +s on directories, but not files */
65037 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
65038 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
65039 + proc_is_chrooted(current)) {
65040 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
65041 + return -EPERM;
65042 + }
65043 +#endif
65044 + return 0;
65045 +}
65046 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
65047 new file mode 100644
65048 index 0000000..ce65ceb
65049 --- /dev/null
65050 +++ b/grsecurity/grsec_disabled.c
65051 @@ -0,0 +1,434 @@
65052 +#include <linux/kernel.h>
65053 +#include <linux/module.h>
65054 +#include <linux/sched.h>
65055 +#include <linux/file.h>
65056 +#include <linux/fs.h>
65057 +#include <linux/kdev_t.h>
65058 +#include <linux/net.h>
65059 +#include <linux/in.h>
65060 +#include <linux/ip.h>
65061 +#include <linux/skbuff.h>
65062 +#include <linux/sysctl.h>
65063 +
65064 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
65065 +void
65066 +pax_set_initial_flags(struct linux_binprm *bprm)
65067 +{
65068 + return;
65069 +}
65070 +#endif
65071 +
65072 +#ifdef CONFIG_SYSCTL
65073 +__u32
65074 +gr_handle_sysctl(const struct ctl_table * table, const int op)
65075 +{
65076 + return 0;
65077 +}
65078 +#endif
65079 +
65080 +#ifdef CONFIG_TASKSTATS
65081 +int gr_is_taskstats_denied(int pid)
65082 +{
65083 + return 0;
65084 +}
65085 +#endif
65086 +
65087 +int
65088 +gr_acl_is_enabled(void)
65089 +{
65090 + return 0;
65091 +}
65092 +
65093 +void
65094 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65095 +{
65096 + return;
65097 +}
65098 +
65099 +int
65100 +gr_handle_rawio(const struct inode *inode)
65101 +{
65102 + return 0;
65103 +}
65104 +
65105 +void
65106 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65107 +{
65108 + return;
65109 +}
65110 +
65111 +int
65112 +gr_handle_ptrace(struct task_struct *task, const long request)
65113 +{
65114 + return 0;
65115 +}
65116 +
65117 +int
65118 +gr_handle_proc_ptrace(struct task_struct *task)
65119 +{
65120 + return 0;
65121 +}
65122 +
65123 +int
65124 +gr_set_acls(const int type)
65125 +{
65126 + return 0;
65127 +}
65128 +
65129 +int
65130 +gr_check_hidden_task(const struct task_struct *tsk)
65131 +{
65132 + return 0;
65133 +}
65134 +
65135 +int
65136 +gr_check_protected_task(const struct task_struct *task)
65137 +{
65138 + return 0;
65139 +}
65140 +
65141 +int
65142 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65143 +{
65144 + return 0;
65145 +}
65146 +
65147 +void
65148 +gr_copy_label(struct task_struct *tsk)
65149 +{
65150 + return;
65151 +}
65152 +
65153 +void
65154 +gr_set_pax_flags(struct task_struct *task)
65155 +{
65156 + return;
65157 +}
65158 +
65159 +int
65160 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65161 + const int unsafe_share)
65162 +{
65163 + return 0;
65164 +}
65165 +
65166 +void
65167 +gr_handle_delete(const ino_t ino, const dev_t dev)
65168 +{
65169 + return;
65170 +}
65171 +
65172 +void
65173 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65174 +{
65175 + return;
65176 +}
65177 +
65178 +void
65179 +gr_handle_crash(struct task_struct *task, const int sig)
65180 +{
65181 + return;
65182 +}
65183 +
65184 +int
65185 +gr_check_crash_exec(const struct file *filp)
65186 +{
65187 + return 0;
65188 +}
65189 +
65190 +int
65191 +gr_check_crash_uid(const kuid_t uid)
65192 +{
65193 + return 0;
65194 +}
65195 +
65196 +void
65197 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65198 + struct dentry *old_dentry,
65199 + struct dentry *new_dentry,
65200 + struct vfsmount *mnt, const __u8 replace)
65201 +{
65202 + return;
65203 +}
65204 +
65205 +int
65206 +gr_search_socket(const int family, const int type, const int protocol)
65207 +{
65208 + return 1;
65209 +}
65210 +
65211 +int
65212 +gr_search_connectbind(const int mode, const struct socket *sock,
65213 + const struct sockaddr_in *addr)
65214 +{
65215 + return 0;
65216 +}
65217 +
65218 +void
65219 +gr_handle_alertkill(struct task_struct *task)
65220 +{
65221 + return;
65222 +}
65223 +
65224 +__u32
65225 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
65226 +{
65227 + return 1;
65228 +}
65229 +
65230 +__u32
65231 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65232 + const struct vfsmount * mnt)
65233 +{
65234 + return 1;
65235 +}
65236 +
65237 +__u32
65238 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65239 + int acc_mode)
65240 +{
65241 + return 1;
65242 +}
65243 +
65244 +__u32
65245 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
65246 +{
65247 + return 1;
65248 +}
65249 +
65250 +__u32
65251 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
65252 +{
65253 + return 1;
65254 +}
65255 +
65256 +int
65257 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
65258 + unsigned int *vm_flags)
65259 +{
65260 + return 1;
65261 +}
65262 +
65263 +__u32
65264 +gr_acl_handle_truncate(const struct dentry * dentry,
65265 + const struct vfsmount * mnt)
65266 +{
65267 + return 1;
65268 +}
65269 +
65270 +__u32
65271 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
65272 +{
65273 + return 1;
65274 +}
65275 +
65276 +__u32
65277 +gr_acl_handle_access(const struct dentry * dentry,
65278 + const struct vfsmount * mnt, const int fmode)
65279 +{
65280 + return 1;
65281 +}
65282 +
65283 +__u32
65284 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
65285 + umode_t *mode)
65286 +{
65287 + return 1;
65288 +}
65289 +
65290 +__u32
65291 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
65292 +{
65293 + return 1;
65294 +}
65295 +
65296 +__u32
65297 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
65298 +{
65299 + return 1;
65300 +}
65301 +
65302 +void
65303 +grsecurity_init(void)
65304 +{
65305 + return;
65306 +}
65307 +
65308 +umode_t gr_acl_umask(void)
65309 +{
65310 + return 0;
65311 +}
65312 +
65313 +__u32
65314 +gr_acl_handle_mknod(const struct dentry * new_dentry,
65315 + const struct dentry * parent_dentry,
65316 + const struct vfsmount * parent_mnt,
65317 + const int mode)
65318 +{
65319 + return 1;
65320 +}
65321 +
65322 +__u32
65323 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
65324 + const struct dentry * parent_dentry,
65325 + const struct vfsmount * parent_mnt)
65326 +{
65327 + return 1;
65328 +}
65329 +
65330 +__u32
65331 +gr_acl_handle_symlink(const struct dentry * new_dentry,
65332 + const struct dentry * parent_dentry,
65333 + const struct vfsmount * parent_mnt, const struct filename *from)
65334 +{
65335 + return 1;
65336 +}
65337 +
65338 +__u32
65339 +gr_acl_handle_link(const struct dentry * new_dentry,
65340 + const struct dentry * parent_dentry,
65341 + const struct vfsmount * parent_mnt,
65342 + const struct dentry * old_dentry,
65343 + const struct vfsmount * old_mnt, const struct filename *to)
65344 +{
65345 + return 1;
65346 +}
65347 +
65348 +int
65349 +gr_acl_handle_rename(const struct dentry *new_dentry,
65350 + const struct dentry *parent_dentry,
65351 + const struct vfsmount *parent_mnt,
65352 + const struct dentry *old_dentry,
65353 + const struct inode *old_parent_inode,
65354 + const struct vfsmount *old_mnt, const struct filename *newname)
65355 +{
65356 + return 0;
65357 +}
65358 +
65359 +int
65360 +gr_acl_handle_filldir(const struct file *file, const char *name,
65361 + const int namelen, const ino_t ino)
65362 +{
65363 + return 1;
65364 +}
65365 +
65366 +int
65367 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65368 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
65369 +{
65370 + return 1;
65371 +}
65372 +
65373 +int
65374 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
65375 +{
65376 + return 0;
65377 +}
65378 +
65379 +int
65380 +gr_search_accept(const struct socket *sock)
65381 +{
65382 + return 0;
65383 +}
65384 +
65385 +int
65386 +gr_search_listen(const struct socket *sock)
65387 +{
65388 + return 0;
65389 +}
65390 +
65391 +int
65392 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
65393 +{
65394 + return 0;
65395 +}
65396 +
65397 +__u32
65398 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
65399 +{
65400 + return 1;
65401 +}
65402 +
65403 +__u32
65404 +gr_acl_handle_creat(const struct dentry * dentry,
65405 + const struct dentry * p_dentry,
65406 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65407 + const int imode)
65408 +{
65409 + return 1;
65410 +}
65411 +
65412 +void
65413 +gr_acl_handle_exit(void)
65414 +{
65415 + return;
65416 +}
65417 +
65418 +int
65419 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65420 +{
65421 + return 1;
65422 +}
65423 +
65424 +void
65425 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
65426 +{
65427 + return;
65428 +}
65429 +
65430 +int
65431 +gr_acl_handle_procpidmem(const struct task_struct *task)
65432 +{
65433 + return 0;
65434 +}
65435 +
65436 +int
65437 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
65438 +{
65439 + return 0;
65440 +}
65441 +
65442 +int
65443 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
65444 +{
65445 + return 0;
65446 +}
65447 +
65448 +void
65449 +gr_set_kernel_label(struct task_struct *task)
65450 +{
65451 + return;
65452 +}
65453 +
65454 +int
65455 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65456 +{
65457 + return 0;
65458 +}
65459 +
65460 +int
65461 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65462 +{
65463 + return 0;
65464 +}
65465 +
65466 +int gr_acl_enable_at_secure(void)
65467 +{
65468 + return 0;
65469 +}
65470 +
65471 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
65472 +{
65473 + return dentry->d_sb->s_dev;
65474 +}
65475 +
65476 +void gr_put_exec_file(struct task_struct *task)
65477 +{
65478 + return;
65479 +}
65480 +
65481 +EXPORT_SYMBOL(gr_set_kernel_label);
65482 +#ifdef CONFIG_SECURITY
65483 +EXPORT_SYMBOL(gr_check_user_change);
65484 +EXPORT_SYMBOL(gr_check_group_change);
65485 +#endif
65486 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
65487 new file mode 100644
65488 index 0000000..387032b
65489 --- /dev/null
65490 +++ b/grsecurity/grsec_exec.c
65491 @@ -0,0 +1,187 @@
65492 +#include <linux/kernel.h>
65493 +#include <linux/sched.h>
65494 +#include <linux/file.h>
65495 +#include <linux/binfmts.h>
65496 +#include <linux/fs.h>
65497 +#include <linux/types.h>
65498 +#include <linux/grdefs.h>
65499 +#include <linux/grsecurity.h>
65500 +#include <linux/grinternal.h>
65501 +#include <linux/capability.h>
65502 +#include <linux/module.h>
65503 +#include <linux/compat.h>
65504 +
65505 +#include <asm/uaccess.h>
65506 +
65507 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65508 +static char gr_exec_arg_buf[132];
65509 +static DEFINE_MUTEX(gr_exec_arg_mutex);
65510 +#endif
65511 +
65512 +struct user_arg_ptr {
65513 +#ifdef CONFIG_COMPAT
65514 + bool is_compat;
65515 +#endif
65516 + union {
65517 + const char __user *const __user *native;
65518 +#ifdef CONFIG_COMPAT
65519 + const compat_uptr_t __user *compat;
65520 +#endif
65521 + } ptr;
65522 +};
65523 +
65524 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
65525 +
65526 +void
65527 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
65528 +{
65529 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65530 + char *grarg = gr_exec_arg_buf;
65531 + unsigned int i, x, execlen = 0;
65532 + char c;
65533 +
65534 + if (!((grsec_enable_execlog && grsec_enable_group &&
65535 + in_group_p(grsec_audit_gid))
65536 + || (grsec_enable_execlog && !grsec_enable_group)))
65537 + return;
65538 +
65539 + mutex_lock(&gr_exec_arg_mutex);
65540 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
65541 +
65542 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
65543 + const char __user *p;
65544 + unsigned int len;
65545 +
65546 + p = get_user_arg_ptr(argv, i);
65547 + if (IS_ERR(p))
65548 + goto log;
65549 +
65550 + len = strnlen_user(p, 128 - execlen);
65551 + if (len > 128 - execlen)
65552 + len = 128 - execlen;
65553 + else if (len > 0)
65554 + len--;
65555 + if (copy_from_user(grarg + execlen, p, len))
65556 + goto log;
65557 +
65558 + /* rewrite unprintable characters */
65559 + for (x = 0; x < len; x++) {
65560 + c = *(grarg + execlen + x);
65561 + if (c < 32 || c > 126)
65562 + *(grarg + execlen + x) = ' ';
65563 + }
65564 +
65565 + execlen += len;
65566 + *(grarg + execlen) = ' ';
65567 + *(grarg + execlen + 1) = '\0';
65568 + execlen++;
65569 + }
65570 +
65571 + log:
65572 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
65573 + bprm->file->f_path.mnt, grarg);
65574 + mutex_unlock(&gr_exec_arg_mutex);
65575 +#endif
65576 + return;
65577 +}
65578 +
65579 +#ifdef CONFIG_GRKERNSEC
65580 +extern int gr_acl_is_capable(const int cap);
65581 +extern int gr_acl_is_capable_nolog(const int cap);
65582 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65583 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
65584 +extern int gr_chroot_is_capable(const int cap);
65585 +extern int gr_chroot_is_capable_nolog(const int cap);
65586 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65587 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
65588 +#endif
65589 +
65590 +const char *captab_log[] = {
65591 + "CAP_CHOWN",
65592 + "CAP_DAC_OVERRIDE",
65593 + "CAP_DAC_READ_SEARCH",
65594 + "CAP_FOWNER",
65595 + "CAP_FSETID",
65596 + "CAP_KILL",
65597 + "CAP_SETGID",
65598 + "CAP_SETUID",
65599 + "CAP_SETPCAP",
65600 + "CAP_LINUX_IMMUTABLE",
65601 + "CAP_NET_BIND_SERVICE",
65602 + "CAP_NET_BROADCAST",
65603 + "CAP_NET_ADMIN",
65604 + "CAP_NET_RAW",
65605 + "CAP_IPC_LOCK",
65606 + "CAP_IPC_OWNER",
65607 + "CAP_SYS_MODULE",
65608 + "CAP_SYS_RAWIO",
65609 + "CAP_SYS_CHROOT",
65610 + "CAP_SYS_PTRACE",
65611 + "CAP_SYS_PACCT",
65612 + "CAP_SYS_ADMIN",
65613 + "CAP_SYS_BOOT",
65614 + "CAP_SYS_NICE",
65615 + "CAP_SYS_RESOURCE",
65616 + "CAP_SYS_TIME",
65617 + "CAP_SYS_TTY_CONFIG",
65618 + "CAP_MKNOD",
65619 + "CAP_LEASE",
65620 + "CAP_AUDIT_WRITE",
65621 + "CAP_AUDIT_CONTROL",
65622 + "CAP_SETFCAP",
65623 + "CAP_MAC_OVERRIDE",
65624 + "CAP_MAC_ADMIN",
65625 + "CAP_SYSLOG",
65626 + "CAP_WAKE_ALARM"
65627 +};
65628 +
65629 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
65630 +
65631 +int gr_is_capable(const int cap)
65632 +{
65633 +#ifdef CONFIG_GRKERNSEC
65634 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
65635 + return 1;
65636 + return 0;
65637 +#else
65638 + return 1;
65639 +#endif
65640 +}
65641 +
65642 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65643 +{
65644 +#ifdef CONFIG_GRKERNSEC
65645 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
65646 + return 1;
65647 + return 0;
65648 +#else
65649 + return 1;
65650 +#endif
65651 +}
65652 +
65653 +int gr_is_capable_nolog(const int cap)
65654 +{
65655 +#ifdef CONFIG_GRKERNSEC
65656 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
65657 + return 1;
65658 + return 0;
65659 +#else
65660 + return 1;
65661 +#endif
65662 +}
65663 +
65664 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
65665 +{
65666 +#ifdef CONFIG_GRKERNSEC
65667 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
65668 + return 1;
65669 + return 0;
65670 +#else
65671 + return 1;
65672 +#endif
65673 +}
65674 +
65675 +EXPORT_SYMBOL(gr_is_capable);
65676 +EXPORT_SYMBOL(gr_is_capable_nolog);
65677 +EXPORT_SYMBOL(gr_task_is_capable);
65678 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
65679 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
65680 new file mode 100644
65681 index 0000000..06cc6ea
65682 --- /dev/null
65683 +++ b/grsecurity/grsec_fifo.c
65684 @@ -0,0 +1,24 @@
65685 +#include <linux/kernel.h>
65686 +#include <linux/sched.h>
65687 +#include <linux/fs.h>
65688 +#include <linux/file.h>
65689 +#include <linux/grinternal.h>
65690 +
65691 +int
65692 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65693 + const struct dentry *dir, const int flag, const int acc_mode)
65694 +{
65695 +#ifdef CONFIG_GRKERNSEC_FIFO
65696 + const struct cred *cred = current_cred();
65697 +
65698 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65699 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65700 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65701 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65702 + if (!inode_permission(dentry->d_inode, acc_mode))
65703 + gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, GR_GLOBAL_UID(dentry->d_inode->i_uid), GR_GLOBAL_GID(dentry->d_inode->i_gid));
65704 + return -EACCES;
65705 + }
65706 +#endif
65707 + return 0;
65708 +}
65709 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65710 new file mode 100644
65711 index 0000000..8ca18bf
65712 --- /dev/null
65713 +++ b/grsecurity/grsec_fork.c
65714 @@ -0,0 +1,23 @@
65715 +#include <linux/kernel.h>
65716 +#include <linux/sched.h>
65717 +#include <linux/grsecurity.h>
65718 +#include <linux/grinternal.h>
65719 +#include <linux/errno.h>
65720 +
65721 +void
65722 +gr_log_forkfail(const int retval)
65723 +{
65724 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65725 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65726 + switch (retval) {
65727 + case -EAGAIN:
65728 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65729 + break;
65730 + case -ENOMEM:
65731 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65732 + break;
65733 + }
65734 + }
65735 +#endif
65736 + return;
65737 +}
65738 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65739 new file mode 100644
65740 index 0000000..ab2d875
65741 --- /dev/null
65742 +++ b/grsecurity/grsec_init.c
65743 @@ -0,0 +1,279 @@
65744 +#include <linux/kernel.h>
65745 +#include <linux/sched.h>
65746 +#include <linux/mm.h>
65747 +#include <linux/gracl.h>
65748 +#include <linux/slab.h>
65749 +#include <linux/vmalloc.h>
65750 +#include <linux/percpu.h>
65751 +#include <linux/module.h>
65752 +
65753 +int grsec_enable_ptrace_readexec;
65754 +int grsec_enable_setxid;
65755 +int grsec_enable_symlinkown;
65756 +kgid_t grsec_symlinkown_gid;
65757 +int grsec_enable_brute;
65758 +int grsec_enable_link;
65759 +int grsec_enable_dmesg;
65760 +int grsec_enable_harden_ptrace;
65761 +int grsec_enable_fifo;
65762 +int grsec_enable_execlog;
65763 +int grsec_enable_signal;
65764 +int grsec_enable_forkfail;
65765 +int grsec_enable_audit_ptrace;
65766 +int grsec_enable_time;
65767 +int grsec_enable_group;
65768 +kgid_t grsec_audit_gid;
65769 +int grsec_enable_chdir;
65770 +int grsec_enable_mount;
65771 +int grsec_enable_rofs;
65772 +int grsec_enable_chroot_findtask;
65773 +int grsec_enable_chroot_mount;
65774 +int grsec_enable_chroot_shmat;
65775 +int grsec_enable_chroot_fchdir;
65776 +int grsec_enable_chroot_double;
65777 +int grsec_enable_chroot_pivot;
65778 +int grsec_enable_chroot_chdir;
65779 +int grsec_enable_chroot_chmod;
65780 +int grsec_enable_chroot_mknod;
65781 +int grsec_enable_chroot_nice;
65782 +int grsec_enable_chroot_execlog;
65783 +int grsec_enable_chroot_caps;
65784 +int grsec_enable_chroot_sysctl;
65785 +int grsec_enable_chroot_unix;
65786 +int grsec_enable_tpe;
65787 +kgid_t grsec_tpe_gid;
65788 +int grsec_enable_blackhole;
65789 +#ifdef CONFIG_IPV6_MODULE
65790 +EXPORT_SYMBOL(grsec_enable_blackhole);
65791 +#endif
65792 +int grsec_lastack_retries;
65793 +int grsec_enable_tpe_all;
65794 +int grsec_enable_tpe_invert;
65795 +int grsec_enable_socket_all;
65796 +kgid_t grsec_socket_all_gid;
65797 +int grsec_enable_socket_client;
65798 +kgid_t grsec_socket_client_gid;
65799 +int grsec_enable_socket_server;
65800 +kgid_t grsec_socket_server_gid;
65801 +int grsec_resource_logging;
65802 +int grsec_disable_privio;
65803 +int grsec_enable_log_rwxmaps;
65804 +int grsec_lock;
65805 +
65806 +DEFINE_SPINLOCK(grsec_alert_lock);
65807 +unsigned long grsec_alert_wtime = 0;
65808 +unsigned long grsec_alert_fyet = 0;
65809 +
65810 +DEFINE_SPINLOCK(grsec_audit_lock);
65811 +
65812 +DEFINE_RWLOCK(grsec_exec_file_lock);
65813 +
65814 +char *gr_shared_page[4];
65815 +
65816 +char *gr_alert_log_fmt;
65817 +char *gr_audit_log_fmt;
65818 +char *gr_alert_log_buf;
65819 +char *gr_audit_log_buf;
65820 +
65821 +extern struct gr_arg *gr_usermode;
65822 +extern unsigned char *gr_system_salt;
65823 +extern unsigned char *gr_system_sum;
65824 +
65825 +void __init
65826 +grsecurity_init(void)
65827 +{
65828 + int j;
65829 + /* create the per-cpu shared pages */
65830 +
65831 +#ifdef CONFIG_X86
65832 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65833 +#endif
65834 +
65835 + for (j = 0; j < 4; j++) {
65836 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65837 + if (gr_shared_page[j] == NULL) {
65838 + panic("Unable to allocate grsecurity shared page");
65839 + return;
65840 + }
65841 + }
65842 +
65843 + /* allocate log buffers */
65844 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65845 + if (!gr_alert_log_fmt) {
65846 + panic("Unable to allocate grsecurity alert log format buffer");
65847 + return;
65848 + }
65849 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65850 + if (!gr_audit_log_fmt) {
65851 + panic("Unable to allocate grsecurity audit log format buffer");
65852 + return;
65853 + }
65854 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65855 + if (!gr_alert_log_buf) {
65856 + panic("Unable to allocate grsecurity alert log buffer");
65857 + return;
65858 + }
65859 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65860 + if (!gr_audit_log_buf) {
65861 + panic("Unable to allocate grsecurity audit log buffer");
65862 + return;
65863 + }
65864 +
65865 + /* allocate memory for authentication structure */
65866 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65867 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65868 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65869 +
65870 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65871 + panic("Unable to allocate grsecurity authentication structure");
65872 + return;
65873 + }
65874 +
65875 +
65876 +#ifdef CONFIG_GRKERNSEC_IO
65877 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65878 + grsec_disable_privio = 1;
65879 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65880 + grsec_disable_privio = 1;
65881 +#else
65882 + grsec_disable_privio = 0;
65883 +#endif
65884 +#endif
65885 +
65886 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65887 + /* for backward compatibility, tpe_invert always defaults to on if
65888 + enabled in the kernel
65889 + */
65890 + grsec_enable_tpe_invert = 1;
65891 +#endif
65892 +
65893 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65894 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65895 + grsec_lock = 1;
65896 +#endif
65897 +
65898 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65899 + grsec_enable_log_rwxmaps = 1;
65900 +#endif
65901 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65902 + grsec_enable_group = 1;
65903 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65904 +#endif
65905 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65906 + grsec_enable_ptrace_readexec = 1;
65907 +#endif
65908 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65909 + grsec_enable_chdir = 1;
65910 +#endif
65911 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65912 + grsec_enable_harden_ptrace = 1;
65913 +#endif
65914 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65915 + grsec_enable_mount = 1;
65916 +#endif
65917 +#ifdef CONFIG_GRKERNSEC_LINK
65918 + grsec_enable_link = 1;
65919 +#endif
65920 +#ifdef CONFIG_GRKERNSEC_BRUTE
65921 + grsec_enable_brute = 1;
65922 +#endif
65923 +#ifdef CONFIG_GRKERNSEC_DMESG
65924 + grsec_enable_dmesg = 1;
65925 +#endif
65926 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65927 + grsec_enable_blackhole = 1;
65928 + grsec_lastack_retries = 4;
65929 +#endif
65930 +#ifdef CONFIG_GRKERNSEC_FIFO
65931 + grsec_enable_fifo = 1;
65932 +#endif
65933 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65934 + grsec_enable_execlog = 1;
65935 +#endif
65936 +#ifdef CONFIG_GRKERNSEC_SETXID
65937 + grsec_enable_setxid = 1;
65938 +#endif
65939 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65940 + grsec_enable_signal = 1;
65941 +#endif
65942 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65943 + grsec_enable_forkfail = 1;
65944 +#endif
65945 +#ifdef CONFIG_GRKERNSEC_TIME
65946 + grsec_enable_time = 1;
65947 +#endif
65948 +#ifdef CONFIG_GRKERNSEC_RESLOG
65949 + grsec_resource_logging = 1;
65950 +#endif
65951 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65952 + grsec_enable_chroot_findtask = 1;
65953 +#endif
65954 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65955 + grsec_enable_chroot_unix = 1;
65956 +#endif
65957 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65958 + grsec_enable_chroot_mount = 1;
65959 +#endif
65960 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65961 + grsec_enable_chroot_fchdir = 1;
65962 +#endif
65963 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65964 + grsec_enable_chroot_shmat = 1;
65965 +#endif
65966 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65967 + grsec_enable_audit_ptrace = 1;
65968 +#endif
65969 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65970 + grsec_enable_chroot_double = 1;
65971 +#endif
65972 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65973 + grsec_enable_chroot_pivot = 1;
65974 +#endif
65975 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65976 + grsec_enable_chroot_chdir = 1;
65977 +#endif
65978 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65979 + grsec_enable_chroot_chmod = 1;
65980 +#endif
65981 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65982 + grsec_enable_chroot_mknod = 1;
65983 +#endif
65984 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65985 + grsec_enable_chroot_nice = 1;
65986 +#endif
65987 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65988 + grsec_enable_chroot_execlog = 1;
65989 +#endif
65990 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65991 + grsec_enable_chroot_caps = 1;
65992 +#endif
65993 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65994 + grsec_enable_chroot_sysctl = 1;
65995 +#endif
65996 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65997 + grsec_enable_symlinkown = 1;
65998 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65999 +#endif
66000 +#ifdef CONFIG_GRKERNSEC_TPE
66001 + grsec_enable_tpe = 1;
66002 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
66003 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66004 + grsec_enable_tpe_all = 1;
66005 +#endif
66006 +#endif
66007 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66008 + grsec_enable_socket_all = 1;
66009 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
66010 +#endif
66011 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66012 + grsec_enable_socket_client = 1;
66013 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
66014 +#endif
66015 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66016 + grsec_enable_socket_server = 1;
66017 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
66018 +#endif
66019 +#endif
66020 +
66021 + return;
66022 +}
66023 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
66024 new file mode 100644
66025 index 0000000..5e05e20
66026 --- /dev/null
66027 +++ b/grsecurity/grsec_link.c
66028 @@ -0,0 +1,58 @@
66029 +#include <linux/kernel.h>
66030 +#include <linux/sched.h>
66031 +#include <linux/fs.h>
66032 +#include <linux/file.h>
66033 +#include <linux/grinternal.h>
66034 +
66035 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
66036 +{
66037 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66038 + const struct inode *link_inode = link->dentry->d_inode;
66039 +
66040 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
66041 + /* ignore root-owned links, e.g. /proc/self */
66042 + gr_is_global_nonroot(link_inode->i_uid) && target &&
66043 + !uid_eq(link_inode->i_uid, target->i_uid)) {
66044 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
66045 + return 1;
66046 + }
66047 +#endif
66048 + return 0;
66049 +}
66050 +
66051 +int
66052 +gr_handle_follow_link(const struct inode *parent,
66053 + const struct inode *inode,
66054 + const struct dentry *dentry, const struct vfsmount *mnt)
66055 +{
66056 +#ifdef CONFIG_GRKERNSEC_LINK
66057 + const struct cred *cred = current_cred();
66058 +
66059 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
66060 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
66061 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
66062 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
66063 + return -EACCES;
66064 + }
66065 +#endif
66066 + return 0;
66067 +}
66068 +
66069 +int
66070 +gr_handle_hardlink(const struct dentry *dentry,
66071 + const struct vfsmount *mnt,
66072 + struct inode *inode, const int mode, const struct filename *to)
66073 +{
66074 +#ifdef CONFIG_GRKERNSEC_LINK
66075 + const struct cred *cred = current_cred();
66076 +
66077 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
66078 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
66079 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
66080 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
66081 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
66082 + return -EPERM;
66083 + }
66084 +#endif
66085 + return 0;
66086 +}
66087 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
66088 new file mode 100644
66089 index 0000000..dbe0a6b
66090 --- /dev/null
66091 +++ b/grsecurity/grsec_log.c
66092 @@ -0,0 +1,341 @@
66093 +#include <linux/kernel.h>
66094 +#include <linux/sched.h>
66095 +#include <linux/file.h>
66096 +#include <linux/tty.h>
66097 +#include <linux/fs.h>
66098 +#include <linux/mm.h>
66099 +#include <linux/grinternal.h>
66100 +
66101 +#ifdef CONFIG_TREE_PREEMPT_RCU
66102 +#define DISABLE_PREEMPT() preempt_disable()
66103 +#define ENABLE_PREEMPT() preempt_enable()
66104 +#else
66105 +#define DISABLE_PREEMPT()
66106 +#define ENABLE_PREEMPT()
66107 +#endif
66108 +
66109 +#define BEGIN_LOCKS(x) \
66110 + DISABLE_PREEMPT(); \
66111 + rcu_read_lock(); \
66112 + read_lock(&tasklist_lock); \
66113 + read_lock(&grsec_exec_file_lock); \
66114 + if (x != GR_DO_AUDIT) \
66115 + spin_lock(&grsec_alert_lock); \
66116 + else \
66117 + spin_lock(&grsec_audit_lock)
66118 +
66119 +#define END_LOCKS(x) \
66120 + if (x != GR_DO_AUDIT) \
66121 + spin_unlock(&grsec_alert_lock); \
66122 + else \
66123 + spin_unlock(&grsec_audit_lock); \
66124 + read_unlock(&grsec_exec_file_lock); \
66125 + read_unlock(&tasklist_lock); \
66126 + rcu_read_unlock(); \
66127 + ENABLE_PREEMPT(); \
66128 + if (x == GR_DONT_AUDIT) \
66129 + gr_handle_alertkill(current)
66130 +
66131 +enum {
66132 + FLOODING,
66133 + NO_FLOODING
66134 +};
66135 +
66136 +extern char *gr_alert_log_fmt;
66137 +extern char *gr_audit_log_fmt;
66138 +extern char *gr_alert_log_buf;
66139 +extern char *gr_audit_log_buf;
66140 +
66141 +static int gr_log_start(int audit)
66142 +{
66143 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
66144 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
66145 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66146 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
66147 + unsigned long curr_secs = get_seconds();
66148 +
66149 + if (audit == GR_DO_AUDIT)
66150 + goto set_fmt;
66151 +
66152 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
66153 + grsec_alert_wtime = curr_secs;
66154 + grsec_alert_fyet = 0;
66155 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
66156 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
66157 + grsec_alert_fyet++;
66158 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
66159 + grsec_alert_wtime = curr_secs;
66160 + grsec_alert_fyet++;
66161 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
66162 + return FLOODING;
66163 + }
66164 + else return FLOODING;
66165 +
66166 +set_fmt:
66167 +#endif
66168 + memset(buf, 0, PAGE_SIZE);
66169 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
66170 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
66171 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
66172 + } else if (current->signal->curr_ip) {
66173 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
66174 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
66175 + } else if (gr_acl_is_enabled()) {
66176 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
66177 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
66178 + } else {
66179 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
66180 + strcpy(buf, fmt);
66181 + }
66182 +
66183 + return NO_FLOODING;
66184 +}
66185 +
66186 +static void gr_log_middle(int audit, const char *msg, va_list ap)
66187 + __attribute__ ((format (printf, 2, 0)));
66188 +
66189 +static void gr_log_middle(int audit, const char *msg, va_list ap)
66190 +{
66191 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66192 + unsigned int len = strlen(buf);
66193 +
66194 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
66195 +
66196 + return;
66197 +}
66198 +
66199 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
66200 + __attribute__ ((format (printf, 2, 3)));
66201 +
66202 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
66203 +{
66204 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66205 + unsigned int len = strlen(buf);
66206 + va_list ap;
66207 +
66208 + va_start(ap, msg);
66209 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
66210 + va_end(ap);
66211 +
66212 + return;
66213 +}
66214 +
66215 +static void gr_log_end(int audit, int append_default)
66216 +{
66217 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66218 + if (append_default) {
66219 + struct task_struct *task = current;
66220 + struct task_struct *parent = task->real_parent;
66221 + const struct cred *cred = __task_cred(task);
66222 + const struct cred *pcred = __task_cred(parent);
66223 + unsigned int len = strlen(buf);
66224 +
66225 + snprintf(buf + len, PAGE_SIZE - len - 1, DEFAULTSECMSG, gr_task_fullpath(task), task->comm, task_pid_nr(task), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), gr_parent_task_fullpath(task), parent->comm, task_pid_nr(task->real_parent), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
66226 + }
66227 +
66228 + printk("%s\n", buf);
66229 +
66230 + return;
66231 +}
66232 +
66233 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
66234 +{
66235 + int logtype;
66236 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
66237 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
66238 + void *voidptr = NULL;
66239 + int num1 = 0, num2 = 0;
66240 + unsigned long ulong1 = 0, ulong2 = 0;
66241 + struct dentry *dentry = NULL;
66242 + struct vfsmount *mnt = NULL;
66243 + struct file *file = NULL;
66244 + struct task_struct *task = NULL;
66245 + struct vm_area_struct *vma = NULL;
66246 + const struct cred *cred, *pcred;
66247 + va_list ap;
66248 +
66249 + BEGIN_LOCKS(audit);
66250 + logtype = gr_log_start(audit);
66251 + if (logtype == FLOODING) {
66252 + END_LOCKS(audit);
66253 + return;
66254 + }
66255 + va_start(ap, argtypes);
66256 + switch (argtypes) {
66257 + case GR_TTYSNIFF:
66258 + task = va_arg(ap, struct task_struct *);
66259 + gr_log_middle_varargs(audit, msg, &task->signal->curr_ip, gr_task_fullpath0(task), task->comm, task_pid_nr(task), gr_parent_task_fullpath0(task), task->real_parent->comm, task_pid_nr(task->real_parent));
66260 + break;
66261 + case GR_SYSCTL_HIDDEN:
66262 + str1 = va_arg(ap, char *);
66263 + gr_log_middle_varargs(audit, msg, result, str1);
66264 + break;
66265 + case GR_RBAC:
66266 + dentry = va_arg(ap, struct dentry *);
66267 + mnt = va_arg(ap, struct vfsmount *);
66268 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
66269 + break;
66270 + case GR_RBAC_STR:
66271 + dentry = va_arg(ap, struct dentry *);
66272 + mnt = va_arg(ap, struct vfsmount *);
66273 + str1 = va_arg(ap, char *);
66274 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
66275 + break;
66276 + case GR_STR_RBAC:
66277 + str1 = va_arg(ap, char *);
66278 + dentry = va_arg(ap, struct dentry *);
66279 + mnt = va_arg(ap, struct vfsmount *);
66280 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
66281 + break;
66282 + case GR_RBAC_MODE2:
66283 + dentry = va_arg(ap, struct dentry *);
66284 + mnt = va_arg(ap, struct vfsmount *);
66285 + str1 = va_arg(ap, char *);
66286 + str2 = va_arg(ap, char *);
66287 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
66288 + break;
66289 + case GR_RBAC_MODE3:
66290 + dentry = va_arg(ap, struct dentry *);
66291 + mnt = va_arg(ap, struct vfsmount *);
66292 + str1 = va_arg(ap, char *);
66293 + str2 = va_arg(ap, char *);
66294 + str3 = va_arg(ap, char *);
66295 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
66296 + break;
66297 + case GR_FILENAME:
66298 + dentry = va_arg(ap, struct dentry *);
66299 + mnt = va_arg(ap, struct vfsmount *);
66300 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
66301 + break;
66302 + case GR_STR_FILENAME:
66303 + str1 = va_arg(ap, char *);
66304 + dentry = va_arg(ap, struct dentry *);
66305 + mnt = va_arg(ap, struct vfsmount *);
66306 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
66307 + break;
66308 + case GR_FILENAME_STR:
66309 + dentry = va_arg(ap, struct dentry *);
66310 + mnt = va_arg(ap, struct vfsmount *);
66311 + str1 = va_arg(ap, char *);
66312 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
66313 + break;
66314 + case GR_FILENAME_TWO_INT:
66315 + dentry = va_arg(ap, struct dentry *);
66316 + mnt = va_arg(ap, struct vfsmount *);
66317 + num1 = va_arg(ap, int);
66318 + num2 = va_arg(ap, int);
66319 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
66320 + break;
66321 + case GR_FILENAME_TWO_INT_STR:
66322 + dentry = va_arg(ap, struct dentry *);
66323 + mnt = va_arg(ap, struct vfsmount *);
66324 + num1 = va_arg(ap, int);
66325 + num2 = va_arg(ap, int);
66326 + str1 = va_arg(ap, char *);
66327 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
66328 + break;
66329 + case GR_TEXTREL:
66330 + file = va_arg(ap, struct file *);
66331 + ulong1 = va_arg(ap, unsigned long);
66332 + ulong2 = va_arg(ap, unsigned long);
66333 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
66334 + break;
66335 + case GR_PTRACE:
66336 + task = va_arg(ap, struct task_struct *);
66337 + gr_log_middle_varargs(audit, msg, task->exec_file ? gr_to_filename(task->exec_file->f_path.dentry, task->exec_file->f_path.mnt) : "(none)", task->comm, task_pid_nr(task));
66338 + break;
66339 + case GR_RESOURCE:
66340 + task = va_arg(ap, struct task_struct *);
66341 + cred = __task_cred(task);
66342 + pcred = __task_cred(task->real_parent);
66343 + ulong1 = va_arg(ap, unsigned long);
66344 + str1 = va_arg(ap, char *);
66345 + ulong2 = va_arg(ap, unsigned long);
66346 + gr_log_middle_varargs(audit, msg, ulong1, str1, ulong2, gr_task_fullpath(task), task->comm, task_pid_nr(task), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), gr_parent_task_fullpath(task), task->real_parent->comm, task_pid_nr(task->real_parent), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
66347 + break;
66348 + case GR_CAP:
66349 + task = va_arg(ap, struct task_struct *);
66350 + cred = __task_cred(task);
66351 + pcred = __task_cred(task->real_parent);
66352 + str1 = va_arg(ap, char *);
66353 + gr_log_middle_varargs(audit, msg, str1, gr_task_fullpath(task), task->comm, task_pid_nr(task), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), gr_parent_task_fullpath(task), task->real_parent->comm, task_pid_nr(task->real_parent), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
66354 + break;
66355 + case GR_SIG:
66356 + str1 = va_arg(ap, char *);
66357 + voidptr = va_arg(ap, void *);
66358 + gr_log_middle_varargs(audit, msg, str1, voidptr);
66359 + break;
66360 + case GR_SIG2:
66361 + task = va_arg(ap, struct task_struct *);
66362 + cred = __task_cred(task);
66363 + pcred = __task_cred(task->real_parent);
66364 + num1 = va_arg(ap, int);
66365 + gr_log_middle_varargs(audit, msg, num1, gr_task_fullpath0(task), task->comm, task_pid_nr(task), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), gr_parent_task_fullpath0(task), task->real_parent->comm, task_pid_nr(task->real_parent), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
66366 + break;
66367 + case GR_CRASH1:
66368 + task = va_arg(ap, struct task_struct *);
66369 + cred = __task_cred(task);
66370 + pcred = __task_cred(task->real_parent);
66371 + ulong1 = va_arg(ap, unsigned long);
66372 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task_pid_nr(task), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), gr_parent_task_fullpath(task), task->real_parent->comm, task_pid_nr(task->real_parent), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid), GR_GLOBAL_UID(cred->uid), ulong1);
66373 + break;
66374 + case GR_CRASH2:
66375 + task = va_arg(ap, struct task_struct *);
66376 + cred = __task_cred(task);
66377 + pcred = __task_cred(task->real_parent);
66378 + ulong1 = va_arg(ap, unsigned long);
66379 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task_pid_nr(task), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), gr_parent_task_fullpath(task), task->real_parent->comm, task_pid_nr(task->real_parent), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid), ulong1);
66380 + break;
66381 + case GR_RWXMAP:
66382 + file = va_arg(ap, struct file *);
66383 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
66384 + break;
66385 + case GR_RWXMAPVMA:
66386 + vma = va_arg(ap, struct vm_area_struct *);
66387 + if (vma->vm_file)
66388 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
66389 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
66390 + str1 = "<stack>";
66391 + else if (vma->vm_start <= current->mm->brk &&
66392 + vma->vm_end >= current->mm->start_brk)
66393 + str1 = "<heap>";
66394 + else
66395 + str1 = "<anonymous mapping>";
66396 + gr_log_middle_varargs(audit, msg, str1);
66397 + break;
66398 + case GR_PSACCT:
66399 + {
66400 + unsigned int wday, cday;
66401 + __u8 whr, chr;
66402 + __u8 wmin, cmin;
66403 + __u8 wsec, csec;
66404 + char cur_tty[64] = { 0 };
66405 + char parent_tty[64] = { 0 };
66406 +
66407 + task = va_arg(ap, struct task_struct *);
66408 + wday = va_arg(ap, unsigned int);
66409 + cday = va_arg(ap, unsigned int);
66410 + whr = va_arg(ap, int);
66411 + chr = va_arg(ap, int);
66412 + wmin = va_arg(ap, int);
66413 + cmin = va_arg(ap, int);
66414 + wsec = va_arg(ap, int);
66415 + csec = va_arg(ap, int);
66416 + ulong1 = va_arg(ap, unsigned long);
66417 + cred = __task_cred(task);
66418 + pcred = __task_cred(task->real_parent);
66419 +
66420 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task_pid_nr(task), &task->signal->curr_ip, tty_name(task->signal->tty, cur_tty), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), wday, whr, wmin, wsec, cday, chr, cmin, csec, (task->flags & PF_SIGNALED) ? "killed by signal" : "exited", ulong1, gr_parent_task_fullpath(task), task->real_parent->comm, task_pid_nr(task->real_parent), &task->real_parent->signal->curr_ip, tty_name(task->real_parent->signal->tty, parent_tty), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
66421 + }
66422 + break;
66423 + default:
66424 + gr_log_middle(audit, msg, ap);
66425 + }
66426 + va_end(ap);
66427 + // these don't need DEFAULTSECARGS printed on the end
66428 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
66429 + gr_log_end(audit, 0);
66430 + else
66431 + gr_log_end(audit, 1);
66432 + END_LOCKS(audit);
66433 +}
66434 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
66435 new file mode 100644
66436 index 0000000..f536303
66437 --- /dev/null
66438 +++ b/grsecurity/grsec_mem.c
66439 @@ -0,0 +1,40 @@
66440 +#include <linux/kernel.h>
66441 +#include <linux/sched.h>
66442 +#include <linux/mm.h>
66443 +#include <linux/mman.h>
66444 +#include <linux/grinternal.h>
66445 +
66446 +void
66447 +gr_handle_ioperm(void)
66448 +{
66449 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
66450 + return;
66451 +}
66452 +
66453 +void
66454 +gr_handle_iopl(void)
66455 +{
66456 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
66457 + return;
66458 +}
66459 +
66460 +void
66461 +gr_handle_mem_readwrite(u64 from, u64 to)
66462 +{
66463 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
66464 + return;
66465 +}
66466 +
66467 +void
66468 +gr_handle_vm86(void)
66469 +{
66470 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
66471 + return;
66472 +}
66473 +
66474 +void
66475 +gr_log_badprocpid(const char *entry)
66476 +{
66477 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
66478 + return;
66479 +}
66480 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
66481 new file mode 100644
66482 index 0000000..2131422
66483 --- /dev/null
66484 +++ b/grsecurity/grsec_mount.c
66485 @@ -0,0 +1,62 @@
66486 +#include <linux/kernel.h>
66487 +#include <linux/sched.h>
66488 +#include <linux/mount.h>
66489 +#include <linux/grsecurity.h>
66490 +#include <linux/grinternal.h>
66491 +
66492 +void
66493 +gr_log_remount(const char *devname, const int retval)
66494 +{
66495 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66496 + if (grsec_enable_mount && (retval >= 0))
66497 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
66498 +#endif
66499 + return;
66500 +}
66501 +
66502 +void
66503 +gr_log_unmount(const char *devname, const int retval)
66504 +{
66505 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66506 + if (grsec_enable_mount && (retval >= 0))
66507 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
66508 +#endif
66509 + return;
66510 +}
66511 +
66512 +void
66513 +gr_log_mount(const char *from, const char *to, const int retval)
66514 +{
66515 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66516 + if (grsec_enable_mount && (retval >= 0))
66517 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
66518 +#endif
66519 + return;
66520 +}
66521 +
66522 +int
66523 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
66524 +{
66525 +#ifdef CONFIG_GRKERNSEC_ROFS
66526 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
66527 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
66528 + return -EPERM;
66529 + } else
66530 + return 0;
66531 +#endif
66532 + return 0;
66533 +}
66534 +
66535 +int
66536 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
66537 +{
66538 +#ifdef CONFIG_GRKERNSEC_ROFS
66539 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
66540 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
66541 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
66542 + return -EPERM;
66543 + } else
66544 + return 0;
66545 +#endif
66546 + return 0;
66547 +}
66548 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
66549 new file mode 100644
66550 index 0000000..6ee9d50
66551 --- /dev/null
66552 +++ b/grsecurity/grsec_pax.c
66553 @@ -0,0 +1,45 @@
66554 +#include <linux/kernel.h>
66555 +#include <linux/sched.h>
66556 +#include <linux/mm.h>
66557 +#include <linux/file.h>
66558 +#include <linux/grinternal.h>
66559 +#include <linux/grsecurity.h>
66560 +
66561 +void
66562 +gr_log_textrel(struct vm_area_struct * vma)
66563 +{
66564 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66565 + if (grsec_enable_log_rwxmaps)
66566 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
66567 +#endif
66568 + return;
66569 +}
66570 +
66571 +void gr_log_ptgnustack(struct file *file)
66572 +{
66573 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66574 + if (grsec_enable_log_rwxmaps)
66575 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
66576 +#endif
66577 + return;
66578 +}
66579 +
66580 +void
66581 +gr_log_rwxmmap(struct file *file)
66582 +{
66583 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66584 + if (grsec_enable_log_rwxmaps)
66585 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
66586 +#endif
66587 + return;
66588 +}
66589 +
66590 +void
66591 +gr_log_rwxmprotect(struct vm_area_struct *vma)
66592 +{
66593 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66594 + if (grsec_enable_log_rwxmaps)
66595 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
66596 +#endif
66597 + return;
66598 +}
66599 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
66600 new file mode 100644
66601 index 0000000..f7f29aa
66602 --- /dev/null
66603 +++ b/grsecurity/grsec_ptrace.c
66604 @@ -0,0 +1,30 @@
66605 +#include <linux/kernel.h>
66606 +#include <linux/sched.h>
66607 +#include <linux/grinternal.h>
66608 +#include <linux/security.h>
66609 +
66610 +void
66611 +gr_audit_ptrace(struct task_struct *task)
66612 +{
66613 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66614 + if (grsec_enable_audit_ptrace)
66615 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
66616 +#endif
66617 + return;
66618 +}
66619 +
66620 +int
66621 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
66622 +{
66623 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66624 + const struct dentry *dentry = file->f_path.dentry;
66625 + const struct vfsmount *mnt = file->f_path.mnt;
66626 +
66627 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
66628 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
66629 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
66630 + return -EACCES;
66631 + }
66632 +#endif
66633 + return 0;
66634 +}
66635 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
66636 new file mode 100644
66637 index 0000000..4e29cc7
66638 --- /dev/null
66639 +++ b/grsecurity/grsec_sig.c
66640 @@ -0,0 +1,246 @@
66641 +#include <linux/kernel.h>
66642 +#include <linux/sched.h>
66643 +#include <linux/fs.h>
66644 +#include <linux/delay.h>
66645 +#include <linux/grsecurity.h>
66646 +#include <linux/grinternal.h>
66647 +#include <linux/hardirq.h>
66648 +
66649 +char *signames[] = {
66650 + [SIGSEGV] = "Segmentation fault",
66651 + [SIGILL] = "Illegal instruction",
66652 + [SIGABRT] = "Abort",
66653 + [SIGBUS] = "Invalid alignment/Bus error"
66654 +};
66655 +
66656 +void
66657 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
66658 +{
66659 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66660 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
66661 + (sig == SIGABRT) || (sig == SIGBUS))) {
66662 + if (task_pid_nr(t) == task_pid_nr(current)) {
66663 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
66664 + } else {
66665 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
66666 + }
66667 + }
66668 +#endif
66669 + return;
66670 +}
66671 +
66672 +int
66673 +gr_handle_signal(const struct task_struct *p, const int sig)
66674 +{
66675 +#ifdef CONFIG_GRKERNSEC
66676 + /* ignore the 0 signal for protected task checks */
66677 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
66678 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
66679 + return -EPERM;
66680 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
66681 + return -EPERM;
66682 + }
66683 +#endif
66684 + return 0;
66685 +}
66686 +
66687 +#ifdef CONFIG_GRKERNSEC
66688 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
66689 +
66690 +int gr_fake_force_sig(int sig, struct task_struct *t)
66691 +{
66692 + unsigned long int flags;
66693 + int ret, blocked, ignored;
66694 + struct k_sigaction *action;
66695 +
66696 + spin_lock_irqsave(&t->sighand->siglock, flags);
66697 + action = &t->sighand->action[sig-1];
66698 + ignored = action->sa.sa_handler == SIG_IGN;
66699 + blocked = sigismember(&t->blocked, sig);
66700 + if (blocked || ignored) {
66701 + action->sa.sa_handler = SIG_DFL;
66702 + if (blocked) {
66703 + sigdelset(&t->blocked, sig);
66704 + recalc_sigpending_and_wake(t);
66705 + }
66706 + }
66707 + if (action->sa.sa_handler == SIG_DFL)
66708 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66709 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66710 +
66711 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66712 +
66713 + return ret;
66714 +}
66715 +#endif
66716 +
66717 +#ifdef CONFIG_GRKERNSEC_BRUTE
66718 +#define GR_USER_BAN_TIME (15 * 60)
66719 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66720 +
66721 +static int __get_dumpable(unsigned long mm_flags)
66722 +{
66723 + int ret;
66724 +
66725 + ret = mm_flags & MMF_DUMPABLE_MASK;
66726 + return (ret >= 2) ? 2 : ret;
66727 +}
66728 +#endif
66729 +
66730 +void gr_handle_brute_attach(unsigned long mm_flags)
66731 +{
66732 +#ifdef CONFIG_GRKERNSEC_BRUTE
66733 + struct task_struct *p = current;
66734 + kuid_t uid = GLOBAL_ROOT_UID;
66735 + int daemon = 0;
66736 +
66737 + if (!grsec_enable_brute)
66738 + return;
66739 +
66740 + rcu_read_lock();
66741 + read_lock(&tasklist_lock);
66742 + read_lock(&grsec_exec_file_lock);
66743 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
66744 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66745 + p->real_parent->brute = 1;
66746 + daemon = 1;
66747 + } else {
66748 + const struct cred *cred = __task_cred(p), *cred2;
66749 + struct task_struct *tsk, *tsk2;
66750 +
66751 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66752 + struct user_struct *user;
66753 +
66754 + uid = cred->uid;
66755 +
66756 + /* this is put upon execution past expiration */
66757 + user = find_user(uid);
66758 + if (user == NULL)
66759 + goto unlock;
66760 + user->suid_banned = 1;
66761 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
66762 + if (user->suid_ban_expires == ~0UL)
66763 + user->suid_ban_expires--;
66764 +
66765 + /* only kill other threads of the same binary, from the same user */
66766 + do_each_thread(tsk2, tsk) {
66767 + cred2 = __task_cred(tsk);
66768 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
66769 + gr_fake_force_sig(SIGKILL, tsk);
66770 + } while_each_thread(tsk2, tsk);
66771 + }
66772 + }
66773 +unlock:
66774 + read_unlock(&grsec_exec_file_lock);
66775 + read_unlock(&tasklist_lock);
66776 + rcu_read_unlock();
66777 +
66778 + if (gr_is_global_nonroot(uid))
66779 + gr_log_fs_int2(GR_DONT_AUDIT, GR_BRUTE_SUID_MSG, p->exec_file->f_path.dentry, p->exec_file->f_path.mnt, GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66780 + else if (daemon)
66781 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66782 +
66783 +#endif
66784 + return;
66785 +}
66786 +
66787 +void gr_handle_brute_check(void)
66788 +{
66789 +#ifdef CONFIG_GRKERNSEC_BRUTE
66790 + struct task_struct *p = current;
66791 +
66792 + if (unlikely(p->brute)) {
66793 + if (!grsec_enable_brute)
66794 + p->brute = 0;
66795 + else if (time_before(get_seconds(), p->brute_expires))
66796 + msleep(30 * 1000);
66797 + }
66798 +#endif
66799 + return;
66800 +}
66801 +
66802 +void gr_handle_kernel_exploit(void)
66803 +{
66804 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66805 + const struct cred *cred;
66806 + struct task_struct *tsk, *tsk2;
66807 + struct user_struct *user;
66808 + kuid_t uid;
66809 +
66810 + if (in_irq() || in_serving_softirq() || in_nmi())
66811 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66812 +
66813 + uid = current_uid();
66814 +
66815 + if (gr_is_global_root(uid))
66816 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66817 + else {
66818 + /* kill all the processes of this user, hold a reference
66819 + to their creds struct, and prevent them from creating
66820 + another process until system reset
66821 + */
66822 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66823 + GR_GLOBAL_UID(uid));
66824 + /* we intentionally leak this ref */
66825 + user = get_uid(current->cred->user);
66826 + if (user)
66827 + user->kernel_banned = 1;
66828 +
66829 + /* kill all processes of this user */
66830 + read_lock(&tasklist_lock);
66831 + do_each_thread(tsk2, tsk) {
66832 + cred = __task_cred(tsk);
66833 + if (uid_eq(cred->uid, uid))
66834 + gr_fake_force_sig(SIGKILL, tsk);
66835 + } while_each_thread(tsk2, tsk);
66836 + read_unlock(&tasklist_lock);
66837 + }
66838 +#endif
66839 +}
66840 +
66841 +#ifdef CONFIG_GRKERNSEC_BRUTE
66842 +static bool suid_ban_expired(struct user_struct *user)
66843 +{
66844 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
66845 + user->suid_banned = 0;
66846 + user->suid_ban_expires = 0;
66847 + free_uid(user);
66848 + return true;
66849 + }
66850 +
66851 + return false;
66852 +}
66853 +#endif
66854 +
66855 +int gr_process_kernel_exec_ban(void)
66856 +{
66857 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66858 + if (unlikely(current->cred->user->kernel_banned))
66859 + return -EPERM;
66860 +#endif
66861 + return 0;
66862 +}
66863 +
66864 +int gr_process_kernel_setuid_ban(struct user_struct *user)
66865 +{
66866 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66867 + if (unlikely(user->kernel_banned))
66868 + gr_fake_force_sig(SIGKILL, current);
66869 +#endif
66870 + return 0;
66871 +}
66872 +
66873 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
66874 +{
66875 +#ifdef CONFIG_GRKERNSEC_BRUTE
66876 + struct user_struct *user = current->cred->user;
66877 + if (unlikely(user->suid_banned)) {
66878 + if (suid_ban_expired(user))
66879 + return 0;
66880 + /* disallow execution of suid binaries only */
66881 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
66882 + return -EPERM;
66883 + }
66884 +#endif
66885 + return 0;
66886 +}
66887 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66888 new file mode 100644
66889 index 0000000..4030d57
66890 --- /dev/null
66891 +++ b/grsecurity/grsec_sock.c
66892 @@ -0,0 +1,244 @@
66893 +#include <linux/kernel.h>
66894 +#include <linux/module.h>
66895 +#include <linux/sched.h>
66896 +#include <linux/file.h>
66897 +#include <linux/net.h>
66898 +#include <linux/in.h>
66899 +#include <linux/ip.h>
66900 +#include <net/sock.h>
66901 +#include <net/inet_sock.h>
66902 +#include <linux/grsecurity.h>
66903 +#include <linux/grinternal.h>
66904 +#include <linux/gracl.h>
66905 +
66906 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66907 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66908 +
66909 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66910 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66911 +
66912 +#ifdef CONFIG_UNIX_MODULE
66913 +EXPORT_SYMBOL(gr_acl_handle_unix);
66914 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66915 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66916 +EXPORT_SYMBOL(gr_handle_create);
66917 +#endif
66918 +
66919 +#ifdef CONFIG_GRKERNSEC
66920 +#define gr_conn_table_size 32749
66921 +struct conn_table_entry {
66922 + struct conn_table_entry *next;
66923 + struct signal_struct *sig;
66924 +};
66925 +
66926 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66927 +DEFINE_SPINLOCK(gr_conn_table_lock);
66928 +
66929 +extern const char * gr_socktype_to_name(unsigned char type);
66930 +extern const char * gr_proto_to_name(unsigned char proto);
66931 +extern const char * gr_sockfamily_to_name(unsigned char family);
66932 +
66933 +static __inline__ int
66934 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66935 +{
66936 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66937 +}
66938 +
66939 +static __inline__ int
66940 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66941 + __u16 sport, __u16 dport)
66942 +{
66943 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66944 + sig->gr_sport == sport && sig->gr_dport == dport))
66945 + return 1;
66946 + else
66947 + return 0;
66948 +}
66949 +
66950 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66951 +{
66952 + struct conn_table_entry **match;
66953 + unsigned int index;
66954 +
66955 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66956 + sig->gr_sport, sig->gr_dport,
66957 + gr_conn_table_size);
66958 +
66959 + newent->sig = sig;
66960 +
66961 + match = &gr_conn_table[index];
66962 + newent->next = *match;
66963 + *match = newent;
66964 +
66965 + return;
66966 +}
66967 +
66968 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66969 +{
66970 + struct conn_table_entry *match, *last = NULL;
66971 + unsigned int index;
66972 +
66973 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66974 + sig->gr_sport, sig->gr_dport,
66975 + gr_conn_table_size);
66976 +
66977 + match = gr_conn_table[index];
66978 + while (match && !conn_match(match->sig,
66979 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66980 + sig->gr_dport)) {
66981 + last = match;
66982 + match = match->next;
66983 + }
66984 +
66985 + if (match) {
66986 + if (last)
66987 + last->next = match->next;
66988 + else
66989 + gr_conn_table[index] = NULL;
66990 + kfree(match);
66991 + }
66992 +
66993 + return;
66994 +}
66995 +
66996 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66997 + __u16 sport, __u16 dport)
66998 +{
66999 + struct conn_table_entry *match;
67000 + unsigned int index;
67001 +
67002 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
67003 +
67004 + match = gr_conn_table[index];
67005 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
67006 + match = match->next;
67007 +
67008 + if (match)
67009 + return match->sig;
67010 + else
67011 + return NULL;
67012 +}
67013 +
67014 +#endif
67015 +
67016 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
67017 +{
67018 +#ifdef CONFIG_GRKERNSEC
67019 + struct signal_struct *sig = task->signal;
67020 + struct conn_table_entry *newent;
67021 +
67022 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
67023 + if (newent == NULL)
67024 + return;
67025 + /* no bh lock needed since we are called with bh disabled */
67026 + spin_lock(&gr_conn_table_lock);
67027 + gr_del_task_from_ip_table_nolock(sig);
67028 + sig->gr_saddr = inet->inet_rcv_saddr;
67029 + sig->gr_daddr = inet->inet_daddr;
67030 + sig->gr_sport = inet->inet_sport;
67031 + sig->gr_dport = inet->inet_dport;
67032 + gr_add_to_task_ip_table_nolock(sig, newent);
67033 + spin_unlock(&gr_conn_table_lock);
67034 +#endif
67035 + return;
67036 +}
67037 +
67038 +void gr_del_task_from_ip_table(struct task_struct *task)
67039 +{
67040 +#ifdef CONFIG_GRKERNSEC
67041 + spin_lock_bh(&gr_conn_table_lock);
67042 + gr_del_task_from_ip_table_nolock(task->signal);
67043 + spin_unlock_bh(&gr_conn_table_lock);
67044 +#endif
67045 + return;
67046 +}
67047 +
67048 +void
67049 +gr_attach_curr_ip(const struct sock *sk)
67050 +{
67051 +#ifdef CONFIG_GRKERNSEC
67052 + struct signal_struct *p, *set;
67053 + const struct inet_sock *inet = inet_sk(sk);
67054 +
67055 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
67056 + return;
67057 +
67058 + set = current->signal;
67059 +
67060 + spin_lock_bh(&gr_conn_table_lock);
67061 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
67062 + inet->inet_dport, inet->inet_sport);
67063 + if (unlikely(p != NULL)) {
67064 + set->curr_ip = p->curr_ip;
67065 + set->used_accept = 1;
67066 + gr_del_task_from_ip_table_nolock(p);
67067 + spin_unlock_bh(&gr_conn_table_lock);
67068 + return;
67069 + }
67070 + spin_unlock_bh(&gr_conn_table_lock);
67071 +
67072 + set->curr_ip = inet->inet_daddr;
67073 + set->used_accept = 1;
67074 +#endif
67075 + return;
67076 +}
67077 +
67078 +int
67079 +gr_handle_sock_all(const int family, const int type, const int protocol)
67080 +{
67081 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
67082 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
67083 + (family != AF_UNIX)) {
67084 + if (family == AF_INET)
67085 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
67086 + else
67087 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
67088 + return -EACCES;
67089 + }
67090 +#endif
67091 + return 0;
67092 +}
67093 +
67094 +int
67095 +gr_handle_sock_server(const struct sockaddr *sck)
67096 +{
67097 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67098 + if (grsec_enable_socket_server &&
67099 + in_group_p(grsec_socket_server_gid) &&
67100 + sck && (sck->sa_family != AF_UNIX) &&
67101 + (sck->sa_family != AF_LOCAL)) {
67102 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
67103 + return -EACCES;
67104 + }
67105 +#endif
67106 + return 0;
67107 +}
67108 +
67109 +int
67110 +gr_handle_sock_server_other(const struct sock *sck)
67111 +{
67112 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67113 + if (grsec_enable_socket_server &&
67114 + in_group_p(grsec_socket_server_gid) &&
67115 + sck && (sck->sk_family != AF_UNIX) &&
67116 + (sck->sk_family != AF_LOCAL)) {
67117 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
67118 + return -EACCES;
67119 + }
67120 +#endif
67121 + return 0;
67122 +}
67123 +
67124 +int
67125 +gr_handle_sock_client(const struct sockaddr *sck)
67126 +{
67127 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
67128 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
67129 + sck && (sck->sa_family != AF_UNIX) &&
67130 + (sck->sa_family != AF_LOCAL)) {
67131 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
67132 + return -EACCES;
67133 + }
67134 +#endif
67135 + return 0;
67136 +}
67137 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
67138 new file mode 100644
67139 index 0000000..7624d1c
67140 --- /dev/null
67141 +++ b/grsecurity/grsec_sysctl.c
67142 @@ -0,0 +1,460 @@
67143 +#include <linux/kernel.h>
67144 +#include <linux/sched.h>
67145 +#include <linux/sysctl.h>
67146 +#include <linux/grsecurity.h>
67147 +#include <linux/grinternal.h>
67148 +
67149 +int
67150 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
67151 +{
67152 +#ifdef CONFIG_GRKERNSEC_SYSCTL
67153 + if (dirname == NULL || name == NULL)
67154 + return 0;
67155 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
67156 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
67157 + return -EACCES;
67158 + }
67159 +#endif
67160 + return 0;
67161 +}
67162 +
67163 +#ifdef CONFIG_GRKERNSEC_ROFS
67164 +static int __maybe_unused one = 1;
67165 +#endif
67166 +
67167 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
67168 +struct ctl_table grsecurity_table[] = {
67169 +#ifdef CONFIG_GRKERNSEC_SYSCTL
67170 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
67171 +#ifdef CONFIG_GRKERNSEC_IO
67172 + {
67173 + .procname = "disable_priv_io",
67174 + .data = &grsec_disable_privio,
67175 + .maxlen = sizeof(int),
67176 + .mode = 0600,
67177 + .proc_handler = &proc_dointvec,
67178 + },
67179 +#endif
67180 +#endif
67181 +#ifdef CONFIG_GRKERNSEC_LINK
67182 + {
67183 + .procname = "linking_restrictions",
67184 + .data = &grsec_enable_link,
67185 + .maxlen = sizeof(int),
67186 + .mode = 0600,
67187 + .proc_handler = &proc_dointvec,
67188 + },
67189 +#endif
67190 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
67191 + {
67192 + .procname = "enforce_symlinksifowner",
67193 + .data = &grsec_enable_symlinkown,
67194 + .maxlen = sizeof(int),
67195 + .mode = 0600,
67196 + .proc_handler = &proc_dointvec,
67197 + },
67198 + {
67199 + .procname = "symlinkown_gid",
67200 + .data = &grsec_symlinkown_gid,
67201 + .maxlen = sizeof(int),
67202 + .mode = 0600,
67203 + .proc_handler = &proc_dointvec,
67204 + },
67205 +#endif
67206 +#ifdef CONFIG_GRKERNSEC_BRUTE
67207 + {
67208 + .procname = "deter_bruteforce",
67209 + .data = &grsec_enable_brute,
67210 + .maxlen = sizeof(int),
67211 + .mode = 0600,
67212 + .proc_handler = &proc_dointvec,
67213 + },
67214 +#endif
67215 +#ifdef CONFIG_GRKERNSEC_FIFO
67216 + {
67217 + .procname = "fifo_restrictions",
67218 + .data = &grsec_enable_fifo,
67219 + .maxlen = sizeof(int),
67220 + .mode = 0600,
67221 + .proc_handler = &proc_dointvec,
67222 + },
67223 +#endif
67224 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
67225 + {
67226 + .procname = "ptrace_readexec",
67227 + .data = &grsec_enable_ptrace_readexec,
67228 + .maxlen = sizeof(int),
67229 + .mode = 0600,
67230 + .proc_handler = &proc_dointvec,
67231 + },
67232 +#endif
67233 +#ifdef CONFIG_GRKERNSEC_SETXID
67234 + {
67235 + .procname = "consistent_setxid",
67236 + .data = &grsec_enable_setxid,
67237 + .maxlen = sizeof(int),
67238 + .mode = 0600,
67239 + .proc_handler = &proc_dointvec,
67240 + },
67241 +#endif
67242 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
67243 + {
67244 + .procname = "ip_blackhole",
67245 + .data = &grsec_enable_blackhole,
67246 + .maxlen = sizeof(int),
67247 + .mode = 0600,
67248 + .proc_handler = &proc_dointvec,
67249 + },
67250 + {
67251 + .procname = "lastack_retries",
67252 + .data = &grsec_lastack_retries,
67253 + .maxlen = sizeof(int),
67254 + .mode = 0600,
67255 + .proc_handler = &proc_dointvec,
67256 + },
67257 +#endif
67258 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67259 + {
67260 + .procname = "exec_logging",
67261 + .data = &grsec_enable_execlog,
67262 + .maxlen = sizeof(int),
67263 + .mode = 0600,
67264 + .proc_handler = &proc_dointvec,
67265 + },
67266 +#endif
67267 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
67268 + {
67269 + .procname = "rwxmap_logging",
67270 + .data = &grsec_enable_log_rwxmaps,
67271 + .maxlen = sizeof(int),
67272 + .mode = 0600,
67273 + .proc_handler = &proc_dointvec,
67274 + },
67275 +#endif
67276 +#ifdef CONFIG_GRKERNSEC_SIGNAL
67277 + {
67278 + .procname = "signal_logging",
67279 + .data = &grsec_enable_signal,
67280 + .maxlen = sizeof(int),
67281 + .mode = 0600,
67282 + .proc_handler = &proc_dointvec,
67283 + },
67284 +#endif
67285 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
67286 + {
67287 + .procname = "forkfail_logging",
67288 + .data = &grsec_enable_forkfail,
67289 + .maxlen = sizeof(int),
67290 + .mode = 0600,
67291 + .proc_handler = &proc_dointvec,
67292 + },
67293 +#endif
67294 +#ifdef CONFIG_GRKERNSEC_TIME
67295 + {
67296 + .procname = "timechange_logging",
67297 + .data = &grsec_enable_time,
67298 + .maxlen = sizeof(int),
67299 + .mode = 0600,
67300 + .proc_handler = &proc_dointvec,
67301 + },
67302 +#endif
67303 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
67304 + {
67305 + .procname = "chroot_deny_shmat",
67306 + .data = &grsec_enable_chroot_shmat,
67307 + .maxlen = sizeof(int),
67308 + .mode = 0600,
67309 + .proc_handler = &proc_dointvec,
67310 + },
67311 +#endif
67312 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
67313 + {
67314 + .procname = "chroot_deny_unix",
67315 + .data = &grsec_enable_chroot_unix,
67316 + .maxlen = sizeof(int),
67317 + .mode = 0600,
67318 + .proc_handler = &proc_dointvec,
67319 + },
67320 +#endif
67321 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
67322 + {
67323 + .procname = "chroot_deny_mount",
67324 + .data = &grsec_enable_chroot_mount,
67325 + .maxlen = sizeof(int),
67326 + .mode = 0600,
67327 + .proc_handler = &proc_dointvec,
67328 + },
67329 +#endif
67330 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
67331 + {
67332 + .procname = "chroot_deny_fchdir",
67333 + .data = &grsec_enable_chroot_fchdir,
67334 + .maxlen = sizeof(int),
67335 + .mode = 0600,
67336 + .proc_handler = &proc_dointvec,
67337 + },
67338 +#endif
67339 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
67340 + {
67341 + .procname = "chroot_deny_chroot",
67342 + .data = &grsec_enable_chroot_double,
67343 + .maxlen = sizeof(int),
67344 + .mode = 0600,
67345 + .proc_handler = &proc_dointvec,
67346 + },
67347 +#endif
67348 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
67349 + {
67350 + .procname = "chroot_deny_pivot",
67351 + .data = &grsec_enable_chroot_pivot,
67352 + .maxlen = sizeof(int),
67353 + .mode = 0600,
67354 + .proc_handler = &proc_dointvec,
67355 + },
67356 +#endif
67357 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
67358 + {
67359 + .procname = "chroot_enforce_chdir",
67360 + .data = &grsec_enable_chroot_chdir,
67361 + .maxlen = sizeof(int),
67362 + .mode = 0600,
67363 + .proc_handler = &proc_dointvec,
67364 + },
67365 +#endif
67366 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
67367 + {
67368 + .procname = "chroot_deny_chmod",
67369 + .data = &grsec_enable_chroot_chmod,
67370 + .maxlen = sizeof(int),
67371 + .mode = 0600,
67372 + .proc_handler = &proc_dointvec,
67373 + },
67374 +#endif
67375 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
67376 + {
67377 + .procname = "chroot_deny_mknod",
67378 + .data = &grsec_enable_chroot_mknod,
67379 + .maxlen = sizeof(int),
67380 + .mode = 0600,
67381 + .proc_handler = &proc_dointvec,
67382 + },
67383 +#endif
67384 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
67385 + {
67386 + .procname = "chroot_restrict_nice",
67387 + .data = &grsec_enable_chroot_nice,
67388 + .maxlen = sizeof(int),
67389 + .mode = 0600,
67390 + .proc_handler = &proc_dointvec,
67391 + },
67392 +#endif
67393 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
67394 + {
67395 + .procname = "chroot_execlog",
67396 + .data = &grsec_enable_chroot_execlog,
67397 + .maxlen = sizeof(int),
67398 + .mode = 0600,
67399 + .proc_handler = &proc_dointvec,
67400 + },
67401 +#endif
67402 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67403 + {
67404 + .procname = "chroot_caps",
67405 + .data = &grsec_enable_chroot_caps,
67406 + .maxlen = sizeof(int),
67407 + .mode = 0600,
67408 + .proc_handler = &proc_dointvec,
67409 + },
67410 +#endif
67411 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
67412 + {
67413 + .procname = "chroot_deny_sysctl",
67414 + .data = &grsec_enable_chroot_sysctl,
67415 + .maxlen = sizeof(int),
67416 + .mode = 0600,
67417 + .proc_handler = &proc_dointvec,
67418 + },
67419 +#endif
67420 +#ifdef CONFIG_GRKERNSEC_TPE
67421 + {
67422 + .procname = "tpe",
67423 + .data = &grsec_enable_tpe,
67424 + .maxlen = sizeof(int),
67425 + .mode = 0600,
67426 + .proc_handler = &proc_dointvec,
67427 + },
67428 + {
67429 + .procname = "tpe_gid",
67430 + .data = &grsec_tpe_gid,
67431 + .maxlen = sizeof(int),
67432 + .mode = 0600,
67433 + .proc_handler = &proc_dointvec,
67434 + },
67435 +#endif
67436 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67437 + {
67438 + .procname = "tpe_invert",
67439 + .data = &grsec_enable_tpe_invert,
67440 + .maxlen = sizeof(int),
67441 + .mode = 0600,
67442 + .proc_handler = &proc_dointvec,
67443 + },
67444 +#endif
67445 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67446 + {
67447 + .procname = "tpe_restrict_all",
67448 + .data = &grsec_enable_tpe_all,
67449 + .maxlen = sizeof(int),
67450 + .mode = 0600,
67451 + .proc_handler = &proc_dointvec,
67452 + },
67453 +#endif
67454 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
67455 + {
67456 + .procname = "socket_all",
67457 + .data = &grsec_enable_socket_all,
67458 + .maxlen = sizeof(int),
67459 + .mode = 0600,
67460 + .proc_handler = &proc_dointvec,
67461 + },
67462 + {
67463 + .procname = "socket_all_gid",
67464 + .data = &grsec_socket_all_gid,
67465 + .maxlen = sizeof(int),
67466 + .mode = 0600,
67467 + .proc_handler = &proc_dointvec,
67468 + },
67469 +#endif
67470 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
67471 + {
67472 + .procname = "socket_client",
67473 + .data = &grsec_enable_socket_client,
67474 + .maxlen = sizeof(int),
67475 + .mode = 0600,
67476 + .proc_handler = &proc_dointvec,
67477 + },
67478 + {
67479 + .procname = "socket_client_gid",
67480 + .data = &grsec_socket_client_gid,
67481 + .maxlen = sizeof(int),
67482 + .mode = 0600,
67483 + .proc_handler = &proc_dointvec,
67484 + },
67485 +#endif
67486 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67487 + {
67488 + .procname = "socket_server",
67489 + .data = &grsec_enable_socket_server,
67490 + .maxlen = sizeof(int),
67491 + .mode = 0600,
67492 + .proc_handler = &proc_dointvec,
67493 + },
67494 + {
67495 + .procname = "socket_server_gid",
67496 + .data = &grsec_socket_server_gid,
67497 + .maxlen = sizeof(int),
67498 + .mode = 0600,
67499 + .proc_handler = &proc_dointvec,
67500 + },
67501 +#endif
67502 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
67503 + {
67504 + .procname = "audit_group",
67505 + .data = &grsec_enable_group,
67506 + .maxlen = sizeof(int),
67507 + .mode = 0600,
67508 + .proc_handler = &proc_dointvec,
67509 + },
67510 + {
67511 + .procname = "audit_gid",
67512 + .data = &grsec_audit_gid,
67513 + .maxlen = sizeof(int),
67514 + .mode = 0600,
67515 + .proc_handler = &proc_dointvec,
67516 + },
67517 +#endif
67518 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
67519 + {
67520 + .procname = "audit_chdir",
67521 + .data = &grsec_enable_chdir,
67522 + .maxlen = sizeof(int),
67523 + .mode = 0600,
67524 + .proc_handler = &proc_dointvec,
67525 + },
67526 +#endif
67527 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
67528 + {
67529 + .procname = "audit_mount",
67530 + .data = &grsec_enable_mount,
67531 + .maxlen = sizeof(int),
67532 + .mode = 0600,
67533 + .proc_handler = &proc_dointvec,
67534 + },
67535 +#endif
67536 +#ifdef CONFIG_GRKERNSEC_DMESG
67537 + {
67538 + .procname = "dmesg",
67539 + .data = &grsec_enable_dmesg,
67540 + .maxlen = sizeof(int),
67541 + .mode = 0600,
67542 + .proc_handler = &proc_dointvec,
67543 + },
67544 +#endif
67545 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
67546 + {
67547 + .procname = "chroot_findtask",
67548 + .data = &grsec_enable_chroot_findtask,
67549 + .maxlen = sizeof(int),
67550 + .mode = 0600,
67551 + .proc_handler = &proc_dointvec,
67552 + },
67553 +#endif
67554 +#ifdef CONFIG_GRKERNSEC_RESLOG
67555 + {
67556 + .procname = "resource_logging",
67557 + .data = &grsec_resource_logging,
67558 + .maxlen = sizeof(int),
67559 + .mode = 0600,
67560 + .proc_handler = &proc_dointvec,
67561 + },
67562 +#endif
67563 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
67564 + {
67565 + .procname = "audit_ptrace",
67566 + .data = &grsec_enable_audit_ptrace,
67567 + .maxlen = sizeof(int),
67568 + .mode = 0600,
67569 + .proc_handler = &proc_dointvec,
67570 + },
67571 +#endif
67572 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67573 + {
67574 + .procname = "harden_ptrace",
67575 + .data = &grsec_enable_harden_ptrace,
67576 + .maxlen = sizeof(int),
67577 + .mode = 0600,
67578 + .proc_handler = &proc_dointvec,
67579 + },
67580 +#endif
67581 + {
67582 + .procname = "grsec_lock",
67583 + .data = &grsec_lock,
67584 + .maxlen = sizeof(int),
67585 + .mode = 0600,
67586 + .proc_handler = &proc_dointvec,
67587 + },
67588 +#endif
67589 +#ifdef CONFIG_GRKERNSEC_ROFS
67590 + {
67591 + .procname = "romount_protect",
67592 + .data = &grsec_enable_rofs,
67593 + .maxlen = sizeof(int),
67594 + .mode = 0600,
67595 + .proc_handler = &proc_dointvec_minmax,
67596 + .extra1 = &one,
67597 + .extra2 = &one,
67598 + },
67599 +#endif
67600 + { }
67601 +};
67602 +#endif
67603 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
67604 new file mode 100644
67605 index 0000000..0dc13c3
67606 --- /dev/null
67607 +++ b/grsecurity/grsec_time.c
67608 @@ -0,0 +1,16 @@
67609 +#include <linux/kernel.h>
67610 +#include <linux/sched.h>
67611 +#include <linux/grinternal.h>
67612 +#include <linux/module.h>
67613 +
67614 +void
67615 +gr_log_timechange(void)
67616 +{
67617 +#ifdef CONFIG_GRKERNSEC_TIME
67618 + if (grsec_enable_time)
67619 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
67620 +#endif
67621 + return;
67622 +}
67623 +
67624 +EXPORT_SYMBOL(gr_log_timechange);
67625 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
67626 new file mode 100644
67627 index 0000000..ee57dcf
67628 --- /dev/null
67629 +++ b/grsecurity/grsec_tpe.c
67630 @@ -0,0 +1,73 @@
67631 +#include <linux/kernel.h>
67632 +#include <linux/sched.h>
67633 +#include <linux/file.h>
67634 +#include <linux/fs.h>
67635 +#include <linux/grinternal.h>
67636 +
67637 +extern int gr_acl_tpe_check(void);
67638 +
67639 +int
67640 +gr_tpe_allow(const struct file *file)
67641 +{
67642 +#ifdef CONFIG_GRKERNSEC
67643 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
67644 + const struct cred *cred = current_cred();
67645 + char *msg = NULL;
67646 + char *msg2 = NULL;
67647 +
67648 + // never restrict root
67649 + if (gr_is_global_root(cred->uid))
67650 + return 1;
67651 +
67652 + if (grsec_enable_tpe) {
67653 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67654 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
67655 + msg = "not being in trusted group";
67656 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
67657 + msg = "being in untrusted group";
67658 +#else
67659 + if (in_group_p(grsec_tpe_gid))
67660 + msg = "being in untrusted group";
67661 +#endif
67662 + }
67663 + if (!msg && gr_acl_tpe_check())
67664 + msg = "being in untrusted role";
67665 +
67666 + // not in any affected group/role
67667 + if (!msg)
67668 + goto next_check;
67669 +
67670 + if (gr_is_global_nonroot(inode->i_uid))
67671 + msg2 = "file in non-root-owned directory";
67672 + else if (inode->i_mode & S_IWOTH)
67673 + msg2 = "file in world-writable directory";
67674 + else if (inode->i_mode & S_IWGRP)
67675 + msg2 = "file in group-writable directory";
67676 +
67677 + if (msg && msg2) {
67678 + char fullmsg[70] = {0};
67679 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
67680 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
67681 + return 0;
67682 + }
67683 + msg = NULL;
67684 +next_check:
67685 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67686 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
67687 + return 1;
67688 +
67689 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
67690 + msg = "directory not owned by user";
67691 + else if (inode->i_mode & S_IWOTH)
67692 + msg = "file in world-writable directory";
67693 + else if (inode->i_mode & S_IWGRP)
67694 + msg = "file in group-writable directory";
67695 +
67696 + if (msg) {
67697 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
67698 + return 0;
67699 + }
67700 +#endif
67701 +#endif
67702 + return 1;
67703 +}
67704 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67705 new file mode 100644
67706 index 0000000..9f7b1ac
67707 --- /dev/null
67708 +++ b/grsecurity/grsum.c
67709 @@ -0,0 +1,61 @@
67710 +#include <linux/err.h>
67711 +#include <linux/kernel.h>
67712 +#include <linux/sched.h>
67713 +#include <linux/mm.h>
67714 +#include <linux/scatterlist.h>
67715 +#include <linux/crypto.h>
67716 +#include <linux/gracl.h>
67717 +
67718 +
67719 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67720 +#error "crypto and sha256 must be built into the kernel"
67721 +#endif
67722 +
67723 +int
67724 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67725 +{
67726 + char *p;
67727 + struct crypto_hash *tfm;
67728 + struct hash_desc desc;
67729 + struct scatterlist sg;
67730 + unsigned char temp_sum[GR_SHA_LEN];
67731 + volatile int retval = 0;
67732 + volatile int dummy = 0;
67733 + unsigned int i;
67734 +
67735 + sg_init_table(&sg, 1);
67736 +
67737 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67738 + if (IS_ERR(tfm)) {
67739 + /* should never happen, since sha256 should be built in */
67740 + return 1;
67741 + }
67742 +
67743 + desc.tfm = tfm;
67744 + desc.flags = 0;
67745 +
67746 + crypto_hash_init(&desc);
67747 +
67748 + p = salt;
67749 + sg_set_buf(&sg, p, GR_SALT_LEN);
67750 + crypto_hash_update(&desc, &sg, sg.length);
67751 +
67752 + p = entry->pw;
67753 + sg_set_buf(&sg, p, strlen(p));
67754 +
67755 + crypto_hash_update(&desc, &sg, sg.length);
67756 +
67757 + crypto_hash_final(&desc, temp_sum);
67758 +
67759 + memset(entry->pw, 0, GR_PW_LEN);
67760 +
67761 + for (i = 0; i < GR_SHA_LEN; i++)
67762 + if (sum[i] != temp_sum[i])
67763 + retval = 1;
67764 + else
67765 + dummy = 1; // waste a cycle
67766 +
67767 + crypto_free_hash(tfm);
67768 +
67769 + return retval;
67770 +}
67771 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67772 index 77ff547..181834f 100644
67773 --- a/include/asm-generic/4level-fixup.h
67774 +++ b/include/asm-generic/4level-fixup.h
67775 @@ -13,8 +13,10 @@
67776 #define pmd_alloc(mm, pud, address) \
67777 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67778 NULL: pmd_offset(pud, address))
67779 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67780
67781 #define pud_alloc(mm, pgd, address) (pgd)
67782 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67783 #define pud_offset(pgd, start) (pgd)
67784 #define pud_none(pud) 0
67785 #define pud_bad(pud) 0
67786 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67787 index b7babf0..04ad282 100644
67788 --- a/include/asm-generic/atomic-long.h
67789 +++ b/include/asm-generic/atomic-long.h
67790 @@ -22,6 +22,12 @@
67791
67792 typedef atomic64_t atomic_long_t;
67793
67794 +#ifdef CONFIG_PAX_REFCOUNT
67795 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67796 +#else
67797 +typedef atomic64_t atomic_long_unchecked_t;
67798 +#endif
67799 +
67800 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67801
67802 static inline long atomic_long_read(atomic_long_t *l)
67803 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67804 return (long)atomic64_read(v);
67805 }
67806
67807 +#ifdef CONFIG_PAX_REFCOUNT
67808 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67809 +{
67810 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67811 +
67812 + return (long)atomic64_read_unchecked(v);
67813 +}
67814 +#endif
67815 +
67816 static inline void atomic_long_set(atomic_long_t *l, long i)
67817 {
67818 atomic64_t *v = (atomic64_t *)l;
67819 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67820 atomic64_set(v, i);
67821 }
67822
67823 +#ifdef CONFIG_PAX_REFCOUNT
67824 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67825 +{
67826 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67827 +
67828 + atomic64_set_unchecked(v, i);
67829 +}
67830 +#endif
67831 +
67832 static inline void atomic_long_inc(atomic_long_t *l)
67833 {
67834 atomic64_t *v = (atomic64_t *)l;
67835 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67836 atomic64_inc(v);
67837 }
67838
67839 +#ifdef CONFIG_PAX_REFCOUNT
67840 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67841 +{
67842 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67843 +
67844 + atomic64_inc_unchecked(v);
67845 +}
67846 +#endif
67847 +
67848 static inline void atomic_long_dec(atomic_long_t *l)
67849 {
67850 atomic64_t *v = (atomic64_t *)l;
67851 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67852 atomic64_dec(v);
67853 }
67854
67855 +#ifdef CONFIG_PAX_REFCOUNT
67856 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67857 +{
67858 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67859 +
67860 + atomic64_dec_unchecked(v);
67861 +}
67862 +#endif
67863 +
67864 static inline void atomic_long_add(long i, atomic_long_t *l)
67865 {
67866 atomic64_t *v = (atomic64_t *)l;
67867 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67868 atomic64_add(i, v);
67869 }
67870
67871 +#ifdef CONFIG_PAX_REFCOUNT
67872 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67873 +{
67874 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67875 +
67876 + atomic64_add_unchecked(i, v);
67877 +}
67878 +#endif
67879 +
67880 static inline void atomic_long_sub(long i, atomic_long_t *l)
67881 {
67882 atomic64_t *v = (atomic64_t *)l;
67883 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67884 atomic64_sub(i, v);
67885 }
67886
67887 +#ifdef CONFIG_PAX_REFCOUNT
67888 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67889 +{
67890 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67891 +
67892 + atomic64_sub_unchecked(i, v);
67893 +}
67894 +#endif
67895 +
67896 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67897 {
67898 atomic64_t *v = (atomic64_t *)l;
67899 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67900 return (long)atomic64_add_return(i, v);
67901 }
67902
67903 +#ifdef CONFIG_PAX_REFCOUNT
67904 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67905 +{
67906 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67907 +
67908 + return (long)atomic64_add_return_unchecked(i, v);
67909 +}
67910 +#endif
67911 +
67912 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67913 {
67914 atomic64_t *v = (atomic64_t *)l;
67915 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67916 return (long)atomic64_inc_return(v);
67917 }
67918
67919 +#ifdef CONFIG_PAX_REFCOUNT
67920 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67921 +{
67922 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67923 +
67924 + return (long)atomic64_inc_return_unchecked(v);
67925 +}
67926 +#endif
67927 +
67928 static inline long atomic_long_dec_return(atomic_long_t *l)
67929 {
67930 atomic64_t *v = (atomic64_t *)l;
67931 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67932
67933 typedef atomic_t atomic_long_t;
67934
67935 +#ifdef CONFIG_PAX_REFCOUNT
67936 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67937 +#else
67938 +typedef atomic_t atomic_long_unchecked_t;
67939 +#endif
67940 +
67941 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67942 static inline long atomic_long_read(atomic_long_t *l)
67943 {
67944 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67945 return (long)atomic_read(v);
67946 }
67947
67948 +#ifdef CONFIG_PAX_REFCOUNT
67949 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67950 +{
67951 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67952 +
67953 + return (long)atomic_read_unchecked(v);
67954 +}
67955 +#endif
67956 +
67957 static inline void atomic_long_set(atomic_long_t *l, long i)
67958 {
67959 atomic_t *v = (atomic_t *)l;
67960 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67961 atomic_set(v, i);
67962 }
67963
67964 +#ifdef CONFIG_PAX_REFCOUNT
67965 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67966 +{
67967 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67968 +
67969 + atomic_set_unchecked(v, i);
67970 +}
67971 +#endif
67972 +
67973 static inline void atomic_long_inc(atomic_long_t *l)
67974 {
67975 atomic_t *v = (atomic_t *)l;
67976 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67977 atomic_inc(v);
67978 }
67979
67980 +#ifdef CONFIG_PAX_REFCOUNT
67981 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67982 +{
67983 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67984 +
67985 + atomic_inc_unchecked(v);
67986 +}
67987 +#endif
67988 +
67989 static inline void atomic_long_dec(atomic_long_t *l)
67990 {
67991 atomic_t *v = (atomic_t *)l;
67992 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67993 atomic_dec(v);
67994 }
67995
67996 +#ifdef CONFIG_PAX_REFCOUNT
67997 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67998 +{
67999 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68000 +
68001 + atomic_dec_unchecked(v);
68002 +}
68003 +#endif
68004 +
68005 static inline void atomic_long_add(long i, atomic_long_t *l)
68006 {
68007 atomic_t *v = (atomic_t *)l;
68008 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
68009 atomic_add(i, v);
68010 }
68011
68012 +#ifdef CONFIG_PAX_REFCOUNT
68013 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
68014 +{
68015 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68016 +
68017 + atomic_add_unchecked(i, v);
68018 +}
68019 +#endif
68020 +
68021 static inline void atomic_long_sub(long i, atomic_long_t *l)
68022 {
68023 atomic_t *v = (atomic_t *)l;
68024 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
68025 atomic_sub(i, v);
68026 }
68027
68028 +#ifdef CONFIG_PAX_REFCOUNT
68029 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
68030 +{
68031 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68032 +
68033 + atomic_sub_unchecked(i, v);
68034 +}
68035 +#endif
68036 +
68037 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
68038 {
68039 atomic_t *v = (atomic_t *)l;
68040 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
68041 return (long)atomic_add_return(i, v);
68042 }
68043
68044 +#ifdef CONFIG_PAX_REFCOUNT
68045 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
68046 +{
68047 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68048 +
68049 + return (long)atomic_add_return_unchecked(i, v);
68050 +}
68051 +
68052 +#endif
68053 +
68054 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
68055 {
68056 atomic_t *v = (atomic_t *)l;
68057 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
68058 return (long)atomic_inc_return(v);
68059 }
68060
68061 +#ifdef CONFIG_PAX_REFCOUNT
68062 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
68063 +{
68064 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68065 +
68066 + return (long)atomic_inc_return_unchecked(v);
68067 +}
68068 +#endif
68069 +
68070 static inline long atomic_long_dec_return(atomic_long_t *l)
68071 {
68072 atomic_t *v = (atomic_t *)l;
68073 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
68074
68075 #endif /* BITS_PER_LONG == 64 */
68076
68077 +#ifdef CONFIG_PAX_REFCOUNT
68078 +static inline void pax_refcount_needs_these_functions(void)
68079 +{
68080 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
68081 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
68082 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
68083 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
68084 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
68085 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
68086 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
68087 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
68088 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
68089 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
68090 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
68091 +#ifdef CONFIG_X86
68092 + atomic_clear_mask_unchecked(0, NULL);
68093 + atomic_set_mask_unchecked(0, NULL);
68094 +#endif
68095 +
68096 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
68097 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
68098 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
68099 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
68100 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
68101 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
68102 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
68103 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
68104 +}
68105 +#else
68106 +#define atomic_read_unchecked(v) atomic_read(v)
68107 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
68108 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
68109 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
68110 +#define atomic_inc_unchecked(v) atomic_inc(v)
68111 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
68112 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
68113 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
68114 +#define atomic_dec_unchecked(v) atomic_dec(v)
68115 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
68116 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
68117 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
68118 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
68119 +
68120 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
68121 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
68122 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
68123 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
68124 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
68125 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
68126 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
68127 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
68128 +#endif
68129 +
68130 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
68131 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
68132 index 33bd2de..f31bff97 100644
68133 --- a/include/asm-generic/atomic.h
68134 +++ b/include/asm-generic/atomic.h
68135 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
68136 * Atomically clears the bits set in @mask from @v
68137 */
68138 #ifndef atomic_clear_mask
68139 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
68140 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
68141 {
68142 unsigned long flags;
68143
68144 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
68145 index b18ce4f..2ee2843 100644
68146 --- a/include/asm-generic/atomic64.h
68147 +++ b/include/asm-generic/atomic64.h
68148 @@ -16,6 +16,8 @@ typedef struct {
68149 long long counter;
68150 } atomic64_t;
68151
68152 +typedef atomic64_t atomic64_unchecked_t;
68153 +
68154 #define ATOMIC64_INIT(i) { (i) }
68155
68156 extern long long atomic64_read(const atomic64_t *v);
68157 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
68158 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
68159 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
68160
68161 +#define atomic64_read_unchecked(v) atomic64_read(v)
68162 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
68163 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
68164 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
68165 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
68166 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
68167 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
68168 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
68169 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
68170 +
68171 #endif /* _ASM_GENERIC_ATOMIC64_H */
68172 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
68173 index 1bfcfe5..e04c5c9 100644
68174 --- a/include/asm-generic/cache.h
68175 +++ b/include/asm-generic/cache.h
68176 @@ -6,7 +6,7 @@
68177 * cache lines need to provide their own cache.h.
68178 */
68179
68180 -#define L1_CACHE_SHIFT 5
68181 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
68182 +#define L1_CACHE_SHIFT 5UL
68183 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
68184
68185 #endif /* __ASM_GENERIC_CACHE_H */
68186 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
68187 index 0d68a1e..b74a761 100644
68188 --- a/include/asm-generic/emergency-restart.h
68189 +++ b/include/asm-generic/emergency-restart.h
68190 @@ -1,7 +1,7 @@
68191 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
68192 #define _ASM_GENERIC_EMERGENCY_RESTART_H
68193
68194 -static inline void machine_emergency_restart(void)
68195 +static inline __noreturn void machine_emergency_restart(void)
68196 {
68197 machine_restart(NULL);
68198 }
68199 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
68200 index 90f99c7..00ce236 100644
68201 --- a/include/asm-generic/kmap_types.h
68202 +++ b/include/asm-generic/kmap_types.h
68203 @@ -2,9 +2,9 @@
68204 #define _ASM_GENERIC_KMAP_TYPES_H
68205
68206 #ifdef __WITH_KM_FENCE
68207 -# define KM_TYPE_NR 41
68208 +# define KM_TYPE_NR 42
68209 #else
68210 -# define KM_TYPE_NR 20
68211 +# define KM_TYPE_NR 21
68212 #endif
68213
68214 #endif
68215 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
68216 index 9ceb03b..62b0b8f 100644
68217 --- a/include/asm-generic/local.h
68218 +++ b/include/asm-generic/local.h
68219 @@ -23,24 +23,37 @@ typedef struct
68220 atomic_long_t a;
68221 } local_t;
68222
68223 +typedef struct {
68224 + atomic_long_unchecked_t a;
68225 +} local_unchecked_t;
68226 +
68227 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
68228
68229 #define local_read(l) atomic_long_read(&(l)->a)
68230 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
68231 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
68232 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
68233 #define local_inc(l) atomic_long_inc(&(l)->a)
68234 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
68235 #define local_dec(l) atomic_long_dec(&(l)->a)
68236 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
68237 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
68238 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
68239 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
68240 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
68241
68242 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
68243 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
68244 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
68245 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
68246 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
68247 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
68248 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
68249 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
68250 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
68251
68252 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
68253 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
68254 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
68255 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
68256 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
68257 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
68258 index 725612b..9cc513a 100644
68259 --- a/include/asm-generic/pgtable-nopmd.h
68260 +++ b/include/asm-generic/pgtable-nopmd.h
68261 @@ -1,14 +1,19 @@
68262 #ifndef _PGTABLE_NOPMD_H
68263 #define _PGTABLE_NOPMD_H
68264
68265 -#ifndef __ASSEMBLY__
68266 -
68267 #include <asm-generic/pgtable-nopud.h>
68268
68269 -struct mm_struct;
68270 -
68271 #define __PAGETABLE_PMD_FOLDED
68272
68273 +#define PMD_SHIFT PUD_SHIFT
68274 +#define PTRS_PER_PMD 1
68275 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
68276 +#define PMD_MASK (~(PMD_SIZE-1))
68277 +
68278 +#ifndef __ASSEMBLY__
68279 +
68280 +struct mm_struct;
68281 +
68282 /*
68283 * Having the pmd type consist of a pud gets the size right, and allows
68284 * us to conceptually access the pud entry that this pmd is folded into
68285 @@ -16,11 +21,6 @@ struct mm_struct;
68286 */
68287 typedef struct { pud_t pud; } pmd_t;
68288
68289 -#define PMD_SHIFT PUD_SHIFT
68290 -#define PTRS_PER_PMD 1
68291 -#define PMD_SIZE (1UL << PMD_SHIFT)
68292 -#define PMD_MASK (~(PMD_SIZE-1))
68293 -
68294 /*
68295 * The "pud_xxx()" functions here are trivial for a folded two-level
68296 * setup: the pmd is never bad, and a pmd always exists (as it's folded
68297 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
68298 index 810431d..0ec4804f 100644
68299 --- a/include/asm-generic/pgtable-nopud.h
68300 +++ b/include/asm-generic/pgtable-nopud.h
68301 @@ -1,10 +1,15 @@
68302 #ifndef _PGTABLE_NOPUD_H
68303 #define _PGTABLE_NOPUD_H
68304
68305 -#ifndef __ASSEMBLY__
68306 -
68307 #define __PAGETABLE_PUD_FOLDED
68308
68309 +#define PUD_SHIFT PGDIR_SHIFT
68310 +#define PTRS_PER_PUD 1
68311 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
68312 +#define PUD_MASK (~(PUD_SIZE-1))
68313 +
68314 +#ifndef __ASSEMBLY__
68315 +
68316 /*
68317 * Having the pud type consist of a pgd gets the size right, and allows
68318 * us to conceptually access the pgd entry that this pud is folded into
68319 @@ -12,11 +17,6 @@
68320 */
68321 typedef struct { pgd_t pgd; } pud_t;
68322
68323 -#define PUD_SHIFT PGDIR_SHIFT
68324 -#define PTRS_PER_PUD 1
68325 -#define PUD_SIZE (1UL << PUD_SHIFT)
68326 -#define PUD_MASK (~(PUD_SIZE-1))
68327 -
68328 /*
68329 * The "pgd_xxx()" functions here are trivial for a folded two-level
68330 * setup: the pud is never bad, and a pud always exists (as it's folded
68331 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
68332 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
68333
68334 #define pgd_populate(mm, pgd, pud) do { } while (0)
68335 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
68336 /*
68337 * (puds are folded into pgds so this doesn't get actually called,
68338 * but the define is needed for a generic inline function.)
68339 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
68340 index a59ff51..2594a70 100644
68341 --- a/include/asm-generic/pgtable.h
68342 +++ b/include/asm-generic/pgtable.h
68343 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
68344 }
68345 #endif /* CONFIG_NUMA_BALANCING */
68346
68347 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
68348 +static inline unsigned long pax_open_kernel(void) { return 0; }
68349 +#endif
68350 +
68351 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
68352 +static inline unsigned long pax_close_kernel(void) { return 0; }
68353 +#endif
68354 +
68355 #endif /* CONFIG_MMU */
68356
68357 #endif /* !__ASSEMBLY__ */
68358 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
68359 index eb58d2d..df131bf 100644
68360 --- a/include/asm-generic/vmlinux.lds.h
68361 +++ b/include/asm-generic/vmlinux.lds.h
68362 @@ -239,6 +239,7 @@
68363 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
68364 VMLINUX_SYMBOL(__start_rodata) = .; \
68365 *(.rodata) *(.rodata.*) \
68366 + *(.data..read_only) \
68367 *(__vermagic) /* Kernel version magic */ \
68368 . = ALIGN(8); \
68369 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
68370 @@ -749,17 +750,18 @@
68371 * section in the linker script will go there too. @phdr should have
68372 * a leading colon.
68373 *
68374 - * Note that this macros defines __per_cpu_load as an absolute symbol.
68375 + * Note that this macros defines per_cpu_load as an absolute symbol.
68376 * If there is no need to put the percpu section at a predetermined
68377 * address, use PERCPU_SECTION.
68378 */
68379 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
68380 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
68381 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
68382 + per_cpu_load = .; \
68383 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
68384 - LOAD_OFFSET) { \
68385 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
68386 PERCPU_INPUT(cacheline) \
68387 } phdr \
68388 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
68389 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
68390
68391 /**
68392 * PERCPU_SECTION - define output section for percpu area, simple version
68393 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
68394 index 418d270..bfd2794 100644
68395 --- a/include/crypto/algapi.h
68396 +++ b/include/crypto/algapi.h
68397 @@ -34,7 +34,7 @@ struct crypto_type {
68398 unsigned int maskclear;
68399 unsigned int maskset;
68400 unsigned int tfmsize;
68401 -};
68402 +} __do_const;
68403
68404 struct crypto_instance {
68405 struct crypto_alg alg;
68406 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
68407 index 63d17ee..716de2b 100644
68408 --- a/include/drm/drmP.h
68409 +++ b/include/drm/drmP.h
68410 @@ -72,6 +72,7 @@
68411 #include <linux/workqueue.h>
68412 #include <linux/poll.h>
68413 #include <asm/pgalloc.h>
68414 +#include <asm/local.h>
68415 #include <drm/drm.h>
68416 #include <drm/drm_sarea.h>
68417
68418 @@ -296,10 +297,12 @@ do { \
68419 * \param cmd command.
68420 * \param arg argument.
68421 */
68422 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
68423 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
68424 + struct drm_file *file_priv);
68425 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
68426 struct drm_file *file_priv);
68427
68428 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
68429 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
68430 unsigned long arg);
68431
68432 #define DRM_IOCTL_NR(n) _IOC_NR(n)
68433 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
68434 struct drm_ioctl_desc {
68435 unsigned int cmd;
68436 int flags;
68437 - drm_ioctl_t *func;
68438 + drm_ioctl_t func;
68439 unsigned int cmd_drv;
68440 const char *name;
68441 -};
68442 +} __do_const;
68443
68444 /**
68445 * Creates a driver or general drm_ioctl_desc array entry for the given
68446 @@ -1015,7 +1018,7 @@ struct drm_info_list {
68447 int (*show)(struct seq_file*, void*); /** show callback */
68448 u32 driver_features; /**< Required driver features for this entry */
68449 void *data;
68450 -};
68451 +} __do_const;
68452
68453 /**
68454 * debugfs node structure. This structure represents a debugfs file.
68455 @@ -1088,7 +1091,7 @@ struct drm_device {
68456
68457 /** \name Usage Counters */
68458 /*@{ */
68459 - int open_count; /**< Outstanding files open */
68460 + local_t open_count; /**< Outstanding files open */
68461 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
68462 atomic_t vma_count; /**< Outstanding vma areas open */
68463 int buf_use; /**< Buffers in use -- cannot alloc */
68464 @@ -1099,7 +1102,7 @@ struct drm_device {
68465 /*@{ */
68466 unsigned long counters;
68467 enum drm_stat_type types[15];
68468 - atomic_t counts[15];
68469 + atomic_unchecked_t counts[15];
68470 /*@} */
68471
68472 struct list_head filelist;
68473 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
68474 index f43d556..94d9343 100644
68475 --- a/include/drm/drm_crtc_helper.h
68476 +++ b/include/drm/drm_crtc_helper.h
68477 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
68478 struct drm_connector *connector);
68479 /* disable encoder when not in use - more explicit than dpms off */
68480 void (*disable)(struct drm_encoder *encoder);
68481 -};
68482 +} __no_const;
68483
68484 /**
68485 * drm_connector_helper_funcs - helper operations for connectors
68486 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
68487 index 72dcbe8..8db58d7 100644
68488 --- a/include/drm/ttm/ttm_memory.h
68489 +++ b/include/drm/ttm/ttm_memory.h
68490 @@ -48,7 +48,7 @@
68491
68492 struct ttm_mem_shrink {
68493 int (*do_shrink) (struct ttm_mem_shrink *);
68494 -};
68495 +} __no_const;
68496
68497 /**
68498 * struct ttm_mem_global - Global memory accounting structure.
68499 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
68500 index 4b840e8..155d235 100644
68501 --- a/include/keys/asymmetric-subtype.h
68502 +++ b/include/keys/asymmetric-subtype.h
68503 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
68504 /* Verify the signature on a key of this subtype (optional) */
68505 int (*verify_signature)(const struct key *key,
68506 const struct public_key_signature *sig);
68507 -};
68508 +} __do_const;
68509
68510 /**
68511 * asymmetric_key_subtype - Get the subtype from an asymmetric key
68512 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
68513 index c1da539..1dcec55 100644
68514 --- a/include/linux/atmdev.h
68515 +++ b/include/linux/atmdev.h
68516 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
68517 #endif
68518
68519 struct k_atm_aal_stats {
68520 -#define __HANDLE_ITEM(i) atomic_t i
68521 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
68522 __AAL_STAT_ITEMS
68523 #undef __HANDLE_ITEM
68524 };
68525 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
68526 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
68527 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
68528 struct module *owner;
68529 -};
68530 +} __do_const ;
68531
68532 struct atmphy_ops {
68533 int (*start)(struct atm_dev *dev);
68534 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
68535 index 70cf138..0418ee2 100644
68536 --- a/include/linux/binfmts.h
68537 +++ b/include/linux/binfmts.h
68538 @@ -73,8 +73,10 @@ struct linux_binfmt {
68539 int (*load_binary)(struct linux_binprm *);
68540 int (*load_shlib)(struct file *);
68541 int (*core_dump)(struct coredump_params *cprm);
68542 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
68543 + void (*handle_mmap)(struct file *);
68544 unsigned long min_coredump; /* minimal dump size */
68545 -};
68546 +} __do_const;
68547
68548 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
68549
68550 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
68551 index 2fdb4a4..54aad7e 100644
68552 --- a/include/linux/blkdev.h
68553 +++ b/include/linux/blkdev.h
68554 @@ -1526,7 +1526,7 @@ struct block_device_operations {
68555 /* this callback is with swap_lock and sometimes page table lock held */
68556 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
68557 struct module *owner;
68558 -};
68559 +} __do_const;
68560
68561 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
68562 unsigned long);
68563 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
68564 index 7c2e030..b72475d 100644
68565 --- a/include/linux/blktrace_api.h
68566 +++ b/include/linux/blktrace_api.h
68567 @@ -23,7 +23,7 @@ struct blk_trace {
68568 struct dentry *dir;
68569 struct dentry *dropped_file;
68570 struct dentry *msg_file;
68571 - atomic_t dropped;
68572 + atomic_unchecked_t dropped;
68573 };
68574
68575 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
68576 diff --git a/include/linux/cache.h b/include/linux/cache.h
68577 index 4c57065..4307975 100644
68578 --- a/include/linux/cache.h
68579 +++ b/include/linux/cache.h
68580 @@ -16,6 +16,10 @@
68581 #define __read_mostly
68582 #endif
68583
68584 +#ifndef __read_only
68585 +#define __read_only __read_mostly
68586 +#endif
68587 +
68588 #ifndef ____cacheline_aligned
68589 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
68590 #endif
68591 diff --git a/include/linux/capability.h b/include/linux/capability.h
68592 index d9a4f7f4..19f77d6 100644
68593 --- a/include/linux/capability.h
68594 +++ b/include/linux/capability.h
68595 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
68596 extern bool nsown_capable(int cap);
68597 extern bool inode_capable(const struct inode *inode, int cap);
68598 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
68599 +extern bool capable_nolog(int cap);
68600 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
68601 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
68602
68603 /* audit system wants to get cap info from files as well */
68604 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
68605
68606 +extern int is_privileged_binary(const struct dentry *dentry);
68607 +
68608 #endif /* !_LINUX_CAPABILITY_H */
68609 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
68610 index 8609d57..86e4d79 100644
68611 --- a/include/linux/cdrom.h
68612 +++ b/include/linux/cdrom.h
68613 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
68614
68615 /* driver specifications */
68616 const int capability; /* capability flags */
68617 - int n_minors; /* number of active minor devices */
68618 /* handle uniform packets for scsi type devices (scsi,atapi) */
68619 int (*generic_packet) (struct cdrom_device_info *,
68620 struct packet_command *);
68621 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
68622 index 4ce9056..86caac6 100644
68623 --- a/include/linux/cleancache.h
68624 +++ b/include/linux/cleancache.h
68625 @@ -31,7 +31,7 @@ struct cleancache_ops {
68626 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
68627 void (*invalidate_inode)(int, struct cleancache_filekey);
68628 void (*invalidate_fs)(int);
68629 -};
68630 +} __no_const;
68631
68632 extern struct cleancache_ops *
68633 cleancache_register_ops(struct cleancache_ops *ops);
68634 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
68635 index 1186098..f87e53d 100644
68636 --- a/include/linux/clk-provider.h
68637 +++ b/include/linux/clk-provider.h
68638 @@ -132,6 +132,7 @@ struct clk_ops {
68639 unsigned long);
68640 void (*init)(struct clk_hw *hw);
68641 };
68642 +typedef struct clk_ops __no_const clk_ops_no_const;
68643
68644 /**
68645 * struct clk_init_data - holds init data that's common to all clocks and is
68646 diff --git a/include/linux/compat.h b/include/linux/compat.h
68647 index 7f0c1dd..b5729c6 100644
68648 --- a/include/linux/compat.h
68649 +++ b/include/linux/compat.h
68650 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
68651 compat_size_t __user *len_ptr);
68652
68653 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
68654 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
68655 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
68656 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
68657 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
68658 compat_ssize_t msgsz, int msgflg);
68659 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
68660 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
68661 compat_ulong_t addr, compat_ulong_t data);
68662 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
68663 - compat_long_t addr, compat_long_t data);
68664 + compat_ulong_t addr, compat_ulong_t data);
68665
68666 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
68667 /*
68668 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
68669 index 842de22..7f3a41f 100644
68670 --- a/include/linux/compiler-gcc4.h
68671 +++ b/include/linux/compiler-gcc4.h
68672 @@ -39,9 +39,29 @@
68673 # define __compiletime_warning(message) __attribute__((warning(message)))
68674 # define __compiletime_error(message) __attribute__((error(message)))
68675 #endif /* __CHECKER__ */
68676 +
68677 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
68678 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
68679 +#define __bos0(ptr) __bos((ptr), 0)
68680 +#define __bos1(ptr) __bos((ptr), 1)
68681 #endif /* GCC_VERSION >= 40300 */
68682
68683 #if GCC_VERSION >= 40500
68684 +
68685 +#ifdef CONSTIFY_PLUGIN
68686 +#define __no_const __attribute__((no_const))
68687 +#define __do_const __attribute__((do_const))
68688 +#endif
68689 +
68690 +#ifdef SIZE_OVERFLOW_PLUGIN
68691 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
68692 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
68693 +#endif
68694 +
68695 +#ifdef LATENT_ENTROPY_PLUGIN
68696 +#define __latent_entropy __attribute__((latent_entropy))
68697 +#endif
68698 +
68699 /*
68700 * Mark a position in code as unreachable. This can be used to
68701 * suppress control flow warnings after asm blocks that transfer
68702 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68703 index 92669cd..1771a15 100644
68704 --- a/include/linux/compiler.h
68705 +++ b/include/linux/compiler.h
68706 @@ -5,11 +5,14 @@
68707
68708 #ifdef __CHECKER__
68709 # define __user __attribute__((noderef, address_space(1)))
68710 +# define __force_user __force __user
68711 # define __kernel __attribute__((address_space(0)))
68712 +# define __force_kernel __force __kernel
68713 # define __safe __attribute__((safe))
68714 # define __force __attribute__((force))
68715 # define __nocast __attribute__((nocast))
68716 # define __iomem __attribute__((noderef, address_space(2)))
68717 +# define __force_iomem __force __iomem
68718 # define __must_hold(x) __attribute__((context(x,1,1)))
68719 # define __acquires(x) __attribute__((context(x,0,1)))
68720 # define __releases(x) __attribute__((context(x,1,0)))
68721 @@ -17,20 +20,37 @@
68722 # define __release(x) __context__(x,-1)
68723 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68724 # define __percpu __attribute__((noderef, address_space(3)))
68725 +# define __force_percpu __force __percpu
68726 #ifdef CONFIG_SPARSE_RCU_POINTER
68727 # define __rcu __attribute__((noderef, address_space(4)))
68728 +# define __force_rcu __force __rcu
68729 #else
68730 # define __rcu
68731 +# define __force_rcu
68732 #endif
68733 extern void __chk_user_ptr(const volatile void __user *);
68734 extern void __chk_io_ptr(const volatile void __iomem *);
68735 #else
68736 -# define __user
68737 -# define __kernel
68738 +# ifdef CHECKER_PLUGIN
68739 +//# define __user
68740 +//# define __force_user
68741 +//# define __kernel
68742 +//# define __force_kernel
68743 +# else
68744 +# ifdef STRUCTLEAK_PLUGIN
68745 +# define __user __attribute__((user))
68746 +# else
68747 +# define __user
68748 +# endif
68749 +# define __force_user
68750 +# define __kernel
68751 +# define __force_kernel
68752 +# endif
68753 # define __safe
68754 # define __force
68755 # define __nocast
68756 # define __iomem
68757 +# define __force_iomem
68758 # define __chk_user_ptr(x) (void)0
68759 # define __chk_io_ptr(x) (void)0
68760 # define __builtin_warning(x, y...) (1)
68761 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68762 # define __release(x) (void)0
68763 # define __cond_lock(x,c) (c)
68764 # define __percpu
68765 +# define __force_percpu
68766 # define __rcu
68767 +# define __force_rcu
68768 #endif
68769
68770 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68771 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68772 # define __attribute_const__ /* unimplemented */
68773 #endif
68774
68775 +#ifndef __no_const
68776 +# define __no_const
68777 +#endif
68778 +
68779 +#ifndef __do_const
68780 +# define __do_const
68781 +#endif
68782 +
68783 +#ifndef __size_overflow
68784 +# define __size_overflow(...)
68785 +#endif
68786 +
68787 +#ifndef __intentional_overflow
68788 +# define __intentional_overflow(...)
68789 +#endif
68790 +
68791 +#ifndef __latent_entropy
68792 +# define __latent_entropy
68793 +#endif
68794 +
68795 /*
68796 * Tell gcc if a function is cold. The compiler will assume any path
68797 * directly leading to the call is unlikely.
68798 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68799 #define __cold
68800 #endif
68801
68802 +#ifndef __alloc_size
68803 +#define __alloc_size(...)
68804 +#endif
68805 +
68806 +#ifndef __bos
68807 +#define __bos(ptr, arg)
68808 +#endif
68809 +
68810 +#ifndef __bos0
68811 +#define __bos0(ptr)
68812 +#endif
68813 +
68814 +#ifndef __bos1
68815 +#define __bos1(ptr)
68816 +#endif
68817 +
68818 /* Simple shorthand for a section definition */
68819 #ifndef __section
68820 # define __section(S) __attribute__ ((__section__(#S)))
68821 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68822 * use is to mediate communication between process-level code and irq/NMI
68823 * handlers, all running on the same CPU.
68824 */
68825 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68826 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68827 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68828
68829 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
68830 #ifdef CONFIG_KPROBES
68831 diff --git a/include/linux/completion.h b/include/linux/completion.h
68832 index 33f0280..35c6568 100644
68833 --- a/include/linux/completion.h
68834 +++ b/include/linux/completion.h
68835 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68836 extern void wait_for_completion(struct completion *);
68837 extern void wait_for_completion_io(struct completion *);
68838 extern int wait_for_completion_interruptible(struct completion *x);
68839 -extern int wait_for_completion_killable(struct completion *x);
68840 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68841 extern unsigned long wait_for_completion_timeout(struct completion *x,
68842 unsigned long timeout);
68843 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68844 unsigned long timeout);
68845 extern long wait_for_completion_interruptible_timeout(
68846 - struct completion *x, unsigned long timeout);
68847 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68848 extern long wait_for_completion_killable_timeout(
68849 - struct completion *x, unsigned long timeout);
68850 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68851 extern bool try_wait_for_completion(struct completion *x);
68852 extern bool completion_done(struct completion *x);
68853
68854 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68855 index 34025df..d94bbbc 100644
68856 --- a/include/linux/configfs.h
68857 +++ b/include/linux/configfs.h
68858 @@ -125,7 +125,7 @@ struct configfs_attribute {
68859 const char *ca_name;
68860 struct module *ca_owner;
68861 umode_t ca_mode;
68862 -};
68863 +} __do_const;
68864
68865 /*
68866 * Users often need to create attribute structures for their configurable
68867 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68868 index 9f3c7e8..a18c7b6 100644
68869 --- a/include/linux/cpu.h
68870 +++ b/include/linux/cpu.h
68871 @@ -115,7 +115,7 @@ enum {
68872 /* Need to know about CPUs going up/down? */
68873 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68874 #define cpu_notifier(fn, pri) { \
68875 - static struct notifier_block fn##_nb __cpuinitdata = \
68876 + static struct notifier_block fn##_nb = \
68877 { .notifier_call = fn, .priority = pri }; \
68878 register_cpu_notifier(&fn##_nb); \
68879 }
68880 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68881 index 037d36a..ca5fe6e 100644
68882 --- a/include/linux/cpufreq.h
68883 +++ b/include/linux/cpufreq.h
68884 @@ -262,7 +262,7 @@ struct cpufreq_driver {
68885 int (*suspend) (struct cpufreq_policy *policy);
68886 int (*resume) (struct cpufreq_policy *policy);
68887 struct freq_attr **attr;
68888 -};
68889 +} __do_const;
68890
68891 /* flags */
68892
68893 @@ -321,6 +321,7 @@ struct global_attr {
68894 ssize_t (*store)(struct kobject *a, struct attribute *b,
68895 const char *c, size_t count);
68896 };
68897 +typedef struct global_attr __no_const global_attr_no_const;
68898
68899 #define define_one_global_ro(_name) \
68900 static struct global_attr _name = \
68901 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68902 index 8f04062..900239a 100644
68903 --- a/include/linux/cpuidle.h
68904 +++ b/include/linux/cpuidle.h
68905 @@ -52,7 +52,8 @@ struct cpuidle_state {
68906 int index);
68907
68908 int (*enter_dead) (struct cpuidle_device *dev, int index);
68909 -};
68910 +} __do_const;
68911 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68912
68913 /* Idle State Flags */
68914 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68915 @@ -191,7 +192,7 @@ struct cpuidle_governor {
68916 void (*reflect) (struct cpuidle_device *dev, int index);
68917
68918 struct module *owner;
68919 -};
68920 +} __do_const;
68921
68922 #ifdef CONFIG_CPU_IDLE
68923
68924 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68925 index d08e4d2..95fad61 100644
68926 --- a/include/linux/cpumask.h
68927 +++ b/include/linux/cpumask.h
68928 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68929 }
68930
68931 /* Valid inputs for n are -1 and 0. */
68932 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68933 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68934 {
68935 return n+1;
68936 }
68937
68938 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68939 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68940 {
68941 return n+1;
68942 }
68943
68944 -static inline unsigned int cpumask_next_and(int n,
68945 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68946 const struct cpumask *srcp,
68947 const struct cpumask *andp)
68948 {
68949 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68950 *
68951 * Returns >= nr_cpu_ids if no further cpus set.
68952 */
68953 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68954 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68955 {
68956 /* -1 is a legal arg here. */
68957 if (n != -1)
68958 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68959 *
68960 * Returns >= nr_cpu_ids if no further cpus unset.
68961 */
68962 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68963 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68964 {
68965 /* -1 is a legal arg here. */
68966 if (n != -1)
68967 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68968 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68969 }
68970
68971 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68972 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68973 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68974
68975 /**
68976 diff --git a/include/linux/cred.h b/include/linux/cred.h
68977 index 04421e8..6bce4ef 100644
68978 --- a/include/linux/cred.h
68979 +++ b/include/linux/cred.h
68980 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68981 static inline void validate_process_creds(void)
68982 {
68983 }
68984 +static inline void validate_task_creds(struct task_struct *task)
68985 +{
68986 +}
68987 #endif
68988
68989 /**
68990 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68991 index b92eadf..b4ecdc1 100644
68992 --- a/include/linux/crypto.h
68993 +++ b/include/linux/crypto.h
68994 @@ -373,7 +373,7 @@ struct cipher_tfm {
68995 const u8 *key, unsigned int keylen);
68996 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68997 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68998 -};
68999 +} __no_const;
69000
69001 struct hash_tfm {
69002 int (*init)(struct hash_desc *desc);
69003 @@ -394,13 +394,13 @@ struct compress_tfm {
69004 int (*cot_decompress)(struct crypto_tfm *tfm,
69005 const u8 *src, unsigned int slen,
69006 u8 *dst, unsigned int *dlen);
69007 -};
69008 +} __no_const;
69009
69010 struct rng_tfm {
69011 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
69012 unsigned int dlen);
69013 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
69014 -};
69015 +} __no_const;
69016
69017 #define crt_ablkcipher crt_u.ablkcipher
69018 #define crt_aead crt_u.aead
69019 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
69020 index 653589e..4ef254a 100644
69021 --- a/include/linux/ctype.h
69022 +++ b/include/linux/ctype.h
69023 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
69024 * Fast implementation of tolower() for internal usage. Do not use in your
69025 * code.
69026 */
69027 -static inline char _tolower(const char c)
69028 +static inline unsigned char _tolower(const unsigned char c)
69029 {
69030 return c | 0x20;
69031 }
69032 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
69033 index 7925bf0..d5143d2 100644
69034 --- a/include/linux/decompress/mm.h
69035 +++ b/include/linux/decompress/mm.h
69036 @@ -77,7 +77,7 @@ static void free(void *where)
69037 * warnings when not needed (indeed large_malloc / large_free are not
69038 * needed by inflate */
69039
69040 -#define malloc(a) kmalloc(a, GFP_KERNEL)
69041 +#define malloc(a) kmalloc((a), GFP_KERNEL)
69042 #define free(a) kfree(a)
69043
69044 #define large_malloc(a) vmalloc(a)
69045 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
69046 index fe8c447..bdc1f33 100644
69047 --- a/include/linux/devfreq.h
69048 +++ b/include/linux/devfreq.h
69049 @@ -114,7 +114,7 @@ struct devfreq_governor {
69050 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
69051 int (*event_handler)(struct devfreq *devfreq,
69052 unsigned int event, void *data);
69053 -};
69054 +} __do_const;
69055
69056 /**
69057 * struct devfreq - Device devfreq structure
69058 diff --git a/include/linux/device.h b/include/linux/device.h
69059 index c0a1261..dba7569 100644
69060 --- a/include/linux/device.h
69061 +++ b/include/linux/device.h
69062 @@ -290,7 +290,7 @@ struct subsys_interface {
69063 struct list_head node;
69064 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
69065 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
69066 -};
69067 +} __do_const;
69068
69069 int subsys_interface_register(struct subsys_interface *sif);
69070 void subsys_interface_unregister(struct subsys_interface *sif);
69071 @@ -473,7 +473,7 @@ struct device_type {
69072 void (*release)(struct device *dev);
69073
69074 const struct dev_pm_ops *pm;
69075 -};
69076 +} __do_const;
69077
69078 /* interface for exporting device attributes */
69079 struct device_attribute {
69080 @@ -483,11 +483,12 @@ struct device_attribute {
69081 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
69082 const char *buf, size_t count);
69083 };
69084 +typedef struct device_attribute __no_const device_attribute_no_const;
69085
69086 struct dev_ext_attribute {
69087 struct device_attribute attr;
69088 void *var;
69089 -};
69090 +} __do_const;
69091
69092 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
69093 char *buf);
69094 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
69095 index 94af418..b1ca7a2 100644
69096 --- a/include/linux/dma-mapping.h
69097 +++ b/include/linux/dma-mapping.h
69098 @@ -54,7 +54,7 @@ struct dma_map_ops {
69099 u64 (*get_required_mask)(struct device *dev);
69100 #endif
69101 int is_phys;
69102 -};
69103 +} __do_const;
69104
69105 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
69106
69107 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
69108 index 96d3e4a..dc36433 100644
69109 --- a/include/linux/dmaengine.h
69110 +++ b/include/linux/dmaengine.h
69111 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
69112 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
69113 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
69114
69115 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
69116 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
69117 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
69118 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
69119 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
69120 struct dma_pinned_list *pinned_list, struct page *page,
69121 unsigned int offset, size_t len);
69122
69123 diff --git a/include/linux/efi.h b/include/linux/efi.h
69124 index 2bc0ad7..3f7b006 100644
69125 --- a/include/linux/efi.h
69126 +++ b/include/linux/efi.h
69127 @@ -745,6 +745,7 @@ struct efivar_operations {
69128 efi_set_variable_t *set_variable;
69129 efi_query_variable_store_t *query_variable_store;
69130 };
69131 +typedef struct efivar_operations __no_const efivar_operations_no_const;
69132
69133 struct efivars {
69134 /*
69135 diff --git a/include/linux/elf.h b/include/linux/elf.h
69136 index 40a3c0e..4c45a38 100644
69137 --- a/include/linux/elf.h
69138 +++ b/include/linux/elf.h
69139 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
69140 #define elf_note elf32_note
69141 #define elf_addr_t Elf32_Off
69142 #define Elf_Half Elf32_Half
69143 +#define elf_dyn Elf32_Dyn
69144
69145 #else
69146
69147 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
69148 #define elf_note elf64_note
69149 #define elf_addr_t Elf64_Off
69150 #define Elf_Half Elf64_Half
69151 +#define elf_dyn Elf64_Dyn
69152
69153 #endif
69154
69155 diff --git a/include/linux/err.h b/include/linux/err.h
69156 index f2edce2..cc2082c 100644
69157 --- a/include/linux/err.h
69158 +++ b/include/linux/err.h
69159 @@ -19,12 +19,12 @@
69160
69161 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
69162
69163 -static inline void * __must_check ERR_PTR(long error)
69164 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
69165 {
69166 return (void *) error;
69167 }
69168
69169 -static inline long __must_check PTR_ERR(const void *ptr)
69170 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
69171 {
69172 return (long) ptr;
69173 }
69174 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
69175 index fcb51c8..bdafcf6 100644
69176 --- a/include/linux/extcon.h
69177 +++ b/include/linux/extcon.h
69178 @@ -134,7 +134,7 @@ struct extcon_dev {
69179 /* /sys/class/extcon/.../mutually_exclusive/... */
69180 struct attribute_group attr_g_muex;
69181 struct attribute **attrs_muex;
69182 - struct device_attribute *d_attrs_muex;
69183 + device_attribute_no_const *d_attrs_muex;
69184 };
69185
69186 /**
69187 diff --git a/include/linux/fb.h b/include/linux/fb.h
69188 index d49c60f..2834fbe 100644
69189 --- a/include/linux/fb.h
69190 +++ b/include/linux/fb.h
69191 @@ -304,7 +304,7 @@ struct fb_ops {
69192 /* called at KDB enter and leave time to prepare the console */
69193 int (*fb_debug_enter)(struct fb_info *info);
69194 int (*fb_debug_leave)(struct fb_info *info);
69195 -};
69196 +} __do_const;
69197
69198 #ifdef CONFIG_FB_TILEBLITTING
69199 #define FB_TILE_CURSOR_NONE 0
69200 diff --git a/include/linux/filter.h b/include/linux/filter.h
69201 index f65f5a6..2f4f93a 100644
69202 --- a/include/linux/filter.h
69203 +++ b/include/linux/filter.h
69204 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
69205
69206 struct sk_buff;
69207 struct sock;
69208 +struct bpf_jit_work;
69209
69210 struct sk_filter
69211 {
69212 @@ -27,6 +28,9 @@ struct sk_filter
69213 unsigned int len; /* Number of filter blocks */
69214 unsigned int (*bpf_func)(const struct sk_buff *skb,
69215 const struct sock_filter *filter);
69216 +#ifdef CONFIG_BPF_JIT
69217 + struct bpf_jit_work *work;
69218 +#endif
69219 struct rcu_head rcu;
69220 struct sock_filter insns[0];
69221 };
69222 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
69223 index 8293262..2b3b8bd 100644
69224 --- a/include/linux/frontswap.h
69225 +++ b/include/linux/frontswap.h
69226 @@ -11,7 +11,7 @@ struct frontswap_ops {
69227 int (*load)(unsigned, pgoff_t, struct page *);
69228 void (*invalidate_page)(unsigned, pgoff_t);
69229 void (*invalidate_area)(unsigned);
69230 -};
69231 +} __no_const;
69232
69233 extern bool frontswap_enabled;
69234 extern struct frontswap_ops *
69235 diff --git a/include/linux/fs.h b/include/linux/fs.h
69236 index 65c2be2..4c53f6e 100644
69237 --- a/include/linux/fs.h
69238 +++ b/include/linux/fs.h
69239 @@ -1543,7 +1543,8 @@ struct file_operations {
69240 long (*fallocate)(struct file *file, int mode, loff_t offset,
69241 loff_t len);
69242 int (*show_fdinfo)(struct seq_file *m, struct file *f);
69243 -};
69244 +} __do_const;
69245 +typedef struct file_operations __no_const file_operations_no_const;
69246
69247 struct inode_operations {
69248 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
69249 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
69250 inode->i_flags |= S_NOSEC;
69251 }
69252
69253 +static inline bool is_sidechannel_device(const struct inode *inode)
69254 +{
69255 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
69256 + umode_t mode = inode->i_mode;
69257 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
69258 +#else
69259 + return false;
69260 +#endif
69261 +}
69262 +
69263 #endif /* _LINUX_FS_H */
69264 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
69265 index 2b93a9a..855d94a 100644
69266 --- a/include/linux/fs_struct.h
69267 +++ b/include/linux/fs_struct.h
69268 @@ -6,7 +6,7 @@
69269 #include <linux/seqlock.h>
69270
69271 struct fs_struct {
69272 - int users;
69273 + atomic_t users;
69274 spinlock_t lock;
69275 seqcount_t seq;
69276 int umask;
69277 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
69278 index 5dfa0aa..6acf322 100644
69279 --- a/include/linux/fscache-cache.h
69280 +++ b/include/linux/fscache-cache.h
69281 @@ -112,7 +112,7 @@ struct fscache_operation {
69282 fscache_operation_release_t release;
69283 };
69284
69285 -extern atomic_t fscache_op_debug_id;
69286 +extern atomic_unchecked_t fscache_op_debug_id;
69287 extern void fscache_op_work_func(struct work_struct *work);
69288
69289 extern void fscache_enqueue_operation(struct fscache_operation *);
69290 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
69291 INIT_WORK(&op->work, fscache_op_work_func);
69292 atomic_set(&op->usage, 1);
69293 op->state = FSCACHE_OP_ST_INITIALISED;
69294 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
69295 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
69296 op->processor = processor;
69297 op->release = release;
69298 INIT_LIST_HEAD(&op->pend_link);
69299 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
69300 index 7a08623..4c07b0f 100644
69301 --- a/include/linux/fscache.h
69302 +++ b/include/linux/fscache.h
69303 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
69304 * - this is mandatory for any object that may have data
69305 */
69306 void (*now_uncached)(void *cookie_netfs_data);
69307 -};
69308 +} __do_const;
69309
69310 /*
69311 * fscache cached network filesystem type
69312 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
69313 index a78680a..87bd73e 100644
69314 --- a/include/linux/fsnotify.h
69315 +++ b/include/linux/fsnotify.h
69316 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
69317 struct inode *inode = path->dentry->d_inode;
69318 __u32 mask = FS_ACCESS;
69319
69320 + if (is_sidechannel_device(inode))
69321 + return;
69322 +
69323 if (S_ISDIR(inode->i_mode))
69324 mask |= FS_ISDIR;
69325
69326 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
69327 struct inode *inode = path->dentry->d_inode;
69328 __u32 mask = FS_MODIFY;
69329
69330 + if (is_sidechannel_device(inode))
69331 + return;
69332 +
69333 if (S_ISDIR(inode->i_mode))
69334 mask |= FS_ISDIR;
69335
69336 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
69337 */
69338 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
69339 {
69340 - return kstrdup(name, GFP_KERNEL);
69341 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
69342 }
69343
69344 /*
69345 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
69346 index 9f3c275..911b591 100644
69347 --- a/include/linux/genhd.h
69348 +++ b/include/linux/genhd.h
69349 @@ -194,7 +194,7 @@ struct gendisk {
69350 struct kobject *slave_dir;
69351
69352 struct timer_rand_state *random;
69353 - atomic_t sync_io; /* RAID */
69354 + atomic_unchecked_t sync_io; /* RAID */
69355 struct disk_events *ev;
69356 #ifdef CONFIG_BLK_DEV_INTEGRITY
69357 struct blk_integrity *integrity;
69358 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
69359 index 023bc34..b02b46a 100644
69360 --- a/include/linux/genl_magic_func.h
69361 +++ b/include/linux/genl_magic_func.h
69362 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
69363 },
69364
69365 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
69366 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
69367 +static struct genl_ops ZZZ_genl_ops[] = {
69368 #include GENL_MAGIC_INCLUDE_FILE
69369 };
69370
69371 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
69372 index 0f615eb..5c3832f 100644
69373 --- a/include/linux/gfp.h
69374 +++ b/include/linux/gfp.h
69375 @@ -35,6 +35,13 @@ struct vm_area_struct;
69376 #define ___GFP_NO_KSWAPD 0x400000u
69377 #define ___GFP_OTHER_NODE 0x800000u
69378 #define ___GFP_WRITE 0x1000000u
69379 +
69380 +#ifdef CONFIG_PAX_USERCOPY_SLABS
69381 +#define ___GFP_USERCOPY 0x2000000u
69382 +#else
69383 +#define ___GFP_USERCOPY 0
69384 +#endif
69385 +
69386 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
69387
69388 /*
69389 @@ -92,6 +99,7 @@ struct vm_area_struct;
69390 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
69391 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
69392 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
69393 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
69394
69395 /*
69396 * This may seem redundant, but it's a way of annotating false positives vs.
69397 @@ -99,7 +107,7 @@ struct vm_area_struct;
69398 */
69399 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
69400
69401 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
69402 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
69403 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
69404
69405 /* This equals 0, but use constants in case they ever change */
69406 @@ -153,6 +161,8 @@ struct vm_area_struct;
69407 /* 4GB DMA on some platforms */
69408 #define GFP_DMA32 __GFP_DMA32
69409
69410 +#define GFP_USERCOPY __GFP_USERCOPY
69411 +
69412 /* Convert GFP flags to their corresponding migrate type */
69413 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
69414 {
69415 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
69416 new file mode 100644
69417 index 0000000..ebe6d72
69418 --- /dev/null
69419 +++ b/include/linux/gracl.h
69420 @@ -0,0 +1,319 @@
69421 +#ifndef GR_ACL_H
69422 +#define GR_ACL_H
69423 +
69424 +#include <linux/grdefs.h>
69425 +#include <linux/resource.h>
69426 +#include <linux/capability.h>
69427 +#include <linux/dcache.h>
69428 +#include <asm/resource.h>
69429 +
69430 +/* Major status information */
69431 +
69432 +#define GR_VERSION "grsecurity 2.9.1"
69433 +#define GRSECURITY_VERSION 0x2901
69434 +
69435 +enum {
69436 + GR_SHUTDOWN = 0,
69437 + GR_ENABLE = 1,
69438 + GR_SPROLE = 2,
69439 + GR_RELOAD = 3,
69440 + GR_SEGVMOD = 4,
69441 + GR_STATUS = 5,
69442 + GR_UNSPROLE = 6,
69443 + GR_PASSSET = 7,
69444 + GR_SPROLEPAM = 8,
69445 +};
69446 +
69447 +/* Password setup definitions
69448 + * kernel/grhash.c */
69449 +enum {
69450 + GR_PW_LEN = 128,
69451 + GR_SALT_LEN = 16,
69452 + GR_SHA_LEN = 32,
69453 +};
69454 +
69455 +enum {
69456 + GR_SPROLE_LEN = 64,
69457 +};
69458 +
69459 +enum {
69460 + GR_NO_GLOB = 0,
69461 + GR_REG_GLOB,
69462 + GR_CREATE_GLOB
69463 +};
69464 +
69465 +#define GR_NLIMITS 32
69466 +
69467 +/* Begin Data Structures */
69468 +
69469 +struct sprole_pw {
69470 + unsigned char *rolename;
69471 + unsigned char salt[GR_SALT_LEN];
69472 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
69473 +};
69474 +
69475 +struct name_entry {
69476 + __u32 key;
69477 + ino_t inode;
69478 + dev_t device;
69479 + char *name;
69480 + __u16 len;
69481 + __u8 deleted;
69482 + struct name_entry *prev;
69483 + struct name_entry *next;
69484 +};
69485 +
69486 +struct inodev_entry {
69487 + struct name_entry *nentry;
69488 + struct inodev_entry *prev;
69489 + struct inodev_entry *next;
69490 +};
69491 +
69492 +struct acl_role_db {
69493 + struct acl_role_label **r_hash;
69494 + __u32 r_size;
69495 +};
69496 +
69497 +struct inodev_db {
69498 + struct inodev_entry **i_hash;
69499 + __u32 i_size;
69500 +};
69501 +
69502 +struct name_db {
69503 + struct name_entry **n_hash;
69504 + __u32 n_size;
69505 +};
69506 +
69507 +struct crash_uid {
69508 + uid_t uid;
69509 + unsigned long expires;
69510 +};
69511 +
69512 +struct gr_hash_struct {
69513 + void **table;
69514 + void **nametable;
69515 + void *first;
69516 + __u32 table_size;
69517 + __u32 used_size;
69518 + int type;
69519 +};
69520 +
69521 +/* Userspace Grsecurity ACL data structures */
69522 +
69523 +struct acl_subject_label {
69524 + char *filename;
69525 + ino_t inode;
69526 + dev_t device;
69527 + __u32 mode;
69528 + kernel_cap_t cap_mask;
69529 + kernel_cap_t cap_lower;
69530 + kernel_cap_t cap_invert_audit;
69531 +
69532 + struct rlimit res[GR_NLIMITS];
69533 + __u32 resmask;
69534 +
69535 + __u8 user_trans_type;
69536 + __u8 group_trans_type;
69537 + uid_t *user_transitions;
69538 + gid_t *group_transitions;
69539 + __u16 user_trans_num;
69540 + __u16 group_trans_num;
69541 +
69542 + __u32 sock_families[2];
69543 + __u32 ip_proto[8];
69544 + __u32 ip_type;
69545 + struct acl_ip_label **ips;
69546 + __u32 ip_num;
69547 + __u32 inaddr_any_override;
69548 +
69549 + __u32 crashes;
69550 + unsigned long expires;
69551 +
69552 + struct acl_subject_label *parent_subject;
69553 + struct gr_hash_struct *hash;
69554 + struct acl_subject_label *prev;
69555 + struct acl_subject_label *next;
69556 +
69557 + struct acl_object_label **obj_hash;
69558 + __u32 obj_hash_size;
69559 + __u16 pax_flags;
69560 +};
69561 +
69562 +struct role_allowed_ip {
69563 + __u32 addr;
69564 + __u32 netmask;
69565 +
69566 + struct role_allowed_ip *prev;
69567 + struct role_allowed_ip *next;
69568 +};
69569 +
69570 +struct role_transition {
69571 + char *rolename;
69572 +
69573 + struct role_transition *prev;
69574 + struct role_transition *next;
69575 +};
69576 +
69577 +struct acl_role_label {
69578 + char *rolename;
69579 + uid_t uidgid;
69580 + __u16 roletype;
69581 +
69582 + __u16 auth_attempts;
69583 + unsigned long expires;
69584 +
69585 + struct acl_subject_label *root_label;
69586 + struct gr_hash_struct *hash;
69587 +
69588 + struct acl_role_label *prev;
69589 + struct acl_role_label *next;
69590 +
69591 + struct role_transition *transitions;
69592 + struct role_allowed_ip *allowed_ips;
69593 + uid_t *domain_children;
69594 + __u16 domain_child_num;
69595 +
69596 + umode_t umask;
69597 +
69598 + struct acl_subject_label **subj_hash;
69599 + __u32 subj_hash_size;
69600 +};
69601 +
69602 +struct user_acl_role_db {
69603 + struct acl_role_label **r_table;
69604 + __u32 num_pointers; /* Number of allocations to track */
69605 + __u32 num_roles; /* Number of roles */
69606 + __u32 num_domain_children; /* Number of domain children */
69607 + __u32 num_subjects; /* Number of subjects */
69608 + __u32 num_objects; /* Number of objects */
69609 +};
69610 +
69611 +struct acl_object_label {
69612 + char *filename;
69613 + ino_t inode;
69614 + dev_t device;
69615 + __u32 mode;
69616 +
69617 + struct acl_subject_label *nested;
69618 + struct acl_object_label *globbed;
69619 +
69620 + /* next two structures not used */
69621 +
69622 + struct acl_object_label *prev;
69623 + struct acl_object_label *next;
69624 +};
69625 +
69626 +struct acl_ip_label {
69627 + char *iface;
69628 + __u32 addr;
69629 + __u32 netmask;
69630 + __u16 low, high;
69631 + __u8 mode;
69632 + __u32 type;
69633 + __u32 proto[8];
69634 +
69635 + /* next two structures not used */
69636 +
69637 + struct acl_ip_label *prev;
69638 + struct acl_ip_label *next;
69639 +};
69640 +
69641 +struct gr_arg {
69642 + struct user_acl_role_db role_db;
69643 + unsigned char pw[GR_PW_LEN];
69644 + unsigned char salt[GR_SALT_LEN];
69645 + unsigned char sum[GR_SHA_LEN];
69646 + unsigned char sp_role[GR_SPROLE_LEN];
69647 + struct sprole_pw *sprole_pws;
69648 + dev_t segv_device;
69649 + ino_t segv_inode;
69650 + uid_t segv_uid;
69651 + __u16 num_sprole_pws;
69652 + __u16 mode;
69653 +};
69654 +
69655 +struct gr_arg_wrapper {
69656 + struct gr_arg *arg;
69657 + __u32 version;
69658 + __u32 size;
69659 +};
69660 +
69661 +struct subject_map {
69662 + struct acl_subject_label *user;
69663 + struct acl_subject_label *kernel;
69664 + struct subject_map *prev;
69665 + struct subject_map *next;
69666 +};
69667 +
69668 +struct acl_subj_map_db {
69669 + struct subject_map **s_hash;
69670 + __u32 s_size;
69671 +};
69672 +
69673 +/* End Data Structures Section */
69674 +
69675 +/* Hash functions generated by empirical testing by Brad Spengler
69676 + Makes good use of the low bits of the inode. Generally 0-1 times
69677 + in loop for successful match. 0-3 for unsuccessful match.
69678 + Shift/add algorithm with modulus of table size and an XOR*/
69679 +
69680 +static __inline__ unsigned int
69681 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
69682 +{
69683 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
69684 +}
69685 +
69686 + static __inline__ unsigned int
69687 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
69688 +{
69689 + return ((const unsigned long)userp % sz);
69690 +}
69691 +
69692 +static __inline__ unsigned int
69693 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
69694 +{
69695 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69696 +}
69697 +
69698 +static __inline__ unsigned int
69699 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69700 +{
69701 + return full_name_hash((const unsigned char *)name, len) % sz;
69702 +}
69703 +
69704 +#define FOR_EACH_ROLE_START(role) \
69705 + role = role_list; \
69706 + while (role) {
69707 +
69708 +#define FOR_EACH_ROLE_END(role) \
69709 + role = role->prev; \
69710 + }
69711 +
69712 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69713 + subj = NULL; \
69714 + iter = 0; \
69715 + while (iter < role->subj_hash_size) { \
69716 + if (subj == NULL) \
69717 + subj = role->subj_hash[iter]; \
69718 + if (subj == NULL) { \
69719 + iter++; \
69720 + continue; \
69721 + }
69722 +
69723 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69724 + subj = subj->next; \
69725 + if (subj == NULL) \
69726 + iter++; \
69727 + }
69728 +
69729 +
69730 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69731 + subj = role->hash->first; \
69732 + while (subj != NULL) {
69733 +
69734 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69735 + subj = subj->next; \
69736 + }
69737 +
69738 +#endif
69739 +
69740 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
69741 new file mode 100644
69742 index 0000000..33ebd1f
69743 --- /dev/null
69744 +++ b/include/linux/gracl_compat.h
69745 @@ -0,0 +1,156 @@
69746 +#ifndef GR_ACL_COMPAT_H
69747 +#define GR_ACL_COMPAT_H
69748 +
69749 +#include <linux/resource.h>
69750 +#include <asm/resource.h>
69751 +
69752 +struct sprole_pw_compat {
69753 + compat_uptr_t rolename;
69754 + unsigned char salt[GR_SALT_LEN];
69755 + unsigned char sum[GR_SHA_LEN];
69756 +};
69757 +
69758 +struct gr_hash_struct_compat {
69759 + compat_uptr_t table;
69760 + compat_uptr_t nametable;
69761 + compat_uptr_t first;
69762 + __u32 table_size;
69763 + __u32 used_size;
69764 + int type;
69765 +};
69766 +
69767 +struct acl_subject_label_compat {
69768 + compat_uptr_t filename;
69769 + compat_ino_t inode;
69770 + __u32 device;
69771 + __u32 mode;
69772 + kernel_cap_t cap_mask;
69773 + kernel_cap_t cap_lower;
69774 + kernel_cap_t cap_invert_audit;
69775 +
69776 + struct compat_rlimit res[GR_NLIMITS];
69777 + __u32 resmask;
69778 +
69779 + __u8 user_trans_type;
69780 + __u8 group_trans_type;
69781 + compat_uptr_t user_transitions;
69782 + compat_uptr_t group_transitions;
69783 + __u16 user_trans_num;
69784 + __u16 group_trans_num;
69785 +
69786 + __u32 sock_families[2];
69787 + __u32 ip_proto[8];
69788 + __u32 ip_type;
69789 + compat_uptr_t ips;
69790 + __u32 ip_num;
69791 + __u32 inaddr_any_override;
69792 +
69793 + __u32 crashes;
69794 + compat_ulong_t expires;
69795 +
69796 + compat_uptr_t parent_subject;
69797 + compat_uptr_t hash;
69798 + compat_uptr_t prev;
69799 + compat_uptr_t next;
69800 +
69801 + compat_uptr_t obj_hash;
69802 + __u32 obj_hash_size;
69803 + __u16 pax_flags;
69804 +};
69805 +
69806 +struct role_allowed_ip_compat {
69807 + __u32 addr;
69808 + __u32 netmask;
69809 +
69810 + compat_uptr_t prev;
69811 + compat_uptr_t next;
69812 +};
69813 +
69814 +struct role_transition_compat {
69815 + compat_uptr_t rolename;
69816 +
69817 + compat_uptr_t prev;
69818 + compat_uptr_t next;
69819 +};
69820 +
69821 +struct acl_role_label_compat {
69822 + compat_uptr_t rolename;
69823 + uid_t uidgid;
69824 + __u16 roletype;
69825 +
69826 + __u16 auth_attempts;
69827 + compat_ulong_t expires;
69828 +
69829 + compat_uptr_t root_label;
69830 + compat_uptr_t hash;
69831 +
69832 + compat_uptr_t prev;
69833 + compat_uptr_t next;
69834 +
69835 + compat_uptr_t transitions;
69836 + compat_uptr_t allowed_ips;
69837 + compat_uptr_t domain_children;
69838 + __u16 domain_child_num;
69839 +
69840 + umode_t umask;
69841 +
69842 + compat_uptr_t subj_hash;
69843 + __u32 subj_hash_size;
69844 +};
69845 +
69846 +struct user_acl_role_db_compat {
69847 + compat_uptr_t r_table;
69848 + __u32 num_pointers;
69849 + __u32 num_roles;
69850 + __u32 num_domain_children;
69851 + __u32 num_subjects;
69852 + __u32 num_objects;
69853 +};
69854 +
69855 +struct acl_object_label_compat {
69856 + compat_uptr_t filename;
69857 + compat_ino_t inode;
69858 + __u32 device;
69859 + __u32 mode;
69860 +
69861 + compat_uptr_t nested;
69862 + compat_uptr_t globbed;
69863 +
69864 + compat_uptr_t prev;
69865 + compat_uptr_t next;
69866 +};
69867 +
69868 +struct acl_ip_label_compat {
69869 + compat_uptr_t iface;
69870 + __u32 addr;
69871 + __u32 netmask;
69872 + __u16 low, high;
69873 + __u8 mode;
69874 + __u32 type;
69875 + __u32 proto[8];
69876 +
69877 + compat_uptr_t prev;
69878 + compat_uptr_t next;
69879 +};
69880 +
69881 +struct gr_arg_compat {
69882 + struct user_acl_role_db_compat role_db;
69883 + unsigned char pw[GR_PW_LEN];
69884 + unsigned char salt[GR_SALT_LEN];
69885 + unsigned char sum[GR_SHA_LEN];
69886 + unsigned char sp_role[GR_SPROLE_LEN];
69887 + compat_uptr_t sprole_pws;
69888 + __u32 segv_device;
69889 + compat_ino_t segv_inode;
69890 + uid_t segv_uid;
69891 + __u16 num_sprole_pws;
69892 + __u16 mode;
69893 +};
69894 +
69895 +struct gr_arg_wrapper_compat {
69896 + compat_uptr_t arg;
69897 + __u32 version;
69898 + __u32 size;
69899 +};
69900 +
69901 +#endif
69902 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69903 new file mode 100644
69904 index 0000000..323ecf2
69905 --- /dev/null
69906 +++ b/include/linux/gralloc.h
69907 @@ -0,0 +1,9 @@
69908 +#ifndef __GRALLOC_H
69909 +#define __GRALLOC_H
69910 +
69911 +void acl_free_all(void);
69912 +int acl_alloc_stack_init(unsigned long size);
69913 +void *acl_alloc(unsigned long len);
69914 +void *acl_alloc_num(unsigned long num, unsigned long len);
69915 +
69916 +#endif
69917 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69918 new file mode 100644
69919 index 0000000..be66033
69920 --- /dev/null
69921 +++ b/include/linux/grdefs.h
69922 @@ -0,0 +1,140 @@
69923 +#ifndef GRDEFS_H
69924 +#define GRDEFS_H
69925 +
69926 +/* Begin grsecurity status declarations */
69927 +
69928 +enum {
69929 + GR_READY = 0x01,
69930 + GR_STATUS_INIT = 0x00 // disabled state
69931 +};
69932 +
69933 +/* Begin ACL declarations */
69934 +
69935 +/* Role flags */
69936 +
69937 +enum {
69938 + GR_ROLE_USER = 0x0001,
69939 + GR_ROLE_GROUP = 0x0002,
69940 + GR_ROLE_DEFAULT = 0x0004,
69941 + GR_ROLE_SPECIAL = 0x0008,
69942 + GR_ROLE_AUTH = 0x0010,
69943 + GR_ROLE_NOPW = 0x0020,
69944 + GR_ROLE_GOD = 0x0040,
69945 + GR_ROLE_LEARN = 0x0080,
69946 + GR_ROLE_TPE = 0x0100,
69947 + GR_ROLE_DOMAIN = 0x0200,
69948 + GR_ROLE_PAM = 0x0400,
69949 + GR_ROLE_PERSIST = 0x0800
69950 +};
69951 +
69952 +/* ACL Subject and Object mode flags */
69953 +enum {
69954 + GR_DELETED = 0x80000000
69955 +};
69956 +
69957 +/* ACL Object-only mode flags */
69958 +enum {
69959 + GR_READ = 0x00000001,
69960 + GR_APPEND = 0x00000002,
69961 + GR_WRITE = 0x00000004,
69962 + GR_EXEC = 0x00000008,
69963 + GR_FIND = 0x00000010,
69964 + GR_INHERIT = 0x00000020,
69965 + GR_SETID = 0x00000040,
69966 + GR_CREATE = 0x00000080,
69967 + GR_DELETE = 0x00000100,
69968 + GR_LINK = 0x00000200,
69969 + GR_AUDIT_READ = 0x00000400,
69970 + GR_AUDIT_APPEND = 0x00000800,
69971 + GR_AUDIT_WRITE = 0x00001000,
69972 + GR_AUDIT_EXEC = 0x00002000,
69973 + GR_AUDIT_FIND = 0x00004000,
69974 + GR_AUDIT_INHERIT= 0x00008000,
69975 + GR_AUDIT_SETID = 0x00010000,
69976 + GR_AUDIT_CREATE = 0x00020000,
69977 + GR_AUDIT_DELETE = 0x00040000,
69978 + GR_AUDIT_LINK = 0x00080000,
69979 + GR_PTRACERD = 0x00100000,
69980 + GR_NOPTRACE = 0x00200000,
69981 + GR_SUPPRESS = 0x00400000,
69982 + GR_NOLEARN = 0x00800000,
69983 + GR_INIT_TRANSFER= 0x01000000
69984 +};
69985 +
69986 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69987 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69988 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69989 +
69990 +/* ACL subject-only mode flags */
69991 +enum {
69992 + GR_KILL = 0x00000001,
69993 + GR_VIEW = 0x00000002,
69994 + GR_PROTECTED = 0x00000004,
69995 + GR_LEARN = 0x00000008,
69996 + GR_OVERRIDE = 0x00000010,
69997 + /* just a placeholder, this mode is only used in userspace */
69998 + GR_DUMMY = 0x00000020,
69999 + GR_PROTSHM = 0x00000040,
70000 + GR_KILLPROC = 0x00000080,
70001 + GR_KILLIPPROC = 0x00000100,
70002 + /* just a placeholder, this mode is only used in userspace */
70003 + GR_NOTROJAN = 0x00000200,
70004 + GR_PROTPROCFD = 0x00000400,
70005 + GR_PROCACCT = 0x00000800,
70006 + GR_RELAXPTRACE = 0x00001000,
70007 + //GR_NESTED = 0x00002000,
70008 + GR_INHERITLEARN = 0x00004000,
70009 + GR_PROCFIND = 0x00008000,
70010 + GR_POVERRIDE = 0x00010000,
70011 + GR_KERNELAUTH = 0x00020000,
70012 + GR_ATSECURE = 0x00040000,
70013 + GR_SHMEXEC = 0x00080000
70014 +};
70015 +
70016 +enum {
70017 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
70018 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
70019 + GR_PAX_ENABLE_MPROTECT = 0x0004,
70020 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
70021 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
70022 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
70023 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
70024 + GR_PAX_DISABLE_MPROTECT = 0x0400,
70025 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
70026 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
70027 +};
70028 +
70029 +enum {
70030 + GR_ID_USER = 0x01,
70031 + GR_ID_GROUP = 0x02,
70032 +};
70033 +
70034 +enum {
70035 + GR_ID_ALLOW = 0x01,
70036 + GR_ID_DENY = 0x02,
70037 +};
70038 +
70039 +#define GR_CRASH_RES 31
70040 +#define GR_UIDTABLE_MAX 500
70041 +
70042 +/* begin resource learning section */
70043 +enum {
70044 + GR_RLIM_CPU_BUMP = 60,
70045 + GR_RLIM_FSIZE_BUMP = 50000,
70046 + GR_RLIM_DATA_BUMP = 10000,
70047 + GR_RLIM_STACK_BUMP = 1000,
70048 + GR_RLIM_CORE_BUMP = 10000,
70049 + GR_RLIM_RSS_BUMP = 500000,
70050 + GR_RLIM_NPROC_BUMP = 1,
70051 + GR_RLIM_NOFILE_BUMP = 5,
70052 + GR_RLIM_MEMLOCK_BUMP = 50000,
70053 + GR_RLIM_AS_BUMP = 500000,
70054 + GR_RLIM_LOCKS_BUMP = 2,
70055 + GR_RLIM_SIGPENDING_BUMP = 5,
70056 + GR_RLIM_MSGQUEUE_BUMP = 10000,
70057 + GR_RLIM_NICE_BUMP = 1,
70058 + GR_RLIM_RTPRIO_BUMP = 1,
70059 + GR_RLIM_RTTIME_BUMP = 1000000
70060 +};
70061 +
70062 +#endif
70063 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
70064 new file mode 100644
70065 index 0000000..fd8598b
70066 --- /dev/null
70067 +++ b/include/linux/grinternal.h
70068 @@ -0,0 +1,228 @@
70069 +#ifndef __GRINTERNAL_H
70070 +#define __GRINTERNAL_H
70071 +
70072 +#ifdef CONFIG_GRKERNSEC
70073 +
70074 +#include <linux/fs.h>
70075 +#include <linux/mnt_namespace.h>
70076 +#include <linux/nsproxy.h>
70077 +#include <linux/gracl.h>
70078 +#include <linux/grdefs.h>
70079 +#include <linux/grmsg.h>
70080 +
70081 +void gr_add_learn_entry(const char *fmt, ...)
70082 + __attribute__ ((format (printf, 1, 2)));
70083 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
70084 + const struct vfsmount *mnt);
70085 +__u32 gr_check_create(const struct dentry *new_dentry,
70086 + const struct dentry *parent,
70087 + const struct vfsmount *mnt, const __u32 mode);
70088 +int gr_check_protected_task(const struct task_struct *task);
70089 +__u32 to_gr_audit(const __u32 reqmode);
70090 +int gr_set_acls(const int type);
70091 +int gr_apply_subject_to_task(struct task_struct *task);
70092 +int gr_acl_is_enabled(void);
70093 +char gr_roletype_to_char(void);
70094 +
70095 +void gr_handle_alertkill(struct task_struct *task);
70096 +char *gr_to_filename(const struct dentry *dentry,
70097 + const struct vfsmount *mnt);
70098 +char *gr_to_filename1(const struct dentry *dentry,
70099 + const struct vfsmount *mnt);
70100 +char *gr_to_filename2(const struct dentry *dentry,
70101 + const struct vfsmount *mnt);
70102 +char *gr_to_filename3(const struct dentry *dentry,
70103 + const struct vfsmount *mnt);
70104 +
70105 +extern int grsec_enable_ptrace_readexec;
70106 +extern int grsec_enable_harden_ptrace;
70107 +extern int grsec_enable_link;
70108 +extern int grsec_enable_fifo;
70109 +extern int grsec_enable_execve;
70110 +extern int grsec_enable_shm;
70111 +extern int grsec_enable_execlog;
70112 +extern int grsec_enable_signal;
70113 +extern int grsec_enable_audit_ptrace;
70114 +extern int grsec_enable_forkfail;
70115 +extern int grsec_enable_time;
70116 +extern int grsec_enable_rofs;
70117 +extern int grsec_enable_chroot_shmat;
70118 +extern int grsec_enable_chroot_mount;
70119 +extern int grsec_enable_chroot_double;
70120 +extern int grsec_enable_chroot_pivot;
70121 +extern int grsec_enable_chroot_chdir;
70122 +extern int grsec_enable_chroot_chmod;
70123 +extern int grsec_enable_chroot_mknod;
70124 +extern int grsec_enable_chroot_fchdir;
70125 +extern int grsec_enable_chroot_nice;
70126 +extern int grsec_enable_chroot_execlog;
70127 +extern int grsec_enable_chroot_caps;
70128 +extern int grsec_enable_chroot_sysctl;
70129 +extern int grsec_enable_chroot_unix;
70130 +extern int grsec_enable_symlinkown;
70131 +extern kgid_t grsec_symlinkown_gid;
70132 +extern int grsec_enable_tpe;
70133 +extern kgid_t grsec_tpe_gid;
70134 +extern int grsec_enable_tpe_all;
70135 +extern int grsec_enable_tpe_invert;
70136 +extern int grsec_enable_socket_all;
70137 +extern kgid_t grsec_socket_all_gid;
70138 +extern int grsec_enable_socket_client;
70139 +extern kgid_t grsec_socket_client_gid;
70140 +extern int grsec_enable_socket_server;
70141 +extern kgid_t grsec_socket_server_gid;
70142 +extern kgid_t grsec_audit_gid;
70143 +extern int grsec_enable_group;
70144 +extern int grsec_enable_log_rwxmaps;
70145 +extern int grsec_enable_mount;
70146 +extern int grsec_enable_chdir;
70147 +extern int grsec_resource_logging;
70148 +extern int grsec_enable_blackhole;
70149 +extern int grsec_lastack_retries;
70150 +extern int grsec_enable_brute;
70151 +extern int grsec_lock;
70152 +
70153 +extern spinlock_t grsec_alert_lock;
70154 +extern unsigned long grsec_alert_wtime;
70155 +extern unsigned long grsec_alert_fyet;
70156 +
70157 +extern spinlock_t grsec_audit_lock;
70158 +
70159 +extern rwlock_t grsec_exec_file_lock;
70160 +
70161 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
70162 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
70163 + (tsk)->exec_file->f_path.mnt) : "/")
70164 +
70165 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
70166 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
70167 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
70168 +
70169 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
70170 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
70171 + (tsk)->exec_file->f_path.mnt) : "/")
70172 +
70173 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
70174 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
70175 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
70176 +
70177 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
70178 +
70179 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
70180 +
70181 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
70182 +{
70183 + if (file1 && file2) {
70184 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
70185 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
70186 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
70187 + return true;
70188 + }
70189 +
70190 + return false;
70191 +}
70192 +
70193 +#define GR_CHROOT_CAPS {{ \
70194 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
70195 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
70196 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
70197 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
70198 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
70199 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
70200 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
70201 +
70202 +#define security_learn(normal_msg,args...) \
70203 +({ \
70204 + read_lock(&grsec_exec_file_lock); \
70205 + gr_add_learn_entry(normal_msg "\n", ## args); \
70206 + read_unlock(&grsec_exec_file_lock); \
70207 +})
70208 +
70209 +enum {
70210 + GR_DO_AUDIT,
70211 + GR_DONT_AUDIT,
70212 + /* used for non-audit messages that we shouldn't kill the task on */
70213 + GR_DONT_AUDIT_GOOD
70214 +};
70215 +
70216 +enum {
70217 + GR_TTYSNIFF,
70218 + GR_RBAC,
70219 + GR_RBAC_STR,
70220 + GR_STR_RBAC,
70221 + GR_RBAC_MODE2,
70222 + GR_RBAC_MODE3,
70223 + GR_FILENAME,
70224 + GR_SYSCTL_HIDDEN,
70225 + GR_NOARGS,
70226 + GR_ONE_INT,
70227 + GR_ONE_INT_TWO_STR,
70228 + GR_ONE_STR,
70229 + GR_STR_INT,
70230 + GR_TWO_STR_INT,
70231 + GR_TWO_INT,
70232 + GR_TWO_U64,
70233 + GR_THREE_INT,
70234 + GR_FIVE_INT_TWO_STR,
70235 + GR_TWO_STR,
70236 + GR_THREE_STR,
70237 + GR_FOUR_STR,
70238 + GR_STR_FILENAME,
70239 + GR_FILENAME_STR,
70240 + GR_FILENAME_TWO_INT,
70241 + GR_FILENAME_TWO_INT_STR,
70242 + GR_TEXTREL,
70243 + GR_PTRACE,
70244 + GR_RESOURCE,
70245 + GR_CAP,
70246 + GR_SIG,
70247 + GR_SIG2,
70248 + GR_CRASH1,
70249 + GR_CRASH2,
70250 + GR_PSACCT,
70251 + GR_RWXMAP,
70252 + GR_RWXMAPVMA
70253 +};
70254 +
70255 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
70256 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
70257 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
70258 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
70259 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
70260 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
70261 +#define gr_log_fs_rbac_mode3(audit, msg, dentry, mnt, str1, str2, str3) gr_log_varargs(audit, msg, GR_RBAC_MODE3, dentry, mnt, str1, str2, str3)
70262 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
70263 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
70264 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
70265 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
70266 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
70267 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
70268 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
70269 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
70270 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
70271 +#define gr_log_int5_str2(audit, msg, num1, num2, str1, str2) gr_log_varargs(audit, msg, GR_FIVE_INT_TWO_STR, num1, num2, str1, str2)
70272 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
70273 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
70274 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
70275 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
70276 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
70277 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
70278 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
70279 +#define gr_log_fs_int2_str(audit, msg, dentry, mnt, num1, num2, str) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT_STR, dentry, mnt, num1, num2, str)
70280 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
70281 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
70282 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
70283 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
70284 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
70285 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
70286 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
70287 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
70288 +#define gr_log_procacct(audit, msg, task, num1, num2, num3, num4, num5, num6, num7, num8, num9) gr_log_varargs(audit, msg, GR_PSACCT, task, num1, num2, num3, num4, num5, num6, num7, num8, num9)
70289 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
70290 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
70291 +
70292 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
70293 +
70294 +#endif
70295 +
70296 +#endif
70297 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
70298 new file mode 100644
70299 index 0000000..a4396b5
70300 --- /dev/null
70301 +++ b/include/linux/grmsg.h
70302 @@ -0,0 +1,113 @@
70303 +#define DEFAULTSECMSG "%.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u, parent %.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u"
70304 +#define GR_ACL_PROCACCT_MSG "%.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u run time:[%ud %uh %um %us] cpu time:[%ud %uh %um %us] %s with exit code %ld, parent %.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u"
70305 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
70306 +#define GR_STOPMOD_MSG "denied modification of module state by "
70307 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
70308 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
70309 +#define GR_IOPERM_MSG "denied use of ioperm() by "
70310 +#define GR_IOPL_MSG "denied use of iopl() by "
70311 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
70312 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
70313 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
70314 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
70315 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
70316 +#define GR_LEARN_AUDIT_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%lu\t%lu\t%.4095s\t%lu\t%pI4"
70317 +#define GR_ID_LEARN_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%c\t%d\t%d\t%d\t%pI4"
70318 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
70319 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
70320 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
70321 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
70322 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
70323 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
70324 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
70325 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
70326 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
70327 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
70328 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
70329 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
70330 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
70331 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
70332 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
70333 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
70334 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
70335 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
70336 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
70337 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
70338 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
70339 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
70340 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
70341 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
70342 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
70343 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
70344 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
70345 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
70346 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
70347 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
70348 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
70349 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
70350 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
70351 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
70352 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
70353 +#define GR_DISABLED_ACL_MSG "Error loading %s, trying to run kernel with acls disabled. To disable acls at startup use <kernel image name> gracl=off from your boot loader"
70354 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
70355 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
70356 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
70357 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
70358 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
70359 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
70360 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
70361 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
70362 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
70363 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
70364 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
70365 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
70366 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
70367 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
70368 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
70369 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
70370 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
70371 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
70372 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
70373 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
70374 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
70375 +#define GR_NICE_CHROOT_MSG "denied priority change by "
70376 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
70377 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
70378 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
70379 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
70380 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
70381 +#define GR_TIME_MSG "time set by "
70382 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
70383 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
70384 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
70385 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
70386 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
70387 +#define GR_BIND_MSG "denied bind() by "
70388 +#define GR_CONNECT_MSG "denied connect() by "
70389 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
70390 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
70391 +#define GR_IP_LEARN_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%pI4\t%u\t%u\t%u\t%u\t%pI4"
70392 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
70393 +#define GR_CAP_ACL_MSG "use of %s denied for "
70394 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
70395 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
70396 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
70397 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
70398 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
70399 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
70400 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
70401 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
70402 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
70403 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
70404 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
70405 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
70406 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
70407 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
70408 +#define GR_VM86_MSG "denied use of vm86 by "
70409 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
70410 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
70411 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
70412 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
70413 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
70414 +#define GR_BRUTE_DAEMON_MSG "bruteforce prevention initiated for the next 30 minutes or until service restarted, stalling each fork 30 seconds. Please investigate the crash report for "
70415 +#define GR_BRUTE_SUID_MSG "bruteforce prevention initiated due to crash of %.950s against uid %u, banning suid/sgid execs for %u minutes. Please investigate the crash report for "
70416 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
70417 new file mode 100644
70418 index 0000000..3676b0b
70419 --- /dev/null
70420 +++ b/include/linux/grsecurity.h
70421 @@ -0,0 +1,242 @@
70422 +#ifndef GR_SECURITY_H
70423 +#define GR_SECURITY_H
70424 +#include <linux/fs.h>
70425 +#include <linux/fs_struct.h>
70426 +#include <linux/binfmts.h>
70427 +#include <linux/gracl.h>
70428 +
70429 +/* notify of brain-dead configs */
70430 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70431 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
70432 +#endif
70433 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
70434 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
70435 +#endif
70436 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
70437 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
70438 +#endif
70439 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
70440 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
70441 +#endif
70442 +
70443 +void gr_handle_brute_attach(unsigned long mm_flags);
70444 +void gr_handle_brute_check(void);
70445 +void gr_handle_kernel_exploit(void);
70446 +
70447 +char gr_roletype_to_char(void);
70448 +
70449 +int gr_acl_enable_at_secure(void);
70450 +
70451 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
70452 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
70453 +
70454 +void gr_del_task_from_ip_table(struct task_struct *p);
70455 +
70456 +int gr_pid_is_chrooted(struct task_struct *p);
70457 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
70458 +int gr_handle_chroot_nice(void);
70459 +int gr_handle_chroot_sysctl(const int op);
70460 +int gr_handle_chroot_setpriority(struct task_struct *p,
70461 + const int niceval);
70462 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
70463 +int gr_handle_chroot_chroot(const struct dentry *dentry,
70464 + const struct vfsmount *mnt);
70465 +void gr_handle_chroot_chdir(const struct path *path);
70466 +int gr_handle_chroot_chmod(const struct dentry *dentry,
70467 + const struct vfsmount *mnt, const int mode);
70468 +int gr_handle_chroot_mknod(const struct dentry *dentry,
70469 + const struct vfsmount *mnt, const int mode);
70470 +int gr_handle_chroot_mount(const struct dentry *dentry,
70471 + const struct vfsmount *mnt,
70472 + const char *dev_name);
70473 +int gr_handle_chroot_pivot(void);
70474 +int gr_handle_chroot_unix(const pid_t pid);
70475 +
70476 +int gr_handle_rawio(const struct inode *inode);
70477 +
70478 +void gr_handle_ioperm(void);
70479 +void gr_handle_iopl(void);
70480 +
70481 +umode_t gr_acl_umask(void);
70482 +
70483 +int gr_tpe_allow(const struct file *file);
70484 +
70485 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
70486 +void gr_clear_chroot_entries(struct task_struct *task);
70487 +
70488 +void gr_log_forkfail(const int retval);
70489 +void gr_log_timechange(void);
70490 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
70491 +void gr_log_chdir(const struct dentry *dentry,
70492 + const struct vfsmount *mnt);
70493 +void gr_log_chroot_exec(const struct dentry *dentry,
70494 + const struct vfsmount *mnt);
70495 +void gr_log_remount(const char *devname, const int retval);
70496 +void gr_log_unmount(const char *devname, const int retval);
70497 +void gr_log_mount(const char *from, const char *to, const int retval);
70498 +void gr_log_textrel(struct vm_area_struct *vma);
70499 +void gr_log_ptgnustack(struct file *file);
70500 +void gr_log_rwxmmap(struct file *file);
70501 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
70502 +
70503 +int gr_handle_follow_link(const struct inode *parent,
70504 + const struct inode *inode,
70505 + const struct dentry *dentry,
70506 + const struct vfsmount *mnt);
70507 +int gr_handle_fifo(const struct dentry *dentry,
70508 + const struct vfsmount *mnt,
70509 + const struct dentry *dir, const int flag,
70510 + const int acc_mode);
70511 +int gr_handle_hardlink(const struct dentry *dentry,
70512 + const struct vfsmount *mnt,
70513 + struct inode *inode,
70514 + const int mode, const struct filename *to);
70515 +
70516 +int gr_is_capable(const int cap);
70517 +int gr_is_capable_nolog(const int cap);
70518 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70519 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
70520 +
70521 +void gr_copy_label(struct task_struct *tsk);
70522 +void gr_handle_crash(struct task_struct *task, const int sig);
70523 +int gr_handle_signal(const struct task_struct *p, const int sig);
70524 +int gr_check_crash_uid(const kuid_t uid);
70525 +int gr_check_protected_task(const struct task_struct *task);
70526 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
70527 +int gr_acl_handle_mmap(const struct file *file,
70528 + const unsigned long prot);
70529 +int gr_acl_handle_mprotect(const struct file *file,
70530 + const unsigned long prot);
70531 +int gr_check_hidden_task(const struct task_struct *tsk);
70532 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
70533 + const struct vfsmount *mnt);
70534 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
70535 + const struct vfsmount *mnt);
70536 +__u32 gr_acl_handle_access(const struct dentry *dentry,
70537 + const struct vfsmount *mnt, const int fmode);
70538 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
70539 + const struct vfsmount *mnt, umode_t *mode);
70540 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
70541 + const struct vfsmount *mnt);
70542 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
70543 + const struct vfsmount *mnt);
70544 +int gr_handle_ptrace(struct task_struct *task, const long request);
70545 +int gr_handle_proc_ptrace(struct task_struct *task);
70546 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
70547 + const struct vfsmount *mnt);
70548 +int gr_check_crash_exec(const struct file *filp);
70549 +int gr_acl_is_enabled(void);
70550 +void gr_set_kernel_label(struct task_struct *task);
70551 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
70552 + const kgid_t gid);
70553 +int gr_set_proc_label(const struct dentry *dentry,
70554 + const struct vfsmount *mnt,
70555 + const int unsafe_flags);
70556 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
70557 + const struct vfsmount *mnt);
70558 +__u32 gr_acl_handle_open(const struct dentry *dentry,
70559 + const struct vfsmount *mnt, int acc_mode);
70560 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
70561 + const struct dentry *p_dentry,
70562 + const struct vfsmount *p_mnt,
70563 + int open_flags, int acc_mode, const int imode);
70564 +void gr_handle_create(const struct dentry *dentry,
70565 + const struct vfsmount *mnt);
70566 +void gr_handle_proc_create(const struct dentry *dentry,
70567 + const struct inode *inode);
70568 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
70569 + const struct dentry *parent_dentry,
70570 + const struct vfsmount *parent_mnt,
70571 + const int mode);
70572 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
70573 + const struct dentry *parent_dentry,
70574 + const struct vfsmount *parent_mnt);
70575 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
70576 + const struct vfsmount *mnt);
70577 +void gr_handle_delete(const ino_t ino, const dev_t dev);
70578 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
70579 + const struct vfsmount *mnt);
70580 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
70581 + const struct dentry *parent_dentry,
70582 + const struct vfsmount *parent_mnt,
70583 + const struct filename *from);
70584 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
70585 + const struct dentry *parent_dentry,
70586 + const struct vfsmount *parent_mnt,
70587 + const struct dentry *old_dentry,
70588 + const struct vfsmount *old_mnt, const struct filename *to);
70589 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
70590 +int gr_acl_handle_rename(struct dentry *new_dentry,
70591 + struct dentry *parent_dentry,
70592 + const struct vfsmount *parent_mnt,
70593 + struct dentry *old_dentry,
70594 + struct inode *old_parent_inode,
70595 + struct vfsmount *old_mnt, const struct filename *newname);
70596 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70597 + struct dentry *old_dentry,
70598 + struct dentry *new_dentry,
70599 + struct vfsmount *mnt, const __u8 replace);
70600 +__u32 gr_check_link(const struct dentry *new_dentry,
70601 + const struct dentry *parent_dentry,
70602 + const struct vfsmount *parent_mnt,
70603 + const struct dentry *old_dentry,
70604 + const struct vfsmount *old_mnt);
70605 +int gr_acl_handle_filldir(const struct file *file, const char *name,
70606 + const unsigned int namelen, const ino_t ino);
70607 +
70608 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
70609 + const struct vfsmount *mnt);
70610 +void gr_acl_handle_exit(void);
70611 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
70612 +int gr_acl_handle_procpidmem(const struct task_struct *task);
70613 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
70614 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
70615 +void gr_audit_ptrace(struct task_struct *task);
70616 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
70617 +void gr_put_exec_file(struct task_struct *task);
70618 +
70619 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
70620 +
70621 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
70622 +extern void gr_learn_resource(const struct task_struct *task, const int res,
70623 + const unsigned long wanted, const int gt);
70624 +#else
70625 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
70626 + const unsigned long wanted, const int gt)
70627 +{
70628 +}
70629 +#endif
70630 +
70631 +#ifdef CONFIG_GRKERNSEC_RESLOG
70632 +extern void gr_log_resource(const struct task_struct *task, const int res,
70633 + const unsigned long wanted, const int gt);
70634 +#else
70635 +static inline void gr_log_resource(const struct task_struct *task, const int res,
70636 + const unsigned long wanted, const int gt)
70637 +{
70638 +}
70639 +#endif
70640 +
70641 +#ifdef CONFIG_GRKERNSEC
70642 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
70643 +void gr_handle_vm86(void);
70644 +void gr_handle_mem_readwrite(u64 from, u64 to);
70645 +
70646 +void gr_log_badprocpid(const char *entry);
70647 +
70648 +extern int grsec_enable_dmesg;
70649 +extern int grsec_disable_privio;
70650 +
70651 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
70652 +extern kgid_t grsec_proc_gid;
70653 +#endif
70654 +
70655 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70656 +extern int grsec_enable_chroot_findtask;
70657 +#endif
70658 +#ifdef CONFIG_GRKERNSEC_SETXID
70659 +extern int grsec_enable_setxid;
70660 +#endif
70661 +#endif
70662 +
70663 +#endif
70664 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
70665 new file mode 100644
70666 index 0000000..e7ffaaf
70667 --- /dev/null
70668 +++ b/include/linux/grsock.h
70669 @@ -0,0 +1,19 @@
70670 +#ifndef __GRSOCK_H
70671 +#define __GRSOCK_H
70672 +
70673 +extern void gr_attach_curr_ip(const struct sock *sk);
70674 +extern int gr_handle_sock_all(const int family, const int type,
70675 + const int protocol);
70676 +extern int gr_handle_sock_server(const struct sockaddr *sck);
70677 +extern int gr_handle_sock_server_other(const struct sock *sck);
70678 +extern int gr_handle_sock_client(const struct sockaddr *sck);
70679 +extern int gr_search_connect(struct socket * sock,
70680 + struct sockaddr_in * addr);
70681 +extern int gr_search_bind(struct socket * sock,
70682 + struct sockaddr_in * addr);
70683 +extern int gr_search_listen(struct socket * sock);
70684 +extern int gr_search_accept(struct socket * sock);
70685 +extern int gr_search_socket(const int domain, const int type,
70686 + const int protocol);
70687 +
70688 +#endif
70689 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
70690 index 7fb31da..08b5114 100644
70691 --- a/include/linux/highmem.h
70692 +++ b/include/linux/highmem.h
70693 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
70694 kunmap_atomic(kaddr);
70695 }
70696
70697 +static inline void sanitize_highpage(struct page *page)
70698 +{
70699 + void *kaddr;
70700 + unsigned long flags;
70701 +
70702 + local_irq_save(flags);
70703 + kaddr = kmap_atomic(page);
70704 + clear_page(kaddr);
70705 + kunmap_atomic(kaddr);
70706 + local_irq_restore(flags);
70707 +}
70708 +
70709 static inline void zero_user_segments(struct page *page,
70710 unsigned start1, unsigned end1,
70711 unsigned start2, unsigned end2)
70712 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
70713 index 1c7b89a..7f52502 100644
70714 --- a/include/linux/hwmon-sysfs.h
70715 +++ b/include/linux/hwmon-sysfs.h
70716 @@ -25,7 +25,8 @@
70717 struct sensor_device_attribute{
70718 struct device_attribute dev_attr;
70719 int index;
70720 -};
70721 +} __do_const;
70722 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
70723 #define to_sensor_dev_attr(_dev_attr) \
70724 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
70725
70726 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
70727 struct device_attribute dev_attr;
70728 u8 index;
70729 u8 nr;
70730 -};
70731 +} __do_const;
70732 #define to_sensor_dev_attr_2(_dev_attr) \
70733 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
70734
70735 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
70736 index e988fa9..ff9f17e 100644
70737 --- a/include/linux/i2c.h
70738 +++ b/include/linux/i2c.h
70739 @@ -366,6 +366,7 @@ struct i2c_algorithm {
70740 /* To determine what the adapter supports */
70741 u32 (*functionality) (struct i2c_adapter *);
70742 };
70743 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
70744
70745 /**
70746 * struct i2c_bus_recovery_info - I2C bus recovery information
70747 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
70748 index d23c3c2..eb63c81 100644
70749 --- a/include/linux/i2o.h
70750 +++ b/include/linux/i2o.h
70751 @@ -565,7 +565,7 @@ struct i2o_controller {
70752 struct i2o_device *exec; /* Executive */
70753 #if BITS_PER_LONG == 64
70754 spinlock_t context_list_lock; /* lock for context_list */
70755 - atomic_t context_list_counter; /* needed for unique contexts */
70756 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
70757 struct list_head context_list; /* list of context id's
70758 and pointers */
70759 #endif
70760 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
70761 index aff7ad8..3942bbd 100644
70762 --- a/include/linux/if_pppox.h
70763 +++ b/include/linux/if_pppox.h
70764 @@ -76,7 +76,7 @@ struct pppox_proto {
70765 int (*ioctl)(struct socket *sock, unsigned int cmd,
70766 unsigned long arg);
70767 struct module *owner;
70768 -};
70769 +} __do_const;
70770
70771 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
70772 extern void unregister_pppox_proto(int proto_num);
70773 diff --git a/include/linux/init.h b/include/linux/init.h
70774 index 8618147..0821126 100644
70775 --- a/include/linux/init.h
70776 +++ b/include/linux/init.h
70777 @@ -39,9 +39,36 @@
70778 * Also note, that this data cannot be "const".
70779 */
70780
70781 +#ifdef MODULE
70782 +#define add_init_latent_entropy
70783 +#define add_devinit_latent_entropy
70784 +#define add_cpuinit_latent_entropy
70785 +#define add_meminit_latent_entropy
70786 +#else
70787 +#define add_init_latent_entropy __latent_entropy
70788 +
70789 +#ifdef CONFIG_HOTPLUG
70790 +#define add_devinit_latent_entropy
70791 +#else
70792 +#define add_devinit_latent_entropy __latent_entropy
70793 +#endif
70794 +
70795 +#ifdef CONFIG_HOTPLUG_CPU
70796 +#define add_cpuinit_latent_entropy
70797 +#else
70798 +#define add_cpuinit_latent_entropy __latent_entropy
70799 +#endif
70800 +
70801 +#ifdef CONFIG_MEMORY_HOTPLUG
70802 +#define add_meminit_latent_entropy
70803 +#else
70804 +#define add_meminit_latent_entropy __latent_entropy
70805 +#endif
70806 +#endif
70807 +
70808 /* These are for everybody (although not all archs will actually
70809 discard it in modules) */
70810 -#define __init __section(.init.text) __cold notrace
70811 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
70812 #define __initdata __section(.init.data)
70813 #define __initconst __constsection(.init.rodata)
70814 #define __exitdata __section(.exit.data)
70815 @@ -94,7 +121,7 @@
70816 #define __exit __section(.exit.text) __exitused __cold notrace
70817
70818 /* Used for HOTPLUG_CPU */
70819 -#define __cpuinit __section(.cpuinit.text) __cold notrace
70820 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
70821 #define __cpuinitdata __section(.cpuinit.data)
70822 #define __cpuinitconst __constsection(.cpuinit.rodata)
70823 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
70824 @@ -102,7 +129,7 @@
70825 #define __cpuexitconst __constsection(.cpuexit.rodata)
70826
70827 /* Used for MEMORY_HOTPLUG */
70828 -#define __meminit __section(.meminit.text) __cold notrace
70829 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
70830 #define __meminitdata __section(.meminit.data)
70831 #define __meminitconst __constsection(.meminit.rodata)
70832 #define __memexit __section(.memexit.text) __exitused __cold notrace
70833 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
70834 index 5cd0f09..c9f67cc 100644
70835 --- a/include/linux/init_task.h
70836 +++ b/include/linux/init_task.h
70837 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
70838
70839 #define INIT_TASK_COMM "swapper"
70840
70841 +#ifdef CONFIG_X86
70842 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
70843 +#else
70844 +#define INIT_TASK_THREAD_INFO
70845 +#endif
70846 +
70847 /*
70848 * INIT_TASK is used to set up the first task table, touch at
70849 * your own risk!. Base=0, limit=0x1fffff (=2MB)
70850 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
70851 RCU_POINTER_INITIALIZER(cred, &init_cred), \
70852 .comm = INIT_TASK_COMM, \
70853 .thread = INIT_THREAD, \
70854 + INIT_TASK_THREAD_INFO \
70855 .fs = &init_fs, \
70856 .files = &init_files, \
70857 .signal = &init_signals, \
70858 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
70859 index 5fa5afe..ac55b25 100644
70860 --- a/include/linux/interrupt.h
70861 +++ b/include/linux/interrupt.h
70862 @@ -430,7 +430,7 @@ enum
70863 /* map softirq index to softirq name. update 'softirq_to_name' in
70864 * kernel/softirq.c when adding a new softirq.
70865 */
70866 -extern char *softirq_to_name[NR_SOFTIRQS];
70867 +extern const char * const softirq_to_name[NR_SOFTIRQS];
70868
70869 /* softirq mask and active fields moved to irq_cpustat_t in
70870 * asm/hardirq.h to get better cache usage. KAO
70871 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70872
70873 struct softirq_action
70874 {
70875 - void (*action)(struct softirq_action *);
70876 -};
70877 + void (*action)(void);
70878 +} __no_const;
70879
70880 asmlinkage void do_softirq(void);
70881 asmlinkage void __do_softirq(void);
70882 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70883 +extern void open_softirq(int nr, void (*action)(void));
70884 extern void softirq_init(void);
70885 extern void __raise_softirq_irqoff(unsigned int nr);
70886
70887 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70888 index 3aeb730..2177f39 100644
70889 --- a/include/linux/iommu.h
70890 +++ b/include/linux/iommu.h
70891 @@ -113,7 +113,7 @@ struct iommu_ops {
70892 u32 (*domain_get_windows)(struct iommu_domain *domain);
70893
70894 unsigned long pgsize_bitmap;
70895 -};
70896 +} __do_const;
70897
70898 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70899 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70900 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70901 index 89b7c24..382af74 100644
70902 --- a/include/linux/ioport.h
70903 +++ b/include/linux/ioport.h
70904 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70905 int adjust_resource(struct resource *res, resource_size_t start,
70906 resource_size_t size);
70907 resource_size_t resource_alignment(struct resource *res);
70908 -static inline resource_size_t resource_size(const struct resource *res)
70909 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70910 {
70911 return res->end - res->start + 1;
70912 }
70913 diff --git a/include/linux/irq.h b/include/linux/irq.h
70914 index bc4e066..50468a9 100644
70915 --- a/include/linux/irq.h
70916 +++ b/include/linux/irq.h
70917 @@ -328,7 +328,8 @@ struct irq_chip {
70918 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70919
70920 unsigned long flags;
70921 -};
70922 +} __do_const;
70923 +typedef struct irq_chip __no_const irq_chip_no_const;
70924
70925 /*
70926 * irq_chip specific flags
70927 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
70928 index 3e203eb..3fe68d0 100644
70929 --- a/include/linux/irqchip/arm-gic.h
70930 +++ b/include/linux/irqchip/arm-gic.h
70931 @@ -59,9 +59,11 @@
70932
70933 #ifndef __ASSEMBLY__
70934
70935 +#include <linux/irq.h>
70936 +
70937 struct device_node;
70938
70939 -extern struct irq_chip gic_arch_extn;
70940 +extern irq_chip_no_const gic_arch_extn;
70941
70942 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
70943 u32 offset, struct device_node *);
70944 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70945 index 6883e19..06992b1 100644
70946 --- a/include/linux/kallsyms.h
70947 +++ b/include/linux/kallsyms.h
70948 @@ -15,7 +15,8 @@
70949
70950 struct module;
70951
70952 -#ifdef CONFIG_KALLSYMS
70953 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70954 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70955 /* Lookup the address for a symbol. Returns 0 if not found. */
70956 unsigned long kallsyms_lookup_name(const char *name);
70957
70958 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70959 /* Stupid that this does nothing, but I didn't create this mess. */
70960 #define __print_symbol(fmt, addr)
70961 #endif /*CONFIG_KALLSYMS*/
70962 +#else /* when included by kallsyms.c, vsnprintf.c, or
70963 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70964 +extern void __print_symbol(const char *fmt, unsigned long address);
70965 +extern int sprint_backtrace(char *buffer, unsigned long address);
70966 +extern int sprint_symbol(char *buffer, unsigned long address);
70967 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70968 +const char *kallsyms_lookup(unsigned long addr,
70969 + unsigned long *symbolsize,
70970 + unsigned long *offset,
70971 + char **modname, char *namebuf);
70972 +#endif
70973
70974 /* This macro allows us to keep printk typechecking */
70975 static __printf(1, 2)
70976 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70977 index 518a53a..5e28358 100644
70978 --- a/include/linux/key-type.h
70979 +++ b/include/linux/key-type.h
70980 @@ -125,7 +125,7 @@ struct key_type {
70981 /* internal fields */
70982 struct list_head link; /* link in types list */
70983 struct lock_class_key lock_class; /* key->sem lock class */
70984 -};
70985 +} __do_const;
70986
70987 extern struct key_type key_type_keyring;
70988
70989 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70990 index c6e091b..a940adf 100644
70991 --- a/include/linux/kgdb.h
70992 +++ b/include/linux/kgdb.h
70993 @@ -52,7 +52,7 @@ extern int kgdb_connected;
70994 extern int kgdb_io_module_registered;
70995
70996 extern atomic_t kgdb_setting_breakpoint;
70997 -extern atomic_t kgdb_cpu_doing_single_step;
70998 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70999
71000 extern struct task_struct *kgdb_usethread;
71001 extern struct task_struct *kgdb_contthread;
71002 @@ -254,7 +254,7 @@ struct kgdb_arch {
71003 void (*correct_hw_break)(void);
71004
71005 void (*enable_nmi)(bool on);
71006 -};
71007 +} __do_const;
71008
71009 /**
71010 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
71011 @@ -279,7 +279,7 @@ struct kgdb_io {
71012 void (*pre_exception) (void);
71013 void (*post_exception) (void);
71014 int is_console;
71015 -};
71016 +} __do_const;
71017
71018 extern struct kgdb_arch arch_kgdb_ops;
71019
71020 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
71021 index 0555cc6..b16a7a4 100644
71022 --- a/include/linux/kmod.h
71023 +++ b/include/linux/kmod.h
71024 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
71025 * usually useless though. */
71026 extern __printf(2, 3)
71027 int __request_module(bool wait, const char *name, ...);
71028 +extern __printf(3, 4)
71029 +int ___request_module(bool wait, char *param_name, const char *name, ...);
71030 #define request_module(mod...) __request_module(true, mod)
71031 #define request_module_nowait(mod...) __request_module(false, mod)
71032 #define try_then_request_module(x, mod...) \
71033 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
71034 index 939b112..ed6ed51 100644
71035 --- a/include/linux/kobject.h
71036 +++ b/include/linux/kobject.h
71037 @@ -111,7 +111,7 @@ struct kobj_type {
71038 struct attribute **default_attrs;
71039 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
71040 const void *(*namespace)(struct kobject *kobj);
71041 -};
71042 +} __do_const;
71043
71044 struct kobj_uevent_env {
71045 char *envp[UEVENT_NUM_ENVP];
71046 @@ -134,6 +134,7 @@ struct kobj_attribute {
71047 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
71048 const char *buf, size_t count);
71049 };
71050 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
71051
71052 extern const struct sysfs_ops kobj_sysfs_ops;
71053
71054 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
71055 index f66b065..c2c29b4 100644
71056 --- a/include/linux/kobject_ns.h
71057 +++ b/include/linux/kobject_ns.h
71058 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
71059 const void *(*netlink_ns)(struct sock *sk);
71060 const void *(*initial_ns)(void);
71061 void (*drop_ns)(void *);
71062 -};
71063 +} __do_const;
71064
71065 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
71066 int kobj_ns_type_registered(enum kobj_ns_type type);
71067 diff --git a/include/linux/kref.h b/include/linux/kref.h
71068 index 484604d..0f6c5b6 100644
71069 --- a/include/linux/kref.h
71070 +++ b/include/linux/kref.h
71071 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
71072 static inline int kref_sub(struct kref *kref, unsigned int count,
71073 void (*release)(struct kref *kref))
71074 {
71075 - WARN_ON(release == NULL);
71076 + BUG_ON(release == NULL);
71077
71078 if (atomic_sub_and_test((int) count, &kref->refcount)) {
71079 release(kref);
71080 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
71081 index 8db53cf..c21121d 100644
71082 --- a/include/linux/kvm_host.h
71083 +++ b/include/linux/kvm_host.h
71084 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
71085 {
71086 }
71087 #endif
71088 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
71089 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
71090 struct module *module);
71091 void kvm_exit(void);
71092
71093 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
71094 struct kvm_guest_debug *dbg);
71095 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
71096
71097 -int kvm_arch_init(void *opaque);
71098 +int kvm_arch_init(const void *opaque);
71099 void kvm_arch_exit(void);
71100
71101 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
71102 diff --git a/include/linux/libata.h b/include/linux/libata.h
71103 index eae7a05..2cdd875 100644
71104 --- a/include/linux/libata.h
71105 +++ b/include/linux/libata.h
71106 @@ -919,7 +919,7 @@ struct ata_port_operations {
71107 * fields must be pointers.
71108 */
71109 const struct ata_port_operations *inherits;
71110 -};
71111 +} __do_const;
71112
71113 struct ata_port_info {
71114 unsigned long flags;
71115 diff --git a/include/linux/list.h b/include/linux/list.h
71116 index b83e565..baa6c1d 100644
71117 --- a/include/linux/list.h
71118 +++ b/include/linux/list.h
71119 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
71120 extern void list_del(struct list_head *entry);
71121 #endif
71122
71123 +extern void __pax_list_add(struct list_head *new,
71124 + struct list_head *prev,
71125 + struct list_head *next);
71126 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
71127 +{
71128 + __pax_list_add(new, head, head->next);
71129 +}
71130 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
71131 +{
71132 + __pax_list_add(new, head->prev, head);
71133 +}
71134 +extern void pax_list_del(struct list_head *entry);
71135 +
71136 /**
71137 * list_replace - replace old entry by new one
71138 * @old : the element to be replaced
71139 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
71140 INIT_LIST_HEAD(entry);
71141 }
71142
71143 +extern void pax_list_del_init(struct list_head *entry);
71144 +
71145 /**
71146 * list_move - delete from one list and add as another's head
71147 * @list: the entry to move
71148 diff --git a/include/linux/math64.h b/include/linux/math64.h
71149 index 2913b86..8dcbb1e 100644
71150 --- a/include/linux/math64.h
71151 +++ b/include/linux/math64.h
71152 @@ -15,7 +15,7 @@
71153 * This is commonly provided by 32bit archs to provide an optimized 64bit
71154 * divide.
71155 */
71156 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71157 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71158 {
71159 *remainder = dividend % divisor;
71160 return dividend / divisor;
71161 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
71162 /**
71163 * div64_u64 - unsigned 64bit divide with 64bit divisor
71164 */
71165 -static inline u64 div64_u64(u64 dividend, u64 divisor)
71166 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
71167 {
71168 return dividend / divisor;
71169 }
71170 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
71171 #define div64_ul(x, y) div_u64((x), (y))
71172
71173 #ifndef div_u64_rem
71174 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71175 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71176 {
71177 *remainder = do_div(dividend, divisor);
71178 return dividend;
71179 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
71180 * divide.
71181 */
71182 #ifndef div_u64
71183 -static inline u64 div_u64(u64 dividend, u32 divisor)
71184 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
71185 {
71186 u32 remainder;
71187 return div_u64_rem(dividend, divisor, &remainder);
71188 diff --git a/include/linux/mm.h b/include/linux/mm.h
71189 index e0c8528..bcf0c29 100644
71190 --- a/include/linux/mm.h
71191 +++ b/include/linux/mm.h
71192 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
71193 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
71194 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
71195 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
71196 +
71197 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71198 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
71199 +#endif
71200 +
71201 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
71202
71203 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
71204 @@ -205,8 +210,8 @@ struct vm_operations_struct {
71205 /* called by access_process_vm when get_user_pages() fails, typically
71206 * for use by special VMAs that can switch between memory and hardware
71207 */
71208 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
71209 - void *buf, int len, int write);
71210 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
71211 + void *buf, size_t len, int write);
71212 #ifdef CONFIG_NUMA
71213 /*
71214 * set_policy() op must add a reference to any non-NULL @new mempolicy
71215 @@ -236,6 +241,7 @@ struct vm_operations_struct {
71216 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
71217 unsigned long size, pgoff_t pgoff);
71218 };
71219 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
71220
71221 struct mmu_gather;
71222 struct inode;
71223 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
71224 unsigned long *pfn);
71225 int follow_phys(struct vm_area_struct *vma, unsigned long address,
71226 unsigned int flags, unsigned long *prot, resource_size_t *phys);
71227 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
71228 - void *buf, int len, int write);
71229 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
71230 + void *buf, size_t len, int write);
71231
71232 static inline void unmap_shared_mapping_range(struct address_space *mapping,
71233 loff_t const holebegin, loff_t const holelen)
71234 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
71235 }
71236 #endif
71237
71238 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
71239 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
71240 - void *buf, int len, int write);
71241 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
71242 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
71243 + void *buf, size_t len, int write);
71244
71245 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
71246 unsigned long start, unsigned long nr_pages,
71247 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
71248 int set_page_dirty_lock(struct page *page);
71249 int clear_page_dirty_for_io(struct page *page);
71250
71251 -/* Is the vma a continuation of the stack vma above it? */
71252 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
71253 -{
71254 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
71255 -}
71256 -
71257 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
71258 - unsigned long addr)
71259 -{
71260 - return (vma->vm_flags & VM_GROWSDOWN) &&
71261 - (vma->vm_start == addr) &&
71262 - !vma_growsdown(vma->vm_prev, addr);
71263 -}
71264 -
71265 -/* Is the vma a continuation of the stack vma below it? */
71266 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
71267 -{
71268 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
71269 -}
71270 -
71271 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
71272 - unsigned long addr)
71273 -{
71274 - return (vma->vm_flags & VM_GROWSUP) &&
71275 - (vma->vm_end == addr) &&
71276 - !vma_growsup(vma->vm_next, addr);
71277 -}
71278 -
71279 extern pid_t
71280 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
71281
71282 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
71283 }
71284 #endif
71285
71286 +#ifdef CONFIG_MMU
71287 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
71288 +#else
71289 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
71290 +{
71291 + return __pgprot(0);
71292 +}
71293 +#endif
71294 +
71295 int vma_wants_writenotify(struct vm_area_struct *vma);
71296
71297 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
71298 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
71299 {
71300 return 0;
71301 }
71302 +
71303 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
71304 + unsigned long address)
71305 +{
71306 + return 0;
71307 +}
71308 #else
71309 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
71310 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
71311 #endif
71312
71313 #ifdef __PAGETABLE_PMD_FOLDED
71314 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
71315 {
71316 return 0;
71317 }
71318 +
71319 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
71320 + unsigned long address)
71321 +{
71322 + return 0;
71323 +}
71324 #else
71325 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
71326 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
71327 #endif
71328
71329 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
71330 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
71331 NULL: pud_offset(pgd, address);
71332 }
71333
71334 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
71335 +{
71336 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
71337 + NULL: pud_offset(pgd, address);
71338 +}
71339 +
71340 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
71341 {
71342 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
71343 NULL: pmd_offset(pud, address);
71344 }
71345 +
71346 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
71347 +{
71348 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
71349 + NULL: pmd_offset(pud, address);
71350 +}
71351 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
71352
71353 #if USE_SPLIT_PTLOCKS
71354 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71355 unsigned long len, unsigned long prot, unsigned long flags,
71356 unsigned long pgoff, unsigned long *populate);
71357 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
71358 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
71359
71360 #ifdef CONFIG_MMU
71361 extern int __mm_populate(unsigned long addr, unsigned long len,
71362 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
71363 unsigned long high_limit;
71364 unsigned long align_mask;
71365 unsigned long align_offset;
71366 + unsigned long threadstack_offset;
71367 };
71368
71369 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
71370 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
71371 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
71372 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
71373
71374 /*
71375 * Search for an unmapped address range.
71376 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
71377 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
71378 */
71379 static inline unsigned long
71380 -vm_unmapped_area(struct vm_unmapped_area_info *info)
71381 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
71382 {
71383 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
71384 return unmapped_area(info);
71385 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
71386 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
71387 struct vm_area_struct **pprev);
71388
71389 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
71390 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
71391 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
71392 +
71393 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
71394 NULL if none. Assume start_addr < end_addr. */
71395 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
71396 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
71397 return vma;
71398 }
71399
71400 -#ifdef CONFIG_MMU
71401 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
71402 -#else
71403 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
71404 -{
71405 - return __pgprot(0);
71406 -}
71407 -#endif
71408 -
71409 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
71410 unsigned long change_prot_numa(struct vm_area_struct *vma,
71411 unsigned long start, unsigned long end);
71412 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
71413 static inline void vm_stat_account(struct mm_struct *mm,
71414 unsigned long flags, struct file *file, long pages)
71415 {
71416 +
71417 +#ifdef CONFIG_PAX_RANDMMAP
71418 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
71419 +#endif
71420 +
71421 mm->total_vm += pages;
71422 }
71423 #endif /* CONFIG_PROC_FS */
71424 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
71425 extern int sysctl_memory_failure_early_kill;
71426 extern int sysctl_memory_failure_recovery;
71427 extern void shake_page(struct page *p, int access);
71428 -extern atomic_long_t num_poisoned_pages;
71429 +extern atomic_long_unchecked_t num_poisoned_pages;
71430 extern int soft_offline_page(struct page *page, int flags);
71431
71432 extern void dump_page(struct page *page);
71433 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
71434 static inline void setup_nr_node_ids(void) {}
71435 #endif
71436
71437 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
71438 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
71439 +#else
71440 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
71441 +#endif
71442 +
71443 #endif /* __KERNEL__ */
71444 #endif /* _LINUX_MM_H */
71445 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
71446 index ace9a5f..81bdb59 100644
71447 --- a/include/linux/mm_types.h
71448 +++ b/include/linux/mm_types.h
71449 @@ -289,6 +289,8 @@ struct vm_area_struct {
71450 #ifdef CONFIG_NUMA
71451 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
71452 #endif
71453 +
71454 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
71455 };
71456
71457 struct core_thread {
71458 @@ -437,6 +439,24 @@ struct mm_struct {
71459 int first_nid;
71460 #endif
71461 struct uprobes_state uprobes_state;
71462 +
71463 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71464 + unsigned long pax_flags;
71465 +#endif
71466 +
71467 +#ifdef CONFIG_PAX_DLRESOLVE
71468 + unsigned long call_dl_resolve;
71469 +#endif
71470 +
71471 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
71472 + unsigned long call_syscall;
71473 +#endif
71474 +
71475 +#ifdef CONFIG_PAX_ASLR
71476 + unsigned long delta_mmap; /* randomized offset */
71477 + unsigned long delta_stack; /* randomized offset */
71478 +#endif
71479 +
71480 };
71481
71482 /* first nid will either be a valid NID or one of these values */
71483 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
71484 index c5d5278..f0b68c8 100644
71485 --- a/include/linux/mmiotrace.h
71486 +++ b/include/linux/mmiotrace.h
71487 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
71488 /* Called from ioremap.c */
71489 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
71490 void __iomem *addr);
71491 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
71492 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
71493
71494 /* For anyone to insert markers. Remember trailing newline. */
71495 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
71496 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
71497 {
71498 }
71499
71500 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
71501 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
71502 {
71503 }
71504
71505 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
71506 index 5c76737..61f518e 100644
71507 --- a/include/linux/mmzone.h
71508 +++ b/include/linux/mmzone.h
71509 @@ -396,7 +396,7 @@ struct zone {
71510 unsigned long flags; /* zone flags, see below */
71511
71512 /* Zone statistics */
71513 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71514 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71515
71516 /*
71517 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
71518 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
71519 index b508016..237cfe5 100644
71520 --- a/include/linux/mod_devicetable.h
71521 +++ b/include/linux/mod_devicetable.h
71522 @@ -13,7 +13,7 @@
71523 typedef unsigned long kernel_ulong_t;
71524 #endif
71525
71526 -#define PCI_ANY_ID (~0)
71527 +#define PCI_ANY_ID ((__u16)~0)
71528
71529 struct pci_device_id {
71530 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
71531 @@ -139,7 +139,7 @@ struct usb_device_id {
71532 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
71533 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
71534
71535 -#define HID_ANY_ID (~0)
71536 +#define HID_ANY_ID (~0U)
71537 #define HID_BUS_ANY 0xffff
71538 #define HID_GROUP_ANY 0x0000
71539
71540 @@ -465,7 +465,7 @@ struct dmi_system_id {
71541 const char *ident;
71542 struct dmi_strmatch matches[4];
71543 void *driver_data;
71544 -};
71545 +} __do_const;
71546 /*
71547 * struct dmi_device_id appears during expansion of
71548 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
71549 diff --git a/include/linux/module.h b/include/linux/module.h
71550 index 46f1ea0..a34ca37 100644
71551 --- a/include/linux/module.h
71552 +++ b/include/linux/module.h
71553 @@ -17,9 +17,11 @@
71554 #include <linux/moduleparam.h>
71555 #include <linux/tracepoint.h>
71556 #include <linux/export.h>
71557 +#include <linux/fs.h>
71558
71559 #include <linux/percpu.h>
71560 #include <asm/module.h>
71561 +#include <asm/pgtable.h>
71562
71563 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
71564 #define MODULE_SIG_STRING "~Module signature appended~\n"
71565 @@ -54,12 +56,13 @@ struct module_attribute {
71566 int (*test)(struct module *);
71567 void (*free)(struct module *);
71568 };
71569 +typedef struct module_attribute __no_const module_attribute_no_const;
71570
71571 struct module_version_attribute {
71572 struct module_attribute mattr;
71573 const char *module_name;
71574 const char *version;
71575 -} __attribute__ ((__aligned__(sizeof(void *))));
71576 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
71577
71578 extern ssize_t __modver_version_show(struct module_attribute *,
71579 struct module_kobject *, char *);
71580 @@ -232,7 +235,7 @@ struct module
71581
71582 /* Sysfs stuff. */
71583 struct module_kobject mkobj;
71584 - struct module_attribute *modinfo_attrs;
71585 + module_attribute_no_const *modinfo_attrs;
71586 const char *version;
71587 const char *srcversion;
71588 struct kobject *holders_dir;
71589 @@ -281,19 +284,16 @@ struct module
71590 int (*init)(void);
71591
71592 /* If this is non-NULL, vfree after init() returns */
71593 - void *module_init;
71594 + void *module_init_rx, *module_init_rw;
71595
71596 /* Here is the actual code + data, vfree'd on unload. */
71597 - void *module_core;
71598 + void *module_core_rx, *module_core_rw;
71599
71600 /* Here are the sizes of the init and core sections */
71601 - unsigned int init_size, core_size;
71602 + unsigned int init_size_rw, core_size_rw;
71603
71604 /* The size of the executable code in each section. */
71605 - unsigned int init_text_size, core_text_size;
71606 -
71607 - /* Size of RO sections of the module (text+rodata) */
71608 - unsigned int init_ro_size, core_ro_size;
71609 + unsigned int init_size_rx, core_size_rx;
71610
71611 /* Arch-specific module values */
71612 struct mod_arch_specific arch;
71613 @@ -349,6 +349,10 @@ struct module
71614 #ifdef CONFIG_EVENT_TRACING
71615 struct ftrace_event_call **trace_events;
71616 unsigned int num_trace_events;
71617 + struct file_operations trace_id;
71618 + struct file_operations trace_enable;
71619 + struct file_operations trace_format;
71620 + struct file_operations trace_filter;
71621 #endif
71622 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
71623 unsigned int num_ftrace_callsites;
71624 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
71625 bool is_module_percpu_address(unsigned long addr);
71626 bool is_module_text_address(unsigned long addr);
71627
71628 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
71629 +{
71630 +
71631 +#ifdef CONFIG_PAX_KERNEXEC
71632 + if (ktla_ktva(addr) >= (unsigned long)start &&
71633 + ktla_ktva(addr) < (unsigned long)start + size)
71634 + return 1;
71635 +#endif
71636 +
71637 + return ((void *)addr >= start && (void *)addr < start + size);
71638 +}
71639 +
71640 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
71641 +{
71642 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
71643 +}
71644 +
71645 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
71646 +{
71647 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
71648 +}
71649 +
71650 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
71651 +{
71652 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
71653 +}
71654 +
71655 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
71656 +{
71657 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
71658 +}
71659 +
71660 static inline int within_module_core(unsigned long addr, const struct module *mod)
71661 {
71662 - return (unsigned long)mod->module_core <= addr &&
71663 - addr < (unsigned long)mod->module_core + mod->core_size;
71664 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
71665 }
71666
71667 static inline int within_module_init(unsigned long addr, const struct module *mod)
71668 {
71669 - return (unsigned long)mod->module_init <= addr &&
71670 - addr < (unsigned long)mod->module_init + mod->init_size;
71671 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
71672 }
71673
71674 /* Search for module by name: must hold module_mutex. */
71675 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
71676 index 560ca53..ef621ef 100644
71677 --- a/include/linux/moduleloader.h
71678 +++ b/include/linux/moduleloader.h
71679 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
71680 sections. Returns NULL on failure. */
71681 void *module_alloc(unsigned long size);
71682
71683 +#ifdef CONFIG_PAX_KERNEXEC
71684 +void *module_alloc_exec(unsigned long size);
71685 +#else
71686 +#define module_alloc_exec(x) module_alloc(x)
71687 +#endif
71688 +
71689 /* Free memory returned from module_alloc. */
71690 void module_free(struct module *mod, void *module_region);
71691
71692 +#ifdef CONFIG_PAX_KERNEXEC
71693 +void module_free_exec(struct module *mod, void *module_region);
71694 +#else
71695 +#define module_free_exec(x, y) module_free((x), (y))
71696 +#endif
71697 +
71698 /*
71699 * Apply the given relocation to the (simplified) ELF. Return -error
71700 * or 0.
71701 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
71702 unsigned int relsec,
71703 struct module *me)
71704 {
71705 +#ifdef CONFIG_MODULES
71706 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
71707 +#endif
71708 return -ENOEXEC;
71709 }
71710 #endif
71711 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
71712 unsigned int relsec,
71713 struct module *me)
71714 {
71715 +#ifdef CONFIG_MODULES
71716 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
71717 +#endif
71718 return -ENOEXEC;
71719 }
71720 #endif
71721 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
71722 index 137b419..fe663ec 100644
71723 --- a/include/linux/moduleparam.h
71724 +++ b/include/linux/moduleparam.h
71725 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
71726 * @len is usually just sizeof(string).
71727 */
71728 #define module_param_string(name, string, len, perm) \
71729 - static const struct kparam_string __param_string_##name \
71730 + static const struct kparam_string __param_string_##name __used \
71731 = { len, string }; \
71732 __module_param_call(MODULE_PARAM_PREFIX, name, \
71733 &param_ops_string, \
71734 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
71735 */
71736 #define module_param_array_named(name, array, type, nump, perm) \
71737 param_check_##type(name, &(array)[0]); \
71738 - static const struct kparam_array __param_arr_##name \
71739 + static const struct kparam_array __param_arr_##name __used \
71740 = { .max = ARRAY_SIZE(array), .num = nump, \
71741 .ops = &param_ops_##type, \
71742 .elemsize = sizeof(array[0]), .elem = array }; \
71743 diff --git a/include/linux/namei.h b/include/linux/namei.h
71744 index 5a5ff57..5ae5070 100644
71745 --- a/include/linux/namei.h
71746 +++ b/include/linux/namei.h
71747 @@ -19,7 +19,7 @@ struct nameidata {
71748 unsigned seq;
71749 int last_type;
71750 unsigned depth;
71751 - char *saved_names[MAX_NESTED_LINKS + 1];
71752 + const char *saved_names[MAX_NESTED_LINKS + 1];
71753 };
71754
71755 /*
71756 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
71757
71758 extern void nd_jump_link(struct nameidata *nd, struct path *path);
71759
71760 -static inline void nd_set_link(struct nameidata *nd, char *path)
71761 +static inline void nd_set_link(struct nameidata *nd, const char *path)
71762 {
71763 nd->saved_names[nd->depth] = path;
71764 }
71765
71766 -static inline char *nd_get_link(struct nameidata *nd)
71767 +static inline const char *nd_get_link(const struct nameidata *nd)
71768 {
71769 return nd->saved_names[nd->depth];
71770 }
71771 diff --git a/include/linux/net.h b/include/linux/net.h
71772 index 99c9f0c..e1cf296 100644
71773 --- a/include/linux/net.h
71774 +++ b/include/linux/net.h
71775 @@ -183,7 +183,7 @@ struct net_proto_family {
71776 int (*create)(struct net *net, struct socket *sock,
71777 int protocol, int kern);
71778 struct module *owner;
71779 -};
71780 +} __do_const;
71781
71782 struct iovec;
71783 struct kvec;
71784 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
71785 index 96e4c21..9cc8278 100644
71786 --- a/include/linux/netdevice.h
71787 +++ b/include/linux/netdevice.h
71788 @@ -1026,6 +1026,7 @@ struct net_device_ops {
71789 int (*ndo_change_carrier)(struct net_device *dev,
71790 bool new_carrier);
71791 };
71792 +typedef struct net_device_ops __no_const net_device_ops_no_const;
71793
71794 /*
71795 * The DEVICE structure.
71796 @@ -1094,7 +1095,7 @@ struct net_device {
71797 int iflink;
71798
71799 struct net_device_stats stats;
71800 - atomic_long_t rx_dropped; /* dropped packets by core network
71801 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
71802 * Do not use this in drivers.
71803 */
71804
71805 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
71806 index 0060fde..481c6ae 100644
71807 --- a/include/linux/netfilter.h
71808 +++ b/include/linux/netfilter.h
71809 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
71810 #endif
71811 /* Use the module struct to lock set/get code in place */
71812 struct module *owner;
71813 -};
71814 +} __do_const;
71815
71816 /* Function to register/unregister hook points. */
71817 int nf_register_hook(struct nf_hook_ops *reg);
71818 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
71819 index d80e275..c3510b8 100644
71820 --- a/include/linux/netfilter/ipset/ip_set.h
71821 +++ b/include/linux/netfilter/ipset/ip_set.h
71822 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
71823 /* Return true if "b" set is the same as "a"
71824 * according to the create set parameters */
71825 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
71826 -};
71827 +} __do_const;
71828
71829 /* The core set type structure */
71830 struct ip_set_type {
71831 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
71832 index cadb740..d7c37c0 100644
71833 --- a/include/linux/netfilter/nfnetlink.h
71834 +++ b/include/linux/netfilter/nfnetlink.h
71835 @@ -16,7 +16,7 @@ struct nfnl_callback {
71836 const struct nlattr * const cda[]);
71837 const struct nla_policy *policy; /* netlink attribute policy */
71838 const u_int16_t attr_count; /* number of nlattr's */
71839 -};
71840 +} __do_const;
71841
71842 struct nfnetlink_subsystem {
71843 const char *name;
71844 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
71845 new file mode 100644
71846 index 0000000..33f4af8
71847 --- /dev/null
71848 +++ b/include/linux/netfilter/xt_gradm.h
71849 @@ -0,0 +1,9 @@
71850 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
71851 +#define _LINUX_NETFILTER_XT_GRADM_H 1
71852 +
71853 +struct xt_gradm_mtinfo {
71854 + __u16 flags;
71855 + __u16 invflags;
71856 +};
71857 +
71858 +#endif
71859 diff --git a/include/linux/nls.h b/include/linux/nls.h
71860 index 5dc635f..35f5e11 100644
71861 --- a/include/linux/nls.h
71862 +++ b/include/linux/nls.h
71863 @@ -31,7 +31,7 @@ struct nls_table {
71864 const unsigned char *charset2upper;
71865 struct module *owner;
71866 struct nls_table *next;
71867 -};
71868 +} __do_const;
71869
71870 /* this value hold the maximum octet of charset */
71871 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
71872 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
71873 index d14a4c3..a078786 100644
71874 --- a/include/linux/notifier.h
71875 +++ b/include/linux/notifier.h
71876 @@ -54,7 +54,8 @@ struct notifier_block {
71877 notifier_fn_t notifier_call;
71878 struct notifier_block __rcu *next;
71879 int priority;
71880 -};
71881 +} __do_const;
71882 +typedef struct notifier_block __no_const notifier_block_no_const;
71883
71884 struct atomic_notifier_head {
71885 spinlock_t lock;
71886 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
71887 index a4c5624..79d6d88 100644
71888 --- a/include/linux/oprofile.h
71889 +++ b/include/linux/oprofile.h
71890 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71891 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
71892 char const * name, ulong * val);
71893
71894 -/** Create a file for read-only access to an atomic_t. */
71895 +/** Create a file for read-only access to an atomic_unchecked_t. */
71896 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
71897 - char const * name, atomic_t * val);
71898 + char const * name, atomic_unchecked_t * val);
71899
71900 /** create a directory */
71901 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
71902 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
71903 index 8db71dc..a76bf2c 100644
71904 --- a/include/linux/pci_hotplug.h
71905 +++ b/include/linux/pci_hotplug.h
71906 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
71907 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
71908 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
71909 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
71910 -};
71911 +} __do_const;
71912 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
71913
71914 /**
71915 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
71916 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
71917 index c5b6dbf..b124155 100644
71918 --- a/include/linux/perf_event.h
71919 +++ b/include/linux/perf_event.h
71920 @@ -318,8 +318,8 @@ struct perf_event {
71921
71922 enum perf_event_active_state state;
71923 unsigned int attach_state;
71924 - local64_t count;
71925 - atomic64_t child_count;
71926 + local64_t count; /* PaX: fix it one day */
71927 + atomic64_unchecked_t child_count;
71928
71929 /*
71930 * These are the total time in nanoseconds that the event
71931 @@ -370,8 +370,8 @@ struct perf_event {
71932 * These accumulate total time (in nanoseconds) that children
71933 * events have been enabled and running, respectively.
71934 */
71935 - atomic64_t child_total_time_enabled;
71936 - atomic64_t child_total_time_running;
71937 + atomic64_unchecked_t child_total_time_enabled;
71938 + atomic64_unchecked_t child_total_time_running;
71939
71940 /*
71941 * Protect attach/detach and child_list:
71942 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
71943 entry->ip[entry->nr++] = ip;
71944 }
71945
71946 -extern int sysctl_perf_event_paranoid;
71947 +extern int sysctl_perf_event_legitimately_concerned;
71948 extern int sysctl_perf_event_mlock;
71949 extern int sysctl_perf_event_sample_rate;
71950
71951 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
71952 void __user *buffer, size_t *lenp,
71953 loff_t *ppos);
71954
71955 +static inline bool perf_paranoid_any(void)
71956 +{
71957 + return sysctl_perf_event_legitimately_concerned > 2;
71958 +}
71959 +
71960 static inline bool perf_paranoid_tracepoint_raw(void)
71961 {
71962 - return sysctl_perf_event_paranoid > -1;
71963 + return sysctl_perf_event_legitimately_concerned > -1;
71964 }
71965
71966 static inline bool perf_paranoid_cpu(void)
71967 {
71968 - return sysctl_perf_event_paranoid > 0;
71969 + return sysctl_perf_event_legitimately_concerned > 0;
71970 }
71971
71972 static inline bool perf_paranoid_kernel(void)
71973 {
71974 - return sysctl_perf_event_paranoid > 1;
71975 + return sysctl_perf_event_legitimately_concerned > 1;
71976 }
71977
71978 extern void perf_event_init(void);
71979 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
71980 */
71981 #define perf_cpu_notifier(fn) \
71982 do { \
71983 - static struct notifier_block fn##_nb __cpuinitdata = \
71984 + static struct notifier_block fn##_nb = \
71985 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71986 unsigned long cpu = smp_processor_id(); \
71987 unsigned long flags; \
71988 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
71989 struct device_attribute attr;
71990 u64 id;
71991 const char *event_str;
71992 -};
71993 +} __do_const;
71994
71995 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
71996 static struct perf_pmu_events_attr _var = { \
71997 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71998 index b8809fe..ae4ccd0 100644
71999 --- a/include/linux/pipe_fs_i.h
72000 +++ b/include/linux/pipe_fs_i.h
72001 @@ -47,10 +47,10 @@ struct pipe_inode_info {
72002 struct mutex mutex;
72003 wait_queue_head_t wait;
72004 unsigned int nrbufs, curbuf, buffers;
72005 - unsigned int readers;
72006 - unsigned int writers;
72007 - unsigned int files;
72008 - unsigned int waiting_writers;
72009 + atomic_t readers;
72010 + atomic_t writers;
72011 + atomic_t files;
72012 + atomic_t waiting_writers;
72013 unsigned int r_counter;
72014 unsigned int w_counter;
72015 struct page *tmp_page;
72016 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
72017 index 5f28cae..3d23723 100644
72018 --- a/include/linux/platform_data/usb-ehci-s5p.h
72019 +++ b/include/linux/platform_data/usb-ehci-s5p.h
72020 @@ -14,7 +14,7 @@
72021 struct s5p_ehci_platdata {
72022 int (*phy_init)(struct platform_device *pdev, int type);
72023 int (*phy_exit)(struct platform_device *pdev, int type);
72024 -};
72025 +} __no_const;
72026
72027 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
72028
72029 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
72030 index c256c59..8ea94c7 100644
72031 --- a/include/linux/platform_data/usb-ohci-exynos.h
72032 +++ b/include/linux/platform_data/usb-ohci-exynos.h
72033 @@ -14,7 +14,7 @@
72034 struct exynos4_ohci_platdata {
72035 int (*phy_init)(struct platform_device *pdev, int type);
72036 int (*phy_exit)(struct platform_device *pdev, int type);
72037 -};
72038 +} __no_const;
72039
72040 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
72041
72042 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
72043 index 7c1d252..c5c773e 100644
72044 --- a/include/linux/pm_domain.h
72045 +++ b/include/linux/pm_domain.h
72046 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
72047
72048 struct gpd_cpu_data {
72049 unsigned int saved_exit_latency;
72050 - struct cpuidle_state *idle_state;
72051 + cpuidle_state_no_const *idle_state;
72052 };
72053
72054 struct generic_pm_domain {
72055 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
72056 index 7d7e09e..8671ef8 100644
72057 --- a/include/linux/pm_runtime.h
72058 +++ b/include/linux/pm_runtime.h
72059 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
72060
72061 static inline void pm_runtime_mark_last_busy(struct device *dev)
72062 {
72063 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
72064 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
72065 }
72066
72067 #else /* !CONFIG_PM_RUNTIME */
72068 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
72069 index 195aafc..49a7bc2 100644
72070 --- a/include/linux/pnp.h
72071 +++ b/include/linux/pnp.h
72072 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
72073 struct pnp_fixup {
72074 char id[7];
72075 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
72076 -};
72077 +} __do_const;
72078
72079 /* config parameters */
72080 #define PNP_CONFIG_NORMAL 0x0001
72081 diff --git a/include/linux/poison.h b/include/linux/poison.h
72082 index 2110a81..13a11bb 100644
72083 --- a/include/linux/poison.h
72084 +++ b/include/linux/poison.h
72085 @@ -19,8 +19,8 @@
72086 * under normal circumstances, used to verify that nobody uses
72087 * non-initialized list entries.
72088 */
72089 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
72090 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
72091 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
72092 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
72093
72094 /********** include/linux/timer.h **********/
72095 /*
72096 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
72097 index c0f44c2..1572583 100644
72098 --- a/include/linux/power/smartreflex.h
72099 +++ b/include/linux/power/smartreflex.h
72100 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
72101 int (*notify)(struct omap_sr *sr, u32 status);
72102 u8 notify_flags;
72103 u8 class_type;
72104 -};
72105 +} __do_const;
72106
72107 /**
72108 * struct omap_sr_nvalue_table - Smartreflex n-target value info
72109 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
72110 index 4ea1d37..80f4b33 100644
72111 --- a/include/linux/ppp-comp.h
72112 +++ b/include/linux/ppp-comp.h
72113 @@ -84,7 +84,7 @@ struct compressor {
72114 struct module *owner;
72115 /* Extra skb space needed by the compressor algorithm */
72116 unsigned int comp_extra;
72117 -};
72118 +} __do_const;
72119
72120 /*
72121 * The return value from decompress routine is the length of the
72122 diff --git a/include/linux/printk.h b/include/linux/printk.h
72123 index 22c7052..ad3fa0a 100644
72124 --- a/include/linux/printk.h
72125 +++ b/include/linux/printk.h
72126 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
72127 void early_printk(const char *s, ...) { }
72128 #endif
72129
72130 +extern int kptr_restrict;
72131 +
72132 #ifdef CONFIG_PRINTK
72133 asmlinkage __printf(5, 0)
72134 int vprintk_emit(int facility, int level,
72135 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
72136
72137 extern int printk_delay_msec;
72138 extern int dmesg_restrict;
72139 -extern int kptr_restrict;
72140
72141 extern void wake_up_klogd(void);
72142
72143 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
72144 index 608e60a..c26f864 100644
72145 --- a/include/linux/proc_fs.h
72146 +++ b/include/linux/proc_fs.h
72147 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
72148 return proc_create_data(name, mode, parent, proc_fops, NULL);
72149 }
72150
72151 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
72152 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
72153 +{
72154 +#ifdef CONFIG_GRKERNSEC_PROC_USER
72155 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
72156 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
72157 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
72158 +#else
72159 + return proc_create_data(name, mode, parent, proc_fops, NULL);
72160 +#endif
72161 +}
72162 +
72163 +
72164 extern void proc_set_size(struct proc_dir_entry *, loff_t);
72165 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
72166 extern void *PDE_DATA(const struct inode *);
72167 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
72168 index 34a1e10..03a6d03 100644
72169 --- a/include/linux/proc_ns.h
72170 +++ b/include/linux/proc_ns.h
72171 @@ -14,7 +14,7 @@ struct proc_ns_operations {
72172 void (*put)(void *ns);
72173 int (*install)(struct nsproxy *nsproxy, void *ns);
72174 unsigned int (*inum)(void *ns);
72175 -};
72176 +} __do_const;
72177
72178 struct proc_ns {
72179 void *ns;
72180 diff --git a/include/linux/random.h b/include/linux/random.h
72181 index 3b9377d..61b506a 100644
72182 --- a/include/linux/random.h
72183 +++ b/include/linux/random.h
72184 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
72185 u32 prandom_u32_state(struct rnd_state *);
72186 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
72187
72188 +static inline unsigned long pax_get_random_long(void)
72189 +{
72190 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
72191 +}
72192 +
72193 /*
72194 * Handle minimum values for seeds
72195 */
72196 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
72197 index f4b1001..8ddb2b6 100644
72198 --- a/include/linux/rculist.h
72199 +++ b/include/linux/rculist.h
72200 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
72201 struct list_head *prev, struct list_head *next);
72202 #endif
72203
72204 +extern void __pax_list_add_rcu(struct list_head *new,
72205 + struct list_head *prev, struct list_head *next);
72206 +
72207 /**
72208 * list_add_rcu - add a new entry to rcu-protected list
72209 * @new: new entry to be added
72210 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
72211 __list_add_rcu(new, head, head->next);
72212 }
72213
72214 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
72215 +{
72216 + __pax_list_add_rcu(new, head, head->next);
72217 +}
72218 +
72219 /**
72220 * list_add_tail_rcu - add a new entry to rcu-protected list
72221 * @new: new entry to be added
72222 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
72223 __list_add_rcu(new, head->prev, head);
72224 }
72225
72226 +static inline void pax_list_add_tail_rcu(struct list_head *new,
72227 + struct list_head *head)
72228 +{
72229 + __pax_list_add_rcu(new, head->prev, head);
72230 +}
72231 +
72232 /**
72233 * list_del_rcu - deletes entry from list without re-initialization
72234 * @entry: the element to delete from the list.
72235 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
72236 entry->prev = LIST_POISON2;
72237 }
72238
72239 +extern void pax_list_del_rcu(struct list_head *entry);
72240 +
72241 /**
72242 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
72243 * @n: the element to delete from the hash list.
72244 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
72245 index 23b3630..e1bc12b 100644
72246 --- a/include/linux/reboot.h
72247 +++ b/include/linux/reboot.h
72248 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
72249 * Architecture-specific implementations of sys_reboot commands.
72250 */
72251
72252 -extern void machine_restart(char *cmd);
72253 -extern void machine_halt(void);
72254 -extern void machine_power_off(void);
72255 +extern void machine_restart(char *cmd) __noreturn;
72256 +extern void machine_halt(void) __noreturn;
72257 +extern void machine_power_off(void) __noreturn;
72258
72259 extern void machine_shutdown(void);
72260 struct pt_regs;
72261 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
72262 */
72263
72264 extern void kernel_restart_prepare(char *cmd);
72265 -extern void kernel_restart(char *cmd);
72266 -extern void kernel_halt(void);
72267 -extern void kernel_power_off(void);
72268 +extern void kernel_restart(char *cmd) __noreturn;
72269 +extern void kernel_halt(void) __noreturn;
72270 +extern void kernel_power_off(void) __noreturn;
72271
72272 extern int C_A_D; /* for sysctl */
72273 void ctrl_alt_del(void);
72274 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
72275 * Emergency restart, callable from an interrupt handler.
72276 */
72277
72278 -extern void emergency_restart(void);
72279 +extern void emergency_restart(void) __noreturn;
72280 #include <asm/emergency-restart.h>
72281
72282 #endif /* _LINUX_REBOOT_H */
72283 diff --git a/include/linux/regset.h b/include/linux/regset.h
72284 index 8e0c9fe..ac4d221 100644
72285 --- a/include/linux/regset.h
72286 +++ b/include/linux/regset.h
72287 @@ -161,7 +161,8 @@ struct user_regset {
72288 unsigned int align;
72289 unsigned int bias;
72290 unsigned int core_note_type;
72291 -};
72292 +} __do_const;
72293 +typedef struct user_regset __no_const user_regset_no_const;
72294
72295 /**
72296 * struct user_regset_view - available regsets
72297 diff --git a/include/linux/relay.h b/include/linux/relay.h
72298 index d7c8359..818daf5 100644
72299 --- a/include/linux/relay.h
72300 +++ b/include/linux/relay.h
72301 @@ -157,7 +157,7 @@ struct rchan_callbacks
72302 * The callback should return 0 if successful, negative if not.
72303 */
72304 int (*remove_buf_file)(struct dentry *dentry);
72305 -};
72306 +} __no_const;
72307
72308 /*
72309 * CONFIG_RELAY kernel API, kernel/relay.c
72310 diff --git a/include/linux/rio.h b/include/linux/rio.h
72311 index 18e0993..8ab5b21 100644
72312 --- a/include/linux/rio.h
72313 +++ b/include/linux/rio.h
72314 @@ -345,7 +345,7 @@ struct rio_ops {
72315 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
72316 u64 rstart, u32 size, u32 flags);
72317 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
72318 -};
72319 +} __no_const;
72320
72321 #define RIO_RESOURCE_MEM 0x00000100
72322 #define RIO_RESOURCE_DOORBELL 0x00000200
72323 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
72324 index 6dacb93..6174423 100644
72325 --- a/include/linux/rmap.h
72326 +++ b/include/linux/rmap.h
72327 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
72328 void anon_vma_init(void); /* create anon_vma_cachep */
72329 int anon_vma_prepare(struct vm_area_struct *);
72330 void unlink_anon_vmas(struct vm_area_struct *);
72331 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
72332 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
72333 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
72334 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
72335
72336 static inline void anon_vma_merge(struct vm_area_struct *vma,
72337 struct vm_area_struct *next)
72338 diff --git a/include/linux/sched.h b/include/linux/sched.h
72339 index 178a8d9..450bf11 100644
72340 --- a/include/linux/sched.h
72341 +++ b/include/linux/sched.h
72342 @@ -62,6 +62,7 @@ struct bio_list;
72343 struct fs_struct;
72344 struct perf_event_context;
72345 struct blk_plug;
72346 +struct linux_binprm;
72347
72348 /*
72349 * List of flags we want to share for kernel threads,
72350 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
72351 extern int in_sched_functions(unsigned long addr);
72352
72353 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
72354 -extern signed long schedule_timeout(signed long timeout);
72355 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
72356 extern signed long schedule_timeout_interruptible(signed long timeout);
72357 extern signed long schedule_timeout_killable(signed long timeout);
72358 extern signed long schedule_timeout_uninterruptible(signed long timeout);
72359 @@ -314,6 +315,19 @@ struct nsproxy;
72360 struct user_namespace;
72361
72362 #ifdef CONFIG_MMU
72363 +
72364 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
72365 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
72366 +#else
72367 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
72368 +{
72369 + return 0;
72370 +}
72371 +#endif
72372 +
72373 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
72374 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
72375 +
72376 extern void arch_pick_mmap_layout(struct mm_struct *mm);
72377 extern unsigned long
72378 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
72379 @@ -591,6 +605,17 @@ struct signal_struct {
72380 #ifdef CONFIG_TASKSTATS
72381 struct taskstats *stats;
72382 #endif
72383 +
72384 +#ifdef CONFIG_GRKERNSEC
72385 + u32 curr_ip;
72386 + u32 saved_ip;
72387 + u32 gr_saddr;
72388 + u32 gr_daddr;
72389 + u16 gr_sport;
72390 + u16 gr_dport;
72391 + u8 used_accept:1;
72392 +#endif
72393 +
72394 #ifdef CONFIG_AUDIT
72395 unsigned audit_tty;
72396 unsigned audit_tty_log_passwd;
72397 @@ -671,6 +696,14 @@ struct user_struct {
72398 struct key *session_keyring; /* UID's default session keyring */
72399 #endif
72400
72401 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72402 + unsigned char kernel_banned;
72403 +#endif
72404 +#ifdef CONFIG_GRKERNSEC_BRUTE
72405 + unsigned char suid_banned;
72406 + unsigned long suid_ban_expires;
72407 +#endif
72408 +
72409 /* Hash table maintenance information */
72410 struct hlist_node uidhash_node;
72411 kuid_t uid;
72412 @@ -1158,8 +1191,8 @@ struct task_struct {
72413 struct list_head thread_group;
72414
72415 struct completion *vfork_done; /* for vfork() */
72416 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
72417 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
72418 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
72419 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
72420
72421 cputime_t utime, stime, utimescaled, stimescaled;
72422 cputime_t gtime;
72423 @@ -1184,11 +1217,6 @@ struct task_struct {
72424 struct task_cputime cputime_expires;
72425 struct list_head cpu_timers[3];
72426
72427 -/* process credentials */
72428 - const struct cred __rcu *real_cred; /* objective and real subjective task
72429 - * credentials (COW) */
72430 - const struct cred __rcu *cred; /* effective (overridable) subjective task
72431 - * credentials (COW) */
72432 char comm[TASK_COMM_LEN]; /* executable name excluding path
72433 - access with [gs]et_task_comm (which lock
72434 it with task_lock())
72435 @@ -1205,6 +1233,10 @@ struct task_struct {
72436 #endif
72437 /* CPU-specific state of this task */
72438 struct thread_struct thread;
72439 +/* thread_info moved to task_struct */
72440 +#ifdef CONFIG_X86
72441 + struct thread_info tinfo;
72442 +#endif
72443 /* filesystem information */
72444 struct fs_struct *fs;
72445 /* open file information */
72446 @@ -1278,6 +1310,10 @@ struct task_struct {
72447 gfp_t lockdep_reclaim_gfp;
72448 #endif
72449
72450 +/* process credentials */
72451 + const struct cred __rcu *real_cred; /* objective and real subjective task
72452 + * credentials (COW) */
72453 +
72454 /* journalling filesystem info */
72455 void *journal_info;
72456
72457 @@ -1316,6 +1352,10 @@ struct task_struct {
72458 /* cg_list protected by css_set_lock and tsk->alloc_lock */
72459 struct list_head cg_list;
72460 #endif
72461 +
72462 + const struct cred __rcu *cred; /* effective (overridable) subjective task
72463 + * credentials (COW) */
72464 +
72465 #ifdef CONFIG_FUTEX
72466 struct robust_list_head __user *robust_list;
72467 #ifdef CONFIG_COMPAT
72468 @@ -1416,8 +1456,76 @@ struct task_struct {
72469 unsigned int sequential_io;
72470 unsigned int sequential_io_avg;
72471 #endif
72472 +
72473 +#ifdef CONFIG_GRKERNSEC
72474 + /* grsecurity */
72475 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
72476 + u64 exec_id;
72477 +#endif
72478 +#ifdef CONFIG_GRKERNSEC_SETXID
72479 + const struct cred *delayed_cred;
72480 +#endif
72481 + struct dentry *gr_chroot_dentry;
72482 + struct acl_subject_label *acl;
72483 + struct acl_role_label *role;
72484 + struct file *exec_file;
72485 + unsigned long brute_expires;
72486 + u16 acl_role_id;
72487 + /* is this the task that authenticated to the special role */
72488 + u8 acl_sp_role;
72489 + u8 is_writable;
72490 + u8 brute;
72491 + u8 gr_is_chrooted;
72492 +#endif
72493 +
72494 };
72495
72496 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
72497 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
72498 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
72499 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
72500 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
72501 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
72502 +
72503 +#ifdef CONFIG_PAX_SOFTMODE
72504 +extern int pax_softmode;
72505 +#endif
72506 +
72507 +extern int pax_check_flags(unsigned long *);
72508 +
72509 +/* if tsk != current then task_lock must be held on it */
72510 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
72511 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
72512 +{
72513 + if (likely(tsk->mm))
72514 + return tsk->mm->pax_flags;
72515 + else
72516 + return 0UL;
72517 +}
72518 +
72519 +/* if tsk != current then task_lock must be held on it */
72520 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
72521 +{
72522 + if (likely(tsk->mm)) {
72523 + tsk->mm->pax_flags = flags;
72524 + return 0;
72525 + }
72526 + return -EINVAL;
72527 +}
72528 +#endif
72529 +
72530 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
72531 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
72532 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
72533 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
72534 +#endif
72535 +
72536 +struct path;
72537 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
72538 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
72539 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
72540 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
72541 +
72542 /* Future-safe accessor for struct task_struct's cpus_allowed. */
72543 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
72544
72545 @@ -1476,7 +1584,7 @@ struct pid_namespace;
72546 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
72547 struct pid_namespace *ns);
72548
72549 -static inline pid_t task_pid_nr(struct task_struct *tsk)
72550 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
72551 {
72552 return tsk->pid;
72553 }
72554 @@ -1919,7 +2027,9 @@ void yield(void);
72555 extern struct exec_domain default_exec_domain;
72556
72557 union thread_union {
72558 +#ifndef CONFIG_X86
72559 struct thread_info thread_info;
72560 +#endif
72561 unsigned long stack[THREAD_SIZE/sizeof(long)];
72562 };
72563
72564 @@ -1952,6 +2062,7 @@ extern struct pid_namespace init_pid_ns;
72565 */
72566
72567 extern struct task_struct *find_task_by_vpid(pid_t nr);
72568 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
72569 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
72570 struct pid_namespace *ns);
72571
72572 @@ -2118,7 +2229,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
72573 extern void exit_itimers(struct signal_struct *);
72574 extern void flush_itimer_signals(void);
72575
72576 -extern void do_group_exit(int);
72577 +extern __noreturn void do_group_exit(int);
72578
72579 extern int allow_signal(int);
72580 extern int disallow_signal(int);
72581 @@ -2309,9 +2420,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
72582
72583 #endif
72584
72585 -static inline int object_is_on_stack(void *obj)
72586 +static inline int object_starts_on_stack(void *obj)
72587 {
72588 - void *stack = task_stack_page(current);
72589 + const void *stack = task_stack_page(current);
72590
72591 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
72592 }
72593 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
72594 index bf8086b..962b035 100644
72595 --- a/include/linux/sched/sysctl.h
72596 +++ b/include/linux/sched/sysctl.h
72597 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
72598 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
72599
72600 extern int sysctl_max_map_count;
72601 +extern unsigned long sysctl_heap_stack_gap;
72602
72603 extern unsigned int sysctl_sched_latency;
72604 extern unsigned int sysctl_sched_min_granularity;
72605 diff --git a/include/linux/security.h b/include/linux/security.h
72606 index 4686491..2bd210e 100644
72607 --- a/include/linux/security.h
72608 +++ b/include/linux/security.h
72609 @@ -26,6 +26,7 @@
72610 #include <linux/capability.h>
72611 #include <linux/slab.h>
72612 #include <linux/err.h>
72613 +#include <linux/grsecurity.h>
72614
72615 struct linux_binprm;
72616 struct cred;
72617 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
72618 index 2da29ac..aac448ec 100644
72619 --- a/include/linux/seq_file.h
72620 +++ b/include/linux/seq_file.h
72621 @@ -26,6 +26,9 @@ struct seq_file {
72622 struct mutex lock;
72623 const struct seq_operations *op;
72624 int poll_event;
72625 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
72626 + u64 exec_id;
72627 +#endif
72628 #ifdef CONFIG_USER_NS
72629 struct user_namespace *user_ns;
72630 #endif
72631 @@ -38,6 +41,7 @@ struct seq_operations {
72632 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
72633 int (*show) (struct seq_file *m, void *v);
72634 };
72635 +typedef struct seq_operations __no_const seq_operations_no_const;
72636
72637 #define SEQ_SKIP 1
72638
72639 diff --git a/include/linux/shm.h b/include/linux/shm.h
72640 index 429c199..4d42e38 100644
72641 --- a/include/linux/shm.h
72642 +++ b/include/linux/shm.h
72643 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
72644
72645 /* The task created the shm object. NULL if the task is dead. */
72646 struct task_struct *shm_creator;
72647 +#ifdef CONFIG_GRKERNSEC
72648 + time_t shm_createtime;
72649 + pid_t shm_lapid;
72650 +#endif
72651 };
72652
72653 /* shm_mode upper byte flags */
72654 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
72655 index dec1748..112c1f9 100644
72656 --- a/include/linux/skbuff.h
72657 +++ b/include/linux/skbuff.h
72658 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
72659 extern struct sk_buff *__alloc_skb(unsigned int size,
72660 gfp_t priority, int flags, int node);
72661 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
72662 -static inline struct sk_buff *alloc_skb(unsigned int size,
72663 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
72664 gfp_t priority)
72665 {
72666 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
72667 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
72668 */
72669 static inline int skb_queue_empty(const struct sk_buff_head *list)
72670 {
72671 - return list->next == (struct sk_buff *)list;
72672 + return list->next == (const struct sk_buff *)list;
72673 }
72674
72675 /**
72676 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
72677 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
72678 const struct sk_buff *skb)
72679 {
72680 - return skb->next == (struct sk_buff *)list;
72681 + return skb->next == (const struct sk_buff *)list;
72682 }
72683
72684 /**
72685 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
72686 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
72687 const struct sk_buff *skb)
72688 {
72689 - return skb->prev == (struct sk_buff *)list;
72690 + return skb->prev == (const struct sk_buff *)list;
72691 }
72692
72693 /**
72694 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
72695 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
72696 */
72697 #ifndef NET_SKB_PAD
72698 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
72699 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
72700 #endif
72701
72702 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
72703 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
72704 int noblock, int *err);
72705 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
72706 struct poll_table_struct *wait);
72707 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
72708 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
72709 int offset, struct iovec *to,
72710 int size);
72711 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
72712 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
72713 nf_bridge_put(skb->nf_bridge);
72714 skb->nf_bridge = NULL;
72715 #endif
72716 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
72717 + skb->nf_trace = 0;
72718 +#endif
72719 }
72720
72721 static inline void nf_reset_trace(struct sk_buff *skb)
72722 diff --git a/include/linux/slab.h b/include/linux/slab.h
72723 index 0c62175..f016ac1 100644
72724 --- a/include/linux/slab.h
72725 +++ b/include/linux/slab.h
72726 @@ -12,15 +12,29 @@
72727 #include <linux/gfp.h>
72728 #include <linux/types.h>
72729 #include <linux/workqueue.h>
72730 -
72731 +#include <linux/err.h>
72732
72733 /*
72734 * Flags to pass to kmem_cache_create().
72735 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
72736 */
72737 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
72738 +
72739 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72740 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
72741 +#else
72742 +#define SLAB_USERCOPY 0x00000000UL
72743 +#endif
72744 +
72745 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
72746 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
72747 +
72748 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
72749 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
72750 +#else
72751 +#define SLAB_NO_SANITIZE 0x00000000UL
72752 +#endif
72753 +
72754 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
72755 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
72756 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
72757 @@ -89,10 +103,13 @@
72758 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
72759 * Both make kfree a no-op.
72760 */
72761 -#define ZERO_SIZE_PTR ((void *)16)
72762 +#define ZERO_SIZE_PTR \
72763 +({ \
72764 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
72765 + (void *)(-MAX_ERRNO-1L); \
72766 +})
72767
72768 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
72769 - (unsigned long)ZERO_SIZE_PTR)
72770 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
72771
72772
72773 struct mem_cgroup;
72774 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
72775 void kfree(const void *);
72776 void kzfree(const void *);
72777 size_t ksize(const void *);
72778 +const char *check_heap_object(const void *ptr, unsigned long n);
72779 +bool is_usercopy_object(const void *ptr);
72780
72781 /*
72782 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
72783 @@ -164,7 +183,7 @@ struct kmem_cache {
72784 unsigned int align; /* Alignment as calculated */
72785 unsigned long flags; /* Active flags on the slab */
72786 const char *name; /* Slab name for sysfs */
72787 - int refcount; /* Use counter */
72788 + atomic_t refcount; /* Use counter */
72789 void (*ctor)(void *); /* Called on object slot creation */
72790 struct list_head list; /* List of all slab caches on the system */
72791 };
72792 @@ -226,6 +245,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
72793 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72794 #endif
72795
72796 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72797 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
72798 +#endif
72799 +
72800 /*
72801 * Figure out which kmalloc slab an allocation of a certain size
72802 * belongs to.
72803 @@ -234,7 +257,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72804 * 2 = 120 .. 192 bytes
72805 * n = 2^(n-1) .. 2^n -1
72806 */
72807 -static __always_inline int kmalloc_index(size_t size)
72808 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
72809 {
72810 if (!size)
72811 return 0;
72812 @@ -406,6 +429,7 @@ void print_slabinfo_header(struct seq_file *m);
72813 * for general use, and so are not documented here. For a full list of
72814 * potential flags, always refer to linux/gfp.h.
72815 */
72816 +
72817 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
72818 {
72819 if (size != 0 && n > SIZE_MAX / size)
72820 @@ -465,7 +489,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
72821 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72822 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72823 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72824 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72825 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
72826 #define kmalloc_track_caller(size, flags) \
72827 __kmalloc_track_caller(size, flags, _RET_IP_)
72828 #else
72829 @@ -485,7 +509,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72830 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72831 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72832 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72833 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
72834 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
72835 #define kmalloc_node_track_caller(size, flags, node) \
72836 __kmalloc_node_track_caller(size, flags, node, \
72837 _RET_IP_)
72838 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
72839 index cd40158..4e2f7af 100644
72840 --- a/include/linux/slab_def.h
72841 +++ b/include/linux/slab_def.h
72842 @@ -50,7 +50,7 @@ struct kmem_cache {
72843 /* 4) cache creation/removal */
72844 const char *name;
72845 struct list_head list;
72846 - int refcount;
72847 + atomic_t refcount;
72848 int object_size;
72849 int align;
72850
72851 @@ -66,10 +66,14 @@ struct kmem_cache {
72852 unsigned long node_allocs;
72853 unsigned long node_frees;
72854 unsigned long node_overflow;
72855 - atomic_t allochit;
72856 - atomic_t allocmiss;
72857 - atomic_t freehit;
72858 - atomic_t freemiss;
72859 + atomic_unchecked_t allochit;
72860 + atomic_unchecked_t allocmiss;
72861 + atomic_unchecked_t freehit;
72862 + atomic_unchecked_t freemiss;
72863 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
72864 + atomic_unchecked_t sanitized;
72865 + atomic_unchecked_t not_sanitized;
72866 +#endif
72867
72868 /*
72869 * If debugging is enabled, then the allocator can add additional
72870 @@ -103,7 +107,7 @@ struct kmem_cache {
72871 };
72872
72873 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72874 -void *__kmalloc(size_t size, gfp_t flags);
72875 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
72876
72877 #ifdef CONFIG_TRACING
72878 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
72879 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72880 cachep = kmalloc_dma_caches[i];
72881 else
72882 #endif
72883 +
72884 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72885 + if (flags & GFP_USERCOPY)
72886 + cachep = kmalloc_usercopy_caches[i];
72887 + else
72888 +#endif
72889 +
72890 cachep = kmalloc_caches[i];
72891
72892 ret = kmem_cache_alloc_trace(cachep, flags, size);
72893 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72894 }
72895
72896 #ifdef CONFIG_NUMA
72897 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
72898 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72899 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72900
72901 #ifdef CONFIG_TRACING
72902 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72903 cachep = kmalloc_dma_caches[i];
72904 else
72905 #endif
72906 +
72907 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72908 + if (flags & GFP_USERCOPY)
72909 + cachep = kmalloc_usercopy_caches[i];
72910 + else
72911 +#endif
72912 +
72913 cachep = kmalloc_caches[i];
72914
72915 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
72916 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
72917 index f28e14a..7831211 100644
72918 --- a/include/linux/slob_def.h
72919 +++ b/include/linux/slob_def.h
72920 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
72921 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
72922 }
72923
72924 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72925 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72926
72927 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72928 {
72929 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72930 return __kmalloc_node(size, flags, NUMA_NO_NODE);
72931 }
72932
72933 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
72934 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
72935 {
72936 return kmalloc(size, flags);
72937 }
72938 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
72939 index 027276f..092bfe8 100644
72940 --- a/include/linux/slub_def.h
72941 +++ b/include/linux/slub_def.h
72942 @@ -80,7 +80,7 @@ struct kmem_cache {
72943 struct kmem_cache_order_objects max;
72944 struct kmem_cache_order_objects min;
72945 gfp_t allocflags; /* gfp flags to use on each alloc */
72946 - int refcount; /* Refcount for slab cache destroy */
72947 + atomic_t refcount; /* Refcount for slab cache destroy */
72948 void (*ctor)(void *);
72949 int inuse; /* Offset to metadata */
72950 int align; /* Alignment */
72951 @@ -105,7 +105,7 @@ struct kmem_cache {
72952 };
72953
72954 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72955 -void *__kmalloc(size_t size, gfp_t flags);
72956 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
72957
72958 static __always_inline void *
72959 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
72960 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
72961 }
72962 #endif
72963
72964 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
72965 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
72966 {
72967 unsigned int order = get_order(size);
72968 return kmalloc_order_trace(size, flags, order);
72969 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72970 }
72971
72972 #ifdef CONFIG_NUMA
72973 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72974 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72975 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72976
72977 #ifdef CONFIG_TRACING
72978 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
72979 index 54f91d3..be2c379 100644
72980 --- a/include/linux/sock_diag.h
72981 +++ b/include/linux/sock_diag.h
72982 @@ -11,7 +11,7 @@ struct sock;
72983 struct sock_diag_handler {
72984 __u8 family;
72985 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
72986 -};
72987 +} __do_const;
72988
72989 int sock_diag_register(const struct sock_diag_handler *h);
72990 void sock_diag_unregister(const struct sock_diag_handler *h);
72991 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
72992 index 680f9a3..f13aeb0 100644
72993 --- a/include/linux/sonet.h
72994 +++ b/include/linux/sonet.h
72995 @@ -7,7 +7,7 @@
72996 #include <uapi/linux/sonet.h>
72997
72998 struct k_sonet_stats {
72999 -#define __HANDLE_ITEM(i) atomic_t i
73000 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73001 __SONET_ITEMS
73002 #undef __HANDLE_ITEM
73003 };
73004 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
73005 index 07d8e53..dc934c9 100644
73006 --- a/include/linux/sunrpc/addr.h
73007 +++ b/include/linux/sunrpc/addr.h
73008 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
73009 {
73010 switch (sap->sa_family) {
73011 case AF_INET:
73012 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
73013 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
73014 case AF_INET6:
73015 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
73016 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
73017 }
73018 return 0;
73019 }
73020 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
73021 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
73022 const struct sockaddr *src)
73023 {
73024 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
73025 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
73026 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
73027
73028 dsin->sin_family = ssin->sin_family;
73029 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
73030 if (sa->sa_family != AF_INET6)
73031 return 0;
73032
73033 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
73034 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
73035 }
73036
73037 #endif /* _LINUX_SUNRPC_ADDR_H */
73038 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
73039 index bfe11be..12bc8c4 100644
73040 --- a/include/linux/sunrpc/clnt.h
73041 +++ b/include/linux/sunrpc/clnt.h
73042 @@ -96,7 +96,7 @@ struct rpc_procinfo {
73043 unsigned int p_timer; /* Which RTT timer to use */
73044 u32 p_statidx; /* Which procedure to account */
73045 const char * p_name; /* name of procedure */
73046 -};
73047 +} __do_const;
73048
73049 #ifdef __KERNEL__
73050
73051 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
73052 index 1f0216b..6a4fa50 100644
73053 --- a/include/linux/sunrpc/svc.h
73054 +++ b/include/linux/sunrpc/svc.h
73055 @@ -411,7 +411,7 @@ struct svc_procedure {
73056 unsigned int pc_count; /* call count */
73057 unsigned int pc_cachetype; /* cache info (NFS) */
73058 unsigned int pc_xdrressize; /* maximum size of XDR reply */
73059 -};
73060 +} __do_const;
73061
73062 /*
73063 * Function prototypes.
73064 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
73065 index 0b8e3e6..33e0a01 100644
73066 --- a/include/linux/sunrpc/svc_rdma.h
73067 +++ b/include/linux/sunrpc/svc_rdma.h
73068 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
73069 extern unsigned int svcrdma_max_requests;
73070 extern unsigned int svcrdma_max_req_size;
73071
73072 -extern atomic_t rdma_stat_recv;
73073 -extern atomic_t rdma_stat_read;
73074 -extern atomic_t rdma_stat_write;
73075 -extern atomic_t rdma_stat_sq_starve;
73076 -extern atomic_t rdma_stat_rq_starve;
73077 -extern atomic_t rdma_stat_rq_poll;
73078 -extern atomic_t rdma_stat_rq_prod;
73079 -extern atomic_t rdma_stat_sq_poll;
73080 -extern atomic_t rdma_stat_sq_prod;
73081 +extern atomic_unchecked_t rdma_stat_recv;
73082 +extern atomic_unchecked_t rdma_stat_read;
73083 +extern atomic_unchecked_t rdma_stat_write;
73084 +extern atomic_unchecked_t rdma_stat_sq_starve;
73085 +extern atomic_unchecked_t rdma_stat_rq_starve;
73086 +extern atomic_unchecked_t rdma_stat_rq_poll;
73087 +extern atomic_unchecked_t rdma_stat_rq_prod;
73088 +extern atomic_unchecked_t rdma_stat_sq_poll;
73089 +extern atomic_unchecked_t rdma_stat_sq_prod;
73090
73091 #define RPCRDMA_VERSION 1
73092
73093 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
73094 index ff374ab..7fd2ecb 100644
73095 --- a/include/linux/sunrpc/svcauth.h
73096 +++ b/include/linux/sunrpc/svcauth.h
73097 @@ -109,7 +109,7 @@ struct auth_ops {
73098 int (*release)(struct svc_rqst *rq);
73099 void (*domain_release)(struct auth_domain *);
73100 int (*set_client)(struct svc_rqst *rq);
73101 -};
73102 +} __do_const;
73103
73104 #define SVC_GARBAGE 1
73105 #define SVC_SYSERR 2
73106 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
73107 index a5ffd32..0935dea 100644
73108 --- a/include/linux/swiotlb.h
73109 +++ b/include/linux/swiotlb.h
73110 @@ -60,7 +60,8 @@ extern void
73111
73112 extern void
73113 swiotlb_free_coherent(struct device *hwdev, size_t size,
73114 - void *vaddr, dma_addr_t dma_handle);
73115 + void *vaddr, dma_addr_t dma_handle,
73116 + struct dma_attrs *attrs);
73117
73118 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
73119 unsigned long offset, size_t size,
73120 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
73121 index 4147d70..d356a10 100644
73122 --- a/include/linux/syscalls.h
73123 +++ b/include/linux/syscalls.h
73124 @@ -97,8 +97,12 @@ struct sigaltstack;
73125 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
73126
73127 #define __SC_DECL(t, a) t a
73128 -#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
73129 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
73130 +#define __TYPE_IS_SL(t) (__same_type((t)0, 0L))
73131 +#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
73132 +#define __TYPE_IS_SLL(t) (__same_type((t)0, 0LL))
73133 +#define __TYPE_IS_ULL(t) (__same_type((t)0, 0ULL))
73134 +#define __TYPE_IS_LL(t) (__TYPE_IS_SLL(t) || __TYPE_IS_ULL(t))
73135 +#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), __builtin_choose_expr(__TYPE_IS_ULL(t), 0ULL, 0LL), __builtin_choose_expr(__TYPE_IS_UL(t), 0UL, 0L))) a
73136 #define __SC_CAST(t, a) (t) a
73137 #define __SC_ARGS(t, a) a
73138 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
73139 @@ -362,11 +366,11 @@ asmlinkage long sys_sync(void);
73140 asmlinkage long sys_fsync(unsigned int fd);
73141 asmlinkage long sys_fdatasync(unsigned int fd);
73142 asmlinkage long sys_bdflush(int func, long data);
73143 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
73144 - char __user *type, unsigned long flags,
73145 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
73146 + const char __user *type, unsigned long flags,
73147 void __user *data);
73148 -asmlinkage long sys_umount(char __user *name, int flags);
73149 -asmlinkage long sys_oldumount(char __user *name);
73150 +asmlinkage long sys_umount(const char __user *name, int flags);
73151 +asmlinkage long sys_oldumount(const char __user *name);
73152 asmlinkage long sys_truncate(const char __user *path, long length);
73153 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
73154 asmlinkage long sys_stat(const char __user *filename,
73155 @@ -578,7 +582,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
73156 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
73157 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
73158 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
73159 - struct sockaddr __user *, int);
73160 + struct sockaddr __user *, int) __intentional_overflow(0);
73161 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
73162 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
73163 unsigned int vlen, unsigned flags);
73164 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
73165 index 27b3b0b..e093dd9 100644
73166 --- a/include/linux/syscore_ops.h
73167 +++ b/include/linux/syscore_ops.h
73168 @@ -16,7 +16,7 @@ struct syscore_ops {
73169 int (*suspend)(void);
73170 void (*resume)(void);
73171 void (*shutdown)(void);
73172 -};
73173 +} __do_const;
73174
73175 extern void register_syscore_ops(struct syscore_ops *ops);
73176 extern void unregister_syscore_ops(struct syscore_ops *ops);
73177 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
73178 index 14a8ff2..af52bad 100644
73179 --- a/include/linux/sysctl.h
73180 +++ b/include/linux/sysctl.h
73181 @@ -34,13 +34,13 @@ struct ctl_table_root;
73182 struct ctl_table_header;
73183 struct ctl_dir;
73184
73185 -typedef struct ctl_table ctl_table;
73186 -
73187 typedef int proc_handler (struct ctl_table *ctl, int write,
73188 void __user *buffer, size_t *lenp, loff_t *ppos);
73189
73190 extern int proc_dostring(struct ctl_table *, int,
73191 void __user *, size_t *, loff_t *);
73192 +extern int proc_dostring_modpriv(struct ctl_table *, int,
73193 + void __user *, size_t *, loff_t *);
73194 extern int proc_dointvec(struct ctl_table *, int,
73195 void __user *, size_t *, loff_t *);
73196 extern int proc_dointvec_minmax(struct ctl_table *, int,
73197 @@ -115,7 +115,9 @@ struct ctl_table
73198 struct ctl_table_poll *poll;
73199 void *extra1;
73200 void *extra2;
73201 -};
73202 +} __do_const;
73203 +typedef struct ctl_table __no_const ctl_table_no_const;
73204 +typedef struct ctl_table ctl_table;
73205
73206 struct ctl_node {
73207 struct rb_node node;
73208 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
73209 index e2cee22..3ddb921 100644
73210 --- a/include/linux/sysfs.h
73211 +++ b/include/linux/sysfs.h
73212 @@ -31,7 +31,8 @@ struct attribute {
73213 struct lock_class_key *key;
73214 struct lock_class_key skey;
73215 #endif
73216 -};
73217 +} __do_const;
73218 +typedef struct attribute __no_const attribute_no_const;
73219
73220 /**
73221 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
73222 @@ -59,8 +60,8 @@ struct attribute_group {
73223 umode_t (*is_visible)(struct kobject *,
73224 struct attribute *, int);
73225 struct attribute **attrs;
73226 -};
73227 -
73228 +} __do_const;
73229 +typedef struct attribute_group __no_const attribute_group_no_const;
73230
73231
73232 /**
73233 @@ -107,7 +108,8 @@ struct bin_attribute {
73234 char *, loff_t, size_t);
73235 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
73236 struct vm_area_struct *vma);
73237 -};
73238 +} __do_const;
73239 +typedef struct bin_attribute __no_const bin_attribute_no_const;
73240
73241 /**
73242 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
73243 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
73244 index 7faf933..9b85a0c 100644
73245 --- a/include/linux/sysrq.h
73246 +++ b/include/linux/sysrq.h
73247 @@ -16,6 +16,7 @@
73248
73249 #include <linux/errno.h>
73250 #include <linux/types.h>
73251 +#include <linux/compiler.h>
73252
73253 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
73254 #define SYSRQ_DEFAULT_ENABLE 1
73255 @@ -36,7 +37,7 @@ struct sysrq_key_op {
73256 char *help_msg;
73257 char *action_msg;
73258 int enable_mask;
73259 -};
73260 +} __do_const;
73261
73262 #ifdef CONFIG_MAGIC_SYSRQ
73263
73264 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
73265 index e7e0473..7989295 100644
73266 --- a/include/linux/thread_info.h
73267 +++ b/include/linux/thread_info.h
73268 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
73269 #error "no set_restore_sigmask() provided and default one won't work"
73270 #endif
73271
73272 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
73273 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
73274 +{
73275 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
73276 + if (!__builtin_constant_p(n))
73277 +#endif
73278 + __check_object_size(ptr, n, to_user);
73279 +}
73280 +
73281 #endif /* __KERNEL__ */
73282
73283 #endif /* _LINUX_THREAD_INFO_H */
73284 diff --git a/include/linux/tty.h b/include/linux/tty.h
73285 index 8780bd2..d1ae08b 100644
73286 --- a/include/linux/tty.h
73287 +++ b/include/linux/tty.h
73288 @@ -194,7 +194,7 @@ struct tty_port {
73289 const struct tty_port_operations *ops; /* Port operations */
73290 spinlock_t lock; /* Lock protecting tty field */
73291 int blocked_open; /* Waiting to open */
73292 - int count; /* Usage count */
73293 + atomic_t count; /* Usage count */
73294 wait_queue_head_t open_wait; /* Open waiters */
73295 wait_queue_head_t close_wait; /* Close waiters */
73296 wait_queue_head_t delta_msr_wait; /* Modem status change */
73297 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
73298 struct tty_struct *tty, struct file *filp);
73299 static inline int tty_port_users(struct tty_port *port)
73300 {
73301 - return port->count + port->blocked_open;
73302 + return atomic_read(&port->count) + port->blocked_open;
73303 }
73304
73305 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
73306 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
73307 index 756a609..b302dd6 100644
73308 --- a/include/linux/tty_driver.h
73309 +++ b/include/linux/tty_driver.h
73310 @@ -285,7 +285,7 @@ struct tty_operations {
73311 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
73312 #endif
73313 const struct file_operations *proc_fops;
73314 -};
73315 +} __do_const;
73316
73317 struct tty_driver {
73318 int magic; /* magic number for this structure */
73319 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
73320 index 58390c7..95e214c 100644
73321 --- a/include/linux/tty_ldisc.h
73322 +++ b/include/linux/tty_ldisc.h
73323 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
73324
73325 struct module *owner;
73326
73327 - int refcount;
73328 + atomic_t refcount;
73329 };
73330
73331 struct tty_ldisc {
73332 diff --git a/include/linux/types.h b/include/linux/types.h
73333 index 4d118ba..c3ee9bf 100644
73334 --- a/include/linux/types.h
73335 +++ b/include/linux/types.h
73336 @@ -176,10 +176,26 @@ typedef struct {
73337 int counter;
73338 } atomic_t;
73339
73340 +#ifdef CONFIG_PAX_REFCOUNT
73341 +typedef struct {
73342 + int counter;
73343 +} atomic_unchecked_t;
73344 +#else
73345 +typedef atomic_t atomic_unchecked_t;
73346 +#endif
73347 +
73348 #ifdef CONFIG_64BIT
73349 typedef struct {
73350 long counter;
73351 } atomic64_t;
73352 +
73353 +#ifdef CONFIG_PAX_REFCOUNT
73354 +typedef struct {
73355 + long counter;
73356 +} atomic64_unchecked_t;
73357 +#else
73358 +typedef atomic64_t atomic64_unchecked_t;
73359 +#endif
73360 #endif
73361
73362 struct list_head {
73363 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
73364 index 5ca0951..ab496a5 100644
73365 --- a/include/linux/uaccess.h
73366 +++ b/include/linux/uaccess.h
73367 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
73368 long ret; \
73369 mm_segment_t old_fs = get_fs(); \
73370 \
73371 - set_fs(KERNEL_DS); \
73372 pagefault_disable(); \
73373 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
73374 - pagefault_enable(); \
73375 + set_fs(KERNEL_DS); \
73376 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
73377 set_fs(old_fs); \
73378 + pagefault_enable(); \
73379 ret; \
73380 })
73381
73382 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
73383 index 8e522cbc..aa8572d 100644
73384 --- a/include/linux/uidgid.h
73385 +++ b/include/linux/uidgid.h
73386 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
73387
73388 #endif /* CONFIG_USER_NS */
73389
73390 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
73391 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
73392 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
73393 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
73394 +
73395 #endif /* _LINUX_UIDGID_H */
73396 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
73397 index 99c1b4d..562e6f3 100644
73398 --- a/include/linux/unaligned/access_ok.h
73399 +++ b/include/linux/unaligned/access_ok.h
73400 @@ -4,34 +4,34 @@
73401 #include <linux/kernel.h>
73402 #include <asm/byteorder.h>
73403
73404 -static inline u16 get_unaligned_le16(const void *p)
73405 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
73406 {
73407 - return le16_to_cpup((__le16 *)p);
73408 + return le16_to_cpup((const __le16 *)p);
73409 }
73410
73411 -static inline u32 get_unaligned_le32(const void *p)
73412 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
73413 {
73414 - return le32_to_cpup((__le32 *)p);
73415 + return le32_to_cpup((const __le32 *)p);
73416 }
73417
73418 -static inline u64 get_unaligned_le64(const void *p)
73419 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
73420 {
73421 - return le64_to_cpup((__le64 *)p);
73422 + return le64_to_cpup((const __le64 *)p);
73423 }
73424
73425 -static inline u16 get_unaligned_be16(const void *p)
73426 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
73427 {
73428 - return be16_to_cpup((__be16 *)p);
73429 + return be16_to_cpup((const __be16 *)p);
73430 }
73431
73432 -static inline u32 get_unaligned_be32(const void *p)
73433 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
73434 {
73435 - return be32_to_cpup((__be32 *)p);
73436 + return be32_to_cpup((const __be32 *)p);
73437 }
73438
73439 -static inline u64 get_unaligned_be64(const void *p)
73440 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
73441 {
73442 - return be64_to_cpup((__be64 *)p);
73443 + return be64_to_cpup((const __be64 *)p);
73444 }
73445
73446 static inline void put_unaligned_le16(u16 val, void *p)
73447 diff --git a/include/linux/usb.h b/include/linux/usb.h
73448 index a0bee5a..5533a52 100644
73449 --- a/include/linux/usb.h
73450 +++ b/include/linux/usb.h
73451 @@ -552,7 +552,7 @@ struct usb_device {
73452 int maxchild;
73453
73454 u32 quirks;
73455 - atomic_t urbnum;
73456 + atomic_unchecked_t urbnum;
73457
73458 unsigned long active_duration;
73459
73460 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
73461
73462 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
73463 __u8 request, __u8 requesttype, __u16 value, __u16 index,
73464 - void *data, __u16 size, int timeout);
73465 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
73466 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
73467 void *data, int len, int *actual_length, int timeout);
73468 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
73469 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
73470 index e452ba6..78f8e80 100644
73471 --- a/include/linux/usb/renesas_usbhs.h
73472 +++ b/include/linux/usb/renesas_usbhs.h
73473 @@ -39,7 +39,7 @@ enum {
73474 */
73475 struct renesas_usbhs_driver_callback {
73476 int (*notify_hotplug)(struct platform_device *pdev);
73477 -};
73478 +} __no_const;
73479
73480 /*
73481 * callback functions for platform
73482 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
73483 index 6f8fbcf..8259001 100644
73484 --- a/include/linux/vermagic.h
73485 +++ b/include/linux/vermagic.h
73486 @@ -25,9 +25,35 @@
73487 #define MODULE_ARCH_VERMAGIC ""
73488 #endif
73489
73490 +#ifdef CONFIG_PAX_REFCOUNT
73491 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
73492 +#else
73493 +#define MODULE_PAX_REFCOUNT ""
73494 +#endif
73495 +
73496 +#ifdef CONSTIFY_PLUGIN
73497 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
73498 +#else
73499 +#define MODULE_CONSTIFY_PLUGIN ""
73500 +#endif
73501 +
73502 +#ifdef STACKLEAK_PLUGIN
73503 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
73504 +#else
73505 +#define MODULE_STACKLEAK_PLUGIN ""
73506 +#endif
73507 +
73508 +#ifdef CONFIG_GRKERNSEC
73509 +#define MODULE_GRSEC "GRSEC "
73510 +#else
73511 +#define MODULE_GRSEC ""
73512 +#endif
73513 +
73514 #define VERMAGIC_STRING \
73515 UTS_RELEASE " " \
73516 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
73517 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
73518 - MODULE_ARCH_VERMAGIC
73519 + MODULE_ARCH_VERMAGIC \
73520 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
73521 + MODULE_GRSEC
73522
73523 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
73524 index 7d5773a..541c01c 100644
73525 --- a/include/linux/vmalloc.h
73526 +++ b/include/linux/vmalloc.h
73527 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
73528 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
73529 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
73530 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
73531 +
73532 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
73533 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
73534 +#endif
73535 +
73536 /* bits [20..32] reserved for arch specific ioremap internals */
73537
73538 /*
73539 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
73540 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
73541 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
73542 unsigned long start, unsigned long end, gfp_t gfp_mask,
73543 - pgprot_t prot, int node, const void *caller);
73544 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
73545 extern void vfree(const void *addr);
73546
73547 extern void *vmap(struct page **pages, unsigned int count,
73548 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
73549 extern void free_vm_area(struct vm_struct *area);
73550
73551 /* for /dev/kmem */
73552 -extern long vread(char *buf, char *addr, unsigned long count);
73553 -extern long vwrite(char *buf, char *addr, unsigned long count);
73554 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
73555 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
73556
73557 /*
73558 * Internals. Dont't use..
73559 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
73560 index c586679..f06b389 100644
73561 --- a/include/linux/vmstat.h
73562 +++ b/include/linux/vmstat.h
73563 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
73564 /*
73565 * Zone based page accounting with per cpu differentials.
73566 */
73567 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73568 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73569
73570 static inline void zone_page_state_add(long x, struct zone *zone,
73571 enum zone_stat_item item)
73572 {
73573 - atomic_long_add(x, &zone->vm_stat[item]);
73574 - atomic_long_add(x, &vm_stat[item]);
73575 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
73576 + atomic_long_add_unchecked(x, &vm_stat[item]);
73577 }
73578
73579 static inline unsigned long global_page_state(enum zone_stat_item item)
73580 {
73581 - long x = atomic_long_read(&vm_stat[item]);
73582 + long x = atomic_long_read_unchecked(&vm_stat[item]);
73583 #ifdef CONFIG_SMP
73584 if (x < 0)
73585 x = 0;
73586 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
73587 static inline unsigned long zone_page_state(struct zone *zone,
73588 enum zone_stat_item item)
73589 {
73590 - long x = atomic_long_read(&zone->vm_stat[item]);
73591 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
73592 #ifdef CONFIG_SMP
73593 if (x < 0)
73594 x = 0;
73595 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
73596 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
73597 enum zone_stat_item item)
73598 {
73599 - long x = atomic_long_read(&zone->vm_stat[item]);
73600 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
73601
73602 #ifdef CONFIG_SMP
73603 int cpu;
73604 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
73605
73606 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
73607 {
73608 - atomic_long_inc(&zone->vm_stat[item]);
73609 - atomic_long_inc(&vm_stat[item]);
73610 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
73611 + atomic_long_inc_unchecked(&vm_stat[item]);
73612 }
73613
73614 static inline void __inc_zone_page_state(struct page *page,
73615 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
73616
73617 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
73618 {
73619 - atomic_long_dec(&zone->vm_stat[item]);
73620 - atomic_long_dec(&vm_stat[item]);
73621 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
73622 + atomic_long_dec_unchecked(&vm_stat[item]);
73623 }
73624
73625 static inline void __dec_zone_page_state(struct page *page,
73626 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
73627 index fdbafc6..49dfe4f 100644
73628 --- a/include/linux/xattr.h
73629 +++ b/include/linux/xattr.h
73630 @@ -28,7 +28,7 @@ struct xattr_handler {
73631 size_t size, int handler_flags);
73632 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
73633 size_t size, int flags, int handler_flags);
73634 -};
73635 +} __do_const;
73636
73637 struct xattr {
73638 char *name;
73639 @@ -37,6 +37,9 @@ struct xattr {
73640 };
73641
73642 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
73643 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
73644 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
73645 +#endif
73646 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
73647 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
73648 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
73649 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
73650 index 9c5a6b4..09c9438 100644
73651 --- a/include/linux/zlib.h
73652 +++ b/include/linux/zlib.h
73653 @@ -31,6 +31,7 @@
73654 #define _ZLIB_H
73655
73656 #include <linux/zconf.h>
73657 +#include <linux/compiler.h>
73658
73659 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
73660 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
73661 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
73662
73663 /* basic functions */
73664
73665 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
73666 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
73667 /*
73668 Returns the number of bytes that needs to be allocated for a per-
73669 stream workspace with the specified parameters. A pointer to this
73670 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
73671 index 95d1c91..6798cca 100644
73672 --- a/include/media/v4l2-dev.h
73673 +++ b/include/media/v4l2-dev.h
73674 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
73675 int (*mmap) (struct file *, struct vm_area_struct *);
73676 int (*open) (struct file *);
73677 int (*release) (struct file *);
73678 -};
73679 +} __do_const;
73680
73681 /*
73682 * Newer version of video_device, handled by videodev2.c
73683 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
73684 index adcbb20..62c2559 100644
73685 --- a/include/net/9p/transport.h
73686 +++ b/include/net/9p/transport.h
73687 @@ -57,7 +57,7 @@ struct p9_trans_module {
73688 int (*cancel) (struct p9_client *, struct p9_req_t *req);
73689 int (*zc_request)(struct p9_client *, struct p9_req_t *,
73690 char *, char *, int , int, int, int);
73691 -};
73692 +} __do_const;
73693
73694 void v9fs_register_trans(struct p9_trans_module *m);
73695 void v9fs_unregister_trans(struct p9_trans_module *m);
73696 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
73697 index fb94cf1..7c0c987 100644
73698 --- a/include/net/bluetooth/l2cap.h
73699 +++ b/include/net/bluetooth/l2cap.h
73700 @@ -551,7 +551,7 @@ struct l2cap_ops {
73701 void (*defer) (struct l2cap_chan *chan);
73702 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
73703 unsigned long len, int nb);
73704 -};
73705 +} __do_const;
73706
73707 struct l2cap_conn {
73708 struct hci_conn *hcon;
73709 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
73710 index f2ae33d..c457cf0 100644
73711 --- a/include/net/caif/cfctrl.h
73712 +++ b/include/net/caif/cfctrl.h
73713 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
73714 void (*radioset_rsp)(void);
73715 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
73716 struct cflayer *client_layer);
73717 -};
73718 +} __no_const;
73719
73720 /* Link Setup Parameters for CAIF-Links. */
73721 struct cfctrl_link_param {
73722 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
73723 struct cfctrl {
73724 struct cfsrvl serv;
73725 struct cfctrl_rsp res;
73726 - atomic_t req_seq_no;
73727 - atomic_t rsp_seq_no;
73728 + atomic_unchecked_t req_seq_no;
73729 + atomic_unchecked_t rsp_seq_no;
73730 struct list_head list;
73731 /* Protects from simultaneous access to first_req list */
73732 spinlock_t info_list_lock;
73733 diff --git a/include/net/flow.h b/include/net/flow.h
73734 index 628e11b..4c475df 100644
73735 --- a/include/net/flow.h
73736 +++ b/include/net/flow.h
73737 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
73738
73739 extern void flow_cache_flush(void);
73740 extern void flow_cache_flush_deferred(void);
73741 -extern atomic_t flow_cache_genid;
73742 +extern atomic_unchecked_t flow_cache_genid;
73743
73744 #endif
73745 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
73746 index 93024a4..eeb6b6e 100644
73747 --- a/include/net/genetlink.h
73748 +++ b/include/net/genetlink.h
73749 @@ -119,7 +119,7 @@ struct genl_ops {
73750 struct netlink_callback *cb);
73751 int (*done)(struct netlink_callback *cb);
73752 struct list_head ops_list;
73753 -};
73754 +} __do_const;
73755
73756 extern int genl_register_family(struct genl_family *family);
73757 extern int genl_register_family_with_ops(struct genl_family *family,
73758 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
73759 index 734d9b5..48a9a4b 100644
73760 --- a/include/net/gro_cells.h
73761 +++ b/include/net/gro_cells.h
73762 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
73763 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
73764
73765 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
73766 - atomic_long_inc(&dev->rx_dropped);
73767 + atomic_long_inc_unchecked(&dev->rx_dropped);
73768 kfree_skb(skb);
73769 return;
73770 }
73771 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
73772 index de2c785..0588a6b 100644
73773 --- a/include/net/inet_connection_sock.h
73774 +++ b/include/net/inet_connection_sock.h
73775 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
73776 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
73777 int (*bind_conflict)(const struct sock *sk,
73778 const struct inet_bind_bucket *tb, bool relax);
73779 -};
73780 +} __do_const;
73781
73782 /** inet_connection_sock - INET connection oriented sock
73783 *
73784 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
73785 index 53f464d..ba76aaa 100644
73786 --- a/include/net/inetpeer.h
73787 +++ b/include/net/inetpeer.h
73788 @@ -47,8 +47,8 @@ struct inet_peer {
73789 */
73790 union {
73791 struct {
73792 - atomic_t rid; /* Frag reception counter */
73793 - atomic_t ip_id_count; /* IP ID for the next packet */
73794 + atomic_unchecked_t rid; /* Frag reception counter */
73795 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
73796 };
73797 struct rcu_head rcu;
73798 struct inet_peer *gc_next;
73799 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
73800 more++;
73801 inet_peer_refcheck(p);
73802 do {
73803 - old = atomic_read(&p->ip_id_count);
73804 + old = atomic_read_unchecked(&p->ip_id_count);
73805 new = old + more;
73806 if (!new)
73807 new = 1;
73808 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
73809 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
73810 return new;
73811 }
73812
73813 diff --git a/include/net/ip.h b/include/net/ip.h
73814 index a68f838..74518ab 100644
73815 --- a/include/net/ip.h
73816 +++ b/include/net/ip.h
73817 @@ -202,7 +202,7 @@ extern struct local_ports {
73818 } sysctl_local_ports;
73819 extern void inet_get_local_port_range(int *low, int *high);
73820
73821 -extern unsigned long *sysctl_local_reserved_ports;
73822 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
73823 static inline int inet_is_reserved_local_port(int port)
73824 {
73825 return test_bit(port, sysctl_local_reserved_ports);
73826 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
73827 index e49db91..76a81de 100644
73828 --- a/include/net/ip_fib.h
73829 +++ b/include/net/ip_fib.h
73830 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
73831
73832 #define FIB_RES_SADDR(net, res) \
73833 ((FIB_RES_NH(res).nh_saddr_genid == \
73834 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
73835 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
73836 FIB_RES_NH(res).nh_saddr : \
73837 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
73838 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
73839 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
73840 index 4c062cc..3562c31 100644
73841 --- a/include/net/ip_vs.h
73842 +++ b/include/net/ip_vs.h
73843 @@ -612,7 +612,7 @@ struct ip_vs_conn {
73844 struct ip_vs_conn *control; /* Master control connection */
73845 atomic_t n_control; /* Number of controlled ones */
73846 struct ip_vs_dest *dest; /* real server */
73847 - atomic_t in_pkts; /* incoming packet counter */
73848 + atomic_unchecked_t in_pkts; /* incoming packet counter */
73849
73850 /* packet transmitter for different forwarding methods. If it
73851 mangles the packet, it must return NF_DROP or better NF_STOLEN,
73852 @@ -761,7 +761,7 @@ struct ip_vs_dest {
73853 __be16 port; /* port number of the server */
73854 union nf_inet_addr addr; /* IP address of the server */
73855 volatile unsigned int flags; /* dest status flags */
73856 - atomic_t conn_flags; /* flags to copy to conn */
73857 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
73858 atomic_t weight; /* server weight */
73859
73860 atomic_t refcnt; /* reference counter */
73861 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
73862 /* ip_vs_lblc */
73863 int sysctl_lblc_expiration;
73864 struct ctl_table_header *lblc_ctl_header;
73865 - struct ctl_table *lblc_ctl_table;
73866 + ctl_table_no_const *lblc_ctl_table;
73867 /* ip_vs_lblcr */
73868 int sysctl_lblcr_expiration;
73869 struct ctl_table_header *lblcr_ctl_header;
73870 - struct ctl_table *lblcr_ctl_table;
73871 + ctl_table_no_const *lblcr_ctl_table;
73872 /* ip_vs_est */
73873 struct list_head est_list; /* estimator list */
73874 spinlock_t est_lock;
73875 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
73876 index 80ffde3..968b0f4 100644
73877 --- a/include/net/irda/ircomm_tty.h
73878 +++ b/include/net/irda/ircomm_tty.h
73879 @@ -35,6 +35,7 @@
73880 #include <linux/termios.h>
73881 #include <linux/timer.h>
73882 #include <linux/tty.h> /* struct tty_struct */
73883 +#include <asm/local.h>
73884
73885 #include <net/irda/irias_object.h>
73886 #include <net/irda/ircomm_core.h>
73887 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
73888 index 714cc9a..ea05f3e 100644
73889 --- a/include/net/iucv/af_iucv.h
73890 +++ b/include/net/iucv/af_iucv.h
73891 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
73892 struct iucv_sock_list {
73893 struct hlist_head head;
73894 rwlock_t lock;
73895 - atomic_t autobind_name;
73896 + atomic_unchecked_t autobind_name;
73897 };
73898
73899 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
73900 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
73901 index df83f69..9b640b8 100644
73902 --- a/include/net/llc_c_ac.h
73903 +++ b/include/net/llc_c_ac.h
73904 @@ -87,7 +87,7 @@
73905 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
73906 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
73907
73908 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73909 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73910
73911 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
73912 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
73913 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
73914 index 6ca3113..f8026dd 100644
73915 --- a/include/net/llc_c_ev.h
73916 +++ b/include/net/llc_c_ev.h
73917 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
73918 return (struct llc_conn_state_ev *)skb->cb;
73919 }
73920
73921 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73922 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73923 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73924 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73925
73926 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
73927 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
73928 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
73929 index 0e79cfb..f46db31 100644
73930 --- a/include/net/llc_c_st.h
73931 +++ b/include/net/llc_c_st.h
73932 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
73933 u8 next_state;
73934 llc_conn_ev_qfyr_t *ev_qualifiers;
73935 llc_conn_action_t *ev_actions;
73936 -};
73937 +} __do_const;
73938
73939 struct llc_conn_state {
73940 u8 current_state;
73941 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
73942 index 37a3bbd..55a4241 100644
73943 --- a/include/net/llc_s_ac.h
73944 +++ b/include/net/llc_s_ac.h
73945 @@ -23,7 +23,7 @@
73946 #define SAP_ACT_TEST_IND 9
73947
73948 /* All action functions must look like this */
73949 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73950 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73951
73952 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
73953 struct sk_buff *skb);
73954 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
73955 index 567c681..cd73ac0 100644
73956 --- a/include/net/llc_s_st.h
73957 +++ b/include/net/llc_s_st.h
73958 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
73959 llc_sap_ev_t ev;
73960 u8 next_state;
73961 llc_sap_action_t *ev_actions;
73962 -};
73963 +} __do_const;
73964
73965 struct llc_sap_state {
73966 u8 curr_state;
73967 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
73968 index 885898a..cdace34 100644
73969 --- a/include/net/mac80211.h
73970 +++ b/include/net/mac80211.h
73971 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
73972 void (*add_sta_debugfs)(void *priv, void *priv_sta,
73973 struct dentry *dir);
73974 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
73975 -};
73976 +} __do_const;
73977
73978 static inline int rate_supported(struct ieee80211_sta *sta,
73979 enum ieee80211_band band,
73980 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
73981 index 7e748ad..5c6229b 100644
73982 --- a/include/net/neighbour.h
73983 +++ b/include/net/neighbour.h
73984 @@ -123,7 +123,7 @@ struct neigh_ops {
73985 void (*error_report)(struct neighbour *, struct sk_buff *);
73986 int (*output)(struct neighbour *, struct sk_buff *);
73987 int (*connected_output)(struct neighbour *, struct sk_buff *);
73988 -};
73989 +} __do_const;
73990
73991 struct pneigh_entry {
73992 struct pneigh_entry *next;
73993 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
73994 index b176978..ea169f4 100644
73995 --- a/include/net/net_namespace.h
73996 +++ b/include/net/net_namespace.h
73997 @@ -117,7 +117,7 @@ struct net {
73998 #endif
73999 struct netns_ipvs *ipvs;
74000 struct sock *diag_nlsk;
74001 - atomic_t rt_genid;
74002 + atomic_unchecked_t rt_genid;
74003 };
74004
74005 /*
74006 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
74007 #define __net_init __init
74008 #define __net_exit __exit_refok
74009 #define __net_initdata __initdata
74010 +#ifdef CONSTIFY_PLUGIN
74011 #define __net_initconst __initconst
74012 +#else
74013 +#define __net_initconst __initdata
74014 +#endif
74015 #endif
74016
74017 struct pernet_operations {
74018 @@ -284,7 +288,7 @@ struct pernet_operations {
74019 void (*exit_batch)(struct list_head *net_exit_list);
74020 int *id;
74021 size_t size;
74022 -};
74023 +} __do_const;
74024
74025 /*
74026 * Use these carefully. If you implement a network device and it
74027 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
74028
74029 static inline int rt_genid(struct net *net)
74030 {
74031 - return atomic_read(&net->rt_genid);
74032 + return atomic_read_unchecked(&net->rt_genid);
74033 }
74034
74035 static inline void rt_genid_bump(struct net *net)
74036 {
74037 - atomic_inc(&net->rt_genid);
74038 + atomic_inc_unchecked(&net->rt_genid);
74039 }
74040
74041 #endif /* __NET_NET_NAMESPACE_H */
74042 diff --git a/include/net/netdma.h b/include/net/netdma.h
74043 index 8ba8ce2..99b7fff 100644
74044 --- a/include/net/netdma.h
74045 +++ b/include/net/netdma.h
74046 @@ -24,7 +24,7 @@
74047 #include <linux/dmaengine.h>
74048 #include <linux/skbuff.h>
74049
74050 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
74051 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
74052 struct sk_buff *skb, int offset, struct iovec *to,
74053 size_t len, struct dma_pinned_list *pinned_list);
74054
74055 diff --git a/include/net/netlink.h b/include/net/netlink.h
74056 index 9690b0f..87aded7 100644
74057 --- a/include/net/netlink.h
74058 +++ b/include/net/netlink.h
74059 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
74060 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
74061 {
74062 if (mark)
74063 - skb_trim(skb, (unsigned char *) mark - skb->data);
74064 + skb_trim(skb, (const unsigned char *) mark - skb->data);
74065 }
74066
74067 /**
74068 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
74069 index c9c0c53..53f24c3 100644
74070 --- a/include/net/netns/conntrack.h
74071 +++ b/include/net/netns/conntrack.h
74072 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
74073 struct nf_proto_net {
74074 #ifdef CONFIG_SYSCTL
74075 struct ctl_table_header *ctl_table_header;
74076 - struct ctl_table *ctl_table;
74077 + ctl_table_no_const *ctl_table;
74078 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
74079 struct ctl_table_header *ctl_compat_header;
74080 - struct ctl_table *ctl_compat_table;
74081 + ctl_table_no_const *ctl_compat_table;
74082 #endif
74083 #endif
74084 unsigned int users;
74085 @@ -58,7 +58,7 @@ struct nf_ip_net {
74086 struct nf_icmp_net icmpv6;
74087 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
74088 struct ctl_table_header *ctl_table_header;
74089 - struct ctl_table *ctl_table;
74090 + ctl_table_no_const *ctl_table;
74091 #endif
74092 };
74093
74094 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
74095 index 2ba9de8..47bd6c7 100644
74096 --- a/include/net/netns/ipv4.h
74097 +++ b/include/net/netns/ipv4.h
74098 @@ -67,7 +67,7 @@ struct netns_ipv4 {
74099 kgid_t sysctl_ping_group_range[2];
74100 long sysctl_tcp_mem[3];
74101
74102 - atomic_t dev_addr_genid;
74103 + atomic_unchecked_t dev_addr_genid;
74104
74105 #ifdef CONFIG_IP_MROUTE
74106 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
74107 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
74108 index 005e2c2..023d340 100644
74109 --- a/include/net/netns/ipv6.h
74110 +++ b/include/net/netns/ipv6.h
74111 @@ -71,7 +71,7 @@ struct netns_ipv6 {
74112 struct fib_rules_ops *mr6_rules_ops;
74113 #endif
74114 #endif
74115 - atomic_t dev_addr_genid;
74116 + atomic_unchecked_t dev_addr_genid;
74117 };
74118
74119 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
74120 diff --git a/include/net/protocol.h b/include/net/protocol.h
74121 index 047c047..b9dad15 100644
74122 --- a/include/net/protocol.h
74123 +++ b/include/net/protocol.h
74124 @@ -44,7 +44,7 @@ struct net_protocol {
74125 void (*err_handler)(struct sk_buff *skb, u32 info);
74126 unsigned int no_policy:1,
74127 netns_ok:1;
74128 -};
74129 +} __do_const;
74130
74131 #if IS_ENABLED(CONFIG_IPV6)
74132 struct inet6_protocol {
74133 @@ -57,7 +57,7 @@ struct inet6_protocol {
74134 u8 type, u8 code, int offset,
74135 __be32 info);
74136 unsigned int flags; /* INET6_PROTO_xxx */
74137 -};
74138 +} __do_const;
74139
74140 #define INET6_PROTO_NOPOLICY 0x1
74141 #define INET6_PROTO_FINAL 0x2
74142 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
74143 index 7026648..584cc8c 100644
74144 --- a/include/net/rtnetlink.h
74145 +++ b/include/net/rtnetlink.h
74146 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
74147 const struct net_device *dev);
74148 unsigned int (*get_num_tx_queues)(void);
74149 unsigned int (*get_num_rx_queues)(void);
74150 -};
74151 +} __do_const;
74152
74153 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
74154 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
74155 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
74156 index cd89510..d67810f 100644
74157 --- a/include/net/sctp/sctp.h
74158 +++ b/include/net/sctp/sctp.h
74159 @@ -330,9 +330,9 @@ do { \
74160
74161 #else /* SCTP_DEBUG */
74162
74163 -#define SCTP_DEBUG_PRINTK(whatever...)
74164 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
74165 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
74166 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
74167 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
74168 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
74169 #define SCTP_ENABLE_DEBUG
74170 #define SCTP_DISABLE_DEBUG
74171 #define SCTP_ASSERT(expr, str, func)
74172 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
74173 index 2a82d13..62a31c2 100644
74174 --- a/include/net/sctp/sm.h
74175 +++ b/include/net/sctp/sm.h
74176 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
74177 typedef struct {
74178 sctp_state_fn_t *fn;
74179 const char *name;
74180 -} sctp_sm_table_entry_t;
74181 +} __do_const sctp_sm_table_entry_t;
74182
74183 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
74184 * currently in use.
74185 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
74186 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
74187
74188 /* Extern declarations for major data structures. */
74189 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
74190 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
74191
74192
74193 /* Get the size of a DATA chunk payload. */
74194 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
74195 index 1bd4c41..9250b5b 100644
74196 --- a/include/net/sctp/structs.h
74197 +++ b/include/net/sctp/structs.h
74198 @@ -516,7 +516,7 @@ struct sctp_pf {
74199 struct sctp_association *asoc);
74200 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
74201 struct sctp_af *af;
74202 -};
74203 +} __do_const;
74204
74205
74206 /* Structure to track chunk fragments that have been acked, but peer
74207 diff --git a/include/net/sock.h b/include/net/sock.h
74208 index 66772cf..25bc45b 100644
74209 --- a/include/net/sock.h
74210 +++ b/include/net/sock.h
74211 @@ -325,7 +325,7 @@ struct sock {
74212 #ifdef CONFIG_RPS
74213 __u32 sk_rxhash;
74214 #endif
74215 - atomic_t sk_drops;
74216 + atomic_unchecked_t sk_drops;
74217 int sk_rcvbuf;
74218
74219 struct sk_filter __rcu *sk_filter;
74220 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
74221 }
74222
74223 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
74224 - char __user *from, char *to,
74225 + char __user *from, unsigned char *to,
74226 int copy, int offset)
74227 {
74228 if (skb->ip_summed == CHECKSUM_NONE) {
74229 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
74230 }
74231 }
74232
74233 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
74234 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
74235
74236 /**
74237 * sk_page_frag - return an appropriate page_frag
74238 diff --git a/include/net/tcp.h b/include/net/tcp.h
74239 index 5bba80f..8520a82 100644
74240 --- a/include/net/tcp.h
74241 +++ b/include/net/tcp.h
74242 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
74243 extern void tcp_xmit_retransmit_queue(struct sock *);
74244 extern void tcp_simple_retransmit(struct sock *);
74245 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
74246 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
74247 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
74248
74249 extern void tcp_send_probe0(struct sock *);
74250 extern void tcp_send_partial(struct sock *);
74251 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
74252 struct inet6_skb_parm h6;
74253 #endif
74254 } header; /* For incoming frames */
74255 - __u32 seq; /* Starting sequence number */
74256 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
74257 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
74258 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
74259 __u32 when; /* used to compute rtt's */
74260 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
74261
74262 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
74263
74264 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
74265 /* 1 byte hole */
74266 - __u32 ack_seq; /* Sequence number ACK'd */
74267 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
74268 };
74269
74270 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
74271 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
74272 index 94ce082..62b278d 100644
74273 --- a/include/net/xfrm.h
74274 +++ b/include/net/xfrm.h
74275 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
74276 struct net_device *dev,
74277 const struct flowi *fl);
74278 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
74279 -};
74280 +} __do_const;
74281
74282 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
74283 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
74284 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
74285 struct sk_buff *skb);
74286 int (*transport_finish)(struct sk_buff *skb,
74287 int async);
74288 -};
74289 +} __do_const;
74290
74291 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
74292 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
74293 @@ -424,7 +424,7 @@ struct xfrm_mode {
74294 struct module *owner;
74295 unsigned int encap;
74296 int flags;
74297 -};
74298 +} __do_const;
74299
74300 /* Flags for xfrm_mode. */
74301 enum {
74302 @@ -521,7 +521,7 @@ struct xfrm_policy {
74303 struct timer_list timer;
74304
74305 struct flow_cache_object flo;
74306 - atomic_t genid;
74307 + atomic_unchecked_t genid;
74308 u32 priority;
74309 u32 index;
74310 struct xfrm_mark mark;
74311 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
74312 index 1a046b1..ee0bef0 100644
74313 --- a/include/rdma/iw_cm.h
74314 +++ b/include/rdma/iw_cm.h
74315 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
74316 int backlog);
74317
74318 int (*destroy_listen)(struct iw_cm_id *cm_id);
74319 -};
74320 +} __no_const;
74321
74322 /**
74323 * iw_create_cm_id - Create an IW CM identifier.
74324 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
74325 index e1379b4..67eafbe 100644
74326 --- a/include/scsi/libfc.h
74327 +++ b/include/scsi/libfc.h
74328 @@ -762,6 +762,7 @@ struct libfc_function_template {
74329 */
74330 void (*disc_stop_final) (struct fc_lport *);
74331 };
74332 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
74333
74334 /**
74335 * struct fc_disc - Discovery context
74336 @@ -866,7 +867,7 @@ struct fc_lport {
74337 struct fc_vport *vport;
74338
74339 /* Operational Information */
74340 - struct libfc_function_template tt;
74341 + libfc_function_template_no_const tt;
74342 u8 link_up;
74343 u8 qfull;
74344 enum fc_lport_state state;
74345 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
74346 index cc64587..608f523 100644
74347 --- a/include/scsi/scsi_device.h
74348 +++ b/include/scsi/scsi_device.h
74349 @@ -171,9 +171,9 @@ struct scsi_device {
74350 unsigned int max_device_blocked; /* what device_blocked counts down from */
74351 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
74352
74353 - atomic_t iorequest_cnt;
74354 - atomic_t iodone_cnt;
74355 - atomic_t ioerr_cnt;
74356 + atomic_unchecked_t iorequest_cnt;
74357 + atomic_unchecked_t iodone_cnt;
74358 + atomic_unchecked_t ioerr_cnt;
74359
74360 struct device sdev_gendev,
74361 sdev_dev;
74362 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
74363 index b797e8f..8e2c3aa 100644
74364 --- a/include/scsi/scsi_transport_fc.h
74365 +++ b/include/scsi/scsi_transport_fc.h
74366 @@ -751,7 +751,8 @@ struct fc_function_template {
74367 unsigned long show_host_system_hostname:1;
74368
74369 unsigned long disable_target_scan:1;
74370 -};
74371 +} __do_const;
74372 +typedef struct fc_function_template __no_const fc_function_template_no_const;
74373
74374
74375 /**
74376 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
74377 index 9031a26..750d592 100644
74378 --- a/include/sound/compress_driver.h
74379 +++ b/include/sound/compress_driver.h
74380 @@ -128,7 +128,7 @@ struct snd_compr_ops {
74381 struct snd_compr_caps *caps);
74382 int (*get_codec_caps) (struct snd_compr_stream *stream,
74383 struct snd_compr_codec_caps *codec);
74384 -};
74385 +} __no_const;
74386
74387 /**
74388 * struct snd_compr: Compressed device
74389 diff --git a/include/sound/soc.h b/include/sound/soc.h
74390 index 85c1522..f44bad1 100644
74391 --- a/include/sound/soc.h
74392 +++ b/include/sound/soc.h
74393 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
74394 /* probe ordering - for components with runtime dependencies */
74395 int probe_order;
74396 int remove_order;
74397 -};
74398 +} __do_const;
74399
74400 /* SoC platform interface */
74401 struct snd_soc_platform_driver {
74402 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
74403 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
74404 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
74405 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
74406 -};
74407 +} __do_const;
74408
74409 struct snd_soc_platform {
74410 const char *name;
74411 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
74412 index 4ea4f98..a63629b 100644
74413 --- a/include/target/target_core_base.h
74414 +++ b/include/target/target_core_base.h
74415 @@ -653,7 +653,7 @@ struct se_device {
74416 spinlock_t stats_lock;
74417 /* Active commands on this virtual SE device */
74418 atomic_t simple_cmds;
74419 - atomic_t dev_ordered_id;
74420 + atomic_unchecked_t dev_ordered_id;
74421 atomic_t dev_ordered_sync;
74422 atomic_t dev_qf_count;
74423 int export_count;
74424 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
74425 new file mode 100644
74426 index 0000000..fb634b7
74427 --- /dev/null
74428 +++ b/include/trace/events/fs.h
74429 @@ -0,0 +1,53 @@
74430 +#undef TRACE_SYSTEM
74431 +#define TRACE_SYSTEM fs
74432 +
74433 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
74434 +#define _TRACE_FS_H
74435 +
74436 +#include <linux/fs.h>
74437 +#include <linux/tracepoint.h>
74438 +
74439 +TRACE_EVENT(do_sys_open,
74440 +
74441 + TP_PROTO(const char *filename, int flags, int mode),
74442 +
74443 + TP_ARGS(filename, flags, mode),
74444 +
74445 + TP_STRUCT__entry(
74446 + __string( filename, filename )
74447 + __field( int, flags )
74448 + __field( int, mode )
74449 + ),
74450 +
74451 + TP_fast_assign(
74452 + __assign_str(filename, filename);
74453 + __entry->flags = flags;
74454 + __entry->mode = mode;
74455 + ),
74456 +
74457 + TP_printk("\"%s\" %x %o",
74458 + __get_str(filename), __entry->flags, __entry->mode)
74459 +);
74460 +
74461 +TRACE_EVENT(open_exec,
74462 +
74463 + TP_PROTO(const char *filename),
74464 +
74465 + TP_ARGS(filename),
74466 +
74467 + TP_STRUCT__entry(
74468 + __string( filename, filename )
74469 + ),
74470 +
74471 + TP_fast_assign(
74472 + __assign_str(filename, filename);
74473 + ),
74474 +
74475 + TP_printk("\"%s\"",
74476 + __get_str(filename))
74477 +);
74478 +
74479 +#endif /* _TRACE_FS_H */
74480 +
74481 +/* This part must be outside protection */
74482 +#include <trace/define_trace.h>
74483 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
74484 index 1c09820..7f5ec79 100644
74485 --- a/include/trace/events/irq.h
74486 +++ b/include/trace/events/irq.h
74487 @@ -36,7 +36,7 @@ struct softirq_action;
74488 */
74489 TRACE_EVENT(irq_handler_entry,
74490
74491 - TP_PROTO(int irq, struct irqaction *action),
74492 + TP_PROTO(int irq, const struct irqaction *action),
74493
74494 TP_ARGS(irq, action),
74495
74496 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
74497 */
74498 TRACE_EVENT(irq_handler_exit,
74499
74500 - TP_PROTO(int irq, struct irqaction *action, int ret),
74501 + TP_PROTO(int irq, const struct irqaction *action, int ret),
74502
74503 TP_ARGS(irq, action, ret),
74504
74505 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
74506 index 7caf44c..23c6f27 100644
74507 --- a/include/uapi/linux/a.out.h
74508 +++ b/include/uapi/linux/a.out.h
74509 @@ -39,6 +39,14 @@ enum machine_type {
74510 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
74511 };
74512
74513 +/* Constants for the N_FLAGS field */
74514 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
74515 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
74516 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
74517 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
74518 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
74519 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
74520 +
74521 #if !defined (N_MAGIC)
74522 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
74523 #endif
74524 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
74525 index d876736..ccce5c0 100644
74526 --- a/include/uapi/linux/byteorder/little_endian.h
74527 +++ b/include/uapi/linux/byteorder/little_endian.h
74528 @@ -42,51 +42,51 @@
74529
74530 static inline __le64 __cpu_to_le64p(const __u64 *p)
74531 {
74532 - return (__force __le64)*p;
74533 + return (__force const __le64)*p;
74534 }
74535 -static inline __u64 __le64_to_cpup(const __le64 *p)
74536 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
74537 {
74538 - return (__force __u64)*p;
74539 + return (__force const __u64)*p;
74540 }
74541 static inline __le32 __cpu_to_le32p(const __u32 *p)
74542 {
74543 - return (__force __le32)*p;
74544 + return (__force const __le32)*p;
74545 }
74546 static inline __u32 __le32_to_cpup(const __le32 *p)
74547 {
74548 - return (__force __u32)*p;
74549 + return (__force const __u32)*p;
74550 }
74551 static inline __le16 __cpu_to_le16p(const __u16 *p)
74552 {
74553 - return (__force __le16)*p;
74554 + return (__force const __le16)*p;
74555 }
74556 static inline __u16 __le16_to_cpup(const __le16 *p)
74557 {
74558 - return (__force __u16)*p;
74559 + return (__force const __u16)*p;
74560 }
74561 static inline __be64 __cpu_to_be64p(const __u64 *p)
74562 {
74563 - return (__force __be64)__swab64p(p);
74564 + return (__force const __be64)__swab64p(p);
74565 }
74566 static inline __u64 __be64_to_cpup(const __be64 *p)
74567 {
74568 - return __swab64p((__u64 *)p);
74569 + return __swab64p((const __u64 *)p);
74570 }
74571 static inline __be32 __cpu_to_be32p(const __u32 *p)
74572 {
74573 - return (__force __be32)__swab32p(p);
74574 + return (__force const __be32)__swab32p(p);
74575 }
74576 -static inline __u32 __be32_to_cpup(const __be32 *p)
74577 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
74578 {
74579 - return __swab32p((__u32 *)p);
74580 + return __swab32p((const __u32 *)p);
74581 }
74582 static inline __be16 __cpu_to_be16p(const __u16 *p)
74583 {
74584 - return (__force __be16)__swab16p(p);
74585 + return (__force const __be16)__swab16p(p);
74586 }
74587 static inline __u16 __be16_to_cpup(const __be16 *p)
74588 {
74589 - return __swab16p((__u16 *)p);
74590 + return __swab16p((const __u16 *)p);
74591 }
74592 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
74593 #define __le64_to_cpus(x) do { (void)(x); } while (0)
74594 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
74595 index ef6103b..d4e65dd 100644
74596 --- a/include/uapi/linux/elf.h
74597 +++ b/include/uapi/linux/elf.h
74598 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
74599 #define PT_GNU_EH_FRAME 0x6474e550
74600
74601 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
74602 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
74603 +
74604 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
74605 +
74606 +/* Constants for the e_flags field */
74607 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
74608 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
74609 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
74610 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
74611 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
74612 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
74613
74614 /*
74615 * Extended Numbering
74616 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
74617 #define DT_DEBUG 21
74618 #define DT_TEXTREL 22
74619 #define DT_JMPREL 23
74620 +#define DT_FLAGS 30
74621 + #define DF_TEXTREL 0x00000004
74622 #define DT_ENCODING 32
74623 #define OLD_DT_LOOS 0x60000000
74624 #define DT_LOOS 0x6000000d
74625 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
74626 #define PF_W 0x2
74627 #define PF_X 0x1
74628
74629 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
74630 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
74631 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
74632 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
74633 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
74634 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
74635 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
74636 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
74637 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
74638 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
74639 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
74640 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
74641 +
74642 typedef struct elf32_phdr{
74643 Elf32_Word p_type;
74644 Elf32_Off p_offset;
74645 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
74646 #define EI_OSABI 7
74647 #define EI_PAD 8
74648
74649 +#define EI_PAX 14
74650 +
74651 #define ELFMAG0 0x7f /* EI_MAG */
74652 #define ELFMAG1 'E'
74653 #define ELFMAG2 'L'
74654 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
74655 index aa169c4..6a2771d 100644
74656 --- a/include/uapi/linux/personality.h
74657 +++ b/include/uapi/linux/personality.h
74658 @@ -30,6 +30,7 @@ enum {
74659 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
74660 ADDR_NO_RANDOMIZE | \
74661 ADDR_COMPAT_LAYOUT | \
74662 + ADDR_LIMIT_3GB | \
74663 MMAP_PAGE_ZERO)
74664
74665 /*
74666 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
74667 index 7530e74..e714828 100644
74668 --- a/include/uapi/linux/screen_info.h
74669 +++ b/include/uapi/linux/screen_info.h
74670 @@ -43,7 +43,8 @@ struct screen_info {
74671 __u16 pages; /* 0x32 */
74672 __u16 vesa_attributes; /* 0x34 */
74673 __u32 capabilities; /* 0x36 */
74674 - __u8 _reserved[6]; /* 0x3a */
74675 + __u16 vesapm_size; /* 0x3a */
74676 + __u8 _reserved[4]; /* 0x3c */
74677 } __attribute__((packed));
74678
74679 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
74680 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
74681 index 0e011eb..82681b1 100644
74682 --- a/include/uapi/linux/swab.h
74683 +++ b/include/uapi/linux/swab.h
74684 @@ -43,7 +43,7 @@
74685 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
74686 */
74687
74688 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
74689 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
74690 {
74691 #ifdef __HAVE_BUILTIN_BSWAP16__
74692 return __builtin_bswap16(val);
74693 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
74694 #endif
74695 }
74696
74697 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
74698 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
74699 {
74700 #ifdef __HAVE_BUILTIN_BSWAP32__
74701 return __builtin_bswap32(val);
74702 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
74703 #endif
74704 }
74705
74706 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
74707 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
74708 {
74709 #ifdef __HAVE_BUILTIN_BSWAP64__
74710 return __builtin_bswap64(val);
74711 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
74712 index 6d67213..8dab561 100644
74713 --- a/include/uapi/linux/sysctl.h
74714 +++ b/include/uapi/linux/sysctl.h
74715 @@ -155,7 +155,11 @@ enum
74716 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
74717 };
74718
74719 -
74720 +#ifdef CONFIG_PAX_SOFTMODE
74721 +enum {
74722 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
74723 +};
74724 +#endif
74725
74726 /* CTL_VM names: */
74727 enum
74728 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
74729 index e4629b9..6958086 100644
74730 --- a/include/uapi/linux/xattr.h
74731 +++ b/include/uapi/linux/xattr.h
74732 @@ -63,5 +63,9 @@
74733 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
74734 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
74735
74736 +/* User namespace */
74737 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
74738 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
74739 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
74740
74741 #endif /* _UAPI_LINUX_XATTR_H */
74742 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
74743 index f9466fa..f4e2b81 100644
74744 --- a/include/video/udlfb.h
74745 +++ b/include/video/udlfb.h
74746 @@ -53,10 +53,10 @@ struct dlfb_data {
74747 u32 pseudo_palette[256];
74748 int blank_mode; /*one of FB_BLANK_ */
74749 /* blit-only rendering path metrics, exposed through sysfs */
74750 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
74751 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
74752 - atomic_t bytes_sent; /* to usb, after compression including overhead */
74753 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
74754 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
74755 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
74756 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
74757 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
74758 };
74759
74760 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
74761 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
74762 index 1a91850..28573f8 100644
74763 --- a/include/video/uvesafb.h
74764 +++ b/include/video/uvesafb.h
74765 @@ -122,6 +122,7 @@ struct uvesafb_par {
74766 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
74767 u8 pmi_setpal; /* PMI for palette changes */
74768 u16 *pmi_base; /* protected mode interface location */
74769 + u8 *pmi_code; /* protected mode code location */
74770 void *pmi_start;
74771 void *pmi_pal;
74772 u8 *vbe_state_orig; /*
74773 diff --git a/init/Kconfig b/init/Kconfig
74774 index 2d9b831..ae4c8ac 100644
74775 --- a/init/Kconfig
74776 +++ b/init/Kconfig
74777 @@ -1029,6 +1029,7 @@ endif # CGROUPS
74778
74779 config CHECKPOINT_RESTORE
74780 bool "Checkpoint/restore support" if EXPERT
74781 + depends on !GRKERNSEC
74782 default n
74783 help
74784 Enables additional kernel features in a sake of checkpoint/restore.
74785 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
74786
74787 config COMPAT_BRK
74788 bool "Disable heap randomization"
74789 - default y
74790 + default n
74791 help
74792 Randomizing heap placement makes heap exploits harder, but it
74793 also breaks ancient binaries (including anything libc5 based).
74794 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
74795 config STOP_MACHINE
74796 bool
74797 default y
74798 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
74799 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
74800 help
74801 Need stop_machine() primitive.
74802
74803 diff --git a/init/Makefile b/init/Makefile
74804 index 7bc47ee..6da2dc7 100644
74805 --- a/init/Makefile
74806 +++ b/init/Makefile
74807 @@ -2,6 +2,9 @@
74808 # Makefile for the linux kernel.
74809 #
74810
74811 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
74812 +asflags-y := $(GCC_PLUGINS_AFLAGS)
74813 +
74814 obj-y := main.o version.o mounts.o
74815 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
74816 obj-y += noinitramfs.o
74817 diff --git a/init/do_mounts.c b/init/do_mounts.c
74818 index a2b49f2..03a0e17c 100644
74819 --- a/init/do_mounts.c
74820 +++ b/init/do_mounts.c
74821 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
74822 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
74823 {
74824 struct super_block *s;
74825 - int err = sys_mount(name, "/root", fs, flags, data);
74826 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
74827 if (err)
74828 return err;
74829
74830 - sys_chdir("/root");
74831 + sys_chdir((const char __force_user *)"/root");
74832 s = current->fs->pwd.dentry->d_sb;
74833 ROOT_DEV = s->s_dev;
74834 printk(KERN_INFO
74835 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
74836 va_start(args, fmt);
74837 vsprintf(buf, fmt, args);
74838 va_end(args);
74839 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
74840 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
74841 if (fd >= 0) {
74842 sys_ioctl(fd, FDEJECT, 0);
74843 sys_close(fd);
74844 }
74845 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
74846 - fd = sys_open("/dev/console", O_RDWR, 0);
74847 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
74848 if (fd >= 0) {
74849 sys_ioctl(fd, TCGETS, (long)&termios);
74850 termios.c_lflag &= ~ICANON;
74851 sys_ioctl(fd, TCSETSF, (long)&termios);
74852 - sys_read(fd, &c, 1);
74853 + sys_read(fd, (char __user *)&c, 1);
74854 termios.c_lflag |= ICANON;
74855 sys_ioctl(fd, TCSETSF, (long)&termios);
74856 sys_close(fd);
74857 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
74858 mount_root();
74859 out:
74860 devtmpfs_mount("dev");
74861 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74862 - sys_chroot(".");
74863 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74864 + sys_chroot((const char __force_user *)".");
74865 }
74866 diff --git a/init/do_mounts.h b/init/do_mounts.h
74867 index f5b978a..69dbfe8 100644
74868 --- a/init/do_mounts.h
74869 +++ b/init/do_mounts.h
74870 @@ -15,15 +15,15 @@ extern int root_mountflags;
74871
74872 static inline int create_dev(char *name, dev_t dev)
74873 {
74874 - sys_unlink(name);
74875 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
74876 + sys_unlink((char __force_user *)name);
74877 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
74878 }
74879
74880 #if BITS_PER_LONG == 32
74881 static inline u32 bstat(char *name)
74882 {
74883 struct stat64 stat;
74884 - if (sys_stat64(name, &stat) != 0)
74885 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
74886 return 0;
74887 if (!S_ISBLK(stat.st_mode))
74888 return 0;
74889 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
74890 static inline u32 bstat(char *name)
74891 {
74892 struct stat stat;
74893 - if (sys_newstat(name, &stat) != 0)
74894 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
74895 return 0;
74896 if (!S_ISBLK(stat.st_mode))
74897 return 0;
74898 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
74899 index 3e0878e..8a9d7a0 100644
74900 --- a/init/do_mounts_initrd.c
74901 +++ b/init/do_mounts_initrd.c
74902 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
74903 {
74904 sys_unshare(CLONE_FS | CLONE_FILES);
74905 /* stdin/stdout/stderr for /linuxrc */
74906 - sys_open("/dev/console", O_RDWR, 0);
74907 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
74908 sys_dup(0);
74909 sys_dup(0);
74910 /* move initrd over / and chdir/chroot in initrd root */
74911 - sys_chdir("/root");
74912 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74913 - sys_chroot(".");
74914 + sys_chdir((const char __force_user *)"/root");
74915 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74916 + sys_chroot((const char __force_user *)".");
74917 sys_setsid();
74918 return 0;
74919 }
74920 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
74921 create_dev("/dev/root.old", Root_RAM0);
74922 /* mount initrd on rootfs' /root */
74923 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
74924 - sys_mkdir("/old", 0700);
74925 - sys_chdir("/old");
74926 + sys_mkdir((const char __force_user *)"/old", 0700);
74927 + sys_chdir((const char __force_user *)"/old");
74928
74929 /* try loading default modules from initrd */
74930 load_default_modules();
74931 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
74932 current->flags &= ~PF_FREEZER_SKIP;
74933
74934 /* move initrd to rootfs' /old */
74935 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
74936 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
74937 /* switch root and cwd back to / of rootfs */
74938 - sys_chroot("..");
74939 + sys_chroot((const char __force_user *)"..");
74940
74941 if (new_decode_dev(real_root_dev) == Root_RAM0) {
74942 - sys_chdir("/old");
74943 + sys_chdir((const char __force_user *)"/old");
74944 return;
74945 }
74946
74947 - sys_chdir("/");
74948 + sys_chdir((const char __force_user *)"/");
74949 ROOT_DEV = new_decode_dev(real_root_dev);
74950 mount_root();
74951
74952 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
74953 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
74954 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
74955 if (!error)
74956 printk("okay\n");
74957 else {
74958 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
74959 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
74960 if (error == -ENOENT)
74961 printk("/initrd does not exist. Ignored.\n");
74962 else
74963 printk("failed\n");
74964 printk(KERN_NOTICE "Unmounting old root\n");
74965 - sys_umount("/old", MNT_DETACH);
74966 + sys_umount((char __force_user *)"/old", MNT_DETACH);
74967 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
74968 if (fd < 0) {
74969 error = fd;
74970 @@ -127,11 +127,11 @@ int __init initrd_load(void)
74971 * mounted in the normal path.
74972 */
74973 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
74974 - sys_unlink("/initrd.image");
74975 + sys_unlink((const char __force_user *)"/initrd.image");
74976 handle_initrd();
74977 return 1;
74978 }
74979 }
74980 - sys_unlink("/initrd.image");
74981 + sys_unlink((const char __force_user *)"/initrd.image");
74982 return 0;
74983 }
74984 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
74985 index 8cb6db5..d729f50 100644
74986 --- a/init/do_mounts_md.c
74987 +++ b/init/do_mounts_md.c
74988 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
74989 partitioned ? "_d" : "", minor,
74990 md_setup_args[ent].device_names);
74991
74992 - fd = sys_open(name, 0, 0);
74993 + fd = sys_open((char __force_user *)name, 0, 0);
74994 if (fd < 0) {
74995 printk(KERN_ERR "md: open failed - cannot start "
74996 "array %s\n", name);
74997 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
74998 * array without it
74999 */
75000 sys_close(fd);
75001 - fd = sys_open(name, 0, 0);
75002 + fd = sys_open((char __force_user *)name, 0, 0);
75003 sys_ioctl(fd, BLKRRPART, 0);
75004 }
75005 sys_close(fd);
75006 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
75007
75008 wait_for_device_probe();
75009
75010 - fd = sys_open("/dev/md0", 0, 0);
75011 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
75012 if (fd >= 0) {
75013 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
75014 sys_close(fd);
75015 diff --git a/init/init_task.c b/init/init_task.c
75016 index ba0a7f36..2bcf1d5 100644
75017 --- a/init/init_task.c
75018 +++ b/init/init_task.c
75019 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
75020 * Initial thread structure. Alignment of this is handled by a special
75021 * linker map entry.
75022 */
75023 +#ifdef CONFIG_X86
75024 +union thread_union init_thread_union __init_task_data;
75025 +#else
75026 union thread_union init_thread_union __init_task_data =
75027 { INIT_THREAD_INFO(init_task) };
75028 +#endif
75029 diff --git a/init/initramfs.c b/init/initramfs.c
75030 index a67ef9d..2d17ed9 100644
75031 --- a/init/initramfs.c
75032 +++ b/init/initramfs.c
75033 @@ -84,7 +84,7 @@ static void __init free_hash(void)
75034 }
75035 }
75036
75037 -static long __init do_utime(char *filename, time_t mtime)
75038 +static long __init do_utime(char __force_user *filename, time_t mtime)
75039 {
75040 struct timespec t[2];
75041
75042 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
75043 struct dir_entry *de, *tmp;
75044 list_for_each_entry_safe(de, tmp, &dir_list, list) {
75045 list_del(&de->list);
75046 - do_utime(de->name, de->mtime);
75047 + do_utime((char __force_user *)de->name, de->mtime);
75048 kfree(de->name);
75049 kfree(de);
75050 }
75051 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
75052 if (nlink >= 2) {
75053 char *old = find_link(major, minor, ino, mode, collected);
75054 if (old)
75055 - return (sys_link(old, collected) < 0) ? -1 : 1;
75056 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
75057 }
75058 return 0;
75059 }
75060 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
75061 {
75062 struct stat st;
75063
75064 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
75065 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
75066 if (S_ISDIR(st.st_mode))
75067 - sys_rmdir(path);
75068 + sys_rmdir((char __force_user *)path);
75069 else
75070 - sys_unlink(path);
75071 + sys_unlink((char __force_user *)path);
75072 }
75073 }
75074
75075 @@ -315,7 +315,7 @@ static int __init do_name(void)
75076 int openflags = O_WRONLY|O_CREAT;
75077 if (ml != 1)
75078 openflags |= O_TRUNC;
75079 - wfd = sys_open(collected, openflags, mode);
75080 + wfd = sys_open((char __force_user *)collected, openflags, mode);
75081
75082 if (wfd >= 0) {
75083 sys_fchown(wfd, uid, gid);
75084 @@ -327,17 +327,17 @@ static int __init do_name(void)
75085 }
75086 }
75087 } else if (S_ISDIR(mode)) {
75088 - sys_mkdir(collected, mode);
75089 - sys_chown(collected, uid, gid);
75090 - sys_chmod(collected, mode);
75091 + sys_mkdir((char __force_user *)collected, mode);
75092 + sys_chown((char __force_user *)collected, uid, gid);
75093 + sys_chmod((char __force_user *)collected, mode);
75094 dir_add(collected, mtime);
75095 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
75096 S_ISFIFO(mode) || S_ISSOCK(mode)) {
75097 if (maybe_link() == 0) {
75098 - sys_mknod(collected, mode, rdev);
75099 - sys_chown(collected, uid, gid);
75100 - sys_chmod(collected, mode);
75101 - do_utime(collected, mtime);
75102 + sys_mknod((char __force_user *)collected, mode, rdev);
75103 + sys_chown((char __force_user *)collected, uid, gid);
75104 + sys_chmod((char __force_user *)collected, mode);
75105 + do_utime((char __force_user *)collected, mtime);
75106 }
75107 }
75108 return 0;
75109 @@ -346,15 +346,15 @@ static int __init do_name(void)
75110 static int __init do_copy(void)
75111 {
75112 if (count >= body_len) {
75113 - sys_write(wfd, victim, body_len);
75114 + sys_write(wfd, (char __force_user *)victim, body_len);
75115 sys_close(wfd);
75116 - do_utime(vcollected, mtime);
75117 + do_utime((char __force_user *)vcollected, mtime);
75118 kfree(vcollected);
75119 eat(body_len);
75120 state = SkipIt;
75121 return 0;
75122 } else {
75123 - sys_write(wfd, victim, count);
75124 + sys_write(wfd, (char __force_user *)victim, count);
75125 body_len -= count;
75126 eat(count);
75127 return 1;
75128 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
75129 {
75130 collected[N_ALIGN(name_len) + body_len] = '\0';
75131 clean_path(collected, 0);
75132 - sys_symlink(collected + N_ALIGN(name_len), collected);
75133 - sys_lchown(collected, uid, gid);
75134 - do_utime(collected, mtime);
75135 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
75136 + sys_lchown((char __force_user *)collected, uid, gid);
75137 + do_utime((char __force_user *)collected, mtime);
75138 state = SkipIt;
75139 next_state = Reset;
75140 return 0;
75141 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
75142 {
75143 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
75144 if (err)
75145 - panic(err); /* Failed to decompress INTERNAL initramfs */
75146 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
75147 if (initrd_start) {
75148 #ifdef CONFIG_BLK_DEV_RAM
75149 int fd;
75150 diff --git a/init/main.c b/init/main.c
75151 index 9484f4b..4c01430 100644
75152 --- a/init/main.c
75153 +++ b/init/main.c
75154 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
75155 extern void tc_init(void);
75156 #endif
75157
75158 +extern void grsecurity_init(void);
75159 +
75160 /*
75161 * Debug helper: via this flag we know that we are in 'early bootup code'
75162 * where only the boot processor is running with IRQ disabled. This means
75163 @@ -153,6 +155,64 @@ static int __init set_reset_devices(char *str)
75164
75165 __setup("reset_devices", set_reset_devices);
75166
75167 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75168 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
75169 +static int __init setup_grsec_proc_gid(char *str)
75170 +{
75171 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
75172 + return 1;
75173 +}
75174 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
75175 +#endif
75176 +
75177 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
75178 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
75179 +EXPORT_SYMBOL(pax_user_shadow_base);
75180 +extern char pax_enter_kernel_user[];
75181 +extern char pax_exit_kernel_user[];
75182 +extern pgdval_t clone_pgd_mask;
75183 +#endif
75184 +
75185 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
75186 +static int __init setup_pax_nouderef(char *str)
75187 +{
75188 +#ifdef CONFIG_X86_32
75189 + unsigned int cpu;
75190 + struct desc_struct *gdt;
75191 +
75192 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
75193 + gdt = get_cpu_gdt_table(cpu);
75194 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
75195 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
75196 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
75197 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
75198 + }
75199 + loadsegment(ds, __KERNEL_DS);
75200 + loadsegment(es, __KERNEL_DS);
75201 + loadsegment(ss, __KERNEL_DS);
75202 +#else
75203 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
75204 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
75205 + clone_pgd_mask = ~(pgdval_t)0UL;
75206 + pax_user_shadow_base = 0UL;
75207 +#endif
75208 +
75209 + return 0;
75210 +}
75211 +early_param("pax_nouderef", setup_pax_nouderef);
75212 +#endif
75213 +
75214 +#ifdef CONFIG_PAX_SOFTMODE
75215 +int pax_softmode;
75216 +
75217 +static int __init setup_pax_softmode(char *str)
75218 +{
75219 + get_option(&str, &pax_softmode);
75220 + return 1;
75221 +}
75222 +__setup("pax_softmode=", setup_pax_softmode);
75223 +#endif
75224 +
75225 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
75226 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
75227 static const char *panic_later, *panic_param;
75228 @@ -655,8 +715,6 @@ static void __init do_ctors(void)
75229 bool initcall_debug;
75230 core_param(initcall_debug, initcall_debug, bool, 0644);
75231
75232 -static char msgbuf[64];
75233 -
75234 static int __init_or_module do_one_initcall_debug(initcall_t fn)
75235 {
75236 ktime_t calltime, delta, rettime;
75237 @@ -679,23 +737,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
75238 {
75239 int count = preempt_count();
75240 int ret;
75241 + const char *msg1 = "", *msg2 = "";
75242
75243 if (initcall_debug)
75244 ret = do_one_initcall_debug(fn);
75245 else
75246 ret = fn();
75247
75248 - msgbuf[0] = 0;
75249 -
75250 if (preempt_count() != count) {
75251 - sprintf(msgbuf, "preemption imbalance ");
75252 + msg1 = " preemption imbalance";
75253 preempt_count() = count;
75254 }
75255 if (irqs_disabled()) {
75256 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
75257 + msg2 = " disabled interrupts";
75258 local_irq_enable();
75259 }
75260 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
75261 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
75262
75263 return ret;
75264 }
75265 @@ -748,8 +805,14 @@ static void __init do_initcall_level(int level)
75266 level, level,
75267 &repair_env_string);
75268
75269 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
75270 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
75271 do_one_initcall(*fn);
75272 +
75273 +#ifdef LATENT_ENTROPY_PLUGIN
75274 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
75275 +#endif
75276 +
75277 + }
75278 }
75279
75280 static void __init do_initcalls(void)
75281 @@ -783,8 +846,14 @@ static void __init do_pre_smp_initcalls(void)
75282 {
75283 initcall_t *fn;
75284
75285 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
75286 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
75287 do_one_initcall(*fn);
75288 +
75289 +#ifdef LATENT_ENTROPY_PLUGIN
75290 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
75291 +#endif
75292 +
75293 + }
75294 }
75295
75296 /*
75297 @@ -802,8 +871,8 @@ static int run_init_process(const char *init_filename)
75298 {
75299 argv_init[0] = init_filename;
75300 return do_execve(init_filename,
75301 - (const char __user *const __user *)argv_init,
75302 - (const char __user *const __user *)envp_init);
75303 + (const char __user *const __force_user *)argv_init,
75304 + (const char __user *const __force_user *)envp_init);
75305 }
75306
75307 static noinline void __init kernel_init_freeable(void);
75308 @@ -880,7 +949,7 @@ static noinline void __init kernel_init_freeable(void)
75309 do_basic_setup();
75310
75311 /* Open the /dev/console on the rootfs, this should never fail */
75312 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
75313 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
75314 pr_err("Warning: unable to open an initial console.\n");
75315
75316 (void) sys_dup(0);
75317 @@ -893,11 +962,13 @@ static noinline void __init kernel_init_freeable(void)
75318 if (!ramdisk_execute_command)
75319 ramdisk_execute_command = "/init";
75320
75321 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
75322 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
75323 ramdisk_execute_command = NULL;
75324 prepare_namespace();
75325 }
75326
75327 + grsecurity_init();
75328 +
75329 /*
75330 * Ok, we have completed the initial bootup, and
75331 * we're essentially up and running. Get rid of the
75332 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
75333 index 130dfec..cc88451 100644
75334 --- a/ipc/ipc_sysctl.c
75335 +++ b/ipc/ipc_sysctl.c
75336 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
75337 static int proc_ipc_dointvec(ctl_table *table, int write,
75338 void __user *buffer, size_t *lenp, loff_t *ppos)
75339 {
75340 - struct ctl_table ipc_table;
75341 + ctl_table_no_const ipc_table;
75342
75343 memcpy(&ipc_table, table, sizeof(ipc_table));
75344 ipc_table.data = get_ipc(table);
75345 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
75346 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
75347 void __user *buffer, size_t *lenp, loff_t *ppos)
75348 {
75349 - struct ctl_table ipc_table;
75350 + ctl_table_no_const ipc_table;
75351
75352 memcpy(&ipc_table, table, sizeof(ipc_table));
75353 ipc_table.data = get_ipc(table);
75354 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
75355 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
75356 void __user *buffer, size_t *lenp, loff_t *ppos)
75357 {
75358 - struct ctl_table ipc_table;
75359 + ctl_table_no_const ipc_table;
75360 size_t lenp_bef = *lenp;
75361 int rc;
75362
75363 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
75364 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
75365 void __user *buffer, size_t *lenp, loff_t *ppos)
75366 {
75367 - struct ctl_table ipc_table;
75368 + ctl_table_no_const ipc_table;
75369 memcpy(&ipc_table, table, sizeof(ipc_table));
75370 ipc_table.data = get_ipc(table);
75371
75372 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
75373 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
75374 void __user *buffer, size_t *lenp, loff_t *ppos)
75375 {
75376 - struct ctl_table ipc_table;
75377 + ctl_table_no_const ipc_table;
75378 size_t lenp_bef = *lenp;
75379 int oldval;
75380 int rc;
75381 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
75382 index 383d638..943fdbb 100644
75383 --- a/ipc/mq_sysctl.c
75384 +++ b/ipc/mq_sysctl.c
75385 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
75386 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
75387 void __user *buffer, size_t *lenp, loff_t *ppos)
75388 {
75389 - struct ctl_table mq_table;
75390 + ctl_table_no_const mq_table;
75391 memcpy(&mq_table, table, sizeof(mq_table));
75392 mq_table.data = get_mq(table);
75393
75394 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
75395 index e4e47f6..a85e0ad 100644
75396 --- a/ipc/mqueue.c
75397 +++ b/ipc/mqueue.c
75398 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
75399 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
75400 info->attr.mq_msgsize);
75401
75402 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
75403 spin_lock(&mq_lock);
75404 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
75405 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
75406 diff --git a/ipc/msg.c b/ipc/msg.c
75407 index d0c6d96..69a893c 100644
75408 --- a/ipc/msg.c
75409 +++ b/ipc/msg.c
75410 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
75411 return security_msg_queue_associate(msq, msgflg);
75412 }
75413
75414 +static struct ipc_ops msg_ops = {
75415 + .getnew = newque,
75416 + .associate = msg_security,
75417 + .more_checks = NULL
75418 +};
75419 +
75420 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
75421 {
75422 struct ipc_namespace *ns;
75423 - struct ipc_ops msg_ops;
75424 struct ipc_params msg_params;
75425
75426 ns = current->nsproxy->ipc_ns;
75427
75428 - msg_ops.getnew = newque;
75429 - msg_ops.associate = msg_security;
75430 - msg_ops.more_checks = NULL;
75431 -
75432 msg_params.key = key;
75433 msg_params.flg = msgflg;
75434
75435 diff --git a/ipc/sem.c b/ipc/sem.c
75436 index 70480a3..f4e8262 100644
75437 --- a/ipc/sem.c
75438 +++ b/ipc/sem.c
75439 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
75440 return 0;
75441 }
75442
75443 +static struct ipc_ops sem_ops = {
75444 + .getnew = newary,
75445 + .associate = sem_security,
75446 + .more_checks = sem_more_checks
75447 +};
75448 +
75449 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
75450 {
75451 struct ipc_namespace *ns;
75452 - struct ipc_ops sem_ops;
75453 struct ipc_params sem_params;
75454
75455 ns = current->nsproxy->ipc_ns;
75456 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
75457 if (nsems < 0 || nsems > ns->sc_semmsl)
75458 return -EINVAL;
75459
75460 - sem_ops.getnew = newary;
75461 - sem_ops.associate = sem_security;
75462 - sem_ops.more_checks = sem_more_checks;
75463 -
75464 sem_params.key = key;
75465 sem_params.flg = semflg;
75466 sem_params.u.nsems = nsems;
75467 diff --git a/ipc/shm.c b/ipc/shm.c
75468 index 7e199fa..180a1ca 100644
75469 --- a/ipc/shm.c
75470 +++ b/ipc/shm.c
75471 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
75472 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
75473 #endif
75474
75475 +#ifdef CONFIG_GRKERNSEC
75476 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
75477 + const time_t shm_createtime, const kuid_t cuid,
75478 + const int shmid);
75479 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
75480 + const time_t shm_createtime);
75481 +#endif
75482 +
75483 void shm_init_ns(struct ipc_namespace *ns)
75484 {
75485 ns->shm_ctlmax = SHMMAX;
75486 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
75487 shp->shm_lprid = 0;
75488 shp->shm_atim = shp->shm_dtim = 0;
75489 shp->shm_ctim = get_seconds();
75490 +#ifdef CONFIG_GRKERNSEC
75491 + {
75492 + struct timespec timeval;
75493 + do_posix_clock_monotonic_gettime(&timeval);
75494 +
75495 + shp->shm_createtime = timeval.tv_sec;
75496 + }
75497 +#endif
75498 shp->shm_segsz = size;
75499 shp->shm_nattch = 0;
75500 shp->shm_file = file;
75501 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
75502 return 0;
75503 }
75504
75505 +static struct ipc_ops shm_ops = {
75506 + .getnew = newseg,
75507 + .associate = shm_security,
75508 + .more_checks = shm_more_checks
75509 +};
75510 +
75511 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
75512 {
75513 struct ipc_namespace *ns;
75514 - struct ipc_ops shm_ops;
75515 struct ipc_params shm_params;
75516
75517 ns = current->nsproxy->ipc_ns;
75518
75519 - shm_ops.getnew = newseg;
75520 - shm_ops.associate = shm_security;
75521 - shm_ops.more_checks = shm_more_checks;
75522 -
75523 shm_params.key = key;
75524 shm_params.flg = shmflg;
75525 shm_params.u.size = size;
75526 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
75527 f_mode = FMODE_READ | FMODE_WRITE;
75528 }
75529 if (shmflg & SHM_EXEC) {
75530 +
75531 +#ifdef CONFIG_PAX_MPROTECT
75532 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
75533 + goto out;
75534 +#endif
75535 +
75536 prot |= PROT_EXEC;
75537 acc_mode |= S_IXUGO;
75538 }
75539 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
75540 if (err)
75541 goto out_unlock;
75542
75543 +#ifdef CONFIG_GRKERNSEC
75544 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
75545 + shp->shm_perm.cuid, shmid) ||
75546 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
75547 + err = -EACCES;
75548 + goto out_unlock;
75549 + }
75550 +#endif
75551 +
75552 path = shp->shm_file->f_path;
75553 path_get(&path);
75554 shp->shm_nattch++;
75555 +#ifdef CONFIG_GRKERNSEC
75556 + shp->shm_lapid = current->pid;
75557 +#endif
75558 size = i_size_read(path.dentry->d_inode);
75559 shm_unlock(shp);
75560
75561 diff --git a/kernel/acct.c b/kernel/acct.c
75562 index 8d6e145..33e0b1e 100644
75563 --- a/kernel/acct.c
75564 +++ b/kernel/acct.c
75565 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
75566 */
75567 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
75568 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
75569 - file->f_op->write(file, (char *)&ac,
75570 + file->f_op->write(file, (char __force_user *)&ac,
75571 sizeof(acct_t), &file->f_pos);
75572 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
75573 set_fs(fs);
75574 diff --git a/kernel/audit.c b/kernel/audit.c
75575 index 91e53d0..d9e3ec4 100644
75576 --- a/kernel/audit.c
75577 +++ b/kernel/audit.c
75578 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
75579 3) suppressed due to audit_rate_limit
75580 4) suppressed due to audit_backlog_limit
75581 */
75582 -static atomic_t audit_lost = ATOMIC_INIT(0);
75583 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
75584
75585 /* The netlink socket. */
75586 static struct sock *audit_sock;
75587 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
75588 unsigned long now;
75589 int print;
75590
75591 - atomic_inc(&audit_lost);
75592 + atomic_inc_unchecked(&audit_lost);
75593
75594 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
75595
75596 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
75597 printk(KERN_WARNING
75598 "audit: audit_lost=%d audit_rate_limit=%d "
75599 "audit_backlog_limit=%d\n",
75600 - atomic_read(&audit_lost),
75601 + atomic_read_unchecked(&audit_lost),
75602 audit_rate_limit,
75603 audit_backlog_limit);
75604 audit_panic(message);
75605 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
75606 status_set.pid = audit_pid;
75607 status_set.rate_limit = audit_rate_limit;
75608 status_set.backlog_limit = audit_backlog_limit;
75609 - status_set.lost = atomic_read(&audit_lost);
75610 + status_set.lost = atomic_read_unchecked(&audit_lost);
75611 status_set.backlog = skb_queue_len(&audit_skb_queue);
75612 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
75613 &status_set, sizeof(status_set));
75614 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
75615 index 6bd4a90..0ee9eff 100644
75616 --- a/kernel/auditfilter.c
75617 +++ b/kernel/auditfilter.c
75618 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
75619 f->lsm_rule = NULL;
75620
75621 /* Support legacy tests for a valid loginuid */
75622 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
75623 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
75624 f->type = AUDIT_LOGINUID_SET;
75625 f->val = 0;
75626 }
75627 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
75628 index 3c8a601..3a416f6 100644
75629 --- a/kernel/auditsc.c
75630 +++ b/kernel/auditsc.c
75631 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
75632 }
75633
75634 /* global counter which is incremented every time something logs in */
75635 -static atomic_t session_id = ATOMIC_INIT(0);
75636 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
75637
75638 /**
75639 * audit_set_loginuid - set current task's audit_context loginuid
75640 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
75641 return -EPERM;
75642 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
75643
75644 - sessionid = atomic_inc_return(&session_id);
75645 + sessionid = atomic_inc_return_unchecked(&session_id);
75646 if (context && context->in_syscall) {
75647 struct audit_buffer *ab;
75648
75649 diff --git a/kernel/capability.c b/kernel/capability.c
75650 index f6c2ce5..982c0f9 100644
75651 --- a/kernel/capability.c
75652 +++ b/kernel/capability.c
75653 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
75654 * before modification is attempted and the application
75655 * fails.
75656 */
75657 + if (tocopy > ARRAY_SIZE(kdata))
75658 + return -EFAULT;
75659 +
75660 if (copy_to_user(dataptr, kdata, tocopy
75661 * sizeof(struct __user_cap_data_struct))) {
75662 return -EFAULT;
75663 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
75664 int ret;
75665
75666 rcu_read_lock();
75667 - ret = security_capable(__task_cred(t), ns, cap);
75668 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
75669 + gr_task_is_capable(t, __task_cred(t), cap);
75670 rcu_read_unlock();
75671
75672 - return (ret == 0);
75673 + return ret;
75674 }
75675
75676 /**
75677 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
75678 int ret;
75679
75680 rcu_read_lock();
75681 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
75682 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
75683 rcu_read_unlock();
75684
75685 - return (ret == 0);
75686 + return ret;
75687 }
75688
75689 /**
75690 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
75691 BUG();
75692 }
75693
75694 - if (security_capable(current_cred(), ns, cap) == 0) {
75695 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
75696 current->flags |= PF_SUPERPRIV;
75697 return true;
75698 }
75699 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
75700 }
75701 EXPORT_SYMBOL(ns_capable);
75702
75703 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
75704 +{
75705 + if (unlikely(!cap_valid(cap))) {
75706 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
75707 + BUG();
75708 + }
75709 +
75710 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
75711 + current->flags |= PF_SUPERPRIV;
75712 + return true;
75713 + }
75714 + return false;
75715 +}
75716 +EXPORT_SYMBOL(ns_capable_nolog);
75717 +
75718 /**
75719 * file_ns_capable - Determine if the file's opener had a capability in effect
75720 * @file: The file we want to check
75721 @@ -432,6 +451,12 @@ bool capable(int cap)
75722 }
75723 EXPORT_SYMBOL(capable);
75724
75725 +bool capable_nolog(int cap)
75726 +{
75727 + return ns_capable_nolog(&init_user_ns, cap);
75728 +}
75729 +EXPORT_SYMBOL(capable_nolog);
75730 +
75731 /**
75732 * nsown_capable - Check superior capability to one's own user_ns
75733 * @cap: The capability in question
75734 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
75735
75736 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
75737 }
75738 +
75739 +bool inode_capable_nolog(const struct inode *inode, int cap)
75740 +{
75741 + struct user_namespace *ns = current_user_ns();
75742 +
75743 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
75744 +}
75745 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
75746 index c6e77ef..af531a0 100644
75747 --- a/kernel/cgroup.c
75748 +++ b/kernel/cgroup.c
75749 @@ -5391,7 +5391,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
75750 struct css_set *cg = link->cg;
75751 struct task_struct *task;
75752 int count = 0;
75753 - seq_printf(seq, "css_set %p\n", cg);
75754 + seq_printf(seq, "css_set %pK\n", cg);
75755 list_for_each_entry(task, &cg->tasks, cg_list) {
75756 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
75757 seq_puts(seq, " ...\n");
75758 diff --git a/kernel/compat.c b/kernel/compat.c
75759 index 0a09e48..f44f3f0 100644
75760 --- a/kernel/compat.c
75761 +++ b/kernel/compat.c
75762 @@ -13,6 +13,7 @@
75763
75764 #include <linux/linkage.h>
75765 #include <linux/compat.h>
75766 +#include <linux/module.h>
75767 #include <linux/errno.h>
75768 #include <linux/time.h>
75769 #include <linux/signal.h>
75770 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
75771 mm_segment_t oldfs;
75772 long ret;
75773
75774 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
75775 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
75776 oldfs = get_fs();
75777 set_fs(KERNEL_DS);
75778 ret = hrtimer_nanosleep_restart(restart);
75779 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
75780 oldfs = get_fs();
75781 set_fs(KERNEL_DS);
75782 ret = hrtimer_nanosleep(&tu,
75783 - rmtp ? (struct timespec __user *)&rmt : NULL,
75784 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
75785 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
75786 set_fs(oldfs);
75787
75788 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
75789 mm_segment_t old_fs = get_fs();
75790
75791 set_fs(KERNEL_DS);
75792 - ret = sys_sigpending((old_sigset_t __user *) &s);
75793 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
75794 set_fs(old_fs);
75795 if (ret == 0)
75796 ret = put_user(s, set);
75797 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
75798 mm_segment_t old_fs = get_fs();
75799
75800 set_fs(KERNEL_DS);
75801 - ret = sys_old_getrlimit(resource, &r);
75802 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
75803 set_fs(old_fs);
75804
75805 if (!ret) {
75806 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
75807 set_fs (KERNEL_DS);
75808 ret = sys_wait4(pid,
75809 (stat_addr ?
75810 - (unsigned int __user *) &status : NULL),
75811 - options, (struct rusage __user *) &r);
75812 + (unsigned int __force_user *) &status : NULL),
75813 + options, (struct rusage __force_user *) &r);
75814 set_fs (old_fs);
75815
75816 if (ret > 0) {
75817 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
75818 memset(&info, 0, sizeof(info));
75819
75820 set_fs(KERNEL_DS);
75821 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
75822 - uru ? (struct rusage __user *)&ru : NULL);
75823 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
75824 + uru ? (struct rusage __force_user *)&ru : NULL);
75825 set_fs(old_fs);
75826
75827 if ((ret < 0) || (info.si_signo == 0))
75828 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
75829 oldfs = get_fs();
75830 set_fs(KERNEL_DS);
75831 err = sys_timer_settime(timer_id, flags,
75832 - (struct itimerspec __user *) &newts,
75833 - (struct itimerspec __user *) &oldts);
75834 + (struct itimerspec __force_user *) &newts,
75835 + (struct itimerspec __force_user *) &oldts);
75836 set_fs(oldfs);
75837 if (!err && old && put_compat_itimerspec(old, &oldts))
75838 return -EFAULT;
75839 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
75840 oldfs = get_fs();
75841 set_fs(KERNEL_DS);
75842 err = sys_timer_gettime(timer_id,
75843 - (struct itimerspec __user *) &ts);
75844 + (struct itimerspec __force_user *) &ts);
75845 set_fs(oldfs);
75846 if (!err && put_compat_itimerspec(setting, &ts))
75847 return -EFAULT;
75848 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
75849 oldfs = get_fs();
75850 set_fs(KERNEL_DS);
75851 err = sys_clock_settime(which_clock,
75852 - (struct timespec __user *) &ts);
75853 + (struct timespec __force_user *) &ts);
75854 set_fs(oldfs);
75855 return err;
75856 }
75857 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
75858 oldfs = get_fs();
75859 set_fs(KERNEL_DS);
75860 err = sys_clock_gettime(which_clock,
75861 - (struct timespec __user *) &ts);
75862 + (struct timespec __force_user *) &ts);
75863 set_fs(oldfs);
75864 if (!err && put_compat_timespec(&ts, tp))
75865 return -EFAULT;
75866 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
75867
75868 oldfs = get_fs();
75869 set_fs(KERNEL_DS);
75870 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
75871 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
75872 set_fs(oldfs);
75873
75874 err = compat_put_timex(utp, &txc);
75875 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
75876 oldfs = get_fs();
75877 set_fs(KERNEL_DS);
75878 err = sys_clock_getres(which_clock,
75879 - (struct timespec __user *) &ts);
75880 + (struct timespec __force_user *) &ts);
75881 set_fs(oldfs);
75882 if (!err && tp && put_compat_timespec(&ts, tp))
75883 return -EFAULT;
75884 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
75885 long err;
75886 mm_segment_t oldfs;
75887 struct timespec tu;
75888 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
75889 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
75890
75891 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
75892 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
75893 oldfs = get_fs();
75894 set_fs(KERNEL_DS);
75895 err = clock_nanosleep_restart(restart);
75896 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
75897 oldfs = get_fs();
75898 set_fs(KERNEL_DS);
75899 err = sys_clock_nanosleep(which_clock, flags,
75900 - (struct timespec __user *) &in,
75901 - (struct timespec __user *) &out);
75902 + (struct timespec __force_user *) &in,
75903 + (struct timespec __force_user *) &out);
75904 set_fs(oldfs);
75905
75906 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
75907 diff --git a/kernel/configs.c b/kernel/configs.c
75908 index c18b1f1..b9a0132 100644
75909 --- a/kernel/configs.c
75910 +++ b/kernel/configs.c
75911 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
75912 struct proc_dir_entry *entry;
75913
75914 /* create the current config file */
75915 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
75916 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
75917 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
75918 + &ikconfig_file_ops);
75919 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75920 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
75921 + &ikconfig_file_ops);
75922 +#endif
75923 +#else
75924 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
75925 &ikconfig_file_ops);
75926 +#endif
75927 +
75928 if (!entry)
75929 return -ENOMEM;
75930
75931 diff --git a/kernel/cred.c b/kernel/cred.c
75932 index e0573a4..3874e41 100644
75933 --- a/kernel/cred.c
75934 +++ b/kernel/cred.c
75935 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
75936 validate_creds(cred);
75937 alter_cred_subscribers(cred, -1);
75938 put_cred(cred);
75939 +
75940 +#ifdef CONFIG_GRKERNSEC_SETXID
75941 + cred = (struct cred *) tsk->delayed_cred;
75942 + if (cred != NULL) {
75943 + tsk->delayed_cred = NULL;
75944 + validate_creds(cred);
75945 + alter_cred_subscribers(cred, -1);
75946 + put_cred(cred);
75947 + }
75948 +#endif
75949 }
75950
75951 /**
75952 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
75953 * Always returns 0 thus allowing this function to be tail-called at the end
75954 * of, say, sys_setgid().
75955 */
75956 -int commit_creds(struct cred *new)
75957 +static int __commit_creds(struct cred *new)
75958 {
75959 struct task_struct *task = current;
75960 const struct cred *old = task->real_cred;
75961 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
75962
75963 get_cred(new); /* we will require a ref for the subj creds too */
75964
75965 + gr_set_role_label(task, new->uid, new->gid);
75966 +
75967 /* dumpability changes */
75968 if (!uid_eq(old->euid, new->euid) ||
75969 !gid_eq(old->egid, new->egid) ||
75970 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
75971 put_cred(old);
75972 return 0;
75973 }
75974 +#ifdef CONFIG_GRKERNSEC_SETXID
75975 +extern int set_user(struct cred *new);
75976 +
75977 +void gr_delayed_cred_worker(void)
75978 +{
75979 + const struct cred *new = current->delayed_cred;
75980 + struct cred *ncred;
75981 +
75982 + current->delayed_cred = NULL;
75983 +
75984 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
75985 + // from doing get_cred on it when queueing this
75986 + put_cred(new);
75987 + return;
75988 + } else if (new == NULL)
75989 + return;
75990 +
75991 + ncred = prepare_creds();
75992 + if (!ncred)
75993 + goto die;
75994 + // uids
75995 + ncred->uid = new->uid;
75996 + ncred->euid = new->euid;
75997 + ncred->suid = new->suid;
75998 + ncred->fsuid = new->fsuid;
75999 + // gids
76000 + ncred->gid = new->gid;
76001 + ncred->egid = new->egid;
76002 + ncred->sgid = new->sgid;
76003 + ncred->fsgid = new->fsgid;
76004 + // groups
76005 + if (set_groups(ncred, new->group_info) < 0) {
76006 + abort_creds(ncred);
76007 + goto die;
76008 + }
76009 + // caps
76010 + ncred->securebits = new->securebits;
76011 + ncred->cap_inheritable = new->cap_inheritable;
76012 + ncred->cap_permitted = new->cap_permitted;
76013 + ncred->cap_effective = new->cap_effective;
76014 + ncred->cap_bset = new->cap_bset;
76015 +
76016 + if (set_user(ncred)) {
76017 + abort_creds(ncred);
76018 + goto die;
76019 + }
76020 +
76021 + // from doing get_cred on it when queueing this
76022 + put_cred(new);
76023 +
76024 + __commit_creds(ncred);
76025 + return;
76026 +die:
76027 + // from doing get_cred on it when queueing this
76028 + put_cred(new);
76029 + do_group_exit(SIGKILL);
76030 +}
76031 +#endif
76032 +
76033 +int commit_creds(struct cred *new)
76034 +{
76035 +#ifdef CONFIG_GRKERNSEC_SETXID
76036 + int ret;
76037 + int schedule_it = 0;
76038 + struct task_struct *t;
76039 +
76040 + /* we won't get called with tasklist_lock held for writing
76041 + and interrupts disabled as the cred struct in that case is
76042 + init_cred
76043 + */
76044 + if (grsec_enable_setxid && !current_is_single_threaded() &&
76045 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
76046 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
76047 + schedule_it = 1;
76048 + }
76049 + ret = __commit_creds(new);
76050 + if (schedule_it) {
76051 + rcu_read_lock();
76052 + read_lock(&tasklist_lock);
76053 + for (t = next_thread(current); t != current;
76054 + t = next_thread(t)) {
76055 + if (t->delayed_cred == NULL) {
76056 + t->delayed_cred = get_cred(new);
76057 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
76058 + set_tsk_need_resched(t);
76059 + }
76060 + }
76061 + read_unlock(&tasklist_lock);
76062 + rcu_read_unlock();
76063 + }
76064 + return ret;
76065 +#else
76066 + return __commit_creds(new);
76067 +#endif
76068 +}
76069 +
76070 EXPORT_SYMBOL(commit_creds);
76071
76072 /**
76073 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
76074 index 0506d44..2c20034 100644
76075 --- a/kernel/debug/debug_core.c
76076 +++ b/kernel/debug/debug_core.c
76077 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
76078 */
76079 static atomic_t masters_in_kgdb;
76080 static atomic_t slaves_in_kgdb;
76081 -static atomic_t kgdb_break_tasklet_var;
76082 +static atomic_unchecked_t kgdb_break_tasklet_var;
76083 atomic_t kgdb_setting_breakpoint;
76084
76085 struct task_struct *kgdb_usethread;
76086 @@ -133,7 +133,7 @@ int kgdb_single_step;
76087 static pid_t kgdb_sstep_pid;
76088
76089 /* to keep track of the CPU which is doing the single stepping*/
76090 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
76091 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
76092
76093 /*
76094 * If you are debugging a problem where roundup (the collection of
76095 @@ -541,7 +541,7 @@ return_normal:
76096 * kernel will only try for the value of sstep_tries before
76097 * giving up and continuing on.
76098 */
76099 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
76100 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
76101 (kgdb_info[cpu].task &&
76102 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
76103 atomic_set(&kgdb_active, -1);
76104 @@ -635,8 +635,8 @@ cpu_master_loop:
76105 }
76106
76107 kgdb_restore:
76108 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
76109 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
76110 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
76111 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
76112 if (kgdb_info[sstep_cpu].task)
76113 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
76114 else
76115 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
76116 static void kgdb_tasklet_bpt(unsigned long ing)
76117 {
76118 kgdb_breakpoint();
76119 - atomic_set(&kgdb_break_tasklet_var, 0);
76120 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
76121 }
76122
76123 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
76124
76125 void kgdb_schedule_breakpoint(void)
76126 {
76127 - if (atomic_read(&kgdb_break_tasklet_var) ||
76128 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
76129 atomic_read(&kgdb_active) != -1 ||
76130 atomic_read(&kgdb_setting_breakpoint))
76131 return;
76132 - atomic_inc(&kgdb_break_tasklet_var);
76133 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
76134 tasklet_schedule(&kgdb_tasklet_breakpoint);
76135 }
76136 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
76137 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
76138 index 00eb8f7..d7e3244 100644
76139 --- a/kernel/debug/kdb/kdb_main.c
76140 +++ b/kernel/debug/kdb/kdb_main.c
76141 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
76142 continue;
76143
76144 kdb_printf("%-20s%8u 0x%p ", mod->name,
76145 - mod->core_size, (void *)mod);
76146 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
76147 #ifdef CONFIG_MODULE_UNLOAD
76148 kdb_printf("%4ld ", module_refcount(mod));
76149 #endif
76150 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
76151 kdb_printf(" (Loading)");
76152 else
76153 kdb_printf(" (Live)");
76154 - kdb_printf(" 0x%p", mod->module_core);
76155 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
76156
76157 #ifdef CONFIG_MODULE_UNLOAD
76158 {
76159 diff --git a/kernel/events/core.c b/kernel/events/core.c
76160 index e76e495..cbfe63a 100644
76161 --- a/kernel/events/core.c
76162 +++ b/kernel/events/core.c
76163 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
76164 * 0 - disallow raw tracepoint access for unpriv
76165 * 1 - disallow cpu events for unpriv
76166 * 2 - disallow kernel profiling for unpriv
76167 + * 3 - disallow all unpriv perf event use
76168 */
76169 -int sysctl_perf_event_paranoid __read_mostly = 1;
76170 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
76171 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
76172 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
76173 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
76174 +#else
76175 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
76176 +#endif
76177
76178 /* Minimum for 512 kiB + 1 user control page */
76179 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
76180 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
76181 return 0;
76182 }
76183
76184 -static atomic64_t perf_event_id;
76185 +static atomic64_unchecked_t perf_event_id;
76186
76187 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
76188 enum event_type_t event_type);
76189 @@ -2747,7 +2754,7 @@ static void __perf_event_read(void *info)
76190
76191 static inline u64 perf_event_count(struct perf_event *event)
76192 {
76193 - return local64_read(&event->count) + atomic64_read(&event->child_count);
76194 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
76195 }
76196
76197 static u64 perf_event_read(struct perf_event *event)
76198 @@ -3093,9 +3100,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
76199 mutex_lock(&event->child_mutex);
76200 total += perf_event_read(event);
76201 *enabled += event->total_time_enabled +
76202 - atomic64_read(&event->child_total_time_enabled);
76203 + atomic64_read_unchecked(&event->child_total_time_enabled);
76204 *running += event->total_time_running +
76205 - atomic64_read(&event->child_total_time_running);
76206 + atomic64_read_unchecked(&event->child_total_time_running);
76207
76208 list_for_each_entry(child, &event->child_list, child_list) {
76209 total += perf_event_read(child);
76210 @@ -3481,10 +3488,10 @@ void perf_event_update_userpage(struct perf_event *event)
76211 userpg->offset -= local64_read(&event->hw.prev_count);
76212
76213 userpg->time_enabled = enabled +
76214 - atomic64_read(&event->child_total_time_enabled);
76215 + atomic64_read_unchecked(&event->child_total_time_enabled);
76216
76217 userpg->time_running = running +
76218 - atomic64_read(&event->child_total_time_running);
76219 + atomic64_read_unchecked(&event->child_total_time_running);
76220
76221 arch_perf_update_userpage(userpg, now);
76222
76223 @@ -4034,7 +4041,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
76224
76225 /* Data. */
76226 sp = perf_user_stack_pointer(regs);
76227 - rem = __output_copy_user(handle, (void *) sp, dump_size);
76228 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
76229 dyn_size = dump_size - rem;
76230
76231 perf_output_skip(handle, rem);
76232 @@ -4122,11 +4129,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
76233 values[n++] = perf_event_count(event);
76234 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
76235 values[n++] = enabled +
76236 - atomic64_read(&event->child_total_time_enabled);
76237 + atomic64_read_unchecked(&event->child_total_time_enabled);
76238 }
76239 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
76240 values[n++] = running +
76241 - atomic64_read(&event->child_total_time_running);
76242 + atomic64_read_unchecked(&event->child_total_time_running);
76243 }
76244 if (read_format & PERF_FORMAT_ID)
76245 values[n++] = primary_event_id(event);
76246 @@ -4835,12 +4842,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
76247 * need to add enough zero bytes after the string to handle
76248 * the 64bit alignment we do later.
76249 */
76250 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
76251 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
76252 if (!buf) {
76253 name = strncpy(tmp, "//enomem", sizeof(tmp));
76254 goto got_name;
76255 }
76256 - name = d_path(&file->f_path, buf, PATH_MAX);
76257 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
76258 if (IS_ERR(name)) {
76259 name = strncpy(tmp, "//toolong", sizeof(tmp));
76260 goto got_name;
76261 @@ -6262,7 +6269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
76262 event->parent = parent_event;
76263
76264 event->ns = get_pid_ns(task_active_pid_ns(current));
76265 - event->id = atomic64_inc_return(&perf_event_id);
76266 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
76267
76268 event->state = PERF_EVENT_STATE_INACTIVE;
76269
76270 @@ -6572,6 +6579,11 @@ SYSCALL_DEFINE5(perf_event_open,
76271 if (flags & ~PERF_FLAG_ALL)
76272 return -EINVAL;
76273
76274 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
76275 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
76276 + return -EACCES;
76277 +#endif
76278 +
76279 err = perf_copy_attr(attr_uptr, &attr);
76280 if (err)
76281 return err;
76282 @@ -6904,10 +6916,10 @@ static void sync_child_event(struct perf_event *child_event,
76283 /*
76284 * Add back the child's count to the parent's count:
76285 */
76286 - atomic64_add(child_val, &parent_event->child_count);
76287 - atomic64_add(child_event->total_time_enabled,
76288 + atomic64_add_unchecked(child_val, &parent_event->child_count);
76289 + atomic64_add_unchecked(child_event->total_time_enabled,
76290 &parent_event->child_total_time_enabled);
76291 - atomic64_add(child_event->total_time_running,
76292 + atomic64_add_unchecked(child_event->total_time_running,
76293 &parent_event->child_total_time_running);
76294
76295 /*
76296 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
76297 index ca65997..cc8cee4 100644
76298 --- a/kernel/events/internal.h
76299 +++ b/kernel/events/internal.h
76300 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
76301 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
76302 }
76303
76304 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
76305 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
76306 static inline unsigned int \
76307 func_name(struct perf_output_handle *handle, \
76308 - const void *buf, unsigned int len) \
76309 + const void user *buf, unsigned int len) \
76310 { \
76311 unsigned long size, written; \
76312 \
76313 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
76314 return n;
76315 }
76316
76317 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
76318 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
76319
76320 #define MEMCPY_SKIP(dst, src, n) (n)
76321
76322 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
76323 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
76324
76325 #ifndef arch_perf_out_copy_user
76326 #define arch_perf_out_copy_user __copy_from_user_inatomic
76327 #endif
76328
76329 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
76330 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
76331
76332 /* Callchain handling */
76333 extern struct perf_callchain_entry *
76334 diff --git a/kernel/exit.c b/kernel/exit.c
76335 index 7bb73f9..d7978ed 100644
76336 --- a/kernel/exit.c
76337 +++ b/kernel/exit.c
76338 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
76339 struct task_struct *leader;
76340 int zap_leader;
76341 repeat:
76342 +#ifdef CONFIG_NET
76343 + gr_del_task_from_ip_table(p);
76344 +#endif
76345 +
76346 /* don't need to get the RCU readlock here - the process is dead and
76347 * can't be modifying its own credentials. But shut RCU-lockdep up */
76348 rcu_read_lock();
76349 @@ -340,7 +344,7 @@ int allow_signal(int sig)
76350 * know it'll be handled, so that they don't get converted to
76351 * SIGKILL or just silently dropped.
76352 */
76353 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
76354 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
76355 recalc_sigpending();
76356 spin_unlock_irq(&current->sighand->siglock);
76357 return 0;
76358 @@ -709,6 +713,8 @@ void do_exit(long code)
76359 struct task_struct *tsk = current;
76360 int group_dead;
76361
76362 + set_fs(USER_DS);
76363 +
76364 profile_task_exit(tsk);
76365
76366 WARN_ON(blk_needs_flush_plug(tsk));
76367 @@ -725,7 +731,6 @@ void do_exit(long code)
76368 * mm_release()->clear_child_tid() from writing to a user-controlled
76369 * kernel address.
76370 */
76371 - set_fs(USER_DS);
76372
76373 ptrace_event(PTRACE_EVENT_EXIT, code);
76374
76375 @@ -784,6 +789,9 @@ void do_exit(long code)
76376 tsk->exit_code = code;
76377 taskstats_exit(tsk, group_dead);
76378
76379 + gr_acl_handle_psacct(tsk, code);
76380 + gr_acl_handle_exit();
76381 +
76382 exit_mm(tsk);
76383
76384 if (group_dead)
76385 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
76386 * Take down every thread in the group. This is called by fatal signals
76387 * as well as by sys_exit_group (below).
76388 */
76389 -void
76390 +__noreturn void
76391 do_group_exit(int exit_code)
76392 {
76393 struct signal_struct *sig = current->signal;
76394 diff --git a/kernel/fork.c b/kernel/fork.c
76395 index 987b28a..11ee8a5 100644
76396 --- a/kernel/fork.c
76397 +++ b/kernel/fork.c
76398 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
76399 *stackend = STACK_END_MAGIC; /* for overflow detection */
76400
76401 #ifdef CONFIG_CC_STACKPROTECTOR
76402 - tsk->stack_canary = get_random_int();
76403 + tsk->stack_canary = pax_get_random_long();
76404 #endif
76405
76406 /*
76407 @@ -345,13 +345,81 @@ free_tsk:
76408 }
76409
76410 #ifdef CONFIG_MMU
76411 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
76412 +{
76413 + struct vm_area_struct *tmp;
76414 + unsigned long charge;
76415 + struct mempolicy *pol;
76416 + struct file *file;
76417 +
76418 + charge = 0;
76419 + if (mpnt->vm_flags & VM_ACCOUNT) {
76420 + unsigned long len = vma_pages(mpnt);
76421 +
76422 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
76423 + goto fail_nomem;
76424 + charge = len;
76425 + }
76426 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
76427 + if (!tmp)
76428 + goto fail_nomem;
76429 + *tmp = *mpnt;
76430 + tmp->vm_mm = mm;
76431 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
76432 + pol = mpol_dup(vma_policy(mpnt));
76433 + if (IS_ERR(pol))
76434 + goto fail_nomem_policy;
76435 + vma_set_policy(tmp, pol);
76436 + if (anon_vma_fork(tmp, mpnt))
76437 + goto fail_nomem_anon_vma_fork;
76438 + tmp->vm_flags &= ~VM_LOCKED;
76439 + tmp->vm_next = tmp->vm_prev = NULL;
76440 + tmp->vm_mirror = NULL;
76441 + file = tmp->vm_file;
76442 + if (file) {
76443 + struct inode *inode = file_inode(file);
76444 + struct address_space *mapping = file->f_mapping;
76445 +
76446 + get_file(file);
76447 + if (tmp->vm_flags & VM_DENYWRITE)
76448 + atomic_dec(&inode->i_writecount);
76449 + mutex_lock(&mapping->i_mmap_mutex);
76450 + if (tmp->vm_flags & VM_SHARED)
76451 + mapping->i_mmap_writable++;
76452 + flush_dcache_mmap_lock(mapping);
76453 + /* insert tmp into the share list, just after mpnt */
76454 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
76455 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
76456 + else
76457 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
76458 + flush_dcache_mmap_unlock(mapping);
76459 + mutex_unlock(&mapping->i_mmap_mutex);
76460 + }
76461 +
76462 + /*
76463 + * Clear hugetlb-related page reserves for children. This only
76464 + * affects MAP_PRIVATE mappings. Faults generated by the child
76465 + * are not guaranteed to succeed, even if read-only
76466 + */
76467 + if (is_vm_hugetlb_page(tmp))
76468 + reset_vma_resv_huge_pages(tmp);
76469 +
76470 + return tmp;
76471 +
76472 +fail_nomem_anon_vma_fork:
76473 + mpol_put(pol);
76474 +fail_nomem_policy:
76475 + kmem_cache_free(vm_area_cachep, tmp);
76476 +fail_nomem:
76477 + vm_unacct_memory(charge);
76478 + return NULL;
76479 +}
76480 +
76481 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76482 {
76483 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
76484 struct rb_node **rb_link, *rb_parent;
76485 int retval;
76486 - unsigned long charge;
76487 - struct mempolicy *pol;
76488
76489 uprobe_start_dup_mmap();
76490 down_write(&oldmm->mmap_sem);
76491 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76492 mm->locked_vm = 0;
76493 mm->mmap = NULL;
76494 mm->mmap_cache = NULL;
76495 - mm->free_area_cache = oldmm->mmap_base;
76496 - mm->cached_hole_size = ~0UL;
76497 + mm->free_area_cache = oldmm->free_area_cache;
76498 + mm->cached_hole_size = oldmm->cached_hole_size;
76499 mm->map_count = 0;
76500 cpumask_clear(mm_cpumask(mm));
76501 mm->mm_rb = RB_ROOT;
76502 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76503
76504 prev = NULL;
76505 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
76506 - struct file *file;
76507 -
76508 if (mpnt->vm_flags & VM_DONTCOPY) {
76509 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
76510 -vma_pages(mpnt));
76511 continue;
76512 }
76513 - charge = 0;
76514 - if (mpnt->vm_flags & VM_ACCOUNT) {
76515 - unsigned long len = vma_pages(mpnt);
76516 -
76517 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
76518 - goto fail_nomem;
76519 - charge = len;
76520 - }
76521 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
76522 - if (!tmp)
76523 - goto fail_nomem;
76524 - *tmp = *mpnt;
76525 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
76526 - pol = mpol_dup(vma_policy(mpnt));
76527 - retval = PTR_ERR(pol);
76528 - if (IS_ERR(pol))
76529 - goto fail_nomem_policy;
76530 - vma_set_policy(tmp, pol);
76531 - tmp->vm_mm = mm;
76532 - if (anon_vma_fork(tmp, mpnt))
76533 - goto fail_nomem_anon_vma_fork;
76534 - tmp->vm_flags &= ~VM_LOCKED;
76535 - tmp->vm_next = tmp->vm_prev = NULL;
76536 - file = tmp->vm_file;
76537 - if (file) {
76538 - struct inode *inode = file_inode(file);
76539 - struct address_space *mapping = file->f_mapping;
76540 -
76541 - get_file(file);
76542 - if (tmp->vm_flags & VM_DENYWRITE)
76543 - atomic_dec(&inode->i_writecount);
76544 - mutex_lock(&mapping->i_mmap_mutex);
76545 - if (tmp->vm_flags & VM_SHARED)
76546 - mapping->i_mmap_writable++;
76547 - flush_dcache_mmap_lock(mapping);
76548 - /* insert tmp into the share list, just after mpnt */
76549 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
76550 - vma_nonlinear_insert(tmp,
76551 - &mapping->i_mmap_nonlinear);
76552 - else
76553 - vma_interval_tree_insert_after(tmp, mpnt,
76554 - &mapping->i_mmap);
76555 - flush_dcache_mmap_unlock(mapping);
76556 - mutex_unlock(&mapping->i_mmap_mutex);
76557 + tmp = dup_vma(mm, oldmm, mpnt);
76558 + if (!tmp) {
76559 + retval = -ENOMEM;
76560 + goto out;
76561 }
76562
76563 /*
76564 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76565 if (retval)
76566 goto out;
76567 }
76568 +
76569 +#ifdef CONFIG_PAX_SEGMEXEC
76570 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
76571 + struct vm_area_struct *mpnt_m;
76572 +
76573 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
76574 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
76575 +
76576 + if (!mpnt->vm_mirror)
76577 + continue;
76578 +
76579 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
76580 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
76581 + mpnt->vm_mirror = mpnt_m;
76582 + } else {
76583 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
76584 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
76585 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
76586 + mpnt->vm_mirror->vm_mirror = mpnt;
76587 + }
76588 + }
76589 + BUG_ON(mpnt_m);
76590 + }
76591 +#endif
76592 +
76593 /* a new mm has just been created */
76594 arch_dup_mmap(oldmm, mm);
76595 retval = 0;
76596 @@ -473,14 +524,6 @@ out:
76597 up_write(&oldmm->mmap_sem);
76598 uprobe_end_dup_mmap();
76599 return retval;
76600 -fail_nomem_anon_vma_fork:
76601 - mpol_put(pol);
76602 -fail_nomem_policy:
76603 - kmem_cache_free(vm_area_cachep, tmp);
76604 -fail_nomem:
76605 - retval = -ENOMEM;
76606 - vm_unacct_memory(charge);
76607 - goto out;
76608 }
76609
76610 static inline int mm_alloc_pgd(struct mm_struct *mm)
76611 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
76612 return ERR_PTR(err);
76613
76614 mm = get_task_mm(task);
76615 - if (mm && mm != current->mm &&
76616 - !ptrace_may_access(task, mode)) {
76617 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
76618 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
76619 mmput(mm);
76620 mm = ERR_PTR(-EACCES);
76621 }
76622 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
76623 spin_unlock(&fs->lock);
76624 return -EAGAIN;
76625 }
76626 - fs->users++;
76627 + atomic_inc(&fs->users);
76628 spin_unlock(&fs->lock);
76629 return 0;
76630 }
76631 tsk->fs = copy_fs_struct(fs);
76632 if (!tsk->fs)
76633 return -ENOMEM;
76634 + /* Carry through gr_chroot_dentry and is_chrooted instead
76635 + of recomputing it here. Already copied when the task struct
76636 + is duplicated. This allows pivot_root to not be treated as
76637 + a chroot
76638 + */
76639 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
76640 +
76641 return 0;
76642 }
76643
76644 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
76645 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
76646 #endif
76647 retval = -EAGAIN;
76648 +
76649 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
76650 +
76651 if (atomic_read(&p->real_cred->user->processes) >=
76652 task_rlimit(p, RLIMIT_NPROC)) {
76653 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
76654 - p->real_cred->user != INIT_USER)
76655 + if (p->real_cred->user != INIT_USER &&
76656 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
76657 goto bad_fork_free;
76658 }
76659 current->flags &= ~PF_NPROC_EXCEEDED;
76660 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
76661 goto bad_fork_free_pid;
76662 }
76663
76664 + /* synchronizes with gr_set_acls()
76665 + we need to call this past the point of no return for fork()
76666 + */
76667 + gr_copy_label(p);
76668 +
76669 if (clone_flags & CLONE_THREAD) {
76670 current->signal->nr_threads++;
76671 atomic_inc(&current->signal->live);
76672 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
76673 bad_fork_free:
76674 free_task(p);
76675 fork_out:
76676 + gr_log_forkfail(retval);
76677 +
76678 return ERR_PTR(retval);
76679 }
76680
76681 @@ -1613,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
76682 if (clone_flags & CLONE_PARENT_SETTID)
76683 put_user(nr, parent_tidptr);
76684
76685 + gr_handle_brute_check();
76686 +
76687 if (clone_flags & CLONE_VFORK) {
76688 p->vfork_done = &vfork;
76689 init_completion(&vfork);
76690 @@ -1723,7 +1785,7 @@ void __init proc_caches_init(void)
76691 mm_cachep = kmem_cache_create("mm_struct",
76692 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
76693 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
76694 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
76695 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
76696 mmap_init();
76697 nsproxy_cache_init();
76698 }
76699 @@ -1763,7 +1825,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
76700 return 0;
76701
76702 /* don't need lock here; in the worst case we'll do useless copy */
76703 - if (fs->users == 1)
76704 + if (atomic_read(&fs->users) == 1)
76705 return 0;
76706
76707 *new_fsp = copy_fs_struct(fs);
76708 @@ -1875,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
76709 fs = current->fs;
76710 spin_lock(&fs->lock);
76711 current->fs = new_fs;
76712 - if (--fs->users)
76713 + gr_set_chroot_entries(current, &current->fs->root);
76714 + if (atomic_dec_return(&fs->users))
76715 new_fs = NULL;
76716 else
76717 new_fs = fs;
76718 diff --git a/kernel/futex.c b/kernel/futex.c
76719 index 49dacfb..5c6b450 100644
76720 --- a/kernel/futex.c
76721 +++ b/kernel/futex.c
76722 @@ -54,6 +54,7 @@
76723 #include <linux/mount.h>
76724 #include <linux/pagemap.h>
76725 #include <linux/syscalls.h>
76726 +#include <linux/ptrace.h>
76727 #include <linux/signal.h>
76728 #include <linux/export.h>
76729 #include <linux/magic.h>
76730 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
76731 struct page *page, *page_head;
76732 int err, ro = 0;
76733
76734 +#ifdef CONFIG_PAX_SEGMEXEC
76735 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
76736 + return -EFAULT;
76737 +#endif
76738 +
76739 /*
76740 * The futex address must be "naturally" aligned.
76741 */
76742 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
76743 {
76744 u32 curval;
76745 int i;
76746 + mm_segment_t oldfs;
76747
76748 /*
76749 * This will fail and we want it. Some arch implementations do
76750 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
76751 * implementation, the non-functional ones will return
76752 * -ENOSYS.
76753 */
76754 + oldfs = get_fs();
76755 + set_fs(USER_DS);
76756 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
76757 futex_cmpxchg_enabled = 1;
76758 + set_fs(oldfs);
76759
76760 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
76761 plist_head_init(&futex_queues[i].chain);
76762 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
76763 index f9f44fd..29885e4 100644
76764 --- a/kernel/futex_compat.c
76765 +++ b/kernel/futex_compat.c
76766 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
76767 return 0;
76768 }
76769
76770 -static void __user *futex_uaddr(struct robust_list __user *entry,
76771 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
76772 compat_long_t futex_offset)
76773 {
76774 compat_uptr_t base = ptr_to_compat(entry);
76775 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
76776 index 9b22d03..6295b62 100644
76777 --- a/kernel/gcov/base.c
76778 +++ b/kernel/gcov/base.c
76779 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
76780 }
76781
76782 #ifdef CONFIG_MODULES
76783 -static inline int within(void *addr, void *start, unsigned long size)
76784 -{
76785 - return ((addr >= start) && (addr < start + size));
76786 -}
76787 -
76788 /* Update list and generate events when modules are unloaded. */
76789 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76790 void *data)
76791 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76792 prev = NULL;
76793 /* Remove entries located in module from linked list. */
76794 for (info = gcov_info_head; info; info = info->next) {
76795 - if (within(info, mod->module_core, mod->core_size)) {
76796 + if (within_module_core_rw((unsigned long)info, mod)) {
76797 if (prev)
76798 prev->next = info->next;
76799 else
76800 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
76801 index 2288fbd..0f3941f 100644
76802 --- a/kernel/hrtimer.c
76803 +++ b/kernel/hrtimer.c
76804 @@ -1435,7 +1435,7 @@ void hrtimer_peek_ahead_timers(void)
76805 local_irq_restore(flags);
76806 }
76807
76808 -static void run_hrtimer_softirq(struct softirq_action *h)
76809 +static void run_hrtimer_softirq(void)
76810 {
76811 hrtimer_peek_ahead_timers();
76812 }
76813 @@ -1770,7 +1770,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
76814 return NOTIFY_OK;
76815 }
76816
76817 -static struct notifier_block __cpuinitdata hrtimers_nb = {
76818 +static struct notifier_block hrtimers_nb = {
76819 .notifier_call = hrtimer_cpu_notify,
76820 };
76821
76822 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
76823 index 55fcce6..0e4cf34 100644
76824 --- a/kernel/irq_work.c
76825 +++ b/kernel/irq_work.c
76826 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
76827 return NOTIFY_OK;
76828 }
76829
76830 -static struct notifier_block cpu_notify;
76831 +static struct notifier_block cpu_notify = {
76832 + .notifier_call = irq_work_cpu_notify,
76833 + .priority = 0,
76834 +};
76835
76836 static __init int irq_work_init_cpu_notifier(void)
76837 {
76838 - cpu_notify.notifier_call = irq_work_cpu_notify;
76839 - cpu_notify.priority = 0;
76840 register_cpu_notifier(&cpu_notify);
76841 return 0;
76842 }
76843 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
76844 index 60f48fa..7f3a770 100644
76845 --- a/kernel/jump_label.c
76846 +++ b/kernel/jump_label.c
76847 @@ -13,6 +13,7 @@
76848 #include <linux/sort.h>
76849 #include <linux/err.h>
76850 #include <linux/static_key.h>
76851 +#include <linux/mm.h>
76852
76853 #ifdef HAVE_JUMP_LABEL
76854
76855 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
76856
76857 size = (((unsigned long)stop - (unsigned long)start)
76858 / sizeof(struct jump_entry));
76859 + pax_open_kernel();
76860 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
76861 + pax_close_kernel();
76862 }
76863
76864 static void jump_label_update(struct static_key *key, int enable);
76865 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
76866 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
76867 struct jump_entry *iter;
76868
76869 + pax_open_kernel();
76870 for (iter = iter_start; iter < iter_stop; iter++) {
76871 if (within_module_init(iter->code, mod))
76872 iter->code = 0;
76873 }
76874 + pax_close_kernel();
76875 }
76876
76877 static int
76878 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
76879 index 3127ad5..159d880 100644
76880 --- a/kernel/kallsyms.c
76881 +++ b/kernel/kallsyms.c
76882 @@ -11,6 +11,9 @@
76883 * Changed the compression method from stem compression to "table lookup"
76884 * compression (see scripts/kallsyms.c for a more complete description)
76885 */
76886 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76887 +#define __INCLUDED_BY_HIDESYM 1
76888 +#endif
76889 #include <linux/kallsyms.h>
76890 #include <linux/module.h>
76891 #include <linux/init.h>
76892 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
76893
76894 static inline int is_kernel_inittext(unsigned long addr)
76895 {
76896 + if (system_state != SYSTEM_BOOTING)
76897 + return 0;
76898 +
76899 if (addr >= (unsigned long)_sinittext
76900 && addr <= (unsigned long)_einittext)
76901 return 1;
76902 return 0;
76903 }
76904
76905 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76906 +#ifdef CONFIG_MODULES
76907 +static inline int is_module_text(unsigned long addr)
76908 +{
76909 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
76910 + return 1;
76911 +
76912 + addr = ktla_ktva(addr);
76913 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
76914 +}
76915 +#else
76916 +static inline int is_module_text(unsigned long addr)
76917 +{
76918 + return 0;
76919 +}
76920 +#endif
76921 +#endif
76922 +
76923 static inline int is_kernel_text(unsigned long addr)
76924 {
76925 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
76926 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
76927
76928 static inline int is_kernel(unsigned long addr)
76929 {
76930 +
76931 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76932 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
76933 + return 1;
76934 +
76935 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
76936 +#else
76937 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
76938 +#endif
76939 +
76940 return 1;
76941 return in_gate_area_no_mm(addr);
76942 }
76943
76944 static int is_ksym_addr(unsigned long addr)
76945 {
76946 +
76947 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76948 + if (is_module_text(addr))
76949 + return 0;
76950 +#endif
76951 +
76952 if (all_var)
76953 return is_kernel(addr);
76954
76955 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
76956
76957 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
76958 {
76959 - iter->name[0] = '\0';
76960 iter->nameoff = get_symbol_offset(new_pos);
76961 iter->pos = new_pos;
76962 }
76963 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
76964 {
76965 struct kallsym_iter *iter = m->private;
76966
76967 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76968 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
76969 + return 0;
76970 +#endif
76971 +
76972 /* Some debugging symbols have no name. Ignore them. */
76973 if (!iter->name[0])
76974 return 0;
76975 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
76976 */
76977 type = iter->exported ? toupper(iter->type) :
76978 tolower(iter->type);
76979 +
76980 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
76981 type, iter->name, iter->module_name);
76982 } else
76983 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
76984 struct kallsym_iter *iter;
76985 int ret;
76986
76987 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
76988 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
76989 if (!iter)
76990 return -ENOMEM;
76991 reset_iter(iter, 0);
76992 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
76993 index e30ac0f..3528cac 100644
76994 --- a/kernel/kcmp.c
76995 +++ b/kernel/kcmp.c
76996 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
76997 struct task_struct *task1, *task2;
76998 int ret;
76999
77000 +#ifdef CONFIG_GRKERNSEC
77001 + return -ENOSYS;
77002 +#endif
77003 +
77004 rcu_read_lock();
77005
77006 /*
77007 diff --git a/kernel/kexec.c b/kernel/kexec.c
77008 index 59f7b55..4022f65 100644
77009 --- a/kernel/kexec.c
77010 +++ b/kernel/kexec.c
77011 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
77012 unsigned long flags)
77013 {
77014 struct compat_kexec_segment in;
77015 - struct kexec_segment out, __user *ksegments;
77016 + struct kexec_segment out;
77017 + struct kexec_segment __user *ksegments;
77018 unsigned long i, result;
77019
77020 /* Don't allow clients that don't understand the native
77021 diff --git a/kernel/kmod.c b/kernel/kmod.c
77022 index 8241906..d625f2c 100644
77023 --- a/kernel/kmod.c
77024 +++ b/kernel/kmod.c
77025 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
77026 kfree(info->argv);
77027 }
77028
77029 -static int call_modprobe(char *module_name, int wait)
77030 +static int call_modprobe(char *module_name, char *module_param, int wait)
77031 {
77032 struct subprocess_info *info;
77033 static char *envp[] = {
77034 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
77035 NULL
77036 };
77037
77038 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
77039 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
77040 if (!argv)
77041 goto out;
77042
77043 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
77044 argv[1] = "-q";
77045 argv[2] = "--";
77046 argv[3] = module_name; /* check free_modprobe_argv() */
77047 - argv[4] = NULL;
77048 + argv[4] = module_param;
77049 + argv[5] = NULL;
77050
77051 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
77052 NULL, free_modprobe_argv, NULL);
77053 @@ -129,9 +130,8 @@ out:
77054 * If module auto-loading support is disabled then this function
77055 * becomes a no-operation.
77056 */
77057 -int __request_module(bool wait, const char *fmt, ...)
77058 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
77059 {
77060 - va_list args;
77061 char module_name[MODULE_NAME_LEN];
77062 unsigned int max_modprobes;
77063 int ret;
77064 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
77065 */
77066 WARN_ON_ONCE(wait && current_is_async());
77067
77068 - va_start(args, fmt);
77069 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
77070 - va_end(args);
77071 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
77072 if (ret >= MODULE_NAME_LEN)
77073 return -ENAMETOOLONG;
77074
77075 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
77076 if (ret)
77077 return ret;
77078
77079 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77080 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
77081 + /* hack to workaround consolekit/udisks stupidity */
77082 + read_lock(&tasklist_lock);
77083 + if (!strcmp(current->comm, "mount") &&
77084 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
77085 + read_unlock(&tasklist_lock);
77086 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
77087 + return -EPERM;
77088 + }
77089 + read_unlock(&tasklist_lock);
77090 + }
77091 +#endif
77092 +
77093 /* If modprobe needs a service that is in a module, we get a recursive
77094 * loop. Limit the number of running kmod threads to max_threads/2 or
77095 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
77096 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
77097
77098 trace_module_request(module_name, wait, _RET_IP_);
77099
77100 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
77101 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
77102
77103 atomic_dec(&kmod_concurrent);
77104 return ret;
77105 }
77106 +
77107 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
77108 +{
77109 + va_list args;
77110 + int ret;
77111 +
77112 + va_start(args, fmt);
77113 + ret = ____request_module(wait, module_param, fmt, args);
77114 + va_end(args);
77115 +
77116 + return ret;
77117 +}
77118 +
77119 +int __request_module(bool wait, const char *fmt, ...)
77120 +{
77121 + va_list args;
77122 + int ret;
77123 +
77124 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77125 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
77126 + char module_param[MODULE_NAME_LEN];
77127 +
77128 + memset(module_param, 0, sizeof(module_param));
77129 +
77130 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
77131 +
77132 + va_start(args, fmt);
77133 + ret = ____request_module(wait, module_param, fmt, args);
77134 + va_end(args);
77135 +
77136 + return ret;
77137 + }
77138 +#endif
77139 +
77140 + va_start(args, fmt);
77141 + ret = ____request_module(wait, NULL, fmt, args);
77142 + va_end(args);
77143 +
77144 + return ret;
77145 +}
77146 +
77147 EXPORT_SYMBOL(__request_module);
77148 #endif /* CONFIG_MODULES */
77149
77150 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
77151 *
77152 * Thus the __user pointer cast is valid here.
77153 */
77154 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
77155 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
77156
77157 /*
77158 * If ret is 0, either ____call_usermodehelper failed and the
77159 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
77160 static int proc_cap_handler(struct ctl_table *table, int write,
77161 void __user *buffer, size_t *lenp, loff_t *ppos)
77162 {
77163 - struct ctl_table t;
77164 + ctl_table_no_const t;
77165 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
77166 kernel_cap_t new_cap;
77167 int err, i;
77168 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
77169 index bddf3b2..07b90dd 100644
77170 --- a/kernel/kprobes.c
77171 +++ b/kernel/kprobes.c
77172 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
77173 * kernel image and loaded module images reside. This is required
77174 * so x86_64 can correctly handle the %rip-relative fixups.
77175 */
77176 - kip->insns = module_alloc(PAGE_SIZE);
77177 + kip->insns = module_alloc_exec(PAGE_SIZE);
77178 if (!kip->insns) {
77179 kfree(kip);
77180 return NULL;
77181 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
77182 */
77183 if (!list_is_singular(&kip->list)) {
77184 list_del(&kip->list);
77185 - module_free(NULL, kip->insns);
77186 + module_free_exec(NULL, kip->insns);
77187 kfree(kip);
77188 }
77189 return 1;
77190 @@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
77191 {
77192 int i, err = 0;
77193 unsigned long offset = 0, size = 0;
77194 - char *modname, namebuf[128];
77195 + char *modname, namebuf[KSYM_NAME_LEN];
77196 const char *symbol_name;
77197 void *addr;
77198 struct kprobe_blackpoint *kb;
77199 @@ -2168,11 +2168,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
77200 kprobe_type = "k";
77201
77202 if (sym)
77203 - seq_printf(pi, "%p %s %s+0x%x %s ",
77204 + seq_printf(pi, "%pK %s %s+0x%x %s ",
77205 p->addr, kprobe_type, sym, offset,
77206 (modname ? modname : " "));
77207 else
77208 - seq_printf(pi, "%p %s %p ",
77209 + seq_printf(pi, "%pK %s %pK ",
77210 p->addr, kprobe_type, p->addr);
77211
77212 if (!pp)
77213 @@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
77214 const char *sym = NULL;
77215 unsigned int i = *(loff_t *) v;
77216 unsigned long offset = 0;
77217 - char *modname, namebuf[128];
77218 + char *modname, namebuf[KSYM_NAME_LEN];
77219
77220 head = &kprobe_table[i];
77221 preempt_disable();
77222 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
77223 index 6ada93c..dce7d5d 100644
77224 --- a/kernel/ksysfs.c
77225 +++ b/kernel/ksysfs.c
77226 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
77227 {
77228 if (count+1 > UEVENT_HELPER_PATH_LEN)
77229 return -ENOENT;
77230 + if (!capable(CAP_SYS_ADMIN))
77231 + return -EPERM;
77232 memcpy(uevent_helper, buf, count);
77233 uevent_helper[count] = '\0';
77234 if (count && uevent_helper[count-1] == '\n')
77235 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
77236 return count;
77237 }
77238
77239 -static struct bin_attribute notes_attr = {
77240 +static bin_attribute_no_const notes_attr __read_only = {
77241 .attr = {
77242 .name = "notes",
77243 .mode = S_IRUGO,
77244 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
77245 index 1f3186b..bb7dbc6 100644
77246 --- a/kernel/lockdep.c
77247 +++ b/kernel/lockdep.c
77248 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
77249 end = (unsigned long) &_end,
77250 addr = (unsigned long) obj;
77251
77252 +#ifdef CONFIG_PAX_KERNEXEC
77253 + start = ktla_ktva(start);
77254 +#endif
77255 +
77256 /*
77257 * static variable?
77258 */
77259 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
77260 if (!static_obj(lock->key)) {
77261 debug_locks_off();
77262 printk("INFO: trying to register non-static key.\n");
77263 + printk("lock:%pS key:%pS.\n", lock, lock->key);
77264 printk("the code is fine but needs lockdep annotation.\n");
77265 printk("turning off the locking correctness validator.\n");
77266 dump_stack();
77267 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
77268 if (!class)
77269 return 0;
77270 }
77271 - atomic_inc((atomic_t *)&class->ops);
77272 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
77273 if (very_verbose(class)) {
77274 printk("\nacquire class [%p] %s", class->key, class->name);
77275 if (class->name_version > 1)
77276 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
77277 index b2c71c5..7b88d63 100644
77278 --- a/kernel/lockdep_proc.c
77279 +++ b/kernel/lockdep_proc.c
77280 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
77281 return 0;
77282 }
77283
77284 - seq_printf(m, "%p", class->key);
77285 + seq_printf(m, "%pK", class->key);
77286 #ifdef CONFIG_DEBUG_LOCKDEP
77287 seq_printf(m, " OPS:%8ld", class->ops);
77288 #endif
77289 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
77290
77291 list_for_each_entry(entry, &class->locks_after, entry) {
77292 if (entry->distance == 1) {
77293 - seq_printf(m, " -> [%p] ", entry->class->key);
77294 + seq_printf(m, " -> [%pK] ", entry->class->key);
77295 print_name(m, entry->class);
77296 seq_puts(m, "\n");
77297 }
77298 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
77299 if (!class->key)
77300 continue;
77301
77302 - seq_printf(m, "[%p] ", class->key);
77303 + seq_printf(m, "[%pK] ", class->key);
77304 print_name(m, class);
77305 seq_puts(m, "\n");
77306 }
77307 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
77308 if (!i)
77309 seq_line(m, '-', 40-namelen, namelen);
77310
77311 - snprintf(ip, sizeof(ip), "[<%p>]",
77312 + snprintf(ip, sizeof(ip), "[<%pK>]",
77313 (void *)class->contention_point[i]);
77314 seq_printf(m, "%40s %14lu %29s %pS\n",
77315 name, stats->contention_point[i],
77316 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
77317 if (!i)
77318 seq_line(m, '-', 40-namelen, namelen);
77319
77320 - snprintf(ip, sizeof(ip), "[<%p>]",
77321 + snprintf(ip, sizeof(ip), "[<%pK>]",
77322 (void *)class->contending_point[i]);
77323 seq_printf(m, "%40s %14lu %29s %pS\n",
77324 name, stats->contending_point[i],
77325 diff --git a/kernel/module.c b/kernel/module.c
77326 index fa53db8..6f17200 100644
77327 --- a/kernel/module.c
77328 +++ b/kernel/module.c
77329 @@ -61,6 +61,7 @@
77330 #include <linux/pfn.h>
77331 #include <linux/bsearch.h>
77332 #include <linux/fips.h>
77333 +#include <linux/grsecurity.h>
77334 #include <uapi/linux/module.h>
77335 #include "module-internal.h"
77336
77337 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
77338
77339 /* Bounds of module allocation, for speeding __module_address.
77340 * Protected by module_mutex. */
77341 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
77342 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
77343 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
77344
77345 int register_module_notifier(struct notifier_block * nb)
77346 {
77347 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
77348 return true;
77349
77350 list_for_each_entry_rcu(mod, &modules, list) {
77351 - struct symsearch arr[] = {
77352 + struct symsearch modarr[] = {
77353 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
77354 NOT_GPL_ONLY, false },
77355 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
77356 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
77357 if (mod->state == MODULE_STATE_UNFORMED)
77358 continue;
77359
77360 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
77361 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
77362 return true;
77363 }
77364 return false;
77365 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
77366 static int percpu_modalloc(struct module *mod,
77367 unsigned long size, unsigned long align)
77368 {
77369 - if (align > PAGE_SIZE) {
77370 + if (align-1 >= PAGE_SIZE) {
77371 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
77372 mod->name, align, PAGE_SIZE);
77373 align = PAGE_SIZE;
77374 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
77375 static ssize_t show_coresize(struct module_attribute *mattr,
77376 struct module_kobject *mk, char *buffer)
77377 {
77378 - return sprintf(buffer, "%u\n", mk->mod->core_size);
77379 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
77380 }
77381
77382 static struct module_attribute modinfo_coresize =
77383 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
77384 static ssize_t show_initsize(struct module_attribute *mattr,
77385 struct module_kobject *mk, char *buffer)
77386 {
77387 - return sprintf(buffer, "%u\n", mk->mod->init_size);
77388 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
77389 }
77390
77391 static struct module_attribute modinfo_initsize =
77392 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
77393 */
77394 #ifdef CONFIG_SYSFS
77395
77396 -#ifdef CONFIG_KALLSYMS
77397 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
77398 static inline bool sect_empty(const Elf_Shdr *sect)
77399 {
77400 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
77401 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
77402 {
77403 unsigned int notes, loaded, i;
77404 struct module_notes_attrs *notes_attrs;
77405 - struct bin_attribute *nattr;
77406 + bin_attribute_no_const *nattr;
77407
77408 /* failed to create section attributes, so can't create notes */
77409 if (!mod->sect_attrs)
77410 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
77411 static int module_add_modinfo_attrs(struct module *mod)
77412 {
77413 struct module_attribute *attr;
77414 - struct module_attribute *temp_attr;
77415 + module_attribute_no_const *temp_attr;
77416 int error = 0;
77417 int i;
77418
77419 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
77420
77421 static void unset_module_core_ro_nx(struct module *mod)
77422 {
77423 - set_page_attributes(mod->module_core + mod->core_text_size,
77424 - mod->module_core + mod->core_size,
77425 + set_page_attributes(mod->module_core_rw,
77426 + mod->module_core_rw + mod->core_size_rw,
77427 set_memory_x);
77428 - set_page_attributes(mod->module_core,
77429 - mod->module_core + mod->core_ro_size,
77430 + set_page_attributes(mod->module_core_rx,
77431 + mod->module_core_rx + mod->core_size_rx,
77432 set_memory_rw);
77433 }
77434
77435 static void unset_module_init_ro_nx(struct module *mod)
77436 {
77437 - set_page_attributes(mod->module_init + mod->init_text_size,
77438 - mod->module_init + mod->init_size,
77439 + set_page_attributes(mod->module_init_rw,
77440 + mod->module_init_rw + mod->init_size_rw,
77441 set_memory_x);
77442 - set_page_attributes(mod->module_init,
77443 - mod->module_init + mod->init_ro_size,
77444 + set_page_attributes(mod->module_init_rx,
77445 + mod->module_init_rx + mod->init_size_rx,
77446 set_memory_rw);
77447 }
77448
77449 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
77450 list_for_each_entry_rcu(mod, &modules, list) {
77451 if (mod->state == MODULE_STATE_UNFORMED)
77452 continue;
77453 - if ((mod->module_core) && (mod->core_text_size)) {
77454 - set_page_attributes(mod->module_core,
77455 - mod->module_core + mod->core_text_size,
77456 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
77457 + set_page_attributes(mod->module_core_rx,
77458 + mod->module_core_rx + mod->core_size_rx,
77459 set_memory_rw);
77460 }
77461 - if ((mod->module_init) && (mod->init_text_size)) {
77462 - set_page_attributes(mod->module_init,
77463 - mod->module_init + mod->init_text_size,
77464 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
77465 + set_page_attributes(mod->module_init_rx,
77466 + mod->module_init_rx + mod->init_size_rx,
77467 set_memory_rw);
77468 }
77469 }
77470 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
77471 list_for_each_entry_rcu(mod, &modules, list) {
77472 if (mod->state == MODULE_STATE_UNFORMED)
77473 continue;
77474 - if ((mod->module_core) && (mod->core_text_size)) {
77475 - set_page_attributes(mod->module_core,
77476 - mod->module_core + mod->core_text_size,
77477 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
77478 + set_page_attributes(mod->module_core_rx,
77479 + mod->module_core_rx + mod->core_size_rx,
77480 set_memory_ro);
77481 }
77482 - if ((mod->module_init) && (mod->init_text_size)) {
77483 - set_page_attributes(mod->module_init,
77484 - mod->module_init + mod->init_text_size,
77485 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
77486 + set_page_attributes(mod->module_init_rx,
77487 + mod->module_init_rx + mod->init_size_rx,
77488 set_memory_ro);
77489 }
77490 }
77491 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
77492
77493 /* This may be NULL, but that's OK */
77494 unset_module_init_ro_nx(mod);
77495 - module_free(mod, mod->module_init);
77496 + module_free(mod, mod->module_init_rw);
77497 + module_free_exec(mod, mod->module_init_rx);
77498 kfree(mod->args);
77499 percpu_modfree(mod);
77500
77501 /* Free lock-classes: */
77502 - lockdep_free_key_range(mod->module_core, mod->core_size);
77503 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
77504 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
77505
77506 /* Finally, free the core (containing the module structure) */
77507 unset_module_core_ro_nx(mod);
77508 - module_free(mod, mod->module_core);
77509 + module_free_exec(mod, mod->module_core_rx);
77510 + module_free(mod, mod->module_core_rw);
77511
77512 #ifdef CONFIG_MPU
77513 update_protections(current->mm);
77514 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
77515 int ret = 0;
77516 const struct kernel_symbol *ksym;
77517
77518 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77519 + int is_fs_load = 0;
77520 + int register_filesystem_found = 0;
77521 + char *p;
77522 +
77523 + p = strstr(mod->args, "grsec_modharden_fs");
77524 + if (p) {
77525 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
77526 + /* copy \0 as well */
77527 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
77528 + is_fs_load = 1;
77529 + }
77530 +#endif
77531 +
77532 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
77533 const char *name = info->strtab + sym[i].st_name;
77534
77535 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77536 + /* it's a real shame this will never get ripped and copied
77537 + upstream! ;(
77538 + */
77539 + if (is_fs_load && !strcmp(name, "register_filesystem"))
77540 + register_filesystem_found = 1;
77541 +#endif
77542 +
77543 switch (sym[i].st_shndx) {
77544 case SHN_COMMON:
77545 /* We compiled with -fno-common. These are not
77546 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
77547 ksym = resolve_symbol_wait(mod, info, name);
77548 /* Ok if resolved. */
77549 if (ksym && !IS_ERR(ksym)) {
77550 + pax_open_kernel();
77551 sym[i].st_value = ksym->value;
77552 + pax_close_kernel();
77553 break;
77554 }
77555
77556 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
77557 secbase = (unsigned long)mod_percpu(mod);
77558 else
77559 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
77560 + pax_open_kernel();
77561 sym[i].st_value += secbase;
77562 + pax_close_kernel();
77563 break;
77564 }
77565 }
77566
77567 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77568 + if (is_fs_load && !register_filesystem_found) {
77569 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
77570 + ret = -EPERM;
77571 + }
77572 +#endif
77573 +
77574 return ret;
77575 }
77576
77577 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
77578 || s->sh_entsize != ~0UL
77579 || strstarts(sname, ".init"))
77580 continue;
77581 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
77582 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
77583 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
77584 + else
77585 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
77586 pr_debug("\t%s\n", sname);
77587 }
77588 - switch (m) {
77589 - case 0: /* executable */
77590 - mod->core_size = debug_align(mod->core_size);
77591 - mod->core_text_size = mod->core_size;
77592 - break;
77593 - case 1: /* RO: text and ro-data */
77594 - mod->core_size = debug_align(mod->core_size);
77595 - mod->core_ro_size = mod->core_size;
77596 - break;
77597 - case 3: /* whole core */
77598 - mod->core_size = debug_align(mod->core_size);
77599 - break;
77600 - }
77601 }
77602
77603 pr_debug("Init section allocation order:\n");
77604 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
77605 || s->sh_entsize != ~0UL
77606 || !strstarts(sname, ".init"))
77607 continue;
77608 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
77609 - | INIT_OFFSET_MASK);
77610 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
77611 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
77612 + else
77613 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
77614 + s->sh_entsize |= INIT_OFFSET_MASK;
77615 pr_debug("\t%s\n", sname);
77616 }
77617 - switch (m) {
77618 - case 0: /* executable */
77619 - mod->init_size = debug_align(mod->init_size);
77620 - mod->init_text_size = mod->init_size;
77621 - break;
77622 - case 1: /* RO: text and ro-data */
77623 - mod->init_size = debug_align(mod->init_size);
77624 - mod->init_ro_size = mod->init_size;
77625 - break;
77626 - case 3: /* whole init */
77627 - mod->init_size = debug_align(mod->init_size);
77628 - break;
77629 - }
77630 }
77631 }
77632
77633 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
77634
77635 /* Put symbol section at end of init part of module. */
77636 symsect->sh_flags |= SHF_ALLOC;
77637 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
77638 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
77639 info->index.sym) | INIT_OFFSET_MASK;
77640 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
77641
77642 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
77643 }
77644
77645 /* Append room for core symbols at end of core part. */
77646 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
77647 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
77648 - mod->core_size += strtab_size;
77649 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
77650 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
77651 + mod->core_size_rx += strtab_size;
77652
77653 /* Put string table section at end of init part of module. */
77654 strsect->sh_flags |= SHF_ALLOC;
77655 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
77656 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
77657 info->index.str) | INIT_OFFSET_MASK;
77658 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
77659 }
77660 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
77661 /* Make sure we get permanent strtab: don't use info->strtab. */
77662 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
77663
77664 + pax_open_kernel();
77665 +
77666 /* Set types up while we still have access to sections. */
77667 for (i = 0; i < mod->num_symtab; i++)
77668 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
77669
77670 - mod->core_symtab = dst = mod->module_core + info->symoffs;
77671 - mod->core_strtab = s = mod->module_core + info->stroffs;
77672 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
77673 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
77674 src = mod->symtab;
77675 for (ndst = i = 0; i < mod->num_symtab; i++) {
77676 if (i == 0 ||
77677 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
77678 }
77679 }
77680 mod->core_num_syms = ndst;
77681 +
77682 + pax_close_kernel();
77683 }
77684 #else
77685 static inline void layout_symtab(struct module *mod, struct load_info *info)
77686 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
77687 return vmalloc_exec(size);
77688 }
77689
77690 -static void *module_alloc_update_bounds(unsigned long size)
77691 +static void *module_alloc_update_bounds_rw(unsigned long size)
77692 {
77693 void *ret = module_alloc(size);
77694
77695 if (ret) {
77696 mutex_lock(&module_mutex);
77697 /* Update module bounds. */
77698 - if ((unsigned long)ret < module_addr_min)
77699 - module_addr_min = (unsigned long)ret;
77700 - if ((unsigned long)ret + size > module_addr_max)
77701 - module_addr_max = (unsigned long)ret + size;
77702 + if ((unsigned long)ret < module_addr_min_rw)
77703 + module_addr_min_rw = (unsigned long)ret;
77704 + if ((unsigned long)ret + size > module_addr_max_rw)
77705 + module_addr_max_rw = (unsigned long)ret + size;
77706 + mutex_unlock(&module_mutex);
77707 + }
77708 + return ret;
77709 +}
77710 +
77711 +static void *module_alloc_update_bounds_rx(unsigned long size)
77712 +{
77713 + void *ret = module_alloc_exec(size);
77714 +
77715 + if (ret) {
77716 + mutex_lock(&module_mutex);
77717 + /* Update module bounds. */
77718 + if ((unsigned long)ret < module_addr_min_rx)
77719 + module_addr_min_rx = (unsigned long)ret;
77720 + if ((unsigned long)ret + size > module_addr_max_rx)
77721 + module_addr_max_rx = (unsigned long)ret + size;
77722 mutex_unlock(&module_mutex);
77723 }
77724 return ret;
77725 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
77726 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
77727 {
77728 const char *modmagic = get_modinfo(info, "vermagic");
77729 + const char *license = get_modinfo(info, "license");
77730 int err;
77731
77732 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
77733 + if (!license || !license_is_gpl_compatible(license))
77734 + return -ENOEXEC;
77735 +#endif
77736 +
77737 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
77738 modmagic = NULL;
77739
77740 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
77741 }
77742
77743 /* Set up license info based on the info section */
77744 - set_license(mod, get_modinfo(info, "license"));
77745 + set_license(mod, license);
77746
77747 return 0;
77748 }
77749 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
77750 void *ptr;
77751
77752 /* Do the allocs. */
77753 - ptr = module_alloc_update_bounds(mod->core_size);
77754 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
77755 /*
77756 * The pointer to this block is stored in the module structure
77757 * which is inside the block. Just mark it as not being a
77758 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
77759 if (!ptr)
77760 return -ENOMEM;
77761
77762 - memset(ptr, 0, mod->core_size);
77763 - mod->module_core = ptr;
77764 + memset(ptr, 0, mod->core_size_rw);
77765 + mod->module_core_rw = ptr;
77766
77767 - if (mod->init_size) {
77768 - ptr = module_alloc_update_bounds(mod->init_size);
77769 + if (mod->init_size_rw) {
77770 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
77771 /*
77772 * The pointer to this block is stored in the module structure
77773 * which is inside the block. This block doesn't need to be
77774 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
77775 */
77776 kmemleak_ignore(ptr);
77777 if (!ptr) {
77778 - module_free(mod, mod->module_core);
77779 + module_free(mod, mod->module_core_rw);
77780 return -ENOMEM;
77781 }
77782 - memset(ptr, 0, mod->init_size);
77783 - mod->module_init = ptr;
77784 + memset(ptr, 0, mod->init_size_rw);
77785 + mod->module_init_rw = ptr;
77786 } else
77787 - mod->module_init = NULL;
77788 + mod->module_init_rw = NULL;
77789 +
77790 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
77791 + kmemleak_not_leak(ptr);
77792 + if (!ptr) {
77793 + if (mod->module_init_rw)
77794 + module_free(mod, mod->module_init_rw);
77795 + module_free(mod, mod->module_core_rw);
77796 + return -ENOMEM;
77797 + }
77798 +
77799 + pax_open_kernel();
77800 + memset(ptr, 0, mod->core_size_rx);
77801 + pax_close_kernel();
77802 + mod->module_core_rx = ptr;
77803 +
77804 + if (mod->init_size_rx) {
77805 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
77806 + kmemleak_ignore(ptr);
77807 + if (!ptr && mod->init_size_rx) {
77808 + module_free_exec(mod, mod->module_core_rx);
77809 + if (mod->module_init_rw)
77810 + module_free(mod, mod->module_init_rw);
77811 + module_free(mod, mod->module_core_rw);
77812 + return -ENOMEM;
77813 + }
77814 +
77815 + pax_open_kernel();
77816 + memset(ptr, 0, mod->init_size_rx);
77817 + pax_close_kernel();
77818 + mod->module_init_rx = ptr;
77819 + } else
77820 + mod->module_init_rx = NULL;
77821
77822 /* Transfer each section which specifies SHF_ALLOC */
77823 pr_debug("final section addresses:\n");
77824 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
77825 if (!(shdr->sh_flags & SHF_ALLOC))
77826 continue;
77827
77828 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
77829 - dest = mod->module_init
77830 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77831 - else
77832 - dest = mod->module_core + shdr->sh_entsize;
77833 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
77834 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77835 + dest = mod->module_init_rw
77836 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77837 + else
77838 + dest = mod->module_init_rx
77839 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77840 + } else {
77841 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77842 + dest = mod->module_core_rw + shdr->sh_entsize;
77843 + else
77844 + dest = mod->module_core_rx + shdr->sh_entsize;
77845 + }
77846 +
77847 + if (shdr->sh_type != SHT_NOBITS) {
77848 +
77849 +#ifdef CONFIG_PAX_KERNEXEC
77850 +#ifdef CONFIG_X86_64
77851 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
77852 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
77853 +#endif
77854 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
77855 + pax_open_kernel();
77856 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77857 + pax_close_kernel();
77858 + } else
77859 +#endif
77860
77861 - if (shdr->sh_type != SHT_NOBITS)
77862 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77863 + }
77864 /* Update sh_addr to point to copy in image. */
77865 - shdr->sh_addr = (unsigned long)dest;
77866 +
77867 +#ifdef CONFIG_PAX_KERNEXEC
77868 + if (shdr->sh_flags & SHF_EXECINSTR)
77869 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
77870 + else
77871 +#endif
77872 +
77873 + shdr->sh_addr = (unsigned long)dest;
77874 pr_debug("\t0x%lx %s\n",
77875 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
77876 }
77877 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
77878 * Do it before processing of module parameters, so the module
77879 * can provide parameter accessor functions of its own.
77880 */
77881 - if (mod->module_init)
77882 - flush_icache_range((unsigned long)mod->module_init,
77883 - (unsigned long)mod->module_init
77884 - + mod->init_size);
77885 - flush_icache_range((unsigned long)mod->module_core,
77886 - (unsigned long)mod->module_core + mod->core_size);
77887 + if (mod->module_init_rx)
77888 + flush_icache_range((unsigned long)mod->module_init_rx,
77889 + (unsigned long)mod->module_init_rx
77890 + + mod->init_size_rx);
77891 + flush_icache_range((unsigned long)mod->module_core_rx,
77892 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
77893
77894 set_fs(old_fs);
77895 }
77896 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
77897 static void module_deallocate(struct module *mod, struct load_info *info)
77898 {
77899 percpu_modfree(mod);
77900 - module_free(mod, mod->module_init);
77901 - module_free(mod, mod->module_core);
77902 + module_free_exec(mod, mod->module_init_rx);
77903 + module_free_exec(mod, mod->module_core_rx);
77904 + module_free(mod, mod->module_init_rw);
77905 + module_free(mod, mod->module_core_rw);
77906 }
77907
77908 int __weak module_finalize(const Elf_Ehdr *hdr,
77909 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
77910 static int post_relocation(struct module *mod, const struct load_info *info)
77911 {
77912 /* Sort exception table now relocations are done. */
77913 + pax_open_kernel();
77914 sort_extable(mod->extable, mod->extable + mod->num_exentries);
77915 + pax_close_kernel();
77916
77917 /* Copy relocated percpu area over. */
77918 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
77919 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
77920 MODULE_STATE_COMING, mod);
77921
77922 /* Set RO and NX regions for core */
77923 - set_section_ro_nx(mod->module_core,
77924 - mod->core_text_size,
77925 - mod->core_ro_size,
77926 - mod->core_size);
77927 + set_section_ro_nx(mod->module_core_rx,
77928 + mod->core_size_rx,
77929 + mod->core_size_rx,
77930 + mod->core_size_rx);
77931
77932 /* Set RO and NX regions for init */
77933 - set_section_ro_nx(mod->module_init,
77934 - mod->init_text_size,
77935 - mod->init_ro_size,
77936 - mod->init_size);
77937 + set_section_ro_nx(mod->module_init_rx,
77938 + mod->init_size_rx,
77939 + mod->init_size_rx,
77940 + mod->init_size_rx);
77941
77942 do_mod_ctors(mod);
77943 /* Start the module */
77944 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
77945 mod->strtab = mod->core_strtab;
77946 #endif
77947 unset_module_init_ro_nx(mod);
77948 - module_free(mod, mod->module_init);
77949 - mod->module_init = NULL;
77950 - mod->init_size = 0;
77951 - mod->init_ro_size = 0;
77952 - mod->init_text_size = 0;
77953 + module_free(mod, mod->module_init_rw);
77954 + module_free_exec(mod, mod->module_init_rx);
77955 + mod->module_init_rw = NULL;
77956 + mod->module_init_rx = NULL;
77957 + mod->init_size_rw = 0;
77958 + mod->init_size_rx = 0;
77959 mutex_unlock(&module_mutex);
77960 wake_up_all(&module_wq);
77961
77962 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
77963 if (err)
77964 goto free_unload;
77965
77966 + /* Now copy in args */
77967 + mod->args = strndup_user(uargs, ~0UL >> 1);
77968 + if (IS_ERR(mod->args)) {
77969 + err = PTR_ERR(mod->args);
77970 + goto free_unload;
77971 + }
77972 +
77973 /* Set up MODINFO_ATTR fields */
77974 setup_modinfo(mod, info);
77975
77976 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77977 + {
77978 + char *p, *p2;
77979 +
77980 + if (strstr(mod->args, "grsec_modharden_netdev")) {
77981 + printk(KERN_ALERT "grsec: denied auto-loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%.64s instead.", mod->name);
77982 + err = -EPERM;
77983 + goto free_modinfo;
77984 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
77985 + p += sizeof("grsec_modharden_normal") - 1;
77986 + p2 = strstr(p, "_");
77987 + if (p2) {
77988 + *p2 = '\0';
77989 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
77990 + *p2 = '_';
77991 + }
77992 + err = -EPERM;
77993 + goto free_modinfo;
77994 + }
77995 + }
77996 +#endif
77997 +
77998 /* Fix up syms, so that st_value is a pointer to location. */
77999 err = simplify_symbols(mod, info);
78000 if (err < 0)
78001 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
78002
78003 flush_module_icache(mod);
78004
78005 - /* Now copy in args */
78006 - mod->args = strndup_user(uargs, ~0UL >> 1);
78007 - if (IS_ERR(mod->args)) {
78008 - err = PTR_ERR(mod->args);
78009 - goto free_arch_cleanup;
78010 - }
78011 -
78012 dynamic_debug_setup(info->debug, info->num_debug);
78013
78014 /* Finally it's fully formed, ready to start executing. */
78015 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
78016 ddebug_cleanup:
78017 dynamic_debug_remove(info->debug);
78018 synchronize_sched();
78019 - kfree(mod->args);
78020 - free_arch_cleanup:
78021 module_arch_cleanup(mod);
78022 free_modinfo:
78023 free_modinfo(mod);
78024 + kfree(mod->args);
78025 free_unload:
78026 module_unload_free(mod);
78027 unlink_mod:
78028 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
78029 unsigned long nextval;
78030
78031 /* At worse, next value is at end of module */
78032 - if (within_module_init(addr, mod))
78033 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
78034 + if (within_module_init_rx(addr, mod))
78035 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
78036 + else if (within_module_init_rw(addr, mod))
78037 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
78038 + else if (within_module_core_rx(addr, mod))
78039 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
78040 + else if (within_module_core_rw(addr, mod))
78041 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
78042 else
78043 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
78044 + return NULL;
78045
78046 /* Scan for closest preceding symbol, and next symbol. (ELF
78047 starts real symbols at 1). */
78048 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
78049 return 0;
78050
78051 seq_printf(m, "%s %u",
78052 - mod->name, mod->init_size + mod->core_size);
78053 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
78054 print_unload_info(m, mod);
78055
78056 /* Informative for users. */
78057 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
78058 mod->state == MODULE_STATE_COMING ? "Loading":
78059 "Live");
78060 /* Used by oprofile and other similar tools. */
78061 - seq_printf(m, " 0x%pK", mod->module_core);
78062 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
78063
78064 /* Taints info */
78065 if (mod->taints)
78066 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
78067
78068 static int __init proc_modules_init(void)
78069 {
78070 +#ifndef CONFIG_GRKERNSEC_HIDESYM
78071 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78072 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
78073 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78074 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
78075 +#else
78076 proc_create("modules", 0, NULL, &proc_modules_operations);
78077 +#endif
78078 +#else
78079 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
78080 +#endif
78081 return 0;
78082 }
78083 module_init(proc_modules_init);
78084 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
78085 {
78086 struct module *mod;
78087
78088 - if (addr < module_addr_min || addr > module_addr_max)
78089 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
78090 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
78091 return NULL;
78092
78093 list_for_each_entry_rcu(mod, &modules, list) {
78094 if (mod->state == MODULE_STATE_UNFORMED)
78095 continue;
78096 - if (within_module_core(addr, mod)
78097 - || within_module_init(addr, mod))
78098 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
78099 return mod;
78100 }
78101 return NULL;
78102 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
78103 */
78104 struct module *__module_text_address(unsigned long addr)
78105 {
78106 - struct module *mod = __module_address(addr);
78107 + struct module *mod;
78108 +
78109 +#ifdef CONFIG_X86_32
78110 + addr = ktla_ktva(addr);
78111 +#endif
78112 +
78113 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
78114 + return NULL;
78115 +
78116 + mod = __module_address(addr);
78117 +
78118 if (mod) {
78119 /* Make sure it's within the text section. */
78120 - if (!within(addr, mod->module_init, mod->init_text_size)
78121 - && !within(addr, mod->module_core, mod->core_text_size))
78122 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
78123 mod = NULL;
78124 }
78125 return mod;
78126 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
78127 index 7e3443f..b2a1e6b 100644
78128 --- a/kernel/mutex-debug.c
78129 +++ b/kernel/mutex-debug.c
78130 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
78131 }
78132
78133 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
78134 - struct thread_info *ti)
78135 + struct task_struct *task)
78136 {
78137 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
78138
78139 /* Mark the current thread as blocked on the lock: */
78140 - ti->task->blocked_on = waiter;
78141 + task->blocked_on = waiter;
78142 }
78143
78144 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
78145 - struct thread_info *ti)
78146 + struct task_struct *task)
78147 {
78148 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
78149 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
78150 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
78151 - ti->task->blocked_on = NULL;
78152 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
78153 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
78154 + task->blocked_on = NULL;
78155
78156 list_del_init(&waiter->list);
78157 waiter->task = NULL;
78158 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
78159 index 0799fd3..d06ae3b 100644
78160 --- a/kernel/mutex-debug.h
78161 +++ b/kernel/mutex-debug.h
78162 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
78163 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
78164 extern void debug_mutex_add_waiter(struct mutex *lock,
78165 struct mutex_waiter *waiter,
78166 - struct thread_info *ti);
78167 + struct task_struct *task);
78168 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
78169 - struct thread_info *ti);
78170 + struct task_struct *task);
78171 extern void debug_mutex_unlock(struct mutex *lock);
78172 extern void debug_mutex_init(struct mutex *lock, const char *name,
78173 struct lock_class_key *key);
78174 diff --git a/kernel/mutex.c b/kernel/mutex.c
78175 index ad53a66..f1bf8bc 100644
78176 --- a/kernel/mutex.c
78177 +++ b/kernel/mutex.c
78178 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
78179 node->locked = 1;
78180 return;
78181 }
78182 - ACCESS_ONCE(prev->next) = node;
78183 + ACCESS_ONCE_RW(prev->next) = node;
78184 smp_wmb();
78185 /* Wait until the lock holder passes the lock down */
78186 while (!ACCESS_ONCE(node->locked))
78187 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
78188 while (!(next = ACCESS_ONCE(node->next)))
78189 arch_mutex_cpu_relax();
78190 }
78191 - ACCESS_ONCE(next->locked) = 1;
78192 + ACCESS_ONCE_RW(next->locked) = 1;
78193 smp_wmb();
78194 }
78195
78196 @@ -341,7 +341,7 @@ slowpath:
78197 spin_lock_mutex(&lock->wait_lock, flags);
78198
78199 debug_mutex_lock_common(lock, &waiter);
78200 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
78201 + debug_mutex_add_waiter(lock, &waiter, task);
78202
78203 /* add waiting tasks to the end of the waitqueue (FIFO): */
78204 list_add_tail(&waiter.list, &lock->wait_list);
78205 @@ -371,8 +371,7 @@ slowpath:
78206 * TASK_UNINTERRUPTIBLE case.)
78207 */
78208 if (unlikely(signal_pending_state(state, task))) {
78209 - mutex_remove_waiter(lock, &waiter,
78210 - task_thread_info(task));
78211 + mutex_remove_waiter(lock, &waiter, task);
78212 mutex_release(&lock->dep_map, 1, ip);
78213 spin_unlock_mutex(&lock->wait_lock, flags);
78214
78215 @@ -391,7 +390,7 @@ slowpath:
78216 done:
78217 lock_acquired(&lock->dep_map, ip);
78218 /* got the lock - rejoice! */
78219 - mutex_remove_waiter(lock, &waiter, current_thread_info());
78220 + mutex_remove_waiter(lock, &waiter, task);
78221 mutex_set_owner(lock);
78222
78223 /* set it to 0 if there are no waiters left: */
78224 diff --git a/kernel/notifier.c b/kernel/notifier.c
78225 index 2d5cc4c..d9ea600 100644
78226 --- a/kernel/notifier.c
78227 +++ b/kernel/notifier.c
78228 @@ -5,6 +5,7 @@
78229 #include <linux/rcupdate.h>
78230 #include <linux/vmalloc.h>
78231 #include <linux/reboot.h>
78232 +#include <linux/mm.h>
78233
78234 /*
78235 * Notifier list for kernel code which wants to be called
78236 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
78237 while ((*nl) != NULL) {
78238 if (n->priority > (*nl)->priority)
78239 break;
78240 - nl = &((*nl)->next);
78241 + nl = (struct notifier_block **)&((*nl)->next);
78242 }
78243 - n->next = *nl;
78244 + pax_open_kernel();
78245 + *(const void **)&n->next = *nl;
78246 rcu_assign_pointer(*nl, n);
78247 + pax_close_kernel();
78248 return 0;
78249 }
78250
78251 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
78252 return 0;
78253 if (n->priority > (*nl)->priority)
78254 break;
78255 - nl = &((*nl)->next);
78256 + nl = (struct notifier_block **)&((*nl)->next);
78257 }
78258 - n->next = *nl;
78259 + pax_open_kernel();
78260 + *(const void **)&n->next = *nl;
78261 rcu_assign_pointer(*nl, n);
78262 + pax_close_kernel();
78263 return 0;
78264 }
78265
78266 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
78267 {
78268 while ((*nl) != NULL) {
78269 if ((*nl) == n) {
78270 + pax_open_kernel();
78271 rcu_assign_pointer(*nl, n->next);
78272 + pax_close_kernel();
78273 return 0;
78274 }
78275 - nl = &((*nl)->next);
78276 + nl = (struct notifier_block **)&((*nl)->next);
78277 }
78278 return -ENOENT;
78279 }
78280 diff --git a/kernel/panic.c b/kernel/panic.c
78281 index 167ec09..0dda5f9 100644
78282 --- a/kernel/panic.c
78283 +++ b/kernel/panic.c
78284 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
78285 unsigned taint, struct slowpath_args *args)
78286 {
78287 printk(KERN_WARNING "------------[ cut here ]------------\n");
78288 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
78289 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
78290
78291 if (args)
78292 vprintk(args->fmt, args->args);
78293 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
78294 */
78295 void __stack_chk_fail(void)
78296 {
78297 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
78298 + dump_stack();
78299 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
78300 __builtin_return_address(0));
78301 }
78302 EXPORT_SYMBOL(__stack_chk_fail);
78303 diff --git a/kernel/pid.c b/kernel/pid.c
78304 index 0db3e79..95b9dc2 100644
78305 --- a/kernel/pid.c
78306 +++ b/kernel/pid.c
78307 @@ -33,6 +33,7 @@
78308 #include <linux/rculist.h>
78309 #include <linux/bootmem.h>
78310 #include <linux/hash.h>
78311 +#include <linux/security.h>
78312 #include <linux/pid_namespace.h>
78313 #include <linux/init_task.h>
78314 #include <linux/syscalls.h>
78315 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
78316
78317 int pid_max = PID_MAX_DEFAULT;
78318
78319 -#define RESERVED_PIDS 300
78320 +#define RESERVED_PIDS 500
78321
78322 int pid_max_min = RESERVED_PIDS + 1;
78323 int pid_max_max = PID_MAX_LIMIT;
78324 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
78325 */
78326 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
78327 {
78328 + struct task_struct *task;
78329 +
78330 rcu_lockdep_assert(rcu_read_lock_held(),
78331 "find_task_by_pid_ns() needs rcu_read_lock()"
78332 " protection");
78333 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
78334 +
78335 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
78336 +
78337 + if (gr_pid_is_chrooted(task))
78338 + return NULL;
78339 +
78340 + return task;
78341 }
78342
78343 struct task_struct *find_task_by_vpid(pid_t vnr)
78344 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
78345 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
78346 }
78347
78348 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
78349 +{
78350 + rcu_lockdep_assert(rcu_read_lock_held(),
78351 + "find_task_by_pid_ns() needs rcu_read_lock()"
78352 + " protection");
78353 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
78354 +}
78355 +
78356 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
78357 {
78358 struct pid *pid;
78359 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
78360 index 6917e8e..9909aeb 100644
78361 --- a/kernel/pid_namespace.c
78362 +++ b/kernel/pid_namespace.c
78363 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
78364 void __user *buffer, size_t *lenp, loff_t *ppos)
78365 {
78366 struct pid_namespace *pid_ns = task_active_pid_ns(current);
78367 - struct ctl_table tmp = *table;
78368 + ctl_table_no_const tmp = *table;
78369
78370 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
78371 return -EPERM;
78372 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
78373 index 42670e9..8719c2f 100644
78374 --- a/kernel/posix-cpu-timers.c
78375 +++ b/kernel/posix-cpu-timers.c
78376 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
78377
78378 static __init int init_posix_cpu_timers(void)
78379 {
78380 - struct k_clock process = {
78381 + static struct k_clock process = {
78382 .clock_getres = process_cpu_clock_getres,
78383 .clock_get = process_cpu_clock_get,
78384 .timer_create = process_cpu_timer_create,
78385 .nsleep = process_cpu_nsleep,
78386 .nsleep_restart = process_cpu_nsleep_restart,
78387 };
78388 - struct k_clock thread = {
78389 + static struct k_clock thread = {
78390 .clock_getres = thread_cpu_clock_getres,
78391 .clock_get = thread_cpu_clock_get,
78392 .timer_create = thread_cpu_timer_create,
78393 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
78394 index 424c2d4..a9194f7 100644
78395 --- a/kernel/posix-timers.c
78396 +++ b/kernel/posix-timers.c
78397 @@ -43,6 +43,7 @@
78398 #include <linux/hash.h>
78399 #include <linux/posix-clock.h>
78400 #include <linux/posix-timers.h>
78401 +#include <linux/grsecurity.h>
78402 #include <linux/syscalls.h>
78403 #include <linux/wait.h>
78404 #include <linux/workqueue.h>
78405 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
78406 * which we beg off on and pass to do_sys_settimeofday().
78407 */
78408
78409 -static struct k_clock posix_clocks[MAX_CLOCKS];
78410 +static struct k_clock *posix_clocks[MAX_CLOCKS];
78411
78412 /*
78413 * These ones are defined below.
78414 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
78415 */
78416 static __init int init_posix_timers(void)
78417 {
78418 - struct k_clock clock_realtime = {
78419 + static struct k_clock clock_realtime = {
78420 .clock_getres = hrtimer_get_res,
78421 .clock_get = posix_clock_realtime_get,
78422 .clock_set = posix_clock_realtime_set,
78423 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
78424 .timer_get = common_timer_get,
78425 .timer_del = common_timer_del,
78426 };
78427 - struct k_clock clock_monotonic = {
78428 + static struct k_clock clock_monotonic = {
78429 .clock_getres = hrtimer_get_res,
78430 .clock_get = posix_ktime_get_ts,
78431 .nsleep = common_nsleep,
78432 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
78433 .timer_get = common_timer_get,
78434 .timer_del = common_timer_del,
78435 };
78436 - struct k_clock clock_monotonic_raw = {
78437 + static struct k_clock clock_monotonic_raw = {
78438 .clock_getres = hrtimer_get_res,
78439 .clock_get = posix_get_monotonic_raw,
78440 };
78441 - struct k_clock clock_realtime_coarse = {
78442 + static struct k_clock clock_realtime_coarse = {
78443 .clock_getres = posix_get_coarse_res,
78444 .clock_get = posix_get_realtime_coarse,
78445 };
78446 - struct k_clock clock_monotonic_coarse = {
78447 + static struct k_clock clock_monotonic_coarse = {
78448 .clock_getres = posix_get_coarse_res,
78449 .clock_get = posix_get_monotonic_coarse,
78450 };
78451 - struct k_clock clock_tai = {
78452 + static struct k_clock clock_tai = {
78453 .clock_getres = hrtimer_get_res,
78454 .clock_get = posix_get_tai,
78455 .nsleep = common_nsleep,
78456 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
78457 .timer_get = common_timer_get,
78458 .timer_del = common_timer_del,
78459 };
78460 - struct k_clock clock_boottime = {
78461 + static struct k_clock clock_boottime = {
78462 .clock_getres = hrtimer_get_res,
78463 .clock_get = posix_get_boottime,
78464 .nsleep = common_nsleep,
78465 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
78466 return;
78467 }
78468
78469 - posix_clocks[clock_id] = *new_clock;
78470 + posix_clocks[clock_id] = new_clock;
78471 }
78472 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
78473
78474 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
78475 return (id & CLOCKFD_MASK) == CLOCKFD ?
78476 &clock_posix_dynamic : &clock_posix_cpu;
78477
78478 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
78479 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
78480 return NULL;
78481 - return &posix_clocks[id];
78482 + return posix_clocks[id];
78483 }
78484
78485 static int common_timer_create(struct k_itimer *new_timer)
78486 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
78487 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
78488 return -EFAULT;
78489
78490 + /* only the CLOCK_REALTIME clock can be set, all other clocks
78491 + have their clock_set fptr set to a nosettime dummy function
78492 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
78493 + call common_clock_set, which calls do_sys_settimeofday, which
78494 + we hook
78495 + */
78496 +
78497 return kc->clock_set(which_clock, &new_tp);
78498 }
78499
78500 diff --git a/kernel/power/process.c b/kernel/power/process.c
78501 index 98088e0..aaf95c0 100644
78502 --- a/kernel/power/process.c
78503 +++ b/kernel/power/process.c
78504 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
78505 u64 elapsed_csecs64;
78506 unsigned int elapsed_csecs;
78507 bool wakeup = false;
78508 + bool timedout = false;
78509
78510 do_gettimeofday(&start);
78511
78512 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
78513
78514 while (true) {
78515 todo = 0;
78516 + if (time_after(jiffies, end_time))
78517 + timedout = true;
78518 read_lock(&tasklist_lock);
78519 do_each_thread(g, p) {
78520 if (p == current || !freeze_task(p))
78521 continue;
78522
78523 - if (!freezer_should_skip(p))
78524 + if (!freezer_should_skip(p)) {
78525 todo++;
78526 + if (timedout) {
78527 + printk(KERN_ERR "Task refusing to freeze:\n");
78528 + sched_show_task(p);
78529 + }
78530 + }
78531 } while_each_thread(g, p);
78532 read_unlock(&tasklist_lock);
78533
78534 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
78535 todo += wq_busy;
78536 }
78537
78538 - if (!todo || time_after(jiffies, end_time))
78539 + if (!todo || timedout)
78540 break;
78541
78542 if (pm_wakeup_pending()) {
78543 diff --git a/kernel/printk.c b/kernel/printk.c
78544 index d37d45c..ab918b3 100644
78545 --- a/kernel/printk.c
78546 +++ b/kernel/printk.c
78547 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
78548 if (from_file && type != SYSLOG_ACTION_OPEN)
78549 return 0;
78550
78551 +#ifdef CONFIG_GRKERNSEC_DMESG
78552 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
78553 + return -EPERM;
78554 +#endif
78555 +
78556 if (syslog_action_restricted(type)) {
78557 if (capable(CAP_SYSLOG))
78558 return 0;
78559 diff --git a/kernel/profile.c b/kernel/profile.c
78560 index 0bf4007..6234708 100644
78561 --- a/kernel/profile.c
78562 +++ b/kernel/profile.c
78563 @@ -37,7 +37,7 @@ struct profile_hit {
78564 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
78565 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
78566
78567 -static atomic_t *prof_buffer;
78568 +static atomic_unchecked_t *prof_buffer;
78569 static unsigned long prof_len, prof_shift;
78570
78571 int prof_on __read_mostly;
78572 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
78573 hits[i].pc = 0;
78574 continue;
78575 }
78576 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
78577 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
78578 hits[i].hits = hits[i].pc = 0;
78579 }
78580 }
78581 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
78582 * Add the current hit(s) and flush the write-queue out
78583 * to the global buffer:
78584 */
78585 - atomic_add(nr_hits, &prof_buffer[pc]);
78586 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
78587 for (i = 0; i < NR_PROFILE_HIT; ++i) {
78588 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
78589 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
78590 hits[i].pc = hits[i].hits = 0;
78591 }
78592 out:
78593 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
78594 {
78595 unsigned long pc;
78596 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
78597 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
78598 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
78599 }
78600 #endif /* !CONFIG_SMP */
78601
78602 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
78603 return -EFAULT;
78604 buf++; p++; count--; read++;
78605 }
78606 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
78607 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
78608 if (copy_to_user(buf, (void *)pnt, count))
78609 return -EFAULT;
78610 read += count;
78611 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
78612 }
78613 #endif
78614 profile_discard_flip_buffers();
78615 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
78616 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
78617 return count;
78618 }
78619
78620 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
78621 index 335a7ae..3bbbceb 100644
78622 --- a/kernel/ptrace.c
78623 +++ b/kernel/ptrace.c
78624 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
78625 if (seize)
78626 flags |= PT_SEIZED;
78627 rcu_read_lock();
78628 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
78629 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
78630 flags |= PT_PTRACE_CAP;
78631 rcu_read_unlock();
78632 task->ptrace = flags;
78633 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
78634 break;
78635 return -EIO;
78636 }
78637 - if (copy_to_user(dst, buf, retval))
78638 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
78639 return -EFAULT;
78640 copied += retval;
78641 src += retval;
78642 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
78643 bool seized = child->ptrace & PT_SEIZED;
78644 int ret = -EIO;
78645 siginfo_t siginfo, *si;
78646 - void __user *datavp = (void __user *) data;
78647 + void __user *datavp = (__force void __user *) data;
78648 unsigned long __user *datalp = datavp;
78649 unsigned long flags;
78650
78651 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
78652 goto out;
78653 }
78654
78655 + if (gr_handle_ptrace(child, request)) {
78656 + ret = -EPERM;
78657 + goto out_put_task_struct;
78658 + }
78659 +
78660 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
78661 ret = ptrace_attach(child, request, addr, data);
78662 /*
78663 * Some architectures need to do book-keeping after
78664 * a ptrace attach.
78665 */
78666 - if (!ret)
78667 + if (!ret) {
78668 arch_ptrace_attach(child);
78669 + gr_audit_ptrace(child);
78670 + }
78671 goto out_put_task_struct;
78672 }
78673
78674 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
78675 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
78676 if (copied != sizeof(tmp))
78677 return -EIO;
78678 - return put_user(tmp, (unsigned long __user *)data);
78679 + return put_user(tmp, (__force unsigned long __user *)data);
78680 }
78681
78682 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
78683 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
78684 }
78685
78686 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
78687 - compat_long_t addr, compat_long_t data)
78688 + compat_ulong_t addr, compat_ulong_t data)
78689 {
78690 struct task_struct *child;
78691 long ret;
78692 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
78693 goto out;
78694 }
78695
78696 + if (gr_handle_ptrace(child, request)) {
78697 + ret = -EPERM;
78698 + goto out_put_task_struct;
78699 + }
78700 +
78701 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
78702 ret = ptrace_attach(child, request, addr, data);
78703 /*
78704 * Some architectures need to do book-keeping after
78705 * a ptrace attach.
78706 */
78707 - if (!ret)
78708 + if (!ret) {
78709 arch_ptrace_attach(child);
78710 + gr_audit_ptrace(child);
78711 + }
78712 goto out_put_task_struct;
78713 }
78714
78715 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
78716 index 48ab703..07561d4 100644
78717 --- a/kernel/rcupdate.c
78718 +++ b/kernel/rcupdate.c
78719 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
78720 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
78721 */
78722 if (till_stall_check < 3) {
78723 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
78724 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
78725 till_stall_check = 3;
78726 } else if (till_stall_check > 300) {
78727 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
78728 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
78729 till_stall_check = 300;
78730 }
78731 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
78732 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
78733 index a0714a5..2ab5e34 100644
78734 --- a/kernel/rcutiny.c
78735 +++ b/kernel/rcutiny.c
78736 @@ -46,7 +46,7 @@
78737 struct rcu_ctrlblk;
78738 static void invoke_rcu_callbacks(void);
78739 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
78740 -static void rcu_process_callbacks(struct softirq_action *unused);
78741 +static void rcu_process_callbacks(void);
78742 static void __call_rcu(struct rcu_head *head,
78743 void (*func)(struct rcu_head *rcu),
78744 struct rcu_ctrlblk *rcp);
78745 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
78746 rcu_is_callbacks_kthread()));
78747 }
78748
78749 -static void rcu_process_callbacks(struct softirq_action *unused)
78750 +static void rcu_process_callbacks(void)
78751 {
78752 __rcu_process_callbacks(&rcu_sched_ctrlblk);
78753 __rcu_process_callbacks(&rcu_bh_ctrlblk);
78754 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
78755 index 8a23300..4255818 100644
78756 --- a/kernel/rcutiny_plugin.h
78757 +++ b/kernel/rcutiny_plugin.h
78758 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
78759 have_rcu_kthread_work = morework;
78760 local_irq_restore(flags);
78761 if (work)
78762 - rcu_process_callbacks(NULL);
78763 + rcu_process_callbacks();
78764 schedule_timeout_interruptible(1); /* Leave CPU for others. */
78765 }
78766
78767 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
78768 index e1f3a8c..42c94a2 100644
78769 --- a/kernel/rcutorture.c
78770 +++ b/kernel/rcutorture.c
78771 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
78772 { 0 };
78773 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
78774 { 0 };
78775 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78776 -static atomic_t n_rcu_torture_alloc;
78777 -static atomic_t n_rcu_torture_alloc_fail;
78778 -static atomic_t n_rcu_torture_free;
78779 -static atomic_t n_rcu_torture_mberror;
78780 -static atomic_t n_rcu_torture_error;
78781 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78782 +static atomic_unchecked_t n_rcu_torture_alloc;
78783 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
78784 +static atomic_unchecked_t n_rcu_torture_free;
78785 +static atomic_unchecked_t n_rcu_torture_mberror;
78786 +static atomic_unchecked_t n_rcu_torture_error;
78787 static long n_rcu_torture_barrier_error;
78788 static long n_rcu_torture_boost_ktrerror;
78789 static long n_rcu_torture_boost_rterror;
78790 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
78791
78792 spin_lock_bh(&rcu_torture_lock);
78793 if (list_empty(&rcu_torture_freelist)) {
78794 - atomic_inc(&n_rcu_torture_alloc_fail);
78795 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
78796 spin_unlock_bh(&rcu_torture_lock);
78797 return NULL;
78798 }
78799 - atomic_inc(&n_rcu_torture_alloc);
78800 + atomic_inc_unchecked(&n_rcu_torture_alloc);
78801 p = rcu_torture_freelist.next;
78802 list_del_init(p);
78803 spin_unlock_bh(&rcu_torture_lock);
78804 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
78805 static void
78806 rcu_torture_free(struct rcu_torture *p)
78807 {
78808 - atomic_inc(&n_rcu_torture_free);
78809 + atomic_inc_unchecked(&n_rcu_torture_free);
78810 spin_lock_bh(&rcu_torture_lock);
78811 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
78812 spin_unlock_bh(&rcu_torture_lock);
78813 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
78814 i = rp->rtort_pipe_count;
78815 if (i > RCU_TORTURE_PIPE_LEN)
78816 i = RCU_TORTURE_PIPE_LEN;
78817 - atomic_inc(&rcu_torture_wcount[i]);
78818 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78819 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78820 rp->rtort_mbtest = 0;
78821 rcu_torture_free(rp);
78822 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
78823 i = rp->rtort_pipe_count;
78824 if (i > RCU_TORTURE_PIPE_LEN)
78825 i = RCU_TORTURE_PIPE_LEN;
78826 - atomic_inc(&rcu_torture_wcount[i]);
78827 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78828 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78829 rp->rtort_mbtest = 0;
78830 list_del(&rp->rtort_free);
78831 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
78832 i = old_rp->rtort_pipe_count;
78833 if (i > RCU_TORTURE_PIPE_LEN)
78834 i = RCU_TORTURE_PIPE_LEN;
78835 - atomic_inc(&rcu_torture_wcount[i]);
78836 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78837 old_rp->rtort_pipe_count++;
78838 cur_ops->deferred_free(old_rp);
78839 }
78840 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
78841 return;
78842 }
78843 if (p->rtort_mbtest == 0)
78844 - atomic_inc(&n_rcu_torture_mberror);
78845 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78846 spin_lock(&rand_lock);
78847 cur_ops->read_delay(&rand);
78848 n_rcu_torture_timers++;
78849 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
78850 continue;
78851 }
78852 if (p->rtort_mbtest == 0)
78853 - atomic_inc(&n_rcu_torture_mberror);
78854 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78855 cur_ops->read_delay(&rand);
78856 preempt_disable();
78857 pipe_count = p->rtort_pipe_count;
78858 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
78859 rcu_torture_current,
78860 rcu_torture_current_version,
78861 list_empty(&rcu_torture_freelist),
78862 - atomic_read(&n_rcu_torture_alloc),
78863 - atomic_read(&n_rcu_torture_alloc_fail),
78864 - atomic_read(&n_rcu_torture_free));
78865 + atomic_read_unchecked(&n_rcu_torture_alloc),
78866 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
78867 + atomic_read_unchecked(&n_rcu_torture_free));
78868 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
78869 - atomic_read(&n_rcu_torture_mberror),
78870 + atomic_read_unchecked(&n_rcu_torture_mberror),
78871 n_rcu_torture_boost_ktrerror,
78872 n_rcu_torture_boost_rterror);
78873 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
78874 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
78875 n_barrier_attempts,
78876 n_rcu_torture_barrier_error);
78877 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
78878 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
78879 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
78880 n_rcu_torture_barrier_error != 0 ||
78881 n_rcu_torture_boost_ktrerror != 0 ||
78882 n_rcu_torture_boost_rterror != 0 ||
78883 n_rcu_torture_boost_failure != 0 ||
78884 i > 1) {
78885 cnt += sprintf(&page[cnt], "!!! ");
78886 - atomic_inc(&n_rcu_torture_error);
78887 + atomic_inc_unchecked(&n_rcu_torture_error);
78888 WARN_ON_ONCE(1);
78889 }
78890 cnt += sprintf(&page[cnt], "Reader Pipe: ");
78891 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
78892 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
78893 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78894 cnt += sprintf(&page[cnt], " %d",
78895 - atomic_read(&rcu_torture_wcount[i]));
78896 + atomic_read_unchecked(&rcu_torture_wcount[i]));
78897 }
78898 cnt += sprintf(&page[cnt], "\n");
78899 if (cur_ops->stats)
78900 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
78901
78902 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
78903
78904 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78905 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78906 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
78907 else if (n_online_successes != n_online_attempts ||
78908 n_offline_successes != n_offline_attempts)
78909 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
78910
78911 rcu_torture_current = NULL;
78912 rcu_torture_current_version = 0;
78913 - atomic_set(&n_rcu_torture_alloc, 0);
78914 - atomic_set(&n_rcu_torture_alloc_fail, 0);
78915 - atomic_set(&n_rcu_torture_free, 0);
78916 - atomic_set(&n_rcu_torture_mberror, 0);
78917 - atomic_set(&n_rcu_torture_error, 0);
78918 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
78919 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
78920 + atomic_set_unchecked(&n_rcu_torture_free, 0);
78921 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
78922 + atomic_set_unchecked(&n_rcu_torture_error, 0);
78923 n_rcu_torture_barrier_error = 0;
78924 n_rcu_torture_boost_ktrerror = 0;
78925 n_rcu_torture_boost_rterror = 0;
78926 n_rcu_torture_boost_failure = 0;
78927 n_rcu_torture_boosts = 0;
78928 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
78929 - atomic_set(&rcu_torture_wcount[i], 0);
78930 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
78931 for_each_possible_cpu(cpu) {
78932 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78933 per_cpu(rcu_torture_count, cpu)[i] = 0;
78934 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
78935 index 3538001..e379e0b 100644
78936 --- a/kernel/rcutree.c
78937 +++ b/kernel/rcutree.c
78938 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
78939 rcu_prepare_for_idle(smp_processor_id());
78940 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78941 smp_mb__before_atomic_inc(); /* See above. */
78942 - atomic_inc(&rdtp->dynticks);
78943 + atomic_inc_unchecked(&rdtp->dynticks);
78944 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
78945 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78946 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78947
78948 /*
78949 * It is illegal to enter an extended quiescent state while
78950 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
78951 int user)
78952 {
78953 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
78954 - atomic_inc(&rdtp->dynticks);
78955 + atomic_inc_unchecked(&rdtp->dynticks);
78956 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78957 smp_mb__after_atomic_inc(); /* See above. */
78958 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78959 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78960 rcu_cleanup_after_idle(smp_processor_id());
78961 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
78962 if (!user && !is_idle_task(current)) {
78963 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
78964 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
78965
78966 if (rdtp->dynticks_nmi_nesting == 0 &&
78967 - (atomic_read(&rdtp->dynticks) & 0x1))
78968 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
78969 return;
78970 rdtp->dynticks_nmi_nesting++;
78971 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
78972 - atomic_inc(&rdtp->dynticks);
78973 + atomic_inc_unchecked(&rdtp->dynticks);
78974 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78975 smp_mb__after_atomic_inc(); /* See above. */
78976 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78977 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78978 }
78979
78980 /**
78981 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
78982 return;
78983 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78984 smp_mb__before_atomic_inc(); /* See above. */
78985 - atomic_inc(&rdtp->dynticks);
78986 + atomic_inc_unchecked(&rdtp->dynticks);
78987 smp_mb__after_atomic_inc(); /* Force delay to next write. */
78988 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78989 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78990 }
78991
78992 /**
78993 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
78994 int ret;
78995
78996 preempt_disable();
78997 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78998 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78999 preempt_enable();
79000 return ret;
79001 }
79002 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
79003 */
79004 static int dyntick_save_progress_counter(struct rcu_data *rdp)
79005 {
79006 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
79007 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
79008 return (rdp->dynticks_snap & 0x1) == 0;
79009 }
79010
79011 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
79012 unsigned int curr;
79013 unsigned int snap;
79014
79015 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
79016 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
79017 snap = (unsigned int)rdp->dynticks_snap;
79018
79019 /*
79020 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
79021 rdp = this_cpu_ptr(rsp->rda);
79022 rcu_preempt_check_blocked_tasks(rnp);
79023 rnp->qsmask = rnp->qsmaskinit;
79024 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
79025 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
79026 WARN_ON_ONCE(rnp->completed != rsp->completed);
79027 - ACCESS_ONCE(rnp->completed) = rsp->completed;
79028 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
79029 if (rnp == rdp->mynode)
79030 rcu_start_gp_per_cpu(rsp, rnp, rdp);
79031 rcu_preempt_boost_start_gp(rnp);
79032 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
79033 */
79034 rcu_for_each_node_breadth_first(rsp, rnp) {
79035 raw_spin_lock_irq(&rnp->lock);
79036 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
79037 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
79038 rdp = this_cpu_ptr(rsp->rda);
79039 if (rnp == rdp->mynode)
79040 __rcu_process_gp_end(rsp, rnp, rdp);
79041 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
79042 rsp->qlen += rdp->qlen;
79043 rdp->n_cbs_orphaned += rdp->qlen;
79044 rdp->qlen_lazy = 0;
79045 - ACCESS_ONCE(rdp->qlen) = 0;
79046 + ACCESS_ONCE_RW(rdp->qlen) = 0;
79047 }
79048
79049 /*
79050 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
79051 }
79052 smp_mb(); /* List handling before counting for rcu_barrier(). */
79053 rdp->qlen_lazy -= count_lazy;
79054 - ACCESS_ONCE(rdp->qlen) -= count;
79055 + ACCESS_ONCE_RW(rdp->qlen) -= count;
79056 rdp->n_cbs_invoked += count;
79057
79058 /* Reinstate batch limit if we have worked down the excess. */
79059 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
79060 /*
79061 * Do RCU core processing for the current CPU.
79062 */
79063 -static void rcu_process_callbacks(struct softirq_action *unused)
79064 +static void rcu_process_callbacks(void)
79065 {
79066 struct rcu_state *rsp;
79067
79068 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
79069 local_irq_restore(flags);
79070 return;
79071 }
79072 - ACCESS_ONCE(rdp->qlen)++;
79073 + ACCESS_ONCE_RW(rdp->qlen)++;
79074 if (lazy)
79075 rdp->qlen_lazy++;
79076 else
79077 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
79078 * counter wrap on a 32-bit system. Quite a few more CPUs would of
79079 * course be required on a 64-bit system.
79080 */
79081 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
79082 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
79083 (ulong)atomic_long_read(&rsp->expedited_done) +
79084 ULONG_MAX / 8)) {
79085 synchronize_sched();
79086 - atomic_long_inc(&rsp->expedited_wrap);
79087 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
79088 return;
79089 }
79090
79091 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
79092 * Take a ticket. Note that atomic_inc_return() implies a
79093 * full memory barrier.
79094 */
79095 - snap = atomic_long_inc_return(&rsp->expedited_start);
79096 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
79097 firstsnap = snap;
79098 get_online_cpus();
79099 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
79100 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
79101 synchronize_sched_expedited_cpu_stop,
79102 NULL) == -EAGAIN) {
79103 put_online_cpus();
79104 - atomic_long_inc(&rsp->expedited_tryfail);
79105 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
79106
79107 /* Check to see if someone else did our work for us. */
79108 s = atomic_long_read(&rsp->expedited_done);
79109 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
79110 /* ensure test happens before caller kfree */
79111 smp_mb__before_atomic_inc(); /* ^^^ */
79112 - atomic_long_inc(&rsp->expedited_workdone1);
79113 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
79114 return;
79115 }
79116
79117 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
79118 udelay(trycount * num_online_cpus());
79119 } else {
79120 wait_rcu_gp(call_rcu_sched);
79121 - atomic_long_inc(&rsp->expedited_normal);
79122 + atomic_long_inc_unchecked(&rsp->expedited_normal);
79123 return;
79124 }
79125
79126 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
79127 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
79128 /* ensure test happens before caller kfree */
79129 smp_mb__before_atomic_inc(); /* ^^^ */
79130 - atomic_long_inc(&rsp->expedited_workdone2);
79131 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
79132 return;
79133 }
79134
79135 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
79136 * period works for us.
79137 */
79138 get_online_cpus();
79139 - snap = atomic_long_read(&rsp->expedited_start);
79140 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
79141 smp_mb(); /* ensure read is before try_stop_cpus(). */
79142 }
79143 - atomic_long_inc(&rsp->expedited_stoppedcpus);
79144 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
79145
79146 /*
79147 * Everyone up to our most recent fetch is covered by our grace
79148 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
79149 * than we did already did their update.
79150 */
79151 do {
79152 - atomic_long_inc(&rsp->expedited_done_tries);
79153 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
79154 s = atomic_long_read(&rsp->expedited_done);
79155 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
79156 /* ensure test happens before caller kfree */
79157 smp_mb__before_atomic_inc(); /* ^^^ */
79158 - atomic_long_inc(&rsp->expedited_done_lost);
79159 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
79160 break;
79161 }
79162 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
79163 - atomic_long_inc(&rsp->expedited_done_exit);
79164 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
79165
79166 put_online_cpus();
79167 }
79168 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
79169 * ACCESS_ONCE() to prevent the compiler from speculating
79170 * the increment to precede the early-exit check.
79171 */
79172 - ACCESS_ONCE(rsp->n_barrier_done)++;
79173 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
79174 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
79175 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
79176 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
79177 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
79178
79179 /* Increment ->n_barrier_done to prevent duplicate work. */
79180 smp_mb(); /* Keep increment after above mechanism. */
79181 - ACCESS_ONCE(rsp->n_barrier_done)++;
79182 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
79183 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
79184 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
79185 smp_mb(); /* Keep increment before caller's subsequent code. */
79186 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
79187 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
79188 init_callback_list(rdp);
79189 rdp->qlen_lazy = 0;
79190 - ACCESS_ONCE(rdp->qlen) = 0;
79191 + ACCESS_ONCE_RW(rdp->qlen) = 0;
79192 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
79193 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
79194 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
79195 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
79196 rdp->cpu = cpu;
79197 rdp->rsp = rsp;
79198 rcu_boot_init_nocb_percpu_data(rdp);
79199 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
79200 rdp->blimit = blimit;
79201 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
79202 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
79203 - atomic_set(&rdp->dynticks->dynticks,
79204 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
79205 + atomic_set_unchecked(&rdp->dynticks->dynticks,
79206 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
79207 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
79208
79209 /* Add CPU to rcu_node bitmasks. */
79210 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
79211 struct task_struct *t;
79212
79213 for_each_rcu_flavor(rsp) {
79214 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
79215 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
79216 BUG_ON(IS_ERR(t));
79217 rnp = rcu_get_root(rsp);
79218 raw_spin_lock_irqsave(&rnp->lock, flags);
79219 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
79220 index 4df5034..5ee93f2 100644
79221 --- a/kernel/rcutree.h
79222 +++ b/kernel/rcutree.h
79223 @@ -87,7 +87,7 @@ struct rcu_dynticks {
79224 long long dynticks_nesting; /* Track irq/process nesting level. */
79225 /* Process level is worth LLONG_MAX/2. */
79226 int dynticks_nmi_nesting; /* Track NMI nesting level. */
79227 - atomic_t dynticks; /* Even value for idle, else odd. */
79228 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
79229 #ifdef CONFIG_RCU_FAST_NO_HZ
79230 bool all_lazy; /* Are all CPU's CBs lazy? */
79231 unsigned long nonlazy_posted;
79232 @@ -414,17 +414,17 @@ struct rcu_state {
79233 /* _rcu_barrier(). */
79234 /* End of fields guarded by barrier_mutex. */
79235
79236 - atomic_long_t expedited_start; /* Starting ticket. */
79237 - atomic_long_t expedited_done; /* Done ticket. */
79238 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
79239 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
79240 - atomic_long_t expedited_workdone1; /* # done by others #1. */
79241 - atomic_long_t expedited_workdone2; /* # done by others #2. */
79242 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
79243 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
79244 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
79245 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
79246 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
79247 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
79248 + atomic_long_t expedited_done; /* Done ticket. */
79249 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
79250 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
79251 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
79252 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
79253 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
79254 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
79255 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
79256 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
79257 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
79258
79259 unsigned long jiffies_force_qs; /* Time at which to invoke */
79260 /* force_quiescent_state(). */
79261 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
79262 index 3db5a37..b395fb35 100644
79263 --- a/kernel/rcutree_plugin.h
79264 +++ b/kernel/rcutree_plugin.h
79265 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
79266
79267 /* Clean up and exit. */
79268 smp_mb(); /* ensure expedited GP seen before counter increment. */
79269 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
79270 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
79271 unlock_mb_ret:
79272 mutex_unlock(&sync_rcu_preempt_exp_mutex);
79273 mb_ret:
79274 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
79275 free_cpumask_var(cm);
79276 }
79277
79278 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
79279 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
79280 .store = &rcu_cpu_kthread_task,
79281 .thread_should_run = rcu_cpu_kthread_should_run,
79282 .thread_fn = rcu_cpu_kthread,
79283 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
79284 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
79285 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
79286 cpu, ticks_value, ticks_title,
79287 - atomic_read(&rdtp->dynticks) & 0xfff,
79288 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
79289 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
79290 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
79291 fast_no_hz);
79292 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
79293
79294 /* Enqueue the callback on the nocb list and update counts. */
79295 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
79296 - ACCESS_ONCE(*old_rhpp) = rhp;
79297 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
79298 atomic_long_add(rhcount, &rdp->nocb_q_count);
79299 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
79300
79301 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
79302 * Extract queued callbacks, update counts, and wait
79303 * for a grace period to elapse.
79304 */
79305 - ACCESS_ONCE(rdp->nocb_head) = NULL;
79306 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
79307 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
79308 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
79309 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
79310 - ACCESS_ONCE(rdp->nocb_p_count) += c;
79311 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
79312 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
79313 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
79314 rcu_nocb_wait_gp(rdp);
79315
79316 /* Each pass through the following loop invokes a callback. */
79317 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
79318 list = next;
79319 }
79320 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
79321 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
79322 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
79323 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
79324 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
79325 rdp->n_nocbs_invoked += c;
79326 }
79327 return 0;
79328 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
79329 t = kthread_run(rcu_nocb_kthread, rdp,
79330 "rcuo%c/%d", rsp->abbr, cpu);
79331 BUG_ON(IS_ERR(t));
79332 - ACCESS_ONCE(rdp->nocb_kthread) = t;
79333 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
79334 }
79335 }
79336
79337 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
79338 index cf6c174..a8f4b50 100644
79339 --- a/kernel/rcutree_trace.c
79340 +++ b/kernel/rcutree_trace.c
79341 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
79342 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
79343 rdp->passed_quiesce, rdp->qs_pending);
79344 seq_printf(m, " dt=%d/%llx/%d df=%lu",
79345 - atomic_read(&rdp->dynticks->dynticks),
79346 + atomic_read_unchecked(&rdp->dynticks->dynticks),
79347 rdp->dynticks->dynticks_nesting,
79348 rdp->dynticks->dynticks_nmi_nesting,
79349 rdp->dynticks_fqs);
79350 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
79351 struct rcu_state *rsp = (struct rcu_state *)m->private;
79352
79353 seq_printf(m, "s=%lu d=%lu w=%lu tf=%lu wd1=%lu wd2=%lu n=%lu sc=%lu dt=%lu dl=%lu dx=%lu\n",
79354 - atomic_long_read(&rsp->expedited_start),
79355 + atomic_long_read_unchecked(&rsp->expedited_start),
79356 atomic_long_read(&rsp->expedited_done),
79357 - atomic_long_read(&rsp->expedited_wrap),
79358 - atomic_long_read(&rsp->expedited_tryfail),
79359 - atomic_long_read(&rsp->expedited_workdone1),
79360 - atomic_long_read(&rsp->expedited_workdone2),
79361 - atomic_long_read(&rsp->expedited_normal),
79362 - atomic_long_read(&rsp->expedited_stoppedcpus),
79363 - atomic_long_read(&rsp->expedited_done_tries),
79364 - atomic_long_read(&rsp->expedited_done_lost),
79365 - atomic_long_read(&rsp->expedited_done_exit));
79366 + atomic_long_read_unchecked(&rsp->expedited_wrap),
79367 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
79368 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
79369 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
79370 + atomic_long_read_unchecked(&rsp->expedited_normal),
79371 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
79372 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
79373 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
79374 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
79375 return 0;
79376 }
79377
79378 diff --git a/kernel/resource.c b/kernel/resource.c
79379 index d738698..5f8e60a 100644
79380 --- a/kernel/resource.c
79381 +++ b/kernel/resource.c
79382 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
79383
79384 static int __init ioresources_init(void)
79385 {
79386 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79387 +#ifdef CONFIG_GRKERNSEC_PROC_USER
79388 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
79389 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
79390 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79391 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
79392 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
79393 +#endif
79394 +#else
79395 proc_create("ioports", 0, NULL, &proc_ioports_operations);
79396 proc_create("iomem", 0, NULL, &proc_iomem_operations);
79397 +#endif
79398 return 0;
79399 }
79400 __initcall(ioresources_init);
79401 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
79402 index 1d96dd0..994ff19 100644
79403 --- a/kernel/rtmutex-tester.c
79404 +++ b/kernel/rtmutex-tester.c
79405 @@ -22,7 +22,7 @@
79406 #define MAX_RT_TEST_MUTEXES 8
79407
79408 static spinlock_t rttest_lock;
79409 -static atomic_t rttest_event;
79410 +static atomic_unchecked_t rttest_event;
79411
79412 struct test_thread_data {
79413 int opcode;
79414 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79415
79416 case RTTEST_LOCKCONT:
79417 td->mutexes[td->opdata] = 1;
79418 - td->event = atomic_add_return(1, &rttest_event);
79419 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79420 return 0;
79421
79422 case RTTEST_RESET:
79423 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79424 return 0;
79425
79426 case RTTEST_RESETEVENT:
79427 - atomic_set(&rttest_event, 0);
79428 + atomic_set_unchecked(&rttest_event, 0);
79429 return 0;
79430
79431 default:
79432 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79433 return ret;
79434
79435 td->mutexes[id] = 1;
79436 - td->event = atomic_add_return(1, &rttest_event);
79437 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79438 rt_mutex_lock(&mutexes[id]);
79439 - td->event = atomic_add_return(1, &rttest_event);
79440 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79441 td->mutexes[id] = 4;
79442 return 0;
79443
79444 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79445 return ret;
79446
79447 td->mutexes[id] = 1;
79448 - td->event = atomic_add_return(1, &rttest_event);
79449 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79450 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
79451 - td->event = atomic_add_return(1, &rttest_event);
79452 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79453 td->mutexes[id] = ret ? 0 : 4;
79454 return ret ? -EINTR : 0;
79455
79456 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79457 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
79458 return ret;
79459
79460 - td->event = atomic_add_return(1, &rttest_event);
79461 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79462 rt_mutex_unlock(&mutexes[id]);
79463 - td->event = atomic_add_return(1, &rttest_event);
79464 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79465 td->mutexes[id] = 0;
79466 return 0;
79467
79468 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
79469 break;
79470
79471 td->mutexes[dat] = 2;
79472 - td->event = atomic_add_return(1, &rttest_event);
79473 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79474 break;
79475
79476 default:
79477 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
79478 return;
79479
79480 td->mutexes[dat] = 3;
79481 - td->event = atomic_add_return(1, &rttest_event);
79482 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79483 break;
79484
79485 case RTTEST_LOCKNOWAIT:
79486 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
79487 return;
79488
79489 td->mutexes[dat] = 1;
79490 - td->event = atomic_add_return(1, &rttest_event);
79491 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79492 return;
79493
79494 default:
79495 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
79496 index 64de5f8..7735e12 100644
79497 --- a/kernel/sched/auto_group.c
79498 +++ b/kernel/sched/auto_group.c
79499 @@ -11,7 +11,7 @@
79500
79501 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
79502 static struct autogroup autogroup_default;
79503 -static atomic_t autogroup_seq_nr;
79504 +static atomic_unchecked_t autogroup_seq_nr;
79505
79506 void __init autogroup_init(struct task_struct *init_task)
79507 {
79508 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
79509
79510 kref_init(&ag->kref);
79511 init_rwsem(&ag->lock);
79512 - ag->id = atomic_inc_return(&autogroup_seq_nr);
79513 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
79514 ag->tg = tg;
79515 #ifdef CONFIG_RT_GROUP_SCHED
79516 /*
79517 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
79518 index e8b3350..d83d44e 100644
79519 --- a/kernel/sched/core.c
79520 +++ b/kernel/sched/core.c
79521 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
79522 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
79523 * positive (at least 1, or number of jiffies left till timeout) if completed.
79524 */
79525 -long __sched
79526 +long __sched __intentional_overflow(-1)
79527 wait_for_completion_interruptible_timeout(struct completion *x,
79528 unsigned long timeout)
79529 {
79530 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
79531 *
79532 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
79533 */
79534 -int __sched wait_for_completion_killable(struct completion *x)
79535 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
79536 {
79537 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
79538 if (t == -ERESTARTSYS)
79539 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
79540 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
79541 * positive (at least 1, or number of jiffies left till timeout) if completed.
79542 */
79543 -long __sched
79544 +long __sched __intentional_overflow(-1)
79545 wait_for_completion_killable_timeout(struct completion *x,
79546 unsigned long timeout)
79547 {
79548 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
79549 /* convert nice value [19,-20] to rlimit style value [1,40] */
79550 int nice_rlim = 20 - nice;
79551
79552 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
79553 +
79554 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
79555 capable(CAP_SYS_NICE));
79556 }
79557 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
79558 if (nice > 19)
79559 nice = 19;
79560
79561 - if (increment < 0 && !can_nice(current, nice))
79562 + if (increment < 0 && (!can_nice(current, nice) ||
79563 + gr_handle_chroot_nice()))
79564 return -EPERM;
79565
79566 retval = security_task_setnice(current, nice);
79567 @@ -3891,6 +3894,7 @@ recheck:
79568 unsigned long rlim_rtprio =
79569 task_rlimit(p, RLIMIT_RTPRIO);
79570
79571 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
79572 /* can't set/change the rt policy */
79573 if (policy != p->policy && !rlim_rtprio)
79574 return -EPERM;
79575 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
79576
79577 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
79578
79579 -static struct ctl_table sd_ctl_dir[] = {
79580 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
79581 {
79582 .procname = "sched_domain",
79583 .mode = 0555,
79584 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
79585 {}
79586 };
79587
79588 -static struct ctl_table *sd_alloc_ctl_entry(int n)
79589 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
79590 {
79591 - struct ctl_table *entry =
79592 + ctl_table_no_const *entry =
79593 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
79594
79595 return entry;
79596 }
79597
79598 -static void sd_free_ctl_entry(struct ctl_table **tablep)
79599 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
79600 {
79601 - struct ctl_table *entry;
79602 + ctl_table_no_const *entry;
79603
79604 /*
79605 * In the intermediate directories, both the child directory and
79606 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
79607 * will always be set. In the lowest directory the names are
79608 * static strings and all have proc handlers.
79609 */
79610 - for (entry = *tablep; entry->mode; entry++) {
79611 - if (entry->child)
79612 - sd_free_ctl_entry(&entry->child);
79613 + for (entry = tablep; entry->mode; entry++) {
79614 + if (entry->child) {
79615 + sd_free_ctl_entry(entry->child);
79616 + pax_open_kernel();
79617 + entry->child = NULL;
79618 + pax_close_kernel();
79619 + }
79620 if (entry->proc_handler == NULL)
79621 kfree(entry->procname);
79622 }
79623
79624 - kfree(*tablep);
79625 - *tablep = NULL;
79626 + kfree(tablep);
79627 }
79628
79629 static int min_load_idx = 0;
79630 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
79631
79632 static void
79633 -set_table_entry(struct ctl_table *entry,
79634 +set_table_entry(ctl_table_no_const *entry,
79635 const char *procname, void *data, int maxlen,
79636 umode_t mode, proc_handler *proc_handler,
79637 bool load_idx)
79638 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
79639 static struct ctl_table *
79640 sd_alloc_ctl_domain_table(struct sched_domain *sd)
79641 {
79642 - struct ctl_table *table = sd_alloc_ctl_entry(13);
79643 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
79644
79645 if (table == NULL)
79646 return NULL;
79647 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
79648 return table;
79649 }
79650
79651 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
79652 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
79653 {
79654 - struct ctl_table *entry, *table;
79655 + ctl_table_no_const *entry, *table;
79656 struct sched_domain *sd;
79657 int domain_num = 0, i;
79658 char buf[32];
79659 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
79660 static void register_sched_domain_sysctl(void)
79661 {
79662 int i, cpu_num = num_possible_cpus();
79663 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
79664 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
79665 char buf[32];
79666
79667 WARN_ON(sd_ctl_dir[0].child);
79668 + pax_open_kernel();
79669 sd_ctl_dir[0].child = entry;
79670 + pax_close_kernel();
79671
79672 if (entry == NULL)
79673 return;
79674 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
79675 if (sd_sysctl_header)
79676 unregister_sysctl_table(sd_sysctl_header);
79677 sd_sysctl_header = NULL;
79678 - if (sd_ctl_dir[0].child)
79679 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
79680 + if (sd_ctl_dir[0].child) {
79681 + sd_free_ctl_entry(sd_ctl_dir[0].child);
79682 + pax_open_kernel();
79683 + sd_ctl_dir[0].child = NULL;
79684 + pax_close_kernel();
79685 + }
79686 }
79687 #else
79688 static void register_sched_domain_sysctl(void)
79689 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
79690 * happens before everything else. This has to be lower priority than
79691 * the notifier in the perf_event subsystem, though.
79692 */
79693 -static struct notifier_block __cpuinitdata migration_notifier = {
79694 +static struct notifier_block migration_notifier = {
79695 .notifier_call = migration_call,
79696 .priority = CPU_PRI_MIGRATION,
79697 };
79698 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
79699 index c61a614..d7f3d7e 100644
79700 --- a/kernel/sched/fair.c
79701 +++ b/kernel/sched/fair.c
79702 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
79703
79704 static void reset_ptenuma_scan(struct task_struct *p)
79705 {
79706 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
79707 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
79708 p->mm->numa_scan_offset = 0;
79709 }
79710
79711 @@ -5686,7 +5686,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
79712 * run_rebalance_domains is triggered when needed from the scheduler tick.
79713 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
79714 */
79715 -static void run_rebalance_domains(struct softirq_action *h)
79716 +static void run_rebalance_domains(void)
79717 {
79718 int this_cpu = smp_processor_id();
79719 struct rq *this_rq = cpu_rq(this_cpu);
79720 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
79721 index ce39224d..0e09343 100644
79722 --- a/kernel/sched/sched.h
79723 +++ b/kernel/sched/sched.h
79724 @@ -1009,7 +1009,7 @@ struct sched_class {
79725 #ifdef CONFIG_FAIR_GROUP_SCHED
79726 void (*task_move_group) (struct task_struct *p, int on_rq);
79727 #endif
79728 -};
79729 +} __do_const;
79730
79731 #define sched_class_highest (&stop_sched_class)
79732 #define for_each_class(class) \
79733 diff --git a/kernel/signal.c b/kernel/signal.c
79734 index 113411b..17190e2 100644
79735 --- a/kernel/signal.c
79736 +++ b/kernel/signal.c
79737 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
79738
79739 int print_fatal_signals __read_mostly;
79740
79741 -static void __user *sig_handler(struct task_struct *t, int sig)
79742 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
79743 {
79744 return t->sighand->action[sig - 1].sa.sa_handler;
79745 }
79746
79747 -static int sig_handler_ignored(void __user *handler, int sig)
79748 +static int sig_handler_ignored(__sighandler_t handler, int sig)
79749 {
79750 /* Is it explicitly or implicitly ignored? */
79751 return handler == SIG_IGN ||
79752 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
79753
79754 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
79755 {
79756 - void __user *handler;
79757 + __sighandler_t handler;
79758
79759 handler = sig_handler(t, sig);
79760
79761 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
79762 atomic_inc(&user->sigpending);
79763 rcu_read_unlock();
79764
79765 + if (!override_rlimit)
79766 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
79767 +
79768 if (override_rlimit ||
79769 atomic_read(&user->sigpending) <=
79770 task_rlimit(t, RLIMIT_SIGPENDING)) {
79771 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
79772
79773 int unhandled_signal(struct task_struct *tsk, int sig)
79774 {
79775 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
79776 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
79777 if (is_global_init(tsk))
79778 return 1;
79779 if (handler != SIG_IGN && handler != SIG_DFL)
79780 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
79781 }
79782 }
79783
79784 + /* allow glibc communication via tgkill to other threads in our
79785 + thread group */
79786 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
79787 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
79788 + && gr_handle_signal(t, sig))
79789 + return -EPERM;
79790 +
79791 return security_task_kill(t, info, sig, 0);
79792 }
79793
79794 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79795 return send_signal(sig, info, p, 1);
79796 }
79797
79798 -static int
79799 +int
79800 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79801 {
79802 return send_signal(sig, info, t, 0);
79803 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79804 unsigned long int flags;
79805 int ret, blocked, ignored;
79806 struct k_sigaction *action;
79807 + int is_unhandled = 0;
79808
79809 spin_lock_irqsave(&t->sighand->siglock, flags);
79810 action = &t->sighand->action[sig-1];
79811 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79812 }
79813 if (action->sa.sa_handler == SIG_DFL)
79814 t->signal->flags &= ~SIGNAL_UNKILLABLE;
79815 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
79816 + is_unhandled = 1;
79817 ret = specific_send_sig_info(sig, info, t);
79818 spin_unlock_irqrestore(&t->sighand->siglock, flags);
79819
79820 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
79821 + normal operation */
79822 + if (is_unhandled) {
79823 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
79824 + gr_handle_crash(t, sig);
79825 + }
79826 +
79827 return ret;
79828 }
79829
79830 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79831 ret = check_kill_permission(sig, info, p);
79832 rcu_read_unlock();
79833
79834 - if (!ret && sig)
79835 + if (!ret && sig) {
79836 ret = do_send_sig_info(sig, info, p, true);
79837 + if (!ret)
79838 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
79839 + }
79840
79841 return ret;
79842 }
79843 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
79844 int error = -ESRCH;
79845
79846 rcu_read_lock();
79847 - p = find_task_by_vpid(pid);
79848 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
79849 + /* allow glibc communication via tgkill to other threads in our
79850 + thread group */
79851 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
79852 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
79853 + p = find_task_by_vpid_unrestricted(pid);
79854 + else
79855 +#endif
79856 + p = find_task_by_vpid(pid);
79857 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
79858 error = check_kill_permission(sig, info, p);
79859 /*
79860 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
79861 }
79862 seg = get_fs();
79863 set_fs(KERNEL_DS);
79864 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
79865 - (stack_t __force __user *) &uoss,
79866 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
79867 + (stack_t __force_user *) &uoss,
79868 compat_user_stack_pointer());
79869 set_fs(seg);
79870 if (ret >= 0 && uoss_ptr) {
79871 diff --git a/kernel/smp.c b/kernel/smp.c
79872 index 4dba0f7..fe9f773 100644
79873 --- a/kernel/smp.c
79874 +++ b/kernel/smp.c
79875 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
79876 return NOTIFY_OK;
79877 }
79878
79879 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
79880 +static struct notifier_block hotplug_cfd_notifier = {
79881 .notifier_call = hotplug_cfd,
79882 };
79883
79884 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
79885 index 02fc5c9..e54c335 100644
79886 --- a/kernel/smpboot.c
79887 +++ b/kernel/smpboot.c
79888 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
79889 }
79890 smpboot_unpark_thread(plug_thread, cpu);
79891 }
79892 - list_add(&plug_thread->list, &hotplug_threads);
79893 + pax_list_add(&plug_thread->list, &hotplug_threads);
79894 out:
79895 mutex_unlock(&smpboot_threads_lock);
79896 return ret;
79897 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
79898 {
79899 get_online_cpus();
79900 mutex_lock(&smpboot_threads_lock);
79901 - list_del(&plug_thread->list);
79902 + pax_list_del(&plug_thread->list);
79903 smpboot_destroy_threads(plug_thread);
79904 mutex_unlock(&smpboot_threads_lock);
79905 put_online_cpus();
79906 diff --git a/kernel/softirq.c b/kernel/softirq.c
79907 index 3d6833f..da6d93d 100644
79908 --- a/kernel/softirq.c
79909 +++ b/kernel/softirq.c
79910 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
79911 EXPORT_SYMBOL(irq_stat);
79912 #endif
79913
79914 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
79915 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
79916
79917 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
79918
79919 -char *softirq_to_name[NR_SOFTIRQS] = {
79920 +const char * const softirq_to_name[NR_SOFTIRQS] = {
79921 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
79922 "TASKLET", "SCHED", "HRTIMER", "RCU"
79923 };
79924 @@ -250,7 +250,7 @@ restart:
79925 kstat_incr_softirqs_this_cpu(vec_nr);
79926
79927 trace_softirq_entry(vec_nr);
79928 - h->action(h);
79929 + h->action();
79930 trace_softirq_exit(vec_nr);
79931 if (unlikely(prev_count != preempt_count())) {
79932 printk(KERN_ERR "huh, entered softirq %u %s %p"
79933 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
79934 or_softirq_pending(1UL << nr);
79935 }
79936
79937 -void open_softirq(int nr, void (*action)(struct softirq_action *))
79938 +void __init open_softirq(int nr, void (*action)(void))
79939 {
79940 softirq_vec[nr].action = action;
79941 }
79942 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
79943
79944 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
79945
79946 -static void tasklet_action(struct softirq_action *a)
79947 +static void tasklet_action(void)
79948 {
79949 struct tasklet_struct *list;
79950
79951 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
79952 }
79953 }
79954
79955 -static void tasklet_hi_action(struct softirq_action *a)
79956 +static void tasklet_hi_action(void)
79957 {
79958 struct tasklet_struct *list;
79959
79960 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
79961 return NOTIFY_OK;
79962 }
79963
79964 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
79965 +static struct notifier_block remote_softirq_cpu_notifier = {
79966 .notifier_call = remote_softirq_cpu_notify,
79967 };
79968
79969 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
79970 return NOTIFY_OK;
79971 }
79972
79973 -static struct notifier_block __cpuinitdata cpu_nfb = {
79974 +static struct notifier_block cpu_nfb = {
79975 .notifier_call = cpu_callback
79976 };
79977
79978 -static struct smp_hotplug_thread softirq_threads = {
79979 +static struct smp_hotplug_thread softirq_threads __read_only = {
79980 .store = &ksoftirqd,
79981 .thread_should_run = ksoftirqd_should_run,
79982 .thread_fn = run_ksoftirqd,
79983 diff --git a/kernel/srcu.c b/kernel/srcu.c
79984 index 01d5ccb..cdcbee6 100644
79985 --- a/kernel/srcu.c
79986 +++ b/kernel/srcu.c
79987 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
79988
79989 idx = ACCESS_ONCE(sp->completed) & 0x1;
79990 preempt_disable();
79991 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79992 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79993 smp_mb(); /* B */ /* Avoid leaking the critical section. */
79994 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79995 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79996 preempt_enable();
79997 return idx;
79998 }
79999 diff --git a/kernel/sys.c b/kernel/sys.c
80000 index 2bbd9a7..0875671 100644
80001 --- a/kernel/sys.c
80002 +++ b/kernel/sys.c
80003 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
80004 error = -EACCES;
80005 goto out;
80006 }
80007 +
80008 + if (gr_handle_chroot_setpriority(p, niceval)) {
80009 + error = -EACCES;
80010 + goto out;
80011 + }
80012 +
80013 no_nice = security_task_setnice(p, niceval);
80014 if (no_nice) {
80015 error = no_nice;
80016 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
80017 goto error;
80018 }
80019
80020 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
80021 + goto error;
80022 +
80023 if (rgid != (gid_t) -1 ||
80024 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
80025 new->sgid = new->egid;
80026 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
80027 old = current_cred();
80028
80029 retval = -EPERM;
80030 +
80031 + if (gr_check_group_change(kgid, kgid, kgid))
80032 + goto error;
80033 +
80034 if (nsown_capable(CAP_SETGID))
80035 new->gid = new->egid = new->sgid = new->fsgid = kgid;
80036 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
80037 @@ -678,7 +691,7 @@ error:
80038 /*
80039 * change the user struct in a credentials set to match the new UID
80040 */
80041 -static int set_user(struct cred *new)
80042 +int set_user(struct cred *new)
80043 {
80044 struct user_struct *new_user;
80045
80046 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
80047 goto error;
80048 }
80049
80050 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
80051 + goto error;
80052 +
80053 if (!uid_eq(new->uid, old->uid)) {
80054 retval = set_user(new);
80055 if (retval < 0)
80056 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
80057 old = current_cred();
80058
80059 retval = -EPERM;
80060 +
80061 + if (gr_check_crash_uid(kuid))
80062 + goto error;
80063 + if (gr_check_user_change(kuid, kuid, kuid))
80064 + goto error;
80065 +
80066 if (nsown_capable(CAP_SETUID)) {
80067 new->suid = new->uid = kuid;
80068 if (!uid_eq(kuid, old->uid)) {
80069 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
80070 goto error;
80071 }
80072
80073 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
80074 + goto error;
80075 +
80076 if (ruid != (uid_t) -1) {
80077 new->uid = kruid;
80078 if (!uid_eq(kruid, old->uid)) {
80079 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
80080 goto error;
80081 }
80082
80083 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
80084 + goto error;
80085 +
80086 if (rgid != (gid_t) -1)
80087 new->gid = krgid;
80088 if (egid != (gid_t) -1)
80089 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
80090 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
80091 nsown_capable(CAP_SETUID)) {
80092 if (!uid_eq(kuid, old->fsuid)) {
80093 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
80094 + goto error;
80095 +
80096 new->fsuid = kuid;
80097 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
80098 goto change_okay;
80099 }
80100 }
80101
80102 +error:
80103 abort_creds(new);
80104 return old_fsuid;
80105
80106 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
80107 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
80108 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
80109 nsown_capable(CAP_SETGID)) {
80110 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
80111 + goto error;
80112 +
80113 if (!gid_eq(kgid, old->fsgid)) {
80114 new->fsgid = kgid;
80115 goto change_okay;
80116 }
80117 }
80118
80119 +error:
80120 abort_creds(new);
80121 return old_fsgid;
80122
80123 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
80124 return -EFAULT;
80125
80126 down_read(&uts_sem);
80127 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
80128 + error = __copy_to_user(name->sysname, &utsname()->sysname,
80129 __OLD_UTS_LEN);
80130 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
80131 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
80132 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
80133 __OLD_UTS_LEN);
80134 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
80135 - error |= __copy_to_user(&name->release, &utsname()->release,
80136 + error |= __copy_to_user(name->release, &utsname()->release,
80137 __OLD_UTS_LEN);
80138 error |= __put_user(0, name->release + __OLD_UTS_LEN);
80139 - error |= __copy_to_user(&name->version, &utsname()->version,
80140 + error |= __copy_to_user(name->version, &utsname()->version,
80141 __OLD_UTS_LEN);
80142 error |= __put_user(0, name->version + __OLD_UTS_LEN);
80143 - error |= __copy_to_user(&name->machine, &utsname()->machine,
80144 + error |= __copy_to_user(name->machine, &utsname()->machine,
80145 __OLD_UTS_LEN);
80146 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
80147 up_read(&uts_sem);
80148 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
80149 */
80150 new_rlim->rlim_cur = 1;
80151 }
80152 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
80153 + is changed to a lower value. Since tasks can be created by the same
80154 + user in between this limit change and an execve by this task, force
80155 + a recheck only for this task by setting PF_NPROC_EXCEEDED
80156 + */
80157 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
80158 + tsk->flags |= PF_NPROC_EXCEEDED;
80159 }
80160 if (!retval) {
80161 if (old_rlim)
80162 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
80163 index 9edcf45..713c960 100644
80164 --- a/kernel/sysctl.c
80165 +++ b/kernel/sysctl.c
80166 @@ -93,7 +93,6 @@
80167
80168
80169 #if defined(CONFIG_SYSCTL)
80170 -
80171 /* External variables not in a header file. */
80172 extern int sysctl_overcommit_memory;
80173 extern int sysctl_overcommit_ratio;
80174 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
80175
80176 /* Constants used for minimum and maximum */
80177 #ifdef CONFIG_LOCKUP_DETECTOR
80178 -static int sixty = 60;
80179 -static int neg_one = -1;
80180 +static int sixty __read_only = 60;
80181 #endif
80182
80183 -static int zero;
80184 -static int __maybe_unused one = 1;
80185 -static int __maybe_unused two = 2;
80186 -static int __maybe_unused three = 3;
80187 -static unsigned long one_ul = 1;
80188 -static int one_hundred = 100;
80189 +static int neg_one __read_only = -1;
80190 +static int zero __read_only = 0;
80191 +static int __maybe_unused one __read_only = 1;
80192 +static int __maybe_unused two __read_only = 2;
80193 +static int __maybe_unused three __read_only = 3;
80194 +static unsigned long one_ul __read_only = 1;
80195 +static int one_hundred __read_only = 100;
80196 #ifdef CONFIG_PRINTK
80197 -static int ten_thousand = 10000;
80198 +static int ten_thousand __read_only = 10000;
80199 #endif
80200
80201 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
80202 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
80203 void __user *buffer, size_t *lenp, loff_t *ppos);
80204 #endif
80205
80206 -#ifdef CONFIG_PRINTK
80207 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
80208 void __user *buffer, size_t *lenp, loff_t *ppos);
80209 -#endif
80210
80211 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
80212 void __user *buffer, size_t *lenp, loff_t *ppos);
80213 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
80214
80215 #endif
80216
80217 +extern struct ctl_table grsecurity_table[];
80218 +
80219 static struct ctl_table kern_table[];
80220 static struct ctl_table vm_table[];
80221 static struct ctl_table fs_table[];
80222 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
80223 int sysctl_legacy_va_layout;
80224 #endif
80225
80226 +#ifdef CONFIG_PAX_SOFTMODE
80227 +static ctl_table pax_table[] = {
80228 + {
80229 + .procname = "softmode",
80230 + .data = &pax_softmode,
80231 + .maxlen = sizeof(unsigned int),
80232 + .mode = 0600,
80233 + .proc_handler = &proc_dointvec,
80234 + },
80235 +
80236 + { }
80237 +};
80238 +#endif
80239 +
80240 /* The default sysctl tables: */
80241
80242 static struct ctl_table sysctl_base_table[] = {
80243 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
80244 #endif
80245
80246 static struct ctl_table kern_table[] = {
80247 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
80248 + {
80249 + .procname = "grsecurity",
80250 + .mode = 0500,
80251 + .child = grsecurity_table,
80252 + },
80253 +#endif
80254 +
80255 +#ifdef CONFIG_PAX_SOFTMODE
80256 + {
80257 + .procname = "pax",
80258 + .mode = 0500,
80259 + .child = pax_table,
80260 + },
80261 +#endif
80262 +
80263 {
80264 .procname = "sched_child_runs_first",
80265 .data = &sysctl_sched_child_runs_first,
80266 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
80267 .data = &modprobe_path,
80268 .maxlen = KMOD_PATH_LEN,
80269 .mode = 0644,
80270 - .proc_handler = proc_dostring,
80271 + .proc_handler = proc_dostring_modpriv,
80272 },
80273 {
80274 .procname = "modules_disabled",
80275 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
80276 .extra1 = &zero,
80277 .extra2 = &one,
80278 },
80279 +#endif
80280 {
80281 .procname = "kptr_restrict",
80282 .data = &kptr_restrict,
80283 .maxlen = sizeof(int),
80284 .mode = 0644,
80285 .proc_handler = proc_dointvec_minmax_sysadmin,
80286 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80287 + .extra1 = &two,
80288 +#else
80289 .extra1 = &zero,
80290 +#endif
80291 .extra2 = &two,
80292 },
80293 -#endif
80294 {
80295 .procname = "ngroups_max",
80296 .data = &ngroups_max,
80297 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
80298 */
80299 {
80300 .procname = "perf_event_paranoid",
80301 - .data = &sysctl_perf_event_paranoid,
80302 - .maxlen = sizeof(sysctl_perf_event_paranoid),
80303 + .data = &sysctl_perf_event_legitimately_concerned,
80304 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
80305 .mode = 0644,
80306 - .proc_handler = proc_dointvec,
80307 + /* go ahead, be a hero */
80308 + .proc_handler = proc_dointvec_minmax_sysadmin,
80309 + .extra1 = &neg_one,
80310 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80311 + .extra2 = &three,
80312 +#else
80313 + .extra2 = &two,
80314 +#endif
80315 },
80316 {
80317 .procname = "perf_event_mlock_kb",
80318 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
80319 .proc_handler = proc_dointvec_minmax,
80320 .extra1 = &zero,
80321 },
80322 + {
80323 + .procname = "heap_stack_gap",
80324 + .data = &sysctl_heap_stack_gap,
80325 + .maxlen = sizeof(sysctl_heap_stack_gap),
80326 + .mode = 0644,
80327 + .proc_handler = proc_doulongvec_minmax,
80328 + },
80329 #else
80330 {
80331 .procname = "nr_trim_pages",
80332 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
80333 buffer, lenp, ppos);
80334 }
80335
80336 +int proc_dostring_modpriv(struct ctl_table *table, int write,
80337 + void __user *buffer, size_t *lenp, loff_t *ppos)
80338 +{
80339 + if (write && !capable(CAP_SYS_MODULE))
80340 + return -EPERM;
80341 +
80342 + return _proc_do_string(table->data, table->maxlen, write,
80343 + buffer, lenp, ppos);
80344 +}
80345 +
80346 static size_t proc_skip_spaces(char **buf)
80347 {
80348 size_t ret;
80349 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
80350 len = strlen(tmp);
80351 if (len > *size)
80352 len = *size;
80353 + if (len > sizeof(tmp))
80354 + len = sizeof(tmp);
80355 if (copy_to_user(*buf, tmp, len))
80356 return -EFAULT;
80357 *size -= len;
80358 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
80359 static int proc_taint(struct ctl_table *table, int write,
80360 void __user *buffer, size_t *lenp, loff_t *ppos)
80361 {
80362 - struct ctl_table t;
80363 + ctl_table_no_const t;
80364 unsigned long tmptaint = get_taint();
80365 int err;
80366
80367 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
80368 return err;
80369 }
80370
80371 -#ifdef CONFIG_PRINTK
80372 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
80373 void __user *buffer, size_t *lenp, loff_t *ppos)
80374 {
80375 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
80376
80377 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
80378 }
80379 -#endif
80380
80381 struct do_proc_dointvec_minmax_conv_param {
80382 int *min;
80383 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
80384 *i = val;
80385 } else {
80386 val = convdiv * (*i) / convmul;
80387 - if (!first)
80388 + if (!first) {
80389 err = proc_put_char(&buffer, &left, '\t');
80390 + if (err)
80391 + break;
80392 + }
80393 err = proc_put_long(&buffer, &left, val, false);
80394 if (err)
80395 break;
80396 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
80397 return -ENOSYS;
80398 }
80399
80400 +int proc_dostring_modpriv(struct ctl_table *table, int write,
80401 + void __user *buffer, size_t *lenp, loff_t *ppos)
80402 +{
80403 + return -ENOSYS;
80404 +}
80405 +
80406 int proc_dointvec(struct ctl_table *table, int write,
80407 void __user *buffer, size_t *lenp, loff_t *ppos)
80408 {
80409 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
80410 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
80411 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
80412 EXPORT_SYMBOL(proc_dostring);
80413 +EXPORT_SYMBOL(proc_dostring_modpriv);
80414 EXPORT_SYMBOL(proc_doulongvec_minmax);
80415 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
80416 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
80417 index 145bb4d..b2aa969 100644
80418 --- a/kernel/taskstats.c
80419 +++ b/kernel/taskstats.c
80420 @@ -28,9 +28,12 @@
80421 #include <linux/fs.h>
80422 #include <linux/file.h>
80423 #include <linux/pid_namespace.h>
80424 +#include <linux/grsecurity.h>
80425 #include <net/genetlink.h>
80426 #include <linux/atomic.h>
80427
80428 +extern int gr_is_taskstats_denied(int pid);
80429 +
80430 /*
80431 * Maximum length of a cpumask that can be specified in
80432 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
80433 @@ -570,6 +573,9 @@ err:
80434
80435 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
80436 {
80437 + if (gr_is_taskstats_denied(current->pid))
80438 + return -EACCES;
80439 +
80440 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
80441 return cmd_attr_register_cpumask(info);
80442 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
80443 diff --git a/kernel/time.c b/kernel/time.c
80444 index d3617db..c98bbe9 100644
80445 --- a/kernel/time.c
80446 +++ b/kernel/time.c
80447 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
80448 return error;
80449
80450 if (tz) {
80451 + /* we log in do_settimeofday called below, so don't log twice
80452 + */
80453 + if (!tv)
80454 + gr_log_timechange();
80455 +
80456 sys_tz = *tz;
80457 update_vsyscall_tz();
80458 if (firsttime) {
80459 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
80460 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
80461 * value to a scaled second value.
80462 */
80463 -unsigned long
80464 +unsigned long __intentional_overflow(-1)
80465 timespec_to_jiffies(const struct timespec *value)
80466 {
80467 unsigned long sec = value->tv_sec;
80468 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
80469 index f11d83b..d016d91 100644
80470 --- a/kernel/time/alarmtimer.c
80471 +++ b/kernel/time/alarmtimer.c
80472 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
80473 struct platform_device *pdev;
80474 int error = 0;
80475 int i;
80476 - struct k_clock alarm_clock = {
80477 + static struct k_clock alarm_clock = {
80478 .clock_getres = alarm_clock_getres,
80479 .clock_get = alarm_clock_get,
80480 .timer_create = alarm_timer_create,
80481 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
80482 index baeeb5c..c22704a 100644
80483 --- a/kernel/time/timekeeping.c
80484 +++ b/kernel/time/timekeeping.c
80485 @@ -15,6 +15,7 @@
80486 #include <linux/init.h>
80487 #include <linux/mm.h>
80488 #include <linux/sched.h>
80489 +#include <linux/grsecurity.h>
80490 #include <linux/syscore_ops.h>
80491 #include <linux/clocksource.h>
80492 #include <linux/jiffies.h>
80493 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
80494 if (!timespec_valid_strict(tv))
80495 return -EINVAL;
80496
80497 + gr_log_timechange();
80498 +
80499 raw_spin_lock_irqsave(&timekeeper_lock, flags);
80500 write_seqcount_begin(&timekeeper_seq);
80501
80502 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
80503 index 3bdf283..cc68d83 100644
80504 --- a/kernel/time/timer_list.c
80505 +++ b/kernel/time/timer_list.c
80506 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
80507
80508 static void print_name_offset(struct seq_file *m, void *sym)
80509 {
80510 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80511 + SEQ_printf(m, "<%p>", NULL);
80512 +#else
80513 char symname[KSYM_NAME_LEN];
80514
80515 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
80516 SEQ_printf(m, "<%pK>", sym);
80517 else
80518 SEQ_printf(m, "%s", symname);
80519 +#endif
80520 }
80521
80522 static void
80523 @@ -119,7 +123,11 @@ next_one:
80524 static void
80525 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
80526 {
80527 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80528 + SEQ_printf(m, " .base: %p\n", NULL);
80529 +#else
80530 SEQ_printf(m, " .base: %pK\n", base);
80531 +#endif
80532 SEQ_printf(m, " .index: %d\n",
80533 base->index);
80534 SEQ_printf(m, " .resolution: %Lu nsecs\n",
80535 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
80536 {
80537 struct proc_dir_entry *pe;
80538
80539 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
80540 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
80541 +#else
80542 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
80543 +#endif
80544 if (!pe)
80545 return -ENOMEM;
80546 return 0;
80547 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
80548 index 0b537f2..40d6c20 100644
80549 --- a/kernel/time/timer_stats.c
80550 +++ b/kernel/time/timer_stats.c
80551 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
80552 static unsigned long nr_entries;
80553 static struct entry entries[MAX_ENTRIES];
80554
80555 -static atomic_t overflow_count;
80556 +static atomic_unchecked_t overflow_count;
80557
80558 /*
80559 * The entries are in a hash-table, for fast lookup:
80560 @@ -140,7 +140,7 @@ static void reset_entries(void)
80561 nr_entries = 0;
80562 memset(entries, 0, sizeof(entries));
80563 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
80564 - atomic_set(&overflow_count, 0);
80565 + atomic_set_unchecked(&overflow_count, 0);
80566 }
80567
80568 static struct entry *alloc_entry(void)
80569 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
80570 if (likely(entry))
80571 entry->count++;
80572 else
80573 - atomic_inc(&overflow_count);
80574 + atomic_inc_unchecked(&overflow_count);
80575
80576 out_unlock:
80577 raw_spin_unlock_irqrestore(lock, flags);
80578 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
80579
80580 static void print_name_offset(struct seq_file *m, unsigned long addr)
80581 {
80582 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80583 + seq_printf(m, "<%p>", NULL);
80584 +#else
80585 char symname[KSYM_NAME_LEN];
80586
80587 if (lookup_symbol_name(addr, symname) < 0)
80588 - seq_printf(m, "<%p>", (void *)addr);
80589 + seq_printf(m, "<%pK>", (void *)addr);
80590 else
80591 seq_printf(m, "%s", symname);
80592 +#endif
80593 }
80594
80595 static int tstats_show(struct seq_file *m, void *v)
80596 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
80597
80598 seq_puts(m, "Timer Stats Version: v0.2\n");
80599 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
80600 - if (atomic_read(&overflow_count))
80601 + if (atomic_read_unchecked(&overflow_count))
80602 seq_printf(m, "Overflow: %d entries\n",
80603 - atomic_read(&overflow_count));
80604 + atomic_read_unchecked(&overflow_count));
80605
80606 for (i = 0; i < nr_entries; i++) {
80607 entry = entries + i;
80608 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
80609 {
80610 struct proc_dir_entry *pe;
80611
80612 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
80613 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
80614 +#else
80615 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
80616 +#endif
80617 if (!pe)
80618 return -ENOMEM;
80619 return 0;
80620 diff --git a/kernel/timer.c b/kernel/timer.c
80621 index 15bc1b4..32da49c 100644
80622 --- a/kernel/timer.c
80623 +++ b/kernel/timer.c
80624 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
80625 /*
80626 * This function runs timers and the timer-tq in bottom half context.
80627 */
80628 -static void run_timer_softirq(struct softirq_action *h)
80629 +static void run_timer_softirq(void)
80630 {
80631 struct tvec_base *base = __this_cpu_read(tvec_bases);
80632
80633 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
80634 *
80635 * In all cases the return value is guaranteed to be non-negative.
80636 */
80637 -signed long __sched schedule_timeout(signed long timeout)
80638 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
80639 {
80640 struct timer_list timer;
80641 unsigned long expire;
80642 @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
80643 return NOTIFY_OK;
80644 }
80645
80646 -static struct notifier_block __cpuinitdata timers_nb = {
80647 +static struct notifier_block timers_nb = {
80648 .notifier_call = timer_cpu_notify,
80649 };
80650
80651 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
80652 index b8b8560..75b1a09 100644
80653 --- a/kernel/trace/blktrace.c
80654 +++ b/kernel/trace/blktrace.c
80655 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
80656 struct blk_trace *bt = filp->private_data;
80657 char buf[16];
80658
80659 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
80660 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
80661
80662 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
80663 }
80664 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
80665 return 1;
80666
80667 bt = buf->chan->private_data;
80668 - atomic_inc(&bt->dropped);
80669 + atomic_inc_unchecked(&bt->dropped);
80670 return 0;
80671 }
80672
80673 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
80674
80675 bt->dir = dir;
80676 bt->dev = dev;
80677 - atomic_set(&bt->dropped, 0);
80678 + atomic_set_unchecked(&bt->dropped, 0);
80679
80680 ret = -EIO;
80681 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
80682 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
80683 index 6c508ff..ee55a13 100644
80684 --- a/kernel/trace/ftrace.c
80685 +++ b/kernel/trace/ftrace.c
80686 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
80687 if (unlikely(ftrace_disabled))
80688 return 0;
80689
80690 + ret = ftrace_arch_code_modify_prepare();
80691 + FTRACE_WARN_ON(ret);
80692 + if (ret)
80693 + return 0;
80694 +
80695 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
80696 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
80697 if (ret) {
80698 ftrace_bug(ret, ip);
80699 - return 0;
80700 }
80701 - return 1;
80702 + return ret ? 0 : 1;
80703 }
80704
80705 /*
80706 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
80707 if (!count)
80708 return 0;
80709
80710 + pax_open_kernel();
80711 sort(start, count, sizeof(*start),
80712 ftrace_cmp_ips, ftrace_swap_ips);
80713 + pax_close_kernel();
80714
80715 start_pg = ftrace_allocate_pages(count);
80716 if (!start_pg)
80717 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
80718 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
80719
80720 static int ftrace_graph_active;
80721 -static struct notifier_block ftrace_suspend_notifier;
80722 -
80723 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
80724 {
80725 return 0;
80726 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
80727 return NOTIFY_DONE;
80728 }
80729
80730 +static struct notifier_block ftrace_suspend_notifier = {
80731 + .notifier_call = ftrace_suspend_notifier_call
80732 +};
80733 +
80734 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
80735 trace_func_graph_ent_t entryfunc)
80736 {
80737 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
80738 goto out;
80739 }
80740
80741 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
80742 register_pm_notifier(&ftrace_suspend_notifier);
80743
80744 ftrace_graph_active++;
80745 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
80746 index e444ff8..438b8f4 100644
80747 --- a/kernel/trace/ring_buffer.c
80748 +++ b/kernel/trace/ring_buffer.c
80749 @@ -352,9 +352,9 @@ struct buffer_data_page {
80750 */
80751 struct buffer_page {
80752 struct list_head list; /* list of buffer pages */
80753 - local_t write; /* index for next write */
80754 + local_unchecked_t write; /* index for next write */
80755 unsigned read; /* index for next read */
80756 - local_t entries; /* entries on this page */
80757 + local_unchecked_t entries; /* entries on this page */
80758 unsigned long real_end; /* real end of data */
80759 struct buffer_data_page *page; /* Actual data page */
80760 };
80761 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
80762 unsigned long last_overrun;
80763 local_t entries_bytes;
80764 local_t entries;
80765 - local_t overrun;
80766 - local_t commit_overrun;
80767 + local_unchecked_t overrun;
80768 + local_unchecked_t commit_overrun;
80769 local_t dropped_events;
80770 local_t committing;
80771 local_t commits;
80772 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80773 *
80774 * We add a counter to the write field to denote this.
80775 */
80776 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
80777 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
80778 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
80779 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
80780
80781 /*
80782 * Just make sure we have seen our old_write and synchronize
80783 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80784 * cmpxchg to only update if an interrupt did not already
80785 * do it for us. If the cmpxchg fails, we don't care.
80786 */
80787 - (void)local_cmpxchg(&next_page->write, old_write, val);
80788 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
80789 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
80790 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
80791
80792 /*
80793 * No need to worry about races with clearing out the commit.
80794 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
80795
80796 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
80797 {
80798 - return local_read(&bpage->entries) & RB_WRITE_MASK;
80799 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
80800 }
80801
80802 static inline unsigned long rb_page_write(struct buffer_page *bpage)
80803 {
80804 - return local_read(&bpage->write) & RB_WRITE_MASK;
80805 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
80806 }
80807
80808 static int
80809 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
80810 * bytes consumed in ring buffer from here.
80811 * Increment overrun to account for the lost events.
80812 */
80813 - local_add(page_entries, &cpu_buffer->overrun);
80814 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
80815 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80816 }
80817
80818 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
80819 * it is our responsibility to update
80820 * the counters.
80821 */
80822 - local_add(entries, &cpu_buffer->overrun);
80823 + local_add_unchecked(entries, &cpu_buffer->overrun);
80824 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80825
80826 /*
80827 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80828 if (tail == BUF_PAGE_SIZE)
80829 tail_page->real_end = 0;
80830
80831 - local_sub(length, &tail_page->write);
80832 + local_sub_unchecked(length, &tail_page->write);
80833 return;
80834 }
80835
80836 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80837 rb_event_set_padding(event);
80838
80839 /* Set the write back to the previous setting */
80840 - local_sub(length, &tail_page->write);
80841 + local_sub_unchecked(length, &tail_page->write);
80842 return;
80843 }
80844
80845 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80846
80847 /* Set write to end of buffer */
80848 length = (tail + length) - BUF_PAGE_SIZE;
80849 - local_sub(length, &tail_page->write);
80850 + local_sub_unchecked(length, &tail_page->write);
80851 }
80852
80853 /*
80854 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80855 * about it.
80856 */
80857 if (unlikely(next_page == commit_page)) {
80858 - local_inc(&cpu_buffer->commit_overrun);
80859 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80860 goto out_reset;
80861 }
80862
80863 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80864 cpu_buffer->tail_page) &&
80865 (cpu_buffer->commit_page ==
80866 cpu_buffer->reader_page))) {
80867 - local_inc(&cpu_buffer->commit_overrun);
80868 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80869 goto out_reset;
80870 }
80871 }
80872 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80873 length += RB_LEN_TIME_EXTEND;
80874
80875 tail_page = cpu_buffer->tail_page;
80876 - write = local_add_return(length, &tail_page->write);
80877 + write = local_add_return_unchecked(length, &tail_page->write);
80878
80879 /* set write to only the index of the write */
80880 write &= RB_WRITE_MASK;
80881 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80882 kmemcheck_annotate_bitfield(event, bitfield);
80883 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
80884
80885 - local_inc(&tail_page->entries);
80886 + local_inc_unchecked(&tail_page->entries);
80887
80888 /*
80889 * If this is the first commit on the page, then update
80890 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80891
80892 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
80893 unsigned long write_mask =
80894 - local_read(&bpage->write) & ~RB_WRITE_MASK;
80895 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
80896 unsigned long event_length = rb_event_length(event);
80897 /*
80898 * This is on the tail page. It is possible that
80899 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80900 */
80901 old_index += write_mask;
80902 new_index += write_mask;
80903 - index = local_cmpxchg(&bpage->write, old_index, new_index);
80904 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
80905 if (index == old_index) {
80906 /* update counters */
80907 local_sub(event_length, &cpu_buffer->entries_bytes);
80908 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80909
80910 /* Do the likely case first */
80911 if (likely(bpage->page == (void *)addr)) {
80912 - local_dec(&bpage->entries);
80913 + local_dec_unchecked(&bpage->entries);
80914 return;
80915 }
80916
80917 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80918 start = bpage;
80919 do {
80920 if (bpage->page == (void *)addr) {
80921 - local_dec(&bpage->entries);
80922 + local_dec_unchecked(&bpage->entries);
80923 return;
80924 }
80925 rb_inc_page(cpu_buffer, &bpage);
80926 @@ -3138,7 +3138,7 @@ static inline unsigned long
80927 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
80928 {
80929 return local_read(&cpu_buffer->entries) -
80930 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
80931 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
80932 }
80933
80934 /**
80935 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
80936 return 0;
80937
80938 cpu_buffer = buffer->buffers[cpu];
80939 - ret = local_read(&cpu_buffer->overrun);
80940 + ret = local_read_unchecked(&cpu_buffer->overrun);
80941
80942 return ret;
80943 }
80944 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
80945 return 0;
80946
80947 cpu_buffer = buffer->buffers[cpu];
80948 - ret = local_read(&cpu_buffer->commit_overrun);
80949 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
80950
80951 return ret;
80952 }
80953 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
80954 /* if you care about this being correct, lock the buffer */
80955 for_each_buffer_cpu(buffer, cpu) {
80956 cpu_buffer = buffer->buffers[cpu];
80957 - overruns += local_read(&cpu_buffer->overrun);
80958 + overruns += local_read_unchecked(&cpu_buffer->overrun);
80959 }
80960
80961 return overruns;
80962 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80963 /*
80964 * Reset the reader page to size zero.
80965 */
80966 - local_set(&cpu_buffer->reader_page->write, 0);
80967 - local_set(&cpu_buffer->reader_page->entries, 0);
80968 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80969 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80970 local_set(&cpu_buffer->reader_page->page->commit, 0);
80971 cpu_buffer->reader_page->real_end = 0;
80972
80973 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80974 * want to compare with the last_overrun.
80975 */
80976 smp_mb();
80977 - overwrite = local_read(&(cpu_buffer->overrun));
80978 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
80979
80980 /*
80981 * Here's the tricky part.
80982 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80983
80984 cpu_buffer->head_page
80985 = list_entry(cpu_buffer->pages, struct buffer_page, list);
80986 - local_set(&cpu_buffer->head_page->write, 0);
80987 - local_set(&cpu_buffer->head_page->entries, 0);
80988 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
80989 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
80990 local_set(&cpu_buffer->head_page->page->commit, 0);
80991
80992 cpu_buffer->head_page->read = 0;
80993 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80994
80995 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
80996 INIT_LIST_HEAD(&cpu_buffer->new_pages);
80997 - local_set(&cpu_buffer->reader_page->write, 0);
80998 - local_set(&cpu_buffer->reader_page->entries, 0);
80999 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
81000 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
81001 local_set(&cpu_buffer->reader_page->page->commit, 0);
81002 cpu_buffer->reader_page->read = 0;
81003
81004 local_set(&cpu_buffer->entries_bytes, 0);
81005 - local_set(&cpu_buffer->overrun, 0);
81006 - local_set(&cpu_buffer->commit_overrun, 0);
81007 + local_set_unchecked(&cpu_buffer->overrun, 0);
81008 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
81009 local_set(&cpu_buffer->dropped_events, 0);
81010 local_set(&cpu_buffer->entries, 0);
81011 local_set(&cpu_buffer->committing, 0);
81012 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
81013 rb_init_page(bpage);
81014 bpage = reader->page;
81015 reader->page = *data_page;
81016 - local_set(&reader->write, 0);
81017 - local_set(&reader->entries, 0);
81018 + local_set_unchecked(&reader->write, 0);
81019 + local_set_unchecked(&reader->entries, 0);
81020 reader->read = 0;
81021 *data_page = bpage;
81022
81023 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
81024 index f7bc3ce..b8ef9b5 100644
81025 --- a/kernel/trace/trace.c
81026 +++ b/kernel/trace/trace.c
81027 @@ -3303,7 +3303,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
81028 return 0;
81029 }
81030
81031 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
81032 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
81033 {
81034 /* do nothing if flag is already set */
81035 if (!!(trace_flags & mask) == !!enabled)
81036 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
81037 index 51b4448..7be601f 100644
81038 --- a/kernel/trace/trace.h
81039 +++ b/kernel/trace/trace.h
81040 @@ -1035,7 +1035,7 @@ extern const char *__stop___trace_bprintk_fmt[];
81041 void trace_printk_init_buffers(void);
81042 void trace_printk_start_comm(void);
81043 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
81044 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
81045 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
81046
81047 /*
81048 * Normal trace_printk() and friends allocates special buffers
81049 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
81050 index 6953263..2004e16 100644
81051 --- a/kernel/trace/trace_events.c
81052 +++ b/kernel/trace/trace_events.c
81053 @@ -1748,10 +1748,6 @@ static LIST_HEAD(ftrace_module_file_list);
81054 struct ftrace_module_file_ops {
81055 struct list_head list;
81056 struct module *mod;
81057 - struct file_operations id;
81058 - struct file_operations enable;
81059 - struct file_operations format;
81060 - struct file_operations filter;
81061 };
81062
81063 static struct ftrace_module_file_ops *
81064 @@ -1792,17 +1788,12 @@ trace_create_file_ops(struct module *mod)
81065
81066 file_ops->mod = mod;
81067
81068 - file_ops->id = ftrace_event_id_fops;
81069 - file_ops->id.owner = mod;
81070 -
81071 - file_ops->enable = ftrace_enable_fops;
81072 - file_ops->enable.owner = mod;
81073 -
81074 - file_ops->filter = ftrace_event_filter_fops;
81075 - file_ops->filter.owner = mod;
81076 -
81077 - file_ops->format = ftrace_event_format_fops;
81078 - file_ops->format.owner = mod;
81079 + pax_open_kernel();
81080 + mod->trace_id.owner = mod;
81081 + mod->trace_enable.owner = mod;
81082 + mod->trace_filter.owner = mod;
81083 + mod->trace_format.owner = mod;
81084 + pax_close_kernel();
81085
81086 list_add(&file_ops->list, &ftrace_module_file_list);
81087
81088 @@ -1895,8 +1886,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
81089 struct ftrace_module_file_ops *file_ops)
81090 {
81091 return __trace_add_new_event(call, tr,
81092 - &file_ops->id, &file_ops->enable,
81093 - &file_ops->filter, &file_ops->format);
81094 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
81095 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
81096 }
81097
81098 #else
81099 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
81100 index a5e8f48..a9690d2 100644
81101 --- a/kernel/trace/trace_mmiotrace.c
81102 +++ b/kernel/trace/trace_mmiotrace.c
81103 @@ -24,7 +24,7 @@ struct header_iter {
81104 static struct trace_array *mmio_trace_array;
81105 static bool overrun_detected;
81106 static unsigned long prev_overruns;
81107 -static atomic_t dropped_count;
81108 +static atomic_unchecked_t dropped_count;
81109
81110 static void mmio_reset_data(struct trace_array *tr)
81111 {
81112 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
81113
81114 static unsigned long count_overruns(struct trace_iterator *iter)
81115 {
81116 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
81117 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
81118 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
81119
81120 if (over > prev_overruns)
81121 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
81122 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
81123 sizeof(*entry), 0, pc);
81124 if (!event) {
81125 - atomic_inc(&dropped_count);
81126 + atomic_inc_unchecked(&dropped_count);
81127 return;
81128 }
81129 entry = ring_buffer_event_data(event);
81130 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
81131 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
81132 sizeof(*entry), 0, pc);
81133 if (!event) {
81134 - atomic_inc(&dropped_count);
81135 + atomic_inc_unchecked(&dropped_count);
81136 return;
81137 }
81138 entry = ring_buffer_event_data(event);
81139 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
81140 index bb922d9..2a54a257 100644
81141 --- a/kernel/trace/trace_output.c
81142 +++ b/kernel/trace/trace_output.c
81143 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
81144
81145 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
81146 if (!IS_ERR(p)) {
81147 - p = mangle_path(s->buffer + s->len, p, "\n");
81148 + p = mangle_path(s->buffer + s->len, p, "\n\\");
81149 if (p) {
81150 s->len = p - s->buffer;
81151 return 1;
81152 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
81153 goto out;
81154 }
81155
81156 + pax_open_kernel();
81157 if (event->funcs->trace == NULL)
81158 - event->funcs->trace = trace_nop_print;
81159 + *(void **)&event->funcs->trace = trace_nop_print;
81160 if (event->funcs->raw == NULL)
81161 - event->funcs->raw = trace_nop_print;
81162 + *(void **)&event->funcs->raw = trace_nop_print;
81163 if (event->funcs->hex == NULL)
81164 - event->funcs->hex = trace_nop_print;
81165 + *(void **)&event->funcs->hex = trace_nop_print;
81166 if (event->funcs->binary == NULL)
81167 - event->funcs->binary = trace_nop_print;
81168 + *(void **)&event->funcs->binary = trace_nop_print;
81169 + pax_close_kernel();
81170
81171 key = event->type & (EVENT_HASHSIZE - 1);
81172
81173 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
81174 index b20428c..4845a10 100644
81175 --- a/kernel/trace/trace_stack.c
81176 +++ b/kernel/trace/trace_stack.c
81177 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
81178 return;
81179
81180 /* we do not handle interrupt stacks yet */
81181 - if (!object_is_on_stack(stack))
81182 + if (!object_starts_on_stack(stack))
81183 return;
81184
81185 local_irq_save(flags);
81186 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
81187 index d8c30db..f2f6af5 100644
81188 --- a/kernel/user_namespace.c
81189 +++ b/kernel/user_namespace.c
81190 @@ -79,6 +79,21 @@ int create_user_ns(struct cred *new)
81191 !kgid_has_mapping(parent_ns, group))
81192 return -EPERM;
81193
81194 +#ifdef CONFIG_GRKERNSEC
81195 + /*
81196 + * This doesn't really inspire confidence:
81197 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
81198 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
81199 + * Increases kernel attack surface in areas developers
81200 + * previously cared little about ("low importance due
81201 + * to requiring "root" capability")
81202 + * To be removed when this code receives *proper* review
81203 + */
81204 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
81205 + !capable(CAP_SETGID))
81206 + return -EPERM;
81207 +#endif
81208 +
81209 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
81210 if (!ns)
81211 return -ENOMEM;
81212 @@ -105,6 +120,7 @@ int create_user_ns(struct cred *new)
81213 int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
81214 {
81215 struct cred *cred;
81216 + int err;
81217
81218 if (!(unshare_flags & CLONE_NEWUSER))
81219 return 0;
81220 @@ -113,8 +129,12 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
81221 if (!cred)
81222 return -ENOMEM;
81223
81224 - *new_cred = cred;
81225 - return create_user_ns(cred);
81226 + err = create_user_ns(cred);
81227 + if (err)
81228 + put_cred(cred);
81229 + else
81230 + *new_cred = cred;
81231 + return err;
81232 }
81233
81234 void free_user_ns(struct user_namespace *ns)
81235 @@ -853,7 +873,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
81236 if (atomic_read(&current->mm->mm_users) > 1)
81237 return -EINVAL;
81238
81239 - if (current->fs->users != 1)
81240 + if (atomic_read(&current->fs->users) != 1)
81241 return -EINVAL;
81242
81243 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
81244 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
81245 index 4f69f9a..7c6f8f8 100644
81246 --- a/kernel/utsname_sysctl.c
81247 +++ b/kernel/utsname_sysctl.c
81248 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
81249 static int proc_do_uts_string(ctl_table *table, int write,
81250 void __user *buffer, size_t *lenp, loff_t *ppos)
81251 {
81252 - struct ctl_table uts_table;
81253 + ctl_table_no_const uts_table;
81254 int r;
81255 memcpy(&uts_table, table, sizeof(uts_table));
81256 uts_table.data = get_uts(table, write);
81257 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
81258 index 05039e3..17490c7 100644
81259 --- a/kernel/watchdog.c
81260 +++ b/kernel/watchdog.c
81261 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
81262 }
81263 #endif /* CONFIG_SYSCTL */
81264
81265 -static struct smp_hotplug_thread watchdog_threads = {
81266 +static struct smp_hotplug_thread watchdog_threads __read_only = {
81267 .store = &softlockup_watchdog,
81268 .thread_should_run = watchdog_should_run,
81269 .thread_fn = watchdog,
81270 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
81271 index ee8e29a..410568e 100644
81272 --- a/kernel/workqueue.c
81273 +++ b/kernel/workqueue.c
81274 @@ -4584,7 +4584,7 @@ static void rebind_workers(struct worker_pool *pool)
81275 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
81276 worker_flags |= WORKER_REBOUND;
81277 worker_flags &= ~WORKER_UNBOUND;
81278 - ACCESS_ONCE(worker->flags) = worker_flags;
81279 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
81280 }
81281
81282 spin_unlock_irq(&pool->lock);
81283 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
81284 index 74fdc5c..3310593 100644
81285 --- a/lib/Kconfig.debug
81286 +++ b/lib/Kconfig.debug
81287 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
81288
81289 config DEBUG_LOCK_ALLOC
81290 bool "Lock debugging: detect incorrect freeing of live locks"
81291 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
81292 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
81293 select DEBUG_SPINLOCK
81294 select DEBUG_MUTEXES
81295 select LOCKDEP
81296 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
81297
81298 config PROVE_LOCKING
81299 bool "Lock debugging: prove locking correctness"
81300 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
81301 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
81302 select LOCKDEP
81303 select DEBUG_SPINLOCK
81304 select DEBUG_MUTEXES
81305 @@ -614,7 +614,7 @@ config LOCKDEP
81306
81307 config LOCK_STAT
81308 bool "Lock usage statistics"
81309 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
81310 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
81311 select LOCKDEP
81312 select DEBUG_SPINLOCK
81313 select DEBUG_MUTEXES
81314 @@ -1282,6 +1282,7 @@ config LATENCYTOP
81315 depends on DEBUG_KERNEL
81316 depends on STACKTRACE_SUPPORT
81317 depends on PROC_FS
81318 + depends on !GRKERNSEC_HIDESYM
81319 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
81320 select KALLSYMS
81321 select KALLSYMS_ALL
81322 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
81323 config DEBUG_STRICT_USER_COPY_CHECKS
81324 bool "Strict user copy size checks"
81325 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
81326 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
81327 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
81328 help
81329 Enabling this option turns a certain set of sanity checks for user
81330 copy operations into compile time failures.
81331 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
81332
81333 config PROVIDE_OHCI1394_DMA_INIT
81334 bool "Remote debugging over FireWire early on boot"
81335 - depends on PCI && X86
81336 + depends on PCI && X86 && !GRKERNSEC
81337 help
81338 If you want to debug problems which hang or crash the kernel early
81339 on boot and the crashing machine has a FireWire port, you can use
81340 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
81341
81342 config FIREWIRE_OHCI_REMOTE_DMA
81343 bool "Remote debugging over FireWire with firewire-ohci"
81344 - depends on FIREWIRE_OHCI
81345 + depends on FIREWIRE_OHCI && !GRKERNSEC
81346 help
81347 This option lets you use the FireWire bus for remote debugging
81348 with help of the firewire-ohci driver. It enables unfiltered
81349 diff --git a/lib/Makefile b/lib/Makefile
81350 index c55a037..fb46e3b 100644
81351 --- a/lib/Makefile
81352 +++ b/lib/Makefile
81353 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
81354
81355 obj-$(CONFIG_BTREE) += btree.o
81356 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
81357 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
81358 +obj-y += list_debug.o
81359 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
81360
81361 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
81362 diff --git a/lib/bitmap.c b/lib/bitmap.c
81363 index 06f7e4f..f3cf2b0 100644
81364 --- a/lib/bitmap.c
81365 +++ b/lib/bitmap.c
81366 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
81367 {
81368 int c, old_c, totaldigits, ndigits, nchunks, nbits;
81369 u32 chunk;
81370 - const char __user __force *ubuf = (const char __user __force *)buf;
81371 + const char __user *ubuf = (const char __force_user *)buf;
81372
81373 bitmap_zero(maskp, nmaskbits);
81374
81375 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
81376 {
81377 if (!access_ok(VERIFY_READ, ubuf, ulen))
81378 return -EFAULT;
81379 - return __bitmap_parse((const char __force *)ubuf,
81380 + return __bitmap_parse((const char __force_kernel *)ubuf,
81381 ulen, 1, maskp, nmaskbits);
81382
81383 }
81384 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
81385 {
81386 unsigned a, b;
81387 int c, old_c, totaldigits;
81388 - const char __user __force *ubuf = (const char __user __force *)buf;
81389 + const char __user *ubuf = (const char __force_user *)buf;
81390 int exp_digit, in_range;
81391
81392 totaldigits = c = 0;
81393 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
81394 {
81395 if (!access_ok(VERIFY_READ, ubuf, ulen))
81396 return -EFAULT;
81397 - return __bitmap_parselist((const char __force *)ubuf,
81398 + return __bitmap_parselist((const char __force_kernel *)ubuf,
81399 ulen, 1, maskp, nmaskbits);
81400 }
81401 EXPORT_SYMBOL(bitmap_parselist_user);
81402 diff --git a/lib/bug.c b/lib/bug.c
81403 index 1686034..a9c00c8 100644
81404 --- a/lib/bug.c
81405 +++ b/lib/bug.c
81406 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
81407 return BUG_TRAP_TYPE_NONE;
81408
81409 bug = find_bug(bugaddr);
81410 + if (!bug)
81411 + return BUG_TRAP_TYPE_NONE;
81412
81413 file = NULL;
81414 line = 0;
81415 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
81416 index 37061ed..da83f48 100644
81417 --- a/lib/debugobjects.c
81418 +++ b/lib/debugobjects.c
81419 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
81420 if (limit > 4)
81421 return;
81422
81423 - is_on_stack = object_is_on_stack(addr);
81424 + is_on_stack = object_starts_on_stack(addr);
81425 if (is_on_stack == onstack)
81426 return;
81427
81428 diff --git a/lib/devres.c b/lib/devres.c
81429 index 8235331..5881053 100644
81430 --- a/lib/devres.c
81431 +++ b/lib/devres.c
81432 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
81433 void devm_iounmap(struct device *dev, void __iomem *addr)
81434 {
81435 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
81436 - (void *)addr));
81437 + (void __force *)addr));
81438 iounmap(addr);
81439 }
81440 EXPORT_SYMBOL(devm_iounmap);
81441 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
81442 {
81443 ioport_unmap(addr);
81444 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
81445 - devm_ioport_map_match, (void *)addr));
81446 + devm_ioport_map_match, (void __force *)addr));
81447 }
81448 EXPORT_SYMBOL(devm_ioport_unmap);
81449 #endif /* CONFIG_HAS_IOPORT */
81450 diff --git a/lib/div64.c b/lib/div64.c
81451 index a163b6c..9618fa5 100644
81452 --- a/lib/div64.c
81453 +++ b/lib/div64.c
81454 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
81455 EXPORT_SYMBOL(__div64_32);
81456
81457 #ifndef div_s64_rem
81458 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
81459 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
81460 {
81461 u64 quotient;
81462
81463 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
81464 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
81465 */
81466 #ifndef div64_u64
81467 -u64 div64_u64(u64 dividend, u64 divisor)
81468 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
81469 {
81470 u32 high = divisor >> 32;
81471 u64 quot;
81472 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
81473 index d87a17a..ac0d79a 100644
81474 --- a/lib/dma-debug.c
81475 +++ b/lib/dma-debug.c
81476 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
81477
81478 void dma_debug_add_bus(struct bus_type *bus)
81479 {
81480 - struct notifier_block *nb;
81481 + notifier_block_no_const *nb;
81482
81483 if (global_disable)
81484 return;
81485 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
81486
81487 static void check_for_stack(struct device *dev, void *addr)
81488 {
81489 - if (object_is_on_stack(addr))
81490 + if (object_starts_on_stack(addr))
81491 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
81492 "stack [addr=%p]\n", addr);
81493 }
81494 diff --git a/lib/inflate.c b/lib/inflate.c
81495 index 013a761..c28f3fc 100644
81496 --- a/lib/inflate.c
81497 +++ b/lib/inflate.c
81498 @@ -269,7 +269,7 @@ static void free(void *where)
81499 malloc_ptr = free_mem_ptr;
81500 }
81501 #else
81502 -#define malloc(a) kmalloc(a, GFP_KERNEL)
81503 +#define malloc(a) kmalloc((a), GFP_KERNEL)
81504 #define free(a) kfree(a)
81505 #endif
81506
81507 diff --git a/lib/ioremap.c b/lib/ioremap.c
81508 index 0c9216c..863bd89 100644
81509 --- a/lib/ioremap.c
81510 +++ b/lib/ioremap.c
81511 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
81512 unsigned long next;
81513
81514 phys_addr -= addr;
81515 - pmd = pmd_alloc(&init_mm, pud, addr);
81516 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
81517 if (!pmd)
81518 return -ENOMEM;
81519 do {
81520 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
81521 unsigned long next;
81522
81523 phys_addr -= addr;
81524 - pud = pud_alloc(&init_mm, pgd, addr);
81525 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
81526 if (!pud)
81527 return -ENOMEM;
81528 do {
81529 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
81530 index bd2bea9..6b3c95e 100644
81531 --- a/lib/is_single_threaded.c
81532 +++ b/lib/is_single_threaded.c
81533 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
81534 struct task_struct *p, *t;
81535 bool ret;
81536
81537 + if (!mm)
81538 + return true;
81539 +
81540 if (atomic_read(&task->signal->live) != 1)
81541 return false;
81542
81543 diff --git a/lib/kobject.c b/lib/kobject.c
81544 index b7e29a6..2f3ca75 100644
81545 --- a/lib/kobject.c
81546 +++ b/lib/kobject.c
81547 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
81548 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
81549 if (!kset)
81550 return NULL;
81551 - retval = kobject_set_name(&kset->kobj, name);
81552 + retval = kobject_set_name(&kset->kobj, "%s", name);
81553 if (retval) {
81554 kfree(kset);
81555 return NULL;
81556 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
81557
81558
81559 static DEFINE_SPINLOCK(kobj_ns_type_lock);
81560 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
81561 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
81562
81563 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
81564 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
81565 {
81566 enum kobj_ns_type type = ops->type;
81567 int error;
81568 diff --git a/lib/list_debug.c b/lib/list_debug.c
81569 index c24c2f7..06e070b 100644
81570 --- a/lib/list_debug.c
81571 +++ b/lib/list_debug.c
81572 @@ -11,7 +11,9 @@
81573 #include <linux/bug.h>
81574 #include <linux/kernel.h>
81575 #include <linux/rculist.h>
81576 +#include <linux/mm.h>
81577
81578 +#ifdef CONFIG_DEBUG_LIST
81579 /*
81580 * Insert a new entry between two known consecutive entries.
81581 *
81582 @@ -19,21 +21,32 @@
81583 * the prev/next entries already!
81584 */
81585
81586 -void __list_add(struct list_head *new,
81587 - struct list_head *prev,
81588 - struct list_head *next)
81589 +static bool __list_add_debug(struct list_head *new,
81590 + struct list_head *prev,
81591 + struct list_head *next)
81592 {
81593 - WARN(next->prev != prev,
81594 + if (WARN(next->prev != prev,
81595 "list_add corruption. next->prev should be "
81596 "prev (%p), but was %p. (next=%p).\n",
81597 - prev, next->prev, next);
81598 - WARN(prev->next != next,
81599 + prev, next->prev, next) ||
81600 + WARN(prev->next != next,
81601 "list_add corruption. prev->next should be "
81602 "next (%p), but was %p. (prev=%p).\n",
81603 - next, prev->next, prev);
81604 - WARN(new == prev || new == next,
81605 - "list_add double add: new=%p, prev=%p, next=%p.\n",
81606 - new, prev, next);
81607 + next, prev->next, prev) ||
81608 + WARN(new == prev || new == next,
81609 + "list_add double add: new=%p, prev=%p, next=%p.\n",
81610 + new, prev, next))
81611 + return false;
81612 + return true;
81613 +}
81614 +
81615 +void __list_add(struct list_head *new,
81616 + struct list_head *prev,
81617 + struct list_head *next)
81618 +{
81619 + if (!__list_add_debug(new, prev, next))
81620 + return;
81621 +
81622 next->prev = new;
81623 new->next = next;
81624 new->prev = prev;
81625 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
81626 }
81627 EXPORT_SYMBOL(__list_add);
81628
81629 -void __list_del_entry(struct list_head *entry)
81630 +static bool __list_del_entry_debug(struct list_head *entry)
81631 {
81632 struct list_head *prev, *next;
81633
81634 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
81635 WARN(next->prev != entry,
81636 "list_del corruption. next->prev should be %p, "
81637 "but was %p\n", entry, next->prev))
81638 + return false;
81639 + return true;
81640 +}
81641 +
81642 +void __list_del_entry(struct list_head *entry)
81643 +{
81644 + if (!__list_del_entry_debug(entry))
81645 return;
81646
81647 - __list_del(prev, next);
81648 + __list_del(entry->prev, entry->next);
81649 }
81650 EXPORT_SYMBOL(__list_del_entry);
81651
81652 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
81653 void __list_add_rcu(struct list_head *new,
81654 struct list_head *prev, struct list_head *next)
81655 {
81656 - WARN(next->prev != prev,
81657 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
81658 - prev, next->prev, next);
81659 - WARN(prev->next != next,
81660 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
81661 - next, prev->next, prev);
81662 + if (!__list_add_debug(new, prev, next))
81663 + return;
81664 +
81665 new->next = next;
81666 new->prev = prev;
81667 rcu_assign_pointer(list_next_rcu(prev), new);
81668 next->prev = new;
81669 }
81670 EXPORT_SYMBOL(__list_add_rcu);
81671 +#endif
81672 +
81673 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
81674 +{
81675 +#ifdef CONFIG_DEBUG_LIST
81676 + if (!__list_add_debug(new, prev, next))
81677 + return;
81678 +#endif
81679 +
81680 + pax_open_kernel();
81681 + next->prev = new;
81682 + new->next = next;
81683 + new->prev = prev;
81684 + prev->next = new;
81685 + pax_close_kernel();
81686 +}
81687 +EXPORT_SYMBOL(__pax_list_add);
81688 +
81689 +void pax_list_del(struct list_head *entry)
81690 +{
81691 +#ifdef CONFIG_DEBUG_LIST
81692 + if (!__list_del_entry_debug(entry))
81693 + return;
81694 +#endif
81695 +
81696 + pax_open_kernel();
81697 + __list_del(entry->prev, entry->next);
81698 + entry->next = LIST_POISON1;
81699 + entry->prev = LIST_POISON2;
81700 + pax_close_kernel();
81701 +}
81702 +EXPORT_SYMBOL(pax_list_del);
81703 +
81704 +void pax_list_del_init(struct list_head *entry)
81705 +{
81706 + pax_open_kernel();
81707 + __list_del(entry->prev, entry->next);
81708 + INIT_LIST_HEAD(entry);
81709 + pax_close_kernel();
81710 +}
81711 +EXPORT_SYMBOL(pax_list_del_init);
81712 +
81713 +void __pax_list_add_rcu(struct list_head *new,
81714 + struct list_head *prev, struct list_head *next)
81715 +{
81716 +#ifdef CONFIG_DEBUG_LIST
81717 + if (!__list_add_debug(new, prev, next))
81718 + return;
81719 +#endif
81720 +
81721 + pax_open_kernel();
81722 + new->next = next;
81723 + new->prev = prev;
81724 + rcu_assign_pointer(list_next_rcu(prev), new);
81725 + next->prev = new;
81726 + pax_close_kernel();
81727 +}
81728 +EXPORT_SYMBOL(__pax_list_add_rcu);
81729 +
81730 +void pax_list_del_rcu(struct list_head *entry)
81731 +{
81732 +#ifdef CONFIG_DEBUG_LIST
81733 + if (!__list_del_entry_debug(entry))
81734 + return;
81735 +#endif
81736 +
81737 + pax_open_kernel();
81738 + __list_del(entry->prev, entry->next);
81739 + entry->next = LIST_POISON1;
81740 + entry->prev = LIST_POISON2;
81741 + pax_close_kernel();
81742 +}
81743 +EXPORT_SYMBOL(pax_list_del_rcu);
81744 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
81745 index e796429..6e38f9f 100644
81746 --- a/lib/radix-tree.c
81747 +++ b/lib/radix-tree.c
81748 @@ -92,7 +92,7 @@ struct radix_tree_preload {
81749 int nr;
81750 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
81751 };
81752 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
81753 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
81754
81755 static inline void *ptr_to_indirect(void *ptr)
81756 {
81757 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
81758 index bb2b201..46abaf9 100644
81759 --- a/lib/strncpy_from_user.c
81760 +++ b/lib/strncpy_from_user.c
81761 @@ -21,7 +21,7 @@
81762 */
81763 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
81764 {
81765 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81766 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81767 long res = 0;
81768
81769 /*
81770 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
81771 index a28df52..3d55877 100644
81772 --- a/lib/strnlen_user.c
81773 +++ b/lib/strnlen_user.c
81774 @@ -26,7 +26,7 @@
81775 */
81776 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
81777 {
81778 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81779 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81780 long align, res = 0;
81781 unsigned long c;
81782
81783 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
81784 index d23762e..e21eab2 100644
81785 --- a/lib/swiotlb.c
81786 +++ b/lib/swiotlb.c
81787 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
81788
81789 void
81790 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
81791 - dma_addr_t dev_addr)
81792 + dma_addr_t dev_addr, struct dma_attrs *attrs)
81793 {
81794 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
81795
81796 diff --git a/lib/usercopy.c b/lib/usercopy.c
81797 index 4f5b1dd..7cab418 100644
81798 --- a/lib/usercopy.c
81799 +++ b/lib/usercopy.c
81800 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
81801 WARN(1, "Buffer overflow detected!\n");
81802 }
81803 EXPORT_SYMBOL(copy_from_user_overflow);
81804 +
81805 +void copy_to_user_overflow(void)
81806 +{
81807 + WARN(1, "Buffer overflow detected!\n");
81808 +}
81809 +EXPORT_SYMBOL(copy_to_user_overflow);
81810 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
81811 index e149c64..24aa71a 100644
81812 --- a/lib/vsprintf.c
81813 +++ b/lib/vsprintf.c
81814 @@ -16,6 +16,9 @@
81815 * - scnprintf and vscnprintf
81816 */
81817
81818 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81819 +#define __INCLUDED_BY_HIDESYM 1
81820 +#endif
81821 #include <stdarg.h>
81822 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
81823 #include <linux/types.h>
81824 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
81825 return number(buf, end, *(const netdev_features_t *)addr, spec);
81826 }
81827
81828 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81829 +int kptr_restrict __read_mostly = 2;
81830 +#else
81831 int kptr_restrict __read_mostly;
81832 +#endif
81833
81834 /*
81835 * Show a '%p' thing. A kernel extension is that the '%p' is followed
81836 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
81837 * - 'f' For simple symbolic function names without offset
81838 * - 'S' For symbolic direct pointers with offset
81839 * - 's' For symbolic direct pointers without offset
81840 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
81841 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
81842 * - 'B' For backtraced symbolic direct pointers with offset
81843 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
81844 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81845
81846 if (!ptr && *fmt != 'K') {
81847 /*
81848 - * Print (null) with the same width as a pointer so it makes
81849 + * Print (nil) with the same width as a pointer so it makes
81850 * tabular output look nice.
81851 */
81852 if (spec.field_width == -1)
81853 spec.field_width = default_width;
81854 - return string(buf, end, "(null)", spec);
81855 + return string(buf, end, "(nil)", spec);
81856 }
81857
81858 switch (*fmt) {
81859 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81860 /* Fallthrough */
81861 case 'S':
81862 case 's':
81863 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81864 + break;
81865 +#else
81866 + return symbol_string(buf, end, ptr, spec, fmt);
81867 +#endif
81868 + case 'A':
81869 case 'B':
81870 return symbol_string(buf, end, ptr, spec, fmt);
81871 case 'R':
81872 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81873 va_end(va);
81874 return buf;
81875 }
81876 + case 'P':
81877 + break;
81878 case 'K':
81879 /*
81880 * %pK cannot be used in IRQ context because its test
81881 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81882 return number(buf, end,
81883 (unsigned long long) *((phys_addr_t *)ptr), spec);
81884 }
81885 +
81886 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81887 + /* 'P' = approved pointers to copy to userland,
81888 + as in the /proc/kallsyms case, as we make it display nothing
81889 + for non-root users, and the real contents for root users
81890 + Also ignore 'K' pointers, since we force their NULLing for non-root users
81891 + above
81892 + */
81893 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
81894 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
81895 + dump_stack();
81896 + ptr = NULL;
81897 + }
81898 +#endif
81899 +
81900 spec.flags |= SMALL;
81901 if (spec.field_width == -1) {
81902 spec.field_width = default_width;
81903 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81904 typeof(type) value; \
81905 if (sizeof(type) == 8) { \
81906 args = PTR_ALIGN(args, sizeof(u32)); \
81907 - *(u32 *)&value = *(u32 *)args; \
81908 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
81909 + *(u32 *)&value = *(const u32 *)args; \
81910 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
81911 } else { \
81912 args = PTR_ALIGN(args, sizeof(type)); \
81913 - value = *(typeof(type) *)args; \
81914 + value = *(const typeof(type) *)args; \
81915 } \
81916 args += sizeof(type); \
81917 value; \
81918 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81919 case FORMAT_TYPE_STR: {
81920 const char *str_arg = args;
81921 args += strlen(str_arg) + 1;
81922 - str = string(str, end, (char *)str_arg, spec);
81923 + str = string(str, end, str_arg, spec);
81924 break;
81925 }
81926
81927 diff --git a/localversion-grsec b/localversion-grsec
81928 new file mode 100644
81929 index 0000000..7cd6065
81930 --- /dev/null
81931 +++ b/localversion-grsec
81932 @@ -0,0 +1 @@
81933 +-grsec
81934 diff --git a/mm/Kconfig b/mm/Kconfig
81935 index e742d06..c56fdd8 100644
81936 --- a/mm/Kconfig
81937 +++ b/mm/Kconfig
81938 @@ -317,10 +317,10 @@ config KSM
81939 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
81940
81941 config DEFAULT_MMAP_MIN_ADDR
81942 - int "Low address space to protect from user allocation"
81943 + int "Low address space to protect from user allocation"
81944 depends on MMU
81945 - default 4096
81946 - help
81947 + default 65536
81948 + help
81949 This is the portion of low virtual memory which should be protected
81950 from userspace allocation. Keeping a user from writing to low pages
81951 can help reduce the impact of kernel NULL pointer bugs.
81952 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
81953
81954 config HWPOISON_INJECT
81955 tristate "HWPoison pages injector"
81956 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
81957 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
81958 select PROC_PAGE_MONITOR
81959
81960 config NOMMU_INITIAL_TRIM_EXCESS
81961 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
81962 index 5025174..9fc1c5c 100644
81963 --- a/mm/backing-dev.c
81964 +++ b/mm/backing-dev.c
81965 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
81966 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81967 unsigned int cap)
81968 {
81969 - char tmp[32];
81970 int err;
81971
81972 bdi->name = name;
81973 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81974 if (err)
81975 return err;
81976
81977 - sprintf(tmp, "%.28s%s", name, "-%d");
81978 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
81979 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
81980 if (err) {
81981 bdi_destroy(bdi);
81982 return err;
81983 diff --git a/mm/filemap.c b/mm/filemap.c
81984 index 7905fe7..e60faa8 100644
81985 --- a/mm/filemap.c
81986 +++ b/mm/filemap.c
81987 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
81988 struct address_space *mapping = file->f_mapping;
81989
81990 if (!mapping->a_ops->readpage)
81991 - return -ENOEXEC;
81992 + return -ENODEV;
81993 file_accessed(file);
81994 vma->vm_ops = &generic_file_vm_ops;
81995 return 0;
81996 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
81997 *pos = i_size_read(inode);
81998
81999 if (limit != RLIM_INFINITY) {
82000 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
82001 if (*pos >= limit) {
82002 send_sig(SIGXFSZ, current, 0);
82003 return -EFBIG;
82004 diff --git a/mm/fremap.c b/mm/fremap.c
82005 index 87da359..3f41cb1 100644
82006 --- a/mm/fremap.c
82007 +++ b/mm/fremap.c
82008 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
82009 retry:
82010 vma = find_vma(mm, start);
82011
82012 +#ifdef CONFIG_PAX_SEGMEXEC
82013 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
82014 + goto out;
82015 +#endif
82016 +
82017 /*
82018 * Make sure the vma is shared, that it supports prefaulting,
82019 * and that the remapped range is valid and fully within
82020 diff --git a/mm/highmem.c b/mm/highmem.c
82021 index b32b70c..e512eb0 100644
82022 --- a/mm/highmem.c
82023 +++ b/mm/highmem.c
82024 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
82025 * So no dangers, even with speculative execution.
82026 */
82027 page = pte_page(pkmap_page_table[i]);
82028 + pax_open_kernel();
82029 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
82030 -
82031 + pax_close_kernel();
82032 set_page_address(page, NULL);
82033 need_flush = 1;
82034 }
82035 @@ -198,9 +199,11 @@ start:
82036 }
82037 }
82038 vaddr = PKMAP_ADDR(last_pkmap_nr);
82039 +
82040 + pax_open_kernel();
82041 set_pte_at(&init_mm, vaddr,
82042 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
82043 -
82044 + pax_close_kernel();
82045 pkmap_count[last_pkmap_nr] = 1;
82046 set_page_address(page, (void *)vaddr);
82047
82048 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
82049 index 5cf99bf..28634c8 100644
82050 --- a/mm/hugetlb.c
82051 +++ b/mm/hugetlb.c
82052 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
82053 struct hstate *h = &default_hstate;
82054 unsigned long tmp;
82055 int ret;
82056 + ctl_table_no_const hugetlb_table;
82057
82058 tmp = h->max_huge_pages;
82059
82060 if (write && h->order >= MAX_ORDER)
82061 return -EINVAL;
82062
82063 - table->data = &tmp;
82064 - table->maxlen = sizeof(unsigned long);
82065 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
82066 + hugetlb_table = *table;
82067 + hugetlb_table.data = &tmp;
82068 + hugetlb_table.maxlen = sizeof(unsigned long);
82069 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
82070 if (ret)
82071 goto out;
82072
82073 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
82074 struct hstate *h = &default_hstate;
82075 unsigned long tmp;
82076 int ret;
82077 + ctl_table_no_const hugetlb_table;
82078
82079 tmp = h->nr_overcommit_huge_pages;
82080
82081 if (write && h->order >= MAX_ORDER)
82082 return -EINVAL;
82083
82084 - table->data = &tmp;
82085 - table->maxlen = sizeof(unsigned long);
82086 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
82087 + hugetlb_table = *table;
82088 + hugetlb_table.data = &tmp;
82089 + hugetlb_table.maxlen = sizeof(unsigned long);
82090 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
82091 if (ret)
82092 goto out;
82093
82094 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
82095 return 1;
82096 }
82097
82098 +#ifdef CONFIG_PAX_SEGMEXEC
82099 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
82100 +{
82101 + struct mm_struct *mm = vma->vm_mm;
82102 + struct vm_area_struct *vma_m;
82103 + unsigned long address_m;
82104 + pte_t *ptep_m;
82105 +
82106 + vma_m = pax_find_mirror_vma(vma);
82107 + if (!vma_m)
82108 + return;
82109 +
82110 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82111 + address_m = address + SEGMEXEC_TASK_SIZE;
82112 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
82113 + get_page(page_m);
82114 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
82115 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
82116 +}
82117 +#endif
82118 +
82119 /*
82120 * Hugetlb_cow() should be called with page lock of the original hugepage held.
82121 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
82122 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
82123 make_huge_pte(vma, new_page, 1));
82124 page_remove_rmap(old_page);
82125 hugepage_add_new_anon_rmap(new_page, vma, address);
82126 +
82127 +#ifdef CONFIG_PAX_SEGMEXEC
82128 + pax_mirror_huge_pte(vma, address, new_page);
82129 +#endif
82130 +
82131 /* Make the old page be freed below */
82132 new_page = old_page;
82133 }
82134 @@ -2821,6 +2851,10 @@ retry:
82135 && (vma->vm_flags & VM_SHARED)));
82136 set_huge_pte_at(mm, address, ptep, new_pte);
82137
82138 +#ifdef CONFIG_PAX_SEGMEXEC
82139 + pax_mirror_huge_pte(vma, address, page);
82140 +#endif
82141 +
82142 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
82143 /* Optimization, do the COW without a second fault */
82144 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
82145 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82146 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
82147 struct hstate *h = hstate_vma(vma);
82148
82149 +#ifdef CONFIG_PAX_SEGMEXEC
82150 + struct vm_area_struct *vma_m;
82151 +#endif
82152 +
82153 address &= huge_page_mask(h);
82154
82155 ptep = huge_pte_offset(mm, address);
82156 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82157 VM_FAULT_SET_HINDEX(hstate_index(h));
82158 }
82159
82160 +#ifdef CONFIG_PAX_SEGMEXEC
82161 + vma_m = pax_find_mirror_vma(vma);
82162 + if (vma_m) {
82163 + unsigned long address_m;
82164 +
82165 + if (vma->vm_start > vma_m->vm_start) {
82166 + address_m = address;
82167 + address -= SEGMEXEC_TASK_SIZE;
82168 + vma = vma_m;
82169 + h = hstate_vma(vma);
82170 + } else
82171 + address_m = address + SEGMEXEC_TASK_SIZE;
82172 +
82173 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
82174 + return VM_FAULT_OOM;
82175 + address_m &= HPAGE_MASK;
82176 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
82177 + }
82178 +#endif
82179 +
82180 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
82181 if (!ptep)
82182 return VM_FAULT_OOM;
82183 diff --git a/mm/internal.h b/mm/internal.h
82184 index 8562de0..7fdfe92 100644
82185 --- a/mm/internal.h
82186 +++ b/mm/internal.h
82187 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
82188 * in mm/page_alloc.c
82189 */
82190 extern void __free_pages_bootmem(struct page *page, unsigned int order);
82191 +extern void free_compound_page(struct page *page);
82192 extern void prep_compound_page(struct page *page, unsigned long order);
82193 #ifdef CONFIG_MEMORY_FAILURE
82194 extern bool is_free_buddy_page(struct page *page);
82195 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
82196 index c8d7f31..2dbeffd 100644
82197 --- a/mm/kmemleak.c
82198 +++ b/mm/kmemleak.c
82199 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
82200
82201 for (i = 0; i < object->trace_len; i++) {
82202 void *ptr = (void *)object->trace[i];
82203 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
82204 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
82205 }
82206 }
82207
82208 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
82209 return -ENOMEM;
82210 }
82211
82212 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
82213 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
82214 &kmemleak_fops);
82215 if (!dentry)
82216 pr_warning("Failed to create the debugfs kmemleak file\n");
82217 diff --git a/mm/maccess.c b/mm/maccess.c
82218 index d53adf9..03a24bf 100644
82219 --- a/mm/maccess.c
82220 +++ b/mm/maccess.c
82221 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
82222 set_fs(KERNEL_DS);
82223 pagefault_disable();
82224 ret = __copy_from_user_inatomic(dst,
82225 - (__force const void __user *)src, size);
82226 + (const void __force_user *)src, size);
82227 pagefault_enable();
82228 set_fs(old_fs);
82229
82230 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
82231
82232 set_fs(KERNEL_DS);
82233 pagefault_disable();
82234 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
82235 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
82236 pagefault_enable();
82237 set_fs(old_fs);
82238
82239 diff --git a/mm/madvise.c b/mm/madvise.c
82240 index 7055883..aafb1ed 100644
82241 --- a/mm/madvise.c
82242 +++ b/mm/madvise.c
82243 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
82244 pgoff_t pgoff;
82245 unsigned long new_flags = vma->vm_flags;
82246
82247 +#ifdef CONFIG_PAX_SEGMEXEC
82248 + struct vm_area_struct *vma_m;
82249 +#endif
82250 +
82251 switch (behavior) {
82252 case MADV_NORMAL:
82253 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
82254 @@ -126,6 +130,13 @@ success:
82255 /*
82256 * vm_flags is protected by the mmap_sem held in write mode.
82257 */
82258 +
82259 +#ifdef CONFIG_PAX_SEGMEXEC
82260 + vma_m = pax_find_mirror_vma(vma);
82261 + if (vma_m)
82262 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
82263 +#endif
82264 +
82265 vma->vm_flags = new_flags;
82266
82267 out:
82268 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
82269 struct vm_area_struct ** prev,
82270 unsigned long start, unsigned long end)
82271 {
82272 +
82273 +#ifdef CONFIG_PAX_SEGMEXEC
82274 + struct vm_area_struct *vma_m;
82275 +#endif
82276 +
82277 *prev = vma;
82278 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
82279 return -EINVAL;
82280 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
82281 zap_page_range(vma, start, end - start, &details);
82282 } else
82283 zap_page_range(vma, start, end - start, NULL);
82284 +
82285 +#ifdef CONFIG_PAX_SEGMEXEC
82286 + vma_m = pax_find_mirror_vma(vma);
82287 + if (vma_m) {
82288 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
82289 + struct zap_details details = {
82290 + .nonlinear_vma = vma_m,
82291 + .last_index = ULONG_MAX,
82292 + };
82293 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
82294 + } else
82295 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
82296 + }
82297 +#endif
82298 +
82299 return 0;
82300 }
82301
82302 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
82303 if (end < start)
82304 return error;
82305
82306 +#ifdef CONFIG_PAX_SEGMEXEC
82307 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82308 + if (end > SEGMEXEC_TASK_SIZE)
82309 + return error;
82310 + } else
82311 +#endif
82312 +
82313 + if (end > TASK_SIZE)
82314 + return error;
82315 +
82316 error = 0;
82317 if (end == start)
82318 return error;
82319 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
82320 index ceb0c7f..b2b8e94 100644
82321 --- a/mm/memory-failure.c
82322 +++ b/mm/memory-failure.c
82323 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
82324
82325 int sysctl_memory_failure_recovery __read_mostly = 1;
82326
82327 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
82328 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
82329
82330 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
82331
82332 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
82333 pfn, t->comm, t->pid);
82334 si.si_signo = SIGBUS;
82335 si.si_errno = 0;
82336 - si.si_addr = (void *)addr;
82337 + si.si_addr = (void __user *)addr;
82338 #ifdef __ARCH_SI_TRAPNO
82339 si.si_trapno = trapno;
82340 #endif
82341 @@ -760,7 +760,7 @@ static struct page_state {
82342 unsigned long res;
82343 char *msg;
82344 int (*action)(struct page *p, unsigned long pfn);
82345 -} error_states[] = {
82346 +} __do_const error_states[] = {
82347 { reserved, reserved, "reserved kernel", me_kernel },
82348 /*
82349 * free pages are specially detected outside this table:
82350 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
82351 nr_pages = 1 << compound_order(hpage);
82352 else /* normal page or thp */
82353 nr_pages = 1;
82354 - atomic_long_add(nr_pages, &num_poisoned_pages);
82355 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
82356
82357 /*
82358 * We need/can do nothing about count=0 pages.
82359 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
82360 if (!PageHWPoison(hpage)
82361 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
82362 || (p != hpage && TestSetPageHWPoison(hpage))) {
82363 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82364 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82365 return 0;
82366 }
82367 set_page_hwpoison_huge_page(hpage);
82368 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
82369 }
82370 if (hwpoison_filter(p)) {
82371 if (TestClearPageHWPoison(p))
82372 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82373 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82374 unlock_page(hpage);
82375 put_page(hpage);
82376 return 0;
82377 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
82378 return 0;
82379 }
82380 if (TestClearPageHWPoison(p))
82381 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82382 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82383 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
82384 return 0;
82385 }
82386 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
82387 */
82388 if (TestClearPageHWPoison(page)) {
82389 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
82390 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82391 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82392 freeit = 1;
82393 if (PageHuge(page))
82394 clear_page_hwpoison_huge_page(page);
82395 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
82396 } else {
82397 set_page_hwpoison_huge_page(hpage);
82398 dequeue_hwpoisoned_huge_page(hpage);
82399 - atomic_long_add(1 << compound_trans_order(hpage),
82400 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
82401 &num_poisoned_pages);
82402 }
82403 /* keep elevated page count for bad page */
82404 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
82405 if (PageHuge(page)) {
82406 set_page_hwpoison_huge_page(hpage);
82407 dequeue_hwpoisoned_huge_page(hpage);
82408 - atomic_long_add(1 << compound_trans_order(hpage),
82409 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
82410 &num_poisoned_pages);
82411 } else {
82412 SetPageHWPoison(page);
82413 - atomic_long_inc(&num_poisoned_pages);
82414 + atomic_long_inc_unchecked(&num_poisoned_pages);
82415 }
82416 }
82417 /* keep elevated page count for bad page */
82418 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
82419 put_page(page);
82420 pr_info("soft_offline: %#lx: invalidated\n", pfn);
82421 SetPageHWPoison(page);
82422 - atomic_long_inc(&num_poisoned_pages);
82423 + atomic_long_inc_unchecked(&num_poisoned_pages);
82424 return 0;
82425 }
82426
82427 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
82428 ret = -EIO;
82429 } else {
82430 SetPageHWPoison(page);
82431 - atomic_long_inc(&num_poisoned_pages);
82432 + atomic_long_inc_unchecked(&num_poisoned_pages);
82433 }
82434 } else {
82435 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
82436 diff --git a/mm/memory.c b/mm/memory.c
82437 index 5e50800..c47ba9a 100644
82438 --- a/mm/memory.c
82439 +++ b/mm/memory.c
82440 @@ -429,6 +429,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
82441 free_pte_range(tlb, pmd, addr);
82442 } while (pmd++, addr = next, addr != end);
82443
82444 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
82445 start &= PUD_MASK;
82446 if (start < floor)
82447 return;
82448 @@ -443,6 +444,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
82449 pmd = pmd_offset(pud, start);
82450 pud_clear(pud);
82451 pmd_free_tlb(tlb, pmd, start);
82452 +#endif
82453 +
82454 }
82455
82456 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
82457 @@ -462,6 +465,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
82458 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
82459 } while (pud++, addr = next, addr != end);
82460
82461 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
82462 start &= PGDIR_MASK;
82463 if (start < floor)
82464 return;
82465 @@ -476,6 +480,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
82466 pud = pud_offset(pgd, start);
82467 pgd_clear(pgd);
82468 pud_free_tlb(tlb, pud, start);
82469 +#endif
82470 +
82471 }
82472
82473 /*
82474 @@ -1638,12 +1644,6 @@ no_page_table:
82475 return page;
82476 }
82477
82478 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
82479 -{
82480 - return stack_guard_page_start(vma, addr) ||
82481 - stack_guard_page_end(vma, addr+PAGE_SIZE);
82482 -}
82483 -
82484 /**
82485 * __get_user_pages() - pin user pages in memory
82486 * @tsk: task_struct of target task
82487 @@ -1730,10 +1730,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
82488
82489 i = 0;
82490
82491 - do {
82492 + while (nr_pages) {
82493 struct vm_area_struct *vma;
82494
82495 - vma = find_extend_vma(mm, start);
82496 + vma = find_vma(mm, start);
82497 if (!vma && in_gate_area(mm, start)) {
82498 unsigned long pg = start & PAGE_MASK;
82499 pgd_t *pgd;
82500 @@ -1782,7 +1782,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
82501 goto next_page;
82502 }
82503
82504 - if (!vma ||
82505 + if (!vma || start < vma->vm_start ||
82506 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
82507 !(vm_flags & vma->vm_flags))
82508 return i ? : -EFAULT;
82509 @@ -1811,11 +1811,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
82510 int ret;
82511 unsigned int fault_flags = 0;
82512
82513 - /* For mlock, just skip the stack guard page. */
82514 - if (foll_flags & FOLL_MLOCK) {
82515 - if (stack_guard_page(vma, start))
82516 - goto next_page;
82517 - }
82518 if (foll_flags & FOLL_WRITE)
82519 fault_flags |= FAULT_FLAG_WRITE;
82520 if (nonblocking)
82521 @@ -1895,7 +1890,7 @@ next_page:
82522 start += page_increm * PAGE_SIZE;
82523 nr_pages -= page_increm;
82524 } while (nr_pages && start < vma->vm_end);
82525 - } while (nr_pages);
82526 + }
82527 return i;
82528 }
82529 EXPORT_SYMBOL(__get_user_pages);
82530 @@ -2102,6 +2097,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
82531 page_add_file_rmap(page);
82532 set_pte_at(mm, addr, pte, mk_pte(page, prot));
82533
82534 +#ifdef CONFIG_PAX_SEGMEXEC
82535 + pax_mirror_file_pte(vma, addr, page, ptl);
82536 +#endif
82537 +
82538 retval = 0;
82539 pte_unmap_unlock(pte, ptl);
82540 return retval;
82541 @@ -2146,9 +2145,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
82542 if (!page_count(page))
82543 return -EINVAL;
82544 if (!(vma->vm_flags & VM_MIXEDMAP)) {
82545 +
82546 +#ifdef CONFIG_PAX_SEGMEXEC
82547 + struct vm_area_struct *vma_m;
82548 +#endif
82549 +
82550 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
82551 BUG_ON(vma->vm_flags & VM_PFNMAP);
82552 vma->vm_flags |= VM_MIXEDMAP;
82553 +
82554 +#ifdef CONFIG_PAX_SEGMEXEC
82555 + vma_m = pax_find_mirror_vma(vma);
82556 + if (vma_m)
82557 + vma_m->vm_flags |= VM_MIXEDMAP;
82558 +#endif
82559 +
82560 }
82561 return insert_page(vma, addr, page, vma->vm_page_prot);
82562 }
82563 @@ -2231,6 +2242,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
82564 unsigned long pfn)
82565 {
82566 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
82567 + BUG_ON(vma->vm_mirror);
82568
82569 if (addr < vma->vm_start || addr >= vma->vm_end)
82570 return -EFAULT;
82571 @@ -2478,7 +2490,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
82572
82573 BUG_ON(pud_huge(*pud));
82574
82575 - pmd = pmd_alloc(mm, pud, addr);
82576 + pmd = (mm == &init_mm) ?
82577 + pmd_alloc_kernel(mm, pud, addr) :
82578 + pmd_alloc(mm, pud, addr);
82579 if (!pmd)
82580 return -ENOMEM;
82581 do {
82582 @@ -2498,7 +2512,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
82583 unsigned long next;
82584 int err;
82585
82586 - pud = pud_alloc(mm, pgd, addr);
82587 + pud = (mm == &init_mm) ?
82588 + pud_alloc_kernel(mm, pgd, addr) :
82589 + pud_alloc(mm, pgd, addr);
82590 if (!pud)
82591 return -ENOMEM;
82592 do {
82593 @@ -2586,6 +2602,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
82594 copy_user_highpage(dst, src, va, vma);
82595 }
82596
82597 +#ifdef CONFIG_PAX_SEGMEXEC
82598 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
82599 +{
82600 + struct mm_struct *mm = vma->vm_mm;
82601 + spinlock_t *ptl;
82602 + pte_t *pte, entry;
82603 +
82604 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
82605 + entry = *pte;
82606 + if (!pte_present(entry)) {
82607 + if (!pte_none(entry)) {
82608 + BUG_ON(pte_file(entry));
82609 + free_swap_and_cache(pte_to_swp_entry(entry));
82610 + pte_clear_not_present_full(mm, address, pte, 0);
82611 + }
82612 + } else {
82613 + struct page *page;
82614 +
82615 + flush_cache_page(vma, address, pte_pfn(entry));
82616 + entry = ptep_clear_flush(vma, address, pte);
82617 + BUG_ON(pte_dirty(entry));
82618 + page = vm_normal_page(vma, address, entry);
82619 + if (page) {
82620 + update_hiwater_rss(mm);
82621 + if (PageAnon(page))
82622 + dec_mm_counter_fast(mm, MM_ANONPAGES);
82623 + else
82624 + dec_mm_counter_fast(mm, MM_FILEPAGES);
82625 + page_remove_rmap(page);
82626 + page_cache_release(page);
82627 + }
82628 + }
82629 + pte_unmap_unlock(pte, ptl);
82630 +}
82631 +
82632 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
82633 + *
82634 + * the ptl of the lower mapped page is held on entry and is not released on exit
82635 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
82636 + */
82637 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
82638 +{
82639 + struct mm_struct *mm = vma->vm_mm;
82640 + unsigned long address_m;
82641 + spinlock_t *ptl_m;
82642 + struct vm_area_struct *vma_m;
82643 + pmd_t *pmd_m;
82644 + pte_t *pte_m, entry_m;
82645 +
82646 + BUG_ON(!page_m || !PageAnon(page_m));
82647 +
82648 + vma_m = pax_find_mirror_vma(vma);
82649 + if (!vma_m)
82650 + return;
82651 +
82652 + BUG_ON(!PageLocked(page_m));
82653 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82654 + address_m = address + SEGMEXEC_TASK_SIZE;
82655 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82656 + pte_m = pte_offset_map(pmd_m, address_m);
82657 + ptl_m = pte_lockptr(mm, pmd_m);
82658 + if (ptl != ptl_m) {
82659 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82660 + if (!pte_none(*pte_m))
82661 + goto out;
82662 + }
82663 +
82664 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
82665 + page_cache_get(page_m);
82666 + page_add_anon_rmap(page_m, vma_m, address_m);
82667 + inc_mm_counter_fast(mm, MM_ANONPAGES);
82668 + set_pte_at(mm, address_m, pte_m, entry_m);
82669 + update_mmu_cache(vma_m, address_m, pte_m);
82670 +out:
82671 + if (ptl != ptl_m)
82672 + spin_unlock(ptl_m);
82673 + pte_unmap(pte_m);
82674 + unlock_page(page_m);
82675 +}
82676 +
82677 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
82678 +{
82679 + struct mm_struct *mm = vma->vm_mm;
82680 + unsigned long address_m;
82681 + spinlock_t *ptl_m;
82682 + struct vm_area_struct *vma_m;
82683 + pmd_t *pmd_m;
82684 + pte_t *pte_m, entry_m;
82685 +
82686 + BUG_ON(!page_m || PageAnon(page_m));
82687 +
82688 + vma_m = pax_find_mirror_vma(vma);
82689 + if (!vma_m)
82690 + return;
82691 +
82692 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82693 + address_m = address + SEGMEXEC_TASK_SIZE;
82694 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82695 + pte_m = pte_offset_map(pmd_m, address_m);
82696 + ptl_m = pte_lockptr(mm, pmd_m);
82697 + if (ptl != ptl_m) {
82698 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82699 + if (!pte_none(*pte_m))
82700 + goto out;
82701 + }
82702 +
82703 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
82704 + page_cache_get(page_m);
82705 + page_add_file_rmap(page_m);
82706 + inc_mm_counter_fast(mm, MM_FILEPAGES);
82707 + set_pte_at(mm, address_m, pte_m, entry_m);
82708 + update_mmu_cache(vma_m, address_m, pte_m);
82709 +out:
82710 + if (ptl != ptl_m)
82711 + spin_unlock(ptl_m);
82712 + pte_unmap(pte_m);
82713 +}
82714 +
82715 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
82716 +{
82717 + struct mm_struct *mm = vma->vm_mm;
82718 + unsigned long address_m;
82719 + spinlock_t *ptl_m;
82720 + struct vm_area_struct *vma_m;
82721 + pmd_t *pmd_m;
82722 + pte_t *pte_m, entry_m;
82723 +
82724 + vma_m = pax_find_mirror_vma(vma);
82725 + if (!vma_m)
82726 + return;
82727 +
82728 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82729 + address_m = address + SEGMEXEC_TASK_SIZE;
82730 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82731 + pte_m = pte_offset_map(pmd_m, address_m);
82732 + ptl_m = pte_lockptr(mm, pmd_m);
82733 + if (ptl != ptl_m) {
82734 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82735 + if (!pte_none(*pte_m))
82736 + goto out;
82737 + }
82738 +
82739 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
82740 + set_pte_at(mm, address_m, pte_m, entry_m);
82741 +out:
82742 + if (ptl != ptl_m)
82743 + spin_unlock(ptl_m);
82744 + pte_unmap(pte_m);
82745 +}
82746 +
82747 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
82748 +{
82749 + struct page *page_m;
82750 + pte_t entry;
82751 +
82752 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
82753 + goto out;
82754 +
82755 + entry = *pte;
82756 + page_m = vm_normal_page(vma, address, entry);
82757 + if (!page_m)
82758 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
82759 + else if (PageAnon(page_m)) {
82760 + if (pax_find_mirror_vma(vma)) {
82761 + pte_unmap_unlock(pte, ptl);
82762 + lock_page(page_m);
82763 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
82764 + if (pte_same(entry, *pte))
82765 + pax_mirror_anon_pte(vma, address, page_m, ptl);
82766 + else
82767 + unlock_page(page_m);
82768 + }
82769 + } else
82770 + pax_mirror_file_pte(vma, address, page_m, ptl);
82771 +
82772 +out:
82773 + pte_unmap_unlock(pte, ptl);
82774 +}
82775 +#endif
82776 +
82777 /*
82778 * This routine handles present pages, when users try to write
82779 * to a shared page. It is done by copying the page to a new address
82780 @@ -2802,6 +2998,12 @@ gotten:
82781 */
82782 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82783 if (likely(pte_same(*page_table, orig_pte))) {
82784 +
82785 +#ifdef CONFIG_PAX_SEGMEXEC
82786 + if (pax_find_mirror_vma(vma))
82787 + BUG_ON(!trylock_page(new_page));
82788 +#endif
82789 +
82790 if (old_page) {
82791 if (!PageAnon(old_page)) {
82792 dec_mm_counter_fast(mm, MM_FILEPAGES);
82793 @@ -2853,6 +3055,10 @@ gotten:
82794 page_remove_rmap(old_page);
82795 }
82796
82797 +#ifdef CONFIG_PAX_SEGMEXEC
82798 + pax_mirror_anon_pte(vma, address, new_page, ptl);
82799 +#endif
82800 +
82801 /* Free the old page.. */
82802 new_page = old_page;
82803 ret |= VM_FAULT_WRITE;
82804 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82805 swap_free(entry);
82806 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
82807 try_to_free_swap(page);
82808 +
82809 +#ifdef CONFIG_PAX_SEGMEXEC
82810 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
82811 +#endif
82812 +
82813 unlock_page(page);
82814 if (page != swapcache) {
82815 /*
82816 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82817
82818 /* No need to invalidate - it was non-present before */
82819 update_mmu_cache(vma, address, page_table);
82820 +
82821 +#ifdef CONFIG_PAX_SEGMEXEC
82822 + pax_mirror_anon_pte(vma, address, page, ptl);
82823 +#endif
82824 +
82825 unlock:
82826 pte_unmap_unlock(page_table, ptl);
82827 out:
82828 @@ -3170,40 +3386,6 @@ out_release:
82829 }
82830
82831 /*
82832 - * This is like a special single-page "expand_{down|up}wards()",
82833 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
82834 - * doesn't hit another vma.
82835 - */
82836 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
82837 -{
82838 - address &= PAGE_MASK;
82839 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
82840 - struct vm_area_struct *prev = vma->vm_prev;
82841 -
82842 - /*
82843 - * Is there a mapping abutting this one below?
82844 - *
82845 - * That's only ok if it's the same stack mapping
82846 - * that has gotten split..
82847 - */
82848 - if (prev && prev->vm_end == address)
82849 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
82850 -
82851 - expand_downwards(vma, address - PAGE_SIZE);
82852 - }
82853 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
82854 - struct vm_area_struct *next = vma->vm_next;
82855 -
82856 - /* As VM_GROWSDOWN but s/below/above/ */
82857 - if (next && next->vm_start == address + PAGE_SIZE)
82858 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
82859 -
82860 - expand_upwards(vma, address + PAGE_SIZE);
82861 - }
82862 - return 0;
82863 -}
82864 -
82865 -/*
82866 * We enter with non-exclusive mmap_sem (to exclude vma changes,
82867 * but allow concurrent faults), and pte mapped but not yet locked.
82868 * We return with mmap_sem still held, but pte unmapped and unlocked.
82869 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82870 unsigned long address, pte_t *page_table, pmd_t *pmd,
82871 unsigned int flags)
82872 {
82873 - struct page *page;
82874 + struct page *page = NULL;
82875 spinlock_t *ptl;
82876 pte_t entry;
82877
82878 - pte_unmap(page_table);
82879 -
82880 - /* Check if we need to add a guard page to the stack */
82881 - if (check_stack_guard_page(vma, address) < 0)
82882 - return VM_FAULT_SIGBUS;
82883 -
82884 - /* Use the zero-page for reads */
82885 if (!(flags & FAULT_FLAG_WRITE)) {
82886 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
82887 vma->vm_page_prot));
82888 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82889 + ptl = pte_lockptr(mm, pmd);
82890 + spin_lock(ptl);
82891 if (!pte_none(*page_table))
82892 goto unlock;
82893 goto setpte;
82894 }
82895
82896 /* Allocate our own private page. */
82897 + pte_unmap(page_table);
82898 +
82899 if (unlikely(anon_vma_prepare(vma)))
82900 goto oom;
82901 page = alloc_zeroed_user_highpage_movable(vma, address);
82902 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82903 if (!pte_none(*page_table))
82904 goto release;
82905
82906 +#ifdef CONFIG_PAX_SEGMEXEC
82907 + if (pax_find_mirror_vma(vma))
82908 + BUG_ON(!trylock_page(page));
82909 +#endif
82910 +
82911 inc_mm_counter_fast(mm, MM_ANONPAGES);
82912 page_add_new_anon_rmap(page, vma, address);
82913 setpte:
82914 @@ -3263,6 +3446,12 @@ setpte:
82915
82916 /* No need to invalidate - it was non-present before */
82917 update_mmu_cache(vma, address, page_table);
82918 +
82919 +#ifdef CONFIG_PAX_SEGMEXEC
82920 + if (page)
82921 + pax_mirror_anon_pte(vma, address, page, ptl);
82922 +#endif
82923 +
82924 unlock:
82925 pte_unmap_unlock(page_table, ptl);
82926 return 0;
82927 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82928 */
82929 /* Only go through if we didn't race with anybody else... */
82930 if (likely(pte_same(*page_table, orig_pte))) {
82931 +
82932 +#ifdef CONFIG_PAX_SEGMEXEC
82933 + if (anon && pax_find_mirror_vma(vma))
82934 + BUG_ON(!trylock_page(page));
82935 +#endif
82936 +
82937 flush_icache_page(vma, page);
82938 entry = mk_pte(page, vma->vm_page_prot);
82939 if (flags & FAULT_FLAG_WRITE)
82940 @@ -3425,6 +3620,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82941
82942 /* no need to invalidate: a not-present page won't be cached */
82943 update_mmu_cache(vma, address, page_table);
82944 +
82945 +#ifdef CONFIG_PAX_SEGMEXEC
82946 + if (anon)
82947 + pax_mirror_anon_pte(vma, address, page, ptl);
82948 + else
82949 + pax_mirror_file_pte(vma, address, page, ptl);
82950 +#endif
82951 +
82952 } else {
82953 if (cow_page)
82954 mem_cgroup_uncharge_page(cow_page);
82955 @@ -3746,6 +3949,12 @@ int handle_pte_fault(struct mm_struct *mm,
82956 if (flags & FAULT_FLAG_WRITE)
82957 flush_tlb_fix_spurious_fault(vma, address);
82958 }
82959 +
82960 +#ifdef CONFIG_PAX_SEGMEXEC
82961 + pax_mirror_pte(vma, address, pte, pmd, ptl);
82962 + return 0;
82963 +#endif
82964 +
82965 unlock:
82966 pte_unmap_unlock(pte, ptl);
82967 return 0;
82968 @@ -3762,6 +3971,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82969 pmd_t *pmd;
82970 pte_t *pte;
82971
82972 +#ifdef CONFIG_PAX_SEGMEXEC
82973 + struct vm_area_struct *vma_m;
82974 +#endif
82975 +
82976 __set_current_state(TASK_RUNNING);
82977
82978 count_vm_event(PGFAULT);
82979 @@ -3773,6 +3986,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82980 if (unlikely(is_vm_hugetlb_page(vma)))
82981 return hugetlb_fault(mm, vma, address, flags);
82982
82983 +#ifdef CONFIG_PAX_SEGMEXEC
82984 + vma_m = pax_find_mirror_vma(vma);
82985 + if (vma_m) {
82986 + unsigned long address_m;
82987 + pgd_t *pgd_m;
82988 + pud_t *pud_m;
82989 + pmd_t *pmd_m;
82990 +
82991 + if (vma->vm_start > vma_m->vm_start) {
82992 + address_m = address;
82993 + address -= SEGMEXEC_TASK_SIZE;
82994 + vma = vma_m;
82995 + } else
82996 + address_m = address + SEGMEXEC_TASK_SIZE;
82997 +
82998 + pgd_m = pgd_offset(mm, address_m);
82999 + pud_m = pud_alloc(mm, pgd_m, address_m);
83000 + if (!pud_m)
83001 + return VM_FAULT_OOM;
83002 + pmd_m = pmd_alloc(mm, pud_m, address_m);
83003 + if (!pmd_m)
83004 + return VM_FAULT_OOM;
83005 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
83006 + return VM_FAULT_OOM;
83007 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
83008 + }
83009 +#endif
83010 +
83011 retry:
83012 pgd = pgd_offset(mm, address);
83013 pud = pud_alloc(mm, pgd, address);
83014 @@ -3871,6 +4112,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
83015 spin_unlock(&mm->page_table_lock);
83016 return 0;
83017 }
83018 +
83019 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
83020 +{
83021 + pud_t *new = pud_alloc_one(mm, address);
83022 + if (!new)
83023 + return -ENOMEM;
83024 +
83025 + smp_wmb(); /* See comment in __pte_alloc */
83026 +
83027 + spin_lock(&mm->page_table_lock);
83028 + if (pgd_present(*pgd)) /* Another has populated it */
83029 + pud_free(mm, new);
83030 + else
83031 + pgd_populate_kernel(mm, pgd, new);
83032 + spin_unlock(&mm->page_table_lock);
83033 + return 0;
83034 +}
83035 #endif /* __PAGETABLE_PUD_FOLDED */
83036
83037 #ifndef __PAGETABLE_PMD_FOLDED
83038 @@ -3901,6 +4159,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
83039 spin_unlock(&mm->page_table_lock);
83040 return 0;
83041 }
83042 +
83043 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
83044 +{
83045 + pmd_t *new = pmd_alloc_one(mm, address);
83046 + if (!new)
83047 + return -ENOMEM;
83048 +
83049 + smp_wmb(); /* See comment in __pte_alloc */
83050 +
83051 + spin_lock(&mm->page_table_lock);
83052 +#ifndef __ARCH_HAS_4LEVEL_HACK
83053 + if (pud_present(*pud)) /* Another has populated it */
83054 + pmd_free(mm, new);
83055 + else
83056 + pud_populate_kernel(mm, pud, new);
83057 +#else
83058 + if (pgd_present(*pud)) /* Another has populated it */
83059 + pmd_free(mm, new);
83060 + else
83061 + pgd_populate_kernel(mm, pud, new);
83062 +#endif /* __ARCH_HAS_4LEVEL_HACK */
83063 + spin_unlock(&mm->page_table_lock);
83064 + return 0;
83065 +}
83066 #endif /* __PAGETABLE_PMD_FOLDED */
83067
83068 #if !defined(__HAVE_ARCH_GATE_AREA)
83069 @@ -3914,7 +4196,7 @@ static int __init gate_vma_init(void)
83070 gate_vma.vm_start = FIXADDR_USER_START;
83071 gate_vma.vm_end = FIXADDR_USER_END;
83072 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
83073 - gate_vma.vm_page_prot = __P101;
83074 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
83075
83076 return 0;
83077 }
83078 @@ -4048,8 +4330,8 @@ out:
83079 return ret;
83080 }
83081
83082 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
83083 - void *buf, int len, int write)
83084 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
83085 + void *buf, size_t len, int write)
83086 {
83087 resource_size_t phys_addr;
83088 unsigned long prot = 0;
83089 @@ -4074,8 +4356,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
83090 * Access another process' address space as given in mm. If non-NULL, use the
83091 * given task for page fault accounting.
83092 */
83093 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83094 - unsigned long addr, void *buf, int len, int write)
83095 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83096 + unsigned long addr, void *buf, size_t len, int write)
83097 {
83098 struct vm_area_struct *vma;
83099 void *old_buf = buf;
83100 @@ -4083,7 +4365,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83101 down_read(&mm->mmap_sem);
83102 /* ignore errors, just check how much was successfully transferred */
83103 while (len) {
83104 - int bytes, ret, offset;
83105 + ssize_t bytes, ret, offset;
83106 void *maddr;
83107 struct page *page = NULL;
83108
83109 @@ -4142,8 +4424,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83110 *
83111 * The caller must hold a reference on @mm.
83112 */
83113 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83114 - void *buf, int len, int write)
83115 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83116 + void *buf, size_t len, int write)
83117 {
83118 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83119 }
83120 @@ -4153,11 +4435,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83121 * Source/target buffer must be kernel space,
83122 * Do not walk the page table directly, use get_user_pages
83123 */
83124 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
83125 - void *buf, int len, int write)
83126 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
83127 + void *buf, size_t len, int write)
83128 {
83129 struct mm_struct *mm;
83130 - int ret;
83131 + ssize_t ret;
83132
83133 mm = get_task_mm(tsk);
83134 if (!mm)
83135 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
83136 index 4baf12e..5497066 100644
83137 --- a/mm/mempolicy.c
83138 +++ b/mm/mempolicy.c
83139 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
83140 unsigned long vmstart;
83141 unsigned long vmend;
83142
83143 +#ifdef CONFIG_PAX_SEGMEXEC
83144 + struct vm_area_struct *vma_m;
83145 +#endif
83146 +
83147 vma = find_vma(mm, start);
83148 if (!vma || vma->vm_start > start)
83149 return -EFAULT;
83150 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
83151 err = vma_replace_policy(vma, new_pol);
83152 if (err)
83153 goto out;
83154 +
83155 +#ifdef CONFIG_PAX_SEGMEXEC
83156 + vma_m = pax_find_mirror_vma(vma);
83157 + if (vma_m) {
83158 + err = vma_replace_policy(vma_m, new_pol);
83159 + if (err)
83160 + goto out;
83161 + }
83162 +#endif
83163 +
83164 }
83165
83166 out:
83167 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
83168
83169 if (end < start)
83170 return -EINVAL;
83171 +
83172 +#ifdef CONFIG_PAX_SEGMEXEC
83173 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83174 + if (end > SEGMEXEC_TASK_SIZE)
83175 + return -EINVAL;
83176 + } else
83177 +#endif
83178 +
83179 + if (end > TASK_SIZE)
83180 + return -EINVAL;
83181 +
83182 if (end == start)
83183 return 0;
83184
83185 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
83186 */
83187 tcred = __task_cred(task);
83188 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
83189 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
83190 - !capable(CAP_SYS_NICE)) {
83191 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
83192 rcu_read_unlock();
83193 err = -EPERM;
83194 goto out_put;
83195 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
83196 goto out;
83197 }
83198
83199 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83200 + if (mm != current->mm &&
83201 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
83202 + mmput(mm);
83203 + err = -EPERM;
83204 + goto out;
83205 + }
83206 +#endif
83207 +
83208 err = do_migrate_pages(mm, old, new,
83209 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
83210
83211 diff --git a/mm/migrate.c b/mm/migrate.c
83212 index 6f0c244..6d1ae32 100644
83213 --- a/mm/migrate.c
83214 +++ b/mm/migrate.c
83215 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
83216 */
83217 tcred = __task_cred(task);
83218 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
83219 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
83220 - !capable(CAP_SYS_NICE)) {
83221 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
83222 rcu_read_unlock();
83223 err = -EPERM;
83224 goto out;
83225 diff --git a/mm/mlock.c b/mm/mlock.c
83226 index 79b7cf7..9944291 100644
83227 --- a/mm/mlock.c
83228 +++ b/mm/mlock.c
83229 @@ -13,6 +13,7 @@
83230 #include <linux/pagemap.h>
83231 #include <linux/mempolicy.h>
83232 #include <linux/syscalls.h>
83233 +#include <linux/security.h>
83234 #include <linux/sched.h>
83235 #include <linux/export.h>
83236 #include <linux/rmap.h>
83237 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
83238 {
83239 unsigned long nstart, end, tmp;
83240 struct vm_area_struct * vma, * prev;
83241 - int error;
83242 + int error = 0;
83243
83244 VM_BUG_ON(start & ~PAGE_MASK);
83245 VM_BUG_ON(len != PAGE_ALIGN(len));
83246 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
83247 return -EINVAL;
83248 if (end == start)
83249 return 0;
83250 + if (end > TASK_SIZE)
83251 + return -EINVAL;
83252 +
83253 vma = find_vma(current->mm, start);
83254 if (!vma || vma->vm_start > start)
83255 return -ENOMEM;
83256 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
83257 for (nstart = start ; ; ) {
83258 vm_flags_t newflags;
83259
83260 +#ifdef CONFIG_PAX_SEGMEXEC
83261 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
83262 + break;
83263 +#endif
83264 +
83265 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
83266
83267 newflags = vma->vm_flags & ~VM_LOCKED;
83268 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
83269 lock_limit >>= PAGE_SHIFT;
83270
83271 /* check against resource limits */
83272 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
83273 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
83274 error = do_mlock(start, len, 1);
83275 up_write(&current->mm->mmap_sem);
83276 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
83277 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
83278 vm_flags_t newflags;
83279
83280 +#ifdef CONFIG_PAX_SEGMEXEC
83281 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
83282 + break;
83283 +#endif
83284 +
83285 newflags = vma->vm_flags & ~VM_LOCKED;
83286 if (flags & MCL_CURRENT)
83287 newflags |= VM_LOCKED;
83288 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
83289 lock_limit >>= PAGE_SHIFT;
83290
83291 ret = -ENOMEM;
83292 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
83293 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
83294 capable(CAP_IPC_LOCK))
83295 ret = do_mlockall(flags);
83296 diff --git a/mm/mmap.c b/mm/mmap.c
83297 index 7dbe397..e84c411 100644
83298 --- a/mm/mmap.c
83299 +++ b/mm/mmap.c
83300 @@ -36,6 +36,7 @@
83301 #include <linux/sched/sysctl.h>
83302 #include <linux/notifier.h>
83303 #include <linux/memory.h>
83304 +#include <linux/random.h>
83305
83306 #include <asm/uaccess.h>
83307 #include <asm/cacheflush.h>
83308 @@ -52,6 +53,16 @@
83309 #define arch_rebalance_pgtables(addr, len) (addr)
83310 #endif
83311
83312 +static inline void verify_mm_writelocked(struct mm_struct *mm)
83313 +{
83314 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
83315 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83316 + up_read(&mm->mmap_sem);
83317 + BUG();
83318 + }
83319 +#endif
83320 +}
83321 +
83322 static void unmap_region(struct mm_struct *mm,
83323 struct vm_area_struct *vma, struct vm_area_struct *prev,
83324 unsigned long start, unsigned long end);
83325 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
83326 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
83327 *
83328 */
83329 -pgprot_t protection_map[16] = {
83330 +pgprot_t protection_map[16] __read_only = {
83331 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
83332 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
83333 };
83334
83335 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
83336 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
83337 {
83338 - return __pgprot(pgprot_val(protection_map[vm_flags &
83339 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
83340 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
83341 pgprot_val(arch_vm_get_page_prot(vm_flags)));
83342 +
83343 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
83344 + if (!(__supported_pte_mask & _PAGE_NX) &&
83345 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
83346 + (vm_flags & (VM_READ | VM_WRITE)))
83347 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
83348 +#endif
83349 +
83350 + return prot;
83351 }
83352 EXPORT_SYMBOL(vm_get_page_prot);
83353
83354 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
83355 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
83356 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
83357 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
83358 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
83359 /*
83360 * Make sure vm_committed_as in one cacheline and not cacheline shared with
83361 * other variables. It can be updated by several CPUs frequently.
83362 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
83363 struct vm_area_struct *next = vma->vm_next;
83364
83365 might_sleep();
83366 + BUG_ON(vma->vm_mirror);
83367 if (vma->vm_ops && vma->vm_ops->close)
83368 vma->vm_ops->close(vma);
83369 if (vma->vm_file)
83370 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
83371 * not page aligned -Ram Gupta
83372 */
83373 rlim = rlimit(RLIMIT_DATA);
83374 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
83375 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
83376 (mm->end_data - mm->start_data) > rlim)
83377 goto out;
83378 @@ -933,6 +956,12 @@ static int
83379 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
83380 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
83381 {
83382 +
83383 +#ifdef CONFIG_PAX_SEGMEXEC
83384 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
83385 + return 0;
83386 +#endif
83387 +
83388 if (is_mergeable_vma(vma, file, vm_flags) &&
83389 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
83390 if (vma->vm_pgoff == vm_pgoff)
83391 @@ -952,6 +981,12 @@ static int
83392 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
83393 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
83394 {
83395 +
83396 +#ifdef CONFIG_PAX_SEGMEXEC
83397 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
83398 + return 0;
83399 +#endif
83400 +
83401 if (is_mergeable_vma(vma, file, vm_flags) &&
83402 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
83403 pgoff_t vm_pglen;
83404 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
83405 struct vm_area_struct *vma_merge(struct mm_struct *mm,
83406 struct vm_area_struct *prev, unsigned long addr,
83407 unsigned long end, unsigned long vm_flags,
83408 - struct anon_vma *anon_vma, struct file *file,
83409 + struct anon_vma *anon_vma, struct file *file,
83410 pgoff_t pgoff, struct mempolicy *policy)
83411 {
83412 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
83413 struct vm_area_struct *area, *next;
83414 int err;
83415
83416 +#ifdef CONFIG_PAX_SEGMEXEC
83417 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
83418 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
83419 +
83420 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
83421 +#endif
83422 +
83423 /*
83424 * We later require that vma->vm_flags == vm_flags,
83425 * so this tests vma->vm_flags & VM_SPECIAL, too.
83426 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
83427 if (next && next->vm_end == end) /* cases 6, 7, 8 */
83428 next = next->vm_next;
83429
83430 +#ifdef CONFIG_PAX_SEGMEXEC
83431 + if (prev)
83432 + prev_m = pax_find_mirror_vma(prev);
83433 + if (area)
83434 + area_m = pax_find_mirror_vma(area);
83435 + if (next)
83436 + next_m = pax_find_mirror_vma(next);
83437 +#endif
83438 +
83439 /*
83440 * Can it merge with the predecessor?
83441 */
83442 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
83443 /* cases 1, 6 */
83444 err = vma_adjust(prev, prev->vm_start,
83445 next->vm_end, prev->vm_pgoff, NULL);
83446 - } else /* cases 2, 5, 7 */
83447 +
83448 +#ifdef CONFIG_PAX_SEGMEXEC
83449 + if (!err && prev_m)
83450 + err = vma_adjust(prev_m, prev_m->vm_start,
83451 + next_m->vm_end, prev_m->vm_pgoff, NULL);
83452 +#endif
83453 +
83454 + } else { /* cases 2, 5, 7 */
83455 err = vma_adjust(prev, prev->vm_start,
83456 end, prev->vm_pgoff, NULL);
83457 +
83458 +#ifdef CONFIG_PAX_SEGMEXEC
83459 + if (!err && prev_m)
83460 + err = vma_adjust(prev_m, prev_m->vm_start,
83461 + end_m, prev_m->vm_pgoff, NULL);
83462 +#endif
83463 +
83464 + }
83465 if (err)
83466 return NULL;
83467 khugepaged_enter_vma_merge(prev);
83468 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
83469 mpol_equal(policy, vma_policy(next)) &&
83470 can_vma_merge_before(next, vm_flags,
83471 anon_vma, file, pgoff+pglen)) {
83472 - if (prev && addr < prev->vm_end) /* case 4 */
83473 + if (prev && addr < prev->vm_end) { /* case 4 */
83474 err = vma_adjust(prev, prev->vm_start,
83475 addr, prev->vm_pgoff, NULL);
83476 - else /* cases 3, 8 */
83477 +
83478 +#ifdef CONFIG_PAX_SEGMEXEC
83479 + if (!err && prev_m)
83480 + err = vma_adjust(prev_m, prev_m->vm_start,
83481 + addr_m, prev_m->vm_pgoff, NULL);
83482 +#endif
83483 +
83484 + } else { /* cases 3, 8 */
83485 err = vma_adjust(area, addr, next->vm_end,
83486 next->vm_pgoff - pglen, NULL);
83487 +
83488 +#ifdef CONFIG_PAX_SEGMEXEC
83489 + if (!err && area_m)
83490 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
83491 + next_m->vm_pgoff - pglen, NULL);
83492 +#endif
83493 +
83494 + }
83495 if (err)
83496 return NULL;
83497 khugepaged_enter_vma_merge(area);
83498 @@ -1165,8 +1246,10 @@ none:
83499 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
83500 struct file *file, long pages)
83501 {
83502 - const unsigned long stack_flags
83503 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
83504 +
83505 +#ifdef CONFIG_PAX_RANDMMAP
83506 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
83507 +#endif
83508
83509 mm->total_vm += pages;
83510
83511 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
83512 mm->shared_vm += pages;
83513 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
83514 mm->exec_vm += pages;
83515 - } else if (flags & stack_flags)
83516 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
83517 mm->stack_vm += pages;
83518 }
83519 #endif /* CONFIG_PROC_FS */
83520 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83521 * (the exception is when the underlying filesystem is noexec
83522 * mounted, in which case we dont add PROT_EXEC.)
83523 */
83524 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83525 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83526 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
83527 prot |= PROT_EXEC;
83528
83529 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83530 /* Obtain the address to map to. we verify (or select) it and ensure
83531 * that it represents a valid section of the address space.
83532 */
83533 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
83534 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
83535 if (addr & ~PAGE_MASK)
83536 return addr;
83537
83538 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83539 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
83540 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
83541
83542 +#ifdef CONFIG_PAX_MPROTECT
83543 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83544 +
83545 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
83546 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
83547 + mm->binfmt->handle_mmap)
83548 + mm->binfmt->handle_mmap(file);
83549 +#endif
83550 +
83551 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83552 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
83553 + gr_log_rwxmmap(file);
83554 +
83555 +#ifdef CONFIG_PAX_EMUPLT
83556 + vm_flags &= ~VM_EXEC;
83557 +#else
83558 + return -EPERM;
83559 +#endif
83560 +
83561 + }
83562 +
83563 + if (!(vm_flags & VM_EXEC))
83564 + vm_flags &= ~VM_MAYEXEC;
83565 +#else
83566 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83567 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83568 +#endif
83569 + else
83570 + vm_flags &= ~VM_MAYWRITE;
83571 + }
83572 +#endif
83573 +
83574 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
83575 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
83576 + vm_flags &= ~VM_PAGEEXEC;
83577 +#endif
83578 +
83579 if (flags & MAP_LOCKED)
83580 if (!can_do_mlock())
83581 return -EPERM;
83582 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83583 locked += mm->locked_vm;
83584 lock_limit = rlimit(RLIMIT_MEMLOCK);
83585 lock_limit >>= PAGE_SHIFT;
83586 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83587 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
83588 return -EAGAIN;
83589 }
83590 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83591 vm_flags |= VM_NORESERVE;
83592 }
83593
83594 + if (!gr_acl_handle_mmap(file, prot))
83595 + return -EACCES;
83596 +
83597 addr = mmap_region(file, addr, len, vm_flags, pgoff);
83598 if (!IS_ERR_VALUE(addr) &&
83599 ((vm_flags & VM_LOCKED) ||
83600 @@ -1432,7 +1556,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
83601 vm_flags_t vm_flags = vma->vm_flags;
83602
83603 /* If it was private or non-writable, the write bit is already clear */
83604 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
83605 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
83606 return 0;
83607
83608 /* The backer wishes to know when pages are first written to? */
83609 @@ -1480,7 +1604,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
83610 unsigned long charged = 0;
83611 struct inode *inode = file ? file_inode(file) : NULL;
83612
83613 +#ifdef CONFIG_PAX_SEGMEXEC
83614 + struct vm_area_struct *vma_m = NULL;
83615 +#endif
83616 +
83617 + /*
83618 + * mm->mmap_sem is required to protect against another thread
83619 + * changing the mappings in case we sleep.
83620 + */
83621 + verify_mm_writelocked(mm);
83622 +
83623 /* Check against address space limit. */
83624 +
83625 +#ifdef CONFIG_PAX_RANDMMAP
83626 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
83627 +#endif
83628 +
83629 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
83630 unsigned long nr_pages;
83631
83632 @@ -1499,11 +1638,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
83633
83634 /* Clear old maps */
83635 error = -ENOMEM;
83636 -munmap_back:
83637 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83638 if (do_munmap(mm, addr, len))
83639 return -ENOMEM;
83640 - goto munmap_back;
83641 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83642 }
83643
83644 /*
83645 @@ -1534,6 +1672,16 @@ munmap_back:
83646 goto unacct_error;
83647 }
83648
83649 +#ifdef CONFIG_PAX_SEGMEXEC
83650 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
83651 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83652 + if (!vma_m) {
83653 + error = -ENOMEM;
83654 + goto free_vma;
83655 + }
83656 + }
83657 +#endif
83658 +
83659 vma->vm_mm = mm;
83660 vma->vm_start = addr;
83661 vma->vm_end = addr + len;
83662 @@ -1558,6 +1706,13 @@ munmap_back:
83663 if (error)
83664 goto unmap_and_free_vma;
83665
83666 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
83667 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
83668 + vma->vm_flags |= VM_PAGEEXEC;
83669 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83670 + }
83671 +#endif
83672 +
83673 /* Can addr have changed??
83674 *
83675 * Answer: Yes, several device drivers can do it in their
83676 @@ -1596,6 +1751,11 @@ munmap_back:
83677 vma_link(mm, vma, prev, rb_link, rb_parent);
83678 file = vma->vm_file;
83679
83680 +#ifdef CONFIG_PAX_SEGMEXEC
83681 + if (vma_m)
83682 + BUG_ON(pax_mirror_vma(vma_m, vma));
83683 +#endif
83684 +
83685 /* Once vma denies write, undo our temporary denial count */
83686 if (correct_wcount)
83687 atomic_inc(&inode->i_writecount);
83688 @@ -1603,6 +1763,7 @@ out:
83689 perf_event_mmap(vma);
83690
83691 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
83692 + track_exec_limit(mm, addr, addr + len, vm_flags);
83693 if (vm_flags & VM_LOCKED) {
83694 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
83695 vma == get_gate_vma(current->mm)))
83696 @@ -1626,6 +1787,12 @@ unmap_and_free_vma:
83697 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
83698 charged = 0;
83699 free_vma:
83700 +
83701 +#ifdef CONFIG_PAX_SEGMEXEC
83702 + if (vma_m)
83703 + kmem_cache_free(vm_area_cachep, vma_m);
83704 +#endif
83705 +
83706 kmem_cache_free(vm_area_cachep, vma);
83707 unacct_error:
83708 if (charged)
83709 @@ -1633,7 +1800,63 @@ unacct_error:
83710 return error;
83711 }
83712
83713 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
83714 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
83715 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
83716 +{
83717 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
83718 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
83719 +
83720 + return 0;
83721 +}
83722 +#endif
83723 +
83724 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
83725 +{
83726 + if (!vma) {
83727 +#ifdef CONFIG_STACK_GROWSUP
83728 + if (addr > sysctl_heap_stack_gap)
83729 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
83730 + else
83731 + vma = find_vma(current->mm, 0);
83732 + if (vma && (vma->vm_flags & VM_GROWSUP))
83733 + return false;
83734 +#endif
83735 + return true;
83736 + }
83737 +
83738 + if (addr + len > vma->vm_start)
83739 + return false;
83740 +
83741 + if (vma->vm_flags & VM_GROWSDOWN)
83742 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
83743 +#ifdef CONFIG_STACK_GROWSUP
83744 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
83745 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
83746 +#endif
83747 + else if (offset)
83748 + return offset <= vma->vm_start - addr - len;
83749 +
83750 + return true;
83751 +}
83752 +
83753 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
83754 +{
83755 + if (vma->vm_start < len)
83756 + return -ENOMEM;
83757 +
83758 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
83759 + if (offset <= vma->vm_start - len)
83760 + return vma->vm_start - len - offset;
83761 + else
83762 + return -ENOMEM;
83763 + }
83764 +
83765 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
83766 + return vma->vm_start - len - sysctl_heap_stack_gap;
83767 + return -ENOMEM;
83768 +}
83769 +
83770 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
83771 {
83772 /*
83773 * We implement the search by looking for an rbtree node that
83774 @@ -1681,11 +1904,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
83775 }
83776 }
83777
83778 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
83779 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
83780 check_current:
83781 /* Check if current node has a suitable gap */
83782 if (gap_start > high_limit)
83783 return -ENOMEM;
83784 +
83785 + if (gap_end - gap_start > info->threadstack_offset)
83786 + gap_start += info->threadstack_offset;
83787 + else
83788 + gap_start = gap_end;
83789 +
83790 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83791 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83792 + gap_start += sysctl_heap_stack_gap;
83793 + else
83794 + gap_start = gap_end;
83795 + }
83796 + if (vma->vm_flags & VM_GROWSDOWN) {
83797 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83798 + gap_end -= sysctl_heap_stack_gap;
83799 + else
83800 + gap_end = gap_start;
83801 + }
83802 if (gap_end >= low_limit && gap_end - gap_start >= length)
83803 goto found;
83804
83805 @@ -1735,7 +1976,7 @@ found:
83806 return gap_start;
83807 }
83808
83809 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
83810 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
83811 {
83812 struct mm_struct *mm = current->mm;
83813 struct vm_area_struct *vma;
83814 @@ -1789,6 +2030,24 @@ check_current:
83815 gap_end = vma->vm_start;
83816 if (gap_end < low_limit)
83817 return -ENOMEM;
83818 +
83819 + if (gap_end - gap_start > info->threadstack_offset)
83820 + gap_end -= info->threadstack_offset;
83821 + else
83822 + gap_end = gap_start;
83823 +
83824 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83825 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83826 + gap_start += sysctl_heap_stack_gap;
83827 + else
83828 + gap_start = gap_end;
83829 + }
83830 + if (vma->vm_flags & VM_GROWSDOWN) {
83831 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83832 + gap_end -= sysctl_heap_stack_gap;
83833 + else
83834 + gap_end = gap_start;
83835 + }
83836 if (gap_start <= high_limit && gap_end - gap_start >= length)
83837 goto found;
83838
83839 @@ -1852,6 +2111,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83840 struct mm_struct *mm = current->mm;
83841 struct vm_area_struct *vma;
83842 struct vm_unmapped_area_info info;
83843 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83844
83845 if (len > TASK_SIZE)
83846 return -ENOMEM;
83847 @@ -1859,29 +2119,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83848 if (flags & MAP_FIXED)
83849 return addr;
83850
83851 +#ifdef CONFIG_PAX_RANDMMAP
83852 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83853 +#endif
83854 +
83855 if (addr) {
83856 addr = PAGE_ALIGN(addr);
83857 vma = find_vma(mm, addr);
83858 - if (TASK_SIZE - len >= addr &&
83859 - (!vma || addr + len <= vma->vm_start))
83860 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83861 return addr;
83862 }
83863
83864 info.flags = 0;
83865 info.length = len;
83866 info.low_limit = TASK_UNMAPPED_BASE;
83867 +
83868 +#ifdef CONFIG_PAX_RANDMMAP
83869 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83870 + info.low_limit += mm->delta_mmap;
83871 +#endif
83872 +
83873 info.high_limit = TASK_SIZE;
83874 info.align_mask = 0;
83875 + info.threadstack_offset = offset;
83876 return vm_unmapped_area(&info);
83877 }
83878 #endif
83879
83880 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
83881 {
83882 +
83883 +#ifdef CONFIG_PAX_SEGMEXEC
83884 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83885 + return;
83886 +#endif
83887 +
83888 /*
83889 * Is this a new hole at the lowest possible address?
83890 */
83891 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
83892 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
83893 mm->free_area_cache = addr;
83894 }
83895
83896 @@ -1899,6 +2175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83897 struct mm_struct *mm = current->mm;
83898 unsigned long addr = addr0;
83899 struct vm_unmapped_area_info info;
83900 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83901
83902 /* requested length too big for entire address space */
83903 if (len > TASK_SIZE)
83904 @@ -1907,12 +2184,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83905 if (flags & MAP_FIXED)
83906 return addr;
83907
83908 +#ifdef CONFIG_PAX_RANDMMAP
83909 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83910 +#endif
83911 +
83912 /* requesting a specific address */
83913 if (addr) {
83914 addr = PAGE_ALIGN(addr);
83915 vma = find_vma(mm, addr);
83916 - if (TASK_SIZE - len >= addr &&
83917 - (!vma || addr + len <= vma->vm_start))
83918 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83919 return addr;
83920 }
83921
83922 @@ -1921,6 +2201,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83923 info.low_limit = PAGE_SIZE;
83924 info.high_limit = mm->mmap_base;
83925 info.align_mask = 0;
83926 + info.threadstack_offset = offset;
83927 addr = vm_unmapped_area(&info);
83928
83929 /*
83930 @@ -1933,6 +2214,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83931 VM_BUG_ON(addr != -ENOMEM);
83932 info.flags = 0;
83933 info.low_limit = TASK_UNMAPPED_BASE;
83934 +
83935 +#ifdef CONFIG_PAX_RANDMMAP
83936 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83937 + info.low_limit += mm->delta_mmap;
83938 +#endif
83939 +
83940 info.high_limit = TASK_SIZE;
83941 addr = vm_unmapped_area(&info);
83942 }
83943 @@ -1943,6 +2230,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83944
83945 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83946 {
83947 +
83948 +#ifdef CONFIG_PAX_SEGMEXEC
83949 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83950 + return;
83951 +#endif
83952 +
83953 /*
83954 * Is this a new hole at the highest possible address?
83955 */
83956 @@ -1950,8 +2243,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83957 mm->free_area_cache = addr;
83958
83959 /* dont allow allocations above current base */
83960 - if (mm->free_area_cache > mm->mmap_base)
83961 + if (mm->free_area_cache > mm->mmap_base) {
83962 mm->free_area_cache = mm->mmap_base;
83963 + mm->cached_hole_size = ~0UL;
83964 + }
83965 }
83966
83967 unsigned long
83968 @@ -2047,6 +2342,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
83969 return vma;
83970 }
83971
83972 +#ifdef CONFIG_PAX_SEGMEXEC
83973 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
83974 +{
83975 + struct vm_area_struct *vma_m;
83976 +
83977 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
83978 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
83979 + BUG_ON(vma->vm_mirror);
83980 + return NULL;
83981 + }
83982 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
83983 + vma_m = vma->vm_mirror;
83984 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
83985 + BUG_ON(vma->vm_file != vma_m->vm_file);
83986 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
83987 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
83988 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
83989 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
83990 + return vma_m;
83991 +}
83992 +#endif
83993 +
83994 /*
83995 * Verify that the stack growth is acceptable and
83996 * update accounting. This is shared with both the
83997 @@ -2063,6 +2380,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83998 return -ENOMEM;
83999
84000 /* Stack limit test */
84001 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
84002 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
84003 return -ENOMEM;
84004
84005 @@ -2073,6 +2391,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
84006 locked = mm->locked_vm + grow;
84007 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
84008 limit >>= PAGE_SHIFT;
84009 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
84010 if (locked > limit && !capable(CAP_IPC_LOCK))
84011 return -ENOMEM;
84012 }
84013 @@ -2102,37 +2421,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
84014 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
84015 * vma is the last one with address > vma->vm_end. Have to extend vma.
84016 */
84017 +#ifndef CONFIG_IA64
84018 +static
84019 +#endif
84020 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
84021 {
84022 int error;
84023 + bool locknext;
84024
84025 if (!(vma->vm_flags & VM_GROWSUP))
84026 return -EFAULT;
84027
84028 + /* Also guard against wrapping around to address 0. */
84029 + if (address < PAGE_ALIGN(address+1))
84030 + address = PAGE_ALIGN(address+1);
84031 + else
84032 + return -ENOMEM;
84033 +
84034 /*
84035 * We must make sure the anon_vma is allocated
84036 * so that the anon_vma locking is not a noop.
84037 */
84038 if (unlikely(anon_vma_prepare(vma)))
84039 return -ENOMEM;
84040 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
84041 + if (locknext && anon_vma_prepare(vma->vm_next))
84042 + return -ENOMEM;
84043 vma_lock_anon_vma(vma);
84044 + if (locknext)
84045 + vma_lock_anon_vma(vma->vm_next);
84046
84047 /*
84048 * vma->vm_start/vm_end cannot change under us because the caller
84049 * is required to hold the mmap_sem in read mode. We need the
84050 - * anon_vma lock to serialize against concurrent expand_stacks.
84051 - * Also guard against wrapping around to address 0.
84052 + * anon_vma locks to serialize against concurrent expand_stacks
84053 + * and expand_upwards.
84054 */
84055 - if (address < PAGE_ALIGN(address+4))
84056 - address = PAGE_ALIGN(address+4);
84057 - else {
84058 - vma_unlock_anon_vma(vma);
84059 - return -ENOMEM;
84060 - }
84061 error = 0;
84062
84063 /* Somebody else might have raced and expanded it already */
84064 - if (address > vma->vm_end) {
84065 + if (vma->vm_next && (vma->vm_next->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && vma->vm_next->vm_start - address < sysctl_heap_stack_gap)
84066 + error = -ENOMEM;
84067 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
84068 unsigned long size, grow;
84069
84070 size = address - vma->vm_start;
84071 @@ -2167,6 +2497,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
84072 }
84073 }
84074 }
84075 + if (locknext)
84076 + vma_unlock_anon_vma(vma->vm_next);
84077 vma_unlock_anon_vma(vma);
84078 khugepaged_enter_vma_merge(vma);
84079 validate_mm(vma->vm_mm);
84080 @@ -2181,6 +2513,8 @@ int expand_downwards(struct vm_area_struct *vma,
84081 unsigned long address)
84082 {
84083 int error;
84084 + bool lockprev = false;
84085 + struct vm_area_struct *prev;
84086
84087 /*
84088 * We must make sure the anon_vma is allocated
84089 @@ -2194,6 +2528,15 @@ int expand_downwards(struct vm_area_struct *vma,
84090 if (error)
84091 return error;
84092
84093 + prev = vma->vm_prev;
84094 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
84095 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
84096 +#endif
84097 + if (lockprev && anon_vma_prepare(prev))
84098 + return -ENOMEM;
84099 + if (lockprev)
84100 + vma_lock_anon_vma(prev);
84101 +
84102 vma_lock_anon_vma(vma);
84103
84104 /*
84105 @@ -2203,9 +2546,17 @@ int expand_downwards(struct vm_area_struct *vma,
84106 */
84107
84108 /* Somebody else might have raced and expanded it already */
84109 - if (address < vma->vm_start) {
84110 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
84111 + error = -ENOMEM;
84112 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
84113 unsigned long size, grow;
84114
84115 +#ifdef CONFIG_PAX_SEGMEXEC
84116 + struct vm_area_struct *vma_m;
84117 +
84118 + vma_m = pax_find_mirror_vma(vma);
84119 +#endif
84120 +
84121 size = vma->vm_end - address;
84122 grow = (vma->vm_start - address) >> PAGE_SHIFT;
84123
84124 @@ -2230,13 +2581,27 @@ int expand_downwards(struct vm_area_struct *vma,
84125 vma->vm_pgoff -= grow;
84126 anon_vma_interval_tree_post_update_vma(vma);
84127 vma_gap_update(vma);
84128 +
84129 +#ifdef CONFIG_PAX_SEGMEXEC
84130 + if (vma_m) {
84131 + anon_vma_interval_tree_pre_update_vma(vma_m);
84132 + vma_m->vm_start -= grow << PAGE_SHIFT;
84133 + vma_m->vm_pgoff -= grow;
84134 + anon_vma_interval_tree_post_update_vma(vma_m);
84135 + vma_gap_update(vma_m);
84136 + }
84137 +#endif
84138 +
84139 spin_unlock(&vma->vm_mm->page_table_lock);
84140
84141 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
84142 perf_event_mmap(vma);
84143 }
84144 }
84145 }
84146 vma_unlock_anon_vma(vma);
84147 + if (lockprev)
84148 + vma_unlock_anon_vma(prev);
84149 khugepaged_enter_vma_merge(vma);
84150 validate_mm(vma->vm_mm);
84151 return error;
84152 @@ -2334,6 +2699,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
84153 do {
84154 long nrpages = vma_pages(vma);
84155
84156 +#ifdef CONFIG_PAX_SEGMEXEC
84157 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
84158 + vma = remove_vma(vma);
84159 + continue;
84160 + }
84161 +#endif
84162 +
84163 if (vma->vm_flags & VM_ACCOUNT)
84164 nr_accounted += nrpages;
84165 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
84166 @@ -2379,6 +2751,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
84167 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
84168 vma->vm_prev = NULL;
84169 do {
84170 +
84171 +#ifdef CONFIG_PAX_SEGMEXEC
84172 + if (vma->vm_mirror) {
84173 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
84174 + vma->vm_mirror->vm_mirror = NULL;
84175 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
84176 + vma->vm_mirror = NULL;
84177 + }
84178 +#endif
84179 +
84180 vma_rb_erase(vma, &mm->mm_rb);
84181 mm->map_count--;
84182 tail_vma = vma;
84183 @@ -2410,14 +2792,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84184 struct vm_area_struct *new;
84185 int err = -ENOMEM;
84186
84187 +#ifdef CONFIG_PAX_SEGMEXEC
84188 + struct vm_area_struct *vma_m, *new_m = NULL;
84189 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
84190 +#endif
84191 +
84192 if (is_vm_hugetlb_page(vma) && (addr &
84193 ~(huge_page_mask(hstate_vma(vma)))))
84194 return -EINVAL;
84195
84196 +#ifdef CONFIG_PAX_SEGMEXEC
84197 + vma_m = pax_find_mirror_vma(vma);
84198 +#endif
84199 +
84200 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
84201 if (!new)
84202 goto out_err;
84203
84204 +#ifdef CONFIG_PAX_SEGMEXEC
84205 + if (vma_m) {
84206 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
84207 + if (!new_m) {
84208 + kmem_cache_free(vm_area_cachep, new);
84209 + goto out_err;
84210 + }
84211 + }
84212 +#endif
84213 +
84214 /* most fields are the same, copy all, and then fixup */
84215 *new = *vma;
84216
84217 @@ -2430,6 +2831,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84218 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
84219 }
84220
84221 +#ifdef CONFIG_PAX_SEGMEXEC
84222 + if (vma_m) {
84223 + *new_m = *vma_m;
84224 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
84225 + new_m->vm_mirror = new;
84226 + new->vm_mirror = new_m;
84227 +
84228 + if (new_below)
84229 + new_m->vm_end = addr_m;
84230 + else {
84231 + new_m->vm_start = addr_m;
84232 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
84233 + }
84234 + }
84235 +#endif
84236 +
84237 pol = mpol_dup(vma_policy(vma));
84238 if (IS_ERR(pol)) {
84239 err = PTR_ERR(pol);
84240 @@ -2452,6 +2869,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84241 else
84242 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
84243
84244 +#ifdef CONFIG_PAX_SEGMEXEC
84245 + if (!err && vma_m) {
84246 + if (anon_vma_clone(new_m, vma_m))
84247 + goto out_free_mpol;
84248 +
84249 + mpol_get(pol);
84250 + vma_set_policy(new_m, pol);
84251 +
84252 + if (new_m->vm_file)
84253 + get_file(new_m->vm_file);
84254 +
84255 + if (new_m->vm_ops && new_m->vm_ops->open)
84256 + new_m->vm_ops->open(new_m);
84257 +
84258 + if (new_below)
84259 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
84260 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
84261 + else
84262 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
84263 +
84264 + if (err) {
84265 + if (new_m->vm_ops && new_m->vm_ops->close)
84266 + new_m->vm_ops->close(new_m);
84267 + if (new_m->vm_file)
84268 + fput(new_m->vm_file);
84269 + mpol_put(pol);
84270 + }
84271 + }
84272 +#endif
84273 +
84274 /* Success. */
84275 if (!err)
84276 return 0;
84277 @@ -2461,10 +2908,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84278 new->vm_ops->close(new);
84279 if (new->vm_file)
84280 fput(new->vm_file);
84281 - unlink_anon_vmas(new);
84282 out_free_mpol:
84283 mpol_put(pol);
84284 out_free_vma:
84285 +
84286 +#ifdef CONFIG_PAX_SEGMEXEC
84287 + if (new_m) {
84288 + unlink_anon_vmas(new_m);
84289 + kmem_cache_free(vm_area_cachep, new_m);
84290 + }
84291 +#endif
84292 +
84293 + unlink_anon_vmas(new);
84294 kmem_cache_free(vm_area_cachep, new);
84295 out_err:
84296 return err;
84297 @@ -2477,6 +2932,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84298 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84299 unsigned long addr, int new_below)
84300 {
84301 +
84302 +#ifdef CONFIG_PAX_SEGMEXEC
84303 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
84304 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
84305 + if (mm->map_count >= sysctl_max_map_count-1)
84306 + return -ENOMEM;
84307 + } else
84308 +#endif
84309 +
84310 if (mm->map_count >= sysctl_max_map_count)
84311 return -ENOMEM;
84312
84313 @@ -2488,11 +2952,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84314 * work. This now handles partial unmappings.
84315 * Jeremy Fitzhardinge <jeremy@goop.org>
84316 */
84317 +#ifdef CONFIG_PAX_SEGMEXEC
84318 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84319 {
84320 + int ret = __do_munmap(mm, start, len);
84321 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
84322 + return ret;
84323 +
84324 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
84325 +}
84326 +
84327 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84328 +#else
84329 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84330 +#endif
84331 +{
84332 unsigned long end;
84333 struct vm_area_struct *vma, *prev, *last;
84334
84335 + /*
84336 + * mm->mmap_sem is required to protect against another thread
84337 + * changing the mappings in case we sleep.
84338 + */
84339 + verify_mm_writelocked(mm);
84340 +
84341 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
84342 return -EINVAL;
84343
84344 @@ -2567,6 +3050,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84345 /* Fix up all other VM information */
84346 remove_vma_list(mm, vma);
84347
84348 + track_exec_limit(mm, start, end, 0UL);
84349 +
84350 return 0;
84351 }
84352
84353 @@ -2575,6 +3060,13 @@ int vm_munmap(unsigned long start, size_t len)
84354 int ret;
84355 struct mm_struct *mm = current->mm;
84356
84357 +
84358 +#ifdef CONFIG_PAX_SEGMEXEC
84359 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
84360 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
84361 + return -EINVAL;
84362 +#endif
84363 +
84364 down_write(&mm->mmap_sem);
84365 ret = do_munmap(mm, start, len);
84366 up_write(&mm->mmap_sem);
84367 @@ -2588,16 +3080,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
84368 return vm_munmap(addr, len);
84369 }
84370
84371 -static inline void verify_mm_writelocked(struct mm_struct *mm)
84372 -{
84373 -#ifdef CONFIG_DEBUG_VM
84374 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
84375 - WARN_ON(1);
84376 - up_read(&mm->mmap_sem);
84377 - }
84378 -#endif
84379 -}
84380 -
84381 /*
84382 * this is really a simplified "do_mmap". it only handles
84383 * anonymous maps. eventually we may be able to do some
84384 @@ -2611,6 +3093,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84385 struct rb_node ** rb_link, * rb_parent;
84386 pgoff_t pgoff = addr >> PAGE_SHIFT;
84387 int error;
84388 + unsigned long charged;
84389
84390 len = PAGE_ALIGN(len);
84391 if (!len)
84392 @@ -2618,16 +3101,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84393
84394 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
84395
84396 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
84397 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
84398 + flags &= ~VM_EXEC;
84399 +
84400 +#ifdef CONFIG_PAX_MPROTECT
84401 + if (mm->pax_flags & MF_PAX_MPROTECT)
84402 + flags &= ~VM_MAYEXEC;
84403 +#endif
84404 +
84405 + }
84406 +#endif
84407 +
84408 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
84409 if (error & ~PAGE_MASK)
84410 return error;
84411
84412 + charged = len >> PAGE_SHIFT;
84413 +
84414 /*
84415 * mlock MCL_FUTURE?
84416 */
84417 if (mm->def_flags & VM_LOCKED) {
84418 unsigned long locked, lock_limit;
84419 - locked = len >> PAGE_SHIFT;
84420 + locked = charged;
84421 locked += mm->locked_vm;
84422 lock_limit = rlimit(RLIMIT_MEMLOCK);
84423 lock_limit >>= PAGE_SHIFT;
84424 @@ -2644,21 +3141,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84425 /*
84426 * Clear old maps. this also does some error checking for us
84427 */
84428 - munmap_back:
84429 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
84430 if (do_munmap(mm, addr, len))
84431 return -ENOMEM;
84432 - goto munmap_back;
84433 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
84434 }
84435
84436 /* Check against address space limits *after* clearing old maps... */
84437 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
84438 + if (!may_expand_vm(mm, charged))
84439 return -ENOMEM;
84440
84441 if (mm->map_count > sysctl_max_map_count)
84442 return -ENOMEM;
84443
84444 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
84445 + if (security_vm_enough_memory_mm(mm, charged))
84446 return -ENOMEM;
84447
84448 /* Can we just expand an old private anonymous mapping? */
84449 @@ -2672,7 +3168,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84450 */
84451 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
84452 if (!vma) {
84453 - vm_unacct_memory(len >> PAGE_SHIFT);
84454 + vm_unacct_memory(charged);
84455 return -ENOMEM;
84456 }
84457
84458 @@ -2686,9 +3182,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84459 vma_link(mm, vma, prev, rb_link, rb_parent);
84460 out:
84461 perf_event_mmap(vma);
84462 - mm->total_vm += len >> PAGE_SHIFT;
84463 + mm->total_vm += charged;
84464 if (flags & VM_LOCKED)
84465 - mm->locked_vm += (len >> PAGE_SHIFT);
84466 + mm->locked_vm += charged;
84467 + track_exec_limit(mm, addr, addr + len, flags);
84468 return addr;
84469 }
84470
84471 @@ -2750,6 +3247,7 @@ void exit_mmap(struct mm_struct *mm)
84472 while (vma) {
84473 if (vma->vm_flags & VM_ACCOUNT)
84474 nr_accounted += vma_pages(vma);
84475 + vma->vm_mirror = NULL;
84476 vma = remove_vma(vma);
84477 }
84478 vm_unacct_memory(nr_accounted);
84479 @@ -2766,6 +3264,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
84480 struct vm_area_struct *prev;
84481 struct rb_node **rb_link, *rb_parent;
84482
84483 +#ifdef CONFIG_PAX_SEGMEXEC
84484 + struct vm_area_struct *vma_m = NULL;
84485 +#endif
84486 +
84487 + if (security_mmap_addr(vma->vm_start))
84488 + return -EPERM;
84489 +
84490 /*
84491 * The vm_pgoff of a purely anonymous vma should be irrelevant
84492 * until its first write fault, when page's anon_vma and index
84493 @@ -2789,7 +3294,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
84494 security_vm_enough_memory_mm(mm, vma_pages(vma)))
84495 return -ENOMEM;
84496
84497 +#ifdef CONFIG_PAX_SEGMEXEC
84498 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
84499 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
84500 + if (!vma_m)
84501 + return -ENOMEM;
84502 + }
84503 +#endif
84504 +
84505 vma_link(mm, vma, prev, rb_link, rb_parent);
84506 +
84507 +#ifdef CONFIG_PAX_SEGMEXEC
84508 + if (vma_m)
84509 + BUG_ON(pax_mirror_vma(vma_m, vma));
84510 +#endif
84511 +
84512 return 0;
84513 }
84514
84515 @@ -2809,6 +3328,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
84516 struct mempolicy *pol;
84517 bool faulted_in_anon_vma = true;
84518
84519 + BUG_ON(vma->vm_mirror);
84520 +
84521 /*
84522 * If anonymous vma has not yet been faulted, update new pgoff
84523 * to match new location, to increase its chance of merging.
84524 @@ -2875,6 +3396,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
84525 return NULL;
84526 }
84527
84528 +#ifdef CONFIG_PAX_SEGMEXEC
84529 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
84530 +{
84531 + struct vm_area_struct *prev_m;
84532 + struct rb_node **rb_link_m, *rb_parent_m;
84533 + struct mempolicy *pol_m;
84534 +
84535 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
84536 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
84537 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
84538 + *vma_m = *vma;
84539 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
84540 + if (anon_vma_clone(vma_m, vma))
84541 + return -ENOMEM;
84542 + pol_m = vma_policy(vma_m);
84543 + mpol_get(pol_m);
84544 + vma_set_policy(vma_m, pol_m);
84545 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
84546 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
84547 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
84548 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
84549 + if (vma_m->vm_file)
84550 + get_file(vma_m->vm_file);
84551 + if (vma_m->vm_ops && vma_m->vm_ops->open)
84552 + vma_m->vm_ops->open(vma_m);
84553 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
84554 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
84555 + vma_m->vm_mirror = vma;
84556 + vma->vm_mirror = vma_m;
84557 + return 0;
84558 +}
84559 +#endif
84560 +
84561 /*
84562 * Return true if the calling process may expand its vm space by the passed
84563 * number of pages
84564 @@ -2886,6 +3440,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
84565
84566 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
84567
84568 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
84569 if (cur + npages > lim)
84570 return 0;
84571 return 1;
84572 @@ -2956,6 +3511,22 @@ int install_special_mapping(struct mm_struct *mm,
84573 vma->vm_start = addr;
84574 vma->vm_end = addr + len;
84575
84576 +#ifdef CONFIG_PAX_MPROTECT
84577 + if (mm->pax_flags & MF_PAX_MPROTECT) {
84578 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
84579 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
84580 + return -EPERM;
84581 + if (!(vm_flags & VM_EXEC))
84582 + vm_flags &= ~VM_MAYEXEC;
84583 +#else
84584 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
84585 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
84586 +#endif
84587 + else
84588 + vm_flags &= ~VM_MAYWRITE;
84589 + }
84590 +#endif
84591 +
84592 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
84593 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
84594
84595 diff --git a/mm/mprotect.c b/mm/mprotect.c
84596 index 94722a4..e661e29 100644
84597 --- a/mm/mprotect.c
84598 +++ b/mm/mprotect.c
84599 @@ -23,10 +23,18 @@
84600 #include <linux/mmu_notifier.h>
84601 #include <linux/migrate.h>
84602 #include <linux/perf_event.h>
84603 +#include <linux/sched/sysctl.h>
84604 +
84605 +#ifdef CONFIG_PAX_MPROTECT
84606 +#include <linux/elf.h>
84607 +#include <linux/binfmts.h>
84608 +#endif
84609 +
84610 #include <asm/uaccess.h>
84611 #include <asm/pgtable.h>
84612 #include <asm/cacheflush.h>
84613 #include <asm/tlbflush.h>
84614 +#include <asm/mmu_context.h>
84615
84616 #ifndef pgprot_modify
84617 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
84618 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
84619 return pages;
84620 }
84621
84622 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84623 +/* called while holding the mmap semaphor for writing except stack expansion */
84624 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
84625 +{
84626 + unsigned long oldlimit, newlimit = 0UL;
84627 +
84628 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
84629 + return;
84630 +
84631 + spin_lock(&mm->page_table_lock);
84632 + oldlimit = mm->context.user_cs_limit;
84633 + if ((prot & VM_EXEC) && oldlimit < end)
84634 + /* USER_CS limit moved up */
84635 + newlimit = end;
84636 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
84637 + /* USER_CS limit moved down */
84638 + newlimit = start;
84639 +
84640 + if (newlimit) {
84641 + mm->context.user_cs_limit = newlimit;
84642 +
84643 +#ifdef CONFIG_SMP
84644 + wmb();
84645 + cpus_clear(mm->context.cpu_user_cs_mask);
84646 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
84647 +#endif
84648 +
84649 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
84650 + }
84651 + spin_unlock(&mm->page_table_lock);
84652 + if (newlimit == end) {
84653 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
84654 +
84655 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
84656 + if (is_vm_hugetlb_page(vma))
84657 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
84658 + else
84659 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
84660 + }
84661 +}
84662 +#endif
84663 +
84664 int
84665 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
84666 unsigned long start, unsigned long end, unsigned long newflags)
84667 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
84668 int error;
84669 int dirty_accountable = 0;
84670
84671 +#ifdef CONFIG_PAX_SEGMEXEC
84672 + struct vm_area_struct *vma_m = NULL;
84673 + unsigned long start_m, end_m;
84674 +
84675 + start_m = start + SEGMEXEC_TASK_SIZE;
84676 + end_m = end + SEGMEXEC_TASK_SIZE;
84677 +#endif
84678 +
84679 if (newflags == oldflags) {
84680 *pprev = vma;
84681 return 0;
84682 }
84683
84684 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
84685 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
84686 +
84687 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
84688 + return -ENOMEM;
84689 +
84690 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
84691 + return -ENOMEM;
84692 + }
84693 +
84694 /*
84695 * If we make a private mapping writable we increase our commit;
84696 * but (without finer accounting) cannot reduce our commit if we
84697 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
84698 }
84699 }
84700
84701 +#ifdef CONFIG_PAX_SEGMEXEC
84702 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
84703 + if (start != vma->vm_start) {
84704 + error = split_vma(mm, vma, start, 1);
84705 + if (error)
84706 + goto fail;
84707 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
84708 + *pprev = (*pprev)->vm_next;
84709 + }
84710 +
84711 + if (end != vma->vm_end) {
84712 + error = split_vma(mm, vma, end, 0);
84713 + if (error)
84714 + goto fail;
84715 + }
84716 +
84717 + if (pax_find_mirror_vma(vma)) {
84718 + error = __do_munmap(mm, start_m, end_m - start_m);
84719 + if (error)
84720 + goto fail;
84721 + } else {
84722 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
84723 + if (!vma_m) {
84724 + error = -ENOMEM;
84725 + goto fail;
84726 + }
84727 + vma->vm_flags = newflags;
84728 + error = pax_mirror_vma(vma_m, vma);
84729 + if (error) {
84730 + vma->vm_flags = oldflags;
84731 + goto fail;
84732 + }
84733 + }
84734 + }
84735 +#endif
84736 +
84737 /*
84738 * First try to merge with previous and/or next vma.
84739 */
84740 @@ -296,9 +400,21 @@ success:
84741 * vm_flags and vm_page_prot are protected by the mmap_sem
84742 * held in write mode.
84743 */
84744 +
84745 +#ifdef CONFIG_PAX_SEGMEXEC
84746 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
84747 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
84748 +#endif
84749 +
84750 vma->vm_flags = newflags;
84751 +
84752 +#ifdef CONFIG_PAX_MPROTECT
84753 + if (mm->binfmt && mm->binfmt->handle_mprotect)
84754 + mm->binfmt->handle_mprotect(vma, newflags);
84755 +#endif
84756 +
84757 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
84758 - vm_get_page_prot(newflags));
84759 + vm_get_page_prot(vma->vm_flags));
84760
84761 if (vma_wants_writenotify(vma)) {
84762 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
84763 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84764 end = start + len;
84765 if (end <= start)
84766 return -ENOMEM;
84767 +
84768 +#ifdef CONFIG_PAX_SEGMEXEC
84769 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
84770 + if (end > SEGMEXEC_TASK_SIZE)
84771 + return -EINVAL;
84772 + } else
84773 +#endif
84774 +
84775 + if (end > TASK_SIZE)
84776 + return -EINVAL;
84777 +
84778 if (!arch_validate_prot(prot))
84779 return -EINVAL;
84780
84781 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84782 /*
84783 * Does the application expect PROT_READ to imply PROT_EXEC:
84784 */
84785 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
84786 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
84787 prot |= PROT_EXEC;
84788
84789 vm_flags = calc_vm_prot_bits(prot);
84790 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84791 if (start > vma->vm_start)
84792 prev = vma;
84793
84794 +#ifdef CONFIG_PAX_MPROTECT
84795 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
84796 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
84797 +#endif
84798 +
84799 for (nstart = start ; ; ) {
84800 unsigned long newflags;
84801
84802 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84803
84804 /* newflags >> 4 shift VM_MAY% in place of VM_% */
84805 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
84806 + if (prot & (PROT_WRITE | PROT_EXEC))
84807 + gr_log_rwxmprotect(vma);
84808 +
84809 + error = -EACCES;
84810 + goto out;
84811 + }
84812 +
84813 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
84814 error = -EACCES;
84815 goto out;
84816 }
84817 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84818 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
84819 if (error)
84820 goto out;
84821 +
84822 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
84823 +
84824 nstart = tmp;
84825
84826 if (nstart < prev->vm_end)
84827 diff --git a/mm/mremap.c b/mm/mremap.c
84828 index 463a257..c0c7a92 100644
84829 --- a/mm/mremap.c
84830 +++ b/mm/mremap.c
84831 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
84832 continue;
84833 pte = ptep_get_and_clear(mm, old_addr, old_pte);
84834 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
84835 +
84836 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84837 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
84838 + pte = pte_exprotect(pte);
84839 +#endif
84840 +
84841 set_pte_at(mm, new_addr, new_pte, pte);
84842 }
84843
84844 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
84845 if (is_vm_hugetlb_page(vma))
84846 goto Einval;
84847
84848 +#ifdef CONFIG_PAX_SEGMEXEC
84849 + if (pax_find_mirror_vma(vma))
84850 + goto Einval;
84851 +#endif
84852 +
84853 /* We can't remap across vm area boundaries */
84854 if (old_len > vma->vm_end - addr)
84855 goto Efault;
84856 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
84857 unsigned long ret = -EINVAL;
84858 unsigned long charged = 0;
84859 unsigned long map_flags;
84860 + unsigned long pax_task_size = TASK_SIZE;
84861
84862 if (new_addr & ~PAGE_MASK)
84863 goto out;
84864
84865 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
84866 +#ifdef CONFIG_PAX_SEGMEXEC
84867 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84868 + pax_task_size = SEGMEXEC_TASK_SIZE;
84869 +#endif
84870 +
84871 + pax_task_size -= PAGE_SIZE;
84872 +
84873 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
84874 goto out;
84875
84876 /* Check if the location we're moving into overlaps the
84877 * old location at all, and fail if it does.
84878 */
84879 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
84880 - goto out;
84881 -
84882 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
84883 + if (addr + old_len > new_addr && new_addr + new_len > addr)
84884 goto out;
84885
84886 ret = do_munmap(mm, new_addr, new_len);
84887 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84888 unsigned long ret = -EINVAL;
84889 unsigned long charged = 0;
84890 bool locked = false;
84891 + unsigned long pax_task_size = TASK_SIZE;
84892
84893 down_write(&current->mm->mmap_sem);
84894
84895 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84896 if (!new_len)
84897 goto out;
84898
84899 +#ifdef CONFIG_PAX_SEGMEXEC
84900 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84901 + pax_task_size = SEGMEXEC_TASK_SIZE;
84902 +#endif
84903 +
84904 + pax_task_size -= PAGE_SIZE;
84905 +
84906 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
84907 + old_len > pax_task_size || addr > pax_task_size-old_len)
84908 + goto out;
84909 +
84910 if (flags & MREMAP_FIXED) {
84911 if (flags & MREMAP_MAYMOVE)
84912 ret = mremap_to(addr, old_len, new_addr, new_len,
84913 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84914 new_addr = addr;
84915 }
84916 ret = addr;
84917 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
84918 goto out;
84919 }
84920 }
84921 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84922 goto out;
84923 }
84924
84925 + map_flags = vma->vm_flags;
84926 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
84927 + if (!(ret & ~PAGE_MASK)) {
84928 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
84929 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
84930 + }
84931 }
84932 out:
84933 if (ret & ~PAGE_MASK)
84934 diff --git a/mm/nommu.c b/mm/nommu.c
84935 index 298884d..5f74980 100644
84936 --- a/mm/nommu.c
84937 +++ b/mm/nommu.c
84938 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
84939 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
84940 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
84941 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
84942 -int heap_stack_gap = 0;
84943
84944 atomic_long_t mmap_pages_allocated;
84945
84946 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
84947 EXPORT_SYMBOL(find_vma);
84948
84949 /*
84950 - * find a VMA
84951 - * - we don't extend stack VMAs under NOMMU conditions
84952 - */
84953 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
84954 -{
84955 - return find_vma(mm, addr);
84956 -}
84957 -
84958 -/*
84959 * expand a stack to a given address
84960 * - not supported under NOMMU conditions
84961 */
84962 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84963
84964 /* most fields are the same, copy all, and then fixup */
84965 *new = *vma;
84966 + INIT_LIST_HEAD(&new->anon_vma_chain);
84967 *region = *vma->vm_region;
84968 new->vm_region = region;
84969
84970 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
84971 }
84972 EXPORT_SYMBOL(generic_file_remap_pages);
84973
84974 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84975 - unsigned long addr, void *buf, int len, int write)
84976 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84977 + unsigned long addr, void *buf, size_t len, int write)
84978 {
84979 struct vm_area_struct *vma;
84980
84981 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84982 *
84983 * The caller must hold a reference on @mm.
84984 */
84985 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84986 - void *buf, int len, int write)
84987 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
84988 + void *buf, size_t len, int write)
84989 {
84990 return __access_remote_vm(NULL, mm, addr, buf, len, write);
84991 }
84992 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84993 * Access another process' address space.
84994 * - source/target buffer must be kernel space
84995 */
84996 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
84997 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
84998 {
84999 struct mm_struct *mm;
85000
85001 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
85002 index 4514ad7..92eaa1c 100644
85003 --- a/mm/page-writeback.c
85004 +++ b/mm/page-writeback.c
85005 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
85006 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
85007 * - the bdi dirty thresh drops quickly due to change of JBOD workload
85008 */
85009 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
85010 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
85011 unsigned long thresh,
85012 unsigned long bg_thresh,
85013 unsigned long dirty,
85014 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
85015 }
85016 }
85017
85018 -static struct notifier_block __cpuinitdata ratelimit_nb = {
85019 +static struct notifier_block ratelimit_nb = {
85020 .notifier_call = ratelimit_handler,
85021 .next = NULL,
85022 };
85023 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
85024 index 2ee0fd3..6e2edfb 100644
85025 --- a/mm/page_alloc.c
85026 +++ b/mm/page_alloc.c
85027 @@ -60,6 +60,7 @@
85028 #include <linux/page-debug-flags.h>
85029 #include <linux/hugetlb.h>
85030 #include <linux/sched/rt.h>
85031 +#include <linux/random.h>
85032
85033 #include <asm/tlbflush.h>
85034 #include <asm/div64.h>
85035 @@ -345,7 +346,7 @@ out:
85036 * This usage means that zero-order pages may not be compound.
85037 */
85038
85039 -static void free_compound_page(struct page *page)
85040 +void free_compound_page(struct page *page)
85041 {
85042 __free_pages_ok(page, compound_order(page));
85043 }
85044 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
85045 int i;
85046 int bad = 0;
85047
85048 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85049 + unsigned long index = 1UL << order;
85050 +#endif
85051 +
85052 trace_mm_page_free(page, order);
85053 kmemcheck_free_shadow(page, order);
85054
85055 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
85056 debug_check_no_obj_freed(page_address(page),
85057 PAGE_SIZE << order);
85058 }
85059 +
85060 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85061 + for (; index; --index)
85062 + sanitize_highpage(page + index - 1);
85063 +#endif
85064 +
85065 arch_free_page(page, order);
85066 kernel_map_pages(page, 1 << order, 0);
85067
85068 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
85069 local_irq_restore(flags);
85070 }
85071
85072 +#ifdef CONFIG_PAX_LATENT_ENTROPY
85073 +bool __meminitdata extra_latent_entropy;
85074 +
85075 +static int __init setup_pax_extra_latent_entropy(char *str)
85076 +{
85077 + extra_latent_entropy = true;
85078 + return 0;
85079 +}
85080 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
85081 +
85082 +volatile u64 latent_entropy;
85083 +#endif
85084 +
85085 /*
85086 * Read access to zone->managed_pages is safe because it's unsigned long,
85087 * but we still need to serialize writers. Currently all callers of
85088 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
85089 set_page_count(p, 0);
85090 }
85091
85092 +#ifdef CONFIG_PAX_LATENT_ENTROPY
85093 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
85094 + u64 hash = 0;
85095 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
85096 + const u64 *data = lowmem_page_address(page);
85097 +
85098 + for (index = 0; index < end; index++)
85099 + hash ^= hash + data[index];
85100 + latent_entropy ^= hash;
85101 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
85102 + }
85103 +#endif
85104 +
85105 page_zone(page)->managed_pages += 1 << order;
85106 set_page_refcounted(page);
85107 __free_pages(page, order);
85108 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
85109 arch_alloc_page(page, order);
85110 kernel_map_pages(page, 1 << order, 1);
85111
85112 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
85113 if (gfp_flags & __GFP_ZERO)
85114 prep_zero_page(page, order, gfp_flags);
85115 +#endif
85116
85117 if (order && (gfp_flags & __GFP_COMP))
85118 prep_compound_page(page, order);
85119 diff --git a/mm/page_io.c b/mm/page_io.c
85120 index a8a3ef4..7260a60 100644
85121 --- a/mm/page_io.c
85122 +++ b/mm/page_io.c
85123 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
85124 struct file *swap_file = sis->swap_file;
85125 struct address_space *mapping = swap_file->f_mapping;
85126 struct iovec iov = {
85127 - .iov_base = kmap(page),
85128 + .iov_base = (void __force_user *)kmap(page),
85129 .iov_len = PAGE_SIZE,
85130 };
85131
85132 diff --git a/mm/percpu.c b/mm/percpu.c
85133 index 8c8e08f..73a5cda 100644
85134 --- a/mm/percpu.c
85135 +++ b/mm/percpu.c
85136 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
85137 static unsigned int pcpu_high_unit_cpu __read_mostly;
85138
85139 /* the address of the first chunk which starts with the kernel static area */
85140 -void *pcpu_base_addr __read_mostly;
85141 +void *pcpu_base_addr __read_only;
85142 EXPORT_SYMBOL_GPL(pcpu_base_addr);
85143
85144 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
85145 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
85146 index fd26d04..0cea1b0 100644
85147 --- a/mm/process_vm_access.c
85148 +++ b/mm/process_vm_access.c
85149 @@ -13,6 +13,7 @@
85150 #include <linux/uio.h>
85151 #include <linux/sched.h>
85152 #include <linux/highmem.h>
85153 +#include <linux/security.h>
85154 #include <linux/ptrace.h>
85155 #include <linux/slab.h>
85156 #include <linux/syscalls.h>
85157 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
85158 size_t iov_l_curr_offset = 0;
85159 ssize_t iov_len;
85160
85161 + return -ENOSYS; // PaX: until properly audited
85162 +
85163 /*
85164 * Work out how many pages of struct pages we're going to need
85165 * when eventually calling get_user_pages
85166 */
85167 for (i = 0; i < riovcnt; i++) {
85168 iov_len = rvec[i].iov_len;
85169 - if (iov_len > 0) {
85170 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
85171 - + iov_len)
85172 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
85173 - / PAGE_SIZE + 1;
85174 - nr_pages = max(nr_pages, nr_pages_iov);
85175 - }
85176 + if (iov_len <= 0)
85177 + continue;
85178 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
85179 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
85180 + nr_pages = max(nr_pages, nr_pages_iov);
85181 }
85182
85183 if (nr_pages == 0)
85184 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
85185 goto free_proc_pages;
85186 }
85187
85188 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
85189 + rc = -EPERM;
85190 + goto put_task_struct;
85191 + }
85192 +
85193 mm = mm_access(task, PTRACE_MODE_ATTACH);
85194 if (!mm || IS_ERR(mm)) {
85195 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
85196 diff --git a/mm/rmap.c b/mm/rmap.c
85197 index 6280da8..b5c090e 100644
85198 --- a/mm/rmap.c
85199 +++ b/mm/rmap.c
85200 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85201 struct anon_vma *anon_vma = vma->anon_vma;
85202 struct anon_vma_chain *avc;
85203
85204 +#ifdef CONFIG_PAX_SEGMEXEC
85205 + struct anon_vma_chain *avc_m = NULL;
85206 +#endif
85207 +
85208 might_sleep();
85209 if (unlikely(!anon_vma)) {
85210 struct mm_struct *mm = vma->vm_mm;
85211 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85212 if (!avc)
85213 goto out_enomem;
85214
85215 +#ifdef CONFIG_PAX_SEGMEXEC
85216 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
85217 + if (!avc_m)
85218 + goto out_enomem_free_avc;
85219 +#endif
85220 +
85221 anon_vma = find_mergeable_anon_vma(vma);
85222 allocated = NULL;
85223 if (!anon_vma) {
85224 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85225 /* page_table_lock to protect against threads */
85226 spin_lock(&mm->page_table_lock);
85227 if (likely(!vma->anon_vma)) {
85228 +
85229 +#ifdef CONFIG_PAX_SEGMEXEC
85230 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
85231 +
85232 + if (vma_m) {
85233 + BUG_ON(vma_m->anon_vma);
85234 + vma_m->anon_vma = anon_vma;
85235 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
85236 + avc_m = NULL;
85237 + }
85238 +#endif
85239 +
85240 vma->anon_vma = anon_vma;
85241 anon_vma_chain_link(vma, avc, anon_vma);
85242 allocated = NULL;
85243 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85244
85245 if (unlikely(allocated))
85246 put_anon_vma(allocated);
85247 +
85248 +#ifdef CONFIG_PAX_SEGMEXEC
85249 + if (unlikely(avc_m))
85250 + anon_vma_chain_free(avc_m);
85251 +#endif
85252 +
85253 if (unlikely(avc))
85254 anon_vma_chain_free(avc);
85255 }
85256 return 0;
85257
85258 out_enomem_free_avc:
85259 +
85260 +#ifdef CONFIG_PAX_SEGMEXEC
85261 + if (avc_m)
85262 + anon_vma_chain_free(avc_m);
85263 +#endif
85264 +
85265 anon_vma_chain_free(avc);
85266 out_enomem:
85267 return -ENOMEM;
85268 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
85269 * Attach the anon_vmas from src to dst.
85270 * Returns 0 on success, -ENOMEM on failure.
85271 */
85272 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
85273 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
85274 {
85275 struct anon_vma_chain *avc, *pavc;
85276 struct anon_vma *root = NULL;
85277 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
85278 * the corresponding VMA in the parent process is attached to.
85279 * Returns 0 on success, non-zero on failure.
85280 */
85281 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
85282 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
85283 {
85284 struct anon_vma_chain *avc;
85285 struct anon_vma *anon_vma;
85286 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
85287 void __init anon_vma_init(void)
85288 {
85289 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
85290 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
85291 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
85292 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
85293 + anon_vma_ctor);
85294 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
85295 + SLAB_PANIC|SLAB_NO_SANITIZE);
85296 }
85297
85298 /*
85299 diff --git a/mm/shmem.c b/mm/shmem.c
85300 index 5e6a842..b41916e 100644
85301 --- a/mm/shmem.c
85302 +++ b/mm/shmem.c
85303 @@ -33,7 +33,7 @@
85304 #include <linux/swap.h>
85305 #include <linux/aio.h>
85306
85307 -static struct vfsmount *shm_mnt;
85308 +struct vfsmount *shm_mnt;
85309
85310 #ifdef CONFIG_SHMEM
85311 /*
85312 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
85313 #define BOGO_DIRENT_SIZE 20
85314
85315 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
85316 -#define SHORT_SYMLINK_LEN 128
85317 +#define SHORT_SYMLINK_LEN 64
85318
85319 /*
85320 * shmem_fallocate and shmem_writepage communicate via inode->i_private
85321 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
85322 static int shmem_xattr_validate(const char *name)
85323 {
85324 struct { const char *prefix; size_t len; } arr[] = {
85325 +
85326 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
85327 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
85328 +#endif
85329 +
85330 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
85331 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
85332 };
85333 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
85334 if (err)
85335 return err;
85336
85337 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
85338 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
85339 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
85340 + return -EOPNOTSUPP;
85341 + if (size > 8)
85342 + return -EINVAL;
85343 + }
85344 +#endif
85345 +
85346 return simple_xattr_set(&info->xattrs, name, value, size, flags);
85347 }
85348
85349 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
85350 int err = -ENOMEM;
85351
85352 /* Round up to L1_CACHE_BYTES to resist false sharing */
85353 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
85354 - L1_CACHE_BYTES), GFP_KERNEL);
85355 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
85356 if (!sbinfo)
85357 return -ENOMEM;
85358
85359 diff --git a/mm/slab.c b/mm/slab.c
85360 index bd88411..2d46fd6 100644
85361 --- a/mm/slab.c
85362 +++ b/mm/slab.c
85363 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
85364 if ((x)->max_freeable < i) \
85365 (x)->max_freeable = i; \
85366 } while (0)
85367 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
85368 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
85369 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
85370 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
85371 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
85372 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
85373 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
85374 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
85375 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
85376 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
85377 #else
85378 #define STATS_INC_ACTIVE(x) do { } while (0)
85379 #define STATS_DEC_ACTIVE(x) do { } while (0)
85380 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
85381 #define STATS_INC_ALLOCMISS(x) do { } while (0)
85382 #define STATS_INC_FREEHIT(x) do { } while (0)
85383 #define STATS_INC_FREEMISS(x) do { } while (0)
85384 +#define STATS_INC_SANITIZED(x) do { } while (0)
85385 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
85386 #endif
85387
85388 #if DEBUG
85389 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
85390 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
85391 */
85392 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
85393 - const struct slab *slab, void *obj)
85394 + const struct slab *slab, const void *obj)
85395 {
85396 u32 offset = (obj - slab->s_mem);
85397 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
85398 @@ -1384,7 +1388,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
85399 return notifier_from_errno(err);
85400 }
85401
85402 -static struct notifier_block __cpuinitdata cpucache_notifier = {
85403 +static struct notifier_block cpucache_notifier = {
85404 &cpuup_callback, NULL, 0
85405 };
85406
85407 @@ -1565,12 +1569,12 @@ void __init kmem_cache_init(void)
85408 */
85409
85410 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
85411 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
85412 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
85413
85414 if (INDEX_AC != INDEX_NODE)
85415 kmalloc_caches[INDEX_NODE] =
85416 create_kmalloc_cache("kmalloc-node",
85417 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
85418 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
85419
85420 slab_early_init = 0;
85421
85422 @@ -3583,6 +3587,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
85423 struct array_cache *ac = cpu_cache_get(cachep);
85424
85425 check_irq_off();
85426 +
85427 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85428 + if (pax_sanitize_slab) {
85429 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
85430 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
85431 +
85432 + if (cachep->ctor)
85433 + cachep->ctor(objp);
85434 +
85435 + STATS_INC_SANITIZED(cachep);
85436 + } else
85437 + STATS_INC_NOT_SANITIZED(cachep);
85438 + }
85439 +#endif
85440 +
85441 kmemleak_free_recursive(objp, cachep->flags);
85442 objp = cache_free_debugcheck(cachep, objp, caller);
85443
85444 @@ -3800,6 +3819,7 @@ void kfree(const void *objp)
85445
85446 if (unlikely(ZERO_OR_NULL_PTR(objp)))
85447 return;
85448 + VM_BUG_ON(!virt_addr_valid(objp));
85449 local_irq_save(flags);
85450 kfree_debugcheck(objp);
85451 c = virt_to_cache(objp);
85452 @@ -4241,14 +4261,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
85453 }
85454 /* cpu stats */
85455 {
85456 - unsigned long allochit = atomic_read(&cachep->allochit);
85457 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
85458 - unsigned long freehit = atomic_read(&cachep->freehit);
85459 - unsigned long freemiss = atomic_read(&cachep->freemiss);
85460 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
85461 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
85462 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
85463 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
85464
85465 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
85466 allochit, allocmiss, freehit, freemiss);
85467 }
85468 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85469 + {
85470 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
85471 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
85472 +
85473 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
85474 + }
85475 +#endif
85476 #endif
85477 }
85478
85479 @@ -4476,13 +4504,71 @@ static const struct file_operations proc_slabstats_operations = {
85480 static int __init slab_proc_init(void)
85481 {
85482 #ifdef CONFIG_DEBUG_SLAB_LEAK
85483 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
85484 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
85485 #endif
85486 return 0;
85487 }
85488 module_init(slab_proc_init);
85489 #endif
85490
85491 +bool is_usercopy_object(const void *ptr)
85492 +{
85493 + struct page *page;
85494 + struct kmem_cache *cachep;
85495 +
85496 + if (ZERO_OR_NULL_PTR(ptr))
85497 + return false;
85498 +
85499 + if (!slab_is_available())
85500 + return false;
85501 +
85502 + if (!virt_addr_valid(ptr))
85503 + return false;
85504 +
85505 + page = virt_to_head_page(ptr);
85506 +
85507 + if (!PageSlab(page))
85508 + return false;
85509 +
85510 + cachep = page->slab_cache;
85511 + return cachep->flags & SLAB_USERCOPY;
85512 +}
85513 +
85514 +#ifdef CONFIG_PAX_USERCOPY
85515 +const char *check_heap_object(const void *ptr, unsigned long n)
85516 +{
85517 + struct page *page;
85518 + struct kmem_cache *cachep;
85519 + struct slab *slabp;
85520 + unsigned int objnr;
85521 + unsigned long offset;
85522 +
85523 + if (ZERO_OR_NULL_PTR(ptr))
85524 + return "<null>";
85525 +
85526 + if (!virt_addr_valid(ptr))
85527 + return NULL;
85528 +
85529 + page = virt_to_head_page(ptr);
85530 +
85531 + if (!PageSlab(page))
85532 + return NULL;
85533 +
85534 + cachep = page->slab_cache;
85535 + if (!(cachep->flags & SLAB_USERCOPY))
85536 + return cachep->name;
85537 +
85538 + slabp = page->slab_page;
85539 + objnr = obj_to_index(cachep, slabp, ptr);
85540 + BUG_ON(objnr >= cachep->num);
85541 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
85542 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
85543 + return NULL;
85544 +
85545 + return cachep->name;
85546 +}
85547 +#endif
85548 +
85549 /**
85550 * ksize - get the actual amount of memory allocated for a given object
85551 * @objp: Pointer to the object
85552 diff --git a/mm/slab.h b/mm/slab.h
85553 index f96b49e..db1d204 100644
85554 --- a/mm/slab.h
85555 +++ b/mm/slab.h
85556 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
85557 /* The slab cache that manages slab cache information */
85558 extern struct kmem_cache *kmem_cache;
85559
85560 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85561 +#ifdef CONFIG_X86_64
85562 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
85563 +#else
85564 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
85565 +#endif
85566 +extern bool pax_sanitize_slab;
85567 +#endif
85568 +
85569 unsigned long calculate_alignment(unsigned long flags,
85570 unsigned long align, unsigned long size);
85571
85572 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85573
85574 /* Legal flag mask for kmem_cache_create(), for various configurations */
85575 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
85576 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
85577 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
85578 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
85579
85580 #if defined(CONFIG_DEBUG_SLAB)
85581 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
85582 @@ -229,6 +239,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
85583 return s;
85584
85585 page = virt_to_head_page(x);
85586 +
85587 + BUG_ON(!PageSlab(page));
85588 +
85589 cachep = page->slab_cache;
85590 if (slab_equal_or_root(cachep, s))
85591 return cachep;
85592 diff --git a/mm/slab_common.c b/mm/slab_common.c
85593 index 2d41450..4efe6ee 100644
85594 --- a/mm/slab_common.c
85595 +++ b/mm/slab_common.c
85596 @@ -22,11 +22,22 @@
85597
85598 #include "slab.h"
85599
85600 -enum slab_state slab_state;
85601 +enum slab_state slab_state __read_only;
85602 LIST_HEAD(slab_caches);
85603 DEFINE_MUTEX(slab_mutex);
85604 struct kmem_cache *kmem_cache;
85605
85606 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85607 +bool pax_sanitize_slab __read_only = true;
85608 +static int __init pax_sanitize_slab_setup(char *str)
85609 +{
85610 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
85611 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
85612 + return 1;
85613 +}
85614 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
85615 +#endif
85616 +
85617 #ifdef CONFIG_DEBUG_VM
85618 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
85619 size_t size)
85620 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
85621
85622 err = __kmem_cache_create(s, flags);
85623 if (!err) {
85624 - s->refcount = 1;
85625 + atomic_set(&s->refcount, 1);
85626 list_add(&s->list, &slab_caches);
85627 memcg_cache_list_add(memcg, s);
85628 } else {
85629 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
85630
85631 get_online_cpus();
85632 mutex_lock(&slab_mutex);
85633 - s->refcount--;
85634 - if (!s->refcount) {
85635 + if (atomic_dec_and_test(&s->refcount)) {
85636 list_del(&s->list);
85637
85638 if (!__kmem_cache_shutdown(s)) {
85639 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
85640 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
85641 name, size, err);
85642
85643 - s->refcount = -1; /* Exempt from merging for now */
85644 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
85645 }
85646
85647 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
85648 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
85649
85650 create_boot_cache(s, name, size, flags);
85651 list_add(&s->list, &slab_caches);
85652 - s->refcount = 1;
85653 + atomic_set(&s->refcount, 1);
85654 return s;
85655 }
85656
85657 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
85658 EXPORT_SYMBOL(kmalloc_dma_caches);
85659 #endif
85660
85661 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85662 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
85663 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
85664 +#endif
85665 +
85666 /*
85667 * Conversion table for small slabs sizes / 8 to the index in the
85668 * kmalloc array. This is necessary for slabs < 192 since we have non power
85669 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
85670 return kmalloc_dma_caches[index];
85671
85672 #endif
85673 +
85674 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85675 + if (unlikely((flags & GFP_USERCOPY)))
85676 + return kmalloc_usercopy_caches[index];
85677 +
85678 +#endif
85679 +
85680 return kmalloc_caches[index];
85681 }
85682
85683 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
85684 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
85685 if (!kmalloc_caches[i]) {
85686 kmalloc_caches[i] = create_kmalloc_cache(NULL,
85687 - 1 << i, flags);
85688 + 1 << i, SLAB_USERCOPY | flags);
85689 }
85690
85691 /*
85692 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
85693 * earlier power of two caches
85694 */
85695 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
85696 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
85697 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
85698
85699 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
85700 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
85701 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
85702 }
85703
85704 /* Kmalloc array is now usable */
85705 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
85706 }
85707 }
85708 #endif
85709 +
85710 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85711 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
85712 + struct kmem_cache *s = kmalloc_caches[i];
85713 +
85714 + if (s) {
85715 + int size = kmalloc_size(i);
85716 + char *n = kasprintf(GFP_NOWAIT,
85717 + "usercopy-kmalloc-%d", size);
85718 +
85719 + BUG_ON(!n);
85720 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
85721 + size, SLAB_USERCOPY | flags);
85722 + }
85723 + }
85724 +#endif
85725 +
85726 }
85727 #endif /* !CONFIG_SLOB */
85728
85729 @@ -516,6 +555,9 @@ void print_slabinfo_header(struct seq_file *m)
85730 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
85731 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
85732 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
85733 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85734 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
85735 +#endif
85736 #endif
85737 seq_putc(m, '\n');
85738 }
85739 diff --git a/mm/slob.c b/mm/slob.c
85740 index eeed4a0..bb0e9ab 100644
85741 --- a/mm/slob.c
85742 +++ b/mm/slob.c
85743 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
85744 /*
85745 * Return the size of a slob block.
85746 */
85747 -static slobidx_t slob_units(slob_t *s)
85748 +static slobidx_t slob_units(const slob_t *s)
85749 {
85750 if (s->units > 0)
85751 return s->units;
85752 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
85753 /*
85754 * Return the next free slob block pointer after this one.
85755 */
85756 -static slob_t *slob_next(slob_t *s)
85757 +static slob_t *slob_next(const slob_t *s)
85758 {
85759 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
85760 slobidx_t next;
85761 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
85762 /*
85763 * Returns true if s is the last free block in its page.
85764 */
85765 -static int slob_last(slob_t *s)
85766 +static int slob_last(const slob_t *s)
85767 {
85768 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
85769 }
85770
85771 -static void *slob_new_pages(gfp_t gfp, int order, int node)
85772 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
85773 {
85774 - void *page;
85775 + struct page *page;
85776
85777 #ifdef CONFIG_NUMA
85778 if (node != NUMA_NO_NODE)
85779 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
85780 if (!page)
85781 return NULL;
85782
85783 - return page_address(page);
85784 + __SetPageSlab(page);
85785 + return page;
85786 }
85787
85788 -static void slob_free_pages(void *b, int order)
85789 +static void slob_free_pages(struct page *sp, int order)
85790 {
85791 if (current->reclaim_state)
85792 current->reclaim_state->reclaimed_slab += 1 << order;
85793 - free_pages((unsigned long)b, order);
85794 + __ClearPageSlab(sp);
85795 + page_mapcount_reset(sp);
85796 + sp->private = 0;
85797 + __free_pages(sp, order);
85798 }
85799
85800 /*
85801 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
85802
85803 /* Not enough space: must allocate a new page */
85804 if (!b) {
85805 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
85806 - if (!b)
85807 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
85808 + if (!sp)
85809 return NULL;
85810 - sp = virt_to_page(b);
85811 - __SetPageSlab(sp);
85812 + b = page_address(sp);
85813
85814 spin_lock_irqsave(&slob_lock, flags);
85815 sp->units = SLOB_UNITS(PAGE_SIZE);
85816 sp->freelist = b;
85817 + sp->private = 0;
85818 INIT_LIST_HEAD(&sp->list);
85819 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
85820 set_slob_page_free(sp, slob_list);
85821 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
85822 if (slob_page_free(sp))
85823 clear_slob_page_free(sp);
85824 spin_unlock_irqrestore(&slob_lock, flags);
85825 - __ClearPageSlab(sp);
85826 - page_mapcount_reset(sp);
85827 - slob_free_pages(b, 0);
85828 + slob_free_pages(sp, 0);
85829 return;
85830 }
85831
85832 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85833 + if (pax_sanitize_slab)
85834 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
85835 +#endif
85836 +
85837 if (!slob_page_free(sp)) {
85838 /* This slob page is about to become partially free. Easy! */
85839 sp->units = units;
85840 @@ -424,11 +431,10 @@ out:
85841 */
85842
85843 static __always_inline void *
85844 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85845 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
85846 {
85847 - unsigned int *m;
85848 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85849 - void *ret;
85850 + slob_t *m;
85851 + void *ret = NULL;
85852
85853 gfp &= gfp_allowed_mask;
85854
85855 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85856
85857 if (!m)
85858 return NULL;
85859 - *m = size;
85860 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
85861 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
85862 + m[0].units = size;
85863 + m[1].units = align;
85864 ret = (void *)m + align;
85865
85866 trace_kmalloc_node(caller, ret,
85867 size, size + align, gfp, node);
85868 } else {
85869 unsigned int order = get_order(size);
85870 + struct page *page;
85871
85872 if (likely(order))
85873 gfp |= __GFP_COMP;
85874 - ret = slob_new_pages(gfp, order, node);
85875 + page = slob_new_pages(gfp, order, node);
85876 + if (page) {
85877 + ret = page_address(page);
85878 + page->private = size;
85879 + }
85880
85881 trace_kmalloc_node(caller, ret,
85882 size, PAGE_SIZE << order, gfp, node);
85883 }
85884
85885 - kmemleak_alloc(ret, size, 1, gfp);
85886 + return ret;
85887 +}
85888 +
85889 +static __always_inline void *
85890 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85891 +{
85892 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85893 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
85894 +
85895 + if (!ZERO_OR_NULL_PTR(ret))
85896 + kmemleak_alloc(ret, size, 1, gfp);
85897 return ret;
85898 }
85899
85900 @@ -493,34 +517,112 @@ void kfree(const void *block)
85901 return;
85902 kmemleak_free(block);
85903
85904 + VM_BUG_ON(!virt_addr_valid(block));
85905 sp = virt_to_page(block);
85906 - if (PageSlab(sp)) {
85907 + VM_BUG_ON(!PageSlab(sp));
85908 + if (!sp->private) {
85909 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85910 - unsigned int *m = (unsigned int *)(block - align);
85911 - slob_free(m, *m + align);
85912 - } else
85913 + slob_t *m = (slob_t *)(block - align);
85914 + slob_free(m, m[0].units + align);
85915 + } else {
85916 + __ClearPageSlab(sp);
85917 + page_mapcount_reset(sp);
85918 + sp->private = 0;
85919 __free_pages(sp, compound_order(sp));
85920 + }
85921 }
85922 EXPORT_SYMBOL(kfree);
85923
85924 +bool is_usercopy_object(const void *ptr)
85925 +{
85926 + if (!slab_is_available())
85927 + return false;
85928 +
85929 + // PAX: TODO
85930 +
85931 + return false;
85932 +}
85933 +
85934 +#ifdef CONFIG_PAX_USERCOPY
85935 +const char *check_heap_object(const void *ptr, unsigned long n)
85936 +{
85937 + struct page *page;
85938 + const slob_t *free;
85939 + const void *base;
85940 + unsigned long flags;
85941 +
85942 + if (ZERO_OR_NULL_PTR(ptr))
85943 + return "<null>";
85944 +
85945 + if (!virt_addr_valid(ptr))
85946 + return NULL;
85947 +
85948 + page = virt_to_head_page(ptr);
85949 + if (!PageSlab(page))
85950 + return NULL;
85951 +
85952 + if (page->private) {
85953 + base = page;
85954 + if (base <= ptr && n <= page->private - (ptr - base))
85955 + return NULL;
85956 + return "<slob>";
85957 + }
85958 +
85959 + /* some tricky double walking to find the chunk */
85960 + spin_lock_irqsave(&slob_lock, flags);
85961 + base = (void *)((unsigned long)ptr & PAGE_MASK);
85962 + free = page->freelist;
85963 +
85964 + while (!slob_last(free) && (void *)free <= ptr) {
85965 + base = free + slob_units(free);
85966 + free = slob_next(free);
85967 + }
85968 +
85969 + while (base < (void *)free) {
85970 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
85971 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
85972 + int offset;
85973 +
85974 + if (ptr < base + align)
85975 + break;
85976 +
85977 + offset = ptr - base - align;
85978 + if (offset >= m) {
85979 + base += size;
85980 + continue;
85981 + }
85982 +
85983 + if (n > m - offset)
85984 + break;
85985 +
85986 + spin_unlock_irqrestore(&slob_lock, flags);
85987 + return NULL;
85988 + }
85989 +
85990 + spin_unlock_irqrestore(&slob_lock, flags);
85991 + return "<slob>";
85992 +}
85993 +#endif
85994 +
85995 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
85996 size_t ksize(const void *block)
85997 {
85998 struct page *sp;
85999 int align;
86000 - unsigned int *m;
86001 + slob_t *m;
86002
86003 BUG_ON(!block);
86004 if (unlikely(block == ZERO_SIZE_PTR))
86005 return 0;
86006
86007 sp = virt_to_page(block);
86008 - if (unlikely(!PageSlab(sp)))
86009 - return PAGE_SIZE << compound_order(sp);
86010 + VM_BUG_ON(!PageSlab(sp));
86011 + if (sp->private)
86012 + return sp->private;
86013
86014 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
86015 - m = (unsigned int *)(block - align);
86016 - return SLOB_UNITS(*m) * SLOB_UNIT;
86017 + m = (slob_t *)(block - align);
86018 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
86019 }
86020 EXPORT_SYMBOL(ksize);
86021
86022 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
86023
86024 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
86025 {
86026 - void *b;
86027 + void *b = NULL;
86028
86029 flags &= gfp_allowed_mask;
86030
86031 lockdep_trace_alloc(flags);
86032
86033 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86034 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
86035 +#else
86036 if (c->size < PAGE_SIZE) {
86037 b = slob_alloc(c->size, flags, c->align, node);
86038 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
86039 SLOB_UNITS(c->size) * SLOB_UNIT,
86040 flags, node);
86041 } else {
86042 - b = slob_new_pages(flags, get_order(c->size), node);
86043 + struct page *sp;
86044 +
86045 + sp = slob_new_pages(flags, get_order(c->size), node);
86046 + if (sp) {
86047 + b = page_address(sp);
86048 + sp->private = c->size;
86049 + }
86050 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
86051 PAGE_SIZE << get_order(c->size),
86052 flags, node);
86053 }
86054 +#endif
86055
86056 if (c->ctor)
86057 c->ctor(b);
86058 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
86059
86060 static void __kmem_cache_free(void *b, int size)
86061 {
86062 - if (size < PAGE_SIZE)
86063 + struct page *sp;
86064 +
86065 + sp = virt_to_page(b);
86066 + BUG_ON(!PageSlab(sp));
86067 + if (!sp->private)
86068 slob_free(b, size);
86069 else
86070 - slob_free_pages(b, get_order(size));
86071 + slob_free_pages(sp, get_order(size));
86072 }
86073
86074 static void kmem_rcu_free(struct rcu_head *head)
86075 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
86076
86077 void kmem_cache_free(struct kmem_cache *c, void *b)
86078 {
86079 + int size = c->size;
86080 +
86081 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86082 + if (size + c->align < PAGE_SIZE) {
86083 + size += c->align;
86084 + b -= c->align;
86085 + }
86086 +#endif
86087 +
86088 kmemleak_free_recursive(b, c->flags);
86089 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
86090 struct slob_rcu *slob_rcu;
86091 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
86092 - slob_rcu->size = c->size;
86093 + slob_rcu = b + (size - sizeof(struct slob_rcu));
86094 + slob_rcu->size = size;
86095 call_rcu(&slob_rcu->head, kmem_rcu_free);
86096 } else {
86097 - __kmem_cache_free(b, c->size);
86098 + __kmem_cache_free(b, size);
86099 }
86100
86101 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86102 + trace_kfree(_RET_IP_, b);
86103 +#else
86104 trace_kmem_cache_free(_RET_IP_, b);
86105 +#endif
86106 +
86107 }
86108 EXPORT_SYMBOL(kmem_cache_free);
86109
86110 diff --git a/mm/slub.c b/mm/slub.c
86111 index 57707f0..7857bd3 100644
86112 --- a/mm/slub.c
86113 +++ b/mm/slub.c
86114 @@ -198,7 +198,7 @@ struct track {
86115
86116 enum track_item { TRACK_ALLOC, TRACK_FREE };
86117
86118 -#ifdef CONFIG_SYSFS
86119 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86120 static int sysfs_slab_add(struct kmem_cache *);
86121 static int sysfs_slab_alias(struct kmem_cache *, const char *);
86122 static void sysfs_slab_remove(struct kmem_cache *);
86123 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
86124 if (!t->addr)
86125 return;
86126
86127 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
86128 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
86129 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
86130 #ifdef CONFIG_STACKTRACE
86131 {
86132 @@ -2594,6 +2594,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
86133
86134 slab_free_hook(s, x);
86135
86136 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
86137 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
86138 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
86139 + if (s->ctor)
86140 + s->ctor(x);
86141 + }
86142 +#endif
86143 +
86144 redo:
86145 /*
86146 * Determine the currently cpus per cpu slab.
86147 @@ -2661,7 +2669,7 @@ static int slub_min_objects;
86148 * Merge control. If this is set then no merging of slab caches will occur.
86149 * (Could be removed. This was introduced to pacify the merge skeptics.)
86150 */
86151 -static int slub_nomerge;
86152 +static int slub_nomerge = 1;
86153
86154 /*
86155 * Calculate the order of allocation given an slab object size.
86156 @@ -2938,6 +2946,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
86157 s->inuse = size;
86158
86159 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
86160 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
86161 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
86162 +#endif
86163 s->ctor)) {
86164 /*
86165 * Relocate free pointer after the object if it is not
86166 @@ -3283,6 +3294,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
86167 EXPORT_SYMBOL(__kmalloc_node);
86168 #endif
86169
86170 +bool is_usercopy_object(const void *ptr)
86171 +{
86172 + struct page *page;
86173 + struct kmem_cache *s;
86174 +
86175 + if (ZERO_OR_NULL_PTR(ptr))
86176 + return false;
86177 +
86178 + if (!slab_is_available())
86179 + return false;
86180 +
86181 + if (!virt_addr_valid(ptr))
86182 + return false;
86183 +
86184 + page = virt_to_head_page(ptr);
86185 +
86186 + if (!PageSlab(page))
86187 + return false;
86188 +
86189 + s = page->slab_cache;
86190 + return s->flags & SLAB_USERCOPY;
86191 +}
86192 +
86193 +#ifdef CONFIG_PAX_USERCOPY
86194 +const char *check_heap_object(const void *ptr, unsigned long n)
86195 +{
86196 + struct page *page;
86197 + struct kmem_cache *s;
86198 + unsigned long offset;
86199 +
86200 + if (ZERO_OR_NULL_PTR(ptr))
86201 + return "<null>";
86202 +
86203 + if (!virt_addr_valid(ptr))
86204 + return NULL;
86205 +
86206 + page = virt_to_head_page(ptr);
86207 +
86208 + if (!PageSlab(page))
86209 + return NULL;
86210 +
86211 + s = page->slab_cache;
86212 + if (!(s->flags & SLAB_USERCOPY))
86213 + return s->name;
86214 +
86215 + offset = (ptr - page_address(page)) % s->size;
86216 + if (offset <= s->object_size && n <= s->object_size - offset)
86217 + return NULL;
86218 +
86219 + return s->name;
86220 +}
86221 +#endif
86222 +
86223 size_t ksize(const void *object)
86224 {
86225 struct page *page;
86226 @@ -3347,6 +3411,7 @@ void kfree(const void *x)
86227 if (unlikely(ZERO_OR_NULL_PTR(x)))
86228 return;
86229
86230 + VM_BUG_ON(!virt_addr_valid(x));
86231 page = virt_to_head_page(x);
86232 if (unlikely(!PageSlab(page))) {
86233 BUG_ON(!PageCompound(page));
86234 @@ -3652,7 +3717,7 @@ static int slab_unmergeable(struct kmem_cache *s)
86235 /*
86236 * We may have set a slab to be unmergeable during bootstrap.
86237 */
86238 - if (s->refcount < 0)
86239 + if (atomic_read(&s->refcount) < 0)
86240 return 1;
86241
86242 return 0;
86243 @@ -3710,7 +3775,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
86244
86245 s = find_mergeable(memcg, size, align, flags, name, ctor);
86246 if (s) {
86247 - s->refcount++;
86248 + atomic_inc(&s->refcount);
86249 /*
86250 * Adjust the object sizes so that we clear
86251 * the complete object on kzalloc.
86252 @@ -3719,7 +3784,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
86253 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
86254
86255 if (sysfs_slab_alias(s, name)) {
86256 - s->refcount--;
86257 + atomic_dec(&s->refcount);
86258 s = NULL;
86259 }
86260 }
86261 @@ -3781,7 +3846,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
86262 return NOTIFY_OK;
86263 }
86264
86265 -static struct notifier_block __cpuinitdata slab_notifier = {
86266 +static struct notifier_block slab_notifier = {
86267 .notifier_call = slab_cpuup_callback
86268 };
86269
86270 @@ -3839,7 +3904,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
86271 }
86272 #endif
86273
86274 -#ifdef CONFIG_SYSFS
86275 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86276 static int count_inuse(struct page *page)
86277 {
86278 return page->inuse;
86279 @@ -4226,12 +4291,12 @@ static void resiliency_test(void)
86280 validate_slab_cache(kmalloc_caches[9]);
86281 }
86282 #else
86283 -#ifdef CONFIG_SYSFS
86284 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86285 static void resiliency_test(void) {};
86286 #endif
86287 #endif
86288
86289 -#ifdef CONFIG_SYSFS
86290 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86291 enum slab_stat_type {
86292 SL_ALL, /* All slabs */
86293 SL_PARTIAL, /* Only partially allocated slabs */
86294 @@ -4475,7 +4540,7 @@ SLAB_ATTR_RO(ctor);
86295
86296 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
86297 {
86298 - return sprintf(buf, "%d\n", s->refcount - 1);
86299 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
86300 }
86301 SLAB_ATTR_RO(aliases);
86302
86303 @@ -4563,6 +4628,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
86304 SLAB_ATTR_RO(cache_dma);
86305 #endif
86306
86307 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86308 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
86309 +{
86310 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
86311 +}
86312 +SLAB_ATTR_RO(usercopy);
86313 +#endif
86314 +
86315 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
86316 {
86317 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
86318 @@ -4897,6 +4970,9 @@ static struct attribute *slab_attrs[] = {
86319 #ifdef CONFIG_ZONE_DMA
86320 &cache_dma_attr.attr,
86321 #endif
86322 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86323 + &usercopy_attr.attr,
86324 +#endif
86325 #ifdef CONFIG_NUMA
86326 &remote_node_defrag_ratio_attr.attr,
86327 #endif
86328 @@ -5128,6 +5204,7 @@ static char *create_unique_id(struct kmem_cache *s)
86329 return name;
86330 }
86331
86332 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86333 static int sysfs_slab_add(struct kmem_cache *s)
86334 {
86335 int err;
86336 @@ -5151,7 +5228,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
86337 }
86338
86339 s->kobj.kset = slab_kset;
86340 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
86341 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
86342 if (err) {
86343 kobject_put(&s->kobj);
86344 return err;
86345 @@ -5185,6 +5262,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
86346 kobject_del(&s->kobj);
86347 kobject_put(&s->kobj);
86348 }
86349 +#endif
86350
86351 /*
86352 * Need to buffer aliases during bootup until sysfs becomes
86353 @@ -5198,6 +5276,7 @@ struct saved_alias {
86354
86355 static struct saved_alias *alias_list;
86356
86357 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86358 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
86359 {
86360 struct saved_alias *al;
86361 @@ -5220,6 +5299,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
86362 alias_list = al;
86363 return 0;
86364 }
86365 +#endif
86366
86367 static int __init slab_sysfs_init(void)
86368 {
86369 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
86370 index 27eeab3..7c3f7f2 100644
86371 --- a/mm/sparse-vmemmap.c
86372 +++ b/mm/sparse-vmemmap.c
86373 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
86374 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
86375 if (!p)
86376 return NULL;
86377 - pud_populate(&init_mm, pud, p);
86378 + pud_populate_kernel(&init_mm, pud, p);
86379 }
86380 return pud;
86381 }
86382 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
86383 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
86384 if (!p)
86385 return NULL;
86386 - pgd_populate(&init_mm, pgd, p);
86387 + pgd_populate_kernel(&init_mm, pgd, p);
86388 }
86389 return pgd;
86390 }
86391 diff --git a/mm/sparse.c b/mm/sparse.c
86392 index 1c91f0d3..485470a 100644
86393 --- a/mm/sparse.c
86394 +++ b/mm/sparse.c
86395 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
86396
86397 for (i = 0; i < PAGES_PER_SECTION; i++) {
86398 if (PageHWPoison(&memmap[i])) {
86399 - atomic_long_sub(1, &num_poisoned_pages);
86400 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
86401 ClearPageHWPoison(&memmap[i]);
86402 }
86403 }
86404 diff --git a/mm/swap.c b/mm/swap.c
86405 index dfd7d71..ccdf688 100644
86406 --- a/mm/swap.c
86407 +++ b/mm/swap.c
86408 @@ -31,6 +31,7 @@
86409 #include <linux/memcontrol.h>
86410 #include <linux/gfp.h>
86411 #include <linux/uio.h>
86412 +#include <linux/hugetlb.h>
86413
86414 #include "internal.h"
86415
86416 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
86417
86418 __page_cache_release(page);
86419 dtor = get_compound_page_dtor(page);
86420 + if (!PageHuge(page))
86421 + BUG_ON(dtor != free_compound_page);
86422 (*dtor)(page);
86423 }
86424
86425 diff --git a/mm/swapfile.c b/mm/swapfile.c
86426 index 746af55b..7ac94ae 100644
86427 --- a/mm/swapfile.c
86428 +++ b/mm/swapfile.c
86429 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
86430
86431 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
86432 /* Activity counter to indicate that a swapon or swapoff has occurred */
86433 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
86434 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
86435
86436 static inline unsigned char swap_count(unsigned char ent)
86437 {
86438 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
86439 }
86440 filp_close(swap_file, NULL);
86441 err = 0;
86442 - atomic_inc(&proc_poll_event);
86443 + atomic_inc_unchecked(&proc_poll_event);
86444 wake_up_interruptible(&proc_poll_wait);
86445
86446 out_dput:
86447 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
86448
86449 poll_wait(file, &proc_poll_wait, wait);
86450
86451 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
86452 - seq->poll_event = atomic_read(&proc_poll_event);
86453 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
86454 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
86455 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
86456 }
86457
86458 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
86459 return ret;
86460
86461 seq = file->private_data;
86462 - seq->poll_event = atomic_read(&proc_poll_event);
86463 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
86464 return 0;
86465 }
86466
86467 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
86468 (frontswap_map) ? "FS" : "");
86469
86470 mutex_unlock(&swapon_mutex);
86471 - atomic_inc(&proc_poll_event);
86472 + atomic_inc_unchecked(&proc_poll_event);
86473 wake_up_interruptible(&proc_poll_wait);
86474
86475 if (S_ISREG(inode->i_mode))
86476 diff --git a/mm/util.c b/mm/util.c
86477 index ab1424d..7c5bd5a 100644
86478 --- a/mm/util.c
86479 +++ b/mm/util.c
86480 @@ -294,6 +294,12 @@ done:
86481 void arch_pick_mmap_layout(struct mm_struct *mm)
86482 {
86483 mm->mmap_base = TASK_UNMAPPED_BASE;
86484 +
86485 +#ifdef CONFIG_PAX_RANDMMAP
86486 + if (mm->pax_flags & MF_PAX_RANDMMAP)
86487 + mm->mmap_base += mm->delta_mmap;
86488 +#endif
86489 +
86490 mm->get_unmapped_area = arch_get_unmapped_area;
86491 mm->unmap_area = arch_unmap_area;
86492 }
86493 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
86494 index d365724..6cae7c2 100644
86495 --- a/mm/vmalloc.c
86496 +++ b/mm/vmalloc.c
86497 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
86498
86499 pte = pte_offset_kernel(pmd, addr);
86500 do {
86501 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
86502 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
86503 +
86504 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86505 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
86506 + BUG_ON(!pte_exec(*pte));
86507 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
86508 + continue;
86509 + }
86510 +#endif
86511 +
86512 + {
86513 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
86514 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
86515 + }
86516 } while (pte++, addr += PAGE_SIZE, addr != end);
86517 }
86518
86519 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
86520 pte = pte_alloc_kernel(pmd, addr);
86521 if (!pte)
86522 return -ENOMEM;
86523 +
86524 + pax_open_kernel();
86525 do {
86526 struct page *page = pages[*nr];
86527
86528 - if (WARN_ON(!pte_none(*pte)))
86529 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86530 + if (pgprot_val(prot) & _PAGE_NX)
86531 +#endif
86532 +
86533 + if (!pte_none(*pte)) {
86534 + pax_close_kernel();
86535 + WARN_ON(1);
86536 return -EBUSY;
86537 - if (WARN_ON(!page))
86538 + }
86539 + if (!page) {
86540 + pax_close_kernel();
86541 + WARN_ON(1);
86542 return -ENOMEM;
86543 + }
86544 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
86545 (*nr)++;
86546 } while (pte++, addr += PAGE_SIZE, addr != end);
86547 + pax_close_kernel();
86548 return 0;
86549 }
86550
86551 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
86552 pmd_t *pmd;
86553 unsigned long next;
86554
86555 - pmd = pmd_alloc(&init_mm, pud, addr);
86556 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86557 if (!pmd)
86558 return -ENOMEM;
86559 do {
86560 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
86561 pud_t *pud;
86562 unsigned long next;
86563
86564 - pud = pud_alloc(&init_mm, pgd, addr);
86565 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86566 if (!pud)
86567 return -ENOMEM;
86568 do {
86569 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
86570 if (addr >= MODULES_VADDR && addr < MODULES_END)
86571 return 1;
86572 #endif
86573 +
86574 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86575 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
86576 + return 1;
86577 +#endif
86578 +
86579 return is_vmalloc_addr(x);
86580 }
86581
86582 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
86583
86584 if (!pgd_none(*pgd)) {
86585 pud_t *pud = pud_offset(pgd, addr);
86586 +#ifdef CONFIG_X86
86587 + if (!pud_large(*pud))
86588 +#endif
86589 if (!pud_none(*pud)) {
86590 pmd_t *pmd = pmd_offset(pud, addr);
86591 +#ifdef CONFIG_X86
86592 + if (!pmd_large(*pmd))
86593 +#endif
86594 if (!pmd_none(*pmd)) {
86595 pte_t *ptep, pte;
86596
86597 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
86598 * Allocate a region of KVA of the specified size and alignment, within the
86599 * vstart and vend.
86600 */
86601 -static struct vmap_area *alloc_vmap_area(unsigned long size,
86602 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
86603 unsigned long align,
86604 unsigned long vstart, unsigned long vend,
86605 int node, gfp_t gfp_mask)
86606 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
86607 struct vm_struct *area;
86608
86609 BUG_ON(in_interrupt());
86610 +
86611 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
86612 + if (flags & VM_KERNEXEC) {
86613 + if (start != VMALLOC_START || end != VMALLOC_END)
86614 + return NULL;
86615 + start = (unsigned long)MODULES_EXEC_VADDR;
86616 + end = (unsigned long)MODULES_EXEC_END;
86617 + }
86618 +#endif
86619 +
86620 if (flags & VM_IOREMAP) {
86621 int bit = fls(size);
86622
86623 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
86624 if (count > totalram_pages)
86625 return NULL;
86626
86627 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
86628 + if (!(pgprot_val(prot) & _PAGE_NX))
86629 + flags |= VM_KERNEXEC;
86630 +#endif
86631 +
86632 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
86633 __builtin_return_address(0));
86634 if (!area)
86635 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
86636 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
86637 goto fail;
86638
86639 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
86640 + if (!(pgprot_val(prot) & _PAGE_NX))
86641 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
86642 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
86643 + else
86644 +#endif
86645 +
86646 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
86647 start, end, node, gfp_mask, caller);
86648 if (!area)
86649 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
86650 * For tight control over page level allocator and protection flags
86651 * use __vmalloc() instead.
86652 */
86653 -
86654 void *vmalloc_exec(unsigned long size)
86655 {
86656 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
86657 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
86658 NUMA_NO_NODE, __builtin_return_address(0));
86659 }
86660
86661 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
86662 unsigned long uaddr = vma->vm_start;
86663 unsigned long usize = vma->vm_end - vma->vm_start;
86664
86665 + BUG_ON(vma->vm_mirror);
86666 +
86667 if ((PAGE_SIZE-1) & (unsigned long)addr)
86668 return -EINVAL;
86669
86670 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
86671 v->addr, v->addr + v->size, v->size);
86672
86673 if (v->caller)
86674 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86675 + seq_printf(m, " %pK", v->caller);
86676 +#else
86677 seq_printf(m, " %pS", v->caller);
86678 +#endif
86679
86680 if (v->nr_pages)
86681 seq_printf(m, " pages=%d", v->nr_pages);
86682 diff --git a/mm/vmstat.c b/mm/vmstat.c
86683 index f42745e..62f8346 100644
86684 --- a/mm/vmstat.c
86685 +++ b/mm/vmstat.c
86686 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
86687 *
86688 * vm_stat contains the global counters
86689 */
86690 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
86691 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
86692 EXPORT_SYMBOL(vm_stat);
86693
86694 #ifdef CONFIG_SMP
86695 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
86696 v = p->vm_stat_diff[i];
86697 p->vm_stat_diff[i] = 0;
86698 local_irq_restore(flags);
86699 - atomic_long_add(v, &zone->vm_stat[i]);
86700 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
86701 global_diff[i] += v;
86702 #ifdef CONFIG_NUMA
86703 /* 3 seconds idle till flush */
86704 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
86705
86706 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
86707 if (global_diff[i])
86708 - atomic_long_add(global_diff[i], &vm_stat[i]);
86709 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
86710 }
86711
86712 /*
86713 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
86714 if (pset->vm_stat_diff[i]) {
86715 int v = pset->vm_stat_diff[i];
86716 pset->vm_stat_diff[i] = 0;
86717 - atomic_long_add(v, &zone->vm_stat[i]);
86718 - atomic_long_add(v, &vm_stat[i]);
86719 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
86720 + atomic_long_add_unchecked(v, &vm_stat[i]);
86721 }
86722 }
86723 #endif
86724 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
86725 return NOTIFY_OK;
86726 }
86727
86728 -static struct notifier_block __cpuinitdata vmstat_notifier =
86729 +static struct notifier_block vmstat_notifier =
86730 { &vmstat_cpuup_callback, NULL, 0 };
86731 #endif
86732
86733 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
86734 start_cpu_timer(cpu);
86735 #endif
86736 #ifdef CONFIG_PROC_FS
86737 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
86738 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
86739 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
86740 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
86741 + {
86742 + mode_t gr_mode = S_IRUGO;
86743 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86744 + gr_mode = S_IRUSR;
86745 +#endif
86746 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
86747 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
86748 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
86749 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
86750 +#else
86751 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
86752 +#endif
86753 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
86754 + }
86755 #endif
86756 return 0;
86757 }
86758 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
86759 index 9424f37..6aabf19 100644
86760 --- a/net/8021q/vlan.c
86761 +++ b/net/8021q/vlan.c
86762 @@ -469,7 +469,7 @@ out:
86763 return NOTIFY_DONE;
86764 }
86765
86766 -static struct notifier_block vlan_notifier_block __read_mostly = {
86767 +static struct notifier_block vlan_notifier_block = {
86768 .notifier_call = vlan_device_event,
86769 };
86770
86771 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
86772 err = -EPERM;
86773 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
86774 break;
86775 - if ((args.u.name_type >= 0) &&
86776 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
86777 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
86778 struct vlan_net *vn;
86779
86780 vn = net_generic(net, vlan_net_id);
86781 diff --git a/net/9p/mod.c b/net/9p/mod.c
86782 index 6ab36ae..6f1841b 100644
86783 --- a/net/9p/mod.c
86784 +++ b/net/9p/mod.c
86785 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
86786 void v9fs_register_trans(struct p9_trans_module *m)
86787 {
86788 spin_lock(&v9fs_trans_lock);
86789 - list_add_tail(&m->list, &v9fs_trans_list);
86790 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
86791 spin_unlock(&v9fs_trans_lock);
86792 }
86793 EXPORT_SYMBOL(v9fs_register_trans);
86794 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
86795 void v9fs_unregister_trans(struct p9_trans_module *m)
86796 {
86797 spin_lock(&v9fs_trans_lock);
86798 - list_del_init(&m->list);
86799 + pax_list_del_init((struct list_head *)&m->list);
86800 spin_unlock(&v9fs_trans_lock);
86801 }
86802 EXPORT_SYMBOL(v9fs_unregister_trans);
86803 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
86804 index 02efb25..41541a9 100644
86805 --- a/net/9p/trans_fd.c
86806 +++ b/net/9p/trans_fd.c
86807 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
86808 oldfs = get_fs();
86809 set_fs(get_ds());
86810 /* The cast to a user pointer is valid due to the set_fs() */
86811 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
86812 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
86813 set_fs(oldfs);
86814
86815 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
86816 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
86817 index 876fbe8..8bbea9f 100644
86818 --- a/net/atm/atm_misc.c
86819 +++ b/net/atm/atm_misc.c
86820 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
86821 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
86822 return 1;
86823 atm_return(vcc, truesize);
86824 - atomic_inc(&vcc->stats->rx_drop);
86825 + atomic_inc_unchecked(&vcc->stats->rx_drop);
86826 return 0;
86827 }
86828 EXPORT_SYMBOL(atm_charge);
86829 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
86830 }
86831 }
86832 atm_return(vcc, guess);
86833 - atomic_inc(&vcc->stats->rx_drop);
86834 + atomic_inc_unchecked(&vcc->stats->rx_drop);
86835 return NULL;
86836 }
86837 EXPORT_SYMBOL(atm_alloc_charge);
86838 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
86839
86840 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
86841 {
86842 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
86843 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
86844 __SONET_ITEMS
86845 #undef __HANDLE_ITEM
86846 }
86847 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
86848
86849 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
86850 {
86851 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
86852 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
86853 __SONET_ITEMS
86854 #undef __HANDLE_ITEM
86855 }
86856 diff --git a/net/atm/lec.h b/net/atm/lec.h
86857 index 4149db1..f2ab682 100644
86858 --- a/net/atm/lec.h
86859 +++ b/net/atm/lec.h
86860 @@ -48,7 +48,7 @@ struct lane2_ops {
86861 const u8 *tlvs, u32 sizeoftlvs);
86862 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
86863 const u8 *tlvs, u32 sizeoftlvs);
86864 -};
86865 +} __no_const;
86866
86867 /*
86868 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
86869 diff --git a/net/atm/proc.c b/net/atm/proc.c
86870 index bbb6461..cf04016 100644
86871 --- a/net/atm/proc.c
86872 +++ b/net/atm/proc.c
86873 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
86874 const struct k_atm_aal_stats *stats)
86875 {
86876 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
86877 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
86878 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
86879 - atomic_read(&stats->rx_drop));
86880 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
86881 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
86882 + atomic_read_unchecked(&stats->rx_drop));
86883 }
86884
86885 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
86886 diff --git a/net/atm/resources.c b/net/atm/resources.c
86887 index 0447d5d..3cf4728 100644
86888 --- a/net/atm/resources.c
86889 +++ b/net/atm/resources.c
86890 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
86891 static void copy_aal_stats(struct k_atm_aal_stats *from,
86892 struct atm_aal_stats *to)
86893 {
86894 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
86895 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
86896 __AAL_STAT_ITEMS
86897 #undef __HANDLE_ITEM
86898 }
86899 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
86900 static void subtract_aal_stats(struct k_atm_aal_stats *from,
86901 struct atm_aal_stats *to)
86902 {
86903 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
86904 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
86905 __AAL_STAT_ITEMS
86906 #undef __HANDLE_ITEM
86907 }
86908 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
86909 index d5744b7..506bae3 100644
86910 --- a/net/ax25/sysctl_net_ax25.c
86911 +++ b/net/ax25/sysctl_net_ax25.c
86912 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
86913 {
86914 char path[sizeof("net/ax25/") + IFNAMSIZ];
86915 int k;
86916 - struct ctl_table *table;
86917 + ctl_table_no_const *table;
86918
86919 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
86920 if (!table)
86921 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
86922 index f680ee1..97e3542 100644
86923 --- a/net/batman-adv/bat_iv_ogm.c
86924 +++ b/net/batman-adv/bat_iv_ogm.c
86925 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
86926
86927 /* randomize initial seqno to avoid collision */
86928 get_random_bytes(&random_seqno, sizeof(random_seqno));
86929 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86930 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86931
86932 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
86933 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
86934 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
86935 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
86936
86937 /* change sequence number to network order */
86938 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
86939 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
86940 batadv_ogm_packet->seqno = htonl(seqno);
86941 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
86942 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
86943
86944 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
86945 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
86946 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
86947 return;
86948
86949 /* could be changed by schedule_own_packet() */
86950 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
86951 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
86952
86953 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
86954 has_directlink_flag = 1;
86955 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
86956 index 522243a..b48c0ef 100644
86957 --- a/net/batman-adv/hard-interface.c
86958 +++ b/net/batman-adv/hard-interface.c
86959 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
86960 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
86961 dev_add_pack(&hard_iface->batman_adv_ptype);
86962
86963 - atomic_set(&hard_iface->frag_seqno, 1);
86964 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
86965 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
86966 hard_iface->net_dev->name);
86967
86968 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
86969 /* This can't be called via a bat_priv callback because
86970 * we have no bat_priv yet.
86971 */
86972 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
86973 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
86974 hard_iface->bat_iv.ogm_buff = NULL;
86975
86976 return hard_iface;
86977 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
86978 index 819dfb0..9a672d1 100644
86979 --- a/net/batman-adv/soft-interface.c
86980 +++ b/net/batman-adv/soft-interface.c
86981 @@ -253,7 +253,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
86982 primary_if->net_dev->dev_addr, ETH_ALEN);
86983
86984 /* set broadcast sequence number */
86985 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
86986 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
86987 bcast_packet->seqno = htonl(seqno);
86988
86989 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
86990 @@ -472,7 +472,7 @@ static int batadv_softif_init_late(struct net_device *dev)
86991 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
86992
86993 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
86994 - atomic_set(&bat_priv->bcast_seqno, 1);
86995 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
86996 atomic_set(&bat_priv->tt.vn, 0);
86997 atomic_set(&bat_priv->tt.local_changes, 0);
86998 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
86999 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
87000 index aba8364..50fcbb8 100644
87001 --- a/net/batman-adv/types.h
87002 +++ b/net/batman-adv/types.h
87003 @@ -51,7 +51,7 @@
87004 struct batadv_hard_iface_bat_iv {
87005 unsigned char *ogm_buff;
87006 int ogm_buff_len;
87007 - atomic_t ogm_seqno;
87008 + atomic_unchecked_t ogm_seqno;
87009 };
87010
87011 /**
87012 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
87013 int16_t if_num;
87014 char if_status;
87015 struct net_device *net_dev;
87016 - atomic_t frag_seqno;
87017 + atomic_unchecked_t frag_seqno;
87018 struct kobject *hardif_obj;
87019 atomic_t refcount;
87020 struct packet_type batman_adv_ptype;
87021 @@ -558,7 +558,7 @@ struct batadv_priv {
87022 #ifdef CONFIG_BATMAN_ADV_DEBUG
87023 atomic_t log_level;
87024 #endif
87025 - atomic_t bcast_seqno;
87026 + atomic_unchecked_t bcast_seqno;
87027 atomic_t bcast_queue_left;
87028 atomic_t batman_queue_left;
87029 char num_ifaces;
87030 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
87031 index 0bb3b59..ffcbf2f 100644
87032 --- a/net/batman-adv/unicast.c
87033 +++ b/net/batman-adv/unicast.c
87034 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
87035 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
87036 frag2->flags = large_tail;
87037
87038 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
87039 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
87040 frag1->seqno = htons(seqno - 1);
87041 frag2->seqno = htons(seqno);
87042
87043 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
87044 index ace5e55..a65a1c0 100644
87045 --- a/net/bluetooth/hci_core.c
87046 +++ b/net/bluetooth/hci_core.c
87047 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
87048 list_add(&hdev->list, &hci_dev_list);
87049 write_unlock(&hci_dev_list_lock);
87050
87051 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
87052 - WQ_MEM_RECLAIM, 1);
87053 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
87054 + WQ_MEM_RECLAIM, 1, hdev->name);
87055 if (!hdev->workqueue) {
87056 error = -ENOMEM;
87057 goto err;
87058 }
87059
87060 - hdev->req_workqueue = alloc_workqueue(hdev->name,
87061 + hdev->req_workqueue = alloc_workqueue("%s",
87062 WQ_HIGHPRI | WQ_UNBOUND |
87063 - WQ_MEM_RECLAIM, 1);
87064 + WQ_MEM_RECLAIM, 1, hdev->name);
87065 if (!hdev->req_workqueue) {
87066 destroy_workqueue(hdev->workqueue);
87067 error = -ENOMEM;
87068 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
87069 index 9bd7d95..6c4884f 100644
87070 --- a/net/bluetooth/hci_sock.c
87071 +++ b/net/bluetooth/hci_sock.c
87072 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
87073 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
87074 }
87075
87076 - len = min_t(unsigned int, len, sizeof(uf));
87077 + len = min((size_t)len, sizeof(uf));
87078 if (copy_from_user(&uf, optval, len)) {
87079 err = -EFAULT;
87080 break;
87081 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
87082 index 68843a2..30e9342 100644
87083 --- a/net/bluetooth/l2cap_core.c
87084 +++ b/net/bluetooth/l2cap_core.c
87085 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
87086 break;
87087
87088 case L2CAP_CONF_RFC:
87089 - if (olen == sizeof(rfc))
87090 - memcpy(&rfc, (void *)val, olen);
87091 + if (olen != sizeof(rfc))
87092 + break;
87093 +
87094 + memcpy(&rfc, (void *)val, olen);
87095
87096 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
87097 rfc.mode != chan->mode)
87098 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
87099 index 36fed40..be2eeb2 100644
87100 --- a/net/bluetooth/l2cap_sock.c
87101 +++ b/net/bluetooth/l2cap_sock.c
87102 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
87103 struct sock *sk = sock->sk;
87104 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
87105 struct l2cap_options opts;
87106 - int len, err = 0;
87107 + int err = 0;
87108 + size_t len = optlen;
87109 u32 opt;
87110
87111 BT_DBG("sk %p", sk);
87112 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
87113 opts.max_tx = chan->max_tx;
87114 opts.txwin_size = chan->tx_win;
87115
87116 - len = min_t(unsigned int, sizeof(opts), optlen);
87117 + len = min(sizeof(opts), len);
87118 if (copy_from_user((char *) &opts, optval, len)) {
87119 err = -EFAULT;
87120 break;
87121 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
87122 struct bt_security sec;
87123 struct bt_power pwr;
87124 struct l2cap_conn *conn;
87125 - int len, err = 0;
87126 + int err = 0;
87127 + size_t len = optlen;
87128 u32 opt;
87129
87130 BT_DBG("sk %p", sk);
87131 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
87132
87133 sec.level = BT_SECURITY_LOW;
87134
87135 - len = min_t(unsigned int, sizeof(sec), optlen);
87136 + len = min(sizeof(sec), len);
87137 if (copy_from_user((char *) &sec, optval, len)) {
87138 err = -EFAULT;
87139 break;
87140 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
87141
87142 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
87143
87144 - len = min_t(unsigned int, sizeof(pwr), optlen);
87145 + len = min(sizeof(pwr), len);
87146 if (copy_from_user((char *) &pwr, optval, len)) {
87147 err = -EFAULT;
87148 break;
87149 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
87150 index 30b3721..c1bd0a0 100644
87151 --- a/net/bluetooth/rfcomm/sock.c
87152 +++ b/net/bluetooth/rfcomm/sock.c
87153 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
87154 struct sock *sk = sock->sk;
87155 struct bt_security sec;
87156 int err = 0;
87157 - size_t len;
87158 + size_t len = optlen;
87159 u32 opt;
87160
87161 BT_DBG("sk %p", sk);
87162 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
87163
87164 sec.level = BT_SECURITY_LOW;
87165
87166 - len = min_t(unsigned int, sizeof(sec), optlen);
87167 + len = min(sizeof(sec), len);
87168 if (copy_from_user((char *) &sec, optval, len)) {
87169 err = -EFAULT;
87170 break;
87171 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
87172 index b6e44ad..5b0d514 100644
87173 --- a/net/bluetooth/rfcomm/tty.c
87174 +++ b/net/bluetooth/rfcomm/tty.c
87175 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
87176 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
87177
87178 spin_lock_irqsave(&dev->port.lock, flags);
87179 - if (dev->port.count > 0) {
87180 + if (atomic_read(&dev->port.count) > 0) {
87181 spin_unlock_irqrestore(&dev->port.lock, flags);
87182 return;
87183 }
87184 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
87185 return -ENODEV;
87186
87187 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
87188 - dev->channel, dev->port.count);
87189 + dev->channel, atomic_read(&dev->port.count));
87190
87191 spin_lock_irqsave(&dev->port.lock, flags);
87192 - if (++dev->port.count > 1) {
87193 + if (atomic_inc_return(&dev->port.count) > 1) {
87194 spin_unlock_irqrestore(&dev->port.lock, flags);
87195 return 0;
87196 }
87197 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
87198 return;
87199
87200 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
87201 - dev->port.count);
87202 + atomic_read(&dev->port.count));
87203
87204 spin_lock_irqsave(&dev->port.lock, flags);
87205 - if (!--dev->port.count) {
87206 + if (!atomic_dec_return(&dev->port.count)) {
87207 spin_unlock_irqrestore(&dev->port.lock, flags);
87208 if (dev->tty_dev->parent)
87209 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
87210 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
87211 index 3d110c4..4e1b2eb 100644
87212 --- a/net/bridge/netfilter/ebtables.c
87213 +++ b/net/bridge/netfilter/ebtables.c
87214 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87215 tmp.valid_hooks = t->table->valid_hooks;
87216 }
87217 mutex_unlock(&ebt_mutex);
87218 - if (copy_to_user(user, &tmp, *len) != 0){
87219 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
87220 BUGPRINT("c2u Didn't work\n");
87221 ret = -EFAULT;
87222 break;
87223 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
87224 goto out;
87225 tmp.valid_hooks = t->valid_hooks;
87226
87227 - if (copy_to_user(user, &tmp, *len) != 0) {
87228 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
87229 ret = -EFAULT;
87230 break;
87231 }
87232 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
87233 tmp.entries_size = t->table->entries_size;
87234 tmp.valid_hooks = t->table->valid_hooks;
87235
87236 - if (copy_to_user(user, &tmp, *len) != 0) {
87237 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
87238 ret = -EFAULT;
87239 break;
87240 }
87241 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
87242 index 2bd4b58..0dc30a1 100644
87243 --- a/net/caif/cfctrl.c
87244 +++ b/net/caif/cfctrl.c
87245 @@ -10,6 +10,7 @@
87246 #include <linux/spinlock.h>
87247 #include <linux/slab.h>
87248 #include <linux/pkt_sched.h>
87249 +#include <linux/sched.h>
87250 #include <net/caif/caif_layer.h>
87251 #include <net/caif/cfpkt.h>
87252 #include <net/caif/cfctrl.h>
87253 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
87254 memset(&dev_info, 0, sizeof(dev_info));
87255 dev_info.id = 0xff;
87256 cfsrvl_init(&this->serv, 0, &dev_info, false);
87257 - atomic_set(&this->req_seq_no, 1);
87258 - atomic_set(&this->rsp_seq_no, 1);
87259 + atomic_set_unchecked(&this->req_seq_no, 1);
87260 + atomic_set_unchecked(&this->rsp_seq_no, 1);
87261 this->serv.layer.receive = cfctrl_recv;
87262 sprintf(this->serv.layer.name, "ctrl");
87263 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
87264 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
87265 struct cfctrl_request_info *req)
87266 {
87267 spin_lock_bh(&ctrl->info_list_lock);
87268 - atomic_inc(&ctrl->req_seq_no);
87269 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
87270 + atomic_inc_unchecked(&ctrl->req_seq_no);
87271 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
87272 list_add_tail(&req->list, &ctrl->list);
87273 spin_unlock_bh(&ctrl->info_list_lock);
87274 }
87275 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
87276 if (p != first)
87277 pr_warn("Requests are not received in order\n");
87278
87279 - atomic_set(&ctrl->rsp_seq_no,
87280 + atomic_set_unchecked(&ctrl->rsp_seq_no,
87281 p->sequence_no);
87282 list_del(&p->list);
87283 goto out;
87284 diff --git a/net/can/af_can.c b/net/can/af_can.c
87285 index c4e5085..aa9efdf 100644
87286 --- a/net/can/af_can.c
87287 +++ b/net/can/af_can.c
87288 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
87289 };
87290
87291 /* notifier block for netdevice event */
87292 -static struct notifier_block can_netdev_notifier __read_mostly = {
87293 +static struct notifier_block can_netdev_notifier = {
87294 .notifier_call = can_notifier,
87295 };
87296
87297 diff --git a/net/can/gw.c b/net/can/gw.c
87298 index 3ee690e..00d581b 100644
87299 --- a/net/can/gw.c
87300 +++ b/net/can/gw.c
87301 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
87302 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
87303
87304 static HLIST_HEAD(cgw_list);
87305 -static struct notifier_block notifier;
87306
87307 static struct kmem_cache *cgw_cache __read_mostly;
87308
87309 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
87310 return err;
87311 }
87312
87313 +static struct notifier_block notifier = {
87314 + .notifier_call = cgw_notifier
87315 +};
87316 +
87317 static __init int cgw_module_init(void)
87318 {
87319 /* sanitize given module parameter */
87320 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
87321 return -ENOMEM;
87322
87323 /* set notifier */
87324 - notifier.notifier_call = cgw_notifier;
87325 register_netdevice_notifier(&notifier);
87326
87327 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
87328 diff --git a/net/compat.c b/net/compat.c
87329 index f0a1ba6..0541331 100644
87330 --- a/net/compat.c
87331 +++ b/net/compat.c
87332 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
87333 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
87334 __get_user(kmsg->msg_flags, &umsg->msg_flags))
87335 return -EFAULT;
87336 - kmsg->msg_name = compat_ptr(tmp1);
87337 - kmsg->msg_iov = compat_ptr(tmp2);
87338 - kmsg->msg_control = compat_ptr(tmp3);
87339 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
87340 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
87341 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
87342 return 0;
87343 }
87344
87345 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
87346
87347 if (kern_msg->msg_namelen) {
87348 if (mode == VERIFY_READ) {
87349 - int err = move_addr_to_kernel(kern_msg->msg_name,
87350 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
87351 kern_msg->msg_namelen,
87352 kern_address);
87353 if (err < 0)
87354 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
87355 kern_msg->msg_name = NULL;
87356
87357 tot_len = iov_from_user_compat_to_kern(kern_iov,
87358 - (struct compat_iovec __user *)kern_msg->msg_iov,
87359 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
87360 kern_msg->msg_iovlen);
87361 if (tot_len >= 0)
87362 kern_msg->msg_iov = kern_iov;
87363 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
87364
87365 #define CMSG_COMPAT_FIRSTHDR(msg) \
87366 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
87367 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
87368 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
87369 (struct compat_cmsghdr __user *)NULL)
87370
87371 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
87372 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
87373 (ucmlen) <= (unsigned long) \
87374 ((mhdr)->msg_controllen - \
87375 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
87376 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
87377
87378 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
87379 struct compat_cmsghdr __user *cmsg, int cmsg_len)
87380 {
87381 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
87382 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
87383 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
87384 msg->msg_controllen)
87385 return NULL;
87386 return (struct compat_cmsghdr __user *)ptr;
87387 @@ -219,7 +219,7 @@ Efault:
87388
87389 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
87390 {
87391 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
87392 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
87393 struct compat_cmsghdr cmhdr;
87394 struct compat_timeval ctv;
87395 struct compat_timespec cts[3];
87396 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
87397
87398 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
87399 {
87400 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
87401 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
87402 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
87403 int fdnum = scm->fp->count;
87404 struct file **fp = scm->fp->fp;
87405 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
87406 return -EFAULT;
87407 old_fs = get_fs();
87408 set_fs(KERNEL_DS);
87409 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
87410 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
87411 set_fs(old_fs);
87412
87413 return err;
87414 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
87415 len = sizeof(ktime);
87416 old_fs = get_fs();
87417 set_fs(KERNEL_DS);
87418 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
87419 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
87420 set_fs(old_fs);
87421
87422 if (!err) {
87423 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
87424 case MCAST_JOIN_GROUP:
87425 case MCAST_LEAVE_GROUP:
87426 {
87427 - struct compat_group_req __user *gr32 = (void *)optval;
87428 + struct compat_group_req __user *gr32 = (void __user *)optval;
87429 struct group_req __user *kgr =
87430 compat_alloc_user_space(sizeof(struct group_req));
87431 u32 interface;
87432 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
87433 case MCAST_BLOCK_SOURCE:
87434 case MCAST_UNBLOCK_SOURCE:
87435 {
87436 - struct compat_group_source_req __user *gsr32 = (void *)optval;
87437 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
87438 struct group_source_req __user *kgsr = compat_alloc_user_space(
87439 sizeof(struct group_source_req));
87440 u32 interface;
87441 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
87442 }
87443 case MCAST_MSFILTER:
87444 {
87445 - struct compat_group_filter __user *gf32 = (void *)optval;
87446 + struct compat_group_filter __user *gf32 = (void __user *)optval;
87447 struct group_filter __user *kgf;
87448 u32 interface, fmode, numsrc;
87449
87450 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
87451 char __user *optval, int __user *optlen,
87452 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
87453 {
87454 - struct compat_group_filter __user *gf32 = (void *)optval;
87455 + struct compat_group_filter __user *gf32 = (void __user *)optval;
87456 struct group_filter __user *kgf;
87457 int __user *koptlen;
87458 u32 interface, fmode, numsrc;
87459 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
87460
87461 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
87462 return -EINVAL;
87463 - if (copy_from_user(a, args, nas[call]))
87464 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
87465 return -EFAULT;
87466 a0 = a[0];
87467 a1 = a[1];
87468 diff --git a/net/core/datagram.c b/net/core/datagram.c
87469 index b71423d..0360434 100644
87470 --- a/net/core/datagram.c
87471 +++ b/net/core/datagram.c
87472 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
87473 }
87474
87475 kfree_skb(skb);
87476 - atomic_inc(&sk->sk_drops);
87477 + atomic_inc_unchecked(&sk->sk_drops);
87478 sk_mem_reclaim_partial(sk);
87479
87480 return err;
87481 diff --git a/net/core/dev.c b/net/core/dev.c
87482 index 7ddbb31..3902452 100644
87483 --- a/net/core/dev.c
87484 +++ b/net/core/dev.c
87485 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
87486 {
87487 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
87488 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
87489 - atomic_long_inc(&dev->rx_dropped);
87490 + atomic_long_inc_unchecked(&dev->rx_dropped);
87491 kfree_skb(skb);
87492 return NET_RX_DROP;
87493 }
87494 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
87495 skb_orphan(skb);
87496
87497 if (unlikely(!is_skb_forwardable(dev, skb))) {
87498 - atomic_long_inc(&dev->rx_dropped);
87499 + atomic_long_inc_unchecked(&dev->rx_dropped);
87500 kfree_skb(skb);
87501 return NET_RX_DROP;
87502 }
87503 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
87504
87505 struct dev_gso_cb {
87506 void (*destructor)(struct sk_buff *skb);
87507 -};
87508 +} __no_const;
87509
87510 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
87511
87512 @@ -3139,7 +3139,7 @@ enqueue:
87513
87514 local_irq_restore(flags);
87515
87516 - atomic_long_inc(&skb->dev->rx_dropped);
87517 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
87518 kfree_skb(skb);
87519 return NET_RX_DROP;
87520 }
87521 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
87522 }
87523 EXPORT_SYMBOL(netif_rx_ni);
87524
87525 -static void net_tx_action(struct softirq_action *h)
87526 +static void net_tx_action(void)
87527 {
87528 struct softnet_data *sd = &__get_cpu_var(softnet_data);
87529
87530 @@ -3545,7 +3545,7 @@ ncls:
87531 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
87532 } else {
87533 drop:
87534 - atomic_long_inc(&skb->dev->rx_dropped);
87535 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
87536 kfree_skb(skb);
87537 /* Jamal, now you will not able to escape explaining
87538 * me how you were going to use this. :-)
87539 @@ -4153,7 +4153,7 @@ void netif_napi_del(struct napi_struct *napi)
87540 }
87541 EXPORT_SYMBOL(netif_napi_del);
87542
87543 -static void net_rx_action(struct softirq_action *h)
87544 +static void net_rx_action(void)
87545 {
87546 struct softnet_data *sd = &__get_cpu_var(softnet_data);
87547 unsigned long time_limit = jiffies + 2;
87548 @@ -5590,7 +5590,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
87549 } else {
87550 netdev_stats_to_stats64(storage, &dev->stats);
87551 }
87552 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
87553 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
87554 return storage;
87555 }
87556 EXPORT_SYMBOL(dev_get_stats);
87557 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
87558 index 5b7d0e1..cb960fc 100644
87559 --- a/net/core/dev_ioctl.c
87560 +++ b/net/core/dev_ioctl.c
87561 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
87562 if (no_module && capable(CAP_NET_ADMIN))
87563 no_module = request_module("netdev-%s", name);
87564 if (no_module && capable(CAP_SYS_MODULE)) {
87565 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
87566 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
87567 +#else
87568 if (!request_module("%s", name))
87569 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
87570 name);
87571 +#endif
87572 }
87573 }
87574 EXPORT_SYMBOL(dev_load);
87575 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
87576 index ce91766..3b71cdb 100644
87577 --- a/net/core/ethtool.c
87578 +++ b/net/core/ethtool.c
87579 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
87580 if (ret)
87581 return ret;
87582
87583 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
87584 + len = min(tmp.len, dump.len);
87585 if (!len)
87586 return -EFAULT;
87587
87588 + /* Don't ever let the driver think there's more space available
87589 + * than it requested with .get_dump_flag().
87590 + */
87591 + dump.len = len;
87592 +
87593 + /* Always allocate enough space to hold the whole thing so that the
87594 + * driver does not need to check the length and bother with partial
87595 + * dumping.
87596 + */
87597 data = vzalloc(tmp.len);
87598 if (!data)
87599 return -ENOMEM;
87600 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
87601 if (ret)
87602 goto out;
87603
87604 + /* There are two sane possibilities:
87605 + * 1. The driver's .get_dump_data() does not touch dump.len.
87606 + * 2. Or it may set dump.len to how much it really writes, which
87607 + * should be tmp.len (or len if it can do a partial dump).
87608 + * In any case respond to userspace with the actual length of data
87609 + * it's receiving.
87610 + */
87611 + WARN_ON(dump.len != len && dump.len != tmp.len);
87612 + dump.len = len;
87613 +
87614 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
87615 ret = -EFAULT;
87616 goto out;
87617 diff --git a/net/core/flow.c b/net/core/flow.c
87618 index 7102f16..146b4bd 100644
87619 --- a/net/core/flow.c
87620 +++ b/net/core/flow.c
87621 @@ -61,7 +61,7 @@ struct flow_cache {
87622 struct timer_list rnd_timer;
87623 };
87624
87625 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
87626 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
87627 EXPORT_SYMBOL(flow_cache_genid);
87628 static struct flow_cache flow_cache_global;
87629 static struct kmem_cache *flow_cachep __read_mostly;
87630 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
87631
87632 static int flow_entry_valid(struct flow_cache_entry *fle)
87633 {
87634 - if (atomic_read(&flow_cache_genid) != fle->genid)
87635 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
87636 return 0;
87637 if (fle->object && !fle->object->ops->check(fle->object))
87638 return 0;
87639 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
87640 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
87641 fcp->hash_count++;
87642 }
87643 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
87644 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
87645 flo = fle->object;
87646 if (!flo)
87647 goto ret_object;
87648 @@ -279,7 +279,7 @@ nocache:
87649 }
87650 flo = resolver(net, key, family, dir, flo, ctx);
87651 if (fle) {
87652 - fle->genid = atomic_read(&flow_cache_genid);
87653 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
87654 if (!IS_ERR(flo))
87655 fle->object = flo;
87656 else
87657 diff --git a/net/core/iovec.c b/net/core/iovec.c
87658 index de178e4..1dabd8b 100644
87659 --- a/net/core/iovec.c
87660 +++ b/net/core/iovec.c
87661 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
87662 if (m->msg_namelen) {
87663 if (mode == VERIFY_READ) {
87664 void __user *namep;
87665 - namep = (void __user __force *) m->msg_name;
87666 + namep = (void __force_user *) m->msg_name;
87667 err = move_addr_to_kernel(namep, m->msg_namelen,
87668 address);
87669 if (err < 0)
87670 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
87671 }
87672
87673 size = m->msg_iovlen * sizeof(struct iovec);
87674 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
87675 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
87676 return -EFAULT;
87677
87678 m->msg_iov = iov;
87679 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
87680 index ce90b02..8752627 100644
87681 --- a/net/core/neighbour.c
87682 +++ b/net/core/neighbour.c
87683 @@ -2771,7 +2771,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
87684 size_t *lenp, loff_t *ppos)
87685 {
87686 int size, ret;
87687 - ctl_table tmp = *ctl;
87688 + ctl_table_no_const tmp = *ctl;
87689
87690 tmp.extra1 = &zero;
87691 tmp.extra2 = &unres_qlen_max;
87692 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
87693 index 569d355..79cf2d0 100644
87694 --- a/net/core/net-procfs.c
87695 +++ b/net/core/net-procfs.c
87696 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
87697 else
87698 seq_printf(seq, "%04x", ntohs(pt->type));
87699
87700 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87701 + seq_printf(seq, " %-8s %pf\n",
87702 + pt->dev ? pt->dev->name : "", NULL);
87703 +#else
87704 seq_printf(seq, " %-8s %pf\n",
87705 pt->dev ? pt->dev->name : "", pt->func);
87706 +#endif
87707 }
87708
87709 return 0;
87710 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
87711 index 981fed3..536af34 100644
87712 --- a/net/core/net-sysfs.c
87713 +++ b/net/core/net-sysfs.c
87714 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
87715 }
87716 EXPORT_SYMBOL(netdev_class_remove_file);
87717
87718 -int netdev_kobject_init(void)
87719 +int __init netdev_kobject_init(void)
87720 {
87721 kobj_ns_type_register(&net_ns_type_operations);
87722 return class_register(&net_class);
87723 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
87724 index f9765203..9feaef8 100644
87725 --- a/net/core/net_namespace.c
87726 +++ b/net/core/net_namespace.c
87727 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
87728 int error;
87729 LIST_HEAD(net_exit_list);
87730
87731 - list_add_tail(&ops->list, list);
87732 + pax_list_add_tail((struct list_head *)&ops->list, list);
87733 if (ops->init || (ops->id && ops->size)) {
87734 for_each_net(net) {
87735 error = ops_init(ops, net);
87736 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
87737
87738 out_undo:
87739 /* If I have an error cleanup all namespaces I initialized */
87740 - list_del(&ops->list);
87741 + pax_list_del((struct list_head *)&ops->list);
87742 ops_exit_list(ops, &net_exit_list);
87743 ops_free_list(ops, &net_exit_list);
87744 return error;
87745 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
87746 struct net *net;
87747 LIST_HEAD(net_exit_list);
87748
87749 - list_del(&ops->list);
87750 + pax_list_del((struct list_head *)&ops->list);
87751 for_each_net(net)
87752 list_add_tail(&net->exit_list, &net_exit_list);
87753 ops_exit_list(ops, &net_exit_list);
87754 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
87755 mutex_lock(&net_mutex);
87756 error = register_pernet_operations(&pernet_list, ops);
87757 if (!error && (first_device == &pernet_list))
87758 - first_device = &ops->list;
87759 + first_device = (struct list_head *)&ops->list;
87760 mutex_unlock(&net_mutex);
87761 return error;
87762 }
87763 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
87764 index a08bd2b..4e8f43c 100644
87765 --- a/net/core/rtnetlink.c
87766 +++ b/net/core/rtnetlink.c
87767 @@ -58,7 +58,7 @@ struct rtnl_link {
87768 rtnl_doit_func doit;
87769 rtnl_dumpit_func dumpit;
87770 rtnl_calcit_func calcit;
87771 -};
87772 +} __no_const;
87773
87774 static DEFINE_MUTEX(rtnl_mutex);
87775
87776 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
87777 if (rtnl_link_ops_get(ops->kind))
87778 return -EEXIST;
87779
87780 - if (!ops->dellink)
87781 - ops->dellink = unregister_netdevice_queue;
87782 + if (!ops->dellink) {
87783 + pax_open_kernel();
87784 + *(void **)&ops->dellink = unregister_netdevice_queue;
87785 + pax_close_kernel();
87786 + }
87787
87788 - list_add_tail(&ops->list, &link_ops);
87789 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
87790 return 0;
87791 }
87792 EXPORT_SYMBOL_GPL(__rtnl_link_register);
87793 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
87794 for_each_net(net) {
87795 __rtnl_kill_links(net, ops);
87796 }
87797 - list_del(&ops->list);
87798 + pax_list_del((struct list_head *)&ops->list);
87799 }
87800 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
87801
87802 diff --git a/net/core/scm.c b/net/core/scm.c
87803 index 03795d0..eaf7368 100644
87804 --- a/net/core/scm.c
87805 +++ b/net/core/scm.c
87806 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
87807 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
87808 {
87809 struct cmsghdr __user *cm
87810 - = (__force struct cmsghdr __user *)msg->msg_control;
87811 + = (struct cmsghdr __force_user *)msg->msg_control;
87812 struct cmsghdr cmhdr;
87813 int cmlen = CMSG_LEN(len);
87814 int err;
87815 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
87816 err = -EFAULT;
87817 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
87818 goto out;
87819 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
87820 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
87821 goto out;
87822 cmlen = CMSG_SPACE(len);
87823 if (msg->msg_controllen < cmlen)
87824 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
87825 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
87826 {
87827 struct cmsghdr __user *cm
87828 - = (__force struct cmsghdr __user*)msg->msg_control;
87829 + = (struct cmsghdr __force_user *)msg->msg_control;
87830
87831 int fdmax = 0;
87832 int fdnum = scm->fp->count;
87833 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
87834 if (fdnum < fdmax)
87835 fdmax = fdnum;
87836
87837 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
87838 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
87839 i++, cmfptr++)
87840 {
87841 struct socket *sock;
87842 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
87843 index 1c1738c..4cab7f0 100644
87844 --- a/net/core/skbuff.c
87845 +++ b/net/core/skbuff.c
87846 @@ -3087,13 +3087,15 @@ void __init skb_init(void)
87847 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
87848 sizeof(struct sk_buff),
87849 0,
87850 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
87851 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
87852 + SLAB_NO_SANITIZE,
87853 NULL);
87854 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
87855 (2*sizeof(struct sk_buff)) +
87856 sizeof(atomic_t),
87857 0,
87858 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
87859 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
87860 + SLAB_NO_SANITIZE,
87861 NULL);
87862 }
87863
87864 diff --git a/net/core/sock.c b/net/core/sock.c
87865 index d6d024c..6ea7ab4 100644
87866 --- a/net/core/sock.c
87867 +++ b/net/core/sock.c
87868 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87869 struct sk_buff_head *list = &sk->sk_receive_queue;
87870
87871 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
87872 - atomic_inc(&sk->sk_drops);
87873 + atomic_inc_unchecked(&sk->sk_drops);
87874 trace_sock_rcvqueue_full(sk, skb);
87875 return -ENOMEM;
87876 }
87877 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87878 return err;
87879
87880 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
87881 - atomic_inc(&sk->sk_drops);
87882 + atomic_inc_unchecked(&sk->sk_drops);
87883 return -ENOBUFS;
87884 }
87885
87886 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87887 skb_dst_force(skb);
87888
87889 spin_lock_irqsave(&list->lock, flags);
87890 - skb->dropcount = atomic_read(&sk->sk_drops);
87891 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
87892 __skb_queue_tail(list, skb);
87893 spin_unlock_irqrestore(&list->lock, flags);
87894
87895 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
87896 skb->dev = NULL;
87897
87898 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
87899 - atomic_inc(&sk->sk_drops);
87900 + atomic_inc_unchecked(&sk->sk_drops);
87901 goto discard_and_relse;
87902 }
87903 if (nested)
87904 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
87905 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
87906 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
87907 bh_unlock_sock(sk);
87908 - atomic_inc(&sk->sk_drops);
87909 + atomic_inc_unchecked(&sk->sk_drops);
87910 goto discard_and_relse;
87911 }
87912
87913 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87914 struct timeval tm;
87915 } v;
87916
87917 - int lv = sizeof(int);
87918 - int len;
87919 + unsigned int lv = sizeof(int);
87920 + unsigned int len;
87921
87922 if (get_user(len, optlen))
87923 return -EFAULT;
87924 - if (len < 0)
87925 + if (len > INT_MAX)
87926 return -EINVAL;
87927
87928 memset(&v, 0, sizeof(v));
87929 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87930
87931 case SO_PEERNAME:
87932 {
87933 - char address[128];
87934 + char address[_K_SS_MAXSIZE];
87935
87936 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
87937 return -ENOTCONN;
87938 - if (lv < len)
87939 + if (lv < len || sizeof address < len)
87940 return -EINVAL;
87941 if (copy_to_user(optval, address, len))
87942 return -EFAULT;
87943 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87944
87945 if (len > lv)
87946 len = lv;
87947 - if (copy_to_user(optval, &v, len))
87948 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
87949 return -EFAULT;
87950 lenout:
87951 if (put_user(len, optlen))
87952 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
87953 */
87954 smp_wmb();
87955 atomic_set(&sk->sk_refcnt, 1);
87956 - atomic_set(&sk->sk_drops, 0);
87957 + atomic_set_unchecked(&sk->sk_drops, 0);
87958 }
87959 EXPORT_SYMBOL(sock_init_data);
87960
87961 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
87962 index a0e9cf6..ef7f9ed 100644
87963 --- a/net/core/sock_diag.c
87964 +++ b/net/core/sock_diag.c
87965 @@ -9,26 +9,33 @@
87966 #include <linux/inet_diag.h>
87967 #include <linux/sock_diag.h>
87968
87969 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
87970 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
87971 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
87972 static DEFINE_MUTEX(sock_diag_table_mutex);
87973
87974 int sock_diag_check_cookie(void *sk, __u32 *cookie)
87975 {
87976 +#ifndef CONFIG_GRKERNSEC_HIDESYM
87977 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
87978 cookie[1] != INET_DIAG_NOCOOKIE) &&
87979 ((u32)(unsigned long)sk != cookie[0] ||
87980 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
87981 return -ESTALE;
87982 else
87983 +#endif
87984 return 0;
87985 }
87986 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
87987
87988 void sock_diag_save_cookie(void *sk, __u32 *cookie)
87989 {
87990 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87991 + cookie[0] = 0;
87992 + cookie[1] = 0;
87993 +#else
87994 cookie[0] = (u32)(unsigned long)sk;
87995 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
87996 +#endif
87997 }
87998 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
87999
88000 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
88001 mutex_lock(&sock_diag_table_mutex);
88002 if (sock_diag_handlers[hndl->family])
88003 err = -EBUSY;
88004 - else
88005 + else {
88006 + pax_open_kernel();
88007 sock_diag_handlers[hndl->family] = hndl;
88008 + pax_close_kernel();
88009 + }
88010 mutex_unlock(&sock_diag_table_mutex);
88011
88012 return err;
88013 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
88014
88015 mutex_lock(&sock_diag_table_mutex);
88016 BUG_ON(sock_diag_handlers[family] != hnld);
88017 + pax_open_kernel();
88018 sock_diag_handlers[family] = NULL;
88019 + pax_close_kernel();
88020 mutex_unlock(&sock_diag_table_mutex);
88021 }
88022 EXPORT_SYMBOL_GPL(sock_diag_unregister);
88023 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
88024 index cfdb46a..cef55e1 100644
88025 --- a/net/core/sysctl_net_core.c
88026 +++ b/net/core/sysctl_net_core.c
88027 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
88028 {
88029 unsigned int orig_size, size;
88030 int ret, i;
88031 - ctl_table tmp = {
88032 + ctl_table_no_const tmp = {
88033 .data = &size,
88034 .maxlen = sizeof(size),
88035 .mode = table->mode
88036 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
88037
88038 static __net_init int sysctl_core_net_init(struct net *net)
88039 {
88040 - struct ctl_table *tbl;
88041 + ctl_table_no_const *tbl = NULL;
88042
88043 net->core.sysctl_somaxconn = SOMAXCONN;
88044
88045 - tbl = netns_core_table;
88046 if (!net_eq(net, &init_net)) {
88047 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
88048 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
88049 if (tbl == NULL)
88050 goto err_dup;
88051
88052 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
88053 if (net->user_ns != &init_user_ns) {
88054 tbl[0].procname = NULL;
88055 }
88056 - }
88057 -
88058 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
88059 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
88060 + } else
88061 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
88062 if (net->core.sysctl_hdr == NULL)
88063 goto err_reg;
88064
88065 return 0;
88066
88067 err_reg:
88068 - if (tbl != netns_core_table)
88069 - kfree(tbl);
88070 + kfree(tbl);
88071 err_dup:
88072 return -ENOMEM;
88073 }
88074 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
88075 kfree(tbl);
88076 }
88077
88078 -static __net_initdata struct pernet_operations sysctl_core_ops = {
88079 +static __net_initconst struct pernet_operations sysctl_core_ops = {
88080 .init = sysctl_core_net_init,
88081 .exit = sysctl_core_net_exit,
88082 };
88083 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
88084 index c21f200..bc4565b 100644
88085 --- a/net/decnet/af_decnet.c
88086 +++ b/net/decnet/af_decnet.c
88087 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
88088 .sysctl_rmem = sysctl_decnet_rmem,
88089 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
88090 .obj_size = sizeof(struct dn_sock),
88091 + .slab_flags = SLAB_USERCOPY,
88092 };
88093
88094 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
88095 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
88096 index a55eecc..dd8428c 100644
88097 --- a/net/decnet/sysctl_net_decnet.c
88098 +++ b/net/decnet/sysctl_net_decnet.c
88099 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
88100
88101 if (len > *lenp) len = *lenp;
88102
88103 - if (copy_to_user(buffer, addr, len))
88104 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
88105 return -EFAULT;
88106
88107 *lenp = len;
88108 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
88109
88110 if (len > *lenp) len = *lenp;
88111
88112 - if (copy_to_user(buffer, devname, len))
88113 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
88114 return -EFAULT;
88115
88116 *lenp = len;
88117 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
88118 index d01be2a..8976537 100644
88119 --- a/net/ipv4/af_inet.c
88120 +++ b/net/ipv4/af_inet.c
88121 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
88122
88123 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
88124
88125 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
88126 - if (!sysctl_local_reserved_ports)
88127 - goto out;
88128 -
88129 rc = proto_register(&tcp_prot, 1);
88130 if (rc)
88131 - goto out_free_reserved_ports;
88132 + goto out;
88133
88134 rc = proto_register(&udp_prot, 1);
88135 if (rc)
88136 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
88137 proto_unregister(&udp_prot);
88138 out_unregister_tcp_proto:
88139 proto_unregister(&tcp_prot);
88140 -out_free_reserved_ports:
88141 - kfree(sysctl_local_reserved_ports);
88142 goto out;
88143 }
88144
88145 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
88146 index 2e7f194..0fa4d6d 100644
88147 --- a/net/ipv4/ah4.c
88148 +++ b/net/ipv4/ah4.c
88149 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
88150 return;
88151
88152 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
88153 - atomic_inc(&flow_cache_genid);
88154 + atomic_inc_unchecked(&flow_cache_genid);
88155 rt_genid_bump(net);
88156
88157 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
88158 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
88159 index dfc39d4..0d4fa52 100644
88160 --- a/net/ipv4/devinet.c
88161 +++ b/net/ipv4/devinet.c
88162 @@ -771,7 +771,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
88163 ci = nla_data(tb[IFA_CACHEINFO]);
88164 if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) {
88165 err = -EINVAL;
88166 - goto errout;
88167 + goto errout_free;
88168 }
88169 *pvalid_lft = ci->ifa_valid;
88170 *pprefered_lft = ci->ifa_prefered;
88171 @@ -779,6 +779,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
88172
88173 return ifa;
88174
88175 +errout_free:
88176 + inet_free_ifa(ifa);
88177 errout:
88178 return ERR_PTR(err);
88179 }
88180 @@ -1529,7 +1531,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
88181 idx = 0;
88182 head = &net->dev_index_head[h];
88183 rcu_read_lock();
88184 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
88185 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
88186 net->dev_base_seq;
88187 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88188 if (idx < s_idx)
88189 @@ -1840,7 +1842,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
88190 idx = 0;
88191 head = &net->dev_index_head[h];
88192 rcu_read_lock();
88193 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
88194 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
88195 net->dev_base_seq;
88196 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88197 if (idx < s_idx)
88198 @@ -2065,7 +2067,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
88199 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
88200 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
88201
88202 -static struct devinet_sysctl_table {
88203 +static const struct devinet_sysctl_table {
88204 struct ctl_table_header *sysctl_header;
88205 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
88206 } devinet_sysctl = {
88207 @@ -2183,7 +2185,7 @@ static __net_init int devinet_init_net(struct net *net)
88208 int err;
88209 struct ipv4_devconf *all, *dflt;
88210 #ifdef CONFIG_SYSCTL
88211 - struct ctl_table *tbl = ctl_forward_entry;
88212 + ctl_table_no_const *tbl = NULL;
88213 struct ctl_table_header *forw_hdr;
88214 #endif
88215
88216 @@ -2201,7 +2203,7 @@ static __net_init int devinet_init_net(struct net *net)
88217 goto err_alloc_dflt;
88218
88219 #ifdef CONFIG_SYSCTL
88220 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
88221 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
88222 if (tbl == NULL)
88223 goto err_alloc_ctl;
88224
88225 @@ -2221,7 +2223,10 @@ static __net_init int devinet_init_net(struct net *net)
88226 goto err_reg_dflt;
88227
88228 err = -ENOMEM;
88229 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
88230 + if (!net_eq(net, &init_net))
88231 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
88232 + else
88233 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
88234 if (forw_hdr == NULL)
88235 goto err_reg_ctl;
88236 net->ipv4.forw_hdr = forw_hdr;
88237 @@ -2237,8 +2242,7 @@ err_reg_ctl:
88238 err_reg_dflt:
88239 __devinet_sysctl_unregister(all);
88240 err_reg_all:
88241 - if (tbl != ctl_forward_entry)
88242 - kfree(tbl);
88243 + kfree(tbl);
88244 err_alloc_ctl:
88245 #endif
88246 if (dflt != &ipv4_devconf_dflt)
88247 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
88248 index 4cfe34d..a6ba66e 100644
88249 --- a/net/ipv4/esp4.c
88250 +++ b/net/ipv4/esp4.c
88251 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
88252 return;
88253
88254 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
88255 - atomic_inc(&flow_cache_genid);
88256 + atomic_inc_unchecked(&flow_cache_genid);
88257 rt_genid_bump(net);
88258
88259 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
88260 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
88261 index c7629a2..b62d139 100644
88262 --- a/net/ipv4/fib_frontend.c
88263 +++ b/net/ipv4/fib_frontend.c
88264 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
88265 #ifdef CONFIG_IP_ROUTE_MULTIPATH
88266 fib_sync_up(dev);
88267 #endif
88268 - atomic_inc(&net->ipv4.dev_addr_genid);
88269 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
88270 rt_cache_flush(dev_net(dev));
88271 break;
88272 case NETDEV_DOWN:
88273 fib_del_ifaddr(ifa, NULL);
88274 - atomic_inc(&net->ipv4.dev_addr_genid);
88275 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
88276 if (ifa->ifa_dev->ifa_list == NULL) {
88277 /* Last address was deleted from this interface.
88278 * Disable IP.
88279 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
88280 #ifdef CONFIG_IP_ROUTE_MULTIPATH
88281 fib_sync_up(dev);
88282 #endif
88283 - atomic_inc(&net->ipv4.dev_addr_genid);
88284 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
88285 rt_cache_flush(net);
88286 break;
88287 case NETDEV_DOWN:
88288 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
88289 index 8f6cb7a..34507f9 100644
88290 --- a/net/ipv4/fib_semantics.c
88291 +++ b/net/ipv4/fib_semantics.c
88292 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
88293 nh->nh_saddr = inet_select_addr(nh->nh_dev,
88294 nh->nh_gw,
88295 nh->nh_parent->fib_scope);
88296 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
88297 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
88298
88299 return nh->nh_saddr;
88300 }
88301 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
88302 index 6acb541..9ea617d 100644
88303 --- a/net/ipv4/inet_connection_sock.c
88304 +++ b/net/ipv4/inet_connection_sock.c
88305 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
88306 .range = { 32768, 61000 },
88307 };
88308
88309 -unsigned long *sysctl_local_reserved_ports;
88310 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
88311 EXPORT_SYMBOL(sysctl_local_reserved_ports);
88312
88313 void inet_get_local_port_range(int *low, int *high)
88314 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
88315 index 6af375a..c493c74 100644
88316 --- a/net/ipv4/inet_hashtables.c
88317 +++ b/net/ipv4/inet_hashtables.c
88318 @@ -18,12 +18,15 @@
88319 #include <linux/sched.h>
88320 #include <linux/slab.h>
88321 #include <linux/wait.h>
88322 +#include <linux/security.h>
88323
88324 #include <net/inet_connection_sock.h>
88325 #include <net/inet_hashtables.h>
88326 #include <net/secure_seq.h>
88327 #include <net/ip.h>
88328
88329 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
88330 +
88331 /*
88332 * Allocate and initialize a new local port bind bucket.
88333 * The bindhash mutex for snum's hash chain must be held here.
88334 @@ -554,6 +557,8 @@ ok:
88335 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
88336 spin_unlock(&head->lock);
88337
88338 + gr_update_task_in_ip_table(current, inet_sk(sk));
88339 +
88340 if (tw) {
88341 inet_twsk_deschedule(tw, death_row);
88342 while (twrefcnt) {
88343 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
88344 index 000e3d2..5472da3 100644
88345 --- a/net/ipv4/inetpeer.c
88346 +++ b/net/ipv4/inetpeer.c
88347 @@ -503,8 +503,8 @@ relookup:
88348 if (p) {
88349 p->daddr = *daddr;
88350 atomic_set(&p->refcnt, 1);
88351 - atomic_set(&p->rid, 0);
88352 - atomic_set(&p->ip_id_count,
88353 + atomic_set_unchecked(&p->rid, 0);
88354 + atomic_set_unchecked(&p->ip_id_count,
88355 (daddr->family == AF_INET) ?
88356 secure_ip_id(daddr->addr.a4) :
88357 secure_ipv6_id(daddr->addr.a6));
88358 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
88359 index b66910a..cfe416e 100644
88360 --- a/net/ipv4/ip_fragment.c
88361 +++ b/net/ipv4/ip_fragment.c
88362 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
88363 return 0;
88364
88365 start = qp->rid;
88366 - end = atomic_inc_return(&peer->rid);
88367 + end = atomic_inc_return_unchecked(&peer->rid);
88368 qp->rid = end;
88369
88370 rc = qp->q.fragments && (end - start) > max;
88371 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
88372
88373 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
88374 {
88375 - struct ctl_table *table;
88376 + ctl_table_no_const *table = NULL;
88377 struct ctl_table_header *hdr;
88378
88379 - table = ip4_frags_ns_ctl_table;
88380 if (!net_eq(net, &init_net)) {
88381 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
88382 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
88383 if (table == NULL)
88384 goto err_alloc;
88385
88386 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
88387 /* Don't export sysctls to unprivileged users */
88388 if (net->user_ns != &init_user_ns)
88389 table[0].procname = NULL;
88390 - }
88391 + hdr = register_net_sysctl(net, "net/ipv4", table);
88392 + } else
88393 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
88394
88395 - hdr = register_net_sysctl(net, "net/ipv4", table);
88396 if (hdr == NULL)
88397 goto err_reg;
88398
88399 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
88400 return 0;
88401
88402 err_reg:
88403 - if (!net_eq(net, &init_net))
88404 - kfree(table);
88405 + kfree(table);
88406 err_alloc:
88407 return -ENOMEM;
88408 }
88409 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
88410 index 855004f..68e7458 100644
88411 --- a/net/ipv4/ip_gre.c
88412 +++ b/net/ipv4/ip_gre.c
88413 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
88414 module_param(log_ecn_error, bool, 0644);
88415 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88416
88417 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
88418 +static struct rtnl_link_ops ipgre_link_ops;
88419 static int ipgre_tunnel_init(struct net_device *dev);
88420
88421 static int ipgre_net_id __read_mostly;
88422 @@ -919,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
88423 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
88424 };
88425
88426 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
88427 +static struct rtnl_link_ops ipgre_link_ops = {
88428 .kind = "gre",
88429 .maxtype = IFLA_GRE_MAX,
88430 .policy = ipgre_policy,
88431 @@ -933,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
88432 .fill_info = ipgre_fill_info,
88433 };
88434
88435 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
88436 +static struct rtnl_link_ops ipgre_tap_ops = {
88437 .kind = "gretap",
88438 .maxtype = IFLA_GRE_MAX,
88439 .policy = ipgre_policy,
88440 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
88441 index d9c4f11..02b82dbc 100644
88442 --- a/net/ipv4/ip_sockglue.c
88443 +++ b/net/ipv4/ip_sockglue.c
88444 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
88445 len = min_t(unsigned int, len, opt->optlen);
88446 if (put_user(len, optlen))
88447 return -EFAULT;
88448 - if (copy_to_user(optval, opt->__data, len))
88449 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
88450 + copy_to_user(optval, opt->__data, len))
88451 return -EFAULT;
88452 return 0;
88453 }
88454 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
88455 if (sk->sk_type != SOCK_STREAM)
88456 return -ENOPROTOOPT;
88457
88458 - msg.msg_control = optval;
88459 + msg.msg_control = (void __force_kernel *)optval;
88460 msg.msg_controllen = len;
88461 msg.msg_flags = flags;
88462
88463 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
88464 index 17cc0ff..63856c4 100644
88465 --- a/net/ipv4/ip_vti.c
88466 +++ b/net/ipv4/ip_vti.c
88467 @@ -47,7 +47,7 @@
88468 #define HASH_SIZE 16
88469 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
88470
88471 -static struct rtnl_link_ops vti_link_ops __read_mostly;
88472 +static struct rtnl_link_ops vti_link_ops;
88473
88474 static int vti_net_id __read_mostly;
88475 struct vti_net {
88476 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
88477 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
88478 };
88479
88480 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
88481 +static struct rtnl_link_ops vti_link_ops = {
88482 .kind = "vti",
88483 .maxtype = IFLA_VTI_MAX,
88484 .policy = vti_policy,
88485 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
88486 index 59cb8c7..a72160c 100644
88487 --- a/net/ipv4/ipcomp.c
88488 +++ b/net/ipv4/ipcomp.c
88489 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
88490 return;
88491
88492 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
88493 - atomic_inc(&flow_cache_genid);
88494 + atomic_inc_unchecked(&flow_cache_genid);
88495 rt_genid_bump(net);
88496
88497 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
88498 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
88499 index efa1138..20dbba0 100644
88500 --- a/net/ipv4/ipconfig.c
88501 +++ b/net/ipv4/ipconfig.c
88502 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
88503
88504 mm_segment_t oldfs = get_fs();
88505 set_fs(get_ds());
88506 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
88507 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
88508 set_fs(oldfs);
88509 return res;
88510 }
88511 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
88512
88513 mm_segment_t oldfs = get_fs();
88514 set_fs(get_ds());
88515 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
88516 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
88517 set_fs(oldfs);
88518 return res;
88519 }
88520 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
88521
88522 mm_segment_t oldfs = get_fs();
88523 set_fs(get_ds());
88524 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
88525 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
88526 set_fs(oldfs);
88527 return res;
88528 }
88529 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
88530 index 7cfc456..e726868 100644
88531 --- a/net/ipv4/ipip.c
88532 +++ b/net/ipv4/ipip.c
88533 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88534 static int ipip_net_id __read_mostly;
88535
88536 static int ipip_tunnel_init(struct net_device *dev);
88537 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
88538 +static struct rtnl_link_ops ipip_link_ops;
88539
88540 static int ipip_err(struct sk_buff *skb, u32 info)
88541 {
88542 @@ -406,7 +406,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
88543 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
88544 };
88545
88546 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
88547 +static struct rtnl_link_ops ipip_link_ops = {
88548 .kind = "ipip",
88549 .maxtype = IFLA_IPTUN_MAX,
88550 .policy = ipip_policy,
88551 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
88552 index 85a4f21..1beb1f5 100644
88553 --- a/net/ipv4/netfilter/arp_tables.c
88554 +++ b/net/ipv4/netfilter/arp_tables.c
88555 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
88556 #endif
88557
88558 static int get_info(struct net *net, void __user *user,
88559 - const int *len, int compat)
88560 + int len, int compat)
88561 {
88562 char name[XT_TABLE_MAXNAMELEN];
88563 struct xt_table *t;
88564 int ret;
88565
88566 - if (*len != sizeof(struct arpt_getinfo)) {
88567 - duprintf("length %u != %Zu\n", *len,
88568 + if (len != sizeof(struct arpt_getinfo)) {
88569 + duprintf("length %u != %Zu\n", len,
88570 sizeof(struct arpt_getinfo));
88571 return -EINVAL;
88572 }
88573 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
88574 info.size = private->size;
88575 strcpy(info.name, name);
88576
88577 - if (copy_to_user(user, &info, *len) != 0)
88578 + if (copy_to_user(user, &info, len) != 0)
88579 ret = -EFAULT;
88580 else
88581 ret = 0;
88582 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
88583
88584 switch (cmd) {
88585 case ARPT_SO_GET_INFO:
88586 - ret = get_info(sock_net(sk), user, len, 1);
88587 + ret = get_info(sock_net(sk), user, *len, 1);
88588 break;
88589 case ARPT_SO_GET_ENTRIES:
88590 ret = compat_get_entries(sock_net(sk), user, len);
88591 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
88592
88593 switch (cmd) {
88594 case ARPT_SO_GET_INFO:
88595 - ret = get_info(sock_net(sk), user, len, 0);
88596 + ret = get_info(sock_net(sk), user, *len, 0);
88597 break;
88598
88599 case ARPT_SO_GET_ENTRIES:
88600 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
88601 index d23118d..6ad7277 100644
88602 --- a/net/ipv4/netfilter/ip_tables.c
88603 +++ b/net/ipv4/netfilter/ip_tables.c
88604 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
88605 #endif
88606
88607 static int get_info(struct net *net, void __user *user,
88608 - const int *len, int compat)
88609 + int len, int compat)
88610 {
88611 char name[XT_TABLE_MAXNAMELEN];
88612 struct xt_table *t;
88613 int ret;
88614
88615 - if (*len != sizeof(struct ipt_getinfo)) {
88616 - duprintf("length %u != %zu\n", *len,
88617 + if (len != sizeof(struct ipt_getinfo)) {
88618 + duprintf("length %u != %zu\n", len,
88619 sizeof(struct ipt_getinfo));
88620 return -EINVAL;
88621 }
88622 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
88623 info.size = private->size;
88624 strcpy(info.name, name);
88625
88626 - if (copy_to_user(user, &info, *len) != 0)
88627 + if (copy_to_user(user, &info, len) != 0)
88628 ret = -EFAULT;
88629 else
88630 ret = 0;
88631 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88632
88633 switch (cmd) {
88634 case IPT_SO_GET_INFO:
88635 - ret = get_info(sock_net(sk), user, len, 1);
88636 + ret = get_info(sock_net(sk), user, *len, 1);
88637 break;
88638 case IPT_SO_GET_ENTRIES:
88639 ret = compat_get_entries(sock_net(sk), user, len);
88640 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88641
88642 switch (cmd) {
88643 case IPT_SO_GET_INFO:
88644 - ret = get_info(sock_net(sk), user, len, 0);
88645 + ret = get_info(sock_net(sk), user, *len, 0);
88646 break;
88647
88648 case IPT_SO_GET_ENTRIES:
88649 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
88650 index 7d93d62..cbbf2a3 100644
88651 --- a/net/ipv4/ping.c
88652 +++ b/net/ipv4/ping.c
88653 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
88654 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
88655 0, sock_i_ino(sp),
88656 atomic_read(&sp->sk_refcnt), sp,
88657 - atomic_read(&sp->sk_drops), len);
88658 + atomic_read_unchecked(&sp->sk_drops), len);
88659 }
88660
88661 static int ping_seq_show(struct seq_file *seq, void *v)
88662 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
88663 index dd44e0a..06dcca4 100644
88664 --- a/net/ipv4/raw.c
88665 +++ b/net/ipv4/raw.c
88666 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
88667 int raw_rcv(struct sock *sk, struct sk_buff *skb)
88668 {
88669 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
88670 - atomic_inc(&sk->sk_drops);
88671 + atomic_inc_unchecked(&sk->sk_drops);
88672 kfree_skb(skb);
88673 return NET_RX_DROP;
88674 }
88675 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
88676
88677 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
88678 {
88679 + struct icmp_filter filter;
88680 +
88681 if (optlen > sizeof(struct icmp_filter))
88682 optlen = sizeof(struct icmp_filter);
88683 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
88684 + if (copy_from_user(&filter, optval, optlen))
88685 return -EFAULT;
88686 + raw_sk(sk)->filter = filter;
88687 return 0;
88688 }
88689
88690 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
88691 {
88692 int len, ret = -EFAULT;
88693 + struct icmp_filter filter;
88694
88695 if (get_user(len, optlen))
88696 goto out;
88697 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
88698 if (len > sizeof(struct icmp_filter))
88699 len = sizeof(struct icmp_filter);
88700 ret = -EFAULT;
88701 - if (put_user(len, optlen) ||
88702 - copy_to_user(optval, &raw_sk(sk)->filter, len))
88703 + filter = raw_sk(sk)->filter;
88704 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
88705 goto out;
88706 ret = 0;
88707 out: return ret;
88708 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88709 0, 0L, 0,
88710 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88711 0, sock_i_ino(sp),
88712 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88713 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88714 }
88715
88716 static int raw_seq_show(struct seq_file *seq, void *v)
88717 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
88718 index d35bbf0..faa3ab8 100644
88719 --- a/net/ipv4/route.c
88720 +++ b/net/ipv4/route.c
88721 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
88722 .maxlen = sizeof(int),
88723 .mode = 0200,
88724 .proc_handler = ipv4_sysctl_rtcache_flush,
88725 + .extra1 = &init_net,
88726 },
88727 { },
88728 };
88729
88730 static __net_init int sysctl_route_net_init(struct net *net)
88731 {
88732 - struct ctl_table *tbl;
88733 + ctl_table_no_const *tbl = NULL;
88734
88735 - tbl = ipv4_route_flush_table;
88736 if (!net_eq(net, &init_net)) {
88737 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
88738 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
88739 if (tbl == NULL)
88740 goto err_dup;
88741
88742 /* Don't export sysctls to unprivileged users */
88743 if (net->user_ns != &init_user_ns)
88744 tbl[0].procname = NULL;
88745 - }
88746 - tbl[0].extra1 = net;
88747 + tbl[0].extra1 = net;
88748 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
88749 + } else
88750 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
88751
88752 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
88753 if (net->ipv4.route_hdr == NULL)
88754 goto err_reg;
88755 return 0;
88756
88757 err_reg:
88758 - if (tbl != ipv4_route_flush_table)
88759 - kfree(tbl);
88760 + kfree(tbl);
88761 err_dup:
88762 return -ENOMEM;
88763 }
88764 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
88765
88766 static __net_init int rt_genid_init(struct net *net)
88767 {
88768 - atomic_set(&net->rt_genid, 0);
88769 + atomic_set_unchecked(&net->rt_genid, 0);
88770 get_random_bytes(&net->ipv4.dev_addr_genid,
88771 sizeof(net->ipv4.dev_addr_genid));
88772 return 0;
88773 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
88774 index fa2f63f..6554815 100644
88775 --- a/net/ipv4/sysctl_net_ipv4.c
88776 +++ b/net/ipv4/sysctl_net_ipv4.c
88777 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
88778 {
88779 int ret;
88780 int range[2];
88781 - ctl_table tmp = {
88782 + ctl_table_no_const tmp = {
88783 .data = &range,
88784 .maxlen = sizeof(range),
88785 .mode = table->mode,
88786 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
88787 int ret;
88788 gid_t urange[2];
88789 kgid_t low, high;
88790 - ctl_table tmp = {
88791 + ctl_table_no_const tmp = {
88792 .data = &urange,
88793 .maxlen = sizeof(urange),
88794 .mode = table->mode,
88795 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
88796 void __user *buffer, size_t *lenp, loff_t *ppos)
88797 {
88798 char val[TCP_CA_NAME_MAX];
88799 - ctl_table tbl = {
88800 + ctl_table_no_const tbl = {
88801 .data = val,
88802 .maxlen = TCP_CA_NAME_MAX,
88803 };
88804 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
88805 void __user *buffer, size_t *lenp,
88806 loff_t *ppos)
88807 {
88808 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
88809 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
88810 int ret;
88811
88812 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
88813 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
88814 void __user *buffer, size_t *lenp,
88815 loff_t *ppos)
88816 {
88817 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
88818 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
88819 int ret;
88820
88821 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
88822 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
88823 struct mem_cgroup *memcg;
88824 #endif
88825
88826 - ctl_table tmp = {
88827 + ctl_table_no_const tmp = {
88828 .data = &vec,
88829 .maxlen = sizeof(vec),
88830 .mode = ctl->mode,
88831 };
88832
88833 if (!write) {
88834 - ctl->data = &net->ipv4.sysctl_tcp_mem;
88835 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
88836 + ctl_table_no_const tcp_mem = *ctl;
88837 +
88838 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
88839 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
88840 }
88841
88842 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
88843 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
88844 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
88845 size_t *lenp, loff_t *ppos)
88846 {
88847 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
88848 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
88849 struct tcp_fastopen_context *ctxt;
88850 int ret;
88851 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
88852 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
88853 },
88854 {
88855 .procname = "ip_local_reserved_ports",
88856 - .data = NULL, /* initialized in sysctl_ipv4_init */
88857 + .data = sysctl_local_reserved_ports,
88858 .maxlen = 65536,
88859 .mode = 0644,
88860 .proc_handler = proc_do_large_bitmap,
88861 @@ -842,11 +844,10 @@ static struct ctl_table ipv4_net_table[] = {
88862
88863 static __net_init int ipv4_sysctl_init_net(struct net *net)
88864 {
88865 - struct ctl_table *table;
88866 + ctl_table_no_const *table = NULL;
88867
88868 - table = ipv4_net_table;
88869 if (!net_eq(net, &init_net)) {
88870 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
88871 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
88872 if (table == NULL)
88873 goto err_alloc;
88874
88875 @@ -881,15 +882,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
88876
88877 tcp_init_mem(net);
88878
88879 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
88880 + if (!net_eq(net, &init_net))
88881 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
88882 + else
88883 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
88884 if (net->ipv4.ipv4_hdr == NULL)
88885 goto err_reg;
88886
88887 return 0;
88888
88889 err_reg:
88890 - if (!net_eq(net, &init_net))
88891 - kfree(table);
88892 + kfree(table);
88893 err_alloc:
88894 return -ENOMEM;
88895 }
88896 @@ -911,16 +914,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
88897 static __init int sysctl_ipv4_init(void)
88898 {
88899 struct ctl_table_header *hdr;
88900 - struct ctl_table *i;
88901 -
88902 - for (i = ipv4_table; i->procname; i++) {
88903 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
88904 - i->data = sysctl_local_reserved_ports;
88905 - break;
88906 - }
88907 - }
88908 - if (!i->procname)
88909 - return -EINVAL;
88910
88911 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
88912 if (hdr == NULL)
88913 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
88914 index 9c62257..651cc27 100644
88915 --- a/net/ipv4/tcp_input.c
88916 +++ b/net/ipv4/tcp_input.c
88917 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
88918 * simplifies code)
88919 */
88920 static void
88921 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88922 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88923 struct sk_buff *head, struct sk_buff *tail,
88924 u32 start, u32 end)
88925 {
88926 @@ -5522,6 +5522,7 @@ discard:
88927 tcp_paws_reject(&tp->rx_opt, 0))
88928 goto discard_and_undo;
88929
88930 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
88931 if (th->syn) {
88932 /* We see SYN without ACK. It is attempt of
88933 * simultaneous connect with crossed SYNs.
88934 @@ -5572,6 +5573,7 @@ discard:
88935 goto discard;
88936 #endif
88937 }
88938 +#endif
88939 /* "fifth, if neither of the SYN or RST bits is set then
88940 * drop the segment and return."
88941 */
88942 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
88943 goto discard;
88944
88945 if (th->syn) {
88946 - if (th->fin)
88947 + if (th->fin || th->urg || th->psh)
88948 goto discard;
88949 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
88950 return 1;
88951 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
88952 index 7999fc5..c812f42 100644
88953 --- a/net/ipv4/tcp_ipv4.c
88954 +++ b/net/ipv4/tcp_ipv4.c
88955 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
88956 EXPORT_SYMBOL(sysctl_tcp_low_latency);
88957
88958
88959 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88960 +extern int grsec_enable_blackhole;
88961 +#endif
88962 +
88963 #ifdef CONFIG_TCP_MD5SIG
88964 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
88965 __be32 daddr, __be32 saddr, const struct tcphdr *th);
88966 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
88967 return 0;
88968
88969 reset:
88970 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88971 + if (!grsec_enable_blackhole)
88972 +#endif
88973 tcp_v4_send_reset(rsk, skb);
88974 discard:
88975 kfree_skb(skb);
88976 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
88977 TCP_SKB_CB(skb)->sacked = 0;
88978
88979 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88980 - if (!sk)
88981 + if (!sk) {
88982 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88983 + ret = 1;
88984 +#endif
88985 goto no_tcp_socket;
88986 -
88987 + }
88988 process:
88989 - if (sk->sk_state == TCP_TIME_WAIT)
88990 + if (sk->sk_state == TCP_TIME_WAIT) {
88991 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88992 + ret = 2;
88993 +#endif
88994 goto do_time_wait;
88995 + }
88996
88997 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
88998 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88999 @@ -2058,6 +2072,10 @@ csum_error:
89000 bad_packet:
89001 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
89002 } else {
89003 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89004 + if (!grsec_enable_blackhole || (ret == 1 &&
89005 + (skb->dev->flags & IFF_LOOPBACK)))
89006 +#endif
89007 tcp_v4_send_reset(NULL, skb);
89008 }
89009
89010 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
89011 index 0f01788..d52a859 100644
89012 --- a/net/ipv4/tcp_minisocks.c
89013 +++ b/net/ipv4/tcp_minisocks.c
89014 @@ -27,6 +27,10 @@
89015 #include <net/inet_common.h>
89016 #include <net/xfrm.h>
89017
89018 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89019 +extern int grsec_enable_blackhole;
89020 +#endif
89021 +
89022 int sysctl_tcp_syncookies __read_mostly = 1;
89023 EXPORT_SYMBOL(sysctl_tcp_syncookies);
89024
89025 @@ -717,7 +721,10 @@ embryonic_reset:
89026 * avoid becoming vulnerable to outside attack aiming at
89027 * resetting legit local connections.
89028 */
89029 - req->rsk_ops->send_reset(sk, skb);
89030 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89031 + if (!grsec_enable_blackhole)
89032 +#endif
89033 + req->rsk_ops->send_reset(sk, skb);
89034 } else if (fastopen) { /* received a valid RST pkt */
89035 reqsk_fastopen_remove(sk, req, true);
89036 tcp_reset(sk);
89037 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
89038 index d4943f6..e7a74a5 100644
89039 --- a/net/ipv4/tcp_probe.c
89040 +++ b/net/ipv4/tcp_probe.c
89041 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
89042 if (cnt + width >= len)
89043 break;
89044
89045 - if (copy_to_user(buf + cnt, tbuf, width))
89046 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
89047 return -EFAULT;
89048 cnt += width;
89049 }
89050 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
89051 index 4b85e6f..22f9ac9 100644
89052 --- a/net/ipv4/tcp_timer.c
89053 +++ b/net/ipv4/tcp_timer.c
89054 @@ -22,6 +22,10 @@
89055 #include <linux/gfp.h>
89056 #include <net/tcp.h>
89057
89058 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89059 +extern int grsec_lastack_retries;
89060 +#endif
89061 +
89062 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
89063 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
89064 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
89065 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
89066 }
89067 }
89068
89069 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89070 + if ((sk->sk_state == TCP_LAST_ACK) &&
89071 + (grsec_lastack_retries > 0) &&
89072 + (grsec_lastack_retries < retry_until))
89073 + retry_until = grsec_lastack_retries;
89074 +#endif
89075 +
89076 if (retransmits_timed_out(sk, retry_until,
89077 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
89078 /* Has it gone just too far? */
89079 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
89080 index 93b731d..5a2dd92 100644
89081 --- a/net/ipv4/udp.c
89082 +++ b/net/ipv4/udp.c
89083 @@ -87,6 +87,7 @@
89084 #include <linux/types.h>
89085 #include <linux/fcntl.h>
89086 #include <linux/module.h>
89087 +#include <linux/security.h>
89088 #include <linux/socket.h>
89089 #include <linux/sockios.h>
89090 #include <linux/igmp.h>
89091 @@ -111,6 +112,10 @@
89092 #include <trace/events/skb.h>
89093 #include "udp_impl.h"
89094
89095 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89096 +extern int grsec_enable_blackhole;
89097 +#endif
89098 +
89099 struct udp_table udp_table __read_mostly;
89100 EXPORT_SYMBOL(udp_table);
89101
89102 @@ -594,6 +599,9 @@ found:
89103 return s;
89104 }
89105
89106 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
89107 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
89108 +
89109 /*
89110 * This routine is called by the ICMP module when it gets some
89111 * sort of error condition. If err < 0 then the socket should
89112 @@ -890,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
89113 dport = usin->sin_port;
89114 if (dport == 0)
89115 return -EINVAL;
89116 +
89117 + err = gr_search_udp_sendmsg(sk, usin);
89118 + if (err)
89119 + return err;
89120 } else {
89121 if (sk->sk_state != TCP_ESTABLISHED)
89122 return -EDESTADDRREQ;
89123 +
89124 + err = gr_search_udp_sendmsg(sk, NULL);
89125 + if (err)
89126 + return err;
89127 +
89128 daddr = inet->inet_daddr;
89129 dport = inet->inet_dport;
89130 /* Open fast path for connected socket.
89131 @@ -1136,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
89132 IS_UDPLITE(sk));
89133 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
89134 IS_UDPLITE(sk));
89135 - atomic_inc(&sk->sk_drops);
89136 + atomic_inc_unchecked(&sk->sk_drops);
89137 __skb_unlink(skb, rcvq);
89138 __skb_queue_tail(&list_kill, skb);
89139 }
89140 @@ -1222,6 +1239,10 @@ try_again:
89141 if (!skb)
89142 goto out;
89143
89144 + err = gr_search_udp_recvmsg(sk, skb);
89145 + if (err)
89146 + goto out_free;
89147 +
89148 ulen = skb->len - sizeof(struct udphdr);
89149 copied = len;
89150 if (copied > ulen)
89151 @@ -1255,7 +1276,7 @@ try_again:
89152 if (unlikely(err)) {
89153 trace_kfree_skb(skb, udp_recvmsg);
89154 if (!peeked) {
89155 - atomic_inc(&sk->sk_drops);
89156 + atomic_inc_unchecked(&sk->sk_drops);
89157 UDP_INC_STATS_USER(sock_net(sk),
89158 UDP_MIB_INERRORS, is_udplite);
89159 }
89160 @@ -1542,7 +1563,7 @@ csum_error:
89161 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
89162 drop:
89163 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
89164 - atomic_inc(&sk->sk_drops);
89165 + atomic_inc_unchecked(&sk->sk_drops);
89166 kfree_skb(skb);
89167 return -1;
89168 }
89169 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
89170 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
89171
89172 if (!skb1) {
89173 - atomic_inc(&sk->sk_drops);
89174 + atomic_inc_unchecked(&sk->sk_drops);
89175 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
89176 IS_UDPLITE(sk));
89177 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
89178 @@ -1730,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
89179 goto csum_error;
89180
89181 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
89182 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89183 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
89184 +#endif
89185 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
89186
89187 /*
89188 @@ -2160,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
89189 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
89190 0, sock_i_ino(sp),
89191 atomic_read(&sp->sk_refcnt), sp,
89192 - atomic_read(&sp->sk_drops), len);
89193 + atomic_read_unchecked(&sp->sk_drops), len);
89194 }
89195
89196 int udp4_seq_show(struct seq_file *seq, void *v)
89197 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
89198 index 9a459be..086b866 100644
89199 --- a/net/ipv4/xfrm4_policy.c
89200 +++ b/net/ipv4/xfrm4_policy.c
89201 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
89202
89203 static int __net_init xfrm4_net_init(struct net *net)
89204 {
89205 - struct ctl_table *table;
89206 + ctl_table_no_const *table = NULL;
89207 struct ctl_table_header *hdr;
89208
89209 - table = xfrm4_policy_table;
89210 if (!net_eq(net, &init_net)) {
89211 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
89212 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
89213 if (!table)
89214 goto err_alloc;
89215
89216 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
89217 - }
89218 -
89219 - hdr = register_net_sysctl(net, "net/ipv4", table);
89220 + hdr = register_net_sysctl(net, "net/ipv4", table);
89221 + } else
89222 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
89223 if (!hdr)
89224 goto err_reg;
89225
89226 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
89227 return 0;
89228
89229 err_reg:
89230 - if (!net_eq(net, &init_net))
89231 - kfree(table);
89232 + kfree(table);
89233 err_alloc:
89234 return -ENOMEM;
89235 }
89236 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
89237 index fb8c94c..fb18024 100644
89238 --- a/net/ipv6/addrconf.c
89239 +++ b/net/ipv6/addrconf.c
89240 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
89241 idx = 0;
89242 head = &net->dev_index_head[h];
89243 rcu_read_lock();
89244 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
89245 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
89246 net->dev_base_seq;
89247 hlist_for_each_entry_rcu(dev, head, index_hlist) {
89248 if (idx < s_idx)
89249 @@ -2380,7 +2380,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
89250 p.iph.ihl = 5;
89251 p.iph.protocol = IPPROTO_IPV6;
89252 p.iph.ttl = 64;
89253 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
89254 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
89255
89256 if (ops->ndo_do_ioctl) {
89257 mm_segment_t oldfs = get_fs();
89258 @@ -4002,7 +4002,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
89259 s_ip_idx = ip_idx = cb->args[2];
89260
89261 rcu_read_lock();
89262 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
89263 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
89264 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
89265 idx = 0;
89266 head = &net->dev_index_head[h];
89267 @@ -4587,7 +4587,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
89268 dst_free(&ifp->rt->dst);
89269 break;
89270 }
89271 - atomic_inc(&net->ipv6.dev_addr_genid);
89272 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
89273 }
89274
89275 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
89276 @@ -4607,7 +4607,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
89277 int *valp = ctl->data;
89278 int val = *valp;
89279 loff_t pos = *ppos;
89280 - ctl_table lctl;
89281 + ctl_table_no_const lctl;
89282 int ret;
89283
89284 /*
89285 @@ -4689,7 +4689,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
89286 int *valp = ctl->data;
89287 int val = *valp;
89288 loff_t pos = *ppos;
89289 - ctl_table lctl;
89290 + ctl_table_no_const lctl;
89291 int ret;
89292
89293 /*
89294 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
89295 index b4ff0a4..db9b764 100644
89296 --- a/net/ipv6/icmp.c
89297 +++ b/net/ipv6/icmp.c
89298 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
89299
89300 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
89301 {
89302 - struct ctl_table *table;
89303 + ctl_table_no_const *table;
89304
89305 table = kmemdup(ipv6_icmp_table_template,
89306 sizeof(ipv6_icmp_table_template),
89307 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
89308 index ecd6073..58162ae 100644
89309 --- a/net/ipv6/ip6_gre.c
89310 +++ b/net/ipv6/ip6_gre.c
89311 @@ -74,7 +74,7 @@ struct ip6gre_net {
89312 struct net_device *fb_tunnel_dev;
89313 };
89314
89315 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
89316 +static struct rtnl_link_ops ip6gre_link_ops;
89317 static int ip6gre_tunnel_init(struct net_device *dev);
89318 static void ip6gre_tunnel_setup(struct net_device *dev);
89319 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
89320 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
89321 }
89322
89323
89324 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
89325 +static struct inet6_protocol ip6gre_protocol = {
89326 .handler = ip6gre_rcv,
89327 .err_handler = ip6gre_err,
89328 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
89329 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
89330 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
89331 };
89332
89333 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
89334 +static struct rtnl_link_ops ip6gre_link_ops = {
89335 .kind = "ip6gre",
89336 .maxtype = IFLA_GRE_MAX,
89337 .policy = ip6gre_policy,
89338 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
89339 .fill_info = ip6gre_fill_info,
89340 };
89341
89342 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
89343 +static struct rtnl_link_ops ip6gre_tap_ops = {
89344 .kind = "ip6gretap",
89345 .maxtype = IFLA_GRE_MAX,
89346 .policy = ip6gre_policy,
89347 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
89348 index 1e55866..b398dab 100644
89349 --- a/net/ipv6/ip6_tunnel.c
89350 +++ b/net/ipv6/ip6_tunnel.c
89351 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
89352
89353 static int ip6_tnl_dev_init(struct net_device *dev);
89354 static void ip6_tnl_dev_setup(struct net_device *dev);
89355 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
89356 +static struct rtnl_link_ops ip6_link_ops;
89357
89358 static int ip6_tnl_net_id __read_mostly;
89359 struct ip6_tnl_net {
89360 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
89361 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
89362 };
89363
89364 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
89365 +static struct rtnl_link_ops ip6_link_ops = {
89366 .kind = "ip6tnl",
89367 .maxtype = IFLA_IPTUN_MAX,
89368 .policy = ip6_tnl_policy,
89369 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
89370 index d1e2e8e..51c19ae 100644
89371 --- a/net/ipv6/ipv6_sockglue.c
89372 +++ b/net/ipv6/ipv6_sockglue.c
89373 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
89374 if (sk->sk_type != SOCK_STREAM)
89375 return -ENOPROTOOPT;
89376
89377 - msg.msg_control = optval;
89378 + msg.msg_control = (void __force_kernel *)optval;
89379 msg.msg_controllen = len;
89380 msg.msg_flags = flags;
89381
89382 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
89383 index 44400c2..8e11f52 100644
89384 --- a/net/ipv6/netfilter/ip6_tables.c
89385 +++ b/net/ipv6/netfilter/ip6_tables.c
89386 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
89387 #endif
89388
89389 static int get_info(struct net *net, void __user *user,
89390 - const int *len, int compat)
89391 + int len, int compat)
89392 {
89393 char name[XT_TABLE_MAXNAMELEN];
89394 struct xt_table *t;
89395 int ret;
89396
89397 - if (*len != sizeof(struct ip6t_getinfo)) {
89398 - duprintf("length %u != %zu\n", *len,
89399 + if (len != sizeof(struct ip6t_getinfo)) {
89400 + duprintf("length %u != %zu\n", len,
89401 sizeof(struct ip6t_getinfo));
89402 return -EINVAL;
89403 }
89404 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
89405 info.size = private->size;
89406 strcpy(info.name, name);
89407
89408 - if (copy_to_user(user, &info, *len) != 0)
89409 + if (copy_to_user(user, &info, len) != 0)
89410 ret = -EFAULT;
89411 else
89412 ret = 0;
89413 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
89414
89415 switch (cmd) {
89416 case IP6T_SO_GET_INFO:
89417 - ret = get_info(sock_net(sk), user, len, 1);
89418 + ret = get_info(sock_net(sk), user, *len, 1);
89419 break;
89420 case IP6T_SO_GET_ENTRIES:
89421 ret = compat_get_entries(sock_net(sk), user, len);
89422 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
89423
89424 switch (cmd) {
89425 case IP6T_SO_GET_INFO:
89426 - ret = get_info(sock_net(sk), user, len, 0);
89427 + ret = get_info(sock_net(sk), user, *len, 0);
89428 break;
89429
89430 case IP6T_SO_GET_ENTRIES:
89431 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
89432 index dffdc1a..ccc6678 100644
89433 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
89434 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
89435 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
89436
89437 static int nf_ct_frag6_sysctl_register(struct net *net)
89438 {
89439 - struct ctl_table *table;
89440 + ctl_table_no_const *table = NULL;
89441 struct ctl_table_header *hdr;
89442
89443 - table = nf_ct_frag6_sysctl_table;
89444 if (!net_eq(net, &init_net)) {
89445 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
89446 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
89447 GFP_KERNEL);
89448 if (table == NULL)
89449 goto err_alloc;
89450 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
89451 table[0].data = &net->nf_frag.frags.timeout;
89452 table[1].data = &net->nf_frag.frags.low_thresh;
89453 table[2].data = &net->nf_frag.frags.high_thresh;
89454 - }
89455 -
89456 - hdr = register_net_sysctl(net, "net/netfilter", table);
89457 + hdr = register_net_sysctl(net, "net/netfilter", table);
89458 + } else
89459 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
89460 if (hdr == NULL)
89461 goto err_reg;
89462
89463 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
89464 return 0;
89465
89466 err_reg:
89467 - if (!net_eq(net, &init_net))
89468 - kfree(table);
89469 + kfree(table);
89470 err_alloc:
89471 return -ENOMEM;
89472 }
89473 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
89474 index eedff8c..6e13a47 100644
89475 --- a/net/ipv6/raw.c
89476 +++ b/net/ipv6/raw.c
89477 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
89478 {
89479 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
89480 skb_checksum_complete(skb)) {
89481 - atomic_inc(&sk->sk_drops);
89482 + atomic_inc_unchecked(&sk->sk_drops);
89483 kfree_skb(skb);
89484 return NET_RX_DROP;
89485 }
89486 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
89487 struct raw6_sock *rp = raw6_sk(sk);
89488
89489 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
89490 - atomic_inc(&sk->sk_drops);
89491 + atomic_inc_unchecked(&sk->sk_drops);
89492 kfree_skb(skb);
89493 return NET_RX_DROP;
89494 }
89495 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
89496
89497 if (inet->hdrincl) {
89498 if (skb_checksum_complete(skb)) {
89499 - atomic_inc(&sk->sk_drops);
89500 + atomic_inc_unchecked(&sk->sk_drops);
89501 kfree_skb(skb);
89502 return NET_RX_DROP;
89503 }
89504 @@ -602,7 +602,7 @@ out:
89505 return err;
89506 }
89507
89508 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
89509 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
89510 struct flowi6 *fl6, struct dst_entry **dstp,
89511 unsigned int flags)
89512 {
89513 @@ -914,12 +914,15 @@ do_confirm:
89514 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
89515 char __user *optval, int optlen)
89516 {
89517 + struct icmp6_filter filter;
89518 +
89519 switch (optname) {
89520 case ICMPV6_FILTER:
89521 if (optlen > sizeof(struct icmp6_filter))
89522 optlen = sizeof(struct icmp6_filter);
89523 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
89524 + if (copy_from_user(&filter, optval, optlen))
89525 return -EFAULT;
89526 + raw6_sk(sk)->filter = filter;
89527 return 0;
89528 default:
89529 return -ENOPROTOOPT;
89530 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
89531 char __user *optval, int __user *optlen)
89532 {
89533 int len;
89534 + struct icmp6_filter filter;
89535
89536 switch (optname) {
89537 case ICMPV6_FILTER:
89538 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
89539 len = sizeof(struct icmp6_filter);
89540 if (put_user(len, optlen))
89541 return -EFAULT;
89542 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
89543 + filter = raw6_sk(sk)->filter;
89544 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
89545 return -EFAULT;
89546 return 0;
89547 default:
89548 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
89549 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
89550 0,
89551 sock_i_ino(sp),
89552 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
89553 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
89554 }
89555
89556 static int raw6_seq_show(struct seq_file *seq, void *v)
89557 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
89558 index 790d9f4..68ae078 100644
89559 --- a/net/ipv6/reassembly.c
89560 +++ b/net/ipv6/reassembly.c
89561 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
89562
89563 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
89564 {
89565 - struct ctl_table *table;
89566 + ctl_table_no_const *table = NULL;
89567 struct ctl_table_header *hdr;
89568
89569 - table = ip6_frags_ns_ctl_table;
89570 if (!net_eq(net, &init_net)) {
89571 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
89572 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
89573 if (table == NULL)
89574 goto err_alloc;
89575
89576 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
89577 /* Don't export sysctls to unprivileged users */
89578 if (net->user_ns != &init_user_ns)
89579 table[0].procname = NULL;
89580 - }
89581 + hdr = register_net_sysctl(net, "net/ipv6", table);
89582 + } else
89583 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
89584
89585 - hdr = register_net_sysctl(net, "net/ipv6", table);
89586 if (hdr == NULL)
89587 goto err_reg;
89588
89589 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
89590 return 0;
89591
89592 err_reg:
89593 - if (!net_eq(net, &init_net))
89594 - kfree(table);
89595 + kfree(table);
89596 err_alloc:
89597 return -ENOMEM;
89598 }
89599 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
89600 index bacce6c..9d1741a 100644
89601 --- a/net/ipv6/route.c
89602 +++ b/net/ipv6/route.c
89603 @@ -2903,7 +2903,7 @@ ctl_table ipv6_route_table_template[] = {
89604
89605 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
89606 {
89607 - struct ctl_table *table;
89608 + ctl_table_no_const *table;
89609
89610 table = kmemdup(ipv6_route_table_template,
89611 sizeof(ipv6_route_table_template),
89612 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
89613 index 60df36d..f3ab7c8 100644
89614 --- a/net/ipv6/sit.c
89615 +++ b/net/ipv6/sit.c
89616 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
89617 static void ipip6_dev_free(struct net_device *dev);
89618 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
89619 __be32 *v4dst);
89620 -static struct rtnl_link_ops sit_link_ops __read_mostly;
89621 +static struct rtnl_link_ops sit_link_ops;
89622
89623 static int sit_net_id __read_mostly;
89624 struct sit_net {
89625 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
89626 #endif
89627 };
89628
89629 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
89630 +static struct rtnl_link_ops sit_link_ops = {
89631 .kind = "sit",
89632 .maxtype = IFLA_IPTUN_MAX,
89633 .policy = ipip6_policy,
89634 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
89635 index e85c48b..b8268d3 100644
89636 --- a/net/ipv6/sysctl_net_ipv6.c
89637 +++ b/net/ipv6/sysctl_net_ipv6.c
89638 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
89639
89640 static int __net_init ipv6_sysctl_net_init(struct net *net)
89641 {
89642 - struct ctl_table *ipv6_table;
89643 + ctl_table_no_const *ipv6_table;
89644 struct ctl_table *ipv6_route_table;
89645 struct ctl_table *ipv6_icmp_table;
89646 int err;
89647 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
89648 index 0a17ed9..2526cc3 100644
89649 --- a/net/ipv6/tcp_ipv6.c
89650 +++ b/net/ipv6/tcp_ipv6.c
89651 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
89652 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
89653 }
89654
89655 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89656 +extern int grsec_enable_blackhole;
89657 +#endif
89658 +
89659 static void tcp_v6_hash(struct sock *sk)
89660 {
89661 if (sk->sk_state != TCP_CLOSE) {
89662 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
89663 return 0;
89664
89665 reset:
89666 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89667 + if (!grsec_enable_blackhole)
89668 +#endif
89669 tcp_v6_send_reset(sk, skb);
89670 discard:
89671 if (opt_skb)
89672 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
89673 TCP_SKB_CB(skb)->sacked = 0;
89674
89675 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
89676 - if (!sk)
89677 + if (!sk) {
89678 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89679 + ret = 1;
89680 +#endif
89681 goto no_tcp_socket;
89682 + }
89683
89684 process:
89685 - if (sk->sk_state == TCP_TIME_WAIT)
89686 + if (sk->sk_state == TCP_TIME_WAIT) {
89687 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89688 + ret = 2;
89689 +#endif
89690 goto do_time_wait;
89691 + }
89692
89693 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
89694 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
89695 @@ -1536,6 +1551,10 @@ csum_error:
89696 bad_packet:
89697 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
89698 } else {
89699 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89700 + if (!grsec_enable_blackhole || (ret == 1 &&
89701 + (skb->dev->flags & IFF_LOOPBACK)))
89702 +#endif
89703 tcp_v6_send_reset(NULL, skb);
89704 }
89705
89706 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
89707 index e7b28f9..d09c290 100644
89708 --- a/net/ipv6/udp.c
89709 +++ b/net/ipv6/udp.c
89710 @@ -52,6 +52,10 @@
89711 #include <trace/events/skb.h>
89712 #include "udp_impl.h"
89713
89714 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89715 +extern int grsec_enable_blackhole;
89716 +#endif
89717 +
89718 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
89719 {
89720 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
89721 @@ -419,7 +423,7 @@ try_again:
89722 if (unlikely(err)) {
89723 trace_kfree_skb(skb, udpv6_recvmsg);
89724 if (!peeked) {
89725 - atomic_inc(&sk->sk_drops);
89726 + atomic_inc_unchecked(&sk->sk_drops);
89727 if (is_udp4)
89728 UDP_INC_STATS_USER(sock_net(sk),
89729 UDP_MIB_INERRORS,
89730 @@ -665,7 +669,7 @@ csum_error:
89731 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
89732 drop:
89733 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
89734 - atomic_inc(&sk->sk_drops);
89735 + atomic_inc_unchecked(&sk->sk_drops);
89736 kfree_skb(skb);
89737 return -1;
89738 }
89739 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
89740 if (likely(skb1 == NULL))
89741 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
89742 if (!skb1) {
89743 - atomic_inc(&sk->sk_drops);
89744 + atomic_inc_unchecked(&sk->sk_drops);
89745 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
89746 IS_UDPLITE(sk));
89747 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
89748 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
89749 goto csum_error;
89750
89751 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
89752 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89753 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
89754 +#endif
89755 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
89756
89757 kfree_skb(skb);
89758 @@ -1392,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
89759 0,
89760 sock_i_ino(sp),
89761 atomic_read(&sp->sk_refcnt), sp,
89762 - atomic_read(&sp->sk_drops));
89763 + atomic_read_unchecked(&sp->sk_drops));
89764 }
89765
89766 int udp6_seq_show(struct seq_file *seq, void *v)
89767 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
89768 index 23ed03d..465a71d 100644
89769 --- a/net/ipv6/xfrm6_policy.c
89770 +++ b/net/ipv6/xfrm6_policy.c
89771 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
89772
89773 static int __net_init xfrm6_net_init(struct net *net)
89774 {
89775 - struct ctl_table *table;
89776 + ctl_table_no_const *table = NULL;
89777 struct ctl_table_header *hdr;
89778
89779 - table = xfrm6_policy_table;
89780 if (!net_eq(net, &init_net)) {
89781 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
89782 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
89783 if (!table)
89784 goto err_alloc;
89785
89786 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
89787 - }
89788 + hdr = register_net_sysctl(net, "net/ipv6", table);
89789 + } else
89790 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
89791
89792 - hdr = register_net_sysctl(net, "net/ipv6", table);
89793 if (!hdr)
89794 goto err_reg;
89795
89796 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
89797 return 0;
89798
89799 err_reg:
89800 - if (!net_eq(net, &init_net))
89801 - kfree(table);
89802 + kfree(table);
89803 err_alloc:
89804 return -ENOMEM;
89805 }
89806 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
89807 index 41ac7938..75e3bb1 100644
89808 --- a/net/irda/ircomm/ircomm_tty.c
89809 +++ b/net/irda/ircomm/ircomm_tty.c
89810 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89811 add_wait_queue(&port->open_wait, &wait);
89812
89813 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
89814 - __FILE__, __LINE__, tty->driver->name, port->count);
89815 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89816
89817 spin_lock_irqsave(&port->lock, flags);
89818 if (!tty_hung_up_p(filp))
89819 - port->count--;
89820 + atomic_dec(&port->count);
89821 port->blocked_open++;
89822 spin_unlock_irqrestore(&port->lock, flags);
89823
89824 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89825 }
89826
89827 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
89828 - __FILE__, __LINE__, tty->driver->name, port->count);
89829 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89830
89831 schedule();
89832 }
89833 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89834
89835 spin_lock_irqsave(&port->lock, flags);
89836 if (!tty_hung_up_p(filp))
89837 - port->count++;
89838 + atomic_inc(&port->count);
89839 port->blocked_open--;
89840 spin_unlock_irqrestore(&port->lock, flags);
89841
89842 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
89843 - __FILE__, __LINE__, tty->driver->name, port->count);
89844 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89845
89846 if (!retval)
89847 port->flags |= ASYNC_NORMAL_ACTIVE;
89848 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
89849
89850 /* ++ is not atomic, so this should be protected - Jean II */
89851 spin_lock_irqsave(&self->port.lock, flags);
89852 - self->port.count++;
89853 + atomic_inc(&self->port.count);
89854 spin_unlock_irqrestore(&self->port.lock, flags);
89855 tty_port_tty_set(&self->port, tty);
89856
89857 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
89858 - self->line, self->port.count);
89859 + self->line, atomic_read(&self->port.count));
89860
89861 /* Not really used by us, but lets do it anyway */
89862 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
89863 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
89864 tty_kref_put(port->tty);
89865 }
89866 port->tty = NULL;
89867 - port->count = 0;
89868 + atomic_set(&port->count, 0);
89869 spin_unlock_irqrestore(&port->lock, flags);
89870
89871 wake_up_interruptible(&port->open_wait);
89872 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
89873 seq_putc(m, '\n');
89874
89875 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
89876 - seq_printf(m, "Open count: %d\n", self->port.count);
89877 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
89878 seq_printf(m, "Max data size: %d\n", self->max_data_size);
89879 seq_printf(m, "Max header size: %d\n", self->max_header_size);
89880
89881 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
89882 index ae69165..c8b82d8 100644
89883 --- a/net/iucv/af_iucv.c
89884 +++ b/net/iucv/af_iucv.c
89885 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
89886
89887 write_lock_bh(&iucv_sk_list.lock);
89888
89889 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
89890 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89891 while (__iucv_get_sock_by_name(name)) {
89892 sprintf(name, "%08x",
89893 - atomic_inc_return(&iucv_sk_list.autobind_name));
89894 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89895 }
89896
89897 write_unlock_bh(&iucv_sk_list.lock);
89898 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
89899 index 4fe76ff..426a904 100644
89900 --- a/net/iucv/iucv.c
89901 +++ b/net/iucv/iucv.c
89902 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
89903 return NOTIFY_OK;
89904 }
89905
89906 -static struct notifier_block __refdata iucv_cpu_notifier = {
89907 +static struct notifier_block iucv_cpu_notifier = {
89908 .notifier_call = iucv_cpu_notify,
89909 };
89910
89911 diff --git a/net/key/af_key.c b/net/key/af_key.c
89912 index 9da8620..97070ad 100644
89913 --- a/net/key/af_key.c
89914 +++ b/net/key/af_key.c
89915 @@ -3047,10 +3047,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
89916 static u32 get_acqseq(void)
89917 {
89918 u32 res;
89919 - static atomic_t acqseq;
89920 + static atomic_unchecked_t acqseq;
89921
89922 do {
89923 - res = atomic_inc_return(&acqseq);
89924 + res = atomic_inc_return_unchecked(&acqseq);
89925 } while (!res);
89926 return res;
89927 }
89928 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
89929 index 4fdb306e..920086a 100644
89930 --- a/net/mac80211/cfg.c
89931 +++ b/net/mac80211/cfg.c
89932 @@ -804,7 +804,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
89933 ret = ieee80211_vif_use_channel(sdata, chandef,
89934 IEEE80211_CHANCTX_EXCLUSIVE);
89935 }
89936 - } else if (local->open_count == local->monitors) {
89937 + } else if (local_read(&local->open_count) == local->monitors) {
89938 local->_oper_chandef = *chandef;
89939 ieee80211_hw_config(local, 0);
89940 }
89941 @@ -2920,7 +2920,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
89942 else
89943 local->probe_req_reg--;
89944
89945 - if (!local->open_count)
89946 + if (!local_read(&local->open_count))
89947 break;
89948
89949 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
89950 @@ -3383,8 +3383,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
89951 if (chanctx_conf) {
89952 *chandef = chanctx_conf->def;
89953 ret = 0;
89954 - } else if (local->open_count > 0 &&
89955 - local->open_count == local->monitors &&
89956 + } else if (local_read(&local->open_count) > 0 &&
89957 + local_read(&local->open_count) == local->monitors &&
89958 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
89959 if (local->use_chanctx)
89960 *chandef = local->monitor_chandef;
89961 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
89962 index 9ca8e32..48e4a9b 100644
89963 --- a/net/mac80211/ieee80211_i.h
89964 +++ b/net/mac80211/ieee80211_i.h
89965 @@ -28,6 +28,7 @@
89966 #include <net/ieee80211_radiotap.h>
89967 #include <net/cfg80211.h>
89968 #include <net/mac80211.h>
89969 +#include <asm/local.h>
89970 #include "key.h"
89971 #include "sta_info.h"
89972 #include "debug.h"
89973 @@ -891,7 +892,7 @@ struct ieee80211_local {
89974 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
89975 spinlock_t queue_stop_reason_lock;
89976
89977 - int open_count;
89978 + local_t open_count;
89979 int monitors, cooked_mntrs;
89980 /* number of interfaces with corresponding FIF_ flags */
89981 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
89982 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
89983 index 514e90f..56f22bf 100644
89984 --- a/net/mac80211/iface.c
89985 +++ b/net/mac80211/iface.c
89986 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89987 break;
89988 }
89989
89990 - if (local->open_count == 0) {
89991 + if (local_read(&local->open_count) == 0) {
89992 res = drv_start(local);
89993 if (res)
89994 goto err_del_bss;
89995 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89996 break;
89997 }
89998
89999 - if (local->monitors == 0 && local->open_count == 0) {
90000 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
90001 res = ieee80211_add_virtual_monitor(local);
90002 if (res)
90003 goto err_stop;
90004 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
90005 atomic_inc(&local->iff_promiscs);
90006
90007 if (coming_up)
90008 - local->open_count++;
90009 + local_inc(&local->open_count);
90010
90011 if (hw_reconf_flags)
90012 ieee80211_hw_config(local, hw_reconf_flags);
90013 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
90014 err_del_interface:
90015 drv_remove_interface(local, sdata);
90016 err_stop:
90017 - if (!local->open_count)
90018 + if (!local_read(&local->open_count))
90019 drv_stop(local);
90020 err_del_bss:
90021 sdata->bss = NULL;
90022 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90023 }
90024
90025 if (going_down)
90026 - local->open_count--;
90027 + local_dec(&local->open_count);
90028
90029 switch (sdata->vif.type) {
90030 case NL80211_IFTYPE_AP_VLAN:
90031 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90032 }
90033 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
90034
90035 - if (local->open_count == 0)
90036 + if (local_read(&local->open_count) == 0)
90037 ieee80211_clear_tx_pending(local);
90038
90039 /*
90040 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90041
90042 ieee80211_recalc_ps(local, -1);
90043
90044 - if (local->open_count == 0) {
90045 + if (local_read(&local->open_count) == 0) {
90046 ieee80211_stop_device(local);
90047
90048 /* no reconfiguring after stop! */
90049 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90050 ieee80211_configure_filter(local);
90051 ieee80211_hw_config(local, hw_reconf_flags);
90052
90053 - if (local->monitors == local->open_count)
90054 + if (local->monitors == local_read(&local->open_count))
90055 ieee80211_add_virtual_monitor(local);
90056 }
90057
90058 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
90059 index 8a7bfc4..4407cd0 100644
90060 --- a/net/mac80211/main.c
90061 +++ b/net/mac80211/main.c
90062 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
90063 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
90064 IEEE80211_CONF_CHANGE_POWER);
90065
90066 - if (changed && local->open_count) {
90067 + if (changed && local_read(&local->open_count)) {
90068 ret = drv_config(local, changed);
90069 /*
90070 * Goal:
90071 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
90072 index 7fc5d0d..07ea536 100644
90073 --- a/net/mac80211/pm.c
90074 +++ b/net/mac80211/pm.c
90075 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
90076 struct ieee80211_sub_if_data *sdata;
90077 struct sta_info *sta;
90078
90079 - if (!local->open_count)
90080 + if (!local_read(&local->open_count))
90081 goto suspend;
90082
90083 ieee80211_scan_cancel(local);
90084 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
90085 cancel_work_sync(&local->dynamic_ps_enable_work);
90086 del_timer_sync(&local->dynamic_ps_timer);
90087
90088 - local->wowlan = wowlan && local->open_count;
90089 + local->wowlan = wowlan && local_read(&local->open_count);
90090 if (local->wowlan) {
90091 int err = drv_suspend(local, wowlan);
90092 if (err < 0) {
90093 @@ -113,7 +113,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
90094 WARN_ON(!list_empty(&local->chanctx_list));
90095
90096 /* stop hardware - this must stop RX */
90097 - if (local->open_count)
90098 + if (local_read(&local->open_count))
90099 ieee80211_stop_device(local);
90100
90101 suspend:
90102 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
90103 index a02bef3..f2f38dd 100644
90104 --- a/net/mac80211/rate.c
90105 +++ b/net/mac80211/rate.c
90106 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
90107
90108 ASSERT_RTNL();
90109
90110 - if (local->open_count)
90111 + if (local_read(&local->open_count))
90112 return -EBUSY;
90113
90114 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
90115 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
90116 index c97a065..ff61928 100644
90117 --- a/net/mac80211/rc80211_pid_debugfs.c
90118 +++ b/net/mac80211/rc80211_pid_debugfs.c
90119 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
90120
90121 spin_unlock_irqrestore(&events->lock, status);
90122
90123 - if (copy_to_user(buf, pb, p))
90124 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
90125 return -EFAULT;
90126
90127 return p;
90128 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
90129 index 72e6292..e6319eb 100644
90130 --- a/net/mac80211/util.c
90131 +++ b/net/mac80211/util.c
90132 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
90133 }
90134 #endif
90135 /* everything else happens only if HW was up & running */
90136 - if (!local->open_count)
90137 + if (!local_read(&local->open_count))
90138 goto wake_up;
90139
90140 /*
90141 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
90142 local->in_reconfig = false;
90143 barrier();
90144
90145 - if (local->monitors == local->open_count && local->monitors > 0)
90146 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
90147 ieee80211_add_virtual_monitor(local);
90148
90149 /*
90150 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
90151 index 56d22ca..87c778f 100644
90152 --- a/net/netfilter/Kconfig
90153 +++ b/net/netfilter/Kconfig
90154 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
90155
90156 To compile it as a module, choose M here. If unsure, say N.
90157
90158 +config NETFILTER_XT_MATCH_GRADM
90159 + tristate '"gradm" match support'
90160 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
90161 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
90162 + ---help---
90163 + The gradm match allows to match on grsecurity RBAC being enabled.
90164 + It is useful when iptables rules are applied early on bootup to
90165 + prevent connections to the machine (except from a trusted host)
90166 + while the RBAC system is disabled.
90167 +
90168 config NETFILTER_XT_MATCH_HASHLIMIT
90169 tristate '"hashlimit" match support'
90170 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
90171 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
90172 index a1abf87..dbcb7ee 100644
90173 --- a/net/netfilter/Makefile
90174 +++ b/net/netfilter/Makefile
90175 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
90176 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
90177 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
90178 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
90179 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
90180 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
90181 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
90182 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
90183 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
90184 index f771390..145b765 100644
90185 --- a/net/netfilter/ipset/ip_set_core.c
90186 +++ b/net/netfilter/ipset/ip_set_core.c
90187 @@ -1820,7 +1820,7 @@ done:
90188 return ret;
90189 }
90190
90191 -static struct nf_sockopt_ops so_set __read_mostly = {
90192 +static struct nf_sockopt_ops so_set = {
90193 .pf = PF_INET,
90194 .get_optmin = SO_IP_SET,
90195 .get_optmax = SO_IP_SET + 1,
90196 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
90197 index a083bda..da661c3 100644
90198 --- a/net/netfilter/ipvs/ip_vs_conn.c
90199 +++ b/net/netfilter/ipvs/ip_vs_conn.c
90200 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
90201 /* Increase the refcnt counter of the dest */
90202 ip_vs_dest_hold(dest);
90203
90204 - conn_flags = atomic_read(&dest->conn_flags);
90205 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
90206 if (cp->protocol != IPPROTO_UDP)
90207 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
90208 flags = cp->flags;
90209 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
90210
90211 cp->control = NULL;
90212 atomic_set(&cp->n_control, 0);
90213 - atomic_set(&cp->in_pkts, 0);
90214 + atomic_set_unchecked(&cp->in_pkts, 0);
90215
90216 cp->packet_xmit = NULL;
90217 cp->app = NULL;
90218 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
90219
90220 /* Don't drop the entry if its number of incoming packets is not
90221 located in [0, 8] */
90222 - i = atomic_read(&cp->in_pkts);
90223 + i = atomic_read_unchecked(&cp->in_pkts);
90224 if (i > 8 || i < 0) return 0;
90225
90226 if (!todrop_rate[i]) return 0;
90227 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
90228 index 23b8eb5..48a8959 100644
90229 --- a/net/netfilter/ipvs/ip_vs_core.c
90230 +++ b/net/netfilter/ipvs/ip_vs_core.c
90231 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
90232 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
90233 /* do not touch skb anymore */
90234
90235 - atomic_inc(&cp->in_pkts);
90236 + atomic_inc_unchecked(&cp->in_pkts);
90237 ip_vs_conn_put(cp);
90238 return ret;
90239 }
90240 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
90241 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
90242 pkts = sysctl_sync_threshold(ipvs);
90243 else
90244 - pkts = atomic_add_return(1, &cp->in_pkts);
90245 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
90246
90247 if (ipvs->sync_state & IP_VS_STATE_MASTER)
90248 ip_vs_sync_conn(net, cp, pkts);
90249 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
90250 index 9e6c2a0..28552e2 100644
90251 --- a/net/netfilter/ipvs/ip_vs_ctl.c
90252 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
90253 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
90254 */
90255 ip_vs_rs_hash(ipvs, dest);
90256 }
90257 - atomic_set(&dest->conn_flags, conn_flags);
90258 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
90259
90260 /* bind the service */
90261 if (!dest->svc) {
90262 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
90263 * align with netns init in ip_vs_control_net_init()
90264 */
90265
90266 -static struct ctl_table vs_vars[] = {
90267 +static ctl_table_no_const vs_vars[] __read_only = {
90268 {
90269 .procname = "amemthresh",
90270 .maxlen = sizeof(int),
90271 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
90272 " %-7s %-6d %-10d %-10d\n",
90273 &dest->addr.in6,
90274 ntohs(dest->port),
90275 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
90276 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
90277 atomic_read(&dest->weight),
90278 atomic_read(&dest->activeconns),
90279 atomic_read(&dest->inactconns));
90280 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
90281 "%-7s %-6d %-10d %-10d\n",
90282 ntohl(dest->addr.ip),
90283 ntohs(dest->port),
90284 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
90285 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
90286 atomic_read(&dest->weight),
90287 atomic_read(&dest->activeconns),
90288 atomic_read(&dest->inactconns));
90289 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
90290
90291 entry.addr = dest->addr.ip;
90292 entry.port = dest->port;
90293 - entry.conn_flags = atomic_read(&dest->conn_flags);
90294 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
90295 entry.weight = atomic_read(&dest->weight);
90296 entry.u_threshold = dest->u_threshold;
90297 entry.l_threshold = dest->l_threshold;
90298 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
90299 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
90300 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
90301 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
90302 - (atomic_read(&dest->conn_flags) &
90303 + (atomic_read_unchecked(&dest->conn_flags) &
90304 IP_VS_CONN_F_FWD_MASK)) ||
90305 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
90306 atomic_read(&dest->weight)) ||
90307 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
90308 {
90309 int idx;
90310 struct netns_ipvs *ipvs = net_ipvs(net);
90311 - struct ctl_table *tbl;
90312 + ctl_table_no_const *tbl;
90313
90314 atomic_set(&ipvs->dropentry, 0);
90315 spin_lock_init(&ipvs->dropentry_lock);
90316 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
90317 index 5ea26bd..c9bc65f 100644
90318 --- a/net/netfilter/ipvs/ip_vs_lblc.c
90319 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
90320 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
90321 * IPVS LBLC sysctl table
90322 */
90323 #ifdef CONFIG_SYSCTL
90324 -static ctl_table vs_vars_table[] = {
90325 +static ctl_table_no_const vs_vars_table[] __read_only = {
90326 {
90327 .procname = "lblc_expiration",
90328 .data = NULL,
90329 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
90330 index 50123c2..067c773 100644
90331 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
90332 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
90333 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
90334 * IPVS LBLCR sysctl table
90335 */
90336
90337 -static ctl_table vs_vars_table[] = {
90338 +static ctl_table_no_const vs_vars_table[] __read_only = {
90339 {
90340 .procname = "lblcr_expiration",
90341 .data = NULL,
90342 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
90343 index f6046d9..4f10cfd 100644
90344 --- a/net/netfilter/ipvs/ip_vs_sync.c
90345 +++ b/net/netfilter/ipvs/ip_vs_sync.c
90346 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
90347 cp = cp->control;
90348 if (cp) {
90349 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
90350 - pkts = atomic_add_return(1, &cp->in_pkts);
90351 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
90352 else
90353 pkts = sysctl_sync_threshold(ipvs);
90354 ip_vs_sync_conn(net, cp->control, pkts);
90355 @@ -758,7 +758,7 @@ control:
90356 if (!cp)
90357 return;
90358 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
90359 - pkts = atomic_add_return(1, &cp->in_pkts);
90360 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
90361 else
90362 pkts = sysctl_sync_threshold(ipvs);
90363 goto sloop;
90364 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
90365
90366 if (opt)
90367 memcpy(&cp->in_seq, opt, sizeof(*opt));
90368 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
90369 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
90370 cp->state = state;
90371 cp->old_state = cp->state;
90372 /*
90373 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
90374 index b75ff64..0c51bbe 100644
90375 --- a/net/netfilter/ipvs/ip_vs_xmit.c
90376 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
90377 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
90378 else
90379 rc = NF_ACCEPT;
90380 /* do not touch skb anymore */
90381 - atomic_inc(&cp->in_pkts);
90382 + atomic_inc_unchecked(&cp->in_pkts);
90383 goto out;
90384 }
90385
90386 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
90387 else
90388 rc = NF_ACCEPT;
90389 /* do not touch skb anymore */
90390 - atomic_inc(&cp->in_pkts);
90391 + atomic_inc_unchecked(&cp->in_pkts);
90392 goto out;
90393 }
90394
90395 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
90396 index 2d3030a..7ba1c0a 100644
90397 --- a/net/netfilter/nf_conntrack_acct.c
90398 +++ b/net/netfilter/nf_conntrack_acct.c
90399 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
90400 #ifdef CONFIG_SYSCTL
90401 static int nf_conntrack_acct_init_sysctl(struct net *net)
90402 {
90403 - struct ctl_table *table;
90404 + ctl_table_no_const *table;
90405
90406 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
90407 GFP_KERNEL);
90408 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
90409 index 0283bae..5febcb0 100644
90410 --- a/net/netfilter/nf_conntrack_core.c
90411 +++ b/net/netfilter/nf_conntrack_core.c
90412 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
90413 #define DYING_NULLS_VAL ((1<<30)+1)
90414 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
90415
90416 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90417 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
90418 +#endif
90419 +
90420 int nf_conntrack_init_net(struct net *net)
90421 {
90422 int ret;
90423 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
90424 goto err_stat;
90425 }
90426
90427 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90428 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
90429 +#else
90430 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
90431 +#endif
90432 if (!net->ct.slabname) {
90433 ret = -ENOMEM;
90434 goto err_slabname;
90435 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
90436 index 1df1761..ce8b88a 100644
90437 --- a/net/netfilter/nf_conntrack_ecache.c
90438 +++ b/net/netfilter/nf_conntrack_ecache.c
90439 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
90440 #ifdef CONFIG_SYSCTL
90441 static int nf_conntrack_event_init_sysctl(struct net *net)
90442 {
90443 - struct ctl_table *table;
90444 + ctl_table_no_const *table;
90445
90446 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
90447 GFP_KERNEL);
90448 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
90449 index 974a2a4..52cc6ff 100644
90450 --- a/net/netfilter/nf_conntrack_helper.c
90451 +++ b/net/netfilter/nf_conntrack_helper.c
90452 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
90453
90454 static int nf_conntrack_helper_init_sysctl(struct net *net)
90455 {
90456 - struct ctl_table *table;
90457 + ctl_table_no_const *table;
90458
90459 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
90460 GFP_KERNEL);
90461 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
90462 index 0ab9636..cea3c6a 100644
90463 --- a/net/netfilter/nf_conntrack_proto.c
90464 +++ b/net/netfilter/nf_conntrack_proto.c
90465 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
90466
90467 static void
90468 nf_ct_unregister_sysctl(struct ctl_table_header **header,
90469 - struct ctl_table **table,
90470 + ctl_table_no_const **table,
90471 unsigned int users)
90472 {
90473 if (users > 0)
90474 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
90475 index a99b6c3..3841268 100644
90476 --- a/net/netfilter/nf_conntrack_proto_dccp.c
90477 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
90478 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
90479 out_invalid:
90480 if (LOG_INVALID(net, IPPROTO_DCCP))
90481 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
90482 - NULL, msg);
90483 + NULL, "%s", msg);
90484 return false;
90485 }
90486
90487 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
90488
90489 out_invalid:
90490 if (LOG_INVALID(net, IPPROTO_DCCP))
90491 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
90492 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
90493 return -NF_ACCEPT;
90494 }
90495
90496 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
90497 index bd700b4..4a3dc61 100644
90498 --- a/net/netfilter/nf_conntrack_standalone.c
90499 +++ b/net/netfilter/nf_conntrack_standalone.c
90500 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
90501
90502 static int nf_conntrack_standalone_init_sysctl(struct net *net)
90503 {
90504 - struct ctl_table *table;
90505 + ctl_table_no_const *table;
90506
90507 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
90508 GFP_KERNEL);
90509 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
90510 index 902fb0a..87f7fdb 100644
90511 --- a/net/netfilter/nf_conntrack_timestamp.c
90512 +++ b/net/netfilter/nf_conntrack_timestamp.c
90513 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
90514 #ifdef CONFIG_SYSCTL
90515 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
90516 {
90517 - struct ctl_table *table;
90518 + ctl_table_no_const *table;
90519
90520 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
90521 GFP_KERNEL);
90522 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
90523 index 3b18dd1..f79e0ca 100644
90524 --- a/net/netfilter/nf_log.c
90525 +++ b/net/netfilter/nf_log.c
90526 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
90527
90528 #ifdef CONFIG_SYSCTL
90529 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
90530 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
90531 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
90532
90533 static int nf_log_proc_dostring(ctl_table *table, int write,
90534 void __user *buffer, size_t *lenp, loff_t *ppos)
90535 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
90536 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
90537 mutex_unlock(&nf_log_mutex);
90538 } else {
90539 + ctl_table_no_const nf_log_table = *table;
90540 +
90541 mutex_lock(&nf_log_mutex);
90542 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
90543 lockdep_is_held(&nf_log_mutex));
90544 if (!logger)
90545 - table->data = "NONE";
90546 + nf_log_table.data = "NONE";
90547 else
90548 - table->data = logger->name;
90549 - r = proc_dostring(table, write, buffer, lenp, ppos);
90550 + nf_log_table.data = logger->name;
90551 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
90552 mutex_unlock(&nf_log_mutex);
90553 }
90554
90555 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
90556 index f042ae5..30ea486 100644
90557 --- a/net/netfilter/nf_sockopt.c
90558 +++ b/net/netfilter/nf_sockopt.c
90559 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
90560 }
90561 }
90562
90563 - list_add(&reg->list, &nf_sockopts);
90564 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
90565 out:
90566 mutex_unlock(&nf_sockopt_mutex);
90567 return ret;
90568 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
90569 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
90570 {
90571 mutex_lock(&nf_sockopt_mutex);
90572 - list_del(&reg->list);
90573 + pax_list_del((struct list_head *)&reg->list);
90574 mutex_unlock(&nf_sockopt_mutex);
90575 }
90576 EXPORT_SYMBOL(nf_unregister_sockopt);
90577 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
90578 index 962e979..d4ae2e9 100644
90579 --- a/net/netfilter/nfnetlink_log.c
90580 +++ b/net/netfilter/nfnetlink_log.c
90581 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
90582 struct nfnl_log_net {
90583 spinlock_t instances_lock;
90584 struct hlist_head instance_table[INSTANCE_BUCKETS];
90585 - atomic_t global_seq;
90586 + atomic_unchecked_t global_seq;
90587 };
90588
90589 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
90590 @@ -559,7 +559,7 @@ __build_packet_message(struct nfnl_log_net *log,
90591 /* global sequence number */
90592 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
90593 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
90594 - htonl(atomic_inc_return(&log->global_seq))))
90595 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
90596 goto nla_put_failure;
90597
90598 if (data_len) {
90599 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
90600 new file mode 100644
90601 index 0000000..c566332
90602 --- /dev/null
90603 +++ b/net/netfilter/xt_gradm.c
90604 @@ -0,0 +1,51 @@
90605 +/*
90606 + * gradm match for netfilter
90607 + * Copyright © Zbigniew Krzystolik, 2010
90608 + *
90609 + * This program is free software; you can redistribute it and/or modify
90610 + * it under the terms of the GNU General Public License; either version
90611 + * 2 or 3 as published by the Free Software Foundation.
90612 + */
90613 +#include <linux/module.h>
90614 +#include <linux/moduleparam.h>
90615 +#include <linux/skbuff.h>
90616 +#include <linux/netfilter/x_tables.h>
90617 +#include <linux/grsecurity.h>
90618 +#include <linux/netfilter/xt_gradm.h>
90619 +
90620 +static bool
90621 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
90622 +{
90623 + const struct xt_gradm_mtinfo *info = par->matchinfo;
90624 + bool retval = false;
90625 + if (gr_acl_is_enabled())
90626 + retval = true;
90627 + return retval ^ info->invflags;
90628 +}
90629 +
90630 +static struct xt_match gradm_mt_reg __read_mostly = {
90631 + .name = "gradm",
90632 + .revision = 0,
90633 + .family = NFPROTO_UNSPEC,
90634 + .match = gradm_mt,
90635 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
90636 + .me = THIS_MODULE,
90637 +};
90638 +
90639 +static int __init gradm_mt_init(void)
90640 +{
90641 + return xt_register_match(&gradm_mt_reg);
90642 +}
90643 +
90644 +static void __exit gradm_mt_exit(void)
90645 +{
90646 + xt_unregister_match(&gradm_mt_reg);
90647 +}
90648 +
90649 +module_init(gradm_mt_init);
90650 +module_exit(gradm_mt_exit);
90651 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
90652 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
90653 +MODULE_LICENSE("GPL");
90654 +MODULE_ALIAS("ipt_gradm");
90655 +MODULE_ALIAS("ip6t_gradm");
90656 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
90657 index 4fe4fb4..87a89e5 100644
90658 --- a/net/netfilter/xt_statistic.c
90659 +++ b/net/netfilter/xt_statistic.c
90660 @@ -19,7 +19,7 @@
90661 #include <linux/module.h>
90662
90663 struct xt_statistic_priv {
90664 - atomic_t count;
90665 + atomic_unchecked_t count;
90666 } ____cacheline_aligned_in_smp;
90667
90668 MODULE_LICENSE("GPL");
90669 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
90670 break;
90671 case XT_STATISTIC_MODE_NTH:
90672 do {
90673 - oval = atomic_read(&info->master->count);
90674 + oval = atomic_read_unchecked(&info->master->count);
90675 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
90676 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
90677 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
90678 if (nval == 0)
90679 ret = !ret;
90680 break;
90681 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
90682 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
90683 if (info->master == NULL)
90684 return -ENOMEM;
90685 - atomic_set(&info->master->count, info->u.nth.count);
90686 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
90687
90688 return 0;
90689 }
90690 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
90691 index 57ee84d..8b99cf5 100644
90692 --- a/net/netlink/af_netlink.c
90693 +++ b/net/netlink/af_netlink.c
90694 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
90695 sk->sk_error_report(sk);
90696 }
90697 }
90698 - atomic_inc(&sk->sk_drops);
90699 + atomic_inc_unchecked(&sk->sk_drops);
90700 }
90701
90702 static void netlink_rcv_wake(struct sock *sk)
90703 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
90704 sk_wmem_alloc_get(s),
90705 nlk->cb,
90706 atomic_read(&s->sk_refcnt),
90707 - atomic_read(&s->sk_drops),
90708 + atomic_read_unchecked(&s->sk_drops),
90709 sock_i_ino(s)
90710 );
90711
90712 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
90713 index 2fd6dbe..1032269 100644
90714 --- a/net/netlink/genetlink.c
90715 +++ b/net/netlink/genetlink.c
90716 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
90717 goto errout;
90718 }
90719
90720 + pax_open_kernel();
90721 if (ops->dumpit)
90722 - ops->flags |= GENL_CMD_CAP_DUMP;
90723 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
90724 if (ops->doit)
90725 - ops->flags |= GENL_CMD_CAP_DO;
90726 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
90727 if (ops->policy)
90728 - ops->flags |= GENL_CMD_CAP_HASPOL;
90729 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
90730 + pax_close_kernel();
90731
90732 genl_lock_all();
90733 - list_add_tail(&ops->ops_list, &family->ops_list);
90734 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
90735 genl_unlock_all();
90736
90737 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
90738 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
90739 err = 0;
90740 errout:
90741 return err;
90742 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
90743 genl_lock_all();
90744 list_for_each_entry(rc, &family->ops_list, ops_list) {
90745 if (rc == ops) {
90746 - list_del(&ops->ops_list);
90747 + pax_list_del((struct list_head *)&ops->ops_list);
90748 genl_unlock_all();
90749 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
90750 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
90751 return 0;
90752 }
90753 }
90754 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
90755 index ec0c80f..41e1830 100644
90756 --- a/net/netrom/af_netrom.c
90757 +++ b/net/netrom/af_netrom.c
90758 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
90759 *uaddr_len = sizeof(struct full_sockaddr_ax25);
90760 } else {
90761 sax->fsa_ax25.sax25_family = AF_NETROM;
90762 - sax->fsa_ax25.sax25_ndigis = 0;
90763 sax->fsa_ax25.sax25_call = nr->source_addr;
90764 *uaddr_len = sizeof(struct sockaddr_ax25);
90765 }
90766 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
90767 index 20a1bd0..bb8f1c1 100644
90768 --- a/net/packet/af_packet.c
90769 +++ b/net/packet/af_packet.c
90770 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
90771
90772 spin_lock(&sk->sk_receive_queue.lock);
90773 po->stats.stats1.tp_packets++;
90774 - skb->dropcount = atomic_read(&sk->sk_drops);
90775 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
90776 __skb_queue_tail(&sk->sk_receive_queue, skb);
90777 spin_unlock(&sk->sk_receive_queue.lock);
90778 sk->sk_data_ready(sk, skb->len);
90779 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
90780 drop_n_acct:
90781 spin_lock(&sk->sk_receive_queue.lock);
90782 po->stats.stats1.tp_drops++;
90783 - atomic_inc(&sk->sk_drops);
90784 + atomic_inc_unchecked(&sk->sk_drops);
90785 spin_unlock(&sk->sk_receive_queue.lock);
90786
90787 drop_n_restore:
90788 @@ -2640,6 +2640,7 @@ out:
90789
90790 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90791 {
90792 + struct sock_extended_err ee;
90793 struct sock_exterr_skb *serr;
90794 struct sk_buff *skb, *skb2;
90795 int copied, err;
90796 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90797 sock_recv_timestamp(msg, sk, skb);
90798
90799 serr = SKB_EXT_ERR(skb);
90800 + ee = serr->ee;
90801 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
90802 - sizeof(serr->ee), &serr->ee);
90803 + sizeof ee, &ee);
90804
90805 msg->msg_flags |= MSG_ERRQUEUE;
90806 err = copied;
90807 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90808 case PACKET_HDRLEN:
90809 if (len > sizeof(int))
90810 len = sizeof(int);
90811 - if (copy_from_user(&val, optval, len))
90812 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
90813 return -EFAULT;
90814 switch (val) {
90815 case TPACKET_V1:
90816 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90817 len = lv;
90818 if (put_user(len, optlen))
90819 return -EFAULT;
90820 - if (copy_to_user(optval, data, len))
90821 + if (len > sizeof(st) || copy_to_user(optval, data, len))
90822 return -EFAULT;
90823 return 0;
90824 }
90825 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
90826 index 5a940db..d6a502d 100644
90827 --- a/net/phonet/af_phonet.c
90828 +++ b/net/phonet/af_phonet.c
90829 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
90830 {
90831 int err = 0;
90832
90833 - if (protocol >= PHONET_NPROTO)
90834 + if (protocol < 0 || protocol >= PHONET_NPROTO)
90835 return -EINVAL;
90836
90837 err = proto_register(pp->prot, 1);
90838 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
90839 index e774117..900b8b7 100644
90840 --- a/net/phonet/pep.c
90841 +++ b/net/phonet/pep.c
90842 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90843
90844 case PNS_PEP_CTRL_REQ:
90845 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
90846 - atomic_inc(&sk->sk_drops);
90847 + atomic_inc_unchecked(&sk->sk_drops);
90848 break;
90849 }
90850 __skb_pull(skb, 4);
90851 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90852 }
90853
90854 if (pn->rx_credits == 0) {
90855 - atomic_inc(&sk->sk_drops);
90856 + atomic_inc_unchecked(&sk->sk_drops);
90857 err = -ENOBUFS;
90858 break;
90859 }
90860 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
90861 }
90862
90863 if (pn->rx_credits == 0) {
90864 - atomic_inc(&sk->sk_drops);
90865 + atomic_inc_unchecked(&sk->sk_drops);
90866 err = NET_RX_DROP;
90867 break;
90868 }
90869 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
90870 index 1afd138..0b42453 100644
90871 --- a/net/phonet/socket.c
90872 +++ b/net/phonet/socket.c
90873 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
90874 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
90875 sock_i_ino(sk),
90876 atomic_read(&sk->sk_refcnt), sk,
90877 - atomic_read(&sk->sk_drops), &len);
90878 + atomic_read_unchecked(&sk->sk_drops), &len);
90879 }
90880 seq_printf(seq, "%*s\n", 127 - len, "");
90881 return 0;
90882 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
90883 index d6bbbbd..61561e4 100644
90884 --- a/net/phonet/sysctl.c
90885 +++ b/net/phonet/sysctl.c
90886 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
90887 {
90888 int ret;
90889 int range[2] = {local_port_range[0], local_port_range[1]};
90890 - ctl_table tmp = {
90891 + ctl_table_no_const tmp = {
90892 .data = &range,
90893 .maxlen = sizeof(range),
90894 .mode = table->mode,
90895 diff --git a/net/rds/cong.c b/net/rds/cong.c
90896 index e5b65ac..f3b6fb7 100644
90897 --- a/net/rds/cong.c
90898 +++ b/net/rds/cong.c
90899 @@ -78,7 +78,7 @@
90900 * finds that the saved generation number is smaller than the global generation
90901 * number, it wakes up the process.
90902 */
90903 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
90904 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
90905
90906 /*
90907 * Congestion monitoring
90908 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
90909 rdsdebug("waking map %p for %pI4\n",
90910 map, &map->m_addr);
90911 rds_stats_inc(s_cong_update_received);
90912 - atomic_inc(&rds_cong_generation);
90913 + atomic_inc_unchecked(&rds_cong_generation);
90914 if (waitqueue_active(&map->m_waitq))
90915 wake_up(&map->m_waitq);
90916 if (waitqueue_active(&rds_poll_waitq))
90917 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
90918
90919 int rds_cong_updated_since(unsigned long *recent)
90920 {
90921 - unsigned long gen = atomic_read(&rds_cong_generation);
90922 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
90923
90924 if (likely(*recent == gen))
90925 return 0;
90926 diff --git a/net/rds/ib.h b/net/rds/ib.h
90927 index 7280ab8..e04f4ea 100644
90928 --- a/net/rds/ib.h
90929 +++ b/net/rds/ib.h
90930 @@ -128,7 +128,7 @@ struct rds_ib_connection {
90931 /* sending acks */
90932 unsigned long i_ack_flags;
90933 #ifdef KERNEL_HAS_ATOMIC64
90934 - atomic64_t i_ack_next; /* next ACK to send */
90935 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90936 #else
90937 spinlock_t i_ack_lock; /* protect i_ack_next */
90938 u64 i_ack_next; /* next ACK to send */
90939 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
90940 index 31b74f5..dc1fbfa 100644
90941 --- a/net/rds/ib_cm.c
90942 +++ b/net/rds/ib_cm.c
90943 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
90944 /* Clear the ACK state */
90945 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90946 #ifdef KERNEL_HAS_ATOMIC64
90947 - atomic64_set(&ic->i_ack_next, 0);
90948 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90949 #else
90950 ic->i_ack_next = 0;
90951 #endif
90952 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
90953 index 8eb9501..0c386ff 100644
90954 --- a/net/rds/ib_recv.c
90955 +++ b/net/rds/ib_recv.c
90956 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90957 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
90958 int ack_required)
90959 {
90960 - atomic64_set(&ic->i_ack_next, seq);
90961 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90962 if (ack_required) {
90963 smp_mb__before_clear_bit();
90964 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90965 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90966 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90967 smp_mb__after_clear_bit();
90968
90969 - return atomic64_read(&ic->i_ack_next);
90970 + return atomic64_read_unchecked(&ic->i_ack_next);
90971 }
90972 #endif
90973
90974 diff --git a/net/rds/iw.h b/net/rds/iw.h
90975 index 04ce3b1..48119a6 100644
90976 --- a/net/rds/iw.h
90977 +++ b/net/rds/iw.h
90978 @@ -134,7 +134,7 @@ struct rds_iw_connection {
90979 /* sending acks */
90980 unsigned long i_ack_flags;
90981 #ifdef KERNEL_HAS_ATOMIC64
90982 - atomic64_t i_ack_next; /* next ACK to send */
90983 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90984 #else
90985 spinlock_t i_ack_lock; /* protect i_ack_next */
90986 u64 i_ack_next; /* next ACK to send */
90987 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
90988 index a91e1db..cf3053f 100644
90989 --- a/net/rds/iw_cm.c
90990 +++ b/net/rds/iw_cm.c
90991 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
90992 /* Clear the ACK state */
90993 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90994 #ifdef KERNEL_HAS_ATOMIC64
90995 - atomic64_set(&ic->i_ack_next, 0);
90996 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90997 #else
90998 ic->i_ack_next = 0;
90999 #endif
91000 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
91001 index 4503335..db566b4 100644
91002 --- a/net/rds/iw_recv.c
91003 +++ b/net/rds/iw_recv.c
91004 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
91005 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
91006 int ack_required)
91007 {
91008 - atomic64_set(&ic->i_ack_next, seq);
91009 + atomic64_set_unchecked(&ic->i_ack_next, seq);
91010 if (ack_required) {
91011 smp_mb__before_clear_bit();
91012 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
91013 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
91014 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
91015 smp_mb__after_clear_bit();
91016
91017 - return atomic64_read(&ic->i_ack_next);
91018 + return atomic64_read_unchecked(&ic->i_ack_next);
91019 }
91020 #endif
91021
91022 diff --git a/net/rds/rds.h b/net/rds/rds.h
91023 index ec1d731..90a3a8d 100644
91024 --- a/net/rds/rds.h
91025 +++ b/net/rds/rds.h
91026 @@ -449,7 +449,7 @@ struct rds_transport {
91027 void (*sync_mr)(void *trans_private, int direction);
91028 void (*free_mr)(void *trans_private, int invalidate);
91029 void (*flush_mrs)(void);
91030 -};
91031 +} __do_const;
91032
91033 struct rds_sock {
91034 struct sock rs_sk;
91035 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
91036 index edac9ef..16bcb98 100644
91037 --- a/net/rds/tcp.c
91038 +++ b/net/rds/tcp.c
91039 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
91040 int val = 1;
91041
91042 set_fs(KERNEL_DS);
91043 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
91044 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
91045 sizeof(val));
91046 set_fs(oldfs);
91047 }
91048 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
91049 index 81cf5a4..b5826ff 100644
91050 --- a/net/rds/tcp_send.c
91051 +++ b/net/rds/tcp_send.c
91052 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
91053
91054 oldfs = get_fs();
91055 set_fs(KERNEL_DS);
91056 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
91057 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
91058 sizeof(val));
91059 set_fs(oldfs);
91060 }
91061 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
91062 index e61aa60..f07cc89 100644
91063 --- a/net/rxrpc/af_rxrpc.c
91064 +++ b/net/rxrpc/af_rxrpc.c
91065 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
91066 __be32 rxrpc_epoch;
91067
91068 /* current debugging ID */
91069 -atomic_t rxrpc_debug_id;
91070 +atomic_unchecked_t rxrpc_debug_id;
91071
91072 /* count of skbs currently in use */
91073 atomic_t rxrpc_n_skbs;
91074 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
91075 index e4d9cbc..b229649 100644
91076 --- a/net/rxrpc/ar-ack.c
91077 +++ b/net/rxrpc/ar-ack.c
91078 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
91079
91080 _enter("{%d,%d,%d,%d},",
91081 call->acks_hard, call->acks_unacked,
91082 - atomic_read(&call->sequence),
91083 + atomic_read_unchecked(&call->sequence),
91084 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
91085
91086 stop = 0;
91087 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
91088
91089 /* each Tx packet has a new serial number */
91090 sp->hdr.serial =
91091 - htonl(atomic_inc_return(&call->conn->serial));
91092 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
91093
91094 hdr = (struct rxrpc_header *) txb->head;
91095 hdr->serial = sp->hdr.serial;
91096 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
91097 */
91098 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
91099 {
91100 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
91101 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
91102 }
91103
91104 /*
91105 @@ -629,7 +629,7 @@ process_further:
91106
91107 latest = ntohl(sp->hdr.serial);
91108 hard = ntohl(ack.firstPacket);
91109 - tx = atomic_read(&call->sequence);
91110 + tx = atomic_read_unchecked(&call->sequence);
91111
91112 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
91113 latest,
91114 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
91115 goto maybe_reschedule;
91116
91117 send_ACK_with_skew:
91118 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
91119 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
91120 ntohl(ack.serial));
91121 send_ACK:
91122 mtu = call->conn->trans->peer->if_mtu;
91123 @@ -1173,7 +1173,7 @@ send_ACK:
91124 ackinfo.rxMTU = htonl(5692);
91125 ackinfo.jumbo_max = htonl(4);
91126
91127 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
91128 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
91129 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
91130 ntohl(hdr.serial),
91131 ntohs(ack.maxSkew),
91132 @@ -1191,7 +1191,7 @@ send_ACK:
91133 send_message:
91134 _debug("send message");
91135
91136 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
91137 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
91138 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
91139 send_message_2:
91140
91141 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
91142 index a3bbb36..3341fb9 100644
91143 --- a/net/rxrpc/ar-call.c
91144 +++ b/net/rxrpc/ar-call.c
91145 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
91146 spin_lock_init(&call->lock);
91147 rwlock_init(&call->state_lock);
91148 atomic_set(&call->usage, 1);
91149 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
91150 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91151 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
91152
91153 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
91154 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
91155 index 4106ca9..a338d7a 100644
91156 --- a/net/rxrpc/ar-connection.c
91157 +++ b/net/rxrpc/ar-connection.c
91158 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
91159 rwlock_init(&conn->lock);
91160 spin_lock_init(&conn->state_lock);
91161 atomic_set(&conn->usage, 1);
91162 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
91163 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91164 conn->avail_calls = RXRPC_MAXCALLS;
91165 conn->size_align = 4;
91166 conn->header_size = sizeof(struct rxrpc_header);
91167 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
91168 index e7ed43a..6afa140 100644
91169 --- a/net/rxrpc/ar-connevent.c
91170 +++ b/net/rxrpc/ar-connevent.c
91171 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
91172
91173 len = iov[0].iov_len + iov[1].iov_len;
91174
91175 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
91176 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
91177 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
91178
91179 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
91180 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
91181 index 529572f..c758ca7 100644
91182 --- a/net/rxrpc/ar-input.c
91183 +++ b/net/rxrpc/ar-input.c
91184 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
91185 /* track the latest serial number on this connection for ACK packet
91186 * information */
91187 serial = ntohl(sp->hdr.serial);
91188 - hi_serial = atomic_read(&call->conn->hi_serial);
91189 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
91190 while (serial > hi_serial)
91191 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
91192 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
91193 serial);
91194
91195 /* request ACK generation for any ACK or DATA packet that requests
91196 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
91197 index a693aca..81e7293 100644
91198 --- a/net/rxrpc/ar-internal.h
91199 +++ b/net/rxrpc/ar-internal.h
91200 @@ -272,8 +272,8 @@ struct rxrpc_connection {
91201 int error; /* error code for local abort */
91202 int debug_id; /* debug ID for printks */
91203 unsigned int call_counter; /* call ID counter */
91204 - atomic_t serial; /* packet serial number counter */
91205 - atomic_t hi_serial; /* highest serial number received */
91206 + atomic_unchecked_t serial; /* packet serial number counter */
91207 + atomic_unchecked_t hi_serial; /* highest serial number received */
91208 u8 avail_calls; /* number of calls available */
91209 u8 size_align; /* data size alignment (for security) */
91210 u8 header_size; /* rxrpc + security header size */
91211 @@ -346,7 +346,7 @@ struct rxrpc_call {
91212 spinlock_t lock;
91213 rwlock_t state_lock; /* lock for state transition */
91214 atomic_t usage;
91215 - atomic_t sequence; /* Tx data packet sequence counter */
91216 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
91217 u32 abort_code; /* local/remote abort code */
91218 enum { /* current state of call */
91219 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
91220 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
91221 */
91222 extern atomic_t rxrpc_n_skbs;
91223 extern __be32 rxrpc_epoch;
91224 -extern atomic_t rxrpc_debug_id;
91225 +extern atomic_unchecked_t rxrpc_debug_id;
91226 extern struct workqueue_struct *rxrpc_workqueue;
91227
91228 /*
91229 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
91230 index 87f7135..74d3703 100644
91231 --- a/net/rxrpc/ar-local.c
91232 +++ b/net/rxrpc/ar-local.c
91233 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
91234 spin_lock_init(&local->lock);
91235 rwlock_init(&local->services_lock);
91236 atomic_set(&local->usage, 1);
91237 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
91238 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91239 memcpy(&local->srx, srx, sizeof(*srx));
91240 }
91241
91242 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
91243 index e1ac183..b43e10e 100644
91244 --- a/net/rxrpc/ar-output.c
91245 +++ b/net/rxrpc/ar-output.c
91246 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
91247 sp->hdr.cid = call->cid;
91248 sp->hdr.callNumber = call->call_id;
91249 sp->hdr.seq =
91250 - htonl(atomic_inc_return(&call->sequence));
91251 + htonl(atomic_inc_return_unchecked(&call->sequence));
91252 sp->hdr.serial =
91253 - htonl(atomic_inc_return(&conn->serial));
91254 + htonl(atomic_inc_return_unchecked(&conn->serial));
91255 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
91256 sp->hdr.userStatus = 0;
91257 sp->hdr.securityIndex = conn->security_ix;
91258 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
91259 index bebaa43..2644591 100644
91260 --- a/net/rxrpc/ar-peer.c
91261 +++ b/net/rxrpc/ar-peer.c
91262 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
91263 INIT_LIST_HEAD(&peer->error_targets);
91264 spin_lock_init(&peer->lock);
91265 atomic_set(&peer->usage, 1);
91266 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
91267 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91268 memcpy(&peer->srx, srx, sizeof(*srx));
91269
91270 rxrpc_assess_MTU_size(peer);
91271 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
91272 index 38047f7..9f48511 100644
91273 --- a/net/rxrpc/ar-proc.c
91274 +++ b/net/rxrpc/ar-proc.c
91275 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
91276 atomic_read(&conn->usage),
91277 rxrpc_conn_states[conn->state],
91278 key_serial(conn->key),
91279 - atomic_read(&conn->serial),
91280 - atomic_read(&conn->hi_serial));
91281 + atomic_read_unchecked(&conn->serial),
91282 + atomic_read_unchecked(&conn->hi_serial));
91283
91284 return 0;
91285 }
91286 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
91287 index 92df566..87ec1bf 100644
91288 --- a/net/rxrpc/ar-transport.c
91289 +++ b/net/rxrpc/ar-transport.c
91290 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
91291 spin_lock_init(&trans->client_lock);
91292 rwlock_init(&trans->conn_lock);
91293 atomic_set(&trans->usage, 1);
91294 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
91295 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91296
91297 if (peer->srx.transport.family == AF_INET) {
91298 switch (peer->srx.transport_type) {
91299 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
91300 index f226709..0e735a8 100644
91301 --- a/net/rxrpc/rxkad.c
91302 +++ b/net/rxrpc/rxkad.c
91303 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
91304
91305 len = iov[0].iov_len + iov[1].iov_len;
91306
91307 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
91308 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
91309 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
91310
91311 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
91312 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
91313
91314 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
91315
91316 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
91317 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
91318 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
91319
91320 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
91321 diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
91322 index ca8e0a5..1f9c314 100644
91323 --- a/net/sched/sch_atm.c
91324 +++ b/net/sched/sch_atm.c
91325 @@ -605,6 +605,7 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
91326 struct sockaddr_atmpvc pvc;
91327 int state;
91328
91329 + memset(&pvc, 0, sizeof(pvc));
91330 pvc.sap_family = AF_ATMPVC;
91331 pvc.sap_addr.itf = flow->vcc->dev ? flow->vcc->dev->number : -1;
91332 pvc.sap_addr.vpi = flow->vcc->vpi;
91333 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
91334 index 391a245..296b3d7 100644
91335 --- a/net/sctp/ipv6.c
91336 +++ b/net/sctp/ipv6.c
91337 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
91338 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
91339 };
91340
91341 -static struct sctp_af sctp_af_inet6 = {
91342 +static struct sctp_af sctp_af_inet6 __read_only = {
91343 .sa_family = AF_INET6,
91344 .sctp_xmit = sctp_v6_xmit,
91345 .setsockopt = ipv6_setsockopt,
91346 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
91347 #endif
91348 };
91349
91350 -static struct sctp_pf sctp_pf_inet6 = {
91351 +static struct sctp_pf sctp_pf_inet6 __read_only = {
91352 .event_msgname = sctp_inet6_event_msgname,
91353 .skb_msgname = sctp_inet6_skb_msgname,
91354 .af_supported = sctp_inet6_af_supported,
91355 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
91356
91357 void sctp_v6_pf_exit(void)
91358 {
91359 - list_del(&sctp_af_inet6.list);
91360 + pax_list_del(&sctp_af_inet6.list);
91361 }
91362
91363 /* Initialize IPv6 support and register with socket layer. */
91364 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
91365 index 4e45ee3..e66a031 100644
91366 --- a/net/sctp/proc.c
91367 +++ b/net/sctp/proc.c
91368 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
91369 seq_printf(seq,
91370 "%8pK %8pK %-3d %-3d %-2d %-4d "
91371 "%4d %8d %8d %7d %5lu %-5d %5d ",
91372 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
91373 + assoc, sk,
91374 + sctp_sk(sk)->type, sk->sk_state,
91375 assoc->state, hash,
91376 assoc->assoc_id,
91377 assoc->sndbuf_used,
91378 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
91379 index eaee00c..97c0afd 100644
91380 --- a/net/sctp/protocol.c
91381 +++ b/net/sctp/protocol.c
91382 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
91383 return 0;
91384 }
91385
91386 + pax_open_kernel();
91387 INIT_LIST_HEAD(&af->list);
91388 - list_add_tail(&af->list, &sctp_address_families);
91389 + pax_close_kernel();
91390 + pax_list_add_tail(&af->list, &sctp_address_families);
91391 return 1;
91392 }
91393
91394 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
91395
91396 static struct sctp_af sctp_af_inet;
91397
91398 -static struct sctp_pf sctp_pf_inet = {
91399 +static struct sctp_pf sctp_pf_inet __read_only = {
91400 .event_msgname = sctp_inet_event_msgname,
91401 .skb_msgname = sctp_inet_skb_msgname,
91402 .af_supported = sctp_inet_af_supported,
91403 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
91404 };
91405
91406 /* IPv4 address related functions. */
91407 -static struct sctp_af sctp_af_inet = {
91408 +static struct sctp_af sctp_af_inet __read_only = {
91409 .sa_family = AF_INET,
91410 .sctp_xmit = sctp_v4_xmit,
91411 .setsockopt = ip_setsockopt,
91412 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
91413
91414 static void sctp_v4_pf_exit(void)
91415 {
91416 - list_del(&sctp_af_inet.list);
91417 + pax_list_del(&sctp_af_inet.list);
91418 }
91419
91420 static int sctp_v4_protosw_init(void)
91421 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
91422 index 8aab894..f6b7e7d 100644
91423 --- a/net/sctp/sm_sideeffect.c
91424 +++ b/net/sctp/sm_sideeffect.c
91425 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
91426 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
91427 }
91428
91429 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
91430 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
91431 NULL,
91432 sctp_generate_t1_cookie_event,
91433 sctp_generate_t1_init_event,
91434 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
91435 index 6abb1ca..1678f8b 100644
91436 --- a/net/sctp/socket.c
91437 +++ b/net/sctp/socket.c
91438 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
91439 {
91440 struct sctp_association *asoc;
91441 struct sctp_ulpevent *event;
91442 + struct sctp_event_subscribe subscribe;
91443
91444 if (optlen > sizeof(struct sctp_event_subscribe))
91445 return -EINVAL;
91446 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
91447 + if (copy_from_user(&subscribe, optval, optlen))
91448 return -EFAULT;
91449 + sctp_sk(sk)->subscribe = subscribe;
91450
91451 /*
91452 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
91453 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
91454 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
91455 int __user *optlen)
91456 {
91457 + struct sctp_event_subscribe subscribe;
91458 +
91459 if (len <= 0)
91460 return -EINVAL;
91461 if (len > sizeof(struct sctp_event_subscribe))
91462 len = sizeof(struct sctp_event_subscribe);
91463 if (put_user(len, optlen))
91464 return -EFAULT;
91465 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
91466 + subscribe = sctp_sk(sk)->subscribe;
91467 + if (copy_to_user(optval, &subscribe, len))
91468 return -EFAULT;
91469 return 0;
91470 }
91471 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
91472 */
91473 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
91474 {
91475 + __u32 autoclose;
91476 +
91477 /* Applicable to UDP-style socket only */
91478 if (sctp_style(sk, TCP))
91479 return -EOPNOTSUPP;
91480 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
91481 len = sizeof(int);
91482 if (put_user(len, optlen))
91483 return -EFAULT;
91484 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
91485 + autoclose = sctp_sk(sk)->autoclose;
91486 + if (copy_to_user(optval, &autoclose, sizeof(int)))
91487 return -EFAULT;
91488 return 0;
91489 }
91490 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
91491 */
91492 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
91493 {
91494 + struct sctp_initmsg initmsg;
91495 +
91496 if (len < sizeof(struct sctp_initmsg))
91497 return -EINVAL;
91498 len = sizeof(struct sctp_initmsg);
91499 if (put_user(len, optlen))
91500 return -EFAULT;
91501 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
91502 + initmsg = sctp_sk(sk)->initmsg;
91503 + if (copy_to_user(optval, &initmsg, len))
91504 return -EFAULT;
91505 return 0;
91506 }
91507 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
91508 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
91509 if (space_left < addrlen)
91510 return -ENOMEM;
91511 + if (addrlen > sizeof(temp) || addrlen < 0)
91512 + return -EFAULT;
91513 if (copy_to_user(to, &temp, addrlen))
91514 return -EFAULT;
91515 to += addrlen;
91516 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
91517 index bf3c6e8..376d8d0 100644
91518 --- a/net/sctp/sysctl.c
91519 +++ b/net/sctp/sysctl.c
91520 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
91521 {
91522 struct net *net = current->nsproxy->net_ns;
91523 char tmp[8];
91524 - ctl_table tbl;
91525 + ctl_table_no_const tbl;
91526 int ret;
91527 int changed = 0;
91528 char *none = "none";
91529 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
91530
91531 int sctp_sysctl_net_register(struct net *net)
91532 {
91533 - struct ctl_table *table;
91534 + ctl_table_no_const *table;
91535 int i;
91536
91537 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
91538 diff --git a/net/socket.c b/net/socket.c
91539 index 4ca1526..df83e47 100644
91540 --- a/net/socket.c
91541 +++ b/net/socket.c
91542 @@ -88,6 +88,7 @@
91543 #include <linux/magic.h>
91544 #include <linux/slab.h>
91545 #include <linux/xattr.h>
91546 +#include <linux/in.h>
91547
91548 #include <asm/uaccess.h>
91549 #include <asm/unistd.h>
91550 @@ -105,6 +106,8 @@
91551 #include <linux/sockios.h>
91552 #include <linux/atalk.h>
91553
91554 +#include <linux/grsock.h>
91555 +
91556 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
91557 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
91558 unsigned long nr_segs, loff_t pos);
91559 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
91560 &sockfs_dentry_operations, SOCKFS_MAGIC);
91561 }
91562
91563 -static struct vfsmount *sock_mnt __read_mostly;
91564 +struct vfsmount *sock_mnt __read_mostly;
91565
91566 static struct file_system_type sock_fs_type = {
91567 .name = "sockfs",
91568 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
91569 return -EAFNOSUPPORT;
91570 if (type < 0 || type >= SOCK_MAX)
91571 return -EINVAL;
91572 + if (protocol < 0)
91573 + return -EINVAL;
91574
91575 /* Compatibility.
91576
91577 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
91578 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
91579 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
91580
91581 + if(!gr_search_socket(family, type, protocol)) {
91582 + retval = -EACCES;
91583 + goto out;
91584 + }
91585 +
91586 + if (gr_handle_sock_all(family, type, protocol)) {
91587 + retval = -EACCES;
91588 + goto out;
91589 + }
91590 +
91591 retval = sock_create(family, type, protocol, &sock);
91592 if (retval < 0)
91593 goto out;
91594 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
91595 if (sock) {
91596 err = move_addr_to_kernel(umyaddr, addrlen, &address);
91597 if (err >= 0) {
91598 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
91599 + err = -EACCES;
91600 + goto error;
91601 + }
91602 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
91603 + if (err)
91604 + goto error;
91605 +
91606 err = security_socket_bind(sock,
91607 (struct sockaddr *)&address,
91608 addrlen);
91609 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
91610 (struct sockaddr *)
91611 &address, addrlen);
91612 }
91613 +error:
91614 fput_light(sock->file, fput_needed);
91615 }
91616 return err;
91617 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
91618 if ((unsigned int)backlog > somaxconn)
91619 backlog = somaxconn;
91620
91621 + if (gr_handle_sock_server_other(sock->sk)) {
91622 + err = -EPERM;
91623 + goto error;
91624 + }
91625 +
91626 + err = gr_search_listen(sock);
91627 + if (err)
91628 + goto error;
91629 +
91630 err = security_socket_listen(sock, backlog);
91631 if (!err)
91632 err = sock->ops->listen(sock, backlog);
91633
91634 +error:
91635 fput_light(sock->file, fput_needed);
91636 }
91637 return err;
91638 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
91639 newsock->type = sock->type;
91640 newsock->ops = sock->ops;
91641
91642 + if (gr_handle_sock_server_other(sock->sk)) {
91643 + err = -EPERM;
91644 + sock_release(newsock);
91645 + goto out_put;
91646 + }
91647 +
91648 + err = gr_search_accept(sock);
91649 + if (err) {
91650 + sock_release(newsock);
91651 + goto out_put;
91652 + }
91653 +
91654 /*
91655 * We don't need try_module_get here, as the listening socket (sock)
91656 * has the protocol module (sock->ops->owner) held.
91657 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
91658 fd_install(newfd, newfile);
91659 err = newfd;
91660
91661 + gr_attach_curr_ip(newsock->sk);
91662 +
91663 out_put:
91664 fput_light(sock->file, fput_needed);
91665 out:
91666 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
91667 int, addrlen)
91668 {
91669 struct socket *sock;
91670 + struct sockaddr *sck;
91671 struct sockaddr_storage address;
91672 int err, fput_needed;
91673
91674 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
91675 if (err < 0)
91676 goto out_put;
91677
91678 + sck = (struct sockaddr *)&address;
91679 +
91680 + if (gr_handle_sock_client(sck)) {
91681 + err = -EACCES;
91682 + goto out_put;
91683 + }
91684 +
91685 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
91686 + if (err)
91687 + goto out_put;
91688 +
91689 err =
91690 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
91691 if (err)
91692 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
91693 * the protocol.
91694 */
91695
91696 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
91697 +
91698 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
91699 unsigned int, flags, struct sockaddr __user *, addr,
91700 int, addr_len)
91701 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
91702 struct socket *sock;
91703 struct iovec iov;
91704 struct msghdr msg;
91705 - struct sockaddr_storage address;
91706 + struct sockaddr_storage address = { };
91707 int err, err2;
91708 int fput_needed;
91709
91710 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
91711 * checking falls down on this.
91712 */
91713 if (copy_from_user(ctl_buf,
91714 - (void __user __force *)msg_sys->msg_control,
91715 + (void __force_user *)msg_sys->msg_control,
91716 ctl_len))
91717 goto out_freectl;
91718 msg_sys->msg_control = ctl_buf;
91719 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
91720 int err, total_len, len;
91721
91722 /* kernel mode address */
91723 - struct sockaddr_storage addr;
91724 + struct sockaddr_storage addr = { };
91725
91726 /* user mode address pointers */
91727 struct sockaddr __user *uaddr;
91728 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
91729 * kernel msghdr to use the kernel address space)
91730 */
91731
91732 - uaddr = (__force void __user *)msg_sys->msg_name;
91733 + uaddr = (void __force_user *)msg_sys->msg_name;
91734 uaddr_len = COMPAT_NAMELEN(msg);
91735 if (MSG_CMSG_COMPAT & flags) {
91736 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
91737 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
91738 old_fs = get_fs();
91739 set_fs(KERNEL_DS);
91740 err = dev_ioctl(net, cmd,
91741 - (struct ifreq __user __force *) &kifr);
91742 + (struct ifreq __force_user *) &kifr);
91743 set_fs(old_fs);
91744
91745 return err;
91746 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
91747
91748 old_fs = get_fs();
91749 set_fs(KERNEL_DS);
91750 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
91751 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
91752 set_fs(old_fs);
91753
91754 if (cmd == SIOCGIFMAP && !err) {
91755 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
91756 ret |= __get_user(rtdev, &(ur4->rt_dev));
91757 if (rtdev) {
91758 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
91759 - r4.rt_dev = (char __user __force *)devname;
91760 + r4.rt_dev = (char __force_user *)devname;
91761 devname[15] = 0;
91762 } else
91763 r4.rt_dev = NULL;
91764 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
91765 int __user *uoptlen;
91766 int err;
91767
91768 - uoptval = (char __user __force *) optval;
91769 - uoptlen = (int __user __force *) optlen;
91770 + uoptval = (char __force_user *) optval;
91771 + uoptlen = (int __force_user *) optlen;
91772
91773 set_fs(KERNEL_DS);
91774 if (level == SOL_SOCKET)
91775 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
91776 char __user *uoptval;
91777 int err;
91778
91779 - uoptval = (char __user __force *) optval;
91780 + uoptval = (char __force_user *) optval;
91781
91782 set_fs(KERNEL_DS);
91783 if (level == SOL_SOCKET)
91784 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
91785 index 5a750b9..ca5d7af 100644
91786 --- a/net/sunrpc/clnt.c
91787 +++ b/net/sunrpc/clnt.c
91788 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
91789 (RPC_IS_ASYNC(task) ? "async" : "sync"));
91790
91791 /* Increment call count */
91792 - task->tk_msg.rpc_proc->p_count++;
91793 + pax_open_kernel();
91794 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
91795 + pax_close_kernel();
91796 clnt->cl_stats->rpccnt++;
91797 task->tk_action = call_reserve;
91798 }
91799 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
91800 index 5356b12..c0f4c29 100644
91801 --- a/net/sunrpc/sched.c
91802 +++ b/net/sunrpc/sched.c
91803 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
91804 #ifdef RPC_DEBUG
91805 static void rpc_task_set_debuginfo(struct rpc_task *task)
91806 {
91807 - static atomic_t rpc_pid;
91808 + static atomic_unchecked_t rpc_pid;
91809
91810 - task->tk_pid = atomic_inc_return(&rpc_pid);
91811 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
91812 }
91813 #else
91814 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
91815 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
91816 index 89a588b..678ed90 100644
91817 --- a/net/sunrpc/svc.c
91818 +++ b/net/sunrpc/svc.c
91819 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
91820
91821 __module_get(serv->sv_module);
91822 task = kthread_create_on_node(serv->sv_function, rqstp,
91823 - node, serv->sv_name);
91824 + node, "%s", serv->sv_name);
91825 if (IS_ERR(task)) {
91826 error = PTR_ERR(task);
91827 module_put(serv->sv_module);
91828 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
91829 svc_putnl(resv, RPC_SUCCESS);
91830
91831 /* Bump per-procedure stats counter */
91832 - procp->pc_count++;
91833 + pax_open_kernel();
91834 + (*(unsigned int *)&procp->pc_count)++;
91835 + pax_close_kernel();
91836
91837 /* Initialize storage for argp and resp */
91838 memset(rqstp->rq_argp, 0, procp->pc_argsize);
91839 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
91840 index 8343737..677025e 100644
91841 --- a/net/sunrpc/xprtrdma/svc_rdma.c
91842 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
91843 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
91844 static unsigned int min_max_inline = 4096;
91845 static unsigned int max_max_inline = 65536;
91846
91847 -atomic_t rdma_stat_recv;
91848 -atomic_t rdma_stat_read;
91849 -atomic_t rdma_stat_write;
91850 -atomic_t rdma_stat_sq_starve;
91851 -atomic_t rdma_stat_rq_starve;
91852 -atomic_t rdma_stat_rq_poll;
91853 -atomic_t rdma_stat_rq_prod;
91854 -atomic_t rdma_stat_sq_poll;
91855 -atomic_t rdma_stat_sq_prod;
91856 +atomic_unchecked_t rdma_stat_recv;
91857 +atomic_unchecked_t rdma_stat_read;
91858 +atomic_unchecked_t rdma_stat_write;
91859 +atomic_unchecked_t rdma_stat_sq_starve;
91860 +atomic_unchecked_t rdma_stat_rq_starve;
91861 +atomic_unchecked_t rdma_stat_rq_poll;
91862 +atomic_unchecked_t rdma_stat_rq_prod;
91863 +atomic_unchecked_t rdma_stat_sq_poll;
91864 +atomic_unchecked_t rdma_stat_sq_prod;
91865
91866 /* Temporary NFS request map and context caches */
91867 struct kmem_cache *svc_rdma_map_cachep;
91868 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
91869 len -= *ppos;
91870 if (len > *lenp)
91871 len = *lenp;
91872 - if (len && copy_to_user(buffer, str_buf, len))
91873 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
91874 return -EFAULT;
91875 *lenp = len;
91876 *ppos += len;
91877 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
91878 {
91879 .procname = "rdma_stat_read",
91880 .data = &rdma_stat_read,
91881 - .maxlen = sizeof(atomic_t),
91882 + .maxlen = sizeof(atomic_unchecked_t),
91883 .mode = 0644,
91884 .proc_handler = read_reset_stat,
91885 },
91886 {
91887 .procname = "rdma_stat_recv",
91888 .data = &rdma_stat_recv,
91889 - .maxlen = sizeof(atomic_t),
91890 + .maxlen = sizeof(atomic_unchecked_t),
91891 .mode = 0644,
91892 .proc_handler = read_reset_stat,
91893 },
91894 {
91895 .procname = "rdma_stat_write",
91896 .data = &rdma_stat_write,
91897 - .maxlen = sizeof(atomic_t),
91898 + .maxlen = sizeof(atomic_unchecked_t),
91899 .mode = 0644,
91900 .proc_handler = read_reset_stat,
91901 },
91902 {
91903 .procname = "rdma_stat_sq_starve",
91904 .data = &rdma_stat_sq_starve,
91905 - .maxlen = sizeof(atomic_t),
91906 + .maxlen = sizeof(atomic_unchecked_t),
91907 .mode = 0644,
91908 .proc_handler = read_reset_stat,
91909 },
91910 {
91911 .procname = "rdma_stat_rq_starve",
91912 .data = &rdma_stat_rq_starve,
91913 - .maxlen = sizeof(atomic_t),
91914 + .maxlen = sizeof(atomic_unchecked_t),
91915 .mode = 0644,
91916 .proc_handler = read_reset_stat,
91917 },
91918 {
91919 .procname = "rdma_stat_rq_poll",
91920 .data = &rdma_stat_rq_poll,
91921 - .maxlen = sizeof(atomic_t),
91922 + .maxlen = sizeof(atomic_unchecked_t),
91923 .mode = 0644,
91924 .proc_handler = read_reset_stat,
91925 },
91926 {
91927 .procname = "rdma_stat_rq_prod",
91928 .data = &rdma_stat_rq_prod,
91929 - .maxlen = sizeof(atomic_t),
91930 + .maxlen = sizeof(atomic_unchecked_t),
91931 .mode = 0644,
91932 .proc_handler = read_reset_stat,
91933 },
91934 {
91935 .procname = "rdma_stat_sq_poll",
91936 .data = &rdma_stat_sq_poll,
91937 - .maxlen = sizeof(atomic_t),
91938 + .maxlen = sizeof(atomic_unchecked_t),
91939 .mode = 0644,
91940 .proc_handler = read_reset_stat,
91941 },
91942 {
91943 .procname = "rdma_stat_sq_prod",
91944 .data = &rdma_stat_sq_prod,
91945 - .maxlen = sizeof(atomic_t),
91946 + .maxlen = sizeof(atomic_unchecked_t),
91947 .mode = 0644,
91948 .proc_handler = read_reset_stat,
91949 },
91950 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91951 index 0ce7552..d074459 100644
91952 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91953 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91954 @@ -501,7 +501,7 @@ next_sge:
91955 svc_rdma_put_context(ctxt, 0);
91956 goto out;
91957 }
91958 - atomic_inc(&rdma_stat_read);
91959 + atomic_inc_unchecked(&rdma_stat_read);
91960
91961 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
91962 chl_map->ch[ch_no].count -= read_wr.num_sge;
91963 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91964 dto_q);
91965 list_del_init(&ctxt->dto_q);
91966 } else {
91967 - atomic_inc(&rdma_stat_rq_starve);
91968 + atomic_inc_unchecked(&rdma_stat_rq_starve);
91969 clear_bit(XPT_DATA, &xprt->xpt_flags);
91970 ctxt = NULL;
91971 }
91972 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91973 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
91974 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
91975 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
91976 - atomic_inc(&rdma_stat_recv);
91977 + atomic_inc_unchecked(&rdma_stat_recv);
91978
91979 /* Build up the XDR from the receive buffers. */
91980 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
91981 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91982 index c1d124d..acfc59e 100644
91983 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91984 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91985 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
91986 write_wr.wr.rdma.remote_addr = to;
91987
91988 /* Post It */
91989 - atomic_inc(&rdma_stat_write);
91990 + atomic_inc_unchecked(&rdma_stat_write);
91991 if (svc_rdma_send(xprt, &write_wr))
91992 goto err;
91993 return 0;
91994 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91995 index 62e4f9b..dd3f2d7 100644
91996 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
91997 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91998 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91999 return;
92000
92001 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
92002 - atomic_inc(&rdma_stat_rq_poll);
92003 + atomic_inc_unchecked(&rdma_stat_rq_poll);
92004
92005 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
92006 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
92007 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
92008 }
92009
92010 if (ctxt)
92011 - atomic_inc(&rdma_stat_rq_prod);
92012 + atomic_inc_unchecked(&rdma_stat_rq_prod);
92013
92014 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
92015 /*
92016 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
92017 return;
92018
92019 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
92020 - atomic_inc(&rdma_stat_sq_poll);
92021 + atomic_inc_unchecked(&rdma_stat_sq_poll);
92022 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
92023 if (wc.status != IB_WC_SUCCESS)
92024 /* Close the transport */
92025 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
92026 }
92027
92028 if (ctxt)
92029 - atomic_inc(&rdma_stat_sq_prod);
92030 + atomic_inc_unchecked(&rdma_stat_sq_prod);
92031 }
92032
92033 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
92034 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
92035 spin_lock_bh(&xprt->sc_lock);
92036 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
92037 spin_unlock_bh(&xprt->sc_lock);
92038 - atomic_inc(&rdma_stat_sq_starve);
92039 + atomic_inc_unchecked(&rdma_stat_sq_starve);
92040
92041 /* See if we can opportunistically reap SQ WR to make room */
92042 sq_cq_reap(xprt);
92043 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
92044 index 9bc6db0..47ac8c0 100644
92045 --- a/net/sysctl_net.c
92046 +++ b/net/sysctl_net.c
92047 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
92048 kgid_t root_gid = make_kgid(net->user_ns, 0);
92049
92050 /* Allow network administrator to have same access as root. */
92051 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
92052 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
92053 uid_eq(root_uid, current_uid())) {
92054 int mode = (table->mode >> 6) & 7;
92055 return (mode << 6) | (mode << 3) | mode;
92056 diff --git a/net/tipc/link.c b/net/tipc/link.c
92057 index a80feee..2bbbe70 100644
92058 --- a/net/tipc/link.c
92059 +++ b/net/tipc/link.c
92060 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
92061 struct tipc_msg fragm_hdr;
92062 struct sk_buff *buf, *buf_chain, *prev;
92063 u32 fragm_crs, fragm_rest, hsz, sect_rest;
92064 - const unchar *sect_crs;
92065 + const unchar __user *sect_crs;
92066 int curr_sect;
92067 u32 fragm_no;
92068
92069 @@ -1242,7 +1242,7 @@ again:
92070
92071 if (!sect_rest) {
92072 sect_rest = msg_sect[++curr_sect].iov_len;
92073 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
92074 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
92075 }
92076
92077 if (sect_rest < fragm_rest)
92078 @@ -1261,7 +1261,7 @@ error:
92079 }
92080 } else
92081 skb_copy_to_linear_data_offset(buf, fragm_crs,
92082 - sect_crs, sz);
92083 + (const void __force_kernel *)sect_crs, sz);
92084 sect_crs += sz;
92085 sect_rest -= sz;
92086 fragm_crs += sz;
92087 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
92088 index f2db8a8..9245aa4 100644
92089 --- a/net/tipc/msg.c
92090 +++ b/net/tipc/msg.c
92091 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
92092 msg_sect[cnt].iov_len);
92093 else
92094 skb_copy_to_linear_data_offset(*buf, pos,
92095 - msg_sect[cnt].iov_base,
92096 + (const void __force_kernel *)msg_sect[cnt].iov_base,
92097 msg_sect[cnt].iov_len);
92098 pos += msg_sect[cnt].iov_len;
92099 }
92100 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
92101 index 6b42d47..2ac24d5 100644
92102 --- a/net/tipc/subscr.c
92103 +++ b/net/tipc/subscr.c
92104 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
92105 {
92106 struct iovec msg_sect;
92107
92108 - msg_sect.iov_base = (void *)&sub->evt;
92109 + msg_sect.iov_base = (void __force_user *)&sub->evt;
92110 msg_sect.iov_len = sizeof(struct tipc_event);
92111
92112 sub->evt.event = htohl(event, sub->swap);
92113 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
92114 index 826e099..4fa8c93 100644
92115 --- a/net/unix/af_unix.c
92116 +++ b/net/unix/af_unix.c
92117 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
92118 err = -ECONNREFUSED;
92119 if (!S_ISSOCK(inode->i_mode))
92120 goto put_fail;
92121 +
92122 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
92123 + err = -EACCES;
92124 + goto put_fail;
92125 + }
92126 +
92127 u = unix_find_socket_byinode(inode);
92128 if (!u)
92129 goto put_fail;
92130 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
92131 if (u) {
92132 struct dentry *dentry;
92133 dentry = unix_sk(u)->path.dentry;
92134 +
92135 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
92136 + err = -EPERM;
92137 + sock_put(u);
92138 + goto fail;
92139 + }
92140 +
92141 if (dentry)
92142 touch_atime(&unix_sk(u)->path);
92143 } else
92144 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
92145 */
92146 err = security_path_mknod(&path, dentry, mode, 0);
92147 if (!err) {
92148 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
92149 + err = -EACCES;
92150 + goto out;
92151 + }
92152 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
92153 if (!err) {
92154 res->mnt = mntget(path.mnt);
92155 res->dentry = dget(dentry);
92156 + gr_handle_create(dentry, path.mnt);
92157 }
92158 }
92159 +out:
92160 done_path_create(&path, dentry);
92161 return err;
92162 }
92163 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
92164 seq_puts(seq, "Num RefCount Protocol Flags Type St "
92165 "Inode Path\n");
92166 else {
92167 - struct sock *s = v;
92168 + struct sock *s = v, *peer;
92169 struct unix_sock *u = unix_sk(s);
92170 unix_state_lock(s);
92171 + peer = unix_peer(s);
92172 + unix_state_unlock(s);
92173 +
92174 + unix_state_double_lock(s, peer);
92175
92176 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
92177 s,
92178 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
92179 }
92180 for ( ; i < len; i++)
92181 seq_putc(seq, u->addr->name->sun_path[i]);
92182 - }
92183 - unix_state_unlock(s);
92184 + } else if (peer)
92185 + seq_printf(seq, " P%lu", sock_i_ino(peer));
92186 +
92187 + unix_state_double_unlock(s, peer);
92188 seq_putc(seq, '\n');
92189 }
92190
92191 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
92192 index 8800604..0526440 100644
92193 --- a/net/unix/sysctl_net_unix.c
92194 +++ b/net/unix/sysctl_net_unix.c
92195 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
92196
92197 int __net_init unix_sysctl_register(struct net *net)
92198 {
92199 - struct ctl_table *table;
92200 + ctl_table_no_const *table;
92201
92202 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
92203 if (table == NULL)
92204 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
92205 index c8717c1..08539f5 100644
92206 --- a/net/wireless/wext-core.c
92207 +++ b/net/wireless/wext-core.c
92208 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
92209 */
92210
92211 /* Support for very large requests */
92212 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
92213 - (user_length > descr->max_tokens)) {
92214 + if (user_length > descr->max_tokens) {
92215 /* Allow userspace to GET more than max so
92216 * we can support any size GET requests.
92217 * There is still a limit : -ENOMEM.
92218 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
92219 }
92220 }
92221
92222 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
92223 - /*
92224 - * If this is a GET, but not NOMAX, it means that the extra
92225 - * data is not bounded by userspace, but by max_tokens. Thus
92226 - * set the length to max_tokens. This matches the extra data
92227 - * allocation.
92228 - * The driver should fill it with the number of tokens it
92229 - * provided, and it may check iwp->length rather than having
92230 - * knowledge of max_tokens. If the driver doesn't change the
92231 - * iwp->length, this ioctl just copies back max_token tokens
92232 - * filled with zeroes. Hopefully the driver isn't claiming
92233 - * them to be valid data.
92234 - */
92235 - iwp->length = descr->max_tokens;
92236 - }
92237 -
92238 err = handler(dev, info, (union iwreq_data *) iwp, extra);
92239
92240 iwp->length += essid_compat;
92241 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
92242 index ea970b8..c68edb9f 100644
92243 --- a/net/xfrm/xfrm_policy.c
92244 +++ b/net/xfrm/xfrm_policy.c
92245 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
92246 {
92247 policy->walk.dead = 1;
92248
92249 - atomic_inc(&policy->genid);
92250 + atomic_inc_unchecked(&policy->genid);
92251
92252 del_timer(&policy->polq.hold_timer);
92253 xfrm_queue_purge(&policy->polq.hold_queue);
92254 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
92255 hlist_add_head(&policy->bydst, chain);
92256 xfrm_pol_hold(policy);
92257 net->xfrm.policy_count[dir]++;
92258 - atomic_inc(&flow_cache_genid);
92259 + atomic_inc_unchecked(&flow_cache_genid);
92260 rt_genid_bump(net);
92261 if (delpol) {
92262 xfrm_policy_requeue(delpol, policy);
92263 @@ -1629,7 +1629,7 @@ free_dst:
92264 goto out;
92265 }
92266
92267 -static int inline
92268 +static inline int
92269 xfrm_dst_alloc_copy(void **target, const void *src, int size)
92270 {
92271 if (!*target) {
92272 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
92273 return 0;
92274 }
92275
92276 -static int inline
92277 +static inline int
92278 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
92279 {
92280 #ifdef CONFIG_XFRM_SUB_POLICY
92281 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
92282 #endif
92283 }
92284
92285 -static int inline
92286 +static inline int
92287 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
92288 {
92289 #ifdef CONFIG_XFRM_SUB_POLICY
92290 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
92291
92292 xdst->num_pols = num_pols;
92293 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
92294 - xdst->policy_genid = atomic_read(&pols[0]->genid);
92295 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
92296
92297 return xdst;
92298 }
92299 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
92300 if (xdst->xfrm_genid != dst->xfrm->genid)
92301 return 0;
92302 if (xdst->num_pols > 0 &&
92303 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
92304 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
92305 return 0;
92306
92307 mtu = dst_mtu(dst->child);
92308 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
92309 dst_ops->link_failure = xfrm_link_failure;
92310 if (likely(dst_ops->neigh_lookup == NULL))
92311 dst_ops->neigh_lookup = xfrm_neigh_lookup;
92312 - if (likely(afinfo->garbage_collect == NULL))
92313 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
92314 + if (likely(afinfo->garbage_collect == NULL)) {
92315 + pax_open_kernel();
92316 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
92317 + pax_close_kernel();
92318 + }
92319 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
92320 }
92321 spin_unlock(&xfrm_policy_afinfo_lock);
92322 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
92323 dst_ops->check = NULL;
92324 dst_ops->negative_advice = NULL;
92325 dst_ops->link_failure = NULL;
92326 - afinfo->garbage_collect = NULL;
92327 + pax_open_kernel();
92328 + *(void **)&afinfo->garbage_collect = NULL;
92329 + pax_close_kernel();
92330 }
92331 return err;
92332 }
92333 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
92334 sizeof(pol->xfrm_vec[i].saddr));
92335 pol->xfrm_vec[i].encap_family = mp->new_family;
92336 /* flush bundles */
92337 - atomic_inc(&pol->genid);
92338 + atomic_inc_unchecked(&pol->genid);
92339 }
92340 }
92341
92342 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
92343 index 78f66fa..9286768 100644
92344 --- a/net/xfrm/xfrm_state.c
92345 +++ b/net/xfrm/xfrm_state.c
92346 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
92347
92348 if (unlikely(afinfo == NULL))
92349 return -EAFNOSUPPORT;
92350 - typemap = afinfo->type_map;
92351 + typemap = (const struct xfrm_type **)afinfo->type_map;
92352 spin_lock_bh(&xfrm_type_lock);
92353
92354 - if (likely(typemap[type->proto] == NULL))
92355 + if (likely(typemap[type->proto] == NULL)) {
92356 + pax_open_kernel();
92357 typemap[type->proto] = type;
92358 - else
92359 + pax_close_kernel();
92360 + } else
92361 err = -EEXIST;
92362 spin_unlock_bh(&xfrm_type_lock);
92363 xfrm_state_put_afinfo(afinfo);
92364 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
92365
92366 if (unlikely(afinfo == NULL))
92367 return -EAFNOSUPPORT;
92368 - typemap = afinfo->type_map;
92369 + typemap = (const struct xfrm_type **)afinfo->type_map;
92370 spin_lock_bh(&xfrm_type_lock);
92371
92372 if (unlikely(typemap[type->proto] != type))
92373 err = -ENOENT;
92374 - else
92375 + else {
92376 + pax_open_kernel();
92377 typemap[type->proto] = NULL;
92378 + pax_close_kernel();
92379 + }
92380 spin_unlock_bh(&xfrm_type_lock);
92381 xfrm_state_put_afinfo(afinfo);
92382 return err;
92383 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
92384 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
92385 {
92386 struct xfrm_state_afinfo *afinfo;
92387 - const struct xfrm_type **typemap;
92388 const struct xfrm_type *type;
92389 int modload_attempted = 0;
92390
92391 @@ -222,9 +226,8 @@ retry:
92392 afinfo = xfrm_state_get_afinfo(family);
92393 if (unlikely(afinfo == NULL))
92394 return NULL;
92395 - typemap = afinfo->type_map;
92396
92397 - type = typemap[proto];
92398 + type = afinfo->type_map[proto];
92399 if (unlikely(type && !try_module_get(type->owner)))
92400 type = NULL;
92401 if (!type && !modload_attempted) {
92402 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
92403 return -EAFNOSUPPORT;
92404
92405 err = -EEXIST;
92406 - modemap = afinfo->mode_map;
92407 + modemap = (struct xfrm_mode **)afinfo->mode_map;
92408 spin_lock_bh(&xfrm_mode_lock);
92409 if (modemap[mode->encap])
92410 goto out;
92411 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
92412 if (!try_module_get(afinfo->owner))
92413 goto out;
92414
92415 - mode->afinfo = afinfo;
92416 + pax_open_kernel();
92417 + *(const void **)&mode->afinfo = afinfo;
92418 modemap[mode->encap] = mode;
92419 + pax_close_kernel();
92420 err = 0;
92421
92422 out:
92423 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
92424 return -EAFNOSUPPORT;
92425
92426 err = -ENOENT;
92427 - modemap = afinfo->mode_map;
92428 + modemap = (struct xfrm_mode **)afinfo->mode_map;
92429 spin_lock_bh(&xfrm_mode_lock);
92430 if (likely(modemap[mode->encap] == mode)) {
92431 + pax_open_kernel();
92432 modemap[mode->encap] = NULL;
92433 + pax_close_kernel();
92434 module_put(mode->afinfo->owner);
92435 err = 0;
92436 }
92437 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
92438 index 05a6e3d..6716ec9 100644
92439 --- a/net/xfrm/xfrm_sysctl.c
92440 +++ b/net/xfrm/xfrm_sysctl.c
92441 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
92442
92443 int __net_init xfrm_sysctl_init(struct net *net)
92444 {
92445 - struct ctl_table *table;
92446 + ctl_table_no_const *table;
92447
92448 __xfrm_sysctl_init(net);
92449
92450 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
92451 index d5d859c..781cbcb 100644
92452 --- a/scripts/Makefile.build
92453 +++ b/scripts/Makefile.build
92454 @@ -111,7 +111,7 @@ endif
92455 endif
92456
92457 # Do not include host rules unless needed
92458 -ifneq ($(hostprogs-y)$(hostprogs-m),)
92459 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
92460 include scripts/Makefile.host
92461 endif
92462
92463 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
92464 index 686cb0d..9d653bf 100644
92465 --- a/scripts/Makefile.clean
92466 +++ b/scripts/Makefile.clean
92467 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
92468 __clean-files := $(extra-y) $(always) \
92469 $(targets) $(clean-files) \
92470 $(host-progs) \
92471 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
92472 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
92473 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
92474
92475 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
92476
92477 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
92478 index 1ac414f..38575f7 100644
92479 --- a/scripts/Makefile.host
92480 +++ b/scripts/Makefile.host
92481 @@ -31,6 +31,8 @@
92482 # Note: Shared libraries consisting of C++ files are not supported
92483
92484 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
92485 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
92486 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
92487
92488 # C code
92489 # Executables compiled from a single .c file
92490 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
92491 # Shared libaries (only .c supported)
92492 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
92493 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
92494 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
92495 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
92496 # Remove .so files from "xxx-objs"
92497 host-cobjs := $(filter-out %.so,$(host-cobjs))
92498 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
92499
92500 -#Object (.o) files used by the shared libaries
92501 +# Object (.o) files used by the shared libaries
92502 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
92503 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
92504
92505 # output directory for programs/.o files
92506 # hostprogs-y := tools/build may have been specified. Retrieve directory
92507 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
92508 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
92509 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
92510 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
92511 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
92512 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
92513 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
92514 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
92515
92516 obj-dirs += $(host-objdirs)
92517 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
92518 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
92519 $(call if_changed_dep,host-cshobjs)
92520
92521 +# Compile .c file, create position independent .o file
92522 +# host-cxxshobjs -> .o
92523 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
92524 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
92525 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
92526 + $(call if_changed_dep,host-cxxshobjs)
92527 +
92528 # Link a shared library, based on position independent .o files
92529 # *.o -> .so shared library (host-cshlib)
92530 quiet_cmd_host-cshlib = HOSTLLD -shared $@
92531 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
92532 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
92533 $(call if_changed,host-cshlib)
92534
92535 +# Link a shared library, based on position independent .o files
92536 +# *.o -> .so shared library (host-cxxshlib)
92537 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
92538 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
92539 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
92540 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
92541 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
92542 + $(call if_changed,host-cxxshlib)
92543 +
92544 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
92545 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
92546 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
92547
92548 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
92549 index 078fe1d..fbdb363 100644
92550 --- a/scripts/basic/fixdep.c
92551 +++ b/scripts/basic/fixdep.c
92552 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
92553 /*
92554 * Lookup a value in the configuration string.
92555 */
92556 -static int is_defined_config(const char *name, int len, unsigned int hash)
92557 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
92558 {
92559 struct item *aux;
92560
92561 @@ -211,10 +211,10 @@ static void clear_config(void)
92562 /*
92563 * Record the use of a CONFIG_* word.
92564 */
92565 -static void use_config(const char *m, int slen)
92566 +static void use_config(const char *m, unsigned int slen)
92567 {
92568 unsigned int hash = strhash(m, slen);
92569 - int c, i;
92570 + unsigned int c, i;
92571
92572 if (is_defined_config(m, slen, hash))
92573 return;
92574 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
92575
92576 static void parse_config_file(const char *map, size_t len)
92577 {
92578 - const int *end = (const int *) (map + len);
92579 + const unsigned int *end = (const unsigned int *) (map + len);
92580 /* start at +1, so that p can never be < map */
92581 - const int *m = (const int *) map + 1;
92582 + const unsigned int *m = (const unsigned int *) map + 1;
92583 const char *p, *q;
92584
92585 for (; m < end; m++) {
92586 @@ -435,7 +435,7 @@ static void print_deps(void)
92587 static void traps(void)
92588 {
92589 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
92590 - int *p = (int *)test;
92591 + unsigned int *p = (unsigned int *)test;
92592
92593 if (*p != INT_CONF) {
92594 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
92595 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
92596 new file mode 100644
92597 index 0000000..5e0222d
92598 --- /dev/null
92599 +++ b/scripts/gcc-plugin.sh
92600 @@ -0,0 +1,17 @@
92601 +#!/bin/bash
92602 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
92603 +#include "gcc-plugin.h"
92604 +#include "tree.h"
92605 +#include "tm.h"
92606 +#include "rtl.h"
92607 +#ifdef ENABLE_BUILD_WITH_CXX
92608 +#warning $2
92609 +#else
92610 +#warning $1
92611 +#endif
92612 +EOF`
92613 +if [ $? -eq 0 ]
92614 +then
92615 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
92616 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
92617 +fi
92618 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
92619 index 643764f..6cc0137 100644
92620 --- a/scripts/headers_install.sh
92621 +++ b/scripts/headers_install.sh
92622 @@ -29,6 +29,7 @@ do
92623 FILE="$(basename "$i")"
92624 sed -r \
92625 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
92626 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
92627 -e 's/__attribute_const__([ \t]|$)/\1/g' \
92628 -e 's@^#include <linux/compiler.h>@@' \
92629 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
92630 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
92631 index 0149949..d482a0d 100644
92632 --- a/scripts/link-vmlinux.sh
92633 +++ b/scripts/link-vmlinux.sh
92634 @@ -158,7 +158,7 @@ else
92635 fi;
92636
92637 # final build of init/
92638 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
92639 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
92640
92641 kallsymso=""
92642 kallsyms_vmlinux=""
92643 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
92644 index 45f9a33..e4194b3 100644
92645 --- a/scripts/mod/file2alias.c
92646 +++ b/scripts/mod/file2alias.c
92647 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
92648 unsigned long size, unsigned long id_size,
92649 void *symval)
92650 {
92651 - int i;
92652 + unsigned int i;
92653
92654 if (size % id_size || size < id_size) {
92655 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
92656 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
92657 /* USB is special because the bcdDevice can be matched against a numeric range */
92658 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
92659 static void do_usb_entry(void *symval,
92660 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
92661 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
92662 unsigned char range_lo, unsigned char range_hi,
92663 unsigned char max, struct module *mod)
92664 {
92665 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
92666 {
92667 unsigned int devlo, devhi;
92668 unsigned char chi, clo, max;
92669 - int ndigits;
92670 + unsigned int ndigits;
92671
92672 DEF_FIELD(symval, usb_device_id, match_flags);
92673 DEF_FIELD(symval, usb_device_id, idVendor);
92674 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
92675 for (i = 0; i < count; i++) {
92676 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
92677 char acpi_id[sizeof(*id)];
92678 - int j;
92679 + unsigned int j;
92680
92681 buf_printf(&mod->dev_table_buf,
92682 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
92683 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
92684
92685 for (j = 0; j < PNP_MAX_DEVICES; j++) {
92686 const char *id = (char *)(*devs)[j].id;
92687 - int i2, j2;
92688 + unsigned int i2, j2;
92689 int dup = 0;
92690
92691 if (!id[0])
92692 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
92693 /* add an individual alias for every device entry */
92694 if (!dup) {
92695 char acpi_id[PNP_ID_LEN];
92696 - int k;
92697 + unsigned int k;
92698
92699 buf_printf(&mod->dev_table_buf,
92700 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
92701 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
92702 static int do_dmi_entry(const char *filename, void *symval,
92703 char *alias)
92704 {
92705 - int i, j;
92706 + unsigned int i, j;
92707 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
92708 sprintf(alias, "dmi*");
92709
92710 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
92711 index a4be8e1..6e8a5fb 100644
92712 --- a/scripts/mod/modpost.c
92713 +++ b/scripts/mod/modpost.c
92714 @@ -933,6 +933,7 @@ enum mismatch {
92715 ANY_INIT_TO_ANY_EXIT,
92716 ANY_EXIT_TO_ANY_INIT,
92717 EXPORT_TO_INIT_EXIT,
92718 + DATA_TO_TEXT
92719 };
92720
92721 struct sectioncheck {
92722 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
92723 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
92724 .mismatch = EXPORT_TO_INIT_EXIT,
92725 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
92726 +},
92727 +/* Do not reference code from writable data */
92728 +{
92729 + .fromsec = { DATA_SECTIONS, NULL },
92730 + .tosec = { TEXT_SECTIONS, NULL },
92731 + .mismatch = DATA_TO_TEXT
92732 }
92733 };
92734
92735 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
92736 continue;
92737 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
92738 continue;
92739 - if (sym->st_value == addr)
92740 - return sym;
92741 /* Find a symbol nearby - addr are maybe negative */
92742 d = sym->st_value - addr;
92743 + if (d == 0)
92744 + return sym;
92745 if (d < 0)
92746 d = addr - sym->st_value;
92747 if (d < distance) {
92748 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
92749 tosym, prl_to, prl_to, tosym);
92750 free(prl_to);
92751 break;
92752 + case DATA_TO_TEXT:
92753 +#if 0
92754 + fprintf(stderr,
92755 + "The %s %s:%s references\n"
92756 + "the %s %s:%s%s\n",
92757 + from, fromsec, fromsym, to, tosec, tosym, to_p);
92758 +#endif
92759 + break;
92760 }
92761 fprintf(stderr, "\n");
92762 }
92763 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
92764 static void check_sec_ref(struct module *mod, const char *modname,
92765 struct elf_info *elf)
92766 {
92767 - int i;
92768 + unsigned int i;
92769 Elf_Shdr *sechdrs = elf->sechdrs;
92770
92771 /* Walk through all sections */
92772 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
92773 va_end(ap);
92774 }
92775
92776 -void buf_write(struct buffer *buf, const char *s, int len)
92777 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
92778 {
92779 if (buf->size - buf->pos < len) {
92780 buf->size += len + SZ;
92781 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
92782 if (fstat(fileno(file), &st) < 0)
92783 goto close_write;
92784
92785 - if (st.st_size != b->pos)
92786 + if (st.st_size != (off_t)b->pos)
92787 goto close_write;
92788
92789 tmp = NOFAIL(malloc(b->pos));
92790 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
92791 index 51207e4..f7d603d 100644
92792 --- a/scripts/mod/modpost.h
92793 +++ b/scripts/mod/modpost.h
92794 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
92795
92796 struct buffer {
92797 char *p;
92798 - int pos;
92799 - int size;
92800 + unsigned int pos;
92801 + unsigned int size;
92802 };
92803
92804 void __attribute__((format(printf, 2, 3)))
92805 buf_printf(struct buffer *buf, const char *fmt, ...);
92806
92807 void
92808 -buf_write(struct buffer *buf, const char *s, int len);
92809 +buf_write(struct buffer *buf, const char *s, unsigned int len);
92810
92811 struct module {
92812 struct module *next;
92813 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
92814 index 9dfcd6d..099068e 100644
92815 --- a/scripts/mod/sumversion.c
92816 +++ b/scripts/mod/sumversion.c
92817 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
92818 goto out;
92819 }
92820
92821 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
92822 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
92823 warn("writing sum in %s failed: %s\n",
92824 filename, strerror(errno));
92825 goto out;
92826 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
92827 index acb8650..b8c5f02 100644
92828 --- a/scripts/package/builddeb
92829 +++ b/scripts/package/builddeb
92830 @@ -246,6 +246,7 @@ fi
92831 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
92832 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
92833 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
92834 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
92835 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
92836 mkdir -p "$destdir"
92837 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
92838 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
92839 index 68bb4ef..2f419e1 100644
92840 --- a/scripts/pnmtologo.c
92841 +++ b/scripts/pnmtologo.c
92842 @@ -244,14 +244,14 @@ static void write_header(void)
92843 fprintf(out, " * Linux logo %s\n", logoname);
92844 fputs(" */\n\n", out);
92845 fputs("#include <linux/linux_logo.h>\n\n", out);
92846 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
92847 + fprintf(out, "static unsigned char %s_data[] = {\n",
92848 logoname);
92849 }
92850
92851 static void write_footer(void)
92852 {
92853 fputs("\n};\n\n", out);
92854 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
92855 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
92856 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
92857 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
92858 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
92859 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
92860 fputs("\n};\n\n", out);
92861
92862 /* write logo clut */
92863 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
92864 + fprintf(out, "static unsigned char %s_clut[] = {\n",
92865 logoname);
92866 write_hex_cnt = 0;
92867 for (i = 0; i < logo_clutsize; i++) {
92868 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
92869 index f5eb43d..1814de8 100644
92870 --- a/scripts/sortextable.h
92871 +++ b/scripts/sortextable.h
92872 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
92873 const char *secstrtab;
92874 const char *strtab;
92875 char *extab_image;
92876 - int extab_index = 0;
92877 - int i;
92878 - int idx;
92879 + unsigned int extab_index = 0;
92880 + unsigned int i;
92881 + unsigned int idx;
92882
92883 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
92884 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
92885 diff --git a/security/Kconfig b/security/Kconfig
92886 index e9c6ac7..80e2642 100644
92887 --- a/security/Kconfig
92888 +++ b/security/Kconfig
92889 @@ -4,6 +4,954 @@
92890
92891 menu "Security options"
92892
92893 +menu "Grsecurity"
92894 +
92895 + config ARCH_TRACK_EXEC_LIMIT
92896 + bool
92897 +
92898 + config PAX_KERNEXEC_PLUGIN
92899 + bool
92900 +
92901 + config PAX_PER_CPU_PGD
92902 + bool
92903 +
92904 + config TASK_SIZE_MAX_SHIFT
92905 + int
92906 + depends on X86_64
92907 + default 47 if !PAX_PER_CPU_PGD
92908 + default 42 if PAX_PER_CPU_PGD
92909 +
92910 + config PAX_ENABLE_PAE
92911 + bool
92912 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
92913 +
92914 + config PAX_USERCOPY_SLABS
92915 + bool
92916 +
92917 +config GRKERNSEC
92918 + bool "Grsecurity"
92919 + select CRYPTO
92920 + select CRYPTO_SHA256
92921 + select PROC_FS
92922 + select STOP_MACHINE
92923 + select TTY
92924 + help
92925 + If you say Y here, you will be able to configure many features
92926 + that will enhance the security of your system. It is highly
92927 + recommended that you say Y here and read through the help
92928 + for each option so that you fully understand the features and
92929 + can evaluate their usefulness for your machine.
92930 +
92931 +choice
92932 + prompt "Configuration Method"
92933 + depends on GRKERNSEC
92934 + default GRKERNSEC_CONFIG_CUSTOM
92935 + help
92936 +
92937 +config GRKERNSEC_CONFIG_AUTO
92938 + bool "Automatic"
92939 + help
92940 + If you choose this configuration method, you'll be able to answer a small
92941 + number of simple questions about how you plan to use this kernel.
92942 + The settings of grsecurity and PaX will be automatically configured for
92943 + the highest commonly-used settings within the provided constraints.
92944 +
92945 + If you require additional configuration, custom changes can still be made
92946 + from the "custom configuration" menu.
92947 +
92948 +config GRKERNSEC_CONFIG_CUSTOM
92949 + bool "Custom"
92950 + help
92951 + If you choose this configuration method, you'll be able to configure all
92952 + grsecurity and PaX settings manually. Via this method, no options are
92953 + automatically enabled.
92954 +
92955 +endchoice
92956 +
92957 +choice
92958 + prompt "Usage Type"
92959 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92960 + default GRKERNSEC_CONFIG_SERVER
92961 + help
92962 +
92963 +config GRKERNSEC_CONFIG_SERVER
92964 + bool "Server"
92965 + help
92966 + Choose this option if you plan to use this kernel on a server.
92967 +
92968 +config GRKERNSEC_CONFIG_DESKTOP
92969 + bool "Desktop"
92970 + help
92971 + Choose this option if you plan to use this kernel on a desktop.
92972 +
92973 +endchoice
92974 +
92975 +choice
92976 + prompt "Virtualization Type"
92977 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
92978 + default GRKERNSEC_CONFIG_VIRT_NONE
92979 + help
92980 +
92981 +config GRKERNSEC_CONFIG_VIRT_NONE
92982 + bool "None"
92983 + help
92984 + Choose this option if this kernel will be run on bare metal.
92985 +
92986 +config GRKERNSEC_CONFIG_VIRT_GUEST
92987 + bool "Guest"
92988 + help
92989 + Choose this option if this kernel will be run as a VM guest.
92990 +
92991 +config GRKERNSEC_CONFIG_VIRT_HOST
92992 + bool "Host"
92993 + help
92994 + Choose this option if this kernel will be run as a VM host.
92995 +
92996 +endchoice
92997 +
92998 +choice
92999 + prompt "Virtualization Hardware"
93000 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
93001 + help
93002 +
93003 +config GRKERNSEC_CONFIG_VIRT_EPT
93004 + bool "EPT/RVI Processor Support"
93005 + depends on X86
93006 + help
93007 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
93008 + hardware virtualization. This allows for additional kernel hardening protections
93009 + to operate without additional performance impact.
93010 +
93011 + To see if your Intel processor supports EPT, see:
93012 + http://ark.intel.com/Products/VirtualizationTechnology
93013 + (Most Core i3/5/7 support EPT)
93014 +
93015 + To see if your AMD processor supports RVI, see:
93016 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
93017 +
93018 +config GRKERNSEC_CONFIG_VIRT_SOFT
93019 + bool "First-gen/No Hardware Virtualization"
93020 + help
93021 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
93022 + support hardware virtualization or doesn't support the EPT/RVI extensions.
93023 +
93024 +endchoice
93025 +
93026 +choice
93027 + prompt "Virtualization Software"
93028 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
93029 + help
93030 +
93031 +config GRKERNSEC_CONFIG_VIRT_XEN
93032 + bool "Xen"
93033 + help
93034 + Choose this option if this kernel is running as a Xen guest or host.
93035 +
93036 +config GRKERNSEC_CONFIG_VIRT_VMWARE
93037 + bool "VMWare"
93038 + help
93039 + Choose this option if this kernel is running as a VMWare guest or host.
93040 +
93041 +config GRKERNSEC_CONFIG_VIRT_KVM
93042 + bool "KVM"
93043 + help
93044 + Choose this option if this kernel is running as a KVM guest or host.
93045 +
93046 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
93047 + bool "VirtualBox"
93048 + help
93049 + Choose this option if this kernel is running as a VirtualBox guest or host.
93050 +
93051 +endchoice
93052 +
93053 +choice
93054 + prompt "Required Priorities"
93055 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
93056 + default GRKERNSEC_CONFIG_PRIORITY_PERF
93057 + help
93058 +
93059 +config GRKERNSEC_CONFIG_PRIORITY_PERF
93060 + bool "Performance"
93061 + help
93062 + Choose this option if performance is of highest priority for this deployment
93063 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
93064 + clearing of structures intended for userland, and freed memory sanitizing will
93065 + be disabled.
93066 +
93067 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
93068 + bool "Security"
93069 + help
93070 + Choose this option if security is of highest priority for this deployment of
93071 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
93072 + for userland, and freed memory sanitizing will be enabled for this kernel.
93073 + In a worst-case scenario, these features can introduce a 20% performance hit
93074 + (UDEREF on x64 contributing half of this hit).
93075 +
93076 +endchoice
93077 +
93078 +menu "Default Special Groups"
93079 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
93080 +
93081 +config GRKERNSEC_PROC_GID
93082 + int "GID exempted from /proc restrictions"
93083 + default 1001
93084 + help
93085 + Setting this GID determines which group will be exempted from
93086 + grsecurity's /proc restrictions, allowing users of the specified
93087 + group to view network statistics and the existence of other users'
93088 + processes on the system. This GID may also be chosen at boot time
93089 + via "grsec_proc_gid=" on the kernel commandline.
93090 +
93091 +config GRKERNSEC_TPE_UNTRUSTED_GID
93092 + int "GID for TPE-untrusted users"
93093 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
93094 + default 1005
93095 + help
93096 + Setting this GID determines which group untrusted users should
93097 + be added to. These users will be placed under grsecurity's Trusted Path
93098 + Execution mechanism, preventing them from executing their own binaries.
93099 + The users will only be able to execute binaries in directories owned and
93100 + writable only by the root user. If the sysctl option is enabled, a sysctl
93101 + option with name "tpe_gid" is created.
93102 +
93103 +config GRKERNSEC_TPE_TRUSTED_GID
93104 + int "GID for TPE-trusted users"
93105 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
93106 + default 1005
93107 + help
93108 + Setting this GID determines what group TPE restrictions will be
93109 + *disabled* for. If the sysctl option is enabled, a sysctl option
93110 + with name "tpe_gid" is created.
93111 +
93112 +config GRKERNSEC_SYMLINKOWN_GID
93113 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
93114 + depends on GRKERNSEC_CONFIG_SERVER
93115 + default 1006
93116 + help
93117 + Setting this GID determines what group kernel-enforced
93118 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
93119 + is enabled, a sysctl option with name "symlinkown_gid" is created.
93120 +
93121 +
93122 +endmenu
93123 +
93124 +menu "Customize Configuration"
93125 +depends on GRKERNSEC
93126 +
93127 +menu "PaX"
93128 +
93129 +config PAX
93130 + bool "Enable various PaX features"
93131 + default y if GRKERNSEC_CONFIG_AUTO
93132 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
93133 + help
93134 + This allows you to enable various PaX features. PaX adds
93135 + intrusion prevention mechanisms to the kernel that reduce
93136 + the risks posed by exploitable memory corruption bugs.
93137 +
93138 +menu "PaX Control"
93139 + depends on PAX
93140 +
93141 +config PAX_SOFTMODE
93142 + bool 'Support soft mode'
93143 + help
93144 + Enabling this option will allow you to run PaX in soft mode, that
93145 + is, PaX features will not be enforced by default, only on executables
93146 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
93147 + support as they are the only way to mark executables for soft mode use.
93148 +
93149 + Soft mode can be activated by using the "pax_softmode=1" kernel command
93150 + line option on boot. Furthermore you can control various PaX features
93151 + at runtime via the entries in /proc/sys/kernel/pax.
93152 +
93153 +config PAX_EI_PAX
93154 + bool 'Use legacy ELF header marking'
93155 + default y if GRKERNSEC_CONFIG_AUTO
93156 + help
93157 + Enabling this option will allow you to control PaX features on
93158 + a per executable basis via the 'chpax' utility available at
93159 + http://pax.grsecurity.net/. The control flags will be read from
93160 + an otherwise reserved part of the ELF header. This marking has
93161 + numerous drawbacks (no support for soft-mode, toolchain does not
93162 + know about the non-standard use of the ELF header) therefore it
93163 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
93164 + support.
93165 +
93166 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
93167 + support as well, they will override the legacy EI_PAX marks.
93168 +
93169 + If you enable none of the marking options then all applications
93170 + will run with PaX enabled on them by default.
93171 +
93172 +config PAX_PT_PAX_FLAGS
93173 + bool 'Use ELF program header marking'
93174 + default y if GRKERNSEC_CONFIG_AUTO
93175 + help
93176 + Enabling this option will allow you to control PaX features on
93177 + a per executable basis via the 'paxctl' utility available at
93178 + http://pax.grsecurity.net/. The control flags will be read from
93179 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
93180 + has the benefits of supporting both soft mode and being fully
93181 + integrated into the toolchain (the binutils patch is available
93182 + from http://pax.grsecurity.net).
93183 +
93184 + Note that if you enable the legacy EI_PAX marking support as well,
93185 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
93186 +
93187 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
93188 + must make sure that the marks are the same if a binary has both marks.
93189 +
93190 + If you enable none of the marking options then all applications
93191 + will run with PaX enabled on them by default.
93192 +
93193 +config PAX_XATTR_PAX_FLAGS
93194 + bool 'Use filesystem extended attributes marking'
93195 + default y if GRKERNSEC_CONFIG_AUTO
93196 + select CIFS_XATTR if CIFS
93197 + select EXT2_FS_XATTR if EXT2_FS
93198 + select EXT3_FS_XATTR if EXT3_FS
93199 + select EXT4_FS_XATTR if EXT4_FS
93200 + select JFFS2_FS_XATTR if JFFS2_FS
93201 + select REISERFS_FS_XATTR if REISERFS_FS
93202 + select SQUASHFS_XATTR if SQUASHFS
93203 + select TMPFS_XATTR if TMPFS
93204 + select UBIFS_FS_XATTR if UBIFS_FS
93205 + help
93206 + Enabling this option will allow you to control PaX features on
93207 + a per executable basis via the 'setfattr' utility. The control
93208 + flags will be read from the user.pax.flags extended attribute of
93209 + the file. This marking has the benefit of supporting binary-only
93210 + applications that self-check themselves (e.g., skype) and would
93211 + not tolerate chpax/paxctl changes. The main drawback is that
93212 + extended attributes are not supported by some filesystems (e.g.,
93213 + isofs, udf, vfat) so copying files through such filesystems will
93214 + lose the extended attributes and these PaX markings.
93215 +
93216 + Note that if you enable the legacy EI_PAX marking support as well,
93217 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
93218 +
93219 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
93220 + must make sure that the marks are the same if a binary has both marks.
93221 +
93222 + If you enable none of the marking options then all applications
93223 + will run with PaX enabled on them by default.
93224 +
93225 +choice
93226 + prompt 'MAC system integration'
93227 + default PAX_HAVE_ACL_FLAGS
93228 + help
93229 + Mandatory Access Control systems have the option of controlling
93230 + PaX flags on a per executable basis, choose the method supported
93231 + by your particular system.
93232 +
93233 + - "none": if your MAC system does not interact with PaX,
93234 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
93235 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
93236 +
93237 + NOTE: this option is for developers/integrators only.
93238 +
93239 + config PAX_NO_ACL_FLAGS
93240 + bool 'none'
93241 +
93242 + config PAX_HAVE_ACL_FLAGS
93243 + bool 'direct'
93244 +
93245 + config PAX_HOOK_ACL_FLAGS
93246 + bool 'hook'
93247 +endchoice
93248 +
93249 +endmenu
93250 +
93251 +menu "Non-executable pages"
93252 + depends on PAX
93253 +
93254 +config PAX_NOEXEC
93255 + bool "Enforce non-executable pages"
93256 + default y if GRKERNSEC_CONFIG_AUTO
93257 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
93258 + help
93259 + By design some architectures do not allow for protecting memory
93260 + pages against execution or even if they do, Linux does not make
93261 + use of this feature. In practice this means that if a page is
93262 + readable (such as the stack or heap) it is also executable.
93263 +
93264 + There is a well known exploit technique that makes use of this
93265 + fact and a common programming mistake where an attacker can
93266 + introduce code of his choice somewhere in the attacked program's
93267 + memory (typically the stack or the heap) and then execute it.
93268 +
93269 + If the attacked program was running with different (typically
93270 + higher) privileges than that of the attacker, then he can elevate
93271 + his own privilege level (e.g. get a root shell, write to files for
93272 + which he does not have write access to, etc).
93273 +
93274 + Enabling this option will let you choose from various features
93275 + that prevent the injection and execution of 'foreign' code in
93276 + a program.
93277 +
93278 + This will also break programs that rely on the old behaviour and
93279 + expect that dynamically allocated memory via the malloc() family
93280 + of functions is executable (which it is not). Notable examples
93281 + are the XFree86 4.x server, the java runtime and wine.
93282 +
93283 +config PAX_PAGEEXEC
93284 + bool "Paging based non-executable pages"
93285 + default y if GRKERNSEC_CONFIG_AUTO
93286 + depends on PAX_NOEXEC && (!X86_32 || M586 || M586TSC || M586MMX || M686 || MPENTIUMII || MPENTIUMIII || MPENTIUMM || MCORE2 || MATOM || MPENTIUM4 || MPSC || MK7 || MK8 || MWINCHIPC6 || MWINCHIP2 || MWINCHIP3D || MVIAC3_2 || MVIAC7)
93287 + select ARCH_TRACK_EXEC_LIMIT if X86_32
93288 + help
93289 + This implementation is based on the paging feature of the CPU.
93290 + On i386 without hardware non-executable bit support there is a
93291 + variable but usually low performance impact, however on Intel's
93292 + P4 core based CPUs it is very high so you should not enable this
93293 + for kernels meant to be used on such CPUs.
93294 +
93295 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
93296 + with hardware non-executable bit support there is no performance
93297 + impact, on ppc the impact is negligible.
93298 +
93299 + Note that several architectures require various emulations due to
93300 + badly designed userland ABIs, this will cause a performance impact
93301 + but will disappear as soon as userland is fixed. For example, ppc
93302 + userland MUST have been built with secure-plt by a recent toolchain.
93303 +
93304 +config PAX_SEGMEXEC
93305 + bool "Segmentation based non-executable pages"
93306 + default y if GRKERNSEC_CONFIG_AUTO
93307 + depends on PAX_NOEXEC && X86_32
93308 + help
93309 + This implementation is based on the segmentation feature of the
93310 + CPU and has a very small performance impact, however applications
93311 + will be limited to a 1.5 GB address space instead of the normal
93312 + 3 GB.
93313 +
93314 +config PAX_EMUTRAMP
93315 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
93316 + default y if PARISC
93317 + help
93318 + There are some programs and libraries that for one reason or
93319 + another attempt to execute special small code snippets from
93320 + non-executable memory pages. Most notable examples are the
93321 + signal handler return code generated by the kernel itself and
93322 + the GCC trampolines.
93323 +
93324 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
93325 + such programs will no longer work under your kernel.
93326 +
93327 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
93328 + utilities to enable trampoline emulation for the affected programs
93329 + yet still have the protection provided by the non-executable pages.
93330 +
93331 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
93332 + your system will not even boot.
93333 +
93334 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
93335 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
93336 + for the affected files.
93337 +
93338 + NOTE: enabling this feature *may* open up a loophole in the
93339 + protection provided by non-executable pages that an attacker
93340 + could abuse. Therefore the best solution is to not have any
93341 + files on your system that would require this option. This can
93342 + be achieved by not using libc5 (which relies on the kernel
93343 + signal handler return code) and not using or rewriting programs
93344 + that make use of the nested function implementation of GCC.
93345 + Skilled users can just fix GCC itself so that it implements
93346 + nested function calls in a way that does not interfere with PaX.
93347 +
93348 +config PAX_EMUSIGRT
93349 + bool "Automatically emulate sigreturn trampolines"
93350 + depends on PAX_EMUTRAMP && PARISC
93351 + default y
93352 + help
93353 + Enabling this option will have the kernel automatically detect
93354 + and emulate signal return trampolines executing on the stack
93355 + that would otherwise lead to task termination.
93356 +
93357 + This solution is intended as a temporary one for users with
93358 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
93359 + Modula-3 runtime, etc) or executables linked to such, basically
93360 + everything that does not specify its own SA_RESTORER function in
93361 + normal executable memory like glibc 2.1+ does.
93362 +
93363 + On parisc you MUST enable this option, otherwise your system will
93364 + not even boot.
93365 +
93366 + NOTE: this feature cannot be disabled on a per executable basis
93367 + and since it *does* open up a loophole in the protection provided
93368 + by non-executable pages, the best solution is to not have any
93369 + files on your system that would require this option.
93370 +
93371 +config PAX_MPROTECT
93372 + bool "Restrict mprotect()"
93373 + default y if GRKERNSEC_CONFIG_AUTO
93374 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
93375 + help
93376 + Enabling this option will prevent programs from
93377 + - changing the executable status of memory pages that were
93378 + not originally created as executable,
93379 + - making read-only executable pages writable again,
93380 + - creating executable pages from anonymous memory,
93381 + - making read-only-after-relocations (RELRO) data pages writable again.
93382 +
93383 + You should say Y here to complete the protection provided by
93384 + the enforcement of non-executable pages.
93385 +
93386 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
93387 + this feature on a per file basis.
93388 +
93389 +config PAX_MPROTECT_COMPAT
93390 + bool "Use legacy/compat protection demoting (read help)"
93391 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
93392 + depends on PAX_MPROTECT
93393 + help
93394 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
93395 + by sending the proper error code to the application. For some broken
93396 + userland, this can cause problems with Python or other applications. The
93397 + current implementation however allows for applications like clamav to
93398 + detect if JIT compilation/execution is allowed and to fall back gracefully
93399 + to an interpreter-based mode if it does not. While we encourage everyone
93400 + to use the current implementation as-is and push upstream to fix broken
93401 + userland (note that the RWX logging option can assist with this), in some
93402 + environments this may not be possible. Having to disable MPROTECT
93403 + completely on certain binaries reduces the security benefit of PaX,
93404 + so this option is provided for those environments to revert to the old
93405 + behavior.
93406 +
93407 +config PAX_ELFRELOCS
93408 + bool "Allow ELF text relocations (read help)"
93409 + depends on PAX_MPROTECT
93410 + default n
93411 + help
93412 + Non-executable pages and mprotect() restrictions are effective
93413 + in preventing the introduction of new executable code into an
93414 + attacked task's address space. There remain only two venues
93415 + for this kind of attack: if the attacker can execute already
93416 + existing code in the attacked task then he can either have it
93417 + create and mmap() a file containing his code or have it mmap()
93418 + an already existing ELF library that does not have position
93419 + independent code in it and use mprotect() on it to make it
93420 + writable and copy his code there. While protecting against
93421 + the former approach is beyond PaX, the latter can be prevented
93422 + by having only PIC ELF libraries on one's system (which do not
93423 + need to relocate their code). If you are sure this is your case,
93424 + as is the case with all modern Linux distributions, then leave
93425 + this option disabled. You should say 'n' here.
93426 +
93427 +config PAX_ETEXECRELOCS
93428 + bool "Allow ELF ET_EXEC text relocations"
93429 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
93430 + select PAX_ELFRELOCS
93431 + default y
93432 + help
93433 + On some architectures there are incorrectly created applications
93434 + that require text relocations and would not work without enabling
93435 + this option. If you are an alpha, ia64 or parisc user, you should
93436 + enable this option and disable it once you have made sure that
93437 + none of your applications need it.
93438 +
93439 +config PAX_EMUPLT
93440 + bool "Automatically emulate ELF PLT"
93441 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
93442 + default y
93443 + help
93444 + Enabling this option will have the kernel automatically detect
93445 + and emulate the Procedure Linkage Table entries in ELF files.
93446 + On some architectures such entries are in writable memory, and
93447 + become non-executable leading to task termination. Therefore
93448 + it is mandatory that you enable this option on alpha, parisc,
93449 + sparc and sparc64, otherwise your system would not even boot.
93450 +
93451 + NOTE: this feature *does* open up a loophole in the protection
93452 + provided by the non-executable pages, therefore the proper
93453 + solution is to modify the toolchain to produce a PLT that does
93454 + not need to be writable.
93455 +
93456 +config PAX_DLRESOLVE
93457 + bool 'Emulate old glibc resolver stub'
93458 + depends on PAX_EMUPLT && SPARC
93459 + default n
93460 + help
93461 + This option is needed if userland has an old glibc (before 2.4)
93462 + that puts a 'save' instruction into the runtime generated resolver
93463 + stub that needs special emulation.
93464 +
93465 +config PAX_KERNEXEC
93466 + bool "Enforce non-executable kernel pages"
93467 + default y if GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_NONE || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_GUEST) || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_KVM))
93468 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
93469 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
93470 + select PAX_KERNEXEC_PLUGIN if X86_64
93471 + help
93472 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
93473 + that is, enabling this option will make it harder to inject
93474 + and execute 'foreign' code in kernel memory itself.
93475 +
93476 +choice
93477 + prompt "Return Address Instrumentation Method"
93478 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
93479 + depends on PAX_KERNEXEC_PLUGIN
93480 + help
93481 + Select the method used to instrument function pointer dereferences.
93482 + Note that binary modules cannot be instrumented by this approach.
93483 +
93484 + Note that the implementation requires a gcc with plugin support,
93485 + i.e., gcc 4.5 or newer. You may need to install the supporting
93486 + headers explicitly in addition to the normal gcc package.
93487 +
93488 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
93489 + bool "bts"
93490 + help
93491 + This method is compatible with binary only modules but has
93492 + a higher runtime overhead.
93493 +
93494 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
93495 + bool "or"
93496 + depends on !PARAVIRT
93497 + help
93498 + This method is incompatible with binary only modules but has
93499 + a lower runtime overhead.
93500 +endchoice
93501 +
93502 +config PAX_KERNEXEC_PLUGIN_METHOD
93503 + string
93504 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
93505 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
93506 + default ""
93507 +
93508 +config PAX_KERNEXEC_MODULE_TEXT
93509 + int "Minimum amount of memory reserved for module code"
93510 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
93511 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
93512 + depends on PAX_KERNEXEC && X86_32
93513 + help
93514 + Due to implementation details the kernel must reserve a fixed
93515 + amount of memory for runtime allocated code (such as modules)
93516 + at compile time that cannot be changed at runtime. Here you
93517 + can specify the minimum amount in MB that will be reserved.
93518 + Due to the same implementation details this size will always
93519 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
93520 + the actually available memory for runtime allocated code will
93521 + usually be more than this minimum.
93522 +
93523 + The default 4 MB should be enough for most users but if you have
93524 + an excessive number of modules (e.g., most distribution configs
93525 + compile many drivers as modules) or use huge modules such as
93526 + nvidia's kernel driver, you will need to adjust this amount.
93527 + A good rule of thumb is to look at your currently loaded kernel
93528 + modules and add up their sizes.
93529 +
93530 +endmenu
93531 +
93532 +menu "Address Space Layout Randomization"
93533 + depends on PAX
93534 +
93535 +config PAX_ASLR
93536 + bool "Address Space Layout Randomization"
93537 + default y if GRKERNSEC_CONFIG_AUTO
93538 + help
93539 + Many if not most exploit techniques rely on the knowledge of
93540 + certain addresses in the attacked program. The following options
93541 + will allow the kernel to apply a certain amount of randomization
93542 + to specific parts of the program thereby forcing an attacker to
93543 + guess them in most cases. Any failed guess will most likely crash
93544 + the attacked program which allows the kernel to detect such attempts
93545 + and react on them. PaX itself provides no reaction mechanisms,
93546 + instead it is strongly encouraged that you make use of Nergal's
93547 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
93548 + (http://www.grsecurity.net/) built-in crash detection features or
93549 + develop one yourself.
93550 +
93551 + By saying Y here you can choose to randomize the following areas:
93552 + - top of the task's kernel stack
93553 + - top of the task's userland stack
93554 + - base address for mmap() requests that do not specify one
93555 + (this includes all libraries)
93556 + - base address of the main executable
93557 +
93558 + It is strongly recommended to say Y here as address space layout
93559 + randomization has negligible impact on performance yet it provides
93560 + a very effective protection.
93561 +
93562 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
93563 + this feature on a per file basis.
93564 +
93565 +config PAX_RANDKSTACK
93566 + bool "Randomize kernel stack base"
93567 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
93568 + depends on X86_TSC && X86
93569 + help
93570 + By saying Y here the kernel will randomize every task's kernel
93571 + stack on every system call. This will not only force an attacker
93572 + to guess it but also prevent him from making use of possible
93573 + leaked information about it.
93574 +
93575 + Since the kernel stack is a rather scarce resource, randomization
93576 + may cause unexpected stack overflows, therefore you should very
93577 + carefully test your system. Note that once enabled in the kernel
93578 + configuration, this feature cannot be disabled on a per file basis.
93579 +
93580 +config PAX_RANDUSTACK
93581 + bool "Randomize user stack base"
93582 + default y if GRKERNSEC_CONFIG_AUTO
93583 + depends on PAX_ASLR
93584 + help
93585 + By saying Y here the kernel will randomize every task's userland
93586 + stack. The randomization is done in two steps where the second
93587 + one may apply a big amount of shift to the top of the stack and
93588 + cause problems for programs that want to use lots of memory (more
93589 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
93590 + For this reason the second step can be controlled by 'chpax' or
93591 + 'paxctl' on a per file basis.
93592 +
93593 +config PAX_RANDMMAP
93594 + bool "Randomize mmap() base"
93595 + default y if GRKERNSEC_CONFIG_AUTO
93596 + depends on PAX_ASLR
93597 + help
93598 + By saying Y here the kernel will use a randomized base address for
93599 + mmap() requests that do not specify one themselves. As a result
93600 + all dynamically loaded libraries will appear at random addresses
93601 + and therefore be harder to exploit by a technique where an attacker
93602 + attempts to execute library code for his purposes (e.g. spawn a
93603 + shell from an exploited program that is running at an elevated
93604 + privilege level).
93605 +
93606 + Furthermore, if a program is relinked as a dynamic ELF file, its
93607 + base address will be randomized as well, completing the full
93608 + randomization of the address space layout. Attacking such programs
93609 + becomes a guess game. You can find an example of doing this at
93610 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
93611 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
93612 +
93613 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
93614 + feature on a per file basis.
93615 +
93616 +endmenu
93617 +
93618 +menu "Miscellaneous hardening features"
93619 +
93620 +config PAX_MEMORY_SANITIZE
93621 + bool "Sanitize all freed memory"
93622 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
93623 + depends on !HIBERNATION
93624 + help
93625 + By saying Y here the kernel will erase memory pages and slab objects
93626 + as soon as they are freed. This in turn reduces the lifetime of data
93627 + stored in them, making it less likely that sensitive information such
93628 + as passwords, cryptographic secrets, etc stay in memory for too long.
93629 +
93630 + This is especially useful for programs whose runtime is short, long
93631 + lived processes and the kernel itself benefit from this as long as
93632 + they ensure timely freeing of memory that may hold sensitive
93633 + information.
93634 +
93635 + A nice side effect of the sanitization of slab objects is the
93636 + reduction of possible info leaks caused by padding bytes within the
93637 + leaky structures. Use-after-free bugs for structures containing
93638 + pointers can also be detected as dereferencing the sanitized pointer
93639 + will generate an access violation.
93640 +
93641 + The tradeoff is performance impact, on a single CPU system kernel
93642 + compilation sees a 3% slowdown, other systems and workloads may vary
93643 + and you are advised to test this feature on your expected workload
93644 + before deploying it.
93645 +
93646 + To reduce the performance penalty by sanitizing pages only, albeit
93647 + limiting the effectiveness of this feature at the same time, slab
93648 + sanitization can be disabled with the kernel commandline parameter
93649 + "pax_sanitize_slab=0".
93650 +
93651 + Note that this feature does not protect data stored in live pages,
93652 + e.g., process memory swapped to disk may stay there for a long time.
93653 +
93654 +config PAX_MEMORY_STACKLEAK
93655 + bool "Sanitize kernel stack"
93656 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
93657 + depends on X86
93658 + help
93659 + By saying Y here the kernel will erase the kernel stack before it
93660 + returns from a system call. This in turn reduces the information
93661 + that a kernel stack leak bug can reveal.
93662 +
93663 + Note that such a bug can still leak information that was put on
93664 + the stack by the current system call (the one eventually triggering
93665 + the bug) but traces of earlier system calls on the kernel stack
93666 + cannot leak anymore.
93667 +
93668 + The tradeoff is performance impact: on a single CPU system kernel
93669 + compilation sees a 1% slowdown, other systems and workloads may vary
93670 + and you are advised to test this feature on your expected workload
93671 + before deploying it.
93672 +
93673 + Note that the full feature requires a gcc with plugin support,
93674 + i.e., gcc 4.5 or newer. You may need to install the supporting
93675 + headers explicitly in addition to the normal gcc package. Using
93676 + older gcc versions means that functions with large enough stack
93677 + frames may leave uninitialized memory behind that may be exposed
93678 + to a later syscall leaking the stack.
93679 +
93680 +config PAX_MEMORY_STRUCTLEAK
93681 + bool "Forcibly initialize local variables copied to userland"
93682 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
93683 + help
93684 + By saying Y here the kernel will zero initialize some local
93685 + variables that are going to be copied to userland. This in
93686 + turn prevents unintended information leakage from the kernel
93687 + stack should later code forget to explicitly set all parts of
93688 + the copied variable.
93689 +
93690 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
93691 + at a much smaller coverage.
93692 +
93693 + Note that the implementation requires a gcc with plugin support,
93694 + i.e., gcc 4.5 or newer. You may need to install the supporting
93695 + headers explicitly in addition to the normal gcc package.
93696 +
93697 +config PAX_MEMORY_UDEREF
93698 + bool "Prevent invalid userland pointer dereference"
93699 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
93700 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
93701 + select PAX_PER_CPU_PGD if X86_64
93702 + help
93703 + By saying Y here the kernel will be prevented from dereferencing
93704 + userland pointers in contexts where the kernel expects only kernel
93705 + pointers. This is both a useful runtime debugging feature and a
93706 + security measure that prevents exploiting a class of kernel bugs.
93707 +
93708 + The tradeoff is that some virtualization solutions may experience
93709 + a huge slowdown and therefore you should not enable this feature
93710 + for kernels meant to run in such environments. Whether a given VM
93711 + solution is affected or not is best determined by simply trying it
93712 + out, the performance impact will be obvious right on boot as this
93713 + mechanism engages from very early on. A good rule of thumb is that
93714 + VMs running on CPUs without hardware virtualization support (i.e.,
93715 + the majority of IA-32 CPUs) will likely experience the slowdown.
93716 +
93717 +config PAX_REFCOUNT
93718 + bool "Prevent various kernel object reference counter overflows"
93719 + default y if GRKERNSEC_CONFIG_AUTO
93720 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
93721 + help
93722 + By saying Y here the kernel will detect and prevent overflowing
93723 + various (but not all) kinds of object reference counters. Such
93724 + overflows can normally occur due to bugs only and are often, if
93725 + not always, exploitable.
93726 +
93727 + The tradeoff is that data structures protected by an overflowed
93728 + refcount will never be freed and therefore will leak memory. Note
93729 + that this leak also happens even without this protection but in
93730 + that case the overflow can eventually trigger the freeing of the
93731 + data structure while it is still being used elsewhere, resulting
93732 + in the exploitable situation that this feature prevents.
93733 +
93734 + Since this has a negligible performance impact, you should enable
93735 + this feature.
93736 +
93737 +config PAX_CONSTIFY_PLUGIN
93738 + bool "Automatically constify eligible structures"
93739 + default y
93740 + depends on !UML && PAX_KERNEXEC
93741 + help
93742 + By saying Y here the compiler will automatically constify a class
93743 + of types that contain only function pointers. This reduces the
93744 + kernel's attack surface and also produces a better memory layout.
93745 +
93746 + Note that the implementation requires a gcc with plugin support,
93747 + i.e., gcc 4.5 or newer. You may need to install the supporting
93748 + headers explicitly in addition to the normal gcc package.
93749 +
93750 + Note that if some code really has to modify constified variables
93751 + then the source code will have to be patched to allow it. Examples
93752 + can be found in PaX itself (the no_const attribute) and for some
93753 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
93754 +
93755 +config PAX_USERCOPY
93756 + bool "Harden heap object copies between kernel and userland"
93757 + default y if GRKERNSEC_CONFIG_AUTO
93758 + depends on ARM || IA64 || PPC || SPARC || X86
93759 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
93760 + select PAX_USERCOPY_SLABS
93761 + help
93762 + By saying Y here the kernel will enforce the size of heap objects
93763 + when they are copied in either direction between the kernel and
93764 + userland, even if only a part of the heap object is copied.
93765 +
93766 + Specifically, this checking prevents information leaking from the
93767 + kernel heap during kernel to userland copies (if the kernel heap
93768 + object is otherwise fully initialized) and prevents kernel heap
93769 + overflows during userland to kernel copies.
93770 +
93771 + Note that the current implementation provides the strictest bounds
93772 + checks for the SLUB allocator.
93773 +
93774 + Enabling this option also enables per-slab cache protection against
93775 + data in a given cache being copied into/out of via userland
93776 + accessors. Though the whitelist of regions will be reduced over
93777 + time, it notably protects important data structures like task structs.
93778 +
93779 + If frame pointers are enabled on x86, this option will also restrict
93780 + copies into and out of the kernel stack to local variables within a
93781 + single frame.
93782 +
93783 + Since this has a negligible performance impact, you should enable
93784 + this feature.
93785 +
93786 +config PAX_USERCOPY_DEBUG
93787 + bool
93788 + depends on X86 && PAX_USERCOPY
93789 + default n
93790 +
93791 +config PAX_SIZE_OVERFLOW
93792 + bool "Prevent various integer overflows in function size parameters"
93793 + default y if GRKERNSEC_CONFIG_AUTO
93794 + depends on X86
93795 + help
93796 + By saying Y here the kernel recomputes expressions of function
93797 + arguments marked by a size_overflow attribute with double integer
93798 + precision (DImode/TImode for 32/64 bit integer types).
93799 +
93800 + The recomputed argument is checked against TYPE_MAX and an event
93801 + is logged on overflow and the triggering process is killed.
93802 +
93803 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
93804 +
93805 + Note that the implementation requires a gcc with plugin support,
93806 + i.e., gcc 4.5 or newer. You may need to install the supporting
93807 + headers explicitly in addition to the normal gcc package.
93808 +
93809 +config PAX_LATENT_ENTROPY
93810 + bool "Generate some entropy during boot"
93811 + default y if GRKERNSEC_CONFIG_AUTO
93812 + help
93813 + By saying Y here the kernel will instrument early boot code to
93814 + extract some entropy from both original and artificially created
93815 + program state. This will help especially embedded systems where
93816 + there is little 'natural' source of entropy normally. The cost
93817 + is some slowdown of the boot process.
93818 +
93819 + When pax_extra_latent_entropy is passed on the kernel command line,
93820 + entropy will be extracted from up to the first 4GB of RAM while the
93821 + runtime memory allocator is being initialized. This costs even more
93822 + slowdown of the boot process.
93823 +
93824 + Note that the implementation requires a gcc with plugin support,
93825 + i.e., gcc 4.5 or newer. You may need to install the supporting
93826 + headers explicitly in addition to the normal gcc package.
93827 +
93828 + Note that entropy extracted this way is not cryptographically
93829 + secure!
93830 +
93831 +endmenu
93832 +
93833 +endmenu
93834 +
93835 +source grsecurity/Kconfig
93836 +
93837 +endmenu
93838 +
93839 +endmenu
93840 +
93841 source security/keys/Kconfig
93842
93843 config SECURITY_DMESG_RESTRICT
93844 @@ -103,7 +1051,7 @@ config INTEL_TXT
93845 config LSM_MMAP_MIN_ADDR
93846 int "Low address space for LSM to protect from user allocation"
93847 depends on SECURITY && SECURITY_SELINUX
93848 - default 32768 if ARM
93849 + default 32768 if ALPHA || ARM || PARISC || SPARC32
93850 default 65536
93851 help
93852 This is the portion of low virtual memory which should be protected
93853 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
93854 index 9b9013b..51ebf96 100644
93855 --- a/security/apparmor/Kconfig
93856 +++ b/security/apparmor/Kconfig
93857 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
93858 boot.
93859
93860 If you are unsure how to answer this question, answer 1.
93861 +
93862 +config SECURITY_APPARMOR_COMPAT_24
93863 + bool "Enable AppArmor 2.4 compatability"
93864 + depends on SECURITY_APPARMOR
93865 + default y
93866 + help
93867 + This option enables compatability with AppArmor 2.4. It is
93868 + recommended if compatability with older versions of AppArmor
93869 + is desired.
93870 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
93871 index 16c15ec..42b7c9f 100644
93872 --- a/security/apparmor/apparmorfs.c
93873 +++ b/security/apparmor/apparmorfs.c
93874 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
93875 .release = single_release,
93876 };
93877
93878 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93879 +/**
93880 + * __next_namespace - find the next namespace to list
93881 + * @root: root namespace to stop search at (NOT NULL)
93882 + * @ns: current ns position (NOT NULL)
93883 + *
93884 + * Find the next namespace from @ns under @root and handle all locking needed
93885 + * while switching current namespace.
93886 + *
93887 + * Returns: next namespace or NULL if at last namespace under @root
93888 + * NOTE: will not unlock root->lock
93889 + */
93890 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
93891 + struct aa_namespace *ns)
93892 +{
93893 + struct aa_namespace *parent;
93894 +
93895 + /* is next namespace a child */
93896 + if (!list_empty(&ns->sub_ns)) {
93897 + struct aa_namespace *next;
93898 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
93899 + read_lock(&next->lock);
93900 + return next;
93901 + }
93902 +
93903 + /* check if the next ns is a sibling, parent, gp, .. */
93904 + parent = ns->parent;
93905 + while (parent) {
93906 + read_unlock(&ns->lock);
93907 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
93908 + read_lock(&ns->lock);
93909 + return ns;
93910 + }
93911 + if (parent == root)
93912 + return NULL;
93913 + ns = parent;
93914 + parent = parent->parent;
93915 + }
93916 +
93917 + return NULL;
93918 +}
93919 +
93920 +/**
93921 + * __first_profile - find the first profile in a namespace
93922 + * @root: namespace that is root of profiles being displayed (NOT NULL)
93923 + * @ns: namespace to start in (NOT NULL)
93924 + *
93925 + * Returns: unrefcounted profile or NULL if no profile
93926 + */
93927 +static struct aa_profile *__first_profile(struct aa_namespace *root,
93928 + struct aa_namespace *ns)
93929 +{
93930 + for ( ; ns; ns = __next_namespace(root, ns)) {
93931 + if (!list_empty(&ns->base.profiles))
93932 + return list_first_entry(&ns->base.profiles,
93933 + struct aa_profile, base.list);
93934 + }
93935 + return NULL;
93936 +}
93937 +
93938 +/**
93939 + * __next_profile - step to the next profile in a profile tree
93940 + * @profile: current profile in tree (NOT NULL)
93941 + *
93942 + * Perform a depth first taversal on the profile tree in a namespace
93943 + *
93944 + * Returns: next profile or NULL if done
93945 + * Requires: profile->ns.lock to be held
93946 + */
93947 +static struct aa_profile *__next_profile(struct aa_profile *p)
93948 +{
93949 + struct aa_profile *parent;
93950 + struct aa_namespace *ns = p->ns;
93951 +
93952 + /* is next profile a child */
93953 + if (!list_empty(&p->base.profiles))
93954 + return list_first_entry(&p->base.profiles, typeof(*p),
93955 + base.list);
93956 +
93957 + /* is next profile a sibling, parent sibling, gp, subling, .. */
93958 + parent = p->parent;
93959 + while (parent) {
93960 + list_for_each_entry_continue(p, &parent->base.profiles,
93961 + base.list)
93962 + return p;
93963 + p = parent;
93964 + parent = parent->parent;
93965 + }
93966 +
93967 + /* is next another profile in the namespace */
93968 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
93969 + return p;
93970 +
93971 + return NULL;
93972 +}
93973 +
93974 +/**
93975 + * next_profile - step to the next profile in where ever it may be
93976 + * @root: root namespace (NOT NULL)
93977 + * @profile: current profile (NOT NULL)
93978 + *
93979 + * Returns: next profile or NULL if there isn't one
93980 + */
93981 +static struct aa_profile *next_profile(struct aa_namespace *root,
93982 + struct aa_profile *profile)
93983 +{
93984 + struct aa_profile *next = __next_profile(profile);
93985 + if (next)
93986 + return next;
93987 +
93988 + /* finished all profiles in namespace move to next namespace */
93989 + return __first_profile(root, __next_namespace(root, profile->ns));
93990 +}
93991 +
93992 +/**
93993 + * p_start - start a depth first traversal of profile tree
93994 + * @f: seq_file to fill
93995 + * @pos: current position
93996 + *
93997 + * Returns: first profile under current namespace or NULL if none found
93998 + *
93999 + * acquires first ns->lock
94000 + */
94001 +static void *p_start(struct seq_file *f, loff_t *pos)
94002 + __acquires(root->lock)
94003 +{
94004 + struct aa_profile *profile = NULL;
94005 + struct aa_namespace *root = aa_current_profile()->ns;
94006 + loff_t l = *pos;
94007 + f->private = aa_get_namespace(root);
94008 +
94009 +
94010 + /* find the first profile */
94011 + read_lock(&root->lock);
94012 + profile = __first_profile(root, root);
94013 +
94014 + /* skip to position */
94015 + for (; profile && l > 0; l--)
94016 + profile = next_profile(root, profile);
94017 +
94018 + return profile;
94019 +}
94020 +
94021 +/**
94022 + * p_next - read the next profile entry
94023 + * @f: seq_file to fill
94024 + * @p: profile previously returned
94025 + * @pos: current position
94026 + *
94027 + * Returns: next profile after @p or NULL if none
94028 + *
94029 + * may acquire/release locks in namespace tree as necessary
94030 + */
94031 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
94032 +{
94033 + struct aa_profile *profile = p;
94034 + struct aa_namespace *root = f->private;
94035 + (*pos)++;
94036 +
94037 + return next_profile(root, profile);
94038 +}
94039 +
94040 +/**
94041 + * p_stop - stop depth first traversal
94042 + * @f: seq_file we are filling
94043 + * @p: the last profile writen
94044 + *
94045 + * Release all locking done by p_start/p_next on namespace tree
94046 + */
94047 +static void p_stop(struct seq_file *f, void *p)
94048 + __releases(root->lock)
94049 +{
94050 + struct aa_profile *profile = p;
94051 + struct aa_namespace *root = f->private, *ns;
94052 +
94053 + if (profile) {
94054 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
94055 + read_unlock(&ns->lock);
94056 + }
94057 + read_unlock(&root->lock);
94058 + aa_put_namespace(root);
94059 +}
94060 +
94061 +/**
94062 + * seq_show_profile - show a profile entry
94063 + * @f: seq_file to file
94064 + * @p: current position (profile) (NOT NULL)
94065 + *
94066 + * Returns: error on failure
94067 + */
94068 +static int seq_show_profile(struct seq_file *f, void *p)
94069 +{
94070 + struct aa_profile *profile = (struct aa_profile *)p;
94071 + struct aa_namespace *root = f->private;
94072 +
94073 + if (profile->ns != root)
94074 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
94075 + seq_printf(f, "%s (%s)\n", profile->base.hname,
94076 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
94077 +
94078 + return 0;
94079 +}
94080 +
94081 +static const struct seq_operations aa_fs_profiles_op = {
94082 + .start = p_start,
94083 + .next = p_next,
94084 + .stop = p_stop,
94085 + .show = seq_show_profile,
94086 +};
94087 +
94088 +static int profiles_open(struct inode *inode, struct file *file)
94089 +{
94090 + return seq_open(file, &aa_fs_profiles_op);
94091 +}
94092 +
94093 +static int profiles_release(struct inode *inode, struct file *file)
94094 +{
94095 + return seq_release(inode, file);
94096 +}
94097 +
94098 +const struct file_operations aa_fs_profiles_fops = {
94099 + .open = profiles_open,
94100 + .read = seq_read,
94101 + .llseek = seq_lseek,
94102 + .release = profiles_release,
94103 +};
94104 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
94105 +
94106 /** Base file system setup **/
94107
94108 static struct aa_fs_entry aa_fs_entry_file[] = {
94109 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
94110 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
94111 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
94112 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
94113 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
94114 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
94115 +#endif
94116 AA_FS_DIR("features", aa_fs_entry_features),
94117 { }
94118 };
94119 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
94120 index b21830e..a7d1a17 100644
94121 --- a/security/apparmor/lsm.c
94122 +++ b/security/apparmor/lsm.c
94123 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
94124 return error;
94125 }
94126
94127 -static struct security_operations apparmor_ops = {
94128 +static struct security_operations apparmor_ops __read_only = {
94129 .name = "apparmor",
94130
94131 .ptrace_access_check = apparmor_ptrace_access_check,
94132 diff --git a/security/commoncap.c b/security/commoncap.c
94133 index c44b6fe..932df30 100644
94134 --- a/security/commoncap.c
94135 +++ b/security/commoncap.c
94136 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
94137 return 0;
94138 }
94139
94140 +/* returns:
94141 + 1 for suid privilege
94142 + 2 for sgid privilege
94143 + 3 for fscap privilege
94144 +*/
94145 +int is_privileged_binary(const struct dentry *dentry)
94146 +{
94147 + struct cpu_vfs_cap_data capdata;
94148 + struct inode *inode = dentry->d_inode;
94149 +
94150 + if (!inode || S_ISDIR(inode->i_mode))
94151 + return 0;
94152 +
94153 + if (inode->i_mode & S_ISUID)
94154 + return 1;
94155 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
94156 + return 2;
94157 +
94158 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
94159 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
94160 + return 3;
94161 + }
94162 +
94163 + return 0;
94164 +}
94165 +
94166 /*
94167 * Attempt to get the on-exec apply capability sets for an executable file from
94168 * its xattrs and, if present, apply them to the proposed credentials being
94169 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
94170 const struct cred *cred = current_cred();
94171 kuid_t root_uid = make_kuid(cred->user_ns, 0);
94172
94173 + if (gr_acl_enable_at_secure())
94174 + return 1;
94175 +
94176 if (!uid_eq(cred->uid, root_uid)) {
94177 if (bprm->cap_effective)
94178 return 1;
94179 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
94180 index a41c9c1..83da6dd 100644
94181 --- a/security/integrity/ima/ima.h
94182 +++ b/security/integrity/ima/ima.h
94183 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
94184 extern spinlock_t ima_queue_lock;
94185
94186 struct ima_h_table {
94187 - atomic_long_t len; /* number of stored measurements in the list */
94188 - atomic_long_t violations;
94189 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
94190 + atomic_long_unchecked_t violations;
94191 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
94192 };
94193 extern struct ima_h_table ima_htable;
94194 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
94195 index 1c03e8f1..398a941 100644
94196 --- a/security/integrity/ima/ima_api.c
94197 +++ b/security/integrity/ima/ima_api.c
94198 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
94199 int result;
94200
94201 /* can overflow, only indicator */
94202 - atomic_long_inc(&ima_htable.violations);
94203 + atomic_long_inc_unchecked(&ima_htable.violations);
94204
94205 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
94206 if (!entry) {
94207 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
94208 index 38477c9..87a60c7 100644
94209 --- a/security/integrity/ima/ima_fs.c
94210 +++ b/security/integrity/ima/ima_fs.c
94211 @@ -28,12 +28,12 @@
94212 static int valid_policy = 1;
94213 #define TMPBUFLEN 12
94214 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
94215 - loff_t *ppos, atomic_long_t *val)
94216 + loff_t *ppos, atomic_long_unchecked_t *val)
94217 {
94218 char tmpbuf[TMPBUFLEN];
94219 ssize_t len;
94220
94221 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
94222 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
94223 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
94224 }
94225
94226 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
94227 index ff63fe0..809cd96 100644
94228 --- a/security/integrity/ima/ima_queue.c
94229 +++ b/security/integrity/ima/ima_queue.c
94230 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
94231 INIT_LIST_HEAD(&qe->later);
94232 list_add_tail_rcu(&qe->later, &ima_measurements);
94233
94234 - atomic_long_inc(&ima_htable.len);
94235 + atomic_long_inc_unchecked(&ima_htable.len);
94236 key = ima_hash_key(entry->digest);
94237 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
94238 return 0;
94239 diff --git a/security/keys/compat.c b/security/keys/compat.c
94240 index d65fa7f..cbfe366 100644
94241 --- a/security/keys/compat.c
94242 +++ b/security/keys/compat.c
94243 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
94244 if (ret == 0)
94245 goto no_payload_free;
94246
94247 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
94248 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
94249 err:
94250 if (iov != iovstack)
94251 kfree(iov);
94252 diff --git a/security/keys/internal.h b/security/keys/internal.h
94253 index d4f1468..cc52f92 100644
94254 --- a/security/keys/internal.h
94255 +++ b/security/keys/internal.h
94256 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
94257 extern long keyctl_invalidate_key(key_serial_t);
94258
94259 extern long keyctl_instantiate_key_common(key_serial_t,
94260 - const struct iovec *,
94261 + const struct iovec __user *,
94262 unsigned, size_t, key_serial_t);
94263
94264 /*
94265 diff --git a/security/keys/key.c b/security/keys/key.c
94266 index 8fb7c7b..ba3610d 100644
94267 --- a/security/keys/key.c
94268 +++ b/security/keys/key.c
94269 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
94270
94271 atomic_set(&key->usage, 1);
94272 init_rwsem(&key->sem);
94273 - lockdep_set_class(&key->sem, &type->lock_class);
94274 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
94275 key->type = type;
94276 key->user = user;
94277 key->quotalen = quotalen;
94278 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
94279 struct key_type *p;
94280 int ret;
94281
94282 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
94283 + pax_open_kernel();
94284 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
94285 + pax_close_kernel();
94286
94287 ret = -EEXIST;
94288 down_write(&key_types_sem);
94289 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
94290 }
94291
94292 /* store the type */
94293 - list_add(&ktype->link, &key_types_list);
94294 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
94295
94296 pr_notice("Key type %s registered\n", ktype->name);
94297 ret = 0;
94298 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
94299 void unregister_key_type(struct key_type *ktype)
94300 {
94301 down_write(&key_types_sem);
94302 - list_del_init(&ktype->link);
94303 + pax_list_del_init((struct list_head *)&ktype->link);
94304 downgrade_write(&key_types_sem);
94305 key_gc_keytype(ktype);
94306 pr_notice("Key type %s unregistered\n", ktype->name);
94307 @@ -1084,10 +1086,10 @@ void __init key_init(void)
94308 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
94309
94310 /* add the special key types */
94311 - list_add_tail(&key_type_keyring.link, &key_types_list);
94312 - list_add_tail(&key_type_dead.link, &key_types_list);
94313 - list_add_tail(&key_type_user.link, &key_types_list);
94314 - list_add_tail(&key_type_logon.link, &key_types_list);
94315 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
94316 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
94317 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
94318 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
94319
94320 /* record the root user tracking */
94321 rb_link_node(&root_key_user.node,
94322 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
94323 index 33cfd27..842fc5a 100644
94324 --- a/security/keys/keyctl.c
94325 +++ b/security/keys/keyctl.c
94326 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
94327 /*
94328 * Copy the iovec data from userspace
94329 */
94330 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
94331 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
94332 unsigned ioc)
94333 {
94334 for (; ioc > 0; ioc--) {
94335 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
94336 * If successful, 0 will be returned.
94337 */
94338 long keyctl_instantiate_key_common(key_serial_t id,
94339 - const struct iovec *payload_iov,
94340 + const struct iovec __user *payload_iov,
94341 unsigned ioc,
94342 size_t plen,
94343 key_serial_t ringid)
94344 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
94345 [0].iov_len = plen
94346 };
94347
94348 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
94349 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
94350 }
94351
94352 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
94353 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
94354 if (ret == 0)
94355 goto no_payload_free;
94356
94357 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
94358 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
94359 err:
94360 if (iov != iovstack)
94361 kfree(iov);
94362 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
94363 index 6ece7f2..ecdb55c 100644
94364 --- a/security/keys/keyring.c
94365 +++ b/security/keys/keyring.c
94366 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
94367 ret = -EFAULT;
94368
94369 for (loop = 0; loop < klist->nkeys; loop++) {
94370 + key_serial_t serial;
94371 key = rcu_deref_link_locked(klist, loop,
94372 keyring);
94373 + serial = key->serial;
94374
94375 tmp = sizeof(key_serial_t);
94376 if (tmp > buflen)
94377 tmp = buflen;
94378
94379 - if (copy_to_user(buffer,
94380 - &key->serial,
94381 - tmp) != 0)
94382 + if (copy_to_user(buffer, &serial, tmp))
94383 goto error;
94384
94385 buflen -= tmp;
94386 diff --git a/security/min_addr.c b/security/min_addr.c
94387 index f728728..6457a0c 100644
94388 --- a/security/min_addr.c
94389 +++ b/security/min_addr.c
94390 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
94391 */
94392 static void update_mmap_min_addr(void)
94393 {
94394 +#ifndef SPARC
94395 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
94396 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
94397 mmap_min_addr = dac_mmap_min_addr;
94398 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
94399 #else
94400 mmap_min_addr = dac_mmap_min_addr;
94401 #endif
94402 +#endif
94403 }
94404
94405 /*
94406 diff --git a/security/security.c b/security/security.c
94407 index a3dce87..9ca1435 100644
94408 --- a/security/security.c
94409 +++ b/security/security.c
94410 @@ -20,6 +20,7 @@
94411 #include <linux/ima.h>
94412 #include <linux/evm.h>
94413 #include <linux/fsnotify.h>
94414 +#include <linux/mm.h>
94415 #include <linux/mman.h>
94416 #include <linux/mount.h>
94417 #include <linux/personality.h>
94418 @@ -32,8 +33,8 @@
94419 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
94420 CONFIG_DEFAULT_SECURITY;
94421
94422 -static struct security_operations *security_ops;
94423 -static struct security_operations default_security_ops = {
94424 +static struct security_operations *security_ops __read_only;
94425 +static struct security_operations default_security_ops __read_only = {
94426 .name = "default",
94427 };
94428
94429 @@ -74,7 +75,9 @@ int __init security_init(void)
94430
94431 void reset_security_ops(void)
94432 {
94433 + pax_open_kernel();
94434 security_ops = &default_security_ops;
94435 + pax_close_kernel();
94436 }
94437
94438 /* Save user chosen LSM */
94439 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
94440 index 5c6f2cd..b4f945c 100644
94441 --- a/security/selinux/hooks.c
94442 +++ b/security/selinux/hooks.c
94443 @@ -96,8 +96,6 @@
94444
94445 #define NUM_SEL_MNT_OPTS 5
94446
94447 -extern struct security_operations *security_ops;
94448 -
94449 /* SECMARK reference count */
94450 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
94451
94452 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
94453
94454 #endif
94455
94456 -static struct security_operations selinux_ops = {
94457 +static struct security_operations selinux_ops __read_only = {
94458 .name = "selinux",
94459
94460 .ptrace_access_check = selinux_ptrace_access_check,
94461 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
94462 index 65f67cb..3f141ef 100644
94463 --- a/security/selinux/include/xfrm.h
94464 +++ b/security/selinux/include/xfrm.h
94465 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
94466
94467 static inline void selinux_xfrm_notify_policyload(void)
94468 {
94469 - atomic_inc(&flow_cache_genid);
94470 + atomic_inc_unchecked(&flow_cache_genid);
94471 rt_genid_bump(&init_net);
94472 }
94473 #else
94474 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
94475 index d52c780..6431349 100644
94476 --- a/security/smack/smack_lsm.c
94477 +++ b/security/smack/smack_lsm.c
94478 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
94479 return 0;
94480 }
94481
94482 -struct security_operations smack_ops = {
94483 +struct security_operations smack_ops __read_only = {
94484 .name = "smack",
94485
94486 .ptrace_access_check = smack_ptrace_access_check,
94487 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
94488 index 390c646..f2f8db3 100644
94489 --- a/security/tomoyo/mount.c
94490 +++ b/security/tomoyo/mount.c
94491 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
94492 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
94493 need_dev = -1; /* dev_name is a directory */
94494 } else {
94495 + if (!capable(CAP_SYS_ADMIN)) {
94496 + error = -EPERM;
94497 + goto out;
94498 + }
94499 fstype = get_fs_type(type);
94500 if (!fstype) {
94501 error = -ENODEV;
94502 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
94503 index f0b756e..b129202 100644
94504 --- a/security/tomoyo/tomoyo.c
94505 +++ b/security/tomoyo/tomoyo.c
94506 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
94507 * tomoyo_security_ops is a "struct security_operations" which is used for
94508 * registering TOMOYO.
94509 */
94510 -static struct security_operations tomoyo_security_ops = {
94511 +static struct security_operations tomoyo_security_ops __read_only = {
94512 .name = "tomoyo",
94513 .cred_alloc_blank = tomoyo_cred_alloc_blank,
94514 .cred_prepare = tomoyo_cred_prepare,
94515 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
94516 index 20ef514..4182bed 100644
94517 --- a/security/yama/Kconfig
94518 +++ b/security/yama/Kconfig
94519 @@ -1,6 +1,6 @@
94520 config SECURITY_YAMA
94521 bool "Yama support"
94522 - depends on SECURITY
94523 + depends on SECURITY && !GRKERNSEC
94524 select SECURITYFS
94525 select SECURITY_PATH
94526 default n
94527 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
94528 index 13c88fbc..f8c115e 100644
94529 --- a/security/yama/yama_lsm.c
94530 +++ b/security/yama/yama_lsm.c
94531 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
94532 }
94533
94534 #ifndef CONFIG_SECURITY_YAMA_STACKED
94535 -static struct security_operations yama_ops = {
94536 +static struct security_operations yama_ops __read_only = {
94537 .name = "yama",
94538
94539 .ptrace_access_check = yama_ptrace_access_check,
94540 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
94541 #endif
94542
94543 #ifdef CONFIG_SYSCTL
94544 +static int zero __read_only;
94545 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
94546 +
94547 static int yama_dointvec_minmax(struct ctl_table *table, int write,
94548 void __user *buffer, size_t *lenp, loff_t *ppos)
94549 {
94550 - int rc;
94551 + ctl_table_no_const yama_table;
94552
94553 if (write && !capable(CAP_SYS_PTRACE))
94554 return -EPERM;
94555
94556 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
94557 - if (rc)
94558 - return rc;
94559 -
94560 + yama_table = *table;
94561 /* Lock the max value if it ever gets set. */
94562 - if (write && *(int *)table->data == *(int *)table->extra2)
94563 - table->extra1 = table->extra2;
94564 -
94565 - return rc;
94566 + if (ptrace_scope == max_scope)
94567 + yama_table.extra1 = &max_scope;
94568 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
94569 }
94570
94571 -static int zero;
94572 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
94573 -
94574 struct ctl_path yama_sysctl_path[] = {
94575 { .procname = "kernel", },
94576 { .procname = "yama", },
94577 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
94578 index 4cedc69..e59d8a3 100644
94579 --- a/sound/aoa/codecs/onyx.c
94580 +++ b/sound/aoa/codecs/onyx.c
94581 @@ -54,7 +54,7 @@ struct onyx {
94582 spdif_locked:1,
94583 analog_locked:1,
94584 original_mute:2;
94585 - int open_count;
94586 + local_t open_count;
94587 struct codec_info *codec_info;
94588
94589 /* mutex serializes concurrent access to the device
94590 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
94591 struct onyx *onyx = cii->codec_data;
94592
94593 mutex_lock(&onyx->mutex);
94594 - onyx->open_count++;
94595 + local_inc(&onyx->open_count);
94596 mutex_unlock(&onyx->mutex);
94597
94598 return 0;
94599 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
94600 struct onyx *onyx = cii->codec_data;
94601
94602 mutex_lock(&onyx->mutex);
94603 - onyx->open_count--;
94604 - if (!onyx->open_count)
94605 + if (local_dec_and_test(&onyx->open_count))
94606 onyx->spdif_locked = onyx->analog_locked = 0;
94607 mutex_unlock(&onyx->mutex);
94608
94609 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
94610 index ffd2025..df062c9 100644
94611 --- a/sound/aoa/codecs/onyx.h
94612 +++ b/sound/aoa/codecs/onyx.h
94613 @@ -11,6 +11,7 @@
94614 #include <linux/i2c.h>
94615 #include <asm/pmac_low_i2c.h>
94616 #include <asm/prom.h>
94617 +#include <asm/local.h>
94618
94619 /* PCM3052 register definitions */
94620
94621 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
94622 index 4c1cc51..16040040 100644
94623 --- a/sound/core/oss/pcm_oss.c
94624 +++ b/sound/core/oss/pcm_oss.c
94625 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
94626 if (in_kernel) {
94627 mm_segment_t fs;
94628 fs = snd_enter_user();
94629 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
94630 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
94631 snd_leave_user(fs);
94632 } else {
94633 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
94634 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
94635 }
94636 if (ret != -EPIPE && ret != -ESTRPIPE)
94637 break;
94638 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
94639 if (in_kernel) {
94640 mm_segment_t fs;
94641 fs = snd_enter_user();
94642 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
94643 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
94644 snd_leave_user(fs);
94645 } else {
94646 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
94647 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
94648 }
94649 if (ret == -EPIPE) {
94650 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
94651 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
94652 struct snd_pcm_plugin_channel *channels;
94653 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
94654 if (!in_kernel) {
94655 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
94656 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
94657 return -EFAULT;
94658 buf = runtime->oss.buffer;
94659 }
94660 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
94661 }
94662 } else {
94663 tmp = snd_pcm_oss_write2(substream,
94664 - (const char __force *)buf,
94665 + (const char __force_kernel *)buf,
94666 runtime->oss.period_bytes, 0);
94667 if (tmp <= 0)
94668 goto err;
94669 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
94670 struct snd_pcm_runtime *runtime = substream->runtime;
94671 snd_pcm_sframes_t frames, frames1;
94672 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
94673 - char __user *final_dst = (char __force __user *)buf;
94674 + char __user *final_dst = (char __force_user *)buf;
94675 if (runtime->oss.plugin_first) {
94676 struct snd_pcm_plugin_channel *channels;
94677 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
94678 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
94679 xfer += tmp;
94680 runtime->oss.buffer_used -= tmp;
94681 } else {
94682 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
94683 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
94684 runtime->oss.period_bytes, 0);
94685 if (tmp <= 0)
94686 goto err;
94687 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
94688 size1);
94689 size1 /= runtime->channels; /* frames */
94690 fs = snd_enter_user();
94691 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
94692 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
94693 snd_leave_user(fs);
94694 }
94695 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
94696 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
94697 index af49721..e85058e 100644
94698 --- a/sound/core/pcm_compat.c
94699 +++ b/sound/core/pcm_compat.c
94700 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
94701 int err;
94702
94703 fs = snd_enter_user();
94704 - err = snd_pcm_delay(substream, &delay);
94705 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
94706 snd_leave_user(fs);
94707 if (err < 0)
94708 return err;
94709 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
94710 index f928181..33fb83d 100644
94711 --- a/sound/core/pcm_native.c
94712 +++ b/sound/core/pcm_native.c
94713 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
94714 switch (substream->stream) {
94715 case SNDRV_PCM_STREAM_PLAYBACK:
94716 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
94717 - (void __user *)arg);
94718 + (void __force_user *)arg);
94719 break;
94720 case SNDRV_PCM_STREAM_CAPTURE:
94721 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
94722 - (void __user *)arg);
94723 + (void __force_user *)arg);
94724 break;
94725 default:
94726 result = -EINVAL;
94727 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
94728 index 040c60e..989a19a 100644
94729 --- a/sound/core/seq/seq_device.c
94730 +++ b/sound/core/seq/seq_device.c
94731 @@ -64,7 +64,7 @@ struct ops_list {
94732 int argsize; /* argument size */
94733
94734 /* operators */
94735 - struct snd_seq_dev_ops ops;
94736 + struct snd_seq_dev_ops *ops;
94737
94738 /* registered devices */
94739 struct list_head dev_list; /* list of devices */
94740 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
94741
94742 mutex_lock(&ops->reg_mutex);
94743 /* copy driver operators */
94744 - ops->ops = *entry;
94745 + ops->ops = entry;
94746 ops->driver |= DRIVER_LOADED;
94747 ops->argsize = argsize;
94748
94749 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
94750 dev->name, ops->id, ops->argsize, dev->argsize);
94751 return -EINVAL;
94752 }
94753 - if (ops->ops.init_device(dev) >= 0) {
94754 + if (ops->ops->init_device(dev) >= 0) {
94755 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
94756 ops->num_init_devices++;
94757 } else {
94758 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
94759 dev->name, ops->id, ops->argsize, dev->argsize);
94760 return -EINVAL;
94761 }
94762 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
94763 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
94764 dev->status = SNDRV_SEQ_DEVICE_FREE;
94765 dev->driver_data = NULL;
94766 ops->num_init_devices--;
94767 diff --git a/sound/core/sound.c b/sound/core/sound.c
94768 index f002bd9..c462985 100644
94769 --- a/sound/core/sound.c
94770 +++ b/sound/core/sound.c
94771 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
94772 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
94773 default: return;
94774 }
94775 - request_module(str);
94776 + request_module("%s", str);
94777 }
94778
94779 #endif /* modular kernel */
94780 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
94781 index 4e0dd22..7a1f32c 100644
94782 --- a/sound/drivers/mts64.c
94783 +++ b/sound/drivers/mts64.c
94784 @@ -29,6 +29,7 @@
94785 #include <sound/initval.h>
94786 #include <sound/rawmidi.h>
94787 #include <sound/control.h>
94788 +#include <asm/local.h>
94789
94790 #define CARD_NAME "Miditerminal 4140"
94791 #define DRIVER_NAME "MTS64"
94792 @@ -67,7 +68,7 @@ struct mts64 {
94793 struct pardevice *pardev;
94794 int pardev_claimed;
94795
94796 - int open_count;
94797 + local_t open_count;
94798 int current_midi_output_port;
94799 int current_midi_input_port;
94800 u8 mode[MTS64_NUM_INPUT_PORTS];
94801 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94802 {
94803 struct mts64 *mts = substream->rmidi->private_data;
94804
94805 - if (mts->open_count == 0) {
94806 + if (local_read(&mts->open_count) == 0) {
94807 /* We don't need a spinlock here, because this is just called
94808 if the device has not been opened before.
94809 So there aren't any IRQs from the device */
94810 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94811
94812 msleep(50);
94813 }
94814 - ++(mts->open_count);
94815 + local_inc(&mts->open_count);
94816
94817 return 0;
94818 }
94819 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94820 struct mts64 *mts = substream->rmidi->private_data;
94821 unsigned long flags;
94822
94823 - --(mts->open_count);
94824 - if (mts->open_count == 0) {
94825 + if (local_dec_return(&mts->open_count) == 0) {
94826 /* We need the spinlock_irqsave here because we can still
94827 have IRQs at this point */
94828 spin_lock_irqsave(&mts->lock, flags);
94829 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94830
94831 msleep(500);
94832
94833 - } else if (mts->open_count < 0)
94834 - mts->open_count = 0;
94835 + } else if (local_read(&mts->open_count) < 0)
94836 + local_set(&mts->open_count, 0);
94837
94838 return 0;
94839 }
94840 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
94841 index b953fb4..1999c01 100644
94842 --- a/sound/drivers/opl4/opl4_lib.c
94843 +++ b/sound/drivers/opl4/opl4_lib.c
94844 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
94845 MODULE_DESCRIPTION("OPL4 driver");
94846 MODULE_LICENSE("GPL");
94847
94848 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
94849 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
94850 {
94851 int timeout = 10;
94852 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
94853 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
94854 index 991018d..8984740 100644
94855 --- a/sound/drivers/portman2x4.c
94856 +++ b/sound/drivers/portman2x4.c
94857 @@ -48,6 +48,7 @@
94858 #include <sound/initval.h>
94859 #include <sound/rawmidi.h>
94860 #include <sound/control.h>
94861 +#include <asm/local.h>
94862
94863 #define CARD_NAME "Portman 2x4"
94864 #define DRIVER_NAME "portman"
94865 @@ -85,7 +86,7 @@ struct portman {
94866 struct pardevice *pardev;
94867 int pardev_claimed;
94868
94869 - int open_count;
94870 + local_t open_count;
94871 int mode[PORTMAN_NUM_INPUT_PORTS];
94872 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
94873 };
94874 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
94875 index ea995af..f1bfa37 100644
94876 --- a/sound/firewire/amdtp.c
94877 +++ b/sound/firewire/amdtp.c
94878 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
94879 ptr = s->pcm_buffer_pointer + data_blocks;
94880 if (ptr >= pcm->runtime->buffer_size)
94881 ptr -= pcm->runtime->buffer_size;
94882 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
94883 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
94884
94885 s->pcm_period_pointer += data_blocks;
94886 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
94887 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
94888 */
94889 void amdtp_out_stream_update(struct amdtp_out_stream *s)
94890 {
94891 - ACCESS_ONCE(s->source_node_id_field) =
94892 + ACCESS_ONCE_RW(s->source_node_id_field) =
94893 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
94894 }
94895 EXPORT_SYMBOL(amdtp_out_stream_update);
94896 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
94897 index b680c5e..061b7a0 100644
94898 --- a/sound/firewire/amdtp.h
94899 +++ b/sound/firewire/amdtp.h
94900 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
94901 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
94902 struct snd_pcm_substream *pcm)
94903 {
94904 - ACCESS_ONCE(s->pcm) = pcm;
94905 + ACCESS_ONCE_RW(s->pcm) = pcm;
94906 }
94907
94908 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
94909 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
94910 index d428ffe..751ef78 100644
94911 --- a/sound/firewire/isight.c
94912 +++ b/sound/firewire/isight.c
94913 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
94914 ptr += count;
94915 if (ptr >= runtime->buffer_size)
94916 ptr -= runtime->buffer_size;
94917 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
94918 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
94919
94920 isight->period_counter += count;
94921 if (isight->period_counter >= runtime->period_size) {
94922 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
94923 if (err < 0)
94924 return err;
94925
94926 - ACCESS_ONCE(isight->pcm_active) = true;
94927 + ACCESS_ONCE_RW(isight->pcm_active) = true;
94928
94929 return 0;
94930 }
94931 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
94932 {
94933 struct isight *isight = substream->private_data;
94934
94935 - ACCESS_ONCE(isight->pcm_active) = false;
94936 + ACCESS_ONCE_RW(isight->pcm_active) = false;
94937
94938 mutex_lock(&isight->mutex);
94939 isight_stop_streaming(isight);
94940 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
94941
94942 switch (cmd) {
94943 case SNDRV_PCM_TRIGGER_START:
94944 - ACCESS_ONCE(isight->pcm_running) = true;
94945 + ACCESS_ONCE_RW(isight->pcm_running) = true;
94946 break;
94947 case SNDRV_PCM_TRIGGER_STOP:
94948 - ACCESS_ONCE(isight->pcm_running) = false;
94949 + ACCESS_ONCE_RW(isight->pcm_running) = false;
94950 break;
94951 default:
94952 return -EINVAL;
94953 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
94954 index 844a555..985ab83 100644
94955 --- a/sound/firewire/scs1x.c
94956 +++ b/sound/firewire/scs1x.c
94957 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
94958 {
94959 struct scs *scs = stream->rmidi->private_data;
94960
94961 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
94962 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
94963 if (up) {
94964 scs->output_idle = false;
94965 tasklet_schedule(&scs->tasklet);
94966 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
94967 {
94968 struct scs *scs = stream->rmidi->private_data;
94969
94970 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
94971 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
94972 }
94973
94974 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
94975 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
94976
94977 snd_card_disconnect(scs->card);
94978
94979 - ACCESS_ONCE(scs->output) = NULL;
94980 - ACCESS_ONCE(scs->input) = NULL;
94981 + ACCESS_ONCE_RW(scs->output) = NULL;
94982 + ACCESS_ONCE_RW(scs->input) = NULL;
94983
94984 wait_event(scs->idle_wait, scs->output_idle);
94985
94986 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
94987 index 048439a..3be9f6f 100644
94988 --- a/sound/oss/sb_audio.c
94989 +++ b/sound/oss/sb_audio.c
94990 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
94991 buf16 = (signed short *)(localbuf + localoffs);
94992 while (c)
94993 {
94994 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94995 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94996 if (copy_from_user(lbuf8,
94997 userbuf+useroffs + p,
94998 locallen))
94999 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
95000 index 7d8803a..559f8d0 100644
95001 --- a/sound/oss/swarm_cs4297a.c
95002 +++ b/sound/oss/swarm_cs4297a.c
95003 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
95004 {
95005 struct cs4297a_state *s;
95006 u32 pwr, id;
95007 - mm_segment_t fs;
95008 int rval;
95009 #ifndef CONFIG_BCM_CS4297A_CSWARM
95010 u64 cfg;
95011 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
95012 if (!rval) {
95013 char *sb1250_duart_present;
95014
95015 +#if 0
95016 + mm_segment_t fs;
95017 fs = get_fs();
95018 set_fs(KERNEL_DS);
95019 -#if 0
95020 val = SOUND_MASK_LINE;
95021 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
95022 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
95023 val = initvol[i].vol;
95024 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
95025 }
95026 + set_fs(fs);
95027 // cs4297a_write_ac97(s, 0x18, 0x0808);
95028 #else
95029 // cs4297a_write_ac97(s, 0x5e, 0x180);
95030 cs4297a_write_ac97(s, 0x02, 0x0808);
95031 cs4297a_write_ac97(s, 0x18, 0x0808);
95032 #endif
95033 - set_fs(fs);
95034
95035 list_add(&s->list, &cs4297a_devs);
95036
95037 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
95038 index 4631a23..001ae57 100644
95039 --- a/sound/pci/ymfpci/ymfpci.h
95040 +++ b/sound/pci/ymfpci/ymfpci.h
95041 @@ -358,7 +358,7 @@ struct snd_ymfpci {
95042 spinlock_t reg_lock;
95043 spinlock_t voice_lock;
95044 wait_queue_head_t interrupt_sleep;
95045 - atomic_t interrupt_sleep_count;
95046 + atomic_unchecked_t interrupt_sleep_count;
95047 struct snd_info_entry *proc_entry;
95048 const struct firmware *dsp_microcode;
95049 const struct firmware *controller_microcode;
95050 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
95051 index 22056c5..25d3244 100644
95052 --- a/sound/pci/ymfpci/ymfpci_main.c
95053 +++ b/sound/pci/ymfpci/ymfpci_main.c
95054 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
95055 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
95056 break;
95057 }
95058 - if (atomic_read(&chip->interrupt_sleep_count)) {
95059 - atomic_set(&chip->interrupt_sleep_count, 0);
95060 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
95061 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
95062 wake_up(&chip->interrupt_sleep);
95063 }
95064 __end:
95065 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
95066 continue;
95067 init_waitqueue_entry(&wait, current);
95068 add_wait_queue(&chip->interrupt_sleep, &wait);
95069 - atomic_inc(&chip->interrupt_sleep_count);
95070 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
95071 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
95072 remove_wait_queue(&chip->interrupt_sleep, &wait);
95073 }
95074 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
95075 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
95076 spin_unlock(&chip->reg_lock);
95077
95078 - if (atomic_read(&chip->interrupt_sleep_count)) {
95079 - atomic_set(&chip->interrupt_sleep_count, 0);
95080 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
95081 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
95082 wake_up(&chip->interrupt_sleep);
95083 }
95084 }
95085 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
95086 spin_lock_init(&chip->reg_lock);
95087 spin_lock_init(&chip->voice_lock);
95088 init_waitqueue_head(&chip->interrupt_sleep);
95089 - atomic_set(&chip->interrupt_sleep_count, 0);
95090 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
95091 chip->card = card;
95092 chip->pci = pci;
95093 chip->irq = -1;
95094 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
95095 index 0f0bed6..c161e28 100644
95096 --- a/sound/soc/fsl/fsl_ssi.c
95097 +++ b/sound/soc/fsl/fsl_ssi.c
95098 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
95099 {
95100 struct fsl_ssi_private *ssi_private;
95101 int ret = 0;
95102 - struct device_attribute *dev_attr = NULL;
95103 + device_attribute_no_const *dev_attr = NULL;
95104 struct device_node *np = pdev->dev.of_node;
95105 const char *p, *sprop;
95106 const uint32_t *iprop;
95107 diff --git a/sound/sound_core.c b/sound/sound_core.c
95108 index 359753f..45759f4 100644
95109 --- a/sound/sound_core.c
95110 +++ b/sound/sound_core.c
95111 @@ -292,7 +292,7 @@ retry:
95112 }
95113
95114 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
95115 - NULL, s->name+6);
95116 + NULL, "%s", s->name+6);
95117 return s->unit_minor;
95118
95119 fail:
95120 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
95121 new file mode 100644
95122 index 0000000..50f2f2f
95123 --- /dev/null
95124 +++ b/tools/gcc/.gitignore
95125 @@ -0,0 +1 @@
95126 +size_overflow_hash.h
95127 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
95128 new file mode 100644
95129 index 0000000..144dbee
95130 --- /dev/null
95131 +++ b/tools/gcc/Makefile
95132 @@ -0,0 +1,45 @@
95133 +#CC := gcc
95134 +#PLUGIN_SOURCE_FILES := pax_plugin.c
95135 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
95136 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
95137 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
95138 +
95139 +ifeq ($(PLUGINCC),$(HOSTCC))
95140 +HOSTLIBS := hostlibs
95141 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
95142 +else
95143 +HOSTLIBS := hostcxxlibs
95144 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
95145 +endif
95146 +
95147 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
95148 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
95149 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
95150 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
95151 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
95152 +$(HOSTLIBS)-y += colorize_plugin.so
95153 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
95154 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
95155 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
95156 +
95157 +always := $($(HOSTLIBS)-y)
95158 +
95159 +constify_plugin-objs := constify_plugin.o
95160 +stackleak_plugin-objs := stackleak_plugin.o
95161 +kallocstat_plugin-objs := kallocstat_plugin.o
95162 +kernexec_plugin-objs := kernexec_plugin.o
95163 +checker_plugin-objs := checker_plugin.o
95164 +colorize_plugin-objs := colorize_plugin.o
95165 +size_overflow_plugin-objs := size_overflow_plugin.o
95166 +latent_entropy_plugin-objs := latent_entropy_plugin.o
95167 +structleak_plugin-objs := structleak_plugin.o
95168 +
95169 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
95170 +
95171 +quiet_cmd_build_size_overflow_hash = GENHASH $@
95172 + cmd_build_size_overflow_hash = \
95173 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
95174 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
95175 + $(call if_changed,build_size_overflow_hash)
95176 +
95177 +targets += size_overflow_hash.h
95178 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
95179 new file mode 100644
95180 index 0000000..22f03c0
95181 --- /dev/null
95182 +++ b/tools/gcc/checker_plugin.c
95183 @@ -0,0 +1,172 @@
95184 +/*
95185 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
95186 + * Licensed under the GPL v2
95187 + *
95188 + * Note: the choice of the license means that the compilation process is
95189 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95190 + * but for the kernel it doesn't matter since it doesn't link against
95191 + * any of the gcc libraries
95192 + *
95193 + * gcc plugin to implement various sparse (source code checker) features
95194 + *
95195 + * TODO:
95196 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
95197 + *
95198 + * BUGS:
95199 + * - none known
95200 + */
95201 +#include "gcc-plugin.h"
95202 +#include "config.h"
95203 +#include "system.h"
95204 +#include "coretypes.h"
95205 +#include "tree.h"
95206 +#include "tree-pass.h"
95207 +#include "flags.h"
95208 +#include "intl.h"
95209 +#include "toplev.h"
95210 +#include "plugin.h"
95211 +//#include "expr.h" where are you...
95212 +#include "diagnostic.h"
95213 +#include "plugin-version.h"
95214 +#include "tm.h"
95215 +#include "function.h"
95216 +#include "basic-block.h"
95217 +#include "gimple.h"
95218 +#include "rtl.h"
95219 +#include "emit-rtl.h"
95220 +#include "tree-flow.h"
95221 +#include "target.h"
95222 +
95223 +extern void c_register_addr_space (const char *str, addr_space_t as);
95224 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
95225 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
95226 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
95227 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
95228 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
95229 +
95230 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95231 +extern rtx emit_move_insn(rtx x, rtx y);
95232 +
95233 +int plugin_is_GPL_compatible;
95234 +
95235 +static struct plugin_info checker_plugin_info = {
95236 + .version = "201111150100",
95237 + .help = NULL,
95238 +};
95239 +
95240 +#define ADDR_SPACE_KERNEL 0
95241 +#define ADDR_SPACE_FORCE_KERNEL 1
95242 +#define ADDR_SPACE_USER 2
95243 +#define ADDR_SPACE_FORCE_USER 3
95244 +#define ADDR_SPACE_IOMEM 0
95245 +#define ADDR_SPACE_FORCE_IOMEM 0
95246 +#define ADDR_SPACE_PERCPU 0
95247 +#define ADDR_SPACE_FORCE_PERCPU 0
95248 +#define ADDR_SPACE_RCU 0
95249 +#define ADDR_SPACE_FORCE_RCU 0
95250 +
95251 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
95252 +{
95253 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
95254 +}
95255 +
95256 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
95257 +{
95258 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
95259 +}
95260 +
95261 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
95262 +{
95263 + return default_addr_space_valid_pointer_mode(mode, as);
95264 +}
95265 +
95266 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
95267 +{
95268 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
95269 +}
95270 +
95271 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
95272 +{
95273 + return default_addr_space_legitimize_address(x, oldx, mode, as);
95274 +}
95275 +
95276 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
95277 +{
95278 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
95279 + return true;
95280 +
95281 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
95282 + return true;
95283 +
95284 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
95285 + return true;
95286 +
95287 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
95288 + return true;
95289 +
95290 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
95291 + return true;
95292 +
95293 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
95294 + return true;
95295 +
95296 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
95297 + return true;
95298 +
95299 + return subset == superset;
95300 +}
95301 +
95302 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
95303 +{
95304 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
95305 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
95306 +
95307 + return op;
95308 +}
95309 +
95310 +static void register_checker_address_spaces(void *event_data, void *data)
95311 +{
95312 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
95313 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
95314 + c_register_addr_space("__user", ADDR_SPACE_USER);
95315 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
95316 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
95317 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
95318 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
95319 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
95320 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
95321 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
95322 +
95323 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
95324 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
95325 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
95326 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
95327 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
95328 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
95329 + targetm.addr_space.convert = checker_addr_space_convert;
95330 +}
95331 +
95332 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95333 +{
95334 + const char * const plugin_name = plugin_info->base_name;
95335 + const int argc = plugin_info->argc;
95336 + const struct plugin_argument * const argv = plugin_info->argv;
95337 + int i;
95338 +
95339 + if (!plugin_default_version_check(version, &gcc_version)) {
95340 + error(G_("incompatible gcc/plugin versions"));
95341 + return 1;
95342 + }
95343 +
95344 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
95345 +
95346 + for (i = 0; i < argc; ++i)
95347 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95348 +
95349 + if (TARGET_64BIT == 0)
95350 + return 0;
95351 +
95352 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
95353 +
95354 + return 0;
95355 +}
95356 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
95357 new file mode 100644
95358 index 0000000..414fe5e
95359 --- /dev/null
95360 +++ b/tools/gcc/colorize_plugin.c
95361 @@ -0,0 +1,151 @@
95362 +/*
95363 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
95364 + * Licensed under the GPL v2
95365 + *
95366 + * Note: the choice of the license means that the compilation process is
95367 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95368 + * but for the kernel it doesn't matter since it doesn't link against
95369 + * any of the gcc libraries
95370 + *
95371 + * gcc plugin to colorize diagnostic output
95372 + *
95373 + */
95374 +
95375 +#include "gcc-plugin.h"
95376 +#include "config.h"
95377 +#include "system.h"
95378 +#include "coretypes.h"
95379 +#include "tree.h"
95380 +#include "tree-pass.h"
95381 +#include "flags.h"
95382 +#include "intl.h"
95383 +#include "toplev.h"
95384 +#include "plugin.h"
95385 +#include "diagnostic.h"
95386 +#include "plugin-version.h"
95387 +#include "tm.h"
95388 +
95389 +int plugin_is_GPL_compatible;
95390 +
95391 +static struct plugin_info colorize_plugin_info = {
95392 + .version = "201302112000",
95393 + .help = NULL,
95394 +};
95395 +
95396 +#define GREEN "\033[32m\033[2m"
95397 +#define LIGHTGREEN "\033[32m\033[1m"
95398 +#define YELLOW "\033[33m\033[2m"
95399 +#define LIGHTYELLOW "\033[33m\033[1m"
95400 +#define RED "\033[31m\033[2m"
95401 +#define LIGHTRED "\033[31m\033[1m"
95402 +#define BLUE "\033[34m\033[2m"
95403 +#define LIGHTBLUE "\033[34m\033[1m"
95404 +#define BRIGHT "\033[m\033[1m"
95405 +#define NORMAL "\033[m"
95406 +
95407 +static diagnostic_starter_fn old_starter;
95408 +static diagnostic_finalizer_fn old_finalizer;
95409 +
95410 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
95411 +{
95412 + const char *color;
95413 + char *newprefix;
95414 +
95415 + switch (diagnostic->kind) {
95416 + case DK_NOTE:
95417 + color = LIGHTBLUE;
95418 + break;
95419 +
95420 + case DK_PEDWARN:
95421 + case DK_WARNING:
95422 + color = LIGHTYELLOW;
95423 + break;
95424 +
95425 + case DK_ERROR:
95426 + case DK_FATAL:
95427 + case DK_ICE:
95428 + case DK_PERMERROR:
95429 + case DK_SORRY:
95430 + color = LIGHTRED;
95431 + break;
95432 +
95433 + default:
95434 + color = NORMAL;
95435 + }
95436 +
95437 + old_starter(context, diagnostic);
95438 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
95439 + return;
95440 + pp_destroy_prefix(context->printer);
95441 + pp_set_prefix(context->printer, newprefix);
95442 +}
95443 +
95444 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
95445 +{
95446 + old_finalizer(context, diagnostic);
95447 +}
95448 +
95449 +static void colorize_arm(void)
95450 +{
95451 + old_starter = diagnostic_starter(global_dc);
95452 + old_finalizer = diagnostic_finalizer(global_dc);
95453 +
95454 + diagnostic_starter(global_dc) = start_colorize;
95455 + diagnostic_finalizer(global_dc) = finalize_colorize;
95456 +}
95457 +
95458 +static unsigned int execute_colorize_rearm(void)
95459 +{
95460 + if (diagnostic_starter(global_dc) == start_colorize)
95461 + return 0;
95462 +
95463 + colorize_arm();
95464 + return 0;
95465 +}
95466 +
95467 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
95468 + .pass = {
95469 + .type = SIMPLE_IPA_PASS,
95470 + .name = "colorize_rearm",
95471 +#if BUILDING_GCC_VERSION >= 4008
95472 + .optinfo_flags = OPTGROUP_NONE,
95473 +#endif
95474 + .gate = NULL,
95475 + .execute = execute_colorize_rearm,
95476 + .sub = NULL,
95477 + .next = NULL,
95478 + .static_pass_number = 0,
95479 + .tv_id = TV_NONE,
95480 + .properties_required = 0,
95481 + .properties_provided = 0,
95482 + .properties_destroyed = 0,
95483 + .todo_flags_start = 0,
95484 + .todo_flags_finish = 0
95485 + }
95486 +};
95487 +
95488 +static void colorize_start_unit(void *gcc_data, void *user_data)
95489 +{
95490 + colorize_arm();
95491 +}
95492 +
95493 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95494 +{
95495 + const char * const plugin_name = plugin_info->base_name;
95496 + struct register_pass_info colorize_rearm_pass_info = {
95497 + .pass = &pass_ipa_colorize_rearm.pass,
95498 + .reference_pass_name = "*free_lang_data",
95499 + .ref_pass_instance_number = 1,
95500 + .pos_op = PASS_POS_INSERT_AFTER
95501 + };
95502 +
95503 + if (!plugin_default_version_check(version, &gcc_version)) {
95504 + error(G_("incompatible gcc/plugin versions"));
95505 + return 1;
95506 + }
95507 +
95508 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
95509 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
95510 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
95511 + return 0;
95512 +}
95513 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
95514 new file mode 100644
95515 index 0000000..c17312d
95516 --- /dev/null
95517 +++ b/tools/gcc/constify_plugin.c
95518 @@ -0,0 +1,560 @@
95519 +/*
95520 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
95521 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
95522 + * Licensed under the GPL v2, or (at your option) v3
95523 + *
95524 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
95525 + *
95526 + * Homepage:
95527 + * http://www.grsecurity.net/~ephox/const_plugin/
95528 + *
95529 + * Usage:
95530 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
95531 + * $ gcc -fplugin=constify_plugin.so test.c -O2
95532 + */
95533 +
95534 +#include "gcc-plugin.h"
95535 +#include "config.h"
95536 +#include "system.h"
95537 +#include "coretypes.h"
95538 +#include "tree.h"
95539 +#include "tree-pass.h"
95540 +#include "flags.h"
95541 +#include "intl.h"
95542 +#include "toplev.h"
95543 +#include "plugin.h"
95544 +#include "diagnostic.h"
95545 +#include "plugin-version.h"
95546 +#include "tm.h"
95547 +#include "function.h"
95548 +#include "basic-block.h"
95549 +#include "gimple.h"
95550 +#include "rtl.h"
95551 +#include "emit-rtl.h"
95552 +#include "tree-flow.h"
95553 +#include "target.h"
95554 +#include "langhooks.h"
95555 +
95556 +// should come from c-tree.h if only it were installed for gcc 4.5...
95557 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
95558 +
95559 +// unused type flag in all versions 4.5-4.8
95560 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
95561 +
95562 +int plugin_is_GPL_compatible;
95563 +
95564 +static struct plugin_info const_plugin_info = {
95565 + .version = "201305231310",
95566 + .help = "no-constify\tturn off constification\n",
95567 +};
95568 +
95569 +typedef struct {
95570 + bool has_fptr_field;
95571 + bool has_writable_field;
95572 + bool has_do_const_field;
95573 + bool has_no_const_field;
95574 +} constify_info;
95575 +
95576 +static const_tree get_field_type(const_tree field)
95577 +{
95578 + return strip_array_types(TREE_TYPE(field));
95579 +}
95580 +
95581 +static bool is_fptr(const_tree field)
95582 +{
95583 + const_tree ptr = get_field_type(field);
95584 +
95585 + if (TREE_CODE(ptr) != POINTER_TYPE)
95586 + return false;
95587 +
95588 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
95589 +}
95590 +
95591 +/*
95592 + * determine whether the given structure type meets the requirements for automatic constification,
95593 + * including the constification attributes on nested structure types
95594 + */
95595 +static void constifiable(const_tree node, constify_info *cinfo)
95596 +{
95597 + const_tree field;
95598 +
95599 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
95600 +
95601 + // e.g., pointer to structure fields while still constructing the structure type
95602 + if (TYPE_FIELDS(node) == NULL_TREE)
95603 + return;
95604 +
95605 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
95606 + const_tree type = get_field_type(field);
95607 + enum tree_code code = TREE_CODE(type);
95608 +
95609 + if (node == type)
95610 + continue;
95611 +
95612 + if (is_fptr(field))
95613 + cinfo->has_fptr_field = true;
95614 + else if (!TREE_READONLY(field))
95615 + cinfo->has_writable_field = true;
95616 +
95617 + if (code == RECORD_TYPE || code == UNION_TYPE) {
95618 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95619 + cinfo->has_do_const_field = true;
95620 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
95621 + cinfo->has_no_const_field = true;
95622 + else
95623 + constifiable(type, cinfo);
95624 + }
95625 + }
95626 +}
95627 +
95628 +static bool constified(const_tree node)
95629 +{
95630 + constify_info cinfo = {
95631 + .has_fptr_field = false,
95632 + .has_writable_field = false,
95633 + .has_do_const_field = false,
95634 + .has_no_const_field = false
95635 + };
95636 +
95637 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
95638 +
95639 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
95640 + gcc_assert(!TYPE_READONLY(node));
95641 + return false;
95642 + }
95643 +
95644 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
95645 + gcc_assert(TYPE_READONLY(node));
95646 + return true;
95647 + }
95648 +
95649 + constifiable(node, &cinfo);
95650 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
95651 + return false;
95652 +
95653 + return TYPE_READONLY(node);
95654 +}
95655 +
95656 +static void deconstify_tree(tree node);
95657 +
95658 +static void deconstify_type(tree type)
95659 +{
95660 + tree field;
95661 +
95662 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
95663 +
95664 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
95665 + const_tree fieldtype = get_field_type(field);
95666 +
95667 + // special case handling of simple ptr-to-same-array-type members
95668 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
95669 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
95670 +
95671 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
95672 + continue;
95673 + if (TREE_TYPE(TREE_TYPE(field)) == type)
95674 + continue;
95675 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
95676 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
95677 + TREE_TYPE(TREE_TYPE(field)) = type;
95678 + }
95679 + continue;
95680 + }
95681 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
95682 + continue;
95683 + if (!constified(fieldtype))
95684 + continue;
95685 +
95686 + deconstify_tree(field);
95687 + TREE_READONLY(field) = 0;
95688 + }
95689 + TYPE_READONLY(type) = 0;
95690 + C_TYPE_FIELDS_READONLY(type) = 0;
95691 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95692 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
95693 +}
95694 +
95695 +static void deconstify_tree(tree node)
95696 +{
95697 + tree old_type, new_type, field;
95698 +
95699 + old_type = TREE_TYPE(node);
95700 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
95701 + node = TREE_TYPE(node) = copy_node(old_type);
95702 + old_type = TREE_TYPE(old_type);
95703 + }
95704 +
95705 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
95706 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
95707 +
95708 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
95709 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
95710 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
95711 + DECL_FIELD_CONTEXT(field) = new_type;
95712 +
95713 + deconstify_type(new_type);
95714 +
95715 + TREE_TYPE(node) = new_type;
95716 +}
95717 +
95718 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95719 +{
95720 + tree type;
95721 + constify_info cinfo = {
95722 + .has_fptr_field = false,
95723 + .has_writable_field = false,
95724 + .has_do_const_field = false,
95725 + .has_no_const_field = false
95726 + };
95727 +
95728 + *no_add_attrs = true;
95729 + if (TREE_CODE(*node) == FUNCTION_DECL) {
95730 + error("%qE attribute does not apply to functions", name);
95731 + return NULL_TREE;
95732 + }
95733 +
95734 + if (TREE_CODE(*node) == PARM_DECL) {
95735 + error("%qE attribute does not apply to function parameters", name);
95736 + return NULL_TREE;
95737 + }
95738 +
95739 + if (TREE_CODE(*node) == VAR_DECL) {
95740 + error("%qE attribute does not apply to variables", name);
95741 + return NULL_TREE;
95742 + }
95743 +
95744 + if (TYPE_P(*node)) {
95745 + *no_add_attrs = false;
95746 + type = *node;
95747 + } else {
95748 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
95749 + type = TREE_TYPE(*node);
95750 + }
95751 +
95752 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
95753 + error("%qE attribute applies to struct and union types only", name);
95754 + return NULL_TREE;
95755 + }
95756 +
95757 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
95758 + error("%qE attribute is already applied to the type", name);
95759 + return NULL_TREE;
95760 + }
95761 +
95762 + if (TYPE_P(*node)) {
95763 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95764 + error("%qE attribute is incompatible with 'do_const'", name);
95765 + return NULL_TREE;
95766 + }
95767 +
95768 + constifiable(type, &cinfo);
95769 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95770 + deconstify_tree(*node);
95771 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
95772 + return NULL_TREE;
95773 + }
95774 +
95775 + error("%qE attribute used on type that is not constified", name);
95776 + return NULL_TREE;
95777 +}
95778 +
95779 +static void constify_type(tree type)
95780 +{
95781 + TYPE_READONLY(type) = 1;
95782 + C_TYPE_FIELDS_READONLY(type) = 1;
95783 + TYPE_CONSTIFY_VISITED(type) = 1;
95784 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
95785 +}
95786 +
95787 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95788 +{
95789 + *no_add_attrs = true;
95790 + if (!TYPE_P(*node)) {
95791 + error("%qE attribute applies to types only", name);
95792 + return NULL_TREE;
95793 + }
95794 +
95795 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
95796 + error("%qE attribute applies to struct and union types only", name);
95797 + return NULL_TREE;
95798 + }
95799 +
95800 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
95801 + error("%qE attribute is already applied to the type", name);
95802 + return NULL_TREE;
95803 + }
95804 +
95805 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
95806 + error("%qE attribute is incompatible with 'no_const'", name);
95807 + return NULL_TREE;
95808 + }
95809 +
95810 + *no_add_attrs = false;
95811 + return NULL_TREE;
95812 +}
95813 +
95814 +static struct attribute_spec no_const_attr = {
95815 + .name = "no_const",
95816 + .min_length = 0,
95817 + .max_length = 0,
95818 + .decl_required = false,
95819 + .type_required = false,
95820 + .function_type_required = false,
95821 + .handler = handle_no_const_attribute,
95822 +#if BUILDING_GCC_VERSION >= 4007
95823 + .affects_type_identity = true
95824 +#endif
95825 +};
95826 +
95827 +static struct attribute_spec do_const_attr = {
95828 + .name = "do_const",
95829 + .min_length = 0,
95830 + .max_length = 0,
95831 + .decl_required = false,
95832 + .type_required = false,
95833 + .function_type_required = false,
95834 + .handler = handle_do_const_attribute,
95835 +#if BUILDING_GCC_VERSION >= 4007
95836 + .affects_type_identity = true
95837 +#endif
95838 +};
95839 +
95840 +static void register_attributes(void *event_data, void *data)
95841 +{
95842 + register_attribute(&no_const_attr);
95843 + register_attribute(&do_const_attr);
95844 +}
95845 +
95846 +static void finish_type(void *event_data, void *data)
95847 +{
95848 + tree type = (tree)event_data;
95849 + constify_info cinfo = {
95850 + .has_fptr_field = false,
95851 + .has_writable_field = false,
95852 + .has_do_const_field = false,
95853 + .has_no_const_field = false
95854 + };
95855 +
95856 + if (type == NULL_TREE || type == error_mark_node)
95857 + return;
95858 +
95859 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
95860 + return;
95861 +
95862 + constifiable(type, &cinfo);
95863 +
95864 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
95865 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95866 + return;
95867 + if (cinfo.has_writable_field)
95868 + return;
95869 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
95870 + return;
95871 + }
95872 +
95873 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
95874 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
95875 + deconstify_type(type);
95876 + TYPE_CONSTIFY_VISITED(type) = 1;
95877 + } else
95878 + error("'no_const' attribute used on type that is not constified");
95879 + return;
95880 + }
95881 +
95882 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95883 + constify_type(type);
95884 + return;
95885 + }
95886 +
95887 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
95888 + constify_type(type);
95889 + return;
95890 + }
95891 +
95892 + deconstify_type(type);
95893 + TYPE_CONSTIFY_VISITED(type) = 1;
95894 +}
95895 +
95896 +static void check_global_variables(void)
95897 +{
95898 + struct varpool_node *node;
95899 +
95900 +#if BUILDING_GCC_VERSION <= 4007
95901 + for (node = varpool_nodes; node; node = node->next) {
95902 + tree var = node->decl;
95903 +#else
95904 + FOR_EACH_VARIABLE(node) {
95905 + tree var = node->symbol.decl;
95906 +#endif
95907 + tree type = TREE_TYPE(var);
95908 +
95909 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95910 + continue;
95911 +
95912 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95913 + continue;
95914 +
95915 + if (!TYPE_CONSTIFY_VISITED(type))
95916 + continue;
95917 +
95918 + if (DECL_EXTERNAL(var))
95919 + continue;
95920 +
95921 + if (DECL_INITIAL(var))
95922 + continue;
95923 +
95924 + // this works around a gcc bug/feature where uninitialized globals
95925 + // are moved into the .bss section regardless of any constification
95926 + DECL_INITIAL(var) = build_constructor(type, NULL);
95927 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
95928 + }
95929 +}
95930 +
95931 +static unsigned int check_local_variables(void)
95932 +{
95933 + unsigned int ret = 0;
95934 + tree var;
95935 +
95936 +#if BUILDING_GCC_VERSION == 4005
95937 + tree vars;
95938 +#else
95939 + unsigned int i;
95940 +#endif
95941 +
95942 +#if BUILDING_GCC_VERSION == 4005
95943 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
95944 + var = TREE_VALUE(vars);
95945 +#else
95946 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
95947 +#endif
95948 + tree type = TREE_TYPE(var);
95949 +
95950 + gcc_assert(DECL_P(var));
95951 + if (is_global_var(var))
95952 + continue;
95953 +
95954 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95955 + continue;
95956 +
95957 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95958 + continue;
95959 +
95960 + if (!TYPE_CONSTIFY_VISITED(type))
95961 + continue;
95962 +
95963 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
95964 + ret = 1;
95965 + }
95966 + return ret;
95967 +}
95968 +
95969 +static unsigned int check_variables(void)
95970 +{
95971 + check_global_variables();
95972 + return check_local_variables();
95973 +}
95974 +
95975 + unsigned int ret = 0;
95976 +static struct gimple_opt_pass pass_local_variable = {
95977 + {
95978 + .type = GIMPLE_PASS,
95979 + .name = "check_variables",
95980 +#if BUILDING_GCC_VERSION >= 4008
95981 + .optinfo_flags = OPTGROUP_NONE,
95982 +#endif
95983 + .gate = NULL,
95984 + .execute = check_variables,
95985 + .sub = NULL,
95986 + .next = NULL,
95987 + .static_pass_number = 0,
95988 + .tv_id = TV_NONE,
95989 + .properties_required = 0,
95990 + .properties_provided = 0,
95991 + .properties_destroyed = 0,
95992 + .todo_flags_start = 0,
95993 + .todo_flags_finish = 0
95994 + }
95995 +};
95996 +
95997 +static struct {
95998 + const char *name;
95999 + const char *asm_op;
96000 +} sections[] = {
96001 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
96002 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
96003 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
96004 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
96005 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
96006 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
96007 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
96008 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
96009 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
96010 +};
96011 +
96012 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
96013 +
96014 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
96015 +{
96016 + size_t i;
96017 +
96018 + for (i = 0; i < ARRAY_SIZE(sections); i++)
96019 + if (!strcmp(sections[i].name, name))
96020 + return 0;
96021 + return old_section_type_flags(decl, name, reloc);
96022 +}
96023 +
96024 +static void constify_start_unit(void *gcc_data, void *user_data)
96025 +{
96026 +// size_t i;
96027 +
96028 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
96029 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
96030 +// sections[i].section = get_section(sections[i].name, 0, NULL);
96031 +
96032 + old_section_type_flags = targetm.section_type_flags;
96033 + targetm.section_type_flags = constify_section_type_flags;
96034 +}
96035 +
96036 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96037 +{
96038 + const char * const plugin_name = plugin_info->base_name;
96039 + const int argc = plugin_info->argc;
96040 + const struct plugin_argument * const argv = plugin_info->argv;
96041 + int i;
96042 + bool constify = true;
96043 +
96044 + struct register_pass_info local_variable_pass_info = {
96045 + .pass = &pass_local_variable.pass,
96046 + .reference_pass_name = "ssa",
96047 + .ref_pass_instance_number = 1,
96048 + .pos_op = PASS_POS_INSERT_BEFORE
96049 + };
96050 +
96051 + if (!plugin_default_version_check(version, &gcc_version)) {
96052 + error(G_("incompatible gcc/plugin versions"));
96053 + return 1;
96054 + }
96055 +
96056 + for (i = 0; i < argc; ++i) {
96057 + if (!(strcmp(argv[i].key, "no-constify"))) {
96058 + constify = false;
96059 + continue;
96060 + }
96061 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96062 + }
96063 +
96064 + if (strcmp(lang_hooks.name, "GNU C")) {
96065 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
96066 + constify = false;
96067 + }
96068 +
96069 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
96070 + if (constify) {
96071 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
96072 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
96073 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
96074 + }
96075 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96076 +
96077 + return 0;
96078 +}
96079 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
96080 new file mode 100644
96081 index 0000000..e518932
96082 --- /dev/null
96083 +++ b/tools/gcc/generate_size_overflow_hash.sh
96084 @@ -0,0 +1,94 @@
96085 +#!/bin/bash
96086 +
96087 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
96088 +
96089 +header1="size_overflow_hash.h"
96090 +database="size_overflow_hash.data"
96091 +n=65536
96092 +
96093 +usage() {
96094 +cat <<EOF
96095 +usage: $0 options
96096 +OPTIONS:
96097 + -h|--help help
96098 + -o header file
96099 + -d database file
96100 + -n hash array size
96101 +EOF
96102 + return 0
96103 +}
96104 +
96105 +while true
96106 +do
96107 + case "$1" in
96108 + -h|--help) usage && exit 0;;
96109 + -n) n=$2; shift 2;;
96110 + -o) header1="$2"; shift 2;;
96111 + -d) database="$2"; shift 2;;
96112 + --) shift 1; break ;;
96113 + *) break ;;
96114 + esac
96115 +done
96116 +
96117 +create_defines() {
96118 + for i in `seq 0 31`
96119 + do
96120 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
96121 + done
96122 + echo >> "$header1"
96123 +}
96124 +
96125 +create_structs() {
96126 + rm -f "$header1"
96127 +
96128 + create_defines
96129 +
96130 + cat "$database" | while read data
96131 + do
96132 + data_array=($data)
96133 + struct_hash_name="${data_array[0]}"
96134 + funcn="${data_array[1]}"
96135 + params="${data_array[2]}"
96136 + next="${data_array[4]}"
96137 +
96138 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
96139 +
96140 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
96141 + echo -en "\t.param\t= " >> "$header1"
96142 + line=
96143 + for param_num in ${params//-/ };
96144 + do
96145 + line="${line}PARAM"$param_num"|"
96146 + done
96147 +
96148 + echo -e "${line%?},\n};\n" >> "$header1"
96149 + done
96150 +}
96151 +
96152 +create_headers() {
96153 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
96154 +}
96155 +
96156 +create_array_elements() {
96157 + index=0
96158 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
96159 + do
96160 + data_array=($data)
96161 + i="${data_array[3]}"
96162 + hash="${data_array[0]}"
96163 + while [[ $index -lt $i ]]
96164 + do
96165 + echo -e "\t["$index"]\t= NULL," >> "$header1"
96166 + index=$(($index + 1))
96167 + done
96168 + index=$(($index + 1))
96169 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
96170 + done
96171 + echo '};' >> $header1
96172 +}
96173 +
96174 +create_structs
96175 +create_headers
96176 +create_array_elements
96177 +
96178 +exit 0
96179 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
96180 new file mode 100644
96181 index 0000000..568b360
96182 --- /dev/null
96183 +++ b/tools/gcc/kallocstat_plugin.c
96184 @@ -0,0 +1,170 @@
96185 +/*
96186 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
96187 + * Licensed under the GPL v2
96188 + *
96189 + * Note: the choice of the license means that the compilation process is
96190 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96191 + * but for the kernel it doesn't matter since it doesn't link against
96192 + * any of the gcc libraries
96193 + *
96194 + * gcc plugin to find the distribution of k*alloc sizes
96195 + *
96196 + * TODO:
96197 + *
96198 + * BUGS:
96199 + * - none known
96200 + */
96201 +#include "gcc-plugin.h"
96202 +#include "config.h"
96203 +#include "system.h"
96204 +#include "coretypes.h"
96205 +#include "tree.h"
96206 +#include "tree-pass.h"
96207 +#include "flags.h"
96208 +#include "intl.h"
96209 +#include "toplev.h"
96210 +#include "plugin.h"
96211 +//#include "expr.h" where are you...
96212 +#include "diagnostic.h"
96213 +#include "plugin-version.h"
96214 +#include "tm.h"
96215 +#include "function.h"
96216 +#include "basic-block.h"
96217 +#include "gimple.h"
96218 +#include "rtl.h"
96219 +#include "emit-rtl.h"
96220 +
96221 +extern void print_gimple_stmt(FILE *, gimple, int, int);
96222 +
96223 +int plugin_is_GPL_compatible;
96224 +
96225 +static const char * const kalloc_functions[] = {
96226 + "__kmalloc",
96227 + "kmalloc",
96228 + "kmalloc_large",
96229 + "kmalloc_node",
96230 + "kmalloc_order",
96231 + "kmalloc_order_trace",
96232 + "kmalloc_slab",
96233 + "kzalloc",
96234 + "kzalloc_node",
96235 +};
96236 +
96237 +static struct plugin_info kallocstat_plugin_info = {
96238 + .version = "201302112000",
96239 +};
96240 +
96241 +static unsigned int execute_kallocstat(void);
96242 +
96243 +static struct gimple_opt_pass kallocstat_pass = {
96244 + .pass = {
96245 + .type = GIMPLE_PASS,
96246 + .name = "kallocstat",
96247 +#if BUILDING_GCC_VERSION >= 4008
96248 + .optinfo_flags = OPTGROUP_NONE,
96249 +#endif
96250 + .gate = NULL,
96251 + .execute = execute_kallocstat,
96252 + .sub = NULL,
96253 + .next = NULL,
96254 + .static_pass_number = 0,
96255 + .tv_id = TV_NONE,
96256 + .properties_required = 0,
96257 + .properties_provided = 0,
96258 + .properties_destroyed = 0,
96259 + .todo_flags_start = 0,
96260 + .todo_flags_finish = 0
96261 + }
96262 +};
96263 +
96264 +static bool is_kalloc(const char *fnname)
96265 +{
96266 + size_t i;
96267 +
96268 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
96269 + if (!strcmp(fnname, kalloc_functions[i]))
96270 + return true;
96271 + return false;
96272 +}
96273 +
96274 +static unsigned int execute_kallocstat(void)
96275 +{
96276 + basic_block bb;
96277 +
96278 + // 1. loop through BBs and GIMPLE statements
96279 + FOR_EACH_BB(bb) {
96280 + gimple_stmt_iterator gsi;
96281 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96282 + // gimple match:
96283 + tree fndecl, size;
96284 + gimple call_stmt;
96285 + const char *fnname;
96286 +
96287 + // is it a call
96288 + call_stmt = gsi_stmt(gsi);
96289 + if (!is_gimple_call(call_stmt))
96290 + continue;
96291 + fndecl = gimple_call_fndecl(call_stmt);
96292 + if (fndecl == NULL_TREE)
96293 + continue;
96294 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
96295 + continue;
96296 +
96297 + // is it a call to k*alloc
96298 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
96299 + if (!is_kalloc(fnname))
96300 + continue;
96301 +
96302 + // is the size arg the result of a simple const assignment
96303 + size = gimple_call_arg(call_stmt, 0);
96304 + while (true) {
96305 + gimple def_stmt;
96306 + expanded_location xloc;
96307 + size_t size_val;
96308 +
96309 + if (TREE_CODE(size) != SSA_NAME)
96310 + break;
96311 + def_stmt = SSA_NAME_DEF_STMT(size);
96312 + if (!def_stmt || !is_gimple_assign(def_stmt))
96313 + break;
96314 + if (gimple_num_ops(def_stmt) != 2)
96315 + break;
96316 + size = gimple_assign_rhs1(def_stmt);
96317 + if (!TREE_CONSTANT(size))
96318 + continue;
96319 + xloc = expand_location(gimple_location(def_stmt));
96320 + if (!xloc.file)
96321 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
96322 + size_val = TREE_INT_CST_LOW(size);
96323 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
96324 + break;
96325 + }
96326 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
96327 +//debug_tree(gimple_call_fn(call_stmt));
96328 +//print_node(stderr, "pax", fndecl, 4);
96329 + }
96330 + }
96331 +
96332 + return 0;
96333 +}
96334 +
96335 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96336 +{
96337 + const char * const plugin_name = plugin_info->base_name;
96338 + struct register_pass_info kallocstat_pass_info = {
96339 + .pass = &kallocstat_pass.pass,
96340 + .reference_pass_name = "ssa",
96341 + .ref_pass_instance_number = 1,
96342 + .pos_op = PASS_POS_INSERT_AFTER
96343 + };
96344 +
96345 + if (!plugin_default_version_check(version, &gcc_version)) {
96346 + error(G_("incompatible gcc/plugin versions"));
96347 + return 1;
96348 + }
96349 +
96350 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
96351 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
96352 +
96353 + return 0;
96354 +}
96355 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
96356 new file mode 100644
96357 index 0000000..0408e06
96358 --- /dev/null
96359 +++ b/tools/gcc/kernexec_plugin.c
96360 @@ -0,0 +1,465 @@
96361 +/*
96362 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
96363 + * Licensed under the GPL v2
96364 + *
96365 + * Note: the choice of the license means that the compilation process is
96366 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96367 + * but for the kernel it doesn't matter since it doesn't link against
96368 + * any of the gcc libraries
96369 + *
96370 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
96371 + *
96372 + * TODO:
96373 + *
96374 + * BUGS:
96375 + * - none known
96376 + */
96377 +#include "gcc-plugin.h"
96378 +#include "config.h"
96379 +#include "system.h"
96380 +#include "coretypes.h"
96381 +#include "tree.h"
96382 +#include "tree-pass.h"
96383 +#include "flags.h"
96384 +#include "intl.h"
96385 +#include "toplev.h"
96386 +#include "plugin.h"
96387 +//#include "expr.h" where are you...
96388 +#include "diagnostic.h"
96389 +#include "plugin-version.h"
96390 +#include "tm.h"
96391 +#include "function.h"
96392 +#include "basic-block.h"
96393 +#include "gimple.h"
96394 +#include "rtl.h"
96395 +#include "emit-rtl.h"
96396 +#include "tree-flow.h"
96397 +
96398 +extern void print_gimple_stmt(FILE *, gimple, int, int);
96399 +extern rtx emit_move_insn(rtx x, rtx y);
96400 +
96401 +#if BUILDING_GCC_VERSION <= 4006
96402 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
96403 +#endif
96404 +
96405 +#if BUILDING_GCC_VERSION >= 4008
96406 +#define TODO_dump_func 0
96407 +#endif
96408 +
96409 +int plugin_is_GPL_compatible;
96410 +
96411 +static struct plugin_info kernexec_plugin_info = {
96412 + .version = "201302112000",
96413 + .help = "method=[bts|or]\tinstrumentation method\n"
96414 +};
96415 +
96416 +static unsigned int execute_kernexec_reload(void);
96417 +static unsigned int execute_kernexec_fptr(void);
96418 +static unsigned int execute_kernexec_retaddr(void);
96419 +static bool kernexec_cmodel_check(void);
96420 +
96421 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
96422 +static void (*kernexec_instrument_retaddr)(rtx);
96423 +
96424 +static struct gimple_opt_pass kernexec_reload_pass = {
96425 + .pass = {
96426 + .type = GIMPLE_PASS,
96427 + .name = "kernexec_reload",
96428 +#if BUILDING_GCC_VERSION >= 4008
96429 + .optinfo_flags = OPTGROUP_NONE,
96430 +#endif
96431 + .gate = kernexec_cmodel_check,
96432 + .execute = execute_kernexec_reload,
96433 + .sub = NULL,
96434 + .next = NULL,
96435 + .static_pass_number = 0,
96436 + .tv_id = TV_NONE,
96437 + .properties_required = 0,
96438 + .properties_provided = 0,
96439 + .properties_destroyed = 0,
96440 + .todo_flags_start = 0,
96441 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
96442 + }
96443 +};
96444 +
96445 +static struct gimple_opt_pass kernexec_fptr_pass = {
96446 + .pass = {
96447 + .type = GIMPLE_PASS,
96448 + .name = "kernexec_fptr",
96449 +#if BUILDING_GCC_VERSION >= 4008
96450 + .optinfo_flags = OPTGROUP_NONE,
96451 +#endif
96452 + .gate = kernexec_cmodel_check,
96453 + .execute = execute_kernexec_fptr,
96454 + .sub = NULL,
96455 + .next = NULL,
96456 + .static_pass_number = 0,
96457 + .tv_id = TV_NONE,
96458 + .properties_required = 0,
96459 + .properties_provided = 0,
96460 + .properties_destroyed = 0,
96461 + .todo_flags_start = 0,
96462 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
96463 + }
96464 +};
96465 +
96466 +static struct rtl_opt_pass kernexec_retaddr_pass = {
96467 + .pass = {
96468 + .type = RTL_PASS,
96469 + .name = "kernexec_retaddr",
96470 +#if BUILDING_GCC_VERSION >= 4008
96471 + .optinfo_flags = OPTGROUP_NONE,
96472 +#endif
96473 + .gate = kernexec_cmodel_check,
96474 + .execute = execute_kernexec_retaddr,
96475 + .sub = NULL,
96476 + .next = NULL,
96477 + .static_pass_number = 0,
96478 + .tv_id = TV_NONE,
96479 + .properties_required = 0,
96480 + .properties_provided = 0,
96481 + .properties_destroyed = 0,
96482 + .todo_flags_start = 0,
96483 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
96484 + }
96485 +};
96486 +
96487 +static bool kernexec_cmodel_check(void)
96488 +{
96489 + tree section;
96490 +
96491 + if (ix86_cmodel != CM_KERNEL)
96492 + return false;
96493 +
96494 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
96495 + if (!section || !TREE_VALUE(section))
96496 + return true;
96497 +
96498 + section = TREE_VALUE(TREE_VALUE(section));
96499 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
96500 + return true;
96501 +
96502 + return false;
96503 +}
96504 +
96505 +/*
96506 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
96507 + */
96508 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
96509 +{
96510 + gimple asm_movabs_stmt;
96511 +
96512 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
96513 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
96514 + gimple_asm_set_volatile(asm_movabs_stmt, true);
96515 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
96516 + update_stmt(asm_movabs_stmt);
96517 +}
96518 +
96519 +/*
96520 + * find all asm() stmts that clobber r10 and add a reload of r10
96521 + */
96522 +static unsigned int execute_kernexec_reload(void)
96523 +{
96524 + basic_block bb;
96525 +
96526 + // 1. loop through BBs and GIMPLE statements
96527 + FOR_EACH_BB(bb) {
96528 + gimple_stmt_iterator gsi;
96529 +
96530 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96531 + // gimple match: __asm__ ("" : : : "r10");
96532 + gimple asm_stmt;
96533 + size_t nclobbers;
96534 +
96535 + // is it an asm ...
96536 + asm_stmt = gsi_stmt(gsi);
96537 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
96538 + continue;
96539 +
96540 + // ... clobbering r10
96541 + nclobbers = gimple_asm_nclobbers(asm_stmt);
96542 + while (nclobbers--) {
96543 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
96544 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
96545 + continue;
96546 + kernexec_reload_fptr_mask(&gsi);
96547 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
96548 + break;
96549 + }
96550 + }
96551 + }
96552 +
96553 + return 0;
96554 +}
96555 +
96556 +/*
96557 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
96558 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
96559 + */
96560 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
96561 +{
96562 + gimple assign_intptr, assign_new_fptr, call_stmt;
96563 + tree intptr, old_fptr, new_fptr, kernexec_mask;
96564 +
96565 + call_stmt = gsi_stmt(*gsi);
96566 + old_fptr = gimple_call_fn(call_stmt);
96567 +
96568 + // create temporary unsigned long variable used for bitops and cast fptr to it
96569 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
96570 +#if BUILDING_GCC_VERSION <= 4007
96571 + add_referenced_var(intptr);
96572 + mark_sym_for_renaming(intptr);
96573 +#endif
96574 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
96575 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
96576 + update_stmt(assign_intptr);
96577 +
96578 + // apply logical or to temporary unsigned long and bitmask
96579 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
96580 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
96581 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
96582 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
96583 + update_stmt(assign_intptr);
96584 +
96585 + // cast temporary unsigned long back to a temporary fptr variable
96586 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
96587 +#if BUILDING_GCC_VERSION <= 4007
96588 + add_referenced_var(new_fptr);
96589 + mark_sym_for_renaming(new_fptr);
96590 +#endif
96591 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
96592 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
96593 + update_stmt(assign_new_fptr);
96594 +
96595 + // replace call stmt fn with the new fptr
96596 + gimple_call_set_fn(call_stmt, new_fptr);
96597 + update_stmt(call_stmt);
96598 +}
96599 +
96600 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
96601 +{
96602 + gimple asm_or_stmt, call_stmt;
96603 + tree old_fptr, new_fptr, input, output;
96604 +#if BUILDING_GCC_VERSION <= 4007
96605 + VEC(tree, gc) *inputs = NULL;
96606 + VEC(tree, gc) *outputs = NULL;
96607 +#else
96608 + vec<tree, va_gc> *inputs = NULL;
96609 + vec<tree, va_gc> *outputs = NULL;
96610 +#endif
96611 +
96612 + call_stmt = gsi_stmt(*gsi);
96613 + old_fptr = gimple_call_fn(call_stmt);
96614 +
96615 + // create temporary fptr variable
96616 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
96617 +#if BUILDING_GCC_VERSION <= 4007
96618 + add_referenced_var(new_fptr);
96619 + mark_sym_for_renaming(new_fptr);
96620 +#endif
96621 +
96622 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
96623 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
96624 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
96625 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
96626 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
96627 +#if BUILDING_GCC_VERSION <= 4007
96628 + VEC_safe_push(tree, gc, inputs, input);
96629 + VEC_safe_push(tree, gc, outputs, output);
96630 +#else
96631 + vec_safe_push(inputs, input);
96632 + vec_safe_push(outputs, output);
96633 +#endif
96634 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
96635 + gimple_asm_set_volatile(asm_or_stmt, true);
96636 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
96637 + update_stmt(asm_or_stmt);
96638 +
96639 + // replace call stmt fn with the new fptr
96640 + gimple_call_set_fn(call_stmt, new_fptr);
96641 + update_stmt(call_stmt);
96642 +}
96643 +
96644 +/*
96645 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
96646 + */
96647 +static unsigned int execute_kernexec_fptr(void)
96648 +{
96649 + basic_block bb;
96650 +
96651 + // 1. loop through BBs and GIMPLE statements
96652 + FOR_EACH_BB(bb) {
96653 + gimple_stmt_iterator gsi;
96654 +
96655 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96656 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
96657 + tree fn;
96658 + gimple call_stmt;
96659 +
96660 + // is it a call ...
96661 + call_stmt = gsi_stmt(gsi);
96662 + if (!is_gimple_call(call_stmt))
96663 + continue;
96664 + fn = gimple_call_fn(call_stmt);
96665 + if (TREE_CODE(fn) == ADDR_EXPR)
96666 + continue;
96667 + if (TREE_CODE(fn) != SSA_NAME)
96668 + gcc_unreachable();
96669 +
96670 + // ... through a function pointer
96671 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
96672 + fn = SSA_NAME_VAR(fn);
96673 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
96674 + debug_tree(fn);
96675 + gcc_unreachable();
96676 + }
96677 + }
96678 + fn = TREE_TYPE(fn);
96679 + if (TREE_CODE(fn) != POINTER_TYPE)
96680 + continue;
96681 + fn = TREE_TYPE(fn);
96682 + if (TREE_CODE(fn) != FUNCTION_TYPE)
96683 + continue;
96684 +
96685 + kernexec_instrument_fptr(&gsi);
96686 +
96687 +//debug_tree(gimple_call_fn(call_stmt));
96688 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
96689 + }
96690 + }
96691 +
96692 + return 0;
96693 +}
96694 +
96695 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
96696 +static void kernexec_instrument_retaddr_bts(rtx insn)
96697 +{
96698 + rtx btsq;
96699 + rtvec argvec, constraintvec, labelvec;
96700 + int line;
96701 +
96702 + // create asm volatile("btsq $63,(%%rsp)":::)
96703 + argvec = rtvec_alloc(0);
96704 + constraintvec = rtvec_alloc(0);
96705 + labelvec = rtvec_alloc(0);
96706 + line = expand_location(RTL_LOCATION(insn)).line;
96707 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
96708 + MEM_VOLATILE_P(btsq) = 1;
96709 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
96710 + emit_insn_before(btsq, insn);
96711 +}
96712 +
96713 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
96714 +static void kernexec_instrument_retaddr_or(rtx insn)
96715 +{
96716 + rtx orq;
96717 + rtvec argvec, constraintvec, labelvec;
96718 + int line;
96719 +
96720 + // create asm volatile("orq %%r10,(%%rsp)":::)
96721 + argvec = rtvec_alloc(0);
96722 + constraintvec = rtvec_alloc(0);
96723 + labelvec = rtvec_alloc(0);
96724 + line = expand_location(RTL_LOCATION(insn)).line;
96725 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
96726 + MEM_VOLATILE_P(orq) = 1;
96727 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
96728 + emit_insn_before(orq, insn);
96729 +}
96730 +
96731 +/*
96732 + * find all asm level function returns and forcibly set the highest bit of the return address
96733 + */
96734 +static unsigned int execute_kernexec_retaddr(void)
96735 +{
96736 + rtx insn;
96737 +
96738 + // 1. find function returns
96739 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
96740 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
96741 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
96742 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
96743 + rtx body;
96744 +
96745 + // is it a retn
96746 + if (!JUMP_P(insn))
96747 + continue;
96748 + body = PATTERN(insn);
96749 + if (GET_CODE(body) == PARALLEL)
96750 + body = XVECEXP(body, 0, 0);
96751 + if (!ANY_RETURN_P(body))
96752 + continue;
96753 + kernexec_instrument_retaddr(insn);
96754 + }
96755 +
96756 +// print_simple_rtl(stderr, get_insns());
96757 +// print_rtl(stderr, get_insns());
96758 +
96759 + return 0;
96760 +}
96761 +
96762 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96763 +{
96764 + const char * const plugin_name = plugin_info->base_name;
96765 + const int argc = plugin_info->argc;
96766 + const struct plugin_argument * const argv = plugin_info->argv;
96767 + int i;
96768 + struct register_pass_info kernexec_reload_pass_info = {
96769 + .pass = &kernexec_reload_pass.pass,
96770 + .reference_pass_name = "ssa",
96771 + .ref_pass_instance_number = 1,
96772 + .pos_op = PASS_POS_INSERT_AFTER
96773 + };
96774 + struct register_pass_info kernexec_fptr_pass_info = {
96775 + .pass = &kernexec_fptr_pass.pass,
96776 + .reference_pass_name = "ssa",
96777 + .ref_pass_instance_number = 1,
96778 + .pos_op = PASS_POS_INSERT_AFTER
96779 + };
96780 + struct register_pass_info kernexec_retaddr_pass_info = {
96781 + .pass = &kernexec_retaddr_pass.pass,
96782 + .reference_pass_name = "pro_and_epilogue",
96783 + .ref_pass_instance_number = 1,
96784 + .pos_op = PASS_POS_INSERT_AFTER
96785 + };
96786 +
96787 + if (!plugin_default_version_check(version, &gcc_version)) {
96788 + error(G_("incompatible gcc/plugin versions"));
96789 + return 1;
96790 + }
96791 +
96792 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
96793 +
96794 + if (TARGET_64BIT == 0)
96795 + return 0;
96796 +
96797 + for (i = 0; i < argc; ++i) {
96798 + if (!strcmp(argv[i].key, "method")) {
96799 + if (!argv[i].value) {
96800 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96801 + continue;
96802 + }
96803 + if (!strcmp(argv[i].value, "bts")) {
96804 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
96805 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
96806 + } else if (!strcmp(argv[i].value, "or")) {
96807 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
96808 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
96809 + fix_register("r10", 1, 1);
96810 + } else
96811 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96812 + continue;
96813 + }
96814 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96815 + }
96816 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
96817 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
96818 +
96819 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
96820 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
96821 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
96822 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
96823 +
96824 + return 0;
96825 +}
96826 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
96827 new file mode 100644
96828 index 0000000..b5395ba
96829 --- /dev/null
96830 +++ b/tools/gcc/latent_entropy_plugin.c
96831 @@ -0,0 +1,327 @@
96832 +/*
96833 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
96834 + * Licensed under the GPL v2
96835 + *
96836 + * Note: the choice of the license means that the compilation process is
96837 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96838 + * but for the kernel it doesn't matter since it doesn't link against
96839 + * any of the gcc libraries
96840 + *
96841 + * gcc plugin to help generate a little bit of entropy from program state,
96842 + * used during boot in the kernel
96843 + *
96844 + * TODO:
96845 + * - add ipa pass to identify not explicitly marked candidate functions
96846 + * - mix in more program state (function arguments/return values, loop variables, etc)
96847 + * - more instrumentation control via attribute parameters
96848 + *
96849 + * BUGS:
96850 + * - LTO needs -flto-partition=none for now
96851 + */
96852 +#include "gcc-plugin.h"
96853 +#include "config.h"
96854 +#include "system.h"
96855 +#include "coretypes.h"
96856 +#include "tree.h"
96857 +#include "tree-pass.h"
96858 +#include "flags.h"
96859 +#include "intl.h"
96860 +#include "toplev.h"
96861 +#include "plugin.h"
96862 +//#include "expr.h" where are you...
96863 +#include "diagnostic.h"
96864 +#include "plugin-version.h"
96865 +#include "tm.h"
96866 +#include "function.h"
96867 +#include "basic-block.h"
96868 +#include "gimple.h"
96869 +#include "rtl.h"
96870 +#include "emit-rtl.h"
96871 +#include "tree-flow.h"
96872 +#include "langhooks.h"
96873 +
96874 +#if BUILDING_GCC_VERSION >= 4008
96875 +#define TODO_dump_func 0
96876 +#endif
96877 +
96878 +int plugin_is_GPL_compatible;
96879 +
96880 +static tree latent_entropy_decl;
96881 +
96882 +static struct plugin_info latent_entropy_plugin_info = {
96883 + .version = "201303102320",
96884 + .help = NULL
96885 +};
96886 +
96887 +static unsigned int execute_latent_entropy(void);
96888 +static bool gate_latent_entropy(void);
96889 +
96890 +static struct gimple_opt_pass latent_entropy_pass = {
96891 + .pass = {
96892 + .type = GIMPLE_PASS,
96893 + .name = "latent_entropy",
96894 +#if BUILDING_GCC_VERSION >= 4008
96895 + .optinfo_flags = OPTGROUP_NONE,
96896 +#endif
96897 + .gate = gate_latent_entropy,
96898 + .execute = execute_latent_entropy,
96899 + .sub = NULL,
96900 + .next = NULL,
96901 + .static_pass_number = 0,
96902 + .tv_id = TV_NONE,
96903 + .properties_required = PROP_gimple_leh | PROP_cfg,
96904 + .properties_provided = 0,
96905 + .properties_destroyed = 0,
96906 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
96907 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
96908 + }
96909 +};
96910 +
96911 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
96912 +{
96913 + if (TREE_CODE(*node) != FUNCTION_DECL) {
96914 + *no_add_attrs = true;
96915 + error("%qE attribute only applies to functions", name);
96916 + }
96917 + return NULL_TREE;
96918 +}
96919 +
96920 +static struct attribute_spec latent_entropy_attr = {
96921 + .name = "latent_entropy",
96922 + .min_length = 0,
96923 + .max_length = 0,
96924 + .decl_required = true,
96925 + .type_required = false,
96926 + .function_type_required = false,
96927 + .handler = handle_latent_entropy_attribute,
96928 +#if BUILDING_GCC_VERSION >= 4007
96929 + .affects_type_identity = false
96930 +#endif
96931 +};
96932 +
96933 +static void register_attributes(void *event_data, void *data)
96934 +{
96935 + register_attribute(&latent_entropy_attr);
96936 +}
96937 +
96938 +static bool gate_latent_entropy(void)
96939 +{
96940 + tree latent_entropy_attr;
96941 +
96942 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
96943 + return latent_entropy_attr != NULL_TREE;
96944 +}
96945 +
96946 +static unsigned HOST_WIDE_INT seed;
96947 +static unsigned HOST_WIDE_INT get_random_const(void)
96948 +{
96949 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
96950 + return seed;
96951 +}
96952 +
96953 +static enum tree_code get_op(tree *rhs)
96954 +{
96955 + static enum tree_code op;
96956 + unsigned HOST_WIDE_INT random_const;
96957 +
96958 + random_const = get_random_const();
96959 +
96960 + switch (op) {
96961 + case BIT_XOR_EXPR:
96962 + op = PLUS_EXPR;
96963 + break;
96964 +
96965 + case PLUS_EXPR:
96966 + if (rhs) {
96967 + op = LROTATE_EXPR;
96968 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
96969 + break;
96970 + }
96971 +
96972 + case LROTATE_EXPR:
96973 + default:
96974 + op = BIT_XOR_EXPR;
96975 + break;
96976 + }
96977 + if (rhs)
96978 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
96979 + return op;
96980 +}
96981 +
96982 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
96983 +{
96984 + gimple_stmt_iterator gsi;
96985 + gimple assign;
96986 + tree addxorrol, rhs;
96987 + enum tree_code op;
96988 +
96989 + op = get_op(&rhs);
96990 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
96991 + assign = gimple_build_assign(local_entropy, addxorrol);
96992 +#if BUILDING_GCC_VERSION <= 4007
96993 + find_referenced_vars_in(assign);
96994 +#endif
96995 +//debug_bb(bb);
96996 + gsi = gsi_after_labels(bb);
96997 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
96998 + update_stmt(assign);
96999 +}
97000 +
97001 +static void perturb_latent_entropy(basic_block bb, tree rhs)
97002 +{
97003 + gimple_stmt_iterator gsi;
97004 + gimple assign;
97005 + tree addxorrol, temp;
97006 +
97007 + // 1. create temporary copy of latent_entropy
97008 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
97009 +#if BUILDING_GCC_VERSION <= 4007
97010 + add_referenced_var(temp);
97011 + mark_sym_for_renaming(temp);
97012 +#endif
97013 +
97014 + // 2. read...
97015 + assign = gimple_build_assign(temp, latent_entropy_decl);
97016 +#if BUILDING_GCC_VERSION <= 4007
97017 + find_referenced_vars_in(assign);
97018 +#endif
97019 + gsi = gsi_after_labels(bb);
97020 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97021 + update_stmt(assign);
97022 +
97023 + // 3. ...modify...
97024 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
97025 + assign = gimple_build_assign(temp, addxorrol);
97026 +#if BUILDING_GCC_VERSION <= 4007
97027 + find_referenced_vars_in(assign);
97028 +#endif
97029 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97030 + update_stmt(assign);
97031 +
97032 + // 4. ...write latent_entropy
97033 + assign = gimple_build_assign(latent_entropy_decl, temp);
97034 +#if BUILDING_GCC_VERSION <= 4007
97035 + find_referenced_vars_in(assign);
97036 +#endif
97037 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97038 + update_stmt(assign);
97039 +}
97040 +
97041 +static unsigned int execute_latent_entropy(void)
97042 +{
97043 + basic_block bb;
97044 + gimple assign;
97045 + gimple_stmt_iterator gsi;
97046 + tree local_entropy;
97047 +
97048 + if (!latent_entropy_decl) {
97049 + struct varpool_node *node;
97050 +
97051 +#if BUILDING_GCC_VERSION <= 4007
97052 + for (node = varpool_nodes; node; node = node->next) {
97053 + tree var = node->decl;
97054 +#else
97055 + FOR_EACH_VARIABLE(node) {
97056 + tree var = node->symbol.decl;
97057 +#endif
97058 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
97059 + continue;
97060 + latent_entropy_decl = var;
97061 +// debug_tree(var);
97062 + break;
97063 + }
97064 + if (!latent_entropy_decl) {
97065 +// debug_tree(current_function_decl);
97066 + return 0;
97067 + }
97068 + }
97069 +
97070 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
97071 +
97072 + // 1. create local entropy variable
97073 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
97074 +#if BUILDING_GCC_VERSION <= 4007
97075 + add_referenced_var(local_entropy);
97076 + mark_sym_for_renaming(local_entropy);
97077 +#endif
97078 +
97079 + // 2. initialize local entropy variable
97080 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
97081 + if (dom_info_available_p(CDI_DOMINATORS))
97082 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
97083 + gsi = gsi_start_bb(bb);
97084 +
97085 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
97086 +// gimple_set_location(assign, loc);
97087 +#if BUILDING_GCC_VERSION <= 4007
97088 + find_referenced_vars_in(assign);
97089 +#endif
97090 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97091 + update_stmt(assign);
97092 + bb = bb->next_bb;
97093 +
97094 + // 3. instrument each BB with an operation on the local entropy variable
97095 + while (bb != EXIT_BLOCK_PTR) {
97096 + perturb_local_entropy(bb, local_entropy);
97097 + bb = bb->next_bb;
97098 + };
97099 +
97100 + // 4. mix local entropy into the global entropy variable
97101 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
97102 + return 0;
97103 +}
97104 +
97105 +static void start_unit_callback(void *gcc_data, void *user_data)
97106 +{
97107 + tree latent_entropy_type;
97108 +
97109 +#if BUILDING_GCC_VERSION >= 4007
97110 + seed = get_random_seed(false);
97111 +#else
97112 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
97113 + seed *= seed;
97114 +#endif
97115 +
97116 + if (in_lto_p)
97117 + return;
97118 +
97119 + // extern volatile u64 latent_entropy
97120 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
97121 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
97122 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
97123 +
97124 + TREE_STATIC(latent_entropy_decl) = 1;
97125 + TREE_PUBLIC(latent_entropy_decl) = 1;
97126 + TREE_USED(latent_entropy_decl) = 1;
97127 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
97128 + DECL_EXTERNAL(latent_entropy_decl) = 1;
97129 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
97130 + DECL_INITIAL(latent_entropy_decl) = NULL;
97131 + lang_hooks.decls.pushdecl(latent_entropy_decl);
97132 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
97133 +// varpool_finalize_decl(latent_entropy_decl);
97134 +// varpool_mark_needed_node(latent_entropy_decl);
97135 +}
97136 +
97137 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
97138 +{
97139 + const char * const plugin_name = plugin_info->base_name;
97140 + struct register_pass_info latent_entropy_pass_info = {
97141 + .pass = &latent_entropy_pass.pass,
97142 + .reference_pass_name = "optimized",
97143 + .ref_pass_instance_number = 1,
97144 + .pos_op = PASS_POS_INSERT_BEFORE
97145 + };
97146 +
97147 + if (!plugin_default_version_check(version, &gcc_version)) {
97148 + error(G_("incompatible gcc/plugin versions"));
97149 + return 1;
97150 + }
97151 +
97152 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
97153 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
97154 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
97155 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
97156 +
97157 + return 0;
97158 +}
97159 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
97160 new file mode 100644
97161 index 0000000..b04803b
97162 --- /dev/null
97163 +++ b/tools/gcc/size_overflow_hash.data
97164 @@ -0,0 +1,6350 @@
97165 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
97166 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
97167 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
97168 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
97169 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
97170 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
97171 +padzero_55 padzero 1 55 &sel_read_policyvers_55
97172 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
97173 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
97174 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
97175 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
97176 +load_msg_95 load_msg 2 95 NULL
97177 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
97178 +init_q_132 init_q 4 132 NULL
97179 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
97180 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
97181 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
97182 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
97183 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
97184 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
97185 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
97186 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
97187 +br_port_info_size_268 br_port_info_size 0 268 NULL
97188 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
97189 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
97190 +SYSC_connect_304 SYSC_connect 3 304 NULL
97191 +syslog_print_307 syslog_print 2 307 NULL
97192 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
97193 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
97194 +next_node_allowed_318 next_node_allowed 1 318 NULL
97195 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
97196 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
97197 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
97198 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
97199 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
97200 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
97201 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
97202 +pidlist_resize_496 pidlist_resize 2 496 NULL
97203 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
97204 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
97205 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
97206 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
97207 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
97208 +dle_count_543 dle_count 0 543 NULL
97209 +devres_alloc_551 devres_alloc 2 551 NULL
97210 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
97211 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
97212 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
97213 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
97214 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
97215 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
97216 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
97217 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
97218 +isp1760_register_628 isp1760_register 1-2 628 NULL
97219 +clone_split_bio_633 clone_split_bio 6 633 NULL
97220 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
97221 +remap_to_cache_640 remap_to_cache 3 640 NULL
97222 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
97223 +unlink_queued_645 unlink_queued 3-4 645 NULL
97224 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
97225 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
97226 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
97227 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
97228 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
97229 +disk_max_parts_719 disk_max_parts 0 719 NULL
97230 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
97231 +dvb_video_write_754 dvb_video_write 3 754 NULL
97232 +if_writecmd_815 if_writecmd 2 815 NULL
97233 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
97234 +read_fifo_826 read_fifo 3 826 NULL
97235 +um_idi_read_850 um_idi_read 3 850 NULL
97236 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
97237 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
97238 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
97239 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
97240 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
97241 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
97242 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
97243 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
97244 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
97245 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
97246 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
97247 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
97248 +_do_truncate_1019 _do_truncate 2 1019 NULL
97249 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
97250 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
97251 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
97252 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
97253 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
97254 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
97255 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
97256 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
97257 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
97258 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
97259 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
97260 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
97261 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
97262 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
97263 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
97264 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
97265 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
97266 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
97267 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
97268 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
97269 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
97270 +nested_get_page_1252 nested_get_page 2 1252 NULL
97271 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
97272 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
97273 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
97274 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
97275 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
97276 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
97277 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
97278 +ffs_1322 ffs 0 1322 NULL
97279 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
97280 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
97281 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
97282 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
97283 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
97284 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
97285 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
97286 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
97287 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
97288 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
97289 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
97290 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
97291 +zone_page_state_1393 zone_page_state 0 1393 NULL
97292 +file_read_actor_1401 file_read_actor 4 1401 NULL
97293 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
97294 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
97295 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
97296 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
97297 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
97298 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
97299 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
97300 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
97301 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
97302 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
97303 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
97304 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
97305 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
97306 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
97307 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
97308 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
97309 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
97310 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
97311 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
97312 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
97313 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
97314 +rmap_add_1677 rmap_add 3 1677 NULL
97315 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
97316 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
97317 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
97318 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
97319 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
97320 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
97321 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
97322 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
97323 +cosa_write_1774 cosa_write 3 1774 NULL
97324 +update_macheader_1775 update_macheader 7 1775 NULL
97325 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
97326 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
97327 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
97328 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
97329 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
97330 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
97331 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
97332 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
97333 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
97334 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
97335 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
97336 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
97337 +read_swap_header_1957 read_swap_header 0 1957 NULL
97338 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
97339 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
97340 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
97341 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
97342 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
97343 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
97344 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
97345 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
97346 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
97347 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
97348 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
97349 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
97350 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
97351 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
97352 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
97353 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
97354 +audit_expand_2098 audit_expand 2 2098 NULL
97355 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
97356 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
97357 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
97358 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
97359 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
97360 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
97361 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
97362 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
97363 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
97364 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
97365 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
97366 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
97367 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
97368 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
97369 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
97370 +vhci_write_2224 vhci_write 3 2224 NULL
97371 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
97372 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
97373 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
97374 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
97375 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
97376 +do_update_counters_2259 do_update_counters 4 2259 NULL
97377 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
97378 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
97379 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
97380 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
97381 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
97382 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
97383 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
97384 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
97385 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
97386 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
97387 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
97388 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
97389 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
97390 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
97391 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
97392 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
97393 +raid1_size_2419 raid1_size 0-2 2419 NULL
97394 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
97395 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
97396 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
97397 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
97398 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
97399 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
97400 +update_pmkid_2481 update_pmkid 4 2481 NULL
97401 +wiphy_new_2482 wiphy_new 2 2482 NULL
97402 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
97403 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
97404 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
97405 +dm_write_2513 dm_write 3 2513 NULL
97406 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
97407 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
97408 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
97409 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
97410 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
97411 +slot_bytes_2609 slot_bytes 0 2609 NULL
97412 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
97413 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
97414 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
97415 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
97416 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
97417 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
97418 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
97419 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
97420 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
97421 +__next_cpu_2782 __next_cpu 1 2782 NULL
97422 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
97423 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
97424 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
97425 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
97426 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
97427 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
97428 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
97429 +mq_map_2871 mq_map 2 2871 NULL
97430 +nla_padlen_2883 nla_padlen 1 2883 NULL
97431 +cmm_write_2896 cmm_write 3 2896 NULL
97432 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
97433 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
97434 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
97435 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
97436 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
97437 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
97438 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
97439 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
97440 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
97441 +depth_write_3021 depth_write 3 3021 NULL
97442 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
97443 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
97444 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
97445 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
97446 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
97447 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
97448 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
97449 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
97450 +free_coherent_3082 free_coherent 4-2 3082 NULL
97451 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
97452 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
97453 +rb_alloc_3102 rb_alloc 1 3102 NULL
97454 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
97455 +print_time_3132 print_time 0 3132 NULL
97456 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
97457 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
97458 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
97459 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
97460 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
97461 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
97462 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
97463 +alloc_context_3194 alloc_context 1 3194 NULL
97464 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
97465 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
97466 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
97467 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
97468 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
97469 +key_key_read_3241 key_key_read 3 3241 NULL
97470 +number_3243 number 0 3243 NULL
97471 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
97472 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
97473 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
97474 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
97475 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
97476 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
97477 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
97478 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
97479 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
97480 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
97481 +scnprintf_3360 scnprintf 0-2 3360 NULL
97482 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
97483 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
97484 +send_stream_3397 send_stream 4 3397 NULL
97485 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
97486 +msix_map_region_3411 msix_map_region 3 3411 NULL
97487 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
97488 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
97489 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
97490 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
97491 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
97492 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
97493 +map_single_3449 map_single 0-2 3449 NULL
97494 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
97495 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
97496 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
97497 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
97498 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
97499 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
97500 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
97501 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
97502 +SyS_readv_3539 SyS_readv 3 3539 NULL
97503 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
97504 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
97505 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
97506 +evtchn_read_3569 evtchn_read 3 3569 NULL
97507 +vc_resize_3585 vc_resize 2-3 3585 NULL
97508 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
97509 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
97510 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
97511 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
97512 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
97513 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
97514 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
97515 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
97516 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
97517 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
97518 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
97519 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
97520 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
97521 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
97522 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
97523 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
97524 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
97525 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
97526 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
97527 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
97528 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
97529 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
97530 +get_fd_set_3866 get_fd_set 1 3866 NULL
97531 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
97532 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
97533 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
97534 +nvram_write_3894 nvram_write 3 3894 NULL
97535 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
97536 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
97537 +vcs_write_3910 vcs_write 3 3910 NULL
97538 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
97539 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
97540 +do_add_counters_3992 do_add_counters 3 3992 NULL
97541 +userspace_status_4004 userspace_status 4 4004 NULL
97542 +mei_write_4005 mei_write 3 4005 NULL nohasharray
97543 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
97544 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
97545 +mm_populate_4016 mm_populate 1 4016 NULL
97546 +blk_end_request_4024 blk_end_request 3 4024 NULL
97547 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
97548 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
97549 +read_file_queues_4078 read_file_queues 3 4078 NULL
97550 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
97551 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
97552 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
97553 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
97554 +tm6000_read_4151 tm6000_read 3 4151 NULL
97555 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
97556 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
97557 +get_alua_req_4166 get_alua_req 3 4166 NULL
97558 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
97559 +read_file_bool_4180 read_file_bool 3 4180 NULL
97560 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
97561 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
97562 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
97563 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
97564 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
97565 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
97566 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
97567 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
97568 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
97569 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
97570 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
97571 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
97572 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
97573 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
97574 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
97575 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
97576 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
97577 +memparse_4444 memparse 0 4444 NULL
97578 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
97579 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
97580 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
97581 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
97582 +set_link_security_4502 set_link_security 4 4502 NULL
97583 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
97584 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
97585 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
97586 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
97587 +tty_register_device_4544 tty_register_device 2 4544 NULL
97588 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
97589 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
97590 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
97591 +bch_alloc_4593 bch_alloc 1 4593 NULL
97592 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
97593 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
97594 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
97595 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
97596 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
97597 +kone_receive_4690 kone_receive 4 4690 NULL
97598 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
97599 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
97600 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
97601 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
97602 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
97603 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
97604 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
97605 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
97606 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
97607 +create_subvol_4791 create_subvol 4 4791 NULL
97608 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
97609 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
97610 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
97611 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
97612 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
97613 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
97614 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
97615 +sys_ipc_4889 sys_ipc 3 4889 NULL
97616 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
97617 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
97618 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
97619 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
97620 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
97621 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
97622 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
97623 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
97624 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
97625 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
97626 +do_mincore_5018 do_mincore 0-1 5018 NULL
97627 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
97628 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
97629 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
97630 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
97631 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
97632 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
97633 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
97634 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
97635 +sound_write_5102 sound_write 3 5102 NULL
97636 +clear_dirty_5105 clear_dirty 3 5105 NULL
97637 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
97638 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
97639 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
97640 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
97641 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
97642 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
97643 +skb_network_header_5203 skb_network_header 0 5203 NULL
97644 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
97645 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
97646 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
97647 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
97648 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
97649 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
97650 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
97651 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
97652 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
97653 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
97654 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
97655 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
97656 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
97657 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
97658 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
97659 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
97660 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
97661 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
97662 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
97663 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
97664 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
97665 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
97666 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
97667 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
97668 +tty_write_5494 tty_write 3 5494 NULL
97669 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
97670 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
97671 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
97672 +spidev_message_5518 spidev_message 3 5518 NULL
97673 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
97674 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
97675 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
97676 +le_readq_5557 le_readq 0 5557 NULL
97677 +inw_5558 inw 0 5558 NULL
97678 +fir16_create_5574 fir16_create 3 5574 NULL
97679 +bioset_create_5580 bioset_create 1 5580 NULL
97680 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
97681 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
97682 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
97683 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
97684 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
97685 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
97686 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
97687 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
97688 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
97689 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
97690 +get_arg_5694 get_arg 3 5694 NULL
97691 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
97692 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
97693 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
97694 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
97695 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
97696 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
97697 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
97698 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
97699 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
97700 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
97701 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
97702 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
97703 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
97704 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
97705 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
97706 +setup_req_5848 setup_req 3 5848 NULL
97707 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
97708 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
97709 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
97710 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
97711 +port_show_regs_5904 port_show_regs 3 5904 NULL
97712 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
97713 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
97714 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
97715 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
97716 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
97717 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
97718 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
97719 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
97720 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
97721 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
97722 +native_pte_val_5978 native_pte_val 0 5978 NULL
97723 +SyS_semop_5980 SyS_semop 3 5980 NULL
97724 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
97725 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
97726 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
97727 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
97728 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
97729 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
97730 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
97731 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
97732 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
97733 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
97734 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
97735 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
97736 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
97737 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
97738 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
97739 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
97740 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
97741 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
97742 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
97743 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
97744 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
97745 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
97746 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
97747 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
97748 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
97749 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
97750 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
97751 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
97752 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
97753 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
97754 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
97755 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
97756 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
97757 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
97758 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
97759 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
97760 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
97761 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
97762 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
97763 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
97764 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
97765 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
97766 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
97767 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
97768 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
97769 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
97770 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
97771 +mei_read_6507 mei_read 3 6507 NULL
97772 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
97773 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
97774 +wdm_read_6549 wdm_read 3 6549 NULL
97775 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
97776 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
97777 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
97778 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
97779 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
97780 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
97781 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
97782 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
97783 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
97784 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
97785 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
97786 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
97787 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
97788 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
97789 +mpeg_read_6708 mpeg_read 3 6708 NULL
97790 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
97791 +video_proc_write_6724 video_proc_write 3 6724 NULL
97792 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
97793 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
97794 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
97795 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
97796 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
97797 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
97798 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
97799 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
97800 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
97801 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
97802 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
97803 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
97804 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
97805 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
97806 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
97807 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
97808 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
97809 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
97810 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
97811 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
97812 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
97813 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
97814 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
97815 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
97816 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
97817 +request_key_async_6990 request_key_async 4 6990 NULL
97818 +tpl_write_6998 tpl_write 3 6998 NULL
97819 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
97820 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
97821 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
97822 +wimax_msg_7030 wimax_msg 4 7030 NULL
97823 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
97824 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
97825 +event_enable_read_7074 event_enable_read 3 7074 NULL
97826 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
97827 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
97828 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
97829 +check_header_7108 check_header 0 7108 NULL
97830 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
97831 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
97832 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
97833 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
97834 +get_param_h_7247 get_param_h 0 7247 NULL
97835 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
97836 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
97837 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
97838 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
97839 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
97840 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
97841 +mgmt_control_7349 mgmt_control 3 7349 NULL
97842 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
97843 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
97844 +hweight_long_7388 hweight_long 0-1 7388 NULL
97845 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
97846 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
97847 +readb_7401 readb 0 7401 NULL
97848 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
97849 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
97850 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
97851 +numa_emulation_7466 numa_emulation 2 7466 NULL
97852 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
97853 +garp_request_join_7471 garp_request_join 4 7471 NULL
97854 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
97855 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
97856 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
97857 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
97858 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
97859 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
97860 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
97861 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
97862 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
97863 +groups_alloc_7614 groups_alloc 1 7614 NULL
97864 +sg_virt_7616 sg_virt 0 7616 NULL
97865 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
97866 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
97867 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
97868 +dev_write_7708 dev_write 3 7708 NULL
97869 +unmap_region_7709 unmap_region 1 7709 NULL
97870 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
97871 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
97872 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
97873 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
97874 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
97875 +ioread32be_7773 ioread32be 0 7773 NULL
97876 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
97877 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
97878 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
97879 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
97880 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
97881 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
97882 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
97883 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
97884 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
97885 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
97886 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
97887 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
97888 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
97889 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
97890 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
97891 +sys_mbind_7990 sys_mbind 5 7990 NULL
97892 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
97893 +vcs_read_8017 vcs_read 3 8017 NULL
97894 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
97895 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
97896 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
97897 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
97898 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
97899 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
97900 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
97901 +venus_lookup_8121 venus_lookup 4 8121 NULL
97902 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
97903 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
97904 +ore_truncate_8181 ore_truncate 3 8181 NULL
97905 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
97906 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
97907 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
97908 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
97909 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
97910 +play_iframe_8219 play_iframe 3 8219 NULL
97911 +create_log_8225 create_log 2 8225 NULL nohasharray
97912 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
97913 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
97914 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
97915 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
97916 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
97917 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
97918 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
97919 +init_cdev_8274 init_cdev 1 8274 NULL
97920 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
97921 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
97922 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
97923 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
97924 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
97925 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
97926 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
97927 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
97928 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
97929 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
97930 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
97931 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
97932 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
97933 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
97934 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
97935 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
97936 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
97937 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
97938 +dev_config_8506 dev_config 3 8506 NULL
97939 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
97940 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
97941 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
97942 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
97943 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
97944 +user_on_off_8552 user_on_off 2 8552 NULL
97945 +profile_remove_8556 profile_remove 3 8556 NULL
97946 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
97947 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
97948 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
97949 +tower_write_8580 tower_write 3 8580 NULL
97950 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
97951 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
97952 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
97953 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
97954 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
97955 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
97956 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
97957 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
97958 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
97959 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
97960 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
97961 +arcfb_write_8702 arcfb_write 3 8702 NULL
97962 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
97963 +init_header_8703 init_header 0 8703 &i_size_read_8703
97964 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
97965 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
97966 +f_dupfd_8730 f_dupfd 1 8730 NULL
97967 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
97968 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
97969 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
97970 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
97971 +sys_prctl_8766 sys_prctl 4 8766 NULL
97972 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
97973 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
97974 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
97975 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
97976 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
97977 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
97978 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
97979 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
97980 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
97981 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
97982 +clear_bitset_8840 clear_bitset 2 8840 NULL
97983 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
97984 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
97985 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
97986 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
97987 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
97988 +layout_commit_8926 layout_commit 3 8926 NULL
97989 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
97990 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
97991 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
97992 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
97993 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
97994 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
97995 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
97996 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
97997 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
97998 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
97999 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
98000 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
98001 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
98002 +nla_put_9042 nla_put 3 9042 NULL
98003 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
98004 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
98005 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
98006 +string_9080 string 0 9080 NULL
98007 +create_queues_9088 create_queues 2-3 9088 NULL
98008 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
98009 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
98010 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
98011 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
98012 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
98013 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
98014 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
98015 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
98016 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
98017 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
98018 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
98019 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
98020 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
98021 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
98022 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
98023 +get_pfn_9207 get_pfn 1 9207 NULL
98024 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
98025 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
98026 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
98027 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
98028 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
98029 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
98030 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
98031 +flakey_status_9274 flakey_status 5 9274 NULL
98032 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
98033 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
98034 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
98035 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
98036 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
98037 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
98038 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
98039 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
98040 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
98041 +read_9397 read 3 9397 NULL
98042 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
98043 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
98044 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
98045 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
98046 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
98047 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
98048 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
98049 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
98050 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
98051 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
98052 +lp_write_9511 lp_write 3 9511 NULL
98053 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
98054 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
98055 +read_file_dma_9530 read_file_dma 3 9530 NULL
98056 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
98057 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
98058 +fw_node_create_9559 fw_node_create 2 9559 NULL
98059 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
98060 +kobj_map_9566 kobj_map 2-3 9566 NULL
98061 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
98062 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
98063 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
98064 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
98065 +do_sync_9604 do_sync 1 9604 NULL
98066 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
98067 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
98068 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
98069 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
98070 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
98071 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
98072 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
98073 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
98074 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
98075 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
98076 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
98077 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
98078 +is_hole_9694 is_hole 2 9694 NULL nohasharray
98079 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
98080 +fnb_9703 fnb 2-3 9703 NULL
98081 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
98082 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
98083 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
98084 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
98085 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
98086 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
98087 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
98088 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
98089 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
98090 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
98091 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
98092 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
98093 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
98094 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
98095 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
98096 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
98097 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
98098 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
98099 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
98100 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
98101 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
98102 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
98103 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
98104 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
98105 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
98106 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
98107 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
98108 +read_file_misc_9948 read_file_misc 3 9948 NULL
98109 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
98110 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
98111 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
98112 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
98113 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
98114 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
98115 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
98116 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
98117 +handle_request_10024 handle_request 9 10024 NULL
98118 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
98119 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
98120 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
98121 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
98122 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
98123 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
98124 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
98125 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
98126 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
98127 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
98128 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
98129 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
98130 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
98131 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
98132 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
98133 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
98134 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
98135 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
98136 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
98137 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
98138 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
98139 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
98140 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
98141 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
98142 +read_emulate_10310 read_emulate 2-4 10310 NULL
98143 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
98144 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
98145 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
98146 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
98147 +get_dump_page_10338 get_dump_page 1 10338 NULL
98148 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
98149 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
98150 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
98151 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
98152 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
98153 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
98154 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
98155 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
98156 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
98157 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
98158 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
98159 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
98160 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
98161 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
98162 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
98163 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
98164 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
98165 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
98166 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
98167 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
98168 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
98169 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
98170 +otp_read_10594 otp_read 2-4-5 10594 NULL
98171 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
98172 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
98173 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
98174 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
98175 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
98176 +parport_write_10669 parport_write 0 10669 NULL
98177 +inl_10708 inl 0 10708 NULL nohasharray
98178 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
98179 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
98180 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
98181 +spi_sync_10731 spi_sync 0 10731 NULL
98182 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
98183 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
98184 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
98185 +sys_syslog_10746 sys_syslog 3 10746 NULL
98186 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
98187 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
98188 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
98189 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
98190 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
98191 +sys_bind_10799 sys_bind 3 10799 NULL
98192 +compat_put_int_10828 compat_put_int 1 10828 NULL
98193 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
98194 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
98195 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
98196 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
98197 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
98198 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
98199 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
98200 +get_scq_10897 get_scq 2 10897 NULL
98201 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
98202 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
98203 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
98204 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
98205 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
98206 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
98207 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
98208 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
98209 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
98210 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
98211 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
98212 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
98213 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
98214 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
98215 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
98216 +count_argc_11083 count_argc 0 11083 NULL
98217 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
98218 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
98219 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
98220 +page_offset_11120 page_offset 0 11120 NULL
98221 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
98222 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
98223 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
98224 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
98225 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
98226 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
98227 +__swab16p_11220 __swab16p 0 11220 NULL
98228 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
98229 +mmap_region_11247 mmap_region 0-2 11247 NULL
98230 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
98231 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
98232 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
98233 +cru_detect_11272 cru_detect 1 11272 NULL
98234 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
98235 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
98236 +construct_key_11329 construct_key 3 11329 NULL nohasharray
98237 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
98238 +next_segment_11330 next_segment 0-2-1 11330 NULL
98239 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
98240 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
98241 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
98242 +sel_write_create_11353 sel_write_create 3 11353 NULL
98243 +handle_unit_11355 handle_unit 0-1 11355 NULL
98244 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
98245 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
98246 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
98247 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
98248 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
98249 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
98250 +str_to_user_11411 str_to_user 2 11411 NULL
98251 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
98252 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
98253 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
98254 +trace_options_read_11419 trace_options_read 3 11419 NULL
98255 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
98256 +prepare_image_11424 prepare_image 0 11424 NULL
98257 +vring_size_11426 vring_size 0-1-2 11426 NULL
98258 +bttv_read_11432 bttv_read 3 11432 NULL
98259 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
98260 +swp_offset_11475 swp_offset 0 11475 NULL
98261 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
98262 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
98263 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
98264 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
98265 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
98266 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
98267 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
98268 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
98269 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
98270 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
98271 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
98272 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
98273 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
98274 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
98275 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
98276 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
98277 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
98278 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
98279 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
98280 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
98281 +split_11691 split 2 11691 NULL
98282 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
98283 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
98284 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
98285 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
98286 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
98287 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
98288 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
98289 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
98290 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
98291 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
98292 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
98293 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
98294 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
98295 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
98296 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
98297 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
98298 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
98299 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
98300 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
98301 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
98302 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
98303 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
98304 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
98305 +atmel_read16_11981 atmel_read16 0 11981 NULL
98306 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
98307 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
98308 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
98309 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
98310 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
98311 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
98312 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
98313 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
98314 +set_powered_12129 set_powered 4 12129 NULL
98315 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
98316 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
98317 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
98318 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
98319 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
98320 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
98321 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
98322 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
98323 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
98324 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
98325 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
98326 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
98327 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
98328 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
98329 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
98330 +scaled_div_12201 scaled_div 1-2 12201 NULL
98331 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
98332 +receive_copy_12216 receive_copy 3 12216 NULL
98333 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
98334 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
98335 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
98336 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
98337 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
98338 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
98339 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
98340 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
98341 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
98342 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
98343 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
98344 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
98345 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
98346 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
98347 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
98348 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
98349 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
98350 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
98351 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
98352 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
98353 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
98354 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
98355 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
98356 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
98357 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
98358 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
98359 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
98360 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
98361 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
98362 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
98363 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
98364 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
98365 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
98366 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
98367 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
98368 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
98369 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
98370 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
98371 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
98372 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
98373 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
98374 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
98375 +wb_create_12651 wb_create 1 12651 NULL
98376 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
98377 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
98378 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
98379 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
98380 +ivtv_write_12721 ivtv_write 3 12721 NULL
98381 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
98382 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
98383 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
98384 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
98385 +listxattr_12769 listxattr 3 12769 NULL
98386 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
98387 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
98388 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
98389 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
98390 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
98391 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
98392 +readq_12825 readq 0 12825 NULL
98393 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
98394 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
98395 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
98396 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
98397 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
98398 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
98399 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
98400 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
98401 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
98402 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
98403 +bm_status_write_12964 bm_status_write 3 12964 NULL
98404 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
98405 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
98406 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
98407 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
98408 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
98409 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
98410 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
98411 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
98412 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
98413 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
98414 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
98415 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
98416 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
98417 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
98418 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
98419 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
98420 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
98421 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
98422 +blk_update_request_13146 blk_update_request 3 13146 NULL
98423 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
98424 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
98425 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
98426 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
98427 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
98428 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
98429 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
98430 +comedi_read_13199 comedi_read 3 13199 NULL
98431 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
98432 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
98433 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
98434 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
98435 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
98436 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
98437 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
98438 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
98439 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
98440 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
98441 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
98442 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
98443 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
98444 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
98445 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
98446 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
98447 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
98448 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
98449 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
98450 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
98451 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
98452 +cache_ctr_13364 cache_ctr 2 13364 NULL
98453 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
98454 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
98455 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
98456 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
98457 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
98458 +sky2_receive_13407 sky2_receive 2 13407 NULL
98459 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
98460 +keyring_read_13438 keyring_read 3 13438 NULL
98461 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
98462 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
98463 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
98464 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
98465 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
98466 +core_status_13515 core_status 4 13515 NULL
98467 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
98468 +bm_init_13529 bm_init 2 13529 NULL
98469 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
98470 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
98471 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
98472 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
98473 +sys_madvise_13569 sys_madvise 1 13569 NULL
98474 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
98475 +cache_write_13589 cache_write 3 13589 NULL
98476 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
98477 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
98478 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
98479 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
98480 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
98481 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
98482 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
98483 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
98484 +packet_snd_13634 packet_snd 3 13634 NULL
98485 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
98486 +cache_downcall_13666 cache_downcall 3 13666 NULL
98487 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
98488 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
98489 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
98490 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
98491 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
98492 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
98493 +random_read_13815 random_read 3 13815 NULL
98494 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
98495 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
98496 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
98497 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
98498 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
98499 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
98500 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
98501 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
98502 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
98503 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
98504 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
98505 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
98506 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
98507 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
98508 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
98509 +com90xx_found_13974 com90xx_found 3 13974 NULL
98510 +qcam_read_13977 qcam_read 3 13977 NULL
98511 +dsp_read_13980 dsp_read 2 13980 NULL
98512 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
98513 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
98514 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
98515 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
98516 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
98517 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
98518 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
98519 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
98520 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
98521 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
98522 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
98523 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
98524 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
98525 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
98526 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
98527 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
98528 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
98529 +em_canid_change_14150 em_canid_change 3 14150 NULL
98530 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
98531 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
98532 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
98533 +alloc_async_14208 alloc_async 1 14208 NULL
98534 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
98535 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
98536 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
98537 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
98538 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
98539 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
98540 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
98541 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
98542 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
98543 +rr_status_14293 rr_status 5 14293 NULL
98544 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
98545 +oo_objects_14319 oo_objects 0 14319 NULL
98546 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
98547 +scsi2int_14358 scsi2int 0 14358 NULL
98548 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
98549 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
98550 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
98551 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
98552 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
98553 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
98554 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
98555 +block_size_14443 block_size 0 14443 NULL
98556 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
98557 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
98558 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
98559 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
98560 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
98561 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
98562 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
98563 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
98564 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
98565 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
98566 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
98567 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
98568 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
98569 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
98570 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
98571 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
98572 +dbJoin_14644 dbJoin 0 14644 NULL
98573 +profile_replace_14652 profile_replace 3 14652 NULL
98574 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
98575 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
98576 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
98577 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
98578 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
98579 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
98580 +get_bio_block_14714 get_bio_block 0 14714 NULL
98581 +vfd_write_14717 vfd_write 3 14717 NULL
98582 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
98583 +raid1_resize_14740 raid1_resize 2 14740 NULL
98584 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
98585 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
98586 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
98587 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
98588 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
98589 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
98590 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
98591 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
98592 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
98593 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
98594 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
98595 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
98596 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
98597 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
98598 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
98599 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
98600 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
98601 +unifi_read_14899 unifi_read 3 14899 NULL
98602 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
98603 +krealloc_14908 krealloc 2 14908 NULL
98604 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
98605 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
98606 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
98607 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
98608 +queue_cnt_14951 queue_cnt 0 14951 NULL
98609 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
98610 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
98611 +setkey_14987 setkey 3 14987 NULL nohasharray
98612 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
98613 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
98614 +vmap_15025 vmap 2 15025 NULL
98615 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
98616 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
98617 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
98618 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
98619 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
98620 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
98621 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
98622 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
98623 +start_port_15124 start_port 0 15124 NULL
98624 +memchr_15126 memchr 0 15126 NULL
98625 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
98626 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
98627 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
98628 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
98629 +reserve_resources_15194 reserve_resources 3 15194 NULL
98630 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
98631 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
98632 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
98633 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
98634 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
98635 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
98636 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
98637 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
98638 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
98639 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
98640 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
98641 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
98642 +ioread16_15342 ioread16 0 15342 NULL
98643 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
98644 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
98645 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
98646 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
98647 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
98648 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
98649 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
98650 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
98651 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
98652 +get_modalias_15406 get_modalias 2 15406 NULL
98653 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
98654 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
98655 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
98656 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
98657 +memweight_15450 memweight 2 15450 NULL
98658 +vmalloc_15464 vmalloc 1 15464 NULL
98659 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
98660 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
98661 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
98662 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
98663 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
98664 +persistent_status_15574 persistent_status 4 15574 NULL
98665 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
98666 +vme_user_write_15587 vme_user_write 3 15587 NULL
98667 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
98668 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
98669 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
98670 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
98671 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
98672 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
98673 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
98674 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
98675 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
98676 +fs_path_add_15648 fs_path_add 3 15648 NULL
98677 +xsd_read_15653 xsd_read 3 15653 NULL
98678 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
98679 +unix_bind_15668 unix_bind 3 15668 NULL
98680 +dm_read_15674 dm_read 3 15674 NULL
98681 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
98682 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
98683 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
98684 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
98685 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
98686 +do_test_15766 do_test 1 15766 NULL
98687 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
98688 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
98689 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
98690 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
98691 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
98692 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
98693 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
98694 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
98695 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
98696 +table_size_15851 table_size 0-1-2 15851 NULL
98697 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
98698 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
98699 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
98700 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
98701 +native_read_msr_15905 native_read_msr 0 15905 NULL
98702 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
98703 +power_read_15939 power_read 3 15939 NULL
98704 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
98705 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
98706 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
98707 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
98708 +frame_alloc_15981 frame_alloc 4 15981 NULL
98709 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
98710 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
98711 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
98712 +got_frame_16028 got_frame 2 16028 NULL
98713 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
98714 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
98715 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
98716 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
98717 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
98718 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
98719 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
98720 +fsm_init_16134 fsm_init 2 16134 NULL
98721 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
98722 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
98723 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
98724 +mapping_level_16188 mapping_level 2 16188 NULL
98725 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
98726 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
98727 +create_table_16213 create_table 2 16213 NULL
98728 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
98729 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
98730 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
98731 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
98732 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
98733 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
98734 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
98735 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
98736 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
98737 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
98738 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
98739 +account_16283 account 0-2-4 16283 NULL nohasharray
98740 +mirror_status_16283 mirror_status 5 16283 &account_16283
98741 +retry_instruction_16285 retry_instruction 2 16285 NULL
98742 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
98743 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
98744 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
98745 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
98746 +wb_map_16301 wb_map 2 16301 NULL
98747 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
98748 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
98749 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
98750 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
98751 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
98752 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
98753 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
98754 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
98755 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
98756 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
98757 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
98758 +raid10_resize_16537 raid10_resize 2 16537 NULL
98759 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
98760 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
98761 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
98762 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
98763 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
98764 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
98765 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
98766 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
98767 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
98768 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
98769 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
98770 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
98771 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
98772 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
98773 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
98774 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
98775 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
98776 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
98777 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
98778 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
98779 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
98780 +st_write_16874 st_write 3 16874 NULL
98781 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
98782 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
98783 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
98784 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
98785 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
98786 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
98787 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
98788 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
98789 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
98790 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
98791 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
98792 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
98793 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
98794 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
98795 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
98796 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
98797 +mac_address_string_17091 mac_address_string 0 17091 NULL
98798 +entry_length_17093 entry_length 0 17093 NULL
98799 +sys_preadv_17100 sys_preadv 3 17100 NULL
98800 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
98801 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
98802 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
98803 +sep_read_17161 sep_read 3 17161 NULL
98804 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
98805 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
98806 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
98807 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
98808 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
98809 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
98810 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
98811 +to_oblock_17254 to_oblock 0-1 17254 NULL
98812 +unpack_value_17259 unpack_value 1 17259 NULL
98813 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
98814 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
98815 +alloc_ep_17269 alloc_ep 1 17269 NULL
98816 +pg_read_17276 pg_read 3 17276 NULL
98817 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
98818 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
98819 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
98820 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
98821 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
98822 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
98823 +skb_pad_17302 skb_pad 2 17302 NULL
98824 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
98825 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
98826 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
98827 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
98828 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
98829 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
98830 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
98831 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
98832 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
98833 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
98834 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
98835 +compat_cmd_17465 compat_cmd 2 17465 NULL
98836 +probe_bios_17467 probe_bios 1 17467 NULL
98837 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
98838 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
98839 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
98840 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
98841 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
98842 +copy_from_user_17559 copy_from_user 3 17559 NULL
98843 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
98844 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
98845 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
98846 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
98847 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
98848 +osst_execute_17607 osst_execute 7-6 17607 NULL
98849 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
98850 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
98851 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
98852 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
98853 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
98854 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
98855 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
98856 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
98857 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
98858 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
98859 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
98860 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
98861 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
98862 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
98863 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
98864 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
98865 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
98866 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
98867 +perf_clock_17787 perf_clock 0 17787 NULL
98868 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
98869 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
98870 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
98871 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
98872 +count_leafs_17842 count_leafs 0 17842 NULL
98873 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
98874 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
98875 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
98876 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
98877 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
98878 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
98879 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
98880 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
98881 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
98882 +recover_head_17904 recover_head 3 17904 NULL
98883 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
98884 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
98885 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
98886 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
98887 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
98888 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
98889 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
98890 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
98891 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
98892 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
98893 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
98894 +fill_read_18019 fill_read 0 18019 NULL
98895 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
98896 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
98897 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
98898 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
98899 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
98900 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
98901 +packet_came_18072 packet_came 3 18072 NULL
98902 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
98903 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
98904 +get_vm_area_18080 get_vm_area 1 18080 NULL
98905 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
98906 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
98907 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
98908 +svc_getnl_18120 svc_getnl 0 18120 NULL
98909 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
98910 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
98911 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
98912 +_has_tag_18169 _has_tag 2 18169 NULL
98913 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
98914 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
98915 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
98916 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
98917 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
98918 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
98919 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
98920 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
98921 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
98922 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
98923 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
98924 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
98925 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
98926 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
98927 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
98928 +um_idi_write_18293 um_idi_write 3 18293 NULL
98929 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
98930 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
98931 +vga_r_18310 vga_r 0 18310 NULL
98932 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
98933 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
98934 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
98935 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
98936 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
98937 +ep_io_18367 ep_io 0 18367 NULL
98938 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
98939 +ci_role_write_18388 ci_role_write 3 18388 NULL
98940 +__video_register_device_18399 __video_register_device 3 18399 NULL
98941 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
98942 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
98943 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
98944 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
98945 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
98946 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
98947 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
98948 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
98949 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
98950 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
98951 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
98952 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
98953 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
98954 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
98955 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
98956 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
98957 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
98958 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
98959 +debug_output_18575 debug_output 3 18575 NULL
98960 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
98961 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
98962 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
98963 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
98964 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
98965 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
98966 +from_buffer_18625 from_buffer 3 18625 NULL
98967 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
98968 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
98969 +unmap_page_18665 unmap_page 2-3 18665 NULL
98970 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
98971 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
98972 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
98973 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
98974 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
98975 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
98976 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
98977 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
98978 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
98979 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
98980 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
98981 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
98982 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
98983 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
98984 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
98985 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
98986 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
98987 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
98988 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
98989 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
98990 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
98991 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
98992 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
98993 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
98994 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
98995 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
98996 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
98997 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
98998 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
98999 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
99000 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
99001 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
99002 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
99003 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
99004 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
99005 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
99006 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
99007 +huge_page_size_19008 huge_page_size 0 19008 NULL
99008 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
99009 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
99010 +revalidate_19043 revalidate 2 19043 NULL
99011 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
99012 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
99013 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
99014 +msix_map_region_19072 msix_map_region 2 19072 NULL
99015 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
99016 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
99017 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
99018 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
99019 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
99020 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
99021 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
99022 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
99023 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
99024 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
99025 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
99026 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
99027 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
99028 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
99029 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
99030 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
99031 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
99032 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
99033 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
99034 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
99035 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
99036 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
99037 +qc_capture_19298 qc_capture 3 19298 NULL
99038 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
99039 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
99040 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
99041 +debug_read_19322 debug_read 3 19322 NULL
99042 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
99043 +closure_sub_19359 closure_sub 2 19359 NULL
99044 +read_zero_19366 read_zero 3 19366 NULL
99045 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
99046 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
99047 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
99048 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
99049 +__phys_addr_19434 __phys_addr 0 19434 NULL
99050 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
99051 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
99052 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
99053 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
99054 +sky2_read16_19475 sky2_read16 0 19475 NULL
99055 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
99056 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
99057 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
99058 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
99059 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
99060 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
99061 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
99062 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
99063 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
99064 +nfsd_read_19568 nfsd_read 5 19568 NULL
99065 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
99066 +bm_status_read_19583 bm_status_read 3 19583 NULL
99067 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
99068 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
99069 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
99070 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
99071 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
99072 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
99073 +bio_detain_19690 bio_detain 2 19690 NULL
99074 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
99075 +read_reg_19723 read_reg 0 19723 NULL
99076 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
99077 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
99078 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
99079 +p9_client_read_19750 p9_client_read 5 19750 NULL
99080 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
99081 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
99082 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
99083 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
99084 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
99085 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
99086 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
99087 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
99088 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
99089 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
99090 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
99091 +__nla_put_19857 __nla_put 3 19857 NULL
99092 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
99093 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
99094 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
99095 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
99096 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
99097 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
99098 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
99099 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
99100 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
99101 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
99102 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
99103 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
99104 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
99105 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
99106 +team_options_register_20091 team_options_register 3 20091 NULL
99107 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
99108 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
99109 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
99110 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
99111 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
99112 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
99113 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
99114 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
99115 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
99116 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
99117 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
99118 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
99119 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
99120 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
99121 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
99122 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
99123 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
99124 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
99125 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
99126 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
99127 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
99128 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
99129 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
99130 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
99131 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
99132 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
99133 +read_buf_20469 read_buf 2 20469 NULL
99134 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
99135 +fast_user_write_20494 fast_user_write 5 20494 NULL
99136 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
99137 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
99138 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
99139 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
99140 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
99141 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
99142 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
99143 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
99144 +venus_create_20555 venus_create 4 20555 NULL
99145 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
99146 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
99147 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
99148 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
99149 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
99150 +lirc_write_20604 lirc_write 3 20604 NULL
99151 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
99152 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
99153 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
99154 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
99155 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
99156 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
99157 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
99158 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
99159 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
99160 +cpumask_size_20683 cpumask_size 0 20683 NULL
99161 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
99162 +gru_vtop_20689 gru_vtop 2 20689 NULL
99163 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
99164 +__maestro_read_20700 __maestro_read 0 20700 NULL
99165 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
99166 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
99167 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
99168 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
99169 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
99170 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
99171 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
99172 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
99173 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
99174 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
99175 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
99176 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
99177 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
99178 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
99179 +sys_sendto_20809 sys_sendto 6 20809 NULL
99180 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
99181 +strndup_user_20819 strndup_user 2 20819 NULL
99182 +calc_layout_20829 calc_layout 3 20829 NULL
99183 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
99184 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
99185 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
99186 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
99187 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
99188 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
99189 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
99190 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
99191 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
99192 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
99193 +htable_bits_20933 htable_bits 0 20933 NULL
99194 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
99195 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
99196 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
99197 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
99198 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
99199 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
99200 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
99201 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
99202 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
99203 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
99204 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
99205 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
99206 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
99207 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
99208 +multipath_status_21094 multipath_status 5 21094 NULL
99209 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
99210 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
99211 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
99212 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
99213 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
99214 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
99215 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
99216 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
99217 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
99218 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
99219 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
99220 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
99221 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
99222 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
99223 +input_ff_create_21240 input_ff_create 2 21240 NULL
99224 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
99225 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
99226 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
99227 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
99228 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
99229 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
99230 +add_res_range_21310 add_res_range 4 21310 NULL
99231 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
99232 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
99233 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
99234 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
99235 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
99236 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
99237 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
99238 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
99239 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
99240 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
99241 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
99242 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
99243 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
99244 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
99245 +concat_writev_21451 concat_writev 3 21451 NULL
99246 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
99247 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
99248 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
99249 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
99250 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
99251 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
99252 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
99253 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
99254 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
99255 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
99256 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
99257 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
99258 +validate_nnode_21638 validate_nnode 0 21638 NULL
99259 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
99260 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
99261 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
99262 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
99263 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
99264 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
99265 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
99266 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
99267 +vm_brk_21739 vm_brk 1 21739 NULL
99268 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
99269 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
99270 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
99271 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
99272 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
99273 +min_odd_21802 min_odd 0 21802 NULL
99274 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
99275 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
99276 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
99277 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
99278 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
99279 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
99280 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
99281 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
99282 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
99283 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
99284 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
99285 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
99286 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
99287 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
99288 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
99289 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
99290 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
99291 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
99292 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
99293 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
99294 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
99295 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
99296 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
99297 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
99298 +write_opcode_22082 write_opcode 2 22082 NULL
99299 +mem_rw_22085 mem_rw 3 22085 NULL
99300 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
99301 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
99302 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
99303 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
99304 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
99305 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
99306 +compat_insn_22142 compat_insn 2 22142 NULL
99307 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
99308 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
99309 +fls_22210 fls 0 22210 NULL
99310 +mem_write_22232 mem_write 3 22232 NULL
99311 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
99312 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
99313 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
99314 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
99315 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
99316 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
99317 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
99318 +extend_brk_22301 extend_brk 0 22301 NULL
99319 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
99320 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
99321 +get_segment_base_22324 get_segment_base 0 22324 NULL
99322 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
99323 +atomic_read_22342 atomic_read 0 22342 NULL
99324 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
99325 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
99326 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
99327 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
99328 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
99329 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
99330 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
99331 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
99332 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
99333 +zoran_write_22404 zoran_write 3 22404 NULL
99334 +queue_reply_22416 queue_reply 3 22416 NULL
99335 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
99336 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
99337 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
99338 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
99339 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
99340 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
99341 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
99342 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
99343 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
99344 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
99345 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
99346 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
99347 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
99348 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
99349 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
99350 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
99351 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
99352 +snapshot_read_22601 snapshot_read 3 22601 NULL
99353 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
99354 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
99355 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
99356 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
99357 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
99358 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
99359 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
99360 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
99361 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
99362 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
99363 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
99364 +map_22700 map 2 22700 NULL
99365 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
99366 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
99367 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
99368 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
99369 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
99370 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
99371 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
99372 +print_frame_22769 print_frame 0 22769 NULL
99373 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
99374 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
99375 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
99376 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
99377 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
99378 +create_attr_set_22861 create_attr_set 1 22861 NULL
99379 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
99380 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
99381 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
99382 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
99383 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
99384 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
99385 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
99386 +vme_get_size_22964 vme_get_size 0 22964 NULL
99387 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
99388 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
99389 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
99390 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
99391 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
99392 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
99393 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
99394 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
99395 +st_status_23032 st_status 5 23032 NULL
99396 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
99397 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
99398 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
99399 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
99400 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
99401 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
99402 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
99403 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
99404 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
99405 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
99406 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
99407 +fls_long_23096 fls_long 0 23096 NULL
99408 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
99409 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
99410 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
99411 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
99412 +__clear_user_23118 __clear_user 0 23118 NULL
99413 +dm_write_async_23120 dm_write_async 3 23120 NULL
99414 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
99415 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
99416 +read_file_ani_23161 read_file_ani 3 23161 NULL
99417 +ioremap_23172 ioremap 1-2 23172 NULL
99418 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
99419 +usblp_write_23178 usblp_write 3 23178 NULL
99420 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
99421 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
99422 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
99423 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
99424 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
99425 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
99426 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
99427 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
99428 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
99429 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
99430 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
99431 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
99432 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
99433 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
99434 +doc_probe_23285 doc_probe 1 23285 NULL
99435 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
99436 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
99437 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
99438 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
99439 +page_readlink_23346 page_readlink 3 23346 NULL
99440 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
99441 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
99442 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
99443 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
99444 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
99445 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
99446 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
99447 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
99448 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
99449 +event_filter_read_23494 event_filter_read 3 23494 NULL
99450 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
99451 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
99452 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
99453 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
99454 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
99455 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
99456 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
99457 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
99458 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
99459 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
99460 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
99461 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
99462 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
99463 +sInW_23663 sInW 0 23663 NULL
99464 +SyS_connect_23669 SyS_connect 3 23669 NULL
99465 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
99466 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
99467 +cx18_read_23699 cx18_read 3 23699 NULL
99468 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
99469 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
99470 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
99471 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
99472 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
99473 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
99474 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
99475 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
99476 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
99477 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
99478 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
99479 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
99480 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
99481 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
99482 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
99483 +p54_init_common_23850 p54_init_common 1 23850 NULL
99484 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
99485 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
99486 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
99487 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
99488 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
99489 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
99490 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
99491 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
99492 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
99493 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
99494 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
99495 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
99496 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
99497 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
99498 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
99499 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
99500 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
99501 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
99502 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
99503 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
99504 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
99505 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
99506 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
99507 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
99508 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
99509 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
99510 +mpu401_read_24126 mpu401_read 3 24126 NULL
99511 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
99512 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
99513 +set_discard_24162 set_discard 2 24162 NULL
99514 +adu_read_24177 adu_read 3 24177 NULL
99515 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
99516 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
99517 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
99518 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
99519 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
99520 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
99521 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
99522 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
99523 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
99524 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
99525 +thin_status_24278 thin_status 5 24278 NULL
99526 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
99527 +msg_size_24288 msg_size 0 24288 NULL
99528 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
99529 +map_page_24298 map_page 3-4 24298 NULL
99530 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
99531 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
99532 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
99533 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
99534 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
99535 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
99536 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
99537 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
99538 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
99539 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
99540 +igetword_24373 igetword 0 24373 NULL
99541 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
99542 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
99543 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
99544 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
99545 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
99546 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
99547 +smk_user_access_24440 smk_user_access 3 24440 NULL
99548 +page_address_24444 page_address 0 24444 NULL
99549 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
99550 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
99551 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
99552 +pd_video_read_24510 pd_video_read 3 24510 NULL
99553 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
99554 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
99555 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
99556 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
99557 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
99558 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
99559 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
99560 +count_preds_24600 count_preds 0 24600 NULL
99561 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
99562 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
99563 +context_alloc_24645 context_alloc 3 24645 NULL
99564 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
99565 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
99566 +read_fs_24717 read_fs 0 24717 NULL
99567 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
99568 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
99569 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
99570 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
99571 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
99572 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
99573 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
99574 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
99575 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
99576 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
99577 +cache_read_24790 cache_read 3 24790 NULL
99578 +unpack_str_24798 unpack_str 0 24798 NULL
99579 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
99580 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
99581 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
99582 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
99583 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
99584 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
99585 +setup_buffering_24872 setup_buffering 3 24872 NULL
99586 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
99587 +queues_read_24877 queues_read 3 24877 NULL nohasharray
99588 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
99589 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
99590 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
99591 +next_token_24929 next_token 0 24929 NULL
99592 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
99593 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
99594 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
99595 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
99596 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
99597 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
99598 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
99599 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
99600 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
99601 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
99602 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
99603 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
99604 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
99605 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
99606 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
99607 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
99608 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
99609 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
99610 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
99611 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
99612 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
99613 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
99614 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
99615 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
99616 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
99617 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
99618 +stripe_status_25259 stripe_status 5 25259 NULL
99619 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
99620 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
99621 +vfs_writev_25278 vfs_writev 3 25278 NULL
99622 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
99623 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
99624 +help_25316 help 5 25316 NULL nohasharray
99625 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
99626 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
99627 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
99628 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
99629 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
99630 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
99631 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
99632 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
99633 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
99634 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
99635 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
99636 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
99637 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
99638 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
99639 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
99640 +sb_permission_25523 sb_permission 0 25523 NULL
99641 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
99642 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
99643 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
99644 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
99645 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
99646 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
99647 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
99648 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
99649 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
99650 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
99651 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
99652 +__direct_map_25647 __direct_map 5-6 25647 NULL
99653 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
99654 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
99655 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
99656 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
99657 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
99658 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
99659 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
99660 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
99661 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
99662 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
99663 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
99664 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
99665 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
99666 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
99667 +sg_read_25799 sg_read 3 25799 NULL
99668 +system_enable_read_25815 system_enable_read 3 25815 NULL
99669 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
99670 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
99671 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
99672 +parport_read_25855 parport_read 0 25855 NULL
99673 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
99674 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
99675 +key_attr_size_25865 key_attr_size 0 25865 NULL
99676 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
99677 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
99678 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
99679 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
99680 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
99681 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
99682 +rcname_read_25919 rcname_read 3 25919 NULL
99683 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
99684 +key_flags_read_25931 key_flags_read 3 25931 NULL
99685 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
99686 +flush_25957 flush 2 25957 NULL
99687 +video_register_device_25971 video_register_device 3 25971 NULL
99688 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
99689 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
99690 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
99691 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
99692 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
99693 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
99694 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
99695 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
99696 +tun_do_read_26047 tun_do_read 5 26047 NULL
99697 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
99698 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
99699 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
99700 +skb_cow_26138 skb_cow 2 26138 NULL
99701 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
99702 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
99703 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
99704 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
99705 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
99706 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
99707 +disk_devt_26180 disk_devt 0 26180 NULL
99708 +get_registers_26187 get_registers 3 26187 NULL
99709 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
99710 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
99711 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
99712 +mce_write_26201 mce_write 3 26201 NULL
99713 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
99714 +bio_split_26235 bio_split 2 26235 NULL
99715 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
99716 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
99717 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
99718 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
99719 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
99720 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
99721 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
99722 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
99723 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
99724 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
99725 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
99726 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
99727 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
99728 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
99729 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
99730 +read_vmcore_26501 read_vmcore 3 26501 NULL
99731 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
99732 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
99733 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
99734 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
99735 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
99736 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
99737 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
99738 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
99739 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
99740 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
99741 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
99742 +pack_value_26625 pack_value 1 26625 NULL
99743 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
99744 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
99745 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
99746 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
99747 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
99748 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
99749 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
99750 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
99751 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
99752 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
99753 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
99754 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
99755 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
99756 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
99757 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
99758 +smk_write_load_26829 smk_write_load 3 26829 NULL
99759 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
99760 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
99761 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
99762 +scnprint_id_26842 scnprint_id 3 26842 NULL
99763 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
99764 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
99765 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
99766 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
99767 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
99768 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
99769 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
99770 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
99771 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
99772 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
99773 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
99774 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
99775 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
99776 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
99777 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
99778 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
99779 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
99780 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
99781 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
99782 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
99783 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
99784 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
99785 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
99786 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
99787 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
99788 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
99789 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
99790 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
99791 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
99792 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
99793 +pms_capture_27142 pms_capture 4 27142 NULL
99794 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
99795 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
99796 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
99797 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
99798 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
99799 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
99800 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
99801 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
99802 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
99803 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
99804 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
99805 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
99806 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
99807 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
99808 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
99809 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
99810 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
99811 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
99812 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
99813 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
99814 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
99815 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
99816 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
99817 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
99818 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
99819 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
99820 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
99821 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
99822 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
99823 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
99824 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
99825 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
99826 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
99827 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
99828 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
99829 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
99830 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
99831 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
99832 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
99833 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
99834 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
99835 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
99836 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
99837 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
99838 +qword_get_27670 qword_get 0 27670 NULL
99839 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
99840 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
99841 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
99842 +evm_write_key_27715 evm_write_key 3 27715 NULL
99843 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
99844 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
99845 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
99846 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
99847 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
99848 +kcalloc_27770 kcalloc 1-2 27770 NULL
99849 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
99850 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
99851 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
99852 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
99853 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
99854 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
99855 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
99856 +read_profile_27859 read_profile 3 27859 NULL
99857 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
99858 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
99859 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
99860 +gluebi_write_27905 gluebi_write 3 27905 NULL
99861 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
99862 +bm_find_next_27929 bm_find_next 2 27929 NULL
99863 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
99864 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
99865 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
99866 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
99867 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
99868 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
99869 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
99870 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
99871 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
99872 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
99873 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
99874 +pool_status_28055 pool_status 5 28055 NULL
99875 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
99876 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
99877 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
99878 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
99879 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
99880 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
99881 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
99882 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
99883 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
99884 +video_read_28148 video_read 3 28148 NULL
99885 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
99886 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
99887 +vread_28173 vread 0 28173 NULL
99888 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
99889 +d_path_28198 d_path 0 28198 NULL
99890 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
99891 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
99892 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
99893 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
99894 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
99895 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
99896 +usemap_size_28281 usemap_size 0 28281 NULL
99897 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
99898 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
99899 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
99900 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
99901 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
99902 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
99903 +snapshot_write_28351 snapshot_write 3 28351 NULL
99904 +sys_writev_28384 sys_writev 3 28384 NULL
99905 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
99906 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
99907 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
99908 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
99909 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
99910 +__split_large_page_28429 __split_large_page 2 28429 NULL
99911 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
99912 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
99913 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
99914 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
99915 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
99916 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
99917 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
99918 +max_response_pages_28492 max_response_pages 0 28492 NULL
99919 +clear_discard_28494 clear_discard 2 28494 NULL
99920 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
99921 +__next_node_28521 __next_node 1 28521 NULL
99922 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
99923 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
99924 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
99925 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
99926 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
99927 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
99928 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
99929 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
99930 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
99931 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
99932 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
99933 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
99934 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
99935 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
99936 +_set_range_28627 _set_range 3 28627 NULL
99937 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
99938 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
99939 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
99940 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
99941 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
99942 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
99943 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
99944 +spi_execute_28736 spi_execute 5 28736 NULL
99945 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
99946 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
99947 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
99948 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
99949 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
99950 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
99951 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
99952 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
99953 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
99954 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
99955 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
99956 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
99957 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
99958 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
99959 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
99960 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
99961 +to_cblock_28899 to_cblock 0-1 28899 NULL
99962 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
99963 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
99964 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
99965 +push_rx_28939 push_rx 3 28939 NULL
99966 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
99967 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
99968 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
99969 +bin_uuid_28999 bin_uuid 3 28999 NULL
99970 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
99971 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
99972 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
99973 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
99974 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
99975 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
99976 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
99977 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
99978 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
99979 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
99980 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
99981 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
99982 +snprintf_29125 snprintf 0 29125 NULL
99983 +iov_shorten_29130 iov_shorten 0 29130 NULL
99984 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
99985 +reshape_ring_29147 reshape_ring 2 29147 NULL
99986 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
99987 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
99988 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
99989 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
99990 +__mm_populate_29204 __mm_populate 1 29204 NULL
99991 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
99992 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
99993 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
99994 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
99995 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
99996 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
99997 +recover_peb_29238 recover_peb 6-7 29238 NULL
99998 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
99999 +block_div_29268 block_div 0-1-2 29268 NULL
100000 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
100001 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
100002 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
100003 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
100004 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
100005 +tun_put_user_29337 tun_put_user 5 29337 NULL
100006 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
100007 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
100008 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
100009 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
100010 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
100011 +mempool_create_29437 mempool_create 1 29437 NULL
100012 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
100013 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
100014 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
100015 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
100016 +do_register_entry_29478 do_register_entry 4 29478 NULL
100017 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
100018 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
100019 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
100020 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
100021 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
100022 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
100023 +set_brk_29551 set_brk 1 29551 NULL nohasharray
100024 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
100025 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
100026 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
100027 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
100028 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
100029 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
100030 +slots_per_page_29601 slots_per_page 0 29601 NULL
100031 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
100032 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
100033 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
100034 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
100035 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
100036 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
100037 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
100038 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
100039 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
100040 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
100041 +probes_write_29711 probes_write 3 29711 NULL
100042 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
100043 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
100044 +std_nic_write_29752 std_nic_write 3 29752 NULL
100045 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
100046 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
100047 +dbAlloc_29794 dbAlloc 0 29794 NULL
100048 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
100049 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
100050 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
100051 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
100052 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
100053 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
100054 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
100055 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
100056 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
100057 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
100058 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
100059 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
100060 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
100061 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
100062 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
100063 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
100064 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
100065 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
100066 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
100067 +drp_wmove_30043 drp_wmove 4 30043 NULL
100068 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
100069 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
100070 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
100071 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
100072 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
100073 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
100074 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
100075 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
100076 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
100077 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
100078 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
100079 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
100080 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
100081 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
100082 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
100083 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
100084 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
100085 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
100086 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
100087 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
100088 +compat_readv_30273 compat_readv 3 30273 NULL
100089 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
100090 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
100091 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
100092 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
100093 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
100094 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
100095 +resource_from_user_30341 resource_from_user 3 30341 NULL
100096 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
100097 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
100098 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
100099 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
100100 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
100101 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
100102 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
100103 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
100104 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
100105 +mq_create_30425 mq_create 1 30425 NULL
100106 +enable_write_30456 enable_write 3 30456 NULL
100107 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
100108 +urandom_read_30462 urandom_read 3 30462 NULL
100109 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
100110 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
100111 +write_head_30481 write_head 4 30481 NULL
100112 +adu_write_30487 adu_write 3 30487 NULL
100113 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
100114 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
100115 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
100116 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
100117 +set_le_30581 set_le 4 30581 NULL
100118 +from_cblock_30582 from_cblock 0-1 30582 NULL
100119 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
100120 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
100121 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
100122 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
100123 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
100124 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
100125 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
100126 +agp_remap_30665 agp_remap 2 30665 NULL
100127 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
100128 +il_free_pages_30692 il_free_pages 2 30692 NULL
100129 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
100130 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
100131 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
100132 +snapshot_status_30744 snapshot_status 5 30744 NULL
100133 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
100134 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
100135 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
100136 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
100137 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
100138 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
100139 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
100140 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
100141 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
100142 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
100143 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
100144 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
100145 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
100146 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
100147 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
100148 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
100149 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
100150 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
100151 +sys_mincore_31079 sys_mincore 1 31079 NULL
100152 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
100153 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
100154 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
100155 +depth_read_31112 depth_read 3 31112 NULL
100156 +ssb_read16_31139 ssb_read16 0 31139 NULL
100157 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
100158 +size_inside_page_31141 size_inside_page 0 31141 NULL
100159 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
100160 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
100161 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
100162 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
100163 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
100164 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
100165 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
100166 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
100167 +__read_reg_31216 __read_reg 0 31216 NULL
100168 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
100169 +cyy_readb_31240 cyy_readb 0 31240 NULL
100170 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
100171 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
100172 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
100173 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
100174 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
100175 +command_file_write_31318 command_file_write 3 31318 NULL
100176 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
100177 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
100178 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
100179 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
100180 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
100181 +inb_31388 inb 0 31388 NULL
100182 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
100183 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
100184 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
100185 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
100186 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
100187 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
100188 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
100189 +do_fcntl_31468 do_fcntl 3 31468 NULL
100190 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
100191 +alg_setkey_31485 alg_setkey 3 31485 NULL
100192 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
100193 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
100194 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
100195 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
100196 +hidraw_write_31536 hidraw_write 3 31536 NULL
100197 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
100198 +usbvision_read_31555 usbvision_read 3 31555 NULL
100199 +normalize_31566 normalize 0-1-2 31566 NULL
100200 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
100201 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
100202 +osst_write_31581 osst_write 3 31581 NULL
100203 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
100204 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
100205 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
100206 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
100207 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
100208 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
100209 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
100210 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
100211 +__lgread_31668 __lgread 4 31668 NULL
100212 +symbol_string_31670 symbol_string 0 31670 NULL
100213 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
100214 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
100215 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
100216 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
100217 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
100218 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
100219 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
100220 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
100221 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
100222 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
100223 +muldiv64_31743 muldiv64 2-3 31743 NULL
100224 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
100225 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
100226 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
100227 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
100228 +get_count_order_31800 get_count_order 0 31800 NULL
100229 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
100230 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
100231 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
100232 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
100233 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
100234 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
100235 +xattr_permission_31907 xattr_permission 0 31907 NULL
100236 +new_dir_31919 new_dir 3 31919 NULL
100237 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
100238 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
100239 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
100240 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
100241 +vb2_write_31948 vb2_write 3 31948 NULL
100242 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
100243 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
100244 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
100245 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
100246 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
100247 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
100248 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
100249 +calc_hmac_32010 calc_hmac 3 32010 NULL
100250 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
100251 +aead_len_32021 aead_len 0 32021 NULL
100252 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
100253 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
100254 +stk_read_32038 stk_read 3 32038 NULL
100255 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
100256 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
100257 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
100258 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
100259 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
100260 +bio_alloc_32095 bio_alloc 2 32095 NULL
100261 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
100262 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
100263 +disk_status_32120 disk_status 4 32120 NULL
100264 +venus_link_32165 venus_link 5 32165 NULL
100265 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
100266 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
100267 +load_header_32183 load_header 0 32183 NULL
100268 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
100269 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
100270 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
100271 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
100272 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
100273 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
100274 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
100275 +hex_string_32310 hex_string 0 32310 NULL
100276 +SyS_select_32319 SyS_select 1 32319 NULL
100277 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
100278 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
100279 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
100280 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
100281 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
100282 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
100283 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
100284 +local_clock_32385 local_clock 0 32385 NULL
100285 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
100286 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
100287 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
100288 +log_text_32428 log_text 0 32428 NULL
100289 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
100290 +hid_input_report_32458 hid_input_report 4 32458 NULL
100291 +cache_status_32462 cache_status 5 32462 NULL
100292 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
100293 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
100294 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
100295 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
100296 +disconnect_32521 disconnect 4 32521 NULL
100297 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
100298 +ilo_read_32531 ilo_read 3 32531 NULL
100299 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
100300 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
100301 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
100302 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
100303 +__first_node_32558 __first_node 0 32558 NULL
100304 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
100305 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
100306 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
100307 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
100308 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
100309 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
100310 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
100311 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
100312 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
100313 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
100314 +kvmalloc_32646 kvmalloc 1 32646 NULL
100315 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
100316 +generic_readlink_32654 generic_readlink 3 32654 NULL
100317 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
100318 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
100319 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
100320 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
100321 +get_arg_page_32746 get_arg_page 2 32746 NULL
100322 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
100323 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
100324 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
100325 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
100326 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
100327 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
100328 +vga_rseq_32848 vga_rseq 0 32848 NULL
100329 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
100330 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
100331 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
100332 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
100333 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
100334 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
100335 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
100336 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
100337 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
100338 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
100339 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
100340 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
100341 +compat_filldir_32999 compat_filldir 3 32999 NULL
100342 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
100343 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
100344 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
100345 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
100346 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
100347 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
100348 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
100349 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
100350 +alloc_tio_33077 alloc_tio 3 33077 NULL
100351 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
100352 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
100353 +write_node_33121 write_node 4 33121 NULL
100354 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
100355 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
100356 +__len_within_target_33132 __len_within_target 0 33132 NULL
100357 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
100358 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
100359 +pp_read_33210 pp_read 3 33210 NULL
100360 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
100361 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
100362 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
100363 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
100364 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
100365 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
100366 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
100367 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
100368 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
100369 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
100370 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
100371 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
100372 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
100373 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
100374 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
100375 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
100376 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
100377 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
100378 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
100379 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
100380 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
100381 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
100382 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
100383 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
100384 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
100385 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
100386 +create_entry_33479 create_entry 2 33479 NULL
100387 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
100388 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
100389 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
100390 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
100391 +res_counter_read_33499 res_counter_read 4 33499 NULL
100392 +fb_read_33506 fb_read 3 33506 NULL
100393 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
100394 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
100395 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
100396 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
100397 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
100398 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
100399 +dup_array_33551 dup_array 3 33551 NULL
100400 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
100401 +count_subheaders_33591 count_subheaders 0 33591 NULL
100402 +scsi_execute_33596 scsi_execute 5 33596 NULL
100403 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
100404 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
100405 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
100406 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
100407 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
100408 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
100409 +inw_p_33668 inw_p 0 33668 NULL
100410 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
100411 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
100412 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
100413 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
100414 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
100415 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
100416 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
100417 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
100418 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
100419 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
100420 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
100421 +Read_hfc_33755 Read_hfc 0 33755 NULL
100422 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
100423 +hashtab_create_33769 hashtab_create 3 33769 NULL
100424 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
100425 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
100426 +find_next_offset_33804 find_next_offset 3 33804 NULL
100427 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
100428 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
100429 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
100430 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
100431 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
100432 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
100433 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
100434 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
100435 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
100436 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
100437 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
100438 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
100439 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
100440 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
100441 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
100442 +ppp_write_34034 ppp_write 3 34034 NULL
100443 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
100444 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
100445 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
100446 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
100447 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
100448 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
100449 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
100450 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
100451 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
100452 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
100453 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
100454 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
100455 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
100456 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
100457 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
100458 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
100459 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
100460 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
100461 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
100462 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
100463 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
100464 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
100465 +__insert_34349 __insert 2-3 34349 NULL
100466 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
100467 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
100468 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
100469 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
100470 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
100471 +ea_read_34378 ea_read 0 34378 NULL
100472 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
100473 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
100474 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
100475 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
100476 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
100477 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
100478 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
100479 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
100480 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
100481 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
100482 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
100483 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
100484 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
100485 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
100486 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
100487 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
100488 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
100489 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
100490 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
100491 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
100492 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
100493 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
100494 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
100495 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
100496 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
100497 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
100498 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
100499 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
100500 +port_print_34704 port_print 3 34704 NULL
100501 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
100502 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
100503 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
100504 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
100505 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
100506 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
100507 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
100508 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
100509 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
100510 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
100511 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
100512 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
100513 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
100514 +msg_print_text_34889 msg_print_text 0 34889 NULL
100515 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
100516 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
100517 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
100518 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
100519 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
100520 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
100521 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
100522 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
100523 +Realloc_34961 Realloc 2 34961 NULL
100524 +mq_lookup_34990 mq_lookup 2 34990 NULL
100525 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
100526 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
100527 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
100528 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
100529 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
100530 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
100531 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
100532 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
100533 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
100534 +store_ifalias_35088 store_ifalias 4 35088 NULL
100535 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
100536 +capi_write_35104 capi_write 3 35104 NULL nohasharray
100537 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
100538 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
100539 +pointer_35138 pointer 0 35138 NULL
100540 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
100541 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
100542 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
100543 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
100544 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
100545 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
100546 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
100547 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
100548 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
100549 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
100550 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
100551 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
100552 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
100553 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
100554 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
100555 +set_fd_set_35249 set_fd_set 1 35249 NULL
100556 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
100557 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
100558 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
100559 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
100560 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
100561 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
100562 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
100563 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
100564 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
100565 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
100566 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
100567 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
100568 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
100569 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
100570 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
100571 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
100572 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
100573 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
100574 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
100575 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
100576 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
100577 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
100578 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
100579 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
100580 +async_setkey_35521 async_setkey 3 35521 NULL
100581 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
100582 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
100583 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
100584 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
100585 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
100586 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
100587 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
100588 +ReadZReg_35604 ReadZReg 0 35604 NULL
100589 +kernel_readv_35617 kernel_readv 3 35617 NULL
100590 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
100591 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
100592 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
100593 +store_debug_level_35652 store_debug_level 3 35652 NULL
100594 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
100595 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
100596 +dm_table_create_35687 dm_table_create 3 35687 NULL
100597 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
100598 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
100599 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
100600 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
100601 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
100602 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
100603 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
100604 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
100605 +fls64_35862 fls64 0 35862 NULL
100606 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
100607 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
100608 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
100609 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
100610 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
100611 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
100612 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
100613 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
100614 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
100615 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
100616 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
100617 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
100618 +acl_alloc_35979 acl_alloc 1 35979 NULL
100619 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
100620 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
100621 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
100622 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
100623 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
100624 +account_shadowed_36048 account_shadowed 2 36048 NULL
100625 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
100626 +write_emulate_36065 write_emulate 2-4 36065 NULL
100627 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
100628 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
100629 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
100630 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
100631 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
100632 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
100633 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
100634 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
100635 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
100636 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
100637 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
100638 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
100639 +twl_set_36154 twl_set 2 36154 NULL
100640 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
100641 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
100642 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
100643 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
100644 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
100645 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
100646 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
100647 +is_dirty_36223 is_dirty 2 36223 NULL
100648 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
100649 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
100650 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
100651 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
100652 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
100653 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
100654 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
100655 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
100656 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
100657 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
100658 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
100659 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
100660 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
100661 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
100662 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
100663 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
100664 +lc_create_36332 lc_create 4 36332 NULL
100665 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
100666 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
100667 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
100668 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
100669 +to_sector_36361 to_sector 0-1 36361 NULL
100670 +tunables_read_36385 tunables_read 3 36385 NULL
100671 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
100672 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
100673 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
100674 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
100675 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
100676 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
100677 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
100678 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
100679 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
100680 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
100681 +get_param_l_36518 get_param_l 0 36518 NULL
100682 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
100683 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
100684 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
100685 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
100686 +get_entry_len_36549 get_entry_len 0 36549 NULL
100687 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
100688 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
100689 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
100690 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
100691 +__erst_read_36579 __erst_read 0 36579 NULL
100692 +put_cmsg_36589 put_cmsg 4 36589 NULL
100693 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
100694 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
100695 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
100696 +format_decode_36638 format_decode 0 36638 NULL
100697 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
100698 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
100699 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
100700 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
100701 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
100702 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
100703 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
100704 +sched_clock_36717 sched_clock 0 36717 NULL
100705 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
100706 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
100707 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
100708 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
100709 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
100710 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
100711 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
100712 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
100713 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
100714 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
100715 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
100716 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
100717 +cm_write_36858 cm_write 3 36858 NULL
100718 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
100719 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
100720 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
100721 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
100722 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
100723 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
100724 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
100725 +build_key_36931 build_key 1 36931 NULL
100726 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
100727 +write_leb_36957 write_leb 5 36957 NULL
100728 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
100729 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
100730 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
100731 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
100732 +setxattr_37006 setxattr 4 37006 NULL
100733 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
100734 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
100735 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
100736 +parse_command_37079 parse_command 2 37079 NULL
100737 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
100738 +tun_get_user_37094 tun_get_user 5 37094 NULL
100739 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
100740 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
100741 +msg_word_37164 msg_word 0 37164 NULL
100742 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
100743 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
100744 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
100745 +__do_replace_37227 __do_replace 5 37227 NULL
100746 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
100747 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
100748 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
100749 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
100750 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
100751 +c101_run_37279 c101_run 2 37279 NULL
100752 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
100753 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
100754 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
100755 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
100756 +send_msg_37323 send_msg 4 37323 NULL
100757 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
100758 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
100759 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
100760 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
100761 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
100762 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
100763 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
100764 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
100765 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
100766 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
100767 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
100768 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
100769 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
100770 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
100771 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
100772 +__remove_37457 __remove 2 37457 NULL
100773 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
100774 +get_est_timing_37484 get_est_timing 0 37484 NULL
100775 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
100776 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
100777 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
100778 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
100779 +hdr_size_37536 hdr_size 0 37536 NULL
100780 +a2p_37544 a2p 0-1 37544 NULL
100781 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
100782 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
100783 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
100784 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
100785 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
100786 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
100787 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
100788 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
100789 +check_pt_base_37635 check_pt_base 3 37635 NULL
100790 +alloc_fd_37637 alloc_fd 1 37637 NULL
100791 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
100792 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
100793 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
100794 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
100795 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
100796 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
100797 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
100798 +nametbl_header_37698 nametbl_header 2 37698 NULL
100799 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
100800 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
100801 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
100802 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
100803 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
100804 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
100805 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
100806 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
100807 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
100808 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
100809 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
100810 +deny_write_access_37813 deny_write_access 0 37813 NULL
100811 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
100812 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
100813 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
100814 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
100815 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
100816 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
100817 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
100818 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
100819 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
100820 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
100821 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
100822 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
100823 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
100824 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
100825 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
100826 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
100827 +vfs_readv_38011 vfs_readv 3 38011 NULL
100828 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
100829 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
100830 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
100831 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
100832 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
100833 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
100834 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
100835 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
100836 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
100837 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
100838 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
100839 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
100840 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
100841 +ep0_read_38095 ep0_read 3 38095 NULL
100842 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
100843 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
100844 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
100845 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
100846 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
100847 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
100848 +cdev_add_38176 cdev_add 2-3 38176 NULL
100849 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
100850 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
100851 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
100852 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
100853 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
100854 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
100855 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
100856 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
100857 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
100858 +from_dblock_38256 from_dblock 0-1 38256 NULL
100859 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
100860 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
100861 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
100862 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
100863 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
100864 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
100865 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
100866 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
100867 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
100868 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
100869 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
100870 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
100871 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
100872 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
100873 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
100874 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
100875 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
100876 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
100877 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
100878 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
100879 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
100880 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
100881 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
100882 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
100883 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
100884 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
100885 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
100886 +dev_names_read_38509 dev_names_read 3 38509 NULL
100887 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
100888 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
100889 +set_queue_count_38519 set_queue_count 0 38519 NULL
100890 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
100891 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
100892 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
100893 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
100894 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
100895 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
100896 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
100897 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
100898 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
100899 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
100900 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
100901 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
100902 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
100903 +cma_create_area_38642 cma_create_area 2 38642 NULL
100904 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
100905 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
100906 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
100907 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
100908 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
100909 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
100910 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
100911 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
100912 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
100913 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
100914 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
100915 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
100916 +udf_readpages_38761 udf_readpages 4 38761 NULL
100917 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
100918 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
100919 +err_decode_38804 err_decode 2 38804 NULL
100920 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
100921 +sys_select_38827 sys_select 1 38827 NULL
100922 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
100923 +direct_entry_38836 direct_entry 3 38836 NULL
100924 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
100925 +interfaces_38859 interfaces 2 38859 NULL
100926 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
100927 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
100928 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
100929 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
100930 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
100931 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
100932 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
100933 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
100934 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
100935 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
100936 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
100937 +udf_new_block_38999 udf_new_block 4 38999 NULL
100938 +get_nodes_39012 get_nodes 3 39012 NULL
100939 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
100940 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
100941 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
100942 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
100943 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
100944 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
100945 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
100946 +ea_foreach_39133 ea_foreach 0 39133 NULL
100947 +generic_permission_39150 generic_permission 0 39150 NULL
100948 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
100949 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
100950 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
100951 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
100952 +init_list_set_39188 init_list_set 2-3 39188 NULL
100953 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
100954 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
100955 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
100956 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
100957 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
100958 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
100959 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
100960 +drm_order_39244 drm_order 0 39244 NULL
100961 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
100962 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
100963 +__skb_cow_39254 __skb_cow 2 39254 NULL
100964 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
100965 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
100966 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
100967 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
100968 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
100969 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
100970 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
100971 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
100972 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
100973 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
100974 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
100975 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
100976 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
100977 +__send_to_port_39386 __send_to_port 3 39386 NULL
100978 +user_power_read_39414 user_power_read 3 39414 NULL
100979 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
100980 +sys_semop_39457 sys_semop 3 39457 NULL
100981 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
100982 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
100983 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
100984 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
100985 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
100986 +int_proc_write_39542 int_proc_write 3 39542 NULL
100987 +pp_write_39554 pp_write 3 39554 NULL
100988 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
100989 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
100990 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
100991 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
100992 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
100993 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
100994 +ext_depth_39607 ext_depth 0 39607 NULL
100995 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
100996 +sdio_readb_39618 sdio_readb 0 39618 NULL
100997 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
100998 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
100999 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
101000 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
101001 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
101002 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
101003 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
101004 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
101005 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
101006 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
101007 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
101008 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
101009 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
101010 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
101011 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
101012 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
101013 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
101014 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
101015 +pkt_add_39897 pkt_add 3 39897 NULL
101016 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
101017 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
101018 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
101019 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
101020 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
101021 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
101022 +__spi_async_39932 __spi_async 0 39932 NULL
101023 +__get_order_39935 __get_order 0 39935 NULL
101024 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
101025 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
101026 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
101027 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
101028 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
101029 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
101030 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
101031 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
101032 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
101033 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
101034 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
101035 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
101036 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
101037 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
101038 +add_tty_40055 add_tty 1 40055 NULL nohasharray
101039 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
101040 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
101041 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
101042 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
101043 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
101044 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
101045 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
101046 +pt_write_40159 pt_write 3 40159 NULL
101047 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
101048 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
101049 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
101050 +allocate_probes_40204 allocate_probes 1 40204 NULL
101051 +compat_put_long_40214 compat_put_long 1 40214 NULL
101052 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
101053 +osst_read_40237 osst_read 3 40237 NULL
101054 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
101055 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
101056 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
101057 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
101058 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
101059 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
101060 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
101061 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
101062 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
101063 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
101064 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
101065 +mmio_read_40348 mmio_read 4 40348 NULL
101066 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
101067 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
101068 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
101069 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
101070 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
101071 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
101072 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
101073 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
101074 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
101075 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
101076 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
101077 +tty_write_room_40495 tty_write_room 0 40495 NULL
101078 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
101079 +sg_phys_40507 sg_phys 0 40507 NULL
101080 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
101081 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
101082 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
101083 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
101084 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
101085 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
101086 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
101087 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
101088 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
101089 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
101090 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
101091 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
101092 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
101093 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
101094 +fops_read_40672 fops_read 3 40672 NULL
101095 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
101096 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
101097 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
101098 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
101099 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
101100 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
101101 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
101102 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
101103 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
101104 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
101105 +card_send_command_40757 card_send_command 3 40757 NULL
101106 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
101107 +pg_write_40766 pg_write 3 40766 NULL
101108 +show_list_40775 show_list 3 40775 NULL
101109 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
101110 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
101111 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
101112 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
101113 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
101114 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
101115 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
101116 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
101117 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
101118 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
101119 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
101120 +read_file_queue_40895 read_file_queue 3 40895 NULL
101121 +waiters_read_40902 waiters_read 3 40902 NULL
101122 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
101123 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
101124 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
101125 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
101126 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
101127 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
101128 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
101129 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
101130 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
101131 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
101132 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
101133 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
101134 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
101135 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
101136 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
101137 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
101138 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
101139 +dma_attach_41094 dma_attach 5-6 41094 NULL
101140 +provide_user_output_41105 provide_user_output 3 41105 NULL
101141 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
101142 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
101143 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
101144 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
101145 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
101146 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
101147 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
101148 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
101149 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
101150 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
101151 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
101152 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
101153 +erst_read_41260 erst_read 0 41260 NULL
101154 +__fprog_create_41263 __fprog_create 2 41263 NULL
101155 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
101156 +alloc_context_41283 alloc_context 1 41283 NULL
101157 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
101158 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
101159 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
101160 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
101161 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
101162 +kmp_init_41373 kmp_init 2 41373 NULL
101163 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
101164 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
101165 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
101166 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
101167 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
101168 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
101169 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
101170 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
101171 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
101172 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
101173 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
101174 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
101175 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
101176 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
101177 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
101178 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
101179 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
101180 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
101181 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
101182 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
101183 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
101184 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
101185 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
101186 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
101187 +vga_io_r_41609 vga_io_r 0 41609 NULL
101188 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
101189 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
101190 +a2mp_send_41615 a2mp_send 4 41615 NULL
101191 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
101192 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
101193 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
101194 +get_std_timing_41654 get_std_timing 0 41654 NULL
101195 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
101196 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
101197 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
101198 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
101199 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
101200 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
101201 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
101202 +fillonedir_41746 fillonedir 3 41746 NULL
101203 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
101204 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
101205 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
101206 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
101207 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
101208 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
101209 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
101210 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
101211 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
101212 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
101213 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
101214 +get_packet_41914 get_packet 3 41914 NULL
101215 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
101216 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
101217 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
101218 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
101219 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
101220 +read_gssp_41947 read_gssp 3 41947 NULL
101221 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
101222 +portnames_read_41958 portnames_read 3 41958 NULL
101223 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
101224 +dst_mtu_41969 dst_mtu 0 41969 NULL
101225 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
101226 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
101227 +lguest_map_42008 lguest_map 1-2 42008 NULL
101228 +pool_allocate_42012 pool_allocate 3 42012 NULL
101229 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
101230 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
101231 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
101232 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
101233 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
101234 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
101235 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
101236 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
101237 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
101238 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
101239 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
101240 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
101241 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
101242 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
101243 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
101244 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
101245 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
101246 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
101247 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
101248 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
101249 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
101250 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
101251 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
101252 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
101253 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
101254 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
101255 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
101256 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
101257 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
101258 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
101259 +free_cblock_42318 free_cblock 2 42318 NULL
101260 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
101261 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
101262 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
101263 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
101264 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
101265 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
101266 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
101267 +krng_get_random_42420 krng_get_random 3 42420 NULL
101268 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
101269 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
101270 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
101271 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
101272 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
101273 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
101274 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
101275 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
101276 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
101277 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
101278 +bypass_write_42498 bypass_write 3 42498 NULL
101279 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
101280 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
101281 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
101282 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
101283 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
101284 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
101285 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
101286 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
101287 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
101288 +map_state_42602 map_state 1 42602 NULL nohasharray
101289 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
101290 +nd_get_link_42603 nd_get_link 0 42603 NULL
101291 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
101292 +resp_write_42628 resp_write 2 42628 NULL
101293 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
101294 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
101295 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
101296 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
101297 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
101298 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
101299 +vb2_read_42703 vb2_read 3 42703 NULL
101300 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
101301 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
101302 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
101303 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
101304 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
101305 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
101306 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
101307 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
101308 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
101309 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
101310 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
101311 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
101312 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
101313 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
101314 +set_arg_42824 set_arg 3 42824 NULL
101315 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
101316 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
101317 +prandom_u32_42853 prandom_u32 0 42853 NULL
101318 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
101319 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
101320 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
101321 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
101322 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
101323 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
101324 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
101325 +hd_end_request_42904 hd_end_request 2 42904 NULL
101326 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
101327 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
101328 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
101329 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
101330 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
101331 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
101332 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
101333 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
101334 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
101335 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
101336 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
101337 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
101338 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
101339 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
101340 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
101341 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
101342 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
101343 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
101344 +uuid_string_43154 uuid_string 0 43154 NULL
101345 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
101346 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
101347 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
101348 +process_measurement_43190 process_measurement 0 43190 NULL
101349 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
101350 +uio_write_43202 uio_write 3 43202 NULL
101351 +iso_callback_43208 iso_callback 3 43208 NULL
101352 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
101353 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
101354 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
101355 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
101356 +fixup_leb_43256 fixup_leb 3 43256 NULL
101357 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
101358 +evtchn_write_43278 evtchn_write 3 43278 NULL
101359 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
101360 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
101361 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
101362 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
101363 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
101364 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
101365 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
101366 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
101367 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
101368 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
101369 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
101370 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
101371 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
101372 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
101373 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
101374 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
101375 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
101376 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
101377 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
101378 +do_readlink_43518 do_readlink 2 43518 NULL
101379 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
101380 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
101381 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
101382 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
101383 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
101384 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
101385 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
101386 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
101387 +proc_read_43614 proc_read 3 43614 NULL
101388 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
101389 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
101390 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
101391 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
101392 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
101393 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
101394 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
101395 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
101396 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
101397 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
101398 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
101399 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
101400 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
101401 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
101402 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
101403 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
101404 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
101405 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
101406 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
101407 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
101408 +read_flush_43851 read_flush 3 43851 NULL
101409 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
101410 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
101411 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
101412 +SendString_43928 SendString 3 43928 NULL
101413 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
101414 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
101415 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
101416 +nla_reserve_43984 nla_reserve 3 43984 NULL
101417 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
101418 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
101419 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
101420 +emit_flags_44006 emit_flags 4-3 44006 NULL
101421 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
101422 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
101423 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
101424 +load_discard_44083 load_discard 3 44083 NULL
101425 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
101426 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
101427 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
101428 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
101429 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
101430 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
101431 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
101432 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
101433 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
101434 +__set_free_44211 __set_free 2 44211 NULL
101435 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
101436 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
101437 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
101438 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
101439 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
101440 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
101441 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
101442 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
101443 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
101444 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
101445 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
101446 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
101447 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
101448 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
101449 +__is_discarded_44359 __is_discarded 2 44359 NULL
101450 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
101451 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
101452 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
101453 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
101454 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
101455 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
101456 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
101457 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
101458 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
101459 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
101460 +bio_advance_44496 bio_advance 2 44496 NULL
101461 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
101462 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
101463 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
101464 +spidev_write_44510 spidev_write 3 44510 NULL
101465 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
101466 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
101467 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
101468 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
101469 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
101470 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
101471 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
101472 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
101473 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
101474 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
101475 +mpi_resize_44674 mpi_resize 2 44674 NULL
101476 +ts_read_44687 ts_read 3 44687 NULL
101477 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
101478 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
101479 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
101480 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
101481 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
101482 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
101483 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
101484 +set_brk_44749 set_brk 1 44749 NULL
101485 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
101486 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
101487 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
101488 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
101489 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
101490 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
101491 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
101492 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
101493 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
101494 +sisusb_write_44834 sisusb_write 3 44834 NULL
101495 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
101496 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
101497 +cubic_root_44848 cubic_root 1 44848 NULL
101498 +copydesc_user_44855 copydesc_user 3 44855 NULL
101499 +skb_availroom_44883 skb_availroom 0 44883 NULL
101500 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
101501 +do_tty_write_44896 do_tty_write 5 44896 NULL
101502 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
101503 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
101504 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
101505 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
101506 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
101507 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
101508 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
101509 +sel_write_user_45060 sel_write_user 3 45060 NULL
101510 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
101511 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
101512 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
101513 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
101514 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
101515 +usbdev_read_45114 usbdev_read 3 45114 NULL
101516 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
101517 +send_to_tty_45141 send_to_tty 3 45141 NULL
101518 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
101519 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
101520 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
101521 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
101522 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
101523 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
101524 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
101525 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
101526 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
101527 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
101528 +add_child_45201 add_child 4 45201 NULL
101529 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
101530 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
101531 +__dirty_45228 __dirty 2 45228 NULL
101532 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
101533 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
101534 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
101535 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
101536 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
101537 +pte_val_45313 pte_val 0 45313 NULL
101538 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
101539 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
101540 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
101541 +keymap_store_45406 keymap_store 4 45406 NULL
101542 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
101543 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
101544 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
101545 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
101546 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
101547 +__node_remap_45458 __node_remap 4 45458 NULL
101548 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
101549 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
101550 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
101551 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
101552 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
101553 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
101554 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
101555 +copy_macs_45534 copy_macs 4 45534 NULL
101556 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
101557 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
101558 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
101559 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
101560 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
101561 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
101562 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
101563 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
101564 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
101565 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
101566 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
101567 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
101568 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
101569 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
101570 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
101571 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
101572 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
101573 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
101574 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
101575 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
101576 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
101577 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
101578 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
101579 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
101580 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
101581 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
101582 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
101583 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
101584 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
101585 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
101586 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
101587 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
101588 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
101589 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
101590 +isdn_write_45863 isdn_write 3 45863 NULL
101591 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
101592 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
101593 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
101594 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
101595 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
101596 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
101597 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
101598 +alloc_mr_45935 alloc_mr 1 45935 NULL
101599 +split_large_page_45941 split_large_page 2 45941 NULL
101600 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
101601 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
101602 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
101603 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
101604 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
101605 +get_free_entries_46030 get_free_entries 1 46030 NULL
101606 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
101607 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
101608 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
101609 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
101610 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
101611 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
101612 +slhc_toss_46066 slhc_toss 0 46066 NULL
101613 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
101614 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
101615 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
101616 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
101617 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
101618 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
101619 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
101620 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
101621 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
101622 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
101623 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
101624 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
101625 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
101626 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
101627 +add_conn_list_46197 add_conn_list 3 46197 NULL
101628 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
101629 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
101630 +dsp_write_46218 dsp_write 2 46218 NULL
101631 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
101632 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
101633 +ReadReg_46277 ReadReg 0 46277 NULL
101634 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
101635 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
101636 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
101637 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
101638 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
101639 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
101640 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
101641 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
101642 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
101643 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
101644 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
101645 +filldir64_46469 filldir64 3 46469 NULL
101646 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
101647 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
101648 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
101649 +kmsg_read_46514 kmsg_read 3 46514 NULL
101650 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
101651 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
101652 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
101653 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
101654 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
101655 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
101656 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
101657 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
101658 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
101659 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
101660 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
101661 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
101662 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
101663 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
101664 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
101665 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
101666 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
101667 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
101668 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
101669 +prepare_copy_46725 prepare_copy 2 46725 NULL
101670 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
101671 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
101672 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
101673 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
101674 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
101675 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
101676 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
101677 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
101678 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
101679 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
101680 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
101681 +spi_async_46857 spi_async 0 46857 NULL
101682 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
101683 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
101684 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
101685 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
101686 +rvmalloc_46873 rvmalloc 1 46873 NULL
101687 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
101688 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
101689 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
101690 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
101691 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
101692 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
101693 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
101694 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
101695 +fb_write_46924 fb_write 3 46924 NULL
101696 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
101697 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
101698 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
101699 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
101700 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
101701 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
101702 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
101703 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
101704 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
101705 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
101706 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
101707 +__map_single_47020 __map_single 3-4-7 47020 NULL
101708 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
101709 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
101710 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
101711 +fs_path_len_47060 fs_path_len 0 47060 NULL
101712 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
101713 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
101714 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
101715 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
101716 +mousedev_read_47123 mousedev_read 3 47123 NULL
101717 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
101718 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
101719 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
101720 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
101721 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
101722 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
101723 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
101724 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
101725 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
101726 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
101727 +l2headersize_47238 l2headersize 0 47238 NULL
101728 +options_write_47243 options_write 3 47243 NULL
101729 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
101730 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
101731 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
101732 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
101733 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
101734 +vsnprintf_47291 vsnprintf 0 47291 NULL
101735 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
101736 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
101737 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
101738 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
101739 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
101740 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
101741 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
101742 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
101743 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
101744 +nametbl_list_47391 nametbl_list 2 47391 NULL
101745 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
101746 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
101747 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
101748 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
101749 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
101750 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
101751 +vzalloc_47421 vzalloc 1 47421 NULL
101752 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
101753 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
101754 +__load_mapping_47460 __load_mapping 2 47460 NULL
101755 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
101756 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
101757 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
101758 +core_sys_select_47494 core_sys_select 1 47494 NULL
101759 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
101760 +unlink_simple_47506 unlink_simple 3 47506 NULL
101761 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
101762 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
101763 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
101764 +oz_events_read_47535 oz_events_read 3 47535 NULL
101765 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
101766 +read_ldt_47570 read_ldt 2 47570 NULL
101767 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
101768 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
101769 +pci_iomap_47575 pci_iomap 3 47575 NULL
101770 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
101771 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
101772 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
101773 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
101774 +uea_request_47613 uea_request 4 47613 NULL
101775 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
101776 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
101777 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
101778 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
101779 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
101780 +save_microcode_47717 save_microcode 3 47717 NULL
101781 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
101782 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
101783 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
101784 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
101785 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
101786 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
101787 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
101788 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
101789 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
101790 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
101791 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
101792 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
101793 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
101794 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
101795 +vhci_read_47878 vhci_read 3 47878 NULL
101796 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
101797 +load_mapping_47904 load_mapping 3 47904 NULL
101798 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
101799 +comedi_write_47926 comedi_write 3 47926 NULL
101800 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
101801 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
101802 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
101803 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
101804 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
101805 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
101806 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
101807 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
101808 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
101809 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
101810 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
101811 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
101812 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
101813 +disc_write_48070 disc_write 3 48070 NULL
101814 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
101815 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
101816 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
101817 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
101818 +set_discoverable_48141 set_discoverable 4 48141 NULL
101819 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
101820 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
101821 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
101822 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
101823 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
101824 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
101825 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
101826 +init_ipath_48187 init_ipath 1 48187 NULL
101827 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
101828 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
101829 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
101830 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
101831 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
101832 +read_file_recv_48232 read_file_recv 3 48232 NULL
101833 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
101834 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
101835 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
101836 +send_set_info_48288 send_set_info 7 48288 NULL
101837 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
101838 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
101839 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
101840 +hash_setkey_48310 hash_setkey 3 48310 NULL
101841 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
101842 +skb_add_data_48363 skb_add_data 3 48363 NULL
101843 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
101844 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
101845 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
101846 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
101847 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
101848 +print_filtered_48442 print_filtered 2-0 48442 NULL
101849 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
101850 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
101851 +send_control_msg_48498 send_control_msg 6 48498 NULL
101852 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
101853 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
101854 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
101855 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
101856 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
101857 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
101858 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
101859 +named_distribute_48544 named_distribute 4 48544 NULL
101860 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
101861 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
101862 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
101863 +mtd_read_48655 mtd_read 0 48655 NULL
101864 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
101865 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
101866 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
101867 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
101868 +altera_drscan_48698 altera_drscan 2 48698 NULL
101869 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
101870 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
101871 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
101872 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
101873 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
101874 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
101875 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
101876 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
101877 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
101878 +azx_get_position_48841 azx_get_position 0 48841 NULL
101879 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
101880 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
101881 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
101882 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
101883 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
101884 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
101885 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
101886 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
101887 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
101888 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
101889 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
101890 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
101891 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
101892 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
101893 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
101894 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
101895 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
101896 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
101897 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
101898 +transient_status_49027 transient_status 4 49027 NULL
101899 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
101900 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
101901 +ubi_read_49061 ubi_read 0 49061 NULL
101902 +scsi_register_49094 scsi_register 2 49094 NULL
101903 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
101904 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
101905 +check_exists_49119 check_exists 2 49119 NULL nohasharray
101906 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
101907 +pt_read_49136 pt_read 3 49136 NULL
101908 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
101909 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
101910 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
101911 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
101912 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
101913 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
101914 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
101915 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
101916 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
101917 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
101918 +resp_write_same_49217 resp_write_same 2 49217 NULL
101919 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
101920 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
101921 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
101922 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
101923 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
101924 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
101925 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
101926 +uio_read_49300 uio_read 3 49300 NULL
101927 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
101928 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
101929 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
101930 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
101931 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
101932 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
101933 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
101934 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
101935 +px_raw_event_49371 px_raw_event 4 49371 NULL
101936 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
101937 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
101938 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
101939 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
101940 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
101941 +md_domain_init_49432 md_domain_init 2 49432 NULL
101942 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
101943 +get_lru_size_49441 get_lru_size 0 49441 NULL
101944 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
101945 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
101946 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
101947 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
101948 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
101949 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
101950 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
101951 +smk_write_access_49561 smk_write_access 3 49561 NULL
101952 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
101953 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
101954 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
101955 +tap_write_49595 tap_write 3 49595 NULL
101956 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
101957 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
101958 +heap_init_49617 heap_init 2 49617 NULL
101959 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
101960 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
101961 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
101962 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
101963 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
101964 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
101965 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
101966 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
101967 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
101968 +check_frame_49741 check_frame 0 49741 NULL
101969 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
101970 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
101971 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
101972 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
101973 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
101974 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
101975 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
101976 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
101977 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
101978 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
101979 +add_uuid_49831 add_uuid 4 49831 NULL
101980 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
101981 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
101982 +twl4030_write_49846 twl4030_write 2 49846 NULL
101983 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
101984 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
101985 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
101986 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
101987 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
101988 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
101989 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
101990 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
101991 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
101992 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
101993 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
101994 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
101995 +__module_alloc_50004 __module_alloc 1 50004 NULL
101996 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
101997 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
101998 +isdn_read_50021 isdn_read 3 50021 NULL
101999 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
102000 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
102001 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
102002 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
102003 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
102004 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
102005 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
102006 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
102007 +read_file_slot_50111 read_file_slot 3 50111 NULL
102008 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
102009 +copy_items_50140 copy_items 6 50140 NULL
102010 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
102011 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
102012 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
102013 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
102014 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
102015 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
102016 +odev_update_50169 odev_update 2 50169 NULL
102017 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
102018 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
102019 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
102020 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
102021 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
102022 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
102023 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
102024 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
102025 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
102026 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
102027 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
102028 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
102029 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
102030 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
102031 +do_launder_page_50329 do_launder_page 0 50329 NULL
102032 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
102033 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
102034 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
102035 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
102036 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
102037 +tpm_read_50344 tpm_read 3 50344 NULL
102038 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
102039 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
102040 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
102041 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
102042 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
102043 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
102044 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
102045 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
102046 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
102047 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
102048 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
102049 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
102050 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
102051 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
102052 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
102053 +force_mapping_50464 force_mapping 2 50464 NULL
102054 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
102055 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
102056 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
102057 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
102058 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
102059 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
102060 +fat_readpages_50582 fat_readpages 4 50582 NULL
102061 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
102062 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
102063 +sge_rx_50594 sge_rx 3 50594 NULL
102064 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
102065 +__ffs_50625 __ffs 0 50625 NULL
102066 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
102067 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
102068 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
102069 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
102070 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
102071 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
102072 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
102073 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
102074 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
102075 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
102076 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
102077 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
102078 +skb_padto_50759 skb_padto 2 50759 NULL
102079 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
102080 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
102081 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
102082 +tpm_write_50798 tpm_write 3 50798 NULL
102083 +write_flush_50803 write_flush 3 50803 NULL
102084 +dvb_play_50814 dvb_play 3 50814 NULL
102085 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
102086 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
102087 +SetArea_50835 SetArea 4 50835 NULL nohasharray
102088 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
102089 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
102090 +self_check_write_50856 self_check_write 5 50856 NULL
102091 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
102092 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
102093 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
102094 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
102095 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
102096 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
102097 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
102098 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
102099 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
102100 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
102101 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
102102 +timeout_write_50991 timeout_write 3 50991 NULL
102103 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
102104 +proc_write_51003 proc_write 3 51003 NULL
102105 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
102106 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
102107 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
102108 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
102109 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
102110 +dump_midi_51040 dump_midi 3 51040 NULL
102111 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
102112 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
102113 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
102114 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
102115 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
102116 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
102117 +ti_recv_51110 ti_recv 3 51110 NULL
102118 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
102119 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
102120 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
102121 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
102122 +set_dirty_51144 set_dirty 3 51144 NULL
102123 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
102124 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
102125 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
102126 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
102127 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
102128 +tipc_send_51238 tipc_send 4 51238 NULL
102129 +drm_property_create_51239 drm_property_create 4 51239 NULL
102130 +st_read_51251 st_read 3 51251 NULL
102131 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
102132 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
102133 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
102134 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
102135 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
102136 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
102137 +get_cell_51316 get_cell 2 51316 NULL
102138 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
102139 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
102140 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
102141 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
102142 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
102143 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
102144 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
102145 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
102146 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
102147 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
102148 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
102149 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
102150 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
102151 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
102152 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
102153 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
102154 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
102155 +vaddr_51480 vaddr 0 51480 NULL
102156 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
102157 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
102158 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
102159 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
102160 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
102161 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
102162 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
102163 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
102164 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
102165 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
102166 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
102167 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
102168 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
102169 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
102170 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
102171 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
102172 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
102173 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
102174 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
102175 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
102176 +sel_write_access_51704 sel_write_access 3 51704 NULL
102177 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
102178 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
102179 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
102180 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
102181 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
102182 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
102183 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
102184 +if_write_51756 if_write 3 51756 NULL
102185 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
102186 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
102187 +to_ratio_51809 to_ratio 2-1 51809 NULL
102188 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
102189 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
102190 +ioread32_51847 ioread32 0 51847 NULL nohasharray
102191 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
102192 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
102193 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
102194 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
102195 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
102196 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
102197 +user_read_51881 user_read 3 51881 NULL
102198 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
102199 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
102200 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
102201 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
102202 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
102203 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
102204 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
102205 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
102206 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
102207 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
102208 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
102209 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
102210 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
102211 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
102212 +rdmalt_52022 rdmalt 0 52022 NULL
102213 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
102214 +override_release_52032 override_release 2 52032 NULL
102215 +end_port_52042 end_port 0 52042 NULL
102216 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
102217 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
102218 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
102219 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
102220 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
102221 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
102222 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
102223 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
102224 +retry_count_read_52129 retry_count_read 3 52129 NULL
102225 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
102226 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
102227 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
102228 +htable_size_52148 htable_size 0-1 52148 NULL
102229 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
102230 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
102231 +alix_present_52165 alix_present 1 52165 NULL
102232 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
102233 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
102234 +print_prefix_52176 print_prefix 0 52176 NULL
102235 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
102236 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
102237 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
102238 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
102239 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
102240 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
102241 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
102242 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
102243 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
102244 +atomic64_read_52300 atomic64_read 0 52300 NULL
102245 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
102246 +read_file_reset_52310 read_file_reset 3 52310 NULL
102247 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
102248 +hwflags_read_52318 hwflags_read 3 52318 NULL
102249 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
102250 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
102251 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
102252 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
102253 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
102254 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
102255 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
102256 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
102257 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
102258 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
102259 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
102260 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
102261 +delay_status_52431 delay_status 5 52431 NULL
102262 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
102263 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
102264 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
102265 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
102266 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
102267 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
102268 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
102269 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
102270 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
102271 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
102272 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
102273 +from_oblock_52546 from_oblock 0-1 52546 NULL
102274 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
102275 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
102276 +emit_code_52583 emit_code 0-3 52583 NULL
102277 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
102278 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
102279 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
102280 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
102281 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
102282 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
102283 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
102284 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
102285 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
102286 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
102287 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
102288 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
102289 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
102290 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
102291 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
102292 +twlreg_write_52880 twlreg_write 3 52880 NULL
102293 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
102294 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
102295 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
102296 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
102297 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
102298 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
102299 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
102300 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
102301 +send_packet_52960 send_packet 4 52960 NULL
102302 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
102303 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
102304 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
102305 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
102306 +num_node_state_52989 num_node_state 0 52989 NULL
102307 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
102308 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
102309 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
102310 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
102311 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
102312 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
102313 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
102314 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
102315 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
102316 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
102317 +verity_status_53120 verity_status 5 53120 NULL
102318 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
102319 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
102320 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
102321 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
102322 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
102323 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
102324 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
102325 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
102326 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
102327 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
102328 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
102329 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
102330 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
102331 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
102332 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
102333 +vm_mmap_53339 vm_mmap 0 53339 NULL
102334 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
102335 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
102336 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
102337 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
102338 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
102339 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
102340 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
102341 +n2_run_53459 n2_run 3 53459 NULL
102342 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
102343 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
102344 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
102345 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
102346 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
102347 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
102348 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
102349 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
102350 +check_acl_53512 check_acl 0 53512 NULL
102351 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
102352 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
102353 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
102354 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
102355 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
102356 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
102357 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
102358 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
102359 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
102360 +_preload_range_53676 _preload_range 2-3 53676 NULL
102361 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
102362 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
102363 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
102364 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
102365 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
102366 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
102367 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
102368 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
102369 +wdm_write_53735 wdm_write 3 53735 NULL
102370 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
102371 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
102372 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
102373 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
102374 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
102375 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
102376 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
102377 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
102378 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
102379 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
102380 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
102381 +pms_read_53873 pms_read 3 53873 NULL
102382 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
102383 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
102384 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
102385 +proc_file_read_53905 proc_file_read 3 53905 NULL
102386 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
102387 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
102388 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
102389 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
102390 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
102391 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
102392 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
102393 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
102394 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
102395 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
102396 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
102397 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
102398 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
102399 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
102400 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
102401 +_malloc_54077 _malloc 1 54077 NULL
102402 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
102403 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
102404 +create_xattr_54106 create_xattr 5 54106 NULL
102405 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
102406 +strn_len_54122 strn_len 0 54122 NULL
102407 +isku_receive_54130 isku_receive 4 54130 NULL
102408 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
102409 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
102410 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
102411 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
102412 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
102413 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
102414 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
102415 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
102416 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
102417 +reada_add_block_54247 reada_add_block 2 54247 NULL
102418 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
102419 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
102420 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
102421 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
102422 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
102423 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
102424 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
102425 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
102426 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
102427 +sprintf_54306 sprintf 0 54306 NULL
102428 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
102429 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
102430 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
102431 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
102432 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
102433 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
102434 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
102435 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
102436 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
102437 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
102438 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
102439 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
102440 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
102441 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
102442 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
102443 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
102444 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
102445 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
102446 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
102447 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
102448 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
102449 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
102450 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
102451 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
102452 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
102453 +viacam_read_54526 viacam_read 3 54526 NULL
102454 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
102455 +setsockopt_54539 setsockopt 5 54539 NULL
102456 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
102457 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
102458 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
102459 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
102460 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
102461 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
102462 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
102463 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
102464 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
102465 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
102466 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
102467 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
102468 +evm_read_key_54674 evm_read_key 3 54674 NULL
102469 +resource_string_54699 resource_string 0 54699 NULL
102470 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
102471 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
102472 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
102473 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
102474 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
102475 +kzalloc_54740 kzalloc 1 54740 NULL
102476 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
102477 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
102478 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
102479 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
102480 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
102481 +domain_init_54797 domain_init 2 54797 NULL
102482 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
102483 +get_dev_size_54807 get_dev_size 0 54807 NULL
102484 +nfsd_write_54809 nfsd_write 6 54809 NULL
102485 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
102486 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
102487 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
102488 +write_rio_54837 write_rio 3 54837 NULL
102489 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
102490 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
102491 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
102492 +printer_read_54851 printer_read 3 54851 NULL
102493 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
102494 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
102495 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
102496 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
102497 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
102498 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
102499 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
102500 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
102501 +add_port_54941 add_port 2 54941 NULL
102502 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
102503 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
102504 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
102505 +c4_add_card_54968 c4_add_card 3 54968 NULL
102506 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
102507 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
102508 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
102509 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
102510 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
102511 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
102512 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
102513 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
102514 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
102515 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
102516 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
102517 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
102518 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
102519 +corrupt_data_55120 corrupt_data 0 55120 NULL
102520 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
102521 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
102522 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
102523 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
102524 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
102525 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
102526 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
102527 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
102528 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
102529 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
102530 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
102531 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
102532 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
102533 +dump_command_55220 dump_command 1 55220 NULL
102534 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
102535 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
102536 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
102537 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
102538 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
102539 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
102540 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
102541 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
102542 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
102543 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
102544 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
102545 +do_shmat_55336 do_shmat 5 55336 NULL
102546 +vme_user_read_55338 vme_user_read 3 55338 NULL
102547 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
102548 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
102549 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
102550 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
102551 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
102552 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
102553 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
102554 +alloc_skb_55439 alloc_skb 1 55439 NULL
102555 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
102556 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
102557 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
102558 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
102559 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
102560 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
102561 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
102562 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
102563 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
102564 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
102565 +ea_get_55522 ea_get 0 55522 NULL
102566 +buffer_size_55534 buffer_size 0 55534 NULL
102567 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
102568 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
102569 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
102570 +add_partition_55588 add_partition 2 55588 NULL
102571 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
102572 +free_pages_55603 free_pages 1 55603 NULL
102573 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
102574 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
102575 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
102576 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
102577 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
102578 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
102579 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
102580 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
102581 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
102582 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
102583 +read_oldmem_55658 read_oldmem 3 55658 NULL
102584 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
102585 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
102586 +get_info_55681 get_info 3 55681 NULL
102587 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
102588 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
102589 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
102590 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
102591 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
102592 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
102593 +set_local_name_55757 set_local_name 4 55757 NULL
102594 +strlen_55778 strlen 0 55778 NULL
102595 +set_spte_55783 set_spte 5-4 55783 NULL
102596 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
102597 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
102598 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
102599 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
102600 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
102601 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
102602 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
102603 +hsc_write_55875 hsc_write 3 55875 NULL
102604 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
102605 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
102606 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
102607 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
102608 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
102609 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
102610 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
102611 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
102612 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
102613 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
102614 +__set_discard_56081 __set_discard 2 56081 NULL
102615 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
102616 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
102617 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
102618 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
102619 +map_addr_56144 map_addr 7 56144 NULL
102620 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
102621 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
102622 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
102623 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
102624 +skb_headroom_56200 skb_headroom 0 56200 NULL
102625 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
102626 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
102627 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
102628 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
102629 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
102630 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
102631 +fd_copyin_56247 fd_copyin 3 56247 NULL
102632 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
102633 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
102634 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
102635 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
102636 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
102637 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
102638 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
102639 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
102640 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
102641 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
102642 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
102643 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
102644 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
102645 +dev_read_56369 dev_read 3 56369 NULL
102646 +write_gssp_56404 write_gssp 3 56404 NULL
102647 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
102648 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
102649 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
102650 +store_msg_56417 store_msg 3 56417 NULL
102651 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
102652 +fl_create_56435 fl_create 5 56435 NULL
102653 +gnttab_map_56439 gnttab_map 2 56439 NULL
102654 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
102655 +set_connectable_56458 set_connectable 4 56458 NULL
102656 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
102657 +putused_user_56467 putused_user 3 56467 NULL
102658 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
102659 +global_rt_period_56476 global_rt_period 0 56476 NULL
102660 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
102661 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
102662 +init_map_ip_56508 init_map_ip 5 56508 NULL
102663 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
102664 +ip_options_get_56538 ip_options_get 4 56538 NULL
102665 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
102666 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
102667 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
102668 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
102669 +event_filter_write_56609 event_filter_write 3 56609 NULL
102670 +gather_array_56641 gather_array 3 56641 NULL
102671 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
102672 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
102673 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
102674 +build_map_info_56696 build_map_info 2 56696 NULL
102675 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
102676 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
102677 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
102678 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
102679 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
102680 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
102681 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
102682 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
102683 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
102684 +hash_lookup_56792 hash_lookup 2 56792 NULL
102685 +do_syslog_56807 do_syslog 3 56807 NULL
102686 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
102687 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
102688 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
102689 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
102690 +wb_lookup_56858 wb_lookup 2 56858 NULL
102691 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
102692 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
102693 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
102694 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
102695 +strcspn_56913 strcspn 0 56913 NULL
102696 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
102697 +check_header_56930 check_header 2 56930 NULL
102698 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
102699 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
102700 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
102701 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
102702 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
102703 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
102704 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
102705 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
102706 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
102707 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
102708 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
102709 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
102710 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
102711 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
102712 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
102713 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
102714 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
102715 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
102716 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
102717 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
102718 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
102719 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
102720 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
102721 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
102722 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
102723 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
102724 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
102725 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
102726 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
102727 +flush_space_57241 flush_space 3 57241 NULL
102728 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
102729 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
102730 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
102731 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
102732 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
102733 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
102734 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
102735 +fw_file_size_57307 fw_file_size 0 57307 NULL
102736 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
102737 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
102738 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
102739 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
102740 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
102741 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
102742 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
102743 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
102744 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
102745 +read_file_blob_57406 read_file_blob 3 57406 NULL
102746 +enclosure_register_57412 enclosure_register 3 57412 NULL
102747 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
102748 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
102749 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
102750 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
102751 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
102752 +ReadReg_57453 ReadReg 0 57453 NULL
102753 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
102754 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
102755 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
102756 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
102757 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
102758 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
102759 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
102760 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
102761 +skb_headlen_57501 skb_headlen 0 57501 NULL
102762 +copy_in_user_57502 copy_in_user 3 57502 NULL
102763 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
102764 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
102765 +init_tag_map_57515 init_tag_map 3 57515 NULL
102766 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
102767 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
102768 +inode_permission_57531 inode_permission 0 57531 NULL
102769 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
102770 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
102771 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
102772 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
102773 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
102774 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
102775 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
102776 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
102777 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
102778 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
102779 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
102780 +mem_read_57631 mem_read 3 57631 NULL
102781 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
102782 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
102783 +r3964_write_57662 r3964_write 4 57662 NULL
102784 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
102785 +__lgwrite_57669 __lgwrite 4 57669 NULL
102786 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
102787 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
102788 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
102789 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
102790 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
102791 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
102792 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
102793 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
102794 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
102795 +ld2_57794 ld2 0 57794 NULL
102796 +ivtv_read_57796 ivtv_read 3 57796 NULL
102797 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
102798 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
102799 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
102800 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
102801 +copy_to_user_57835 copy_to_user 3 57835 NULL
102802 +flash_read_57843 flash_read 3 57843 NULL
102803 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
102804 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
102805 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
102806 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
102807 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
102808 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
102809 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
102810 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
102811 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
102812 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
102813 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
102814 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
102815 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
102816 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
102817 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
102818 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
102819 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
102820 +mce_async_out_58056 mce_async_out 3 58056 NULL
102821 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
102822 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
102823 +cm4040_write_58079 cm4040_write 3 58079 NULL
102824 +udi_log_event_58105 udi_log_event 3 58105 NULL
102825 +savemem_58129 savemem 3 58129 NULL
102826 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
102827 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
102828 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
102829 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
102830 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
102831 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
102832 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
102833 +read_file_debug_58256 read_file_debug 3 58256 NULL
102834 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
102835 +profile_load_58267 profile_load 3 58267 NULL
102836 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
102837 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
102838 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
102839 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
102840 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
102841 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
102842 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
102843 +next_pidmap_58347 next_pidmap 2 58347 NULL
102844 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
102845 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
102846 +save_hint_58359 save_hint 2 58359 NULL
102847 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
102848 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
102849 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
102850 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
102851 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
102852 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
102853 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
102854 +capabilities_read_58457 capabilities_read 3 58457 NULL
102855 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
102856 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
102857 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
102858 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
102859 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
102860 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
102861 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
102862 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
102863 +__clear_discard_58546 __clear_discard 2 58546 NULL
102864 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
102865 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
102866 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
102867 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
102868 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
102869 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
102870 +xip_file_read_58592 xip_file_read 3 58592 NULL
102871 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
102872 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
102873 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
102874 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
102875 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
102876 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
102877 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
102878 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
102879 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
102880 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
102881 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
102882 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
102883 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
102884 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
102885 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
102886 +acpi_map_58725 acpi_map 1-2 58725 NULL
102887 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
102888 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
102889 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
102890 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
102891 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
102892 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
102893 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
102894 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
102895 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
102896 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
102897 +ep_read_58813 ep_read 3 58813 NULL
102898 +command_write_58841 command_write 3 58841 NULL
102899 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
102900 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
102901 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
102902 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
102903 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
102904 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
102905 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
102906 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
102907 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
102908 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
102909 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
102910 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
102911 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
102912 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
102913 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
102914 +ep_write_59008 ep_write 3 59008 NULL
102915 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
102916 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
102917 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
102918 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
102919 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
102920 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
102921 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
102922 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
102923 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
102924 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
102925 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
102926 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
102927 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
102928 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
102929 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
102930 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
102931 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
102932 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
102933 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
102934 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
102935 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
102936 +dt3155_read_59226 dt3155_read 3 59226 NULL
102937 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
102938 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
102939 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
102940 +nla_len_59258 nla_len 0 59258 NULL
102941 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
102942 +fd_copyout_59323 fd_copyout 3 59323 NULL
102943 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
102944 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
102945 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
102946 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
102947 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
102948 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
102949 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
102950 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
102951 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
102952 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
102953 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
102954 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
102955 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
102956 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
102957 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
102958 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
102959 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
102960 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
102961 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
102962 +tunables_write_59563 tunables_write 3 59563 NULL
102963 +memdup_user_59590 memdup_user 2 59590 NULL
102964 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
102965 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
102966 +mtrr_write_59622 mtrr_write 3 59622 NULL
102967 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
102968 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
102969 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
102970 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
102971 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
102972 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
102973 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
102974 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
102975 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
102976 +sriov_enable_59689 sriov_enable 2 59689 NULL
102977 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
102978 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
102979 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
102980 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
102981 +strnlen_59746 strnlen 0 59746 NULL
102982 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
102983 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
102984 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
102985 +venus_remove_59781 venus_remove 4 59781 NULL
102986 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
102987 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
102988 +ipw_write_59807 ipw_write 3 59807 NULL
102989 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
102990 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
102991 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
102992 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
102993 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
102994 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
102995 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
102996 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
102997 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
102998 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
102999 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
103000 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
103001 +lookup_node_59953 lookup_node 2 59953 NULL
103002 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
103003 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
103004 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
103005 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
103006 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
103007 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
103008 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
103009 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
103010 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
103011 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
103012 +register_device_60015 register_device 2-3 60015 NULL
103013 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
103014 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
103015 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
103016 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
103017 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
103018 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
103019 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
103020 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
103021 +compat_writev_60063 compat_writev 3 60063 NULL
103022 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
103023 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
103024 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
103025 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
103026 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
103027 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
103028 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
103029 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
103030 +init_state_60165 init_state 2 60165 NULL
103031 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
103032 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
103033 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
103034 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
103035 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
103036 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
103037 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
103038 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
103039 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
103040 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
103041 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
103042 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
103043 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
103044 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
103045 +printer_write_60276 printer_write 3 60276 NULL
103046 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
103047 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
103048 +getDataLength_60301 getDataLength 0 60301 NULL
103049 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
103050 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
103051 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
103052 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
103053 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
103054 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
103055 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
103056 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
103057 +driver_names_read_60399 driver_names_read 3 60399 NULL
103058 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
103059 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
103060 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
103061 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
103062 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
103063 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
103064 +rx_data_60442 rx_data 4 60442 NULL nohasharray
103065 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
103066 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
103067 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
103068 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
103069 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
103070 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
103071 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
103072 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
103073 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
103074 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
103075 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
103076 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
103077 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
103078 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
103079 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
103080 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
103081 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
103082 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
103083 +init_data_container_60709 init_data_container 1 60709 NULL
103084 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
103085 +raid_status_60755 raid_status 5 60755 NULL
103086 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
103087 +opticon_write_60775 opticon_write 4 60775 NULL
103088 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
103089 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
103090 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
103091 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
103092 +generic_writepages_60871 generic_writepages 0 60871 NULL
103093 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
103094 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
103095 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
103096 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
103097 +sys_mlock_60932 sys_mlock 1 60932 NULL
103098 +pti_char_write_60960 pti_char_write 3 60960 NULL
103099 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
103100 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
103101 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
103102 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
103103 +symtab_init_61050 symtab_init 2 61050 NULL
103104 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
103105 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
103106 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
103107 +get_derived_key_61100 get_derived_key 4 61100 NULL
103108 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
103109 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
103110 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
103111 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
103112 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
103113 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
103114 +__vmalloc_61168 __vmalloc 1 61168 NULL
103115 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
103116 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
103117 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
103118 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
103119 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
103120 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
103121 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
103122 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
103123 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
103124 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
103125 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
103126 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
103127 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
103128 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
103129 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
103130 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
103131 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
103132 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
103133 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
103134 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
103135 +change_xattr_61390 change_xattr 5 61390 NULL
103136 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
103137 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
103138 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
103139 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
103140 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
103141 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
103142 +erst_errno_61526 erst_errno 0 61526 NULL
103143 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
103144 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
103145 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
103146 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
103147 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
103148 +seq_open_private_61589 seq_open_private 3 61589 NULL
103149 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
103150 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
103151 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
103152 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
103153 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
103154 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
103155 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
103156 +resize_stripes_61650 resize_stripes 2 61650 NULL
103157 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
103158 +insert_one_name_61668 insert_one_name 7 61668 NULL
103159 +lock_loop_61681 lock_loop 1 61681 NULL
103160 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
103161 +filter_read_61692 filter_read 3 61692 NULL
103162 +iov_length_61716 iov_length 0 61716 NULL
103163 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
103164 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
103165 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
103166 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
103167 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
103168 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
103169 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
103170 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
103171 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
103172 +get_fw_name_61874 get_fw_name 3 61874 NULL
103173 +free_init_pages_61875 free_init_pages 2 61875 NULL
103174 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
103175 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
103176 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
103177 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
103178 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
103179 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
103180 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
103181 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
103182 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
103183 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
103184 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
103185 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
103186 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
103187 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
103188 +cow_file_range_61979 cow_file_range 3 61979 NULL
103189 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
103190 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
103191 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
103192 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
103193 +SYSC_select_62024 SYSC_select 1 62024 NULL
103194 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
103195 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
103196 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
103197 +do_pselect_62061 do_pselect 1 62061 NULL
103198 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
103199 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
103200 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
103201 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
103202 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
103203 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
103204 +ql_status_62135 ql_status 5 62135 NULL
103205 +video_usercopy_62151 video_usercopy 2 62151 NULL
103206 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
103207 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
103208 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
103209 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
103210 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
103211 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
103212 +allocate_partition_62245 allocate_partition 4 62245 NULL
103213 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
103214 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
103215 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
103216 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
103217 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
103218 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
103219 +subseq_list_62332 subseq_list 3-0 62332 NULL
103220 +flash_write_62354 flash_write 3 62354 NULL
103221 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
103222 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
103223 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
103224 +altera_irscan_62396 altera_irscan 2 62396 NULL
103225 +set_ssp_62411 set_ssp 4 62411 NULL
103226 +unmap_single_62423 unmap_single 2 62423 NULL
103227 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
103228 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
103229 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
103230 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
103231 +remove_mapping_62491 remove_mapping 2 62491 NULL
103232 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
103233 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
103234 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
103235 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
103236 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
103237 +debugfs_read_62535 debugfs_read 3 62535 NULL
103238 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
103239 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
103240 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
103241 +get_subdir_62581 get_subdir 3 62581 NULL
103242 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
103243 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
103244 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
103245 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
103246 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
103247 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
103248 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
103249 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
103250 +write_62671 write 3 62671 NULL
103251 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
103252 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
103253 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
103254 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
103255 +rdm_62719 rdm 0 62719 NULL
103256 +key_replays_read_62746 key_replays_read 3 62746 NULL
103257 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
103258 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
103259 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
103260 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
103261 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
103262 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
103263 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
103264 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
103265 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
103266 +set_swbp_62853 set_swbp 3 62853 NULL
103267 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
103268 +aoechr_write_62883 aoechr_write 3 62883 NULL
103269 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
103270 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
103271 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
103272 +getdqbuf_62908 getdqbuf 1 62908 NULL
103273 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
103274 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
103275 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
103276 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
103277 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
103278 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
103279 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
103280 +unlink1_63059 unlink1 3 63059 NULL
103281 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
103282 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
103283 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
103284 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
103285 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
103286 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
103287 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
103288 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
103289 +vme_master_read_63221 vme_master_read 0 63221 NULL
103290 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
103291 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
103292 +ptp_read_63251 ptp_read 4 63251 NULL
103293 +raid5_resize_63306 raid5_resize 2 63306 NULL
103294 +proc_info_read_63344 proc_info_read 3 63344 NULL
103295 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
103296 +idmouse_read_63374 idmouse_read 3 63374 NULL
103297 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
103298 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
103299 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
103300 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
103301 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
103302 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
103303 +kone_send_63435 kone_send 4 63435 NULL
103304 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
103305 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
103306 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
103307 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
103308 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
103309 +read_kcore_63488 read_kcore 3 63488 NULL
103310 +save_hint_63497 save_hint 2 63497 NULL
103311 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
103312 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
103313 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
103314 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
103315 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
103316 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
103317 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
103318 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
103319 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
103320 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
103321 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
103322 +module_alloc_63630 module_alloc 1 63630 NULL
103323 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
103324 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
103325 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
103326 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
103327 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
103328 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
103329 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
103330 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
103331 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
103332 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
103333 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
103334 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
103335 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
103336 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
103337 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
103338 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
103339 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
103340 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
103341 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
103342 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
103343 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
103344 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
103345 +prepare_copy_63826 prepare_copy 2 63826 NULL
103346 +sel_write_load_63830 sel_write_load 3 63830 NULL
103347 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
103348 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
103349 +divas_write_63901 divas_write 3 63901 NULL
103350 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
103351 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
103352 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
103353 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
103354 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
103355 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
103356 +__team_options_register_63941 __team_options_register 3 63941 NULL
103357 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
103358 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
103359 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
103360 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
103361 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
103362 +kmemdup_64015 kmemdup 2 64015 NULL
103363 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
103364 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
103365 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
103366 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
103367 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
103368 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
103369 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
103370 +get_u8_64076 get_u8 0 64076 NULL
103371 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
103372 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
103373 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
103374 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
103375 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
103376 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
103377 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
103378 +init_bch_64130 init_bch 1-2 64130 NULL
103379 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
103380 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
103381 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
103382 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
103383 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
103384 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
103385 +read_pulse_64227 read_pulse 0-3 64227 NULL
103386 +header_len_64232 header_len 0 64232 NULL
103387 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
103388 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
103389 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
103390 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
103391 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
103392 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
103393 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
103394 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
103395 +ffz_64324 ffz 0 64324 NULL
103396 +map_region_64328 map_region 1 64328 NULL
103397 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
103398 +ts_write_64336 ts_write 3 64336 NULL
103399 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
103400 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
103401 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
103402 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
103403 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
103404 +ilo_write_64378 ilo_write 3 64378 NULL
103405 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
103406 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
103407 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
103408 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
103409 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
103410 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
103411 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
103412 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
103413 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
103414 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
103415 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
103416 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
103417 +cap_capable_64462 cap_capable 0 64462 NULL
103418 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
103419 +single_open_size_64483 single_open_size 4 64483 NULL
103420 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
103421 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
103422 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
103423 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
103424 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
103425 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
103426 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
103427 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
103428 +SyS_bind_64544 SyS_bind 3 64544 NULL
103429 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
103430 +__spi_sync_64561 __spi_sync 0 64561 NULL
103431 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
103432 +fanotify_write_64623 fanotify_write 3 64623 NULL
103433 +to_dblock_64655 to_dblock 0-1 64655 NULL
103434 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
103435 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
103436 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
103437 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
103438 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
103439 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
103440 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
103441 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
103442 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
103443 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
103444 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
103445 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
103446 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
103447 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
103448 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
103449 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
103450 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
103451 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
103452 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
103453 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
103454 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
103455 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
103456 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
103457 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
103458 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
103459 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
103460 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
103461 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
103462 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
103463 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
103464 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
103465 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
103466 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
103467 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
103468 +pskb_pull_65005 pskb_pull 2 65005 NULL
103469 +unifi_write_65012 unifi_write 3 65012 NULL
103470 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
103471 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
103472 +insert_dent_65034 insert_dent 7 65034 NULL
103473 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
103474 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
103475 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
103476 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
103477 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
103478 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
103479 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
103480 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
103481 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
103482 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
103483 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
103484 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
103485 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
103486 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
103487 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
103488 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
103489 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
103490 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
103491 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
103492 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
103493 +get_var_len_65304 get_var_len 0 65304 NULL
103494 +unpack_array_65318 unpack_array 0 65318 NULL
103495 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
103496 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
103497 +init_list_set_65351 init_list_set 2-3 65351 NULL
103498 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
103499 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
103500 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
103501 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
103502 +strchr_65372 strchr 0 65372 NULL nohasharray
103503 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
103504 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
103505 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
103506 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
103507 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
103508 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
103509 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
103510 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
103511 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
103512 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
103513 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
103514 +alloc_dr_65495 alloc_dr 2 65495 NULL
103515 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
103516 new file mode 100644
103517 index 0000000..9db0d0e
103518 --- /dev/null
103519 +++ b/tools/gcc/size_overflow_plugin.c
103520 @@ -0,0 +1,2114 @@
103521 +/*
103522 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
103523 + * Licensed under the GPL v2, or (at your option) v3
103524 + *
103525 + * Homepage:
103526 + * http://www.grsecurity.net/~ephox/overflow_plugin/
103527 + *
103528 + * Documentation:
103529 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
103530 + *
103531 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
103532 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
103533 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
103534 + *
103535 + * Usage:
103536 + * $ gcc -I`gcc -print-file-name=plugin`/include/c-family -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -ggdb -Wall -W -o size_overflow_plugin.so size_overflow_plugin.c
103537 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
103538 + */
103539 +
103540 +#include "gcc-plugin.h"
103541 +#include "config.h"
103542 +#include "system.h"
103543 +#include "coretypes.h"
103544 +#include "tree.h"
103545 +#include "tree-pass.h"
103546 +#include "intl.h"
103547 +#include "plugin-version.h"
103548 +#include "tm.h"
103549 +#include "toplev.h"
103550 +#include "function.h"
103551 +#include "tree-flow.h"
103552 +#include "plugin.h"
103553 +#include "gimple.h"
103554 +#include "diagnostic.h"
103555 +#include "cfgloop.h"
103556 +
103557 +#if BUILDING_GCC_VERSION >= 4008
103558 +#define TODO_dump_func 0
103559 +#endif
103560 +
103561 +struct size_overflow_hash {
103562 + const struct size_overflow_hash * const next;
103563 + const char * const name;
103564 + const unsigned int param;
103565 +};
103566 +
103567 +#include "size_overflow_hash.h"
103568 +
103569 +enum mark {
103570 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
103571 +};
103572 +
103573 +enum err_code_conditions {
103574 + CAST_ONLY, FROM_CONST
103575 +};
103576 +
103577 +static unsigned int call_count = 0;
103578 +
103579 +#define __unused __attribute__((__unused__))
103580 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103581 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
103582 +#define BEFORE_STMT true
103583 +#define AFTER_STMT false
103584 +#define CREATE_NEW_VAR NULL_TREE
103585 +#define CODES_LIMIT 32
103586 +#define MAX_PARAM 31
103587 +#define MY_STMT GF_PLF_1
103588 +#define NO_CAST_CHECK GF_PLF_2
103589 +#define FROM_ARG true
103590 +#define FROM_RET false
103591 +
103592 +#if BUILDING_GCC_VERSION == 4005
103593 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
103594 +#endif
103595 +
103596 +int plugin_is_GPL_compatible;
103597 +void debug_gimple_stmt(gimple gs);
103598 +
103599 +static tree expand(struct pointer_set_t *visited, tree lhs);
103600 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
103601 +static tree report_size_overflow_decl;
103602 +static const_tree const_char_ptr_type_node;
103603 +static unsigned int handle_function(void);
103604 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
103605 +static tree get_size_overflow_type(gimple stmt, const_tree node);
103606 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
103607 +static void print_missing_msg(tree func, unsigned int argnum);
103608 +
103609 +static struct plugin_info size_overflow_plugin_info = {
103610 + .version = "20130410beta",
103611 + .help = "no-size-overflow\tturn off size overflow checking\n",
103612 +};
103613 +
103614 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
103615 +{
103616 + unsigned int arg_count;
103617 + enum tree_code code = TREE_CODE(*node);
103618 +
103619 + switch (code) {
103620 + case FUNCTION_DECL:
103621 + arg_count = type_num_arguments(TREE_TYPE(*node));
103622 + break;
103623 + case FUNCTION_TYPE:
103624 + case METHOD_TYPE:
103625 + arg_count = type_num_arguments(*node);
103626 + break;
103627 + default:
103628 + *no_add_attrs = true;
103629 + error("%s: %qE attribute only applies to functions", __func__, name);
103630 + return NULL_TREE;
103631 + }
103632 +
103633 + for (; args; args = TREE_CHAIN(args)) {
103634 + tree position = TREE_VALUE(args);
103635 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
103636 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
103637 + *no_add_attrs = true;
103638 + }
103639 + }
103640 + return NULL_TREE;
103641 +}
103642 +
103643 +static const char* get_asm_name(tree node)
103644 +{
103645 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
103646 +}
103647 +
103648 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
103649 +{
103650 + unsigned int arg_count, arg_num;
103651 + enum tree_code code = TREE_CODE(*node);
103652 +
103653 + switch (code) {
103654 + case FUNCTION_DECL:
103655 + arg_count = type_num_arguments(TREE_TYPE(*node));
103656 + break;
103657 + case FUNCTION_TYPE:
103658 + case METHOD_TYPE:
103659 + arg_count = type_num_arguments(*node);
103660 + break;
103661 + case FIELD_DECL:
103662 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
103663 + if (arg_num != 0) {
103664 + *no_add_attrs = true;
103665 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
103666 + }
103667 + return NULL_TREE;
103668 + default:
103669 + *no_add_attrs = true;
103670 + error("%qE attribute only applies to functions", name);
103671 + return NULL_TREE;
103672 + }
103673 +
103674 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
103675 + return NULL_TREE;
103676 +
103677 + for (; args; args = TREE_CHAIN(args)) {
103678 + tree position = TREE_VALUE(args);
103679 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
103680 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
103681 + *no_add_attrs = true;
103682 + }
103683 + }
103684 + return NULL_TREE;
103685 +}
103686 +
103687 +static struct attribute_spec size_overflow_attr = {
103688 + .name = "size_overflow",
103689 + .min_length = 1,
103690 + .max_length = -1,
103691 + .decl_required = true,
103692 + .type_required = false,
103693 + .function_type_required = false,
103694 + .handler = handle_size_overflow_attribute,
103695 +#if BUILDING_GCC_VERSION >= 4007
103696 + .affects_type_identity = false
103697 +#endif
103698 +};
103699 +
103700 +static struct attribute_spec intentional_overflow_attr = {
103701 + .name = "intentional_overflow",
103702 + .min_length = 1,
103703 + .max_length = -1,
103704 + .decl_required = true,
103705 + .type_required = false,
103706 + .function_type_required = false,
103707 + .handler = handle_intentional_overflow_attribute,
103708 +#if BUILDING_GCC_VERSION >= 4007
103709 + .affects_type_identity = false
103710 +#endif
103711 +};
103712 +
103713 +static void register_attributes(void __unused *event_data, void __unused *data)
103714 +{
103715 + register_attribute(&size_overflow_attr);
103716 + register_attribute(&intentional_overflow_attr);
103717 +}
103718 +
103719 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
103720 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
103721 +{
103722 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
103723 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
103724 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
103725 +
103726 + unsigned int m = 0x57559429;
103727 + unsigned int n = 0x5052acdb;
103728 + const unsigned int *key4 = (const unsigned int *)key;
103729 + unsigned int h = len;
103730 + unsigned int k = len + seed + n;
103731 + unsigned long long p;
103732 +
103733 + while (len >= 8) {
103734 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
103735 + len -= 8;
103736 + }
103737 + if (len >= 4) {
103738 + cwmixb(key4[0]) key4 += 1;
103739 + len -= 4;
103740 + }
103741 + if (len)
103742 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
103743 + cwmixb(h ^ (k + n));
103744 + return k ^ h;
103745 +
103746 +#undef cwfold
103747 +#undef cwmixa
103748 +#undef cwmixb
103749 +}
103750 +
103751 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
103752 +{
103753 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
103754 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
103755 + return fn ^ codes;
103756 +}
103757 +
103758 +static inline tree get_original_function_decl(tree fndecl)
103759 +{
103760 + if (DECL_ABSTRACT_ORIGIN(fndecl))
103761 + return DECL_ABSTRACT_ORIGIN(fndecl);
103762 + return fndecl;
103763 +}
103764 +
103765 +static inline gimple get_def_stmt(const_tree node)
103766 +{
103767 + gcc_assert(node != NULL_TREE);
103768 + if (TREE_CODE(node) != SSA_NAME)
103769 + return NULL;
103770 + return SSA_NAME_DEF_STMT(node);
103771 +}
103772 +
103773 +static unsigned char get_tree_code(const_tree type)
103774 +{
103775 + switch (TREE_CODE(type)) {
103776 + case ARRAY_TYPE:
103777 + return 0;
103778 + case BOOLEAN_TYPE:
103779 + return 1;
103780 + case ENUMERAL_TYPE:
103781 + return 2;
103782 + case FUNCTION_TYPE:
103783 + return 3;
103784 + case INTEGER_TYPE:
103785 + return 4;
103786 + case POINTER_TYPE:
103787 + return 5;
103788 + case RECORD_TYPE:
103789 + return 6;
103790 + case UNION_TYPE:
103791 + return 7;
103792 + case VOID_TYPE:
103793 + return 8;
103794 + case REAL_TYPE:
103795 + return 9;
103796 + case VECTOR_TYPE:
103797 + return 10;
103798 + case REFERENCE_TYPE:
103799 + return 11;
103800 + case OFFSET_TYPE:
103801 + return 12;
103802 + case COMPLEX_TYPE:
103803 + return 13;
103804 + default:
103805 + debug_tree((tree)type);
103806 + gcc_unreachable();
103807 + }
103808 +}
103809 +
103810 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
103811 +{
103812 + gcc_assert(type != NULL_TREE);
103813 +
103814 + while (type && len < CODES_LIMIT) {
103815 + tree_codes[len] = get_tree_code(type);
103816 + len++;
103817 + type = TREE_TYPE(type);
103818 + }
103819 + return len;
103820 +}
103821 +
103822 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
103823 +{
103824 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
103825 + enum tree_code code = TREE_CODE(type);
103826 + size_t len = 0;
103827 +
103828 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
103829 +
103830 + arg = TYPE_ARG_TYPES(type);
103831 + // skip builtins __builtin_constant_p
103832 + if (!arg && DECL_BUILT_IN(fndecl))
103833 + return 0;
103834 +
103835 + if (TREE_CODE_CLASS(code) == tcc_type)
103836 + result = type;
103837 + else
103838 + result = DECL_RESULT(fndecl);
103839 +
103840 + gcc_assert(result != NULL_TREE);
103841 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
103842 +
103843 + if (arg == NULL_TREE) {
103844 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
103845 + arg_field = DECL_ARGUMENT_FLD(fndecl);
103846 + if (arg_field == NULL_TREE)
103847 + return 0;
103848 + arg = TREE_TYPE(arg_field);
103849 + len = add_type_codes(arg, tree_codes, len);
103850 + gcc_assert(len != 0);
103851 + return len;
103852 + }
103853 +
103854 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
103855 + while (arg && len < CODES_LIMIT) {
103856 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
103857 + arg = TREE_CHAIN(arg);
103858 + }
103859 +
103860 + gcc_assert(len != 0);
103861 + return len;
103862 +}
103863 +
103864 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
103865 +{
103866 + unsigned int hash;
103867 + const struct size_overflow_hash *entry;
103868 + unsigned char tree_codes[CODES_LIMIT];
103869 + size_t len;
103870 + const char *func_name;
103871 +
103872 + fndecl = get_original_function_decl(fndecl);
103873 + len = get_function_decl(fndecl, tree_codes);
103874 + if (len == 0)
103875 + return NULL;
103876 +
103877 + func_name = get_asm_name(fndecl);
103878 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
103879 +
103880 + entry = size_overflow_hash[hash];
103881 + while (entry) {
103882 + if (!strcmp(entry->name, func_name))
103883 + return entry;
103884 + entry = entry->next;
103885 + }
103886 +
103887 + return NULL;
103888 +}
103889 +
103890 +static bool is_bool(const_tree node)
103891 +{
103892 + const_tree type;
103893 +
103894 + if (node == NULL_TREE)
103895 + return false;
103896 +
103897 + type = TREE_TYPE(node);
103898 + if (!INTEGRAL_TYPE_P(type))
103899 + return false;
103900 + if (TREE_CODE(type) == BOOLEAN_TYPE)
103901 + return true;
103902 + if (TYPE_PRECISION(type) == 1)
103903 + return true;
103904 + return false;
103905 +}
103906 +
103907 +static bool skip_types(const_tree var)
103908 +{
103909 + tree type;
103910 +
103911 + if (is_gimple_constant(var))
103912 + return true;
103913 +
103914 + switch (TREE_CODE(var)) {
103915 + case ADDR_EXPR:
103916 +#if BUILDING_GCC_VERSION >= 4006
103917 + case MEM_REF:
103918 +#endif
103919 + case ARRAY_REF:
103920 + case BIT_FIELD_REF:
103921 + case INDIRECT_REF:
103922 + case TARGET_MEM_REF:
103923 + return true;
103924 + case PARM_DECL:
103925 + case VAR_DECL:
103926 + case COMPONENT_REF:
103927 + return false;
103928 + default:
103929 + break;
103930 + }
103931 +
103932 + gcc_assert(TREE_CODE(var) == SSA_NAME);
103933 +
103934 + type = TREE_TYPE(var);
103935 + switch (TREE_CODE(type)) {
103936 + case INTEGER_TYPE:
103937 + case ENUMERAL_TYPE:
103938 + return false;
103939 + case BOOLEAN_TYPE:
103940 + return is_bool(var);
103941 + default:
103942 + break;
103943 + }
103944 +
103945 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
103946 +
103947 + type = TREE_TYPE(type);
103948 + gcc_assert(type != NULL_TREE);
103949 + switch (TREE_CODE(type)) {
103950 + case RECORD_TYPE:
103951 + case POINTER_TYPE:
103952 + case ARRAY_TYPE:
103953 + return true;
103954 + case VOID_TYPE:
103955 + case INTEGER_TYPE:
103956 + case UNION_TYPE:
103957 + return false;
103958 + default:
103959 + break;
103960 + }
103961 +
103962 + debug_tree((tree)var);
103963 + gcc_unreachable();
103964 +}
103965 +
103966 +static unsigned int find_arg_number(const_tree arg, tree func)
103967 +{
103968 + tree var;
103969 + unsigned int argnum = 1;
103970 +
103971 + if (TREE_CODE(arg) == SSA_NAME)
103972 + arg = SSA_NAME_VAR(arg);
103973 +
103974 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
103975 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
103976 + continue;
103977 + if (!skip_types(var))
103978 + return argnum;
103979 + }
103980 +
103981 + return 0;
103982 +}
103983 +
103984 +static tree create_new_var(tree type)
103985 +{
103986 + tree new_var = create_tmp_var(type, "cicus");
103987 +
103988 +#if BUILDING_GCC_VERSION <= 4007
103989 + add_referenced_var(new_var);
103990 + mark_sym_for_renaming(new_var);
103991 +#endif
103992 + return new_var;
103993 +}
103994 +
103995 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
103996 +{
103997 + gimple assign;
103998 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103999 + tree type = TREE_TYPE(rhs1);
104000 + tree lhs = create_new_var(type);
104001 +
104002 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
104003 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
104004 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
104005 +
104006 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
104007 + update_stmt(assign);
104008 + gimple_set_plf(assign, MY_STMT, true);
104009 + return assign;
104010 +}
104011 +
104012 +static tree cast_a_tree(tree type, tree var)
104013 +{
104014 + gcc_assert(type != NULL_TREE);
104015 + gcc_assert(var != NULL_TREE);
104016 + gcc_assert(fold_convertible_p(type, var));
104017 +
104018 + return fold_convert(type, var);
104019 +}
104020 +
104021 +static tree get_lhs(const_gimple stmt)
104022 +{
104023 + switch (gimple_code(stmt)) {
104024 + case GIMPLE_ASSIGN:
104025 + return gimple_get_lhs(stmt);
104026 + case GIMPLE_PHI:
104027 + return gimple_phi_result(stmt);
104028 + case GIMPLE_CALL:
104029 + return gimple_call_lhs(stmt);
104030 + default:
104031 + return NULL_TREE;
104032 + }
104033 +}
104034 +
104035 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
104036 +{
104037 + const_gimple def_stmt = get_def_stmt(rhs);
104038 +
104039 + if (force)
104040 + return false;
104041 +
104042 + if (is_gimple_constant(rhs))
104043 + return false;
104044 +
104045 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
104046 + return false;
104047 +
104048 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
104049 + return false;
104050 +
104051 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
104052 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
104053 + return false;
104054 +
104055 + return true;
104056 +}
104057 +
104058 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
104059 +{
104060 + gimple assign, def_stmt;
104061 +
104062 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
104063 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
104064 + gcc_unreachable();
104065 +
104066 + def_stmt = get_def_stmt(rhs);
104067 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
104068 + return def_stmt;
104069 +
104070 + if (lhs == CREATE_NEW_VAR)
104071 + lhs = create_new_var(dst_type);
104072 +
104073 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
104074 +
104075 + if (!gsi_end_p(*gsi)) {
104076 + location_t loc = gimple_location(gsi_stmt(*gsi));
104077 + gimple_set_location(assign, loc);
104078 + }
104079 +
104080 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
104081 +
104082 + if (before)
104083 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
104084 + else
104085 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
104086 + update_stmt(assign);
104087 + gimple_set_plf(assign, MY_STMT, true);
104088 +
104089 + return assign;
104090 +}
104091 +
104092 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
104093 +{
104094 + gimple_stmt_iterator gsi;
104095 + tree lhs;
104096 + const_gimple new_stmt;
104097 +
104098 + if (rhs == NULL_TREE)
104099 + return NULL_TREE;
104100 +
104101 + gsi = gsi_for_stmt(stmt);
104102 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
104103 +
104104 + lhs = get_lhs(new_stmt);
104105 + gcc_assert(lhs != NULL_TREE);
104106 + return lhs;
104107 +}
104108 +
104109 +static tree cast_to_TI_type(gimple stmt, tree node)
104110 +{
104111 + gimple_stmt_iterator gsi;
104112 + gimple cast_stmt;
104113 + tree type = TREE_TYPE(node);
104114 +
104115 + if (types_compatible_p(type, intTI_type_node))
104116 + return node;
104117 +
104118 + gsi = gsi_for_stmt(stmt);
104119 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
104120 + return gimple_get_lhs(cast_stmt);
104121 +}
104122 +
104123 +static void check_function_hash(const_gimple stmt)
104124 +{
104125 + tree func;
104126 + const struct size_overflow_hash *hash;
104127 +
104128 + if (gimple_code(stmt) != GIMPLE_CALL)
104129 + return;
104130 +
104131 + func = gimple_call_fndecl(stmt);
104132 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
104133 + if (func == NULL_TREE)
104134 + return;
104135 +
104136 + hash = get_function_hash(func);
104137 + if (!hash)
104138 + print_missing_msg(func, 0);
104139 +}
104140 +
104141 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
104142 +{
104143 + tree lhs, new_lhs;
104144 + gimple_stmt_iterator gsi;
104145 +
104146 + if (rhs1 == NULL_TREE) {
104147 + debug_gimple_stmt(oldstmt);
104148 + error("%s: rhs1 is NULL_TREE", __func__);
104149 + gcc_unreachable();
104150 + }
104151 +
104152 + switch (gimple_code(oldstmt)) {
104153 + case GIMPLE_ASM:
104154 + lhs = rhs1;
104155 + break;
104156 + case GIMPLE_CALL:
104157 + lhs = gimple_call_lhs(oldstmt);
104158 + break;
104159 + case GIMPLE_ASSIGN:
104160 + lhs = gimple_get_lhs(oldstmt);
104161 + break;
104162 + default:
104163 + debug_gimple_stmt(oldstmt);
104164 + gcc_unreachable();
104165 + }
104166 +
104167 + gsi = gsi_for_stmt(oldstmt);
104168 + pointer_set_insert(visited, oldstmt);
104169 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
104170 + basic_block next_bb, cur_bb;
104171 + const_edge e;
104172 +
104173 + gcc_assert(before == false);
104174 + gcc_assert(stmt_can_throw_internal(oldstmt));
104175 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
104176 + gcc_assert(!gsi_end_p(gsi));
104177 +
104178 + cur_bb = gimple_bb(oldstmt);
104179 + next_bb = cur_bb->next_bb;
104180 + e = find_edge(cur_bb, next_bb);
104181 + gcc_assert(e != NULL);
104182 + gcc_assert(e->flags & EDGE_FALLTHRU);
104183 +
104184 + gsi = gsi_after_labels(next_bb);
104185 + gcc_assert(!gsi_end_p(gsi));
104186 +
104187 + before = true;
104188 + oldstmt = gsi_stmt(gsi);
104189 + }
104190 +
104191 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
104192 + return new_lhs;
104193 +}
104194 +
104195 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
104196 +{
104197 + gimple stmt;
104198 + gimple_stmt_iterator gsi;
104199 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
104200 +
104201 + if (gimple_plf(oldstmt, MY_STMT))
104202 + return lhs;
104203 +
104204 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
104205 + rhs1 = gimple_assign_rhs1(oldstmt);
104206 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
104207 + }
104208 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
104209 + rhs2 = gimple_assign_rhs2(oldstmt);
104210 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
104211 + }
104212 +
104213 + stmt = gimple_copy(oldstmt);
104214 + gimple_set_location(stmt, gimple_location(oldstmt));
104215 + gimple_set_plf(stmt, MY_STMT, true);
104216 +
104217 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
104218 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
104219 +
104220 + size_overflow_type = get_size_overflow_type(oldstmt, node);
104221 +
104222 + new_var = create_new_var(size_overflow_type);
104223 + new_var = make_ssa_name(new_var, stmt);
104224 + gimple_set_lhs(stmt, new_var);
104225 +
104226 + if (rhs1 != NULL_TREE)
104227 + gimple_assign_set_rhs1(stmt, rhs1);
104228 +
104229 + if (rhs2 != NULL_TREE)
104230 + gimple_assign_set_rhs2(stmt, rhs2);
104231 +#if BUILDING_GCC_VERSION >= 4007
104232 + if (rhs3 != NULL_TREE)
104233 + gimple_assign_set_rhs3(stmt, rhs3);
104234 +#endif
104235 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
104236 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
104237 +
104238 + gsi = gsi_for_stmt(oldstmt);
104239 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
104240 + update_stmt(stmt);
104241 + pointer_set_insert(visited, oldstmt);
104242 + return gimple_get_lhs(stmt);
104243 +}
104244 +
104245 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
104246 +{
104247 + basic_block first_bb;
104248 + gimple assign;
104249 + gimple_stmt_iterator gsi;
104250 +
104251 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104252 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
104253 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
104254 +
104255 + gsi = gsi_start_bb(first_bb);
104256 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
104257 + return gimple_get_lhs(assign);
104258 +}
104259 +
104260 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
104261 +{
104262 + gimple_stmt_iterator gsi;
104263 + const_gimple assign;
104264 + gimple def_stmt = get_def_stmt(new_arg);
104265 +
104266 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
104267 + gsi = gsi_after_labels(gimple_bb(def_stmt));
104268 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
104269 + } else {
104270 + gsi = gsi_for_stmt(def_stmt);
104271 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
104272 + }
104273 +
104274 + return gimple_get_lhs(assign);
104275 +}
104276 +
104277 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
104278 +{
104279 + basic_block bb;
104280 + gimple_stmt_iterator gsi;
104281 + const_gimple assign, def_stmt;
104282 +
104283 + def_stmt = get_def_stmt(arg);
104284 + bb = gimple_bb(def_stmt);
104285 + gcc_assert(bb->index != 0);
104286 + gsi = gsi_after_labels(bb);
104287 +
104288 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
104289 + return gimple_get_lhs(assign);
104290 +}
104291 +
104292 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
104293 +{
104294 + tree size_overflow_type;
104295 + const_gimple def_stmt = get_def_stmt(arg);
104296 +
104297 + if (phi_ssa_name != NULL_TREE)
104298 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
104299 +
104300 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
104301 +
104302 + if (new_arg != NULL_TREE) {
104303 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
104304 + return use_phi_ssa_name(phi_ssa_name, new_arg);
104305 + }
104306 +
104307 + switch(gimple_code(def_stmt)) {
104308 + case GIMPLE_PHI:
104309 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
104310 + case GIMPLE_NOP:
104311 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
104312 + default:
104313 + debug_gimple_stmt((gimple)def_stmt);
104314 + gcc_unreachable();
104315 + }
104316 +}
104317 +
104318 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
104319 +{
104320 + basic_block bb;
104321 + gimple phi;
104322 + gimple_seq seq;
104323 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
104324 +
104325 + bb = gsi_bb(gsi);
104326 +
104327 + phi = create_phi_node(result, bb);
104328 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
104329 + seq = phi_nodes(bb);
104330 + gsi = gsi_last(seq);
104331 + gsi_remove(&gsi, false);
104332 +
104333 + gsi = gsi_for_stmt(oldstmt);
104334 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
104335 + gimple_set_bb(phi, bb);
104336 + gimple_set_plf(phi, MY_STMT, true);
104337 + return phi;
104338 +}
104339 +
104340 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
104341 +{
104342 + gimple new_phi = NULL;
104343 + gimple oldstmt = get_def_stmt(orig_result);
104344 + tree phi_ssa_name = NULL_TREE;
104345 + unsigned int i;
104346 +
104347 + pointer_set_insert(visited, oldstmt);
104348 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
104349 + tree arg, new_arg;
104350 +
104351 + arg = gimple_phi_arg_def(oldstmt, i);
104352 +
104353 + new_arg = expand(visited, arg);
104354 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
104355 + if (i == 0) {
104356 + phi_ssa_name = new_arg;
104357 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
104358 + }
104359 +
104360 + gcc_assert(new_phi != NULL);
104361 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
104362 + }
104363 +
104364 + gcc_assert(new_phi != NULL);
104365 + update_stmt(new_phi);
104366 + return gimple_phi_result(new_phi);
104367 +}
104368 +
104369 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
104370 +{
104371 + const_gimple assign;
104372 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
104373 + tree origtype = TREE_TYPE(orig_rhs);
104374 +
104375 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
104376 +
104377 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
104378 + return gimple_get_lhs(assign);
104379 +}
104380 +
104381 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
104382 +{
104383 + const_tree rhs1, lhs, rhs1_type, lhs_type;
104384 + enum machine_mode lhs_mode, rhs_mode;
104385 + gimple def_stmt = get_def_stmt(no_const_rhs);
104386 +
104387 + if (!gimple_assign_cast_p(def_stmt))
104388 + return false;
104389 +
104390 + rhs1 = gimple_assign_rhs1(def_stmt);
104391 + lhs = gimple_get_lhs(def_stmt);
104392 + rhs1_type = TREE_TYPE(rhs1);
104393 + lhs_type = TREE_TYPE(lhs);
104394 + rhs_mode = TYPE_MODE(rhs1_type);
104395 + lhs_mode = TYPE_MODE(lhs_type);
104396 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
104397 + return false;
104398 +
104399 + return true;
104400 +}
104401 +
104402 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
104403 +{
104404 + tree rhs1 = gimple_assign_rhs1(stmt);
104405 + tree lhs = gimple_get_lhs(stmt);
104406 + const_tree rhs1_type = TREE_TYPE(rhs1);
104407 + const_tree lhs_type = TREE_TYPE(lhs);
104408 +
104409 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
104410 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104411 +
104412 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
104413 +}
104414 +
104415 +static bool no_uses(tree node)
104416 +{
104417 + imm_use_iterator imm_iter;
104418 + use_operand_p use_p;
104419 +
104420 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
104421 + const_gimple use_stmt = USE_STMT(use_p);
104422 + if (use_stmt == NULL)
104423 + return true;
104424 + if (is_gimple_debug(use_stmt))
104425 + continue;
104426 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
104427 + continue;
104428 + return false;
104429 + }
104430 + return true;
104431 +}
104432 +
104433 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
104434 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
104435 +{
104436 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
104437 + gimple def_stmt = get_def_stmt(lhs);
104438 +
104439 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
104440 + return false;
104441 +
104442 + rhs1 = gimple_assign_rhs1(def_stmt);
104443 + rhs_type = TREE_TYPE(rhs1);
104444 + lhs_type = TREE_TYPE(lhs);
104445 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
104446 + return false;
104447 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
104448 + return false;
104449 +
104450 + def_stmt = get_def_stmt(rhs1);
104451 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
104452 + return false;
104453 +
104454 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
104455 + return false;
104456 +
104457 + rhs1 = gimple_assign_rhs1(def_stmt);
104458 + rhs2 = gimple_assign_rhs2(def_stmt);
104459 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
104460 + return false;
104461 +
104462 + if (is_gimple_constant(rhs2))
104463 + not_const_rhs = rhs1;
104464 + else
104465 + not_const_rhs = rhs2;
104466 +
104467 + return no_uses(not_const_rhs);
104468 +}
104469 +
104470 +static bool skip_lhs_cast_check(const_gimple stmt)
104471 +{
104472 + const_tree rhs = gimple_assign_rhs1(stmt);
104473 + const_gimple def_stmt = get_def_stmt(rhs);
104474 +
104475 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
104476 + if (gimple_code(def_stmt) == GIMPLE_ASM)
104477 + return true;
104478 +
104479 + if (is_const_plus_unsigned_signed_truncation(rhs))
104480 + return true;
104481 +
104482 + return false;
104483 +}
104484 +
104485 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
104486 +{
104487 + bool cast_lhs, cast_rhs;
104488 + tree lhs = gimple_get_lhs(stmt);
104489 + tree rhs = gimple_assign_rhs1(stmt);
104490 + const_tree lhs_type = TREE_TYPE(lhs);
104491 + const_tree rhs_type = TREE_TYPE(rhs);
104492 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
104493 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
104494 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
104495 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
104496 +
104497 + static bool check_lhs[3][4] = {
104498 + // ss su us uu
104499 + { false, true, true, false }, // lhs > rhs
104500 + { false, false, false, false }, // lhs = rhs
104501 + { true, true, true, true }, // lhs < rhs
104502 + };
104503 +
104504 + static bool check_rhs[3][4] = {
104505 + // ss su us uu
104506 + { true, false, true, true }, // lhs > rhs
104507 + { true, false, true, true }, // lhs = rhs
104508 + { true, false, true, true }, // lhs < rhs
104509 + };
104510 +
104511 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
104512 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
104513 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104514 +
104515 + if (lhs_size > rhs_size) {
104516 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104517 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104518 + } else if (lhs_size == rhs_size) {
104519 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104520 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104521 + } else {
104522 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104523 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104524 + }
104525 +
104526 + if (!cast_lhs && !cast_rhs)
104527 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104528 +
104529 + if (cast_lhs && !skip_lhs_cast_check(stmt))
104530 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
104531 +
104532 + if (cast_rhs)
104533 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
104534 +
104535 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104536 +}
104537 +
104538 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
104539 +{
104540 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
104541 +
104542 + if (gimple_plf(stmt, MY_STMT))
104543 + return lhs;
104544 +
104545 + rhs1 = gimple_assign_rhs1(stmt);
104546 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
104547 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104548 +
104549 + new_rhs1 = expand(visited, rhs1);
104550 +
104551 + if (new_rhs1 == NULL_TREE)
104552 + return create_cast_assign(visited, stmt);
104553 +
104554 + if (gimple_plf(stmt, NO_CAST_CHECK))
104555 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104556 +
104557 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
104558 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
104559 +
104560 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
104561 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
104562 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104563 + }
104564 +
104565 + if (!gimple_assign_cast_p(stmt))
104566 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104567 +
104568 + return create_cast_overflow_check(visited, new_rhs1, stmt);
104569 +}
104570 +
104571 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
104572 +{
104573 + tree rhs1, lhs = gimple_get_lhs(stmt);
104574 + gimple def_stmt = get_def_stmt(lhs);
104575 +
104576 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
104577 + rhs1 = gimple_assign_rhs1(def_stmt);
104578 +
104579 + if (is_gimple_constant(rhs1))
104580 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
104581 +
104582 + switch (TREE_CODE(rhs1)) {
104583 + case SSA_NAME:
104584 + return handle_unary_rhs(visited, def_stmt);
104585 + case ARRAY_REF:
104586 + case BIT_FIELD_REF:
104587 + case ADDR_EXPR:
104588 + case COMPONENT_REF:
104589 + case INDIRECT_REF:
104590 +#if BUILDING_GCC_VERSION >= 4006
104591 + case MEM_REF:
104592 +#endif
104593 + case TARGET_MEM_REF:
104594 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
104595 + case PARM_DECL:
104596 + case VAR_DECL:
104597 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104598 +
104599 + default:
104600 + debug_gimple_stmt(def_stmt);
104601 + debug_tree(rhs1);
104602 + gcc_unreachable();
104603 + }
104604 +}
104605 +
104606 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
104607 +{
104608 + gimple cond_stmt;
104609 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
104610 +
104611 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
104612 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
104613 + update_stmt(cond_stmt);
104614 +}
104615 +
104616 +static tree create_string_param(tree string)
104617 +{
104618 + tree i_type, a_type;
104619 + const int length = TREE_STRING_LENGTH(string);
104620 +
104621 + gcc_assert(length > 0);
104622 +
104623 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
104624 + a_type = build_array_type(char_type_node, i_type);
104625 +
104626 + TREE_TYPE(string) = a_type;
104627 + TREE_CONSTANT(string) = 1;
104628 + TREE_READONLY(string) = 1;
104629 +
104630 + return build1(ADDR_EXPR, ptr_type_node, string);
104631 +}
104632 +
104633 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
104634 +{
104635 + gimple func_stmt;
104636 + const_gimple def_stmt;
104637 + const_tree loc_line;
104638 + tree loc_file, ssa_name, current_func;
104639 + expanded_location xloc;
104640 + char *ssa_name_buf;
104641 + int len;
104642 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
104643 +
104644 + def_stmt = get_def_stmt(arg);
104645 + xloc = expand_location(gimple_location(def_stmt));
104646 +
104647 + if (!gimple_has_location(def_stmt)) {
104648 + xloc = expand_location(gimple_location(stmt));
104649 + if (!gimple_has_location(stmt))
104650 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
104651 + }
104652 +
104653 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
104654 +
104655 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
104656 + loc_file = create_string_param(loc_file);
104657 +
104658 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
104659 + current_func = create_string_param(current_func);
104660 +
104661 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
104662 + call_count++;
104663 + len = asprintf(&ssa_name_buf, "%s_%u %s, count: %u\n", NAME(SSA_NAME_VAR(arg)), SSA_NAME_VERSION(arg), min ? "min" : "max", call_count);
104664 + gcc_assert(len > 0);
104665 + ssa_name = build_string(len + 1, ssa_name_buf);
104666 + free(ssa_name_buf);
104667 + ssa_name = create_string_param(ssa_name);
104668 +
104669 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
104670 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
104671 +
104672 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
104673 +}
104674 +
104675 +static void __unused print_the_code_insertions(const_gimple stmt)
104676 +{
104677 + location_t loc = gimple_location(stmt);
104678 +
104679 + inform(loc, "Integer size_overflow check applied here.");
104680 +}
104681 +
104682 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
104683 +{
104684 + basic_block cond_bb, join_bb, bb_true;
104685 + edge e;
104686 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
104687 +
104688 + cond_bb = gimple_bb(stmt);
104689 + if (before)
104690 + gsi_prev(&gsi);
104691 + if (gsi_end_p(gsi))
104692 + e = split_block_after_labels(cond_bb);
104693 + else
104694 + e = split_block(cond_bb, gsi_stmt(gsi));
104695 + cond_bb = e->src;
104696 + join_bb = e->dest;
104697 + e->flags = EDGE_FALSE_VALUE;
104698 + e->probability = REG_BR_PROB_BASE;
104699 +
104700 + bb_true = create_empty_bb(cond_bb);
104701 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
104702 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
104703 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
104704 +
104705 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
104706 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
104707 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
104708 +
104709 + if (current_loops != NULL) {
104710 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
104711 + add_bb_to_loop(bb_true, cond_bb->loop_father);
104712 + }
104713 +
104714 + insert_cond(cond_bb, arg, cond_code, type_value);
104715 + insert_cond_result(bb_true, stmt, arg, min);
104716 +
104717 +// print_the_code_insertions(stmt);
104718 +}
104719 +
104720 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
104721 +{
104722 + const_tree rhs_type = TREE_TYPE(rhs);
104723 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
104724 +
104725 + gcc_assert(rhs_type != NULL_TREE);
104726 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
104727 + return;
104728 +
104729 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
104730 +
104731 + if (is_const_plus_unsigned_signed_truncation(rhs))
104732 + return;
104733 +
104734 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
104735 + // typemax (-1) < typemin (0)
104736 + if (TREE_OVERFLOW(type_max))
104737 + return;
104738 +
104739 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
104740 +
104741 + cast_rhs_type = TREE_TYPE(cast_rhs);
104742 + type_max_type = TREE_TYPE(type_max);
104743 + type_min_type = TREE_TYPE(type_min);
104744 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
104745 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
104746 +
104747 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
104748 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
104749 +}
104750 +
104751 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
104752 +{
104753 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
104754 + return false;
104755 + if (!is_gimple_constant(rhs))
104756 + return false;
104757 + return true;
104758 +}
104759 +
104760 +static tree get_def_stmt_rhs(const_tree var)
104761 +{
104762 + tree rhs1, def_stmt_rhs1;
104763 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
104764 +
104765 + def_stmt = get_def_stmt(var);
104766 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
104767 +
104768 + rhs1 = gimple_assign_rhs1(def_stmt);
104769 + rhs1_def_stmt = get_def_stmt(rhs1);
104770 + if (!gimple_assign_cast_p(rhs1_def_stmt))
104771 + return rhs1;
104772 +
104773 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
104774 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
104775 +
104776 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
104777 + case GIMPLE_CALL:
104778 + case GIMPLE_NOP:
104779 + case GIMPLE_ASM:
104780 + case GIMPLE_PHI:
104781 + return def_stmt_rhs1;
104782 + case GIMPLE_ASSIGN:
104783 + return rhs1;
104784 + default:
104785 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
104786 + gcc_unreachable();
104787 + }
104788 +}
104789 +
104790 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
104791 +{
104792 + tree new_rhs, orig_rhs;
104793 + void (*gimple_assign_set_rhs)(gimple, tree);
104794 + tree rhs1 = gimple_assign_rhs1(stmt);
104795 + tree rhs2 = gimple_assign_rhs2(stmt);
104796 + tree lhs = gimple_get_lhs(stmt);
104797 +
104798 + if (!check_overflow)
104799 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104800 +
104801 + if (change_rhs == NULL_TREE)
104802 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104803 +
104804 + if (new_rhs2 == NULL_TREE) {
104805 + orig_rhs = rhs1;
104806 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
104807 + } else {
104808 + orig_rhs = rhs2;
104809 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
104810 + }
104811 +
104812 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
104813 +
104814 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
104815 + gimple_assign_set_rhs(stmt, new_rhs);
104816 + update_stmt(stmt);
104817 +
104818 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104819 +}
104820 +
104821 +static bool is_subtraction_special(const_gimple stmt)
104822 +{
104823 + gimple rhs1_def_stmt, rhs2_def_stmt;
104824 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
104825 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
104826 + const_tree rhs1 = gimple_assign_rhs1(stmt);
104827 + const_tree rhs2 = gimple_assign_rhs2(stmt);
104828 +
104829 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
104830 + return false;
104831 +
104832 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
104833 +
104834 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
104835 + return false;
104836 +
104837 + rhs1_def_stmt = get_def_stmt(rhs1);
104838 + rhs2_def_stmt = get_def_stmt(rhs2);
104839 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
104840 + return false;
104841 +
104842 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
104843 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
104844 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
104845 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
104846 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
104847 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
104848 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
104849 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
104850 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
104851 + return false;
104852 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
104853 + return false;
104854 +
104855 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
104856 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
104857 + return true;
104858 +}
104859 +
104860 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
104861 +{
104862 + tree new_rhs1, new_rhs2;
104863 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
104864 + gimple assign, stmt = get_def_stmt(lhs);
104865 + tree rhs1 = gimple_assign_rhs1(stmt);
104866 + tree rhs2 = gimple_assign_rhs2(stmt);
104867 +
104868 + if (!is_subtraction_special(stmt))
104869 + return NULL_TREE;
104870 +
104871 + new_rhs1 = expand(visited, rhs1);
104872 + new_rhs2 = expand(visited, rhs2);
104873 +
104874 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
104875 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
104876 +
104877 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
104878 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
104879 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
104880 + }
104881 +
104882 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
104883 + new_lhs = gimple_get_lhs(assign);
104884 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
104885 +
104886 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
104887 +}
104888 +
104889 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
104890 +{
104891 + const_gimple def_stmt;
104892 +
104893 + if (TREE_CODE(rhs) != SSA_NAME)
104894 + return false;
104895 +
104896 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
104897 + return false;
104898 +
104899 + def_stmt = get_def_stmt(rhs);
104900 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
104901 + return false;
104902 +
104903 + return true;
104904 +}
104905 +
104906 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
104907 +{
104908 + tree rhs1, rhs2, new_lhs;
104909 + gimple def_stmt = get_def_stmt(lhs);
104910 + tree new_rhs1 = NULL_TREE;
104911 + tree new_rhs2 = NULL_TREE;
104912 +
104913 + rhs1 = gimple_assign_rhs1(def_stmt);
104914 + rhs2 = gimple_assign_rhs2(def_stmt);
104915 +
104916 + /* no DImode/TImode division in the 32/64 bit kernel */
104917 + switch (gimple_assign_rhs_code(def_stmt)) {
104918 + case RDIV_EXPR:
104919 + case TRUNC_DIV_EXPR:
104920 + case CEIL_DIV_EXPR:
104921 + case FLOOR_DIV_EXPR:
104922 + case ROUND_DIV_EXPR:
104923 + case TRUNC_MOD_EXPR:
104924 + case CEIL_MOD_EXPR:
104925 + case FLOOR_MOD_EXPR:
104926 + case ROUND_MOD_EXPR:
104927 + case EXACT_DIV_EXPR:
104928 + case POINTER_PLUS_EXPR:
104929 + case BIT_AND_EXPR:
104930 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
104931 + default:
104932 + break;
104933 + }
104934 +
104935 + new_lhs = handle_integer_truncation(visited, lhs);
104936 + if (new_lhs != NULL_TREE)
104937 + return new_lhs;
104938 +
104939 + if (TREE_CODE(rhs1) == SSA_NAME)
104940 + new_rhs1 = expand(visited, rhs1);
104941 + if (TREE_CODE(rhs2) == SSA_NAME)
104942 + new_rhs2 = expand(visited, rhs2);
104943 +
104944 + if (is_a_neg_overflow(def_stmt, rhs2))
104945 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
104946 + if (is_a_neg_overflow(def_stmt, rhs1))
104947 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
104948 +
104949 +
104950 + if (is_a_constant_overflow(def_stmt, rhs2))
104951 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
104952 + if (is_a_constant_overflow(def_stmt, rhs1))
104953 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
104954 +
104955 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
104956 +}
104957 +
104958 +#if BUILDING_GCC_VERSION >= 4007
104959 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
104960 +{
104961 + if (is_gimple_constant(rhs))
104962 + return cast_a_tree(size_overflow_type, rhs);
104963 + if (TREE_CODE(rhs) != SSA_NAME)
104964 + return NULL_TREE;
104965 + return expand(visited, rhs);
104966 +}
104967 +
104968 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
104969 +{
104970 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
104971 + gimple def_stmt = get_def_stmt(lhs);
104972 +
104973 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
104974 +
104975 + rhs1 = gimple_assign_rhs1(def_stmt);
104976 + rhs2 = gimple_assign_rhs2(def_stmt);
104977 + rhs3 = gimple_assign_rhs3(def_stmt);
104978 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
104979 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
104980 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
104981 +
104982 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
104983 +}
104984 +#endif
104985 +
104986 +static tree get_size_overflow_type(gimple stmt, const_tree node)
104987 +{
104988 + const_tree type;
104989 + tree new_type;
104990 +
104991 + gcc_assert(node != NULL_TREE);
104992 +
104993 + type = TREE_TYPE(node);
104994 +
104995 + if (gimple_plf(stmt, MY_STMT))
104996 + return TREE_TYPE(node);
104997 +
104998 + switch (TYPE_MODE(type)) {
104999 + case QImode:
105000 + new_type = intHI_type_node;
105001 + break;
105002 + case HImode:
105003 + new_type = intSI_type_node;
105004 + break;
105005 + case SImode:
105006 + new_type = intDI_type_node;
105007 + break;
105008 + case DImode:
105009 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
105010 + new_type = intDI_type_node;
105011 + else
105012 + new_type = intTI_type_node;
105013 + break;
105014 + default:
105015 + debug_tree((tree)node);
105016 + error("%s: unsupported gcc configuration.", __func__);
105017 + gcc_unreachable();
105018 + }
105019 +
105020 + if (TYPE_QUALS(type) != 0)
105021 + return build_qualified_type(new_type, TYPE_QUALS(type));
105022 + return new_type;
105023 +}
105024 +
105025 +static tree expand_visited(gimple def_stmt)
105026 +{
105027 + const_gimple next_stmt;
105028 + gimple_stmt_iterator gsi;
105029 + enum gimple_code code = gimple_code(def_stmt);
105030 +
105031 + if (code == GIMPLE_ASM)
105032 + return NULL_TREE;
105033 +
105034 + gsi = gsi_for_stmt(def_stmt);
105035 + gsi_next(&gsi);
105036 +
105037 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
105038 + return NULL_TREE;
105039 + gcc_assert(!gsi_end_p(gsi));
105040 + next_stmt = gsi_stmt(gsi);
105041 +
105042 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
105043 + return NULL_TREE;
105044 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
105045 +
105046 + return get_lhs(next_stmt);
105047 +}
105048 +
105049 +static tree expand(struct pointer_set_t *visited, tree lhs)
105050 +{
105051 + gimple def_stmt;
105052 +
105053 + if (skip_types(lhs))
105054 + return NULL_TREE;
105055 +
105056 + def_stmt = get_def_stmt(lhs);
105057 +
105058 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
105059 + return NULL_TREE;
105060 +
105061 + if (gimple_plf(def_stmt, MY_STMT))
105062 + return lhs;
105063 +
105064 + if (pointer_set_contains(visited, def_stmt))
105065 + return expand_visited(def_stmt);
105066 +
105067 + switch (gimple_code(def_stmt)) {
105068 + case GIMPLE_PHI:
105069 + return handle_phi(visited, lhs);
105070 + case GIMPLE_CALL:
105071 + case GIMPLE_ASM:
105072 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
105073 + case GIMPLE_ASSIGN:
105074 + switch (gimple_num_ops(def_stmt)) {
105075 + case 2:
105076 + return handle_unary_ops(visited, def_stmt);
105077 + case 3:
105078 + return handle_binary_ops(visited, lhs);
105079 +#if BUILDING_GCC_VERSION >= 4007
105080 + case 4:
105081 + return handle_ternary_ops(visited, lhs);
105082 +#endif
105083 + }
105084 + default:
105085 + debug_gimple_stmt(def_stmt);
105086 + error("%s: unknown gimple code", __func__);
105087 + gcc_unreachable();
105088 + }
105089 +}
105090 +
105091 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
105092 +{
105093 + const_gimple assign;
105094 + tree orig_type = TREE_TYPE(orig_node);
105095 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
105096 +
105097 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
105098 + return gimple_get_lhs(assign);
105099 +}
105100 +
105101 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
105102 +{
105103 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
105104 + update_stmt(stmt);
105105 +}
105106 +
105107 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
105108 +{
105109 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
105110 + update_stmt(stmt);
105111 +}
105112 +
105113 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
105114 +{
105115 + tree arg;
105116 + const_tree origarg;
105117 +
105118 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
105119 + return true;
105120 +
105121 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
105122 + while (origarg && *argnum) {
105123 + (*argnum)--;
105124 + origarg = TREE_CHAIN(origarg);
105125 + }
105126 +
105127 + gcc_assert(*argnum == 0);
105128 +
105129 + gcc_assert(origarg != NULL_TREE);
105130 + *argnum = 0;
105131 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
105132 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
105133 + return true;
105134 + return false;
105135 +}
105136 +
105137 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
105138 +{
105139 + gimple phi = get_def_stmt(result);
105140 + unsigned int i, n = gimple_phi_num_args(phi);
105141 +
105142 + if (!phi)
105143 + return MARK_NO;
105144 +
105145 + pointer_set_insert(visited, phi);
105146 + for (i = 0; i < n; i++) {
105147 + enum mark marked;
105148 + const_tree arg = gimple_phi_arg_def(phi, i);
105149 + marked = pre_expand(visited, search_err_code, arg);
105150 + if (marked != MARK_NO)
105151 + return marked;
105152 + }
105153 + return MARK_NO;
105154 +}
105155 +
105156 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
105157 +{
105158 + gimple def_stmt = get_def_stmt(lhs);
105159 + const_tree rhs;
105160 +
105161 + if (!def_stmt)
105162 + return MARK_NO;
105163 +
105164 + rhs = gimple_assign_rhs1(def_stmt);
105165 +
105166 + def_stmt = get_def_stmt(rhs);
105167 + if (is_gimple_constant(rhs))
105168 + search_err_code[FROM_CONST] = true;
105169 +
105170 + return pre_expand(visited, search_err_code, rhs);
105171 +}
105172 +
105173 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
105174 +{
105175 + gimple def_stmt = get_def_stmt(lhs);
105176 + const_tree rhs1, rhs2;
105177 + enum mark marked;
105178 +
105179 + if (!def_stmt)
105180 + return MARK_NO;
105181 +
105182 + search_err_code[CAST_ONLY] = false;
105183 +
105184 + rhs1 = gimple_assign_rhs1(def_stmt);
105185 + rhs2 = gimple_assign_rhs2(def_stmt);
105186 + marked = pre_expand(visited, search_err_code, rhs1);
105187 + if (marked != MARK_NO)
105188 + return marked;
105189 + return pre_expand(visited, search_err_code, rhs2);
105190 +}
105191 +
105192 +static const_tree search_field_decl(const_tree comp_ref)
105193 +{
105194 + const_tree field = NULL_TREE;
105195 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
105196 +
105197 + for (i = 0; i < len; i++) {
105198 + field = TREE_OPERAND(comp_ref, i);
105199 + if (TREE_CODE(field) == FIELD_DECL)
105200 + break;
105201 + }
105202 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
105203 + return field;
105204 +}
105205 +
105206 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
105207 +{
105208 + const_tree attr, p;
105209 +
105210 + // mm/filemap.c D.35286_51 = D.35283_46 (file_10(D), mapping_11, pos_1, D.35273_50, D.35285_49, page.14_48, fsdata.15_47);
105211 + if (fndecl == NULL_TREE)
105212 + return MARK_NO;
105213 +
105214 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
105215 + if (!attr || !TREE_VALUE(attr))
105216 + return MARK_NO;
105217 +
105218 + p = TREE_VALUE(attr);
105219 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
105220 + return MARK_TURN_OFF;
105221 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
105222 + return MARK_NOT_INTENTIONAL;
105223 + if (argnum == 0) {
105224 + gcc_assert(current_function_decl == fndecl);
105225 + return MARK_NO;
105226 + }
105227 +
105228 + do {
105229 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
105230 + return MARK_YES;
105231 + p = TREE_CHAIN(p);
105232 + } while (p);
105233 +
105234 + return MARK_NO;
105235 +}
105236 +
105237 +static void print_missing_msg(tree func, unsigned int argnum)
105238 +{
105239 + unsigned int new_hash;
105240 + size_t len;
105241 + unsigned char tree_codes[CODES_LIMIT];
105242 + location_t loc;
105243 + const char *curfunc;
105244 +
105245 + func = get_original_function_decl(func);
105246 + loc = DECL_SOURCE_LOCATION(func);
105247 + curfunc = get_asm_name(func);
105248 +
105249 + len = get_function_decl(func, tree_codes);
105250 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
105251 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
105252 +}
105253 +
105254 +static unsigned int search_missing_attribute(const_tree arg)
105255 +{
105256 + unsigned int argnum;
105257 + const struct size_overflow_hash *hash;
105258 + const_tree type = TREE_TYPE(arg);
105259 + tree func = get_original_function_decl(current_function_decl);
105260 +
105261 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
105262 +
105263 + if (TREE_CODE(type) == POINTER_TYPE)
105264 + return 0;
105265 +
105266 + argnum = find_arg_number(arg, func);
105267 + if (argnum == 0)
105268 + return 0;
105269 +
105270 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
105271 + return argnum;
105272 +
105273 + hash = get_function_hash(func);
105274 + if (!hash || !(hash->param & (1U << argnum))) {
105275 + print_missing_msg(func, argnum);
105276 + return 0;
105277 + }
105278 + return argnum;
105279 +}
105280 +
105281 +static enum mark is_already_marked(const_tree lhs)
105282 +{
105283 + unsigned int argnum;
105284 + const_tree fndecl;
105285 +
105286 + argnum = search_missing_attribute(lhs);
105287 + fndecl = get_original_function_decl(current_function_decl);
105288 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
105289 + return MARK_YES;
105290 + return MARK_NO;
105291 +}
105292 +
105293 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
105294 +{
105295 + const_gimple def_stmt;
105296 +
105297 + if (skip_types(lhs))
105298 + return MARK_NO;
105299 +
105300 + if (TREE_CODE(lhs) == PARM_DECL)
105301 + return is_already_marked(lhs);
105302 +
105303 + if (TREE_CODE(lhs) == COMPONENT_REF) {
105304 + const_tree field, attr;
105305 +
105306 + field = search_field_decl(lhs);
105307 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
105308 + if (!attr || !TREE_VALUE(attr))
105309 + return MARK_NO;
105310 + return MARK_YES;
105311 + }
105312 +
105313 + def_stmt = get_def_stmt(lhs);
105314 +
105315 + if (!def_stmt)
105316 + return MARK_NO;
105317 +
105318 + if (pointer_set_contains(visited, def_stmt))
105319 + return MARK_NO;
105320 +
105321 + switch (gimple_code(def_stmt)) {
105322 + case GIMPLE_NOP:
105323 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
105324 + return is_already_marked(lhs);
105325 + return MARK_NO;
105326 + case GIMPLE_PHI:
105327 + return walk_phi(visited, search_err_code, lhs);
105328 + case GIMPLE_CALL:
105329 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
105330 + return MARK_TURN_OFF;
105331 + check_function_hash(def_stmt);
105332 + return MARK_NO;
105333 + case GIMPLE_ASM:
105334 + search_err_code[CAST_ONLY] = false;
105335 + return MARK_NO;
105336 + case GIMPLE_ASSIGN:
105337 + switch (gimple_num_ops(def_stmt)) {
105338 + case 2:
105339 + return walk_unary_ops(visited, search_err_code, lhs);
105340 + case 3:
105341 + return walk_binary_ops(visited, search_err_code, lhs);
105342 + }
105343 + default:
105344 + debug_gimple_stmt((gimple)def_stmt);
105345 + error("%s: unknown gimple code", __func__);
105346 + gcc_unreachable();
105347 + }
105348 +}
105349 +
105350 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
105351 +static bool skip_asm(const_tree arg)
105352 +{
105353 + gimple def_stmt = get_def_stmt(arg);
105354 +
105355 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
105356 + return false;
105357 +
105358 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
105359 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
105360 +}
105361 +
105362 +/*
105363 +0</MARK_YES: no dup, search attributes (so, int)
105364 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
105365 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
105366 +*/
105367 +
105368 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
105369 +{
105370 + struct pointer_set_t *visited;
105371 + enum mark is_marked, is_found;
105372 + location_t loc;
105373 + bool search_err_code[2] = {true, false};
105374 +
105375 + is_marked = mark_status(current_function_decl, 0);
105376 + if (is_marked == MARK_TURN_OFF)
105377 + return true;
105378 +
105379 + is_marked = mark_status(fndecl, argnum + 1);
105380 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
105381 + return true;
105382 +
105383 + visited = pointer_set_create();
105384 + is_found = pre_expand(visited, search_err_code, arg);
105385 + pointer_set_destroy(visited);
105386 +
105387 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
105388 + return true;
105389 +
105390 + if (where == FROM_ARG && skip_asm(arg))
105391 + return true;
105392 +
105393 + if (is_found == MARK_TURN_OFF)
105394 + return true;
105395 +
105396 + if ((is_found == MARK_YES && is_marked == MARK_YES))
105397 + return true;
105398 +
105399 + if (is_found == MARK_YES) {
105400 + loc = DECL_SOURCE_LOCATION(fndecl);
105401 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
105402 + return true;
105403 + }
105404 + return false;
105405 +}
105406 +
105407 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
105408 +{
105409 + struct pointer_set_t *visited;
105410 + tree arg, new_arg;
105411 + bool match;
105412 +
105413 + if (argnum == 0)
105414 + return;
105415 +
105416 + argnum--;
105417 +
105418 + match = get_function_arg(&argnum, fndecl);
105419 + if (!match)
105420 + return;
105421 + gcc_assert(gimple_call_num_args(stmt) > argnum);
105422 + arg = gimple_call_arg(stmt, argnum);
105423 + if (arg == NULL_TREE)
105424 + return;
105425 +
105426 + if (skip_types(arg))
105427 + return;
105428 +
105429 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
105430 + return;
105431 +
105432 + visited = pointer_set_create();
105433 + new_arg = expand(visited, arg);
105434 + pointer_set_destroy(visited);
105435 +
105436 + if (new_arg == NULL_TREE)
105437 + return;
105438 +
105439 + change_function_arg(stmt, arg, argnum, new_arg);
105440 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
105441 +}
105442 +
105443 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
105444 +{
105445 + tree p = TREE_VALUE(attr);
105446 + do {
105447 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
105448 + p = TREE_CHAIN(p);
105449 + } while (p);
105450 +}
105451 +
105452 +static void handle_function_by_hash(gimple stmt, tree fndecl)
105453 +{
105454 + unsigned int num;
105455 + const struct size_overflow_hash *hash;
105456 +
105457 + hash = get_function_hash(fndecl);
105458 + if (!hash)
105459 + return;
105460 +
105461 + for (num = 0; num <= MAX_PARAM; num++)
105462 + if (hash->param & (1U << num))
105463 + handle_function_arg(stmt, fndecl, num);
105464 +}
105465 +
105466 +static bool check_return_value(void)
105467 +{
105468 + const struct size_overflow_hash *hash;
105469 +
105470 + hash = get_function_hash(current_function_decl);
105471 + if (!hash || !(hash->param & 1U << 0))
105472 + return false;
105473 +
105474 + return true;
105475 +}
105476 +
105477 +static void handle_return_value(gimple ret_stmt)
105478 +{
105479 + struct pointer_set_t *visited;
105480 + tree ret, new_ret;
105481 +
105482 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
105483 + return;
105484 +
105485 + ret = gimple_return_retval(ret_stmt);
105486 +
105487 + if (skip_types(ret))
105488 + return;
105489 +
105490 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
105491 + return;
105492 +
105493 + visited = pointer_set_create();
105494 + new_ret = expand(visited, ret);
105495 + pointer_set_destroy(visited);
105496 +
105497 + change_function_return(ret_stmt, ret, new_ret);
105498 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
105499 +}
105500 +
105501 +static void set_plf_false(void)
105502 +{
105503 + basic_block bb;
105504 +
105505 + FOR_ALL_BB(bb) {
105506 + gimple_stmt_iterator si;
105507 +
105508 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
105509 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
105510 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
105511 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
105512 + }
105513 +}
105514 +
105515 +static unsigned int handle_function(void)
105516 +{
105517 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
105518 + bool check_ret;
105519 +
105520 + set_plf_false();
105521 +
105522 + check_ret = check_return_value();
105523 +
105524 + do {
105525 + gimple_stmt_iterator gsi;
105526 + next = bb->next_bb;
105527 +
105528 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
105529 + tree fndecl, attr;
105530 + gimple stmt = gsi_stmt(gsi);
105531 +
105532 + if (check_ret)
105533 + handle_return_value(stmt);
105534 +
105535 + if (!(is_gimple_call(stmt)))
105536 + continue;
105537 + fndecl = gimple_call_fndecl(stmt);
105538 + if (fndecl == NULL_TREE)
105539 + continue;
105540 + if (gimple_call_num_args(stmt) == 0)
105541 + continue;
105542 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
105543 + if (!attr || !TREE_VALUE(attr))
105544 + handle_function_by_hash(stmt, fndecl);
105545 + else
105546 + handle_function_by_attribute(stmt, attr, fndecl);
105547 + gsi = gsi_for_stmt(stmt);
105548 + next = gimple_bb(stmt)->next_bb;
105549 + }
105550 + bb = next;
105551 + } while (bb);
105552 + return 0;
105553 +}
105554 +
105555 +static struct gimple_opt_pass size_overflow_pass = {
105556 + .pass = {
105557 + .type = GIMPLE_PASS,
105558 + .name = "size_overflow",
105559 +#if BUILDING_GCC_VERSION >= 4008
105560 + .optinfo_flags = OPTGROUP_NONE,
105561 +#endif
105562 + .gate = NULL,
105563 + .execute = handle_function,
105564 + .sub = NULL,
105565 + .next = NULL,
105566 + .static_pass_number = 0,
105567 + .tv_id = TV_NONE,
105568 + .properties_required = PROP_cfg,
105569 + .properties_provided = 0,
105570 + .properties_destroyed = 0,
105571 + .todo_flags_start = 0,
105572 + .todo_flags_finish = TODO_dump_func | TODO_verify_ssa | TODO_verify_stmts | TODO_remove_unused_locals | TODO_update_ssa_no_phi | TODO_cleanup_cfg | TODO_ggc_collect | TODO_verify_flow
105573 + }
105574 +};
105575 +
105576 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
105577 +{
105578 + tree fntype;
105579 +
105580 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
105581 +
105582 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
105583 + fntype = build_function_type_list(void_type_node,
105584 + const_char_ptr_type_node,
105585 + unsigned_type_node,
105586 + const_char_ptr_type_node,
105587 + const_char_ptr_type_node,
105588 + NULL_TREE);
105589 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
105590 +
105591 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
105592 + TREE_PUBLIC(report_size_overflow_decl) = 1;
105593 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
105594 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
105595 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
105596 +}
105597 +
105598 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
105599 +{
105600 + int i;
105601 + const char * const plugin_name = plugin_info->base_name;
105602 + const int argc = plugin_info->argc;
105603 + const struct plugin_argument * const argv = plugin_info->argv;
105604 + bool enable = true;
105605 +
105606 + struct register_pass_info size_overflow_pass_info = {
105607 + .pass = &size_overflow_pass.pass,
105608 + .reference_pass_name = "ssa",
105609 + .ref_pass_instance_number = 1,
105610 + .pos_op = PASS_POS_INSERT_AFTER
105611 + };
105612 +
105613 + if (!plugin_default_version_check(version, &gcc_version)) {
105614 + error(G_("incompatible gcc/plugin versions"));
105615 + return 1;
105616 + }
105617 +
105618 + for (i = 0; i < argc; ++i) {
105619 + if (!strcmp(argv[i].key, "no-size-overflow")) {
105620 + enable = false;
105621 + continue;
105622 + }
105623 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105624 + }
105625 +
105626 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
105627 + if (enable) {
105628 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
105629 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
105630 + }
105631 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
105632 +
105633 + return 0;
105634 +}
105635 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
105636 new file mode 100644
105637 index 0000000..ac2901e
105638 --- /dev/null
105639 +++ b/tools/gcc/stackleak_plugin.c
105640 @@ -0,0 +1,327 @@
105641 +/*
105642 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
105643 + * Licensed under the GPL v2
105644 + *
105645 + * Note: the choice of the license means that the compilation process is
105646 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
105647 + * but for the kernel it doesn't matter since it doesn't link against
105648 + * any of the gcc libraries
105649 + *
105650 + * gcc plugin to help implement various PaX features
105651 + *
105652 + * - track lowest stack pointer
105653 + *
105654 + * TODO:
105655 + * - initialize all local variables
105656 + *
105657 + * BUGS:
105658 + * - none known
105659 + */
105660 +#include "gcc-plugin.h"
105661 +#include "config.h"
105662 +#include "system.h"
105663 +#include "coretypes.h"
105664 +#include "tree.h"
105665 +#include "tree-pass.h"
105666 +#include "flags.h"
105667 +#include "intl.h"
105668 +#include "toplev.h"
105669 +#include "plugin.h"
105670 +//#include "expr.h" where are you...
105671 +#include "diagnostic.h"
105672 +#include "plugin-version.h"
105673 +#include "tm.h"
105674 +#include "function.h"
105675 +#include "basic-block.h"
105676 +#include "gimple.h"
105677 +#include "rtl.h"
105678 +#include "emit-rtl.h"
105679 +
105680 +#if BUILDING_GCC_VERSION >= 4008
105681 +#define TODO_dump_func 0
105682 +#endif
105683 +
105684 +extern void print_gimple_stmt(FILE *, gimple, int, int);
105685 +
105686 +int plugin_is_GPL_compatible;
105687 +
105688 +static int track_frame_size = -1;
105689 +static const char track_function[] = "pax_track_stack";
105690 +static const char check_function[] = "pax_check_alloca";
105691 +static bool init_locals;
105692 +
105693 +static struct plugin_info stackleak_plugin_info = {
105694 + .version = "201302112000",
105695 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
105696 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
105697 +};
105698 +
105699 +static bool gate_stackleak_track_stack(void);
105700 +static unsigned int execute_stackleak_tree_instrument(void);
105701 +static unsigned int execute_stackleak_final(void);
105702 +
105703 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
105704 + .pass = {
105705 + .type = GIMPLE_PASS,
105706 + .name = "stackleak_tree_instrument",
105707 +#if BUILDING_GCC_VERSION >= 4008
105708 + .optinfo_flags = OPTGROUP_NONE,
105709 +#endif
105710 + .gate = gate_stackleak_track_stack,
105711 + .execute = execute_stackleak_tree_instrument,
105712 + .sub = NULL,
105713 + .next = NULL,
105714 + .static_pass_number = 0,
105715 + .tv_id = TV_NONE,
105716 + .properties_required = PROP_gimple_leh | PROP_cfg,
105717 + .properties_provided = 0,
105718 + .properties_destroyed = 0,
105719 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
105720 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
105721 + }
105722 +};
105723 +
105724 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
105725 + .pass = {
105726 + .type = RTL_PASS,
105727 + .name = "stackleak_final",
105728 +#if BUILDING_GCC_VERSION >= 4008
105729 + .optinfo_flags = OPTGROUP_NONE,
105730 +#endif
105731 + .gate = gate_stackleak_track_stack,
105732 + .execute = execute_stackleak_final,
105733 + .sub = NULL,
105734 + .next = NULL,
105735 + .static_pass_number = 0,
105736 + .tv_id = TV_NONE,
105737 + .properties_required = 0,
105738 + .properties_provided = 0,
105739 + .properties_destroyed = 0,
105740 + .todo_flags_start = 0,
105741 + .todo_flags_finish = TODO_dump_func
105742 + }
105743 +};
105744 +
105745 +static bool gate_stackleak_track_stack(void)
105746 +{
105747 + return track_frame_size >= 0;
105748 +}
105749 +
105750 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
105751 +{
105752 + gimple check_alloca;
105753 + tree fntype, fndecl, alloca_size;
105754 +
105755 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
105756 + fndecl = build_fn_decl(check_function, fntype);
105757 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
105758 +
105759 + // insert call to void pax_check_alloca(unsigned long size)
105760 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
105761 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
105762 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
105763 +}
105764 +
105765 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
105766 +{
105767 + gimple track_stack;
105768 + tree fntype, fndecl;
105769 +
105770 + fntype = build_function_type_list(void_type_node, NULL_TREE);
105771 + fndecl = build_fn_decl(track_function, fntype);
105772 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
105773 +
105774 + // insert call to void pax_track_stack(void)
105775 + track_stack = gimple_build_call(fndecl, 0);
105776 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
105777 +}
105778 +
105779 +#if BUILDING_GCC_VERSION == 4005
105780 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
105781 +{
105782 + tree fndecl;
105783 +
105784 + if (!is_gimple_call(stmt))
105785 + return false;
105786 + fndecl = gimple_call_fndecl(stmt);
105787 + if (!fndecl)
105788 + return false;
105789 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
105790 + return false;
105791 +// print_node(stderr, "pax", fndecl, 4);
105792 + return DECL_FUNCTION_CODE(fndecl) == code;
105793 +}
105794 +#endif
105795 +
105796 +static bool is_alloca(gimple stmt)
105797 +{
105798 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
105799 + return true;
105800 +
105801 +#if BUILDING_GCC_VERSION >= 4007
105802 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
105803 + return true;
105804 +#endif
105805 +
105806 + return false;
105807 +}
105808 +
105809 +static unsigned int execute_stackleak_tree_instrument(void)
105810 +{
105811 + basic_block bb, entry_bb;
105812 + bool prologue_instrumented = false, is_leaf = true;
105813 +
105814 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
105815 +
105816 + // 1. loop through BBs and GIMPLE statements
105817 + FOR_EACH_BB(bb) {
105818 + gimple_stmt_iterator gsi;
105819 +
105820 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
105821 + gimple stmt;
105822 +
105823 + stmt = gsi_stmt(gsi);
105824 +
105825 + if (is_gimple_call(stmt))
105826 + is_leaf = false;
105827 +
105828 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
105829 + if (!is_alloca(stmt))
105830 + continue;
105831 +
105832 + // 2. insert stack overflow check before each __builtin_alloca call
105833 + stackleak_check_alloca(&gsi);
105834 +
105835 + // 3. insert track call after each __builtin_alloca call
105836 + stackleak_add_instrumentation(&gsi);
105837 + if (bb == entry_bb)
105838 + prologue_instrumented = true;
105839 + }
105840 + }
105841 +
105842 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
105843 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
105844 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
105845 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
105846 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
105847 + return 0;
105848 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
105849 + return 0;
105850 +
105851 + // 4. insert track call at the beginning
105852 + if (!prologue_instrumented) {
105853 + gimple_stmt_iterator gsi;
105854 +
105855 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
105856 + if (dom_info_available_p(CDI_DOMINATORS))
105857 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
105858 + gsi = gsi_start_bb(bb);
105859 + stackleak_add_instrumentation(&gsi);
105860 + }
105861 +
105862 + return 0;
105863 +}
105864 +
105865 +static unsigned int execute_stackleak_final(void)
105866 +{
105867 + rtx insn, next;
105868 +
105869 + if (cfun->calls_alloca)
105870 + return 0;
105871 +
105872 + // keep calls only if function frame is big enough
105873 + if (get_frame_size() >= track_frame_size)
105874 + return 0;
105875 +
105876 + // 1. find pax_track_stack calls
105877 + for (insn = get_insns(); insn; insn = next) {
105878 + // rtl match: (call_insn 8 7 9 3 (call (mem (symbol_ref ("pax_track_stack") [flags 0x41] <function_decl 0xb7470e80 pax_track_stack>) [0 S1 A8]) (4)) -1 (nil) (nil))
105879 + rtx body;
105880 +
105881 + next = NEXT_INSN(insn);
105882 + if (!CALL_P(insn))
105883 + continue;
105884 + body = PATTERN(insn);
105885 + if (GET_CODE(body) != CALL)
105886 + continue;
105887 + body = XEXP(body, 0);
105888 + if (GET_CODE(body) != MEM)
105889 + continue;
105890 + body = XEXP(body, 0);
105891 + if (GET_CODE(body) != SYMBOL_REF)
105892 + continue;
105893 + if (strcmp(XSTR(body, 0), track_function))
105894 + continue;
105895 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
105896 + // 2. delete call
105897 + delete_insn_and_edges(insn);
105898 +#if BUILDING_GCC_VERSION >= 4007
105899 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
105900 + insn = next;
105901 + next = NEXT_INSN(insn);
105902 + delete_insn_and_edges(insn);
105903 + }
105904 +#endif
105905 + }
105906 +
105907 +// print_simple_rtl(stderr, get_insns());
105908 +// print_rtl(stderr, get_insns());
105909 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
105910 +
105911 + return 0;
105912 +}
105913 +
105914 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
105915 +{
105916 + const char * const plugin_name = plugin_info->base_name;
105917 + const int argc = plugin_info->argc;
105918 + const struct plugin_argument * const argv = plugin_info->argv;
105919 + int i;
105920 + struct register_pass_info stackleak_tree_instrument_pass_info = {
105921 + .pass = &stackleak_tree_instrument_pass.pass,
105922 +// .reference_pass_name = "tree_profile",
105923 + .reference_pass_name = "optimized",
105924 + .ref_pass_instance_number = 1,
105925 + .pos_op = PASS_POS_INSERT_BEFORE
105926 + };
105927 + struct register_pass_info stackleak_final_pass_info = {
105928 + .pass = &stackleak_final_rtl_opt_pass.pass,
105929 + .reference_pass_name = "final",
105930 + .ref_pass_instance_number = 1,
105931 + .pos_op = PASS_POS_INSERT_BEFORE
105932 + };
105933 +
105934 + if (!plugin_default_version_check(version, &gcc_version)) {
105935 + error(G_("incompatible gcc/plugin versions"));
105936 + return 1;
105937 + }
105938 +
105939 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
105940 +
105941 + for (i = 0; i < argc; ++i) {
105942 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
105943 + if (!argv[i].value) {
105944 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105945 + continue;
105946 + }
105947 + track_frame_size = atoi(argv[i].value);
105948 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
105949 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
105950 + continue;
105951 + }
105952 + if (!strcmp(argv[i].key, "initialize-locals")) {
105953 + if (argv[i].value) {
105954 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
105955 + continue;
105956 + }
105957 + init_locals = true;
105958 + continue;
105959 + }
105960 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105961 + }
105962 +
105963 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
105964 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
105965 +
105966 + return 0;
105967 +}
105968 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
105969 new file mode 100644
105970 index 0000000..4fae911
105971 --- /dev/null
105972 +++ b/tools/gcc/structleak_plugin.c
105973 @@ -0,0 +1,277 @@
105974 +/*
105975 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
105976 + * Licensed under the GPL v2
105977 + *
105978 + * Note: the choice of the license means that the compilation process is
105979 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
105980 + * but for the kernel it doesn't matter since it doesn't link against
105981 + * any of the gcc libraries
105982 + *
105983 + * gcc plugin to forcibly initialize certain local variables that could
105984 + * otherwise leak kernel stack to userland if they aren't properly initialized
105985 + * by later code
105986 + *
105987 + * Homepage: http://pax.grsecurity.net/
105988 + *
105989 + * Usage:
105990 + * $ # for 4.5/4.6/C based 4.7
105991 + * $ gcc -I`gcc -print-file-name=plugin`/include -I`gcc -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
105992 + * $ # for C++ based 4.7/4.8+
105993 + * $ g++ -I`g++ -print-file-name=plugin`/include -I`g++ -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
105994 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
105995 + *
105996 + * TODO: eliminate redundant initializers
105997 + * increase type coverage
105998 + */
105999 +
106000 +#include "gcc-plugin.h"
106001 +#include "config.h"
106002 +#include "system.h"
106003 +#include "coretypes.h"
106004 +#include "tree.h"
106005 +#include "tree-pass.h"
106006 +#include "intl.h"
106007 +#include "plugin-version.h"
106008 +#include "tm.h"
106009 +#include "toplev.h"
106010 +#include "function.h"
106011 +#include "tree-flow.h"
106012 +#include "plugin.h"
106013 +#include "gimple.h"
106014 +#include "diagnostic.h"
106015 +#include "cfgloop.h"
106016 +#include "langhooks.h"
106017 +
106018 +#if BUILDING_GCC_VERSION >= 4008
106019 +#define TODO_dump_func 0
106020 +#endif
106021 +
106022 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
106023 +
106024 +// unused type flag in all versions 4.5-4.8
106025 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
106026 +
106027 +int plugin_is_GPL_compatible;
106028 +void debug_gimple_stmt(gimple gs);
106029 +
106030 +static struct plugin_info structleak_plugin_info = {
106031 + .version = "201304082245",
106032 + .help = "disable\tdo not activate plugin\n",
106033 +};
106034 +
106035 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
106036 +{
106037 + *no_add_attrs = true;
106038 +
106039 + // check for types? for now accept everything linux has to offer
106040 + if (TREE_CODE(*node) != FIELD_DECL)
106041 + return NULL_TREE;
106042 +
106043 + *no_add_attrs = false;
106044 + return NULL_TREE;
106045 +}
106046 +
106047 +static struct attribute_spec user_attr = {
106048 + .name = "user",
106049 + .min_length = 0,
106050 + .max_length = 0,
106051 + .decl_required = false,
106052 + .type_required = false,
106053 + .function_type_required = false,
106054 + .handler = handle_user_attribute,
106055 +#if BUILDING_GCC_VERSION >= 4007
106056 + .affects_type_identity = true
106057 +#endif
106058 +};
106059 +
106060 +static void register_attributes(void *event_data, void *data)
106061 +{
106062 + register_attribute(&user_attr);
106063 +// register_attribute(&force_attr);
106064 +}
106065 +
106066 +static tree get_field_type(tree field)
106067 +{
106068 + return strip_array_types(TREE_TYPE(field));
106069 +}
106070 +
106071 +static bool is_userspace_type(tree type)
106072 +{
106073 + tree field;
106074 +
106075 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
106076 + tree fieldtype = get_field_type(field);
106077 + enum tree_code code = TREE_CODE(fieldtype);
106078 +
106079 + if (code == RECORD_TYPE || code == UNION_TYPE)
106080 + if (is_userspace_type(fieldtype))
106081 + return true;
106082 +
106083 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
106084 + return true;
106085 + }
106086 + return false;
106087 +}
106088 +
106089 +static void finish_type(void *event_data, void *data)
106090 +{
106091 + tree type = (tree)event_data;
106092 +
106093 + if (TYPE_USERSPACE(type))
106094 + return;
106095 +
106096 + if (is_userspace_type(type))
106097 + TYPE_USERSPACE(type) = 1;
106098 +}
106099 +
106100 +static void initialize(tree var)
106101 +{
106102 + basic_block bb;
106103 + gimple_stmt_iterator gsi;
106104 + tree initializer;
106105 + gimple init_stmt;
106106 +
106107 + // this is the original entry bb before the forced split
106108 + // TODO: check further BBs in case more splits occured before us
106109 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
106110 +
106111 + // first check if the variable is already initialized, warn otherwise
106112 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
106113 + gimple stmt = gsi_stmt(gsi);
106114 + tree rhs1;
106115 +
106116 + // we're looking for an assignment of a single rhs...
106117 + if (!gimple_assign_single_p(stmt))
106118 + continue;
106119 + rhs1 = gimple_assign_rhs1(stmt);
106120 +#if BUILDING_GCC_VERSION >= 4007
106121 + // ... of a non-clobbering expression...
106122 + if (TREE_CLOBBER_P(rhs1))
106123 + continue;
106124 +#endif
106125 + // ... to our variable...
106126 + if (gimple_get_lhs(stmt) != var)
106127 + continue;
106128 + // if it's an initializer then we're good
106129 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
106130 + return;
106131 + }
106132 +
106133 + // these aren't the 0days you're looking for
106134 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
106135 +
106136 + // build the initializer expression
106137 + initializer = build_constructor(TREE_TYPE(var), NULL);
106138 +
106139 + // build the initializer stmt
106140 + init_stmt = gimple_build_assign(var, initializer);
106141 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
106142 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
106143 + update_stmt(init_stmt);
106144 +}
106145 +
106146 +static unsigned int handle_function(void)
106147 +{
106148 + basic_block bb;
106149 + unsigned int ret = 0;
106150 + tree var;
106151 +
106152 +#if BUILDING_GCC_VERSION == 4005
106153 + tree vars;
106154 +#else
106155 + unsigned int i;
106156 +#endif
106157 +
106158 + // split the first bb where we can put the forced initializers
106159 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
106160 + if (dom_info_available_p(CDI_DOMINATORS))
106161 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
106162 +
106163 + // enumarate all local variables and forcibly initialize our targets
106164 +#if BUILDING_GCC_VERSION == 4005
106165 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
106166 + var = TREE_VALUE(vars);
106167 +#else
106168 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
106169 +#endif
106170 + tree type = TREE_TYPE(var);
106171 +
106172 + gcc_assert(DECL_P(var));
106173 + if (!auto_var_in_fn_p(var, current_function_decl))
106174 + continue;
106175 +
106176 + // only care about structure types
106177 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
106178 + continue;
106179 +
106180 + // if the type is of interest, examine the variable
106181 + if (TYPE_USERSPACE(type))
106182 + initialize(var);
106183 + }
106184 +
106185 + return ret;
106186 +}
106187 +
106188 +static struct gimple_opt_pass structleak_pass = {
106189 + .pass = {
106190 + .type = GIMPLE_PASS,
106191 + .name = "structleak",
106192 +#if BUILDING_GCC_VERSION >= 4008
106193 + .optinfo_flags = OPTGROUP_NONE,
106194 +#endif
106195 + .gate = NULL,
106196 + .execute = handle_function,
106197 + .sub = NULL,
106198 + .next = NULL,
106199 + .static_pass_number = 0,
106200 + .tv_id = TV_NONE,
106201 + .properties_required = PROP_cfg,
106202 + .properties_provided = 0,
106203 + .properties_destroyed = 0,
106204 + .todo_flags_start = 0,
106205 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa | TODO_ggc_collect | TODO_verify_flow
106206 + }
106207 +};
106208 +
106209 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
106210 +{
106211 + int i;
106212 + const char * const plugin_name = plugin_info->base_name;
106213 + const int argc = plugin_info->argc;
106214 + const struct plugin_argument * const argv = plugin_info->argv;
106215 + bool enable = true;
106216 +
106217 + struct register_pass_info structleak_pass_info = {
106218 + .pass = &structleak_pass.pass,
106219 + .reference_pass_name = "ssa",
106220 + .ref_pass_instance_number = 1,
106221 + .pos_op = PASS_POS_INSERT_AFTER
106222 + };
106223 +
106224 + if (!plugin_default_version_check(version, &gcc_version)) {
106225 + error(G_("incompatible gcc/plugin versions"));
106226 + return 1;
106227 + }
106228 +
106229 + if (strcmp(lang_hooks.name, "GNU C")) {
106230 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
106231 + enable = false;
106232 + }
106233 +
106234 + for (i = 0; i < argc; ++i) {
106235 + if (!strcmp(argv[i].key, "disable")) {
106236 + enable = false;
106237 + continue;
106238 + }
106239 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
106240 + }
106241 +
106242 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
106243 + if (enable) {
106244 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
106245 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
106246 + }
106247 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
106248 +
106249 + return 0;
106250 +}
106251 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
106252 index 6789d78..4afd019e 100644
106253 --- a/tools/perf/util/include/asm/alternative-asm.h
106254 +++ b/tools/perf/util/include/asm/alternative-asm.h
106255 @@ -5,4 +5,7 @@
106256
106257 #define altinstruction_entry #
106258
106259 + .macro pax_force_retaddr rip=0, reload=0
106260 + .endm
106261 +
106262 #endif
106263 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
106264 index 96b919d..c49bb74 100644
106265 --- a/tools/perf/util/include/linux/compiler.h
106266 +++ b/tools/perf/util/include/linux/compiler.h
106267 @@ -18,4 +18,12 @@
106268 #define __force
106269 #endif
106270
106271 +#ifndef __size_overflow
106272 +# define __size_overflow(...)
106273 +#endif
106274 +
106275 +#ifndef __intentional_overflow
106276 +# define __intentional_overflow(...)
106277 +#endif
106278 +
106279 #endif
106280 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
106281 index 302681c..3bde377 100644
106282 --- a/virt/kvm/kvm_main.c
106283 +++ b/virt/kvm/kvm_main.c
106284 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
106285
106286 static cpumask_var_t cpus_hardware_enabled;
106287 static int kvm_usage_count = 0;
106288 -static atomic_t hardware_enable_failed;
106289 +static atomic_unchecked_t hardware_enable_failed;
106290
106291 struct kmem_cache *kvm_vcpu_cache;
106292 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
106293
106294 -static __read_mostly struct preempt_ops kvm_preempt_ops;
106295 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
106296 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
106297 +static struct preempt_ops kvm_preempt_ops = {
106298 + .sched_in = kvm_sched_in,
106299 + .sched_out = kvm_sched_out,
106300 +};
106301
106302 struct dentry *kvm_debugfs_dir;
106303
106304 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
106305 /* We can read the guest memory with __xxx_user() later on. */
106306 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
106307 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
106308 - !access_ok(VERIFY_WRITE,
106309 + !__access_ok(VERIFY_WRITE,
106310 (void __user *)(unsigned long)mem->userspace_addr,
106311 mem->memory_size)))
106312 goto out;
106313 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
106314 return 0;
106315 }
106316
106317 -static struct file_operations kvm_vcpu_fops = {
106318 +static file_operations_no_const kvm_vcpu_fops __read_only = {
106319 .release = kvm_vcpu_release,
106320 .unlocked_ioctl = kvm_vcpu_ioctl,
106321 #ifdef CONFIG_COMPAT
106322 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
106323 return 0;
106324 }
106325
106326 -static struct file_operations kvm_vm_fops = {
106327 +static file_operations_no_const kvm_vm_fops __read_only = {
106328 .release = kvm_vm_release,
106329 .unlocked_ioctl = kvm_vm_ioctl,
106330 #ifdef CONFIG_COMPAT
106331 @@ -2662,7 +2667,7 @@ out:
106332 return r;
106333 }
106334
106335 -static struct file_operations kvm_chardev_ops = {
106336 +static file_operations_no_const kvm_chardev_ops __read_only = {
106337 .unlocked_ioctl = kvm_dev_ioctl,
106338 .compat_ioctl = kvm_dev_ioctl,
106339 .llseek = noop_llseek,
106340 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
106341
106342 if (r) {
106343 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
106344 - atomic_inc(&hardware_enable_failed);
106345 + atomic_inc_unchecked(&hardware_enable_failed);
106346 printk(KERN_INFO "kvm: enabling virtualization on "
106347 "CPU%d failed\n", cpu);
106348 }
106349 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
106350
106351 kvm_usage_count++;
106352 if (kvm_usage_count == 1) {
106353 - atomic_set(&hardware_enable_failed, 0);
106354 + atomic_set_unchecked(&hardware_enable_failed, 0);
106355 on_each_cpu(hardware_enable_nolock, NULL, 1);
106356
106357 - if (atomic_read(&hardware_enable_failed)) {
106358 + if (atomic_read_unchecked(&hardware_enable_failed)) {
106359 hardware_disable_all_nolock();
106360 r = -EBUSY;
106361 }
106362 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
106363 kvm_arch_vcpu_put(vcpu);
106364 }
106365
106366 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106367 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106368 struct module *module)
106369 {
106370 int r;
106371 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106372 if (!vcpu_align)
106373 vcpu_align = __alignof__(struct kvm_vcpu);
106374 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
106375 - 0, NULL);
106376 + SLAB_USERCOPY, NULL);
106377 if (!kvm_vcpu_cache) {
106378 r = -ENOMEM;
106379 goto out_free_3;
106380 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106381 if (r)
106382 goto out_free;
106383
106384 + pax_open_kernel();
106385 kvm_chardev_ops.owner = module;
106386 kvm_vm_fops.owner = module;
106387 kvm_vcpu_fops.owner = module;
106388 + pax_close_kernel();
106389
106390 r = misc_register(&kvm_dev);
106391 if (r) {
106392 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106393
106394 register_syscore_ops(&kvm_syscore_ops);
106395
106396 - kvm_preempt_ops.sched_in = kvm_sched_in;
106397 - kvm_preempt_ops.sched_out = kvm_sched_out;
106398 -
106399 r = kvm_init_debug();
106400 if (r) {
106401 printk(KERN_ERR "kvm: create debugfs files failed\n");