]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.8-201401191015.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.8-201401191015.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..903b673 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,32 +101,40 @@ 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 crc32table.h*
90 cscope.*
91 defkeymap.c
92 +devicetable-offsets.h
93 devlist.h*
94 dnotify_test
95 docproc
96 dslm
97 +dtc-lexer.lex.c
98 elf2ecoff
99 elfconfig.h*
100 evergreen_reg_safe.h
101 +exception_policy.conf
102 fixdep
103 flask.h
104 fore200e_mkfirm
105 @@ -125,12 +142,15 @@ fore200e_pca_fw.c*
106 gconf
107 gconf.glade.h
108 gen-devlist
109 +gen-kdb_cmds.c
110 gen_crc32table
111 gen_init_cpio
112 generated
113 genheaders
114 genksyms
115 *_gray256.c
116 +hash
117 +hid-example
118 hpet_example
119 hugepage-mmap
120 hugepage-shm
121 @@ -145,14 +165,14 @@ int32.c
122 int4.c
123 int8.c
124 kallsyms
125 -kconfig
126 +kern_constants.h
127 keywords.c
128 ksym.c*
129 ksym.h*
130 kxgettext
131 lex.c
132 lex.*.c
133 -linux
134 +lib1funcs.S
135 logo_*.c
136 logo_*_clut224.c
137 logo_*_mono.c
138 @@ -162,14 +182,15 @@ mach-types.h
139 machtypes.h
140 map
141 map_hugetlb
142 -media
143 mconf
144 +mdp
145 miboot*
146 mk_elfconfig
147 mkboot
148 mkbugboot
149 mkcpustr
150 mkdep
151 +mkpiggy
152 mkprep
153 mkregtable
154 mktables
155 @@ -185,6 +206,8 @@ oui.c*
156 page-types
157 parse.c
158 parse.h
159 +parse-events*
160 +pasyms.h
161 patches*
162 pca200e.bin
163 pca200e_ecd.bin2
164 @@ -194,6 +217,7 @@ perf-archive
165 piggyback
166 piggy.gzip
167 piggy.S
168 +pmu-*
169 pnmtologo
170 ppc_defs.h*
171 pss_boot.h
172 @@ -203,7 +227,10 @@ r200_reg_safe.h
173 r300_reg_safe.h
174 r420_reg_safe.h
175 r600_reg_safe.h
176 +realmode.lds
177 +realmode.relocs
178 recordmcount
179 +regdb.c
180 relocs
181 rlim_names.h
182 rn50_reg_safe.h
183 @@ -213,8 +240,12 @@ series
184 setup
185 setup.bin
186 setup.elf
187 +signing_key*
188 +size_overflow_hash.h
189 sImage
190 +slabinfo
191 sm_tbl*
192 +sortextable
193 split-include
194 syscalltab.h
195 tables.c
196 @@ -224,6 +255,7 @@ tftpboot.img
197 timeconst.h
198 times.h*
199 trix_boot.h
200 +user_constants.h
201 utsrelease.h*
202 vdso-syms.lds
203 vdso.lds
204 @@ -235,13 +267,17 @@ vdso32.lds
205 vdso32.so.dbg
206 vdso64.lds
207 vdso64.so.dbg
208 +vdsox32.lds
209 +vdsox32-syms.lds
210 version.h*
211 vmImage
212 vmlinux
213 vmlinux-*
214 vmlinux.aout
215 vmlinux.bin.all
216 +vmlinux.bin.bz2
217 vmlinux.lds
218 +vmlinux.relocs
219 vmlinuz
220 voffset.h
221 vsyscall.lds
222 @@ -249,9 +285,12 @@ vsyscall_32.lds
223 wanxlfw.inc
224 uImage
225 unifdef
226 +utsrelease.h
227 wakeup.bin
228 wakeup.elf
229 wakeup.lds
230 +x509*
231 zImage*
232 zconf.hash.c
233 +zconf.lex.c
234 zoffset.h
235 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
236 index 4f7c57c..a2dc685 100644
237 --- a/Documentation/kernel-parameters.txt
238 +++ b/Documentation/kernel-parameters.txt
239 @@ -1031,6 +1031,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
240 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
241 Default: 1024
242
243 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
244 + ignore grsecurity's /proc restrictions
245 +
246 +
247 hashdist= [KNL,NUMA] Large hashes allocated during boot
248 are distributed across NUMA nodes. Defaults on
249 for 64-bit NUMA, off otherwise.
250 @@ -2001,6 +2005,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
251 noexec=on: enable non-executable mappings (default)
252 noexec=off: disable non-executable mappings
253
254 + nopcid [X86-64]
255 + Disable PCID (Process-Context IDentifier) even if it
256 + is supported by the processor.
257 +
258 nosmap [X86]
259 Disable SMAP (Supervisor Mode Access Prevention)
260 even if it is supported by processor.
261 @@ -2268,6 +2276,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
262 the specified number of seconds. This is to be used if
263 your oopses keep scrolling off the screen.
264
265 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
266 + virtualization environments that don't cope well with the
267 + expand down segment used by UDEREF on X86-32 or the frequent
268 + page table updates on X86-64.
269 +
270 + pax_sanitize_slab=
271 + 0/1 to disable/enable slab object sanitization (enabled by
272 + default).
273 +
274 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
275 +
276 + pax_extra_latent_entropy
277 + Enable a very simple form of latent entropy extraction
278 + from the first 4GB of memory as the bootmem allocator
279 + passes the memory pages to the buddy allocator.
280 +
281 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
282 + when the processor supports PCID.
283 +
284 pcbit= [HW,ISDN]
285
286 pcd. [PARIDE]
287 diff --git a/Makefile b/Makefile
288 index 5d0ec13..d3dcef2 100644
289 --- a/Makefile
290 +++ b/Makefile
291 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
292
293 HOSTCC = gcc
294 HOSTCXX = g++
295 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
296 -HOSTCXXFLAGS = -O2
297 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
298 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
299 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
300
301 # Decide whether to build built-in, modular, or both.
302 # Normally, just do built-in.
303 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
304 # Rules shared between *config targets and build targets
305
306 # Basic helpers built in scripts/
307 -PHONY += scripts_basic
308 -scripts_basic:
309 +PHONY += scripts_basic gcc-plugins
310 +scripts_basic: gcc-plugins
311 $(Q)$(MAKE) $(build)=scripts/basic
312 $(Q)rm -f .tmp_quiet_recordmcount
313
314 @@ -576,6 +577,65 @@ else
315 KBUILD_CFLAGS += -O2
316 endif
317
318 +ifndef DISABLE_PAX_PLUGINS
319 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
320 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
321 +else
322 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
323 +endif
324 +ifneq ($(PLUGINCC),)
325 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
326 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
327 +endif
328 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
329 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
330 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
331 +endif
332 +ifdef CONFIG_KALLOCSTAT_PLUGIN
333 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
334 +endif
335 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
336 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
337 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
338 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
339 +endif
340 +ifdef CONFIG_CHECKER_PLUGIN
341 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
342 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
343 +endif
344 +endif
345 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
346 +ifdef CONFIG_PAX_SIZE_OVERFLOW
347 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
348 +endif
349 +ifdef CONFIG_PAX_LATENT_ENTROPY
350 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
351 +endif
352 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
353 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
354 +endif
355 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
356 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
357 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
358 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
359 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
360 +ifeq ($(KBUILD_EXTMOD),)
361 +gcc-plugins:
362 + $(Q)$(MAKE) $(build)=tools/gcc
363 +else
364 +gcc-plugins: ;
365 +endif
366 +else
367 +gcc-plugins:
368 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
369 + $(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.))
370 +else
371 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
372 +endif
373 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
374 +endif
375 +endif
376 +
377 include $(srctree)/arch/$(SRCARCH)/Makefile
378
379 ifdef CONFIG_READABLE_ASM
380 @@ -733,7 +793,7 @@ export mod_sign_cmd
381
382
383 ifeq ($(KBUILD_EXTMOD),)
384 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
385 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
386
387 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
388 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
389 @@ -782,6 +842,8 @@ endif
390
391 # The actual objects are generated when descending,
392 # make sure no implicit rule kicks in
393 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
396
397 # Handle descending into subdirectories listed in $(vmlinux-dirs)
398 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
399 # Error messages still appears in the original language
400
401 PHONY += $(vmlinux-dirs)
402 -$(vmlinux-dirs): prepare scripts
403 +$(vmlinux-dirs): gcc-plugins prepare scripts
404 $(Q)$(MAKE) $(build)=$@
405
406 define filechk_kernel.release
407 @@ -834,10 +896,13 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
408
409 archprepare: archheaders archscripts prepare1 scripts_basic
410
411 +prepare0: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
412 +prepare0: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
413 prepare0: archprepare FORCE
414 $(Q)$(MAKE) $(build)=.
415
416 # All the preparing..
417 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
418 prepare: prepare0
419
420 # Generate some files
421 @@ -945,6 +1010,8 @@ all: modules
422 # using awk while concatenating to the final file.
423
424 PHONY += modules
425 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
426 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
427 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
428 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
429 @$(kecho) ' Building modules, stage 2.';
430 @@ -960,7 +1027,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
431
432 # Target to prepare building external modules
433 PHONY += modules_prepare
434 -modules_prepare: prepare scripts
435 +modules_prepare: gcc-plugins prepare scripts
436
437 # Target to install modules
438 PHONY += modules_install
439 @@ -1026,7 +1093,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
440 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
441 signing_key.priv signing_key.x509 x509.genkey \
442 extra_certificates signing_key.x509.keyid \
443 - signing_key.x509.signer
444 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
445
446 # clean - Delete most, but leave enough to build external modules
447 #
448 @@ -1066,6 +1133,7 @@ distclean: mrproper
449 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
450 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
451 -o -name '.*.rej' \
452 + -o -name '.*.rej' -o -name '*.so' \
453 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
454 -type f -print | xargs rm -f
455
456 @@ -1227,6 +1295,8 @@ PHONY += $(module-dirs) modules
457 $(module-dirs): crmodverdir $(objtree)/Module.symvers
458 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
459
460 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 modules: $(module-dirs)
463 @$(kecho) ' Building modules, stage 2.';
464 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
465 @@ -1366,17 +1436,21 @@ else
466 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
467 endif
468
469 -%.s: %.c prepare scripts FORCE
470 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
471 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
472 +%.s: %.c gcc-plugins prepare scripts FORCE
473 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
474 %.i: %.c prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.c prepare scripts FORCE
477 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
478 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
479 +%.o: %.c gcc-plugins prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 %.lst: %.c prepare scripts FORCE
482 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
483 -%.s: %.S prepare scripts FORCE
484 +%.s: %.S gcc-plugins prepare scripts FORCE
485 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
486 -%.o: %.S prepare scripts FORCE
487 +%.o: %.S gcc-plugins prepare scripts FORCE
488 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
489 %.symtypes: %.c prepare scripts FORCE
490 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
491 @@ -1386,11 +1460,15 @@ endif
492 $(cmd_crmodverdir)
493 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
494 $(build)=$(build-dir)
495 -%/: prepare scripts FORCE
496 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
497 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
498 +%/: gcc-plugins prepare scripts FORCE
499 $(cmd_crmodverdir)
500 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
501 $(build)=$(build-dir)
502 -%.ko: prepare scripts FORCE
503 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
504 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
505 +%.ko: gcc-plugins prepare scripts FORCE
506 $(cmd_crmodverdir)
507 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
508 $(build)=$(build-dir) $(@:.ko=.o)
509 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
510 index 78b03ef..da28a51 100644
511 --- a/arch/alpha/include/asm/atomic.h
512 +++ b/arch/alpha/include/asm/atomic.h
513 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
514 #define atomic_dec(v) atomic_sub(1,(v))
515 #define atomic64_dec(v) atomic64_sub(1,(v))
516
517 +#define atomic64_read_unchecked(v) atomic64_read(v)
518 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
519 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
520 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
521 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
522 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
523 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
524 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
525 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
526 +
527 #define smp_mb__before_atomic_dec() smp_mb()
528 #define smp_mb__after_atomic_dec() smp_mb()
529 #define smp_mb__before_atomic_inc() smp_mb()
530 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
531 index ad368a9..fbe0f25 100644
532 --- a/arch/alpha/include/asm/cache.h
533 +++ b/arch/alpha/include/asm/cache.h
534 @@ -4,19 +4,19 @@
535 #ifndef __ARCH_ALPHA_CACHE_H
536 #define __ARCH_ALPHA_CACHE_H
537
538 +#include <linux/const.h>
539
540 /* Bytes per L1 (data) cache line. */
541 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
542 -# define L1_CACHE_BYTES 64
543 # define L1_CACHE_SHIFT 6
544 #else
545 /* Both EV4 and EV5 are write-through, read-allocate,
546 direct-mapped, physical.
547 */
548 -# define L1_CACHE_BYTES 32
549 # define L1_CACHE_SHIFT 5
550 #endif
551
552 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
553 #define SMP_CACHE_BYTES L1_CACHE_BYTES
554
555 #endif
556 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
557 index 968d999..d36b2df 100644
558 --- a/arch/alpha/include/asm/elf.h
559 +++ b/arch/alpha/include/asm/elf.h
560 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
561
562 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
563
564 +#ifdef CONFIG_PAX_ASLR
565 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
566 +
567 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
568 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
569 +#endif
570 +
571 /* $0 is set by ld.so to a pointer to a function which might be
572 registered using atexit. This provides a mean for the dynamic
573 linker to call DT_FINI functions for shared libraries that have
574 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
575 index bc2a0da..8ad11ee 100644
576 --- a/arch/alpha/include/asm/pgalloc.h
577 +++ b/arch/alpha/include/asm/pgalloc.h
578 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
579 pgd_set(pgd, pmd);
580 }
581
582 +static inline void
583 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
584 +{
585 + pgd_populate(mm, pgd, pmd);
586 +}
587 +
588 extern pgd_t *pgd_alloc(struct mm_struct *mm);
589
590 static inline void
591 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
592 index d8f9b7e..f6222fa 100644
593 --- a/arch/alpha/include/asm/pgtable.h
594 +++ b/arch/alpha/include/asm/pgtable.h
595 @@ -102,6 +102,17 @@ struct vm_area_struct;
596 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
597 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
598 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
599 +
600 +#ifdef CONFIG_PAX_PAGEEXEC
601 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
602 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
603 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
604 +#else
605 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
606 +# define PAGE_COPY_NOEXEC PAGE_COPY
607 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
608 +#endif
609 +
610 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
611
612 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
613 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
614 index 2fd00b7..cfd5069 100644
615 --- a/arch/alpha/kernel/module.c
616 +++ b/arch/alpha/kernel/module.c
617 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
618
619 /* The small sections were sorted to the end of the segment.
620 The following should definitely cover them. */
621 - gp = (u64)me->module_core + me->core_size - 0x8000;
622 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
623 got = sechdrs[me->arch.gotsecindex].sh_addr;
624
625 for (i = 0; i < n; i++) {
626 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
627 index 1402fcc..0b1abd2 100644
628 --- a/arch/alpha/kernel/osf_sys.c
629 +++ b/arch/alpha/kernel/osf_sys.c
630 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
631 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
632
633 static unsigned long
634 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 - unsigned long limit)
636 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
637 + unsigned long limit, unsigned long flags)
638 {
639 struct vm_unmapped_area_info info;
640 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
641
642 info.flags = 0;
643 info.length = len;
644 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
645 info.high_limit = limit;
646 info.align_mask = 0;
647 info.align_offset = 0;
648 + info.threadstack_offset = offset;
649 return vm_unmapped_area(&info);
650 }
651
652 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
653 merely specific addresses, but regions of memory -- perhaps
654 this feature should be incorporated into all ports? */
655
656 +#ifdef CONFIG_PAX_RANDMMAP
657 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
658 +#endif
659 +
660 if (addr) {
661 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
662 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
663 if (addr != (unsigned long) -ENOMEM)
664 return addr;
665 }
666
667 /* Next, try allocating at TASK_UNMAPPED_BASE. */
668 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
669 - len, limit);
670 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
671 +
672 if (addr != (unsigned long) -ENOMEM)
673 return addr;
674
675 /* Finally, try allocating in low memory. */
676 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
677 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
678
679 return addr;
680 }
681 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
682 index 98838a0..b304fb4 100644
683 --- a/arch/alpha/mm/fault.c
684 +++ b/arch/alpha/mm/fault.c
685 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
686 __reload_thread(pcb);
687 }
688
689 +#ifdef CONFIG_PAX_PAGEEXEC
690 +/*
691 + * PaX: decide what to do with offenders (regs->pc = fault address)
692 + *
693 + * returns 1 when task should be killed
694 + * 2 when patched PLT trampoline was detected
695 + * 3 when unpatched PLT trampoline was detected
696 + */
697 +static int pax_handle_fetch_fault(struct pt_regs *regs)
698 +{
699 +
700 +#ifdef CONFIG_PAX_EMUPLT
701 + int err;
702 +
703 + do { /* PaX: patched PLT emulation #1 */
704 + unsigned int ldah, ldq, jmp;
705 +
706 + err = get_user(ldah, (unsigned int *)regs->pc);
707 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
708 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
709 +
710 + if (err)
711 + break;
712 +
713 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
714 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
715 + jmp == 0x6BFB0000U)
716 + {
717 + unsigned long r27, addr;
718 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
719 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
720 +
721 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
722 + err = get_user(r27, (unsigned long *)addr);
723 + if (err)
724 + break;
725 +
726 + regs->r27 = r27;
727 + regs->pc = r27;
728 + return 2;
729 + }
730 + } while (0);
731 +
732 + do { /* PaX: patched PLT emulation #2 */
733 + unsigned int ldah, lda, br;
734 +
735 + err = get_user(ldah, (unsigned int *)regs->pc);
736 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
737 + err |= get_user(br, (unsigned int *)(regs->pc+8));
738 +
739 + if (err)
740 + break;
741 +
742 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
743 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
744 + (br & 0xFFE00000U) == 0xC3E00000U)
745 + {
746 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
747 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
748 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
749 +
750 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
751 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
752 + return 2;
753 + }
754 + } while (0);
755 +
756 + do { /* PaX: unpatched PLT emulation */
757 + unsigned int br;
758 +
759 + err = get_user(br, (unsigned int *)regs->pc);
760 +
761 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
762 + unsigned int br2, ldq, nop, jmp;
763 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
764 +
765 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
766 + err = get_user(br2, (unsigned int *)addr);
767 + err |= get_user(ldq, (unsigned int *)(addr+4));
768 + err |= get_user(nop, (unsigned int *)(addr+8));
769 + err |= get_user(jmp, (unsigned int *)(addr+12));
770 + err |= get_user(resolver, (unsigned long *)(addr+16));
771 +
772 + if (err)
773 + break;
774 +
775 + if (br2 == 0xC3600000U &&
776 + ldq == 0xA77B000CU &&
777 + nop == 0x47FF041FU &&
778 + jmp == 0x6B7B0000U)
779 + {
780 + regs->r28 = regs->pc+4;
781 + regs->r27 = addr+16;
782 + regs->pc = resolver;
783 + return 3;
784 + }
785 + }
786 + } while (0);
787 +#endif
788 +
789 + return 1;
790 +}
791 +
792 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
793 +{
794 + unsigned long i;
795 +
796 + printk(KERN_ERR "PAX: bytes at PC: ");
797 + for (i = 0; i < 5; i++) {
798 + unsigned int c;
799 + if (get_user(c, (unsigned int *)pc+i))
800 + printk(KERN_CONT "???????? ");
801 + else
802 + printk(KERN_CONT "%08x ", c);
803 + }
804 + printk("\n");
805 +}
806 +#endif
807
808 /*
809 * This routine handles page faults. It determines the address,
810 @@ -133,8 +251,29 @@ retry:
811 good_area:
812 si_code = SEGV_ACCERR;
813 if (cause < 0) {
814 - if (!(vma->vm_flags & VM_EXEC))
815 + if (!(vma->vm_flags & VM_EXEC)) {
816 +
817 +#ifdef CONFIG_PAX_PAGEEXEC
818 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
819 + goto bad_area;
820 +
821 + up_read(&mm->mmap_sem);
822 + switch (pax_handle_fetch_fault(regs)) {
823 +
824 +#ifdef CONFIG_PAX_EMUPLT
825 + case 2:
826 + case 3:
827 + return;
828 +#endif
829 +
830 + }
831 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
832 + do_group_exit(SIGKILL);
833 +#else
834 goto bad_area;
835 +#endif
836 +
837 + }
838 } else if (!cause) {
839 /* Allow reads even for write-only mappings */
840 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
841 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
842 index 1ad6fb6..9406b3d 100644
843 --- a/arch/arm/Kconfig
844 +++ b/arch/arm/Kconfig
845 @@ -1832,7 +1832,7 @@ config ALIGNMENT_TRAP
846
847 config UACCESS_WITH_MEMCPY
848 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
849 - depends on MMU
850 + depends on MMU && !PAX_MEMORY_UDEREF
851 default y if CPU_FEROCEON
852 help
853 Implement faster copy_to_user and clear_user methods for CPU
854 @@ -2097,6 +2097,7 @@ config XIP_PHYS_ADDR
855 config KEXEC
856 bool "Kexec system call (EXPERIMENTAL)"
857 depends on (!SMP || PM_SLEEP_SMP)
858 + depends on !GRKERNSEC_KMEM
859 help
860 kexec is a system call that implements the ability to shutdown your
861 current kernel, and to start another kernel. It is like a reboot
862 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
863 index da1c77d..2ee6056 100644
864 --- a/arch/arm/include/asm/atomic.h
865 +++ b/arch/arm/include/asm/atomic.h
866 @@ -17,17 +17,35 @@
867 #include <asm/barrier.h>
868 #include <asm/cmpxchg.h>
869
870 +#ifdef CONFIG_GENERIC_ATOMIC64
871 +#include <asm-generic/atomic64.h>
872 +#endif
873 +
874 #define ATOMIC_INIT(i) { (i) }
875
876 #ifdef __KERNEL__
877
878 +#define _ASM_EXTABLE(from, to) \
879 +" .pushsection __ex_table,\"a\"\n"\
880 +" .align 3\n" \
881 +" .long " #from ", " #to"\n" \
882 +" .popsection"
883 +
884 /*
885 * On ARM, ordinary assignment (str instruction) doesn't clear the local
886 * strex/ldrex monitor on some implementations. The reason we can use it for
887 * atomic_set() is the clrex or dummy strex done on every exception return.
888 */
889 #define atomic_read(v) (*(volatile int *)&(v)->counter)
890 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
891 +{
892 + return v->counter;
893 +}
894 #define atomic_set(v,i) (((v)->counter) = (i))
895 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
896 +{
897 + v->counter = i;
898 +}
899
900 #if __LINUX_ARM_ARCH__ >= 6
901
902 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
903 int result;
904
905 __asm__ __volatile__("@ atomic_add\n"
906 +"1: ldrex %1, [%3]\n"
907 +" adds %0, %1, %4\n"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +" bvc 3f\n"
911 +"2: bkpt 0xf103\n"
912 +"3:\n"
913 +#endif
914 +
915 +" strex %1, %0, [%3]\n"
916 +" teq %1, #0\n"
917 +" bne 1b"
918 +
919 +#ifdef CONFIG_PAX_REFCOUNT
920 +"\n4:\n"
921 + _ASM_EXTABLE(2b, 4b)
922 +#endif
923 +
924 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
925 + : "r" (&v->counter), "Ir" (i)
926 + : "cc");
927 +}
928 +
929 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
930 +{
931 + unsigned long tmp;
932 + int result;
933 +
934 + __asm__ __volatile__("@ atomic_add_unchecked\n"
935 "1: ldrex %0, [%3]\n"
936 " add %0, %0, %4\n"
937 " strex %1, %0, [%3]\n"
938 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
939 smp_mb();
940
941 __asm__ __volatile__("@ atomic_add_return\n"
942 +"1: ldrex %1, [%3]\n"
943 +" adds %0, %1, %4\n"
944 +
945 +#ifdef CONFIG_PAX_REFCOUNT
946 +" bvc 3f\n"
947 +" mov %0, %1\n"
948 +"2: bkpt 0xf103\n"
949 +"3:\n"
950 +#endif
951 +
952 +" strex %1, %0, [%3]\n"
953 +" teq %1, #0\n"
954 +" bne 1b"
955 +
956 +#ifdef CONFIG_PAX_REFCOUNT
957 +"\n4:\n"
958 + _ASM_EXTABLE(2b, 4b)
959 +#endif
960 +
961 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
962 + : "r" (&v->counter), "Ir" (i)
963 + : "cc");
964 +
965 + smp_mb();
966 +
967 + return result;
968 +}
969 +
970 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
971 +{
972 + unsigned long tmp;
973 + int result;
974 +
975 + smp_mb();
976 +
977 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
978 "1: ldrex %0, [%3]\n"
979 " add %0, %0, %4\n"
980 " strex %1, %0, [%3]\n"
981 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
982 int result;
983
984 __asm__ __volatile__("@ atomic_sub\n"
985 +"1: ldrex %1, [%3]\n"
986 +" subs %0, %1, %4\n"
987 +
988 +#ifdef CONFIG_PAX_REFCOUNT
989 +" bvc 3f\n"
990 +"2: bkpt 0xf103\n"
991 +"3:\n"
992 +#endif
993 +
994 +" strex %1, %0, [%3]\n"
995 +" teq %1, #0\n"
996 +" bne 1b"
997 +
998 +#ifdef CONFIG_PAX_REFCOUNT
999 +"\n4:\n"
1000 + _ASM_EXTABLE(2b, 4b)
1001 +#endif
1002 +
1003 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1004 + : "r" (&v->counter), "Ir" (i)
1005 + : "cc");
1006 +}
1007 +
1008 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1009 +{
1010 + unsigned long tmp;
1011 + int result;
1012 +
1013 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1014 "1: ldrex %0, [%3]\n"
1015 " sub %0, %0, %4\n"
1016 " strex %1, %0, [%3]\n"
1017 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1018 smp_mb();
1019
1020 __asm__ __volatile__("@ atomic_sub_return\n"
1021 -"1: ldrex %0, [%3]\n"
1022 -" sub %0, %0, %4\n"
1023 +"1: ldrex %1, [%3]\n"
1024 +" subs %0, %1, %4\n"
1025 +
1026 +#ifdef CONFIG_PAX_REFCOUNT
1027 +" bvc 3f\n"
1028 +" mov %0, %1\n"
1029 +"2: bkpt 0xf103\n"
1030 +"3:\n"
1031 +#endif
1032 +
1033 " strex %1, %0, [%3]\n"
1034 " teq %1, #0\n"
1035 " bne 1b"
1036 +
1037 +#ifdef CONFIG_PAX_REFCOUNT
1038 +"\n4:\n"
1039 + _ASM_EXTABLE(2b, 4b)
1040 +#endif
1041 +
1042 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1043 : "r" (&v->counter), "Ir" (i)
1044 : "cc");
1045 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1046 return oldval;
1047 }
1048
1049 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1050 +{
1051 + unsigned long oldval, res;
1052 +
1053 + smp_mb();
1054 +
1055 + do {
1056 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1057 + "ldrex %1, [%3]\n"
1058 + "mov %0, #0\n"
1059 + "teq %1, %4\n"
1060 + "strexeq %0, %5, [%3]\n"
1061 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1062 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1063 + : "cc");
1064 + } while (res);
1065 +
1066 + smp_mb();
1067 +
1068 + return oldval;
1069 +}
1070 +
1071 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1072 {
1073 unsigned long tmp, tmp2;
1074 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1075
1076 return val;
1077 }
1078 +
1079 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1080 +{
1081 + return atomic_add_return(i, v);
1082 +}
1083 +
1084 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1085 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1086 +{
1087 + (void) atomic_add_return(i, v);
1088 +}
1089
1090 static inline int atomic_sub_return(int i, atomic_t *v)
1091 {
1092 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1093 return val;
1094 }
1095 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1096 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1097 +{
1098 + (void) atomic_sub_return(i, v);
1099 +}
1100
1101 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 {
1103 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1104 return ret;
1105 }
1106
1107 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1108 +{
1109 + return atomic_cmpxchg(v, old, new);
1110 +}
1111 +
1112 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1113 {
1114 unsigned long flags;
1115 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1116 #endif /* __LINUX_ARM_ARCH__ */
1117
1118 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1119 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1120 +{
1121 + return xchg(&v->counter, new);
1122 +}
1123
1124 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 {
1126 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1127 }
1128
1129 #define atomic_inc(v) atomic_add(1, v)
1130 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1131 +{
1132 + atomic_add_unchecked(1, v);
1133 +}
1134 #define atomic_dec(v) atomic_sub(1, v)
1135 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1136 +{
1137 + atomic_sub_unchecked(1, v);
1138 +}
1139
1140 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1141 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1142 +{
1143 + return atomic_add_return_unchecked(1, v) == 0;
1144 +}
1145 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1146 #define atomic_inc_return(v) (atomic_add_return(1, v))
1147 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1148 +{
1149 + return atomic_add_return_unchecked(1, v);
1150 +}
1151 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1152 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1153
1154 @@ -241,6 +428,14 @@ typedef struct {
1155 u64 __aligned(8) counter;
1156 } atomic64_t;
1157
1158 +#ifdef CONFIG_PAX_REFCOUNT
1159 +typedef struct {
1160 + u64 __aligned(8) counter;
1161 +} atomic64_unchecked_t;
1162 +#else
1163 +typedef atomic64_t atomic64_unchecked_t;
1164 +#endif
1165 +
1166 #define ATOMIC64_INIT(i) { (i) }
1167
1168 #ifdef CONFIG_ARM_LPAE
1169 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1170 return result;
1171 }
1172
1173 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1174 +{
1175 + u64 result;
1176 +
1177 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1178 +" ldrd %0, %H0, [%1]"
1179 + : "=&r" (result)
1180 + : "r" (&v->counter), "Qo" (v->counter)
1181 + );
1182 +
1183 + return result;
1184 +}
1185 +
1186 static inline void atomic64_set(atomic64_t *v, u64 i)
1187 {
1188 __asm__ __volatile__("@ atomic64_set\n"
1189 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1190 : "r" (&v->counter), "r" (i)
1191 );
1192 }
1193 +
1194 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1195 +{
1196 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1197 +" strd %2, %H2, [%1]"
1198 + : "=Qo" (v->counter)
1199 + : "r" (&v->counter), "r" (i)
1200 + );
1201 +}
1202 #else
1203 static inline u64 atomic64_read(const atomic64_t *v)
1204 {
1205 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1206 return result;
1207 }
1208
1209 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1210 +{
1211 + u64 result;
1212 +
1213 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1214 +" ldrexd %0, %H0, [%1]"
1215 + : "=&r" (result)
1216 + : "r" (&v->counter), "Qo" (v->counter)
1217 + );
1218 +
1219 + return result;
1220 +}
1221 +
1222 static inline void atomic64_set(atomic64_t *v, u64 i)
1223 {
1224 u64 tmp;
1225 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1226 : "r" (&v->counter), "r" (i)
1227 : "cc");
1228 }
1229 +
1230 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1231 +{
1232 + u64 tmp;
1233 +
1234 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1235 +"1: ldrexd %0, %H0, [%2]\n"
1236 +" strexd %0, %3, %H3, [%2]\n"
1237 +" teq %0, #0\n"
1238 +" bne 1b"
1239 + : "=&r" (tmp), "=Qo" (v->counter)
1240 + : "r" (&v->counter), "r" (i)
1241 + : "cc");
1242 +}
1243 +
1244 #endif
1245
1246 static inline void atomic64_add(u64 i, atomic64_t *v)
1247 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1248 __asm__ __volatile__("@ atomic64_add\n"
1249 "1: ldrexd %0, %H0, [%3]\n"
1250 " adds %0, %0, %4\n"
1251 +" adcs %H0, %H0, %H4\n"
1252 +
1253 +#ifdef CONFIG_PAX_REFCOUNT
1254 +" bvc 3f\n"
1255 +"2: bkpt 0xf103\n"
1256 +"3:\n"
1257 +#endif
1258 +
1259 +" strexd %1, %0, %H0, [%3]\n"
1260 +" teq %1, #0\n"
1261 +" bne 1b"
1262 +
1263 +#ifdef CONFIG_PAX_REFCOUNT
1264 +"\n4:\n"
1265 + _ASM_EXTABLE(2b, 4b)
1266 +#endif
1267 +
1268 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1269 + : "r" (&v->counter), "r" (i)
1270 + : "cc");
1271 +}
1272 +
1273 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1274 +{
1275 + u64 result;
1276 + unsigned long tmp;
1277 +
1278 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1279 +"1: ldrexd %0, %H0, [%3]\n"
1280 +" adds %0, %0, %4\n"
1281 " adc %H0, %H0, %H4\n"
1282 " strexd %1, %0, %H0, [%3]\n"
1283 " teq %1, #0\n"
1284 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1285
1286 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1287 {
1288 - u64 result;
1289 - unsigned long tmp;
1290 + u64 result, tmp;
1291
1292 smp_mb();
1293
1294 __asm__ __volatile__("@ atomic64_add_return\n"
1295 +"1: ldrexd %1, %H1, [%3]\n"
1296 +" adds %0, %1, %4\n"
1297 +" adcs %H0, %H1, %H4\n"
1298 +
1299 +#ifdef CONFIG_PAX_REFCOUNT
1300 +" bvc 3f\n"
1301 +" mov %0, %1\n"
1302 +" mov %H0, %H1\n"
1303 +"2: bkpt 0xf103\n"
1304 +"3:\n"
1305 +#endif
1306 +
1307 +" strexd %1, %0, %H0, [%3]\n"
1308 +" teq %1, #0\n"
1309 +" bne 1b"
1310 +
1311 +#ifdef CONFIG_PAX_REFCOUNT
1312 +"\n4:\n"
1313 + _ASM_EXTABLE(2b, 4b)
1314 +#endif
1315 +
1316 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1317 + : "r" (&v->counter), "r" (i)
1318 + : "cc");
1319 +
1320 + smp_mb();
1321 +
1322 + return result;
1323 +}
1324 +
1325 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1326 +{
1327 + u64 result;
1328 + unsigned long tmp;
1329 +
1330 + smp_mb();
1331 +
1332 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1333 "1: ldrexd %0, %H0, [%3]\n"
1334 " adds %0, %0, %4\n"
1335 " adc %H0, %H0, %H4\n"
1336 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1337 __asm__ __volatile__("@ atomic64_sub\n"
1338 "1: ldrexd %0, %H0, [%3]\n"
1339 " subs %0, %0, %4\n"
1340 +" sbcs %H0, %H0, %H4\n"
1341 +
1342 +#ifdef CONFIG_PAX_REFCOUNT
1343 +" bvc 3f\n"
1344 +"2: bkpt 0xf103\n"
1345 +"3:\n"
1346 +#endif
1347 +
1348 +" strexd %1, %0, %H0, [%3]\n"
1349 +" teq %1, #0\n"
1350 +" bne 1b"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +"\n4:\n"
1354 + _ASM_EXTABLE(2b, 4b)
1355 +#endif
1356 +
1357 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1358 + : "r" (&v->counter), "r" (i)
1359 + : "cc");
1360 +}
1361 +
1362 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1363 +{
1364 + u64 result;
1365 + unsigned long tmp;
1366 +
1367 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1368 +"1: ldrexd %0, %H0, [%3]\n"
1369 +" subs %0, %0, %4\n"
1370 " sbc %H0, %H0, %H4\n"
1371 " strexd %1, %0, %H0, [%3]\n"
1372 " teq %1, #0\n"
1373 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1374
1375 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1376 {
1377 - u64 result;
1378 - unsigned long tmp;
1379 + u64 result, tmp;
1380
1381 smp_mb();
1382
1383 __asm__ __volatile__("@ atomic64_sub_return\n"
1384 -"1: ldrexd %0, %H0, [%3]\n"
1385 -" subs %0, %0, %4\n"
1386 -" sbc %H0, %H0, %H4\n"
1387 +"1: ldrexd %1, %H1, [%3]\n"
1388 +" subs %0, %1, %4\n"
1389 +" sbcs %H0, %H1, %H4\n"
1390 +
1391 +#ifdef CONFIG_PAX_REFCOUNT
1392 +" bvc 3f\n"
1393 +" mov %0, %1\n"
1394 +" mov %H0, %H1\n"
1395 +"2: bkpt 0xf103\n"
1396 +"3:\n"
1397 +#endif
1398 +
1399 " strexd %1, %0, %H0, [%3]\n"
1400 " teq %1, #0\n"
1401 " bne 1b"
1402 +
1403 +#ifdef CONFIG_PAX_REFCOUNT
1404 +"\n4:\n"
1405 + _ASM_EXTABLE(2b, 4b)
1406 +#endif
1407 +
1408 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1409 : "r" (&v->counter), "r" (i)
1410 : "cc");
1411 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1412 return oldval;
1413 }
1414
1415 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1416 +{
1417 + u64 oldval;
1418 + unsigned long res;
1419 +
1420 + smp_mb();
1421 +
1422 + do {
1423 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1424 + "ldrexd %1, %H1, [%3]\n"
1425 + "mov %0, #0\n"
1426 + "teq %1, %4\n"
1427 + "teqeq %H1, %H4\n"
1428 + "strexdeq %0, %5, %H5, [%3]"
1429 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1430 + : "r" (&ptr->counter), "r" (old), "r" (new)
1431 + : "cc");
1432 + } while (res);
1433 +
1434 + smp_mb();
1435 +
1436 + return oldval;
1437 +}
1438 +
1439 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1440 {
1441 u64 result;
1442 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1443
1444 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1445 {
1446 - u64 result;
1447 - unsigned long tmp;
1448 + u64 result, tmp;
1449
1450 smp_mb();
1451
1452 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1453 -"1: ldrexd %0, %H0, [%3]\n"
1454 -" subs %0, %0, #1\n"
1455 -" sbc %H0, %H0, #0\n"
1456 +"1: ldrexd %1, %H1, [%3]\n"
1457 +" subs %0, %1, #1\n"
1458 +" sbcs %H0, %H1, #0\n"
1459 +
1460 +#ifdef CONFIG_PAX_REFCOUNT
1461 +" bvc 3f\n"
1462 +" mov %0, %1\n"
1463 +" mov %H0, %H1\n"
1464 +"2: bkpt 0xf103\n"
1465 +"3:\n"
1466 +#endif
1467 +
1468 " teq %H0, #0\n"
1469 -" bmi 2f\n"
1470 +" bmi 4f\n"
1471 " strexd %1, %0, %H0, [%3]\n"
1472 " teq %1, #0\n"
1473 " bne 1b\n"
1474 -"2:"
1475 +"4:\n"
1476 +
1477 +#ifdef CONFIG_PAX_REFCOUNT
1478 + _ASM_EXTABLE(2b, 4b)
1479 +#endif
1480 +
1481 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1482 : "r" (&v->counter)
1483 : "cc");
1484 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1485 " teq %0, %5\n"
1486 " teqeq %H0, %H5\n"
1487 " moveq %1, #0\n"
1488 -" beq 2f\n"
1489 +" beq 4f\n"
1490 " adds %0, %0, %6\n"
1491 -" adc %H0, %H0, %H6\n"
1492 +" adcs %H0, %H0, %H6\n"
1493 +
1494 +#ifdef CONFIG_PAX_REFCOUNT
1495 +" bvc 3f\n"
1496 +"2: bkpt 0xf103\n"
1497 +"3:\n"
1498 +#endif
1499 +
1500 " strexd %2, %0, %H0, [%4]\n"
1501 " teq %2, #0\n"
1502 " bne 1b\n"
1503 -"2:"
1504 +"4:\n"
1505 +
1506 +#ifdef CONFIG_PAX_REFCOUNT
1507 + _ASM_EXTABLE(2b, 4b)
1508 +#endif
1509 +
1510 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1511 : "r" (&v->counter), "r" (u), "r" (a)
1512 : "cc");
1513 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1514
1515 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1516 #define atomic64_inc(v) atomic64_add(1LL, (v))
1517 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1518 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1519 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1520 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1521 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1522 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1523 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1524 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1525 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1526 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1527 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1528 index 75fe66b..ba3dee4 100644
1529 --- a/arch/arm/include/asm/cache.h
1530 +++ b/arch/arm/include/asm/cache.h
1531 @@ -4,8 +4,10 @@
1532 #ifndef __ASMARM_CACHE_H
1533 #define __ASMARM_CACHE_H
1534
1535 +#include <linux/const.h>
1536 +
1537 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1538 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1539 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1540
1541 /*
1542 * Memory returned by kmalloc() may be used for DMA, so we must make
1543 @@ -24,5 +26,6 @@
1544 #endif
1545
1546 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1547 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1548
1549 #endif
1550 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1551 index 15f2d5b..43ffa53 100644
1552 --- a/arch/arm/include/asm/cacheflush.h
1553 +++ b/arch/arm/include/asm/cacheflush.h
1554 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1555 void (*dma_unmap_area)(const void *, size_t, int);
1556
1557 void (*dma_flush_range)(const void *, const void *);
1558 -};
1559 +} __no_const;
1560
1561 /*
1562 * Select the calling method
1563 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1564 index 6dcc164..b14d917 100644
1565 --- a/arch/arm/include/asm/checksum.h
1566 +++ b/arch/arm/include/asm/checksum.h
1567 @@ -37,7 +37,19 @@ __wsum
1568 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1569
1570 __wsum
1571 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1572 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1573 +
1574 +static inline __wsum
1575 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1576 +{
1577 + __wsum ret;
1578 + pax_open_userland();
1579 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1580 + pax_close_userland();
1581 + return ret;
1582 +}
1583 +
1584 +
1585
1586 /*
1587 * Fold a partial checksum without adding pseudo headers
1588 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1589 index 4f009c1..466c59b 100644
1590 --- a/arch/arm/include/asm/cmpxchg.h
1591 +++ b/arch/arm/include/asm/cmpxchg.h
1592 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1593
1594 #define xchg(ptr,x) \
1595 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1596 +#define xchg_unchecked(ptr,x) \
1597 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1598
1599 #include <asm-generic/cmpxchg-local.h>
1600
1601 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1602 index 6ddbe44..b5e38b1 100644
1603 --- a/arch/arm/include/asm/domain.h
1604 +++ b/arch/arm/include/asm/domain.h
1605 @@ -48,18 +48,37 @@
1606 * Domain types
1607 */
1608 #define DOMAIN_NOACCESS 0
1609 -#define DOMAIN_CLIENT 1
1610 #ifdef CONFIG_CPU_USE_DOMAINS
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_KERNELCLIENT 1
1613 #define DOMAIN_MANAGER 3
1614 +#define DOMAIN_VECTORS DOMAIN_USER
1615 #else
1616 +
1617 +#ifdef CONFIG_PAX_KERNEXEC
1618 #define DOMAIN_MANAGER 1
1619 +#define DOMAIN_KERNEXEC 3
1620 +#else
1621 +#define DOMAIN_MANAGER 1
1622 +#endif
1623 +
1624 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1625 +#define DOMAIN_USERCLIENT 0
1626 +#define DOMAIN_UDEREF 1
1627 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1628 +#else
1629 +#define DOMAIN_USERCLIENT 1
1630 +#define DOMAIN_VECTORS DOMAIN_USER
1631 +#endif
1632 +#define DOMAIN_KERNELCLIENT 1
1633 +
1634 #endif
1635
1636 #define domain_val(dom,type) ((type) << (2*(dom)))
1637
1638 #ifndef __ASSEMBLY__
1639
1640 -#ifdef CONFIG_CPU_USE_DOMAINS
1641 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1642 static inline void set_domain(unsigned val)
1643 {
1644 asm volatile(
1645 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1646 isb();
1647 }
1648
1649 -#define modify_domain(dom,type) \
1650 - do { \
1651 - struct thread_info *thread = current_thread_info(); \
1652 - unsigned int domain = thread->cpu_domain; \
1653 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1654 - thread->cpu_domain = domain | domain_val(dom, type); \
1655 - set_domain(thread->cpu_domain); \
1656 - } while (0)
1657 -
1658 +extern void modify_domain(unsigned int dom, unsigned int type);
1659 #else
1660 static inline void set_domain(unsigned val) { }
1661 static inline void modify_domain(unsigned dom, unsigned type) { }
1662 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1663 index f4b46d3..abc9b2b 100644
1664 --- a/arch/arm/include/asm/elf.h
1665 +++ b/arch/arm/include/asm/elf.h
1666 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1667 the loader. We need to make sure that it is out of the way of the program
1668 that it will "exec", and that there is sufficient room for the brk. */
1669
1670 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1671 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1672 +
1673 +#ifdef CONFIG_PAX_ASLR
1674 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1675 +
1676 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1677 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1678 +#endif
1679
1680 /* When the program starts, a1 contains a pointer to a function to be
1681 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1682 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1683 extern void elf_set_personality(const struct elf32_hdr *);
1684 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1685
1686 -struct mm_struct;
1687 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1688 -#define arch_randomize_brk arch_randomize_brk
1689 -
1690 #ifdef CONFIG_MMU
1691 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1692 struct linux_binprm;
1693 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1694 index de53547..52b9a28 100644
1695 --- a/arch/arm/include/asm/fncpy.h
1696 +++ b/arch/arm/include/asm/fncpy.h
1697 @@ -81,7 +81,9 @@
1698 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1699 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1700 \
1701 + pax_open_kernel(); \
1702 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1703 + pax_close_kernel(); \
1704 flush_icache_range((unsigned long)(dest_buf), \
1705 (unsigned long)(dest_buf) + (size)); \
1706 \
1707 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1708 index e42cf59..7b94b8f 100644
1709 --- a/arch/arm/include/asm/futex.h
1710 +++ b/arch/arm/include/asm/futex.h
1711 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 smp_mb();
1718 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1719 "1: ldrex %1, [%4]\n"
1720 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "cc", "memory");
1722 smp_mb();
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1730 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1731 return -EFAULT;
1732
1733 + pax_open_userland();
1734 +
1735 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1736 "1: " TUSER(ldr) " %1, [%4]\n"
1737 " teq %1, %2\n"
1738 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1739 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1740 : "cc", "memory");
1741
1742 + pax_close_userland();
1743 +
1744 *uval = val;
1745 return ret;
1746 }
1747 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1748 return -EFAULT;
1749
1750 pagefault_disable(); /* implies preempt_disable() */
1751 + pax_open_userland();
1752
1753 switch (op) {
1754 case FUTEX_OP_SET:
1755 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1756 ret = -ENOSYS;
1757 }
1758
1759 + pax_close_userland();
1760 pagefault_enable(); /* subsumes preempt_enable() */
1761
1762 if (!ret) {
1763 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1764 index 83eb2f7..ed77159 100644
1765 --- a/arch/arm/include/asm/kmap_types.h
1766 +++ b/arch/arm/include/asm/kmap_types.h
1767 @@ -4,6 +4,6 @@
1768 /*
1769 * This is the "bare minimum". AIO seems to require this.
1770 */
1771 -#define KM_TYPE_NR 16
1772 +#define KM_TYPE_NR 17
1773
1774 #endif
1775 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1776 index 9e614a1..3302cca 100644
1777 --- a/arch/arm/include/asm/mach/dma.h
1778 +++ b/arch/arm/include/asm/mach/dma.h
1779 @@ -22,7 +22,7 @@ struct dma_ops {
1780 int (*residue)(unsigned int, dma_t *); /* optional */
1781 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1782 const char *type;
1783 -};
1784 +} __do_const;
1785
1786 struct dma_struct {
1787 void *addr; /* single DMA address */
1788 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1789 index 2fe141f..192dc01 100644
1790 --- a/arch/arm/include/asm/mach/map.h
1791 +++ b/arch/arm/include/asm/mach/map.h
1792 @@ -27,13 +27,16 @@ struct map_desc {
1793 #define MT_MINICLEAN 6
1794 #define MT_LOW_VECTORS 7
1795 #define MT_HIGH_VECTORS 8
1796 -#define MT_MEMORY 9
1797 +#define MT_MEMORY_RWX 9
1798 #define MT_ROM 10
1799 -#define MT_MEMORY_NONCACHED 11
1800 +#define MT_MEMORY_NONCACHED_RX 11
1801 #define MT_MEMORY_DTCM 12
1802 #define MT_MEMORY_ITCM 13
1803 #define MT_MEMORY_SO 14
1804 #define MT_MEMORY_DMA_READY 15
1805 +#define MT_MEMORY_RW 16
1806 +#define MT_MEMORY_RX 17
1807 +#define MT_MEMORY_NONCACHED_RW 18
1808
1809 #ifdef CONFIG_MMU
1810 extern void iotable_init(struct map_desc *, int);
1811 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1812 index f94784f..9a09a4a 100644
1813 --- a/arch/arm/include/asm/outercache.h
1814 +++ b/arch/arm/include/asm/outercache.h
1815 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1816 #endif
1817 void (*set_debug)(unsigned long);
1818 void (*resume)(void);
1819 -};
1820 +} __no_const;
1821
1822 extern struct outer_cache_fns outer_cache;
1823
1824 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1825 index 4355f0e..c229913 100644
1826 --- a/arch/arm/include/asm/page.h
1827 +++ b/arch/arm/include/asm/page.h
1828 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1829 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1830 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1831 unsigned long vaddr, struct vm_area_struct *vma);
1832 -};
1833 +} __no_const;
1834
1835 #ifdef MULTI_USER
1836 extern struct cpu_user_fns cpu_user;
1837 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1838 index 943504f..c37a730 100644
1839 --- a/arch/arm/include/asm/pgalloc.h
1840 +++ b/arch/arm/include/asm/pgalloc.h
1841 @@ -17,6 +17,7 @@
1842 #include <asm/processor.h>
1843 #include <asm/cacheflush.h>
1844 #include <asm/tlbflush.h>
1845 +#include <asm/system_info.h>
1846
1847 #define check_pgt_cache() do { } while (0)
1848
1849 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1850 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1851 }
1852
1853 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1854 +{
1855 + pud_populate(mm, pud, pmd);
1856 +}
1857 +
1858 #else /* !CONFIG_ARM_LPAE */
1859
1860 /*
1861 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1862 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1863 #define pmd_free(mm, pmd) do { } while (0)
1864 #define pud_populate(mm,pmd,pte) BUG()
1865 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1866
1867 #endif /* CONFIG_ARM_LPAE */
1868
1869 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1870 __free_page(pte);
1871 }
1872
1873 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1874 +{
1875 +#ifdef CONFIG_ARM_LPAE
1876 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1877 +#else
1878 + if (addr & SECTION_SIZE)
1879 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1880 + else
1881 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1882 +#endif
1883 + flush_pmd_entry(pmdp);
1884 +}
1885 +
1886 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1887 pmdval_t prot)
1888 {
1889 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1890 static inline void
1891 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1892 {
1893 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1894 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1895 }
1896 #define pmd_pgtable(pmd) pmd_page(pmd)
1897
1898 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1899 index 5cfba15..f415e1a 100644
1900 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1901 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1902 @@ -20,12 +20,15 @@
1903 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1904 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1905 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1906 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1907 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1908 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1909 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1910 +
1911 /*
1912 * - section
1913 */
1914 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1915 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1916 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1917 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1918 @@ -37,6 +40,7 @@
1919 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1920 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1921 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1922 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1923
1924 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1925 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1926 @@ -66,6 +70,7 @@
1927 * - extended small page/tiny page
1928 */
1929 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1930 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1931 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1932 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1933 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1934 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1935 index f97ee02..cc9fe9e 100644
1936 --- a/arch/arm/include/asm/pgtable-2level.h
1937 +++ b/arch/arm/include/asm/pgtable-2level.h
1938 @@ -126,6 +126,9 @@
1939 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1940 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1941
1942 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1943 +#define L_PTE_PXN (_AT(pteval_t, 0))
1944 +
1945 /*
1946 * These are the memory types, defined to be compatible with
1947 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1948 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1949 index 626989f..9d67a33 100644
1950 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1951 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1952 @@ -75,6 +75,7 @@
1953 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1954 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1955 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1956 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1957 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1958
1959 /*
1960 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1961 index 5689c18..eea12f9 100644
1962 --- a/arch/arm/include/asm/pgtable-3level.h
1963 +++ b/arch/arm/include/asm/pgtable-3level.h
1964 @@ -82,6 +82,7 @@
1965 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1966 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1967 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1968 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1969 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1970 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1971 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1972 @@ -95,6 +96,7 @@
1973 /*
1974 * To be used in assembly code with the upper page attributes.
1975 */
1976 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1977 #define L_PTE_XN_HIGH (1 << (54 - 32))
1978 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1979
1980 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1981 index 1571d12..b8a9b43 100644
1982 --- a/arch/arm/include/asm/pgtable.h
1983 +++ b/arch/arm/include/asm/pgtable.h
1984 @@ -33,6 +33,9 @@
1985 #include <asm/pgtable-2level.h>
1986 #endif
1987
1988 +#define ktla_ktva(addr) (addr)
1989 +#define ktva_ktla(addr) (addr)
1990 +
1991 /*
1992 * Just any arbitrary offset to the start of the vmalloc VM area: the
1993 * current 8MB value just means that there will be a 8MB "hole" after the
1994 @@ -48,6 +51,9 @@
1995 #define LIBRARY_TEXT_START 0x0c000000
1996
1997 #ifndef __ASSEMBLY__
1998 +extern pteval_t __supported_pte_mask;
1999 +extern pmdval_t __supported_pmd_mask;
2000 +
2001 extern void __pte_error(const char *file, int line, pte_t);
2002 extern void __pmd_error(const char *file, int line, pmd_t);
2003 extern void __pgd_error(const char *file, int line, pgd_t);
2004 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2005 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2006 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2007
2008 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2009 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2010 +
2011 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2012 +#include <asm/domain.h>
2013 +#include <linux/thread_info.h>
2014 +#include <linux/preempt.h>
2015 +
2016 +static inline int test_domain(int domain, int domaintype)
2017 +{
2018 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2019 +}
2020 +#endif
2021 +
2022 +#ifdef CONFIG_PAX_KERNEXEC
2023 +static inline unsigned long pax_open_kernel(void) {
2024 +#ifdef CONFIG_ARM_LPAE
2025 + /* TODO */
2026 +#else
2027 + preempt_disable();
2028 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2029 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2030 +#endif
2031 + return 0;
2032 +}
2033 +
2034 +static inline unsigned long pax_close_kernel(void) {
2035 +#ifdef CONFIG_ARM_LPAE
2036 + /* TODO */
2037 +#else
2038 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2039 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2040 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2041 + preempt_enable_no_resched();
2042 +#endif
2043 + return 0;
2044 +}
2045 +#else
2046 +static inline unsigned long pax_open_kernel(void) { return 0; }
2047 +static inline unsigned long pax_close_kernel(void) { return 0; }
2048 +#endif
2049 +
2050 /*
2051 * This is the lowest virtual address we can permit any user space
2052 * mapping to be mapped at. This is particularly important for
2053 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2054 /*
2055 * The pgprot_* and protection_map entries will be fixed up in runtime
2056 * to include the cachable and bufferable bits based on memory policy,
2057 - * as well as any architecture dependent bits like global/ASID and SMP
2058 - * shared mapping bits.
2059 + * as well as any architecture dependent bits like global/ASID, PXN,
2060 + * and SMP shared mapping bits.
2061 */
2062 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2063
2064 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2065 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2066 {
2067 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2068 - L_PTE_NONE | L_PTE_VALID;
2069 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2070 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2071 return pte;
2072 }
2073 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2074 index 5324c11..bcae5f0 100644
2075 --- a/arch/arm/include/asm/proc-fns.h
2076 +++ b/arch/arm/include/asm/proc-fns.h
2077 @@ -75,7 +75,7 @@ extern struct processor {
2078 unsigned int suspend_size;
2079 void (*do_suspend)(void *);
2080 void (*do_resume)(void *);
2081 -} processor;
2082 +} __do_const processor;
2083
2084 #ifndef MULTI_CPU
2085 extern void cpu_proc_init(void);
2086 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2087 index c4ae171..ea0c0c2 100644
2088 --- a/arch/arm/include/asm/psci.h
2089 +++ b/arch/arm/include/asm/psci.h
2090 @@ -29,7 +29,7 @@ struct psci_operations {
2091 int (*cpu_off)(struct psci_power_state state);
2092 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2093 int (*migrate)(unsigned long cpuid);
2094 -};
2095 +} __no_const;
2096
2097 extern struct psci_operations psci_ops;
2098 extern struct smp_operations psci_smp_ops;
2099 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2100 index a8cae71c..65dd797 100644
2101 --- a/arch/arm/include/asm/smp.h
2102 +++ b/arch/arm/include/asm/smp.h
2103 @@ -110,7 +110,7 @@ struct smp_operations {
2104 int (*cpu_disable)(unsigned int cpu);
2105 #endif
2106 #endif
2107 -};
2108 +} __no_const;
2109
2110 /*
2111 * set platform specific SMP operations
2112 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2113 index df5e13d..97efb82 100644
2114 --- a/arch/arm/include/asm/thread_info.h
2115 +++ b/arch/arm/include/asm/thread_info.h
2116 @@ -88,9 +88,9 @@ struct thread_info {
2117 .flags = 0, \
2118 .preempt_count = INIT_PREEMPT_COUNT, \
2119 .addr_limit = KERNEL_DS, \
2120 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2121 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2122 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2123 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2124 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2125 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2126 .restart_block = { \
2127 .fn = do_no_restart_syscall, \
2128 }, \
2129 @@ -163,7 +163,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2130 #define TIF_SYSCALL_AUDIT 9
2131 #define TIF_SYSCALL_TRACEPOINT 10
2132 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2133 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2134 +/* within 8 bits of TIF_SYSCALL_TRACE
2135 + * to meet flexible second operand requirements
2136 + */
2137 +#define TIF_GRSEC_SETXID 12
2138 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2139 #define TIF_USING_IWMMXT 17
2140 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2141 #define TIF_RESTORE_SIGMASK 20
2142 @@ -176,10 +180,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2143 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2144 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2145 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2146 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2147
2148 /* Checks for any syscall work in entry-common.S */
2149 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2150 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2151 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2152
2153 /*
2154 * Change these and you break ASM code in entry-common.S
2155 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2156 index 72abdc5..9eba222 100644
2157 --- a/arch/arm/include/asm/uaccess.h
2158 +++ b/arch/arm/include/asm/uaccess.h
2159 @@ -18,6 +18,7 @@
2160 #include <asm/domain.h>
2161 #include <asm/unified.h>
2162 #include <asm/compiler.h>
2163 +#include <asm/pgtable.h>
2164
2165 #if __LINUX_ARM_ARCH__ < 6
2166 #include <asm-generic/uaccess-unaligned.h>
2167 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2168 static inline void set_fs(mm_segment_t fs)
2169 {
2170 current_thread_info()->addr_limit = fs;
2171 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2172 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2173 }
2174
2175 #define segment_eq(a,b) ((a) == (b))
2176
2177 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2178 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2179 +
2180 +static inline void pax_open_userland(void)
2181 +{
2182 +
2183 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2184 + if (segment_eq(get_fs(), USER_DS)) {
2185 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2186 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2187 + }
2188 +#endif
2189 +
2190 +}
2191 +
2192 +static inline void pax_close_userland(void)
2193 +{
2194 +
2195 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2196 + if (segment_eq(get_fs(), USER_DS)) {
2197 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2198 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2199 + }
2200 +#endif
2201 +
2202 +}
2203 +
2204 #define __addr_ok(addr) ({ \
2205 unsigned long flag; \
2206 __asm__("cmp %2, %0; movlo %0, #0" \
2207 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2208
2209 #define get_user(x,p) \
2210 ({ \
2211 + int __e; \
2212 might_fault(); \
2213 - __get_user_check(x,p); \
2214 + pax_open_userland(); \
2215 + __e = __get_user_check(x,p); \
2216 + pax_close_userland(); \
2217 + __e; \
2218 })
2219
2220 extern int __put_user_1(void *, unsigned int);
2221 @@ -195,8 +227,12 @@ extern int __put_user_8(void *, unsigned long long);
2222
2223 #define put_user(x,p) \
2224 ({ \
2225 + int __e; \
2226 might_fault(); \
2227 - __put_user_check(x,p); \
2228 + pax_open_userland(); \
2229 + __e = __put_user_check(x,p); \
2230 + pax_close_userland(); \
2231 + __e; \
2232 })
2233
2234 #else /* CONFIG_MMU */
2235 @@ -237,13 +273,17 @@ static inline void set_fs(mm_segment_t fs)
2236 #define __get_user(x,ptr) \
2237 ({ \
2238 long __gu_err = 0; \
2239 + pax_open_userland(); \
2240 __get_user_err((x),(ptr),__gu_err); \
2241 + pax_close_userland(); \
2242 __gu_err; \
2243 })
2244
2245 #define __get_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __get_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -319,13 +359,17 @@ do { \
2254 #define __put_user(x,ptr) \
2255 ({ \
2256 long __pu_err = 0; \
2257 + pax_open_userland(); \
2258 __put_user_err((x),(ptr),__pu_err); \
2259 + pax_close_userland(); \
2260 __pu_err; \
2261 })
2262
2263 #define __put_user_error(x,ptr,err) \
2264 ({ \
2265 + pax_open_userland(); \
2266 __put_user_err((x),(ptr),err); \
2267 + pax_close_userland(); \
2268 (void) 0; \
2269 })
2270
2271 @@ -425,11 +469,44 @@ do { \
2272
2273
2274 #ifdef CONFIG_MMU
2275 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2276 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2277 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2278 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2279 +
2280 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2281 +{
2282 + unsigned long ret;
2283 +
2284 + check_object_size(to, n, false);
2285 + pax_open_userland();
2286 + ret = ___copy_from_user(to, from, n);
2287 + pax_close_userland();
2288 + return ret;
2289 +}
2290 +
2291 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2292 +{
2293 + unsigned long ret;
2294 +
2295 + check_object_size(from, n, true);
2296 + pax_open_userland();
2297 + ret = ___copy_to_user(to, from, n);
2298 + pax_close_userland();
2299 + return ret;
2300 +}
2301 +
2302 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2303 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2304 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2305 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2306 +
2307 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2308 +{
2309 + unsigned long ret;
2310 + pax_open_userland();
2311 + ret = ___clear_user(addr, n);
2312 + pax_close_userland();
2313 + return ret;
2314 +}
2315 +
2316 #else
2317 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2318 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2319 @@ -438,6 +515,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2320
2321 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2322 {
2323 + if ((long)n < 0)
2324 + return n;
2325 +
2326 if (access_ok(VERIFY_READ, from, n))
2327 n = __copy_from_user(to, from, n);
2328 else /* security hole - plug it */
2329 @@ -447,6 +527,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2330
2331 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2332 {
2333 + if ((long)n < 0)
2334 + return n;
2335 +
2336 if (access_ok(VERIFY_WRITE, to, n))
2337 n = __copy_to_user(to, from, n);
2338 return n;
2339 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2340 index 5af0ed1..cea83883 100644
2341 --- a/arch/arm/include/uapi/asm/ptrace.h
2342 +++ b/arch/arm/include/uapi/asm/ptrace.h
2343 @@ -92,7 +92,7 @@
2344 * ARMv7 groups of PSR bits
2345 */
2346 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2347 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2348 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2349 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2350 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2351
2352 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2353 index 60d3b73..e5a0f22 100644
2354 --- a/arch/arm/kernel/armksyms.c
2355 +++ b/arch/arm/kernel/armksyms.c
2356 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2357
2358 /* networking */
2359 EXPORT_SYMBOL(csum_partial);
2360 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2361 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2362 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2363 EXPORT_SYMBOL(__csum_ipv6_magic);
2364
2365 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2366 #ifdef CONFIG_MMU
2367 EXPORT_SYMBOL(copy_page);
2368
2369 -EXPORT_SYMBOL(__copy_from_user);
2370 -EXPORT_SYMBOL(__copy_to_user);
2371 -EXPORT_SYMBOL(__clear_user);
2372 +EXPORT_SYMBOL(___copy_from_user);
2373 +EXPORT_SYMBOL(___copy_to_user);
2374 +EXPORT_SYMBOL(___clear_user);
2375
2376 EXPORT_SYMBOL(__get_user_1);
2377 EXPORT_SYMBOL(__get_user_2);
2378 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2379 index ec3e5cf..b450ee3 100644
2380 --- a/arch/arm/kernel/entry-armv.S
2381 +++ b/arch/arm/kernel/entry-armv.S
2382 @@ -47,6 +47,87 @@
2383 9997:
2384 .endm
2385
2386 + .macro pax_enter_kernel
2387 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2388 + @ make aligned space for saved DACR
2389 + sub sp, sp, #8
2390 + @ save regs
2391 + stmdb sp!, {r1, r2}
2392 + @ read DACR from cpu_domain into r1
2393 + mov r2, sp
2394 + @ assume 8K pages, since we have to split the immediate in two
2395 + bic r2, r2, #(0x1fc0)
2396 + bic r2, r2, #(0x3f)
2397 + ldr r1, [r2, #TI_CPU_DOMAIN]
2398 + @ store old DACR on stack
2399 + str r1, [sp, #8]
2400 +#ifdef CONFIG_PAX_KERNEXEC
2401 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2402 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2403 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2404 +#endif
2405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2406 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2407 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2408 +#endif
2409 + @ write r1 to current_thread_info()->cpu_domain
2410 + str r1, [r2, #TI_CPU_DOMAIN]
2411 + @ write r1 to DACR
2412 + mcr p15, 0, r1, c3, c0, 0
2413 + @ instruction sync
2414 + instr_sync
2415 + @ restore regs
2416 + ldmia sp!, {r1, r2}
2417 +#endif
2418 + .endm
2419 +
2420 + .macro pax_open_userland
2421 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2422 + @ save regs
2423 + stmdb sp!, {r0, r1}
2424 + @ read DACR from cpu_domain into r1
2425 + mov r0, sp
2426 + @ assume 8K pages, since we have to split the immediate in two
2427 + bic r0, r0, #(0x1fc0)
2428 + bic r0, r0, #(0x3f)
2429 + ldr r1, [r0, #TI_CPU_DOMAIN]
2430 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2431 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2432 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2433 + @ write r1 to current_thread_info()->cpu_domain
2434 + str r1, [r0, #TI_CPU_DOMAIN]
2435 + @ write r1 to DACR
2436 + mcr p15, 0, r1, c3, c0, 0
2437 + @ instruction sync
2438 + instr_sync
2439 + @ restore regs
2440 + ldmia sp!, {r0, r1}
2441 +#endif
2442 + .endm
2443 +
2444 + .macro pax_close_userland
2445 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2446 + @ save regs
2447 + stmdb sp!, {r0, r1}
2448 + @ read DACR from cpu_domain into r1
2449 + mov r0, sp
2450 + @ assume 8K pages, since we have to split the immediate in two
2451 + bic r0, r0, #(0x1fc0)
2452 + bic r0, r0, #(0x3f)
2453 + ldr r1, [r0, #TI_CPU_DOMAIN]
2454 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2455 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2456 + @ write r1 to current_thread_info()->cpu_domain
2457 + str r1, [r0, #TI_CPU_DOMAIN]
2458 + @ write r1 to DACR
2459 + mcr p15, 0, r1, c3, c0, 0
2460 + @ instruction sync
2461 + instr_sync
2462 + @ restore regs
2463 + ldmia sp!, {r0, r1}
2464 +#endif
2465 + .endm
2466 +
2467 .macro pabt_helper
2468 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2469 #ifdef MULTI_PABORT
2470 @@ -89,11 +170,15 @@
2471 * Invalid mode handlers
2472 */
2473 .macro inv_entry, reason
2474 +
2475 + pax_enter_kernel
2476 +
2477 sub sp, sp, #S_FRAME_SIZE
2478 ARM( stmib sp, {r1 - lr} )
2479 THUMB( stmia sp, {r0 - r12} )
2480 THUMB( str sp, [sp, #S_SP] )
2481 THUMB( str lr, [sp, #S_LR] )
2482 +
2483 mov r1, #\reason
2484 .endm
2485
2486 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2487 .macro svc_entry, stack_hole=0
2488 UNWIND(.fnstart )
2489 UNWIND(.save {r0 - pc} )
2490 +
2491 + pax_enter_kernel
2492 +
2493 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2494 +
2495 #ifdef CONFIG_THUMB2_KERNEL
2496 SPFIX( str r0, [sp] ) @ temporarily saved
2497 SPFIX( mov r0, sp )
2498 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2499 ldmia r0, {r3 - r5}
2500 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2501 mov r6, #-1 @ "" "" "" ""
2502 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2503 + @ offset sp by 8 as done in pax_enter_kernel
2504 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2505 +#else
2506 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2507 +#endif
2508 SPFIX( addeq r2, r2, #4 )
2509 str r3, [sp, #-4]! @ save the "real" r0 copied
2510 @ from the exception stack
2511 @@ -317,6 +411,9 @@ ENDPROC(__pabt_svc)
2512 .macro usr_entry
2513 UNWIND(.fnstart )
2514 UNWIND(.cantunwind ) @ don't unwind the user space
2515 +
2516 + pax_enter_kernel_user
2517 +
2518 sub sp, sp, #S_FRAME_SIZE
2519 ARM( stmib sp, {r1 - r12} )
2520 THUMB( stmia sp, {r0 - r12} )
2521 @@ -416,7 +513,9 @@ __und_usr:
2522 tst r3, #PSR_T_BIT @ Thumb mode?
2523 bne __und_usr_thumb
2524 sub r4, r2, #4 @ ARM instr at LR - 4
2525 + pax_open_userland
2526 1: ldrt r0, [r4]
2527 + pax_close_userland
2528 #ifdef CONFIG_CPU_ENDIAN_BE8
2529 rev r0, r0 @ little endian instruction
2530 #endif
2531 @@ -451,10 +550,14 @@ __und_usr_thumb:
2532 */
2533 .arch armv6t2
2534 #endif
2535 + pax_open_userland
2536 2: ldrht r5, [r4]
2537 + pax_close_userland
2538 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2539 blo __und_usr_fault_16 @ 16bit undefined instruction
2540 + pax_open_userland
2541 3: ldrht r0, [r2]
2542 + pax_close_userland
2543 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2544 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2545 orr r0, r0, r5, lsl #16
2546 @@ -483,7 +586,8 @@ ENDPROC(__und_usr)
2547 */
2548 .pushsection .fixup, "ax"
2549 .align 2
2550 -4: mov pc, r9
2551 +4: pax_close_userland
2552 + mov pc, r9
2553 .popsection
2554 .pushsection __ex_table,"a"
2555 .long 1b, 4b
2556 @@ -693,7 +797,7 @@ ENTRY(__switch_to)
2557 THUMB( str lr, [ip], #4 )
2558 ldr r4, [r2, #TI_TP_VALUE]
2559 ldr r5, [r2, #TI_TP_VALUE + 4]
2560 -#ifdef CONFIG_CPU_USE_DOMAINS
2561 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2562 ldr r6, [r2, #TI_CPU_DOMAIN]
2563 #endif
2564 switch_tls r1, r4, r5, r3, r7
2565 @@ -702,7 +806,7 @@ ENTRY(__switch_to)
2566 ldr r8, =__stack_chk_guard
2567 ldr r7, [r7, #TSK_STACK_CANARY]
2568 #endif
2569 -#ifdef CONFIG_CPU_USE_DOMAINS
2570 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2572 #endif
2573 mov r5, r0
2574 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2575 index bc6bd96..bd026cb 100644
2576 --- a/arch/arm/kernel/entry-common.S
2577 +++ b/arch/arm/kernel/entry-common.S
2578 @@ -10,18 +10,46 @@
2579
2580 #include <asm/unistd.h>
2581 #include <asm/ftrace.h>
2582 +#include <asm/domain.h>
2583 #include <asm/unwind.h>
2584
2585 +#include "entry-header.S"
2586 +
2587 #ifdef CONFIG_NEED_RET_TO_USER
2588 #include <mach/entry-macro.S>
2589 #else
2590 .macro arch_ret_to_user, tmp1, tmp2
2591 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2592 + @ save regs
2593 + stmdb sp!, {r1, r2}
2594 + @ read DACR from cpu_domain into r1
2595 + mov r2, sp
2596 + @ assume 8K pages, since we have to split the immediate in two
2597 + bic r2, r2, #(0x1fc0)
2598 + bic r2, r2, #(0x3f)
2599 + ldr r1, [r2, #TI_CPU_DOMAIN]
2600 +#ifdef CONFIG_PAX_KERNEXEC
2601 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2602 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2603 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2604 +#endif
2605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2606 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2607 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2608 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2609 +#endif
2610 + @ write r1 to current_thread_info()->cpu_domain
2611 + str r1, [r2, #TI_CPU_DOMAIN]
2612 + @ write r1 to DACR
2613 + mcr p15, 0, r1, c3, c0, 0
2614 + @ instruction sync
2615 + instr_sync
2616 + @ restore regs
2617 + ldmia sp!, {r1, r2}
2618 +#endif
2619 .endm
2620 #endif
2621
2622 -#include "entry-header.S"
2623 -
2624 -
2625 .align 5
2626 /*
2627 * This is the fast syscall return path. We do as little as
2628 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2629 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2630 #endif
2631
2632 + /*
2633 + * do this here to avoid a performance hit of wrapping the code above
2634 + * that directly dereferences userland to parse the SWI instruction
2635 + */
2636 + pax_enter_kernel_user
2637 +
2638 adr tbl, sys_call_table @ load syscall table pointer
2639
2640 #if defined(CONFIG_OABI_COMPAT)
2641 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2642 index 39f89fb..d612bd9 100644
2643 --- a/arch/arm/kernel/entry-header.S
2644 +++ b/arch/arm/kernel/entry-header.S
2645 @@ -184,6 +184,60 @@
2646 msr cpsr_c, \rtemp @ switch back to the SVC mode
2647 .endm
2648
2649 + .macro pax_enter_kernel_user
2650 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2651 + @ save regs
2652 + stmdb sp!, {r0, r1}
2653 + @ read DACR from cpu_domain into r1
2654 + mov r0, sp
2655 + @ assume 8K pages, since we have to split the immediate in two
2656 + bic r0, r0, #(0x1fc0)
2657 + bic r0, r0, #(0x3f)
2658 + ldr r1, [r0, #TI_CPU_DOMAIN]
2659 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2660 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2661 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2662 +#endif
2663 +#ifdef CONFIG_PAX_KERNEXEC
2664 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2665 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r0, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r0, r1}
2676 +#endif
2677 + .endm
2678 +
2679 + .macro pax_exit_kernel
2680 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2681 + @ save regs
2682 + stmdb sp!, {r0, r1}
2683 + @ read old DACR from stack into r1
2684 + ldr r1, [sp, #(8 + S_SP)]
2685 + sub r1, r1, #8
2686 + ldr r1, [r1]
2687 +
2688 + @ write r1 to current_thread_info()->cpu_domain
2689 + mov r0, sp
2690 + @ assume 8K pages, since we have to split the immediate in two
2691 + bic r0, r0, #(0x1fc0)
2692 + bic r0, r0, #(0x3f)
2693 + str r1, [r0, #TI_CPU_DOMAIN]
2694 + @ write r1 to DACR
2695 + mcr p15, 0, r1, c3, c0, 0
2696 + @ instruction sync
2697 + instr_sync
2698 + @ restore regs
2699 + ldmia sp!, {r0, r1}
2700 +#endif
2701 + .endm
2702 +
2703 #ifndef CONFIG_THUMB2_KERNEL
2704 .macro svc_exit, rpsr, irq = 0
2705 .if \irq != 0
2706 @@ -203,6 +257,9 @@
2707 blne trace_hardirqs_off
2708 #endif
2709 .endif
2710 +
2711 + pax_exit_kernel
2712 +
2713 msr spsr_cxsf, \rpsr
2714 #if defined(CONFIG_CPU_V6)
2715 ldr r0, [sp]
2716 @@ -266,6 +323,9 @@
2717 blne trace_hardirqs_off
2718 #endif
2719 .endif
2720 +
2721 + pax_exit_kernel
2722 +
2723 ldr lr, [sp, #S_SP] @ top of the stack
2724 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2725 clrex @ clear the exclusive monitor
2726 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2727 index 918875d..cd5fa27 100644
2728 --- a/arch/arm/kernel/fiq.c
2729 +++ b/arch/arm/kernel/fiq.c
2730 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2731 void *base = vectors_page;
2732 unsigned offset = FIQ_OFFSET;
2733
2734 + pax_open_kernel();
2735 memcpy(base + offset, start, length);
2736 + pax_close_kernel();
2737 +
2738 if (!cache_is_vipt_nonaliasing())
2739 flush_icache_range((unsigned long)base + offset, offset +
2740 length);
2741 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2742 index 476de57..4857a76 100644
2743 --- a/arch/arm/kernel/head.S
2744 +++ b/arch/arm/kernel/head.S
2745 @@ -52,7 +52,9 @@
2746 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2747
2748 .macro pgtbl, rd, phys
2749 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2750 + mov \rd, #TEXT_OFFSET
2751 + sub \rd, #PG_DIR_SIZE
2752 + add \rd, \rd, \phys
2753 .endm
2754
2755 /*
2756 @@ -432,7 +434,7 @@ __enable_mmu:
2757 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2758 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2759 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2760 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2761 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2762 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2763 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2764 #endif
2765 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2766 index 084dc88..fce4e68 100644
2767 --- a/arch/arm/kernel/module.c
2768 +++ b/arch/arm/kernel/module.c
2769 @@ -37,12 +37,39 @@
2770 #endif
2771
2772 #ifdef CONFIG_MMU
2773 -void *module_alloc(unsigned long size)
2774 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2775 {
2776 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2777 + return NULL;
2778 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2779 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2780 + GFP_KERNEL, prot, -1,
2781 __builtin_return_address(0));
2782 }
2783 +
2784 +void *module_alloc(unsigned long size)
2785 +{
2786 +
2787 +#ifdef CONFIG_PAX_KERNEXEC
2788 + return __module_alloc(size, PAGE_KERNEL);
2789 +#else
2790 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2791 +#endif
2792 +
2793 +}
2794 +
2795 +#ifdef CONFIG_PAX_KERNEXEC
2796 +void module_free_exec(struct module *mod, void *module_region)
2797 +{
2798 + module_free(mod, module_region);
2799 +}
2800 +EXPORT_SYMBOL(module_free_exec);
2801 +
2802 +void *module_alloc_exec(unsigned long size)
2803 +{
2804 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2805 +}
2806 +EXPORT_SYMBOL(module_alloc_exec);
2807 +#endif
2808 #endif
2809
2810 int
2811 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2812 index 07314af..c46655c 100644
2813 --- a/arch/arm/kernel/patch.c
2814 +++ b/arch/arm/kernel/patch.c
2815 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2816 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2817 int size;
2818
2819 + pax_open_kernel();
2820 if (thumb2 && __opcode_is_thumb16(insn)) {
2821 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2822 size = sizeof(u16);
2823 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2824 *(u32 *)addr = insn;
2825 size = sizeof(u32);
2826 }
2827 + pax_close_kernel();
2828
2829 flush_icache_range((uintptr_t)(addr),
2830 (uintptr_t)(addr) + size);
2831 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2832 index 92f7b15..7048500 100644
2833 --- a/arch/arm/kernel/process.c
2834 +++ b/arch/arm/kernel/process.c
2835 @@ -217,6 +217,7 @@ void machine_power_off(void)
2836
2837 if (pm_power_off)
2838 pm_power_off();
2839 + BUG();
2840 }
2841
2842 /*
2843 @@ -230,7 +231,7 @@ void machine_power_off(void)
2844 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2845 * to use. Implementing such co-ordination would be essentially impossible.
2846 */
2847 -void machine_restart(char *cmd)
2848 +__noreturn void machine_restart(char *cmd)
2849 {
2850 local_irq_disable();
2851 smp_send_stop();
2852 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2853
2854 show_regs_print_info(KERN_DEFAULT);
2855
2856 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2857 - print_symbol("LR is at %s\n", regs->ARM_lr);
2858 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2859 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2860 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2861 "sp : %08lx ip : %08lx fp : %08lx\n",
2862 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2863 @@ -425,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2864 return 0;
2865 }
2866
2867 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2868 -{
2869 - unsigned long range_end = mm->brk + 0x02000000;
2870 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2871 -}
2872 -
2873 #ifdef CONFIG_MMU
2874 #ifdef CONFIG_KUSER_HELPERS
2875 /*
2876 @@ -446,7 +441,7 @@ static struct vm_area_struct gate_vma = {
2877
2878 static int __init gate_vma_init(void)
2879 {
2880 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2881 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2882 return 0;
2883 }
2884 arch_initcall(gate_vma_init);
2885 @@ -472,41 +467,16 @@ int in_gate_area_no_mm(unsigned long addr)
2886
2887 const char *arch_vma_name(struct vm_area_struct *vma)
2888 {
2889 - return is_gate_vma(vma) ? "[vectors]" :
2890 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2891 - "[sigpage]" : NULL;
2892 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2893 }
2894
2895 -static struct page *signal_page;
2896 -extern struct page *get_signal_page(void);
2897 -
2898 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2899 {
2900 struct mm_struct *mm = current->mm;
2901 - unsigned long addr;
2902 - int ret;
2903 -
2904 - if (!signal_page)
2905 - signal_page = get_signal_page();
2906 - if (!signal_page)
2907 - return -ENOMEM;
2908
2909 down_write(&mm->mmap_sem);
2910 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2911 - if (IS_ERR_VALUE(addr)) {
2912 - ret = addr;
2913 - goto up_fail;
2914 - }
2915 -
2916 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2917 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2918 - &signal_page);
2919 -
2920 - if (ret == 0)
2921 - mm->context.sigpage = addr;
2922 -
2923 - up_fail:
2924 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2925 up_write(&mm->mmap_sem);
2926 - return ret;
2927 + return 0;
2928 }
2929 #endif
2930 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2931 index 4693188..4596c5e 100644
2932 --- a/arch/arm/kernel/psci.c
2933 +++ b/arch/arm/kernel/psci.c
2934 @@ -24,7 +24,7 @@
2935 #include <asm/opcodes-virt.h>
2936 #include <asm/psci.h>
2937
2938 -struct psci_operations psci_ops;
2939 +struct psci_operations psci_ops __read_only;
2940
2941 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2942
2943 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2944 index 0dd3b79..e018f64 100644
2945 --- a/arch/arm/kernel/ptrace.c
2946 +++ b/arch/arm/kernel/ptrace.c
2947 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2948 return current_thread_info()->syscall;
2949 }
2950
2951 +#ifdef CONFIG_GRKERNSEC_SETXID
2952 +extern void gr_delayed_cred_worker(void);
2953 +#endif
2954 +
2955 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2956 {
2957 current_thread_info()->syscall = scno;
2958
2959 +#ifdef CONFIG_GRKERNSEC_SETXID
2960 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2961 + gr_delayed_cred_worker();
2962 +#endif
2963 +
2964 /* Do the secure computing check first; failures should be fast. */
2965 if (secure_computing(scno) == -1)
2966 return -1;
2967 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2968 index 0e1e2b3..c0e821d 100644
2969 --- a/arch/arm/kernel/setup.c
2970 +++ b/arch/arm/kernel/setup.c
2971 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2972 unsigned int elf_hwcap __read_mostly;
2973 EXPORT_SYMBOL(elf_hwcap);
2974
2975 +pteval_t __supported_pte_mask __read_only;
2976 +pmdval_t __supported_pmd_mask __read_only;
2977
2978 #ifdef MULTI_CPU
2979 -struct processor processor __read_mostly;
2980 +struct processor processor;
2981 #endif
2982 #ifdef MULTI_TLB
2983 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2984 +struct cpu_tlb_fns cpu_tlb __read_only;
2985 #endif
2986 #ifdef MULTI_USER
2987 -struct cpu_user_fns cpu_user __read_mostly;
2988 +struct cpu_user_fns cpu_user __read_only;
2989 #endif
2990 #ifdef MULTI_CACHE
2991 -struct cpu_cache_fns cpu_cache __read_mostly;
2992 +struct cpu_cache_fns cpu_cache __read_only;
2993 #endif
2994 #ifdef CONFIG_OUTER_CACHE
2995 -struct outer_cache_fns outer_cache __read_mostly;
2996 +struct outer_cache_fns outer_cache __read_only;
2997 EXPORT_SYMBOL(outer_cache);
2998 #endif
2999
3000 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
3001 asm("mrc p15, 0, %0, c0, c1, 4"
3002 : "=r" (mmfr0));
3003 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3004 - (mmfr0 & 0x000000f0) >= 0x00000030)
3005 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3006 cpu_arch = CPU_ARCH_ARMv7;
3007 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3008 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3009 + __supported_pte_mask |= L_PTE_PXN;
3010 + __supported_pmd_mask |= PMD_PXNTABLE;
3011 + }
3012 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3013 (mmfr0 & 0x000000f0) == 0x00000020)
3014 cpu_arch = CPU_ARCH_ARMv6;
3015 else
3016 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3017 __cpu_architecture = __get_cpu_architecture();
3018
3019 #ifdef MULTI_CPU
3020 - processor = *list->proc;
3021 + memcpy((void *)&processor, list->proc, sizeof processor);
3022 #endif
3023 #ifdef MULTI_TLB
3024 cpu_tlb = *list->tlb;
3025 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3026 index ab33042..11248a8 100644
3027 --- a/arch/arm/kernel/signal.c
3028 +++ b/arch/arm/kernel/signal.c
3029 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3030 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3031 };
3032
3033 -static unsigned long signal_return_offset;
3034 -
3035 #ifdef CONFIG_CRUNCH
3036 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3037 {
3038 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3039 * except when the MPU has protected the vectors
3040 * page from PL0
3041 */
3042 - retcode = mm->context.sigpage + signal_return_offset +
3043 - (idx << 2) + thumb;
3044 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3045 } else
3046 #endif
3047 {
3048 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3049 } while (thread_flags & _TIF_WORK_MASK);
3050 return 0;
3051 }
3052 -
3053 -struct page *get_signal_page(void)
3054 -{
3055 - unsigned long ptr;
3056 - unsigned offset;
3057 - struct page *page;
3058 - void *addr;
3059 -
3060 - page = alloc_pages(GFP_KERNEL, 0);
3061 -
3062 - if (!page)
3063 - return NULL;
3064 -
3065 - addr = page_address(page);
3066 -
3067 - /* Give the signal return code some randomness */
3068 - offset = 0x200 + (get_random_int() & 0x7fc);
3069 - signal_return_offset = offset;
3070 -
3071 - /*
3072 - * Copy signal return handlers into the vector page, and
3073 - * set sigreturn to be a pointer to these.
3074 - */
3075 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3076 -
3077 - ptr = (unsigned long)addr + offset;
3078 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3079 -
3080 - return page;
3081 -}
3082 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3083 index 72024ea..ae302dd 100644
3084 --- a/arch/arm/kernel/smp.c
3085 +++ b/arch/arm/kernel/smp.c
3086 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3087
3088 static DECLARE_COMPLETION(cpu_running);
3089
3090 -static struct smp_operations smp_ops;
3091 +static struct smp_operations smp_ops __read_only;
3092
3093 void __init smp_set_ops(struct smp_operations *ops)
3094 {
3095 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3096 index 1f735aa..08af6f7 100644
3097 --- a/arch/arm/kernel/traps.c
3098 +++ b/arch/arm/kernel/traps.c
3099 @@ -61,7 +61,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3100 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3101 {
3102 #ifdef CONFIG_KALLSYMS
3103 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3104 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3105 #else
3106 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3107 #endif
3108 @@ -263,6 +263,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3109 static int die_owner = -1;
3110 static unsigned int die_nest_count;
3111
3112 +extern void gr_handle_kernel_exploit(void);
3113 +
3114 static unsigned long oops_begin(void)
3115 {
3116 int cpu;
3117 @@ -305,6 +307,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3118 panic("Fatal exception in interrupt");
3119 if (panic_on_oops)
3120 panic("Fatal exception");
3121 +
3122 + gr_handle_kernel_exploit();
3123 +
3124 if (signr)
3125 do_exit(signr);
3126 }
3127 @@ -635,7 +640,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3128 * The user helper at 0xffff0fe0 must be used instead.
3129 * (see entry-armv.S for details)
3130 */
3131 + pax_open_kernel();
3132 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3133 + pax_close_kernel();
3134 }
3135 return 0;
3136
3137 @@ -892,7 +899,11 @@ void __init early_trap_init(void *vectors_base)
3138 kuser_init(vectors_base);
3139
3140 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3141 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3142 +
3143 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3144 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3145 +#endif
3146 +
3147 #else /* ifndef CONFIG_CPU_V7M */
3148 /*
3149 * on V7-M there is no need to copy the vector table to a dedicated
3150 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3151 index 7bcee5c..e2f3249 100644
3152 --- a/arch/arm/kernel/vmlinux.lds.S
3153 +++ b/arch/arm/kernel/vmlinux.lds.S
3154 @@ -8,7 +8,11 @@
3155 #include <asm/thread_info.h>
3156 #include <asm/memory.h>
3157 #include <asm/page.h>
3158 -
3159 +
3160 +#ifdef CONFIG_PAX_KERNEXEC
3161 +#include <asm/pgtable.h>
3162 +#endif
3163 +
3164 #define PROC_INFO \
3165 . = ALIGN(4); \
3166 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3167 @@ -34,7 +38,7 @@
3168 #endif
3169
3170 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3171 - defined(CONFIG_GENERIC_BUG)
3172 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3173 #define ARM_EXIT_KEEP(x) x
3174 #define ARM_EXIT_DISCARD(x)
3175 #else
3176 @@ -90,6 +94,11 @@ SECTIONS
3177 _text = .;
3178 HEAD_TEXT
3179 }
3180 +
3181 +#ifdef CONFIG_PAX_KERNEXEC
3182 + . = ALIGN(1<<SECTION_SHIFT);
3183 +#endif
3184 +
3185 .text : { /* Real text segment */
3186 _stext = .; /* Text and read-only data */
3187 __exception_text_start = .;
3188 @@ -112,6 +121,8 @@ SECTIONS
3189 ARM_CPU_KEEP(PROC_INFO)
3190 }
3191
3192 + _etext = .; /* End of text section */
3193 +
3194 RO_DATA(PAGE_SIZE)
3195
3196 . = ALIGN(4);
3197 @@ -142,7 +153,9 @@ SECTIONS
3198
3199 NOTES
3200
3201 - _etext = .; /* End of text and rodata section */
3202 +#ifdef CONFIG_PAX_KERNEXEC
3203 + . = ALIGN(1<<SECTION_SHIFT);
3204 +#endif
3205
3206 #ifndef CONFIG_XIP_KERNEL
3207 . = ALIGN(PAGE_SIZE);
3208 @@ -220,6 +233,11 @@ SECTIONS
3209 . = PAGE_OFFSET + TEXT_OFFSET;
3210 #else
3211 __init_end = .;
3212 +
3213 +#ifdef CONFIG_PAX_KERNEXEC
3214 + . = ALIGN(1<<SECTION_SHIFT);
3215 +#endif
3216 +
3217 . = ALIGN(THREAD_SIZE);
3218 __data_loc = .;
3219 #endif
3220 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3221 index 9c697db..115237f 100644
3222 --- a/arch/arm/kvm/arm.c
3223 +++ b/arch/arm/kvm/arm.c
3224 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3225 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3226
3227 /* The VMID used in the VTTBR */
3228 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3229 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3230 static u8 kvm_next_vmid;
3231 static DEFINE_SPINLOCK(kvm_vmid_lock);
3232
3233 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3234 */
3235 static bool need_new_vmid_gen(struct kvm *kvm)
3236 {
3237 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3238 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3239 }
3240
3241 /**
3242 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3243
3244 /* First user of a new VMID generation? */
3245 if (unlikely(kvm_next_vmid == 0)) {
3246 - atomic64_inc(&kvm_vmid_gen);
3247 + atomic64_inc_unchecked(&kvm_vmid_gen);
3248 kvm_next_vmid = 1;
3249
3250 /*
3251 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3252 kvm_call_hyp(__kvm_flush_vm_context);
3253 }
3254
3255 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3256 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3257 kvm->arch.vmid = kvm_next_vmid;
3258 kvm_next_vmid++;
3259
3260 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3261 index 14a0d98..7771a7d 100644
3262 --- a/arch/arm/lib/clear_user.S
3263 +++ b/arch/arm/lib/clear_user.S
3264 @@ -12,14 +12,14 @@
3265
3266 .text
3267
3268 -/* Prototype: int __clear_user(void *addr, size_t sz)
3269 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3270 * Purpose : clear some user memory
3271 * Params : addr - user memory address to clear
3272 * : sz - number of bytes to clear
3273 * Returns : number of bytes NOT cleared
3274 */
3275 ENTRY(__clear_user_std)
3276 -WEAK(__clear_user)
3277 +WEAK(___clear_user)
3278 stmfd sp!, {r1, lr}
3279 mov r2, #0
3280 cmp r1, #4
3281 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3282 USER( strnebt r2, [r0])
3283 mov r0, #0
3284 ldmfd sp!, {r1, pc}
3285 -ENDPROC(__clear_user)
3286 +ENDPROC(___clear_user)
3287 ENDPROC(__clear_user_std)
3288
3289 .pushsection .fixup,"ax"
3290 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3291 index 66a477a..bee61d3 100644
3292 --- a/arch/arm/lib/copy_from_user.S
3293 +++ b/arch/arm/lib/copy_from_user.S
3294 @@ -16,7 +16,7 @@
3295 /*
3296 * Prototype:
3297 *
3298 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3299 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3300 *
3301 * Purpose:
3302 *
3303 @@ -84,11 +84,11 @@
3304
3305 .text
3306
3307 -ENTRY(__copy_from_user)
3308 +ENTRY(___copy_from_user)
3309
3310 #include "copy_template.S"
3311
3312 -ENDPROC(__copy_from_user)
3313 +ENDPROC(___copy_from_user)
3314
3315 .pushsection .fixup,"ax"
3316 .align 0
3317 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3318 index 6ee2f67..d1cce76 100644
3319 --- a/arch/arm/lib/copy_page.S
3320 +++ b/arch/arm/lib/copy_page.S
3321 @@ -10,6 +10,7 @@
3322 * ASM optimised string functions
3323 */
3324 #include <linux/linkage.h>
3325 +#include <linux/const.h>
3326 #include <asm/assembler.h>
3327 #include <asm/asm-offsets.h>
3328 #include <asm/cache.h>
3329 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3330 index d066df6..df28194 100644
3331 --- a/arch/arm/lib/copy_to_user.S
3332 +++ b/arch/arm/lib/copy_to_user.S
3333 @@ -16,7 +16,7 @@
3334 /*
3335 * Prototype:
3336 *
3337 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3338 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3339 *
3340 * Purpose:
3341 *
3342 @@ -88,11 +88,11 @@
3343 .text
3344
3345 ENTRY(__copy_to_user_std)
3346 -WEAK(__copy_to_user)
3347 +WEAK(___copy_to_user)
3348
3349 #include "copy_template.S"
3350
3351 -ENDPROC(__copy_to_user)
3352 +ENDPROC(___copy_to_user)
3353 ENDPROC(__copy_to_user_std)
3354
3355 .pushsection .fixup,"ax"
3356 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3357 index 7d08b43..f7ca7ea 100644
3358 --- a/arch/arm/lib/csumpartialcopyuser.S
3359 +++ b/arch/arm/lib/csumpartialcopyuser.S
3360 @@ -57,8 +57,8 @@
3361 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3362 */
3363
3364 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3365 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3366 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3367 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3368
3369 #include "csumpartialcopygeneric.S"
3370
3371 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3372 index 5306de3..aed6d03 100644
3373 --- a/arch/arm/lib/delay.c
3374 +++ b/arch/arm/lib/delay.c
3375 @@ -28,7 +28,7 @@
3376 /*
3377 * Default to the loop-based delay implementation.
3378 */
3379 -struct arm_delay_ops arm_delay_ops = {
3380 +struct arm_delay_ops arm_delay_ops __read_only = {
3381 .delay = __loop_delay,
3382 .const_udelay = __loop_const_udelay,
3383 .udelay = __loop_udelay,
3384 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3385 index 025f742..a9e5b3b 100644
3386 --- a/arch/arm/lib/uaccess_with_memcpy.c
3387 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3388 @@ -104,7 +104,7 @@ out:
3389 }
3390
3391 unsigned long
3392 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3393 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3394 {
3395 /*
3396 * This test is stubbed out of the main function above to keep
3397 @@ -155,7 +155,7 @@ out:
3398 return n;
3399 }
3400
3401 -unsigned long __clear_user(void __user *addr, unsigned long n)
3402 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3403 {
3404 /* See rational for this in __copy_to_user() above. */
3405 if (n < 64)
3406 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3407 index 1767611..d2e7e24 100644
3408 --- a/arch/arm/mach-kirkwood/common.c
3409 +++ b/arch/arm/mach-kirkwood/common.c
3410 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3411 clk_gate_ops.disable(hw);
3412 }
3413
3414 -static struct clk_ops clk_gate_fn_ops;
3415 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3416 +{
3417 + return clk_gate_ops.is_enabled(hw);
3418 +}
3419 +
3420 +static struct clk_ops clk_gate_fn_ops = {
3421 + .enable = clk_gate_fn_enable,
3422 + .disable = clk_gate_fn_disable,
3423 + .is_enabled = clk_gate_fn_is_enabled,
3424 +};
3425
3426 static struct clk __init *clk_register_gate_fn(struct device *dev,
3427 const char *name,
3428 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3429 gate_fn->fn_en = fn_en;
3430 gate_fn->fn_dis = fn_dis;
3431
3432 - /* ops is the gate ops, but with our enable/disable functions */
3433 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3434 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3435 - clk_gate_fn_ops = clk_gate_ops;
3436 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3437 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3438 - }
3439 -
3440 clk = clk_register(dev, &gate_fn->gate.hw);
3441
3442 if (IS_ERR(clk))
3443 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3444 index 827d1500..2885dc6 100644
3445 --- a/arch/arm/mach-omap2/board-n8x0.c
3446 +++ b/arch/arm/mach-omap2/board-n8x0.c
3447 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3448 }
3449 #endif
3450
3451 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3452 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3453 .late_init = n8x0_menelaus_late_init,
3454 };
3455
3456 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3457 index 579697a..1d5a3b2 100644
3458 --- a/arch/arm/mach-omap2/gpmc.c
3459 +++ b/arch/arm/mach-omap2/gpmc.c
3460 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3461 };
3462
3463 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3464 -static struct irq_chip gpmc_irq_chip;
3465 static int gpmc_irq_start;
3466
3467 static struct resource gpmc_mem_root;
3468 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3469
3470 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3471
3472 +static struct irq_chip gpmc_irq_chip = {
3473 + .name = "gpmc",
3474 + .irq_startup = gpmc_irq_noop_ret,
3475 + .irq_enable = gpmc_irq_enable,
3476 + .irq_disable = gpmc_irq_disable,
3477 + .irq_shutdown = gpmc_irq_noop,
3478 + .irq_ack = gpmc_irq_noop,
3479 + .irq_mask = gpmc_irq_noop,
3480 + .irq_unmask = gpmc_irq_noop,
3481 +
3482 +};
3483 +
3484 static int gpmc_setup_irq(void)
3485 {
3486 int i;
3487 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3488 return gpmc_irq_start;
3489 }
3490
3491 - gpmc_irq_chip.name = "gpmc";
3492 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3493 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3494 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3495 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3496 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3497 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3498 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3499 -
3500 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3501 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3502
3503 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3504 index f991016..145ebeb 100644
3505 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3506 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3507 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3508 int (*finish_suspend)(unsigned long cpu_state);
3509 void (*resume)(void);
3510 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3511 -};
3512 +} __no_const;
3513
3514 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3515 static struct powerdomain *mpuss_pd;
3516 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3517 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3518 {}
3519
3520 -struct cpu_pm_ops omap_pm_ops = {
3521 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3522 .finish_suspend = default_finish_suspend,
3523 .resume = dummy_cpu_resume,
3524 .scu_prepare = dummy_scu_prepare,
3525 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3526 index 813c615..ce467c6 100644
3527 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3528 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3529 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3530 return NOTIFY_OK;
3531 }
3532
3533 -static struct notifier_block __refdata irq_hotplug_notifier = {
3534 +static struct notifier_block irq_hotplug_notifier = {
3535 .notifier_call = irq_cpu_hotplug_notify,
3536 };
3537
3538 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3539 index 53f0735..5b54eb6 100644
3540 --- a/arch/arm/mach-omap2/omap_device.c
3541 +++ b/arch/arm/mach-omap2/omap_device.c
3542 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3543 struct platform_device __init *omap_device_build(const char *pdev_name,
3544 int pdev_id,
3545 struct omap_hwmod *oh,
3546 - void *pdata, int pdata_len)
3547 + const void *pdata, int pdata_len)
3548 {
3549 struct omap_hwmod *ohs[] = { oh };
3550
3551 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3552 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3553 int pdev_id,
3554 struct omap_hwmod **ohs,
3555 - int oh_cnt, void *pdata,
3556 + int oh_cnt, const void *pdata,
3557 int pdata_len)
3558 {
3559 int ret = -ENOMEM;
3560 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3561 index 17ca1ae..beba869 100644
3562 --- a/arch/arm/mach-omap2/omap_device.h
3563 +++ b/arch/arm/mach-omap2/omap_device.h
3564 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3565 /* Core code interface */
3566
3567 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3568 - struct omap_hwmod *oh, void *pdata,
3569 + struct omap_hwmod *oh, const void *pdata,
3570 int pdata_len);
3571
3572 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3573 struct omap_hwmod **oh, int oh_cnt,
3574 - void *pdata, int pdata_len);
3575 + const void *pdata, int pdata_len);
3576
3577 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3578 struct omap_hwmod **ohs, int oh_cnt);
3579 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3580 index 832adb1..49b62c4 100644
3581 --- a/arch/arm/mach-omap2/omap_hwmod.c
3582 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3583 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3584 int (*init_clkdm)(struct omap_hwmod *oh);
3585 void (*update_context_lost)(struct omap_hwmod *oh);
3586 int (*get_context_lost)(struct omap_hwmod *oh);
3587 -};
3588 +} __no_const;
3589
3590 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3591 -static struct omap_hwmod_soc_ops soc_ops;
3592 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3593
3594 /* omap_hwmod_list contains all registered struct omap_hwmods */
3595 static LIST_HEAD(omap_hwmod_list);
3596 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3597 index d15c7bb..b2d1f0c 100644
3598 --- a/arch/arm/mach-omap2/wd_timer.c
3599 +++ b/arch/arm/mach-omap2/wd_timer.c
3600 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3601 struct omap_hwmod *oh;
3602 char *oh_name = "wd_timer2";
3603 char *dev_name = "omap_wdt";
3604 - struct omap_wd_timer_platform_data pdata;
3605 + static struct omap_wd_timer_platform_data pdata = {
3606 + .read_reset_sources = prm_read_reset_sources
3607 + };
3608
3609 if (!cpu_class_is_omap2() || of_have_populated_dt())
3610 return 0;
3611 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3612 return -EINVAL;
3613 }
3614
3615 - pdata.read_reset_sources = prm_read_reset_sources;
3616 -
3617 pdev = omap_device_build(dev_name, id, oh, &pdata,
3618 sizeof(struct omap_wd_timer_platform_data));
3619 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3620 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3621 index b82dcae..44ee5b6 100644
3622 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3623 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3624 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3625 bool entered_lp2 = false;
3626
3627 if (tegra_pending_sgi())
3628 - ACCESS_ONCE(abort_flag) = true;
3629 + ACCESS_ONCE_RW(abort_flag) = true;
3630
3631 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3632
3633 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3634 index 656324a..0beba28 100644
3635 --- a/arch/arm/mach-ux500/setup.h
3636 +++ b/arch/arm/mach-ux500/setup.h
3637 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3638 .type = MT_DEVICE, \
3639 }
3640
3641 -#define __MEM_DEV_DESC(x, sz) { \
3642 - .virtual = IO_ADDRESS(x), \
3643 - .pfn = __phys_to_pfn(x), \
3644 - .length = sz, \
3645 - .type = MT_MEMORY, \
3646 -}
3647 -
3648 extern struct smp_operations ux500_smp_ops;
3649 extern void ux500_cpu_die(unsigned int cpu);
3650
3651 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3652 index cd2c88e..4dd9b67 100644
3653 --- a/arch/arm/mm/Kconfig
3654 +++ b/arch/arm/mm/Kconfig
3655 @@ -446,7 +446,7 @@ config CPU_32v5
3656
3657 config CPU_32v6
3658 bool
3659 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3660 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3661 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3662
3663 config CPU_32v6K
3664 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3665
3666 config CPU_USE_DOMAINS
3667 bool
3668 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3669 help
3670 This option enables or disables the use of domain switching
3671 via the set_fs() function.
3672 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3673 config KUSER_HELPERS
3674 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3675 default y
3676 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3677 help
3678 Warning: disabling this option may break user programs.
3679
3680 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3681 See Documentation/arm/kernel_user_helpers.txt for details.
3682
3683 However, the fixed address nature of these helpers can be used
3684 - by ROP (return orientated programming) authors when creating
3685 + by ROP (Return Oriented Programming) authors when creating
3686 exploits.
3687
3688 If all of the binaries and libraries which run on your platform
3689 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3690 index 6f4585b..7b6f52b 100644
3691 --- a/arch/arm/mm/alignment.c
3692 +++ b/arch/arm/mm/alignment.c
3693 @@ -211,10 +211,12 @@ union offset_union {
3694 #define __get16_unaligned_check(ins,val,addr) \
3695 do { \
3696 unsigned int err = 0, v, a = addr; \
3697 + pax_open_userland(); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val = v << ((BE) ? 8 : 0); \
3700 __get8_unaligned_check(ins,v,a,err); \
3701 val |= v << ((BE) ? 0 : 8); \
3702 + pax_close_userland(); \
3703 if (err) \
3704 goto fault; \
3705 } while (0)
3706 @@ -228,6 +230,7 @@ union offset_union {
3707 #define __get32_unaligned_check(ins,val,addr) \
3708 do { \
3709 unsigned int err = 0, v, a = addr; \
3710 + pax_open_userland(); \
3711 __get8_unaligned_check(ins,v,a,err); \
3712 val = v << ((BE) ? 24 : 0); \
3713 __get8_unaligned_check(ins,v,a,err); \
3714 @@ -236,6 +239,7 @@ union offset_union {
3715 val |= v << ((BE) ? 8 : 16); \
3716 __get8_unaligned_check(ins,v,a,err); \
3717 val |= v << ((BE) ? 0 : 24); \
3718 + pax_close_userland(); \
3719 if (err) \
3720 goto fault; \
3721 } while (0)
3722 @@ -249,6 +253,7 @@ union offset_union {
3723 #define __put16_unaligned_check(ins,val,addr) \
3724 do { \
3725 unsigned int err = 0, v = val, a = addr; \
3726 + pax_open_userland(); \
3727 __asm__( FIRST_BYTE_16 \
3728 ARM( "1: "ins" %1, [%2], #1\n" ) \
3729 THUMB( "1: "ins" %1, [%2]\n" ) \
3730 @@ -268,6 +273,7 @@ union offset_union {
3731 " .popsection\n" \
3732 : "=r" (err), "=&r" (v), "=&r" (a) \
3733 : "0" (err), "1" (v), "2" (a)); \
3734 + pax_close_userland(); \
3735 if (err) \
3736 goto fault; \
3737 } while (0)
3738 @@ -281,6 +287,7 @@ union offset_union {
3739 #define __put32_unaligned_check(ins,val,addr) \
3740 do { \
3741 unsigned int err = 0, v = val, a = addr; \
3742 + pax_open_userland(); \
3743 __asm__( FIRST_BYTE_32 \
3744 ARM( "1: "ins" %1, [%2], #1\n" ) \
3745 THUMB( "1: "ins" %1, [%2]\n" ) \
3746 @@ -310,6 +317,7 @@ union offset_union {
3747 " .popsection\n" \
3748 : "=r" (err), "=&r" (v), "=&r" (a) \
3749 : "0" (err), "1" (v), "2" (a)); \
3750 + pax_close_userland(); \
3751 if (err) \
3752 goto fault; \
3753 } while (0)
3754 diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3755 index 447da6f..77a5057 100644
3756 --- a/arch/arm/mm/cache-l2x0.c
3757 +++ b/arch/arm/mm/cache-l2x0.c
3758 @@ -45,7 +45,7 @@ struct l2x0_of_data {
3759 void (*setup)(const struct device_node *, u32 *, u32 *);
3760 void (*save)(void);
3761 struct outer_cache_fns outer_cache;
3762 -};
3763 +} __do_const;
3764
3765 static bool of_init = false;
3766
3767 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3768 index 84e6f77..0b52f31 100644
3769 --- a/arch/arm/mm/context.c
3770 +++ b/arch/arm/mm/context.c
3771 @@ -43,7 +43,7 @@
3772 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3773
3774 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3775 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3776 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3777 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3778
3779 static DEFINE_PER_CPU(atomic64_t, active_asids);
3780 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3781 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3782 {
3783 u64 asid = atomic64_read(&mm->context.id);
3784 - u64 generation = atomic64_read(&asid_generation);
3785 + u64 generation = atomic64_read_unchecked(&asid_generation);
3786
3787 if (asid != 0 && is_reserved_asid(asid)) {
3788 /*
3789 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3790 */
3791 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3792 if (asid == NUM_USER_ASIDS) {
3793 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3794 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3795 &asid_generation);
3796 flush_context(cpu);
3797 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3798 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3799 cpu_set_reserved_ttbr0();
3800
3801 asid = atomic64_read(&mm->context.id);
3802 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3803 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3804 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3805 goto switch_mm_fastpath;
3806
3807 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3808 /* Check that our ASID belongs to the current generation. */
3809 asid = atomic64_read(&mm->context.id);
3810 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3811 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3812 asid = new_context(mm, cpu);
3813 atomic64_set(&mm->context.id, asid);
3814 }
3815 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3816 index eb8830a..5360ce7 100644
3817 --- a/arch/arm/mm/fault.c
3818 +++ b/arch/arm/mm/fault.c
3819 @@ -25,6 +25,7 @@
3820 #include <asm/system_misc.h>
3821 #include <asm/system_info.h>
3822 #include <asm/tlbflush.h>
3823 +#include <asm/sections.h>
3824
3825 #include "fault.h"
3826
3827 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3828 if (fixup_exception(regs))
3829 return;
3830
3831 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3832 + if (addr < TASK_SIZE) {
3833 + if (current->signal->curr_ip)
3834 + 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),
3835 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3836 + else
3837 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3838 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3839 + }
3840 +#endif
3841 +
3842 +#ifdef CONFIG_PAX_KERNEXEC
3843 + if ((fsr & FSR_WRITE) &&
3844 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3845 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3846 + {
3847 + if (current->signal->curr_ip)
3848 + 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),
3849 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3850 + else
3851 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3852 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3853 + }
3854 +#endif
3855 +
3856 /*
3857 * No handler, we'll have to terminate things with extreme prejudice.
3858 */
3859 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3860 }
3861 #endif
3862
3863 +#ifdef CONFIG_PAX_PAGEEXEC
3864 + if (fsr & FSR_LNX_PF) {
3865 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3866 + do_group_exit(SIGKILL);
3867 + }
3868 +#endif
3869 +
3870 tsk->thread.address = addr;
3871 tsk->thread.error_code = fsr;
3872 tsk->thread.trap_no = 14;
3873 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3874 }
3875 #endif /* CONFIG_MMU */
3876
3877 +#ifdef CONFIG_PAX_PAGEEXEC
3878 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3879 +{
3880 + long i;
3881 +
3882 + printk(KERN_ERR "PAX: bytes at PC: ");
3883 + for (i = 0; i < 20; i++) {
3884 + unsigned char c;
3885 + if (get_user(c, (__force unsigned char __user *)pc+i))
3886 + printk(KERN_CONT "?? ");
3887 + else
3888 + printk(KERN_CONT "%02x ", c);
3889 + }
3890 + printk("\n");
3891 +
3892 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3893 + for (i = -1; i < 20; i++) {
3894 + unsigned long c;
3895 + if (get_user(c, (__force unsigned long __user *)sp+i))
3896 + printk(KERN_CONT "???????? ");
3897 + else
3898 + printk(KERN_CONT "%08lx ", c);
3899 + }
3900 + printk("\n");
3901 +}
3902 +#endif
3903 +
3904 /*
3905 * First Level Translation Fault Handler
3906 *
3907 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3908 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3909 struct siginfo info;
3910
3911 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3912 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3913 + if (current->signal->curr_ip)
3914 + 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),
3915 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3916 + else
3917 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3918 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3919 + goto die;
3920 + }
3921 +#endif
3922 +
3923 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3924 return;
3925
3926 +die:
3927 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3928 inf->name, fsr, addr);
3929
3930 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3931 ifsr_info[nr].name = name;
3932 }
3933
3934 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3935 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3936 +
3937 asmlinkage void __exception
3938 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3939 {
3940 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3941 struct siginfo info;
3942 + unsigned long pc = instruction_pointer(regs);
3943 +
3944 + if (user_mode(regs)) {
3945 + unsigned long sigpage = current->mm->context.sigpage;
3946 +
3947 + if (sigpage <= pc && pc < sigpage + 7*4) {
3948 + if (pc < sigpage + 3*4)
3949 + sys_sigreturn(regs);
3950 + else
3951 + sys_rt_sigreturn(regs);
3952 + return;
3953 + }
3954 + if (pc == 0xffff0f60UL) {
3955 + /*
3956 + * PaX: __kuser_cmpxchg64 emulation
3957 + */
3958 + // TODO
3959 + //regs->ARM_pc = regs->ARM_lr;
3960 + //return;
3961 + }
3962 + if (pc == 0xffff0fa0UL) {
3963 + /*
3964 + * PaX: __kuser_memory_barrier emulation
3965 + */
3966 + // dmb(); implied by the exception
3967 + regs->ARM_pc = regs->ARM_lr;
3968 + return;
3969 + }
3970 + if (pc == 0xffff0fc0UL) {
3971 + /*
3972 + * PaX: __kuser_cmpxchg emulation
3973 + */
3974 + // TODO
3975 + //long new;
3976 + //int op;
3977 +
3978 + //op = FUTEX_OP_SET << 28;
3979 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3980 + //regs->ARM_r0 = old != new;
3981 + //regs->ARM_pc = regs->ARM_lr;
3982 + //return;
3983 + }
3984 + if (pc == 0xffff0fe0UL) {
3985 + /*
3986 + * PaX: __kuser_get_tls emulation
3987 + */
3988 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3989 + regs->ARM_pc = regs->ARM_lr;
3990 + return;
3991 + }
3992 + }
3993 +
3994 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3995 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3996 + if (current->signal->curr_ip)
3997 + 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),
3998 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3999 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4000 + else
4001 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
4002 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4003 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4004 + goto die;
4005 + }
4006 +#endif
4007 +
4008 +#ifdef CONFIG_PAX_REFCOUNT
4009 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4010 + unsigned int bkpt;
4011 +
4012 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4013 + current->thread.error_code = ifsr;
4014 + current->thread.trap_no = 0;
4015 + pax_report_refcount_overflow(regs);
4016 + fixup_exception(regs);
4017 + return;
4018 + }
4019 + }
4020 +#endif
4021
4022 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4023 return;
4024
4025 +die:
4026 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4027 inf->name, ifsr, addr);
4028
4029 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4030 index cf08bdf..772656c 100644
4031 --- a/arch/arm/mm/fault.h
4032 +++ b/arch/arm/mm/fault.h
4033 @@ -3,6 +3,7 @@
4034
4035 /*
4036 * Fault status register encodings. We steal bit 31 for our own purposes.
4037 + * Set when the FSR value is from an instruction fault.
4038 */
4039 #define FSR_LNX_PF (1 << 31)
4040 #define FSR_WRITE (1 << 11)
4041 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4042 }
4043 #endif
4044
4045 +/* valid for LPAE and !LPAE */
4046 +static inline int is_xn_fault(unsigned int fsr)
4047 +{
4048 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4049 +}
4050 +
4051 +static inline int is_domain_fault(unsigned int fsr)
4052 +{
4053 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4054 +}
4055 +
4056 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4057 unsigned long search_exception_table(unsigned long addr);
4058
4059 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4060 index 18ec4c5..479bb6a 100644
4061 --- a/arch/arm/mm/init.c
4062 +++ b/arch/arm/mm/init.c
4063 @@ -30,6 +30,8 @@
4064 #include <asm/setup.h>
4065 #include <asm/tlb.h>
4066 #include <asm/fixmap.h>
4067 +#include <asm/system_info.h>
4068 +#include <asm/cp15.h>
4069
4070 #include <asm/mach/arch.h>
4071 #include <asm/mach/map.h>
4072 @@ -684,7 +686,46 @@ void free_initmem(void)
4073 {
4074 #ifdef CONFIG_HAVE_TCM
4075 extern char __tcm_start, __tcm_end;
4076 +#endif
4077
4078 +#ifdef CONFIG_PAX_KERNEXEC
4079 + unsigned long addr;
4080 + pgd_t *pgd;
4081 + pud_t *pud;
4082 + pmd_t *pmd;
4083 + int cpu_arch = cpu_architecture();
4084 + unsigned int cr = get_cr();
4085 +
4086 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4087 + /* make pages tables, etc before .text NX */
4088 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4089 + pgd = pgd_offset_k(addr);
4090 + pud = pud_offset(pgd, addr);
4091 + pmd = pmd_offset(pud, addr);
4092 + __section_update(pmd, addr, PMD_SECT_XN);
4093 + }
4094 + /* make init NX */
4095 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4096 + pgd = pgd_offset_k(addr);
4097 + pud = pud_offset(pgd, addr);
4098 + pmd = pmd_offset(pud, addr);
4099 + __section_update(pmd, addr, PMD_SECT_XN);
4100 + }
4101 + /* make kernel code/rodata RX */
4102 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4103 + pgd = pgd_offset_k(addr);
4104 + pud = pud_offset(pgd, addr);
4105 + pmd = pmd_offset(pud, addr);
4106 +#ifdef CONFIG_ARM_LPAE
4107 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4108 +#else
4109 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4110 +#endif
4111 + }
4112 + }
4113 +#endif
4114 +
4115 +#ifdef CONFIG_HAVE_TCM
4116 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4117 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4118 #endif
4119 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4120 index f123d6e..04bf569 100644
4121 --- a/arch/arm/mm/ioremap.c
4122 +++ b/arch/arm/mm/ioremap.c
4123 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4124 unsigned int mtype;
4125
4126 if (cached)
4127 - mtype = MT_MEMORY;
4128 + mtype = MT_MEMORY_RX;
4129 else
4130 - mtype = MT_MEMORY_NONCACHED;
4131 + mtype = MT_MEMORY_NONCACHED_RX;
4132
4133 return __arm_ioremap_caller(phys_addr, size, mtype,
4134 __builtin_return_address(0));
4135 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4136 index 304661d..53a6b19 100644
4137 --- a/arch/arm/mm/mmap.c
4138 +++ b/arch/arm/mm/mmap.c
4139 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4140 struct vm_area_struct *vma;
4141 int do_align = 0;
4142 int aliasing = cache_is_vipt_aliasing();
4143 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4144 struct vm_unmapped_area_info info;
4145
4146 /*
4147 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4148 if (len > TASK_SIZE)
4149 return -ENOMEM;
4150
4151 +#ifdef CONFIG_PAX_RANDMMAP
4152 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4153 +#endif
4154 +
4155 if (addr) {
4156 if (do_align)
4157 addr = COLOUR_ALIGN(addr, pgoff);
4158 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4159 addr = PAGE_ALIGN(addr);
4160
4161 vma = find_vma(mm, addr);
4162 - if (TASK_SIZE - len >= addr &&
4163 - (!vma || addr + len <= vma->vm_start))
4164 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4165 return addr;
4166 }
4167
4168 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4169 info.high_limit = TASK_SIZE;
4170 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4171 info.align_offset = pgoff << PAGE_SHIFT;
4172 + info.threadstack_offset = offset;
4173 return vm_unmapped_area(&info);
4174 }
4175
4176 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4177 unsigned long addr = addr0;
4178 int do_align = 0;
4179 int aliasing = cache_is_vipt_aliasing();
4180 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4181 struct vm_unmapped_area_info info;
4182
4183 /*
4184 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4185 return addr;
4186 }
4187
4188 +#ifdef CONFIG_PAX_RANDMMAP
4189 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4190 +#endif
4191 +
4192 /* requesting a specific address */
4193 if (addr) {
4194 if (do_align)
4195 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4196 else
4197 addr = PAGE_ALIGN(addr);
4198 vma = find_vma(mm, addr);
4199 - if (TASK_SIZE - len >= addr &&
4200 - (!vma || addr + len <= vma->vm_start))
4201 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4202 return addr;
4203 }
4204
4205 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4206 info.high_limit = mm->mmap_base;
4207 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4208 info.align_offset = pgoff << PAGE_SHIFT;
4209 + info.threadstack_offset = offset;
4210 addr = vm_unmapped_area(&info);
4211
4212 /*
4213 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4214 {
4215 unsigned long random_factor = 0UL;
4216
4217 +#ifdef CONFIG_PAX_RANDMMAP
4218 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4219 +#endif
4220 +
4221 /* 8 bits of randomness in 20 address space bits */
4222 if ((current->flags & PF_RANDOMIZE) &&
4223 !(current->personality & ADDR_NO_RANDOMIZE))
4224 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4225
4226 if (mmap_is_legacy()) {
4227 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4228 +
4229 +#ifdef CONFIG_PAX_RANDMMAP
4230 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4231 + mm->mmap_base += mm->delta_mmap;
4232 +#endif
4233 +
4234 mm->get_unmapped_area = arch_get_unmapped_area;
4235 } else {
4236 mm->mmap_base = mmap_base(random_factor);
4237 +
4238 +#ifdef CONFIG_PAX_RANDMMAP
4239 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4240 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4241 +#endif
4242 +
4243 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4244 }
4245 }
4246 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4247 index b1d17ee..7a6f4d3 100644
4248 --- a/arch/arm/mm/mmu.c
4249 +++ b/arch/arm/mm/mmu.c
4250 @@ -36,6 +36,22 @@
4251 #include "mm.h"
4252 #include "tcm.h"
4253
4254 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4255 +void modify_domain(unsigned int dom, unsigned int type)
4256 +{
4257 + struct thread_info *thread = current_thread_info();
4258 + unsigned int domain = thread->cpu_domain;
4259 + /*
4260 + * DOMAIN_MANAGER might be defined to some other value,
4261 + * use the arch-defined constant
4262 + */
4263 + domain &= ~domain_val(dom, 3);
4264 + thread->cpu_domain = domain | domain_val(dom, type);
4265 + set_domain(thread->cpu_domain);
4266 +}
4267 +EXPORT_SYMBOL(modify_domain);
4268 +#endif
4269 +
4270 /*
4271 * empty_zero_page is a special page that is used for
4272 * zero-initialized data and COW.
4273 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4274
4275 #endif /* ifdef CONFIG_CPU_CP15 / else */
4276
4277 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4278 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4279 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4280
4281 -static struct mem_type mem_types[] = {
4282 +#ifdef CONFIG_PAX_KERNEXEC
4283 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4284 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4285 +#else
4286 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4287 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4288 +#endif
4289 +
4290 +static struct mem_type mem_types[] __read_only = {
4291 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4292 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4293 L_PTE_SHARED,
4294 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4295 [MT_UNCACHED] = {
4296 .prot_pte = PROT_PTE_DEVICE,
4297 .prot_l1 = PMD_TYPE_TABLE,
4298 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4299 + .prot_sect = PROT_SECT_DEVICE,
4300 .domain = DOMAIN_IO,
4301 },
4302 [MT_CACHECLEAN] = {
4303 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4304 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4305 .domain = DOMAIN_KERNEL,
4306 },
4307 #ifndef CONFIG_ARM_LPAE
4308 [MT_MINICLEAN] = {
4309 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4310 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4311 .domain = DOMAIN_KERNEL,
4312 },
4313 #endif
4314 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4315 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4316 L_PTE_RDONLY,
4317 .prot_l1 = PMD_TYPE_TABLE,
4318 - .domain = DOMAIN_USER,
4319 + .domain = DOMAIN_VECTORS,
4320 },
4321 [MT_HIGH_VECTORS] = {
4322 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4323 L_PTE_USER | L_PTE_RDONLY,
4324 .prot_l1 = PMD_TYPE_TABLE,
4325 - .domain = DOMAIN_USER,
4326 + .domain = DOMAIN_VECTORS,
4327 },
4328 - [MT_MEMORY] = {
4329 + [MT_MEMORY_RWX] = {
4330 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4331 .prot_l1 = PMD_TYPE_TABLE,
4332 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4333 .domain = DOMAIN_KERNEL,
4334 },
4335 + [MT_MEMORY_RW] = {
4336 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4337 + .prot_l1 = PMD_TYPE_TABLE,
4338 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4339 + .domain = DOMAIN_KERNEL,
4340 + },
4341 + [MT_MEMORY_RX] = {
4342 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4343 + .prot_l1 = PMD_TYPE_TABLE,
4344 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4345 + .domain = DOMAIN_KERNEL,
4346 + },
4347 [MT_ROM] = {
4348 - .prot_sect = PMD_TYPE_SECT,
4349 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4350 .domain = DOMAIN_KERNEL,
4351 },
4352 - [MT_MEMORY_NONCACHED] = {
4353 + [MT_MEMORY_NONCACHED_RW] = {
4354 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4355 L_PTE_MT_BUFFERABLE,
4356 .prot_l1 = PMD_TYPE_TABLE,
4357 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4358 .domain = DOMAIN_KERNEL,
4359 },
4360 + [MT_MEMORY_NONCACHED_RX] = {
4361 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4362 + L_PTE_MT_BUFFERABLE,
4363 + .prot_l1 = PMD_TYPE_TABLE,
4364 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4365 + .domain = DOMAIN_KERNEL,
4366 + },
4367 [MT_MEMORY_DTCM] = {
4368 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4369 - L_PTE_XN,
4370 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4371 .prot_l1 = PMD_TYPE_TABLE,
4372 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4373 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4374 .domain = DOMAIN_KERNEL,
4375 },
4376 [MT_MEMORY_ITCM] = {
4377 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4378 },
4379 [MT_MEMORY_SO] = {
4380 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4381 - L_PTE_MT_UNCACHED | L_PTE_XN,
4382 + L_PTE_MT_UNCACHED,
4383 .prot_l1 = PMD_TYPE_TABLE,
4384 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4385 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4386 + PMD_SECT_UNCACHED,
4387 .domain = DOMAIN_KERNEL,
4388 },
4389 [MT_MEMORY_DMA_READY] = {
4390 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4391 * to prevent speculative instruction fetches.
4392 */
4393 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4394 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4395 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4396 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4397 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4399 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4400 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4401 +
4402 + /* Mark other regions on ARMv6+ as execute-never */
4403 +
4404 +#ifdef CONFIG_PAX_KERNEXEC
4405 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4406 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4407 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4408 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4409 +#ifndef CONFIG_ARM_LPAE
4410 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4411 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4412 +#endif
4413 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4414 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4416 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4417 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4418 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4419 +#endif
4420 +
4421 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4422 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4423 }
4424 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4425 /*
4426 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4427 * from SVC mode and no access from userspace.
4428 */
4429 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4430 +#ifdef CONFIG_PAX_KERNEXEC
4431 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4432 +#endif
4433 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4434 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4435 #endif
4436 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4437 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4438 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4439 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4440 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4441 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4442 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4443 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4444 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4445 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4446 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4447 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4448 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4449 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4450 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4451 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4452 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4453 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4454 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4455 }
4456 }
4457
4458 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4459 if (cpu_arch >= CPU_ARCH_ARMv6) {
4460 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4461 /* Non-cacheable Normal is XCB = 001 */
4462 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4463 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4464 + PMD_SECT_BUFFERED;
4465 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4466 PMD_SECT_BUFFERED;
4467 } else {
4468 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4469 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4470 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4471 + PMD_SECT_TEX(1);
4472 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4473 PMD_SECT_TEX(1);
4474 }
4475 } else {
4476 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4477 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4478 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4479 }
4480
4481 #ifdef CONFIG_ARM_LPAE
4482 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4483 vecs_pgprot |= PTE_EXT_AF;
4484 #endif
4485
4486 + user_pgprot |= __supported_pte_mask;
4487 +
4488 for (i = 0; i < 16; i++) {
4489 pteval_t v = pgprot_val(protection_map[i]);
4490 protection_map[i] = __pgprot(v | user_pgprot);
4491 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4492
4493 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4494 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4495 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4496 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4497 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4498 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4499 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4500 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4501 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4502 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4503 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4504 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4505 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4506 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4507 mem_types[MT_ROM].prot_sect |= cp->pmd;
4508
4509 switch (cp->pmd) {
4510 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4511 * called function. This means you can't use any function or debugging
4512 * method which may touch any device, otherwise the kernel _will_ crash.
4513 */
4514 +
4515 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4516 +
4517 static void __init devicemaps_init(const struct machine_desc *mdesc)
4518 {
4519 struct map_desc map;
4520 unsigned long addr;
4521 - void *vectors;
4522
4523 - /*
4524 - * Allocate the vector page early.
4525 - */
4526 - vectors = early_alloc(PAGE_SIZE * 2);
4527 -
4528 - early_trap_init(vectors);
4529 + early_trap_init(&vectors);
4530
4531 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4532 pmd_clear(pmd_off_k(addr));
4533 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4534 * location (0xffff0000). If we aren't using high-vectors, also
4535 * create a mapping at the low-vectors virtual address.
4536 */
4537 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4538 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4539 map.virtual = 0xffff0000;
4540 map.length = PAGE_SIZE;
4541 #ifdef CONFIG_KUSER_HELPERS
4542 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4543 map.pfn = __phys_to_pfn(start);
4544 map.virtual = __phys_to_virt(start);
4545 map.length = end - start;
4546 - map.type = MT_MEMORY;
4547
4548 +#ifdef CONFIG_PAX_KERNEXEC
4549 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4550 + struct map_desc kernel;
4551 + struct map_desc initmap;
4552 +
4553 + /* when freeing initmem we will make this RW */
4554 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4555 + initmap.virtual = (unsigned long)__init_begin;
4556 + initmap.length = _sdata - __init_begin;
4557 + initmap.type = MT_MEMORY_RWX;
4558 + create_mapping(&initmap);
4559 +
4560 + /* when freeing initmem we will make this RX */
4561 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4562 + kernel.virtual = (unsigned long)_stext;
4563 + kernel.length = __init_begin - _stext;
4564 + kernel.type = MT_MEMORY_RWX;
4565 + create_mapping(&kernel);
4566 +
4567 + if (map.virtual < (unsigned long)_stext) {
4568 + map.length = (unsigned long)_stext - map.virtual;
4569 + map.type = MT_MEMORY_RWX;
4570 + create_mapping(&map);
4571 + }
4572 +
4573 + map.pfn = __phys_to_pfn(__pa(_sdata));
4574 + map.virtual = (unsigned long)_sdata;
4575 + map.length = end - __pa(_sdata);
4576 + }
4577 +#endif
4578 +
4579 + map.type = MT_MEMORY_RW;
4580 create_mapping(&map);
4581 }
4582 }
4583 diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
4584 index 99b44e0..8c9106f 100644
4585 --- a/arch/arm/net/bpf_jit_32.c
4586 +++ b/arch/arm/net/bpf_jit_32.c
4587 @@ -637,10 +637,10 @@ load_ind:
4588 emit(ARM_MUL(r_A, r_A, r_X), ctx);
4589 break;
4590 case BPF_S_ALU_DIV_K:
4591 - /* current k == reciprocal_value(userspace k) */
4592 + if (k == 1)
4593 + break;
4594 emit_mov_i(r_scratch, k, ctx);
4595 - /* A = top 32 bits of the product */
4596 - emit(ARM_UMULL(r_scratch, r_A, r_A, r_scratch), ctx);
4597 + emit_udiv(r_A, r_A, r_scratch, ctx);
4598 break;
4599 case BPF_S_ALU_DIV_X:
4600 update_on_xread(ctx);
4601 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4602 index a5bc92d..0bb4730 100644
4603 --- a/arch/arm/plat-omap/sram.c
4604 +++ b/arch/arm/plat-omap/sram.c
4605 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4606 * Looks like we need to preserve some bootloader code at the
4607 * beginning of SRAM for jumping to flash for reboot to work...
4608 */
4609 + pax_open_kernel();
4610 memset_io(omap_sram_base + omap_sram_skip, 0,
4611 omap_sram_size - omap_sram_skip);
4612 + pax_close_kernel();
4613 }
4614 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4615 index ce6d763..cfea917 100644
4616 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4617 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4618 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4619 int (*started)(unsigned ch);
4620 int (*flush)(unsigned ch);
4621 int (*stop)(unsigned ch);
4622 -};
4623 +} __no_const;
4624
4625 extern void *samsung_dmadev_get_ops(void);
4626 extern void *s3c_dma_get_ops(void);
4627 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4628 index c3a58a1..78fbf54 100644
4629 --- a/arch/avr32/include/asm/cache.h
4630 +++ b/arch/avr32/include/asm/cache.h
4631 @@ -1,8 +1,10 @@
4632 #ifndef __ASM_AVR32_CACHE_H
4633 #define __ASM_AVR32_CACHE_H
4634
4635 +#include <linux/const.h>
4636 +
4637 #define L1_CACHE_SHIFT 5
4638 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4639 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4640
4641 /*
4642 * Memory returned by kmalloc() may be used for DMA, so we must make
4643 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4644 index d232888..87c8df1 100644
4645 --- a/arch/avr32/include/asm/elf.h
4646 +++ b/arch/avr32/include/asm/elf.h
4647 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4648 the loader. We need to make sure that it is out of the way of the program
4649 that it will "exec", and that there is sufficient room for the brk. */
4650
4651 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4652 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4653
4654 +#ifdef CONFIG_PAX_ASLR
4655 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4656 +
4657 +#define PAX_DELTA_MMAP_LEN 15
4658 +#define PAX_DELTA_STACK_LEN 15
4659 +#endif
4660
4661 /* This yields a mask that user programs can use to figure out what
4662 instruction set this CPU supports. This could be done in user space,
4663 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4664 index 479330b..53717a8 100644
4665 --- a/arch/avr32/include/asm/kmap_types.h
4666 +++ b/arch/avr32/include/asm/kmap_types.h
4667 @@ -2,9 +2,9 @@
4668 #define __ASM_AVR32_KMAP_TYPES_H
4669
4670 #ifdef CONFIG_DEBUG_HIGHMEM
4671 -# define KM_TYPE_NR 29
4672 +# define KM_TYPE_NR 30
4673 #else
4674 -# define KM_TYPE_NR 14
4675 +# define KM_TYPE_NR 15
4676 #endif
4677
4678 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4679 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4680 index 0eca933..eb78c7b 100644
4681 --- a/arch/avr32/mm/fault.c
4682 +++ b/arch/avr32/mm/fault.c
4683 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4684
4685 int exception_trace = 1;
4686
4687 +#ifdef CONFIG_PAX_PAGEEXEC
4688 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4689 +{
4690 + unsigned long i;
4691 +
4692 + printk(KERN_ERR "PAX: bytes at PC: ");
4693 + for (i = 0; i < 20; i++) {
4694 + unsigned char c;
4695 + if (get_user(c, (unsigned char *)pc+i))
4696 + printk(KERN_CONT "???????? ");
4697 + else
4698 + printk(KERN_CONT "%02x ", c);
4699 + }
4700 + printk("\n");
4701 +}
4702 +#endif
4703 +
4704 /*
4705 * This routine handles page faults. It determines the address and the
4706 * problem, and then passes it off to one of the appropriate routines.
4707 @@ -176,6 +193,16 @@ bad_area:
4708 up_read(&mm->mmap_sem);
4709
4710 if (user_mode(regs)) {
4711 +
4712 +#ifdef CONFIG_PAX_PAGEEXEC
4713 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4714 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4715 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4716 + do_group_exit(SIGKILL);
4717 + }
4718 + }
4719 +#endif
4720 +
4721 if (exception_trace && printk_ratelimit())
4722 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4723 "sp %08lx ecr %lu\n",
4724 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4725 index 568885a..f8008df 100644
4726 --- a/arch/blackfin/include/asm/cache.h
4727 +++ b/arch/blackfin/include/asm/cache.h
4728 @@ -7,6 +7,7 @@
4729 #ifndef __ARCH_BLACKFIN_CACHE_H
4730 #define __ARCH_BLACKFIN_CACHE_H
4731
4732 +#include <linux/const.h>
4733 #include <linux/linkage.h> /* for asmlinkage */
4734
4735 /*
4736 @@ -14,7 +15,7 @@
4737 * Blackfin loads 32 bytes for cache
4738 */
4739 #define L1_CACHE_SHIFT 5
4740 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4741 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4742 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4743
4744 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4745 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4746 index aea2718..3639a60 100644
4747 --- a/arch/cris/include/arch-v10/arch/cache.h
4748 +++ b/arch/cris/include/arch-v10/arch/cache.h
4749 @@ -1,8 +1,9 @@
4750 #ifndef _ASM_ARCH_CACHE_H
4751 #define _ASM_ARCH_CACHE_H
4752
4753 +#include <linux/const.h>
4754 /* Etrax 100LX have 32-byte cache-lines. */
4755 -#define L1_CACHE_BYTES 32
4756 #define L1_CACHE_SHIFT 5
4757 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4758
4759 #endif /* _ASM_ARCH_CACHE_H */
4760 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4761 index 7caf25d..ee65ac5 100644
4762 --- a/arch/cris/include/arch-v32/arch/cache.h
4763 +++ b/arch/cris/include/arch-v32/arch/cache.h
4764 @@ -1,11 +1,12 @@
4765 #ifndef _ASM_CRIS_ARCH_CACHE_H
4766 #define _ASM_CRIS_ARCH_CACHE_H
4767
4768 +#include <linux/const.h>
4769 #include <arch/hwregs/dma.h>
4770
4771 /* A cache-line is 32 bytes. */
4772 -#define L1_CACHE_BYTES 32
4773 #define L1_CACHE_SHIFT 5
4774 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4775
4776 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4777
4778 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4779 index b86329d..6709906 100644
4780 --- a/arch/frv/include/asm/atomic.h
4781 +++ b/arch/frv/include/asm/atomic.h
4782 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4783 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4784 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4785
4786 +#define atomic64_read_unchecked(v) atomic64_read(v)
4787 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4788 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4789 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4790 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4791 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4792 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4793 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4794 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4795 +
4796 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4797 {
4798 int c, old;
4799 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4800 index 2797163..c2a401d 100644
4801 --- a/arch/frv/include/asm/cache.h
4802 +++ b/arch/frv/include/asm/cache.h
4803 @@ -12,10 +12,11 @@
4804 #ifndef __ASM_CACHE_H
4805 #define __ASM_CACHE_H
4806
4807 +#include <linux/const.h>
4808
4809 /* bytes per L1 cache line */
4810 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4811 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4812 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4813
4814 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4815 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4816 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4817 index 43901f2..0d8b865 100644
4818 --- a/arch/frv/include/asm/kmap_types.h
4819 +++ b/arch/frv/include/asm/kmap_types.h
4820 @@ -2,6 +2,6 @@
4821 #ifndef _ASM_KMAP_TYPES_H
4822 #define _ASM_KMAP_TYPES_H
4823
4824 -#define KM_TYPE_NR 17
4825 +#define KM_TYPE_NR 18
4826
4827 #endif
4828 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4829 index 836f147..4cf23f5 100644
4830 --- a/arch/frv/mm/elf-fdpic.c
4831 +++ b/arch/frv/mm/elf-fdpic.c
4832 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4833 {
4834 struct vm_area_struct *vma;
4835 struct vm_unmapped_area_info info;
4836 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4837
4838 if (len > TASK_SIZE)
4839 return -ENOMEM;
4840 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4841 if (addr) {
4842 addr = PAGE_ALIGN(addr);
4843 vma = find_vma(current->mm, addr);
4844 - if (TASK_SIZE - len >= addr &&
4845 - (!vma || addr + len <= vma->vm_start))
4846 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4847 goto success;
4848 }
4849
4850 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4851 info.high_limit = (current->mm->start_stack - 0x00200000);
4852 info.align_mask = 0;
4853 info.align_offset = 0;
4854 + info.threadstack_offset = offset;
4855 addr = vm_unmapped_area(&info);
4856 if (!(addr & ~PAGE_MASK))
4857 goto success;
4858 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4859 index f4ca594..adc72fd6 100644
4860 --- a/arch/hexagon/include/asm/cache.h
4861 +++ b/arch/hexagon/include/asm/cache.h
4862 @@ -21,9 +21,11 @@
4863 #ifndef __ASM_CACHE_H
4864 #define __ASM_CACHE_H
4865
4866 +#include <linux/const.h>
4867 +
4868 /* Bytes per L1 cache line */
4869 -#define L1_CACHE_SHIFT (5)
4870 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4871 +#define L1_CACHE_SHIFT 5
4872 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4873
4874 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4875 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4876 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
4877 index 7740ab1..17fa8c5 100644
4878 --- a/arch/ia64/Kconfig
4879 +++ b/arch/ia64/Kconfig
4880 @@ -554,6 +554,7 @@ source "drivers/sn/Kconfig"
4881 config KEXEC
4882 bool "kexec system call"
4883 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
4884 + depends on !GRKERNSEC_KMEM
4885 help
4886 kexec is a system call that implements the ability to shutdown your
4887 current kernel, and to start another kernel. It is like a reboot
4888 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4889 index 6e6fe18..a6ae668 100644
4890 --- a/arch/ia64/include/asm/atomic.h
4891 +++ b/arch/ia64/include/asm/atomic.h
4892 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4893 #define atomic64_inc(v) atomic64_add(1, (v))
4894 #define atomic64_dec(v) atomic64_sub(1, (v))
4895
4896 +#define atomic64_read_unchecked(v) atomic64_read(v)
4897 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4898 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4899 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4900 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4901 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4902 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4903 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4904 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4905 +
4906 /* Atomic operations are already serializing */
4907 #define smp_mb__before_atomic_dec() barrier()
4908 #define smp_mb__after_atomic_dec() barrier()
4909 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4910 index 988254a..e1ee885 100644
4911 --- a/arch/ia64/include/asm/cache.h
4912 +++ b/arch/ia64/include/asm/cache.h
4913 @@ -1,6 +1,7 @@
4914 #ifndef _ASM_IA64_CACHE_H
4915 #define _ASM_IA64_CACHE_H
4916
4917 +#include <linux/const.h>
4918
4919 /*
4920 * Copyright (C) 1998-2000 Hewlett-Packard Co
4921 @@ -9,7 +10,7 @@
4922
4923 /* Bytes per L1 (data) cache line. */
4924 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4925 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4927
4928 #ifdef CONFIG_SMP
4929 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4930 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4931 index 5a83c5c..4d7f553 100644
4932 --- a/arch/ia64/include/asm/elf.h
4933 +++ b/arch/ia64/include/asm/elf.h
4934 @@ -42,6 +42,13 @@
4935 */
4936 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4937
4938 +#ifdef CONFIG_PAX_ASLR
4939 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4940 +
4941 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4942 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4943 +#endif
4944 +
4945 #define PT_IA_64_UNWIND 0x70000001
4946
4947 /* IA-64 relocations: */
4948 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4949 index 96a8d92..617a1cf 100644
4950 --- a/arch/ia64/include/asm/pgalloc.h
4951 +++ b/arch/ia64/include/asm/pgalloc.h
4952 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4953 pgd_val(*pgd_entry) = __pa(pud);
4954 }
4955
4956 +static inline void
4957 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4958 +{
4959 + pgd_populate(mm, pgd_entry, pud);
4960 +}
4961 +
4962 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4963 {
4964 return quicklist_alloc(0, GFP_KERNEL, NULL);
4965 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4966 pud_val(*pud_entry) = __pa(pmd);
4967 }
4968
4969 +static inline void
4970 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4971 +{
4972 + pud_populate(mm, pud_entry, pmd);
4973 +}
4974 +
4975 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4976 {
4977 return quicklist_alloc(0, GFP_KERNEL, NULL);
4978 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4979 index 7935115..c0eca6a 100644
4980 --- a/arch/ia64/include/asm/pgtable.h
4981 +++ b/arch/ia64/include/asm/pgtable.h
4982 @@ -12,7 +12,7 @@
4983 * David Mosberger-Tang <davidm@hpl.hp.com>
4984 */
4985
4986 -
4987 +#include <linux/const.h>
4988 #include <asm/mman.h>
4989 #include <asm/page.h>
4990 #include <asm/processor.h>
4991 @@ -142,6 +142,17 @@
4992 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4993 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4994 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4995 +
4996 +#ifdef CONFIG_PAX_PAGEEXEC
4997 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4998 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4999 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5000 +#else
5001 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5002 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5003 +# define PAGE_COPY_NOEXEC PAGE_COPY
5004 +#endif
5005 +
5006 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5007 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5008 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5009 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5010 index 45698cd..e8e2dbc 100644
5011 --- a/arch/ia64/include/asm/spinlock.h
5012 +++ b/arch/ia64/include/asm/spinlock.h
5013 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5014 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5015
5016 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5017 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5018 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5019 }
5020
5021 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5022 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5023 index 449c8c0..18965fb 100644
5024 --- a/arch/ia64/include/asm/uaccess.h
5025 +++ b/arch/ia64/include/asm/uaccess.h
5026 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5027 static inline unsigned long
5028 __copy_to_user (void __user *to, const void *from, unsigned long count)
5029 {
5030 + if (count > INT_MAX)
5031 + return count;
5032 +
5033 + if (!__builtin_constant_p(count))
5034 + check_object_size(from, count, true);
5035 +
5036 return __copy_user(to, (__force void __user *) from, count);
5037 }
5038
5039 static inline unsigned long
5040 __copy_from_user (void *to, const void __user *from, unsigned long count)
5041 {
5042 + if (count > INT_MAX)
5043 + return count;
5044 +
5045 + if (!__builtin_constant_p(count))
5046 + check_object_size(to, count, false);
5047 +
5048 return __copy_user((__force void __user *) to, from, count);
5049 }
5050
5051 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5052 ({ \
5053 void __user *__cu_to = (to); \
5054 const void *__cu_from = (from); \
5055 - long __cu_len = (n); \
5056 + unsigned long __cu_len = (n); \
5057 \
5058 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5059 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5060 + if (!__builtin_constant_p(n)) \
5061 + check_object_size(__cu_from, __cu_len, true); \
5062 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5063 + } \
5064 __cu_len; \
5065 })
5066
5067 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5068 ({ \
5069 void *__cu_to = (to); \
5070 const void __user *__cu_from = (from); \
5071 - long __cu_len = (n); \
5072 + unsigned long __cu_len = (n); \
5073 \
5074 __chk_user_ptr(__cu_from); \
5075 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5076 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5077 + if (!__builtin_constant_p(n)) \
5078 + check_object_size(__cu_to, __cu_len, false); \
5079 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5080 + } \
5081 __cu_len; \
5082 })
5083
5084 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5085 index 24603be..948052d 100644
5086 --- a/arch/ia64/kernel/module.c
5087 +++ b/arch/ia64/kernel/module.c
5088 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5089 void
5090 module_free (struct module *mod, void *module_region)
5091 {
5092 - if (mod && mod->arch.init_unw_table &&
5093 - module_region == mod->module_init) {
5094 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5095 unw_remove_unwind_table(mod->arch.init_unw_table);
5096 mod->arch.init_unw_table = NULL;
5097 }
5098 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5099 }
5100
5101 static inline int
5102 +in_init_rx (const struct module *mod, uint64_t addr)
5103 +{
5104 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5105 +}
5106 +
5107 +static inline int
5108 +in_init_rw (const struct module *mod, uint64_t addr)
5109 +{
5110 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5111 +}
5112 +
5113 +static inline int
5114 in_init (const struct module *mod, uint64_t addr)
5115 {
5116 - return addr - (uint64_t) mod->module_init < mod->init_size;
5117 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5118 +}
5119 +
5120 +static inline int
5121 +in_core_rx (const struct module *mod, uint64_t addr)
5122 +{
5123 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5124 +}
5125 +
5126 +static inline int
5127 +in_core_rw (const struct module *mod, uint64_t addr)
5128 +{
5129 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5130 }
5131
5132 static inline int
5133 in_core (const struct module *mod, uint64_t addr)
5134 {
5135 - return addr - (uint64_t) mod->module_core < mod->core_size;
5136 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5137 }
5138
5139 static inline int
5140 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5141 break;
5142
5143 case RV_BDREL:
5144 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5145 + if (in_init_rx(mod, val))
5146 + val -= (uint64_t) mod->module_init_rx;
5147 + else if (in_init_rw(mod, val))
5148 + val -= (uint64_t) mod->module_init_rw;
5149 + else if (in_core_rx(mod, val))
5150 + val -= (uint64_t) mod->module_core_rx;
5151 + else if (in_core_rw(mod, val))
5152 + val -= (uint64_t) mod->module_core_rw;
5153 break;
5154
5155 case RV_LTV:
5156 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5157 * addresses have been selected...
5158 */
5159 uint64_t gp;
5160 - if (mod->core_size > MAX_LTOFF)
5161 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5162 /*
5163 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5164 * at the end of the module.
5165 */
5166 - gp = mod->core_size - MAX_LTOFF / 2;
5167 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5168 else
5169 - gp = mod->core_size / 2;
5170 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5171 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5172 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5173 mod->arch.gp = gp;
5174 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5175 }
5176 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5177 index ab33328..f39506c 100644
5178 --- a/arch/ia64/kernel/palinfo.c
5179 +++ b/arch/ia64/kernel/palinfo.c
5180 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5181 return NOTIFY_OK;
5182 }
5183
5184 -static struct notifier_block __refdata palinfo_cpu_notifier =
5185 +static struct notifier_block palinfo_cpu_notifier =
5186 {
5187 .notifier_call = palinfo_cpu_callback,
5188 .priority = 0,
5189 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5190 index 41e33f8..65180b2a 100644
5191 --- a/arch/ia64/kernel/sys_ia64.c
5192 +++ b/arch/ia64/kernel/sys_ia64.c
5193 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5194 unsigned long align_mask = 0;
5195 struct mm_struct *mm = current->mm;
5196 struct vm_unmapped_area_info info;
5197 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5198
5199 if (len > RGN_MAP_LIMIT)
5200 return -ENOMEM;
5201 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5202 if (REGION_NUMBER(addr) == RGN_HPAGE)
5203 addr = 0;
5204 #endif
5205 +
5206 +#ifdef CONFIG_PAX_RANDMMAP
5207 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5208 + addr = mm->free_area_cache;
5209 + else
5210 +#endif
5211 +
5212 if (!addr)
5213 addr = TASK_UNMAPPED_BASE;
5214
5215 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5216 info.high_limit = TASK_SIZE;
5217 info.align_mask = align_mask;
5218 info.align_offset = 0;
5219 + info.threadstack_offset = offset;
5220 return vm_unmapped_area(&info);
5221 }
5222
5223 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5224 index 0ccb28f..8992469 100644
5225 --- a/arch/ia64/kernel/vmlinux.lds.S
5226 +++ b/arch/ia64/kernel/vmlinux.lds.S
5227 @@ -198,7 +198,7 @@ SECTIONS {
5228 /* Per-cpu data: */
5229 . = ALIGN(PERCPU_PAGE_SIZE);
5230 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5231 - __phys_per_cpu_start = __per_cpu_load;
5232 + __phys_per_cpu_start = per_cpu_load;
5233 /*
5234 * ensure percpu data fits
5235 * into percpu page size
5236 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5237 index 7225dad..2a7c8256 100644
5238 --- a/arch/ia64/mm/fault.c
5239 +++ b/arch/ia64/mm/fault.c
5240 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5241 return pte_present(pte);
5242 }
5243
5244 +#ifdef CONFIG_PAX_PAGEEXEC
5245 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5246 +{
5247 + unsigned long i;
5248 +
5249 + printk(KERN_ERR "PAX: bytes at PC: ");
5250 + for (i = 0; i < 8; i++) {
5251 + unsigned int c;
5252 + if (get_user(c, (unsigned int *)pc+i))
5253 + printk(KERN_CONT "???????? ");
5254 + else
5255 + printk(KERN_CONT "%08x ", c);
5256 + }
5257 + printk("\n");
5258 +}
5259 +#endif
5260 +
5261 # define VM_READ_BIT 0
5262 # define VM_WRITE_BIT 1
5263 # define VM_EXEC_BIT 2
5264 @@ -151,8 +168,21 @@ retry:
5265 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5266 goto bad_area;
5267
5268 - if ((vma->vm_flags & mask) != mask)
5269 + if ((vma->vm_flags & mask) != mask) {
5270 +
5271 +#ifdef CONFIG_PAX_PAGEEXEC
5272 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5273 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5274 + goto bad_area;
5275 +
5276 + up_read(&mm->mmap_sem);
5277 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5278 + do_group_exit(SIGKILL);
5279 + }
5280 +#endif
5281 +
5282 goto bad_area;
5283 + }
5284
5285 /*
5286 * If for any reason at all we couldn't handle the fault, make
5287 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5288 index 68232db..6ca80af 100644
5289 --- a/arch/ia64/mm/hugetlbpage.c
5290 +++ b/arch/ia64/mm/hugetlbpage.c
5291 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5292 unsigned long pgoff, unsigned long flags)
5293 {
5294 struct vm_unmapped_area_info info;
5295 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5296
5297 if (len > RGN_MAP_LIMIT)
5298 return -ENOMEM;
5299 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5300 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5301 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5302 info.align_offset = 0;
5303 + info.threadstack_offset = offset;
5304 return vm_unmapped_area(&info);
5305 }
5306
5307 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5308 index b6f7f43..c04320d 100644
5309 --- a/arch/ia64/mm/init.c
5310 +++ b/arch/ia64/mm/init.c
5311 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5312 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5313 vma->vm_end = vma->vm_start + PAGE_SIZE;
5314 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5315 +
5316 +#ifdef CONFIG_PAX_PAGEEXEC
5317 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5318 + vma->vm_flags &= ~VM_EXEC;
5319 +
5320 +#ifdef CONFIG_PAX_MPROTECT
5321 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5322 + vma->vm_flags &= ~VM_MAYEXEC;
5323 +#endif
5324 +
5325 + }
5326 +#endif
5327 +
5328 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5329 down_write(&current->mm->mmap_sem);
5330 if (insert_vm_struct(current->mm, vma)) {
5331 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5332 index 40b3ee9..8c2c112 100644
5333 --- a/arch/m32r/include/asm/cache.h
5334 +++ b/arch/m32r/include/asm/cache.h
5335 @@ -1,8 +1,10 @@
5336 #ifndef _ASM_M32R_CACHE_H
5337 #define _ASM_M32R_CACHE_H
5338
5339 +#include <linux/const.h>
5340 +
5341 /* L1 cache line size */
5342 #define L1_CACHE_SHIFT 4
5343 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5344 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5345
5346 #endif /* _ASM_M32R_CACHE_H */
5347 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5348 index 82abd15..d95ae5d 100644
5349 --- a/arch/m32r/lib/usercopy.c
5350 +++ b/arch/m32r/lib/usercopy.c
5351 @@ -14,6 +14,9 @@
5352 unsigned long
5353 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5354 {
5355 + if ((long)n < 0)
5356 + return n;
5357 +
5358 prefetch(from);
5359 if (access_ok(VERIFY_WRITE, to, n))
5360 __copy_user(to,from,n);
5361 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5362 unsigned long
5363 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5364 {
5365 + if ((long)n < 0)
5366 + return n;
5367 +
5368 prefetchw(to);
5369 if (access_ok(VERIFY_READ, from, n))
5370 __copy_user_zeroing(to,from,n);
5371 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5372 index 0395c51..5f26031 100644
5373 --- a/arch/m68k/include/asm/cache.h
5374 +++ b/arch/m68k/include/asm/cache.h
5375 @@ -4,9 +4,11 @@
5376 #ifndef __ARCH_M68K_CACHE_H
5377 #define __ARCH_M68K_CACHE_H
5378
5379 +#include <linux/const.h>
5380 +
5381 /* bytes per L1 cache line */
5382 #define L1_CACHE_SHIFT 4
5383 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5384 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5385
5386 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5387
5388 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5389 index 0424315..defcca9 100644
5390 --- a/arch/metag/mm/hugetlbpage.c
5391 +++ b/arch/metag/mm/hugetlbpage.c
5392 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5393 info.high_limit = TASK_SIZE;
5394 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5395 info.align_offset = 0;
5396 + info.threadstack_offset = 0;
5397 return vm_unmapped_area(&info);
5398 }
5399
5400 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5401 index 4efe96a..60e8699 100644
5402 --- a/arch/microblaze/include/asm/cache.h
5403 +++ b/arch/microblaze/include/asm/cache.h
5404 @@ -13,11 +13,12 @@
5405 #ifndef _ASM_MICROBLAZE_CACHE_H
5406 #define _ASM_MICROBLAZE_CACHE_H
5407
5408 +#include <linux/const.h>
5409 #include <asm/registers.h>
5410
5411 #define L1_CACHE_SHIFT 5
5412 /* word-granular cache in microblaze */
5413 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5414 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5415
5416 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5417
5418 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5419 index f75ab4a..adc6968 100644
5420 --- a/arch/mips/Kconfig
5421 +++ b/arch/mips/Kconfig
5422 @@ -2283,6 +2283,7 @@ source "kernel/Kconfig.preempt"
5423
5424 config KEXEC
5425 bool "Kexec system call"
5426 + depends on !GRKERNSEC_KMEM
5427 help
5428 kexec is a system call that implements the ability to shutdown your
5429 current kernel, and to start another kernel. It is like a reboot
5430 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5431 index 08b6079..8b554d2 100644
5432 --- a/arch/mips/include/asm/atomic.h
5433 +++ b/arch/mips/include/asm/atomic.h
5434 @@ -21,15 +21,39 @@
5435 #include <asm/cmpxchg.h>
5436 #include <asm/war.h>
5437
5438 +#ifdef CONFIG_GENERIC_ATOMIC64
5439 +#include <asm-generic/atomic64.h>
5440 +#endif
5441 +
5442 #define ATOMIC_INIT(i) { (i) }
5443
5444 +#ifdef CONFIG_64BIT
5445 +#define _ASM_EXTABLE(from, to) \
5446 +" .section __ex_table,\"a\"\n" \
5447 +" .dword " #from ", " #to"\n" \
5448 +" .previous\n"
5449 +#else
5450 +#define _ASM_EXTABLE(from, to) \
5451 +" .section __ex_table,\"a\"\n" \
5452 +" .word " #from ", " #to"\n" \
5453 +" .previous\n"
5454 +#endif
5455 +
5456 /*
5457 * atomic_read - read atomic variable
5458 * @v: pointer of type atomic_t
5459 *
5460 * Atomically reads the value of @v.
5461 */
5462 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5463 +static inline int atomic_read(const atomic_t *v)
5464 +{
5465 + return (*(volatile const int *) &v->counter);
5466 +}
5467 +
5468 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5469 +{
5470 + return (*(volatile const int *) &v->counter);
5471 +}
5472
5473 /*
5474 * atomic_set - set atomic variable
5475 @@ -38,7 +62,15 @@
5476 *
5477 * Atomically sets the value of @v to @i.
5478 */
5479 -#define atomic_set(v, i) ((v)->counter = (i))
5480 +static inline void atomic_set(atomic_t *v, int i)
5481 +{
5482 + v->counter = i;
5483 +}
5484 +
5485 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5486 +{
5487 + v->counter = i;
5488 +}
5489
5490 /*
5491 * atomic_add - add integer to atomic variable
5492 @@ -47,7 +79,67 @@
5493 *
5494 * Atomically adds @i to @v.
5495 */
5496 -static __inline__ void atomic_add(int i, atomic_t * v)
5497 +static __inline__ void atomic_add(int i, atomic_t *v)
5498 +{
5499 + int temp;
5500 +
5501 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5502 + __asm__ __volatile__(
5503 + " .set mips3 \n"
5504 + "1: ll %0, %1 # atomic_add \n"
5505 +#ifdef CONFIG_PAX_REFCOUNT
5506 + /* Exception on overflow. */
5507 + "2: add %0, %2 \n"
5508 +#else
5509 + " addu %0, %2 \n"
5510 +#endif
5511 + " sc %0, %1 \n"
5512 + " beqzl %0, 1b \n"
5513 +#ifdef CONFIG_PAX_REFCOUNT
5514 + "3: \n"
5515 + _ASM_EXTABLE(2b, 3b)
5516 +#endif
5517 + " .set mips0 \n"
5518 + : "=&r" (temp), "+m" (v->counter)
5519 + : "Ir" (i));
5520 + } else if (kernel_uses_llsc) {
5521 + __asm__ __volatile__(
5522 + " .set mips3 \n"
5523 + "1: ll %0, %1 # atomic_add \n"
5524 +#ifdef CONFIG_PAX_REFCOUNT
5525 + /* Exception on overflow. */
5526 + "2: add %0, %2 \n"
5527 +#else
5528 + " addu %0, %2 \n"
5529 +#endif
5530 + " sc %0, %1 \n"
5531 + " beqz %0, 1b \n"
5532 +#ifdef CONFIG_PAX_REFCOUNT
5533 + "3: \n"
5534 + _ASM_EXTABLE(2b, 3b)
5535 +#endif
5536 + " .set mips0 \n"
5537 + : "=&r" (temp), "+m" (v->counter)
5538 + : "Ir" (i));
5539 + } else {
5540 + unsigned long flags;
5541 +
5542 + raw_local_irq_save(flags);
5543 + __asm__ __volatile__(
5544 +#ifdef CONFIG_PAX_REFCOUNT
5545 + /* Exception on overflow. */
5546 + "1: add %0, %1 \n"
5547 + "2: \n"
5548 + _ASM_EXTABLE(1b, 2b)
5549 +#else
5550 + " addu %0, %1 \n"
5551 +#endif
5552 + : "+r" (v->counter) : "Ir" (i));
5553 + raw_local_irq_restore(flags);
5554 + }
5555 +}
5556 +
5557 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5558 {
5559 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5560 int temp;
5561 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5562 *
5563 * Atomically subtracts @i from @v.
5564 */
5565 -static __inline__ void atomic_sub(int i, atomic_t * v)
5566 +static __inline__ void atomic_sub(int i, atomic_t *v)
5567 +{
5568 + int temp;
5569 +
5570 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5571 + __asm__ __volatile__(
5572 + " .set mips3 \n"
5573 + "1: ll %0, %1 # atomic64_sub \n"
5574 +#ifdef CONFIG_PAX_REFCOUNT
5575 + /* Exception on overflow. */
5576 + "2: sub %0, %2 \n"
5577 +#else
5578 + " subu %0, %2 \n"
5579 +#endif
5580 + " sc %0, %1 \n"
5581 + " beqzl %0, 1b \n"
5582 +#ifdef CONFIG_PAX_REFCOUNT
5583 + "3: \n"
5584 + _ASM_EXTABLE(2b, 3b)
5585 +#endif
5586 + " .set mips0 \n"
5587 + : "=&r" (temp), "+m" (v->counter)
5588 + : "Ir" (i));
5589 + } else if (kernel_uses_llsc) {
5590 + __asm__ __volatile__(
5591 + " .set mips3 \n"
5592 + "1: ll %0, %1 # atomic64_sub \n"
5593 +#ifdef CONFIG_PAX_REFCOUNT
5594 + /* Exception on overflow. */
5595 + "2: sub %0, %2 \n"
5596 +#else
5597 + " subu %0, %2 \n"
5598 +#endif
5599 + " sc %0, %1 \n"
5600 + " beqz %0, 1b \n"
5601 +#ifdef CONFIG_PAX_REFCOUNT
5602 + "3: \n"
5603 + _ASM_EXTABLE(2b, 3b)
5604 +#endif
5605 + " .set mips0 \n"
5606 + : "=&r" (temp), "+m" (v->counter)
5607 + : "Ir" (i));
5608 + } else {
5609 + unsigned long flags;
5610 +
5611 + raw_local_irq_save(flags);
5612 + __asm__ __volatile__(
5613 +#ifdef CONFIG_PAX_REFCOUNT
5614 + /* Exception on overflow. */
5615 + "1: sub %0, %1 \n"
5616 + "2: \n"
5617 + _ASM_EXTABLE(1b, 2b)
5618 +#else
5619 + " subu %0, %1 \n"
5620 +#endif
5621 + : "+r" (v->counter) : "Ir" (i));
5622 + raw_local_irq_restore(flags);
5623 + }
5624 +}
5625 +
5626 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5627 {
5628 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5629 int temp;
5630 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5631 /*
5632 * Same as above, but return the result value
5633 */
5634 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5635 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5636 +{
5637 + int result;
5638 + int temp;
5639 +
5640 + smp_mb__before_llsc();
5641 +
5642 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5643 + __asm__ __volatile__(
5644 + " .set mips3 \n"
5645 + "1: ll %1, %2 # atomic_add_return \n"
5646 +#ifdef CONFIG_PAX_REFCOUNT
5647 + "2: add %0, %1, %3 \n"
5648 +#else
5649 + " addu %0, %1, %3 \n"
5650 +#endif
5651 + " sc %0, %2 \n"
5652 + " beqzl %0, 1b \n"
5653 +#ifdef CONFIG_PAX_REFCOUNT
5654 + " b 4f \n"
5655 + " .set noreorder \n"
5656 + "3: b 5f \n"
5657 + " move %0, %1 \n"
5658 + " .set reorder \n"
5659 + _ASM_EXTABLE(2b, 3b)
5660 +#endif
5661 + "4: addu %0, %1, %3 \n"
5662 +#ifdef CONFIG_PAX_REFCOUNT
5663 + "5: \n"
5664 +#endif
5665 + " .set mips0 \n"
5666 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5667 + : "Ir" (i));
5668 + } else if (kernel_uses_llsc) {
5669 + __asm__ __volatile__(
5670 + " .set mips3 \n"
5671 + "1: ll %1, %2 # atomic_add_return \n"
5672 +#ifdef CONFIG_PAX_REFCOUNT
5673 + "2: add %0, %1, %3 \n"
5674 +#else
5675 + " addu %0, %1, %3 \n"
5676 +#endif
5677 + " sc %0, %2 \n"
5678 + " bnez %0, 4f \n"
5679 + " b 1b \n"
5680 +#ifdef CONFIG_PAX_REFCOUNT
5681 + " .set noreorder \n"
5682 + "3: b 5f \n"
5683 + " move %0, %1 \n"
5684 + " .set reorder \n"
5685 + _ASM_EXTABLE(2b, 3b)
5686 +#endif
5687 + "4: addu %0, %1, %3 \n"
5688 +#ifdef CONFIG_PAX_REFCOUNT
5689 + "5: \n"
5690 +#endif
5691 + " .set mips0 \n"
5692 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5693 + : "Ir" (i));
5694 + } else {
5695 + unsigned long flags;
5696 +
5697 + raw_local_irq_save(flags);
5698 + __asm__ __volatile__(
5699 + " lw %0, %1 \n"
5700 +#ifdef CONFIG_PAX_REFCOUNT
5701 + /* Exception on overflow. */
5702 + "1: add %0, %2 \n"
5703 +#else
5704 + " addu %0, %2 \n"
5705 +#endif
5706 + " sw %0, %1 \n"
5707 +#ifdef CONFIG_PAX_REFCOUNT
5708 + /* Note: Dest reg is not modified on overflow */
5709 + "2: \n"
5710 + _ASM_EXTABLE(1b, 2b)
5711 +#endif
5712 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5713 + raw_local_irq_restore(flags);
5714 + }
5715 +
5716 + smp_llsc_mb();
5717 +
5718 + return result;
5719 +}
5720 +
5721 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5722 {
5723 int result;
5724
5725 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5726 return result;
5727 }
5728
5729 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5730 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5731 +{
5732 + int result;
5733 + int temp;
5734 +
5735 + smp_mb__before_llsc();
5736 +
5737 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5738 + __asm__ __volatile__(
5739 + " .set mips3 \n"
5740 + "1: ll %1, %2 # atomic_sub_return \n"
5741 +#ifdef CONFIG_PAX_REFCOUNT
5742 + "2: sub %0, %1, %3 \n"
5743 +#else
5744 + " subu %0, %1, %3 \n"
5745 +#endif
5746 + " sc %0, %2 \n"
5747 + " beqzl %0, 1b \n"
5748 +#ifdef CONFIG_PAX_REFCOUNT
5749 + " b 4f \n"
5750 + " .set noreorder \n"
5751 + "3: b 5f \n"
5752 + " move %0, %1 \n"
5753 + " .set reorder \n"
5754 + _ASM_EXTABLE(2b, 3b)
5755 +#endif
5756 + "4: subu %0, %1, %3 \n"
5757 +#ifdef CONFIG_PAX_REFCOUNT
5758 + "5: \n"
5759 +#endif
5760 + " .set mips0 \n"
5761 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5762 + : "Ir" (i), "m" (v->counter)
5763 + : "memory");
5764 + } else if (kernel_uses_llsc) {
5765 + __asm__ __volatile__(
5766 + " .set mips3 \n"
5767 + "1: ll %1, %2 # atomic_sub_return \n"
5768 +#ifdef CONFIG_PAX_REFCOUNT
5769 + "2: sub %0, %1, %3 \n"
5770 +#else
5771 + " subu %0, %1, %3 \n"
5772 +#endif
5773 + " sc %0, %2 \n"
5774 + " bnez %0, 4f \n"
5775 + " b 1b \n"
5776 +#ifdef CONFIG_PAX_REFCOUNT
5777 + " .set noreorder \n"
5778 + "3: b 5f \n"
5779 + " move %0, %1 \n"
5780 + " .set reorder \n"
5781 + _ASM_EXTABLE(2b, 3b)
5782 +#endif
5783 + "4: subu %0, %1, %3 \n"
5784 +#ifdef CONFIG_PAX_REFCOUNT
5785 + "5: \n"
5786 +#endif
5787 + " .set mips0 \n"
5788 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5789 + : "Ir" (i));
5790 + } else {
5791 + unsigned long flags;
5792 +
5793 + raw_local_irq_save(flags);
5794 + __asm__ __volatile__(
5795 + " lw %0, %1 \n"
5796 +#ifdef CONFIG_PAX_REFCOUNT
5797 + /* Exception on overflow. */
5798 + "1: sub %0, %2 \n"
5799 +#else
5800 + " subu %0, %2 \n"
5801 +#endif
5802 + " sw %0, %1 \n"
5803 +#ifdef CONFIG_PAX_REFCOUNT
5804 + /* Note: Dest reg is not modified on overflow */
5805 + "2: \n"
5806 + _ASM_EXTABLE(1b, 2b)
5807 +#endif
5808 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5809 + raw_local_irq_restore(flags);
5810 + }
5811 +
5812 + smp_llsc_mb();
5813 +
5814 + return result;
5815 +}
5816 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5817 {
5818 int result;
5819
5820 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5821 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5822 * The function returns the old value of @v minus @i.
5823 */
5824 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5825 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5826 {
5827 int result;
5828
5829 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5830 return result;
5831 }
5832
5833 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5834 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5835 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5836 +{
5837 + return cmpxchg(&v->counter, old, new);
5838 +}
5839 +
5840 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5841 + int new)
5842 +{
5843 + return cmpxchg(&(v->counter), old, new);
5844 +}
5845 +
5846 +static inline int atomic_xchg(atomic_t *v, int new)
5847 +{
5848 + return xchg(&v->counter, new);
5849 +}
5850 +
5851 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5852 +{
5853 + return xchg(&(v->counter), new);
5854 +}
5855
5856 /**
5857 * __atomic_add_unless - add unless the number is a given value
5858 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5859
5860 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5861 #define atomic_inc_return(v) atomic_add_return(1, (v))
5862 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5863 +{
5864 + return atomic_add_return_unchecked(1, v);
5865 +}
5866
5867 /*
5868 * atomic_sub_and_test - subtract value from variable and test result
5869 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5870 * other cases.
5871 */
5872 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5873 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5874 +{
5875 + return atomic_add_return_unchecked(1, v) == 0;
5876 +}
5877
5878 /*
5879 * atomic_dec_and_test - decrement by 1 and test
5880 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5881 * Atomically increments @v by 1.
5882 */
5883 #define atomic_inc(v) atomic_add(1, (v))
5884 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5885 +{
5886 + atomic_add_unchecked(1, v);
5887 +}
5888
5889 /*
5890 * atomic_dec - decrement and test
5891 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5892 * Atomically decrements @v by 1.
5893 */
5894 #define atomic_dec(v) atomic_sub(1, (v))
5895 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5896 +{
5897 + atomic_sub_unchecked(1, v);
5898 +}
5899
5900 /*
5901 * atomic_add_negative - add and test if negative
5902 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5903 * @v: pointer of type atomic64_t
5904 *
5905 */
5906 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5907 +static inline long atomic64_read(const atomic64_t *v)
5908 +{
5909 + return (*(volatile const long *) &v->counter);
5910 +}
5911 +
5912 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5913 +{
5914 + return (*(volatile const long *) &v->counter);
5915 +}
5916
5917 /*
5918 * atomic64_set - set atomic variable
5919 * @v: pointer of type atomic64_t
5920 * @i: required value
5921 */
5922 -#define atomic64_set(v, i) ((v)->counter = (i))
5923 +static inline void atomic64_set(atomic64_t *v, long i)
5924 +{
5925 + v->counter = i;
5926 +}
5927 +
5928 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5929 +{
5930 + v->counter = i;
5931 +}
5932
5933 /*
5934 * atomic64_add - add integer to atomic variable
5935 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5936 *
5937 * Atomically adds @i to @v.
5938 */
5939 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5940 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5941 +{
5942 + long temp;
5943 +
5944 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5945 + __asm__ __volatile__(
5946 + " .set mips3 \n"
5947 + "1: lld %0, %1 # atomic64_add \n"
5948 +#ifdef CONFIG_PAX_REFCOUNT
5949 + /* Exception on overflow. */
5950 + "2: dadd %0, %2 \n"
5951 +#else
5952 + " daddu %0, %2 \n"
5953 +#endif
5954 + " scd %0, %1 \n"
5955 + " beqzl %0, 1b \n"
5956 +#ifdef CONFIG_PAX_REFCOUNT
5957 + "3: \n"
5958 + _ASM_EXTABLE(2b, 3b)
5959 +#endif
5960 + " .set mips0 \n"
5961 + : "=&r" (temp), "+m" (v->counter)
5962 + : "Ir" (i));
5963 + } else if (kernel_uses_llsc) {
5964 + __asm__ __volatile__(
5965 + " .set mips3 \n"
5966 + "1: lld %0, %1 # atomic64_add \n"
5967 +#ifdef CONFIG_PAX_REFCOUNT
5968 + /* Exception on overflow. */
5969 + "2: dadd %0, %2 \n"
5970 +#else
5971 + " daddu %0, %2 \n"
5972 +#endif
5973 + " scd %0, %1 \n"
5974 + " beqz %0, 1b \n"
5975 +#ifdef CONFIG_PAX_REFCOUNT
5976 + "3: \n"
5977 + _ASM_EXTABLE(2b, 3b)
5978 +#endif
5979 + " .set mips0 \n"
5980 + : "=&r" (temp), "+m" (v->counter)
5981 + : "Ir" (i));
5982 + } else {
5983 + unsigned long flags;
5984 +
5985 + raw_local_irq_save(flags);
5986 + __asm__ __volatile__(
5987 +#ifdef CONFIG_PAX_REFCOUNT
5988 + /* Exception on overflow. */
5989 + "1: dadd %0, %1 \n"
5990 + "2: \n"
5991 + _ASM_EXTABLE(1b, 2b)
5992 +#else
5993 + " daddu %0, %1 \n"
5994 +#endif
5995 + : "+r" (v->counter) : "Ir" (i));
5996 + raw_local_irq_restore(flags);
5997 + }
5998 +}
5999 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
6000 {
6001 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6002 long temp;
6003 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
6004 *
6005 * Atomically subtracts @i from @v.
6006 */
6007 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
6008 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
6009 +{
6010 + long temp;
6011 +
6012 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6013 + __asm__ __volatile__(
6014 + " .set mips3 \n"
6015 + "1: lld %0, %1 # atomic64_sub \n"
6016 +#ifdef CONFIG_PAX_REFCOUNT
6017 + /* Exception on overflow. */
6018 + "2: dsub %0, %2 \n"
6019 +#else
6020 + " dsubu %0, %2 \n"
6021 +#endif
6022 + " scd %0, %1 \n"
6023 + " beqzl %0, 1b \n"
6024 +#ifdef CONFIG_PAX_REFCOUNT
6025 + "3: \n"
6026 + _ASM_EXTABLE(2b, 3b)
6027 +#endif
6028 + " .set mips0 \n"
6029 + : "=&r" (temp), "+m" (v->counter)
6030 + : "Ir" (i));
6031 + } else if (kernel_uses_llsc) {
6032 + __asm__ __volatile__(
6033 + " .set mips3 \n"
6034 + "1: lld %0, %1 # atomic64_sub \n"
6035 +#ifdef CONFIG_PAX_REFCOUNT
6036 + /* Exception on overflow. */
6037 + "2: dsub %0, %2 \n"
6038 +#else
6039 + " dsubu %0, %2 \n"
6040 +#endif
6041 + " scd %0, %1 \n"
6042 + " beqz %0, 1b \n"
6043 +#ifdef CONFIG_PAX_REFCOUNT
6044 + "3: \n"
6045 + _ASM_EXTABLE(2b, 3b)
6046 +#endif
6047 + " .set mips0 \n"
6048 + : "=&r" (temp), "+m" (v->counter)
6049 + : "Ir" (i));
6050 + } else {
6051 + unsigned long flags;
6052 +
6053 + raw_local_irq_save(flags);
6054 + __asm__ __volatile__(
6055 +#ifdef CONFIG_PAX_REFCOUNT
6056 + /* Exception on overflow. */
6057 + "1: dsub %0, %1 \n"
6058 + "2: \n"
6059 + _ASM_EXTABLE(1b, 2b)
6060 +#else
6061 + " dsubu %0, %1 \n"
6062 +#endif
6063 + : "+r" (v->counter) : "Ir" (i));
6064 + raw_local_irq_restore(flags);
6065 + }
6066 +}
6067 +
6068 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6069 {
6070 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6071 long temp;
6072 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6073 /*
6074 * Same as above, but return the result value
6075 */
6076 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6077 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6078 +{
6079 + long result;
6080 + long temp;
6081 +
6082 + smp_mb__before_llsc();
6083 +
6084 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6085 + __asm__ __volatile__(
6086 + " .set mips3 \n"
6087 + "1: lld %1, %2 # atomic64_add_return \n"
6088 +#ifdef CONFIG_PAX_REFCOUNT
6089 + "2: dadd %0, %1, %3 \n"
6090 +#else
6091 + " daddu %0, %1, %3 \n"
6092 +#endif
6093 + " scd %0, %2 \n"
6094 + " beqzl %0, 1b \n"
6095 +#ifdef CONFIG_PAX_REFCOUNT
6096 + " b 4f \n"
6097 + " .set noreorder \n"
6098 + "3: b 5f \n"
6099 + " move %0, %1 \n"
6100 + " .set reorder \n"
6101 + _ASM_EXTABLE(2b, 3b)
6102 +#endif
6103 + "4: daddu %0, %1, %3 \n"
6104 +#ifdef CONFIG_PAX_REFCOUNT
6105 + "5: \n"
6106 +#endif
6107 + " .set mips0 \n"
6108 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6109 + : "Ir" (i));
6110 + } else if (kernel_uses_llsc) {
6111 + __asm__ __volatile__(
6112 + " .set mips3 \n"
6113 + "1: lld %1, %2 # atomic64_add_return \n"
6114 +#ifdef CONFIG_PAX_REFCOUNT
6115 + "2: dadd %0, %1, %3 \n"
6116 +#else
6117 + " daddu %0, %1, %3 \n"
6118 +#endif
6119 + " scd %0, %2 \n"
6120 + " bnez %0, 4f \n"
6121 + " b 1b \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + " .set noreorder \n"
6124 + "3: b 5f \n"
6125 + " move %0, %1 \n"
6126 + " .set reorder \n"
6127 + _ASM_EXTABLE(2b, 3b)
6128 +#endif
6129 + "4: daddu %0, %1, %3 \n"
6130 +#ifdef CONFIG_PAX_REFCOUNT
6131 + "5: \n"
6132 +#endif
6133 + " .set mips0 \n"
6134 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6135 + : "Ir" (i), "m" (v->counter)
6136 + : "memory");
6137 + } else {
6138 + unsigned long flags;
6139 +
6140 + raw_local_irq_save(flags);
6141 + __asm__ __volatile__(
6142 + " ld %0, %1 \n"
6143 +#ifdef CONFIG_PAX_REFCOUNT
6144 + /* Exception on overflow. */
6145 + "1: dadd %0, %2 \n"
6146 +#else
6147 + " daddu %0, %2 \n"
6148 +#endif
6149 + " sd %0, %1 \n"
6150 +#ifdef CONFIG_PAX_REFCOUNT
6151 + /* Note: Dest reg is not modified on overflow */
6152 + "2: \n"
6153 + _ASM_EXTABLE(1b, 2b)
6154 +#endif
6155 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6156 + raw_local_irq_restore(flags);
6157 + }
6158 +
6159 + smp_llsc_mb();
6160 +
6161 + return result;
6162 +}
6163 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6164 {
6165 long result;
6166
6167 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6168 return result;
6169 }
6170
6171 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6172 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6173 +{
6174 + long result;
6175 + long temp;
6176 +
6177 + smp_mb__before_llsc();
6178 +
6179 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6180 + long temp;
6181 +
6182 + __asm__ __volatile__(
6183 + " .set mips3 \n"
6184 + "1: lld %1, %2 # atomic64_sub_return \n"
6185 +#ifdef CONFIG_PAX_REFCOUNT
6186 + "2: dsub %0, %1, %3 \n"
6187 +#else
6188 + " dsubu %0, %1, %3 \n"
6189 +#endif
6190 + " scd %0, %2 \n"
6191 + " beqzl %0, 1b \n"
6192 +#ifdef CONFIG_PAX_REFCOUNT
6193 + " b 4f \n"
6194 + " .set noreorder \n"
6195 + "3: b 5f \n"
6196 + " move %0, %1 \n"
6197 + " .set reorder \n"
6198 + _ASM_EXTABLE(2b, 3b)
6199 +#endif
6200 + "4: dsubu %0, %1, %3 \n"
6201 +#ifdef CONFIG_PAX_REFCOUNT
6202 + "5: \n"
6203 +#endif
6204 + " .set mips0 \n"
6205 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6206 + : "Ir" (i), "m" (v->counter)
6207 + : "memory");
6208 + } else if (kernel_uses_llsc) {
6209 + __asm__ __volatile__(
6210 + " .set mips3 \n"
6211 + "1: lld %1, %2 # atomic64_sub_return \n"
6212 +#ifdef CONFIG_PAX_REFCOUNT
6213 + "2: dsub %0, %1, %3 \n"
6214 +#else
6215 + " dsubu %0, %1, %3 \n"
6216 +#endif
6217 + " scd %0, %2 \n"
6218 + " bnez %0, 4f \n"
6219 + " b 1b \n"
6220 +#ifdef CONFIG_PAX_REFCOUNT
6221 + " .set noreorder \n"
6222 + "3: b 5f \n"
6223 + " move %0, %1 \n"
6224 + " .set reorder \n"
6225 + _ASM_EXTABLE(2b, 3b)
6226 +#endif
6227 + "4: dsubu %0, %1, %3 \n"
6228 +#ifdef CONFIG_PAX_REFCOUNT
6229 + "5: \n"
6230 +#endif
6231 + " .set mips0 \n"
6232 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6233 + : "Ir" (i), "m" (v->counter)
6234 + : "memory");
6235 + } else {
6236 + unsigned long flags;
6237 +
6238 + raw_local_irq_save(flags);
6239 + __asm__ __volatile__(
6240 + " ld %0, %1 \n"
6241 +#ifdef CONFIG_PAX_REFCOUNT
6242 + /* Exception on overflow. */
6243 + "1: dsub %0, %2 \n"
6244 +#else
6245 + " dsubu %0, %2 \n"
6246 +#endif
6247 + " sd %0, %1 \n"
6248 +#ifdef CONFIG_PAX_REFCOUNT
6249 + /* Note: Dest reg is not modified on overflow */
6250 + "2: \n"
6251 + _ASM_EXTABLE(1b, 2b)
6252 +#endif
6253 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6254 + raw_local_irq_restore(flags);
6255 + }
6256 +
6257 + smp_llsc_mb();
6258 +
6259 + return result;
6260 +}
6261 +
6262 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6263 {
6264 long result;
6265
6266 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6267 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6268 * The function returns the old value of @v minus @i.
6269 */
6270 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6271 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6272 {
6273 long result;
6274
6275 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6276 return result;
6277 }
6278
6279 -#define atomic64_cmpxchg(v, o, n) \
6280 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6281 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6282 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6283 +{
6284 + return cmpxchg(&v->counter, old, new);
6285 +}
6286 +
6287 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6288 + long new)
6289 +{
6290 + return cmpxchg(&(v->counter), old, new);
6291 +}
6292 +
6293 +static inline long atomic64_xchg(atomic64_t *v, long new)
6294 +{
6295 + return xchg(&v->counter, new);
6296 +}
6297 +
6298 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6299 +{
6300 + return xchg(&(v->counter), new);
6301 +}
6302
6303 /**
6304 * atomic64_add_unless - add unless the number is a given value
6305 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6306
6307 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6308 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6309 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6310
6311 /*
6312 * atomic64_sub_and_test - subtract value from variable and test result
6313 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6314 * other cases.
6315 */
6316 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6317 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6318
6319 /*
6320 * atomic64_dec_and_test - decrement by 1 and test
6321 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6322 * Atomically increments @v by 1.
6323 */
6324 #define atomic64_inc(v) atomic64_add(1, (v))
6325 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6326
6327 /*
6328 * atomic64_dec - decrement and test
6329 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6330 * Atomically decrements @v by 1.
6331 */
6332 #define atomic64_dec(v) atomic64_sub(1, (v))
6333 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6334
6335 /*
6336 * atomic64_add_negative - add and test if negative
6337 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6338 index b4db69f..8f3b093 100644
6339 --- a/arch/mips/include/asm/cache.h
6340 +++ b/arch/mips/include/asm/cache.h
6341 @@ -9,10 +9,11 @@
6342 #ifndef _ASM_CACHE_H
6343 #define _ASM_CACHE_H
6344
6345 +#include <linux/const.h>
6346 #include <kmalloc.h>
6347
6348 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6349 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6350 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6351
6352 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6353 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6354 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6355 index cf3ae24..238d22f 100644
6356 --- a/arch/mips/include/asm/elf.h
6357 +++ b/arch/mips/include/asm/elf.h
6358 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6359 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6360 #endif
6361
6362 +#ifdef CONFIG_PAX_ASLR
6363 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6364 +
6365 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6366 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6367 +#endif
6368 +
6369 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6370 struct linux_binprm;
6371 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6372 int uses_interp);
6373
6374 -struct mm_struct;
6375 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6376 -#define arch_randomize_brk arch_randomize_brk
6377 -
6378 #endif /* _ASM_ELF_H */
6379 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6380 index c1f6afa..38cc6e9 100644
6381 --- a/arch/mips/include/asm/exec.h
6382 +++ b/arch/mips/include/asm/exec.h
6383 @@ -12,6 +12,6 @@
6384 #ifndef _ASM_EXEC_H
6385 #define _ASM_EXEC_H
6386
6387 -extern unsigned long arch_align_stack(unsigned long sp);
6388 +#define arch_align_stack(x) ((x) & ~0xfUL)
6389
6390 #endif /* _ASM_EXEC_H */
6391 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6392 index d44622c..64990d2 100644
6393 --- a/arch/mips/include/asm/local.h
6394 +++ b/arch/mips/include/asm/local.h
6395 @@ -12,15 +12,25 @@ typedef struct
6396 atomic_long_t a;
6397 } local_t;
6398
6399 +typedef struct {
6400 + atomic_long_unchecked_t a;
6401 +} local_unchecked_t;
6402 +
6403 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6404
6405 #define local_read(l) atomic_long_read(&(l)->a)
6406 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6407 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6408 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6409
6410 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6411 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6412 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6413 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6414 #define local_inc(l) atomic_long_inc(&(l)->a)
6415 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6416 #define local_dec(l) atomic_long_dec(&(l)->a)
6417 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6418
6419 /*
6420 * Same as above, but return the result value
6421 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6422 return result;
6423 }
6424
6425 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6426 +{
6427 + unsigned long result;
6428 +
6429 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6430 + unsigned long temp;
6431 +
6432 + __asm__ __volatile__(
6433 + " .set mips3 \n"
6434 + "1:" __LL "%1, %2 # local_add_return \n"
6435 + " addu %0, %1, %3 \n"
6436 + __SC "%0, %2 \n"
6437 + " beqzl %0, 1b \n"
6438 + " addu %0, %1, %3 \n"
6439 + " .set mips0 \n"
6440 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6441 + : "Ir" (i), "m" (l->a.counter)
6442 + : "memory");
6443 + } else if (kernel_uses_llsc) {
6444 + unsigned long temp;
6445 +
6446 + __asm__ __volatile__(
6447 + " .set mips3 \n"
6448 + "1:" __LL "%1, %2 # local_add_return \n"
6449 + " addu %0, %1, %3 \n"
6450 + __SC "%0, %2 \n"
6451 + " beqz %0, 1b \n"
6452 + " addu %0, %1, %3 \n"
6453 + " .set mips0 \n"
6454 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6455 + : "Ir" (i), "m" (l->a.counter)
6456 + : "memory");
6457 + } else {
6458 + unsigned long flags;
6459 +
6460 + local_irq_save(flags);
6461 + result = l->a.counter;
6462 + result += i;
6463 + l->a.counter = result;
6464 + local_irq_restore(flags);
6465 + }
6466 +
6467 + return result;
6468 +}
6469 +
6470 static __inline__ long local_sub_return(long i, local_t * l)
6471 {
6472 unsigned long result;
6473 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6474
6475 #define local_cmpxchg(l, o, n) \
6476 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6477 +#define local_cmpxchg_unchecked(l, o, n) \
6478 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6479 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6480
6481 /**
6482 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6483 index f6be474..12ad554 100644
6484 --- a/arch/mips/include/asm/page.h
6485 +++ b/arch/mips/include/asm/page.h
6486 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6487 #ifdef CONFIG_CPU_MIPS32
6488 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6489 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6490 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6491 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6492 #else
6493 typedef struct { unsigned long long pte; } pte_t;
6494 #define pte_val(x) ((x).pte)
6495 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6496 index 881d18b..cea38bc 100644
6497 --- a/arch/mips/include/asm/pgalloc.h
6498 +++ b/arch/mips/include/asm/pgalloc.h
6499 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6500 {
6501 set_pud(pud, __pud((unsigned long)pmd));
6502 }
6503 +
6504 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6505 +{
6506 + pud_populate(mm, pud, pmd);
6507 +}
6508 #endif
6509
6510 /*
6511 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6512 index 25da651..ae2a259 100644
6513 --- a/arch/mips/include/asm/smtc_proc.h
6514 +++ b/arch/mips/include/asm/smtc_proc.h
6515 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6516
6517 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6518
6519 -extern atomic_t smtc_fpu_recoveries;
6520 +extern atomic_unchecked_t smtc_fpu_recoveries;
6521
6522 #endif /* __ASM_SMTC_PROC_H */
6523 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6524 index 61215a3..213ee0e 100644
6525 --- a/arch/mips/include/asm/thread_info.h
6526 +++ b/arch/mips/include/asm/thread_info.h
6527 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6528 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6529 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6530 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6531 +/* li takes a 32bit immediate */
6532 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6533 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6534
6535 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6536 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6537 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6538 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6539 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6540 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6541
6542 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6543 - _TIF_SYSCALL_AUDIT)
6544 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6545
6546 /* work to do in syscall_trace_leave() */
6547 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6548 - _TIF_SYSCALL_AUDIT)
6549 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6550
6551 /* work to do on interrupt/exception return */
6552 #define _TIF_WORK_MASK \
6553 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6554 /* work to do on any return to u-space */
6555 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6556 - _TIF_WORK_SYSCALL_EXIT)
6557 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6558
6559 #endif /* __KERNEL__ */
6560
6561 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6562 index 1188e00..41cf144 100644
6563 --- a/arch/mips/kernel/binfmt_elfn32.c
6564 +++ b/arch/mips/kernel/binfmt_elfn32.c
6565 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6566 #undef ELF_ET_DYN_BASE
6567 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6568
6569 +#ifdef CONFIG_PAX_ASLR
6570 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6571 +
6572 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6573 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6574 +#endif
6575 +
6576 #include <asm/processor.h>
6577 #include <linux/module.h>
6578 #include <linux/elfcore.h>
6579 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6580 index 202e581..689ca79 100644
6581 --- a/arch/mips/kernel/binfmt_elfo32.c
6582 +++ b/arch/mips/kernel/binfmt_elfo32.c
6583 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6584 #undef ELF_ET_DYN_BASE
6585 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6586
6587 +#ifdef CONFIG_PAX_ASLR
6588 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6589 +
6590 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6591 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6592 +#endif
6593 +
6594 #include <asm/processor.h>
6595
6596 /*
6597 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6598 index d1fea7a..45602ea 100644
6599 --- a/arch/mips/kernel/irq.c
6600 +++ b/arch/mips/kernel/irq.c
6601 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6602 printk("unexpected IRQ # %d\n", irq);
6603 }
6604
6605 -atomic_t irq_err_count;
6606 +atomic_unchecked_t irq_err_count;
6607
6608 int arch_show_interrupts(struct seq_file *p, int prec)
6609 {
6610 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6611 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6612 return 0;
6613 }
6614
6615 asmlinkage void spurious_interrupt(void)
6616 {
6617 - atomic_inc(&irq_err_count);
6618 + atomic_inc_unchecked(&irq_err_count);
6619 }
6620
6621 void __init init_IRQ(void)
6622 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6623 index ddc7610..8c58f17 100644
6624 --- a/arch/mips/kernel/process.c
6625 +++ b/arch/mips/kernel/process.c
6626 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6627 out:
6628 return pc;
6629 }
6630 -
6631 -/*
6632 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6633 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6634 - */
6635 -unsigned long arch_align_stack(unsigned long sp)
6636 -{
6637 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6638 - sp -= get_random_int() & ~PAGE_MASK;
6639 -
6640 - return sp & ALMASK;
6641 -}
6642 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6643 index 8ae1ebe..1bcbf47 100644
6644 --- a/arch/mips/kernel/ptrace.c
6645 +++ b/arch/mips/kernel/ptrace.c
6646 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6647 return arch;
6648 }
6649
6650 +#ifdef CONFIG_GRKERNSEC_SETXID
6651 +extern void gr_delayed_cred_worker(void);
6652 +#endif
6653 +
6654 /*
6655 * Notification of system call entry/exit
6656 * - triggered by current->work.syscall_trace
6657 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6658 /* do the secure computing check first */
6659 secure_computing_strict(regs->regs[2]);
6660
6661 +#ifdef CONFIG_GRKERNSEC_SETXID
6662 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6663 + gr_delayed_cred_worker();
6664 +#endif
6665 +
6666 if (!(current->ptrace & PT_PTRACED))
6667 goto out;
6668
6669 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6670 index c10aa84..9ec2e60 100644
6671 --- a/arch/mips/kernel/smtc-proc.c
6672 +++ b/arch/mips/kernel/smtc-proc.c
6673 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6674
6675 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6676
6677 -atomic_t smtc_fpu_recoveries;
6678 +atomic_unchecked_t smtc_fpu_recoveries;
6679
6680 static int smtc_proc_show(struct seq_file *m, void *v)
6681 {
6682 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6683 for(i = 0; i < NR_CPUS; i++)
6684 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6685 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6686 - atomic_read(&smtc_fpu_recoveries));
6687 + atomic_read_unchecked(&smtc_fpu_recoveries));
6688 return 0;
6689 }
6690
6691 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6692 smtc_cpu_stats[i].selfipis = 0;
6693 }
6694
6695 - atomic_set(&smtc_fpu_recoveries, 0);
6696 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6697
6698 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6699 }
6700 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6701 index dfc1b91..11a2c07 100644
6702 --- a/arch/mips/kernel/smtc.c
6703 +++ b/arch/mips/kernel/smtc.c
6704 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6705 }
6706 smtc_ipi_qdump();
6707 printk("%d Recoveries of \"stolen\" FPU\n",
6708 - atomic_read(&smtc_fpu_recoveries));
6709 + atomic_read_unchecked(&smtc_fpu_recoveries));
6710 }
6711
6712
6713 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6714 index 84536bf..79caa4d 100644
6715 --- a/arch/mips/kernel/sync-r4k.c
6716 +++ b/arch/mips/kernel/sync-r4k.c
6717 @@ -21,8 +21,8 @@
6718 #include <asm/mipsregs.h>
6719
6720 static atomic_t count_start_flag = ATOMIC_INIT(0);
6721 -static atomic_t count_count_start = ATOMIC_INIT(0);
6722 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6723 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6724 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6725 static atomic_t count_reference = ATOMIC_INIT(0);
6726
6727 #define COUNTON 100
6728 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6729
6730 for (i = 0; i < NR_LOOPS; i++) {
6731 /* slaves loop on '!= 2' */
6732 - while (atomic_read(&count_count_start) != 1)
6733 + while (atomic_read_unchecked(&count_count_start) != 1)
6734 mb();
6735 - atomic_set(&count_count_stop, 0);
6736 + atomic_set_unchecked(&count_count_stop, 0);
6737 smp_wmb();
6738
6739 /* this lets the slaves write their count register */
6740 - atomic_inc(&count_count_start);
6741 + atomic_inc_unchecked(&count_count_start);
6742
6743 /*
6744 * Everyone initialises count in the last loop:
6745 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6746 /*
6747 * Wait for all slaves to leave the synchronization point:
6748 */
6749 - while (atomic_read(&count_count_stop) != 1)
6750 + while (atomic_read_unchecked(&count_count_stop) != 1)
6751 mb();
6752 - atomic_set(&count_count_start, 0);
6753 + atomic_set_unchecked(&count_count_start, 0);
6754 smp_wmb();
6755 - atomic_inc(&count_count_stop);
6756 + atomic_inc_unchecked(&count_count_stop);
6757 }
6758 /* Arrange for an interrupt in a short while */
6759 write_c0_compare(read_c0_count() + COUNTON);
6760 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6761 initcount = atomic_read(&count_reference);
6762
6763 for (i = 0; i < NR_LOOPS; i++) {
6764 - atomic_inc(&count_count_start);
6765 - while (atomic_read(&count_count_start) != 2)
6766 + atomic_inc_unchecked(&count_count_start);
6767 + while (atomic_read_unchecked(&count_count_start) != 2)
6768 mb();
6769
6770 /*
6771 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6772 if (i == NR_LOOPS-1)
6773 write_c0_count(initcount);
6774
6775 - atomic_inc(&count_count_stop);
6776 - while (atomic_read(&count_count_stop) != 2)
6777 + atomic_inc_unchecked(&count_count_stop);
6778 + while (atomic_read_unchecked(&count_count_stop) != 2)
6779 mb();
6780 }
6781 /* Arrange for an interrupt in a short while */
6782 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6783 index 524841f..3eef41e 100644
6784 --- a/arch/mips/kernel/traps.c
6785 +++ b/arch/mips/kernel/traps.c
6786 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6787 siginfo_t info;
6788
6789 prev_state = exception_enter();
6790 - die_if_kernel("Integer overflow", regs);
6791 + if (unlikely(!user_mode(regs))) {
6792 +
6793 +#ifdef CONFIG_PAX_REFCOUNT
6794 + if (fixup_exception(regs)) {
6795 + pax_report_refcount_overflow(regs);
6796 + exception_exit(prev_state);
6797 + return;
6798 + }
6799 +#endif
6800 +
6801 + die("Integer overflow", regs);
6802 + }
6803
6804 info.si_code = FPE_INTOVF;
6805 info.si_signo = SIGFPE;
6806 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6807 index becc42b..9e43d4b 100644
6808 --- a/arch/mips/mm/fault.c
6809 +++ b/arch/mips/mm/fault.c
6810 @@ -28,6 +28,23 @@
6811 #include <asm/highmem.h> /* For VMALLOC_END */
6812 #include <linux/kdebug.h>
6813
6814 +#ifdef CONFIG_PAX_PAGEEXEC
6815 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6816 +{
6817 + unsigned long i;
6818 +
6819 + printk(KERN_ERR "PAX: bytes at PC: ");
6820 + for (i = 0; i < 5; i++) {
6821 + unsigned int c;
6822 + if (get_user(c, (unsigned int *)pc+i))
6823 + printk(KERN_CONT "???????? ");
6824 + else
6825 + printk(KERN_CONT "%08x ", c);
6826 + }
6827 + printk("\n");
6828 +}
6829 +#endif
6830 +
6831 /*
6832 * This routine handles page faults. It determines the address,
6833 * and the problem, and then passes it off to one of the appropriate
6834 @@ -199,6 +216,14 @@ bad_area:
6835 bad_area_nosemaphore:
6836 /* User mode accesses just cause a SIGSEGV */
6837 if (user_mode(regs)) {
6838 +
6839 +#ifdef CONFIG_PAX_PAGEEXEC
6840 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6841 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6842 + do_group_exit(SIGKILL);
6843 + }
6844 +#endif
6845 +
6846 tsk->thread.cp0_badvaddr = address;
6847 tsk->thread.error_code = write;
6848 #if 0
6849 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6850 index f1baadd..8537544 100644
6851 --- a/arch/mips/mm/mmap.c
6852 +++ b/arch/mips/mm/mmap.c
6853 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6854 struct vm_area_struct *vma;
6855 unsigned long addr = addr0;
6856 int do_color_align;
6857 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6858 struct vm_unmapped_area_info info;
6859
6860 if (unlikely(len > TASK_SIZE))
6861 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6862 do_color_align = 1;
6863
6864 /* requesting a specific address */
6865 +
6866 +#ifdef CONFIG_PAX_RANDMMAP
6867 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6868 +#endif
6869 +
6870 if (addr) {
6871 if (do_color_align)
6872 addr = COLOUR_ALIGN(addr, pgoff);
6873 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6874 addr = PAGE_ALIGN(addr);
6875
6876 vma = find_vma(mm, addr);
6877 - if (TASK_SIZE - len >= addr &&
6878 - (!vma || addr + len <= vma->vm_start))
6879 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6880 return addr;
6881 }
6882
6883 info.length = len;
6884 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6885 info.align_offset = pgoff << PAGE_SHIFT;
6886 + info.threadstack_offset = offset;
6887
6888 if (dir == DOWN) {
6889 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6890 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6891 {
6892 unsigned long random_factor = 0UL;
6893
6894 +#ifdef CONFIG_PAX_RANDMMAP
6895 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6896 +#endif
6897 +
6898 if (current->flags & PF_RANDOMIZE) {
6899 random_factor = get_random_int();
6900 random_factor = random_factor << PAGE_SHIFT;
6901 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6902
6903 if (mmap_is_legacy()) {
6904 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6905 +
6906 +#ifdef CONFIG_PAX_RANDMMAP
6907 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6908 + mm->mmap_base += mm->delta_mmap;
6909 +#endif
6910 +
6911 mm->get_unmapped_area = arch_get_unmapped_area;
6912 } else {
6913 mm->mmap_base = mmap_base(random_factor);
6914 +
6915 +#ifdef CONFIG_PAX_RANDMMAP
6916 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6917 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6918 +#endif
6919 +
6920 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6921 }
6922 }
6923
6924 -static inline unsigned long brk_rnd(void)
6925 -{
6926 - unsigned long rnd = get_random_int();
6927 -
6928 - rnd = rnd << PAGE_SHIFT;
6929 - /* 8MB for 32bit, 256MB for 64bit */
6930 - if (TASK_IS_32BIT_ADDR)
6931 - rnd = rnd & 0x7ffffful;
6932 - else
6933 - rnd = rnd & 0xffffffful;
6934 -
6935 - return rnd;
6936 -}
6937 -
6938 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6939 -{
6940 - unsigned long base = mm->brk;
6941 - unsigned long ret;
6942 -
6943 - ret = PAGE_ALIGN(base + brk_rnd());
6944 -
6945 - if (ret < mm->brk)
6946 - return mm->brk;
6947 -
6948 - return ret;
6949 -}
6950 -
6951 int __virt_addr_valid(const volatile void *kaddr)
6952 {
6953 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6954 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6955 index a2358b4..7cead4f 100644
6956 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6957 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6958 @@ -187,9 +187,9 @@ void
6959 cont_nmi_dump(void)
6960 {
6961 #ifndef REAL_NMI_SIGNAL
6962 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6963 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6964
6965 - atomic_inc(&nmied_cpus);
6966 + atomic_inc_unchecked(&nmied_cpus);
6967 #endif
6968 /*
6969 * Only allow 1 cpu to proceed
6970 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6971 udelay(10000);
6972 }
6973 #else
6974 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6975 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6976 #endif
6977
6978 /*
6979 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6980 index 967d144..db12197 100644
6981 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6982 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6983 @@ -11,12 +11,14 @@
6984 #ifndef _ASM_PROC_CACHE_H
6985 #define _ASM_PROC_CACHE_H
6986
6987 +#include <linux/const.h>
6988 +
6989 /* L1 cache */
6990
6991 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6992 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6993 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6994 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6995 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6996 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6997
6998 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6999 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7000 index bcb5df2..84fabd2 100644
7001 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7002 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7003 @@ -16,13 +16,15 @@
7004 #ifndef _ASM_PROC_CACHE_H
7005 #define _ASM_PROC_CACHE_H
7006
7007 +#include <linux/const.h>
7008 +
7009 /*
7010 * L1 cache
7011 */
7012 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7013 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
7014 -#define L1_CACHE_BYTES 32 /* bytes per entry */
7015 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
7016 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7017 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7018
7019 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7020 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7021 index 4ce7a01..449202a 100644
7022 --- a/arch/openrisc/include/asm/cache.h
7023 +++ b/arch/openrisc/include/asm/cache.h
7024 @@ -19,11 +19,13 @@
7025 #ifndef __ASM_OPENRISC_CACHE_H
7026 #define __ASM_OPENRISC_CACHE_H
7027
7028 +#include <linux/const.h>
7029 +
7030 /* FIXME: How can we replace these with values from the CPU...
7031 * they shouldn't be hard-coded!
7032 */
7033
7034 -#define L1_CACHE_BYTES 16
7035 #define L1_CACHE_SHIFT 4
7036 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7037
7038 #endif /* __ASM_OPENRISC_CACHE_H */
7039 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7040 index 472886c..00e7df9 100644
7041 --- a/arch/parisc/include/asm/atomic.h
7042 +++ b/arch/parisc/include/asm/atomic.h
7043 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7044 return dec;
7045 }
7046
7047 +#define atomic64_read_unchecked(v) atomic64_read(v)
7048 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7049 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7050 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7051 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7052 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7053 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7054 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7055 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7056 +
7057 #endif /* !CONFIG_64BIT */
7058
7059
7060 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7061 index 47f11c7..3420df2 100644
7062 --- a/arch/parisc/include/asm/cache.h
7063 +++ b/arch/parisc/include/asm/cache.h
7064 @@ -5,6 +5,7 @@
7065 #ifndef __ARCH_PARISC_CACHE_H
7066 #define __ARCH_PARISC_CACHE_H
7067
7068 +#include <linux/const.h>
7069
7070 /*
7071 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7072 @@ -15,13 +16,13 @@
7073 * just ruin performance.
7074 */
7075 #ifdef CONFIG_PA20
7076 -#define L1_CACHE_BYTES 64
7077 #define L1_CACHE_SHIFT 6
7078 #else
7079 -#define L1_CACHE_BYTES 32
7080 #define L1_CACHE_SHIFT 5
7081 #endif
7082
7083 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7084 +
7085 #ifndef __ASSEMBLY__
7086
7087 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7088 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7089 index ad2b503..bdf1651 100644
7090 --- a/arch/parisc/include/asm/elf.h
7091 +++ b/arch/parisc/include/asm/elf.h
7092 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7093
7094 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7095
7096 +#ifdef CONFIG_PAX_ASLR
7097 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7098 +
7099 +#define PAX_DELTA_MMAP_LEN 16
7100 +#define PAX_DELTA_STACK_LEN 16
7101 +#endif
7102 +
7103 /* This yields a mask that user programs can use to figure out what
7104 instruction set this CPU supports. This could be done in user space,
7105 but it's not easy, and we've already done it here. */
7106 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7107 index fc987a1..6e068ef 100644
7108 --- a/arch/parisc/include/asm/pgalloc.h
7109 +++ b/arch/parisc/include/asm/pgalloc.h
7110 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7111 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7112 }
7113
7114 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7115 +{
7116 + pgd_populate(mm, pgd, pmd);
7117 +}
7118 +
7119 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7120 {
7121 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7122 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7123 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7124 #define pmd_free(mm, x) do { } while (0)
7125 #define pgd_populate(mm, pmd, pte) BUG()
7126 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7127
7128 #endif
7129
7130 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7131 index 34899b5..02dd060 100644
7132 --- a/arch/parisc/include/asm/pgtable.h
7133 +++ b/arch/parisc/include/asm/pgtable.h
7134 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7135 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7136 #define PAGE_COPY PAGE_EXECREAD
7137 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7138 +
7139 +#ifdef CONFIG_PAX_PAGEEXEC
7140 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7141 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7142 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7143 +#else
7144 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7145 +# define PAGE_COPY_NOEXEC PAGE_COPY
7146 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7147 +#endif
7148 +
7149 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7150 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7151 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7152 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7153 index e0a8235..ce2f1e1 100644
7154 --- a/arch/parisc/include/asm/uaccess.h
7155 +++ b/arch/parisc/include/asm/uaccess.h
7156 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7157 const void __user *from,
7158 unsigned long n)
7159 {
7160 - int sz = __compiletime_object_size(to);
7161 + size_t sz = __compiletime_object_size(to);
7162 int ret = -EFAULT;
7163
7164 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7165 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7166 ret = __copy_from_user(to, from, n);
7167 else
7168 copy_from_user_overflow();
7169 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7170 index 2a625fb..9908930 100644
7171 --- a/arch/parisc/kernel/module.c
7172 +++ b/arch/parisc/kernel/module.c
7173 @@ -98,16 +98,38 @@
7174
7175 /* three functions to determine where in the module core
7176 * or init pieces the location is */
7177 +static inline int in_init_rx(struct module *me, void *loc)
7178 +{
7179 + return (loc >= me->module_init_rx &&
7180 + loc < (me->module_init_rx + me->init_size_rx));
7181 +}
7182 +
7183 +static inline int in_init_rw(struct module *me, void *loc)
7184 +{
7185 + return (loc >= me->module_init_rw &&
7186 + loc < (me->module_init_rw + me->init_size_rw));
7187 +}
7188 +
7189 static inline int in_init(struct module *me, void *loc)
7190 {
7191 - return (loc >= me->module_init &&
7192 - loc <= (me->module_init + me->init_size));
7193 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7194 +}
7195 +
7196 +static inline int in_core_rx(struct module *me, void *loc)
7197 +{
7198 + return (loc >= me->module_core_rx &&
7199 + loc < (me->module_core_rx + me->core_size_rx));
7200 +}
7201 +
7202 +static inline int in_core_rw(struct module *me, void *loc)
7203 +{
7204 + return (loc >= me->module_core_rw &&
7205 + loc < (me->module_core_rw + me->core_size_rw));
7206 }
7207
7208 static inline int in_core(struct module *me, void *loc)
7209 {
7210 - return (loc >= me->module_core &&
7211 - loc <= (me->module_core + me->core_size));
7212 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7213 }
7214
7215 static inline int in_local(struct module *me, void *loc)
7216 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7217 }
7218
7219 /* align things a bit */
7220 - me->core_size = ALIGN(me->core_size, 16);
7221 - me->arch.got_offset = me->core_size;
7222 - me->core_size += gots * sizeof(struct got_entry);
7223 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7224 + me->arch.got_offset = me->core_size_rw;
7225 + me->core_size_rw += gots * sizeof(struct got_entry);
7226
7227 - me->core_size = ALIGN(me->core_size, 16);
7228 - me->arch.fdesc_offset = me->core_size;
7229 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7230 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7231 + me->arch.fdesc_offset = me->core_size_rw;
7232 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7233
7234 me->arch.got_max = gots;
7235 me->arch.fdesc_max = fdescs;
7236 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7237
7238 BUG_ON(value == 0);
7239
7240 - got = me->module_core + me->arch.got_offset;
7241 + got = me->module_core_rw + me->arch.got_offset;
7242 for (i = 0; got[i].addr; i++)
7243 if (got[i].addr == value)
7244 goto out;
7245 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7246 #ifdef CONFIG_64BIT
7247 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7248 {
7249 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7250 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7251
7252 if (!value) {
7253 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7254 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7255
7256 /* Create new one */
7257 fdesc->addr = value;
7258 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7259 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7260 return (Elf_Addr)fdesc;
7261 }
7262 #endif /* CONFIG_64BIT */
7263 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7264
7265 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7266 end = table + sechdrs[me->arch.unwind_section].sh_size;
7267 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7268 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7269
7270 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7271 me->arch.unwind_section, table, end, gp);
7272 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7273 index 0d3a9d4..44975d0 100644
7274 --- a/arch/parisc/kernel/sys_parisc.c
7275 +++ b/arch/parisc/kernel/sys_parisc.c
7276 @@ -33,9 +33,11 @@
7277 #include <linux/utsname.h>
7278 #include <linux/personality.h>
7279
7280 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7281 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7282 + unsigned long flags)
7283 {
7284 struct vm_unmapped_area_info info;
7285 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7286
7287 info.flags = 0;
7288 info.length = len;
7289 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7290 info.high_limit = TASK_SIZE;
7291 info.align_mask = 0;
7292 info.align_offset = 0;
7293 + info.threadstack_offset = offset;
7294 return vm_unmapped_area(&info);
7295 }
7296
7297 @@ -69,15 +72,17 @@ static unsigned long shared_align_offset(struct file *filp, unsigned long pgoff)
7298 }
7299
7300 static unsigned long get_shared_area(struct file *filp, unsigned long addr,
7301 - unsigned long len, unsigned long pgoff)
7302 + unsigned long len, unsigned long pgoff, unsigned long flags)
7303 {
7304 struct vm_unmapped_area_info info;
7305 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7306
7307 info.flags = 0;
7308 info.length = len;
7309 info.low_limit = PAGE_ALIGN(addr);
7310 info.high_limit = TASK_SIZE;
7311 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7312 + info.threadstack_offset = offset;
7313 info.align_offset = shared_align_offset(filp, pgoff);
7314 return vm_unmapped_area(&info);
7315 }
7316 @@ -93,13 +98,20 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7317 return -EINVAL;
7318 return addr;
7319 }
7320 - if (!addr)
7321 + if (!addr) {
7322 addr = TASK_UNMAPPED_BASE;
7323
7324 +#ifdef CONFIG_PAX_RANDMMAP
7325 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7326 + addr += current->mm->delta_mmap;
7327 +#endif
7328 +
7329 + }
7330 +
7331 if (filp || (flags & MAP_SHARED))
7332 - addr = get_shared_area(filp, addr, len, pgoff);
7333 + addr = get_shared_area(filp, addr, len, pgoff, flags);
7334 else
7335 - addr = get_unshared_area(addr, len);
7336 + addr = get_unshared_area(addr, len, flags);
7337
7338 return addr;
7339 }
7340 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7341 index 1cd1d0c..44ec918 100644
7342 --- a/arch/parisc/kernel/traps.c
7343 +++ b/arch/parisc/kernel/traps.c
7344 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7345
7346 down_read(&current->mm->mmap_sem);
7347 vma = find_vma(current->mm,regs->iaoq[0]);
7348 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7349 - && (vma->vm_flags & VM_EXEC)) {
7350 -
7351 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7352 fault_address = regs->iaoq[0];
7353 fault_space = regs->iasq[0];
7354
7355 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7356 index 0293588..3b229aa 100644
7357 --- a/arch/parisc/mm/fault.c
7358 +++ b/arch/parisc/mm/fault.c
7359 @@ -15,6 +15,7 @@
7360 #include <linux/sched.h>
7361 #include <linux/interrupt.h>
7362 #include <linux/module.h>
7363 +#include <linux/unistd.h>
7364
7365 #include <asm/uaccess.h>
7366 #include <asm/traps.h>
7367 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7368 static unsigned long
7369 parisc_acctyp(unsigned long code, unsigned int inst)
7370 {
7371 - if (code == 6 || code == 16)
7372 + if (code == 6 || code == 7 || code == 16)
7373 return VM_EXEC;
7374
7375 switch (inst & 0xf0000000) {
7376 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7377 }
7378 #endif
7379
7380 +#ifdef CONFIG_PAX_PAGEEXEC
7381 +/*
7382 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7383 + *
7384 + * returns 1 when task should be killed
7385 + * 2 when rt_sigreturn trampoline was detected
7386 + * 3 when unpatched PLT trampoline was detected
7387 + */
7388 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7389 +{
7390 +
7391 +#ifdef CONFIG_PAX_EMUPLT
7392 + int err;
7393 +
7394 + do { /* PaX: unpatched PLT emulation */
7395 + unsigned int bl, depwi;
7396 +
7397 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7398 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7399 +
7400 + if (err)
7401 + break;
7402 +
7403 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7404 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7405 +
7406 + err = get_user(ldw, (unsigned int *)addr);
7407 + err |= get_user(bv, (unsigned int *)(addr+4));
7408 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7409 +
7410 + if (err)
7411 + break;
7412 +
7413 + if (ldw == 0x0E801096U &&
7414 + bv == 0xEAC0C000U &&
7415 + ldw2 == 0x0E881095U)
7416 + {
7417 + unsigned int resolver, map;
7418 +
7419 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7420 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7421 + if (err)
7422 + break;
7423 +
7424 + regs->gr[20] = instruction_pointer(regs)+8;
7425 + regs->gr[21] = map;
7426 + regs->gr[22] = resolver;
7427 + regs->iaoq[0] = resolver | 3UL;
7428 + regs->iaoq[1] = regs->iaoq[0] + 4;
7429 + return 3;
7430 + }
7431 + }
7432 + } while (0);
7433 +#endif
7434 +
7435 +#ifdef CONFIG_PAX_EMUTRAMP
7436 +
7437 +#ifndef CONFIG_PAX_EMUSIGRT
7438 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7439 + return 1;
7440 +#endif
7441 +
7442 + do { /* PaX: rt_sigreturn emulation */
7443 + unsigned int ldi1, ldi2, bel, nop;
7444 +
7445 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7446 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7447 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7448 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7449 +
7450 + if (err)
7451 + break;
7452 +
7453 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7454 + ldi2 == 0x3414015AU &&
7455 + bel == 0xE4008200U &&
7456 + nop == 0x08000240U)
7457 + {
7458 + regs->gr[25] = (ldi1 & 2) >> 1;
7459 + regs->gr[20] = __NR_rt_sigreturn;
7460 + regs->gr[31] = regs->iaoq[1] + 16;
7461 + regs->sr[0] = regs->iasq[1];
7462 + regs->iaoq[0] = 0x100UL;
7463 + regs->iaoq[1] = regs->iaoq[0] + 4;
7464 + regs->iasq[0] = regs->sr[2];
7465 + regs->iasq[1] = regs->sr[2];
7466 + return 2;
7467 + }
7468 + } while (0);
7469 +#endif
7470 +
7471 + return 1;
7472 +}
7473 +
7474 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7475 +{
7476 + unsigned long i;
7477 +
7478 + printk(KERN_ERR "PAX: bytes at PC: ");
7479 + for (i = 0; i < 5; i++) {
7480 + unsigned int c;
7481 + if (get_user(c, (unsigned int *)pc+i))
7482 + printk(KERN_CONT "???????? ");
7483 + else
7484 + printk(KERN_CONT "%08x ", c);
7485 + }
7486 + printk("\n");
7487 +}
7488 +#endif
7489 +
7490 int fixup_exception(struct pt_regs *regs)
7491 {
7492 const struct exception_table_entry *fix;
7493 @@ -204,8 +315,33 @@ retry:
7494
7495 good_area:
7496
7497 - if ((vma->vm_flags & acc_type) != acc_type)
7498 + if ((vma->vm_flags & acc_type) != acc_type) {
7499 +
7500 +#ifdef CONFIG_PAX_PAGEEXEC
7501 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7502 + (address & ~3UL) == instruction_pointer(regs))
7503 + {
7504 + up_read(&mm->mmap_sem);
7505 + switch (pax_handle_fetch_fault(regs)) {
7506 +
7507 +#ifdef CONFIG_PAX_EMUPLT
7508 + case 3:
7509 + return;
7510 +#endif
7511 +
7512 +#ifdef CONFIG_PAX_EMUTRAMP
7513 + case 2:
7514 + return;
7515 +#endif
7516 +
7517 + }
7518 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7519 + do_group_exit(SIGKILL);
7520 + }
7521 +#endif
7522 +
7523 goto bad_area;
7524 + }
7525
7526 /*
7527 * If for any reason at all we couldn't handle the fault, make
7528 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7529 index 38f3b7e..7e485c0 100644
7530 --- a/arch/powerpc/Kconfig
7531 +++ b/arch/powerpc/Kconfig
7532 @@ -378,6 +378,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
7533 config KEXEC
7534 bool "kexec system call"
7535 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7536 + depends on !GRKERNSEC_KMEM
7537 help
7538 kexec is a system call that implements the ability to shutdown your
7539 current kernel, and to start another kernel. It is like a reboot
7540 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7541 index e3b1d41..8e81edf 100644
7542 --- a/arch/powerpc/include/asm/atomic.h
7543 +++ b/arch/powerpc/include/asm/atomic.h
7544 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7545 return t1;
7546 }
7547
7548 +#define atomic64_read_unchecked(v) atomic64_read(v)
7549 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7550 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7551 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7552 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7553 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7554 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7555 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7556 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7557 +
7558 #endif /* __powerpc64__ */
7559
7560 #endif /* __KERNEL__ */
7561 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7562 index 9e495c9..b6878e5 100644
7563 --- a/arch/powerpc/include/asm/cache.h
7564 +++ b/arch/powerpc/include/asm/cache.h
7565 @@ -3,6 +3,7 @@
7566
7567 #ifdef __KERNEL__
7568
7569 +#include <linux/const.h>
7570
7571 /* bytes per L1 cache line */
7572 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7573 @@ -22,7 +23,7 @@
7574 #define L1_CACHE_SHIFT 7
7575 #endif
7576
7577 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7578 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7579
7580 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7581
7582 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7583 index cc0655a..13eac2e 100644
7584 --- a/arch/powerpc/include/asm/elf.h
7585 +++ b/arch/powerpc/include/asm/elf.h
7586 @@ -28,8 +28,19 @@
7587 the loader. We need to make sure that it is out of the way of the program
7588 that it will "exec", and that there is sufficient room for the brk. */
7589
7590 -extern unsigned long randomize_et_dyn(unsigned long base);
7591 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7592 +#define ELF_ET_DYN_BASE (0x20000000)
7593 +
7594 +#ifdef CONFIG_PAX_ASLR
7595 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7596 +
7597 +#ifdef __powerpc64__
7598 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7599 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7600 +#else
7601 +#define PAX_DELTA_MMAP_LEN 15
7602 +#define PAX_DELTA_STACK_LEN 15
7603 +#endif
7604 +#endif
7605
7606 /*
7607 * Our registers are always unsigned longs, whether we're a 32 bit
7608 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7609 (0x7ff >> (PAGE_SHIFT - 12)) : \
7610 (0x3ffff >> (PAGE_SHIFT - 12)))
7611
7612 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7613 -#define arch_randomize_brk arch_randomize_brk
7614 -
7615 -
7616 #ifdef CONFIG_SPU_BASE
7617 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7618 #define NT_SPU 1
7619 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7620 index 8196e9c..d83a9f3 100644
7621 --- a/arch/powerpc/include/asm/exec.h
7622 +++ b/arch/powerpc/include/asm/exec.h
7623 @@ -4,6 +4,6 @@
7624 #ifndef _ASM_POWERPC_EXEC_H
7625 #define _ASM_POWERPC_EXEC_H
7626
7627 -extern unsigned long arch_align_stack(unsigned long sp);
7628 +#define arch_align_stack(x) ((x) & ~0xfUL)
7629
7630 #endif /* _ASM_POWERPC_EXEC_H */
7631 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7632 index 5acabbd..7ea14fa 100644
7633 --- a/arch/powerpc/include/asm/kmap_types.h
7634 +++ b/arch/powerpc/include/asm/kmap_types.h
7635 @@ -10,7 +10,7 @@
7636 * 2 of the License, or (at your option) any later version.
7637 */
7638
7639 -#define KM_TYPE_NR 16
7640 +#define KM_TYPE_NR 17
7641
7642 #endif /* __KERNEL__ */
7643 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7644 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7645 index 8565c25..2865190 100644
7646 --- a/arch/powerpc/include/asm/mman.h
7647 +++ b/arch/powerpc/include/asm/mman.h
7648 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7649 }
7650 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7651
7652 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7653 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7654 {
7655 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7656 }
7657 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7658 index b9f4262..dcf04f7 100644
7659 --- a/arch/powerpc/include/asm/page.h
7660 +++ b/arch/powerpc/include/asm/page.h
7661 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7662 * and needs to be executable. This means the whole heap ends
7663 * up being executable.
7664 */
7665 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7666 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7667 +#define VM_DATA_DEFAULT_FLAGS32 \
7668 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7669 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7670
7671 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7672 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7673 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7674 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7675 #endif
7676
7677 +#define ktla_ktva(addr) (addr)
7678 +#define ktva_ktla(addr) (addr)
7679 +
7680 #ifndef CONFIG_PPC_BOOK3S_64
7681 /*
7682 * Use the top bit of the higher-level page table entries to indicate whether
7683 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7684 index 88693ce..ac6f9ab 100644
7685 --- a/arch/powerpc/include/asm/page_64.h
7686 +++ b/arch/powerpc/include/asm/page_64.h
7687 @@ -153,15 +153,18 @@ do { \
7688 * stack by default, so in the absence of a PT_GNU_STACK program header
7689 * we turn execute permission off.
7690 */
7691 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7692 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7693 +#define VM_STACK_DEFAULT_FLAGS32 \
7694 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7695 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7696
7697 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7698 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7699
7700 +#ifndef CONFIG_PAX_PAGEEXEC
7701 #define VM_STACK_DEFAULT_FLAGS \
7702 (is_32bit_task() ? \
7703 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7704 +#endif
7705
7706 #include <asm-generic/getorder.h>
7707
7708 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7709 index 256d6f8..b0166a7 100644
7710 --- a/arch/powerpc/include/asm/pgalloc-64.h
7711 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7712 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7713 #ifndef CONFIG_PPC_64K_PAGES
7714
7715 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7716 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7717
7718 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7719 {
7720 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7721 pud_set(pud, (unsigned long)pmd);
7722 }
7723
7724 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7725 +{
7726 + pud_populate(mm, pud, pmd);
7727 +}
7728 +
7729 #define pmd_populate(mm, pmd, pte_page) \
7730 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7731 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7732 @@ -169,6 +175,7 @@ extern void __tlb_remove_table(void *_table);
7733 #endif
7734
7735 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7736 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7737
7738 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7739 pte_t *pte)
7740 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7741 index 7d6eacf..14c0240 100644
7742 --- a/arch/powerpc/include/asm/pgtable.h
7743 +++ b/arch/powerpc/include/asm/pgtable.h
7744 @@ -2,6 +2,7 @@
7745 #define _ASM_POWERPC_PGTABLE_H
7746 #ifdef __KERNEL__
7747
7748 +#include <linux/const.h>
7749 #ifndef __ASSEMBLY__
7750 #include <asm/processor.h> /* For TASK_SIZE */
7751 #include <asm/mmu.h>
7752 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7753 index 4aad413..85d86bf 100644
7754 --- a/arch/powerpc/include/asm/pte-hash32.h
7755 +++ b/arch/powerpc/include/asm/pte-hash32.h
7756 @@ -21,6 +21,7 @@
7757 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7758 #define _PAGE_USER 0x004 /* usermode access allowed */
7759 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7760 +#define _PAGE_EXEC _PAGE_GUARDED
7761 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7762 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7763 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7764 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7765 index 10d1ef0..8f83abc 100644
7766 --- a/arch/powerpc/include/asm/reg.h
7767 +++ b/arch/powerpc/include/asm/reg.h
7768 @@ -234,6 +234,7 @@
7769 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7770 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7771 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7772 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7773 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7774 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7775 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7776 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7777 index 98da78e..dc68271 100644
7778 --- a/arch/powerpc/include/asm/smp.h
7779 +++ b/arch/powerpc/include/asm/smp.h
7780 @@ -50,7 +50,7 @@ struct smp_ops_t {
7781 int (*cpu_disable)(void);
7782 void (*cpu_die)(unsigned int nr);
7783 int (*cpu_bootable)(unsigned int nr);
7784 -};
7785 +} __no_const;
7786
7787 extern void smp_send_debugger_break(void);
7788 extern void start_secondary_resume(void);
7789 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7790 index ba7b197..d292e26 100644
7791 --- a/arch/powerpc/include/asm/thread_info.h
7792 +++ b/arch/powerpc/include/asm/thread_info.h
7793 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7794 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7795 TIF_NEED_RESCHED */
7796 #define TIF_32BIT 4 /* 32 bit binary */
7797 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7798 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7799 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7800 #define TIF_SINGLESTEP 8 /* singlestepping active */
7801 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7802 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7803 for stack store? */
7804 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7805 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7806 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7807 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7808
7809 /* as above, but as bit values */
7810 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7811 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7812 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7813 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7814 #define _TIF_NOHZ (1<<TIF_NOHZ)
7815 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7816 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7817 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7818 - _TIF_NOHZ)
7819 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7820
7821 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7822 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7823 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7824 index 9485b43..4718d50 100644
7825 --- a/arch/powerpc/include/asm/uaccess.h
7826 +++ b/arch/powerpc/include/asm/uaccess.h
7827 @@ -318,52 +318,6 @@ do { \
7828 extern unsigned long __copy_tofrom_user(void __user *to,
7829 const void __user *from, unsigned long size);
7830
7831 -#ifndef __powerpc64__
7832 -
7833 -static inline unsigned long copy_from_user(void *to,
7834 - const void __user *from, unsigned long n)
7835 -{
7836 - unsigned long over;
7837 -
7838 - if (access_ok(VERIFY_READ, from, n))
7839 - return __copy_tofrom_user((__force void __user *)to, from, n);
7840 - if ((unsigned long)from < TASK_SIZE) {
7841 - over = (unsigned long)from + n - TASK_SIZE;
7842 - return __copy_tofrom_user((__force void __user *)to, from,
7843 - n - over) + over;
7844 - }
7845 - return n;
7846 -}
7847 -
7848 -static inline unsigned long copy_to_user(void __user *to,
7849 - const void *from, unsigned long n)
7850 -{
7851 - unsigned long over;
7852 -
7853 - if (access_ok(VERIFY_WRITE, to, n))
7854 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7855 - if ((unsigned long)to < TASK_SIZE) {
7856 - over = (unsigned long)to + n - TASK_SIZE;
7857 - return __copy_tofrom_user(to, (__force void __user *)from,
7858 - n - over) + over;
7859 - }
7860 - return n;
7861 -}
7862 -
7863 -#else /* __powerpc64__ */
7864 -
7865 -#define __copy_in_user(to, from, size) \
7866 - __copy_tofrom_user((to), (from), (size))
7867 -
7868 -extern unsigned long copy_from_user(void *to, const void __user *from,
7869 - unsigned long n);
7870 -extern unsigned long copy_to_user(void __user *to, const void *from,
7871 - unsigned long n);
7872 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7873 - unsigned long n);
7874 -
7875 -#endif /* __powerpc64__ */
7876 -
7877 static inline unsigned long __copy_from_user_inatomic(void *to,
7878 const void __user *from, unsigned long n)
7879 {
7880 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7881 if (ret == 0)
7882 return 0;
7883 }
7884 +
7885 + if (!__builtin_constant_p(n))
7886 + check_object_size(to, n, false);
7887 +
7888 return __copy_tofrom_user((__force void __user *)to, from, n);
7889 }
7890
7891 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7892 if (ret == 0)
7893 return 0;
7894 }
7895 +
7896 + if (!__builtin_constant_p(n))
7897 + check_object_size(from, n, true);
7898 +
7899 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7900 }
7901
7902 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7903 return __copy_to_user_inatomic(to, from, size);
7904 }
7905
7906 +#ifndef __powerpc64__
7907 +
7908 +static inline unsigned long __must_check copy_from_user(void *to,
7909 + const void __user *from, unsigned long n)
7910 +{
7911 + unsigned long over;
7912 +
7913 + if ((long)n < 0)
7914 + return n;
7915 +
7916 + if (access_ok(VERIFY_READ, from, n)) {
7917 + if (!__builtin_constant_p(n))
7918 + check_object_size(to, n, false);
7919 + return __copy_tofrom_user((__force void __user *)to, from, n);
7920 + }
7921 + if ((unsigned long)from < TASK_SIZE) {
7922 + over = (unsigned long)from + n - TASK_SIZE;
7923 + if (!__builtin_constant_p(n - over))
7924 + check_object_size(to, n - over, false);
7925 + return __copy_tofrom_user((__force void __user *)to, from,
7926 + n - over) + over;
7927 + }
7928 + return n;
7929 +}
7930 +
7931 +static inline unsigned long __must_check copy_to_user(void __user *to,
7932 + const void *from, unsigned long n)
7933 +{
7934 + unsigned long over;
7935 +
7936 + if ((long)n < 0)
7937 + return n;
7938 +
7939 + if (access_ok(VERIFY_WRITE, to, n)) {
7940 + if (!__builtin_constant_p(n))
7941 + check_object_size(from, n, true);
7942 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7943 + }
7944 + if ((unsigned long)to < TASK_SIZE) {
7945 + over = (unsigned long)to + n - TASK_SIZE;
7946 + if (!__builtin_constant_p(n))
7947 + check_object_size(from, n - over, true);
7948 + return __copy_tofrom_user(to, (__force void __user *)from,
7949 + n - over) + over;
7950 + }
7951 + return n;
7952 +}
7953 +
7954 +#else /* __powerpc64__ */
7955 +
7956 +#define __copy_in_user(to, from, size) \
7957 + __copy_tofrom_user((to), (from), (size))
7958 +
7959 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7960 +{
7961 + if ((long)n < 0 || n > INT_MAX)
7962 + return n;
7963 +
7964 + if (!__builtin_constant_p(n))
7965 + check_object_size(to, n, false);
7966 +
7967 + if (likely(access_ok(VERIFY_READ, from, n)))
7968 + n = __copy_from_user(to, from, n);
7969 + else
7970 + memset(to, 0, n);
7971 + return n;
7972 +}
7973 +
7974 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7975 +{
7976 + if ((long)n < 0 || n > INT_MAX)
7977 + return n;
7978 +
7979 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7980 + if (!__builtin_constant_p(n))
7981 + check_object_size(from, n, true);
7982 + n = __copy_to_user(to, from, n);
7983 + }
7984 + return n;
7985 +}
7986 +
7987 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7988 + unsigned long n);
7989 +
7990 +#endif /* __powerpc64__ */
7991 +
7992 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7993
7994 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7995 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7996 index 2d06704..1616f1b 100644
7997 --- a/arch/powerpc/kernel/exceptions-64e.S
7998 +++ b/arch/powerpc/kernel/exceptions-64e.S
7999 @@ -757,6 +757,7 @@ storage_fault_common:
8000 std r14,_DAR(r1)
8001 std r15,_DSISR(r1)
8002 addi r3,r1,STACK_FRAME_OVERHEAD
8003 + bl .save_nvgprs
8004 mr r4,r14
8005 mr r5,r15
8006 ld r14,PACA_EXGEN+EX_R14(r13)
8007 @@ -765,8 +766,7 @@ storage_fault_common:
8008 cmpdi r3,0
8009 bne- 1f
8010 b .ret_from_except_lite
8011 -1: bl .save_nvgprs
8012 - mr r5,r3
8013 +1: mr r5,r3
8014 addi r3,r1,STACK_FRAME_OVERHEAD
8015 ld r4,_DAR(r1)
8016 bl .bad_page_fault
8017 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
8018 index 3a9ed6a..b534681 100644
8019 --- a/arch/powerpc/kernel/exceptions-64s.S
8020 +++ b/arch/powerpc/kernel/exceptions-64s.S
8021 @@ -1364,10 +1364,10 @@ handle_page_fault:
8022 11: ld r4,_DAR(r1)
8023 ld r5,_DSISR(r1)
8024 addi r3,r1,STACK_FRAME_OVERHEAD
8025 + bl .save_nvgprs
8026 bl .do_page_fault
8027 cmpdi r3,0
8028 beq+ 12f
8029 - bl .save_nvgprs
8030 mr r5,r3
8031 addi r3,r1,STACK_FRAME_OVERHEAD
8032 lwz r4,_DAR(r1)
8033 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8034 index 2e3200c..7118986 100644
8035 --- a/arch/powerpc/kernel/module_32.c
8036 +++ b/arch/powerpc/kernel/module_32.c
8037 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8038 me->arch.core_plt_section = i;
8039 }
8040 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8041 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8042 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8043 return -ENOEXEC;
8044 }
8045
8046 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8047
8048 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8049 /* Init, or core PLT? */
8050 - if (location >= mod->module_core
8051 - && location < mod->module_core + mod->core_size)
8052 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8053 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8054 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8055 - else
8056 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8057 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8058 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8059 + else {
8060 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8061 + return ~0UL;
8062 + }
8063
8064 /* Find this entry, or if that fails, the next avail. entry */
8065 while (entry->jump[0]) {
8066 @@ -300,7 +305,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
8067 }
8068 #ifdef CONFIG_DYNAMIC_FTRACE
8069 module->arch.tramp =
8070 - do_plt_call(module->module_core,
8071 + do_plt_call(module->module_core_rx,
8072 (unsigned long)ftrace_caller,
8073 sechdrs, module);
8074 #endif
8075 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8076 index 96d2fdf..f6d10c8 100644
8077 --- a/arch/powerpc/kernel/process.c
8078 +++ b/arch/powerpc/kernel/process.c
8079 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
8080 * Lookup NIP late so we have the best change of getting the
8081 * above info out without failing
8082 */
8083 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8084 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8085 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8086 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8087 #endif
8088 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8089 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8090 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8091 newsp = stack[0];
8092 ip = stack[STACK_FRAME_LR_SAVE];
8093 if (!firstframe || ip != lr) {
8094 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8095 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8096 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8097 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8098 - printk(" (%pS)",
8099 + printk(" (%pA)",
8100 (void *)current->ret_stack[curr_frame].ret);
8101 curr_frame--;
8102 }
8103 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8104 struct pt_regs *regs = (struct pt_regs *)
8105 (sp + STACK_FRAME_OVERHEAD);
8106 lr = regs->link;
8107 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8108 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8109 regs->trap, (void *)regs->nip, (void *)lr);
8110 firstframe = 1;
8111 }
8112 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8113 mtspr(SPRN_CTRLT, ctrl);
8114 }
8115 #endif /* CONFIG_PPC64 */
8116 -
8117 -unsigned long arch_align_stack(unsigned long sp)
8118 -{
8119 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8120 - sp -= get_random_int() & ~PAGE_MASK;
8121 - return sp & ~0xf;
8122 -}
8123 -
8124 -static inline unsigned long brk_rnd(void)
8125 -{
8126 - unsigned long rnd = 0;
8127 -
8128 - /* 8MB for 32bit, 1GB for 64bit */
8129 - if (is_32bit_task())
8130 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8131 - else
8132 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8133 -
8134 - return rnd << PAGE_SHIFT;
8135 -}
8136 -
8137 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8138 -{
8139 - unsigned long base = mm->brk;
8140 - unsigned long ret;
8141 -
8142 -#ifdef CONFIG_PPC_STD_MMU_64
8143 - /*
8144 - * If we are using 1TB segments and we are allowed to randomise
8145 - * the heap, we can put it above 1TB so it is backed by a 1TB
8146 - * segment. Otherwise the heap will be in the bottom 1TB
8147 - * which always uses 256MB segments and this may result in a
8148 - * performance penalty.
8149 - */
8150 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8151 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8152 -#endif
8153 -
8154 - ret = PAGE_ALIGN(base + brk_rnd());
8155 -
8156 - if (ret < mm->brk)
8157 - return mm->brk;
8158 -
8159 - return ret;
8160 -}
8161 -
8162 -unsigned long randomize_et_dyn(unsigned long base)
8163 -{
8164 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8165 -
8166 - if (ret < base)
8167 - return base;
8168 -
8169 - return ret;
8170 -}
8171 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8172 index 9a0d24c..e7fbedf 100644
8173 --- a/arch/powerpc/kernel/ptrace.c
8174 +++ b/arch/powerpc/kernel/ptrace.c
8175 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8176 return ret;
8177 }
8178
8179 +#ifdef CONFIG_GRKERNSEC_SETXID
8180 +extern void gr_delayed_cred_worker(void);
8181 +#endif
8182 +
8183 /*
8184 * We must return the syscall number to actually look up in the table.
8185 * This can be -1L to skip running any syscall at all.
8186 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8187
8188 secure_computing_strict(regs->gpr[0]);
8189
8190 +#ifdef CONFIG_GRKERNSEC_SETXID
8191 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8192 + gr_delayed_cred_worker();
8193 +#endif
8194 +
8195 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8196 tracehook_report_syscall_entry(regs))
8197 /*
8198 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8199 {
8200 int step;
8201
8202 +#ifdef CONFIG_GRKERNSEC_SETXID
8203 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8204 + gr_delayed_cred_worker();
8205 +#endif
8206 +
8207 audit_syscall_exit(regs);
8208
8209 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8210 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8211 index fea2dba..a779f6b 100644
8212 --- a/arch/powerpc/kernel/signal_32.c
8213 +++ b/arch/powerpc/kernel/signal_32.c
8214 @@ -1002,7 +1002,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8215 /* Save user registers on the stack */
8216 frame = &rt_sf->uc.uc_mcontext;
8217 addr = frame;
8218 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8219 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8220 sigret = 0;
8221 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8222 } else {
8223 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8224 index 1e7ba88..17afb1b 100644
8225 --- a/arch/powerpc/kernel/signal_64.c
8226 +++ b/arch/powerpc/kernel/signal_64.c
8227 @@ -763,7 +763,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8228 #endif
8229
8230 /* Set up to return from userspace. */
8231 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8232 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8233 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8234 } else {
8235 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8236 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8237 index f783c93..619baf1 100644
8238 --- a/arch/powerpc/kernel/traps.c
8239 +++ b/arch/powerpc/kernel/traps.c
8240 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8241 return flags;
8242 }
8243
8244 +extern void gr_handle_kernel_exploit(void);
8245 +
8246 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8247 int signr)
8248 {
8249 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8250 panic("Fatal exception in interrupt");
8251 if (panic_on_oops)
8252 panic("Fatal exception");
8253 +
8254 + gr_handle_kernel_exploit();
8255 +
8256 do_exit(signr);
8257 }
8258
8259 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8260 index 1d9c926..25f4741 100644
8261 --- a/arch/powerpc/kernel/vdso.c
8262 +++ b/arch/powerpc/kernel/vdso.c
8263 @@ -34,6 +34,7 @@
8264 #include <asm/firmware.h>
8265 #include <asm/vdso.h>
8266 #include <asm/vdso_datapage.h>
8267 +#include <asm/mman.h>
8268
8269 #include "setup.h"
8270
8271 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8272 vdso_base = VDSO32_MBASE;
8273 #endif
8274
8275 - current->mm->context.vdso_base = 0;
8276 + current->mm->context.vdso_base = ~0UL;
8277
8278 /* vDSO has a problem and was disabled, just don't "enable" it for the
8279 * process
8280 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8281 vdso_base = get_unmapped_area(NULL, vdso_base,
8282 (vdso_pages << PAGE_SHIFT) +
8283 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8284 - 0, 0);
8285 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8286 if (IS_ERR_VALUE(vdso_base)) {
8287 rc = vdso_base;
8288 goto fail_mmapsem;
8289 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8290 index 5eea6f3..5d10396 100644
8291 --- a/arch/powerpc/lib/usercopy_64.c
8292 +++ b/arch/powerpc/lib/usercopy_64.c
8293 @@ -9,22 +9,6 @@
8294 #include <linux/module.h>
8295 #include <asm/uaccess.h>
8296
8297 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8298 -{
8299 - if (likely(access_ok(VERIFY_READ, from, n)))
8300 - n = __copy_from_user(to, from, n);
8301 - else
8302 - memset(to, 0, n);
8303 - return n;
8304 -}
8305 -
8306 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8307 -{
8308 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8309 - n = __copy_to_user(to, from, n);
8310 - return n;
8311 -}
8312 -
8313 unsigned long copy_in_user(void __user *to, const void __user *from,
8314 unsigned long n)
8315 {
8316 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8317 return n;
8318 }
8319
8320 -EXPORT_SYMBOL(copy_from_user);
8321 -EXPORT_SYMBOL(copy_to_user);
8322 EXPORT_SYMBOL(copy_in_user);
8323
8324 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8325 index 51ab9e7..7d3c78b 100644
8326 --- a/arch/powerpc/mm/fault.c
8327 +++ b/arch/powerpc/mm/fault.c
8328 @@ -33,6 +33,10 @@
8329 #include <linux/magic.h>
8330 #include <linux/ratelimit.h>
8331 #include <linux/context_tracking.h>
8332 +#include <linux/slab.h>
8333 +#include <linux/pagemap.h>
8334 +#include <linux/compiler.h>
8335 +#include <linux/unistd.h>
8336
8337 #include <asm/firmware.h>
8338 #include <asm/page.h>
8339 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8340 }
8341 #endif
8342
8343 +#ifdef CONFIG_PAX_PAGEEXEC
8344 +/*
8345 + * PaX: decide what to do with offenders (regs->nip = fault address)
8346 + *
8347 + * returns 1 when task should be killed
8348 + */
8349 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8350 +{
8351 + return 1;
8352 +}
8353 +
8354 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8355 +{
8356 + unsigned long i;
8357 +
8358 + printk(KERN_ERR "PAX: bytes at PC: ");
8359 + for (i = 0; i < 5; i++) {
8360 + unsigned int c;
8361 + if (get_user(c, (unsigned int __user *)pc+i))
8362 + printk(KERN_CONT "???????? ");
8363 + else
8364 + printk(KERN_CONT "%08x ", c);
8365 + }
8366 + printk("\n");
8367 +}
8368 +#endif
8369 +
8370 /*
8371 * Check whether the instruction at regs->nip is a store using
8372 * an update addressing form which will update r1.
8373 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8374 * indicate errors in DSISR but can validly be set in SRR1.
8375 */
8376 if (trap == 0x400)
8377 - error_code &= 0x48200000;
8378 + error_code &= 0x58200000;
8379 else
8380 is_write = error_code & DSISR_ISSTORE;
8381 #else
8382 @@ -378,7 +409,7 @@ good_area:
8383 * "undefined". Of those that can be set, this is the only
8384 * one which seems bad.
8385 */
8386 - if (error_code & 0x10000000)
8387 + if (error_code & DSISR_GUARDED)
8388 /* Guarded storage error. */
8389 goto bad_area;
8390 #endif /* CONFIG_8xx */
8391 @@ -393,7 +424,7 @@ good_area:
8392 * processors use the same I/D cache coherency mechanism
8393 * as embedded.
8394 */
8395 - if (error_code & DSISR_PROTFAULT)
8396 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8397 goto bad_area;
8398 #endif /* CONFIG_PPC_STD_MMU */
8399
8400 @@ -483,6 +514,23 @@ bad_area:
8401 bad_area_nosemaphore:
8402 /* User mode accesses cause a SIGSEGV */
8403 if (user_mode(regs)) {
8404 +
8405 +#ifdef CONFIG_PAX_PAGEEXEC
8406 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8407 +#ifdef CONFIG_PPC_STD_MMU
8408 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8409 +#else
8410 + if (is_exec && regs->nip == address) {
8411 +#endif
8412 + switch (pax_handle_fetch_fault(regs)) {
8413 + }
8414 +
8415 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8416 + do_group_exit(SIGKILL);
8417 + }
8418 + }
8419 +#endif
8420 +
8421 _exception(SIGSEGV, regs, code, address);
8422 goto bail;
8423 }
8424 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8425 index cb8bdbe..d770680 100644
8426 --- a/arch/powerpc/mm/mmap.c
8427 +++ b/arch/powerpc/mm/mmap.c
8428 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8429 {
8430 unsigned long rnd = 0;
8431
8432 +#ifdef CONFIG_PAX_RANDMMAP
8433 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8434 +#endif
8435 +
8436 if (current->flags & PF_RANDOMIZE) {
8437 /* 8MB for 32bit, 1GB for 64bit */
8438 if (is_32bit_task())
8439 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8440 */
8441 if (mmap_is_legacy()) {
8442 mm->mmap_base = TASK_UNMAPPED_BASE;
8443 +
8444 +#ifdef CONFIG_PAX_RANDMMAP
8445 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8446 + mm->mmap_base += mm->delta_mmap;
8447 +#endif
8448 +
8449 mm->get_unmapped_area = arch_get_unmapped_area;
8450 } else {
8451 mm->mmap_base = mmap_base();
8452 +
8453 +#ifdef CONFIG_PAX_RANDMMAP
8454 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8455 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8456 +#endif
8457 +
8458 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8459 }
8460 }
8461 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8462 index 7ce9cf3..a964087 100644
8463 --- a/arch/powerpc/mm/slice.c
8464 +++ b/arch/powerpc/mm/slice.c
8465 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8466 if ((mm->task_size - len) < addr)
8467 return 0;
8468 vma = find_vma(mm, addr);
8469 - return (!vma || (addr + len) <= vma->vm_start);
8470 + return check_heap_stack_gap(vma, addr, len, 0);
8471 }
8472
8473 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8474 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8475 info.align_offset = 0;
8476
8477 addr = TASK_UNMAPPED_BASE;
8478 +
8479 +#ifdef CONFIG_PAX_RANDMMAP
8480 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8481 + addr += mm->delta_mmap;
8482 +#endif
8483 +
8484 while (addr < TASK_SIZE) {
8485 info.low_limit = addr;
8486 if (!slice_scan_available(addr, available, 1, &addr))
8487 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8488 if (fixed && addr > (mm->task_size - len))
8489 return -EINVAL;
8490
8491 +#ifdef CONFIG_PAX_RANDMMAP
8492 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8493 + addr = 0;
8494 +#endif
8495 +
8496 /* If hint, make sure it matches our alignment restrictions */
8497 if (!fixed && addr) {
8498 addr = _ALIGN_UP(addr, 1ul << pshift);
8499 diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
8500 index 2345bdb..ebbb2f1 100644
8501 --- a/arch/powerpc/net/bpf_jit_comp.c
8502 +++ b/arch/powerpc/net/bpf_jit_comp.c
8503 @@ -209,10 +209,11 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
8504 }
8505 PPC_DIVWU(r_A, r_A, r_X);
8506 break;
8507 - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
8508 + case BPF_S_ALU_DIV_K: /* A /= K */
8509 + if (K == 1)
8510 + break;
8511 PPC_LI32(r_scratch1, K);
8512 - /* Top 32 bits of 64bit result -> A */
8513 - PPC_MULHWU(r_A, r_A, r_scratch1);
8514 + PPC_DIVWU(r_A, r_A, r_scratch1);
8515 break;
8516 case BPF_S_ALU_AND_X:
8517 ctx->seen |= SEEN_XREG;
8518 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8519 index 9098692..3d54cd1 100644
8520 --- a/arch/powerpc/platforms/cell/spufs/file.c
8521 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8522 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8523 return VM_FAULT_NOPAGE;
8524 }
8525
8526 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8527 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8528 unsigned long address,
8529 - void *buf, int len, int write)
8530 + void *buf, size_t len, int write)
8531 {
8532 struct spu_context *ctx = vma->vm_file->private_data;
8533 unsigned long offset = address - vma->vm_start;
8534 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8535 index c797832..ce575c8 100644
8536 --- a/arch/s390/include/asm/atomic.h
8537 +++ b/arch/s390/include/asm/atomic.h
8538 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8539 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8540 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8541
8542 +#define atomic64_read_unchecked(v) atomic64_read(v)
8543 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8544 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8545 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8546 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8547 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8548 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8549 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8550 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8551 +
8552 #define smp_mb__before_atomic_dec() smp_mb()
8553 #define smp_mb__after_atomic_dec() smp_mb()
8554 #define smp_mb__before_atomic_inc() smp_mb()
8555 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8556 index 4d7ccac..d03d0ad 100644
8557 --- a/arch/s390/include/asm/cache.h
8558 +++ b/arch/s390/include/asm/cache.h
8559 @@ -9,8 +9,10 @@
8560 #ifndef __ARCH_S390_CACHE_H
8561 #define __ARCH_S390_CACHE_H
8562
8563 -#define L1_CACHE_BYTES 256
8564 +#include <linux/const.h>
8565 +
8566 #define L1_CACHE_SHIFT 8
8567 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8568 #define NET_SKB_PAD 32
8569
8570 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8571 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8572 index 78f4f87..598ce39 100644
8573 --- a/arch/s390/include/asm/elf.h
8574 +++ b/arch/s390/include/asm/elf.h
8575 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8576 the loader. We need to make sure that it is out of the way of the program
8577 that it will "exec", and that there is sufficient room for the brk. */
8578
8579 -extern unsigned long randomize_et_dyn(unsigned long base);
8580 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8581 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8582 +
8583 +#ifdef CONFIG_PAX_ASLR
8584 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8585 +
8586 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8587 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8588 +#endif
8589
8590 /* This yields a mask that user programs can use to figure out what
8591 instruction set this CPU supports. */
8592 @@ -222,9 +228,6 @@ struct linux_binprm;
8593 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8594 int arch_setup_additional_pages(struct linux_binprm *, int);
8595
8596 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8597 -#define arch_randomize_brk arch_randomize_brk
8598 -
8599 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8600
8601 #endif
8602 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8603 index c4a93d6..4d2a9b4 100644
8604 --- a/arch/s390/include/asm/exec.h
8605 +++ b/arch/s390/include/asm/exec.h
8606 @@ -7,6 +7,6 @@
8607 #ifndef __ASM_EXEC_H
8608 #define __ASM_EXEC_H
8609
8610 -extern unsigned long arch_align_stack(unsigned long sp);
8611 +#define arch_align_stack(x) ((x) & ~0xfUL)
8612
8613 #endif /* __ASM_EXEC_H */
8614 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8615 index 9c33ed4..e40cbef 100644
8616 --- a/arch/s390/include/asm/uaccess.h
8617 +++ b/arch/s390/include/asm/uaccess.h
8618 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8619 copy_to_user(void __user *to, const void *from, unsigned long n)
8620 {
8621 might_fault();
8622 +
8623 + if ((long)n < 0)
8624 + return n;
8625 +
8626 return __copy_to_user(to, from, n);
8627 }
8628
8629 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8630 static inline unsigned long __must_check
8631 __copy_from_user(void *to, const void __user *from, unsigned long n)
8632 {
8633 + if ((long)n < 0)
8634 + return n;
8635 +
8636 if (__builtin_constant_p(n) && (n <= 256))
8637 return uaccess.copy_from_user_small(n, from, to);
8638 else
8639 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8640 static inline unsigned long __must_check
8641 copy_from_user(void *to, const void __user *from, unsigned long n)
8642 {
8643 - unsigned int sz = __compiletime_object_size(to);
8644 + size_t sz = __compiletime_object_size(to);
8645
8646 might_fault();
8647 - if (unlikely(sz != -1 && sz < n)) {
8648 +
8649 + if ((long)n < 0)
8650 + return n;
8651 +
8652 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8653 copy_from_user_overflow();
8654 return n;
8655 }
8656 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8657 index 7845e15..59c4353 100644
8658 --- a/arch/s390/kernel/module.c
8659 +++ b/arch/s390/kernel/module.c
8660 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8661
8662 /* Increase core size by size of got & plt and set start
8663 offsets for got and plt. */
8664 - me->core_size = ALIGN(me->core_size, 4);
8665 - me->arch.got_offset = me->core_size;
8666 - me->core_size += me->arch.got_size;
8667 - me->arch.plt_offset = me->core_size;
8668 - me->core_size += me->arch.plt_size;
8669 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8670 + me->arch.got_offset = me->core_size_rw;
8671 + me->core_size_rw += me->arch.got_size;
8672 + me->arch.plt_offset = me->core_size_rx;
8673 + me->core_size_rx += me->arch.plt_size;
8674 return 0;
8675 }
8676
8677 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8678 if (info->got_initialized == 0) {
8679 Elf_Addr *gotent;
8680
8681 - gotent = me->module_core + me->arch.got_offset +
8682 + gotent = me->module_core_rw + me->arch.got_offset +
8683 info->got_offset;
8684 *gotent = val;
8685 info->got_initialized = 1;
8686 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8687 rc = apply_rela_bits(loc, val, 0, 64, 0);
8688 else if (r_type == R_390_GOTENT ||
8689 r_type == R_390_GOTPLTENT) {
8690 - val += (Elf_Addr) me->module_core - loc;
8691 + val += (Elf_Addr) me->module_core_rw - loc;
8692 rc = apply_rela_bits(loc, val, 1, 32, 1);
8693 }
8694 break;
8695 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8696 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8697 if (info->plt_initialized == 0) {
8698 unsigned int *ip;
8699 - ip = me->module_core + me->arch.plt_offset +
8700 + ip = me->module_core_rx + me->arch.plt_offset +
8701 info->plt_offset;
8702 #ifndef CONFIG_64BIT
8703 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8704 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8705 val - loc + 0xffffUL < 0x1ffffeUL) ||
8706 (r_type == R_390_PLT32DBL &&
8707 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8708 - val = (Elf_Addr) me->module_core +
8709 + val = (Elf_Addr) me->module_core_rx +
8710 me->arch.plt_offset +
8711 info->plt_offset;
8712 val += rela->r_addend - loc;
8713 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8714 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8715 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8716 val = val + rela->r_addend -
8717 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8718 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8719 if (r_type == R_390_GOTOFF16)
8720 rc = apply_rela_bits(loc, val, 0, 16, 0);
8721 else if (r_type == R_390_GOTOFF32)
8722 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8723 break;
8724 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8725 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8726 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8727 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8728 rela->r_addend - loc;
8729 if (r_type == R_390_GOTPC)
8730 rc = apply_rela_bits(loc, val, 1, 32, 0);
8731 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8732 index c5dbb33..b41f4ee 100644
8733 --- a/arch/s390/kernel/process.c
8734 +++ b/arch/s390/kernel/process.c
8735 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8736 }
8737 return 0;
8738 }
8739 -
8740 -unsigned long arch_align_stack(unsigned long sp)
8741 -{
8742 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8743 - sp -= get_random_int() & ~PAGE_MASK;
8744 - return sp & ~0xf;
8745 -}
8746 -
8747 -static inline unsigned long brk_rnd(void)
8748 -{
8749 - /* 8MB for 32bit, 1GB for 64bit */
8750 - if (is_32bit_task())
8751 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8752 - else
8753 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8754 -}
8755 -
8756 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8757 -{
8758 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8759 -
8760 - if (ret < mm->brk)
8761 - return mm->brk;
8762 - return ret;
8763 -}
8764 -
8765 -unsigned long randomize_et_dyn(unsigned long base)
8766 -{
8767 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8768 -
8769 - if (!(current->flags & PF_RANDOMIZE))
8770 - return base;
8771 - if (ret < base)
8772 - return base;
8773 - return ret;
8774 -}
8775 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8776 index 4002329..99b67cb 100644
8777 --- a/arch/s390/mm/mmap.c
8778 +++ b/arch/s390/mm/mmap.c
8779 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8780 */
8781 if (mmap_is_legacy()) {
8782 mm->mmap_base = TASK_UNMAPPED_BASE;
8783 +
8784 +#ifdef CONFIG_PAX_RANDMMAP
8785 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8786 + mm->mmap_base += mm->delta_mmap;
8787 +#endif
8788 +
8789 mm->get_unmapped_area = arch_get_unmapped_area;
8790 } else {
8791 mm->mmap_base = mmap_base();
8792 +
8793 +#ifdef CONFIG_PAX_RANDMMAP
8794 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8795 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8796 +#endif
8797 +
8798 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8799 }
8800 }
8801 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8802 */
8803 if (mmap_is_legacy()) {
8804 mm->mmap_base = TASK_UNMAPPED_BASE;
8805 +
8806 +#ifdef CONFIG_PAX_RANDMMAP
8807 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8808 + mm->mmap_base += mm->delta_mmap;
8809 +#endif
8810 +
8811 mm->get_unmapped_area = s390_get_unmapped_area;
8812 } else {
8813 mm->mmap_base = mmap_base();
8814 +
8815 +#ifdef CONFIG_PAX_RANDMMAP
8816 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8817 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8818 +#endif
8819 +
8820 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8821 }
8822 }
8823 diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
8824 index a5df511..06f5acc 100644
8825 --- a/arch/s390/net/bpf_jit_comp.c
8826 +++ b/arch/s390/net/bpf_jit_comp.c
8827 @@ -371,11 +371,13 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
8828 /* dr %r4,%r12 */
8829 EMIT2(0x1d4c);
8830 break;
8831 - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K) */
8832 - /* m %r4,<d(K)>(%r13) */
8833 - EMIT4_DISP(0x5c40d000, EMIT_CONST(K));
8834 - /* lr %r5,%r4 */
8835 - EMIT2(0x1854);
8836 + case BPF_S_ALU_DIV_K: /* A /= K */
8837 + if (K == 1)
8838 + break;
8839 + /* lhi %r4,0 */
8840 + EMIT4(0xa7480000);
8841 + /* d %r4,<d(K)>(%r13) */
8842 + EMIT4_DISP(0x5d40d000, EMIT_CONST(K));
8843 break;
8844 case BPF_S_ALU_MOD_X: /* A %= X */
8845 jit->seen |= SEEN_XREG | SEEN_RET0;
8846 @@ -391,6 +393,11 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
8847 EMIT2(0x1854);
8848 break;
8849 case BPF_S_ALU_MOD_K: /* A %= K */
8850 + if (K == 1) {
8851 + /* lhi %r5,0 */
8852 + EMIT4(0xa7580000);
8853 + break;
8854 + }
8855 /* lhi %r4,0 */
8856 EMIT4(0xa7480000);
8857 /* d %r4,<d(K)>(%r13) */
8858 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8859 index ae3d59f..f65f075 100644
8860 --- a/arch/score/include/asm/cache.h
8861 +++ b/arch/score/include/asm/cache.h
8862 @@ -1,7 +1,9 @@
8863 #ifndef _ASM_SCORE_CACHE_H
8864 #define _ASM_SCORE_CACHE_H
8865
8866 +#include <linux/const.h>
8867 +
8868 #define L1_CACHE_SHIFT 4
8869 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8870 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8871
8872 #endif /* _ASM_SCORE_CACHE_H */
8873 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8874 index f9f3cd5..58ff438 100644
8875 --- a/arch/score/include/asm/exec.h
8876 +++ b/arch/score/include/asm/exec.h
8877 @@ -1,6 +1,6 @@
8878 #ifndef _ASM_SCORE_EXEC_H
8879 #define _ASM_SCORE_EXEC_H
8880
8881 -extern unsigned long arch_align_stack(unsigned long sp);
8882 +#define arch_align_stack(x) (x)
8883
8884 #endif /* _ASM_SCORE_EXEC_H */
8885 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8886 index a1519ad3..e8ac1ff 100644
8887 --- a/arch/score/kernel/process.c
8888 +++ b/arch/score/kernel/process.c
8889 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8890
8891 return task_pt_regs(task)->cp0_epc;
8892 }
8893 -
8894 -unsigned long arch_align_stack(unsigned long sp)
8895 -{
8896 - return sp;
8897 -}
8898 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8899 index ef9e555..331bd29 100644
8900 --- a/arch/sh/include/asm/cache.h
8901 +++ b/arch/sh/include/asm/cache.h
8902 @@ -9,10 +9,11 @@
8903 #define __ASM_SH_CACHE_H
8904 #ifdef __KERNEL__
8905
8906 +#include <linux/const.h>
8907 #include <linux/init.h>
8908 #include <cpu/cache.h>
8909
8910 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8911 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8912
8913 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8914
8915 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8916 index 6777177..cb5e44f 100644
8917 --- a/arch/sh/mm/mmap.c
8918 +++ b/arch/sh/mm/mmap.c
8919 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8920 struct mm_struct *mm = current->mm;
8921 struct vm_area_struct *vma;
8922 int do_colour_align;
8923 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8924 struct vm_unmapped_area_info info;
8925
8926 if (flags & MAP_FIXED) {
8927 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8928 if (filp || (flags & MAP_SHARED))
8929 do_colour_align = 1;
8930
8931 +#ifdef CONFIG_PAX_RANDMMAP
8932 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8933 +#endif
8934 +
8935 if (addr) {
8936 if (do_colour_align)
8937 addr = COLOUR_ALIGN(addr, pgoff);
8938 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8939 addr = PAGE_ALIGN(addr);
8940
8941 vma = find_vma(mm, addr);
8942 - if (TASK_SIZE - len >= addr &&
8943 - (!vma || addr + len <= vma->vm_start))
8944 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8945 return addr;
8946 }
8947
8948 info.flags = 0;
8949 info.length = len;
8950 - info.low_limit = TASK_UNMAPPED_BASE;
8951 + info.low_limit = mm->mmap_base;
8952 info.high_limit = TASK_SIZE;
8953 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8954 info.align_offset = pgoff << PAGE_SHIFT;
8955 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8956 struct mm_struct *mm = current->mm;
8957 unsigned long addr = addr0;
8958 int do_colour_align;
8959 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8960 struct vm_unmapped_area_info info;
8961
8962 if (flags & MAP_FIXED) {
8963 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8964 if (filp || (flags & MAP_SHARED))
8965 do_colour_align = 1;
8966
8967 +#ifdef CONFIG_PAX_RANDMMAP
8968 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8969 +#endif
8970 +
8971 /* requesting a specific address */
8972 if (addr) {
8973 if (do_colour_align)
8974 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8975 addr = PAGE_ALIGN(addr);
8976
8977 vma = find_vma(mm, addr);
8978 - if (TASK_SIZE - len >= addr &&
8979 - (!vma || addr + len <= vma->vm_start))
8980 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8981 return addr;
8982 }
8983
8984 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8985 VM_BUG_ON(addr != -ENOMEM);
8986 info.flags = 0;
8987 info.low_limit = TASK_UNMAPPED_BASE;
8988 +
8989 +#ifdef CONFIG_PAX_RANDMMAP
8990 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8991 + info.low_limit += mm->delta_mmap;
8992 +#endif
8993 +
8994 info.high_limit = TASK_SIZE;
8995 addr = vm_unmapped_area(&info);
8996 }
8997 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8998 index be56a24..443328f 100644
8999 --- a/arch/sparc/include/asm/atomic_64.h
9000 +++ b/arch/sparc/include/asm/atomic_64.h
9001 @@ -14,18 +14,40 @@
9002 #define ATOMIC64_INIT(i) { (i) }
9003
9004 #define atomic_read(v) (*(volatile int *)&(v)->counter)
9005 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
9006 +{
9007 + return v->counter;
9008 +}
9009 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
9010 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
9011 +{
9012 + return v->counter;
9013 +}
9014
9015 #define atomic_set(v, i) (((v)->counter) = i)
9016 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
9017 +{
9018 + v->counter = i;
9019 +}
9020 #define atomic64_set(v, i) (((v)->counter) = i)
9021 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
9022 +{
9023 + v->counter = i;
9024 +}
9025
9026 extern void atomic_add(int, atomic_t *);
9027 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
9028 extern void atomic64_add(long, atomic64_t *);
9029 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
9030 extern void atomic_sub(int, atomic_t *);
9031 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
9032 extern void atomic64_sub(long, atomic64_t *);
9033 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
9034
9035 extern int atomic_add_ret(int, atomic_t *);
9036 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
9037 extern long atomic64_add_ret(long, atomic64_t *);
9038 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
9039 extern int atomic_sub_ret(int, atomic_t *);
9040 extern long atomic64_sub_ret(long, atomic64_t *);
9041
9042 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9043 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
9044
9045 #define atomic_inc_return(v) atomic_add_ret(1, v)
9046 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
9047 +{
9048 + return atomic_add_ret_unchecked(1, v);
9049 +}
9050 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
9051 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
9052 +{
9053 + return atomic64_add_ret_unchecked(1, v);
9054 +}
9055
9056 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
9057 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
9058
9059 #define atomic_add_return(i, v) atomic_add_ret(i, v)
9060 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
9061 +{
9062 + return atomic_add_ret_unchecked(i, v);
9063 +}
9064 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
9065 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
9066 +{
9067 + return atomic64_add_ret_unchecked(i, v);
9068 +}
9069
9070 /*
9071 * atomic_inc_and_test - increment and test
9072 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9073 * other cases.
9074 */
9075 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
9076 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9077 +{
9078 + return atomic_inc_return_unchecked(v) == 0;
9079 +}
9080 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
9081
9082 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
9083 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9084 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
9085
9086 #define atomic_inc(v) atomic_add(1, v)
9087 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9088 +{
9089 + atomic_add_unchecked(1, v);
9090 +}
9091 #define atomic64_inc(v) atomic64_add(1, v)
9092 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9093 +{
9094 + atomic64_add_unchecked(1, v);
9095 +}
9096
9097 #define atomic_dec(v) atomic_sub(1, v)
9098 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9099 +{
9100 + atomic_sub_unchecked(1, v);
9101 +}
9102 #define atomic64_dec(v) atomic64_sub(1, v)
9103 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9104 +{
9105 + atomic64_sub_unchecked(1, v);
9106 +}
9107
9108 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9109 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9110
9111 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9112 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9113 +{
9114 + return cmpxchg(&v->counter, old, new);
9115 +}
9116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9118 +{
9119 + return xchg(&v->counter, new);
9120 +}
9121
9122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9123 {
9124 - int c, old;
9125 + int c, old, new;
9126 c = atomic_read(v);
9127 for (;;) {
9128 - if (unlikely(c == (u)))
9129 + if (unlikely(c == u))
9130 break;
9131 - old = atomic_cmpxchg((v), c, c + (a));
9132 +
9133 + asm volatile("addcc %2, %0, %0\n"
9134 +
9135 +#ifdef CONFIG_PAX_REFCOUNT
9136 + "tvs %%icc, 6\n"
9137 +#endif
9138 +
9139 + : "=r" (new)
9140 + : "0" (c), "ir" (a)
9141 + : "cc");
9142 +
9143 + old = atomic_cmpxchg(v, c, new);
9144 if (likely(old == c))
9145 break;
9146 c = old;
9147 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9148 #define atomic64_cmpxchg(v, o, n) \
9149 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9150 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9151 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9152 +{
9153 + return xchg(&v->counter, new);
9154 +}
9155
9156 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9157 {
9158 - long c, old;
9159 + long c, old, new;
9160 c = atomic64_read(v);
9161 for (;;) {
9162 - if (unlikely(c == (u)))
9163 + if (unlikely(c == u))
9164 break;
9165 - old = atomic64_cmpxchg((v), c, c + (a));
9166 +
9167 + asm volatile("addcc %2, %0, %0\n"
9168 +
9169 +#ifdef CONFIG_PAX_REFCOUNT
9170 + "tvs %%xcc, 6\n"
9171 +#endif
9172 +
9173 + : "=r" (new)
9174 + : "0" (c), "ir" (a)
9175 + : "cc");
9176 +
9177 + old = atomic64_cmpxchg(v, c, new);
9178 if (likely(old == c))
9179 break;
9180 c = old;
9181 }
9182 - return c != (u);
9183 + return c != u;
9184 }
9185
9186 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9187 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9188 index 5bb6991..5c2132e 100644
9189 --- a/arch/sparc/include/asm/cache.h
9190 +++ b/arch/sparc/include/asm/cache.h
9191 @@ -7,10 +7,12 @@
9192 #ifndef _SPARC_CACHE_H
9193 #define _SPARC_CACHE_H
9194
9195 +#include <linux/const.h>
9196 +
9197 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9198
9199 #define L1_CACHE_SHIFT 5
9200 -#define L1_CACHE_BYTES 32
9201 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9202
9203 #ifdef CONFIG_SPARC32
9204 #define SMP_CACHE_BYTES_SHIFT 5
9205 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9206 index a24e41f..47677ff 100644
9207 --- a/arch/sparc/include/asm/elf_32.h
9208 +++ b/arch/sparc/include/asm/elf_32.h
9209 @@ -114,6 +114,13 @@ typedef struct {
9210
9211 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9212
9213 +#ifdef CONFIG_PAX_ASLR
9214 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9215 +
9216 +#define PAX_DELTA_MMAP_LEN 16
9217 +#define PAX_DELTA_STACK_LEN 16
9218 +#endif
9219 +
9220 /* This yields a mask that user programs can use to figure out what
9221 instruction set this cpu supports. This can NOT be done in userspace
9222 on Sparc. */
9223 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9224 index 370ca1e..d4f4a98 100644
9225 --- a/arch/sparc/include/asm/elf_64.h
9226 +++ b/arch/sparc/include/asm/elf_64.h
9227 @@ -189,6 +189,13 @@ typedef struct {
9228 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9229 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9230
9231 +#ifdef CONFIG_PAX_ASLR
9232 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9233 +
9234 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9235 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9236 +#endif
9237 +
9238 extern unsigned long sparc64_elf_hwcap;
9239 #define ELF_HWCAP sparc64_elf_hwcap
9240
9241 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9242 index 9b1c36d..209298b 100644
9243 --- a/arch/sparc/include/asm/pgalloc_32.h
9244 +++ b/arch/sparc/include/asm/pgalloc_32.h
9245 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9246 }
9247
9248 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9249 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9250
9251 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9252 unsigned long address)
9253 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9254 index bcfe063..b333142 100644
9255 --- a/arch/sparc/include/asm/pgalloc_64.h
9256 +++ b/arch/sparc/include/asm/pgalloc_64.h
9257 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9258 }
9259
9260 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9261 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9262
9263 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9264 {
9265 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9266 index 502f632..da1917f 100644
9267 --- a/arch/sparc/include/asm/pgtable_32.h
9268 +++ b/arch/sparc/include/asm/pgtable_32.h
9269 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9270 #define PAGE_SHARED SRMMU_PAGE_SHARED
9271 #define PAGE_COPY SRMMU_PAGE_COPY
9272 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9273 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9274 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9275 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9276 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9277
9278 /* Top-level page directory - dummy used by init-mm.
9279 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9280
9281 /* xwr */
9282 #define __P000 PAGE_NONE
9283 -#define __P001 PAGE_READONLY
9284 -#define __P010 PAGE_COPY
9285 -#define __P011 PAGE_COPY
9286 +#define __P001 PAGE_READONLY_NOEXEC
9287 +#define __P010 PAGE_COPY_NOEXEC
9288 +#define __P011 PAGE_COPY_NOEXEC
9289 #define __P100 PAGE_READONLY
9290 #define __P101 PAGE_READONLY
9291 #define __P110 PAGE_COPY
9292 #define __P111 PAGE_COPY
9293
9294 #define __S000 PAGE_NONE
9295 -#define __S001 PAGE_READONLY
9296 -#define __S010 PAGE_SHARED
9297 -#define __S011 PAGE_SHARED
9298 +#define __S001 PAGE_READONLY_NOEXEC
9299 +#define __S010 PAGE_SHARED_NOEXEC
9300 +#define __S011 PAGE_SHARED_NOEXEC
9301 #define __S100 PAGE_READONLY
9302 #define __S101 PAGE_READONLY
9303 #define __S110 PAGE_SHARED
9304 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9305 index 79da178..c2eede8 100644
9306 --- a/arch/sparc/include/asm/pgtsrmmu.h
9307 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9308 @@ -115,6 +115,11 @@
9309 SRMMU_EXEC | SRMMU_REF)
9310 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9311 SRMMU_EXEC | SRMMU_REF)
9312 +
9313 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9314 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9315 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9316 +
9317 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9318 SRMMU_DIRTY | SRMMU_REF)
9319
9320 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9321 index 9689176..63c18ea 100644
9322 --- a/arch/sparc/include/asm/spinlock_64.h
9323 +++ b/arch/sparc/include/asm/spinlock_64.h
9324 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9325
9326 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9327
9328 -static void inline arch_read_lock(arch_rwlock_t *lock)
9329 +static inline void arch_read_lock(arch_rwlock_t *lock)
9330 {
9331 unsigned long tmp1, tmp2;
9332
9333 __asm__ __volatile__ (
9334 "1: ldsw [%2], %0\n"
9335 " brlz,pn %0, 2f\n"
9336 -"4: add %0, 1, %1\n"
9337 +"4: addcc %0, 1, %1\n"
9338 +
9339 +#ifdef CONFIG_PAX_REFCOUNT
9340 +" tvs %%icc, 6\n"
9341 +#endif
9342 +
9343 " cas [%2], %0, %1\n"
9344 " cmp %0, %1\n"
9345 " bne,pn %%icc, 1b\n"
9346 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9347 " .previous"
9348 : "=&r" (tmp1), "=&r" (tmp2)
9349 : "r" (lock)
9350 - : "memory");
9351 + : "memory", "cc");
9352 }
9353
9354 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9355 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9356 {
9357 int tmp1, tmp2;
9358
9359 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9360 "1: ldsw [%2], %0\n"
9361 " brlz,a,pn %0, 2f\n"
9362 " mov 0, %0\n"
9363 -" add %0, 1, %1\n"
9364 +" addcc %0, 1, %1\n"
9365 +
9366 +#ifdef CONFIG_PAX_REFCOUNT
9367 +" tvs %%icc, 6\n"
9368 +#endif
9369 +
9370 " cas [%2], %0, %1\n"
9371 " cmp %0, %1\n"
9372 " bne,pn %%icc, 1b\n"
9373 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9374 return tmp1;
9375 }
9376
9377 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9378 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9379 {
9380 unsigned long tmp1, tmp2;
9381
9382 __asm__ __volatile__(
9383 "1: lduw [%2], %0\n"
9384 -" sub %0, 1, %1\n"
9385 +" subcc %0, 1, %1\n"
9386 +
9387 +#ifdef CONFIG_PAX_REFCOUNT
9388 +" tvs %%icc, 6\n"
9389 +#endif
9390 +
9391 " cas [%2], %0, %1\n"
9392 " cmp %0, %1\n"
9393 " bne,pn %%xcc, 1b\n"
9394 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9395 : "memory");
9396 }
9397
9398 -static void inline arch_write_lock(arch_rwlock_t *lock)
9399 +static inline void arch_write_lock(arch_rwlock_t *lock)
9400 {
9401 unsigned long mask, tmp1, tmp2;
9402
9403 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9404 : "memory");
9405 }
9406
9407 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9408 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9409 {
9410 __asm__ __volatile__(
9411 " stw %%g0, [%0]"
9412 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9413 : "memory");
9414 }
9415
9416 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9417 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9418 {
9419 unsigned long mask, tmp1, tmp2, result;
9420
9421 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9422 index dd38075..e7cac83 100644
9423 --- a/arch/sparc/include/asm/thread_info_32.h
9424 +++ b/arch/sparc/include/asm/thread_info_32.h
9425 @@ -49,6 +49,8 @@ struct thread_info {
9426 unsigned long w_saved;
9427
9428 struct restart_block restart_block;
9429 +
9430 + unsigned long lowest_stack;
9431 };
9432
9433 /*
9434 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9435 index d5e5042..9bfee76 100644
9436 --- a/arch/sparc/include/asm/thread_info_64.h
9437 +++ b/arch/sparc/include/asm/thread_info_64.h
9438 @@ -63,6 +63,8 @@ struct thread_info {
9439 struct pt_regs *kern_una_regs;
9440 unsigned int kern_una_insn;
9441
9442 + unsigned long lowest_stack;
9443 +
9444 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9445 };
9446
9447 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9448 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9449 /* flag bit 6 is available */
9450 #define TIF_32BIT 7 /* 32-bit binary */
9451 -/* flag bit 8 is available */
9452 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9453 #define TIF_SECCOMP 9 /* secure computing */
9454 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9455 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9456 +
9457 /* NOTE: Thread flags >= 12 should be ones we have no interest
9458 * in using in assembly, else we can't use the mask as
9459 * an immediate value in instructions such as andcc.
9460 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9461 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9462 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9463 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9464 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9465
9466 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9467 _TIF_DO_NOTIFY_RESUME_MASK | \
9468 _TIF_NEED_RESCHED)
9469 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9470
9471 +#define _TIF_WORK_SYSCALL \
9472 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9473 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9474 +
9475 +
9476 /*
9477 * Thread-synchronous status.
9478 *
9479 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9480 index 0167d26..767bb0c 100644
9481 --- a/arch/sparc/include/asm/uaccess.h
9482 +++ b/arch/sparc/include/asm/uaccess.h
9483 @@ -1,5 +1,6 @@
9484 #ifndef ___ASM_SPARC_UACCESS_H
9485 #define ___ASM_SPARC_UACCESS_H
9486 +
9487 #if defined(__sparc__) && defined(__arch64__)
9488 #include <asm/uaccess_64.h>
9489 #else
9490 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9491 index 53a28dd..50c38c3 100644
9492 --- a/arch/sparc/include/asm/uaccess_32.h
9493 +++ b/arch/sparc/include/asm/uaccess_32.h
9494 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9495
9496 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9497 {
9498 - if (n && __access_ok((unsigned long) to, n))
9499 + if ((long)n < 0)
9500 + return n;
9501 +
9502 + if (n && __access_ok((unsigned long) to, n)) {
9503 + if (!__builtin_constant_p(n))
9504 + check_object_size(from, n, true);
9505 return __copy_user(to, (__force void __user *) from, n);
9506 - else
9507 + } else
9508 return n;
9509 }
9510
9511 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9512 {
9513 + if ((long)n < 0)
9514 + return n;
9515 +
9516 + if (!__builtin_constant_p(n))
9517 + check_object_size(from, n, true);
9518 +
9519 return __copy_user(to, (__force void __user *) from, n);
9520 }
9521
9522 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9523 {
9524 - if (n && __access_ok((unsigned long) from, n))
9525 + if ((long)n < 0)
9526 + return n;
9527 +
9528 + if (n && __access_ok((unsigned long) from, n)) {
9529 + if (!__builtin_constant_p(n))
9530 + check_object_size(to, n, false);
9531 return __copy_user((__force void __user *) to, from, n);
9532 - else
9533 + } else
9534 return n;
9535 }
9536
9537 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9538 {
9539 + if ((long)n < 0)
9540 + return n;
9541 +
9542 return __copy_user((__force void __user *) to, from, n);
9543 }
9544
9545 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9546 index e562d3c..191f176 100644
9547 --- a/arch/sparc/include/asm/uaccess_64.h
9548 +++ b/arch/sparc/include/asm/uaccess_64.h
9549 @@ -10,6 +10,7 @@
9550 #include <linux/compiler.h>
9551 #include <linux/string.h>
9552 #include <linux/thread_info.h>
9553 +#include <linux/kernel.h>
9554 #include <asm/asi.h>
9555 #include <asm/spitfire.h>
9556 #include <asm-generic/uaccess-unaligned.h>
9557 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9558 static inline unsigned long __must_check
9559 copy_from_user(void *to, const void __user *from, unsigned long size)
9560 {
9561 - unsigned long ret = ___copy_from_user(to, from, size);
9562 + unsigned long ret;
9563
9564 + if ((long)size < 0 || size > INT_MAX)
9565 + return size;
9566 +
9567 + if (!__builtin_constant_p(size))
9568 + check_object_size(to, size, false);
9569 +
9570 + ret = ___copy_from_user(to, from, size);
9571 if (unlikely(ret))
9572 ret = copy_from_user_fixup(to, from, size);
9573
9574 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9575 static inline unsigned long __must_check
9576 copy_to_user(void __user *to, const void *from, unsigned long size)
9577 {
9578 - unsigned long ret = ___copy_to_user(to, from, size);
9579 + unsigned long ret;
9580
9581 + if ((long)size < 0 || size > INT_MAX)
9582 + return size;
9583 +
9584 + if (!__builtin_constant_p(size))
9585 + check_object_size(from, size, true);
9586 +
9587 + ret = ___copy_to_user(to, from, size);
9588 if (unlikely(ret))
9589 ret = copy_to_user_fixup(to, from, size);
9590 return ret;
9591 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9592 index d15cc17..d0ae796 100644
9593 --- a/arch/sparc/kernel/Makefile
9594 +++ b/arch/sparc/kernel/Makefile
9595 @@ -4,7 +4,7 @@
9596 #
9597
9598 asflags-y := -ansi
9599 -ccflags-y := -Werror
9600 +#ccflags-y := -Werror
9601
9602 extra-y := head_$(BITS).o
9603
9604 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9605 index fdd819d..5af08c8 100644
9606 --- a/arch/sparc/kernel/process_32.c
9607 +++ b/arch/sparc/kernel/process_32.c
9608 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9609
9610 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9611 r->psr, r->pc, r->npc, r->y, print_tainted());
9612 - printk("PC: <%pS>\n", (void *) r->pc);
9613 + printk("PC: <%pA>\n", (void *) r->pc);
9614 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9615 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9616 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9617 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9618 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9619 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9620 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9621 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9622
9623 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9624 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9625 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9626 rw = (struct reg_window32 *) fp;
9627 pc = rw->ins[7];
9628 printk("[%08lx : ", pc);
9629 - printk("%pS ] ", (void *) pc);
9630 + printk("%pA ] ", (void *) pc);
9631 fp = rw->ins[6];
9632 } while (++count < 16);
9633 printk("\n");
9634 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9635 index baebab2..9cd13b1 100644
9636 --- a/arch/sparc/kernel/process_64.c
9637 +++ b/arch/sparc/kernel/process_64.c
9638 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9639 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9640 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9641 if (regs->tstate & TSTATE_PRIV)
9642 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9643 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9644 }
9645
9646 void show_regs(struct pt_regs *regs)
9647 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9648
9649 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9650 regs->tpc, regs->tnpc, regs->y, print_tainted());
9651 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9652 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9653 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9654 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9655 regs->u_regs[3]);
9656 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9657 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9658 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9659 regs->u_regs[15]);
9660 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9661 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9662 show_regwindow(regs);
9663 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9664 }
9665 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9666 ((tp && tp->task) ? tp->task->pid : -1));
9667
9668 if (gp->tstate & TSTATE_PRIV) {
9669 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9670 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9671 (void *) gp->tpc,
9672 (void *) gp->o7,
9673 (void *) gp->i7,
9674 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9675 index 79cc0d1..ec62734 100644
9676 --- a/arch/sparc/kernel/prom_common.c
9677 +++ b/arch/sparc/kernel/prom_common.c
9678 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9679
9680 unsigned int prom_early_allocated __initdata;
9681
9682 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9683 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9684 .nextprop = prom_common_nextprop,
9685 .getproplen = prom_getproplen,
9686 .getproperty = prom_getproperty,
9687 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9688 index 773c1f2..a8bdd87 100644
9689 --- a/arch/sparc/kernel/ptrace_64.c
9690 +++ b/arch/sparc/kernel/ptrace_64.c
9691 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9692 return ret;
9693 }
9694
9695 +#ifdef CONFIG_GRKERNSEC_SETXID
9696 +extern void gr_delayed_cred_worker(void);
9697 +#endif
9698 +
9699 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9700 {
9701 int ret = 0;
9702 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9703 /* do the secure computing check first */
9704 secure_computing_strict(regs->u_regs[UREG_G1]);
9705
9706 +#ifdef CONFIG_GRKERNSEC_SETXID
9707 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9708 + gr_delayed_cred_worker();
9709 +#endif
9710 +
9711 if (test_thread_flag(TIF_SYSCALL_TRACE))
9712 ret = tracehook_report_syscall_entry(regs);
9713
9714 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9715
9716 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9717 {
9718 +#ifdef CONFIG_GRKERNSEC_SETXID
9719 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9720 + gr_delayed_cred_worker();
9721 +#endif
9722 +
9723 audit_syscall_exit(regs);
9724
9725 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9726 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9727 index e142545..fd29654 100644
9728 --- a/arch/sparc/kernel/smp_64.c
9729 +++ b/arch/sparc/kernel/smp_64.c
9730 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9731 extern unsigned long xcall_flush_dcache_page_spitfire;
9732
9733 #ifdef CONFIG_DEBUG_DCFLUSH
9734 -extern atomic_t dcpage_flushes;
9735 -extern atomic_t dcpage_flushes_xcall;
9736 +extern atomic_unchecked_t dcpage_flushes;
9737 +extern atomic_unchecked_t dcpage_flushes_xcall;
9738 #endif
9739
9740 static inline void __local_flush_dcache_page(struct page *page)
9741 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9742 return;
9743
9744 #ifdef CONFIG_DEBUG_DCFLUSH
9745 - atomic_inc(&dcpage_flushes);
9746 + atomic_inc_unchecked(&dcpage_flushes);
9747 #endif
9748
9749 this_cpu = get_cpu();
9750 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9751 xcall_deliver(data0, __pa(pg_addr),
9752 (u64) pg_addr, cpumask_of(cpu));
9753 #ifdef CONFIG_DEBUG_DCFLUSH
9754 - atomic_inc(&dcpage_flushes_xcall);
9755 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9756 #endif
9757 }
9758 }
9759 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9760 preempt_disable();
9761
9762 #ifdef CONFIG_DEBUG_DCFLUSH
9763 - atomic_inc(&dcpage_flushes);
9764 + atomic_inc_unchecked(&dcpage_flushes);
9765 #endif
9766 data0 = 0;
9767 pg_addr = page_address(page);
9768 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9769 xcall_deliver(data0, __pa(pg_addr),
9770 (u64) pg_addr, cpu_online_mask);
9771 #ifdef CONFIG_DEBUG_DCFLUSH
9772 - atomic_inc(&dcpage_flushes_xcall);
9773 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9774 #endif
9775 }
9776 __local_flush_dcache_page(page);
9777 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9778 index 3a8d184..49498a8 100644
9779 --- a/arch/sparc/kernel/sys_sparc_32.c
9780 +++ b/arch/sparc/kernel/sys_sparc_32.c
9781 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9782 if (len > TASK_SIZE - PAGE_SIZE)
9783 return -ENOMEM;
9784 if (!addr)
9785 - addr = TASK_UNMAPPED_BASE;
9786 + addr = current->mm->mmap_base;
9787
9788 info.flags = 0;
9789 info.length = len;
9790 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9791 index 51561b8..8256764 100644
9792 --- a/arch/sparc/kernel/sys_sparc_64.c
9793 +++ b/arch/sparc/kernel/sys_sparc_64.c
9794 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9795 struct vm_area_struct * vma;
9796 unsigned long task_size = TASK_SIZE;
9797 int do_color_align;
9798 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9799 struct vm_unmapped_area_info info;
9800
9801 if (flags & MAP_FIXED) {
9802 /* We do not accept a shared mapping if it would violate
9803 * cache aliasing constraints.
9804 */
9805 - if ((flags & MAP_SHARED) &&
9806 + if ((filp || (flags & MAP_SHARED)) &&
9807 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9808 return -EINVAL;
9809 return addr;
9810 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9811 if (filp || (flags & MAP_SHARED))
9812 do_color_align = 1;
9813
9814 +#ifdef CONFIG_PAX_RANDMMAP
9815 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9816 +#endif
9817 +
9818 if (addr) {
9819 if (do_color_align)
9820 addr = COLOR_ALIGN(addr, pgoff);
9821 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9822 addr = PAGE_ALIGN(addr);
9823
9824 vma = find_vma(mm, addr);
9825 - if (task_size - len >= addr &&
9826 - (!vma || addr + len <= vma->vm_start))
9827 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9828 return addr;
9829 }
9830
9831 info.flags = 0;
9832 info.length = len;
9833 - info.low_limit = TASK_UNMAPPED_BASE;
9834 + info.low_limit = mm->mmap_base;
9835 info.high_limit = min(task_size, VA_EXCLUDE_START);
9836 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9837 info.align_offset = pgoff << PAGE_SHIFT;
9838 + info.threadstack_offset = offset;
9839 addr = vm_unmapped_area(&info);
9840
9841 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9842 VM_BUG_ON(addr != -ENOMEM);
9843 info.low_limit = VA_EXCLUDE_END;
9844 +
9845 +#ifdef CONFIG_PAX_RANDMMAP
9846 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9847 + info.low_limit += mm->delta_mmap;
9848 +#endif
9849 +
9850 info.high_limit = task_size;
9851 addr = vm_unmapped_area(&info);
9852 }
9853 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9854 unsigned long task_size = STACK_TOP32;
9855 unsigned long addr = addr0;
9856 int do_color_align;
9857 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9858 struct vm_unmapped_area_info info;
9859
9860 /* This should only ever run for 32-bit processes. */
9861 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9862 /* We do not accept a shared mapping if it would violate
9863 * cache aliasing constraints.
9864 */
9865 - if ((flags & MAP_SHARED) &&
9866 + if ((filp || (flags & MAP_SHARED)) &&
9867 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9868 return -EINVAL;
9869 return addr;
9870 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9871 if (filp || (flags & MAP_SHARED))
9872 do_color_align = 1;
9873
9874 +#ifdef CONFIG_PAX_RANDMMAP
9875 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9876 +#endif
9877 +
9878 /* requesting a specific address */
9879 if (addr) {
9880 if (do_color_align)
9881 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9882 addr = PAGE_ALIGN(addr);
9883
9884 vma = find_vma(mm, addr);
9885 - if (task_size - len >= addr &&
9886 - (!vma || addr + len <= vma->vm_start))
9887 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9888 return addr;
9889 }
9890
9891 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9892 info.high_limit = mm->mmap_base;
9893 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9894 info.align_offset = pgoff << PAGE_SHIFT;
9895 + info.threadstack_offset = offset;
9896 addr = vm_unmapped_area(&info);
9897
9898 /*
9899 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9900 VM_BUG_ON(addr != -ENOMEM);
9901 info.flags = 0;
9902 info.low_limit = TASK_UNMAPPED_BASE;
9903 +
9904 +#ifdef CONFIG_PAX_RANDMMAP
9905 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9906 + info.low_limit += mm->delta_mmap;
9907 +#endif
9908 +
9909 info.high_limit = STACK_TOP32;
9910 addr = vm_unmapped_area(&info);
9911 }
9912 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9913 EXPORT_SYMBOL(get_fb_unmapped_area);
9914
9915 /* Essentially the same as PowerPC. */
9916 -static unsigned long mmap_rnd(void)
9917 +static unsigned long mmap_rnd(struct mm_struct *mm)
9918 {
9919 unsigned long rnd = 0UL;
9920
9921 +#ifdef CONFIG_PAX_RANDMMAP
9922 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9923 +#endif
9924 +
9925 if (current->flags & PF_RANDOMIZE) {
9926 unsigned long val = get_random_int();
9927 if (test_thread_flag(TIF_32BIT))
9928 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9929
9930 void arch_pick_mmap_layout(struct mm_struct *mm)
9931 {
9932 - unsigned long random_factor = mmap_rnd();
9933 + unsigned long random_factor = mmap_rnd(mm);
9934 unsigned long gap;
9935
9936 /*
9937 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9938 gap == RLIM_INFINITY ||
9939 sysctl_legacy_va_layout) {
9940 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9941 +
9942 +#ifdef CONFIG_PAX_RANDMMAP
9943 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9944 + mm->mmap_base += mm->delta_mmap;
9945 +#endif
9946 +
9947 mm->get_unmapped_area = arch_get_unmapped_area;
9948 } else {
9949 /* We know it's 32-bit */
9950 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9951 gap = (task_size / 6 * 5);
9952
9953 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9954 +
9955 +#ifdef CONFIG_PAX_RANDMMAP
9956 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9957 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9958 +#endif
9959 +
9960 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9961 }
9962 }
9963 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9964 index d950197..192f9d8 100644
9965 --- a/arch/sparc/kernel/syscalls.S
9966 +++ b/arch/sparc/kernel/syscalls.S
9967 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9968 #endif
9969 .align 32
9970 1: ldx [%g6 + TI_FLAGS], %l5
9971 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9972 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9973 be,pt %icc, rtrap
9974 nop
9975 call syscall_trace_leave
9976 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9977
9978 srl %i3, 0, %o3 ! IEU0
9979 srl %i2, 0, %o2 ! IEU0 Group
9980 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9981 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9982 bne,pn %icc, linux_syscall_trace32 ! CTI
9983 mov %i0, %l5 ! IEU1
9984 5: call %l7 ! CTI Group brk forced
9985 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9986
9987 mov %i3, %o3 ! IEU1
9988 mov %i4, %o4 ! IEU0 Group
9989 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9990 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9991 bne,pn %icc, linux_syscall_trace ! CTI Group
9992 mov %i0, %l5 ! IEU0
9993 2: call %l7 ! CTI Group brk forced
9994 @@ -223,7 +223,7 @@ ret_sys_call:
9995
9996 cmp %o0, -ERESTART_RESTARTBLOCK
9997 bgeu,pn %xcc, 1f
9998 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9999 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10000 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
10001
10002 2:
10003 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
10004 index 6629829..036032d 100644
10005 --- a/arch/sparc/kernel/traps_32.c
10006 +++ b/arch/sparc/kernel/traps_32.c
10007 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
10008 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
10009 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
10010
10011 +extern void gr_handle_kernel_exploit(void);
10012 +
10013 void die_if_kernel(char *str, struct pt_regs *regs)
10014 {
10015 static int die_counter;
10016 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10017 count++ < 30 &&
10018 (((unsigned long) rw) >= PAGE_OFFSET) &&
10019 !(((unsigned long) rw) & 0x7)) {
10020 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
10021 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
10022 (void *) rw->ins[7]);
10023 rw = (struct reg_window32 *)rw->ins[6];
10024 }
10025 }
10026 printk("Instruction DUMP:");
10027 instruction_dump ((unsigned long *) regs->pc);
10028 - if(regs->psr & PSR_PS)
10029 + if(regs->psr & PSR_PS) {
10030 + gr_handle_kernel_exploit();
10031 do_exit(SIGKILL);
10032 + }
10033 do_exit(SIGSEGV);
10034 }
10035
10036 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
10037 index b3f833a..f485f80 100644
10038 --- a/arch/sparc/kernel/traps_64.c
10039 +++ b/arch/sparc/kernel/traps_64.c
10040 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
10041 i + 1,
10042 p->trapstack[i].tstate, p->trapstack[i].tpc,
10043 p->trapstack[i].tnpc, p->trapstack[i].tt);
10044 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
10045 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
10046 }
10047 }
10048
10049 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
10050
10051 lvl -= 0x100;
10052 if (regs->tstate & TSTATE_PRIV) {
10053 +
10054 +#ifdef CONFIG_PAX_REFCOUNT
10055 + if (lvl == 6)
10056 + pax_report_refcount_overflow(regs);
10057 +#endif
10058 +
10059 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
10060 die_if_kernel(buffer, regs);
10061 }
10062 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
10063 void bad_trap_tl1(struct pt_regs *regs, long lvl)
10064 {
10065 char buffer[32];
10066 -
10067 +
10068 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
10069 0, lvl, SIGTRAP) == NOTIFY_STOP)
10070 return;
10071
10072 +#ifdef CONFIG_PAX_REFCOUNT
10073 + if (lvl == 6)
10074 + pax_report_refcount_overflow(regs);
10075 +#endif
10076 +
10077 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
10078
10079 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
10080 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
10081 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
10082 printk("%s" "ERROR(%d): ",
10083 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
10084 - printk("TPC<%pS>\n", (void *) regs->tpc);
10085 + printk("TPC<%pA>\n", (void *) regs->tpc);
10086 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
10087 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
10088 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
10089 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10090 smp_processor_id(),
10091 (type & 0x1) ? 'I' : 'D',
10092 regs->tpc);
10093 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10094 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10095 panic("Irrecoverable Cheetah+ parity error.");
10096 }
10097
10098 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10099 smp_processor_id(),
10100 (type & 0x1) ? 'I' : 'D',
10101 regs->tpc);
10102 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10103 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10104 }
10105
10106 struct sun4v_error_entry {
10107 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10108 /*0x38*/u64 reserved_5;
10109 };
10110
10111 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10112 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10113 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10114 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10115
10116 static const char *sun4v_err_type_to_str(u8 type)
10117 {
10118 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10119 }
10120
10121 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10122 - int cpu, const char *pfx, atomic_t *ocnt)
10123 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10124 {
10125 u64 *raw_ptr = (u64 *) ent;
10126 u32 attrs;
10127 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10128
10129 show_regs(regs);
10130
10131 - if ((cnt = atomic_read(ocnt)) != 0) {
10132 - atomic_set(ocnt, 0);
10133 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10134 + atomic_set_unchecked(ocnt, 0);
10135 wmb();
10136 printk("%s: Queue overflowed %d times.\n",
10137 pfx, cnt);
10138 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10139 */
10140 void sun4v_resum_overflow(struct pt_regs *regs)
10141 {
10142 - atomic_inc(&sun4v_resum_oflow_cnt);
10143 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10144 }
10145
10146 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10147 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10148 /* XXX Actually even this can make not that much sense. Perhaps
10149 * XXX we should just pull the plug and panic directly from here?
10150 */
10151 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10152 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10153 }
10154
10155 unsigned long sun4v_err_itlb_vaddr;
10156 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10157
10158 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10159 regs->tpc, tl);
10160 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10161 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10162 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10163 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10164 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10165 (void *) regs->u_regs[UREG_I7]);
10166 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10167 "pte[%lx] error[%lx]\n",
10168 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10169
10170 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10171 regs->tpc, tl);
10172 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10173 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10174 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10175 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10176 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10177 (void *) regs->u_regs[UREG_I7]);
10178 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10179 "pte[%lx] error[%lx]\n",
10180 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10181 fp = (unsigned long)sf->fp + STACK_BIAS;
10182 }
10183
10184 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10185 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10186 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10187 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10188 int index = tsk->curr_ret_stack;
10189 if (tsk->ret_stack && index >= graph) {
10190 pc = tsk->ret_stack[index - graph].ret;
10191 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10192 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10193 graph++;
10194 }
10195 }
10196 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10197 return (struct reg_window *) (fp + STACK_BIAS);
10198 }
10199
10200 +extern void gr_handle_kernel_exploit(void);
10201 +
10202 void die_if_kernel(char *str, struct pt_regs *regs)
10203 {
10204 static int die_counter;
10205 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10206 while (rw &&
10207 count++ < 30 &&
10208 kstack_valid(tp, (unsigned long) rw)) {
10209 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10210 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10211 (void *) rw->ins[7]);
10212
10213 rw = kernel_stack_up(rw);
10214 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10215 }
10216 user_instruction_dump ((unsigned int __user *) regs->tpc);
10217 }
10218 - if (regs->tstate & TSTATE_PRIV)
10219 + if (regs->tstate & TSTATE_PRIV) {
10220 + gr_handle_kernel_exploit();
10221 do_exit(SIGKILL);
10222 + }
10223 do_exit(SIGSEGV);
10224 }
10225 EXPORT_SYMBOL(die_if_kernel);
10226 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10227 index 8201c25e..072a2a7 100644
10228 --- a/arch/sparc/kernel/unaligned_64.c
10229 +++ b/arch/sparc/kernel/unaligned_64.c
10230 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10231 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10232
10233 if (__ratelimit(&ratelimit)) {
10234 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10235 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10236 regs->tpc, (void *) regs->tpc);
10237 }
10238 }
10239 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10240 index dbe119b..089c7c1 100644
10241 --- a/arch/sparc/lib/Makefile
10242 +++ b/arch/sparc/lib/Makefile
10243 @@ -2,7 +2,7 @@
10244 #
10245
10246 asflags-y := -ansi -DST_DIV0=0x02
10247 -ccflags-y := -Werror
10248 +#ccflags-y := -Werror
10249
10250 lib-$(CONFIG_SPARC32) += ashrdi3.o
10251 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10252 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10253 index 85c233d..68500e0 100644
10254 --- a/arch/sparc/lib/atomic_64.S
10255 +++ b/arch/sparc/lib/atomic_64.S
10256 @@ -17,7 +17,12 @@
10257 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10258 BACKOFF_SETUP(%o2)
10259 1: lduw [%o1], %g1
10260 - add %g1, %o0, %g7
10261 + addcc %g1, %o0, %g7
10262 +
10263 +#ifdef CONFIG_PAX_REFCOUNT
10264 + tvs %icc, 6
10265 +#endif
10266 +
10267 cas [%o1], %g1, %g7
10268 cmp %g1, %g7
10269 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10270 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10271 2: BACKOFF_SPIN(%o2, %o3, 1b)
10272 ENDPROC(atomic_add)
10273
10274 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10275 + BACKOFF_SETUP(%o2)
10276 +1: lduw [%o1], %g1
10277 + add %g1, %o0, %g7
10278 + cas [%o1], %g1, %g7
10279 + cmp %g1, %g7
10280 + bne,pn %icc, 2f
10281 + nop
10282 + retl
10283 + nop
10284 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10285 +ENDPROC(atomic_add_unchecked)
10286 +
10287 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10288 BACKOFF_SETUP(%o2)
10289 1: lduw [%o1], %g1
10290 - sub %g1, %o0, %g7
10291 + subcc %g1, %o0, %g7
10292 +
10293 +#ifdef CONFIG_PAX_REFCOUNT
10294 + tvs %icc, 6
10295 +#endif
10296 +
10297 cas [%o1], %g1, %g7
10298 cmp %g1, %g7
10299 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10300 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10301 2: BACKOFF_SPIN(%o2, %o3, 1b)
10302 ENDPROC(atomic_sub)
10303
10304 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10305 + BACKOFF_SETUP(%o2)
10306 +1: lduw [%o1], %g1
10307 + sub %g1, %o0, %g7
10308 + cas [%o1], %g1, %g7
10309 + cmp %g1, %g7
10310 + bne,pn %icc, 2f
10311 + nop
10312 + retl
10313 + nop
10314 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10315 +ENDPROC(atomic_sub_unchecked)
10316 +
10317 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10318 BACKOFF_SETUP(%o2)
10319 1: lduw [%o1], %g1
10320 - add %g1, %o0, %g7
10321 + addcc %g1, %o0, %g7
10322 +
10323 +#ifdef CONFIG_PAX_REFCOUNT
10324 + tvs %icc, 6
10325 +#endif
10326 +
10327 cas [%o1], %g1, %g7
10328 cmp %g1, %g7
10329 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10330 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10331 2: BACKOFF_SPIN(%o2, %o3, 1b)
10332 ENDPROC(atomic_add_ret)
10333
10334 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10335 + BACKOFF_SETUP(%o2)
10336 +1: lduw [%o1], %g1
10337 + addcc %g1, %o0, %g7
10338 + cas [%o1], %g1, %g7
10339 + cmp %g1, %g7
10340 + bne,pn %icc, 2f
10341 + add %g7, %o0, %g7
10342 + sra %g7, 0, %o0
10343 + retl
10344 + nop
10345 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10346 +ENDPROC(atomic_add_ret_unchecked)
10347 +
10348 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10349 BACKOFF_SETUP(%o2)
10350 1: lduw [%o1], %g1
10351 - sub %g1, %o0, %g7
10352 + subcc %g1, %o0, %g7
10353 +
10354 +#ifdef CONFIG_PAX_REFCOUNT
10355 + tvs %icc, 6
10356 +#endif
10357 +
10358 cas [%o1], %g1, %g7
10359 cmp %g1, %g7
10360 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10361 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10362 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10363 BACKOFF_SETUP(%o2)
10364 1: ldx [%o1], %g1
10365 - add %g1, %o0, %g7
10366 + addcc %g1, %o0, %g7
10367 +
10368 +#ifdef CONFIG_PAX_REFCOUNT
10369 + tvs %xcc, 6
10370 +#endif
10371 +
10372 casx [%o1], %g1, %g7
10373 cmp %g1, %g7
10374 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10375 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10376 2: BACKOFF_SPIN(%o2, %o3, 1b)
10377 ENDPROC(atomic64_add)
10378
10379 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10380 + BACKOFF_SETUP(%o2)
10381 +1: ldx [%o1], %g1
10382 + addcc %g1, %o0, %g7
10383 + casx [%o1], %g1, %g7
10384 + cmp %g1, %g7
10385 + bne,pn %xcc, 2f
10386 + nop
10387 + retl
10388 + nop
10389 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10390 +ENDPROC(atomic64_add_unchecked)
10391 +
10392 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10393 BACKOFF_SETUP(%o2)
10394 1: ldx [%o1], %g1
10395 - sub %g1, %o0, %g7
10396 + subcc %g1, %o0, %g7
10397 +
10398 +#ifdef CONFIG_PAX_REFCOUNT
10399 + tvs %xcc, 6
10400 +#endif
10401 +
10402 casx [%o1], %g1, %g7
10403 cmp %g1, %g7
10404 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10405 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10406 2: BACKOFF_SPIN(%o2, %o3, 1b)
10407 ENDPROC(atomic64_sub)
10408
10409 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10410 + BACKOFF_SETUP(%o2)
10411 +1: ldx [%o1], %g1
10412 + subcc %g1, %o0, %g7
10413 + casx [%o1], %g1, %g7
10414 + cmp %g1, %g7
10415 + bne,pn %xcc, 2f
10416 + nop
10417 + retl
10418 + nop
10419 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10420 +ENDPROC(atomic64_sub_unchecked)
10421 +
10422 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10423 BACKOFF_SETUP(%o2)
10424 1: ldx [%o1], %g1
10425 - add %g1, %o0, %g7
10426 + addcc %g1, %o0, %g7
10427 +
10428 +#ifdef CONFIG_PAX_REFCOUNT
10429 + tvs %xcc, 6
10430 +#endif
10431 +
10432 casx [%o1], %g1, %g7
10433 cmp %g1, %g7
10434 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10435 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10436 2: BACKOFF_SPIN(%o2, %o3, 1b)
10437 ENDPROC(atomic64_add_ret)
10438
10439 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10440 + BACKOFF_SETUP(%o2)
10441 +1: ldx [%o1], %g1
10442 + addcc %g1, %o0, %g7
10443 + casx [%o1], %g1, %g7
10444 + cmp %g1, %g7
10445 + bne,pn %xcc, 2f
10446 + add %g7, %o0, %g7
10447 + mov %g7, %o0
10448 + retl
10449 + nop
10450 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10451 +ENDPROC(atomic64_add_ret_unchecked)
10452 +
10453 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10454 BACKOFF_SETUP(%o2)
10455 1: ldx [%o1], %g1
10456 - sub %g1, %o0, %g7
10457 + subcc %g1, %o0, %g7
10458 +
10459 +#ifdef CONFIG_PAX_REFCOUNT
10460 + tvs %xcc, 6
10461 +#endif
10462 +
10463 casx [%o1], %g1, %g7
10464 cmp %g1, %g7
10465 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10466 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10467 index 323335b..ed85ea2 100644
10468 --- a/arch/sparc/lib/ksyms.c
10469 +++ b/arch/sparc/lib/ksyms.c
10470 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10471
10472 /* Atomic counter implementation. */
10473 EXPORT_SYMBOL(atomic_add);
10474 +EXPORT_SYMBOL(atomic_add_unchecked);
10475 EXPORT_SYMBOL(atomic_add_ret);
10476 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10477 EXPORT_SYMBOL(atomic_sub);
10478 +EXPORT_SYMBOL(atomic_sub_unchecked);
10479 EXPORT_SYMBOL(atomic_sub_ret);
10480 EXPORT_SYMBOL(atomic64_add);
10481 +EXPORT_SYMBOL(atomic64_add_unchecked);
10482 EXPORT_SYMBOL(atomic64_add_ret);
10483 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10484 EXPORT_SYMBOL(atomic64_sub);
10485 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10486 EXPORT_SYMBOL(atomic64_sub_ret);
10487 EXPORT_SYMBOL(atomic64_dec_if_positive);
10488
10489 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10490 index 30c3ecc..736f015 100644
10491 --- a/arch/sparc/mm/Makefile
10492 +++ b/arch/sparc/mm/Makefile
10493 @@ -2,7 +2,7 @@
10494 #
10495
10496 asflags-y := -ansi
10497 -ccflags-y := -Werror
10498 +#ccflags-y := -Werror
10499
10500 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10501 obj-y += fault_$(BITS).o
10502 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10503 index 59dbd46..1dd7f5e 100644
10504 --- a/arch/sparc/mm/fault_32.c
10505 +++ b/arch/sparc/mm/fault_32.c
10506 @@ -21,6 +21,9 @@
10507 #include <linux/perf_event.h>
10508 #include <linux/interrupt.h>
10509 #include <linux/kdebug.h>
10510 +#include <linux/slab.h>
10511 +#include <linux/pagemap.h>
10512 +#include <linux/compiler.h>
10513
10514 #include <asm/page.h>
10515 #include <asm/pgtable.h>
10516 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10517 return safe_compute_effective_address(regs, insn);
10518 }
10519
10520 +#ifdef CONFIG_PAX_PAGEEXEC
10521 +#ifdef CONFIG_PAX_DLRESOLVE
10522 +static void pax_emuplt_close(struct vm_area_struct *vma)
10523 +{
10524 + vma->vm_mm->call_dl_resolve = 0UL;
10525 +}
10526 +
10527 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10528 +{
10529 + unsigned int *kaddr;
10530 +
10531 + vmf->page = alloc_page(GFP_HIGHUSER);
10532 + if (!vmf->page)
10533 + return VM_FAULT_OOM;
10534 +
10535 + kaddr = kmap(vmf->page);
10536 + memset(kaddr, 0, PAGE_SIZE);
10537 + kaddr[0] = 0x9DE3BFA8U; /* save */
10538 + flush_dcache_page(vmf->page);
10539 + kunmap(vmf->page);
10540 + return VM_FAULT_MAJOR;
10541 +}
10542 +
10543 +static const struct vm_operations_struct pax_vm_ops = {
10544 + .close = pax_emuplt_close,
10545 + .fault = pax_emuplt_fault
10546 +};
10547 +
10548 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10549 +{
10550 + int ret;
10551 +
10552 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10553 + vma->vm_mm = current->mm;
10554 + vma->vm_start = addr;
10555 + vma->vm_end = addr + PAGE_SIZE;
10556 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10557 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10558 + vma->vm_ops = &pax_vm_ops;
10559 +
10560 + ret = insert_vm_struct(current->mm, vma);
10561 + if (ret)
10562 + return ret;
10563 +
10564 + ++current->mm->total_vm;
10565 + return 0;
10566 +}
10567 +#endif
10568 +
10569 +/*
10570 + * PaX: decide what to do with offenders (regs->pc = fault address)
10571 + *
10572 + * returns 1 when task should be killed
10573 + * 2 when patched PLT trampoline was detected
10574 + * 3 when unpatched PLT trampoline was detected
10575 + */
10576 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10577 +{
10578 +
10579 +#ifdef CONFIG_PAX_EMUPLT
10580 + int err;
10581 +
10582 + do { /* PaX: patched PLT emulation #1 */
10583 + unsigned int sethi1, sethi2, jmpl;
10584 +
10585 + err = get_user(sethi1, (unsigned int *)regs->pc);
10586 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10587 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10588 +
10589 + if (err)
10590 + break;
10591 +
10592 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10593 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10594 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10595 + {
10596 + unsigned int addr;
10597 +
10598 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10599 + addr = regs->u_regs[UREG_G1];
10600 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10601 + regs->pc = addr;
10602 + regs->npc = addr+4;
10603 + return 2;
10604 + }
10605 + } while (0);
10606 +
10607 + do { /* PaX: patched PLT emulation #2 */
10608 + unsigned int ba;
10609 +
10610 + err = get_user(ba, (unsigned int *)regs->pc);
10611 +
10612 + if (err)
10613 + break;
10614 +
10615 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10616 + unsigned int addr;
10617 +
10618 + if ((ba & 0xFFC00000U) == 0x30800000U)
10619 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10620 + else
10621 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10622 + regs->pc = addr;
10623 + regs->npc = addr+4;
10624 + return 2;
10625 + }
10626 + } while (0);
10627 +
10628 + do { /* PaX: patched PLT emulation #3 */
10629 + unsigned int sethi, bajmpl, nop;
10630 +
10631 + err = get_user(sethi, (unsigned int *)regs->pc);
10632 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10633 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10634 +
10635 + if (err)
10636 + break;
10637 +
10638 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10639 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10640 + nop == 0x01000000U)
10641 + {
10642 + unsigned int addr;
10643 +
10644 + addr = (sethi & 0x003FFFFFU) << 10;
10645 + regs->u_regs[UREG_G1] = addr;
10646 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10647 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10648 + else
10649 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10650 + regs->pc = addr;
10651 + regs->npc = addr+4;
10652 + return 2;
10653 + }
10654 + } while (0);
10655 +
10656 + do { /* PaX: unpatched PLT emulation step 1 */
10657 + unsigned int sethi, ba, nop;
10658 +
10659 + err = get_user(sethi, (unsigned int *)regs->pc);
10660 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10661 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10662 +
10663 + if (err)
10664 + break;
10665 +
10666 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10667 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10668 + nop == 0x01000000U)
10669 + {
10670 + unsigned int addr, save, call;
10671 +
10672 + if ((ba & 0xFFC00000U) == 0x30800000U)
10673 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10674 + else
10675 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10676 +
10677 + err = get_user(save, (unsigned int *)addr);
10678 + err |= get_user(call, (unsigned int *)(addr+4));
10679 + err |= get_user(nop, (unsigned int *)(addr+8));
10680 + if (err)
10681 + break;
10682 +
10683 +#ifdef CONFIG_PAX_DLRESOLVE
10684 + if (save == 0x9DE3BFA8U &&
10685 + (call & 0xC0000000U) == 0x40000000U &&
10686 + nop == 0x01000000U)
10687 + {
10688 + struct vm_area_struct *vma;
10689 + unsigned long call_dl_resolve;
10690 +
10691 + down_read(&current->mm->mmap_sem);
10692 + call_dl_resolve = current->mm->call_dl_resolve;
10693 + up_read(&current->mm->mmap_sem);
10694 + if (likely(call_dl_resolve))
10695 + goto emulate;
10696 +
10697 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10698 +
10699 + down_write(&current->mm->mmap_sem);
10700 + if (current->mm->call_dl_resolve) {
10701 + call_dl_resolve = current->mm->call_dl_resolve;
10702 + up_write(&current->mm->mmap_sem);
10703 + if (vma)
10704 + kmem_cache_free(vm_area_cachep, vma);
10705 + goto emulate;
10706 + }
10707 +
10708 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10709 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10710 + up_write(&current->mm->mmap_sem);
10711 + if (vma)
10712 + kmem_cache_free(vm_area_cachep, vma);
10713 + return 1;
10714 + }
10715 +
10716 + if (pax_insert_vma(vma, call_dl_resolve)) {
10717 + up_write(&current->mm->mmap_sem);
10718 + kmem_cache_free(vm_area_cachep, vma);
10719 + return 1;
10720 + }
10721 +
10722 + current->mm->call_dl_resolve = call_dl_resolve;
10723 + up_write(&current->mm->mmap_sem);
10724 +
10725 +emulate:
10726 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10727 + regs->pc = call_dl_resolve;
10728 + regs->npc = addr+4;
10729 + return 3;
10730 + }
10731 +#endif
10732 +
10733 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10734 + if ((save & 0xFFC00000U) == 0x05000000U &&
10735 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10736 + nop == 0x01000000U)
10737 + {
10738 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10739 + regs->u_regs[UREG_G2] = addr + 4;
10740 + addr = (save & 0x003FFFFFU) << 10;
10741 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10742 + regs->pc = addr;
10743 + regs->npc = addr+4;
10744 + return 3;
10745 + }
10746 + }
10747 + } while (0);
10748 +
10749 + do { /* PaX: unpatched PLT emulation step 2 */
10750 + unsigned int save, call, nop;
10751 +
10752 + err = get_user(save, (unsigned int *)(regs->pc-4));
10753 + err |= get_user(call, (unsigned int *)regs->pc);
10754 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10755 + if (err)
10756 + break;
10757 +
10758 + if (save == 0x9DE3BFA8U &&
10759 + (call & 0xC0000000U) == 0x40000000U &&
10760 + nop == 0x01000000U)
10761 + {
10762 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10763 +
10764 + regs->u_regs[UREG_RETPC] = regs->pc;
10765 + regs->pc = dl_resolve;
10766 + regs->npc = dl_resolve+4;
10767 + return 3;
10768 + }
10769 + } while (0);
10770 +#endif
10771 +
10772 + return 1;
10773 +}
10774 +
10775 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10776 +{
10777 + unsigned long i;
10778 +
10779 + printk(KERN_ERR "PAX: bytes at PC: ");
10780 + for (i = 0; i < 8; i++) {
10781 + unsigned int c;
10782 + if (get_user(c, (unsigned int *)pc+i))
10783 + printk(KERN_CONT "???????? ");
10784 + else
10785 + printk(KERN_CONT "%08x ", c);
10786 + }
10787 + printk("\n");
10788 +}
10789 +#endif
10790 +
10791 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10792 int text_fault)
10793 {
10794 @@ -229,6 +503,24 @@ good_area:
10795 if (!(vma->vm_flags & VM_WRITE))
10796 goto bad_area;
10797 } else {
10798 +
10799 +#ifdef CONFIG_PAX_PAGEEXEC
10800 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10801 + up_read(&mm->mmap_sem);
10802 + switch (pax_handle_fetch_fault(regs)) {
10803 +
10804 +#ifdef CONFIG_PAX_EMUPLT
10805 + case 2:
10806 + case 3:
10807 + return;
10808 +#endif
10809 +
10810 + }
10811 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10812 + do_group_exit(SIGKILL);
10813 + }
10814 +#endif
10815 +
10816 /* Allow reads even for write-only mappings */
10817 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10818 goto bad_area;
10819 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10820 index 2ebec26..b212598 100644
10821 --- a/arch/sparc/mm/fault_64.c
10822 +++ b/arch/sparc/mm/fault_64.c
10823 @@ -21,6 +21,9 @@
10824 #include <linux/kprobes.h>
10825 #include <linux/kdebug.h>
10826 #include <linux/percpu.h>
10827 +#include <linux/slab.h>
10828 +#include <linux/pagemap.h>
10829 +#include <linux/compiler.h>
10830
10831 #include <asm/page.h>
10832 #include <asm/pgtable.h>
10833 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10834 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10835 regs->tpc);
10836 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10837 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10838 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10839 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10840 dump_stack();
10841 unhandled_fault(regs->tpc, current, regs);
10842 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10843 show_regs(regs);
10844 }
10845
10846 +#ifdef CONFIG_PAX_PAGEEXEC
10847 +#ifdef CONFIG_PAX_DLRESOLVE
10848 +static void pax_emuplt_close(struct vm_area_struct *vma)
10849 +{
10850 + vma->vm_mm->call_dl_resolve = 0UL;
10851 +}
10852 +
10853 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10854 +{
10855 + unsigned int *kaddr;
10856 +
10857 + vmf->page = alloc_page(GFP_HIGHUSER);
10858 + if (!vmf->page)
10859 + return VM_FAULT_OOM;
10860 +
10861 + kaddr = kmap(vmf->page);
10862 + memset(kaddr, 0, PAGE_SIZE);
10863 + kaddr[0] = 0x9DE3BFA8U; /* save */
10864 + flush_dcache_page(vmf->page);
10865 + kunmap(vmf->page);
10866 + return VM_FAULT_MAJOR;
10867 +}
10868 +
10869 +static const struct vm_operations_struct pax_vm_ops = {
10870 + .close = pax_emuplt_close,
10871 + .fault = pax_emuplt_fault
10872 +};
10873 +
10874 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10875 +{
10876 + int ret;
10877 +
10878 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10879 + vma->vm_mm = current->mm;
10880 + vma->vm_start = addr;
10881 + vma->vm_end = addr + PAGE_SIZE;
10882 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10883 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10884 + vma->vm_ops = &pax_vm_ops;
10885 +
10886 + ret = insert_vm_struct(current->mm, vma);
10887 + if (ret)
10888 + return ret;
10889 +
10890 + ++current->mm->total_vm;
10891 + return 0;
10892 +}
10893 +#endif
10894 +
10895 +/*
10896 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10897 + *
10898 + * returns 1 when task should be killed
10899 + * 2 when patched PLT trampoline was detected
10900 + * 3 when unpatched PLT trampoline was detected
10901 + */
10902 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10903 +{
10904 +
10905 +#ifdef CONFIG_PAX_EMUPLT
10906 + int err;
10907 +
10908 + do { /* PaX: patched PLT emulation #1 */
10909 + unsigned int sethi1, sethi2, jmpl;
10910 +
10911 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10912 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10913 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10914 +
10915 + if (err)
10916 + break;
10917 +
10918 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10919 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10920 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10921 + {
10922 + unsigned long addr;
10923 +
10924 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10925 + addr = regs->u_regs[UREG_G1];
10926 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10927 +
10928 + if (test_thread_flag(TIF_32BIT))
10929 + addr &= 0xFFFFFFFFUL;
10930 +
10931 + regs->tpc = addr;
10932 + regs->tnpc = addr+4;
10933 + return 2;
10934 + }
10935 + } while (0);
10936 +
10937 + do { /* PaX: patched PLT emulation #2 */
10938 + unsigned int ba;
10939 +
10940 + err = get_user(ba, (unsigned int *)regs->tpc);
10941 +
10942 + if (err)
10943 + break;
10944 +
10945 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10946 + unsigned long addr;
10947 +
10948 + if ((ba & 0xFFC00000U) == 0x30800000U)
10949 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10950 + else
10951 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10952 +
10953 + if (test_thread_flag(TIF_32BIT))
10954 + addr &= 0xFFFFFFFFUL;
10955 +
10956 + regs->tpc = addr;
10957 + regs->tnpc = addr+4;
10958 + return 2;
10959 + }
10960 + } while (0);
10961 +
10962 + do { /* PaX: patched PLT emulation #3 */
10963 + unsigned int sethi, bajmpl, nop;
10964 +
10965 + err = get_user(sethi, (unsigned int *)regs->tpc);
10966 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10967 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10968 +
10969 + if (err)
10970 + break;
10971 +
10972 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10973 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10974 + nop == 0x01000000U)
10975 + {
10976 + unsigned long addr;
10977 +
10978 + addr = (sethi & 0x003FFFFFU) << 10;
10979 + regs->u_regs[UREG_G1] = addr;
10980 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10981 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10982 + else
10983 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10984 +
10985 + if (test_thread_flag(TIF_32BIT))
10986 + addr &= 0xFFFFFFFFUL;
10987 +
10988 + regs->tpc = addr;
10989 + regs->tnpc = addr+4;
10990 + return 2;
10991 + }
10992 + } while (0);
10993 +
10994 + do { /* PaX: patched PLT emulation #4 */
10995 + unsigned int sethi, mov1, call, mov2;
10996 +
10997 + err = get_user(sethi, (unsigned int *)regs->tpc);
10998 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10999 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
11000 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
11001 +
11002 + if (err)
11003 + break;
11004 +
11005 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11006 + mov1 == 0x8210000FU &&
11007 + (call & 0xC0000000U) == 0x40000000U &&
11008 + mov2 == 0x9E100001U)
11009 + {
11010 + unsigned long addr;
11011 +
11012 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
11013 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11014 +
11015 + if (test_thread_flag(TIF_32BIT))
11016 + addr &= 0xFFFFFFFFUL;
11017 +
11018 + regs->tpc = addr;
11019 + regs->tnpc = addr+4;
11020 + return 2;
11021 + }
11022 + } while (0);
11023 +
11024 + do { /* PaX: patched PLT emulation #5 */
11025 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
11026 +
11027 + err = get_user(sethi, (unsigned int *)regs->tpc);
11028 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11029 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11030 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
11031 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
11032 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
11033 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
11034 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
11035 +
11036 + if (err)
11037 + break;
11038 +
11039 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11040 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11041 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11042 + (or1 & 0xFFFFE000U) == 0x82106000U &&
11043 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11044 + sllx == 0x83287020U &&
11045 + jmpl == 0x81C04005U &&
11046 + nop == 0x01000000U)
11047 + {
11048 + unsigned long addr;
11049 +
11050 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11051 + regs->u_regs[UREG_G1] <<= 32;
11052 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11053 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11054 + regs->tpc = addr;
11055 + regs->tnpc = addr+4;
11056 + return 2;
11057 + }
11058 + } while (0);
11059 +
11060 + do { /* PaX: patched PLT emulation #6 */
11061 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
11062 +
11063 + err = get_user(sethi, (unsigned int *)regs->tpc);
11064 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11065 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11066 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
11067 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
11068 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
11069 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
11070 +
11071 + if (err)
11072 + break;
11073 +
11074 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11075 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11076 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11077 + sllx == 0x83287020U &&
11078 + (or & 0xFFFFE000U) == 0x8A116000U &&
11079 + jmpl == 0x81C04005U &&
11080 + nop == 0x01000000U)
11081 + {
11082 + unsigned long addr;
11083 +
11084 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11085 + regs->u_regs[UREG_G1] <<= 32;
11086 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11087 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11088 + regs->tpc = addr;
11089 + regs->tnpc = addr+4;
11090 + return 2;
11091 + }
11092 + } while (0);
11093 +
11094 + do { /* PaX: unpatched PLT emulation step 1 */
11095 + unsigned int sethi, ba, nop;
11096 +
11097 + err = get_user(sethi, (unsigned int *)regs->tpc);
11098 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11099 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11100 +
11101 + if (err)
11102 + break;
11103 +
11104 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11105 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11106 + nop == 0x01000000U)
11107 + {
11108 + unsigned long addr;
11109 + unsigned int save, call;
11110 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11111 +
11112 + if ((ba & 0xFFC00000U) == 0x30800000U)
11113 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11114 + else
11115 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11116 +
11117 + if (test_thread_flag(TIF_32BIT))
11118 + addr &= 0xFFFFFFFFUL;
11119 +
11120 + err = get_user(save, (unsigned int *)addr);
11121 + err |= get_user(call, (unsigned int *)(addr+4));
11122 + err |= get_user(nop, (unsigned int *)(addr+8));
11123 + if (err)
11124 + break;
11125 +
11126 +#ifdef CONFIG_PAX_DLRESOLVE
11127 + if (save == 0x9DE3BFA8U &&
11128 + (call & 0xC0000000U) == 0x40000000U &&
11129 + nop == 0x01000000U)
11130 + {
11131 + struct vm_area_struct *vma;
11132 + unsigned long call_dl_resolve;
11133 +
11134 + down_read(&current->mm->mmap_sem);
11135 + call_dl_resolve = current->mm->call_dl_resolve;
11136 + up_read(&current->mm->mmap_sem);
11137 + if (likely(call_dl_resolve))
11138 + goto emulate;
11139 +
11140 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11141 +
11142 + down_write(&current->mm->mmap_sem);
11143 + if (current->mm->call_dl_resolve) {
11144 + call_dl_resolve = current->mm->call_dl_resolve;
11145 + up_write(&current->mm->mmap_sem);
11146 + if (vma)
11147 + kmem_cache_free(vm_area_cachep, vma);
11148 + goto emulate;
11149 + }
11150 +
11151 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11152 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11153 + up_write(&current->mm->mmap_sem);
11154 + if (vma)
11155 + kmem_cache_free(vm_area_cachep, vma);
11156 + return 1;
11157 + }
11158 +
11159 + if (pax_insert_vma(vma, call_dl_resolve)) {
11160 + up_write(&current->mm->mmap_sem);
11161 + kmem_cache_free(vm_area_cachep, vma);
11162 + return 1;
11163 + }
11164 +
11165 + current->mm->call_dl_resolve = call_dl_resolve;
11166 + up_write(&current->mm->mmap_sem);
11167 +
11168 +emulate:
11169 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11170 + regs->tpc = call_dl_resolve;
11171 + regs->tnpc = addr+4;
11172 + return 3;
11173 + }
11174 +#endif
11175 +
11176 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11177 + if ((save & 0xFFC00000U) == 0x05000000U &&
11178 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11179 + nop == 0x01000000U)
11180 + {
11181 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11182 + regs->u_regs[UREG_G2] = addr + 4;
11183 + addr = (save & 0x003FFFFFU) << 10;
11184 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11185 +
11186 + if (test_thread_flag(TIF_32BIT))
11187 + addr &= 0xFFFFFFFFUL;
11188 +
11189 + regs->tpc = addr;
11190 + regs->tnpc = addr+4;
11191 + return 3;
11192 + }
11193 +
11194 + /* PaX: 64-bit PLT stub */
11195 + err = get_user(sethi1, (unsigned int *)addr);
11196 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11197 + err |= get_user(or1, (unsigned int *)(addr+8));
11198 + err |= get_user(or2, (unsigned int *)(addr+12));
11199 + err |= get_user(sllx, (unsigned int *)(addr+16));
11200 + err |= get_user(add, (unsigned int *)(addr+20));
11201 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11202 + err |= get_user(nop, (unsigned int *)(addr+28));
11203 + if (err)
11204 + break;
11205 +
11206 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11207 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11208 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11209 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11210 + sllx == 0x89293020U &&
11211 + add == 0x8A010005U &&
11212 + jmpl == 0x89C14000U &&
11213 + nop == 0x01000000U)
11214 + {
11215 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11216 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11217 + regs->u_regs[UREG_G4] <<= 32;
11218 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11219 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11220 + regs->u_regs[UREG_G4] = addr + 24;
11221 + addr = regs->u_regs[UREG_G5];
11222 + regs->tpc = addr;
11223 + regs->tnpc = addr+4;
11224 + return 3;
11225 + }
11226 + }
11227 + } while (0);
11228 +
11229 +#ifdef CONFIG_PAX_DLRESOLVE
11230 + do { /* PaX: unpatched PLT emulation step 2 */
11231 + unsigned int save, call, nop;
11232 +
11233 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11234 + err |= get_user(call, (unsigned int *)regs->tpc);
11235 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11236 + if (err)
11237 + break;
11238 +
11239 + if (save == 0x9DE3BFA8U &&
11240 + (call & 0xC0000000U) == 0x40000000U &&
11241 + nop == 0x01000000U)
11242 + {
11243 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11244 +
11245 + if (test_thread_flag(TIF_32BIT))
11246 + dl_resolve &= 0xFFFFFFFFUL;
11247 +
11248 + regs->u_regs[UREG_RETPC] = regs->tpc;
11249 + regs->tpc = dl_resolve;
11250 + regs->tnpc = dl_resolve+4;
11251 + return 3;
11252 + }
11253 + } while (0);
11254 +#endif
11255 +
11256 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11257 + unsigned int sethi, ba, nop;
11258 +
11259 + err = get_user(sethi, (unsigned int *)regs->tpc);
11260 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11261 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11262 +
11263 + if (err)
11264 + break;
11265 +
11266 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11267 + (ba & 0xFFF00000U) == 0x30600000U &&
11268 + nop == 0x01000000U)
11269 + {
11270 + unsigned long addr;
11271 +
11272 + addr = (sethi & 0x003FFFFFU) << 10;
11273 + regs->u_regs[UREG_G1] = addr;
11274 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11275 +
11276 + if (test_thread_flag(TIF_32BIT))
11277 + addr &= 0xFFFFFFFFUL;
11278 +
11279 + regs->tpc = addr;
11280 + regs->tnpc = addr+4;
11281 + return 2;
11282 + }
11283 + } while (0);
11284 +
11285 +#endif
11286 +
11287 + return 1;
11288 +}
11289 +
11290 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11291 +{
11292 + unsigned long i;
11293 +
11294 + printk(KERN_ERR "PAX: bytes at PC: ");
11295 + for (i = 0; i < 8; i++) {
11296 + unsigned int c;
11297 + if (get_user(c, (unsigned int *)pc+i))
11298 + printk(KERN_CONT "???????? ");
11299 + else
11300 + printk(KERN_CONT "%08x ", c);
11301 + }
11302 + printk("\n");
11303 +}
11304 +#endif
11305 +
11306 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11307 {
11308 struct mm_struct *mm = current->mm;
11309 @@ -342,6 +805,29 @@ retry:
11310 if (!vma)
11311 goto bad_area;
11312
11313 +#ifdef CONFIG_PAX_PAGEEXEC
11314 + /* PaX: detect ITLB misses on non-exec pages */
11315 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11316 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11317 + {
11318 + if (address != regs->tpc)
11319 + goto good_area;
11320 +
11321 + up_read(&mm->mmap_sem);
11322 + switch (pax_handle_fetch_fault(regs)) {
11323 +
11324 +#ifdef CONFIG_PAX_EMUPLT
11325 + case 2:
11326 + case 3:
11327 + return;
11328 +#endif
11329 +
11330 + }
11331 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11332 + do_group_exit(SIGKILL);
11333 + }
11334 +#endif
11335 +
11336 /* Pure DTLB misses do not tell us whether the fault causing
11337 * load/store/atomic was a write or not, it only says that there
11338 * was no match. So in such a case we (carefully) read the
11339 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11340 index 9639964..806cd0c 100644
11341 --- a/arch/sparc/mm/hugetlbpage.c
11342 +++ b/arch/sparc/mm/hugetlbpage.c
11343 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11344 unsigned long addr,
11345 unsigned long len,
11346 unsigned long pgoff,
11347 - unsigned long flags)
11348 + unsigned long flags,
11349 + unsigned long offset)
11350 {
11351 unsigned long task_size = TASK_SIZE;
11352 struct vm_unmapped_area_info info;
11353 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11354
11355 info.flags = 0;
11356 info.length = len;
11357 - info.low_limit = TASK_UNMAPPED_BASE;
11358 + info.low_limit = mm->mmap_base;
11359 info.high_limit = min(task_size, VA_EXCLUDE_START);
11360 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11361 info.align_offset = 0;
11362 + info.threadstack_offset = offset;
11363 addr = vm_unmapped_area(&info);
11364
11365 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11366 VM_BUG_ON(addr != -ENOMEM);
11367 info.low_limit = VA_EXCLUDE_END;
11368 +
11369 +#ifdef CONFIG_PAX_RANDMMAP
11370 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11371 + info.low_limit += mm->delta_mmap;
11372 +#endif
11373 +
11374 info.high_limit = task_size;
11375 addr = vm_unmapped_area(&info);
11376 }
11377 @@ -58,7 +66,8 @@ static unsigned long
11378 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11379 const unsigned long len,
11380 const unsigned long pgoff,
11381 - const unsigned long flags)
11382 + const unsigned long flags,
11383 + const unsigned long offset)
11384 {
11385 struct mm_struct *mm = current->mm;
11386 unsigned long addr = addr0;
11387 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11388 info.high_limit = mm->mmap_base;
11389 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11390 info.align_offset = 0;
11391 + info.threadstack_offset = offset;
11392 addr = vm_unmapped_area(&info);
11393
11394 /*
11395 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11396 VM_BUG_ON(addr != -ENOMEM);
11397 info.flags = 0;
11398 info.low_limit = TASK_UNMAPPED_BASE;
11399 +
11400 +#ifdef CONFIG_PAX_RANDMMAP
11401 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11402 + info.low_limit += mm->delta_mmap;
11403 +#endif
11404 +
11405 info.high_limit = STACK_TOP32;
11406 addr = vm_unmapped_area(&info);
11407 }
11408 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11409 struct mm_struct *mm = current->mm;
11410 struct vm_area_struct *vma;
11411 unsigned long task_size = TASK_SIZE;
11412 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11413
11414 if (test_thread_flag(TIF_32BIT))
11415 task_size = STACK_TOP32;
11416 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11417 return addr;
11418 }
11419
11420 +#ifdef CONFIG_PAX_RANDMMAP
11421 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11422 +#endif
11423 +
11424 if (addr) {
11425 addr = ALIGN(addr, HPAGE_SIZE);
11426 vma = find_vma(mm, addr);
11427 - if (task_size - len >= addr &&
11428 - (!vma || addr + len <= vma->vm_start))
11429 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11430 return addr;
11431 }
11432 if (mm->get_unmapped_area == arch_get_unmapped_area)
11433 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11434 - pgoff, flags);
11435 + pgoff, flags, offset);
11436 else
11437 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11438 - pgoff, flags);
11439 + pgoff, flags, offset);
11440 }
11441
11442 pte_t *huge_pte_alloc(struct mm_struct *mm,
11443 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11444 index ed82eda..0d80e77 100644
11445 --- a/arch/sparc/mm/init_64.c
11446 +++ b/arch/sparc/mm/init_64.c
11447 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11448 int num_kernel_image_mappings;
11449
11450 #ifdef CONFIG_DEBUG_DCFLUSH
11451 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11452 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11453 #ifdef CONFIG_SMP
11454 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11455 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11456 #endif
11457 #endif
11458
11459 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11460 {
11461 BUG_ON(tlb_type == hypervisor);
11462 #ifdef CONFIG_DEBUG_DCFLUSH
11463 - atomic_inc(&dcpage_flushes);
11464 + atomic_inc_unchecked(&dcpage_flushes);
11465 #endif
11466
11467 #ifdef DCACHE_ALIASING_POSSIBLE
11468 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11469
11470 #ifdef CONFIG_DEBUG_DCFLUSH
11471 seq_printf(m, "DCPageFlushes\t: %d\n",
11472 - atomic_read(&dcpage_flushes));
11473 + atomic_read_unchecked(&dcpage_flushes));
11474 #ifdef CONFIG_SMP
11475 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11476 - atomic_read(&dcpage_flushes_xcall));
11477 + atomic_read_unchecked(&dcpage_flushes_xcall));
11478 #endif /* CONFIG_SMP */
11479 #endif /* CONFIG_DEBUG_DCFLUSH */
11480 }
11481 diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
11482 index 218b6b2..01fe994 100644
11483 --- a/arch/sparc/net/bpf_jit_comp.c
11484 +++ b/arch/sparc/net/bpf_jit_comp.c
11485 @@ -497,9 +497,20 @@ void bpf_jit_compile(struct sk_filter *fp)
11486 case BPF_S_ALU_MUL_K: /* A *= K */
11487 emit_alu_K(MUL, K);
11488 break;
11489 - case BPF_S_ALU_DIV_K: /* A /= K */
11490 - emit_alu_K(MUL, K);
11491 - emit_read_y(r_A);
11492 + case BPF_S_ALU_DIV_K: /* A /= K with K != 0*/
11493 + if (K == 1)
11494 + break;
11495 + emit_write_y(G0);
11496 +#ifdef CONFIG_SPARC32
11497 + /* The Sparc v8 architecture requires
11498 + * three instructions between a %y
11499 + * register write and the first use.
11500 + */
11501 + emit_nop();
11502 + emit_nop();
11503 + emit_nop();
11504 +#endif
11505 + emit_alu_K(DIV, K);
11506 break;
11507 case BPF_S_ALU_DIV_X: /* A /= X; */
11508 emit_cmpi(r_X, 0);
11509 diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
11510 index d45a2c4..3c05a78 100644
11511 --- a/arch/tile/Kconfig
11512 +++ b/arch/tile/Kconfig
11513 @@ -185,6 +185,7 @@ source "kernel/Kconfig.hz"
11514
11515 config KEXEC
11516 bool "kexec system call"
11517 + depends on !GRKERNSEC_KMEM
11518 ---help---
11519 kexec is a system call that implements the ability to shutdown your
11520 current kernel, and to start another kernel. It is like a reboot
11521 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11522 index ad220ee..2f537b3 100644
11523 --- a/arch/tile/include/asm/atomic_64.h
11524 +++ b/arch/tile/include/asm/atomic_64.h
11525 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11526
11527 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11528
11529 +#define atomic64_read_unchecked(v) atomic64_read(v)
11530 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11531 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11532 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11533 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11534 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11535 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11536 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11537 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11538 +
11539 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11540 #define smp_mb__before_atomic_dec() smp_mb()
11541 #define smp_mb__after_atomic_dec() smp_mb()
11542 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11543 index 6160761..00cac88 100644
11544 --- a/arch/tile/include/asm/cache.h
11545 +++ b/arch/tile/include/asm/cache.h
11546 @@ -15,11 +15,12 @@
11547 #ifndef _ASM_TILE_CACHE_H
11548 #define _ASM_TILE_CACHE_H
11549
11550 +#include <linux/const.h>
11551 #include <arch/chip.h>
11552
11553 /* bytes per L1 data cache line */
11554 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11555 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11556 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11557
11558 /* bytes per L2 cache line */
11559 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11560 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11561 index b6cde32..c0cb736 100644
11562 --- a/arch/tile/include/asm/uaccess.h
11563 +++ b/arch/tile/include/asm/uaccess.h
11564 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11565 const void __user *from,
11566 unsigned long n)
11567 {
11568 - int sz = __compiletime_object_size(to);
11569 + size_t sz = __compiletime_object_size(to);
11570
11571 - if (likely(sz == -1 || sz >= n))
11572 + if (likely(sz == (size_t)-1 || sz >= n))
11573 n = _copy_from_user(to, from, n);
11574 else
11575 copy_from_user_overflow();
11576 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11577 index 0cb3bba..7338b2d 100644
11578 --- a/arch/tile/mm/hugetlbpage.c
11579 +++ b/arch/tile/mm/hugetlbpage.c
11580 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11581 info.high_limit = TASK_SIZE;
11582 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11583 info.align_offset = 0;
11584 + info.threadstack_offset = 0;
11585 return vm_unmapped_area(&info);
11586 }
11587
11588 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11589 info.high_limit = current->mm->mmap_base;
11590 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11591 info.align_offset = 0;
11592 + info.threadstack_offset = 0;
11593 addr = vm_unmapped_area(&info);
11594
11595 /*
11596 diff --git a/arch/um/Makefile b/arch/um/Makefile
11597 index 133f7de..1d6f2f1 100644
11598 --- a/arch/um/Makefile
11599 +++ b/arch/um/Makefile
11600 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11601 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11602 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11603
11604 +ifdef CONSTIFY_PLUGIN
11605 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11606 +endif
11607 +
11608 #This will adjust *FLAGS accordingly to the platform.
11609 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11610
11611 diff --git a/arch/um/defconfig b/arch/um/defconfig
11612 index 2665e6b..3e3822b 100644
11613 --- a/arch/um/defconfig
11614 +++ b/arch/um/defconfig
11615 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11616 CONFIG_X86_L1_CACHE_SHIFT=5
11617 CONFIG_X86_XADD=y
11618 CONFIG_X86_PPRO_FENCE=y
11619 -CONFIG_X86_WP_WORKS_OK=y
11620 CONFIG_X86_INVLPG=y
11621 CONFIG_X86_BSWAP=y
11622 CONFIG_X86_POPAD_OK=y
11623 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11624 index 19e1bdd..3665b77 100644
11625 --- a/arch/um/include/asm/cache.h
11626 +++ b/arch/um/include/asm/cache.h
11627 @@ -1,6 +1,7 @@
11628 #ifndef __UM_CACHE_H
11629 #define __UM_CACHE_H
11630
11631 +#include <linux/const.h>
11632
11633 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11634 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11635 @@ -12,6 +13,6 @@
11636 # define L1_CACHE_SHIFT 5
11637 #endif
11638
11639 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11640 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11641
11642 #endif
11643 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11644 index 2e0a6b1..a64d0f5 100644
11645 --- a/arch/um/include/asm/kmap_types.h
11646 +++ b/arch/um/include/asm/kmap_types.h
11647 @@ -8,6 +8,6 @@
11648
11649 /* No more #include "asm/arch/kmap_types.h" ! */
11650
11651 -#define KM_TYPE_NR 14
11652 +#define KM_TYPE_NR 15
11653
11654 #endif
11655 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11656 index 5ff53d9..5850cdf 100644
11657 --- a/arch/um/include/asm/page.h
11658 +++ b/arch/um/include/asm/page.h
11659 @@ -14,6 +14,9 @@
11660 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11661 #define PAGE_MASK (~(PAGE_SIZE-1))
11662
11663 +#define ktla_ktva(addr) (addr)
11664 +#define ktva_ktla(addr) (addr)
11665 +
11666 #ifndef __ASSEMBLY__
11667
11668 struct page;
11669 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11670 index 0032f92..cd151e0 100644
11671 --- a/arch/um/include/asm/pgtable-3level.h
11672 +++ b/arch/um/include/asm/pgtable-3level.h
11673 @@ -58,6 +58,7 @@
11674 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11675 #define pud_populate(mm, pud, pmd) \
11676 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11677 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11678
11679 #ifdef CONFIG_64BIT
11680 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11681 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11682 index bbcef52..6a2a483 100644
11683 --- a/arch/um/kernel/process.c
11684 +++ b/arch/um/kernel/process.c
11685 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11686 return 2;
11687 }
11688
11689 -/*
11690 - * Only x86 and x86_64 have an arch_align_stack().
11691 - * All other arches have "#define arch_align_stack(x) (x)"
11692 - * in their asm/system.h
11693 - * As this is included in UML from asm-um/system-generic.h,
11694 - * we can use it to behave as the subarch does.
11695 - */
11696 -#ifndef arch_align_stack
11697 -unsigned long arch_align_stack(unsigned long sp)
11698 -{
11699 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11700 - sp -= get_random_int() % 8192;
11701 - return sp & ~0xf;
11702 -}
11703 -#endif
11704 -
11705 unsigned long get_wchan(struct task_struct *p)
11706 {
11707 unsigned long stack_page, sp, ip;
11708 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11709 index ad8f795..2c7eec6 100644
11710 --- a/arch/unicore32/include/asm/cache.h
11711 +++ b/arch/unicore32/include/asm/cache.h
11712 @@ -12,8 +12,10 @@
11713 #ifndef __UNICORE_CACHE_H__
11714 #define __UNICORE_CACHE_H__
11715
11716 -#define L1_CACHE_SHIFT (5)
11717 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11718 +#include <linux/const.h>
11719 +
11720 +#define L1_CACHE_SHIFT 5
11721 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11722
11723 /*
11724 * Memory returned by kmalloc() may be used for DMA, so we must make
11725 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11726 index f67e839..bfd4748 100644
11727 --- a/arch/x86/Kconfig
11728 +++ b/arch/x86/Kconfig
11729 @@ -247,7 +247,7 @@ config X86_HT
11730
11731 config X86_32_LAZY_GS
11732 def_bool y
11733 - depends on X86_32 && !CC_STACKPROTECTOR
11734 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11735
11736 config ARCH_HWEIGHT_CFLAGS
11737 string
11738 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11739
11740 config X86_MSR
11741 tristate "/dev/cpu/*/msr - Model-specific register support"
11742 + depends on !GRKERNSEC_KMEM
11743 ---help---
11744 This device gives privileged processes access to the x86
11745 Model-Specific Registers (MSRs). It is a character device with
11746 @@ -1122,7 +1123,7 @@ choice
11747
11748 config NOHIGHMEM
11749 bool "off"
11750 - depends on !X86_NUMAQ
11751 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11752 ---help---
11753 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11754 However, the address space of 32-bit x86 processors is only 4
11755 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11756
11757 config HIGHMEM4G
11758 bool "4GB"
11759 - depends on !X86_NUMAQ
11760 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11761 ---help---
11762 Select this if you have a 32-bit processor and between 1 and 4
11763 gigabytes of physical RAM.
11764 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11765 hex
11766 default 0xB0000000 if VMSPLIT_3G_OPT
11767 default 0x80000000 if VMSPLIT_2G
11768 - default 0x78000000 if VMSPLIT_2G_OPT
11769 + default 0x70000000 if VMSPLIT_2G_OPT
11770 default 0x40000000 if VMSPLIT_1G
11771 default 0xC0000000
11772 depends on X86_32
11773 @@ -1614,6 +1615,7 @@ config SECCOMP
11774
11775 config CC_STACKPROTECTOR
11776 bool "Enable -fstack-protector buffer overflow detection"
11777 + depends on X86_64 || !PAX_MEMORY_UDEREF
11778 ---help---
11779 This option turns on the -fstack-protector GCC feature. This
11780 feature puts, at the beginning of functions, a canary value on
11781 @@ -1632,6 +1634,7 @@ source kernel/Kconfig.hz
11782
11783 config KEXEC
11784 bool "kexec system call"
11785 + depends on !GRKERNSEC_KMEM
11786 ---help---
11787 kexec is a system call that implements the ability to shutdown your
11788 current kernel, and to start another kernel. It is like a reboot
11789 @@ -1733,6 +1736,8 @@ config X86_NEED_RELOCS
11790 config PHYSICAL_ALIGN
11791 hex "Alignment value to which kernel should be aligned"
11792 default "0x1000000"
11793 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11794 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11795 range 0x2000 0x1000000 if X86_32
11796 range 0x200000 0x1000000 if X86_64
11797 ---help---
11798 @@ -1812,9 +1817,10 @@ config DEBUG_HOTPLUG_CPU0
11799 If unsure, say N.
11800
11801 config COMPAT_VDSO
11802 - def_bool y
11803 + def_bool n
11804 prompt "Compat VDSO support"
11805 depends on X86_32 || IA32_EMULATION
11806 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11807 ---help---
11808 Map the 32-bit VDSO to the predictable old-style address too.
11809
11810 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11811 index c026cca..14657ae 100644
11812 --- a/arch/x86/Kconfig.cpu
11813 +++ b/arch/x86/Kconfig.cpu
11814 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11815
11816 config X86_F00F_BUG
11817 def_bool y
11818 - depends on M586MMX || M586TSC || M586 || M486
11819 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11820
11821 config X86_INVD_BUG
11822 def_bool y
11823 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11824
11825 config X86_ALIGNMENT_16
11826 def_bool y
11827 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11828 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11829
11830 config X86_INTEL_USERCOPY
11831 def_bool y
11832 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11833 # generates cmov.
11834 config X86_CMOV
11835 def_bool y
11836 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11837 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11838
11839 config X86_MINIMUM_CPU_FAMILY
11840 int
11841 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11842 index 78d91af..8ceb94b 100644
11843 --- a/arch/x86/Kconfig.debug
11844 +++ b/arch/x86/Kconfig.debug
11845 @@ -74,7 +74,7 @@ config X86_PTDUMP
11846 config DEBUG_RODATA
11847 bool "Write protect kernel read-only data structures"
11848 default y
11849 - depends on DEBUG_KERNEL
11850 + depends on DEBUG_KERNEL && BROKEN
11851 ---help---
11852 Mark the kernel read-only data as write-protected in the pagetables,
11853 in order to catch accidental (and incorrect) writes to such const
11854 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11855
11856 config DEBUG_SET_MODULE_RONX
11857 bool "Set loadable kernel module data as NX and text as RO"
11858 - depends on MODULES
11859 + depends on MODULES && BROKEN
11860 ---help---
11861 This option helps catch unintended modifications to loadable
11862 kernel module's text and read-only data. It also prevents execution
11863 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11864 index 57d0215..b4373fb 100644
11865 --- a/arch/x86/Makefile
11866 +++ b/arch/x86/Makefile
11867 @@ -49,14 +49,12 @@ ifeq ($(CONFIG_X86_32),y)
11868 # CPU-specific tuning. Anything which can be shared with UML should go here.
11869 include $(srctree)/arch/x86/Makefile_32.cpu
11870 KBUILD_CFLAGS += $(cflags-y)
11871 -
11872 - # temporary until string.h is fixed
11873 - KBUILD_CFLAGS += -ffreestanding
11874 else
11875 BITS := 64
11876 UTS_MACHINE := x86_64
11877 CHECKFLAGS += -D__x86_64__ -m64
11878
11879 + biarch := $(call cc-option,-m64)
11880 KBUILD_AFLAGS += -m64
11881 KBUILD_CFLAGS += -m64
11882
11883 @@ -89,6 +87,9 @@ else
11884 KBUILD_CFLAGS += -maccumulate-outgoing-args
11885 endif
11886
11887 +# temporary until string.h is fixed
11888 +KBUILD_CFLAGS += -ffreestanding
11889 +
11890 ifdef CONFIG_CC_STACKPROTECTOR
11891 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11892 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11893 @@ -247,3 +248,12 @@ define archhelp
11894 echo ' FDINITRD=file initrd for the booted kernel'
11895 echo ' kvmconfig - Enable additional options for guest kernel support'
11896 endef
11897 +
11898 +define OLD_LD
11899 +
11900 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11901 +*** Please upgrade your binutils to 2.18 or newer
11902 +endef
11903 +
11904 +archprepare:
11905 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11906 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11907 index 6cf0111..f2e2398 100644
11908 --- a/arch/x86/boot/Makefile
11909 +++ b/arch/x86/boot/Makefile
11910 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
11911 $(call cc-option, -fno-unit-at-a-time)) \
11912 $(call cc-option, -fno-stack-protector) \
11913 $(call cc-option, -mpreferred-stack-boundary=2)
11914 +ifdef CONSTIFY_PLUGIN
11915 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11916 +endif
11917 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11918 GCOV_PROFILE := n
11919
11920 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11921 index 878e4b9..20537ab 100644
11922 --- a/arch/x86/boot/bitops.h
11923 +++ b/arch/x86/boot/bitops.h
11924 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11925 u8 v;
11926 const u32 *p = (const u32 *)addr;
11927
11928 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11929 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11930 return v;
11931 }
11932
11933 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11934
11935 static inline void set_bit(int nr, void *addr)
11936 {
11937 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11938 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11939 }
11940
11941 #endif /* BOOT_BITOPS_H */
11942 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11943 index ef72bae..353a184 100644
11944 --- a/arch/x86/boot/boot.h
11945 +++ b/arch/x86/boot/boot.h
11946 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11947 static inline u16 ds(void)
11948 {
11949 u16 seg;
11950 - asm("movw %%ds,%0" : "=rm" (seg));
11951 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11952 return seg;
11953 }
11954
11955 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11956 static inline int memcmp(const void *s1, const void *s2, size_t len)
11957 {
11958 u8 diff;
11959 - asm("repe; cmpsb; setnz %0"
11960 + asm volatile("repe; cmpsb; setnz %0"
11961 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11962 return diff;
11963 }
11964 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11965 index c8a6792..2402765 100644
11966 --- a/arch/x86/boot/compressed/Makefile
11967 +++ b/arch/x86/boot/compressed/Makefile
11968 @@ -16,6 +16,9 @@ KBUILD_CFLAGS += $(cflags-y)
11969 KBUILD_CFLAGS += -mno-mmx -mno-sse
11970 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11971 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11972 +ifdef CONSTIFY_PLUGIN
11973 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11974 +endif
11975
11976 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11977 GCOV_PROFILE := n
11978 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11979 index b7388a4..03844ec 100644
11980 --- a/arch/x86/boot/compressed/eboot.c
11981 +++ b/arch/x86/boot/compressed/eboot.c
11982 @@ -150,7 +150,6 @@ again:
11983 *addr = max_addr;
11984 }
11985
11986 -free_pool:
11987 efi_call_phys1(sys_table->boottime->free_pool, map);
11988
11989 fail:
11990 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11991 if (i == map_size / desc_size)
11992 status = EFI_NOT_FOUND;
11993
11994 -free_pool:
11995 efi_call_phys1(sys_table->boottime->free_pool, map);
11996 fail:
11997 return status;
11998 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11999 index a53440e..c3dbf1e 100644
12000 --- a/arch/x86/boot/compressed/efi_stub_32.S
12001 +++ b/arch/x86/boot/compressed/efi_stub_32.S
12002 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
12003 * parameter 2, ..., param n. To make things easy, we save the return
12004 * address of efi_call_phys in a global variable.
12005 */
12006 - popl %ecx
12007 - movl %ecx, saved_return_addr(%edx)
12008 - /* get the function pointer into ECX*/
12009 - popl %ecx
12010 - movl %ecx, efi_rt_function_ptr(%edx)
12011 + popl saved_return_addr(%edx)
12012 + popl efi_rt_function_ptr(%edx)
12013
12014 /*
12015 * 3. Call the physical function.
12016 */
12017 - call *%ecx
12018 + call *efi_rt_function_ptr(%edx)
12019
12020 /*
12021 * 4. Balance the stack. And because EAX contain the return value,
12022 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
12023 1: popl %edx
12024 subl $1b, %edx
12025
12026 - movl efi_rt_function_ptr(%edx), %ecx
12027 - pushl %ecx
12028 + pushl efi_rt_function_ptr(%edx)
12029
12030 /*
12031 * 10. Push the saved return address onto the stack and return.
12032 */
12033 - movl saved_return_addr(%edx), %ecx
12034 - pushl %ecx
12035 - ret
12036 + jmpl *saved_return_addr(%edx)
12037 ENDPROC(efi_call_phys)
12038 .previous
12039
12040 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
12041 index 5d6f689..9d06730 100644
12042 --- a/arch/x86/boot/compressed/head_32.S
12043 +++ b/arch/x86/boot/compressed/head_32.S
12044 @@ -118,7 +118,7 @@ preferred_addr:
12045 notl %eax
12046 andl %eax, %ebx
12047 #else
12048 - movl $LOAD_PHYSICAL_ADDR, %ebx
12049 + movl $____LOAD_PHYSICAL_ADDR, %ebx
12050 #endif
12051
12052 /* Target address to relocate to for decompression */
12053 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
12054 index c337422..2c5be72 100644
12055 --- a/arch/x86/boot/compressed/head_64.S
12056 +++ b/arch/x86/boot/compressed/head_64.S
12057 @@ -95,7 +95,7 @@ ENTRY(startup_32)
12058 notl %eax
12059 andl %eax, %ebx
12060 #else
12061 - movl $LOAD_PHYSICAL_ADDR, %ebx
12062 + movl $____LOAD_PHYSICAL_ADDR, %ebx
12063 #endif
12064
12065 /* Target address to relocate to for decompression */
12066 @@ -270,7 +270,7 @@ preferred_addr:
12067 notq %rax
12068 andq %rax, %rbp
12069 #else
12070 - movq $LOAD_PHYSICAL_ADDR, %rbp
12071 + movq $____LOAD_PHYSICAL_ADDR, %rbp
12072 #endif
12073
12074 /* Target address to relocate to for decompression */
12075 @@ -362,8 +362,8 @@ gdt:
12076 .long gdt
12077 .word 0
12078 .quad 0x0000000000000000 /* NULL descriptor */
12079 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
12080 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
12081 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
12082 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
12083 .quad 0x0080890000000000 /* TS descriptor */
12084 .quad 0x0000000000000000 /* TS continued */
12085 gdt_end:
12086 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
12087 index 434f077..b6b4b38 100644
12088 --- a/arch/x86/boot/compressed/misc.c
12089 +++ b/arch/x86/boot/compressed/misc.c
12090 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
12091 * Calculate the delta between where vmlinux was linked to load
12092 * and where it was actually loaded.
12093 */
12094 - delta = min_addr - LOAD_PHYSICAL_ADDR;
12095 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
12096 if (!delta) {
12097 debug_putstr("No relocation needed... ");
12098 return;
12099 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
12100 case PT_LOAD:
12101 #ifdef CONFIG_RELOCATABLE
12102 dest = output;
12103 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
12104 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
12105 #else
12106 dest = (void *)(phdr->p_paddr);
12107 #endif
12108 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
12109 error("Destination address too large");
12110 #endif
12111 #ifndef CONFIG_RELOCATABLE
12112 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
12113 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
12114 error("Wrong destination address");
12115 #endif
12116
12117 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
12118 index 4d3ff03..e4972ff 100644
12119 --- a/arch/x86/boot/cpucheck.c
12120 +++ b/arch/x86/boot/cpucheck.c
12121 @@ -74,7 +74,7 @@ static int has_fpu(void)
12122 u16 fcw = -1, fsw = -1;
12123 u32 cr0;
12124
12125 - asm("movl %%cr0,%0" : "=r" (cr0));
12126 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
12127 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
12128 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
12129 asm volatile("movl %0,%%cr0" : : "r" (cr0));
12130 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
12131 {
12132 u32 f0, f1;
12133
12134 - asm("pushfl ; "
12135 + asm volatile("pushfl ; "
12136 "pushfl ; "
12137 "popl %0 ; "
12138 "movl %0,%1 ; "
12139 @@ -115,7 +115,7 @@ static void get_flags(void)
12140 set_bit(X86_FEATURE_FPU, cpu.flags);
12141
12142 if (has_eflag(X86_EFLAGS_ID)) {
12143 - asm("cpuid"
12144 + asm volatile("cpuid"
12145 : "=a" (max_intel_level),
12146 "=b" (cpu_vendor[0]),
12147 "=d" (cpu_vendor[1]),
12148 @@ -124,7 +124,7 @@ static void get_flags(void)
12149
12150 if (max_intel_level >= 0x00000001 &&
12151 max_intel_level <= 0x0000ffff) {
12152 - asm("cpuid"
12153 + asm volatile("cpuid"
12154 : "=a" (tfms),
12155 "=c" (cpu.flags[4]),
12156 "=d" (cpu.flags[0])
12157 @@ -136,7 +136,7 @@ static void get_flags(void)
12158 cpu.model += ((tfms >> 16) & 0xf) << 4;
12159 }
12160
12161 - asm("cpuid"
12162 + asm volatile("cpuid"
12163 : "=a" (max_amd_level)
12164 : "a" (0x80000000)
12165 : "ebx", "ecx", "edx");
12166 @@ -144,7 +144,7 @@ static void get_flags(void)
12167 if (max_amd_level >= 0x80000001 &&
12168 max_amd_level <= 0x8000ffff) {
12169 u32 eax = 0x80000001;
12170 - asm("cpuid"
12171 + asm volatile("cpuid"
12172 : "+a" (eax),
12173 "=c" (cpu.flags[6]),
12174 "=d" (cpu.flags[1])
12175 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12176 u32 ecx = MSR_K7_HWCR;
12177 u32 eax, edx;
12178
12179 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12180 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12181 eax &= ~(1 << 15);
12182 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12183 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12184
12185 get_flags(); /* Make sure it really did something */
12186 err = check_flags();
12187 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12188 u32 ecx = MSR_VIA_FCR;
12189 u32 eax, edx;
12190
12191 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12192 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12193 eax |= (1<<1)|(1<<7);
12194 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12195 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12196
12197 set_bit(X86_FEATURE_CX8, cpu.flags);
12198 err = check_flags();
12199 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12200 u32 eax, edx;
12201 u32 level = 1;
12202
12203 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12204 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12205 - asm("cpuid"
12206 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12207 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12208 + asm volatile("cpuid"
12209 : "+a" (level), "=d" (cpu.flags[0])
12210 : : "ecx", "ebx");
12211 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12212 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12213
12214 err = check_flags();
12215 }
12216 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12217 index 9ec06a1..2c25e79 100644
12218 --- a/arch/x86/boot/header.S
12219 +++ b/arch/x86/boot/header.S
12220 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12221 # single linked list of
12222 # struct setup_data
12223
12224 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12225 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12226
12227 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12228 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12229 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12230 +#else
12231 #define VO_INIT_SIZE (VO__end - VO__text)
12232 +#endif
12233 #if ZO_INIT_SIZE > VO_INIT_SIZE
12234 #define INIT_SIZE ZO_INIT_SIZE
12235 #else
12236 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12237 index db75d07..8e6d0af 100644
12238 --- a/arch/x86/boot/memory.c
12239 +++ b/arch/x86/boot/memory.c
12240 @@ -19,7 +19,7 @@
12241
12242 static int detect_memory_e820(void)
12243 {
12244 - int count = 0;
12245 + unsigned int count = 0;
12246 struct biosregs ireg, oreg;
12247 struct e820entry *desc = boot_params.e820_map;
12248 static struct e820entry buf; /* static so it is zeroed */
12249 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12250 index 11e8c6e..fdbb1ed 100644
12251 --- a/arch/x86/boot/video-vesa.c
12252 +++ b/arch/x86/boot/video-vesa.c
12253 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12254
12255 boot_params.screen_info.vesapm_seg = oreg.es;
12256 boot_params.screen_info.vesapm_off = oreg.di;
12257 + boot_params.screen_info.vesapm_size = oreg.cx;
12258 }
12259
12260 /*
12261 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12262 index 43eda28..5ab5fdb 100644
12263 --- a/arch/x86/boot/video.c
12264 +++ b/arch/x86/boot/video.c
12265 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12266 static unsigned int get_entry(void)
12267 {
12268 char entry_buf[4];
12269 - int i, len = 0;
12270 + unsigned int i, len = 0;
12271 int key;
12272 unsigned int v;
12273
12274 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12275 index 9105655..41779c1 100644
12276 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12277 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12278 @@ -8,6 +8,8 @@
12279 * including this sentence is retained in full.
12280 */
12281
12282 +#include <asm/alternative-asm.h>
12283 +
12284 .extern crypto_ft_tab
12285 .extern crypto_it_tab
12286 .extern crypto_fl_tab
12287 @@ -70,6 +72,8 @@
12288 je B192; \
12289 leaq 32(r9),r9;
12290
12291 +#define ret pax_force_retaddr; ret
12292 +
12293 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12294 movq r1,r2; \
12295 movq r3,r4; \
12296 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12297 index 477e9d7..c92c7d8 100644
12298 --- a/arch/x86/crypto/aesni-intel_asm.S
12299 +++ b/arch/x86/crypto/aesni-intel_asm.S
12300 @@ -31,6 +31,7 @@
12301
12302 #include <linux/linkage.h>
12303 #include <asm/inst.h>
12304 +#include <asm/alternative-asm.h>
12305
12306 #ifdef __x86_64__
12307 .data
12308 @@ -205,7 +206,7 @@ enc: .octa 0x2
12309 * num_initial_blocks = b mod 4
12310 * encrypt the initial num_initial_blocks blocks and apply ghash on
12311 * the ciphertext
12312 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12313 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12314 * are clobbered
12315 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12316 */
12317 @@ -214,8 +215,8 @@ enc: .octa 0x2
12318 .macro INITIAL_BLOCKS_DEC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12319 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12320 mov arg7, %r10 # %r10 = AAD
12321 - mov arg8, %r12 # %r12 = aadLen
12322 - mov %r12, %r11
12323 + mov arg8, %r15 # %r15 = aadLen
12324 + mov %r15, %r11
12325 pxor %xmm\i, %xmm\i
12326 _get_AAD_loop\num_initial_blocks\operation:
12327 movd (%r10), \TMP1
12328 @@ -223,15 +224,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12329 psrldq $4, %xmm\i
12330 pxor \TMP1, %xmm\i
12331 add $4, %r10
12332 - sub $4, %r12
12333 + sub $4, %r15
12334 jne _get_AAD_loop\num_initial_blocks\operation
12335 cmp $16, %r11
12336 je _get_AAD_loop2_done\num_initial_blocks\operation
12337 - mov $16, %r12
12338 + mov $16, %r15
12339 _get_AAD_loop2\num_initial_blocks\operation:
12340 psrldq $4, %xmm\i
12341 - sub $4, %r12
12342 - cmp %r11, %r12
12343 + sub $4, %r15
12344 + cmp %r11, %r15
12345 jne _get_AAD_loop2\num_initial_blocks\operation
12346 _get_AAD_loop2_done\num_initial_blocks\operation:
12347 movdqa SHUF_MASK(%rip), %xmm14
12348 @@ -443,7 +444,7 @@ _initial_blocks_done\num_initial_blocks\operation:
12349 * num_initial_blocks = b mod 4
12350 * encrypt the initial num_initial_blocks blocks and apply ghash on
12351 * the ciphertext
12352 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12353 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12354 * are clobbered
12355 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12356 */
12357 @@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
12358 .macro INITIAL_BLOCKS_ENC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12359 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12360 mov arg7, %r10 # %r10 = AAD
12361 - mov arg8, %r12 # %r12 = aadLen
12362 - mov %r12, %r11
12363 + mov arg8, %r15 # %r15 = aadLen
12364 + mov %r15, %r11
12365 pxor %xmm\i, %xmm\i
12366 _get_AAD_loop\num_initial_blocks\operation:
12367 movd (%r10), \TMP1
12368 @@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12369 psrldq $4, %xmm\i
12370 pxor \TMP1, %xmm\i
12371 add $4, %r10
12372 - sub $4, %r12
12373 + sub $4, %r15
12374 jne _get_AAD_loop\num_initial_blocks\operation
12375 cmp $16, %r11
12376 je _get_AAD_loop2_done\num_initial_blocks\operation
12377 - mov $16, %r12
12378 + mov $16, %r15
12379 _get_AAD_loop2\num_initial_blocks\operation:
12380 psrldq $4, %xmm\i
12381 - sub $4, %r12
12382 - cmp %r11, %r12
12383 + sub $4, %r15
12384 + cmp %r11, %r15
12385 jne _get_AAD_loop2\num_initial_blocks\operation
12386 _get_AAD_loop2_done\num_initial_blocks\operation:
12387 movdqa SHUF_MASK(%rip), %xmm14
12388 @@ -1269,7 +1270,7 @@ TMP7 XMM1 XMM2 XMM3 XMM4 XMMDst
12389 *
12390 *****************************************************************************/
12391 ENTRY(aesni_gcm_dec)
12392 - push %r12
12393 + push %r15
12394 push %r13
12395 push %r14
12396 mov %rsp, %r14
12397 @@ -1279,8 +1280,8 @@ ENTRY(aesni_gcm_dec)
12398 */
12399 sub $VARIABLE_OFFSET, %rsp
12400 and $~63, %rsp # align rsp to 64 bytes
12401 - mov %arg6, %r12
12402 - movdqu (%r12), %xmm13 # %xmm13 = HashKey
12403 + mov %arg6, %r15
12404 + movdqu (%r15), %xmm13 # %xmm13 = HashKey
12405 movdqa SHUF_MASK(%rip), %xmm2
12406 PSHUFB_XMM %xmm2, %xmm13
12407
12408 @@ -1308,10 +1309,10 @@ ENTRY(aesni_gcm_dec)
12409 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
12410 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
12411 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
12412 - mov %r13, %r12
12413 - and $(3<<4), %r12
12414 + mov %r13, %r15
12415 + and $(3<<4), %r15
12416 jz _initial_num_blocks_is_0_decrypt
12417 - cmp $(2<<4), %r12
12418 + cmp $(2<<4), %r15
12419 jb _initial_num_blocks_is_1_decrypt
12420 je _initial_num_blocks_is_2_decrypt
12421 _initial_num_blocks_is_3_decrypt:
12422 @@ -1361,16 +1362,16 @@ _zero_cipher_left_decrypt:
12423 sub $16, %r11
12424 add %r13, %r11
12425 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
12426 - lea SHIFT_MASK+16(%rip), %r12
12427 - sub %r13, %r12
12428 + lea SHIFT_MASK+16(%rip), %r15
12429 + sub %r13, %r15
12430 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
12431 # (%r13 is the number of bytes in plaintext mod 16)
12432 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12433 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12434 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
12435
12436 movdqa %xmm1, %xmm2
12437 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
12438 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12439 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12440 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
12441 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
12442 pand %xmm1, %xmm2
12443 @@ -1399,9 +1400,9 @@ _less_than_8_bytes_left_decrypt:
12444 sub $1, %r13
12445 jne _less_than_8_bytes_left_decrypt
12446 _multiple_of_16_bytes_decrypt:
12447 - mov arg8, %r12 # %r13 = aadLen (number of bytes)
12448 - shl $3, %r12 # convert into number of bits
12449 - movd %r12d, %xmm15 # len(A) in %xmm15
12450 + mov arg8, %r15 # %r13 = aadLen (number of bytes)
12451 + shl $3, %r15 # convert into number of bits
12452 + movd %r15d, %xmm15 # len(A) in %xmm15
12453 shl $3, %arg4 # len(C) in bits (*128)
12454 MOVQ_R64_XMM %arg4, %xmm1
12455 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12456 @@ -1440,7 +1441,8 @@ _return_T_done_decrypt:
12457 mov %r14, %rsp
12458 pop %r14
12459 pop %r13
12460 - pop %r12
12461 + pop %r15
12462 + pax_force_retaddr
12463 ret
12464 ENDPROC(aesni_gcm_dec)
12465
12466 @@ -1529,7 +1531,7 @@ ENDPROC(aesni_gcm_dec)
12467 * poly = x^128 + x^127 + x^126 + x^121 + 1
12468 ***************************************************************************/
12469 ENTRY(aesni_gcm_enc)
12470 - push %r12
12471 + push %r15
12472 push %r13
12473 push %r14
12474 mov %rsp, %r14
12475 @@ -1539,8 +1541,8 @@ ENTRY(aesni_gcm_enc)
12476 #
12477 sub $VARIABLE_OFFSET, %rsp
12478 and $~63, %rsp
12479 - mov %arg6, %r12
12480 - movdqu (%r12), %xmm13
12481 + mov %arg6, %r15
12482 + movdqu (%r15), %xmm13
12483 movdqa SHUF_MASK(%rip), %xmm2
12484 PSHUFB_XMM %xmm2, %xmm13
12485
12486 @@ -1564,13 +1566,13 @@ ENTRY(aesni_gcm_enc)
12487 movdqa %xmm13, HashKey(%rsp)
12488 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
12489 and $-16, %r13
12490 - mov %r13, %r12
12491 + mov %r13, %r15
12492
12493 # Encrypt first few blocks
12494
12495 - and $(3<<4), %r12
12496 + and $(3<<4), %r15
12497 jz _initial_num_blocks_is_0_encrypt
12498 - cmp $(2<<4), %r12
12499 + cmp $(2<<4), %r15
12500 jb _initial_num_blocks_is_1_encrypt
12501 je _initial_num_blocks_is_2_encrypt
12502 _initial_num_blocks_is_3_encrypt:
12503 @@ -1623,14 +1625,14 @@ _zero_cipher_left_encrypt:
12504 sub $16, %r11
12505 add %r13, %r11
12506 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
12507 - lea SHIFT_MASK+16(%rip), %r12
12508 - sub %r13, %r12
12509 + lea SHIFT_MASK+16(%rip), %r15
12510 + sub %r13, %r15
12511 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
12512 # (%r13 is the number of bytes in plaintext mod 16)
12513 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12514 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12515 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
12516 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
12517 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12518 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12519 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
12520 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
12521 movdqa SHUF_MASK(%rip), %xmm10
12522 @@ -1663,9 +1665,9 @@ _less_than_8_bytes_left_encrypt:
12523 sub $1, %r13
12524 jne _less_than_8_bytes_left_encrypt
12525 _multiple_of_16_bytes_encrypt:
12526 - mov arg8, %r12 # %r12 = addLen (number of bytes)
12527 - shl $3, %r12
12528 - movd %r12d, %xmm15 # len(A) in %xmm15
12529 + mov arg8, %r15 # %r15 = addLen (number of bytes)
12530 + shl $3, %r15
12531 + movd %r15d, %xmm15 # len(A) in %xmm15
12532 shl $3, %arg4 # len(C) in bits (*128)
12533 MOVQ_R64_XMM %arg4, %xmm1
12534 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12535 @@ -1704,7 +1706,8 @@ _return_T_done_encrypt:
12536 mov %r14, %rsp
12537 pop %r14
12538 pop %r13
12539 - pop %r12
12540 + pop %r15
12541 + pax_force_retaddr
12542 ret
12543 ENDPROC(aesni_gcm_enc)
12544
12545 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12546 pxor %xmm1, %xmm0
12547 movaps %xmm0, (TKEYP)
12548 add $0x10, TKEYP
12549 + pax_force_retaddr
12550 ret
12551 ENDPROC(_key_expansion_128)
12552 ENDPROC(_key_expansion_256a)
12553 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12554 shufps $0b01001110, %xmm2, %xmm1
12555 movaps %xmm1, 0x10(TKEYP)
12556 add $0x20, TKEYP
12557 + pax_force_retaddr
12558 ret
12559 ENDPROC(_key_expansion_192a)
12560
12561 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12562
12563 movaps %xmm0, (TKEYP)
12564 add $0x10, TKEYP
12565 + pax_force_retaddr
12566 ret
12567 ENDPROC(_key_expansion_192b)
12568
12569 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12570 pxor %xmm1, %xmm2
12571 movaps %xmm2, (TKEYP)
12572 add $0x10, TKEYP
12573 + pax_force_retaddr
12574 ret
12575 ENDPROC(_key_expansion_256b)
12576
12577 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12578 #ifndef __x86_64__
12579 popl KEYP
12580 #endif
12581 + pax_force_retaddr
12582 ret
12583 ENDPROC(aesni_set_key)
12584
12585 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12586 popl KLEN
12587 popl KEYP
12588 #endif
12589 + pax_force_retaddr
12590 ret
12591 ENDPROC(aesni_enc)
12592
12593 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12594 AESENC KEY STATE
12595 movaps 0x70(TKEYP), KEY
12596 AESENCLAST KEY STATE
12597 + pax_force_retaddr
12598 ret
12599 ENDPROC(_aesni_enc1)
12600
12601 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12602 AESENCLAST KEY STATE2
12603 AESENCLAST KEY STATE3
12604 AESENCLAST KEY STATE4
12605 + pax_force_retaddr
12606 ret
12607 ENDPROC(_aesni_enc4)
12608
12609 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12610 popl KLEN
12611 popl KEYP
12612 #endif
12613 + pax_force_retaddr
12614 ret
12615 ENDPROC(aesni_dec)
12616
12617 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12618 AESDEC KEY STATE
12619 movaps 0x70(TKEYP), KEY
12620 AESDECLAST KEY STATE
12621 + pax_force_retaddr
12622 ret
12623 ENDPROC(_aesni_dec1)
12624
12625 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12626 AESDECLAST KEY STATE2
12627 AESDECLAST KEY STATE3
12628 AESDECLAST KEY STATE4
12629 + pax_force_retaddr
12630 ret
12631 ENDPROC(_aesni_dec4)
12632
12633 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12634 popl KEYP
12635 popl LEN
12636 #endif
12637 + pax_force_retaddr
12638 ret
12639 ENDPROC(aesni_ecb_enc)
12640
12641 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12642 popl KEYP
12643 popl LEN
12644 #endif
12645 + pax_force_retaddr
12646 ret
12647 ENDPROC(aesni_ecb_dec)
12648
12649 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12650 popl LEN
12651 popl IVP
12652 #endif
12653 + pax_force_retaddr
12654 ret
12655 ENDPROC(aesni_cbc_enc)
12656
12657 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12658 popl LEN
12659 popl IVP
12660 #endif
12661 + pax_force_retaddr
12662 ret
12663 ENDPROC(aesni_cbc_dec)
12664
12665 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12666 mov $1, TCTR_LOW
12667 MOVQ_R64_XMM TCTR_LOW INC
12668 MOVQ_R64_XMM CTR TCTR_LOW
12669 + pax_force_retaddr
12670 ret
12671 ENDPROC(_aesni_inc_init)
12672
12673 @@ -2579,6 +2598,7 @@ _aesni_inc:
12674 .Linc_low:
12675 movaps CTR, IV
12676 PSHUFB_XMM BSWAP_MASK IV
12677 + pax_force_retaddr
12678 ret
12679 ENDPROC(_aesni_inc)
12680
12681 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12682 .Lctr_enc_ret:
12683 movups IV, (IVP)
12684 .Lctr_enc_just_ret:
12685 + pax_force_retaddr
12686 ret
12687 ENDPROC(aesni_ctr_enc)
12688
12689 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12690 pxor INC, STATE4
12691 movdqu STATE4, 0x70(OUTP)
12692
12693 + pax_force_retaddr
12694 ret
12695 ENDPROC(aesni_xts_crypt8)
12696
12697 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12698 index 246c670..466e2d6 100644
12699 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12700 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12701 @@ -21,6 +21,7 @@
12702 */
12703
12704 #include <linux/linkage.h>
12705 +#include <asm/alternative-asm.h>
12706
12707 .file "blowfish-x86_64-asm.S"
12708 .text
12709 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12710 jnz .L__enc_xor;
12711
12712 write_block();
12713 + pax_force_retaddr
12714 ret;
12715 .L__enc_xor:
12716 xor_block();
12717 + pax_force_retaddr
12718 ret;
12719 ENDPROC(__blowfish_enc_blk)
12720
12721 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12722
12723 movq %r11, %rbp;
12724
12725 + pax_force_retaddr
12726 ret;
12727 ENDPROC(blowfish_dec_blk)
12728
12729 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12730
12731 popq %rbx;
12732 popq %rbp;
12733 + pax_force_retaddr
12734 ret;
12735
12736 .L__enc_xor4:
12737 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12738
12739 popq %rbx;
12740 popq %rbp;
12741 + pax_force_retaddr
12742 ret;
12743 ENDPROC(__blowfish_enc_blk_4way)
12744
12745 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12746 popq %rbx;
12747 popq %rbp;
12748
12749 + pax_force_retaddr
12750 ret;
12751 ENDPROC(blowfish_dec_blk_4way)
12752 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12753 index ce71f92..1dce7ec 100644
12754 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12755 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12756 @@ -16,6 +16,7 @@
12757 */
12758
12759 #include <linux/linkage.h>
12760 +#include <asm/alternative-asm.h>
12761
12762 #define CAMELLIA_TABLE_BYTE_LEN 272
12763
12764 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12765 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12766 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12767 %rcx, (%r9));
12768 + pax_force_retaddr
12769 ret;
12770 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12771
12772 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12773 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12774 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12775 %rax, (%r9));
12776 + pax_force_retaddr
12777 ret;
12778 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12779
12780 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12781 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12782 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12783
12784 + pax_force_retaddr
12785 ret;
12786
12787 .align 8
12788 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12789 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12790 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12791
12792 + pax_force_retaddr
12793 ret;
12794
12795 .align 8
12796 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12797 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12798 %xmm8, %rsi);
12799
12800 + pax_force_retaddr
12801 ret;
12802 ENDPROC(camellia_ecb_enc_16way)
12803
12804 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12805 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12806 %xmm8, %rsi);
12807
12808 + pax_force_retaddr
12809 ret;
12810 ENDPROC(camellia_ecb_dec_16way)
12811
12812 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12813 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12814 %xmm8, %rsi);
12815
12816 + pax_force_retaddr
12817 ret;
12818 ENDPROC(camellia_cbc_dec_16way)
12819
12820 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12821 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12822 %xmm8, %rsi);
12823
12824 + pax_force_retaddr
12825 ret;
12826 ENDPROC(camellia_ctr_16way)
12827
12828 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12829 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12830 %xmm8, %rsi);
12831
12832 + pax_force_retaddr
12833 ret;
12834 ENDPROC(camellia_xts_crypt_16way)
12835
12836 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12837 index 0e0b886..5a3123c 100644
12838 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12839 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12840 @@ -11,6 +11,7 @@
12841 */
12842
12843 #include <linux/linkage.h>
12844 +#include <asm/alternative-asm.h>
12845
12846 #define CAMELLIA_TABLE_BYTE_LEN 272
12847
12848 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12849 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12850 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12851 %rcx, (%r9));
12852 + pax_force_retaddr
12853 ret;
12854 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12855
12856 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12857 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12858 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12859 %rax, (%r9));
12860 + pax_force_retaddr
12861 ret;
12862 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12863
12864 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12865 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12866 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12867
12868 + pax_force_retaddr
12869 ret;
12870
12871 .align 8
12872 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12873 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12874 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12875
12876 + pax_force_retaddr
12877 ret;
12878
12879 .align 8
12880 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12881
12882 vzeroupper;
12883
12884 + pax_force_retaddr
12885 ret;
12886 ENDPROC(camellia_ecb_enc_32way)
12887
12888 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12889
12890 vzeroupper;
12891
12892 + pax_force_retaddr
12893 ret;
12894 ENDPROC(camellia_ecb_dec_32way)
12895
12896 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12897
12898 vzeroupper;
12899
12900 + pax_force_retaddr
12901 ret;
12902 ENDPROC(camellia_cbc_dec_32way)
12903
12904 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12905
12906 vzeroupper;
12907
12908 + pax_force_retaddr
12909 ret;
12910 ENDPROC(camellia_ctr_32way)
12911
12912 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12913
12914 vzeroupper;
12915
12916 + pax_force_retaddr
12917 ret;
12918 ENDPROC(camellia_xts_crypt_32way)
12919
12920 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12921 index 310319c..db3d7b5 100644
12922 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12923 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12924 @@ -21,6 +21,7 @@
12925 */
12926
12927 #include <linux/linkage.h>
12928 +#include <asm/alternative-asm.h>
12929
12930 .file "camellia-x86_64-asm_64.S"
12931 .text
12932 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12933 enc_outunpack(mov, RT1);
12934
12935 movq RRBP, %rbp;
12936 + pax_force_retaddr
12937 ret;
12938
12939 .L__enc_xor:
12940 enc_outunpack(xor, RT1);
12941
12942 movq RRBP, %rbp;
12943 + pax_force_retaddr
12944 ret;
12945 ENDPROC(__camellia_enc_blk)
12946
12947 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12948 dec_outunpack();
12949
12950 movq RRBP, %rbp;
12951 + pax_force_retaddr
12952 ret;
12953 ENDPROC(camellia_dec_blk)
12954
12955 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12956
12957 movq RRBP, %rbp;
12958 popq %rbx;
12959 + pax_force_retaddr
12960 ret;
12961
12962 .L__enc2_xor:
12963 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12964
12965 movq RRBP, %rbp;
12966 popq %rbx;
12967 + pax_force_retaddr
12968 ret;
12969 ENDPROC(__camellia_enc_blk_2way)
12970
12971 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12972
12973 movq RRBP, %rbp;
12974 movq RXOR, %rbx;
12975 + pax_force_retaddr
12976 ret;
12977 ENDPROC(camellia_dec_blk_2way)
12978 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12979 index c35fd5d..2d8c7db 100644
12980 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12981 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12982 @@ -24,6 +24,7 @@
12983 */
12984
12985 #include <linux/linkage.h>
12986 +#include <asm/alternative-asm.h>
12987
12988 .file "cast5-avx-x86_64-asm_64.S"
12989
12990 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12991 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12992 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12993
12994 + pax_force_retaddr
12995 ret;
12996 ENDPROC(__cast5_enc_blk16)
12997
12998 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12999 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
13000 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
13001
13002 + pax_force_retaddr
13003 ret;
13004
13005 .L__skip_dec:
13006 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
13007 vmovdqu RR4, (6*4*4)(%r11);
13008 vmovdqu RL4, (7*4*4)(%r11);
13009
13010 + pax_force_retaddr
13011 ret;
13012 ENDPROC(cast5_ecb_enc_16way)
13013
13014 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
13015 vmovdqu RR4, (6*4*4)(%r11);
13016 vmovdqu RL4, (7*4*4)(%r11);
13017
13018 + pax_force_retaddr
13019 ret;
13020 ENDPROC(cast5_ecb_dec_16way)
13021
13022 @@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
13023 * %rdx: src
13024 */
13025
13026 - pushq %r12;
13027 + pushq %r14;
13028
13029 movq %rsi, %r11;
13030 - movq %rdx, %r12;
13031 + movq %rdx, %r14;
13032
13033 vmovdqu (0*16)(%rdx), RL1;
13034 vmovdqu (1*16)(%rdx), RR1;
13035 @@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
13036 call __cast5_dec_blk16;
13037
13038 /* xor with src */
13039 - vmovq (%r12), RX;
13040 + vmovq (%r14), RX;
13041 vpshufd $0x4f, RX, RX;
13042 vpxor RX, RR1, RR1;
13043 - vpxor 0*16+8(%r12), RL1, RL1;
13044 - vpxor 1*16+8(%r12), RR2, RR2;
13045 - vpxor 2*16+8(%r12), RL2, RL2;
13046 - vpxor 3*16+8(%r12), RR3, RR3;
13047 - vpxor 4*16+8(%r12), RL3, RL3;
13048 - vpxor 5*16+8(%r12), RR4, RR4;
13049 - vpxor 6*16+8(%r12), RL4, RL4;
13050 + vpxor 0*16+8(%r14), RL1, RL1;
13051 + vpxor 1*16+8(%r14), RR2, RR2;
13052 + vpxor 2*16+8(%r14), RL2, RL2;
13053 + vpxor 3*16+8(%r14), RR3, RR3;
13054 + vpxor 4*16+8(%r14), RL3, RL3;
13055 + vpxor 5*16+8(%r14), RR4, RR4;
13056 + vpxor 6*16+8(%r14), RL4, RL4;
13057
13058 vmovdqu RR1, (0*16)(%r11);
13059 vmovdqu RL1, (1*16)(%r11);
13060 @@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
13061 vmovdqu RR4, (6*16)(%r11);
13062 vmovdqu RL4, (7*16)(%r11);
13063
13064 - popq %r12;
13065 + popq %r14;
13066
13067 + pax_force_retaddr
13068 ret;
13069 ENDPROC(cast5_cbc_dec_16way)
13070
13071 @@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
13072 * %rcx: iv (big endian, 64bit)
13073 */
13074
13075 - pushq %r12;
13076 + pushq %r14;
13077
13078 movq %rsi, %r11;
13079 - movq %rdx, %r12;
13080 + movq %rdx, %r14;
13081
13082 vpcmpeqd RTMP, RTMP, RTMP;
13083 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
13084 @@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
13085 call __cast5_enc_blk16;
13086
13087 /* dst = src ^ iv */
13088 - vpxor (0*16)(%r12), RR1, RR1;
13089 - vpxor (1*16)(%r12), RL1, RL1;
13090 - vpxor (2*16)(%r12), RR2, RR2;
13091 - vpxor (3*16)(%r12), RL2, RL2;
13092 - vpxor (4*16)(%r12), RR3, RR3;
13093 - vpxor (5*16)(%r12), RL3, RL3;
13094 - vpxor (6*16)(%r12), RR4, RR4;
13095 - vpxor (7*16)(%r12), RL4, RL4;
13096 + vpxor (0*16)(%r14), RR1, RR1;
13097 + vpxor (1*16)(%r14), RL1, RL1;
13098 + vpxor (2*16)(%r14), RR2, RR2;
13099 + vpxor (3*16)(%r14), RL2, RL2;
13100 + vpxor (4*16)(%r14), RR3, RR3;
13101 + vpxor (5*16)(%r14), RL3, RL3;
13102 + vpxor (6*16)(%r14), RR4, RR4;
13103 + vpxor (7*16)(%r14), RL4, RL4;
13104 vmovdqu RR1, (0*16)(%r11);
13105 vmovdqu RL1, (1*16)(%r11);
13106 vmovdqu RR2, (2*16)(%r11);
13107 @@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
13108 vmovdqu RR4, (6*16)(%r11);
13109 vmovdqu RL4, (7*16)(%r11);
13110
13111 - popq %r12;
13112 + popq %r14;
13113
13114 + pax_force_retaddr
13115 ret;
13116 ENDPROC(cast5_ctr_16way)
13117 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13118 index e3531f8..e123f35 100644
13119 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13120 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13121 @@ -24,6 +24,7 @@
13122 */
13123
13124 #include <linux/linkage.h>
13125 +#include <asm/alternative-asm.h>
13126 #include "glue_helper-asm-avx.S"
13127
13128 .file "cast6-avx-x86_64-asm_64.S"
13129 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
13130 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13131 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13132
13133 + pax_force_retaddr
13134 ret;
13135 ENDPROC(__cast6_enc_blk8)
13136
13137 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
13138 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13139 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13140
13141 + pax_force_retaddr
13142 ret;
13143 ENDPROC(__cast6_dec_blk8)
13144
13145 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
13146
13147 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13148
13149 + pax_force_retaddr
13150 ret;
13151 ENDPROC(cast6_ecb_enc_8way)
13152
13153 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
13154
13155 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13156
13157 + pax_force_retaddr
13158 ret;
13159 ENDPROC(cast6_ecb_dec_8way)
13160
13161 @@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
13162 * %rdx: src
13163 */
13164
13165 - pushq %r12;
13166 + pushq %r14;
13167
13168 movq %rsi, %r11;
13169 - movq %rdx, %r12;
13170 + movq %rdx, %r14;
13171
13172 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13173
13174 call __cast6_dec_blk8;
13175
13176 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13177 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13178
13179 - popq %r12;
13180 + popq %r14;
13181
13182 + pax_force_retaddr
13183 ret;
13184 ENDPROC(cast6_cbc_dec_8way)
13185
13186 @@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
13187 * %rcx: iv (little endian, 128bit)
13188 */
13189
13190 - pushq %r12;
13191 + pushq %r14;
13192
13193 movq %rsi, %r11;
13194 - movq %rdx, %r12;
13195 + movq %rdx, %r14;
13196
13197 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13198 RD2, RX, RKR, RKM);
13199
13200 call __cast6_enc_blk8;
13201
13202 - store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13203 + store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13204
13205 - popq %r12;
13206 + popq %r14;
13207
13208 + pax_force_retaddr
13209 ret;
13210 ENDPROC(cast6_ctr_8way)
13211
13212 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
13213 /* dst <= regs xor IVs(in dst) */
13214 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13215
13216 + pax_force_retaddr
13217 ret;
13218 ENDPROC(cast6_xts_enc_8way)
13219
13220 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
13221 /* dst <= regs xor IVs(in dst) */
13222 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13223
13224 + pax_force_retaddr
13225 ret;
13226 ENDPROC(cast6_xts_dec_8way)
13227 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13228 index dbc4339..de6e120 100644
13229 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13230 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13231 @@ -45,6 +45,7 @@
13232
13233 #include <asm/inst.h>
13234 #include <linux/linkage.h>
13235 +#include <asm/alternative-asm.h>
13236
13237 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
13238
13239 @@ -312,6 +313,7 @@ do_return:
13240 popq %rsi
13241 popq %rdi
13242 popq %rbx
13243 + pax_force_retaddr
13244 ret
13245
13246 ################################################################
13247 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13248 index 586f41a..d02851e 100644
13249 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
13250 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13251 @@ -18,6 +18,7 @@
13252
13253 #include <linux/linkage.h>
13254 #include <asm/inst.h>
13255 +#include <asm/alternative-asm.h>
13256
13257 .data
13258
13259 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
13260 psrlq $1, T2
13261 pxor T2, T1
13262 pxor T1, DATA
13263 + pax_force_retaddr
13264 ret
13265 ENDPROC(__clmul_gf128mul_ble)
13266
13267 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
13268 call __clmul_gf128mul_ble
13269 PSHUFB_XMM BSWAP DATA
13270 movups DATA, (%rdi)
13271 + pax_force_retaddr
13272 ret
13273 ENDPROC(clmul_ghash_mul)
13274
13275 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
13276 PSHUFB_XMM BSWAP DATA
13277 movups DATA, (%rdi)
13278 .Lupdate_just_ret:
13279 + pax_force_retaddr
13280 ret
13281 ENDPROC(clmul_ghash_update)
13282
13283 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
13284 pand .Lpoly, %xmm1
13285 pxor %xmm1, %xmm0
13286 movups %xmm0, (%rdi)
13287 + pax_force_retaddr
13288 ret
13289 ENDPROC(clmul_ghash_setkey)
13290 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13291 index 9279e0b..c4b3d2c 100644
13292 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
13293 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13294 @@ -1,4 +1,5 @@
13295 #include <linux/linkage.h>
13296 +#include <asm/alternative-asm.h>
13297
13298 # enter salsa20_encrypt_bytes
13299 ENTRY(salsa20_encrypt_bytes)
13300 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
13301 add %r11,%rsp
13302 mov %rdi,%rax
13303 mov %rsi,%rdx
13304 + pax_force_retaddr
13305 ret
13306 # bytesatleast65:
13307 ._bytesatleast65:
13308 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
13309 add %r11,%rsp
13310 mov %rdi,%rax
13311 mov %rsi,%rdx
13312 + pax_force_retaddr
13313 ret
13314 ENDPROC(salsa20_keysetup)
13315
13316 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
13317 add %r11,%rsp
13318 mov %rdi,%rax
13319 mov %rsi,%rdx
13320 + pax_force_retaddr
13321 ret
13322 ENDPROC(salsa20_ivsetup)
13323 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13324 index 2f202f4..d9164d6 100644
13325 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13326 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13327 @@ -24,6 +24,7 @@
13328 */
13329
13330 #include <linux/linkage.h>
13331 +#include <asm/alternative-asm.h>
13332 #include "glue_helper-asm-avx.S"
13333
13334 .file "serpent-avx-x86_64-asm_64.S"
13335 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
13336 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13337 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13338
13339 + pax_force_retaddr
13340 ret;
13341 ENDPROC(__serpent_enc_blk8_avx)
13342
13343 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
13344 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13345 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13346
13347 + pax_force_retaddr
13348 ret;
13349 ENDPROC(__serpent_dec_blk8_avx)
13350
13351 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
13352
13353 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13354
13355 + pax_force_retaddr
13356 ret;
13357 ENDPROC(serpent_ecb_enc_8way_avx)
13358
13359 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
13360
13361 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13362
13363 + pax_force_retaddr
13364 ret;
13365 ENDPROC(serpent_ecb_dec_8way_avx)
13366
13367 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
13368
13369 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13370
13371 + pax_force_retaddr
13372 ret;
13373 ENDPROC(serpent_cbc_dec_8way_avx)
13374
13375 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
13376
13377 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13378
13379 + pax_force_retaddr
13380 ret;
13381 ENDPROC(serpent_ctr_8way_avx)
13382
13383 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
13384 /* dst <= regs xor IVs(in dst) */
13385 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13386
13387 + pax_force_retaddr
13388 ret;
13389 ENDPROC(serpent_xts_enc_8way_avx)
13390
13391 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
13392 /* dst <= regs xor IVs(in dst) */
13393 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13394
13395 + pax_force_retaddr
13396 ret;
13397 ENDPROC(serpent_xts_dec_8way_avx)
13398 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
13399 index b222085..abd483c 100644
13400 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
13401 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
13402 @@ -15,6 +15,7 @@
13403 */
13404
13405 #include <linux/linkage.h>
13406 +#include <asm/alternative-asm.h>
13407 #include "glue_helper-asm-avx2.S"
13408
13409 .file "serpent-avx2-asm_64.S"
13410 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
13411 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13412 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13413
13414 + pax_force_retaddr
13415 ret;
13416 ENDPROC(__serpent_enc_blk16)
13417
13418 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
13419 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13420 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13421
13422 + pax_force_retaddr
13423 ret;
13424 ENDPROC(__serpent_dec_blk16)
13425
13426 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
13427
13428 vzeroupper;
13429
13430 + pax_force_retaddr
13431 ret;
13432 ENDPROC(serpent_ecb_enc_16way)
13433
13434 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
13435
13436 vzeroupper;
13437
13438 + pax_force_retaddr
13439 ret;
13440 ENDPROC(serpent_ecb_dec_16way)
13441
13442 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
13443
13444 vzeroupper;
13445
13446 + pax_force_retaddr
13447 ret;
13448 ENDPROC(serpent_cbc_dec_16way)
13449
13450 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13451
13452 vzeroupper;
13453
13454 + pax_force_retaddr
13455 ret;
13456 ENDPROC(serpent_ctr_16way)
13457
13458 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13459
13460 vzeroupper;
13461
13462 + pax_force_retaddr
13463 ret;
13464 ENDPROC(serpent_xts_enc_16way)
13465
13466 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13467
13468 vzeroupper;
13469
13470 + pax_force_retaddr
13471 ret;
13472 ENDPROC(serpent_xts_dec_16way)
13473 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13474 index acc066c..1559cc4 100644
13475 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13476 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13477 @@ -25,6 +25,7 @@
13478 */
13479
13480 #include <linux/linkage.h>
13481 +#include <asm/alternative-asm.h>
13482
13483 .file "serpent-sse2-x86_64-asm_64.S"
13484 .text
13485 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13486 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13487 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13488
13489 + pax_force_retaddr
13490 ret;
13491
13492 .L__enc_xor8:
13493 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13494 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13495
13496 + pax_force_retaddr
13497 ret;
13498 ENDPROC(__serpent_enc_blk_8way)
13499
13500 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13501 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13502 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13503
13504 + pax_force_retaddr
13505 ret;
13506 ENDPROC(serpent_dec_blk_8way)
13507 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13508 index a410950..9dfe7ad 100644
13509 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13510 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13511 @@ -29,6 +29,7 @@
13512 */
13513
13514 #include <linux/linkage.h>
13515 +#include <asm/alternative-asm.h>
13516
13517 #define CTX %rdi // arg1
13518 #define BUF %rsi // arg2
13519 @@ -75,9 +76,9 @@
13520
13521 push %rbx
13522 push %rbp
13523 - push %r12
13524 + push %r14
13525
13526 - mov %rsp, %r12
13527 + mov %rsp, %r14
13528 sub $64, %rsp # allocate workspace
13529 and $~15, %rsp # align stack
13530
13531 @@ -99,11 +100,12 @@
13532 xor %rax, %rax
13533 rep stosq
13534
13535 - mov %r12, %rsp # deallocate workspace
13536 + mov %r14, %rsp # deallocate workspace
13537
13538 - pop %r12
13539 + pop %r14
13540 pop %rbp
13541 pop %rbx
13542 + pax_force_retaddr
13543 ret
13544
13545 ENDPROC(\name)
13546 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13547 index 642f156..51a513c 100644
13548 --- a/arch/x86/crypto/sha256-avx-asm.S
13549 +++ b/arch/x86/crypto/sha256-avx-asm.S
13550 @@ -49,6 +49,7 @@
13551
13552 #ifdef CONFIG_AS_AVX
13553 #include <linux/linkage.h>
13554 +#include <asm/alternative-asm.h>
13555
13556 ## assume buffers not aligned
13557 #define VMOVDQ vmovdqu
13558 @@ -460,6 +461,7 @@ done_hash:
13559 popq %r13
13560 popq %rbp
13561 popq %rbx
13562 + pax_force_retaddr
13563 ret
13564 ENDPROC(sha256_transform_avx)
13565
13566 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13567 index 9e86944..3795e6a 100644
13568 --- a/arch/x86/crypto/sha256-avx2-asm.S
13569 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13570 @@ -50,6 +50,7 @@
13571
13572 #ifdef CONFIG_AS_AVX2
13573 #include <linux/linkage.h>
13574 +#include <asm/alternative-asm.h>
13575
13576 ## assume buffers not aligned
13577 #define VMOVDQ vmovdqu
13578 @@ -720,6 +721,7 @@ done_hash:
13579 popq %r12
13580 popq %rbp
13581 popq %rbx
13582 + pax_force_retaddr
13583 ret
13584 ENDPROC(sha256_transform_rorx)
13585
13586 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13587 index f833b74..8c62a9e 100644
13588 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13589 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13590 @@ -47,6 +47,7 @@
13591 ########################################################################
13592
13593 #include <linux/linkage.h>
13594 +#include <asm/alternative-asm.h>
13595
13596 ## assume buffers not aligned
13597 #define MOVDQ movdqu
13598 @@ -471,6 +472,7 @@ done_hash:
13599 popq %rbp
13600 popq %rbx
13601
13602 + pax_force_retaddr
13603 ret
13604 ENDPROC(sha256_transform_ssse3)
13605
13606 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13607 index 974dde9..a823ff9 100644
13608 --- a/arch/x86/crypto/sha512-avx-asm.S
13609 +++ b/arch/x86/crypto/sha512-avx-asm.S
13610 @@ -49,6 +49,7 @@
13611
13612 #ifdef CONFIG_AS_AVX
13613 #include <linux/linkage.h>
13614 +#include <asm/alternative-asm.h>
13615
13616 .text
13617
13618 @@ -364,6 +365,7 @@ updateblock:
13619 mov frame_RSPSAVE(%rsp), %rsp
13620
13621 nowork:
13622 + pax_force_retaddr
13623 ret
13624 ENDPROC(sha512_transform_avx)
13625
13626 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13627 index 568b961..ed20c37 100644
13628 --- a/arch/x86/crypto/sha512-avx2-asm.S
13629 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13630 @@ -51,6 +51,7 @@
13631
13632 #ifdef CONFIG_AS_AVX2
13633 #include <linux/linkage.h>
13634 +#include <asm/alternative-asm.h>
13635
13636 .text
13637
13638 @@ -678,6 +679,7 @@ done_hash:
13639
13640 # Restore Stack Pointer
13641 mov frame_RSPSAVE(%rsp), %rsp
13642 + pax_force_retaddr
13643 ret
13644 ENDPROC(sha512_transform_rorx)
13645
13646 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13647 index fb56855..6edd768 100644
13648 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13649 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13650 @@ -48,6 +48,7 @@
13651 ########################################################################
13652
13653 #include <linux/linkage.h>
13654 +#include <asm/alternative-asm.h>
13655
13656 .text
13657
13658 @@ -363,6 +364,7 @@ updateblock:
13659 mov frame_RSPSAVE(%rsp), %rsp
13660
13661 nowork:
13662 + pax_force_retaddr
13663 ret
13664 ENDPROC(sha512_transform_ssse3)
13665
13666 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13667 index 0505813..b067311 100644
13668 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13669 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13670 @@ -24,6 +24,7 @@
13671 */
13672
13673 #include <linux/linkage.h>
13674 +#include <asm/alternative-asm.h>
13675 #include "glue_helper-asm-avx.S"
13676
13677 .file "twofish-avx-x86_64-asm_64.S"
13678 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13679 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13680 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13681
13682 + pax_force_retaddr
13683 ret;
13684 ENDPROC(__twofish_enc_blk8)
13685
13686 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13687 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13688 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13689
13690 + pax_force_retaddr
13691 ret;
13692 ENDPROC(__twofish_dec_blk8)
13693
13694 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13695
13696 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13697
13698 + pax_force_retaddr
13699 ret;
13700 ENDPROC(twofish_ecb_enc_8way)
13701
13702 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13703
13704 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13705
13706 + pax_force_retaddr
13707 ret;
13708 ENDPROC(twofish_ecb_dec_8way)
13709
13710 @@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
13711 * %rdx: src
13712 */
13713
13714 - pushq %r12;
13715 + pushq %r14;
13716
13717 movq %rsi, %r11;
13718 - movq %rdx, %r12;
13719 + movq %rdx, %r14;
13720
13721 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13722
13723 call __twofish_dec_blk8;
13724
13725 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13726 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13727
13728 - popq %r12;
13729 + popq %r14;
13730
13731 + pax_force_retaddr
13732 ret;
13733 ENDPROC(twofish_cbc_dec_8way)
13734
13735 @@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
13736 * %rcx: iv (little endian, 128bit)
13737 */
13738
13739 - pushq %r12;
13740 + pushq %r14;
13741
13742 movq %rsi, %r11;
13743 - movq %rdx, %r12;
13744 + movq %rdx, %r14;
13745
13746 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13747 RD2, RX0, RX1, RY0);
13748
13749 call __twofish_enc_blk8;
13750
13751 - store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13752 + store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13753
13754 - popq %r12;
13755 + popq %r14;
13756
13757 + pax_force_retaddr
13758 ret;
13759 ENDPROC(twofish_ctr_8way)
13760
13761 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13762 /* dst <= regs xor IVs(in dst) */
13763 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13764
13765 + pax_force_retaddr
13766 ret;
13767 ENDPROC(twofish_xts_enc_8way)
13768
13769 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13770 /* dst <= regs xor IVs(in dst) */
13771 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13772
13773 + pax_force_retaddr
13774 ret;
13775 ENDPROC(twofish_xts_dec_8way)
13776 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13777 index 1c3b7ce..02f578d 100644
13778 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13779 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13780 @@ -21,6 +21,7 @@
13781 */
13782
13783 #include <linux/linkage.h>
13784 +#include <asm/alternative-asm.h>
13785
13786 .file "twofish-x86_64-asm-3way.S"
13787 .text
13788 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13789 popq %r13;
13790 popq %r14;
13791 popq %r15;
13792 + pax_force_retaddr
13793 ret;
13794
13795 .L__enc_xor3:
13796 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13797 popq %r13;
13798 popq %r14;
13799 popq %r15;
13800 + pax_force_retaddr
13801 ret;
13802 ENDPROC(__twofish_enc_blk_3way)
13803
13804 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13805 popq %r13;
13806 popq %r14;
13807 popq %r15;
13808 + pax_force_retaddr
13809 ret;
13810 ENDPROC(twofish_dec_blk_3way)
13811 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13812 index a039d21..524b8b2 100644
13813 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13814 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13815 @@ -22,6 +22,7 @@
13816
13817 #include <linux/linkage.h>
13818 #include <asm/asm-offsets.h>
13819 +#include <asm/alternative-asm.h>
13820
13821 #define a_offset 0
13822 #define b_offset 4
13823 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13824
13825 popq R1
13826 movq $1,%rax
13827 + pax_force_retaddr
13828 ret
13829 ENDPROC(twofish_enc_blk)
13830
13831 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13832
13833 popq R1
13834 movq $1,%rax
13835 + pax_force_retaddr
13836 ret
13837 ENDPROC(twofish_dec_blk)
13838 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13839 index bae3aba..c1788c1 100644
13840 --- a/arch/x86/ia32/ia32_aout.c
13841 +++ b/arch/x86/ia32/ia32_aout.c
13842 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13843 unsigned long dump_start, dump_size;
13844 struct user32 dump;
13845
13846 + memset(&dump, 0, sizeof(dump));
13847 +
13848 fs = get_fs();
13849 set_fs(KERNEL_DS);
13850 has_dumped = 1;
13851 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13852 index 665a730..8e7a67a 100644
13853 --- a/arch/x86/ia32/ia32_signal.c
13854 +++ b/arch/x86/ia32/ia32_signal.c
13855 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13856 sp -= frame_size;
13857 /* Align the stack pointer according to the i386 ABI,
13858 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13859 - sp = ((sp + 4) & -16ul) - 4;
13860 + sp = ((sp - 12) & -16ul) - 4;
13861 return (void __user *) sp;
13862 }
13863
13864 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13865 * These are actually not used anymore, but left because some
13866 * gdb versions depend on them as a marker.
13867 */
13868 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13869 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13870 } put_user_catch(err);
13871
13872 if (err)
13873 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13874 0xb8,
13875 __NR_ia32_rt_sigreturn,
13876 0x80cd,
13877 - 0,
13878 + 0
13879 };
13880
13881 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13882 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13883
13884 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13885 restorer = ksig->ka.sa.sa_restorer;
13886 + else if (current->mm->context.vdso)
13887 + /* Return stub is in 32bit vsyscall page */
13888 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13889 else
13890 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13891 - rt_sigreturn);
13892 + restorer = &frame->retcode;
13893 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13894
13895 /*
13896 * Not actually used anymore, but left because some gdb
13897 * versions need it.
13898 */
13899 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13900 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13901 } put_user_catch(err);
13902
13903 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13904 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13905 index 4299eb0..c0687a7 100644
13906 --- a/arch/x86/ia32/ia32entry.S
13907 +++ b/arch/x86/ia32/ia32entry.S
13908 @@ -15,8 +15,10 @@
13909 #include <asm/irqflags.h>
13910 #include <asm/asm.h>
13911 #include <asm/smap.h>
13912 +#include <asm/pgtable.h>
13913 #include <linux/linkage.h>
13914 #include <linux/err.h>
13915 +#include <asm/alternative-asm.h>
13916
13917 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13918 #include <linux/elf-em.h>
13919 @@ -62,12 +64,12 @@
13920 */
13921 .macro LOAD_ARGS32 offset, _r9=0
13922 .if \_r9
13923 - movl \offset+16(%rsp),%r9d
13924 + movl \offset+R9(%rsp),%r9d
13925 .endif
13926 - movl \offset+40(%rsp),%ecx
13927 - movl \offset+48(%rsp),%edx
13928 - movl \offset+56(%rsp),%esi
13929 - movl \offset+64(%rsp),%edi
13930 + movl \offset+RCX(%rsp),%ecx
13931 + movl \offset+RDX(%rsp),%edx
13932 + movl \offset+RSI(%rsp),%esi
13933 + movl \offset+RDI(%rsp),%edi
13934 movl %eax,%eax /* zero extension */
13935 .endm
13936
13937 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13938 ENDPROC(native_irq_enable_sysexit)
13939 #endif
13940
13941 + .macro pax_enter_kernel_user
13942 + pax_set_fptr_mask
13943 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13944 + call pax_enter_kernel_user
13945 +#endif
13946 + .endm
13947 +
13948 + .macro pax_exit_kernel_user
13949 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13950 + call pax_exit_kernel_user
13951 +#endif
13952 +#ifdef CONFIG_PAX_RANDKSTACK
13953 + pushq %rax
13954 + pushq %r11
13955 + call pax_randomize_kstack
13956 + popq %r11
13957 + popq %rax
13958 +#endif
13959 + .endm
13960 +
13961 + .macro pax_erase_kstack
13962 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13963 + call pax_erase_kstack
13964 +#endif
13965 + .endm
13966 +
13967 /*
13968 * 32bit SYSENTER instruction entry.
13969 *
13970 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13971 CFI_REGISTER rsp,rbp
13972 SWAPGS_UNSAFE_STACK
13973 movq PER_CPU_VAR(kernel_stack), %rsp
13974 - addq $(KERNEL_STACK_OFFSET),%rsp
13975 - /*
13976 - * No need to follow this irqs on/off section: the syscall
13977 - * disabled irqs, here we enable it straight after entry:
13978 - */
13979 - ENABLE_INTERRUPTS(CLBR_NONE)
13980 movl %ebp,%ebp /* zero extension */
13981 pushq_cfi $__USER32_DS
13982 /*CFI_REL_OFFSET ss,0*/
13983 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13984 CFI_REL_OFFSET rsp,0
13985 pushfq_cfi
13986 /*CFI_REL_OFFSET rflags,0*/
13987 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13988 - CFI_REGISTER rip,r10
13989 + orl $X86_EFLAGS_IF,(%rsp)
13990 + GET_THREAD_INFO(%r11)
13991 + movl TI_sysenter_return(%r11), %r11d
13992 + CFI_REGISTER rip,r11
13993 pushq_cfi $__USER32_CS
13994 /*CFI_REL_OFFSET cs,0*/
13995 movl %eax, %eax
13996 - pushq_cfi %r10
13997 + pushq_cfi %r11
13998 CFI_REL_OFFSET rip,0
13999 pushq_cfi %rax
14000 cld
14001 SAVE_ARGS 0,1,0
14002 + pax_enter_kernel_user
14003 +
14004 +#ifdef CONFIG_PAX_RANDKSTACK
14005 + pax_erase_kstack
14006 +#endif
14007 +
14008 + /*
14009 + * No need to follow this irqs on/off section: the syscall
14010 + * disabled irqs, here we enable it straight after entry:
14011 + */
14012 + ENABLE_INTERRUPTS(CLBR_NONE)
14013 /* no need to do an access_ok check here because rbp has been
14014 32bit zero extended */
14015 +
14016 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14017 + addq pax_user_shadow_base,%rbp
14018 + ASM_PAX_OPEN_USERLAND
14019 +#endif
14020 +
14021 ASM_STAC
14022 1: movl (%rbp),%ebp
14023 _ASM_EXTABLE(1b,ia32_badarg)
14024 ASM_CLAC
14025 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14026 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14027 +
14028 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14029 + ASM_PAX_CLOSE_USERLAND
14030 +#endif
14031 +
14032 + GET_THREAD_INFO(%r11)
14033 + orl $TS_COMPAT,TI_status(%r11)
14034 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14035 CFI_REMEMBER_STATE
14036 jnz sysenter_tracesys
14037 cmpq $(IA32_NR_syscalls-1),%rax
14038 @@ -162,15 +209,18 @@ sysenter_do_call:
14039 sysenter_dispatch:
14040 call *ia32_sys_call_table(,%rax,8)
14041 movq %rax,RAX-ARGOFFSET(%rsp)
14042 + GET_THREAD_INFO(%r11)
14043 DISABLE_INTERRUPTS(CLBR_NONE)
14044 TRACE_IRQS_OFF
14045 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14046 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14047 jnz sysexit_audit
14048 sysexit_from_sys_call:
14049 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14050 + pax_exit_kernel_user
14051 + pax_erase_kstack
14052 + andl $~TS_COMPAT,TI_status(%r11)
14053 /* clear IF, that popfq doesn't enable interrupts early */
14054 - andl $~0x200,EFLAGS-R11(%rsp)
14055 - movl RIP-R11(%rsp),%edx /* User %eip */
14056 + andl $~X86_EFLAGS_IF,EFLAGS(%rsp)
14057 + movl RIP(%rsp),%edx /* User %eip */
14058 CFI_REGISTER rip,rdx
14059 RESTORE_ARGS 0,24,0,0,0,0
14060 xorq %r8,%r8
14061 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
14062 movl %eax,%esi /* 2nd arg: syscall number */
14063 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
14064 call __audit_syscall_entry
14065 +
14066 + pax_erase_kstack
14067 +
14068 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
14069 cmpq $(IA32_NR_syscalls-1),%rax
14070 ja ia32_badsys
14071 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
14072 .endm
14073
14074 .macro auditsys_exit exit
14075 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14076 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14077 jnz ia32_ret_from_sys_call
14078 TRACE_IRQS_ON
14079 ENABLE_INTERRUPTS(CLBR_NONE)
14080 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
14081 1: setbe %al /* 1 if error, 0 if not */
14082 movzbl %al,%edi /* zero-extend that into %edi */
14083 call __audit_syscall_exit
14084 + GET_THREAD_INFO(%r11)
14085 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
14086 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
14087 DISABLE_INTERRUPTS(CLBR_NONE)
14088 TRACE_IRQS_OFF
14089 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14090 + testl %edi,TI_flags(%r11)
14091 jz \exit
14092 CLEAR_RREGS -ARGOFFSET
14093 jmp int_with_check
14094 @@ -237,7 +291,7 @@ sysexit_audit:
14095
14096 sysenter_tracesys:
14097 #ifdef CONFIG_AUDITSYSCALL
14098 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14099 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14100 jz sysenter_auditsys
14101 #endif
14102 SAVE_REST
14103 @@ -249,6 +303,9 @@ sysenter_tracesys:
14104 RESTORE_REST
14105 cmpq $(IA32_NR_syscalls-1),%rax
14106 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
14107 +
14108 + pax_erase_kstack
14109 +
14110 jmp sysenter_do_call
14111 CFI_ENDPROC
14112 ENDPROC(ia32_sysenter_target)
14113 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
14114 ENTRY(ia32_cstar_target)
14115 CFI_STARTPROC32 simple
14116 CFI_SIGNAL_FRAME
14117 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
14118 + CFI_DEF_CFA rsp,0
14119 CFI_REGISTER rip,rcx
14120 /*CFI_REGISTER rflags,r11*/
14121 SWAPGS_UNSAFE_STACK
14122 movl %esp,%r8d
14123 CFI_REGISTER rsp,r8
14124 movq PER_CPU_VAR(kernel_stack),%rsp
14125 + SAVE_ARGS 8*6,0,0
14126 + pax_enter_kernel_user
14127 +
14128 +#ifdef CONFIG_PAX_RANDKSTACK
14129 + pax_erase_kstack
14130 +#endif
14131 +
14132 /*
14133 * No need to follow this irqs on/off section: the syscall
14134 * disabled irqs and here we enable it straight after entry:
14135 */
14136 ENABLE_INTERRUPTS(CLBR_NONE)
14137 - SAVE_ARGS 8,0,0
14138 movl %eax,%eax /* zero extension */
14139 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
14140 movq %rcx,RIP-ARGOFFSET(%rsp)
14141 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
14142 /* no need to do an access_ok check here because r8 has been
14143 32bit zero extended */
14144 /* hardware stack frame is complete now */
14145 +
14146 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14147 + ASM_PAX_OPEN_USERLAND
14148 + movq pax_user_shadow_base,%r8
14149 + addq RSP-ARGOFFSET(%rsp),%r8
14150 +#endif
14151 +
14152 ASM_STAC
14153 1: movl (%r8),%r9d
14154 _ASM_EXTABLE(1b,ia32_badarg)
14155 ASM_CLAC
14156 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14157 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14158 +
14159 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14160 + ASM_PAX_CLOSE_USERLAND
14161 +#endif
14162 +
14163 + GET_THREAD_INFO(%r11)
14164 + orl $TS_COMPAT,TI_status(%r11)
14165 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14166 CFI_REMEMBER_STATE
14167 jnz cstar_tracesys
14168 cmpq $IA32_NR_syscalls-1,%rax
14169 @@ -319,13 +395,16 @@ cstar_do_call:
14170 cstar_dispatch:
14171 call *ia32_sys_call_table(,%rax,8)
14172 movq %rax,RAX-ARGOFFSET(%rsp)
14173 + GET_THREAD_INFO(%r11)
14174 DISABLE_INTERRUPTS(CLBR_NONE)
14175 TRACE_IRQS_OFF
14176 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14177 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14178 jnz sysretl_audit
14179 sysretl_from_sys_call:
14180 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14181 - RESTORE_ARGS 0,-ARG_SKIP,0,0,0
14182 + pax_exit_kernel_user
14183 + pax_erase_kstack
14184 + andl $~TS_COMPAT,TI_status(%r11)
14185 + RESTORE_ARGS 0,-ORIG_RAX,0,0,0
14186 movl RIP-ARGOFFSET(%rsp),%ecx
14187 CFI_REGISTER rip,rcx
14188 movl EFLAGS-ARGOFFSET(%rsp),%r11d
14189 @@ -352,7 +431,7 @@ sysretl_audit:
14190
14191 cstar_tracesys:
14192 #ifdef CONFIG_AUDITSYSCALL
14193 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14194 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14195 jz cstar_auditsys
14196 #endif
14197 xchgl %r9d,%ebp
14198 @@ -366,11 +445,19 @@ cstar_tracesys:
14199 xchgl %ebp,%r9d
14200 cmpq $(IA32_NR_syscalls-1),%rax
14201 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
14202 +
14203 + pax_erase_kstack
14204 +
14205 jmp cstar_do_call
14206 END(ia32_cstar_target)
14207
14208 ia32_badarg:
14209 ASM_CLAC
14210 +
14211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14212 + ASM_PAX_CLOSE_USERLAND
14213 +#endif
14214 +
14215 movq $-EFAULT,%rax
14216 jmp ia32_sysret
14217 CFI_ENDPROC
14218 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
14219 CFI_REL_OFFSET rip,RIP-RIP
14220 PARAVIRT_ADJUST_EXCEPTION_FRAME
14221 SWAPGS
14222 - /*
14223 - * No need to follow this irqs on/off section: the syscall
14224 - * disabled irqs and here we enable it straight after entry:
14225 - */
14226 - ENABLE_INTERRUPTS(CLBR_NONE)
14227 movl %eax,%eax
14228 pushq_cfi %rax
14229 cld
14230 /* note the registers are not zero extended to the sf.
14231 this could be a problem. */
14232 SAVE_ARGS 0,1,0
14233 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14234 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14235 + pax_enter_kernel_user
14236 +
14237 +#ifdef CONFIG_PAX_RANDKSTACK
14238 + pax_erase_kstack
14239 +#endif
14240 +
14241 + /*
14242 + * No need to follow this irqs on/off section: the syscall
14243 + * disabled irqs and here we enable it straight after entry:
14244 + */
14245 + ENABLE_INTERRUPTS(CLBR_NONE)
14246 + GET_THREAD_INFO(%r11)
14247 + orl $TS_COMPAT,TI_status(%r11)
14248 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14249 jnz ia32_tracesys
14250 cmpq $(IA32_NR_syscalls-1),%rax
14251 ja ia32_badsys
14252 @@ -442,6 +536,9 @@ ia32_tracesys:
14253 RESTORE_REST
14254 cmpq $(IA32_NR_syscalls-1),%rax
14255 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
14256 +
14257 + pax_erase_kstack
14258 +
14259 jmp ia32_do_call
14260 END(ia32_syscall)
14261
14262 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
14263 index 8e0ceec..af13504 100644
14264 --- a/arch/x86/ia32/sys_ia32.c
14265 +++ b/arch/x86/ia32/sys_ia32.c
14266 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
14267 */
14268 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
14269 {
14270 - typeof(ubuf->st_uid) uid = 0;
14271 - typeof(ubuf->st_gid) gid = 0;
14272 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
14273 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
14274 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
14275 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
14276 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
14277 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
14278 index 372231c..51b537d 100644
14279 --- a/arch/x86/include/asm/alternative-asm.h
14280 +++ b/arch/x86/include/asm/alternative-asm.h
14281 @@ -18,6 +18,45 @@
14282 .endm
14283 #endif
14284
14285 +#ifdef KERNEXEC_PLUGIN
14286 + .macro pax_force_retaddr_bts rip=0
14287 + btsq $63,\rip(%rsp)
14288 + .endm
14289 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14290 + .macro pax_force_retaddr rip=0, reload=0
14291 + btsq $63,\rip(%rsp)
14292 + .endm
14293 + .macro pax_force_fptr ptr
14294 + btsq $63,\ptr
14295 + .endm
14296 + .macro pax_set_fptr_mask
14297 + .endm
14298 +#endif
14299 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14300 + .macro pax_force_retaddr rip=0, reload=0
14301 + .if \reload
14302 + pax_set_fptr_mask
14303 + .endif
14304 + orq %r12,\rip(%rsp)
14305 + .endm
14306 + .macro pax_force_fptr ptr
14307 + orq %r12,\ptr
14308 + .endm
14309 + .macro pax_set_fptr_mask
14310 + movabs $0x8000000000000000,%r12
14311 + .endm
14312 +#endif
14313 +#else
14314 + .macro pax_force_retaddr rip=0, reload=0
14315 + .endm
14316 + .macro pax_force_fptr ptr
14317 + .endm
14318 + .macro pax_force_retaddr_bts rip=0
14319 + .endm
14320 + .macro pax_set_fptr_mask
14321 + .endm
14322 +#endif
14323 +
14324 .macro altinstruction_entry orig alt feature orig_len alt_len
14325 .long \orig - .
14326 .long \alt - .
14327 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
14328 index 0a3f9c9..c9d081d 100644
14329 --- a/arch/x86/include/asm/alternative.h
14330 +++ b/arch/x86/include/asm/alternative.h
14331 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14332 ".pushsection .discard,\"aw\",@progbits\n" \
14333 DISCARD_ENTRY(1) \
14334 ".popsection\n" \
14335 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14336 + ".pushsection .altinstr_replacement, \"a\"\n" \
14337 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
14338 ".popsection"
14339
14340 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14341 DISCARD_ENTRY(1) \
14342 DISCARD_ENTRY(2) \
14343 ".popsection\n" \
14344 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14345 + ".pushsection .altinstr_replacement, \"a\"\n" \
14346 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
14347 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
14348 ".popsection"
14349 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
14350 index 1d2091a..f5074c1 100644
14351 --- a/arch/x86/include/asm/apic.h
14352 +++ b/arch/x86/include/asm/apic.h
14353 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
14354
14355 #ifdef CONFIG_X86_LOCAL_APIC
14356
14357 -extern unsigned int apic_verbosity;
14358 +extern int apic_verbosity;
14359 extern int local_apic_timer_c2_ok;
14360
14361 extern int disable_apic;
14362 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
14363 index 20370c6..a2eb9b0 100644
14364 --- a/arch/x86/include/asm/apm.h
14365 +++ b/arch/x86/include/asm/apm.h
14366 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
14367 __asm__ __volatile__(APM_DO_ZERO_SEGS
14368 "pushl %%edi\n\t"
14369 "pushl %%ebp\n\t"
14370 - "lcall *%%cs:apm_bios_entry\n\t"
14371 + "lcall *%%ss:apm_bios_entry\n\t"
14372 "setc %%al\n\t"
14373 "popl %%ebp\n\t"
14374 "popl %%edi\n\t"
14375 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
14376 __asm__ __volatile__(APM_DO_ZERO_SEGS
14377 "pushl %%edi\n\t"
14378 "pushl %%ebp\n\t"
14379 - "lcall *%%cs:apm_bios_entry\n\t"
14380 + "lcall *%%ss:apm_bios_entry\n\t"
14381 "setc %%bl\n\t"
14382 "popl %%ebp\n\t"
14383 "popl %%edi\n\t"
14384 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
14385 index 722aa3b..c392d85 100644
14386 --- a/arch/x86/include/asm/atomic.h
14387 +++ b/arch/x86/include/asm/atomic.h
14388 @@ -22,7 +22,18 @@
14389 */
14390 static inline int atomic_read(const atomic_t *v)
14391 {
14392 - return (*(volatile int *)&(v)->counter);
14393 + return (*(volatile const int *)&(v)->counter);
14394 +}
14395 +
14396 +/**
14397 + * atomic_read_unchecked - read atomic variable
14398 + * @v: pointer of type atomic_unchecked_t
14399 + *
14400 + * Atomically reads the value of @v.
14401 + */
14402 +static inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
14403 +{
14404 + return (*(volatile const int *)&(v)->counter);
14405 }
14406
14407 /**
14408 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
14409 }
14410
14411 /**
14412 + * atomic_set_unchecked - set atomic variable
14413 + * @v: pointer of type atomic_unchecked_t
14414 + * @i: required value
14415 + *
14416 + * Atomically sets the value of @v to @i.
14417 + */
14418 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
14419 +{
14420 + v->counter = i;
14421 +}
14422 +
14423 +/**
14424 * atomic_add - add integer to atomic variable
14425 * @i: integer value to add
14426 * @v: pointer of type atomic_t
14427 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
14428 */
14429 static inline void atomic_add(int i, atomic_t *v)
14430 {
14431 - asm volatile(LOCK_PREFIX "addl %1,%0"
14432 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14433 +
14434 +#ifdef CONFIG_PAX_REFCOUNT
14435 + "jno 0f\n"
14436 + LOCK_PREFIX "subl %1,%0\n"
14437 + "int $4\n0:\n"
14438 + _ASM_EXTABLE(0b, 0b)
14439 +#endif
14440 +
14441 + : "+m" (v->counter)
14442 + : "ir" (i));
14443 +}
14444 +
14445 +/**
14446 + * atomic_add_unchecked - add integer to atomic variable
14447 + * @i: integer value to add
14448 + * @v: pointer of type atomic_unchecked_t
14449 + *
14450 + * Atomically adds @i to @v.
14451 + */
14452 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
14453 +{
14454 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14455 : "+m" (v->counter)
14456 : "ir" (i));
14457 }
14458 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
14459 */
14460 static inline void atomic_sub(int i, atomic_t *v)
14461 {
14462 - asm volatile(LOCK_PREFIX "subl %1,%0"
14463 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14464 +
14465 +#ifdef CONFIG_PAX_REFCOUNT
14466 + "jno 0f\n"
14467 + LOCK_PREFIX "addl %1,%0\n"
14468 + "int $4\n0:\n"
14469 + _ASM_EXTABLE(0b, 0b)
14470 +#endif
14471 +
14472 + : "+m" (v->counter)
14473 + : "ir" (i));
14474 +}
14475 +
14476 +/**
14477 + * atomic_sub_unchecked - subtract integer from atomic variable
14478 + * @i: integer value to subtract
14479 + * @v: pointer of type atomic_unchecked_t
14480 + *
14481 + * Atomically subtracts @i from @v.
14482 + */
14483 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
14484 +{
14485 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14486 : "+m" (v->counter)
14487 : "ir" (i));
14488 }
14489 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14490 {
14491 unsigned char c;
14492
14493 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
14494 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
14495 +
14496 +#ifdef CONFIG_PAX_REFCOUNT
14497 + "jno 0f\n"
14498 + LOCK_PREFIX "addl %2,%0\n"
14499 + "int $4\n0:\n"
14500 + _ASM_EXTABLE(0b, 0b)
14501 +#endif
14502 +
14503 + "sete %1\n"
14504 : "+m" (v->counter), "=qm" (c)
14505 : "ir" (i) : "memory");
14506 return c;
14507 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14508 */
14509 static inline void atomic_inc(atomic_t *v)
14510 {
14511 - asm volatile(LOCK_PREFIX "incl %0"
14512 + asm volatile(LOCK_PREFIX "incl %0\n"
14513 +
14514 +#ifdef CONFIG_PAX_REFCOUNT
14515 + "jno 0f\n"
14516 + LOCK_PREFIX "decl %0\n"
14517 + "int $4\n0:\n"
14518 + _ASM_EXTABLE(0b, 0b)
14519 +#endif
14520 +
14521 + : "+m" (v->counter));
14522 +}
14523 +
14524 +/**
14525 + * atomic_inc_unchecked - increment atomic variable
14526 + * @v: pointer of type atomic_unchecked_t
14527 + *
14528 + * Atomically increments @v by 1.
14529 + */
14530 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
14531 +{
14532 + asm volatile(LOCK_PREFIX "incl %0\n"
14533 : "+m" (v->counter));
14534 }
14535
14536 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
14537 */
14538 static inline void atomic_dec(atomic_t *v)
14539 {
14540 - asm volatile(LOCK_PREFIX "decl %0"
14541 + asm volatile(LOCK_PREFIX "decl %0\n"
14542 +
14543 +#ifdef CONFIG_PAX_REFCOUNT
14544 + "jno 0f\n"
14545 + LOCK_PREFIX "incl %0\n"
14546 + "int $4\n0:\n"
14547 + _ASM_EXTABLE(0b, 0b)
14548 +#endif
14549 +
14550 + : "+m" (v->counter));
14551 +}
14552 +
14553 +/**
14554 + * atomic_dec_unchecked - decrement atomic variable
14555 + * @v: pointer of type atomic_unchecked_t
14556 + *
14557 + * Atomically decrements @v by 1.
14558 + */
14559 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
14560 +{
14561 + asm volatile(LOCK_PREFIX "decl %0\n"
14562 : "+m" (v->counter));
14563 }
14564
14565 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
14566 {
14567 unsigned char c;
14568
14569 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14570 + asm volatile(LOCK_PREFIX "decl %0\n"
14571 +
14572 +#ifdef CONFIG_PAX_REFCOUNT
14573 + "jno 0f\n"
14574 + LOCK_PREFIX "incl %0\n"
14575 + "int $4\n0:\n"
14576 + _ASM_EXTABLE(0b, 0b)
14577 +#endif
14578 +
14579 + "sete %1\n"
14580 : "+m" (v->counter), "=qm" (c)
14581 : : "memory");
14582 return c != 0;
14583 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14584 {
14585 unsigned char c;
14586
14587 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14588 + asm volatile(LOCK_PREFIX "incl %0\n"
14589 +
14590 +#ifdef CONFIG_PAX_REFCOUNT
14591 + "jno 0f\n"
14592 + LOCK_PREFIX "decl %0\n"
14593 + "int $4\n0:\n"
14594 + _ASM_EXTABLE(0b, 0b)
14595 +#endif
14596 +
14597 + "sete %1\n"
14598 + : "+m" (v->counter), "=qm" (c)
14599 + : : "memory");
14600 + return c != 0;
14601 +}
14602 +
14603 +/**
14604 + * atomic_inc_and_test_unchecked - increment and test
14605 + * @v: pointer of type atomic_unchecked_t
14606 + *
14607 + * Atomically increments @v by 1
14608 + * and returns true if the result is zero, or false for all
14609 + * other cases.
14610 + */
14611 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14612 +{
14613 + unsigned char c;
14614 +
14615 + asm volatile(LOCK_PREFIX "incl %0\n"
14616 + "sete %1\n"
14617 : "+m" (v->counter), "=qm" (c)
14618 : : "memory");
14619 return c != 0;
14620 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14621 {
14622 unsigned char c;
14623
14624 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14625 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14626 +
14627 +#ifdef CONFIG_PAX_REFCOUNT
14628 + "jno 0f\n"
14629 + LOCK_PREFIX "subl %2,%0\n"
14630 + "int $4\n0:\n"
14631 + _ASM_EXTABLE(0b, 0b)
14632 +#endif
14633 +
14634 + "sets %1\n"
14635 : "+m" (v->counter), "=qm" (c)
14636 : "ir" (i) : "memory");
14637 return c;
14638 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14639 */
14640 static inline int atomic_add_return(int i, atomic_t *v)
14641 {
14642 + return i + xadd_check_overflow(&v->counter, i);
14643 +}
14644 +
14645 +/**
14646 + * atomic_add_return_unchecked - add integer and return
14647 + * @i: integer value to add
14648 + * @v: pointer of type atomic_unchecked_t
14649 + *
14650 + * Atomically adds @i to @v and returns @i + @v
14651 + */
14652 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14653 +{
14654 return i + xadd(&v->counter, i);
14655 }
14656
14657 @@ -188,9 +362,18 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14658 }
14659
14660 #define atomic_inc_return(v) (atomic_add_return(1, v))
14661 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14662 +{
14663 + return atomic_add_return_unchecked(1, v);
14664 +}
14665 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14666
14667 -static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14668 +static inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
14669 +{
14670 + return cmpxchg(&v->counter, old, new);
14671 +}
14672 +
14673 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14674 {
14675 return cmpxchg(&v->counter, old, new);
14676 }
14677 @@ -200,6 +383,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
14678 return xchg(&v->counter, new);
14679 }
14680
14681 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14682 +{
14683 + return xchg(&v->counter, new);
14684 +}
14685 +
14686 /**
14687 * __atomic_add_unless - add unless the number is already a given value
14688 * @v: pointer of type atomic_t
14689 @@ -209,14 +397,27 @@ static inline int atomic_xchg(atomic_t *v, int new)
14690 * Atomically adds @a to @v, so long as @v was not already @u.
14691 * Returns the old value of @v.
14692 */
14693 -static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14694 +static inline int __intentional_overflow(-1) __atomic_add_unless(atomic_t *v, int a, int u)
14695 {
14696 - int c, old;
14697 + int c, old, new;
14698 c = atomic_read(v);
14699 for (;;) {
14700 - if (unlikely(c == (u)))
14701 + if (unlikely(c == u))
14702 break;
14703 - old = atomic_cmpxchg((v), c, c + (a));
14704 +
14705 + asm volatile("addl %2,%0\n"
14706 +
14707 +#ifdef CONFIG_PAX_REFCOUNT
14708 + "jno 0f\n"
14709 + "subl %2,%0\n"
14710 + "int $4\n0:\n"
14711 + _ASM_EXTABLE(0b, 0b)
14712 +#endif
14713 +
14714 + : "=r" (new)
14715 + : "0" (c), "ir" (a));
14716 +
14717 + old = atomic_cmpxchg(v, c, new);
14718 if (likely(old == c))
14719 break;
14720 c = old;
14721 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14722 }
14723
14724 /**
14725 + * atomic_inc_not_zero_hint - increment if not null
14726 + * @v: pointer of type atomic_t
14727 + * @hint: probable value of the atomic before the increment
14728 + *
14729 + * This version of atomic_inc_not_zero() gives a hint of probable
14730 + * value of the atomic. This helps processor to not read the memory
14731 + * before doing the atomic read/modify/write cycle, lowering
14732 + * number of bus transactions on some arches.
14733 + *
14734 + * Returns: 0 if increment was not done, 1 otherwise.
14735 + */
14736 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14737 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14738 +{
14739 + int val, c = hint, new;
14740 +
14741 + /* sanity test, should be removed by compiler if hint is a constant */
14742 + if (!hint)
14743 + return __atomic_add_unless(v, 1, 0);
14744 +
14745 + do {
14746 + asm volatile("incl %0\n"
14747 +
14748 +#ifdef CONFIG_PAX_REFCOUNT
14749 + "jno 0f\n"
14750 + "decl %0\n"
14751 + "int $4\n0:\n"
14752 + _ASM_EXTABLE(0b, 0b)
14753 +#endif
14754 +
14755 + : "=r" (new)
14756 + : "0" (c));
14757 +
14758 + val = atomic_cmpxchg(v, c, new);
14759 + if (val == c)
14760 + return 1;
14761 + c = val;
14762 + } while (c);
14763 +
14764 + return 0;
14765 +}
14766 +
14767 +/**
14768 * atomic_inc_short - increment of a short integer
14769 * @v: pointer to type int
14770 *
14771 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14772 #endif
14773
14774 /* These are x86-specific, used by some header files */
14775 -#define atomic_clear_mask(mask, addr) \
14776 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14777 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14778 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14779 +{
14780 + asm volatile(LOCK_PREFIX "andl %1,%0"
14781 + : "+m" (v->counter)
14782 + : "r" (~(mask))
14783 + : "memory");
14784 +}
14785
14786 -#define atomic_set_mask(mask, addr) \
14787 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14788 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14789 - : "memory")
14790 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14791 +{
14792 + asm volatile(LOCK_PREFIX "andl %1,%0"
14793 + : "+m" (v->counter)
14794 + : "r" (~(mask))
14795 + : "memory");
14796 +}
14797 +
14798 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14799 +{
14800 + asm volatile(LOCK_PREFIX "orl %1,%0"
14801 + : "+m" (v->counter)
14802 + : "r" (mask)
14803 + : "memory");
14804 +}
14805 +
14806 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14807 +{
14808 + asm volatile(LOCK_PREFIX "orl %1,%0"
14809 + : "+m" (v->counter)
14810 + : "r" (mask)
14811 + : "memory");
14812 +}
14813
14814 /* Atomic operations are already serializing on x86 */
14815 #define smp_mb__before_atomic_dec() barrier()
14816 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14817 index b154de7..bf18a5a 100644
14818 --- a/arch/x86/include/asm/atomic64_32.h
14819 +++ b/arch/x86/include/asm/atomic64_32.h
14820 @@ -12,6 +12,14 @@ typedef struct {
14821 u64 __aligned(8) counter;
14822 } atomic64_t;
14823
14824 +#ifdef CONFIG_PAX_REFCOUNT
14825 +typedef struct {
14826 + u64 __aligned(8) counter;
14827 +} atomic64_unchecked_t;
14828 +#else
14829 +typedef atomic64_t atomic64_unchecked_t;
14830 +#endif
14831 +
14832 #define ATOMIC64_INIT(val) { (val) }
14833
14834 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14835 @@ -37,21 +45,31 @@ typedef struct {
14836 ATOMIC64_DECL_ONE(sym##_386)
14837
14838 ATOMIC64_DECL_ONE(add_386);
14839 +ATOMIC64_DECL_ONE(add_unchecked_386);
14840 ATOMIC64_DECL_ONE(sub_386);
14841 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14842 ATOMIC64_DECL_ONE(inc_386);
14843 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14844 ATOMIC64_DECL_ONE(dec_386);
14845 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14846 #endif
14847
14848 #define alternative_atomic64(f, out, in...) \
14849 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14850
14851 ATOMIC64_DECL(read);
14852 +ATOMIC64_DECL(read_unchecked);
14853 ATOMIC64_DECL(set);
14854 +ATOMIC64_DECL(set_unchecked);
14855 ATOMIC64_DECL(xchg);
14856 ATOMIC64_DECL(add_return);
14857 +ATOMIC64_DECL(add_return_unchecked);
14858 ATOMIC64_DECL(sub_return);
14859 +ATOMIC64_DECL(sub_return_unchecked);
14860 ATOMIC64_DECL(inc_return);
14861 +ATOMIC64_DECL(inc_return_unchecked);
14862 ATOMIC64_DECL(dec_return);
14863 +ATOMIC64_DECL(dec_return_unchecked);
14864 ATOMIC64_DECL(dec_if_positive);
14865 ATOMIC64_DECL(inc_not_zero);
14866 ATOMIC64_DECL(add_unless);
14867 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14868 }
14869
14870 /**
14871 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14872 + * @p: pointer to type atomic64_unchecked_t
14873 + * @o: expected value
14874 + * @n: new value
14875 + *
14876 + * Atomically sets @v to @n if it was equal to @o and returns
14877 + * the old value.
14878 + */
14879 +
14880 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14881 +{
14882 + return cmpxchg64(&v->counter, o, n);
14883 +}
14884 +
14885 +/**
14886 * atomic64_xchg - xchg atomic64 variable
14887 * @v: pointer to type atomic64_t
14888 * @n: value to assign
14889 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14890 }
14891
14892 /**
14893 + * atomic64_set_unchecked - set atomic64 variable
14894 + * @v: pointer to type atomic64_unchecked_t
14895 + * @n: value to assign
14896 + *
14897 + * Atomically sets the value of @v to @n.
14898 + */
14899 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14900 +{
14901 + unsigned high = (unsigned)(i >> 32);
14902 + unsigned low = (unsigned)i;
14903 + alternative_atomic64(set, /* no output */,
14904 + "S" (v), "b" (low), "c" (high)
14905 + : "eax", "edx", "memory");
14906 +}
14907 +
14908 +/**
14909 * atomic64_read - read atomic64 variable
14910 * @v: pointer to type atomic64_t
14911 *
14912 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14913 }
14914
14915 /**
14916 + * atomic64_read_unchecked - read atomic64 variable
14917 + * @v: pointer to type atomic64_unchecked_t
14918 + *
14919 + * Atomically reads the value of @v and returns it.
14920 + */
14921 +static inline long long __intentional_overflow(-1) atomic64_read_unchecked(atomic64_unchecked_t *v)
14922 +{
14923 + long long r;
14924 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14925 + return r;
14926 + }
14927 +
14928 +/**
14929 * atomic64_add_return - add and return
14930 * @i: integer value to add
14931 * @v: pointer to type atomic64_t
14932 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14933 return i;
14934 }
14935
14936 +/**
14937 + * atomic64_add_return_unchecked - add and return
14938 + * @i: integer value to add
14939 + * @v: pointer to type atomic64_unchecked_t
14940 + *
14941 + * Atomically adds @i to @v and returns @i + *@v
14942 + */
14943 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14944 +{
14945 + alternative_atomic64(add_return_unchecked,
14946 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14947 + ASM_NO_INPUT_CLOBBER("memory"));
14948 + return i;
14949 +}
14950 +
14951 /*
14952 * Other variants with different arithmetic operators:
14953 */
14954 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14955 return a;
14956 }
14957
14958 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14959 +{
14960 + long long a;
14961 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14962 + "S" (v) : "memory", "ecx");
14963 + return a;
14964 +}
14965 +
14966 static inline long long atomic64_dec_return(atomic64_t *v)
14967 {
14968 long long a;
14969 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14970 }
14971
14972 /**
14973 + * atomic64_add_unchecked - add integer to atomic64 variable
14974 + * @i: integer value to add
14975 + * @v: pointer to type atomic64_unchecked_t
14976 + *
14977 + * Atomically adds @i to @v.
14978 + */
14979 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14980 +{
14981 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14982 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14983 + ASM_NO_INPUT_CLOBBER("memory"));
14984 + return i;
14985 +}
14986 +
14987 +/**
14988 * atomic64_sub - subtract the atomic64 variable
14989 * @i: integer value to subtract
14990 * @v: pointer to type atomic64_t
14991 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14992 index 0e1cbfc..a891fc7 100644
14993 --- a/arch/x86/include/asm/atomic64_64.h
14994 +++ b/arch/x86/include/asm/atomic64_64.h
14995 @@ -18,7 +18,19 @@
14996 */
14997 static inline long atomic64_read(const atomic64_t *v)
14998 {
14999 - return (*(volatile long *)&(v)->counter);
15000 + return (*(volatile const long *)&(v)->counter);
15001 +}
15002 +
15003 +/**
15004 + * atomic64_read_unchecked - read atomic64 variable
15005 + * @v: pointer of type atomic64_unchecked_t
15006 + *
15007 + * Atomically reads the value of @v.
15008 + * Doesn't imply a read memory barrier.
15009 + */
15010 +static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
15011 +{
15012 + return (*(volatile const long *)&(v)->counter);
15013 }
15014
15015 /**
15016 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
15017 }
15018
15019 /**
15020 + * atomic64_set_unchecked - set atomic64 variable
15021 + * @v: pointer to type atomic64_unchecked_t
15022 + * @i: required value
15023 + *
15024 + * Atomically sets the value of @v to @i.
15025 + */
15026 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
15027 +{
15028 + v->counter = i;
15029 +}
15030 +
15031 +/**
15032 * atomic64_add - add integer to atomic64 variable
15033 * @i: integer value to add
15034 * @v: pointer to type atomic64_t
15035 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
15036 */
15037 static inline void atomic64_add(long i, atomic64_t *v)
15038 {
15039 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
15040 +
15041 +#ifdef CONFIG_PAX_REFCOUNT
15042 + "jno 0f\n"
15043 + LOCK_PREFIX "subq %1,%0\n"
15044 + "int $4\n0:\n"
15045 + _ASM_EXTABLE(0b, 0b)
15046 +#endif
15047 +
15048 + : "=m" (v->counter)
15049 + : "er" (i), "m" (v->counter));
15050 +}
15051 +
15052 +/**
15053 + * atomic64_add_unchecked - add integer to atomic64 variable
15054 + * @i: integer value to add
15055 + * @v: pointer to type atomic64_unchecked_t
15056 + *
15057 + * Atomically adds @i to @v.
15058 + */
15059 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
15060 +{
15061 asm volatile(LOCK_PREFIX "addq %1,%0"
15062 : "=m" (v->counter)
15063 : "er" (i), "m" (v->counter));
15064 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
15065 */
15066 static inline void atomic64_sub(long i, atomic64_t *v)
15067 {
15068 - asm volatile(LOCK_PREFIX "subq %1,%0"
15069 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
15070 +
15071 +#ifdef CONFIG_PAX_REFCOUNT
15072 + "jno 0f\n"
15073 + LOCK_PREFIX "addq %1,%0\n"
15074 + "int $4\n0:\n"
15075 + _ASM_EXTABLE(0b, 0b)
15076 +#endif
15077 +
15078 + : "=m" (v->counter)
15079 + : "er" (i), "m" (v->counter));
15080 +}
15081 +
15082 +/**
15083 + * atomic64_sub_unchecked - subtract the atomic64 variable
15084 + * @i: integer value to subtract
15085 + * @v: pointer to type atomic64_unchecked_t
15086 + *
15087 + * Atomically subtracts @i from @v.
15088 + */
15089 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
15090 +{
15091 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
15092 : "=m" (v->counter)
15093 : "er" (i), "m" (v->counter));
15094 }
15095 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15096 {
15097 unsigned char c;
15098
15099 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
15100 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
15101 +
15102 +#ifdef CONFIG_PAX_REFCOUNT
15103 + "jno 0f\n"
15104 + LOCK_PREFIX "addq %2,%0\n"
15105 + "int $4\n0:\n"
15106 + _ASM_EXTABLE(0b, 0b)
15107 +#endif
15108 +
15109 + "sete %1\n"
15110 : "=m" (v->counter), "=qm" (c)
15111 : "er" (i), "m" (v->counter) : "memory");
15112 return c;
15113 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15114 */
15115 static inline void atomic64_inc(atomic64_t *v)
15116 {
15117 + asm volatile(LOCK_PREFIX "incq %0\n"
15118 +
15119 +#ifdef CONFIG_PAX_REFCOUNT
15120 + "jno 0f\n"
15121 + LOCK_PREFIX "decq %0\n"
15122 + "int $4\n0:\n"
15123 + _ASM_EXTABLE(0b, 0b)
15124 +#endif
15125 +
15126 + : "=m" (v->counter)
15127 + : "m" (v->counter));
15128 +}
15129 +
15130 +/**
15131 + * atomic64_inc_unchecked - increment atomic64 variable
15132 + * @v: pointer to type atomic64_unchecked_t
15133 + *
15134 + * Atomically increments @v by 1.
15135 + */
15136 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
15137 +{
15138 asm volatile(LOCK_PREFIX "incq %0"
15139 : "=m" (v->counter)
15140 : "m" (v->counter));
15141 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
15142 */
15143 static inline void atomic64_dec(atomic64_t *v)
15144 {
15145 - asm volatile(LOCK_PREFIX "decq %0"
15146 + asm volatile(LOCK_PREFIX "decq %0\n"
15147 +
15148 +#ifdef CONFIG_PAX_REFCOUNT
15149 + "jno 0f\n"
15150 + LOCK_PREFIX "incq %0\n"
15151 + "int $4\n0:\n"
15152 + _ASM_EXTABLE(0b, 0b)
15153 +#endif
15154 +
15155 + : "=m" (v->counter)
15156 + : "m" (v->counter));
15157 +}
15158 +
15159 +/**
15160 + * atomic64_dec_unchecked - decrement atomic64 variable
15161 + * @v: pointer to type atomic64_t
15162 + *
15163 + * Atomically decrements @v by 1.
15164 + */
15165 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
15166 +{
15167 + asm volatile(LOCK_PREFIX "decq %0\n"
15168 : "=m" (v->counter)
15169 : "m" (v->counter));
15170 }
15171 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
15172 {
15173 unsigned char c;
15174
15175 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
15176 + asm volatile(LOCK_PREFIX "decq %0\n"
15177 +
15178 +#ifdef CONFIG_PAX_REFCOUNT
15179 + "jno 0f\n"
15180 + LOCK_PREFIX "incq %0\n"
15181 + "int $4\n0:\n"
15182 + _ASM_EXTABLE(0b, 0b)
15183 +#endif
15184 +
15185 + "sete %1\n"
15186 : "=m" (v->counter), "=qm" (c)
15187 : "m" (v->counter) : "memory");
15188 return c != 0;
15189 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
15190 {
15191 unsigned char c;
15192
15193 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
15194 + asm volatile(LOCK_PREFIX "incq %0\n"
15195 +
15196 +#ifdef CONFIG_PAX_REFCOUNT
15197 + "jno 0f\n"
15198 + LOCK_PREFIX "decq %0\n"
15199 + "int $4\n0:\n"
15200 + _ASM_EXTABLE(0b, 0b)
15201 +#endif
15202 +
15203 + "sete %1\n"
15204 : "=m" (v->counter), "=qm" (c)
15205 : "m" (v->counter) : "memory");
15206 return c != 0;
15207 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15208 {
15209 unsigned char c;
15210
15211 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
15212 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
15213 +
15214 +#ifdef CONFIG_PAX_REFCOUNT
15215 + "jno 0f\n"
15216 + LOCK_PREFIX "subq %2,%0\n"
15217 + "int $4\n0:\n"
15218 + _ASM_EXTABLE(0b, 0b)
15219 +#endif
15220 +
15221 + "sets %1\n"
15222 : "=m" (v->counter), "=qm" (c)
15223 : "er" (i), "m" (v->counter) : "memory");
15224 return c;
15225 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15226 */
15227 static inline long atomic64_add_return(long i, atomic64_t *v)
15228 {
15229 + return i + xadd_check_overflow(&v->counter, i);
15230 +}
15231 +
15232 +/**
15233 + * atomic64_add_return_unchecked - add and return
15234 + * @i: integer value to add
15235 + * @v: pointer to type atomic64_unchecked_t
15236 + *
15237 + * Atomically adds @i to @v and returns @i + @v
15238 + */
15239 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
15240 +{
15241 return i + xadd(&v->counter, i);
15242 }
15243
15244 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
15245 }
15246
15247 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
15248 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15249 +{
15250 + return atomic64_add_return_unchecked(1, v);
15251 +}
15252 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
15253
15254 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15255 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15256 return cmpxchg(&v->counter, old, new);
15257 }
15258
15259 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
15260 +{
15261 + return cmpxchg(&v->counter, old, new);
15262 +}
15263 +
15264 static inline long atomic64_xchg(atomic64_t *v, long new)
15265 {
15266 return xchg(&v->counter, new);
15267 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
15268 */
15269 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
15270 {
15271 - long c, old;
15272 + long c, old, new;
15273 c = atomic64_read(v);
15274 for (;;) {
15275 - if (unlikely(c == (u)))
15276 + if (unlikely(c == u))
15277 break;
15278 - old = atomic64_cmpxchg((v), c, c + (a));
15279 +
15280 + asm volatile("add %2,%0\n"
15281 +
15282 +#ifdef CONFIG_PAX_REFCOUNT
15283 + "jno 0f\n"
15284 + "sub %2,%0\n"
15285 + "int $4\n0:\n"
15286 + _ASM_EXTABLE(0b, 0b)
15287 +#endif
15288 +
15289 + : "=r" (new)
15290 + : "0" (c), "ir" (a));
15291 +
15292 + old = atomic64_cmpxchg(v, c, new);
15293 if (likely(old == c))
15294 break;
15295 c = old;
15296 }
15297 - return c != (u);
15298 + return c != u;
15299 }
15300
15301 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
15302 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
15303 index 41639ce..ebce552 100644
15304 --- a/arch/x86/include/asm/bitops.h
15305 +++ b/arch/x86/include/asm/bitops.h
15306 @@ -48,7 +48,7 @@
15307 * a mask operation on a byte.
15308 */
15309 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
15310 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
15311 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
15312 #define CONST_MASK(nr) (1 << ((nr) & 7))
15313
15314 /**
15315 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
15316 *
15317 * Undefined if no bit exists, so code should check against 0 first.
15318 */
15319 -static inline unsigned long __ffs(unsigned long word)
15320 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
15321 {
15322 asm("rep; bsf %1,%0"
15323 : "=r" (word)
15324 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
15325 *
15326 * Undefined if no zero exists, so code should check against ~0UL first.
15327 */
15328 -static inline unsigned long ffz(unsigned long word)
15329 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
15330 {
15331 asm("rep; bsf %1,%0"
15332 : "=r" (word)
15333 @@ -389,7 +389,7 @@ static inline unsigned long ffz(unsigned long word)
15334 *
15335 * Undefined if no set bit exists, so code should check against 0 first.
15336 */
15337 -static inline unsigned long __fls(unsigned long word)
15338 +static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
15339 {
15340 asm("bsr %1,%0"
15341 : "=r" (word)
15342 @@ -452,7 +452,7 @@ static inline int ffs(int x)
15343 * set bit if value is nonzero. The last (most significant) bit is
15344 * at position 32.
15345 */
15346 -static inline int fls(int x)
15347 +static inline int __intentional_overflow(-1) fls(int x)
15348 {
15349 int r;
15350
15351 @@ -494,7 +494,7 @@ static inline int fls(int x)
15352 * at position 64.
15353 */
15354 #ifdef CONFIG_X86_64
15355 -static __always_inline int fls64(__u64 x)
15356 +static __always_inline long fls64(__u64 x)
15357 {
15358 int bitpos = -1;
15359 /*
15360 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
15361 index 4fa687a..60f2d39 100644
15362 --- a/arch/x86/include/asm/boot.h
15363 +++ b/arch/x86/include/asm/boot.h
15364 @@ -6,10 +6,15 @@
15365 #include <uapi/asm/boot.h>
15366
15367 /* Physical address where kernel should be loaded. */
15368 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15369 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15370 + (CONFIG_PHYSICAL_ALIGN - 1)) \
15371 & ~(CONFIG_PHYSICAL_ALIGN - 1))
15372
15373 +#ifndef __ASSEMBLY__
15374 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
15375 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
15376 +#endif
15377 +
15378 /* Minimum kernel alignment, as a power of two */
15379 #ifdef CONFIG_X86_64
15380 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
15381 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
15382 index 48f99f1..d78ebf9 100644
15383 --- a/arch/x86/include/asm/cache.h
15384 +++ b/arch/x86/include/asm/cache.h
15385 @@ -5,12 +5,13 @@
15386
15387 /* L1 cache line size */
15388 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
15389 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
15390 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
15391
15392 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
15393 +#define __read_only __attribute__((__section__(".data..read_only")))
15394
15395 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
15396 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
15397 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
15398
15399 #ifdef CONFIG_X86_VSMP
15400 #ifdef CONFIG_SMP
15401 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
15402 index 9863ee3..4a1f8e1 100644
15403 --- a/arch/x86/include/asm/cacheflush.h
15404 +++ b/arch/x86/include/asm/cacheflush.h
15405 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
15406 unsigned long pg_flags = pg->flags & _PGMT_MASK;
15407
15408 if (pg_flags == _PGMT_DEFAULT)
15409 - return -1;
15410 + return ~0UL;
15411 else if (pg_flags == _PGMT_WC)
15412 return _PAGE_CACHE_WC;
15413 else if (pg_flags == _PGMT_UC_MINUS)
15414 diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
15415 index 0fa6750..cb7b2c3 100644
15416 --- a/arch/x86/include/asm/calling.h
15417 +++ b/arch/x86/include/asm/calling.h
15418 @@ -80,103 +80,113 @@ For 32-bit we have the following conventions - kernel is built with
15419 #define RSP 152
15420 #define SS 160
15421
15422 -#define ARGOFFSET R11
15423 -#define SWFRAME ORIG_RAX
15424 +#define ARGOFFSET R15
15425
15426 .macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
15427 - subq $9*8+\addskip, %rsp
15428 - CFI_ADJUST_CFA_OFFSET 9*8+\addskip
15429 - movq_cfi rdi, 8*8
15430 - movq_cfi rsi, 7*8
15431 - movq_cfi rdx, 6*8
15432 + subq $ORIG_RAX-ARGOFFSET+\addskip, %rsp
15433 + CFI_ADJUST_CFA_OFFSET ORIG_RAX-ARGOFFSET+\addskip
15434 + movq_cfi rdi, RDI
15435 + movq_cfi rsi, RSI
15436 + movq_cfi rdx, RDX
15437
15438 .if \save_rcx
15439 - movq_cfi rcx, 5*8
15440 + movq_cfi rcx, RCX
15441 .endif
15442
15443 - movq_cfi rax, 4*8
15444 + movq_cfi rax, RAX
15445
15446 .if \save_r891011
15447 - movq_cfi r8, 3*8
15448 - movq_cfi r9, 2*8
15449 - movq_cfi r10, 1*8
15450 - movq_cfi r11, 0*8
15451 + movq_cfi r8, R8
15452 + movq_cfi r9, R9
15453 + movq_cfi r10, R10
15454 + movq_cfi r11, R11
15455 .endif
15456
15457 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15458 + movq_cfi r12, R12
15459 +#endif
15460 +
15461 .endm
15462
15463 -#define ARG_SKIP (9*8)
15464 +#define ARG_SKIP ORIG_RAX
15465
15466 .macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
15467 rstor_r8910=1, rstor_rdx=1
15468 +
15469 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15470 + movq_cfi_restore R12, r12
15471 +#endif
15472 +
15473 .if \rstor_r11
15474 - movq_cfi_restore 0*8, r11
15475 + movq_cfi_restore R11, r11
15476 .endif
15477
15478 .if \rstor_r8910
15479 - movq_cfi_restore 1*8, r10
15480 - movq_cfi_restore 2*8, r9
15481 - movq_cfi_restore 3*8, r8
15482 + movq_cfi_restore R10, r10
15483 + movq_cfi_restore R9, r9
15484 + movq_cfi_restore R8, r8
15485 .endif
15486
15487 .if \rstor_rax
15488 - movq_cfi_restore 4*8, rax
15489 + movq_cfi_restore RAX, rax
15490 .endif
15491
15492 .if \rstor_rcx
15493 - movq_cfi_restore 5*8, rcx
15494 + movq_cfi_restore RCX, rcx
15495 .endif
15496
15497 .if \rstor_rdx
15498 - movq_cfi_restore 6*8, rdx
15499 + movq_cfi_restore RDX, rdx
15500 .endif
15501
15502 - movq_cfi_restore 7*8, rsi
15503 - movq_cfi_restore 8*8, rdi
15504 + movq_cfi_restore RSI, rsi
15505 + movq_cfi_restore RDI, rdi
15506
15507 - .if ARG_SKIP+\addskip > 0
15508 - addq $ARG_SKIP+\addskip, %rsp
15509 - CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip)
15510 + .if ORIG_RAX+\addskip > 0
15511 + addq $ORIG_RAX+\addskip, %rsp
15512 + CFI_ADJUST_CFA_OFFSET -(ORIG_RAX+\addskip)
15513 .endif
15514 .endm
15515
15516 - .macro LOAD_ARGS offset, skiprax=0
15517 - movq \offset(%rsp), %r11
15518 - movq \offset+8(%rsp), %r10
15519 - movq \offset+16(%rsp), %r9
15520 - movq \offset+24(%rsp), %r8
15521 - movq \offset+40(%rsp), %rcx
15522 - movq \offset+48(%rsp), %rdx
15523 - movq \offset+56(%rsp), %rsi
15524 - movq \offset+64(%rsp), %rdi
15525 + .macro LOAD_ARGS skiprax=0
15526 + movq R11(%rsp), %r11
15527 + movq R10(%rsp), %r10
15528 + movq R9(%rsp), %r9
15529 + movq R8(%rsp), %r8
15530 + movq RCX(%rsp), %rcx
15531 + movq RDX(%rsp), %rdx
15532 + movq RSI(%rsp), %rsi
15533 + movq RDI(%rsp), %rdi
15534 .if \skiprax
15535 .else
15536 - movq \offset+72(%rsp), %rax
15537 + movq RAX(%rsp), %rax
15538 .endif
15539 .endm
15540
15541 -#define REST_SKIP (6*8)
15542 -
15543 .macro SAVE_REST
15544 - subq $REST_SKIP, %rsp
15545 - CFI_ADJUST_CFA_OFFSET REST_SKIP
15546 - movq_cfi rbx, 5*8
15547 - movq_cfi rbp, 4*8
15548 - movq_cfi r12, 3*8
15549 - movq_cfi r13, 2*8
15550 - movq_cfi r14, 1*8
15551 - movq_cfi r15, 0*8
15552 + movq_cfi rbx, RBX
15553 + movq_cfi rbp, RBP
15554 +
15555 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15556 + movq_cfi r12, R12
15557 +#endif
15558 +
15559 + movq_cfi r13, R13
15560 + movq_cfi r14, R14
15561 + movq_cfi r15, R15
15562 .endm
15563
15564 .macro RESTORE_REST
15565 - movq_cfi_restore 0*8, r15
15566 - movq_cfi_restore 1*8, r14
15567 - movq_cfi_restore 2*8, r13
15568 - movq_cfi_restore 3*8, r12
15569 - movq_cfi_restore 4*8, rbp
15570 - movq_cfi_restore 5*8, rbx
15571 - addq $REST_SKIP, %rsp
15572 - CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
15573 + movq_cfi_restore R15, r15
15574 + movq_cfi_restore R14, r14
15575 + movq_cfi_restore R13, r13
15576 +
15577 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15578 + movq_cfi_restore R12, r12
15579 +#endif
15580 +
15581 + movq_cfi_restore RBP, rbp
15582 + movq_cfi_restore RBX, rbx
15583 .endm
15584
15585 .macro SAVE_ALL
15586 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
15587 index f50de69..2b0a458 100644
15588 --- a/arch/x86/include/asm/checksum_32.h
15589 +++ b/arch/x86/include/asm/checksum_32.h
15590 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
15591 int len, __wsum sum,
15592 int *src_err_ptr, int *dst_err_ptr);
15593
15594 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
15595 + int len, __wsum sum,
15596 + int *src_err_ptr, int *dst_err_ptr);
15597 +
15598 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
15599 + int len, __wsum sum,
15600 + int *src_err_ptr, int *dst_err_ptr);
15601 +
15602 /*
15603 * Note: when you get a NULL pointer exception here this means someone
15604 * passed in an incorrect kernel address to one of these functions.
15605 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
15606
15607 might_sleep();
15608 stac();
15609 - ret = csum_partial_copy_generic((__force void *)src, dst,
15610 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
15611 len, sum, err_ptr, NULL);
15612 clac();
15613
15614 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
15615 might_sleep();
15616 if (access_ok(VERIFY_WRITE, dst, len)) {
15617 stac();
15618 - ret = csum_partial_copy_generic(src, (__force void *)dst,
15619 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
15620 len, sum, NULL, err_ptr);
15621 clac();
15622 return ret;
15623 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
15624 index d47786a..ce1b05d 100644
15625 --- a/arch/x86/include/asm/cmpxchg.h
15626 +++ b/arch/x86/include/asm/cmpxchg.h
15627 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
15628 __compiletime_error("Bad argument size for cmpxchg");
15629 extern void __xadd_wrong_size(void)
15630 __compiletime_error("Bad argument size for xadd");
15631 +extern void __xadd_check_overflow_wrong_size(void)
15632 + __compiletime_error("Bad argument size for xadd_check_overflow");
15633 extern void __add_wrong_size(void)
15634 __compiletime_error("Bad argument size for add");
15635 +extern void __add_check_overflow_wrong_size(void)
15636 + __compiletime_error("Bad argument size for add_check_overflow");
15637
15638 /*
15639 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
15640 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
15641 __ret; \
15642 })
15643
15644 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
15645 + ({ \
15646 + __typeof__ (*(ptr)) __ret = (arg); \
15647 + switch (sizeof(*(ptr))) { \
15648 + case __X86_CASE_L: \
15649 + asm volatile (lock #op "l %0, %1\n" \
15650 + "jno 0f\n" \
15651 + "mov %0,%1\n" \
15652 + "int $4\n0:\n" \
15653 + _ASM_EXTABLE(0b, 0b) \
15654 + : "+r" (__ret), "+m" (*(ptr)) \
15655 + : : "memory", "cc"); \
15656 + break; \
15657 + case __X86_CASE_Q: \
15658 + asm volatile (lock #op "q %q0, %1\n" \
15659 + "jno 0f\n" \
15660 + "mov %0,%1\n" \
15661 + "int $4\n0:\n" \
15662 + _ASM_EXTABLE(0b, 0b) \
15663 + : "+r" (__ret), "+m" (*(ptr)) \
15664 + : : "memory", "cc"); \
15665 + break; \
15666 + default: \
15667 + __ ## op ## _check_overflow_wrong_size(); \
15668 + } \
15669 + __ret; \
15670 + })
15671 +
15672 /*
15673 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
15674 * Since this is generally used to protect other memory information, we
15675 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
15676 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
15677 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
15678
15679 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
15680 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
15681 +
15682 #define __add(ptr, inc, lock) \
15683 ({ \
15684 __typeof__ (*(ptr)) __ret = (inc); \
15685 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
15686 index 59c6c40..5e0b22c 100644
15687 --- a/arch/x86/include/asm/compat.h
15688 +++ b/arch/x86/include/asm/compat.h
15689 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
15690 typedef u32 compat_uint_t;
15691 typedef u32 compat_ulong_t;
15692 typedef u64 __attribute__((aligned(4))) compat_u64;
15693 -typedef u32 compat_uptr_t;
15694 +typedef u32 __user compat_uptr_t;
15695
15696 struct compat_timespec {
15697 compat_time_t tv_sec;
15698 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
15699 index 89270b4..f0abf8e 100644
15700 --- a/arch/x86/include/asm/cpufeature.h
15701 +++ b/arch/x86/include/asm/cpufeature.h
15702 @@ -203,7 +203,7 @@
15703 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
15704 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
15705 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
15706 -
15707 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
15708
15709 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
15710 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
15711 @@ -211,7 +211,7 @@
15712 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
15713 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
15714 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
15715 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
15716 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
15717 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
15718 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
15719 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
15720 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
15721 #undef cpu_has_centaur_mcr
15722 #define cpu_has_centaur_mcr 0
15723
15724 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
15725 #endif /* CONFIG_X86_64 */
15726
15727 #if __GNUC__ >= 4
15728 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15729
15730 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
15731 t_warn:
15732 - warn_pre_alternatives();
15733 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
15734 + warn_pre_alternatives();
15735 return false;
15736 #endif
15737
15738 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15739 ".section .discard,\"aw\",@progbits\n"
15740 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15741 ".previous\n"
15742 - ".section .altinstr_replacement,\"ax\"\n"
15743 + ".section .altinstr_replacement,\"a\"\n"
15744 "3: movb $1,%0\n"
15745 "4:\n"
15746 ".previous\n"
15747 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15748 " .byte 2b - 1b\n" /* src len */
15749 " .byte 4f - 3f\n" /* repl len */
15750 ".previous\n"
15751 - ".section .altinstr_replacement,\"ax\"\n"
15752 + ".section .altinstr_replacement,\"a\"\n"
15753 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
15754 "4:\n"
15755 ".previous\n"
15756 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15757 ".section .discard,\"aw\",@progbits\n"
15758 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15759 ".previous\n"
15760 - ".section .altinstr_replacement,\"ax\"\n"
15761 + ".section .altinstr_replacement,\"a\"\n"
15762 "3: movb $0,%0\n"
15763 "4:\n"
15764 ".previous\n"
15765 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15766 ".section .discard,\"aw\",@progbits\n"
15767 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
15768 ".previous\n"
15769 - ".section .altinstr_replacement,\"ax\"\n"
15770 + ".section .altinstr_replacement,\"a\"\n"
15771 "5: movb $1,%0\n"
15772 "6:\n"
15773 ".previous\n"
15774 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
15775 index b90e5df..b462c91 100644
15776 --- a/arch/x86/include/asm/desc.h
15777 +++ b/arch/x86/include/asm/desc.h
15778 @@ -4,6 +4,7 @@
15779 #include <asm/desc_defs.h>
15780 #include <asm/ldt.h>
15781 #include <asm/mmu.h>
15782 +#include <asm/pgtable.h>
15783
15784 #include <linux/smp.h>
15785 #include <linux/percpu.h>
15786 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15787
15788 desc->type = (info->read_exec_only ^ 1) << 1;
15789 desc->type |= info->contents << 2;
15790 + desc->type |= info->seg_not_present ^ 1;
15791
15792 desc->s = 1;
15793 desc->dpl = 0x3;
15794 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15795 }
15796
15797 extern struct desc_ptr idt_descr;
15798 -extern gate_desc idt_table[];
15799 -extern struct desc_ptr debug_idt_descr;
15800 -extern gate_desc debug_idt_table[];
15801 -
15802 -struct gdt_page {
15803 - struct desc_struct gdt[GDT_ENTRIES];
15804 -} __attribute__((aligned(PAGE_SIZE)));
15805 -
15806 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15807 +extern gate_desc idt_table[IDT_ENTRIES];
15808 +extern const struct desc_ptr debug_idt_descr;
15809 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15810
15811 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15812 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15813 {
15814 - return per_cpu(gdt_page, cpu).gdt;
15815 + return cpu_gdt_table[cpu];
15816 }
15817
15818 #ifdef CONFIG_X86_64
15819 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15820 unsigned long base, unsigned dpl, unsigned flags,
15821 unsigned short seg)
15822 {
15823 - gate->a = (seg << 16) | (base & 0xffff);
15824 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15825 + gate->gate.offset_low = base;
15826 + gate->gate.seg = seg;
15827 + gate->gate.reserved = 0;
15828 + gate->gate.type = type;
15829 + gate->gate.s = 0;
15830 + gate->gate.dpl = dpl;
15831 + gate->gate.p = 1;
15832 + gate->gate.offset_high = base >> 16;
15833 }
15834
15835 #endif
15836 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15837
15838 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15839 {
15840 + pax_open_kernel();
15841 memcpy(&idt[entry], gate, sizeof(*gate));
15842 + pax_close_kernel();
15843 }
15844
15845 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15846 {
15847 + pax_open_kernel();
15848 memcpy(&ldt[entry], desc, 8);
15849 + pax_close_kernel();
15850 }
15851
15852 static inline void
15853 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15854 default: size = sizeof(*gdt); break;
15855 }
15856
15857 + pax_open_kernel();
15858 memcpy(&gdt[entry], desc, size);
15859 + pax_close_kernel();
15860 }
15861
15862 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15863 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15864
15865 static inline void native_load_tr_desc(void)
15866 {
15867 + pax_open_kernel();
15868 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15869 + pax_close_kernel();
15870 }
15871
15872 static inline void native_load_gdt(const struct desc_ptr *dtr)
15873 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15874 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15875 unsigned int i;
15876
15877 + pax_open_kernel();
15878 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15879 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15880 + pax_close_kernel();
15881 }
15882
15883 #define _LDT_empty(info) \
15884 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15885 preempt_enable();
15886 }
15887
15888 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15889 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15890 {
15891 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15892 }
15893 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15894 }
15895
15896 #ifdef CONFIG_X86_64
15897 -static inline void set_nmi_gate(int gate, void *addr)
15898 +static inline void set_nmi_gate(int gate, const void *addr)
15899 {
15900 gate_desc s;
15901
15902 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15903 #endif
15904
15905 #ifdef CONFIG_TRACING
15906 -extern struct desc_ptr trace_idt_descr;
15907 -extern gate_desc trace_idt_table[];
15908 +extern const struct desc_ptr trace_idt_descr;
15909 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15910 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15911 {
15912 write_idt_entry(trace_idt_table, entry, gate);
15913 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15914 }
15915 #endif
15916
15917 -static inline void _set_gate(int gate, unsigned type, void *addr,
15918 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15919 unsigned dpl, unsigned ist, unsigned seg)
15920 {
15921 gate_desc s;
15922 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15923 * Pentium F0 0F bugfix can have resulted in the mapped
15924 * IDT being write-protected.
15925 */
15926 -static inline void set_intr_gate(unsigned int n, void *addr)
15927 +static inline void set_intr_gate(unsigned int n, const void *addr)
15928 {
15929 BUG_ON((unsigned)n > 0xFF);
15930 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15931 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15932 /*
15933 * This routine sets up an interrupt gate at directory privilege level 3.
15934 */
15935 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15936 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15937 {
15938 BUG_ON((unsigned)n > 0xFF);
15939 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15940 }
15941
15942 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15943 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15944 {
15945 BUG_ON((unsigned)n > 0xFF);
15946 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15947 }
15948
15949 -static inline void set_trap_gate(unsigned int n, void *addr)
15950 +static inline void set_trap_gate(unsigned int n, const void *addr)
15951 {
15952 BUG_ON((unsigned)n > 0xFF);
15953 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15954 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15955 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15956 {
15957 BUG_ON((unsigned)n > 0xFF);
15958 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15959 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15960 }
15961
15962 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15963 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15964 {
15965 BUG_ON((unsigned)n > 0xFF);
15966 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15967 }
15968
15969 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15970 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15971 {
15972 BUG_ON((unsigned)n > 0xFF);
15973 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15974 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15975 else
15976 load_idt((const struct desc_ptr *)&idt_descr);
15977 }
15978 +
15979 +#ifdef CONFIG_X86_32
15980 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15981 +{
15982 + struct desc_struct d;
15983 +
15984 + if (likely(limit))
15985 + limit = (limit - 1UL) >> PAGE_SHIFT;
15986 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15987 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15988 +}
15989 +#endif
15990 +
15991 #endif /* _ASM_X86_DESC_H */
15992 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15993 index 278441f..b95a174 100644
15994 --- a/arch/x86/include/asm/desc_defs.h
15995 +++ b/arch/x86/include/asm/desc_defs.h
15996 @@ -31,6 +31,12 @@ struct desc_struct {
15997 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15998 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15999 };
16000 + struct {
16001 + u16 offset_low;
16002 + u16 seg;
16003 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
16004 + unsigned offset_high: 16;
16005 + } gate;
16006 };
16007 } __attribute__((packed));
16008
16009 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
16010 index ced283a..ffe04cc 100644
16011 --- a/arch/x86/include/asm/div64.h
16012 +++ b/arch/x86/include/asm/div64.h
16013 @@ -39,7 +39,7 @@
16014 __mod; \
16015 })
16016
16017 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16018 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16019 {
16020 union {
16021 u64 v64;
16022 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
16023 index 9c999c1..3860cb8 100644
16024 --- a/arch/x86/include/asm/elf.h
16025 +++ b/arch/x86/include/asm/elf.h
16026 @@ -243,7 +243,25 @@ extern int force_personality32;
16027 the loader. We need to make sure that it is out of the way of the program
16028 that it will "exec", and that there is sufficient room for the brk. */
16029
16030 +#ifdef CONFIG_PAX_SEGMEXEC
16031 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
16032 +#else
16033 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
16034 +#endif
16035 +
16036 +#ifdef CONFIG_PAX_ASLR
16037 +#ifdef CONFIG_X86_32
16038 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
16039 +
16040 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
16041 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
16042 +#else
16043 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
16044 +
16045 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
16046 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
16047 +#endif
16048 +#endif
16049
16050 /* This yields a mask that user programs can use to figure out what
16051 instruction set this CPU supports. This could be done in user space,
16052 @@ -296,16 +314,12 @@ do { \
16053
16054 #define ARCH_DLINFO \
16055 do { \
16056 - if (vdso_enabled) \
16057 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
16058 - (unsigned long)current->mm->context.vdso); \
16059 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
16060 } while (0)
16061
16062 #define ARCH_DLINFO_X32 \
16063 do { \
16064 - if (vdso_enabled) \
16065 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
16066 - (unsigned long)current->mm->context.vdso); \
16067 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
16068 } while (0)
16069
16070 #define AT_SYSINFO 32
16071 @@ -320,7 +334,7 @@ else \
16072
16073 #endif /* !CONFIG_X86_32 */
16074
16075 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
16076 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
16077
16078 #define VDSO_ENTRY \
16079 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
16080 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
16081 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
16082 #define compat_arch_setup_additional_pages syscall32_setup_pages
16083
16084 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
16085 -#define arch_randomize_brk arch_randomize_brk
16086 -
16087 /*
16088 * True on X86_32 or when emulating IA32 on X86_64
16089 */
16090 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
16091 index 77a99ac..39ff7f5 100644
16092 --- a/arch/x86/include/asm/emergency-restart.h
16093 +++ b/arch/x86/include/asm/emergency-restart.h
16094 @@ -1,6 +1,6 @@
16095 #ifndef _ASM_X86_EMERGENCY_RESTART_H
16096 #define _ASM_X86_EMERGENCY_RESTART_H
16097
16098 -extern void machine_emergency_restart(void);
16099 +extern void machine_emergency_restart(void) __noreturn;
16100
16101 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
16102 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
16103 index 5be9f87..0320912 100644
16104 --- a/arch/x86/include/asm/fpu-internal.h
16105 +++ b/arch/x86/include/asm/fpu-internal.h
16106 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16107 #define user_insn(insn, output, input...) \
16108 ({ \
16109 int err; \
16110 + pax_open_userland(); \
16111 asm volatile(ASM_STAC "\n" \
16112 - "1:" #insn "\n\t" \
16113 + "1:" \
16114 + __copyuser_seg \
16115 + #insn "\n\t" \
16116 "2: " ASM_CLAC "\n" \
16117 ".section .fixup,\"ax\"\n" \
16118 "3: movl $-1,%[err]\n" \
16119 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16120 _ASM_EXTABLE(1b, 3b) \
16121 : [err] "=r" (err), output \
16122 : "0"(0), input); \
16123 + pax_close_userland(); \
16124 err; \
16125 })
16126
16127 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
16128 "fnclex\n\t"
16129 "emms\n\t"
16130 "fildl %P[addr]" /* set F?P to defined value */
16131 - : : [addr] "m" (tsk->thread.fpu.has_fpu));
16132 + : : [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
16133 }
16134
16135 return fpu_restore_checking(&tsk->thread.fpu);
16136 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
16137 index be27ba1..04a8801 100644
16138 --- a/arch/x86/include/asm/futex.h
16139 +++ b/arch/x86/include/asm/futex.h
16140 @@ -12,6 +12,7 @@
16141 #include <asm/smap.h>
16142
16143 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
16144 + typecheck(u32 __user *, uaddr); \
16145 asm volatile("\t" ASM_STAC "\n" \
16146 "1:\t" insn "\n" \
16147 "2:\t" ASM_CLAC "\n" \
16148 @@ -20,15 +21,16 @@
16149 "\tjmp\t2b\n" \
16150 "\t.previous\n" \
16151 _ASM_EXTABLE(1b, 3b) \
16152 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
16153 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
16154 : "i" (-EFAULT), "0" (oparg), "1" (0))
16155
16156 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
16157 + typecheck(u32 __user *, uaddr); \
16158 asm volatile("\t" ASM_STAC "\n" \
16159 "1:\tmovl %2, %0\n" \
16160 "\tmovl\t%0, %3\n" \
16161 "\t" insn "\n" \
16162 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
16163 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
16164 "\tjnz\t1b\n" \
16165 "3:\t" ASM_CLAC "\n" \
16166 "\t.section .fixup,\"ax\"\n" \
16167 @@ -38,7 +40,7 @@
16168 _ASM_EXTABLE(1b, 4b) \
16169 _ASM_EXTABLE(2b, 4b) \
16170 : "=&a" (oldval), "=&r" (ret), \
16171 - "+m" (*uaddr), "=&r" (tem) \
16172 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
16173 : "r" (oparg), "i" (-EFAULT), "1" (0))
16174
16175 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16176 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16177
16178 pagefault_disable();
16179
16180 + pax_open_userland();
16181 switch (op) {
16182 case FUTEX_OP_SET:
16183 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
16184 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
16185 break;
16186 case FUTEX_OP_ADD:
16187 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
16188 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
16189 uaddr, oparg);
16190 break;
16191 case FUTEX_OP_OR:
16192 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16193 default:
16194 ret = -ENOSYS;
16195 }
16196 + pax_close_userland();
16197
16198 pagefault_enable();
16199
16200 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
16201 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
16202 return -EFAULT;
16203
16204 + pax_open_userland();
16205 asm volatile("\t" ASM_STAC "\n"
16206 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
16207 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
16208 "2:\t" ASM_CLAC "\n"
16209 "\t.section .fixup, \"ax\"\n"
16210 "3:\tmov %3, %0\n"
16211 "\tjmp 2b\n"
16212 "\t.previous\n"
16213 _ASM_EXTABLE(1b, 3b)
16214 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
16215 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
16216 : "i" (-EFAULT), "r" (newval), "1" (oldval)
16217 : "memory"
16218 );
16219 + pax_close_userland();
16220
16221 *uval = oldval;
16222 return ret;
16223 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
16224 index 92b3bae..3866449 100644
16225 --- a/arch/x86/include/asm/hw_irq.h
16226 +++ b/arch/x86/include/asm/hw_irq.h
16227 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
16228 extern void enable_IO_APIC(void);
16229
16230 /* Statistics */
16231 -extern atomic_t irq_err_count;
16232 -extern atomic_t irq_mis_count;
16233 +extern atomic_unchecked_t irq_err_count;
16234 +extern atomic_unchecked_t irq_mis_count;
16235
16236 /* EISA */
16237 extern void eisa_set_level_irq(unsigned int irq);
16238 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
16239 index a203659..9889f1c 100644
16240 --- a/arch/x86/include/asm/i8259.h
16241 +++ b/arch/x86/include/asm/i8259.h
16242 @@ -62,7 +62,7 @@ struct legacy_pic {
16243 void (*init)(int auto_eoi);
16244 int (*irq_pending)(unsigned int irq);
16245 void (*make_irq)(unsigned int irq);
16246 -};
16247 +} __do_const;
16248
16249 extern struct legacy_pic *legacy_pic;
16250 extern struct legacy_pic null_legacy_pic;
16251 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
16252 index 34f69cb..6d95446 100644
16253 --- a/arch/x86/include/asm/io.h
16254 +++ b/arch/x86/include/asm/io.h
16255 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
16256 "m" (*(volatile type __force *)addr) barrier); }
16257
16258 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
16259 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
16260 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
16261 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
16262 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
16263
16264 build_mmio_read(__readb, "b", unsigned char, "=q", )
16265 -build_mmio_read(__readw, "w", unsigned short, "=r", )
16266 -build_mmio_read(__readl, "l", unsigned int, "=r", )
16267 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
16268 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
16269
16270 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
16271 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
16272 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
16273 return ioremap_nocache(offset, size);
16274 }
16275
16276 -extern void iounmap(volatile void __iomem *addr);
16277 +extern void iounmap(const volatile void __iomem *addr);
16278
16279 extern void set_iounmap_nonlazy(void);
16280
16281 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
16282
16283 #include <linux/vmalloc.h>
16284
16285 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
16286 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
16287 +{
16288 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16289 +}
16290 +
16291 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
16292 +{
16293 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16294 +}
16295 +
16296 /*
16297 * Convert a virtual cached pointer to an uncached pointer
16298 */
16299 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
16300 index bba3cf8..06bc8da 100644
16301 --- a/arch/x86/include/asm/irqflags.h
16302 +++ b/arch/x86/include/asm/irqflags.h
16303 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
16304 sti; \
16305 sysexit
16306
16307 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
16308 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
16309 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
16310 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
16311 +
16312 #else
16313 #define INTERRUPT_RETURN iret
16314 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
16315 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
16316 index 9454c16..e4100e3 100644
16317 --- a/arch/x86/include/asm/kprobes.h
16318 +++ b/arch/x86/include/asm/kprobes.h
16319 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
16320 #define RELATIVEJUMP_SIZE 5
16321 #define RELATIVECALL_OPCODE 0xe8
16322 #define RELATIVE_ADDR_SIZE 4
16323 -#define MAX_STACK_SIZE 64
16324 -#define MIN_STACK_SIZE(ADDR) \
16325 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
16326 - THREAD_SIZE - (unsigned long)(ADDR))) \
16327 - ? (MAX_STACK_SIZE) \
16328 - : (((unsigned long)current_thread_info()) + \
16329 - THREAD_SIZE - (unsigned long)(ADDR)))
16330 +#define MAX_STACK_SIZE 64UL
16331 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
16332
16333 #define flush_insn_slot(p) do { } while (0)
16334
16335 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
16336 index 2d89e39..baee879 100644
16337 --- a/arch/x86/include/asm/local.h
16338 +++ b/arch/x86/include/asm/local.h
16339 @@ -10,33 +10,97 @@ typedef struct {
16340 atomic_long_t a;
16341 } local_t;
16342
16343 +typedef struct {
16344 + atomic_long_unchecked_t a;
16345 +} local_unchecked_t;
16346 +
16347 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
16348
16349 #define local_read(l) atomic_long_read(&(l)->a)
16350 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
16351 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
16352 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
16353
16354 static inline void local_inc(local_t *l)
16355 {
16356 - asm volatile(_ASM_INC "%0"
16357 + asm volatile(_ASM_INC "%0\n"
16358 +
16359 +#ifdef CONFIG_PAX_REFCOUNT
16360 + "jno 0f\n"
16361 + _ASM_DEC "%0\n"
16362 + "int $4\n0:\n"
16363 + _ASM_EXTABLE(0b, 0b)
16364 +#endif
16365 +
16366 + : "+m" (l->a.counter));
16367 +}
16368 +
16369 +static inline void local_inc_unchecked(local_unchecked_t *l)
16370 +{
16371 + asm volatile(_ASM_INC "%0\n"
16372 : "+m" (l->a.counter));
16373 }
16374
16375 static inline void local_dec(local_t *l)
16376 {
16377 - asm volatile(_ASM_DEC "%0"
16378 + asm volatile(_ASM_DEC "%0\n"
16379 +
16380 +#ifdef CONFIG_PAX_REFCOUNT
16381 + "jno 0f\n"
16382 + _ASM_INC "%0\n"
16383 + "int $4\n0:\n"
16384 + _ASM_EXTABLE(0b, 0b)
16385 +#endif
16386 +
16387 + : "+m" (l->a.counter));
16388 +}
16389 +
16390 +static inline void local_dec_unchecked(local_unchecked_t *l)
16391 +{
16392 + asm volatile(_ASM_DEC "%0\n"
16393 : "+m" (l->a.counter));
16394 }
16395
16396 static inline void local_add(long i, local_t *l)
16397 {
16398 - asm volatile(_ASM_ADD "%1,%0"
16399 + asm volatile(_ASM_ADD "%1,%0\n"
16400 +
16401 +#ifdef CONFIG_PAX_REFCOUNT
16402 + "jno 0f\n"
16403 + _ASM_SUB "%1,%0\n"
16404 + "int $4\n0:\n"
16405 + _ASM_EXTABLE(0b, 0b)
16406 +#endif
16407 +
16408 + : "+m" (l->a.counter)
16409 + : "ir" (i));
16410 +}
16411 +
16412 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
16413 +{
16414 + asm volatile(_ASM_ADD "%1,%0\n"
16415 : "+m" (l->a.counter)
16416 : "ir" (i));
16417 }
16418
16419 static inline void local_sub(long i, local_t *l)
16420 {
16421 - asm volatile(_ASM_SUB "%1,%0"
16422 + asm volatile(_ASM_SUB "%1,%0\n"
16423 +
16424 +#ifdef CONFIG_PAX_REFCOUNT
16425 + "jno 0f\n"
16426 + _ASM_ADD "%1,%0\n"
16427 + "int $4\n0:\n"
16428 + _ASM_EXTABLE(0b, 0b)
16429 +#endif
16430 +
16431 + : "+m" (l->a.counter)
16432 + : "ir" (i));
16433 +}
16434 +
16435 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
16436 +{
16437 + asm volatile(_ASM_SUB "%1,%0\n"
16438 : "+m" (l->a.counter)
16439 : "ir" (i));
16440 }
16441 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
16442 {
16443 unsigned char c;
16444
16445 - asm volatile(_ASM_SUB "%2,%0; sete %1"
16446 + asm volatile(_ASM_SUB "%2,%0\n"
16447 +
16448 +#ifdef CONFIG_PAX_REFCOUNT
16449 + "jno 0f\n"
16450 + _ASM_ADD "%2,%0\n"
16451 + "int $4\n0:\n"
16452 + _ASM_EXTABLE(0b, 0b)
16453 +#endif
16454 +
16455 + "sete %1\n"
16456 : "+m" (l->a.counter), "=qm" (c)
16457 : "ir" (i) : "memory");
16458 return c;
16459 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
16460 {
16461 unsigned char c;
16462
16463 - asm volatile(_ASM_DEC "%0; sete %1"
16464 + asm volatile(_ASM_DEC "%0\n"
16465 +
16466 +#ifdef CONFIG_PAX_REFCOUNT
16467 + "jno 0f\n"
16468 + _ASM_INC "%0\n"
16469 + "int $4\n0:\n"
16470 + _ASM_EXTABLE(0b, 0b)
16471 +#endif
16472 +
16473 + "sete %1\n"
16474 : "+m" (l->a.counter), "=qm" (c)
16475 : : "memory");
16476 return c != 0;
16477 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
16478 {
16479 unsigned char c;
16480
16481 - asm volatile(_ASM_INC "%0; sete %1"
16482 + asm volatile(_ASM_INC "%0\n"
16483 +
16484 +#ifdef CONFIG_PAX_REFCOUNT
16485 + "jno 0f\n"
16486 + _ASM_DEC "%0\n"
16487 + "int $4\n0:\n"
16488 + _ASM_EXTABLE(0b, 0b)
16489 +#endif
16490 +
16491 + "sete %1\n"
16492 : "+m" (l->a.counter), "=qm" (c)
16493 : : "memory");
16494 return c != 0;
16495 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
16496 {
16497 unsigned char c;
16498
16499 - asm volatile(_ASM_ADD "%2,%0; sets %1"
16500 + asm volatile(_ASM_ADD "%2,%0\n"
16501 +
16502 +#ifdef CONFIG_PAX_REFCOUNT
16503 + "jno 0f\n"
16504 + _ASM_SUB "%2,%0\n"
16505 + "int $4\n0:\n"
16506 + _ASM_EXTABLE(0b, 0b)
16507 +#endif
16508 +
16509 + "sets %1\n"
16510 : "+m" (l->a.counter), "=qm" (c)
16511 : "ir" (i) : "memory");
16512 return c;
16513 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
16514 static inline long local_add_return(long i, local_t *l)
16515 {
16516 long __i = i;
16517 + asm volatile(_ASM_XADD "%0, %1\n"
16518 +
16519 +#ifdef CONFIG_PAX_REFCOUNT
16520 + "jno 0f\n"
16521 + _ASM_MOV "%0,%1\n"
16522 + "int $4\n0:\n"
16523 + _ASM_EXTABLE(0b, 0b)
16524 +#endif
16525 +
16526 + : "+r" (i), "+m" (l->a.counter)
16527 + : : "memory");
16528 + return i + __i;
16529 +}
16530 +
16531 +/**
16532 + * local_add_return_unchecked - add and return
16533 + * @i: integer value to add
16534 + * @l: pointer to type local_unchecked_t
16535 + *
16536 + * Atomically adds @i to @l and returns @i + @l
16537 + */
16538 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
16539 +{
16540 + long __i = i;
16541 asm volatile(_ASM_XADD "%0, %1;"
16542 : "+r" (i), "+m" (l->a.counter)
16543 : : "memory");
16544 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
16545
16546 #define local_cmpxchg(l, o, n) \
16547 (cmpxchg_local(&((l)->a.counter), (o), (n)))
16548 +#define local_cmpxchg_unchecked(l, o, n) \
16549 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
16550 /* Always has a lock prefix */
16551 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
16552
16553 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
16554 new file mode 100644
16555 index 0000000..2bfd3ba
16556 --- /dev/null
16557 +++ b/arch/x86/include/asm/mman.h
16558 @@ -0,0 +1,15 @@
16559 +#ifndef _X86_MMAN_H
16560 +#define _X86_MMAN_H
16561 +
16562 +#include <uapi/asm/mman.h>
16563 +
16564 +#ifdef __KERNEL__
16565 +#ifndef __ASSEMBLY__
16566 +#ifdef CONFIG_X86_32
16567 +#define arch_mmap_check i386_mmap_check
16568 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
16569 +#endif
16570 +#endif
16571 +#endif
16572 +
16573 +#endif /* X86_MMAN_H */
16574 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
16575 index 5f55e69..e20bfb1 100644
16576 --- a/arch/x86/include/asm/mmu.h
16577 +++ b/arch/x86/include/asm/mmu.h
16578 @@ -9,7 +9,7 @@
16579 * we put the segment information here.
16580 */
16581 typedef struct {
16582 - void *ldt;
16583 + struct desc_struct *ldt;
16584 int size;
16585
16586 #ifdef CONFIG_X86_64
16587 @@ -18,7 +18,19 @@ typedef struct {
16588 #endif
16589
16590 struct mutex lock;
16591 - void *vdso;
16592 + unsigned long vdso;
16593 +
16594 +#ifdef CONFIG_X86_32
16595 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
16596 + unsigned long user_cs_base;
16597 + unsigned long user_cs_limit;
16598 +
16599 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16600 + cpumask_t cpu_user_cs_mask;
16601 +#endif
16602 +
16603 +#endif
16604 +#endif
16605 } mm_context_t;
16606
16607 #ifdef CONFIG_SMP
16608 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
16609 index be12c53..4d24039 100644
16610 --- a/arch/x86/include/asm/mmu_context.h
16611 +++ b/arch/x86/include/asm/mmu_context.h
16612 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
16613
16614 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
16615 {
16616 +
16617 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16618 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
16619 + unsigned int i;
16620 + pgd_t *pgd;
16621 +
16622 + pax_open_kernel();
16623 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
16624 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
16625 + set_pgd_batched(pgd+i, native_make_pgd(0));
16626 + pax_close_kernel();
16627 + }
16628 +#endif
16629 +
16630 #ifdef CONFIG_SMP
16631 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
16632 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
16633 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16634 struct task_struct *tsk)
16635 {
16636 unsigned cpu = smp_processor_id();
16637 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16638 + int tlbstate = TLBSTATE_OK;
16639 +#endif
16640
16641 if (likely(prev != next)) {
16642 #ifdef CONFIG_SMP
16643 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16644 + tlbstate = this_cpu_read(cpu_tlbstate.state);
16645 +#endif
16646 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16647 this_cpu_write(cpu_tlbstate.active_mm, next);
16648 #endif
16649 cpumask_set_cpu(cpu, mm_cpumask(next));
16650
16651 /* Re-load page tables */
16652 +#ifdef CONFIG_PAX_PER_CPU_PGD
16653 + pax_open_kernel();
16654 +
16655 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16656 + if (static_cpu_has(X86_FEATURE_PCID))
16657 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16658 + else
16659 +#endif
16660 +
16661 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16662 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16663 + pax_close_kernel();
16664 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
16665 +
16666 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16667 + if (static_cpu_has(X86_FEATURE_PCID)) {
16668 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16669 + u64 descriptor[2];
16670 + descriptor[0] = PCID_USER;
16671 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16672 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16673 + descriptor[0] = PCID_KERNEL;
16674 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16675 + }
16676 + } else {
16677 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16678 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16679 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16680 + else
16681 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16682 + }
16683 + } else
16684 +#endif
16685 +
16686 + load_cr3(get_cpu_pgd(cpu, kernel));
16687 +#else
16688 load_cr3(next->pgd);
16689 +#endif
16690
16691 /* Stop flush ipis for the previous mm */
16692 cpumask_clear_cpu(cpu, mm_cpumask(prev));
16693 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16694 /* Load the LDT, if the LDT is different: */
16695 if (unlikely(prev->context.ldt != next->context.ldt))
16696 load_LDT_nolock(&next->context);
16697 +
16698 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16699 + if (!(__supported_pte_mask & _PAGE_NX)) {
16700 + smp_mb__before_clear_bit();
16701 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
16702 + smp_mb__after_clear_bit();
16703 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16704 + }
16705 +#endif
16706 +
16707 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16708 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
16709 + prev->context.user_cs_limit != next->context.user_cs_limit))
16710 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16711 +#ifdef CONFIG_SMP
16712 + else if (unlikely(tlbstate != TLBSTATE_OK))
16713 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16714 +#endif
16715 +#endif
16716 +
16717 }
16718 + else {
16719 +
16720 +#ifdef CONFIG_PAX_PER_CPU_PGD
16721 + pax_open_kernel();
16722 +
16723 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16724 + if (static_cpu_has(X86_FEATURE_PCID))
16725 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16726 + else
16727 +#endif
16728 +
16729 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16730 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16731 + pax_close_kernel();
16732 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
16733 +
16734 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16735 + if (static_cpu_has(X86_FEATURE_PCID)) {
16736 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16737 + u64 descriptor[2];
16738 + descriptor[0] = PCID_USER;
16739 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16740 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16741 + descriptor[0] = PCID_KERNEL;
16742 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16743 + }
16744 + } else {
16745 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16746 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16747 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16748 + else
16749 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16750 + }
16751 + } else
16752 +#endif
16753 +
16754 + load_cr3(get_cpu_pgd(cpu, kernel));
16755 +#endif
16756 +
16757 #ifdef CONFIG_SMP
16758 - else {
16759 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16760 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
16761
16762 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16763 * tlb flush IPI delivery. We must reload CR3
16764 * to make sure to use no freed page tables.
16765 */
16766 +
16767 +#ifndef CONFIG_PAX_PER_CPU_PGD
16768 load_cr3(next->pgd);
16769 +#endif
16770 +
16771 load_LDT_nolock(&next->context);
16772 +
16773 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
16774 + if (!(__supported_pte_mask & _PAGE_NX))
16775 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16776 +#endif
16777 +
16778 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16779 +#ifdef CONFIG_PAX_PAGEEXEC
16780 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
16781 +#endif
16782 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16783 +#endif
16784 +
16785 }
16786 +#endif
16787 }
16788 -#endif
16789 }
16790
16791 #define activate_mm(prev, next) \
16792 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16793 index e3b7819..b257c64 100644
16794 --- a/arch/x86/include/asm/module.h
16795 +++ b/arch/x86/include/asm/module.h
16796 @@ -5,6 +5,7 @@
16797
16798 #ifdef CONFIG_X86_64
16799 /* X86_64 does not define MODULE_PROC_FAMILY */
16800 +#define MODULE_PROC_FAMILY ""
16801 #elif defined CONFIG_M486
16802 #define MODULE_PROC_FAMILY "486 "
16803 #elif defined CONFIG_M586
16804 @@ -57,8 +58,20 @@
16805 #error unknown processor family
16806 #endif
16807
16808 -#ifdef CONFIG_X86_32
16809 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16810 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16811 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16812 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16813 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16814 +#else
16815 +#define MODULE_PAX_KERNEXEC ""
16816 #endif
16817
16818 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16819 +#define MODULE_PAX_UDEREF "UDEREF "
16820 +#else
16821 +#define MODULE_PAX_UDEREF ""
16822 +#endif
16823 +
16824 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16825 +
16826 #endif /* _ASM_X86_MODULE_H */
16827 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16828 index 86f9301..b365cda 100644
16829 --- a/arch/x86/include/asm/nmi.h
16830 +++ b/arch/x86/include/asm/nmi.h
16831 @@ -40,11 +40,11 @@ struct nmiaction {
16832 nmi_handler_t handler;
16833 unsigned long flags;
16834 const char *name;
16835 -};
16836 +} __do_const;
16837
16838 #define register_nmi_handler(t, fn, fg, n, init...) \
16839 ({ \
16840 - static struct nmiaction init fn##_na = { \
16841 + static const struct nmiaction init fn##_na = { \
16842 .handler = (fn), \
16843 .name = (n), \
16844 .flags = (fg), \
16845 @@ -52,7 +52,7 @@ struct nmiaction {
16846 __register_nmi_handler((t), &fn##_na); \
16847 })
16848
16849 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16850 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16851
16852 void unregister_nmi_handler(unsigned int, const char *);
16853
16854 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16855 index c878924..21f4889 100644
16856 --- a/arch/x86/include/asm/page.h
16857 +++ b/arch/x86/include/asm/page.h
16858 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16859 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16860
16861 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16862 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16863
16864 #define __boot_va(x) __va(x)
16865 #define __boot_pa(x) __pa(x)
16866 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16867 index 0f1ddee..e2fc3d1 100644
16868 --- a/arch/x86/include/asm/page_64.h
16869 +++ b/arch/x86/include/asm/page_64.h
16870 @@ -7,9 +7,9 @@
16871
16872 /* duplicated to the one in bootmem.h */
16873 extern unsigned long max_pfn;
16874 -extern unsigned long phys_base;
16875 +extern const unsigned long phys_base;
16876
16877 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16878 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16879 {
16880 unsigned long y = x - __START_KERNEL_map;
16881
16882 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16883 index 401f350..dee5d13 100644
16884 --- a/arch/x86/include/asm/paravirt.h
16885 +++ b/arch/x86/include/asm/paravirt.h
16886 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16887 return (pmd_t) { ret };
16888 }
16889
16890 -static inline pmdval_t pmd_val(pmd_t pmd)
16891 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16892 {
16893 pmdval_t ret;
16894
16895 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16896 val);
16897 }
16898
16899 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16900 +{
16901 + pgdval_t val = native_pgd_val(pgd);
16902 +
16903 + if (sizeof(pgdval_t) > sizeof(long))
16904 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16905 + val, (u64)val >> 32);
16906 + else
16907 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16908 + val);
16909 +}
16910 +
16911 static inline void pgd_clear(pgd_t *pgdp)
16912 {
16913 set_pgd(pgdp, __pgd(0));
16914 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16915 pv_mmu_ops.set_fixmap(idx, phys, flags);
16916 }
16917
16918 +#ifdef CONFIG_PAX_KERNEXEC
16919 +static inline unsigned long pax_open_kernel(void)
16920 +{
16921 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16922 +}
16923 +
16924 +static inline unsigned long pax_close_kernel(void)
16925 +{
16926 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16927 +}
16928 +#else
16929 +static inline unsigned long pax_open_kernel(void) { return 0; }
16930 +static inline unsigned long pax_close_kernel(void) { return 0; }
16931 +#endif
16932 +
16933 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16934
16935 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16936 @@ -906,7 +933,7 @@ extern void default_banner(void);
16937
16938 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16939 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16940 -#define PARA_INDIRECT(addr) *%cs:addr
16941 +#define PARA_INDIRECT(addr) *%ss:addr
16942 #endif
16943
16944 #define INTERRUPT_RETURN \
16945 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16946 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16947 CLBR_NONE, \
16948 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16949 +
16950 +#define GET_CR0_INTO_RDI \
16951 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16952 + mov %rax,%rdi
16953 +
16954 +#define SET_RDI_INTO_CR0 \
16955 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16956 +
16957 +#define GET_CR3_INTO_RDI \
16958 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16959 + mov %rax,%rdi
16960 +
16961 +#define SET_RDI_INTO_CR3 \
16962 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16963 +
16964 #endif /* CONFIG_X86_32 */
16965
16966 #endif /* __ASSEMBLY__ */
16967 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16968 index aab8f67..2531748 100644
16969 --- a/arch/x86/include/asm/paravirt_types.h
16970 +++ b/arch/x86/include/asm/paravirt_types.h
16971 @@ -84,7 +84,7 @@ struct pv_init_ops {
16972 */
16973 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16974 unsigned long addr, unsigned len);
16975 -};
16976 +} __no_const;
16977
16978
16979 struct pv_lazy_ops {
16980 @@ -98,7 +98,7 @@ struct pv_time_ops {
16981 unsigned long long (*sched_clock)(void);
16982 unsigned long long (*steal_clock)(int cpu);
16983 unsigned long (*get_tsc_khz)(void);
16984 -};
16985 +} __no_const;
16986
16987 struct pv_cpu_ops {
16988 /* hooks for various privileged instructions */
16989 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16990
16991 void (*start_context_switch)(struct task_struct *prev);
16992 void (*end_context_switch)(struct task_struct *next);
16993 -};
16994 +} __no_const;
16995
16996 struct pv_irq_ops {
16997 /*
16998 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16999 unsigned long start_eip,
17000 unsigned long start_esp);
17001 #endif
17002 -};
17003 +} __no_const;
17004
17005 struct pv_mmu_ops {
17006 unsigned long (*read_cr2)(void);
17007 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
17008 struct paravirt_callee_save make_pud;
17009
17010 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
17011 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
17012 #endif /* PAGETABLE_LEVELS == 4 */
17013 #endif /* PAGETABLE_LEVELS >= 3 */
17014
17015 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
17016 an mfn. We can tell which is which from the index. */
17017 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
17018 phys_addr_t phys, pgprot_t flags);
17019 +
17020 +#ifdef CONFIG_PAX_KERNEXEC
17021 + unsigned long (*pax_open_kernel)(void);
17022 + unsigned long (*pax_close_kernel)(void);
17023 +#endif
17024 +
17025 };
17026
17027 struct arch_spinlock;
17028 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
17029 index b4389a4..7024269 100644
17030 --- a/arch/x86/include/asm/pgalloc.h
17031 +++ b/arch/x86/include/asm/pgalloc.h
17032 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
17033 pmd_t *pmd, pte_t *pte)
17034 {
17035 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
17036 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
17037 +}
17038 +
17039 +static inline void pmd_populate_user(struct mm_struct *mm,
17040 + pmd_t *pmd, pte_t *pte)
17041 +{
17042 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
17043 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
17044 }
17045
17046 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
17047
17048 #ifdef CONFIG_X86_PAE
17049 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
17050 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
17051 +{
17052 + pud_populate(mm, pudp, pmd);
17053 +}
17054 #else /* !CONFIG_X86_PAE */
17055 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
17056 {
17057 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
17058 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
17059 }
17060 +
17061 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
17062 +{
17063 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
17064 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
17065 +}
17066 #endif /* CONFIG_X86_PAE */
17067
17068 #if PAGETABLE_LEVELS > 3
17069 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
17070 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
17071 }
17072
17073 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
17074 +{
17075 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
17076 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
17077 +}
17078 +
17079 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
17080 {
17081 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
17082 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
17083 index 3bf2dd0..23d2a9f 100644
17084 --- a/arch/x86/include/asm/pgtable-2level.h
17085 +++ b/arch/x86/include/asm/pgtable-2level.h
17086 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
17087
17088 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17089 {
17090 + pax_open_kernel();
17091 *pmdp = pmd;
17092 + pax_close_kernel();
17093 }
17094
17095 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17096 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
17097 index 81bb91b..9392125 100644
17098 --- a/arch/x86/include/asm/pgtable-3level.h
17099 +++ b/arch/x86/include/asm/pgtable-3level.h
17100 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17101
17102 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17103 {
17104 + pax_open_kernel();
17105 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
17106 + pax_close_kernel();
17107 }
17108
17109 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17110 {
17111 + pax_open_kernel();
17112 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
17113 + pax_close_kernel();
17114 }
17115
17116 /*
17117 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
17118 index bbc8b12..f228861 100644
17119 --- a/arch/x86/include/asm/pgtable.h
17120 +++ b/arch/x86/include/asm/pgtable.h
17121 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17122
17123 #ifndef __PAGETABLE_PUD_FOLDED
17124 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
17125 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
17126 #define pgd_clear(pgd) native_pgd_clear(pgd)
17127 #endif
17128
17129 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17130
17131 #define arch_end_context_switch(prev) do {} while(0)
17132
17133 +#define pax_open_kernel() native_pax_open_kernel()
17134 +#define pax_close_kernel() native_pax_close_kernel()
17135 #endif /* CONFIG_PARAVIRT */
17136
17137 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
17138 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
17139 +
17140 +#ifdef CONFIG_PAX_KERNEXEC
17141 +static inline unsigned long native_pax_open_kernel(void)
17142 +{
17143 + unsigned long cr0;
17144 +
17145 + preempt_disable();
17146 + barrier();
17147 + cr0 = read_cr0() ^ X86_CR0_WP;
17148 + BUG_ON(cr0 & X86_CR0_WP);
17149 + write_cr0(cr0);
17150 + return cr0 ^ X86_CR0_WP;
17151 +}
17152 +
17153 +static inline unsigned long native_pax_close_kernel(void)
17154 +{
17155 + unsigned long cr0;
17156 +
17157 + cr0 = read_cr0() ^ X86_CR0_WP;
17158 + BUG_ON(!(cr0 & X86_CR0_WP));
17159 + write_cr0(cr0);
17160 + barrier();
17161 + preempt_enable_no_resched();
17162 + return cr0 ^ X86_CR0_WP;
17163 +}
17164 +#else
17165 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
17166 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
17167 +#endif
17168 +
17169 /*
17170 * The following only work if pte_present() is true.
17171 * Undefined behaviour if not..
17172 */
17173 +static inline int pte_user(pte_t pte)
17174 +{
17175 + return pte_val(pte) & _PAGE_USER;
17176 +}
17177 +
17178 static inline int pte_dirty(pte_t pte)
17179 {
17180 return pte_flags(pte) & _PAGE_DIRTY;
17181 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
17182 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
17183 }
17184
17185 +static inline unsigned long pgd_pfn(pgd_t pgd)
17186 +{
17187 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
17188 +}
17189 +
17190 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
17191
17192 static inline int pmd_large(pmd_t pte)
17193 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
17194 return pte_clear_flags(pte, _PAGE_RW);
17195 }
17196
17197 +static inline pte_t pte_mkread(pte_t pte)
17198 +{
17199 + return __pte(pte_val(pte) | _PAGE_USER);
17200 +}
17201 +
17202 static inline pte_t pte_mkexec(pte_t pte)
17203 {
17204 - return pte_clear_flags(pte, _PAGE_NX);
17205 +#ifdef CONFIG_X86_PAE
17206 + if (__supported_pte_mask & _PAGE_NX)
17207 + return pte_clear_flags(pte, _PAGE_NX);
17208 + else
17209 +#endif
17210 + return pte_set_flags(pte, _PAGE_USER);
17211 +}
17212 +
17213 +static inline pte_t pte_exprotect(pte_t pte)
17214 +{
17215 +#ifdef CONFIG_X86_PAE
17216 + if (__supported_pte_mask & _PAGE_NX)
17217 + return pte_set_flags(pte, _PAGE_NX);
17218 + else
17219 +#endif
17220 + return pte_clear_flags(pte, _PAGE_USER);
17221 }
17222
17223 static inline pte_t pte_mkdirty(pte_t pte)
17224 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
17225 #endif
17226
17227 #ifndef __ASSEMBLY__
17228 +
17229 +#ifdef CONFIG_PAX_PER_CPU_PGD
17230 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
17231 +enum cpu_pgd_type {kernel = 0, user = 1};
17232 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
17233 +{
17234 + return cpu_pgd[cpu][type];
17235 +}
17236 +#endif
17237 +
17238 #include <linux/mm_types.h>
17239 #include <linux/mmdebug.h>
17240 #include <linux/log2.h>
17241 @@ -570,7 +645,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
17242 * Currently stuck as a macro due to indirect forward reference to
17243 * linux/mmzone.h's __section_mem_map_addr() definition:
17244 */
17245 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
17246 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
17247
17248 /* Find an entry in the second-level page table.. */
17249 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
17250 @@ -610,7 +685,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
17251 * Currently stuck as a macro due to indirect forward reference to
17252 * linux/mmzone.h's __section_mem_map_addr() definition:
17253 */
17254 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
17255 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
17256
17257 /* to find an entry in a page-table-directory. */
17258 static inline unsigned long pud_index(unsigned long address)
17259 @@ -625,7 +700,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
17260
17261 static inline int pgd_bad(pgd_t pgd)
17262 {
17263 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
17264 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
17265 }
17266
17267 static inline int pgd_none(pgd_t pgd)
17268 @@ -648,7 +723,12 @@ static inline int pgd_none(pgd_t pgd)
17269 * pgd_offset() returns a (pgd_t *)
17270 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
17271 */
17272 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
17273 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
17274 +
17275 +#ifdef CONFIG_PAX_PER_CPU_PGD
17276 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
17277 +#endif
17278 +
17279 /*
17280 * a shortcut which implies the use of the kernel's pgd, instead
17281 * of a process's
17282 @@ -659,6 +739,23 @@ static inline int pgd_none(pgd_t pgd)
17283 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
17284 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
17285
17286 +#ifdef CONFIG_X86_32
17287 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
17288 +#else
17289 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
17290 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
17291 +
17292 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17293 +#ifdef __ASSEMBLY__
17294 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
17295 +#else
17296 +extern unsigned long pax_user_shadow_base;
17297 +extern pgdval_t clone_pgd_mask;
17298 +#endif
17299 +#endif
17300 +
17301 +#endif
17302 +
17303 #ifndef __ASSEMBLY__
17304
17305 extern int direct_gbpages;
17306 @@ -825,11 +922,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
17307 * dst and src can be on the same page, but the range must not overlap,
17308 * and must not cross a page boundary.
17309 */
17310 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
17311 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
17312 {
17313 - memcpy(dst, src, count * sizeof(pgd_t));
17314 + pax_open_kernel();
17315 + while (count--)
17316 + *dst++ = *src++;
17317 + pax_close_kernel();
17318 }
17319
17320 +#ifdef CONFIG_PAX_PER_CPU_PGD
17321 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
17322 +#endif
17323 +
17324 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17325 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
17326 +#else
17327 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
17328 +#endif
17329 +
17330 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
17331 static inline int page_level_shift(enum pg_level level)
17332 {
17333 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
17334 index 9ee3221..b979c6b 100644
17335 --- a/arch/x86/include/asm/pgtable_32.h
17336 +++ b/arch/x86/include/asm/pgtable_32.h
17337 @@ -25,9 +25,6 @@
17338 struct mm_struct;
17339 struct vm_area_struct;
17340
17341 -extern pgd_t swapper_pg_dir[1024];
17342 -extern pgd_t initial_page_table[1024];
17343 -
17344 static inline void pgtable_cache_init(void) { }
17345 static inline void check_pgt_cache(void) { }
17346 void paging_init(void);
17347 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17348 # include <asm/pgtable-2level.h>
17349 #endif
17350
17351 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
17352 +extern pgd_t initial_page_table[PTRS_PER_PGD];
17353 +#ifdef CONFIG_X86_PAE
17354 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
17355 +#endif
17356 +
17357 #if defined(CONFIG_HIGHPTE)
17358 #define pte_offset_map(dir, address) \
17359 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
17360 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17361 /* Clear a kernel PTE and flush it from the TLB */
17362 #define kpte_clear_flush(ptep, vaddr) \
17363 do { \
17364 + pax_open_kernel(); \
17365 pte_clear(&init_mm, (vaddr), (ptep)); \
17366 + pax_close_kernel(); \
17367 __flush_tlb_one((vaddr)); \
17368 } while (0)
17369
17370 #endif /* !__ASSEMBLY__ */
17371
17372 +#define HAVE_ARCH_UNMAPPED_AREA
17373 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
17374 +
17375 /*
17376 * kern_addr_valid() is (1) for FLATMEM and (0) for
17377 * SPARSEMEM and DISCONTIGMEM
17378 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
17379 index ed5903b..c7fe163 100644
17380 --- a/arch/x86/include/asm/pgtable_32_types.h
17381 +++ b/arch/x86/include/asm/pgtable_32_types.h
17382 @@ -8,7 +8,7 @@
17383 */
17384 #ifdef CONFIG_X86_PAE
17385 # include <asm/pgtable-3level_types.h>
17386 -# define PMD_SIZE (1UL << PMD_SHIFT)
17387 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
17388 # define PMD_MASK (~(PMD_SIZE - 1))
17389 #else
17390 # include <asm/pgtable-2level_types.h>
17391 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
17392 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
17393 #endif
17394
17395 +#ifdef CONFIG_PAX_KERNEXEC
17396 +#ifndef __ASSEMBLY__
17397 +extern unsigned char MODULES_EXEC_VADDR[];
17398 +extern unsigned char MODULES_EXEC_END[];
17399 +#endif
17400 +#include <asm/boot.h>
17401 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
17402 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
17403 +#else
17404 +#define ktla_ktva(addr) (addr)
17405 +#define ktva_ktla(addr) (addr)
17406 +#endif
17407 +
17408 #define MODULES_VADDR VMALLOC_START
17409 #define MODULES_END VMALLOC_END
17410 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
17411 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
17412 index e22c1db..23a625a 100644
17413 --- a/arch/x86/include/asm/pgtable_64.h
17414 +++ b/arch/x86/include/asm/pgtable_64.h
17415 @@ -16,10 +16,14 @@
17416
17417 extern pud_t level3_kernel_pgt[512];
17418 extern pud_t level3_ident_pgt[512];
17419 +extern pud_t level3_vmalloc_start_pgt[512];
17420 +extern pud_t level3_vmalloc_end_pgt[512];
17421 +extern pud_t level3_vmemmap_pgt[512];
17422 +extern pud_t level2_vmemmap_pgt[512];
17423 extern pmd_t level2_kernel_pgt[512];
17424 extern pmd_t level2_fixmap_pgt[512];
17425 -extern pmd_t level2_ident_pgt[512];
17426 -extern pgd_t init_level4_pgt[];
17427 +extern pmd_t level2_ident_pgt[512*2];
17428 +extern pgd_t init_level4_pgt[512];
17429
17430 #define swapper_pg_dir init_level4_pgt
17431
17432 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17433
17434 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17435 {
17436 + pax_open_kernel();
17437 *pmdp = pmd;
17438 + pax_close_kernel();
17439 }
17440
17441 static inline void native_pmd_clear(pmd_t *pmd)
17442 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
17443
17444 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17445 {
17446 + pax_open_kernel();
17447 *pudp = pud;
17448 + pax_close_kernel();
17449 }
17450
17451 static inline void native_pud_clear(pud_t *pud)
17452 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
17453
17454 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
17455 {
17456 + pax_open_kernel();
17457 + *pgdp = pgd;
17458 + pax_close_kernel();
17459 +}
17460 +
17461 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
17462 +{
17463 *pgdp = pgd;
17464 }
17465
17466 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
17467 index 2d88344..4679fc3 100644
17468 --- a/arch/x86/include/asm/pgtable_64_types.h
17469 +++ b/arch/x86/include/asm/pgtable_64_types.h
17470 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
17471 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
17472 #define MODULES_END _AC(0xffffffffff000000, UL)
17473 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
17474 +#define MODULES_EXEC_VADDR MODULES_VADDR
17475 +#define MODULES_EXEC_END MODULES_END
17476 +
17477 +#define ktla_ktva(addr) (addr)
17478 +#define ktva_ktla(addr) (addr)
17479
17480 #define EARLY_DYNAMIC_PAGE_TABLES 64
17481
17482 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
17483 index 0ecac25..306c276 100644
17484 --- a/arch/x86/include/asm/pgtable_types.h
17485 +++ b/arch/x86/include/asm/pgtable_types.h
17486 @@ -16,13 +16,12 @@
17487 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
17488 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
17489 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
17490 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
17491 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
17492 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
17493 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
17494 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
17495 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
17496 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
17497 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
17498 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
17499 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
17500 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
17501
17502 /* If _PAGE_BIT_PRESENT is clear, we use these: */
17503 @@ -40,7 +39,6 @@
17504 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
17505 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
17506 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
17507 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
17508 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
17509 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
17510 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
17511 @@ -87,8 +85,10 @@
17512
17513 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
17514 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
17515 -#else
17516 +#elif defined(CONFIG_KMEMCHECK)
17517 #define _PAGE_NX (_AT(pteval_t, 0))
17518 +#else
17519 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
17520 #endif
17521
17522 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
17523 @@ -146,6 +146,9 @@
17524 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
17525 _PAGE_ACCESSED)
17526
17527 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
17528 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
17529 +
17530 #define __PAGE_KERNEL_EXEC \
17531 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
17532 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
17533 @@ -156,7 +159,7 @@
17534 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
17535 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
17536 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
17537 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
17538 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
17539 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
17540 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
17541 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
17542 @@ -218,8 +221,8 @@
17543 * bits are combined, this will alow user to access the high address mapped
17544 * VDSO in the presence of CONFIG_COMPAT_VDSO
17545 */
17546 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
17547 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
17548 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17549 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17550 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
17551 #endif
17552
17553 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
17554 {
17555 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
17556 }
17557 +#endif
17558
17559 +#if PAGETABLE_LEVELS == 3
17560 +#include <asm-generic/pgtable-nopud.h>
17561 +#endif
17562 +
17563 +#if PAGETABLE_LEVELS == 2
17564 +#include <asm-generic/pgtable-nopmd.h>
17565 +#endif
17566 +
17567 +#ifndef __ASSEMBLY__
17568 #if PAGETABLE_LEVELS > 3
17569 typedef struct { pudval_t pud; } pud_t;
17570
17571 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
17572 return pud.pud;
17573 }
17574 #else
17575 -#include <asm-generic/pgtable-nopud.h>
17576 -
17577 static inline pudval_t native_pud_val(pud_t pud)
17578 {
17579 return native_pgd_val(pud.pgd);
17580 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
17581 return pmd.pmd;
17582 }
17583 #else
17584 -#include <asm-generic/pgtable-nopmd.h>
17585 -
17586 static inline pmdval_t native_pmd_val(pmd_t pmd)
17587 {
17588 return native_pgd_val(pmd.pud.pgd);
17589 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
17590
17591 extern pteval_t __supported_pte_mask;
17592 extern void set_nx(void);
17593 -extern int nx_enabled;
17594
17595 #define pgprot_writecombine pgprot_writecombine
17596 extern pgprot_t pgprot_writecombine(pgprot_t prot);
17597 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
17598 index 987c75e..2723054 100644
17599 --- a/arch/x86/include/asm/processor.h
17600 +++ b/arch/x86/include/asm/processor.h
17601 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
17602 : "memory");
17603 }
17604
17605 +/* invpcid (%rdx),%rax */
17606 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
17607 +
17608 +#define INVPCID_SINGLE_ADDRESS 0UL
17609 +#define INVPCID_SINGLE_CONTEXT 1UL
17610 +#define INVPCID_ALL_GLOBAL 2UL
17611 +#define INVPCID_ALL_MONGLOBAL 3UL
17612 +
17613 +#define PCID_KERNEL 0UL
17614 +#define PCID_USER 1UL
17615 +#define PCID_NOFLUSH (1UL << 63)
17616 +
17617 static inline void load_cr3(pgd_t *pgdir)
17618 {
17619 - write_cr3(__pa(pgdir));
17620 + write_cr3(__pa(pgdir) | PCID_KERNEL);
17621 }
17622
17623 #ifdef CONFIG_X86_32
17624 @@ -283,7 +295,7 @@ struct tss_struct {
17625
17626 } ____cacheline_aligned;
17627
17628 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
17629 +extern struct tss_struct init_tss[NR_CPUS];
17630
17631 /*
17632 * Save the original ist values for checking stack pointers during debugging
17633 @@ -453,6 +465,7 @@ struct thread_struct {
17634 unsigned short ds;
17635 unsigned short fsindex;
17636 unsigned short gsindex;
17637 + unsigned short ss;
17638 #endif
17639 #ifdef CONFIG_X86_32
17640 unsigned long ip;
17641 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
17642 extern unsigned long mmu_cr4_features;
17643 extern u32 *trampoline_cr4_features;
17644
17645 -static inline void set_in_cr4(unsigned long mask)
17646 -{
17647 - unsigned long cr4;
17648 -
17649 - mmu_cr4_features |= mask;
17650 - if (trampoline_cr4_features)
17651 - *trampoline_cr4_features = mmu_cr4_features;
17652 - cr4 = read_cr4();
17653 - cr4 |= mask;
17654 - write_cr4(cr4);
17655 -}
17656 -
17657 -static inline void clear_in_cr4(unsigned long mask)
17658 -{
17659 - unsigned long cr4;
17660 -
17661 - mmu_cr4_features &= ~mask;
17662 - if (trampoline_cr4_features)
17663 - *trampoline_cr4_features = mmu_cr4_features;
17664 - cr4 = read_cr4();
17665 - cr4 &= ~mask;
17666 - write_cr4(cr4);
17667 -}
17668 +extern void set_in_cr4(unsigned long mask);
17669 +extern void clear_in_cr4(unsigned long mask);
17670
17671 typedef struct {
17672 unsigned long seg;
17673 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
17674 */
17675 #define TASK_SIZE PAGE_OFFSET
17676 #define TASK_SIZE_MAX TASK_SIZE
17677 +
17678 +#ifdef CONFIG_PAX_SEGMEXEC
17679 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
17680 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
17681 +#else
17682 #define STACK_TOP TASK_SIZE
17683 -#define STACK_TOP_MAX STACK_TOP
17684 +#endif
17685 +
17686 +#define STACK_TOP_MAX TASK_SIZE
17687
17688 #define INIT_THREAD { \
17689 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17690 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17691 .vm86_info = NULL, \
17692 .sysenter_cs = __KERNEL_CS, \
17693 .io_bitmap_ptr = NULL, \
17694 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
17695 */
17696 #define INIT_TSS { \
17697 .x86_tss = { \
17698 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17699 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17700 .ss0 = __KERNEL_DS, \
17701 .ss1 = __KERNEL_CS, \
17702 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
17703 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
17704 extern unsigned long thread_saved_pc(struct task_struct *tsk);
17705
17706 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
17707 -#define KSTK_TOP(info) \
17708 -({ \
17709 - unsigned long *__ptr = (unsigned long *)(info); \
17710 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
17711 -})
17712 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
17713
17714 /*
17715 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
17716 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17717 #define task_pt_regs(task) \
17718 ({ \
17719 struct pt_regs *__regs__; \
17720 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
17721 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
17722 __regs__ - 1; \
17723 })
17724
17725 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17726 /*
17727 * User space process size. 47bits minus one guard page.
17728 */
17729 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
17730 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
17731
17732 /* This decides where the kernel will search for a free chunk of vm
17733 * space during mmap's.
17734 */
17735 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
17736 - 0xc0000000 : 0xFFFFe000)
17737 + 0xc0000000 : 0xFFFFf000)
17738
17739 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
17740 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
17741 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17742 #define STACK_TOP_MAX TASK_SIZE_MAX
17743
17744 #define INIT_THREAD { \
17745 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17746 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17747 }
17748
17749 #define INIT_TSS { \
17750 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17751 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17752 }
17753
17754 /*
17755 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
17756 */
17757 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
17758
17759 +#ifdef CONFIG_PAX_SEGMEXEC
17760 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
17761 +#endif
17762 +
17763 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
17764
17765 /* Get/set a process' ability to use the timestamp counter instruction */
17766 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
17767 return 0;
17768 }
17769
17770 -extern unsigned long arch_align_stack(unsigned long sp);
17771 +#define arch_align_stack(x) ((x) & ~0xfUL)
17772 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17773
17774 void default_idle(void);
17775 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
17776 #define xen_set_default_idle 0
17777 #endif
17778
17779 -void stop_this_cpu(void *dummy);
17780 +void stop_this_cpu(void *dummy) __noreturn;
17781 void df_debug(struct pt_regs *regs, long error_code);
17782 #endif /* _ASM_X86_PROCESSOR_H */
17783 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17784 index 942a086..6c26446 100644
17785 --- a/arch/x86/include/asm/ptrace.h
17786 +++ b/arch/x86/include/asm/ptrace.h
17787 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17788 }
17789
17790 /*
17791 - * user_mode_vm(regs) determines whether a register set came from user mode.
17792 + * user_mode(regs) determines whether a register set came from user mode.
17793 * This is true if V8086 mode was enabled OR if the register set was from
17794 * protected mode with RPL-3 CS value. This tricky test checks that with
17795 * one comparison. Many places in the kernel can bypass this full check
17796 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17797 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17798 + * be used.
17799 */
17800 -static inline int user_mode(struct pt_regs *regs)
17801 +static inline int user_mode_novm(struct pt_regs *regs)
17802 {
17803 #ifdef CONFIG_X86_32
17804 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17805 #else
17806 - return !!(regs->cs & 3);
17807 + return !!(regs->cs & SEGMENT_RPL_MASK);
17808 #endif
17809 }
17810
17811 -static inline int user_mode_vm(struct pt_regs *regs)
17812 +static inline int user_mode(struct pt_regs *regs)
17813 {
17814 #ifdef CONFIG_X86_32
17815 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17816 USER_RPL;
17817 #else
17818 - return user_mode(regs);
17819 + return user_mode_novm(regs);
17820 #endif
17821 }
17822
17823 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17824 #ifdef CONFIG_X86_64
17825 static inline bool user_64bit_mode(struct pt_regs *regs)
17826 {
17827 + unsigned long cs = regs->cs & 0xffff;
17828 #ifndef CONFIG_PARAVIRT
17829 /*
17830 * On non-paravirt systems, this is the only long mode CPL 3
17831 * selector. We do not allow long mode selectors in the LDT.
17832 */
17833 - return regs->cs == __USER_CS;
17834 + return cs == __USER_CS;
17835 #else
17836 /* Headers are too twisted for this to go in paravirt.h. */
17837 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17838 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17839 #endif
17840 }
17841
17842 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17843 * Traps from the kernel do not save sp and ss.
17844 * Use the helper function to retrieve sp.
17845 */
17846 - if (offset == offsetof(struct pt_regs, sp) &&
17847 - regs->cs == __KERNEL_CS)
17848 - return kernel_stack_pointer(regs);
17849 + if (offset == offsetof(struct pt_regs, sp)) {
17850 + unsigned long cs = regs->cs & 0xffff;
17851 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17852 + return kernel_stack_pointer(regs);
17853 + }
17854 #endif
17855 return *(unsigned long *)((unsigned long)regs + offset);
17856 }
17857 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17858 index 9c6b890..5305f53 100644
17859 --- a/arch/x86/include/asm/realmode.h
17860 +++ b/arch/x86/include/asm/realmode.h
17861 @@ -22,16 +22,14 @@ struct real_mode_header {
17862 #endif
17863 /* APM/BIOS reboot */
17864 u32 machine_real_restart_asm;
17865 -#ifdef CONFIG_X86_64
17866 u32 machine_real_restart_seg;
17867 -#endif
17868 };
17869
17870 /* This must match data at trampoline_32/64.S */
17871 struct trampoline_header {
17872 #ifdef CONFIG_X86_32
17873 u32 start;
17874 - u16 gdt_pad;
17875 + u16 boot_cs;
17876 u16 gdt_limit;
17877 u32 gdt_base;
17878 #else
17879 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17880 index a82c4f1..ac45053 100644
17881 --- a/arch/x86/include/asm/reboot.h
17882 +++ b/arch/x86/include/asm/reboot.h
17883 @@ -6,13 +6,13 @@
17884 struct pt_regs;
17885
17886 struct machine_ops {
17887 - void (*restart)(char *cmd);
17888 - void (*halt)(void);
17889 - void (*power_off)(void);
17890 + void (* __noreturn restart)(char *cmd);
17891 + void (* __noreturn halt)(void);
17892 + void (* __noreturn power_off)(void);
17893 void (*shutdown)(void);
17894 void (*crash_shutdown)(struct pt_regs *);
17895 - void (*emergency_restart)(void);
17896 -};
17897 + void (* __noreturn emergency_restart)(void);
17898 +} __no_const;
17899
17900 extern struct machine_ops machine_ops;
17901
17902 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17903 index cad82c9..2e5c5c1 100644
17904 --- a/arch/x86/include/asm/rwsem.h
17905 +++ b/arch/x86/include/asm/rwsem.h
17906 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17907 {
17908 asm volatile("# beginning down_read\n\t"
17909 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17910 +
17911 +#ifdef CONFIG_PAX_REFCOUNT
17912 + "jno 0f\n"
17913 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17914 + "int $4\n0:\n"
17915 + _ASM_EXTABLE(0b, 0b)
17916 +#endif
17917 +
17918 /* adds 0x00000001 */
17919 " jns 1f\n"
17920 " call call_rwsem_down_read_failed\n"
17921 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17922 "1:\n\t"
17923 " mov %1,%2\n\t"
17924 " add %3,%2\n\t"
17925 +
17926 +#ifdef CONFIG_PAX_REFCOUNT
17927 + "jno 0f\n"
17928 + "sub %3,%2\n"
17929 + "int $4\n0:\n"
17930 + _ASM_EXTABLE(0b, 0b)
17931 +#endif
17932 +
17933 " jle 2f\n\t"
17934 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17935 " jnz 1b\n\t"
17936 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17937 long tmp;
17938 asm volatile("# beginning down_write\n\t"
17939 LOCK_PREFIX " xadd %1,(%2)\n\t"
17940 +
17941 +#ifdef CONFIG_PAX_REFCOUNT
17942 + "jno 0f\n"
17943 + "mov %1,(%2)\n"
17944 + "int $4\n0:\n"
17945 + _ASM_EXTABLE(0b, 0b)
17946 +#endif
17947 +
17948 /* adds 0xffff0001, returns the old value */
17949 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17950 /* was the active mask 0 before? */
17951 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17952 long tmp;
17953 asm volatile("# beginning __up_read\n\t"
17954 LOCK_PREFIX " xadd %1,(%2)\n\t"
17955 +
17956 +#ifdef CONFIG_PAX_REFCOUNT
17957 + "jno 0f\n"
17958 + "mov %1,(%2)\n"
17959 + "int $4\n0:\n"
17960 + _ASM_EXTABLE(0b, 0b)
17961 +#endif
17962 +
17963 /* subtracts 1, returns the old value */
17964 " jns 1f\n\t"
17965 " call call_rwsem_wake\n" /* expects old value in %edx */
17966 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17967 long tmp;
17968 asm volatile("# beginning __up_write\n\t"
17969 LOCK_PREFIX " xadd %1,(%2)\n\t"
17970 +
17971 +#ifdef CONFIG_PAX_REFCOUNT
17972 + "jno 0f\n"
17973 + "mov %1,(%2)\n"
17974 + "int $4\n0:\n"
17975 + _ASM_EXTABLE(0b, 0b)
17976 +#endif
17977 +
17978 /* subtracts 0xffff0001, returns the old value */
17979 " jns 1f\n\t"
17980 " call call_rwsem_wake\n" /* expects old value in %edx */
17981 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17982 {
17983 asm volatile("# beginning __downgrade_write\n\t"
17984 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17985 +
17986 +#ifdef CONFIG_PAX_REFCOUNT
17987 + "jno 0f\n"
17988 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17989 + "int $4\n0:\n"
17990 + _ASM_EXTABLE(0b, 0b)
17991 +#endif
17992 +
17993 /*
17994 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17995 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17996 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17997 */
17998 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17999 {
18000 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
18001 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
18002 +
18003 +#ifdef CONFIG_PAX_REFCOUNT
18004 + "jno 0f\n"
18005 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
18006 + "int $4\n0:\n"
18007 + _ASM_EXTABLE(0b, 0b)
18008 +#endif
18009 +
18010 : "+m" (sem->count)
18011 : "er" (delta));
18012 }
18013 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
18014 */
18015 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
18016 {
18017 - return delta + xadd(&sem->count, delta);
18018 + return delta + xadd_check_overflow(&sem->count, delta);
18019 }
18020
18021 #endif /* __KERNEL__ */
18022 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
18023 index c48a950..bc40804 100644
18024 --- a/arch/x86/include/asm/segment.h
18025 +++ b/arch/x86/include/asm/segment.h
18026 @@ -64,10 +64,15 @@
18027 * 26 - ESPFIX small SS
18028 * 27 - per-cpu [ offset to per-cpu data area ]
18029 * 28 - stack_canary-20 [ for stack protector ]
18030 - * 29 - unused
18031 - * 30 - unused
18032 + * 29 - PCI BIOS CS
18033 + * 30 - PCI BIOS DS
18034 * 31 - TSS for double fault handler
18035 */
18036 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
18037 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
18038 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
18039 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
18040 +
18041 #define GDT_ENTRY_TLS_MIN 6
18042 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
18043
18044 @@ -79,6 +84,8 @@
18045
18046 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
18047
18048 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
18049 +
18050 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
18051
18052 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
18053 @@ -104,6 +111,12 @@
18054 #define __KERNEL_STACK_CANARY 0
18055 #endif
18056
18057 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
18058 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
18059 +
18060 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
18061 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
18062 +
18063 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
18064
18065 /*
18066 @@ -141,7 +154,7 @@
18067 */
18068
18069 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
18070 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
18071 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
18072
18073
18074 #else
18075 @@ -165,6 +178,8 @@
18076 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
18077 #define __USER32_DS __USER_DS
18078
18079 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
18080 +
18081 #define GDT_ENTRY_TSS 8 /* needs two entries */
18082 #define GDT_ENTRY_LDT 10 /* needs two entries */
18083 #define GDT_ENTRY_TLS_MIN 12
18084 @@ -173,6 +188,8 @@
18085 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
18086 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
18087
18088 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
18089 +
18090 /* TLS indexes for 64bit - hardcoded in arch_prctl */
18091 #define FS_TLS 0
18092 #define GS_TLS 1
18093 @@ -180,12 +197,14 @@
18094 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
18095 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
18096
18097 -#define GDT_ENTRIES 16
18098 +#define GDT_ENTRIES 17
18099
18100 #endif
18101
18102 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
18103 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
18104 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
18105 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
18106 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
18107 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
18108 #ifndef CONFIG_PARAVIRT
18109 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
18110 {
18111 unsigned long __limit;
18112 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
18113 - return __limit + 1;
18114 + return __limit;
18115 }
18116
18117 #endif /* !__ASSEMBLY__ */
18118 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
18119 index 8d3120f..352b440 100644
18120 --- a/arch/x86/include/asm/smap.h
18121 +++ b/arch/x86/include/asm/smap.h
18122 @@ -25,11 +25,40 @@
18123
18124 #include <asm/alternative-asm.h>
18125
18126 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18127 +#define ASM_PAX_OPEN_USERLAND \
18128 + 661: jmp 663f; \
18129 + .pushsection .altinstr_replacement, "a" ; \
18130 + 662: pushq %rax; nop; \
18131 + .popsection ; \
18132 + .pushsection .altinstructions, "a" ; \
18133 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18134 + .popsection ; \
18135 + call __pax_open_userland; \
18136 + popq %rax; \
18137 + 663:
18138 +
18139 +#define ASM_PAX_CLOSE_USERLAND \
18140 + 661: jmp 663f; \
18141 + .pushsection .altinstr_replacement, "a" ; \
18142 + 662: pushq %rax; nop; \
18143 + .popsection; \
18144 + .pushsection .altinstructions, "a" ; \
18145 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18146 + .popsection; \
18147 + call __pax_close_userland; \
18148 + popq %rax; \
18149 + 663:
18150 +#else
18151 +#define ASM_PAX_OPEN_USERLAND
18152 +#define ASM_PAX_CLOSE_USERLAND
18153 +#endif
18154 +
18155 #ifdef CONFIG_X86_SMAP
18156
18157 #define ASM_CLAC \
18158 661: ASM_NOP3 ; \
18159 - .pushsection .altinstr_replacement, "ax" ; \
18160 + .pushsection .altinstr_replacement, "a" ; \
18161 662: __ASM_CLAC ; \
18162 .popsection ; \
18163 .pushsection .altinstructions, "a" ; \
18164 @@ -38,7 +67,7 @@
18165
18166 #define ASM_STAC \
18167 661: ASM_NOP3 ; \
18168 - .pushsection .altinstr_replacement, "ax" ; \
18169 + .pushsection .altinstr_replacement, "a" ; \
18170 662: __ASM_STAC ; \
18171 .popsection ; \
18172 .pushsection .altinstructions, "a" ; \
18173 @@ -56,6 +85,37 @@
18174
18175 #include <asm/alternative.h>
18176
18177 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
18178 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
18179 +
18180 +extern void __pax_open_userland(void);
18181 +static __always_inline unsigned long pax_open_userland(void)
18182 +{
18183 +
18184 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18185 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
18186 + :
18187 + : [open] "i" (__pax_open_userland)
18188 + : "memory", "rax");
18189 +#endif
18190 +
18191 + return 0;
18192 +}
18193 +
18194 +extern void __pax_close_userland(void);
18195 +static __always_inline unsigned long pax_close_userland(void)
18196 +{
18197 +
18198 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18199 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
18200 + :
18201 + : [close] "i" (__pax_close_userland)
18202 + : "memory", "rax");
18203 +#endif
18204 +
18205 + return 0;
18206 +}
18207 +
18208 #ifdef CONFIG_X86_SMAP
18209
18210 static __always_inline void clac(void)
18211 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
18212 index 4137890..03fa172 100644
18213 --- a/arch/x86/include/asm/smp.h
18214 +++ b/arch/x86/include/asm/smp.h
18215 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
18216 /* cpus sharing the last level cache: */
18217 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
18218 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
18219 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
18220 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
18221
18222 static inline struct cpumask *cpu_sibling_mask(int cpu)
18223 {
18224 @@ -79,7 +79,7 @@ struct smp_ops {
18225
18226 void (*send_call_func_ipi)(const struct cpumask *mask);
18227 void (*send_call_func_single_ipi)(int cpu);
18228 -};
18229 +} __no_const;
18230
18231 /* Globals due to paravirt */
18232 extern void set_cpu_sibling_map(int cpu);
18233 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
18234 extern int safe_smp_processor_id(void);
18235
18236 #elif defined(CONFIG_X86_64_SMP)
18237 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18238 -
18239 -#define stack_smp_processor_id() \
18240 -({ \
18241 - struct thread_info *ti; \
18242 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
18243 - ti->cpu; \
18244 -})
18245 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18246 +#define stack_smp_processor_id() raw_smp_processor_id()
18247 #define safe_smp_processor_id() smp_processor_id()
18248
18249 #endif
18250 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
18251 index bf156de..1a782ab 100644
18252 --- a/arch/x86/include/asm/spinlock.h
18253 +++ b/arch/x86/include/asm/spinlock.h
18254 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
18255 static inline void arch_read_lock(arch_rwlock_t *rw)
18256 {
18257 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
18258 +
18259 +#ifdef CONFIG_PAX_REFCOUNT
18260 + "jno 0f\n"
18261 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
18262 + "int $4\n0:\n"
18263 + _ASM_EXTABLE(0b, 0b)
18264 +#endif
18265 +
18266 "jns 1f\n"
18267 "call __read_lock_failed\n\t"
18268 "1:\n"
18269 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
18270 static inline void arch_write_lock(arch_rwlock_t *rw)
18271 {
18272 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
18273 +
18274 +#ifdef CONFIG_PAX_REFCOUNT
18275 + "jno 0f\n"
18276 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
18277 + "int $4\n0:\n"
18278 + _ASM_EXTABLE(0b, 0b)
18279 +#endif
18280 +
18281 "jz 1f\n"
18282 "call __write_lock_failed\n\t"
18283 "1:\n"
18284 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
18285
18286 static inline void arch_read_unlock(arch_rwlock_t *rw)
18287 {
18288 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
18289 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
18290 +
18291 +#ifdef CONFIG_PAX_REFCOUNT
18292 + "jno 0f\n"
18293 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
18294 + "int $4\n0:\n"
18295 + _ASM_EXTABLE(0b, 0b)
18296 +#endif
18297 +
18298 :"+m" (rw->lock) : : "memory");
18299 }
18300
18301 static inline void arch_write_unlock(arch_rwlock_t *rw)
18302 {
18303 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
18304 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
18305 +
18306 +#ifdef CONFIG_PAX_REFCOUNT
18307 + "jno 0f\n"
18308 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
18309 + "int $4\n0:\n"
18310 + _ASM_EXTABLE(0b, 0b)
18311 +#endif
18312 +
18313 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
18314 }
18315
18316 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
18317 index 6a99859..03cb807 100644
18318 --- a/arch/x86/include/asm/stackprotector.h
18319 +++ b/arch/x86/include/asm/stackprotector.h
18320 @@ -47,7 +47,7 @@
18321 * head_32 for boot CPU and setup_per_cpu_areas() for others.
18322 */
18323 #define GDT_STACK_CANARY_INIT \
18324 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
18325 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
18326
18327 /*
18328 * Initialize the stackprotector canary value.
18329 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
18330
18331 static inline void load_stack_canary_segment(void)
18332 {
18333 -#ifdef CONFIG_X86_32
18334 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
18335 asm volatile ("mov %0, %%gs" : : "r" (0));
18336 #endif
18337 }
18338 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
18339 index 70bbe39..4ae2bd4 100644
18340 --- a/arch/x86/include/asm/stacktrace.h
18341 +++ b/arch/x86/include/asm/stacktrace.h
18342 @@ -11,28 +11,20 @@
18343
18344 extern int kstack_depth_to_print;
18345
18346 -struct thread_info;
18347 +struct task_struct;
18348 struct stacktrace_ops;
18349
18350 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
18351 - unsigned long *stack,
18352 - unsigned long bp,
18353 - const struct stacktrace_ops *ops,
18354 - void *data,
18355 - unsigned long *end,
18356 - int *graph);
18357 +typedef unsigned long walk_stack_t(struct task_struct *task,
18358 + void *stack_start,
18359 + unsigned long *stack,
18360 + unsigned long bp,
18361 + const struct stacktrace_ops *ops,
18362 + void *data,
18363 + unsigned long *end,
18364 + int *graph);
18365
18366 -extern unsigned long
18367 -print_context_stack(struct thread_info *tinfo,
18368 - unsigned long *stack, unsigned long bp,
18369 - const struct stacktrace_ops *ops, void *data,
18370 - unsigned long *end, int *graph);
18371 -
18372 -extern unsigned long
18373 -print_context_stack_bp(struct thread_info *tinfo,
18374 - unsigned long *stack, unsigned long bp,
18375 - const struct stacktrace_ops *ops, void *data,
18376 - unsigned long *end, int *graph);
18377 +extern walk_stack_t print_context_stack;
18378 +extern walk_stack_t print_context_stack_bp;
18379
18380 /* Generic stack tracer with callbacks */
18381
18382 @@ -40,7 +32,7 @@ struct stacktrace_ops {
18383 void (*address)(void *data, unsigned long address, int reliable);
18384 /* On negative return stop dumping */
18385 int (*stack)(void *data, char *name);
18386 - walk_stack_t walk_stack;
18387 + walk_stack_t *walk_stack;
18388 };
18389
18390 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
18391 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
18392 index d7f3b3b..3cc39f1 100644
18393 --- a/arch/x86/include/asm/switch_to.h
18394 +++ b/arch/x86/include/asm/switch_to.h
18395 @@ -108,7 +108,7 @@ do { \
18396 "call __switch_to\n\t" \
18397 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
18398 __switch_canary \
18399 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
18400 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
18401 "movq %%rax,%%rdi\n\t" \
18402 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
18403 "jnz ret_from_fork\n\t" \
18404 @@ -119,7 +119,7 @@ do { \
18405 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
18406 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
18407 [_tif_fork] "i" (_TIF_FORK), \
18408 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
18409 + [thread_info] "m" (current_tinfo), \
18410 [current_task] "m" (current_task) \
18411 __switch_canary_iparam \
18412 : "memory", "cc" __EXTRA_CLOBBER)
18413 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
18414 index 2781119..618b59b 100644
18415 --- a/arch/x86/include/asm/thread_info.h
18416 +++ b/arch/x86/include/asm/thread_info.h
18417 @@ -10,6 +10,7 @@
18418 #include <linux/compiler.h>
18419 #include <asm/page.h>
18420 #include <asm/types.h>
18421 +#include <asm/percpu.h>
18422
18423 /*
18424 * low level task data that entry.S needs immediate access to
18425 @@ -23,7 +24,6 @@ struct exec_domain;
18426 #include <linux/atomic.h>
18427
18428 struct thread_info {
18429 - struct task_struct *task; /* main task structure */
18430 struct exec_domain *exec_domain; /* execution domain */
18431 __u32 flags; /* low level flags */
18432 __u32 status; /* thread synchronous flags */
18433 @@ -33,19 +33,13 @@ struct thread_info {
18434 mm_segment_t addr_limit;
18435 struct restart_block restart_block;
18436 void __user *sysenter_return;
18437 -#ifdef CONFIG_X86_32
18438 - unsigned long previous_esp; /* ESP of the previous stack in
18439 - case of nested (IRQ) stacks
18440 - */
18441 - __u8 supervisor_stack[0];
18442 -#endif
18443 + unsigned long lowest_stack;
18444 unsigned int sig_on_uaccess_error:1;
18445 unsigned int uaccess_err:1; /* uaccess failed */
18446 };
18447
18448 -#define INIT_THREAD_INFO(tsk) \
18449 +#define INIT_THREAD_INFO \
18450 { \
18451 - .task = &tsk, \
18452 .exec_domain = &default_exec_domain, \
18453 .flags = 0, \
18454 .cpu = 0, \
18455 @@ -56,7 +50,7 @@ struct thread_info {
18456 }, \
18457 }
18458
18459 -#define init_thread_info (init_thread_union.thread_info)
18460 +#define init_thread_info (init_thread_union.stack)
18461 #define init_stack (init_thread_union.stack)
18462
18463 #else /* !__ASSEMBLY__ */
18464 @@ -96,6 +90,7 @@ struct thread_info {
18465 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
18466 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
18467 #define TIF_X32 30 /* 32-bit native x86-64 binary */
18468 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
18469
18470 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
18471 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
18472 @@ -119,17 +114,18 @@ struct thread_info {
18473 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
18474 #define _TIF_ADDR32 (1 << TIF_ADDR32)
18475 #define _TIF_X32 (1 << TIF_X32)
18476 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
18477
18478 /* work to do in syscall_trace_enter() */
18479 #define _TIF_WORK_SYSCALL_ENTRY \
18480 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
18481 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
18482 - _TIF_NOHZ)
18483 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18484
18485 /* work to do in syscall_trace_leave() */
18486 #define _TIF_WORK_SYSCALL_EXIT \
18487 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
18488 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
18489 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
18490
18491 /* work to do on interrupt/exception return */
18492 #define _TIF_WORK_MASK \
18493 @@ -140,7 +136,7 @@ struct thread_info {
18494 /* work to do on any return to user space */
18495 #define _TIF_ALLWORK_MASK \
18496 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
18497 - _TIF_NOHZ)
18498 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18499
18500 /* Only used for 64 bit */
18501 #define _TIF_DO_NOTIFY_MASK \
18502 @@ -156,45 +152,40 @@ struct thread_info {
18503
18504 #define PREEMPT_ACTIVE 0x10000000
18505
18506 -#ifdef CONFIG_X86_32
18507 -
18508 -#define STACK_WARN (THREAD_SIZE/8)
18509 -/*
18510 - * macros/functions for gaining access to the thread information structure
18511 - *
18512 - * preempt_count needs to be 1 initially, until the scheduler is functional.
18513 - */
18514 -#ifndef __ASSEMBLY__
18515 -
18516 -
18517 -/* how to get the current stack pointer from C */
18518 -register unsigned long current_stack_pointer asm("esp") __used;
18519 -
18520 -/* how to get the thread information struct from C */
18521 -static inline struct thread_info *current_thread_info(void)
18522 -{
18523 - return (struct thread_info *)
18524 - (current_stack_pointer & ~(THREAD_SIZE - 1));
18525 -}
18526 -
18527 -#else /* !__ASSEMBLY__ */
18528 -
18529 +#ifdef __ASSEMBLY__
18530 /* how to get the thread information struct from ASM */
18531 #define GET_THREAD_INFO(reg) \
18532 - movl $-THREAD_SIZE, reg; \
18533 - andl %esp, reg
18534 + mov PER_CPU_VAR(current_tinfo), reg
18535
18536 /* use this one if reg already contains %esp */
18537 -#define GET_THREAD_INFO_WITH_ESP(reg) \
18538 - andl $-THREAD_SIZE, reg
18539 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
18540 +#else
18541 +/* how to get the thread information struct from C */
18542 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
18543 +
18544 +static __always_inline struct thread_info *current_thread_info(void)
18545 +{
18546 + return this_cpu_read_stable(current_tinfo);
18547 +}
18548 +#endif
18549 +
18550 +#ifdef CONFIG_X86_32
18551 +
18552 +#define STACK_WARN (THREAD_SIZE/8)
18553 +/*
18554 + * macros/functions for gaining access to the thread information structure
18555 + *
18556 + * preempt_count needs to be 1 initially, until the scheduler is functional.
18557 + */
18558 +#ifndef __ASSEMBLY__
18559 +
18560 +/* how to get the current stack pointer from C */
18561 +register unsigned long current_stack_pointer asm("esp") __used;
18562
18563 #endif
18564
18565 #else /* X86_32 */
18566
18567 -#include <asm/percpu.h>
18568 -#define KERNEL_STACK_OFFSET (5*8)
18569 -
18570 /*
18571 * macros/functions for gaining access to the thread information structure
18572 * preempt_count needs to be 1 initially, until the scheduler is functional.
18573 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
18574 #ifndef __ASSEMBLY__
18575 DECLARE_PER_CPU(unsigned long, kernel_stack);
18576
18577 -static inline struct thread_info *current_thread_info(void)
18578 -{
18579 - struct thread_info *ti;
18580 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
18581 - KERNEL_STACK_OFFSET - THREAD_SIZE);
18582 - return ti;
18583 -}
18584 -
18585 -#else /* !__ASSEMBLY__ */
18586 -
18587 -/* how to get the thread information struct from ASM */
18588 -#define GET_THREAD_INFO(reg) \
18589 - movq PER_CPU_VAR(kernel_stack),reg ; \
18590 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
18591 -
18592 -/*
18593 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
18594 - * a certain register (to be used in assembler memory operands).
18595 - */
18596 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
18597 -
18598 +/* how to get the current stack pointer from C */
18599 +register unsigned long current_stack_pointer asm("rsp") __used;
18600 #endif
18601
18602 #endif /* !X86_32 */
18603 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
18604 extern void arch_task_cache_init(void);
18605 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
18606 extern void arch_release_task_struct(struct task_struct *tsk);
18607 +
18608 +#define __HAVE_THREAD_FUNCTIONS
18609 +#define task_thread_info(task) (&(task)->tinfo)
18610 +#define task_stack_page(task) ((task)->stack)
18611 +#define setup_thread_stack(p, org) do {} while (0)
18612 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
18613 +
18614 #endif
18615 #endif /* _ASM_X86_THREAD_INFO_H */
18616 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
18617 index e6d90ba..0897f44 100644
18618 --- a/arch/x86/include/asm/tlbflush.h
18619 +++ b/arch/x86/include/asm/tlbflush.h
18620 @@ -17,18 +17,44 @@
18621
18622 static inline void __native_flush_tlb(void)
18623 {
18624 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18625 + u64 descriptor[2];
18626 +
18627 + descriptor[0] = PCID_KERNEL;
18628 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
18629 + return;
18630 + }
18631 +
18632 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18633 + if (static_cpu_has(X86_FEATURE_PCID)) {
18634 + unsigned int cpu = raw_get_cpu();
18635 +
18636 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
18637 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
18638 + raw_put_cpu_no_resched();
18639 + return;
18640 + }
18641 +#endif
18642 +
18643 native_write_cr3(native_read_cr3());
18644 }
18645
18646 static inline void __native_flush_tlb_global_irq_disabled(void)
18647 {
18648 - unsigned long cr4;
18649 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18650 + u64 descriptor[2];
18651
18652 - cr4 = native_read_cr4();
18653 - /* clear PGE */
18654 - native_write_cr4(cr4 & ~X86_CR4_PGE);
18655 - /* write old PGE again and flush TLBs */
18656 - native_write_cr4(cr4);
18657 + descriptor[0] = PCID_KERNEL;
18658 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
18659 + } else {
18660 + unsigned long cr4;
18661 +
18662 + cr4 = native_read_cr4();
18663 + /* clear PGE */
18664 + native_write_cr4(cr4 & ~X86_CR4_PGE);
18665 + /* write old PGE again and flush TLBs */
18666 + native_write_cr4(cr4);
18667 + }
18668 }
18669
18670 static inline void __native_flush_tlb_global(void)
18671 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
18672
18673 static inline void __native_flush_tlb_single(unsigned long addr)
18674 {
18675 +
18676 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18677 + u64 descriptor[2];
18678 +
18679 + descriptor[0] = PCID_KERNEL;
18680 + descriptor[1] = addr;
18681 +
18682 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18683 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
18684 + if (addr < TASK_SIZE_MAX)
18685 + descriptor[1] += pax_user_shadow_base;
18686 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18687 + }
18688 +
18689 + descriptor[0] = PCID_USER;
18690 + descriptor[1] = addr;
18691 +#endif
18692 +
18693 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18694 + return;
18695 + }
18696 +
18697 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18698 + if (static_cpu_has(X86_FEATURE_PCID)) {
18699 + unsigned int cpu = raw_get_cpu();
18700 +
18701 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
18702 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18703 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
18704 + raw_put_cpu_no_resched();
18705 +
18706 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
18707 + addr += pax_user_shadow_base;
18708 + }
18709 +#endif
18710 +
18711 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18712 }
18713
18714 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
18715 index 5838fa9..f7ae572 100644
18716 --- a/arch/x86/include/asm/uaccess.h
18717 +++ b/arch/x86/include/asm/uaccess.h
18718 @@ -7,6 +7,7 @@
18719 #include <linux/compiler.h>
18720 #include <linux/thread_info.h>
18721 #include <linux/string.h>
18722 +#include <linux/sched.h>
18723 #include <asm/asm.h>
18724 #include <asm/page.h>
18725 #include <asm/smap.h>
18726 @@ -29,7 +30,12 @@
18727
18728 #define get_ds() (KERNEL_DS)
18729 #define get_fs() (current_thread_info()->addr_limit)
18730 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18731 +void __set_fs(mm_segment_t x);
18732 +void set_fs(mm_segment_t x);
18733 +#else
18734 #define set_fs(x) (current_thread_info()->addr_limit = (x))
18735 +#endif
18736
18737 #define segment_eq(a, b) ((a).seg == (b).seg)
18738
18739 @@ -77,8 +83,33 @@
18740 * checks that the pointer is in the user space range - after calling
18741 * this function, memory access functions may still return -EFAULT.
18742 */
18743 -#define access_ok(type, addr, size) \
18744 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18745 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18746 +#define access_ok(type, addr, size) \
18747 +({ \
18748 + long __size = size; \
18749 + unsigned long __addr = (unsigned long)addr; \
18750 + unsigned long __addr_ao = __addr & PAGE_MASK; \
18751 + unsigned long __end_ao = __addr + __size - 1; \
18752 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
18753 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
18754 + while(__addr_ao <= __end_ao) { \
18755 + char __c_ao; \
18756 + __addr_ao += PAGE_SIZE; \
18757 + if (__size > PAGE_SIZE) \
18758 + cond_resched(); \
18759 + if (__get_user(__c_ao, (char __user *)__addr)) \
18760 + break; \
18761 + if (type != VERIFY_WRITE) { \
18762 + __addr = __addr_ao; \
18763 + continue; \
18764 + } \
18765 + if (__put_user(__c_ao, (char __user *)__addr)) \
18766 + break; \
18767 + __addr = __addr_ao; \
18768 + } \
18769 + } \
18770 + __ret_ao; \
18771 +})
18772
18773 /*
18774 * The exception table consists of pairs of addresses relative to the
18775 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18776 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
18777 __chk_user_ptr(ptr); \
18778 might_fault(); \
18779 + pax_open_userland(); \
18780 asm volatile("call __get_user_%P3" \
18781 : "=a" (__ret_gu), "=r" (__val_gu) \
18782 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18783 (x) = (__typeof__(*(ptr))) __val_gu; \
18784 + pax_close_userland(); \
18785 __ret_gu; \
18786 })
18787
18788 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18789 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18790 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18791
18792 -
18793 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18794 +#define __copyuser_seg "gs;"
18795 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18796 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18797 +#else
18798 +#define __copyuser_seg
18799 +#define __COPYUSER_SET_ES
18800 +#define __COPYUSER_RESTORE_ES
18801 +#endif
18802
18803 #ifdef CONFIG_X86_32
18804 #define __put_user_asm_u64(x, addr, err, errret) \
18805 asm volatile(ASM_STAC "\n" \
18806 - "1: movl %%eax,0(%2)\n" \
18807 - "2: movl %%edx,4(%2)\n" \
18808 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18809 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18810 "3: " ASM_CLAC "\n" \
18811 ".section .fixup,\"ax\"\n" \
18812 "4: movl %3,%0\n" \
18813 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18814
18815 #define __put_user_asm_ex_u64(x, addr) \
18816 asm volatile(ASM_STAC "\n" \
18817 - "1: movl %%eax,0(%1)\n" \
18818 - "2: movl %%edx,4(%1)\n" \
18819 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18820 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18821 "3: " ASM_CLAC "\n" \
18822 _ASM_EXTABLE_EX(1b, 2b) \
18823 _ASM_EXTABLE_EX(2b, 3b) \
18824 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18825 __typeof__(*(ptr)) __pu_val; \
18826 __chk_user_ptr(ptr); \
18827 might_fault(); \
18828 - __pu_val = x; \
18829 + __pu_val = (x); \
18830 + pax_open_userland(); \
18831 switch (sizeof(*(ptr))) { \
18832 case 1: \
18833 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18834 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18835 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18836 break; \
18837 } \
18838 + pax_close_userland(); \
18839 __ret_pu; \
18840 })
18841
18842 @@ -347,8 +390,10 @@ do { \
18843 } while (0)
18844
18845 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18846 +do { \
18847 + pax_open_userland(); \
18848 asm volatile(ASM_STAC "\n" \
18849 - "1: mov"itype" %2,%"rtype"1\n" \
18850 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18851 "2: " ASM_CLAC "\n" \
18852 ".section .fixup,\"ax\"\n" \
18853 "3: mov %3,%0\n" \
18854 @@ -356,8 +401,10 @@ do { \
18855 " jmp 2b\n" \
18856 ".previous\n" \
18857 _ASM_EXTABLE(1b, 3b) \
18858 - : "=r" (err), ltype(x) \
18859 - : "m" (__m(addr)), "i" (errret), "0" (err))
18860 + : "=r" (err), ltype (x) \
18861 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18862 + pax_close_userland(); \
18863 +} while (0)
18864
18865 #define __get_user_size_ex(x, ptr, size) \
18866 do { \
18867 @@ -381,7 +428,7 @@ do { \
18868 } while (0)
18869
18870 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18871 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18872 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18873 "2:\n" \
18874 _ASM_EXTABLE_EX(1b, 2b) \
18875 : ltype(x) : "m" (__m(addr)))
18876 @@ -398,13 +445,24 @@ do { \
18877 int __gu_err; \
18878 unsigned long __gu_val; \
18879 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18880 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18881 + (x) = (__typeof__(*(ptr)))__gu_val; \
18882 __gu_err; \
18883 })
18884
18885 /* FIXME: this hack is definitely wrong -AK */
18886 struct __large_struct { unsigned long buf[100]; };
18887 -#define __m(x) (*(struct __large_struct __user *)(x))
18888 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18889 +#define ____m(x) \
18890 +({ \
18891 + unsigned long ____x = (unsigned long)(x); \
18892 + if (____x < pax_user_shadow_base) \
18893 + ____x += pax_user_shadow_base; \
18894 + (typeof(x))____x; \
18895 +})
18896 +#else
18897 +#define ____m(x) (x)
18898 +#endif
18899 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18900
18901 /*
18902 * Tell gcc we read from memory instead of writing: this is because
18903 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18904 * aliasing issues.
18905 */
18906 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18907 +do { \
18908 + pax_open_userland(); \
18909 asm volatile(ASM_STAC "\n" \
18910 - "1: mov"itype" %"rtype"1,%2\n" \
18911 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18912 "2: " ASM_CLAC "\n" \
18913 ".section .fixup,\"ax\"\n" \
18914 "3: mov %3,%0\n" \
18915 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18916 ".previous\n" \
18917 _ASM_EXTABLE(1b, 3b) \
18918 : "=r"(err) \
18919 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18920 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18921 + pax_close_userland(); \
18922 +} while (0)
18923
18924 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18925 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18926 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18927 "2:\n" \
18928 _ASM_EXTABLE_EX(1b, 2b) \
18929 : : ltype(x), "m" (__m(addr)))
18930 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18931 */
18932 #define uaccess_try do { \
18933 current_thread_info()->uaccess_err = 0; \
18934 + pax_open_userland(); \
18935 stac(); \
18936 barrier();
18937
18938 #define uaccess_catch(err) \
18939 clac(); \
18940 + pax_close_userland(); \
18941 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18942 } while (0)
18943
18944 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18945 * On error, the variable @x is set to zero.
18946 */
18947
18948 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18949 +#define __get_user(x, ptr) get_user((x), (ptr))
18950 +#else
18951 #define __get_user(x, ptr) \
18952 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18953 +#endif
18954
18955 /**
18956 * __put_user: - Write a simple value into user space, with less checking.
18957 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18958 * Returns zero on success, or -EFAULT on error.
18959 */
18960
18961 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18962 +#define __put_user(x, ptr) put_user((x), (ptr))
18963 +#else
18964 #define __put_user(x, ptr) \
18965 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18966 +#endif
18967
18968 #define __get_user_unaligned __get_user
18969 #define __put_user_unaligned __put_user
18970 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18971 #define get_user_ex(x, ptr) do { \
18972 unsigned long __gue_val; \
18973 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18974 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18975 + (x) = (__typeof__(*(ptr)))__gue_val; \
18976 } while (0)
18977
18978 #define put_user_try uaccess_try
18979 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18980 index 7f760a9..b596b9a 100644
18981 --- a/arch/x86/include/asm/uaccess_32.h
18982 +++ b/arch/x86/include/asm/uaccess_32.h
18983 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18984 static __always_inline unsigned long __must_check
18985 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18986 {
18987 + if ((long)n < 0)
18988 + return n;
18989 +
18990 + check_object_size(from, n, true);
18991 +
18992 if (__builtin_constant_p(n)) {
18993 unsigned long ret;
18994
18995 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18996 __copy_to_user(void __user *to, const void *from, unsigned long n)
18997 {
18998 might_fault();
18999 +
19000 return __copy_to_user_inatomic(to, from, n);
19001 }
19002
19003 static __always_inline unsigned long
19004 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
19005 {
19006 + if ((long)n < 0)
19007 + return n;
19008 +
19009 /* Avoid zeroing the tail if the copy fails..
19010 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
19011 * but as the zeroing behaviour is only significant when n is not
19012 @@ -137,6 +146,12 @@ static __always_inline unsigned long
19013 __copy_from_user(void *to, const void __user *from, unsigned long n)
19014 {
19015 might_fault();
19016 +
19017 + if ((long)n < 0)
19018 + return n;
19019 +
19020 + check_object_size(to, n, false);
19021 +
19022 if (__builtin_constant_p(n)) {
19023 unsigned long ret;
19024
19025 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
19026 const void __user *from, unsigned long n)
19027 {
19028 might_fault();
19029 +
19030 + if ((long)n < 0)
19031 + return n;
19032 +
19033 if (__builtin_constant_p(n)) {
19034 unsigned long ret;
19035
19036 @@ -181,15 +200,19 @@ static __always_inline unsigned long
19037 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
19038 unsigned long n)
19039 {
19040 - return __copy_from_user_ll_nocache_nozero(to, from, n);
19041 + if ((long)n < 0)
19042 + return n;
19043 +
19044 + return __copy_from_user_ll_nocache_nozero(to, from, n);
19045 }
19046
19047 -unsigned long __must_check copy_to_user(void __user *to,
19048 - const void *from, unsigned long n);
19049 -unsigned long __must_check _copy_from_user(void *to,
19050 - const void __user *from,
19051 - unsigned long n);
19052 -
19053 +extern void copy_to_user_overflow(void)
19054 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19055 + __compiletime_error("copy_to_user() buffer size is not provably correct")
19056 +#else
19057 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
19058 +#endif
19059 +;
19060
19061 extern void copy_from_user_overflow(void)
19062 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19063 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
19064 #endif
19065 ;
19066
19067 -static inline unsigned long __must_check copy_from_user(void *to,
19068 - const void __user *from,
19069 - unsigned long n)
19070 +/**
19071 + * copy_to_user: - Copy a block of data into user space.
19072 + * @to: Destination address, in user space.
19073 + * @from: Source address, in kernel space.
19074 + * @n: Number of bytes to copy.
19075 + *
19076 + * Context: User context only. This function may sleep.
19077 + *
19078 + * Copy data from kernel space to user space.
19079 + *
19080 + * Returns number of bytes that could not be copied.
19081 + * On success, this will be zero.
19082 + */
19083 +static inline unsigned long __must_check
19084 +copy_to_user(void __user *to, const void *from, unsigned long n)
19085 {
19086 - int sz = __compiletime_object_size(to);
19087 + size_t sz = __compiletime_object_size(from);
19088
19089 - if (likely(sz == -1 || sz >= n))
19090 - n = _copy_from_user(to, from, n);
19091 - else
19092 + if (unlikely(sz != (size_t)-1 && sz < n))
19093 + copy_to_user_overflow();
19094 + else if (access_ok(VERIFY_WRITE, to, n))
19095 + n = __copy_to_user(to, from, n);
19096 + return n;
19097 +}
19098 +
19099 +/**
19100 + * copy_from_user: - Copy a block of data from user space.
19101 + * @to: Destination address, in kernel space.
19102 + * @from: Source address, in user space.
19103 + * @n: Number of bytes to copy.
19104 + *
19105 + * Context: User context only. This function may sleep.
19106 + *
19107 + * Copy data from user space to kernel space.
19108 + *
19109 + * Returns number of bytes that could not be copied.
19110 + * On success, this will be zero.
19111 + *
19112 + * If some data could not be copied, this function will pad the copied
19113 + * data to the requested size using zero bytes.
19114 + */
19115 +static inline unsigned long __must_check
19116 +copy_from_user(void *to, const void __user *from, unsigned long n)
19117 +{
19118 + size_t sz = __compiletime_object_size(to);
19119 +
19120 + check_object_size(to, n, false);
19121 +
19122 + if (unlikely(sz != (size_t)-1 && sz < n))
19123 copy_from_user_overflow();
19124 -
19125 + else if (access_ok(VERIFY_READ, from, n))
19126 + n = __copy_from_user(to, from, n);
19127 + else if ((long)n > 0)
19128 + memset(to, 0, n);
19129 return n;
19130 }
19131
19132 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
19133 index 4f7923d..201b58d 100644
19134 --- a/arch/x86/include/asm/uaccess_64.h
19135 +++ b/arch/x86/include/asm/uaccess_64.h
19136 @@ -10,6 +10,9 @@
19137 #include <asm/alternative.h>
19138 #include <asm/cpufeature.h>
19139 #include <asm/page.h>
19140 +#include <asm/pgtable.h>
19141 +
19142 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
19143
19144 /*
19145 * Copy To/From Userspace
19146 @@ -17,14 +20,14 @@
19147
19148 /* Handles exceptions in both to and from, but doesn't do access_ok */
19149 __must_check unsigned long
19150 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
19151 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
19152 __must_check unsigned long
19153 -copy_user_generic_string(void *to, const void *from, unsigned len);
19154 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
19155 __must_check unsigned long
19156 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
19157 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
19158
19159 -static __always_inline __must_check unsigned long
19160 -copy_user_generic(void *to, const void *from, unsigned len)
19161 +static __always_inline __must_check unsigned long
19162 +copy_user_generic(void *to, const void *from, unsigned long len)
19163 {
19164 unsigned ret;
19165
19166 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
19167 return ret;
19168 }
19169
19170 +static __always_inline __must_check unsigned long
19171 +__copy_to_user(void __user *to, const void *from, unsigned long len);
19172 +static __always_inline __must_check unsigned long
19173 +__copy_from_user(void *to, const void __user *from, unsigned long len);
19174 __must_check unsigned long
19175 -_copy_to_user(void __user *to, const void *from, unsigned len);
19176 -__must_check unsigned long
19177 -_copy_from_user(void *to, const void __user *from, unsigned len);
19178 -__must_check unsigned long
19179 -copy_in_user(void __user *to, const void __user *from, unsigned len);
19180 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
19181 +
19182 +extern void copy_to_user_overflow(void)
19183 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19184 + __compiletime_error("copy_to_user() buffer size is not provably correct")
19185 +#else
19186 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
19187 +#endif
19188 +;
19189 +
19190 +extern void copy_from_user_overflow(void)
19191 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19192 + __compiletime_error("copy_from_user() buffer size is not provably correct")
19193 +#else
19194 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
19195 +#endif
19196 +;
19197
19198 static inline unsigned long __must_check copy_from_user(void *to,
19199 const void __user *from,
19200 unsigned long n)
19201 {
19202 - int sz = __compiletime_object_size(to);
19203 -
19204 might_fault();
19205 - if (likely(sz == -1 || sz >= n))
19206 - n = _copy_from_user(to, from, n);
19207 -#ifdef CONFIG_DEBUG_VM
19208 - else
19209 - WARN(1, "Buffer overflow detected!\n");
19210 -#endif
19211 +
19212 + check_object_size(to, n, false);
19213 +
19214 + if (access_ok(VERIFY_READ, from, n))
19215 + n = __copy_from_user(to, from, n);
19216 + else if (n < INT_MAX)
19217 + memset(to, 0, n);
19218 return n;
19219 }
19220
19221 static __always_inline __must_check
19222 -int copy_to_user(void __user *dst, const void *src, unsigned size)
19223 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
19224 {
19225 might_fault();
19226
19227 - return _copy_to_user(dst, src, size);
19228 + if (access_ok(VERIFY_WRITE, dst, size))
19229 + size = __copy_to_user(dst, src, size);
19230 + return size;
19231 }
19232
19233 static __always_inline __must_check
19234 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
19235 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
19236 {
19237 - int ret = 0;
19238 + size_t sz = __compiletime_object_size(dst);
19239 + unsigned ret = 0;
19240
19241 might_fault();
19242 +
19243 + if (size > INT_MAX)
19244 + return size;
19245 +
19246 + check_object_size(dst, size, false);
19247 +
19248 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19249 + if (!__access_ok(VERIFY_READ, src, size))
19250 + return size;
19251 +#endif
19252 +
19253 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19254 + copy_from_user_overflow();
19255 + return size;
19256 + }
19257 +
19258 if (!__builtin_constant_p(size))
19259 - return copy_user_generic(dst, (__force void *)src, size);
19260 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19261 switch (size) {
19262 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
19263 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
19264 ret, "b", "b", "=q", 1);
19265 return ret;
19266 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
19267 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
19268 ret, "w", "w", "=r", 2);
19269 return ret;
19270 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
19271 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
19272 ret, "l", "k", "=r", 4);
19273 return ret;
19274 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
19275 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19276 ret, "q", "", "=r", 8);
19277 return ret;
19278 case 10:
19279 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19280 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19281 ret, "q", "", "=r", 10);
19282 if (unlikely(ret))
19283 return ret;
19284 __get_user_asm(*(u16 *)(8 + (char *)dst),
19285 - (u16 __user *)(8 + (char __user *)src),
19286 + (const u16 __user *)(8 + (const char __user *)src),
19287 ret, "w", "w", "=r", 2);
19288 return ret;
19289 case 16:
19290 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19291 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19292 ret, "q", "", "=r", 16);
19293 if (unlikely(ret))
19294 return ret;
19295 __get_user_asm(*(u64 *)(8 + (char *)dst),
19296 - (u64 __user *)(8 + (char __user *)src),
19297 + (const u64 __user *)(8 + (const char __user *)src),
19298 ret, "q", "", "=r", 8);
19299 return ret;
19300 default:
19301 - return copy_user_generic(dst, (__force void *)src, size);
19302 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19303 }
19304 }
19305
19306 static __always_inline __must_check
19307 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
19308 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
19309 {
19310 - int ret = 0;
19311 + size_t sz = __compiletime_object_size(src);
19312 + unsigned ret = 0;
19313
19314 might_fault();
19315 +
19316 + if (size > INT_MAX)
19317 + return size;
19318 +
19319 + check_object_size(src, size, true);
19320 +
19321 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19322 + if (!__access_ok(VERIFY_WRITE, dst, size))
19323 + return size;
19324 +#endif
19325 +
19326 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19327 + copy_to_user_overflow();
19328 + return size;
19329 + }
19330 +
19331 if (!__builtin_constant_p(size))
19332 - return copy_user_generic((__force void *)dst, src, size);
19333 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19334 switch (size) {
19335 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
19336 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
19337 ret, "b", "b", "iq", 1);
19338 return ret;
19339 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
19340 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
19341 ret, "w", "w", "ir", 2);
19342 return ret;
19343 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
19344 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
19345 ret, "l", "k", "ir", 4);
19346 return ret;
19347 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
19348 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19349 ret, "q", "", "er", 8);
19350 return ret;
19351 case 10:
19352 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19353 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19354 ret, "q", "", "er", 10);
19355 if (unlikely(ret))
19356 return ret;
19357 asm("":::"memory");
19358 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
19359 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
19360 ret, "w", "w", "ir", 2);
19361 return ret;
19362 case 16:
19363 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19364 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19365 ret, "q", "", "er", 16);
19366 if (unlikely(ret))
19367 return ret;
19368 asm("":::"memory");
19369 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
19370 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
19371 ret, "q", "", "er", 8);
19372 return ret;
19373 default:
19374 - return copy_user_generic((__force void *)dst, src, size);
19375 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19376 }
19377 }
19378
19379 static __always_inline __must_check
19380 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19381 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
19382 {
19383 - int ret = 0;
19384 + unsigned ret = 0;
19385
19386 might_fault();
19387 +
19388 + if (size > INT_MAX)
19389 + return size;
19390 +
19391 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19392 + if (!__access_ok(VERIFY_READ, src, size))
19393 + return size;
19394 + if (!__access_ok(VERIFY_WRITE, dst, size))
19395 + return size;
19396 +#endif
19397 +
19398 if (!__builtin_constant_p(size))
19399 - return copy_user_generic((__force void *)dst,
19400 - (__force void *)src, size);
19401 + return copy_user_generic((__force_kernel void *)____m(dst),
19402 + (__force_kernel const void *)____m(src), size);
19403 switch (size) {
19404 case 1: {
19405 u8 tmp;
19406 - __get_user_asm(tmp, (u8 __user *)src,
19407 + __get_user_asm(tmp, (const u8 __user *)src,
19408 ret, "b", "b", "=q", 1);
19409 if (likely(!ret))
19410 __put_user_asm(tmp, (u8 __user *)dst,
19411 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19412 }
19413 case 2: {
19414 u16 tmp;
19415 - __get_user_asm(tmp, (u16 __user *)src,
19416 + __get_user_asm(tmp, (const u16 __user *)src,
19417 ret, "w", "w", "=r", 2);
19418 if (likely(!ret))
19419 __put_user_asm(tmp, (u16 __user *)dst,
19420 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19421
19422 case 4: {
19423 u32 tmp;
19424 - __get_user_asm(tmp, (u32 __user *)src,
19425 + __get_user_asm(tmp, (const u32 __user *)src,
19426 ret, "l", "k", "=r", 4);
19427 if (likely(!ret))
19428 __put_user_asm(tmp, (u32 __user *)dst,
19429 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19430 }
19431 case 8: {
19432 u64 tmp;
19433 - __get_user_asm(tmp, (u64 __user *)src,
19434 + __get_user_asm(tmp, (const u64 __user *)src,
19435 ret, "q", "", "=r", 8);
19436 if (likely(!ret))
19437 __put_user_asm(tmp, (u64 __user *)dst,
19438 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19439 return ret;
19440 }
19441 default:
19442 - return copy_user_generic((__force void *)dst,
19443 - (__force void *)src, size);
19444 + return copy_user_generic((__force_kernel void *)____m(dst),
19445 + (__force_kernel const void *)____m(src), size);
19446 }
19447 }
19448
19449 -static __must_check __always_inline int
19450 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
19451 +static __must_check __always_inline unsigned long
19452 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
19453 {
19454 - return copy_user_generic(dst, (__force const void *)src, size);
19455 + if (size > INT_MAX)
19456 + return size;
19457 +
19458 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19459 + if (!__access_ok(VERIFY_READ, src, size))
19460 + return size;
19461 +#endif
19462 +
19463 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19464 }
19465
19466 -static __must_check __always_inline int
19467 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
19468 +static __must_check __always_inline unsigned long
19469 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
19470 {
19471 - return copy_user_generic((__force void *)dst, src, size);
19472 + if (size > INT_MAX)
19473 + return size;
19474 +
19475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19476 + if (!__access_ok(VERIFY_WRITE, dst, size))
19477 + return size;
19478 +#endif
19479 +
19480 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19481 }
19482
19483 -extern long __copy_user_nocache(void *dst, const void __user *src,
19484 - unsigned size, int zerorest);
19485 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
19486 + unsigned long size, int zerorest);
19487
19488 -static inline int
19489 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
19490 +static inline unsigned long
19491 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
19492 {
19493 might_fault();
19494 +
19495 + if (size > INT_MAX)
19496 + return size;
19497 +
19498 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19499 + if (!__access_ok(VERIFY_READ, src, size))
19500 + return size;
19501 +#endif
19502 +
19503 return __copy_user_nocache(dst, src, size, 1);
19504 }
19505
19506 -static inline int
19507 +static inline unsigned long
19508 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
19509 - unsigned size)
19510 + unsigned long size)
19511 {
19512 + if (size > INT_MAX)
19513 + return size;
19514 +
19515 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19516 + if (!__access_ok(VERIFY_READ, src, size))
19517 + return size;
19518 +#endif
19519 +
19520 return __copy_user_nocache(dst, src, size, 0);
19521 }
19522
19523 unsigned long
19524 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
19525 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
19526
19527 #endif /* _ASM_X86_UACCESS_64_H */
19528 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
19529 index 5b238981..77fdd78 100644
19530 --- a/arch/x86/include/asm/word-at-a-time.h
19531 +++ b/arch/x86/include/asm/word-at-a-time.h
19532 @@ -11,7 +11,7 @@
19533 * and shift, for example.
19534 */
19535 struct word_at_a_time {
19536 - const unsigned long one_bits, high_bits;
19537 + unsigned long one_bits, high_bits;
19538 };
19539
19540 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
19541 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
19542 index 828a156..650e625 100644
19543 --- a/arch/x86/include/asm/x86_init.h
19544 +++ b/arch/x86/include/asm/x86_init.h
19545 @@ -129,7 +129,7 @@ struct x86_init_ops {
19546 struct x86_init_timers timers;
19547 struct x86_init_iommu iommu;
19548 struct x86_init_pci pci;
19549 -};
19550 +} __no_const;
19551
19552 /**
19553 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
19554 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
19555 void (*setup_percpu_clockev)(void);
19556 void (*early_percpu_clock_init)(void);
19557 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
19558 -};
19559 +} __no_const;
19560
19561 struct timespec;
19562
19563 @@ -168,7 +168,7 @@ struct x86_platform_ops {
19564 void (*save_sched_clock_state)(void);
19565 void (*restore_sched_clock_state)(void);
19566 void (*apic_post_init)(void);
19567 -};
19568 +} __no_const;
19569
19570 struct pci_dev;
19571 struct msi_msg;
19572 @@ -182,7 +182,7 @@ struct x86_msi_ops {
19573 void (*teardown_msi_irqs)(struct pci_dev *dev);
19574 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
19575 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
19576 -};
19577 +} __no_const;
19578
19579 struct IO_APIC_route_entry;
19580 struct io_apic_irq_attr;
19581 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
19582 unsigned int destination, int vector,
19583 struct io_apic_irq_attr *attr);
19584 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
19585 -};
19586 +} __no_const;
19587
19588 extern struct x86_init_ops x86_init;
19589 extern struct x86_cpuinit_ops x86_cpuinit;
19590 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
19591 index b913915..4f5a581 100644
19592 --- a/arch/x86/include/asm/xen/page.h
19593 +++ b/arch/x86/include/asm/xen/page.h
19594 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
19595 extern struct page *m2p_find_override(unsigned long mfn);
19596 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
19597
19598 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
19599 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
19600 {
19601 unsigned long mfn;
19602
19603 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
19604 index 0415cda..3b22adc 100644
19605 --- a/arch/x86/include/asm/xsave.h
19606 +++ b/arch/x86/include/asm/xsave.h
19607 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19608 if (unlikely(err))
19609 return -EFAULT;
19610
19611 + pax_open_userland();
19612 __asm__ __volatile__(ASM_STAC "\n"
19613 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
19614 + "1:"
19615 + __copyuser_seg
19616 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
19617 "2: " ASM_CLAC "\n"
19618 ".section .fixup,\"ax\"\n"
19619 "3: movl $-1,%[err]\n"
19620 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19621 : [err] "=r" (err)
19622 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
19623 : "memory");
19624 + pax_close_userland();
19625 return err;
19626 }
19627
19628 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19629 {
19630 int err;
19631 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
19632 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
19633 u32 lmask = mask;
19634 u32 hmask = mask >> 32;
19635
19636 + pax_open_userland();
19637 __asm__ __volatile__(ASM_STAC "\n"
19638 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19639 + "1:"
19640 + __copyuser_seg
19641 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19642 "2: " ASM_CLAC "\n"
19643 ".section .fixup,\"ax\"\n"
19644 "3: movl $-1,%[err]\n"
19645 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19646 : [err] "=r" (err)
19647 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
19648 : "memory"); /* memory required? */
19649 + pax_close_userland();
19650 return err;
19651 }
19652
19653 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
19654 index bbae024..e1528f9 100644
19655 --- a/arch/x86/include/uapi/asm/e820.h
19656 +++ b/arch/x86/include/uapi/asm/e820.h
19657 @@ -63,7 +63,7 @@ struct e820map {
19658 #define ISA_START_ADDRESS 0xa0000
19659 #define ISA_END_ADDRESS 0x100000
19660
19661 -#define BIOS_BEGIN 0x000a0000
19662 +#define BIOS_BEGIN 0x000c0000
19663 #define BIOS_END 0x00100000
19664
19665 #define BIOS_ROM_BASE 0xffe00000
19666 diff --git a/arch/x86/include/uapi/asm/ptrace-abi.h b/arch/x86/include/uapi/asm/ptrace-abi.h
19667 index 7b0a55a..ad115bf 100644
19668 --- a/arch/x86/include/uapi/asm/ptrace-abi.h
19669 +++ b/arch/x86/include/uapi/asm/ptrace-abi.h
19670 @@ -49,7 +49,6 @@
19671 #define EFLAGS 144
19672 #define RSP 152
19673 #define SS 160
19674 -#define ARGOFFSET R11
19675 #endif /* __ASSEMBLY__ */
19676
19677 /* top of stack page */
19678 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
19679 index a5408b9..5133813 100644
19680 --- a/arch/x86/kernel/Makefile
19681 +++ b/arch/x86/kernel/Makefile
19682 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
19683 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
19684 obj-$(CONFIG_IRQ_WORK) += irq_work.o
19685 obj-y += probe_roms.o
19686 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
19687 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
19688 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
19689 obj-y += syscall_$(BITS).o
19690 obj-$(CONFIG_X86_64) += vsyscall_64.o
19691 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
19692 index 40c7660..f709f4b 100644
19693 --- a/arch/x86/kernel/acpi/boot.c
19694 +++ b/arch/x86/kernel/acpi/boot.c
19695 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
19696 * If your system is blacklisted here, but you find that acpi=force
19697 * works for you, please contact linux-acpi@vger.kernel.org
19698 */
19699 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
19700 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
19701 /*
19702 * Boxes that need ACPI disabled
19703 */
19704 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
19705 };
19706
19707 /* second table for DMI checks that should run after early-quirks */
19708 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
19709 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
19710 /*
19711 * HP laptops which use a DSDT reporting as HP/SB400/10000,
19712 * which includes some code which overrides all temperature
19713 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
19714 index 3312010..a65ca7b 100644
19715 --- a/arch/x86/kernel/acpi/sleep.c
19716 +++ b/arch/x86/kernel/acpi/sleep.c
19717 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
19718 #else /* CONFIG_64BIT */
19719 #ifdef CONFIG_SMP
19720 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
19721 +
19722 + pax_open_kernel();
19723 early_gdt_descr.address =
19724 (unsigned long)get_cpu_gdt_table(smp_processor_id());
19725 + pax_close_kernel();
19726 +
19727 initial_gs = per_cpu_offset(smp_processor_id());
19728 #endif
19729 initial_code = (unsigned long)wakeup_long64;
19730 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
19731 index d1daa66..59fecba 100644
19732 --- a/arch/x86/kernel/acpi/wakeup_32.S
19733 +++ b/arch/x86/kernel/acpi/wakeup_32.S
19734 @@ -29,13 +29,11 @@ wakeup_pmode_return:
19735 # and restore the stack ... but you need gdt for this to work
19736 movl saved_context_esp, %esp
19737
19738 - movl %cs:saved_magic, %eax
19739 - cmpl $0x12345678, %eax
19740 + cmpl $0x12345678, saved_magic
19741 jne bogus_magic
19742
19743 # jump to place where we left off
19744 - movl saved_eip, %eax
19745 - jmp *%eax
19746 + jmp *(saved_eip)
19747
19748 bogus_magic:
19749 jmp bogus_magic
19750 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
19751 index 15e8563..323cbe1 100644
19752 --- a/arch/x86/kernel/alternative.c
19753 +++ b/arch/x86/kernel/alternative.c
19754 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
19755 */
19756 for (a = start; a < end; a++) {
19757 instr = (u8 *)&a->instr_offset + a->instr_offset;
19758 +
19759 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19760 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19761 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19762 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19763 +#endif
19764 +
19765 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19766 BUG_ON(a->replacementlen > a->instrlen);
19767 BUG_ON(a->instrlen > sizeof(insnbuf));
19768 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19769 for (poff = start; poff < end; poff++) {
19770 u8 *ptr = (u8 *)poff + *poff;
19771
19772 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19773 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19774 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19775 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19776 +#endif
19777 +
19778 if (!*poff || ptr < text || ptr >= text_end)
19779 continue;
19780 /* turn DS segment override prefix into lock prefix */
19781 - if (*ptr == 0x3e)
19782 + if (*ktla_ktva(ptr) == 0x3e)
19783 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19784 }
19785 mutex_unlock(&text_mutex);
19786 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19787 for (poff = start; poff < end; poff++) {
19788 u8 *ptr = (u8 *)poff + *poff;
19789
19790 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19791 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19792 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19793 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19794 +#endif
19795 +
19796 if (!*poff || ptr < text || ptr >= text_end)
19797 continue;
19798 /* turn lock prefix into DS segment override prefix */
19799 - if (*ptr == 0xf0)
19800 + if (*ktla_ktva(ptr) == 0xf0)
19801 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19802 }
19803 mutex_unlock(&text_mutex);
19804 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19805
19806 BUG_ON(p->len > MAX_PATCH_LEN);
19807 /* prep the buffer with the original instructions */
19808 - memcpy(insnbuf, p->instr, p->len);
19809 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19810 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19811 (unsigned long)p->instr, p->len);
19812
19813 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19814 if (!uniproc_patched || num_possible_cpus() == 1)
19815 free_init_pages("SMP alternatives",
19816 (unsigned long)__smp_locks,
19817 - (unsigned long)__smp_locks_end);
19818 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19819 #endif
19820
19821 apply_paravirt(__parainstructions, __parainstructions_end);
19822 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19823 * instructions. And on the local CPU you need to be protected again NMI or MCE
19824 * handlers seeing an inconsistent instruction while you patch.
19825 */
19826 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19827 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19828 size_t len)
19829 {
19830 unsigned long flags;
19831 local_irq_save(flags);
19832 - memcpy(addr, opcode, len);
19833 +
19834 + pax_open_kernel();
19835 + memcpy(ktla_ktva(addr), opcode, len);
19836 sync_core();
19837 + pax_close_kernel();
19838 +
19839 local_irq_restore(flags);
19840 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19841 that causes hangs on some VIA CPUs. */
19842 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19843 */
19844 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19845 {
19846 - unsigned long flags;
19847 - char *vaddr;
19848 + unsigned char *vaddr = ktla_ktva(addr);
19849 struct page *pages[2];
19850 - int i;
19851 + size_t i;
19852
19853 if (!core_kernel_text((unsigned long)addr)) {
19854 - pages[0] = vmalloc_to_page(addr);
19855 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19856 + pages[0] = vmalloc_to_page(vaddr);
19857 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19858 } else {
19859 - pages[0] = virt_to_page(addr);
19860 + pages[0] = virt_to_page(vaddr);
19861 WARN_ON(!PageReserved(pages[0]));
19862 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19863 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19864 }
19865 BUG_ON(!pages[0]);
19866 - local_irq_save(flags);
19867 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19868 - if (pages[1])
19869 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19870 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19871 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19872 - clear_fixmap(FIX_TEXT_POKE0);
19873 - if (pages[1])
19874 - clear_fixmap(FIX_TEXT_POKE1);
19875 - local_flush_tlb();
19876 - sync_core();
19877 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19878 - that causes hangs on some VIA CPUs. */
19879 + text_poke_early(addr, opcode, len);
19880 for (i = 0; i < len; i++)
19881 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19882 - local_irq_restore(flags);
19883 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19884 return addr;
19885 }
19886
19887 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19888 if (likely(!bp_patching_in_progress))
19889 return 0;
19890
19891 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19892 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19893 return 0;
19894
19895 /* set up the specified breakpoint handler */
19896 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19897 */
19898 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19899 {
19900 - unsigned char int3 = 0xcc;
19901 + const unsigned char int3 = 0xcc;
19902
19903 bp_int3_handler = handler;
19904 bp_int3_addr = (u8 *)addr + sizeof(int3);
19905 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19906 index a7eb82d..f6e52d4 100644
19907 --- a/arch/x86/kernel/apic/apic.c
19908 +++ b/arch/x86/kernel/apic/apic.c
19909 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19910 /*
19911 * Debug level, exported for io_apic.c
19912 */
19913 -unsigned int apic_verbosity;
19914 +int apic_verbosity;
19915
19916 int pic_mode;
19917
19918 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19919 apic_write(APIC_ESR, 0);
19920 v1 = apic_read(APIC_ESR);
19921 ack_APIC_irq();
19922 - atomic_inc(&irq_err_count);
19923 + atomic_inc_unchecked(&irq_err_count);
19924
19925 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19926 smp_processor_id(), v0 , v1);
19927 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19928 index 00c77cf..2dc6a2d 100644
19929 --- a/arch/x86/kernel/apic/apic_flat_64.c
19930 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19931 @@ -157,7 +157,7 @@ static int flat_probe(void)
19932 return 1;
19933 }
19934
19935 -static struct apic apic_flat = {
19936 +static struct apic apic_flat __read_only = {
19937 .name = "flat",
19938 .probe = flat_probe,
19939 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19940 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19941 return 0;
19942 }
19943
19944 -static struct apic apic_physflat = {
19945 +static struct apic apic_physflat __read_only = {
19946
19947 .name = "physical flat",
19948 .probe = physflat_probe,
19949 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19950 index e145f28..2752888 100644
19951 --- a/arch/x86/kernel/apic/apic_noop.c
19952 +++ b/arch/x86/kernel/apic/apic_noop.c
19953 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19954 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19955 }
19956
19957 -struct apic apic_noop = {
19958 +struct apic apic_noop __read_only = {
19959 .name = "noop",
19960 .probe = noop_probe,
19961 .acpi_madt_oem_check = NULL,
19962 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19963 index d50e364..543bee3 100644
19964 --- a/arch/x86/kernel/apic/bigsmp_32.c
19965 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19966 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19967 return dmi_bigsmp;
19968 }
19969
19970 -static struct apic apic_bigsmp = {
19971 +static struct apic apic_bigsmp __read_only = {
19972
19973 .name = "bigsmp",
19974 .probe = probe_bigsmp,
19975 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19976 index c552247..587a316 100644
19977 --- a/arch/x86/kernel/apic/es7000_32.c
19978 +++ b/arch/x86/kernel/apic/es7000_32.c
19979 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19980 return ret && es7000_apic_is_cluster();
19981 }
19982
19983 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19984 -static struct apic __refdata apic_es7000_cluster = {
19985 +static struct apic apic_es7000_cluster __read_only = {
19986
19987 .name = "es7000",
19988 .probe = probe_es7000,
19989 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19990 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19991 };
19992
19993 -static struct apic __refdata apic_es7000 = {
19994 +static struct apic apic_es7000 __read_only = {
19995
19996 .name = "es7000",
19997 .probe = probe_es7000,
19998 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19999 index e63a5bd..c0babf8 100644
20000 --- a/arch/x86/kernel/apic/io_apic.c
20001 +++ b/arch/x86/kernel/apic/io_apic.c
20002 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
20003 }
20004 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
20005
20006 -void lock_vector_lock(void)
20007 +void lock_vector_lock(void) __acquires(vector_lock)
20008 {
20009 /* Used to the online set of cpus does not change
20010 * during assign_irq_vector.
20011 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
20012 raw_spin_lock(&vector_lock);
20013 }
20014
20015 -void unlock_vector_lock(void)
20016 +void unlock_vector_lock(void) __releases(vector_lock)
20017 {
20018 raw_spin_unlock(&vector_lock);
20019 }
20020 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
20021 ack_APIC_irq();
20022 }
20023
20024 -atomic_t irq_mis_count;
20025 +atomic_unchecked_t irq_mis_count;
20026
20027 #ifdef CONFIG_GENERIC_PENDING_IRQ
20028 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
20029 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
20030 * at the cpu.
20031 */
20032 if (!(v & (1 << (i & 0x1f)))) {
20033 - atomic_inc(&irq_mis_count);
20034 + atomic_inc_unchecked(&irq_mis_count);
20035
20036 eoi_ioapic_irq(irq, cfg);
20037 }
20038 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
20039 index 1e42e8f..daacf44 100644
20040 --- a/arch/x86/kernel/apic/numaq_32.c
20041 +++ b/arch/x86/kernel/apic/numaq_32.c
20042 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
20043 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
20044 }
20045
20046 -/* Use __refdata to keep false positive warning calm. */
20047 -static struct apic __refdata apic_numaq = {
20048 +static struct apic apic_numaq __read_only = {
20049
20050 .name = "NUMAQ",
20051 .probe = probe_numaq,
20052 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
20053 index eb35ef9..f184a21 100644
20054 --- a/arch/x86/kernel/apic/probe_32.c
20055 +++ b/arch/x86/kernel/apic/probe_32.c
20056 @@ -72,7 +72,7 @@ static int probe_default(void)
20057 return 1;
20058 }
20059
20060 -static struct apic apic_default = {
20061 +static struct apic apic_default __read_only = {
20062
20063 .name = "default",
20064 .probe = probe_default,
20065 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
20066 index 77c95c0..434f8a4 100644
20067 --- a/arch/x86/kernel/apic/summit_32.c
20068 +++ b/arch/x86/kernel/apic/summit_32.c
20069 @@ -486,7 +486,7 @@ void setup_summit(void)
20070 }
20071 #endif
20072
20073 -static struct apic apic_summit = {
20074 +static struct apic apic_summit __read_only = {
20075
20076 .name = "summit",
20077 .probe = probe_summit,
20078 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
20079 index 140e29d..d88bc95 100644
20080 --- a/arch/x86/kernel/apic/x2apic_cluster.c
20081 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
20082 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
20083 return notifier_from_errno(err);
20084 }
20085
20086 -static struct notifier_block __refdata x2apic_cpu_notifier = {
20087 +static struct notifier_block x2apic_cpu_notifier = {
20088 .notifier_call = update_clusterinfo,
20089 };
20090
20091 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
20092 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
20093 }
20094
20095 -static struct apic apic_x2apic_cluster = {
20096 +static struct apic apic_x2apic_cluster __read_only = {
20097
20098 .name = "cluster x2apic",
20099 .probe = x2apic_cluster_probe,
20100 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
20101 index 562a76d..a003c0f 100644
20102 --- a/arch/x86/kernel/apic/x2apic_phys.c
20103 +++ b/arch/x86/kernel/apic/x2apic_phys.c
20104 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
20105 return apic == &apic_x2apic_phys;
20106 }
20107
20108 -static struct apic apic_x2apic_phys = {
20109 +static struct apic apic_x2apic_phys __read_only = {
20110
20111 .name = "physical x2apic",
20112 .probe = x2apic_phys_probe,
20113 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
20114 index a419814..1dd34a0 100644
20115 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
20116 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
20117 @@ -357,7 +357,7 @@ static int uv_probe(void)
20118 return apic == &apic_x2apic_uv_x;
20119 }
20120
20121 -static struct apic __refdata apic_x2apic_uv_x = {
20122 +static struct apic apic_x2apic_uv_x __read_only = {
20123
20124 .name = "UV large system",
20125 .probe = uv_probe,
20126 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
20127 index 3ab0343..814c4787 100644
20128 --- a/arch/x86/kernel/apm_32.c
20129 +++ b/arch/x86/kernel/apm_32.c
20130 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
20131 * This is for buggy BIOS's that refer to (real mode) segment 0x40
20132 * even though they are called in protected mode.
20133 */
20134 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
20135 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
20136 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
20137
20138 static const char driver_version[] = "1.16ac"; /* no spaces */
20139 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
20140 BUG_ON(cpu != 0);
20141 gdt = get_cpu_gdt_table(cpu);
20142 save_desc_40 = gdt[0x40 / 8];
20143 +
20144 + pax_open_kernel();
20145 gdt[0x40 / 8] = bad_bios_desc;
20146 + pax_close_kernel();
20147
20148 apm_irq_save(flags);
20149 APM_DO_SAVE_SEGS;
20150 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
20151 &call->esi);
20152 APM_DO_RESTORE_SEGS;
20153 apm_irq_restore(flags);
20154 +
20155 + pax_open_kernel();
20156 gdt[0x40 / 8] = save_desc_40;
20157 + pax_close_kernel();
20158 +
20159 put_cpu();
20160
20161 return call->eax & 0xff;
20162 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
20163 BUG_ON(cpu != 0);
20164 gdt = get_cpu_gdt_table(cpu);
20165 save_desc_40 = gdt[0x40 / 8];
20166 +
20167 + pax_open_kernel();
20168 gdt[0x40 / 8] = bad_bios_desc;
20169 + pax_close_kernel();
20170
20171 apm_irq_save(flags);
20172 APM_DO_SAVE_SEGS;
20173 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
20174 &call->eax);
20175 APM_DO_RESTORE_SEGS;
20176 apm_irq_restore(flags);
20177 +
20178 + pax_open_kernel();
20179 gdt[0x40 / 8] = save_desc_40;
20180 + pax_close_kernel();
20181 +
20182 put_cpu();
20183 return error;
20184 }
20185 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
20186 * code to that CPU.
20187 */
20188 gdt = get_cpu_gdt_table(0);
20189 +
20190 + pax_open_kernel();
20191 set_desc_base(&gdt[APM_CS >> 3],
20192 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
20193 set_desc_base(&gdt[APM_CS_16 >> 3],
20194 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
20195 set_desc_base(&gdt[APM_DS >> 3],
20196 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
20197 + pax_close_kernel();
20198
20199 proc_create("apm", 0, NULL, &apm_file_ops);
20200
20201 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
20202 index 2861082..6d4718e 100644
20203 --- a/arch/x86/kernel/asm-offsets.c
20204 +++ b/arch/x86/kernel/asm-offsets.c
20205 @@ -33,6 +33,8 @@ void common(void) {
20206 OFFSET(TI_status, thread_info, status);
20207 OFFSET(TI_addr_limit, thread_info, addr_limit);
20208 OFFSET(TI_preempt_count, thread_info, preempt_count);
20209 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
20210 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
20211
20212 BLANK();
20213 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
20214 @@ -53,8 +55,26 @@ void common(void) {
20215 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
20216 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
20217 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
20218 +
20219 +#ifdef CONFIG_PAX_KERNEXEC
20220 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
20221 #endif
20222
20223 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20224 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
20225 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
20226 +#ifdef CONFIG_X86_64
20227 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
20228 +#endif
20229 +#endif
20230 +
20231 +#endif
20232 +
20233 + BLANK();
20234 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
20235 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
20236 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
20237 +
20238 #ifdef CONFIG_XEN
20239 BLANK();
20240 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
20241 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
20242 index e7c798b..2b2019b 100644
20243 --- a/arch/x86/kernel/asm-offsets_64.c
20244 +++ b/arch/x86/kernel/asm-offsets_64.c
20245 @@ -77,6 +77,7 @@ int main(void)
20246 BLANK();
20247 #undef ENTRY
20248
20249 + DEFINE(TSS_size, sizeof(struct tss_struct));
20250 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
20251 BLANK();
20252
20253 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
20254 index 47b56a7..efc2bc6 100644
20255 --- a/arch/x86/kernel/cpu/Makefile
20256 +++ b/arch/x86/kernel/cpu/Makefile
20257 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
20258 CFLAGS_REMOVE_perf_event.o = -pg
20259 endif
20260
20261 -# Make sure load_percpu_segment has no stackprotector
20262 -nostackp := $(call cc-option, -fno-stack-protector)
20263 -CFLAGS_common.o := $(nostackp)
20264 -
20265 obj-y := intel_cacheinfo.o scattered.o topology.o
20266 obj-y += proc.o capflags.o powerflags.o common.o
20267 obj-y += rdrand.o
20268 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
20269 index 903a264..fc955f3 100644
20270 --- a/arch/x86/kernel/cpu/amd.c
20271 +++ b/arch/x86/kernel/cpu/amd.c
20272 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
20273 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
20274 {
20275 /* AMD errata T13 (order #21922) */
20276 - if ((c->x86 == 6)) {
20277 + if (c->x86 == 6) {
20278 /* Duron Rev A0 */
20279 if (c->x86_model == 3 && c->x86_mask == 0)
20280 size = 64;
20281 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
20282 index 2793d1f..b4f313a 100644
20283 --- a/arch/x86/kernel/cpu/common.c
20284 +++ b/arch/x86/kernel/cpu/common.c
20285 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
20286
20287 static const struct cpu_dev *this_cpu = &default_cpu;
20288
20289 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
20290 -#ifdef CONFIG_X86_64
20291 - /*
20292 - * We need valid kernel segments for data and code in long mode too
20293 - * IRET will check the segment types kkeil 2000/10/28
20294 - * Also sysret mandates a special GDT layout
20295 - *
20296 - * TLS descriptors are currently at a different place compared to i386.
20297 - * Hopefully nobody expects them at a fixed place (Wine?)
20298 - */
20299 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
20300 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
20301 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
20302 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
20303 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
20304 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
20305 -#else
20306 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
20307 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20308 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
20309 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
20310 - /*
20311 - * Segments used for calling PnP BIOS have byte granularity.
20312 - * They code segments and data segments have fixed 64k limits,
20313 - * the transfer segment sizes are set at run time.
20314 - */
20315 - /* 32-bit code */
20316 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20317 - /* 16-bit code */
20318 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20319 - /* 16-bit data */
20320 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
20321 - /* 16-bit data */
20322 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
20323 - /* 16-bit data */
20324 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
20325 - /*
20326 - * The APM segments have byte granularity and their bases
20327 - * are set at run time. All have 64k limits.
20328 - */
20329 - /* 32-bit code */
20330 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20331 - /* 16-bit code */
20332 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20333 - /* data */
20334 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
20335 -
20336 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20337 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20338 - GDT_STACK_CANARY_INIT
20339 -#endif
20340 -} };
20341 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
20342 -
20343 static int __init x86_xsave_setup(char *s)
20344 {
20345 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
20346 @@ -288,6 +234,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
20347 set_in_cr4(X86_CR4_SMAP);
20348 }
20349
20350 +#ifdef CONFIG_X86_64
20351 +static __init int setup_disable_pcid(char *arg)
20352 +{
20353 + setup_clear_cpu_cap(X86_FEATURE_PCID);
20354 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
20355 +
20356 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20357 + if (clone_pgd_mask != ~(pgdval_t)0UL)
20358 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20359 +#endif
20360 +
20361 + return 1;
20362 +}
20363 +__setup("nopcid", setup_disable_pcid);
20364 +
20365 +static void setup_pcid(struct cpuinfo_x86 *c)
20366 +{
20367 + if (!cpu_has(c, X86_FEATURE_PCID)) {
20368 + clear_cpu_cap(c, X86_FEATURE_INVPCID);
20369 +
20370 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20371 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
20372 + pax_open_kernel();
20373 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20374 + pax_close_kernel();
20375 + printk("PAX: slow and weak UDEREF enabled\n");
20376 + } else
20377 + printk("PAX: UDEREF disabled\n");
20378 +#endif
20379 +
20380 + return;
20381 + }
20382 +
20383 + printk("PAX: PCID detected\n");
20384 + set_in_cr4(X86_CR4_PCIDE);
20385 +
20386 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20387 + pax_open_kernel();
20388 + clone_pgd_mask = ~(pgdval_t)0UL;
20389 + pax_close_kernel();
20390 + if (pax_user_shadow_base)
20391 + printk("PAX: weak UDEREF enabled\n");
20392 + else {
20393 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
20394 + printk("PAX: strong UDEREF enabled\n");
20395 + }
20396 +#endif
20397 +
20398 + if (cpu_has(c, X86_FEATURE_INVPCID))
20399 + printk("PAX: INVPCID detected\n");
20400 +}
20401 +#endif
20402 +
20403 /*
20404 * Some CPU features depend on higher CPUID levels, which may not always
20405 * be available due to CPUID level capping or broken virtualization
20406 @@ -386,7 +385,7 @@ void switch_to_new_gdt(int cpu)
20407 {
20408 struct desc_ptr gdt_descr;
20409
20410 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
20411 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
20412 gdt_descr.size = GDT_SIZE - 1;
20413 load_gdt(&gdt_descr);
20414 /* Reload the per-cpu base */
20415 @@ -875,6 +874,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20416 setup_smep(c);
20417 setup_smap(c);
20418
20419 +#ifdef CONFIG_X86_64
20420 + setup_pcid(c);
20421 +#endif
20422 +
20423 /*
20424 * The vendor-specific functions might have changed features.
20425 * Now we do "generic changes."
20426 @@ -883,6 +886,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20427 /* Filter out anything that depends on CPUID levels we don't have */
20428 filter_cpuid_features(c, true);
20429
20430 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
20431 + setup_clear_cpu_cap(X86_FEATURE_SEP);
20432 +#endif
20433 +
20434 /* If the model name is still unset, do table lookup. */
20435 if (!c->x86_model_id[0]) {
20436 const char *p;
20437 @@ -1070,10 +1077,12 @@ static __init int setup_disablecpuid(char *arg)
20438 }
20439 __setup("clearcpuid=", setup_disablecpuid);
20440
20441 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
20442 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
20443 +
20444 #ifdef CONFIG_X86_64
20445 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20446 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
20447 - (unsigned long) debug_idt_table };
20448 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20449 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
20450
20451 DEFINE_PER_CPU_FIRST(union irq_stack_union,
20452 irq_stack_union) __aligned(PAGE_SIZE) __visible;
20453 @@ -1087,7 +1096,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
20454 EXPORT_PER_CPU_SYMBOL(current_task);
20455
20456 DEFINE_PER_CPU(unsigned long, kernel_stack) =
20457 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
20458 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
20459 EXPORT_PER_CPU_SYMBOL(kernel_stack);
20460
20461 DEFINE_PER_CPU(char *, irq_stack_ptr) =
20462 @@ -1232,7 +1241,7 @@ void cpu_init(void)
20463 load_ucode_ap();
20464
20465 cpu = stack_smp_processor_id();
20466 - t = &per_cpu(init_tss, cpu);
20467 + t = init_tss + cpu;
20468 oist = &per_cpu(orig_ist, cpu);
20469
20470 #ifdef CONFIG_NUMA
20471 @@ -1267,7 +1276,6 @@ void cpu_init(void)
20472 wrmsrl(MSR_KERNEL_GS_BASE, 0);
20473 barrier();
20474
20475 - x86_configure_nx();
20476 enable_x2apic();
20477
20478 /*
20479 @@ -1319,7 +1327,7 @@ void cpu_init(void)
20480 {
20481 int cpu = smp_processor_id();
20482 struct task_struct *curr = current;
20483 - struct tss_struct *t = &per_cpu(init_tss, cpu);
20484 + struct tss_struct *t = init_tss + cpu;
20485 struct thread_struct *thread = &curr->thread;
20486
20487 show_ucode_info_early();
20488 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
20489 index 1414c90..1159406 100644
20490 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
20491 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
20492 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
20493 };
20494
20495 #ifdef CONFIG_AMD_NB
20496 +static struct attribute *default_attrs_amd_nb[] = {
20497 + &type.attr,
20498 + &level.attr,
20499 + &coherency_line_size.attr,
20500 + &physical_line_partition.attr,
20501 + &ways_of_associativity.attr,
20502 + &number_of_sets.attr,
20503 + &size.attr,
20504 + &shared_cpu_map.attr,
20505 + &shared_cpu_list.attr,
20506 + NULL,
20507 + NULL,
20508 + NULL,
20509 + NULL
20510 +};
20511 +
20512 static struct attribute **amd_l3_attrs(void)
20513 {
20514 static struct attribute **attrs;
20515 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
20516
20517 n = ARRAY_SIZE(default_attrs);
20518
20519 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
20520 - n += 2;
20521 -
20522 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
20523 - n += 1;
20524 -
20525 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
20526 - if (attrs == NULL)
20527 - return attrs = default_attrs;
20528 -
20529 - for (n = 0; default_attrs[n]; n++)
20530 - attrs[n] = default_attrs[n];
20531 + attrs = default_attrs_amd_nb;
20532
20533 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
20534 attrs[n++] = &cache_disable_0.attr;
20535 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
20536 .default_attrs = default_attrs,
20537 };
20538
20539 +#ifdef CONFIG_AMD_NB
20540 +static struct kobj_type ktype_cache_amd_nb = {
20541 + .sysfs_ops = &sysfs_ops,
20542 + .default_attrs = default_attrs_amd_nb,
20543 +};
20544 +#endif
20545 +
20546 static struct kobj_type ktype_percpu_entry = {
20547 .sysfs_ops = &sysfs_ops,
20548 };
20549 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
20550 return retval;
20551 }
20552
20553 +#ifdef CONFIG_AMD_NB
20554 + amd_l3_attrs();
20555 +#endif
20556 +
20557 for (i = 0; i < num_cache_leaves; i++) {
20558 + struct kobj_type *ktype;
20559 +
20560 this_object = INDEX_KOBJECT_PTR(cpu, i);
20561 this_object->cpu = cpu;
20562 this_object->index = i;
20563
20564 this_leaf = CPUID4_INFO_IDX(cpu, i);
20565
20566 - ktype_cache.default_attrs = default_attrs;
20567 + ktype = &ktype_cache;
20568 #ifdef CONFIG_AMD_NB
20569 if (this_leaf->base.nb)
20570 - ktype_cache.default_attrs = amd_l3_attrs();
20571 + ktype = &ktype_cache_amd_nb;
20572 #endif
20573 retval = kobject_init_and_add(&(this_object->kobj),
20574 - &ktype_cache,
20575 + ktype,
20576 per_cpu(ici_cache_kobject, cpu),
20577 "index%1lu", i);
20578 if (unlikely(retval)) {
20579 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
20580 index b3218cd..99a75de 100644
20581 --- a/arch/x86/kernel/cpu/mcheck/mce.c
20582 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
20583 @@ -45,6 +45,7 @@
20584 #include <asm/processor.h>
20585 #include <asm/mce.h>
20586 #include <asm/msr.h>
20587 +#include <asm/local.h>
20588
20589 #include "mce-internal.h"
20590
20591 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
20592 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
20593 m->cs, m->ip);
20594
20595 - if (m->cs == __KERNEL_CS)
20596 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
20597 print_symbol("{%s}", m->ip);
20598 pr_cont("\n");
20599 }
20600 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
20601
20602 #define PANIC_TIMEOUT 5 /* 5 seconds */
20603
20604 -static atomic_t mce_paniced;
20605 +static atomic_unchecked_t mce_paniced;
20606
20607 static int fake_panic;
20608 -static atomic_t mce_fake_paniced;
20609 +static atomic_unchecked_t mce_fake_paniced;
20610
20611 /* Panic in progress. Enable interrupts and wait for final IPI */
20612 static void wait_for_panic(void)
20613 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20614 /*
20615 * Make sure only one CPU runs in machine check panic
20616 */
20617 - if (atomic_inc_return(&mce_paniced) > 1)
20618 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
20619 wait_for_panic();
20620 barrier();
20621
20622 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20623 console_verbose();
20624 } else {
20625 /* Don't log too much for fake panic */
20626 - if (atomic_inc_return(&mce_fake_paniced) > 1)
20627 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
20628 return;
20629 }
20630 /* First print corrected ones that are still unlogged */
20631 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20632 if (!fake_panic) {
20633 if (panic_timeout == 0)
20634 panic_timeout = mca_cfg.panic_timeout;
20635 - panic(msg);
20636 + panic("%s", msg);
20637 } else
20638 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
20639 }
20640 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
20641 * might have been modified by someone else.
20642 */
20643 rmb();
20644 - if (atomic_read(&mce_paniced))
20645 + if (atomic_read_unchecked(&mce_paniced))
20646 wait_for_panic();
20647 if (!mca_cfg.monarch_timeout)
20648 goto out;
20649 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
20650 }
20651
20652 /* Call the installed machine check handler for this CPU setup. */
20653 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
20654 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
20655 unexpected_machine_check;
20656
20657 /*
20658 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20659 return;
20660 }
20661
20662 + pax_open_kernel();
20663 machine_check_vector = do_machine_check;
20664 + pax_close_kernel();
20665
20666 __mcheck_cpu_init_generic();
20667 __mcheck_cpu_init_vendor(c);
20668 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20669 */
20670
20671 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
20672 -static int mce_chrdev_open_count; /* #times opened */
20673 +static local_t mce_chrdev_open_count; /* #times opened */
20674 static int mce_chrdev_open_exclu; /* already open exclusive? */
20675
20676 static int mce_chrdev_open(struct inode *inode, struct file *file)
20677 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20678 spin_lock(&mce_chrdev_state_lock);
20679
20680 if (mce_chrdev_open_exclu ||
20681 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
20682 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
20683 spin_unlock(&mce_chrdev_state_lock);
20684
20685 return -EBUSY;
20686 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20687
20688 if (file->f_flags & O_EXCL)
20689 mce_chrdev_open_exclu = 1;
20690 - mce_chrdev_open_count++;
20691 + local_inc(&mce_chrdev_open_count);
20692
20693 spin_unlock(&mce_chrdev_state_lock);
20694
20695 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
20696 {
20697 spin_lock(&mce_chrdev_state_lock);
20698
20699 - mce_chrdev_open_count--;
20700 + local_dec(&mce_chrdev_open_count);
20701 mce_chrdev_open_exclu = 0;
20702
20703 spin_unlock(&mce_chrdev_state_lock);
20704 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
20705
20706 for (i = 0; i < mca_cfg.banks; i++) {
20707 struct mce_bank *b = &mce_banks[i];
20708 - struct device_attribute *a = &b->attr;
20709 + device_attribute_no_const *a = &b->attr;
20710
20711 sysfs_attr_init(&a->attr);
20712 a->attr.name = b->attrname;
20713 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
20714 static void mce_reset(void)
20715 {
20716 cpu_missing = 0;
20717 - atomic_set(&mce_fake_paniced, 0);
20718 + atomic_set_unchecked(&mce_fake_paniced, 0);
20719 atomic_set(&mce_executing, 0);
20720 atomic_set(&mce_callin, 0);
20721 atomic_set(&global_nwo, 0);
20722 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
20723 index 1c044b1..37a2a43 100644
20724 --- a/arch/x86/kernel/cpu/mcheck/p5.c
20725 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
20726 @@ -11,6 +11,7 @@
20727 #include <asm/processor.h>
20728 #include <asm/mce.h>
20729 #include <asm/msr.h>
20730 +#include <asm/pgtable.h>
20731
20732 /* By default disabled */
20733 int mce_p5_enabled __read_mostly;
20734 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
20735 if (!cpu_has(c, X86_FEATURE_MCE))
20736 return;
20737
20738 + pax_open_kernel();
20739 machine_check_vector = pentium_machine_check;
20740 + pax_close_kernel();
20741 /* Make sure the vector pointer is visible before we enable MCEs: */
20742 wmb();
20743
20744 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
20745 index e9a701a..35317d6 100644
20746 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
20747 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
20748 @@ -10,6 +10,7 @@
20749 #include <asm/processor.h>
20750 #include <asm/mce.h>
20751 #include <asm/msr.h>
20752 +#include <asm/pgtable.h>
20753
20754 /* Machine check handler for WinChip C6: */
20755 static void winchip_machine_check(struct pt_regs *regs, long error_code)
20756 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
20757 {
20758 u32 lo, hi;
20759
20760 + pax_open_kernel();
20761 machine_check_vector = winchip_machine_check;
20762 + pax_close_kernel();
20763 /* Make sure the vector pointer is visible before we enable MCEs: */
20764 wmb();
20765
20766 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
20767 index f961de9..8a9d332 100644
20768 --- a/arch/x86/kernel/cpu/mtrr/main.c
20769 +++ b/arch/x86/kernel/cpu/mtrr/main.c
20770 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
20771 u64 size_or_mask, size_and_mask;
20772 static bool mtrr_aps_delayed_init;
20773
20774 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
20775 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20776
20777 const struct mtrr_ops *mtrr_if;
20778
20779 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20780 index df5e41f..816c719 100644
20781 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20782 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20783 @@ -25,7 +25,7 @@ struct mtrr_ops {
20784 int (*validate_add_page)(unsigned long base, unsigned long size,
20785 unsigned int type);
20786 int (*have_wrcomb)(void);
20787 -};
20788 +} __do_const;
20789
20790 extern int generic_get_free_region(unsigned long base, unsigned long size,
20791 int replace_reg);
20792 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20793 index 8a87a32..682a22a 100644
20794 --- a/arch/x86/kernel/cpu/perf_event.c
20795 +++ b/arch/x86/kernel/cpu/perf_event.c
20796 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
20797 pr_info("no hardware sampling interrupt available.\n");
20798 }
20799
20800 -static struct attribute_group x86_pmu_format_group = {
20801 +static attribute_group_no_const x86_pmu_format_group = {
20802 .name = "format",
20803 .attrs = NULL,
20804 };
20805 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
20806 NULL,
20807 };
20808
20809 -static struct attribute_group x86_pmu_events_group = {
20810 +static attribute_group_no_const x86_pmu_events_group = {
20811 .name = "events",
20812 .attrs = events_attr,
20813 };
20814 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20815 if (idx > GDT_ENTRIES)
20816 return 0;
20817
20818 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20819 + desc = get_cpu_gdt_table(smp_processor_id());
20820 }
20821
20822 return get_desc_base(desc + idx);
20823 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20824 break;
20825
20826 perf_callchain_store(entry, frame.return_address);
20827 - fp = frame.next_frame;
20828 + fp = (const void __force_user *)frame.next_frame;
20829 }
20830 }
20831
20832 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20833 index 639d128..e92d7e5 100644
20834 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20835 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20836 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20837 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20838 {
20839 struct attribute **attrs;
20840 - struct attribute_group *attr_group;
20841 + attribute_group_no_const *attr_group;
20842 int i = 0, j;
20843
20844 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20845 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20846 index f31a165..7b46cd8 100644
20847 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20848 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20849 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20850 * v2 and above have a perf capabilities MSR
20851 */
20852 if (version > 1) {
20853 - u64 capabilities;
20854 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20855
20856 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20857 - x86_pmu.intel_cap.capabilities = capabilities;
20858 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20859 + x86_pmu.intel_cap.capabilities = capabilities;
20860 }
20861
20862 intel_ds_init();
20863 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20864 index 4118f9f..f91d0ab 100644
20865 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20866 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20867 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20868 static int __init uncore_type_init(struct intel_uncore_type *type)
20869 {
20870 struct intel_uncore_pmu *pmus;
20871 - struct attribute_group *attr_group;
20872 + attribute_group_no_const *attr_group;
20873 struct attribute **attrs;
20874 int i, j;
20875
20876 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20877 index a80ab71..4089da5 100644
20878 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20879 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20880 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20881 struct uncore_event_desc {
20882 struct kobj_attribute attr;
20883 const char *config;
20884 -};
20885 +} __do_const;
20886
20887 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20888 { \
20889 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20890 index 7d9481c..99c7e4b 100644
20891 --- a/arch/x86/kernel/cpuid.c
20892 +++ b/arch/x86/kernel/cpuid.c
20893 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20894 return notifier_from_errno(err);
20895 }
20896
20897 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20898 +static struct notifier_block cpuid_class_cpu_notifier =
20899 {
20900 .notifier_call = cpuid_class_cpu_callback,
20901 };
20902 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20903 index 18677a9..f67c45b 100644
20904 --- a/arch/x86/kernel/crash.c
20905 +++ b/arch/x86/kernel/crash.c
20906 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20907 {
20908 #ifdef CONFIG_X86_32
20909 struct pt_regs fixed_regs;
20910 -#endif
20911
20912 -#ifdef CONFIG_X86_32
20913 - if (!user_mode_vm(regs)) {
20914 + if (!user_mode(regs)) {
20915 crash_fixup_ss_esp(&fixed_regs, regs);
20916 regs = &fixed_regs;
20917 }
20918 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20919 index afa64ad..dce67dd 100644
20920 --- a/arch/x86/kernel/crash_dump_64.c
20921 +++ b/arch/x86/kernel/crash_dump_64.c
20922 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20923 return -ENOMEM;
20924
20925 if (userbuf) {
20926 - if (copy_to_user(buf, vaddr + offset, csize)) {
20927 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20928 iounmap(vaddr);
20929 return -EFAULT;
20930 }
20931 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20932 index 5d3fe8d..02e1429 100644
20933 --- a/arch/x86/kernel/doublefault.c
20934 +++ b/arch/x86/kernel/doublefault.c
20935 @@ -13,7 +13,7 @@
20936
20937 #define DOUBLEFAULT_STACKSIZE (1024)
20938 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20939 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20940 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20941
20942 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20943
20944 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20945 unsigned long gdt, tss;
20946
20947 native_store_gdt(&gdt_desc);
20948 - gdt = gdt_desc.address;
20949 + gdt = (unsigned long)gdt_desc.address;
20950
20951 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20952
20953 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20954 /* 0x2 bit is always set */
20955 .flags = X86_EFLAGS_SF | 0x2,
20956 .sp = STACK_START,
20957 - .es = __USER_DS,
20958 + .es = __KERNEL_DS,
20959 .cs = __KERNEL_CS,
20960 .ss = __KERNEL_DS,
20961 - .ds = __USER_DS,
20962 + .ds = __KERNEL_DS,
20963 .fs = __KERNEL_PERCPU,
20964
20965 .__cr3 = __pa_nodebug(swapper_pg_dir),
20966 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20967 index deb6421..76bbc12 100644
20968 --- a/arch/x86/kernel/dumpstack.c
20969 +++ b/arch/x86/kernel/dumpstack.c
20970 @@ -2,6 +2,9 @@
20971 * Copyright (C) 1991, 1992 Linus Torvalds
20972 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20973 */
20974 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20975 +#define __INCLUDED_BY_HIDESYM 1
20976 +#endif
20977 #include <linux/kallsyms.h>
20978 #include <linux/kprobes.h>
20979 #include <linux/uaccess.h>
20980 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20981 static void
20982 print_ftrace_graph_addr(unsigned long addr, void *data,
20983 const struct stacktrace_ops *ops,
20984 - struct thread_info *tinfo, int *graph)
20985 + struct task_struct *task, int *graph)
20986 {
20987 - struct task_struct *task;
20988 unsigned long ret_addr;
20989 int index;
20990
20991 if (addr != (unsigned long)return_to_handler)
20992 return;
20993
20994 - task = tinfo->task;
20995 index = task->curr_ret_stack;
20996
20997 if (!task->ret_stack || index < *graph)
20998 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20999 static inline void
21000 print_ftrace_graph_addr(unsigned long addr, void *data,
21001 const struct stacktrace_ops *ops,
21002 - struct thread_info *tinfo, int *graph)
21003 + struct task_struct *task, int *graph)
21004 { }
21005 #endif
21006
21007 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
21008 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
21009 */
21010
21011 -static inline int valid_stack_ptr(struct thread_info *tinfo,
21012 - void *p, unsigned int size, void *end)
21013 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
21014 {
21015 - void *t = tinfo;
21016 if (end) {
21017 if (p < end && p >= (end-THREAD_SIZE))
21018 return 1;
21019 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
21020 }
21021
21022 unsigned long
21023 -print_context_stack(struct thread_info *tinfo,
21024 +print_context_stack(struct task_struct *task, void *stack_start,
21025 unsigned long *stack, unsigned long bp,
21026 const struct stacktrace_ops *ops, void *data,
21027 unsigned long *end, int *graph)
21028 {
21029 struct stack_frame *frame = (struct stack_frame *)bp;
21030
21031 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
21032 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
21033 unsigned long addr;
21034
21035 addr = *stack;
21036 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
21037 } else {
21038 ops->address(data, addr, 0);
21039 }
21040 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
21041 + print_ftrace_graph_addr(addr, data, ops, task, graph);
21042 }
21043 stack++;
21044 }
21045 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
21046 EXPORT_SYMBOL_GPL(print_context_stack);
21047
21048 unsigned long
21049 -print_context_stack_bp(struct thread_info *tinfo,
21050 +print_context_stack_bp(struct task_struct *task, void *stack_start,
21051 unsigned long *stack, unsigned long bp,
21052 const struct stacktrace_ops *ops, void *data,
21053 unsigned long *end, int *graph)
21054 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
21055 struct stack_frame *frame = (struct stack_frame *)bp;
21056 unsigned long *ret_addr = &frame->return_address;
21057
21058 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
21059 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
21060 unsigned long addr = *ret_addr;
21061
21062 if (!__kernel_text_address(addr))
21063 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
21064 ops->address(data, addr, 1);
21065 frame = frame->next_frame;
21066 ret_addr = &frame->return_address;
21067 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
21068 + print_ftrace_graph_addr(addr, data, ops, task, graph);
21069 }
21070
21071 return (unsigned long)frame;
21072 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
21073 static void print_trace_address(void *data, unsigned long addr, int reliable)
21074 {
21075 touch_nmi_watchdog();
21076 - printk(data);
21077 + printk("%s", (char *)data);
21078 printk_address(addr, reliable);
21079 }
21080
21081 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
21082 }
21083 EXPORT_SYMBOL_GPL(oops_begin);
21084
21085 +extern void gr_handle_kernel_exploit(void);
21086 +
21087 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
21088 {
21089 if (regs && kexec_should_crash(current))
21090 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
21091 panic("Fatal exception in interrupt");
21092 if (panic_on_oops)
21093 panic("Fatal exception");
21094 - do_exit(signr);
21095 +
21096 + gr_handle_kernel_exploit();
21097 +
21098 + do_group_exit(signr);
21099 }
21100
21101 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
21102 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
21103 print_modules();
21104 show_regs(regs);
21105 #ifdef CONFIG_X86_32
21106 - if (user_mode_vm(regs)) {
21107 + if (user_mode(regs)) {
21108 sp = regs->sp;
21109 ss = regs->ss & 0xffff;
21110 } else {
21111 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
21112 unsigned long flags = oops_begin();
21113 int sig = SIGSEGV;
21114
21115 - if (!user_mode_vm(regs))
21116 + if (!user_mode(regs))
21117 report_bug(regs->ip, regs);
21118
21119 if (__die(str, regs, err))
21120 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
21121 index f2a1770..540657f 100644
21122 --- a/arch/x86/kernel/dumpstack_32.c
21123 +++ b/arch/x86/kernel/dumpstack_32.c
21124 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21125 bp = stack_frame(task, regs);
21126
21127 for (;;) {
21128 - struct thread_info *context;
21129 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21130
21131 - context = (struct thread_info *)
21132 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
21133 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
21134 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21135
21136 - stack = (unsigned long *)context->previous_esp;
21137 - if (!stack)
21138 + if (stack_start == task_stack_page(task))
21139 break;
21140 + stack = *(unsigned long **)stack_start;
21141 if (ops->stack(data, "IRQ") < 0)
21142 break;
21143 touch_nmi_watchdog();
21144 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
21145 int i;
21146
21147 show_regs_print_info(KERN_EMERG);
21148 - __show_regs(regs, !user_mode_vm(regs));
21149 + __show_regs(regs, !user_mode(regs));
21150
21151 /*
21152 * When in-kernel, we also print out the stack and code at the
21153 * time of the fault..
21154 */
21155 - if (!user_mode_vm(regs)) {
21156 + if (!user_mode(regs)) {
21157 unsigned int code_prologue = code_bytes * 43 / 64;
21158 unsigned int code_len = code_bytes;
21159 unsigned char c;
21160 u8 *ip;
21161 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
21162
21163 pr_emerg("Stack:\n");
21164 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
21165
21166 pr_emerg("Code:");
21167
21168 - ip = (u8 *)regs->ip - code_prologue;
21169 + ip = (u8 *)regs->ip - code_prologue + cs_base;
21170 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
21171 /* try starting at IP */
21172 - ip = (u8 *)regs->ip;
21173 + ip = (u8 *)regs->ip + cs_base;
21174 code_len = code_len - code_prologue + 1;
21175 }
21176 for (i = 0; i < code_len; i++, ip++) {
21177 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
21178 pr_cont(" Bad EIP value.");
21179 break;
21180 }
21181 - if (ip == (u8 *)regs->ip)
21182 + if (ip == (u8 *)regs->ip + cs_base)
21183 pr_cont(" <%02x>", c);
21184 else
21185 pr_cont(" %02x", c);
21186 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
21187 {
21188 unsigned short ud2;
21189
21190 + ip = ktla_ktva(ip);
21191 if (ip < PAGE_OFFSET)
21192 return 0;
21193 if (probe_kernel_address((unsigned short *)ip, ud2))
21194 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
21195
21196 return ud2 == 0x0b0f;
21197 }
21198 +
21199 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21200 +void pax_check_alloca(unsigned long size)
21201 +{
21202 + unsigned long sp = (unsigned long)&sp, stack_left;
21203 +
21204 + /* all kernel stacks are of the same size */
21205 + stack_left = sp & (THREAD_SIZE - 1);
21206 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21207 +}
21208 +EXPORT_SYMBOL(pax_check_alloca);
21209 +#endif
21210 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
21211 index addb207..99635fa 100644
21212 --- a/arch/x86/kernel/dumpstack_64.c
21213 +++ b/arch/x86/kernel/dumpstack_64.c
21214 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21215 unsigned long *irq_stack_end =
21216 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
21217 unsigned used = 0;
21218 - struct thread_info *tinfo;
21219 int graph = 0;
21220 unsigned long dummy;
21221 + void *stack_start;
21222
21223 if (!task)
21224 task = current;
21225 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21226 * current stack address. If the stacks consist of nested
21227 * exceptions
21228 */
21229 - tinfo = task_thread_info(task);
21230 for (;;) {
21231 char *id;
21232 unsigned long *estack_end;
21233 +
21234 estack_end = in_exception_stack(cpu, (unsigned long)stack,
21235 &used, &id);
21236
21237 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21238 if (ops->stack(data, id) < 0)
21239 break;
21240
21241 - bp = ops->walk_stack(tinfo, stack, bp, ops,
21242 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
21243 data, estack_end, &graph);
21244 ops->stack(data, "<EOE>");
21245 /*
21246 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21247 * second-to-last pointer (index -2 to end) in the
21248 * exception stack:
21249 */
21250 + if ((u16)estack_end[-1] != __KERNEL_DS)
21251 + goto out;
21252 stack = (unsigned long *) estack_end[-2];
21253 continue;
21254 }
21255 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21256 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
21257 if (ops->stack(data, "IRQ") < 0)
21258 break;
21259 - bp = ops->walk_stack(tinfo, stack, bp,
21260 + bp = ops->walk_stack(task, irq_stack, stack, bp,
21261 ops, data, irq_stack_end, &graph);
21262 /*
21263 * We link to the next stack (which would be
21264 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21265 /*
21266 * This handles the process stack:
21267 */
21268 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
21269 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21270 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21271 +out:
21272 put_cpu();
21273 }
21274 EXPORT_SYMBOL(dump_trace);
21275 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
21276
21277 return ud2 == 0x0b0f;
21278 }
21279 +
21280 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21281 +void pax_check_alloca(unsigned long size)
21282 +{
21283 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
21284 + unsigned cpu, used;
21285 + char *id;
21286 +
21287 + /* check the process stack first */
21288 + stack_start = (unsigned long)task_stack_page(current);
21289 + stack_end = stack_start + THREAD_SIZE;
21290 + if (likely(stack_start <= sp && sp < stack_end)) {
21291 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
21292 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21293 + return;
21294 + }
21295 +
21296 + cpu = get_cpu();
21297 +
21298 + /* check the irq stacks */
21299 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
21300 + stack_start = stack_end - IRQ_STACK_SIZE;
21301 + if (stack_start <= sp && sp < stack_end) {
21302 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
21303 + put_cpu();
21304 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21305 + return;
21306 + }
21307 +
21308 + /* check the exception stacks */
21309 + used = 0;
21310 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
21311 + stack_start = stack_end - EXCEPTION_STKSZ;
21312 + if (stack_end && stack_start <= sp && sp < stack_end) {
21313 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
21314 + put_cpu();
21315 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21316 + return;
21317 + }
21318 +
21319 + put_cpu();
21320 +
21321 + /* unknown stack */
21322 + BUG();
21323 +}
21324 +EXPORT_SYMBOL(pax_check_alloca);
21325 +#endif
21326 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
21327 index 174da5f..5e55606 100644
21328 --- a/arch/x86/kernel/e820.c
21329 +++ b/arch/x86/kernel/e820.c
21330 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
21331
21332 static void early_panic(char *msg)
21333 {
21334 - early_printk(msg);
21335 - panic(msg);
21336 + early_printk("%s", msg);
21337 + panic("%s", msg);
21338 }
21339
21340 static int userdef __initdata;
21341 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
21342 index d15f575..d692043 100644
21343 --- a/arch/x86/kernel/early_printk.c
21344 +++ b/arch/x86/kernel/early_printk.c
21345 @@ -7,6 +7,7 @@
21346 #include <linux/pci_regs.h>
21347 #include <linux/pci_ids.h>
21348 #include <linux/errno.h>
21349 +#include <linux/sched.h>
21350 #include <asm/io.h>
21351 #include <asm/processor.h>
21352 #include <asm/fcntl.h>
21353 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
21354 index f0dcb0c..9f39b80 100644
21355 --- a/arch/x86/kernel/entry_32.S
21356 +++ b/arch/x86/kernel/entry_32.S
21357 @@ -177,13 +177,153 @@
21358 /*CFI_REL_OFFSET gs, PT_GS*/
21359 .endm
21360 .macro SET_KERNEL_GS reg
21361 +
21362 +#ifdef CONFIG_CC_STACKPROTECTOR
21363 movl $(__KERNEL_STACK_CANARY), \reg
21364 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
21365 + movl $(__USER_DS), \reg
21366 +#else
21367 + xorl \reg, \reg
21368 +#endif
21369 +
21370 movl \reg, %gs
21371 .endm
21372
21373 #endif /* CONFIG_X86_32_LAZY_GS */
21374
21375 -.macro SAVE_ALL
21376 +.macro pax_enter_kernel
21377 +#ifdef CONFIG_PAX_KERNEXEC
21378 + call pax_enter_kernel
21379 +#endif
21380 +.endm
21381 +
21382 +.macro pax_exit_kernel
21383 +#ifdef CONFIG_PAX_KERNEXEC
21384 + call pax_exit_kernel
21385 +#endif
21386 +.endm
21387 +
21388 +#ifdef CONFIG_PAX_KERNEXEC
21389 +ENTRY(pax_enter_kernel)
21390 +#ifdef CONFIG_PARAVIRT
21391 + pushl %eax
21392 + pushl %ecx
21393 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
21394 + mov %eax, %esi
21395 +#else
21396 + mov %cr0, %esi
21397 +#endif
21398 + bts $16, %esi
21399 + jnc 1f
21400 + mov %cs, %esi
21401 + cmp $__KERNEL_CS, %esi
21402 + jz 3f
21403 + ljmp $__KERNEL_CS, $3f
21404 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
21405 +2:
21406 +#ifdef CONFIG_PARAVIRT
21407 + mov %esi, %eax
21408 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
21409 +#else
21410 + mov %esi, %cr0
21411 +#endif
21412 +3:
21413 +#ifdef CONFIG_PARAVIRT
21414 + popl %ecx
21415 + popl %eax
21416 +#endif
21417 + ret
21418 +ENDPROC(pax_enter_kernel)
21419 +
21420 +ENTRY(pax_exit_kernel)
21421 +#ifdef CONFIG_PARAVIRT
21422 + pushl %eax
21423 + pushl %ecx
21424 +#endif
21425 + mov %cs, %esi
21426 + cmp $__KERNEXEC_KERNEL_CS, %esi
21427 + jnz 2f
21428 +#ifdef CONFIG_PARAVIRT
21429 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
21430 + mov %eax, %esi
21431 +#else
21432 + mov %cr0, %esi
21433 +#endif
21434 + btr $16, %esi
21435 + ljmp $__KERNEL_CS, $1f
21436 +1:
21437 +#ifdef CONFIG_PARAVIRT
21438 + mov %esi, %eax
21439 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
21440 +#else
21441 + mov %esi, %cr0
21442 +#endif
21443 +2:
21444 +#ifdef CONFIG_PARAVIRT
21445 + popl %ecx
21446 + popl %eax
21447 +#endif
21448 + ret
21449 +ENDPROC(pax_exit_kernel)
21450 +#endif
21451 +
21452 + .macro pax_erase_kstack
21453 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21454 + call pax_erase_kstack
21455 +#endif
21456 + .endm
21457 +
21458 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21459 +/*
21460 + * ebp: thread_info
21461 + */
21462 +ENTRY(pax_erase_kstack)
21463 + pushl %edi
21464 + pushl %ecx
21465 + pushl %eax
21466 +
21467 + mov TI_lowest_stack(%ebp), %edi
21468 + mov $-0xBEEF, %eax
21469 + std
21470 +
21471 +1: mov %edi, %ecx
21472 + and $THREAD_SIZE_asm - 1, %ecx
21473 + shr $2, %ecx
21474 + repne scasl
21475 + jecxz 2f
21476 +
21477 + cmp $2*16, %ecx
21478 + jc 2f
21479 +
21480 + mov $2*16, %ecx
21481 + repe scasl
21482 + jecxz 2f
21483 + jne 1b
21484 +
21485 +2: cld
21486 + mov %esp, %ecx
21487 + sub %edi, %ecx
21488 +
21489 + cmp $THREAD_SIZE_asm, %ecx
21490 + jb 3f
21491 + ud2
21492 +3:
21493 +
21494 + shr $2, %ecx
21495 + rep stosl
21496 +
21497 + mov TI_task_thread_sp0(%ebp), %edi
21498 + sub $128, %edi
21499 + mov %edi, TI_lowest_stack(%ebp)
21500 +
21501 + popl %eax
21502 + popl %ecx
21503 + popl %edi
21504 + ret
21505 +ENDPROC(pax_erase_kstack)
21506 +#endif
21507 +
21508 +.macro __SAVE_ALL _DS
21509 cld
21510 PUSH_GS
21511 pushl_cfi %fs
21512 @@ -206,7 +346,7 @@
21513 CFI_REL_OFFSET ecx, 0
21514 pushl_cfi %ebx
21515 CFI_REL_OFFSET ebx, 0
21516 - movl $(__USER_DS), %edx
21517 + movl $\_DS, %edx
21518 movl %edx, %ds
21519 movl %edx, %es
21520 movl $(__KERNEL_PERCPU), %edx
21521 @@ -214,6 +354,15 @@
21522 SET_KERNEL_GS %edx
21523 .endm
21524
21525 +.macro SAVE_ALL
21526 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21527 + __SAVE_ALL __KERNEL_DS
21528 + pax_enter_kernel
21529 +#else
21530 + __SAVE_ALL __USER_DS
21531 +#endif
21532 +.endm
21533 +
21534 .macro RESTORE_INT_REGS
21535 popl_cfi %ebx
21536 CFI_RESTORE ebx
21537 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
21538 popfl_cfi
21539 jmp syscall_exit
21540 CFI_ENDPROC
21541 -END(ret_from_fork)
21542 +ENDPROC(ret_from_fork)
21543
21544 ENTRY(ret_from_kernel_thread)
21545 CFI_STARTPROC
21546 @@ -344,7 +493,15 @@ ret_from_intr:
21547 andl $SEGMENT_RPL_MASK, %eax
21548 #endif
21549 cmpl $USER_RPL, %eax
21550 +
21551 +#ifdef CONFIG_PAX_KERNEXEC
21552 + jae resume_userspace
21553 +
21554 + pax_exit_kernel
21555 + jmp resume_kernel
21556 +#else
21557 jb resume_kernel # not returning to v8086 or userspace
21558 +#endif
21559
21560 ENTRY(resume_userspace)
21561 LOCKDEP_SYS_EXIT
21562 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
21563 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
21564 # int/exception return?
21565 jne work_pending
21566 - jmp restore_all
21567 -END(ret_from_exception)
21568 + jmp restore_all_pax
21569 +ENDPROC(ret_from_exception)
21570
21571 #ifdef CONFIG_PREEMPT
21572 ENTRY(resume_kernel)
21573 @@ -372,7 +529,7 @@ need_resched:
21574 jz restore_all
21575 call preempt_schedule_irq
21576 jmp need_resched
21577 -END(resume_kernel)
21578 +ENDPROC(resume_kernel)
21579 #endif
21580 CFI_ENDPROC
21581 /*
21582 @@ -406,30 +563,45 @@ sysenter_past_esp:
21583 /*CFI_REL_OFFSET cs, 0*/
21584 /*
21585 * Push current_thread_info()->sysenter_return to the stack.
21586 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
21587 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
21588 */
21589 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
21590 + pushl_cfi $0
21591 CFI_REL_OFFSET eip, 0
21592
21593 pushl_cfi %eax
21594 SAVE_ALL
21595 + GET_THREAD_INFO(%ebp)
21596 + movl TI_sysenter_return(%ebp),%ebp
21597 + movl %ebp,PT_EIP(%esp)
21598 ENABLE_INTERRUPTS(CLBR_NONE)
21599
21600 /*
21601 * Load the potential sixth argument from user stack.
21602 * Careful about security.
21603 */
21604 + movl PT_OLDESP(%esp),%ebp
21605 +
21606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21607 + mov PT_OLDSS(%esp),%ds
21608 +1: movl %ds:(%ebp),%ebp
21609 + push %ss
21610 + pop %ds
21611 +#else
21612 cmpl $__PAGE_OFFSET-3,%ebp
21613 jae syscall_fault
21614 ASM_STAC
21615 1: movl (%ebp),%ebp
21616 ASM_CLAC
21617 +#endif
21618 +
21619 movl %ebp,PT_EBP(%esp)
21620 _ASM_EXTABLE(1b,syscall_fault)
21621
21622 GET_THREAD_INFO(%ebp)
21623
21624 +#ifdef CONFIG_PAX_RANDKSTACK
21625 + pax_erase_kstack
21626 +#endif
21627 +
21628 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21629 jnz sysenter_audit
21630 sysenter_do_call:
21631 @@ -444,12 +616,24 @@ sysenter_do_call:
21632 testl $_TIF_ALLWORK_MASK, %ecx
21633 jne sysexit_audit
21634 sysenter_exit:
21635 +
21636 +#ifdef CONFIG_PAX_RANDKSTACK
21637 + pushl_cfi %eax
21638 + movl %esp, %eax
21639 + call pax_randomize_kstack
21640 + popl_cfi %eax
21641 +#endif
21642 +
21643 + pax_erase_kstack
21644 +
21645 /* if something modifies registers it must also disable sysexit */
21646 movl PT_EIP(%esp), %edx
21647 movl PT_OLDESP(%esp), %ecx
21648 xorl %ebp,%ebp
21649 TRACE_IRQS_ON
21650 1: mov PT_FS(%esp), %fs
21651 +2: mov PT_DS(%esp), %ds
21652 +3: mov PT_ES(%esp), %es
21653 PTGS_TO_GS
21654 ENABLE_INTERRUPTS_SYSEXIT
21655
21656 @@ -466,6 +650,9 @@ sysenter_audit:
21657 movl %eax,%edx /* 2nd arg: syscall number */
21658 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
21659 call __audit_syscall_entry
21660 +
21661 + pax_erase_kstack
21662 +
21663 pushl_cfi %ebx
21664 movl PT_EAX(%esp),%eax /* reload syscall number */
21665 jmp sysenter_do_call
21666 @@ -491,10 +678,16 @@ sysexit_audit:
21667
21668 CFI_ENDPROC
21669 .pushsection .fixup,"ax"
21670 -2: movl $0,PT_FS(%esp)
21671 +4: movl $0,PT_FS(%esp)
21672 + jmp 1b
21673 +5: movl $0,PT_DS(%esp)
21674 + jmp 1b
21675 +6: movl $0,PT_ES(%esp)
21676 jmp 1b
21677 .popsection
21678 - _ASM_EXTABLE(1b,2b)
21679 + _ASM_EXTABLE(1b,4b)
21680 + _ASM_EXTABLE(2b,5b)
21681 + _ASM_EXTABLE(3b,6b)
21682 PTGS_TO_GS_EX
21683 ENDPROC(ia32_sysenter_target)
21684
21685 @@ -509,6 +702,11 @@ ENTRY(system_call)
21686 pushl_cfi %eax # save orig_eax
21687 SAVE_ALL
21688 GET_THREAD_INFO(%ebp)
21689 +
21690 +#ifdef CONFIG_PAX_RANDKSTACK
21691 + pax_erase_kstack
21692 +#endif
21693 +
21694 # system call tracing in operation / emulation
21695 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21696 jnz syscall_trace_entry
21697 @@ -527,6 +725,15 @@ syscall_exit:
21698 testl $_TIF_ALLWORK_MASK, %ecx # current->work
21699 jne syscall_exit_work
21700
21701 +restore_all_pax:
21702 +
21703 +#ifdef CONFIG_PAX_RANDKSTACK
21704 + movl %esp, %eax
21705 + call pax_randomize_kstack
21706 +#endif
21707 +
21708 + pax_erase_kstack
21709 +
21710 restore_all:
21711 TRACE_IRQS_IRET
21712 restore_all_notrace:
21713 @@ -583,14 +790,34 @@ ldt_ss:
21714 * compensating for the offset by changing to the ESPFIX segment with
21715 * a base address that matches for the difference.
21716 */
21717 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
21718 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
21719 mov %esp, %edx /* load kernel esp */
21720 mov PT_OLDESP(%esp), %eax /* load userspace esp */
21721 mov %dx, %ax /* eax: new kernel esp */
21722 sub %eax, %edx /* offset (low word is 0) */
21723 +#ifdef CONFIG_SMP
21724 + movl PER_CPU_VAR(cpu_number), %ebx
21725 + shll $PAGE_SHIFT_asm, %ebx
21726 + addl $cpu_gdt_table, %ebx
21727 +#else
21728 + movl $cpu_gdt_table, %ebx
21729 +#endif
21730 shr $16, %edx
21731 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
21732 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
21733 +
21734 +#ifdef CONFIG_PAX_KERNEXEC
21735 + mov %cr0, %esi
21736 + btr $16, %esi
21737 + mov %esi, %cr0
21738 +#endif
21739 +
21740 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
21741 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
21742 +
21743 +#ifdef CONFIG_PAX_KERNEXEC
21744 + bts $16, %esi
21745 + mov %esi, %cr0
21746 +#endif
21747 +
21748 pushl_cfi $__ESPFIX_SS
21749 pushl_cfi %eax /* new kernel esp */
21750 /* Disable interrupts, but do not irqtrace this section: we
21751 @@ -619,20 +846,18 @@ work_resched:
21752 movl TI_flags(%ebp), %ecx
21753 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
21754 # than syscall tracing?
21755 - jz restore_all
21756 + jz restore_all_pax
21757 testb $_TIF_NEED_RESCHED, %cl
21758 jnz work_resched
21759
21760 work_notifysig: # deal with pending signals and
21761 # notify-resume requests
21762 + movl %esp, %eax
21763 #ifdef CONFIG_VM86
21764 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
21765 - movl %esp, %eax
21766 jne work_notifysig_v86 # returning to kernel-space or
21767 # vm86-space
21768 1:
21769 -#else
21770 - movl %esp, %eax
21771 #endif
21772 TRACE_IRQS_ON
21773 ENABLE_INTERRUPTS(CLBR_NONE)
21774 @@ -653,7 +878,7 @@ work_notifysig_v86:
21775 movl %eax, %esp
21776 jmp 1b
21777 #endif
21778 -END(work_pending)
21779 +ENDPROC(work_pending)
21780
21781 # perform syscall exit tracing
21782 ALIGN
21783 @@ -661,11 +886,14 @@ syscall_trace_entry:
21784 movl $-ENOSYS,PT_EAX(%esp)
21785 movl %esp, %eax
21786 call syscall_trace_enter
21787 +
21788 + pax_erase_kstack
21789 +
21790 /* What it returned is what we'll actually use. */
21791 cmpl $(NR_syscalls), %eax
21792 jnae syscall_call
21793 jmp syscall_exit
21794 -END(syscall_trace_entry)
21795 +ENDPROC(syscall_trace_entry)
21796
21797 # perform syscall exit tracing
21798 ALIGN
21799 @@ -678,21 +906,25 @@ syscall_exit_work:
21800 movl %esp, %eax
21801 call syscall_trace_leave
21802 jmp resume_userspace
21803 -END(syscall_exit_work)
21804 +ENDPROC(syscall_exit_work)
21805 CFI_ENDPROC
21806
21807 RING0_INT_FRAME # can't unwind into user space anyway
21808 syscall_fault:
21809 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21810 + push %ss
21811 + pop %ds
21812 +#endif
21813 ASM_CLAC
21814 GET_THREAD_INFO(%ebp)
21815 movl $-EFAULT,PT_EAX(%esp)
21816 jmp resume_userspace
21817 -END(syscall_fault)
21818 +ENDPROC(syscall_fault)
21819
21820 syscall_badsys:
21821 movl $-ENOSYS,PT_EAX(%esp)
21822 jmp resume_userspace
21823 -END(syscall_badsys)
21824 +ENDPROC(syscall_badsys)
21825 CFI_ENDPROC
21826 /*
21827 * End of kprobes section
21828 @@ -708,8 +940,15 @@ END(syscall_badsys)
21829 * normal stack and adjusts ESP with the matching offset.
21830 */
21831 /* fixup the stack */
21832 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21833 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21834 +#ifdef CONFIG_SMP
21835 + movl PER_CPU_VAR(cpu_number), %ebx
21836 + shll $PAGE_SHIFT_asm, %ebx
21837 + addl $cpu_gdt_table, %ebx
21838 +#else
21839 + movl $cpu_gdt_table, %ebx
21840 +#endif
21841 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21842 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21843 shl $16, %eax
21844 addl %esp, %eax /* the adjusted stack pointer */
21845 pushl_cfi $__KERNEL_DS
21846 @@ -762,7 +1001,7 @@ vector=vector+1
21847 .endr
21848 2: jmp common_interrupt
21849 .endr
21850 -END(irq_entries_start)
21851 +ENDPROC(irq_entries_start)
21852
21853 .previous
21854 END(interrupt)
21855 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21856 pushl_cfi $do_coprocessor_error
21857 jmp error_code
21858 CFI_ENDPROC
21859 -END(coprocessor_error)
21860 +ENDPROC(coprocessor_error)
21861
21862 ENTRY(simd_coprocessor_error)
21863 RING0_INT_FRAME
21864 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21865 .section .altinstructions,"a"
21866 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21867 .previous
21868 -.section .altinstr_replacement,"ax"
21869 +.section .altinstr_replacement,"a"
21870 663: pushl $do_simd_coprocessor_error
21871 664:
21872 .previous
21873 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21874 #endif
21875 jmp error_code
21876 CFI_ENDPROC
21877 -END(simd_coprocessor_error)
21878 +ENDPROC(simd_coprocessor_error)
21879
21880 ENTRY(device_not_available)
21881 RING0_INT_FRAME
21882 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21883 pushl_cfi $do_device_not_available
21884 jmp error_code
21885 CFI_ENDPROC
21886 -END(device_not_available)
21887 +ENDPROC(device_not_available)
21888
21889 #ifdef CONFIG_PARAVIRT
21890 ENTRY(native_iret)
21891 iret
21892 _ASM_EXTABLE(native_iret, iret_exc)
21893 -END(native_iret)
21894 +ENDPROC(native_iret)
21895
21896 ENTRY(native_irq_enable_sysexit)
21897 sti
21898 sysexit
21899 -END(native_irq_enable_sysexit)
21900 +ENDPROC(native_irq_enable_sysexit)
21901 #endif
21902
21903 ENTRY(overflow)
21904 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21905 pushl_cfi $do_overflow
21906 jmp error_code
21907 CFI_ENDPROC
21908 -END(overflow)
21909 +ENDPROC(overflow)
21910
21911 ENTRY(bounds)
21912 RING0_INT_FRAME
21913 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21914 pushl_cfi $do_bounds
21915 jmp error_code
21916 CFI_ENDPROC
21917 -END(bounds)
21918 +ENDPROC(bounds)
21919
21920 ENTRY(invalid_op)
21921 RING0_INT_FRAME
21922 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21923 pushl_cfi $do_invalid_op
21924 jmp error_code
21925 CFI_ENDPROC
21926 -END(invalid_op)
21927 +ENDPROC(invalid_op)
21928
21929 ENTRY(coprocessor_segment_overrun)
21930 RING0_INT_FRAME
21931 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21932 pushl_cfi $do_coprocessor_segment_overrun
21933 jmp error_code
21934 CFI_ENDPROC
21935 -END(coprocessor_segment_overrun)
21936 +ENDPROC(coprocessor_segment_overrun)
21937
21938 ENTRY(invalid_TSS)
21939 RING0_EC_FRAME
21940 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21941 pushl_cfi $do_invalid_TSS
21942 jmp error_code
21943 CFI_ENDPROC
21944 -END(invalid_TSS)
21945 +ENDPROC(invalid_TSS)
21946
21947 ENTRY(segment_not_present)
21948 RING0_EC_FRAME
21949 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21950 pushl_cfi $do_segment_not_present
21951 jmp error_code
21952 CFI_ENDPROC
21953 -END(segment_not_present)
21954 +ENDPROC(segment_not_present)
21955
21956 ENTRY(stack_segment)
21957 RING0_EC_FRAME
21958 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21959 pushl_cfi $do_stack_segment
21960 jmp error_code
21961 CFI_ENDPROC
21962 -END(stack_segment)
21963 +ENDPROC(stack_segment)
21964
21965 ENTRY(alignment_check)
21966 RING0_EC_FRAME
21967 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21968 pushl_cfi $do_alignment_check
21969 jmp error_code
21970 CFI_ENDPROC
21971 -END(alignment_check)
21972 +ENDPROC(alignment_check)
21973
21974 ENTRY(divide_error)
21975 RING0_INT_FRAME
21976 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21977 pushl_cfi $do_divide_error
21978 jmp error_code
21979 CFI_ENDPROC
21980 -END(divide_error)
21981 +ENDPROC(divide_error)
21982
21983 #ifdef CONFIG_X86_MCE
21984 ENTRY(machine_check)
21985 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21986 pushl_cfi machine_check_vector
21987 jmp error_code
21988 CFI_ENDPROC
21989 -END(machine_check)
21990 +ENDPROC(machine_check)
21991 #endif
21992
21993 ENTRY(spurious_interrupt_bug)
21994 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21995 pushl_cfi $do_spurious_interrupt_bug
21996 jmp error_code
21997 CFI_ENDPROC
21998 -END(spurious_interrupt_bug)
21999 +ENDPROC(spurious_interrupt_bug)
22000 /*
22001 * End of kprobes section
22002 */
22003 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
22004
22005 ENTRY(mcount)
22006 ret
22007 -END(mcount)
22008 +ENDPROC(mcount)
22009
22010 ENTRY(ftrace_caller)
22011 cmpl $0, function_trace_stop
22012 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
22013 .globl ftrace_stub
22014 ftrace_stub:
22015 ret
22016 -END(ftrace_caller)
22017 +ENDPROC(ftrace_caller)
22018
22019 ENTRY(ftrace_regs_caller)
22020 pushf /* push flags before compare (in cs location) */
22021 @@ -1210,7 +1449,7 @@ trace:
22022 popl %ecx
22023 popl %eax
22024 jmp ftrace_stub
22025 -END(mcount)
22026 +ENDPROC(mcount)
22027 #endif /* CONFIG_DYNAMIC_FTRACE */
22028 #endif /* CONFIG_FUNCTION_TRACER */
22029
22030 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
22031 popl %ecx
22032 popl %eax
22033 ret
22034 -END(ftrace_graph_caller)
22035 +ENDPROC(ftrace_graph_caller)
22036
22037 .globl return_to_handler
22038 return_to_handler:
22039 @@ -1284,15 +1523,18 @@ error_code:
22040 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
22041 REG_TO_PTGS %ecx
22042 SET_KERNEL_GS %ecx
22043 - movl $(__USER_DS), %ecx
22044 + movl $(__KERNEL_DS), %ecx
22045 movl %ecx, %ds
22046 movl %ecx, %es
22047 +
22048 + pax_enter_kernel
22049 +
22050 TRACE_IRQS_OFF
22051 movl %esp,%eax # pt_regs pointer
22052 call *%edi
22053 jmp ret_from_exception
22054 CFI_ENDPROC
22055 -END(page_fault)
22056 +ENDPROC(page_fault)
22057
22058 /*
22059 * Debug traps and NMI can happen at the one SYSENTER instruction
22060 @@ -1335,7 +1577,7 @@ debug_stack_correct:
22061 call do_debug
22062 jmp ret_from_exception
22063 CFI_ENDPROC
22064 -END(debug)
22065 +ENDPROC(debug)
22066
22067 /*
22068 * NMI is doubly nasty. It can happen _while_ we're handling
22069 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
22070 xorl %edx,%edx # zero error code
22071 movl %esp,%eax # pt_regs pointer
22072 call do_nmi
22073 +
22074 + pax_exit_kernel
22075 +
22076 jmp restore_all_notrace
22077 CFI_ENDPROC
22078
22079 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
22080 FIXUP_ESPFIX_STACK # %eax == %esp
22081 xorl %edx,%edx # zero error code
22082 call do_nmi
22083 +
22084 + pax_exit_kernel
22085 +
22086 RESTORE_REGS
22087 lss 12+4(%esp), %esp # back to espfix stack
22088 CFI_ADJUST_CFA_OFFSET -24
22089 jmp irq_return
22090 CFI_ENDPROC
22091 -END(nmi)
22092 +ENDPROC(nmi)
22093
22094 ENTRY(int3)
22095 RING0_INT_FRAME
22096 @@ -1427,14 +1675,14 @@ ENTRY(int3)
22097 call do_int3
22098 jmp ret_from_exception
22099 CFI_ENDPROC
22100 -END(int3)
22101 +ENDPROC(int3)
22102
22103 ENTRY(general_protection)
22104 RING0_EC_FRAME
22105 pushl_cfi $do_general_protection
22106 jmp error_code
22107 CFI_ENDPROC
22108 -END(general_protection)
22109 +ENDPROC(general_protection)
22110
22111 #ifdef CONFIG_KVM_GUEST
22112 ENTRY(async_page_fault)
22113 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
22114 pushl_cfi $do_async_page_fault
22115 jmp error_code
22116 CFI_ENDPROC
22117 -END(async_page_fault)
22118 +ENDPROC(async_page_fault)
22119 #endif
22120
22121 /*
22122 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
22123 index b077f4c..8e0df9f 100644
22124 --- a/arch/x86/kernel/entry_64.S
22125 +++ b/arch/x86/kernel/entry_64.S
22126 @@ -59,6 +59,8 @@
22127 #include <asm/context_tracking.h>
22128 #include <asm/smap.h>
22129 #include <linux/err.h>
22130 +#include <asm/pgtable.h>
22131 +#include <asm/alternative-asm.h>
22132
22133 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
22134 #include <linux/elf-em.h>
22135 @@ -80,8 +82,9 @@
22136 #ifdef CONFIG_DYNAMIC_FTRACE
22137
22138 ENTRY(function_hook)
22139 + pax_force_retaddr
22140 retq
22141 -END(function_hook)
22142 +ENDPROC(function_hook)
22143
22144 /* skip is set if stack has been adjusted */
22145 .macro ftrace_caller_setup skip=0
22146 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
22147 #endif
22148
22149 GLOBAL(ftrace_stub)
22150 + pax_force_retaddr
22151 retq
22152 -END(ftrace_caller)
22153 +ENDPROC(ftrace_caller)
22154
22155 ENTRY(ftrace_regs_caller)
22156 /* Save the current flags before compare (in SS location)*/
22157 @@ -191,7 +195,7 @@ ftrace_restore_flags:
22158 popfq
22159 jmp ftrace_stub
22160
22161 -END(ftrace_regs_caller)
22162 +ENDPROC(ftrace_regs_caller)
22163
22164
22165 #else /* ! CONFIG_DYNAMIC_FTRACE */
22166 @@ -212,6 +216,7 @@ ENTRY(function_hook)
22167 #endif
22168
22169 GLOBAL(ftrace_stub)
22170 + pax_force_retaddr
22171 retq
22172
22173 trace:
22174 @@ -225,12 +230,13 @@ trace:
22175 #endif
22176 subq $MCOUNT_INSN_SIZE, %rdi
22177
22178 + pax_force_fptr ftrace_trace_function
22179 call *ftrace_trace_function
22180
22181 MCOUNT_RESTORE_FRAME
22182
22183 jmp ftrace_stub
22184 -END(function_hook)
22185 +ENDPROC(function_hook)
22186 #endif /* CONFIG_DYNAMIC_FTRACE */
22187 #endif /* CONFIG_FUNCTION_TRACER */
22188
22189 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
22190
22191 MCOUNT_RESTORE_FRAME
22192
22193 + pax_force_retaddr
22194 retq
22195 -END(ftrace_graph_caller)
22196 +ENDPROC(ftrace_graph_caller)
22197
22198 GLOBAL(return_to_handler)
22199 subq $24, %rsp
22200 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
22201 movq 8(%rsp), %rdx
22202 movq (%rsp), %rax
22203 addq $24, %rsp
22204 + pax_force_fptr %rdi
22205 jmp *%rdi
22206 +ENDPROC(return_to_handler)
22207 #endif
22208
22209
22210 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
22211 ENDPROC(native_usergs_sysret64)
22212 #endif /* CONFIG_PARAVIRT */
22213
22214 + .macro ljmpq sel, off
22215 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
22216 + .byte 0x48; ljmp *1234f(%rip)
22217 + .pushsection .rodata
22218 + .align 16
22219 + 1234: .quad \off; .word \sel
22220 + .popsection
22221 +#else
22222 + pushq $\sel
22223 + pushq $\off
22224 + lretq
22225 +#endif
22226 + .endm
22227 +
22228 + .macro pax_enter_kernel
22229 + pax_set_fptr_mask
22230 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22231 + call pax_enter_kernel
22232 +#endif
22233 + .endm
22234 +
22235 + .macro pax_exit_kernel
22236 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22237 + call pax_exit_kernel
22238 +#endif
22239 +
22240 + .endm
22241 +
22242 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22243 +ENTRY(pax_enter_kernel)
22244 + pushq %rdi
22245 +
22246 +#ifdef CONFIG_PARAVIRT
22247 + PV_SAVE_REGS(CLBR_RDI)
22248 +#endif
22249 +
22250 +#ifdef CONFIG_PAX_KERNEXEC
22251 + GET_CR0_INTO_RDI
22252 + bts $16,%rdi
22253 + jnc 3f
22254 + mov %cs,%edi
22255 + cmp $__KERNEL_CS,%edi
22256 + jnz 2f
22257 +1:
22258 +#endif
22259 +
22260 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22261 + 661: jmp 111f
22262 + .pushsection .altinstr_replacement, "a"
22263 + 662: ASM_NOP2
22264 + .popsection
22265 + .pushsection .altinstructions, "a"
22266 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22267 + .popsection
22268 + GET_CR3_INTO_RDI
22269 + cmp $0,%dil
22270 + jnz 112f
22271 + mov $__KERNEL_DS,%edi
22272 + mov %edi,%ss
22273 + jmp 111f
22274 +112: cmp $1,%dil
22275 + jz 113f
22276 + ud2
22277 +113: sub $4097,%rdi
22278 + bts $63,%rdi
22279 + SET_RDI_INTO_CR3
22280 + mov $__UDEREF_KERNEL_DS,%edi
22281 + mov %edi,%ss
22282 +111:
22283 +#endif
22284 +
22285 +#ifdef CONFIG_PARAVIRT
22286 + PV_RESTORE_REGS(CLBR_RDI)
22287 +#endif
22288 +
22289 + popq %rdi
22290 + pax_force_retaddr
22291 + retq
22292 +
22293 +#ifdef CONFIG_PAX_KERNEXEC
22294 +2: ljmpq __KERNEL_CS,1b
22295 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
22296 +4: SET_RDI_INTO_CR0
22297 + jmp 1b
22298 +#endif
22299 +ENDPROC(pax_enter_kernel)
22300 +
22301 +ENTRY(pax_exit_kernel)
22302 + pushq %rdi
22303 +
22304 +#ifdef CONFIG_PARAVIRT
22305 + PV_SAVE_REGS(CLBR_RDI)
22306 +#endif
22307 +
22308 +#ifdef CONFIG_PAX_KERNEXEC
22309 + mov %cs,%rdi
22310 + cmp $__KERNEXEC_KERNEL_CS,%edi
22311 + jz 2f
22312 + GET_CR0_INTO_RDI
22313 + bts $16,%rdi
22314 + jnc 4f
22315 +1:
22316 +#endif
22317 +
22318 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22319 + 661: jmp 111f
22320 + .pushsection .altinstr_replacement, "a"
22321 + 662: ASM_NOP2
22322 + .popsection
22323 + .pushsection .altinstructions, "a"
22324 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22325 + .popsection
22326 + mov %ss,%edi
22327 + cmp $__UDEREF_KERNEL_DS,%edi
22328 + jnz 111f
22329 + GET_CR3_INTO_RDI
22330 + cmp $0,%dil
22331 + jz 112f
22332 + ud2
22333 +112: add $4097,%rdi
22334 + bts $63,%rdi
22335 + SET_RDI_INTO_CR3
22336 + mov $__KERNEL_DS,%edi
22337 + mov %edi,%ss
22338 +111:
22339 +#endif
22340 +
22341 +#ifdef CONFIG_PARAVIRT
22342 + PV_RESTORE_REGS(CLBR_RDI);
22343 +#endif
22344 +
22345 + popq %rdi
22346 + pax_force_retaddr
22347 + retq
22348 +
22349 +#ifdef CONFIG_PAX_KERNEXEC
22350 +2: GET_CR0_INTO_RDI
22351 + btr $16,%rdi
22352 + jnc 4f
22353 + ljmpq __KERNEL_CS,3f
22354 +3: SET_RDI_INTO_CR0
22355 + jmp 1b
22356 +4: ud2
22357 + jmp 4b
22358 +#endif
22359 +ENDPROC(pax_exit_kernel)
22360 +#endif
22361 +
22362 + .macro pax_enter_kernel_user
22363 + pax_set_fptr_mask
22364 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22365 + call pax_enter_kernel_user
22366 +#endif
22367 + .endm
22368 +
22369 + .macro pax_exit_kernel_user
22370 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22371 + call pax_exit_kernel_user
22372 +#endif
22373 +#ifdef CONFIG_PAX_RANDKSTACK
22374 + pushq %rax
22375 + pushq %r11
22376 + call pax_randomize_kstack
22377 + popq %r11
22378 + popq %rax
22379 +#endif
22380 + .endm
22381 +
22382 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22383 +ENTRY(pax_enter_kernel_user)
22384 + pushq %rdi
22385 + pushq %rbx
22386 +
22387 +#ifdef CONFIG_PARAVIRT
22388 + PV_SAVE_REGS(CLBR_RDI)
22389 +#endif
22390 +
22391 + 661: jmp 111f
22392 + .pushsection .altinstr_replacement, "a"
22393 + 662: ASM_NOP2
22394 + .popsection
22395 + .pushsection .altinstructions, "a"
22396 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22397 + .popsection
22398 + GET_CR3_INTO_RDI
22399 + cmp $1,%dil
22400 + jnz 4f
22401 + sub $4097,%rdi
22402 + bts $63,%rdi
22403 + SET_RDI_INTO_CR3
22404 + jmp 3f
22405 +111:
22406 +
22407 + GET_CR3_INTO_RDI
22408 + mov %rdi,%rbx
22409 + add $__START_KERNEL_map,%rbx
22410 + sub phys_base(%rip),%rbx
22411 +
22412 +#ifdef CONFIG_PARAVIRT
22413 + cmpl $0, pv_info+PARAVIRT_enabled
22414 + jz 1f
22415 + pushq %rdi
22416 + i = 0
22417 + .rept USER_PGD_PTRS
22418 + mov i*8(%rbx),%rsi
22419 + mov $0,%sil
22420 + lea i*8(%rbx),%rdi
22421 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22422 + i = i + 1
22423 + .endr
22424 + popq %rdi
22425 + jmp 2f
22426 +1:
22427 +#endif
22428 +
22429 + i = 0
22430 + .rept USER_PGD_PTRS
22431 + movb $0,i*8(%rbx)
22432 + i = i + 1
22433 + .endr
22434 +
22435 +2: SET_RDI_INTO_CR3
22436 +
22437 +#ifdef CONFIG_PAX_KERNEXEC
22438 + GET_CR0_INTO_RDI
22439 + bts $16,%rdi
22440 + SET_RDI_INTO_CR0
22441 +#endif
22442 +
22443 +3:
22444 +
22445 +#ifdef CONFIG_PARAVIRT
22446 + PV_RESTORE_REGS(CLBR_RDI)
22447 +#endif
22448 +
22449 + popq %rbx
22450 + popq %rdi
22451 + pax_force_retaddr
22452 + retq
22453 +4: ud2
22454 +ENDPROC(pax_enter_kernel_user)
22455 +
22456 +ENTRY(pax_exit_kernel_user)
22457 + pushq %rdi
22458 + pushq %rbx
22459 +
22460 +#ifdef CONFIG_PARAVIRT
22461 + PV_SAVE_REGS(CLBR_RDI)
22462 +#endif
22463 +
22464 + GET_CR3_INTO_RDI
22465 + 661: jmp 1f
22466 + .pushsection .altinstr_replacement, "a"
22467 + 662: ASM_NOP2
22468 + .popsection
22469 + .pushsection .altinstructions, "a"
22470 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22471 + .popsection
22472 + cmp $0,%dil
22473 + jnz 3f
22474 + add $4097,%rdi
22475 + bts $63,%rdi
22476 + SET_RDI_INTO_CR3
22477 + jmp 2f
22478 +1:
22479 +
22480 + mov %rdi,%rbx
22481 +
22482 +#ifdef CONFIG_PAX_KERNEXEC
22483 + GET_CR0_INTO_RDI
22484 + btr $16,%rdi
22485 + jnc 3f
22486 + SET_RDI_INTO_CR0
22487 +#endif
22488 +
22489 + add $__START_KERNEL_map,%rbx
22490 + sub phys_base(%rip),%rbx
22491 +
22492 +#ifdef CONFIG_PARAVIRT
22493 + cmpl $0, pv_info+PARAVIRT_enabled
22494 + jz 1f
22495 + i = 0
22496 + .rept USER_PGD_PTRS
22497 + mov i*8(%rbx),%rsi
22498 + mov $0x67,%sil
22499 + lea i*8(%rbx),%rdi
22500 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22501 + i = i + 1
22502 + .endr
22503 + jmp 2f
22504 +1:
22505 +#endif
22506 +
22507 + i = 0
22508 + .rept USER_PGD_PTRS
22509 + movb $0x67,i*8(%rbx)
22510 + i = i + 1
22511 + .endr
22512 +2:
22513 +
22514 +#ifdef CONFIG_PARAVIRT
22515 + PV_RESTORE_REGS(CLBR_RDI)
22516 +#endif
22517 +
22518 + popq %rbx
22519 + popq %rdi
22520 + pax_force_retaddr
22521 + retq
22522 +3: ud2
22523 +ENDPROC(pax_exit_kernel_user)
22524 +#endif
22525 +
22526 + .macro pax_enter_kernel_nmi
22527 + pax_set_fptr_mask
22528 +
22529 +#ifdef CONFIG_PAX_KERNEXEC
22530 + GET_CR0_INTO_RDI
22531 + bts $16,%rdi
22532 + jc 110f
22533 + SET_RDI_INTO_CR0
22534 + or $2,%ebx
22535 +110:
22536 +#endif
22537 +
22538 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22539 + 661: jmp 111f
22540 + .pushsection .altinstr_replacement, "a"
22541 + 662: ASM_NOP2
22542 + .popsection
22543 + .pushsection .altinstructions, "a"
22544 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22545 + .popsection
22546 + GET_CR3_INTO_RDI
22547 + cmp $0,%dil
22548 + jz 111f
22549 + sub $4097,%rdi
22550 + or $4,%ebx
22551 + bts $63,%rdi
22552 + SET_RDI_INTO_CR3
22553 + mov $__UDEREF_KERNEL_DS,%edi
22554 + mov %edi,%ss
22555 +111:
22556 +#endif
22557 + .endm
22558 +
22559 + .macro pax_exit_kernel_nmi
22560 +#ifdef CONFIG_PAX_KERNEXEC
22561 + btr $1,%ebx
22562 + jnc 110f
22563 + GET_CR0_INTO_RDI
22564 + btr $16,%rdi
22565 + SET_RDI_INTO_CR0
22566 +110:
22567 +#endif
22568 +
22569 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22570 + btr $2,%ebx
22571 + jnc 111f
22572 + GET_CR3_INTO_RDI
22573 + add $4097,%rdi
22574 + bts $63,%rdi
22575 + SET_RDI_INTO_CR3
22576 + mov $__KERNEL_DS,%edi
22577 + mov %edi,%ss
22578 +111:
22579 +#endif
22580 + .endm
22581 +
22582 + .macro pax_erase_kstack
22583 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22584 + call pax_erase_kstack
22585 +#endif
22586 + .endm
22587 +
22588 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22589 +ENTRY(pax_erase_kstack)
22590 + pushq %rdi
22591 + pushq %rcx
22592 + pushq %rax
22593 + pushq %r11
22594 +
22595 + GET_THREAD_INFO(%r11)
22596 + mov TI_lowest_stack(%r11), %rdi
22597 + mov $-0xBEEF, %rax
22598 + std
22599 +
22600 +1: mov %edi, %ecx
22601 + and $THREAD_SIZE_asm - 1, %ecx
22602 + shr $3, %ecx
22603 + repne scasq
22604 + jecxz 2f
22605 +
22606 + cmp $2*8, %ecx
22607 + jc 2f
22608 +
22609 + mov $2*8, %ecx
22610 + repe scasq
22611 + jecxz 2f
22612 + jne 1b
22613 +
22614 +2: cld
22615 + mov %esp, %ecx
22616 + sub %edi, %ecx
22617 +
22618 + cmp $THREAD_SIZE_asm, %rcx
22619 + jb 3f
22620 + ud2
22621 +3:
22622 +
22623 + shr $3, %ecx
22624 + rep stosq
22625 +
22626 + mov TI_task_thread_sp0(%r11), %rdi
22627 + sub $256, %rdi
22628 + mov %rdi, TI_lowest_stack(%r11)
22629 +
22630 + popq %r11
22631 + popq %rax
22632 + popq %rcx
22633 + popq %rdi
22634 + pax_force_retaddr
22635 + ret
22636 +ENDPROC(pax_erase_kstack)
22637 +#endif
22638
22639 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
22640 #ifdef CONFIG_TRACE_IRQFLAGS
22641 @@ -320,7 +753,7 @@ ENDPROC(native_usergs_sysret64)
22642 .endm
22643
22644 .macro TRACE_IRQS_IRETQ_DEBUG offset=ARGOFFSET
22645 - bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
22646 + bt $X86_EFLAGS_IF_BIT,EFLAGS-\offset(%rsp) /* interrupts off? */
22647 jnc 1f
22648 TRACE_IRQS_ON_DEBUG
22649 1:
22650 @@ -358,27 +791,6 @@ ENDPROC(native_usergs_sysret64)
22651 movq \tmp,R11+\offset(%rsp)
22652 .endm
22653
22654 - .macro FAKE_STACK_FRAME child_rip
22655 - /* push in order ss, rsp, eflags, cs, rip */
22656 - xorl %eax, %eax
22657 - pushq_cfi $__KERNEL_DS /* ss */
22658 - /*CFI_REL_OFFSET ss,0*/
22659 - pushq_cfi %rax /* rsp */
22660 - CFI_REL_OFFSET rsp,0
22661 - pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED) /* eflags - interrupts on */
22662 - /*CFI_REL_OFFSET rflags,0*/
22663 - pushq_cfi $__KERNEL_CS /* cs */
22664 - /*CFI_REL_OFFSET cs,0*/
22665 - pushq_cfi \child_rip /* rip */
22666 - CFI_REL_OFFSET rip,0
22667 - pushq_cfi %rax /* orig rax */
22668 - .endm
22669 -
22670 - .macro UNFAKE_STACK_FRAME
22671 - addq $8*6, %rsp
22672 - CFI_ADJUST_CFA_OFFSET -(6*8)
22673 - .endm
22674 -
22675 /*
22676 * initial frame state for interrupts (and exceptions without error code)
22677 */
22678 @@ -445,25 +857,26 @@ ENDPROC(native_usergs_sysret64)
22679 /* save partial stack frame */
22680 .macro SAVE_ARGS_IRQ
22681 cld
22682 - /* start from rbp in pt_regs and jump over */
22683 - movq_cfi rdi, (RDI-RBP)
22684 - movq_cfi rsi, (RSI-RBP)
22685 - movq_cfi rdx, (RDX-RBP)
22686 - movq_cfi rcx, (RCX-RBP)
22687 - movq_cfi rax, (RAX-RBP)
22688 - movq_cfi r8, (R8-RBP)
22689 - movq_cfi r9, (R9-RBP)
22690 - movq_cfi r10, (R10-RBP)
22691 - movq_cfi r11, (R11-RBP)
22692 + /* start from r15 in pt_regs and jump over */
22693 + movq_cfi rdi, RDI
22694 + movq_cfi rsi, RSI
22695 + movq_cfi rdx, RDX
22696 + movq_cfi rcx, RCX
22697 + movq_cfi rax, RAX
22698 + movq_cfi r8, R8
22699 + movq_cfi r9, R9
22700 + movq_cfi r10, R10
22701 + movq_cfi r11, R11
22702 + movq_cfi r12, R12
22703
22704 /* Save rbp so that we can unwind from get_irq_regs() */
22705 - movq_cfi rbp, 0
22706 + movq_cfi rbp, RBP
22707
22708 /* Save previous stack value */
22709 movq %rsp, %rsi
22710
22711 - leaq -RBP(%rsp),%rdi /* arg1 for handler */
22712 - testl $3, CS-RBP(%rsi)
22713 + movq %rsp,%rdi /* arg1 for handler */
22714 + testb $3, CS(%rsi)
22715 je 1f
22716 SWAPGS
22717 /*
22718 @@ -514,9 +927,10 @@ ENTRY(save_paranoid)
22719 js 1f /* negative -> in kernel */
22720 SWAPGS
22721 xorl %ebx,%ebx
22722 -1: ret
22723 +1: pax_force_retaddr_bts
22724 + ret
22725 CFI_ENDPROC
22726 -END(save_paranoid)
22727 +ENDPROC(save_paranoid)
22728 .popsection
22729
22730 /*
22731 @@ -538,7 +952,7 @@ ENTRY(ret_from_fork)
22732
22733 RESTORE_REST
22734
22735 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22736 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22737 jz 1f
22738
22739 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
22740 @@ -548,15 +962,13 @@ ENTRY(ret_from_fork)
22741 jmp ret_from_sys_call # go to the SYSRET fastpath
22742
22743 1:
22744 - subq $REST_SKIP, %rsp # leave space for volatiles
22745 - CFI_ADJUST_CFA_OFFSET REST_SKIP
22746 movq %rbp, %rdi
22747 call *%rbx
22748 movl $0, RAX(%rsp)
22749 RESTORE_REST
22750 jmp int_ret_from_sys_call
22751 CFI_ENDPROC
22752 -END(ret_from_fork)
22753 +ENDPROC(ret_from_fork)
22754
22755 /*
22756 * System call entry. Up to 6 arguments in registers are supported.
22757 @@ -593,7 +1005,7 @@ END(ret_from_fork)
22758 ENTRY(system_call)
22759 CFI_STARTPROC simple
22760 CFI_SIGNAL_FRAME
22761 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
22762 + CFI_DEF_CFA rsp,0
22763 CFI_REGISTER rip,rcx
22764 /*CFI_REGISTER rflags,r11*/
22765 SWAPGS_UNSAFE_STACK
22766 @@ -606,16 +1018,23 @@ GLOBAL(system_call_after_swapgs)
22767
22768 movq %rsp,PER_CPU_VAR(old_rsp)
22769 movq PER_CPU_VAR(kernel_stack),%rsp
22770 + SAVE_ARGS 8*6,0
22771 + pax_enter_kernel_user
22772 +
22773 +#ifdef CONFIG_PAX_RANDKSTACK
22774 + pax_erase_kstack
22775 +#endif
22776 +
22777 /*
22778 * No need to follow this irqs off/on section - it's straight
22779 * and short:
22780 */
22781 ENABLE_INTERRUPTS(CLBR_NONE)
22782 - SAVE_ARGS 8,0
22783 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
22784 movq %rcx,RIP-ARGOFFSET(%rsp)
22785 CFI_REL_OFFSET rip,RIP-ARGOFFSET
22786 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22787 + GET_THREAD_INFO(%rcx)
22788 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
22789 jnz tracesys
22790 system_call_fastpath:
22791 #if __SYSCALL_MASK == ~0
22792 @@ -639,10 +1058,13 @@ sysret_check:
22793 LOCKDEP_SYS_EXIT
22794 DISABLE_INTERRUPTS(CLBR_NONE)
22795 TRACE_IRQS_OFF
22796 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
22797 + GET_THREAD_INFO(%rcx)
22798 + movl TI_flags(%rcx),%edx
22799 andl %edi,%edx
22800 jnz sysret_careful
22801 CFI_REMEMBER_STATE
22802 + pax_exit_kernel_user
22803 + pax_erase_kstack
22804 /*
22805 * sysretq will re-enable interrupts:
22806 */
22807 @@ -701,6 +1123,9 @@ auditsys:
22808 movq %rax,%rsi /* 2nd arg: syscall number */
22809 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
22810 call __audit_syscall_entry
22811 +
22812 + pax_erase_kstack
22813 +
22814 LOAD_ARGS 0 /* reload call-clobbered registers */
22815 jmp system_call_fastpath
22816
22817 @@ -722,7 +1147,7 @@ sysret_audit:
22818 /* Do syscall tracing */
22819 tracesys:
22820 #ifdef CONFIG_AUDITSYSCALL
22821 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22822 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22823 jz auditsys
22824 #endif
22825 SAVE_REST
22826 @@ -730,12 +1155,15 @@ tracesys:
22827 FIXUP_TOP_OF_STACK %rdi
22828 movq %rsp,%rdi
22829 call syscall_trace_enter
22830 +
22831 + pax_erase_kstack
22832 +
22833 /*
22834 * Reload arg registers from stack in case ptrace changed them.
22835 * We don't reload %rax because syscall_trace_enter() returned
22836 * the value it wants us to use in the table lookup.
22837 */
22838 - LOAD_ARGS ARGOFFSET, 1
22839 + LOAD_ARGS 1
22840 RESTORE_REST
22841 #if __SYSCALL_MASK == ~0
22842 cmpq $__NR_syscall_max,%rax
22843 @@ -765,7 +1193,9 @@ GLOBAL(int_with_check)
22844 andl %edi,%edx
22845 jnz int_careful
22846 andl $~TS_COMPAT,TI_status(%rcx)
22847 - jmp retint_swapgs
22848 + pax_exit_kernel_user
22849 + pax_erase_kstack
22850 + jmp retint_swapgs_pax
22851
22852 /* Either reschedule or signal or syscall exit tracking needed. */
22853 /* First do a reschedule test. */
22854 @@ -811,7 +1241,7 @@ int_restore_rest:
22855 TRACE_IRQS_OFF
22856 jmp int_with_check
22857 CFI_ENDPROC
22858 -END(system_call)
22859 +ENDPROC(system_call)
22860
22861 .macro FORK_LIKE func
22862 ENTRY(stub_\func)
22863 @@ -824,9 +1254,10 @@ ENTRY(stub_\func)
22864 DEFAULT_FRAME 0 8 /* offset 8: return address */
22865 call sys_\func
22866 RESTORE_TOP_OF_STACK %r11, 8
22867 - ret $REST_SKIP /* pop extended registers */
22868 + pax_force_retaddr
22869 + ret
22870 CFI_ENDPROC
22871 -END(stub_\func)
22872 +ENDPROC(stub_\func)
22873 .endm
22874
22875 .macro FIXED_FRAME label,func
22876 @@ -836,9 +1267,10 @@ ENTRY(\label)
22877 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22878 call \func
22879 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22880 + pax_force_retaddr
22881 ret
22882 CFI_ENDPROC
22883 -END(\label)
22884 +ENDPROC(\label)
22885 .endm
22886
22887 FORK_LIKE clone
22888 @@ -846,19 +1278,6 @@ END(\label)
22889 FORK_LIKE vfork
22890 FIXED_FRAME stub_iopl, sys_iopl
22891
22892 -ENTRY(ptregscall_common)
22893 - DEFAULT_FRAME 1 8 /* offset 8: return address */
22894 - RESTORE_TOP_OF_STACK %r11, 8
22895 - movq_cfi_restore R15+8, r15
22896 - movq_cfi_restore R14+8, r14
22897 - movq_cfi_restore R13+8, r13
22898 - movq_cfi_restore R12+8, r12
22899 - movq_cfi_restore RBP+8, rbp
22900 - movq_cfi_restore RBX+8, rbx
22901 - ret $REST_SKIP /* pop extended registers */
22902 - CFI_ENDPROC
22903 -END(ptregscall_common)
22904 -
22905 ENTRY(stub_execve)
22906 CFI_STARTPROC
22907 addq $8, %rsp
22908 @@ -870,7 +1289,7 @@ ENTRY(stub_execve)
22909 RESTORE_REST
22910 jmp int_ret_from_sys_call
22911 CFI_ENDPROC
22912 -END(stub_execve)
22913 +ENDPROC(stub_execve)
22914
22915 /*
22916 * sigreturn is special because it needs to restore all registers on return.
22917 @@ -887,7 +1306,7 @@ ENTRY(stub_rt_sigreturn)
22918 RESTORE_REST
22919 jmp int_ret_from_sys_call
22920 CFI_ENDPROC
22921 -END(stub_rt_sigreturn)
22922 +ENDPROC(stub_rt_sigreturn)
22923
22924 #ifdef CONFIG_X86_X32_ABI
22925 ENTRY(stub_x32_rt_sigreturn)
22926 @@ -901,7 +1320,7 @@ ENTRY(stub_x32_rt_sigreturn)
22927 RESTORE_REST
22928 jmp int_ret_from_sys_call
22929 CFI_ENDPROC
22930 -END(stub_x32_rt_sigreturn)
22931 +ENDPROC(stub_x32_rt_sigreturn)
22932
22933 ENTRY(stub_x32_execve)
22934 CFI_STARTPROC
22935 @@ -915,7 +1334,7 @@ ENTRY(stub_x32_execve)
22936 RESTORE_REST
22937 jmp int_ret_from_sys_call
22938 CFI_ENDPROC
22939 -END(stub_x32_execve)
22940 +ENDPROC(stub_x32_execve)
22941
22942 #endif
22943
22944 @@ -952,7 +1371,7 @@ vector=vector+1
22945 2: jmp common_interrupt
22946 .endr
22947 CFI_ENDPROC
22948 -END(irq_entries_start)
22949 +ENDPROC(irq_entries_start)
22950
22951 .previous
22952 END(interrupt)
22953 @@ -969,9 +1388,19 @@ END(interrupt)
22954 /* 0(%rsp): ~(interrupt number) */
22955 .macro interrupt func
22956 /* reserve pt_regs for scratch regs and rbp */
22957 - subq $ORIG_RAX-RBP, %rsp
22958 - CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22959 + subq $ORIG_RAX, %rsp
22960 + CFI_ADJUST_CFA_OFFSET ORIG_RAX
22961 SAVE_ARGS_IRQ
22962 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22963 + testb $3, CS(%rdi)
22964 + jnz 1f
22965 + pax_enter_kernel
22966 + jmp 2f
22967 +1: pax_enter_kernel_user
22968 +2:
22969 +#else
22970 + pax_enter_kernel
22971 +#endif
22972 call \func
22973 .endm
22974
22975 @@ -997,14 +1426,14 @@ ret_from_intr:
22976
22977 /* Restore saved previous stack */
22978 popq %rsi
22979 - CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */
22980 - leaq ARGOFFSET-RBP(%rsi), %rsp
22981 + CFI_DEF_CFA rsi,SS+8 /* reg/off reset after def_cfa_expr */
22982 + movq %rsi, %rsp
22983 CFI_DEF_CFA_REGISTER rsp
22984 - CFI_ADJUST_CFA_OFFSET RBP-ARGOFFSET
22985 + CFI_ADJUST_CFA_OFFSET -ARGOFFSET
22986
22987 exit_intr:
22988 GET_THREAD_INFO(%rcx)
22989 - testl $3,CS-ARGOFFSET(%rsp)
22990 + testb $3,CS-ARGOFFSET(%rsp)
22991 je retint_kernel
22992
22993 /* Interrupt came from user space */
22994 @@ -1026,12 +1455,16 @@ retint_swapgs: /* return to user-space */
22995 * The iretq could re-enable interrupts:
22996 */
22997 DISABLE_INTERRUPTS(CLBR_ANY)
22998 + pax_exit_kernel_user
22999 +retint_swapgs_pax:
23000 TRACE_IRQS_IRETQ
23001 SWAPGS
23002 jmp restore_args
23003
23004 retint_restore_args: /* return to kernel space */
23005 DISABLE_INTERRUPTS(CLBR_ANY)
23006 + pax_exit_kernel
23007 + pax_force_retaddr (RIP-ARGOFFSET)
23008 /*
23009 * The iretq could re-enable interrupts:
23010 */
23011 @@ -1114,7 +1547,7 @@ ENTRY(retint_kernel)
23012 #endif
23013
23014 CFI_ENDPROC
23015 -END(common_interrupt)
23016 +ENDPROC(common_interrupt)
23017 /*
23018 * End of kprobes section
23019 */
23020 @@ -1132,7 +1565,7 @@ ENTRY(\sym)
23021 interrupt \do_sym
23022 jmp ret_from_intr
23023 CFI_ENDPROC
23024 -END(\sym)
23025 +ENDPROC(\sym)
23026 .endm
23027
23028 #ifdef CONFIG_TRACING
23029 @@ -1215,12 +1648,22 @@ ENTRY(\sym)
23030 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23031 call error_entry
23032 DEFAULT_FRAME 0
23033 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23034 + testb $3, CS(%rsp)
23035 + jnz 1f
23036 + pax_enter_kernel
23037 + jmp 2f
23038 +1: pax_enter_kernel_user
23039 +2:
23040 +#else
23041 + pax_enter_kernel
23042 +#endif
23043 movq %rsp,%rdi /* pt_regs pointer */
23044 xorl %esi,%esi /* no error code */
23045 call \do_sym
23046 jmp error_exit /* %ebx: no swapgs flag */
23047 CFI_ENDPROC
23048 -END(\sym)
23049 +ENDPROC(\sym)
23050 .endm
23051
23052 .macro paranoidzeroentry sym do_sym
23053 @@ -1233,15 +1676,25 @@ ENTRY(\sym)
23054 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23055 call save_paranoid
23056 TRACE_IRQS_OFF
23057 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23058 + testb $3, CS(%rsp)
23059 + jnz 1f
23060 + pax_enter_kernel
23061 + jmp 2f
23062 +1: pax_enter_kernel_user
23063 +2:
23064 +#else
23065 + pax_enter_kernel
23066 +#endif
23067 movq %rsp,%rdi /* pt_regs pointer */
23068 xorl %esi,%esi /* no error code */
23069 call \do_sym
23070 jmp paranoid_exit /* %ebx: no swapgs flag */
23071 CFI_ENDPROC
23072 -END(\sym)
23073 +ENDPROC(\sym)
23074 .endm
23075
23076 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
23077 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
23078 .macro paranoidzeroentry_ist sym do_sym ist
23079 ENTRY(\sym)
23080 INTR_FRAME
23081 @@ -1252,14 +1705,30 @@ ENTRY(\sym)
23082 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23083 call save_paranoid
23084 TRACE_IRQS_OFF_DEBUG
23085 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23086 + testb $3, CS(%rsp)
23087 + jnz 1f
23088 + pax_enter_kernel
23089 + jmp 2f
23090 +1: pax_enter_kernel_user
23091 +2:
23092 +#else
23093 + pax_enter_kernel
23094 +#endif
23095 movq %rsp,%rdi /* pt_regs pointer */
23096 xorl %esi,%esi /* no error code */
23097 +#ifdef CONFIG_SMP
23098 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
23099 + lea init_tss(%r13), %r13
23100 +#else
23101 + lea init_tss(%rip), %r13
23102 +#endif
23103 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
23104 call \do_sym
23105 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
23106 jmp paranoid_exit /* %ebx: no swapgs flag */
23107 CFI_ENDPROC
23108 -END(\sym)
23109 +ENDPROC(\sym)
23110 .endm
23111
23112 .macro errorentry sym do_sym
23113 @@ -1271,13 +1740,23 @@ ENTRY(\sym)
23114 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23115 call error_entry
23116 DEFAULT_FRAME 0
23117 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23118 + testb $3, CS(%rsp)
23119 + jnz 1f
23120 + pax_enter_kernel
23121 + jmp 2f
23122 +1: pax_enter_kernel_user
23123 +2:
23124 +#else
23125 + pax_enter_kernel
23126 +#endif
23127 movq %rsp,%rdi /* pt_regs pointer */
23128 movq ORIG_RAX(%rsp),%rsi /* get error code */
23129 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23130 call \do_sym
23131 jmp error_exit /* %ebx: no swapgs flag */
23132 CFI_ENDPROC
23133 -END(\sym)
23134 +ENDPROC(\sym)
23135 .endm
23136
23137 /* error code is on the stack already */
23138 @@ -1291,13 +1770,23 @@ ENTRY(\sym)
23139 call save_paranoid
23140 DEFAULT_FRAME 0
23141 TRACE_IRQS_OFF
23142 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23143 + testb $3, CS(%rsp)
23144 + jnz 1f
23145 + pax_enter_kernel
23146 + jmp 2f
23147 +1: pax_enter_kernel_user
23148 +2:
23149 +#else
23150 + pax_enter_kernel
23151 +#endif
23152 movq %rsp,%rdi /* pt_regs pointer */
23153 movq ORIG_RAX(%rsp),%rsi /* get error code */
23154 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23155 call \do_sym
23156 jmp paranoid_exit /* %ebx: no swapgs flag */
23157 CFI_ENDPROC
23158 -END(\sym)
23159 +ENDPROC(\sym)
23160 .endm
23161
23162 zeroentry divide_error do_divide_error
23163 @@ -1327,9 +1816,10 @@ gs_change:
23164 2: mfence /* workaround */
23165 SWAPGS
23166 popfq_cfi
23167 + pax_force_retaddr
23168 ret
23169 CFI_ENDPROC
23170 -END(native_load_gs_index)
23171 +ENDPROC(native_load_gs_index)
23172
23173 _ASM_EXTABLE(gs_change,bad_gs)
23174 .section .fixup,"ax"
23175 @@ -1357,9 +1847,10 @@ ENTRY(call_softirq)
23176 CFI_DEF_CFA_REGISTER rsp
23177 CFI_ADJUST_CFA_OFFSET -8
23178 decl PER_CPU_VAR(irq_count)
23179 + pax_force_retaddr
23180 ret
23181 CFI_ENDPROC
23182 -END(call_softirq)
23183 +ENDPROC(call_softirq)
23184
23185 #ifdef CONFIG_XEN
23186 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
23187 @@ -1397,7 +1888,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
23188 decl PER_CPU_VAR(irq_count)
23189 jmp error_exit
23190 CFI_ENDPROC
23191 -END(xen_do_hypervisor_callback)
23192 +ENDPROC(xen_do_hypervisor_callback)
23193
23194 /*
23195 * Hypervisor uses this for application faults while it executes.
23196 @@ -1456,7 +1947,7 @@ ENTRY(xen_failsafe_callback)
23197 SAVE_ALL
23198 jmp error_exit
23199 CFI_ENDPROC
23200 -END(xen_failsafe_callback)
23201 +ENDPROC(xen_failsafe_callback)
23202
23203 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
23204 xen_hvm_callback_vector xen_evtchn_do_upcall
23205 @@ -1508,18 +1999,33 @@ ENTRY(paranoid_exit)
23206 DEFAULT_FRAME
23207 DISABLE_INTERRUPTS(CLBR_NONE)
23208 TRACE_IRQS_OFF_DEBUG
23209 - testl %ebx,%ebx /* swapgs needed? */
23210 + testl $1,%ebx /* swapgs needed? */
23211 jnz paranoid_restore
23212 - testl $3,CS(%rsp)
23213 + testb $3,CS(%rsp)
23214 jnz paranoid_userspace
23215 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23216 + pax_exit_kernel
23217 + TRACE_IRQS_IRETQ 0
23218 + SWAPGS_UNSAFE_STACK
23219 + RESTORE_ALL 8
23220 + pax_force_retaddr_bts
23221 + jmp irq_return
23222 +#endif
23223 paranoid_swapgs:
23224 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23225 + pax_exit_kernel_user
23226 +#else
23227 + pax_exit_kernel
23228 +#endif
23229 TRACE_IRQS_IRETQ 0
23230 SWAPGS_UNSAFE_STACK
23231 RESTORE_ALL 8
23232 jmp irq_return
23233 paranoid_restore:
23234 + pax_exit_kernel
23235 TRACE_IRQS_IRETQ_DEBUG 0
23236 RESTORE_ALL 8
23237 + pax_force_retaddr_bts
23238 jmp irq_return
23239 paranoid_userspace:
23240 GET_THREAD_INFO(%rcx)
23241 @@ -1548,7 +2054,7 @@ paranoid_schedule:
23242 TRACE_IRQS_OFF
23243 jmp paranoid_userspace
23244 CFI_ENDPROC
23245 -END(paranoid_exit)
23246 +ENDPROC(paranoid_exit)
23247
23248 /*
23249 * Exception entry point. This expects an error code/orig_rax on the stack.
23250 @@ -1575,12 +2081,13 @@ ENTRY(error_entry)
23251 movq_cfi r14, R14+8
23252 movq_cfi r15, R15+8
23253 xorl %ebx,%ebx
23254 - testl $3,CS+8(%rsp)
23255 + testb $3,CS+8(%rsp)
23256 je error_kernelspace
23257 error_swapgs:
23258 SWAPGS
23259 error_sti:
23260 TRACE_IRQS_OFF
23261 + pax_force_retaddr_bts
23262 ret
23263
23264 /*
23265 @@ -1607,7 +2114,7 @@ bstep_iret:
23266 movq %rcx,RIP+8(%rsp)
23267 jmp error_swapgs
23268 CFI_ENDPROC
23269 -END(error_entry)
23270 +ENDPROC(error_entry)
23271
23272
23273 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
23274 @@ -1618,7 +2125,7 @@ ENTRY(error_exit)
23275 DISABLE_INTERRUPTS(CLBR_NONE)
23276 TRACE_IRQS_OFF
23277 GET_THREAD_INFO(%rcx)
23278 - testl %eax,%eax
23279 + testl $1,%eax
23280 jne retint_kernel
23281 LOCKDEP_SYS_EXIT_IRQ
23282 movl TI_flags(%rcx),%edx
23283 @@ -1627,7 +2134,7 @@ ENTRY(error_exit)
23284 jnz retint_careful
23285 jmp retint_swapgs
23286 CFI_ENDPROC
23287 -END(error_exit)
23288 +ENDPROC(error_exit)
23289
23290 /*
23291 * Test if a given stack is an NMI stack or not.
23292 @@ -1685,9 +2192,11 @@ ENTRY(nmi)
23293 * If %cs was not the kernel segment, then the NMI triggered in user
23294 * space, which means it is definitely not nested.
23295 */
23296 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
23297 + je 1f
23298 cmpl $__KERNEL_CS, 16(%rsp)
23299 jne first_nmi
23300 -
23301 +1:
23302 /*
23303 * Check the special variable on the stack to see if NMIs are
23304 * executing.
23305 @@ -1721,8 +2230,7 @@ nested_nmi:
23306
23307 1:
23308 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
23309 - leaq -1*8(%rsp), %rdx
23310 - movq %rdx, %rsp
23311 + subq $8, %rsp
23312 CFI_ADJUST_CFA_OFFSET 1*8
23313 leaq -10*8(%rsp), %rdx
23314 pushq_cfi $__KERNEL_DS
23315 @@ -1740,6 +2248,7 @@ nested_nmi_out:
23316 CFI_RESTORE rdx
23317
23318 /* No need to check faults here */
23319 +# pax_force_retaddr_bts
23320 INTERRUPT_RETURN
23321
23322 CFI_RESTORE_STATE
23323 @@ -1852,9 +2361,11 @@ end_repeat_nmi:
23324 * NMI itself takes a page fault, the page fault that was preempted
23325 * will read the information from the NMI page fault and not the
23326 * origin fault. Save it off and restore it if it changes.
23327 - * Use the r12 callee-saved register.
23328 + * Use the r13 callee-saved register.
23329 */
23330 - movq %cr2, %r12
23331 + movq %cr2, %r13
23332 +
23333 + pax_enter_kernel_nmi
23334
23335 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
23336 movq %rsp,%rdi
23337 @@ -1863,31 +2374,36 @@ end_repeat_nmi:
23338
23339 /* Did the NMI take a page fault? Restore cr2 if it did */
23340 movq %cr2, %rcx
23341 - cmpq %rcx, %r12
23342 + cmpq %rcx, %r13
23343 je 1f
23344 - movq %r12, %cr2
23345 + movq %r13, %cr2
23346 1:
23347
23348 - testl %ebx,%ebx /* swapgs needed? */
23349 + testl $1,%ebx /* swapgs needed? */
23350 jnz nmi_restore
23351 nmi_swapgs:
23352 SWAPGS_UNSAFE_STACK
23353 nmi_restore:
23354 + pax_exit_kernel_nmi
23355 /* Pop the extra iret frame at once */
23356 RESTORE_ALL 6*8
23357 + testb $3, 8(%rsp)
23358 + jnz 1f
23359 + pax_force_retaddr_bts
23360 +1:
23361
23362 /* Clear the NMI executing stack variable */
23363 movq $0, 5*8(%rsp)
23364 jmp irq_return
23365 CFI_ENDPROC
23366 -END(nmi)
23367 +ENDPROC(nmi)
23368
23369 ENTRY(ignore_sysret)
23370 CFI_STARTPROC
23371 mov $-ENOSYS,%eax
23372 sysret
23373 CFI_ENDPROC
23374 -END(ignore_sysret)
23375 +ENDPROC(ignore_sysret)
23376
23377 /*
23378 * End of kprobes section
23379 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
23380 index d4bdd25..912664c 100644
23381 --- a/arch/x86/kernel/ftrace.c
23382 +++ b/arch/x86/kernel/ftrace.c
23383 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
23384 {
23385 unsigned char replaced[MCOUNT_INSN_SIZE];
23386
23387 + ip = ktla_ktva(ip);
23388 +
23389 /*
23390 * Note: Due to modules and __init, code can
23391 * disappear and change, we need to protect against faulting
23392 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23393 unsigned char old[MCOUNT_INSN_SIZE], *new;
23394 int ret;
23395
23396 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
23397 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
23398 new = ftrace_call_replace(ip, (unsigned long)func);
23399
23400 /* See comment above by declaration of modifying_ftrace_code */
23401 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23402 /* Also update the regs callback function */
23403 if (!ret) {
23404 ip = (unsigned long)(&ftrace_regs_call);
23405 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
23406 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
23407 new = ftrace_call_replace(ip, (unsigned long)func);
23408 ret = ftrace_modify_code(ip, old, new);
23409 }
23410 @@ -291,7 +293,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
23411 * kernel identity mapping to modify code.
23412 */
23413 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
23414 - ip = (unsigned long)__va(__pa_symbol(ip));
23415 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
23416
23417 return probe_kernel_write((void *)ip, val, size);
23418 }
23419 @@ -301,7 +303,7 @@ static int add_break(unsigned long ip, const char *old)
23420 unsigned char replaced[MCOUNT_INSN_SIZE];
23421 unsigned char brk = BREAKPOINT_INSTRUCTION;
23422
23423 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
23424 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
23425 return -EFAULT;
23426
23427 /* Make sure it is what we expect it to be */
23428 @@ -649,7 +651,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
23429 return ret;
23430
23431 fail_update:
23432 - probe_kernel_write((void *)ip, &old_code[0], 1);
23433 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
23434 goto out;
23435 }
23436
23437 @@ -682,6 +684,8 @@ static int ftrace_mod_jmp(unsigned long ip,
23438 {
23439 unsigned char code[MCOUNT_INSN_SIZE];
23440
23441 + ip = ktla_ktva(ip);
23442 +
23443 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
23444 return -EFAULT;
23445
23446 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
23447 index 1be8e43..d9b9ef6 100644
23448 --- a/arch/x86/kernel/head64.c
23449 +++ b/arch/x86/kernel/head64.c
23450 @@ -67,12 +67,12 @@ again:
23451 pgd = *pgd_p;
23452
23453 /*
23454 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
23455 - * critical -- __PAGE_OFFSET would point us back into the dynamic
23456 + * The use of __early_va rather than __va here is critical:
23457 + * __va would point us back into the dynamic
23458 * range and we might end up looping forever...
23459 */
23460 if (pgd)
23461 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23462 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
23463 else {
23464 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23465 reset_early_page_tables();
23466 @@ -82,13 +82,13 @@ again:
23467 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
23468 for (i = 0; i < PTRS_PER_PUD; i++)
23469 pud_p[i] = 0;
23470 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23471 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
23472 }
23473 pud_p += pud_index(address);
23474 pud = *pud_p;
23475
23476 if (pud)
23477 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23478 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
23479 else {
23480 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23481 reset_early_page_tables();
23482 @@ -98,7 +98,7 @@ again:
23483 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
23484 for (i = 0; i < PTRS_PER_PMD; i++)
23485 pmd_p[i] = 0;
23486 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23487 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
23488 }
23489 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
23490 pmd_p[pmd_index(address)] = pmd;
23491 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
23492 if (console_loglevel == 10)
23493 early_printk("Kernel alive\n");
23494
23495 - clear_page(init_level4_pgt);
23496 /* set init_level4_pgt kernel high mapping*/
23497 init_level4_pgt[511] = early_level4_pgt[511];
23498
23499 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
23500 index 81ba276..30c5411 100644
23501 --- a/arch/x86/kernel/head_32.S
23502 +++ b/arch/x86/kernel/head_32.S
23503 @@ -26,6 +26,12 @@
23504 /* Physical address */
23505 #define pa(X) ((X) - __PAGE_OFFSET)
23506
23507 +#ifdef CONFIG_PAX_KERNEXEC
23508 +#define ta(X) (X)
23509 +#else
23510 +#define ta(X) ((X) - __PAGE_OFFSET)
23511 +#endif
23512 +
23513 /*
23514 * References to members of the new_cpu_data structure.
23515 */
23516 @@ -55,11 +61,7 @@
23517 * and small than max_low_pfn, otherwise will waste some page table entries
23518 */
23519
23520 -#if PTRS_PER_PMD > 1
23521 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
23522 -#else
23523 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
23524 -#endif
23525 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
23526
23527 /* Number of possible pages in the lowmem region */
23528 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
23529 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
23530 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23531
23532 /*
23533 + * Real beginning of normal "text" segment
23534 + */
23535 +ENTRY(stext)
23536 +ENTRY(_stext)
23537 +
23538 +/*
23539 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
23540 * %esi points to the real-mode code as a 32-bit pointer.
23541 * CS and DS must be 4 GB flat segments, but we don't depend on
23542 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23543 * can.
23544 */
23545 __HEAD
23546 +
23547 +#ifdef CONFIG_PAX_KERNEXEC
23548 + jmp startup_32
23549 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
23550 +.fill PAGE_SIZE-5,1,0xcc
23551 +#endif
23552 +
23553 ENTRY(startup_32)
23554 movl pa(stack_start),%ecx
23555
23556 @@ -106,6 +121,59 @@ ENTRY(startup_32)
23557 2:
23558 leal -__PAGE_OFFSET(%ecx),%esp
23559
23560 +#ifdef CONFIG_SMP
23561 + movl $pa(cpu_gdt_table),%edi
23562 + movl $__per_cpu_load,%eax
23563 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
23564 + rorl $16,%eax
23565 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
23566 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
23567 + movl $__per_cpu_end - 1,%eax
23568 + subl $__per_cpu_start,%eax
23569 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
23570 +#endif
23571 +
23572 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23573 + movl $NR_CPUS,%ecx
23574 + movl $pa(cpu_gdt_table),%edi
23575 +1:
23576 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
23577 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
23578 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
23579 + addl $PAGE_SIZE_asm,%edi
23580 + loop 1b
23581 +#endif
23582 +
23583 +#ifdef CONFIG_PAX_KERNEXEC
23584 + movl $pa(boot_gdt),%edi
23585 + movl $__LOAD_PHYSICAL_ADDR,%eax
23586 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
23587 + rorl $16,%eax
23588 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
23589 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
23590 + rorl $16,%eax
23591 +
23592 + ljmp $(__BOOT_CS),$1f
23593 +1:
23594 +
23595 + movl $NR_CPUS,%ecx
23596 + movl $pa(cpu_gdt_table),%edi
23597 + addl $__PAGE_OFFSET,%eax
23598 +1:
23599 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
23600 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
23601 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
23602 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
23603 + rorl $16,%eax
23604 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
23605 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
23606 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
23607 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
23608 + rorl $16,%eax
23609 + addl $PAGE_SIZE_asm,%edi
23610 + loop 1b
23611 +#endif
23612 +
23613 /*
23614 * Clear BSS first so that there are no surprises...
23615 */
23616 @@ -201,8 +269,11 @@ ENTRY(startup_32)
23617 movl %eax, pa(max_pfn_mapped)
23618
23619 /* Do early initialization of the fixmap area */
23620 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23621 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
23622 +#ifdef CONFIG_COMPAT_VDSO
23623 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
23624 +#else
23625 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
23626 +#endif
23627 #else /* Not PAE */
23628
23629 page_pde_offset = (__PAGE_OFFSET >> 20);
23630 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23631 movl %eax, pa(max_pfn_mapped)
23632
23633 /* Do early initialization of the fixmap area */
23634 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23635 - movl %eax,pa(initial_page_table+0xffc)
23636 +#ifdef CONFIG_COMPAT_VDSO
23637 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
23638 +#else
23639 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
23640 +#endif
23641 #endif
23642
23643 #ifdef CONFIG_PARAVIRT
23644 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23645 cmpl $num_subarch_entries, %eax
23646 jae bad_subarch
23647
23648 - movl pa(subarch_entries)(,%eax,4), %eax
23649 - subl $__PAGE_OFFSET, %eax
23650 - jmp *%eax
23651 + jmp *pa(subarch_entries)(,%eax,4)
23652
23653 bad_subarch:
23654 WEAK(lguest_entry)
23655 @@ -261,10 +333,10 @@ WEAK(xen_entry)
23656 __INITDATA
23657
23658 subarch_entries:
23659 - .long default_entry /* normal x86/PC */
23660 - .long lguest_entry /* lguest hypervisor */
23661 - .long xen_entry /* Xen hypervisor */
23662 - .long default_entry /* Moorestown MID */
23663 + .long ta(default_entry) /* normal x86/PC */
23664 + .long ta(lguest_entry) /* lguest hypervisor */
23665 + .long ta(xen_entry) /* Xen hypervisor */
23666 + .long ta(default_entry) /* Moorestown MID */
23667 num_subarch_entries = (. - subarch_entries) / 4
23668 .previous
23669 #else
23670 @@ -354,6 +426,7 @@ default_entry:
23671 movl pa(mmu_cr4_features),%eax
23672 movl %eax,%cr4
23673
23674 +#ifdef CONFIG_X86_PAE
23675 testb $X86_CR4_PAE, %al # check if PAE is enabled
23676 jz enable_paging
23677
23678 @@ -382,6 +455,9 @@ default_entry:
23679 /* Make changes effective */
23680 wrmsr
23681
23682 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
23683 +#endif
23684 +
23685 enable_paging:
23686
23687 /*
23688 @@ -449,14 +525,20 @@ is486:
23689 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
23690 movl %eax,%ss # after changing gdt.
23691
23692 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
23693 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
23694 movl %eax,%ds
23695 movl %eax,%es
23696
23697 movl $(__KERNEL_PERCPU), %eax
23698 movl %eax,%fs # set this cpu's percpu
23699
23700 +#ifdef CONFIG_CC_STACKPROTECTOR
23701 movl $(__KERNEL_STACK_CANARY),%eax
23702 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
23703 + movl $(__USER_DS),%eax
23704 +#else
23705 + xorl %eax,%eax
23706 +#endif
23707 movl %eax,%gs
23708
23709 xorl %eax,%eax # Clear LDT
23710 @@ -512,8 +594,11 @@ setup_once:
23711 * relocation. Manually set base address in stack canary
23712 * segment descriptor.
23713 */
23714 - movl $gdt_page,%eax
23715 + movl $cpu_gdt_table,%eax
23716 movl $stack_canary,%ecx
23717 +#ifdef CONFIG_SMP
23718 + addl $__per_cpu_load,%ecx
23719 +#endif
23720 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
23721 shrl $16, %ecx
23722 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
23723 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
23724 /* This is global to keep gas from relaxing the jumps */
23725 ENTRY(early_idt_handler)
23726 cld
23727 - cmpl $2,%ss:early_recursion_flag
23728 + cmpl $1,%ss:early_recursion_flag
23729 je hlt_loop
23730 incl %ss:early_recursion_flag
23731
23732 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
23733 pushl (20+6*4)(%esp) /* trapno */
23734 pushl $fault_msg
23735 call printk
23736 -#endif
23737 call dump_stack
23738 +#endif
23739 hlt_loop:
23740 hlt
23741 jmp hlt_loop
23742 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
23743 /* This is the default interrupt "handler" :-) */
23744 ALIGN
23745 ignore_int:
23746 - cld
23747 #ifdef CONFIG_PRINTK
23748 + cmpl $2,%ss:early_recursion_flag
23749 + je hlt_loop
23750 + incl %ss:early_recursion_flag
23751 + cld
23752 pushl %eax
23753 pushl %ecx
23754 pushl %edx
23755 @@ -612,9 +700,6 @@ ignore_int:
23756 movl $(__KERNEL_DS),%eax
23757 movl %eax,%ds
23758 movl %eax,%es
23759 - cmpl $2,early_recursion_flag
23760 - je hlt_loop
23761 - incl early_recursion_flag
23762 pushl 16(%esp)
23763 pushl 24(%esp)
23764 pushl 32(%esp)
23765 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
23766 /*
23767 * BSS section
23768 */
23769 -__PAGE_ALIGNED_BSS
23770 - .align PAGE_SIZE
23771 #ifdef CONFIG_X86_PAE
23772 +.section .initial_pg_pmd,"a",@progbits
23773 initial_pg_pmd:
23774 .fill 1024*KPMDS,4,0
23775 #else
23776 +.section .initial_page_table,"a",@progbits
23777 ENTRY(initial_page_table)
23778 .fill 1024,4,0
23779 #endif
23780 +.section .initial_pg_fixmap,"a",@progbits
23781 initial_pg_fixmap:
23782 .fill 1024,4,0
23783 +.section .empty_zero_page,"a",@progbits
23784 ENTRY(empty_zero_page)
23785 .fill 4096,1,0
23786 +.section .swapper_pg_dir,"a",@progbits
23787 ENTRY(swapper_pg_dir)
23788 +#ifdef CONFIG_X86_PAE
23789 + .fill 4,8,0
23790 +#else
23791 .fill 1024,4,0
23792 +#endif
23793
23794 /*
23795 * This starts the data section.
23796 */
23797 #ifdef CONFIG_X86_PAE
23798 -__PAGE_ALIGNED_DATA
23799 - /* Page-aligned for the benefit of paravirt? */
23800 - .align PAGE_SIZE
23801 +.section .initial_page_table,"a",@progbits
23802 ENTRY(initial_page_table)
23803 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
23804 # if KPMDS == 3
23805 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
23806 # error "Kernel PMDs should be 1, 2 or 3"
23807 # endif
23808 .align PAGE_SIZE /* needs to be page-sized too */
23809 +
23810 +#ifdef CONFIG_PAX_PER_CPU_PGD
23811 +ENTRY(cpu_pgd)
23812 + .rept 2*NR_CPUS
23813 + .fill 4,8,0
23814 + .endr
23815 +#endif
23816 +
23817 #endif
23818
23819 .data
23820 .balign 4
23821 ENTRY(stack_start)
23822 - .long init_thread_union+THREAD_SIZE
23823 + .long init_thread_union+THREAD_SIZE-8
23824
23825 __INITRODATA
23826 int_msg:
23827 @@ -722,7 +820,7 @@ fault_msg:
23828 * segment size, and 32-bit linear address value:
23829 */
23830
23831 - .data
23832 +.section .rodata,"a",@progbits
23833 .globl boot_gdt_descr
23834 .globl idt_descr
23835
23836 @@ -731,7 +829,7 @@ fault_msg:
23837 .word 0 # 32 bit align gdt_desc.address
23838 boot_gdt_descr:
23839 .word __BOOT_DS+7
23840 - .long boot_gdt - __PAGE_OFFSET
23841 + .long pa(boot_gdt)
23842
23843 .word 0 # 32-bit align idt_desc.address
23844 idt_descr:
23845 @@ -742,7 +840,7 @@ idt_descr:
23846 .word 0 # 32 bit align gdt_desc.address
23847 ENTRY(early_gdt_descr)
23848 .word GDT_ENTRIES*8-1
23849 - .long gdt_page /* Overwritten for secondary CPUs */
23850 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23851
23852 /*
23853 * The boot_gdt must mirror the equivalent in setup.S and is
23854 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
23855 .align L1_CACHE_BYTES
23856 ENTRY(boot_gdt)
23857 .fill GDT_ENTRY_BOOT_CS,8,0
23858 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23859 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23860 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23861 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23862 +
23863 + .align PAGE_SIZE_asm
23864 +ENTRY(cpu_gdt_table)
23865 + .rept NR_CPUS
23866 + .quad 0x0000000000000000 /* NULL descriptor */
23867 + .quad 0x0000000000000000 /* 0x0b reserved */
23868 + .quad 0x0000000000000000 /* 0x13 reserved */
23869 + .quad 0x0000000000000000 /* 0x1b reserved */
23870 +
23871 +#ifdef CONFIG_PAX_KERNEXEC
23872 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23873 +#else
23874 + .quad 0x0000000000000000 /* 0x20 unused */
23875 +#endif
23876 +
23877 + .quad 0x0000000000000000 /* 0x28 unused */
23878 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23879 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23880 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23881 + .quad 0x0000000000000000 /* 0x4b reserved */
23882 + .quad 0x0000000000000000 /* 0x53 reserved */
23883 + .quad 0x0000000000000000 /* 0x5b reserved */
23884 +
23885 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23886 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23887 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23888 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23889 +
23890 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23891 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23892 +
23893 + /*
23894 + * Segments used for calling PnP BIOS have byte granularity.
23895 + * The code segments and data segments have fixed 64k limits,
23896 + * the transfer segment sizes are set at run time.
23897 + */
23898 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23899 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23900 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23901 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23902 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23903 +
23904 + /*
23905 + * The APM segments have byte granularity and their bases
23906 + * are set at run time. All have 64k limits.
23907 + */
23908 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23909 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23910 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23911 +
23912 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23913 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23914 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23915 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23916 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23917 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23918 +
23919 + /* Be sure this is zeroed to avoid false validations in Xen */
23920 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23921 + .endr
23922 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23923 index e1aabdb..fee4fee 100644
23924 --- a/arch/x86/kernel/head_64.S
23925 +++ b/arch/x86/kernel/head_64.S
23926 @@ -20,6 +20,8 @@
23927 #include <asm/processor-flags.h>
23928 #include <asm/percpu.h>
23929 #include <asm/nops.h>
23930 +#include <asm/cpufeature.h>
23931 +#include <asm/alternative-asm.h>
23932
23933 #ifdef CONFIG_PARAVIRT
23934 #include <asm/asm-offsets.h>
23935 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23936 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23937 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23938 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23939 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23940 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23941 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23942 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23943 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23944 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23945
23946 .text
23947 __HEAD
23948 @@ -89,11 +97,24 @@ startup_64:
23949 * Fixup the physical addresses in the page table
23950 */
23951 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23952 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23953 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23954 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23955 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23956 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23957
23958 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23959 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23960 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23961 +#ifndef CONFIG_XEN
23962 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23963 +#endif
23964 +
23965 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23966 +
23967 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23968 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23969
23970 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23971 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23972
23973 /*
23974 * Set up the identity mapping for the switchover. These
23975 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23976 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23977 1:
23978
23979 - /* Enable PAE mode and PGE */
23980 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23981 + /* Enable PAE mode and PSE/PGE */
23982 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23983 movq %rcx, %cr4
23984
23985 /* Setup early boot stage 4 level pagetables. */
23986 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23987 movl $MSR_EFER, %ecx
23988 rdmsr
23989 btsl $_EFER_SCE, %eax /* Enable System Call */
23990 - btl $20,%edi /* No Execute supported? */
23991 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23992 jnc 1f
23993 btsl $_EFER_NX, %eax
23994 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23995 +#ifndef CONFIG_EFI
23996 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23997 +#endif
23998 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23999 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
24000 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
24001 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
24002 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
24003 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
24004 1: wrmsr /* Make changes effective */
24005
24006 /* Setup cr0 */
24007 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
24008 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
24009 * address given in m16:64.
24010 */
24011 + pax_set_fptr_mask
24012 movq initial_code(%rip),%rax
24013 pushq $0 # fake return address to stop unwinder
24014 pushq $__KERNEL_CS # set correct cs
24015 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
24016 call dump_stack
24017 #ifdef CONFIG_KALLSYMS
24018 leaq early_idt_ripmsg(%rip),%rdi
24019 - movq 40(%rsp),%rsi # %rip again
24020 + movq 88(%rsp),%rsi # %rip again
24021 call __print_symbol
24022 #endif
24023 #endif /* EARLY_PRINTK */
24024 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
24025 early_recursion_flag:
24026 .long 0
24027
24028 + .section .rodata,"a",@progbits
24029 #ifdef CONFIG_EARLY_PRINTK
24030 early_idt_msg:
24031 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
24032 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
24033 NEXT_PAGE(early_dynamic_pgts)
24034 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
24035
24036 - .data
24037 + .section .rodata,"a",@progbits
24038
24039 -#ifndef CONFIG_XEN
24040 NEXT_PAGE(init_level4_pgt)
24041 - .fill 512,8,0
24042 -#else
24043 -NEXT_PAGE(init_level4_pgt)
24044 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
24045 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
24046 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
24047 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
24048 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
24049 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
24050 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
24051 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
24052 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
24053 .org init_level4_pgt + L4_START_KERNEL*8, 0
24054 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
24055 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
24056
24057 +#ifdef CONFIG_PAX_PER_CPU_PGD
24058 +NEXT_PAGE(cpu_pgd)
24059 + .rept 2*NR_CPUS
24060 + .fill 512,8,0
24061 + .endr
24062 +#endif
24063 +
24064 NEXT_PAGE(level3_ident_pgt)
24065 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
24066 +#ifdef CONFIG_XEN
24067 .fill 511, 8, 0
24068 +#else
24069 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
24070 + .fill 510,8,0
24071 +#endif
24072 +
24073 +NEXT_PAGE(level3_vmalloc_start_pgt)
24074 + .fill 512,8,0
24075 +
24076 +NEXT_PAGE(level3_vmalloc_end_pgt)
24077 + .fill 512,8,0
24078 +
24079 +NEXT_PAGE(level3_vmemmap_pgt)
24080 + .fill L3_VMEMMAP_START,8,0
24081 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
24082 +
24083 NEXT_PAGE(level2_ident_pgt)
24084 - /* Since I easily can, map the first 1G.
24085 + /* Since I easily can, map the first 2G.
24086 * Don't set NX because code runs from these pages.
24087 */
24088 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
24089 -#endif
24090 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
24091
24092 NEXT_PAGE(level3_kernel_pgt)
24093 .fill L3_START_KERNEL,8,0
24094 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
24095 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
24096 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
24097
24098 +NEXT_PAGE(level2_vmemmap_pgt)
24099 + .fill 512,8,0
24100 +
24101 NEXT_PAGE(level2_kernel_pgt)
24102 /*
24103 * 512 MB kernel mapping. We spend a full page on this pagetable
24104 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
24105 NEXT_PAGE(level2_fixmap_pgt)
24106 .fill 506,8,0
24107 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
24108 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
24109 - .fill 5,8,0
24110 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
24111 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
24112 + .fill 4,8,0
24113
24114 NEXT_PAGE(level1_fixmap_pgt)
24115 .fill 512,8,0
24116
24117 +NEXT_PAGE(level1_vsyscall_pgt)
24118 + .fill 512,8,0
24119 +
24120 #undef PMDS
24121
24122 - .data
24123 + .align PAGE_SIZE
24124 +ENTRY(cpu_gdt_table)
24125 + .rept NR_CPUS
24126 + .quad 0x0000000000000000 /* NULL descriptor */
24127 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
24128 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
24129 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
24130 + .quad 0x00cffb000000ffff /* __USER32_CS */
24131 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
24132 + .quad 0x00affb000000ffff /* __USER_CS */
24133 +
24134 +#ifdef CONFIG_PAX_KERNEXEC
24135 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
24136 +#else
24137 + .quad 0x0 /* unused */
24138 +#endif
24139 +
24140 + .quad 0,0 /* TSS */
24141 + .quad 0,0 /* LDT */
24142 + .quad 0,0,0 /* three TLS descriptors */
24143 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
24144 + /* asm/segment.h:GDT_ENTRIES must match this */
24145 +
24146 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24147 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
24148 +#else
24149 + .quad 0x0 /* unused */
24150 +#endif
24151 +
24152 + /* zero the remaining page */
24153 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
24154 + .endr
24155 +
24156 .align 16
24157 .globl early_gdt_descr
24158 early_gdt_descr:
24159 .word GDT_ENTRIES*8-1
24160 early_gdt_descr_base:
24161 - .quad INIT_PER_CPU_VAR(gdt_page)
24162 + .quad cpu_gdt_table
24163
24164 ENTRY(phys_base)
24165 /* This must match the first entry in level2_kernel_pgt */
24166 .quad 0x0000000000000000
24167
24168 #include "../../x86/xen/xen-head.S"
24169 -
24170 - __PAGE_ALIGNED_BSS
24171 +
24172 + .section .rodata,"a",@progbits
24173 NEXT_PAGE(empty_zero_page)
24174 .skip PAGE_SIZE
24175 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
24176 index 0fa6912..b37438b 100644
24177 --- a/arch/x86/kernel/i386_ksyms_32.c
24178 +++ b/arch/x86/kernel/i386_ksyms_32.c
24179 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
24180 EXPORT_SYMBOL(cmpxchg8b_emu);
24181 #endif
24182
24183 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
24184 +
24185 /* Networking helper routines. */
24186 EXPORT_SYMBOL(csum_partial_copy_generic);
24187 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
24188 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
24189
24190 EXPORT_SYMBOL(__get_user_1);
24191 EXPORT_SYMBOL(__get_user_2);
24192 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
24193
24194 EXPORT_SYMBOL(csum_partial);
24195 EXPORT_SYMBOL(empty_zero_page);
24196 +
24197 +#ifdef CONFIG_PAX_KERNEXEC
24198 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
24199 +#endif
24200 +
24201 +#ifdef CONFIG_PAX_PER_CPU_PGD
24202 +EXPORT_SYMBOL(cpu_pgd);
24203 +#endif
24204 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
24205 index 5d576ab..1403a03 100644
24206 --- a/arch/x86/kernel/i387.c
24207 +++ b/arch/x86/kernel/i387.c
24208 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
24209 static inline bool interrupted_user_mode(void)
24210 {
24211 struct pt_regs *regs = get_irq_regs();
24212 - return regs && user_mode_vm(regs);
24213 + return regs && user_mode(regs);
24214 }
24215
24216 /*
24217 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
24218 index 9a5c460..84868423 100644
24219 --- a/arch/x86/kernel/i8259.c
24220 +++ b/arch/x86/kernel/i8259.c
24221 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
24222 static void make_8259A_irq(unsigned int irq)
24223 {
24224 disable_irq_nosync(irq);
24225 - io_apic_irqs &= ~(1<<irq);
24226 + io_apic_irqs &= ~(1UL<<irq);
24227 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
24228 i8259A_chip.name);
24229 enable_irq(irq);
24230 @@ -209,7 +209,7 @@ spurious_8259A_irq:
24231 "spurious 8259A interrupt: IRQ%d.\n", irq);
24232 spurious_irq_mask |= irqmask;
24233 }
24234 - atomic_inc(&irq_err_count);
24235 + atomic_inc_unchecked(&irq_err_count);
24236 /*
24237 * Theoretically we do not have to handle this IRQ,
24238 * but in Linux this does not cause problems and is
24239 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
24240 /* (slave's support for AEOI in flat mode is to be investigated) */
24241 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
24242
24243 + pax_open_kernel();
24244 if (auto_eoi)
24245 /*
24246 * In AEOI mode we just have to mask the interrupt
24247 * when acking.
24248 */
24249 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
24250 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
24251 else
24252 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24253 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24254 + pax_close_kernel();
24255
24256 udelay(100); /* wait for 8259A to initialize */
24257
24258 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
24259 index a979b5b..1d6db75 100644
24260 --- a/arch/x86/kernel/io_delay.c
24261 +++ b/arch/x86/kernel/io_delay.c
24262 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
24263 * Quirk table for systems that misbehave (lock up, etc.) if port
24264 * 0x80 is used:
24265 */
24266 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
24267 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
24268 {
24269 .callback = dmi_io_delay_0xed_port,
24270 .ident = "Compaq Presario V6000",
24271 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
24272 index 4ddaf66..49d5c18 100644
24273 --- a/arch/x86/kernel/ioport.c
24274 +++ b/arch/x86/kernel/ioport.c
24275 @@ -6,6 +6,7 @@
24276 #include <linux/sched.h>
24277 #include <linux/kernel.h>
24278 #include <linux/capability.h>
24279 +#include <linux/security.h>
24280 #include <linux/errno.h>
24281 #include <linux/types.h>
24282 #include <linux/ioport.h>
24283 @@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24284 return -EINVAL;
24285 if (turn_on && !capable(CAP_SYS_RAWIO))
24286 return -EPERM;
24287 +#ifdef CONFIG_GRKERNSEC_IO
24288 + if (turn_on && grsec_disable_privio) {
24289 + gr_handle_ioperm();
24290 + return -ENODEV;
24291 + }
24292 +#endif
24293
24294 /*
24295 * If it's the first ioperm() call in this thread's lifetime, set the
24296 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24297 * because the ->io_bitmap_max value must match the bitmap
24298 * contents:
24299 */
24300 - tss = &per_cpu(init_tss, get_cpu());
24301 + tss = init_tss + get_cpu();
24302
24303 if (turn_on)
24304 bitmap_clear(t->io_bitmap_ptr, from, num);
24305 @@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
24306 if (level > old) {
24307 if (!capable(CAP_SYS_RAWIO))
24308 return -EPERM;
24309 +#ifdef CONFIG_GRKERNSEC_IO
24310 + if (grsec_disable_privio) {
24311 + gr_handle_iopl();
24312 + return -ENODEV;
24313 + }
24314 +#endif
24315 }
24316 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
24317 t->iopl = level << 12;
24318 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
24319 index 22d0687..e07b2a5 100644
24320 --- a/arch/x86/kernel/irq.c
24321 +++ b/arch/x86/kernel/irq.c
24322 @@ -21,7 +21,7 @@
24323 #define CREATE_TRACE_POINTS
24324 #include <asm/trace/irq_vectors.h>
24325
24326 -atomic_t irq_err_count;
24327 +atomic_unchecked_t irq_err_count;
24328
24329 /* Function pointer for generic interrupt vector handling */
24330 void (*x86_platform_ipi_callback)(void) = NULL;
24331 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
24332 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
24333 seq_printf(p, " Machine check polls\n");
24334 #endif
24335 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
24336 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
24337 #if defined(CONFIG_X86_IO_APIC)
24338 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
24339 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
24340 #endif
24341 return 0;
24342 }
24343 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
24344
24345 u64 arch_irq_stat(void)
24346 {
24347 - u64 sum = atomic_read(&irq_err_count);
24348 + u64 sum = atomic_read_unchecked(&irq_err_count);
24349 return sum;
24350 }
24351
24352 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
24353 index 4186755..18d6a9e 100644
24354 --- a/arch/x86/kernel/irq_32.c
24355 +++ b/arch/x86/kernel/irq_32.c
24356 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
24357 __asm__ __volatile__("andl %%esp,%0" :
24358 "=r" (sp) : "0" (THREAD_SIZE - 1));
24359
24360 - return sp < (sizeof(struct thread_info) + STACK_WARN);
24361 + return sp < STACK_WARN;
24362 }
24363
24364 static void print_stack_overflow(void)
24365 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
24366 * per-CPU IRQ handling contexts (thread information and stack)
24367 */
24368 union irq_ctx {
24369 - struct thread_info tinfo;
24370 - u32 stack[THREAD_SIZE/sizeof(u32)];
24371 + unsigned long previous_esp;
24372 + u32 stack[THREAD_SIZE/sizeof(u32)];
24373 } __attribute__((aligned(THREAD_SIZE)));
24374
24375 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
24376 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
24377 static inline int
24378 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24379 {
24380 - union irq_ctx *curctx, *irqctx;
24381 + union irq_ctx *irqctx;
24382 u32 *isp, arg1, arg2;
24383
24384 - curctx = (union irq_ctx *) current_thread_info();
24385 irqctx = __this_cpu_read(hardirq_ctx);
24386
24387 /*
24388 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24389 * handler) we can't do that and just have to keep using the
24390 * current stack (which is the irq stack already after all)
24391 */
24392 - if (unlikely(curctx == irqctx))
24393 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
24394 return 0;
24395
24396 /* build the stack frame on the IRQ stack */
24397 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24398 - irqctx->tinfo.task = curctx->tinfo.task;
24399 - irqctx->tinfo.previous_esp = current_stack_pointer;
24400 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24401 + irqctx->previous_esp = current_stack_pointer;
24402
24403 - /* Copy the preempt_count so that the [soft]irq checks work. */
24404 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
24405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24406 + __set_fs(MAKE_MM_SEG(0));
24407 +#endif
24408
24409 if (unlikely(overflow))
24410 call_on_stack(print_stack_overflow, isp);
24411 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24412 : "0" (irq), "1" (desc), "2" (isp),
24413 "D" (desc->handle_irq)
24414 : "memory", "cc", "ecx");
24415 +
24416 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24417 + __set_fs(current_thread_info()->addr_limit);
24418 +#endif
24419 +
24420 return 1;
24421 }
24422
24423 @@ -121,29 +125,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24424 */
24425 void irq_ctx_init(int cpu)
24426 {
24427 - union irq_ctx *irqctx;
24428 -
24429 if (per_cpu(hardirq_ctx, cpu))
24430 return;
24431
24432 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24433 - THREADINFO_GFP,
24434 - THREAD_SIZE_ORDER));
24435 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24436 - irqctx->tinfo.cpu = cpu;
24437 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
24438 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24439 -
24440 - per_cpu(hardirq_ctx, cpu) = irqctx;
24441 -
24442 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24443 - THREADINFO_GFP,
24444 - THREAD_SIZE_ORDER));
24445 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24446 - irqctx->tinfo.cpu = cpu;
24447 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24448 -
24449 - per_cpu(softirq_ctx, cpu) = irqctx;
24450 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24451 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24452
24453 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
24454 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
24455 @@ -152,7 +138,6 @@ void irq_ctx_init(int cpu)
24456 asmlinkage void do_softirq(void)
24457 {
24458 unsigned long flags;
24459 - struct thread_info *curctx;
24460 union irq_ctx *irqctx;
24461 u32 *isp;
24462
24463 @@ -162,15 +147,22 @@ asmlinkage void do_softirq(void)
24464 local_irq_save(flags);
24465
24466 if (local_softirq_pending()) {
24467 - curctx = current_thread_info();
24468 irqctx = __this_cpu_read(softirq_ctx);
24469 - irqctx->tinfo.task = curctx->task;
24470 - irqctx->tinfo.previous_esp = current_stack_pointer;
24471 + irqctx->previous_esp = current_stack_pointer;
24472
24473 /* build the stack frame on the softirq stack */
24474 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24475 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24476 +
24477 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24478 + __set_fs(MAKE_MM_SEG(0));
24479 +#endif
24480
24481 call_on_stack(__do_softirq, isp);
24482 +
24483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24484 + __set_fs(current_thread_info()->addr_limit);
24485 +#endif
24486 +
24487 /*
24488 * Shouldn't happen, we returned above if in_interrupt():
24489 */
24490 @@ -191,7 +183,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
24491 if (unlikely(!desc))
24492 return false;
24493
24494 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24495 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24496 if (unlikely(overflow))
24497 print_stack_overflow();
24498 desc->handle_irq(irq, desc);
24499 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
24500 index d04d3ec..ea4b374 100644
24501 --- a/arch/x86/kernel/irq_64.c
24502 +++ b/arch/x86/kernel/irq_64.c
24503 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
24504 u64 estack_top, estack_bottom;
24505 u64 curbase = (u64)task_stack_page(current);
24506
24507 - if (user_mode_vm(regs))
24508 + if (user_mode(regs))
24509 return;
24510
24511 if (regs->sp >= curbase + sizeof(struct thread_info) +
24512 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
24513 index ee11b7d..4df4d0c 100644
24514 --- a/arch/x86/kernel/jump_label.c
24515 +++ b/arch/x86/kernel/jump_label.c
24516 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
24517 * We are enabling this jump label. If it is not a nop
24518 * then something must have gone wrong.
24519 */
24520 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
24521 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
24522 bug_at((void *)entry->code, __LINE__);
24523
24524 code.jump = 0xe9;
24525 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
24526 */
24527 if (init) {
24528 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
24529 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
24530 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
24531 bug_at((void *)entry->code, __LINE__);
24532 } else {
24533 code.jump = 0xe9;
24534 code.offset = entry->target -
24535 (entry->code + JUMP_LABEL_NOP_SIZE);
24536 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
24537 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
24538 bug_at((void *)entry->code, __LINE__);
24539 }
24540 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
24541 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
24542 index 836f832..a8bda67 100644
24543 --- a/arch/x86/kernel/kgdb.c
24544 +++ b/arch/x86/kernel/kgdb.c
24545 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
24546 #ifdef CONFIG_X86_32
24547 switch (regno) {
24548 case GDB_SS:
24549 - if (!user_mode_vm(regs))
24550 + if (!user_mode(regs))
24551 *(unsigned long *)mem = __KERNEL_DS;
24552 break;
24553 case GDB_SP:
24554 - if (!user_mode_vm(regs))
24555 + if (!user_mode(regs))
24556 *(unsigned long *)mem = kernel_stack_pointer(regs);
24557 break;
24558 case GDB_GS:
24559 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
24560 bp->attr.bp_addr = breakinfo[breakno].addr;
24561 bp->attr.bp_len = breakinfo[breakno].len;
24562 bp->attr.bp_type = breakinfo[breakno].type;
24563 - info->address = breakinfo[breakno].addr;
24564 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
24565 + info->address = ktla_ktva(breakinfo[breakno].addr);
24566 + else
24567 + info->address = breakinfo[breakno].addr;
24568 info->len = breakinfo[breakno].len;
24569 info->type = breakinfo[breakno].type;
24570 val = arch_install_hw_breakpoint(bp);
24571 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
24572 case 'k':
24573 /* clear the trace bit */
24574 linux_regs->flags &= ~X86_EFLAGS_TF;
24575 - atomic_set(&kgdb_cpu_doing_single_step, -1);
24576 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
24577
24578 /* set the trace bit if we're stepping */
24579 if (remcomInBuffer[0] == 's') {
24580 linux_regs->flags |= X86_EFLAGS_TF;
24581 - atomic_set(&kgdb_cpu_doing_single_step,
24582 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
24583 raw_smp_processor_id());
24584 }
24585
24586 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
24587
24588 switch (cmd) {
24589 case DIE_DEBUG:
24590 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
24591 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
24592 if (user_mode(regs))
24593 return single_step_cont(regs, args);
24594 break;
24595 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24596 #endif /* CONFIG_DEBUG_RODATA */
24597
24598 bpt->type = BP_BREAKPOINT;
24599 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
24600 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
24601 BREAK_INSTR_SIZE);
24602 if (err)
24603 return err;
24604 - err = probe_kernel_write((char *)bpt->bpt_addr,
24605 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24606 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
24607 #ifdef CONFIG_DEBUG_RODATA
24608 if (!err)
24609 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24610 return -EBUSY;
24611 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
24612 BREAK_INSTR_SIZE);
24613 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24614 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24615 if (err)
24616 return err;
24617 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
24618 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
24619 if (mutex_is_locked(&text_mutex))
24620 goto knl_write;
24621 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
24622 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24623 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24624 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
24625 goto knl_write;
24626 return err;
24627 knl_write:
24628 #endif /* CONFIG_DEBUG_RODATA */
24629 - return probe_kernel_write((char *)bpt->bpt_addr,
24630 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24631 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
24632 }
24633
24634 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
24635 index 79a3f96..6ba030a 100644
24636 --- a/arch/x86/kernel/kprobes/core.c
24637 +++ b/arch/x86/kernel/kprobes/core.c
24638 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
24639 s32 raddr;
24640 } __packed *insn;
24641
24642 - insn = (struct __arch_relative_insn *)from;
24643 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
24644 +
24645 + pax_open_kernel();
24646 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
24647 insn->op = op;
24648 + pax_close_kernel();
24649 }
24650
24651 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
24652 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
24653 kprobe_opcode_t opcode;
24654 kprobe_opcode_t *orig_opcodes = opcodes;
24655
24656 - if (search_exception_tables((unsigned long)opcodes))
24657 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
24658 return 0; /* Page fault may occur on this address. */
24659
24660 retry:
24661 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
24662 * for the first byte, we can recover the original instruction
24663 * from it and kp->opcode.
24664 */
24665 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24666 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24667 buf[0] = kp->opcode;
24668 - return (unsigned long)buf;
24669 + return ktva_ktla((unsigned long)buf);
24670 }
24671
24672 /*
24673 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24674 /* Another subsystem puts a breakpoint, failed to recover */
24675 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
24676 return 0;
24677 + pax_open_kernel();
24678 memcpy(dest, insn.kaddr, insn.length);
24679 + pax_close_kernel();
24680
24681 #ifdef CONFIG_X86_64
24682 if (insn_rip_relative(&insn)) {
24683 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24684 return 0;
24685 }
24686 disp = (u8 *) dest + insn_offset_displacement(&insn);
24687 + pax_open_kernel();
24688 *(s32 *) disp = (s32) newdisp;
24689 + pax_close_kernel();
24690 }
24691 #endif
24692 return insn.length;
24693 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24694 * nor set current_kprobe, because it doesn't use single
24695 * stepping.
24696 */
24697 - regs->ip = (unsigned long)p->ainsn.insn;
24698 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24699 preempt_enable_no_resched();
24700 return;
24701 }
24702 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24703 regs->flags &= ~X86_EFLAGS_IF;
24704 /* single step inline if the instruction is an int3 */
24705 if (p->opcode == BREAKPOINT_INSTRUCTION)
24706 - regs->ip = (unsigned long)p->addr;
24707 + regs->ip = ktla_ktva((unsigned long)p->addr);
24708 else
24709 - regs->ip = (unsigned long)p->ainsn.insn;
24710 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24711 }
24712
24713 /*
24714 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
24715 setup_singlestep(p, regs, kcb, 0);
24716 return 1;
24717 }
24718 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
24719 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
24720 /*
24721 * The breakpoint instruction was removed right
24722 * after we hit it. Another cpu has removed
24723 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
24724 " movq %rax, 152(%rsp)\n"
24725 RESTORE_REGS_STRING
24726 " popfq\n"
24727 +#ifdef KERNEXEC_PLUGIN
24728 + " btsq $63,(%rsp)\n"
24729 +#endif
24730 #else
24731 " pushf\n"
24732 SAVE_REGS_STRING
24733 @@ -779,7 +789,7 @@ static void __kprobes
24734 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
24735 {
24736 unsigned long *tos = stack_addr(regs);
24737 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
24738 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
24739 unsigned long orig_ip = (unsigned long)p->addr;
24740 kprobe_opcode_t *insn = p->ainsn.insn;
24741
24742 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
24743 struct die_args *args = data;
24744 int ret = NOTIFY_DONE;
24745
24746 - if (args->regs && user_mode_vm(args->regs))
24747 + if (args->regs && user_mode(args->regs))
24748 return ret;
24749
24750 switch (val) {
24751 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
24752 index 898160b..758cde8 100644
24753 --- a/arch/x86/kernel/kprobes/opt.c
24754 +++ b/arch/x86/kernel/kprobes/opt.c
24755 @@ -79,6 +79,7 @@ found:
24756 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
24757 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
24758 {
24759 + pax_open_kernel();
24760 #ifdef CONFIG_X86_64
24761 *addr++ = 0x48;
24762 *addr++ = 0xbf;
24763 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
24764 *addr++ = 0xb8;
24765 #endif
24766 *(unsigned long *)addr = val;
24767 + pax_close_kernel();
24768 }
24769
24770 asm (
24771 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24772 * Verify if the address gap is in 2GB range, because this uses
24773 * a relative jump.
24774 */
24775 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
24776 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
24777 if (abs(rel) > 0x7fffffff)
24778 return -ERANGE;
24779
24780 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24781 op->optinsn.size = ret;
24782
24783 /* Copy arch-dep-instance from template */
24784 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
24785 + pax_open_kernel();
24786 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
24787 + pax_close_kernel();
24788
24789 /* Set probe information */
24790 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
24791
24792 /* Set probe function call */
24793 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
24794 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
24795
24796 /* Set returning jmp instruction at the tail of out-of-line buffer */
24797 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
24798 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
24799 (u8 *)op->kp.addr + op->optinsn.size);
24800
24801 flush_icache_range((unsigned long) buf,
24802 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
24803 WARN_ON(kprobe_disabled(&op->kp));
24804
24805 /* Backup instructions which will be replaced by jump address */
24806 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
24807 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
24808 RELATIVE_ADDR_SIZE);
24809
24810 insn_buf[0] = RELATIVEJUMP_OPCODE;
24811 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
24812 /* This kprobe is really able to run optimized path. */
24813 op = container_of(p, struct optimized_kprobe, kp);
24814 /* Detour through copied instructions */
24815 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
24816 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
24817 if (!reenter)
24818 reset_current_kprobe();
24819 preempt_enable_no_resched();
24820 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
24821 index ebc9873..1b9724b 100644
24822 --- a/arch/x86/kernel/ldt.c
24823 +++ b/arch/x86/kernel/ldt.c
24824 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
24825 if (reload) {
24826 #ifdef CONFIG_SMP
24827 preempt_disable();
24828 - load_LDT(pc);
24829 + load_LDT_nolock(pc);
24830 if (!cpumask_equal(mm_cpumask(current->mm),
24831 cpumask_of(smp_processor_id())))
24832 smp_call_function(flush_ldt, current->mm, 1);
24833 preempt_enable();
24834 #else
24835 - load_LDT(pc);
24836 + load_LDT_nolock(pc);
24837 #endif
24838 }
24839 if (oldsize) {
24840 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
24841 return err;
24842
24843 for (i = 0; i < old->size; i++)
24844 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
24845 + write_ldt_entry(new->ldt, i, old->ldt + i);
24846 return 0;
24847 }
24848
24849 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24850 retval = copy_ldt(&mm->context, &old_mm->context);
24851 mutex_unlock(&old_mm->context.lock);
24852 }
24853 +
24854 + if (tsk == current) {
24855 + mm->context.vdso = 0;
24856 +
24857 +#ifdef CONFIG_X86_32
24858 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24859 + mm->context.user_cs_base = 0UL;
24860 + mm->context.user_cs_limit = ~0UL;
24861 +
24862 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24863 + cpus_clear(mm->context.cpu_user_cs_mask);
24864 +#endif
24865 +
24866 +#endif
24867 +#endif
24868 +
24869 + }
24870 +
24871 return retval;
24872 }
24873
24874 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24875 }
24876 }
24877
24878 +#ifdef CONFIG_PAX_SEGMEXEC
24879 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24880 + error = -EINVAL;
24881 + goto out_unlock;
24882 + }
24883 +#endif
24884 +
24885 fill_ldt(&ldt, &ldt_info);
24886 if (oldmode)
24887 ldt.avl = 0;
24888 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24889 index 5b19e4d..6476a76 100644
24890 --- a/arch/x86/kernel/machine_kexec_32.c
24891 +++ b/arch/x86/kernel/machine_kexec_32.c
24892 @@ -26,7 +26,7 @@
24893 #include <asm/cacheflush.h>
24894 #include <asm/debugreg.h>
24895
24896 -static void set_idt(void *newidt, __u16 limit)
24897 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24898 {
24899 struct desc_ptr curidt;
24900
24901 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24902 }
24903
24904
24905 -static void set_gdt(void *newgdt, __u16 limit)
24906 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24907 {
24908 struct desc_ptr curgdt;
24909
24910 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24911 }
24912
24913 control_page = page_address(image->control_code_page);
24914 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24915 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24916
24917 relocate_kernel_ptr = control_page;
24918 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24919 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24920 index 15c9876..0a43909 100644
24921 --- a/arch/x86/kernel/microcode_core.c
24922 +++ b/arch/x86/kernel/microcode_core.c
24923 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24924 return NOTIFY_OK;
24925 }
24926
24927 -static struct notifier_block __refdata mc_cpu_notifier = {
24928 +static struct notifier_block mc_cpu_notifier = {
24929 .notifier_call = mc_cpu_callback,
24930 };
24931
24932 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24933 index 5fb2ceb..3ae90bb 100644
24934 --- a/arch/x86/kernel/microcode_intel.c
24935 +++ b/arch/x86/kernel/microcode_intel.c
24936 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24937
24938 static int get_ucode_user(void *to, const void *from, size_t n)
24939 {
24940 - return copy_from_user(to, from, n);
24941 + return copy_from_user(to, (const void __force_user *)from, n);
24942 }
24943
24944 static enum ucode_state
24945 request_microcode_user(int cpu, const void __user *buf, size_t size)
24946 {
24947 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24948 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24949 }
24950
24951 static void microcode_fini_cpu(int cpu)
24952 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24953 index 216a4d7..228255a 100644
24954 --- a/arch/x86/kernel/module.c
24955 +++ b/arch/x86/kernel/module.c
24956 @@ -43,15 +43,60 @@ do { \
24957 } while (0)
24958 #endif
24959
24960 -void *module_alloc(unsigned long size)
24961 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24962 {
24963 - if (PAGE_ALIGN(size) > MODULES_LEN)
24964 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24965 return NULL;
24966 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24967 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24968 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24969 -1, __builtin_return_address(0));
24970 }
24971
24972 +void *module_alloc(unsigned long size)
24973 +{
24974 +
24975 +#ifdef CONFIG_PAX_KERNEXEC
24976 + return __module_alloc(size, PAGE_KERNEL);
24977 +#else
24978 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24979 +#endif
24980 +
24981 +}
24982 +
24983 +#ifdef CONFIG_PAX_KERNEXEC
24984 +#ifdef CONFIG_X86_32
24985 +void *module_alloc_exec(unsigned long size)
24986 +{
24987 + struct vm_struct *area;
24988 +
24989 + if (size == 0)
24990 + return NULL;
24991 +
24992 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24993 + return area ? area->addr : NULL;
24994 +}
24995 +EXPORT_SYMBOL(module_alloc_exec);
24996 +
24997 +void module_free_exec(struct module *mod, void *module_region)
24998 +{
24999 + vunmap(module_region);
25000 +}
25001 +EXPORT_SYMBOL(module_free_exec);
25002 +#else
25003 +void module_free_exec(struct module *mod, void *module_region)
25004 +{
25005 + module_free(mod, module_region);
25006 +}
25007 +EXPORT_SYMBOL(module_free_exec);
25008 +
25009 +void *module_alloc_exec(unsigned long size)
25010 +{
25011 + return __module_alloc(size, PAGE_KERNEL_RX);
25012 +}
25013 +EXPORT_SYMBOL(module_alloc_exec);
25014 +#endif
25015 +#endif
25016 +
25017 #ifdef CONFIG_X86_32
25018 int apply_relocate(Elf32_Shdr *sechdrs,
25019 const char *strtab,
25020 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
25021 unsigned int i;
25022 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
25023 Elf32_Sym *sym;
25024 - uint32_t *location;
25025 + uint32_t *plocation, location;
25026
25027 DEBUGP("Applying relocate section %u to %u\n",
25028 relsec, sechdrs[relsec].sh_info);
25029 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
25030 /* This is where to make the change */
25031 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
25032 - + rel[i].r_offset;
25033 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
25034 + location = (uint32_t)plocation;
25035 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
25036 + plocation = ktla_ktva((void *)plocation);
25037 /* This is the symbol it is referring to. Note that all
25038 undefined symbols have been resolved. */
25039 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
25040 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
25041 switch (ELF32_R_TYPE(rel[i].r_info)) {
25042 case R_386_32:
25043 /* We add the value into the location given */
25044 - *location += sym->st_value;
25045 + pax_open_kernel();
25046 + *plocation += sym->st_value;
25047 + pax_close_kernel();
25048 break;
25049 case R_386_PC32:
25050 /* Add the value, subtract its position */
25051 - *location += sym->st_value - (uint32_t)location;
25052 + pax_open_kernel();
25053 + *plocation += sym->st_value - location;
25054 + pax_close_kernel();
25055 break;
25056 default:
25057 pr_err("%s: Unknown relocation: %u\n",
25058 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
25059 case R_X86_64_NONE:
25060 break;
25061 case R_X86_64_64:
25062 + pax_open_kernel();
25063 *(u64 *)loc = val;
25064 + pax_close_kernel();
25065 break;
25066 case R_X86_64_32:
25067 + pax_open_kernel();
25068 *(u32 *)loc = val;
25069 + pax_close_kernel();
25070 if (val != *(u32 *)loc)
25071 goto overflow;
25072 break;
25073 case R_X86_64_32S:
25074 + pax_open_kernel();
25075 *(s32 *)loc = val;
25076 + pax_close_kernel();
25077 if ((s64)val != *(s32 *)loc)
25078 goto overflow;
25079 break;
25080 case R_X86_64_PC32:
25081 val -= (u64)loc;
25082 + pax_open_kernel();
25083 *(u32 *)loc = val;
25084 + pax_close_kernel();
25085 +
25086 #if 0
25087 if ((s64)val != *(s32 *)loc)
25088 goto overflow;
25089 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
25090 index 88458fa..349f7a4 100644
25091 --- a/arch/x86/kernel/msr.c
25092 +++ b/arch/x86/kernel/msr.c
25093 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
25094 return notifier_from_errno(err);
25095 }
25096
25097 -static struct notifier_block __refdata msr_class_cpu_notifier = {
25098 +static struct notifier_block msr_class_cpu_notifier = {
25099 .notifier_call = msr_class_cpu_callback,
25100 };
25101
25102 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
25103 index 6fcb49c..5b3f4ff 100644
25104 --- a/arch/x86/kernel/nmi.c
25105 +++ b/arch/x86/kernel/nmi.c
25106 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
25107 return handled;
25108 }
25109
25110 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25111 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
25112 {
25113 struct nmi_desc *desc = nmi_to_desc(type);
25114 unsigned long flags;
25115 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25116 * event confuses some handlers (kdump uses this flag)
25117 */
25118 if (action->flags & NMI_FLAG_FIRST)
25119 - list_add_rcu(&action->list, &desc->head);
25120 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
25121 else
25122 - list_add_tail_rcu(&action->list, &desc->head);
25123 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
25124
25125 spin_unlock_irqrestore(&desc->lock, flags);
25126 return 0;
25127 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
25128 if (!strcmp(n->name, name)) {
25129 WARN(in_nmi(),
25130 "Trying to free NMI (%s) from NMI context!\n", n->name);
25131 - list_del_rcu(&n->list);
25132 + pax_list_del_rcu((struct list_head *)&n->list);
25133 break;
25134 }
25135 }
25136 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
25137 dotraplinkage notrace __kprobes void
25138 do_nmi(struct pt_regs *regs, long error_code)
25139 {
25140 +
25141 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25142 + if (!user_mode(regs)) {
25143 + unsigned long cs = regs->cs & 0xFFFF;
25144 + unsigned long ip = ktva_ktla(regs->ip);
25145 +
25146 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
25147 + regs->ip = ip;
25148 + }
25149 +#endif
25150 +
25151 nmi_nesting_preprocess(regs);
25152
25153 nmi_enter();
25154 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
25155 index 6d9582e..f746287 100644
25156 --- a/arch/x86/kernel/nmi_selftest.c
25157 +++ b/arch/x86/kernel/nmi_selftest.c
25158 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
25159 {
25160 /* trap all the unknown NMIs we may generate */
25161 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
25162 - __initdata);
25163 + __initconst);
25164 }
25165
25166 static void __init cleanup_nmi_testsuite(void)
25167 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
25168 unsigned long timeout;
25169
25170 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
25171 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
25172 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
25173 nmi_fail = FAILURE;
25174 return;
25175 }
25176 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
25177 index bbb6c73..24a58ef 100644
25178 --- a/arch/x86/kernel/paravirt-spinlocks.c
25179 +++ b/arch/x86/kernel/paravirt-spinlocks.c
25180 @@ -8,7 +8,7 @@
25181
25182 #include <asm/paravirt.h>
25183
25184 -struct pv_lock_ops pv_lock_ops = {
25185 +struct pv_lock_ops pv_lock_ops __read_only = {
25186 #ifdef CONFIG_SMP
25187 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
25188 .unlock_kick = paravirt_nop,
25189 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
25190 index 1b10af8..0b58cbc 100644
25191 --- a/arch/x86/kernel/paravirt.c
25192 +++ b/arch/x86/kernel/paravirt.c
25193 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
25194 {
25195 return x;
25196 }
25197 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25198 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
25199 +#endif
25200
25201 void __init default_banner(void)
25202 {
25203 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
25204 if (opfunc == NULL)
25205 /* If there's no function, patch it with a ud2a (BUG) */
25206 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
25207 - else if (opfunc == _paravirt_nop)
25208 + else if (opfunc == (void *)_paravirt_nop)
25209 /* If the operation is a nop, then nop the callsite */
25210 ret = paravirt_patch_nop();
25211
25212 /* identity functions just return their single argument */
25213 - else if (opfunc == _paravirt_ident_32)
25214 + else if (opfunc == (void *)_paravirt_ident_32)
25215 ret = paravirt_patch_ident_32(insnbuf, len);
25216 - else if (opfunc == _paravirt_ident_64)
25217 + else if (opfunc == (void *)_paravirt_ident_64)
25218 ret = paravirt_patch_ident_64(insnbuf, len);
25219 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25220 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
25221 + ret = paravirt_patch_ident_64(insnbuf, len);
25222 +#endif
25223
25224 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
25225 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
25226 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
25227 if (insn_len > len || start == NULL)
25228 insn_len = len;
25229 else
25230 - memcpy(insnbuf, start, insn_len);
25231 + memcpy(insnbuf, ktla_ktva(start), insn_len);
25232
25233 return insn_len;
25234 }
25235 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
25236 return this_cpu_read(paravirt_lazy_mode);
25237 }
25238
25239 -struct pv_info pv_info = {
25240 +struct pv_info pv_info __read_only = {
25241 .name = "bare hardware",
25242 .paravirt_enabled = 0,
25243 .kernel_rpl = 0,
25244 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
25245 #endif
25246 };
25247
25248 -struct pv_init_ops pv_init_ops = {
25249 +struct pv_init_ops pv_init_ops __read_only = {
25250 .patch = native_patch,
25251 };
25252
25253 -struct pv_time_ops pv_time_ops = {
25254 +struct pv_time_ops pv_time_ops __read_only = {
25255 .sched_clock = native_sched_clock,
25256 .steal_clock = native_steal_clock,
25257 };
25258
25259 -__visible struct pv_irq_ops pv_irq_ops = {
25260 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
25261 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
25262 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
25263 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
25264 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
25265 #endif
25266 };
25267
25268 -__visible struct pv_cpu_ops pv_cpu_ops = {
25269 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
25270 .cpuid = native_cpuid,
25271 .get_debugreg = native_get_debugreg,
25272 .set_debugreg = native_set_debugreg,
25273 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
25274 .end_context_switch = paravirt_nop,
25275 };
25276
25277 -struct pv_apic_ops pv_apic_ops = {
25278 +struct pv_apic_ops pv_apic_ops __read_only= {
25279 #ifdef CONFIG_X86_LOCAL_APIC
25280 .startup_ipi_hook = paravirt_nop,
25281 #endif
25282 };
25283
25284 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
25285 +#ifdef CONFIG_X86_32
25286 +#ifdef CONFIG_X86_PAE
25287 +/* 64-bit pagetable entries */
25288 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
25289 +#else
25290 /* 32-bit pagetable entries */
25291 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
25292 +#endif
25293 #else
25294 /* 64-bit pagetable entries */
25295 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
25296 #endif
25297
25298 -struct pv_mmu_ops pv_mmu_ops = {
25299 +struct pv_mmu_ops pv_mmu_ops __read_only = {
25300
25301 .read_cr2 = native_read_cr2,
25302 .write_cr2 = native_write_cr2,
25303 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
25304 .make_pud = PTE_IDENT,
25305
25306 .set_pgd = native_set_pgd,
25307 + .set_pgd_batched = native_set_pgd_batched,
25308 #endif
25309 #endif /* PAGETABLE_LEVELS >= 3 */
25310
25311 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
25312 },
25313
25314 .set_fixmap = native_set_fixmap,
25315 +
25316 +#ifdef CONFIG_PAX_KERNEXEC
25317 + .pax_open_kernel = native_pax_open_kernel,
25318 + .pax_close_kernel = native_pax_close_kernel,
25319 +#endif
25320 +
25321 };
25322
25323 EXPORT_SYMBOL_GPL(pv_time_ops);
25324 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
25325 index 299d493..2ccb0ee 100644
25326 --- a/arch/x86/kernel/pci-calgary_64.c
25327 +++ b/arch/x86/kernel/pci-calgary_64.c
25328 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
25329 tce_space = be64_to_cpu(readq(target));
25330 tce_space = tce_space & TAR_SW_BITS;
25331
25332 - tce_space = tce_space & (~specified_table_size);
25333 + tce_space = tce_space & (~(unsigned long)specified_table_size);
25334 info->tce_space = (u64 *)__va(tce_space);
25335 }
25336 }
25337 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
25338 index 35ccf75..7a15747 100644
25339 --- a/arch/x86/kernel/pci-iommu_table.c
25340 +++ b/arch/x86/kernel/pci-iommu_table.c
25341 @@ -2,7 +2,7 @@
25342 #include <asm/iommu_table.h>
25343 #include <linux/string.h>
25344 #include <linux/kallsyms.h>
25345 -
25346 +#include <linux/sched.h>
25347
25348 #define DEBUG 1
25349
25350 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
25351 index 6c483ba..d10ce2f 100644
25352 --- a/arch/x86/kernel/pci-swiotlb.c
25353 +++ b/arch/x86/kernel/pci-swiotlb.c
25354 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
25355 void *vaddr, dma_addr_t dma_addr,
25356 struct dma_attrs *attrs)
25357 {
25358 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
25359 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
25360 }
25361
25362 static struct dma_map_ops swiotlb_dma_ops = {
25363 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
25364 index 3fb8d95..254dc51 100644
25365 --- a/arch/x86/kernel/process.c
25366 +++ b/arch/x86/kernel/process.c
25367 @@ -36,7 +36,8 @@
25368 * section. Since TSS's are completely CPU-local, we want them
25369 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
25370 */
25371 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
25372 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
25373 +EXPORT_SYMBOL(init_tss);
25374
25375 #ifdef CONFIG_X86_64
25376 static DEFINE_PER_CPU(unsigned char, is_idle);
25377 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
25378 task_xstate_cachep =
25379 kmem_cache_create("task_xstate", xstate_size,
25380 __alignof__(union thread_xstate),
25381 - SLAB_PANIC | SLAB_NOTRACK, NULL);
25382 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
25383 }
25384
25385 /*
25386 @@ -105,7 +106,7 @@ void exit_thread(void)
25387 unsigned long *bp = t->io_bitmap_ptr;
25388
25389 if (bp) {
25390 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
25391 + struct tss_struct *tss = init_tss + get_cpu();
25392
25393 t->io_bitmap_ptr = NULL;
25394 clear_thread_flag(TIF_IO_BITMAP);
25395 @@ -125,6 +126,9 @@ void flush_thread(void)
25396 {
25397 struct task_struct *tsk = current;
25398
25399 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
25400 + loadsegment(gs, 0);
25401 +#endif
25402 flush_ptrace_hw_breakpoint(tsk);
25403 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
25404 drop_init_fpu(tsk);
25405 @@ -271,7 +275,7 @@ static void __exit_idle(void)
25406 void exit_idle(void)
25407 {
25408 /* idle loop has pid 0 */
25409 - if (current->pid)
25410 + if (task_pid_nr(current))
25411 return;
25412 __exit_idle();
25413 }
25414 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
25415 return ret;
25416 }
25417 #endif
25418 -void stop_this_cpu(void *dummy)
25419 +__noreturn void stop_this_cpu(void *dummy)
25420 {
25421 local_irq_disable();
25422 /*
25423 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
25424 }
25425 early_param("idle", idle_setup);
25426
25427 -unsigned long arch_align_stack(unsigned long sp)
25428 +#ifdef CONFIG_PAX_RANDKSTACK
25429 +void pax_randomize_kstack(struct pt_regs *regs)
25430 {
25431 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
25432 - sp -= get_random_int() % 8192;
25433 - return sp & ~0xf;
25434 -}
25435 + struct thread_struct *thread = &current->thread;
25436 + unsigned long time;
25437
25438 -unsigned long arch_randomize_brk(struct mm_struct *mm)
25439 -{
25440 - unsigned long range_end = mm->brk + 0x02000000;
25441 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
25442 -}
25443 + if (!randomize_va_space)
25444 + return;
25445 +
25446 + if (v8086_mode(regs))
25447 + return;
25448
25449 + rdtscl(time);
25450 +
25451 + /* P4 seems to return a 0 LSB, ignore it */
25452 +#ifdef CONFIG_MPENTIUM4
25453 + time &= 0x3EUL;
25454 + time <<= 2;
25455 +#elif defined(CONFIG_X86_64)
25456 + time &= 0xFUL;
25457 + time <<= 4;
25458 +#else
25459 + time &= 0x1FUL;
25460 + time <<= 3;
25461 +#endif
25462 +
25463 + thread->sp0 ^= time;
25464 + load_sp0(init_tss + smp_processor_id(), thread);
25465 +
25466 +#ifdef CONFIG_X86_64
25467 + this_cpu_write(kernel_stack, thread->sp0);
25468 +#endif
25469 +}
25470 +#endif
25471 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
25472 index 884f98f..ec23e04 100644
25473 --- a/arch/x86/kernel/process_32.c
25474 +++ b/arch/x86/kernel/process_32.c
25475 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
25476 unsigned long thread_saved_pc(struct task_struct *tsk)
25477 {
25478 return ((unsigned long *)tsk->thread.sp)[3];
25479 +//XXX return tsk->thread.eip;
25480 }
25481
25482 void __show_regs(struct pt_regs *regs, int all)
25483 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
25484 unsigned long sp;
25485 unsigned short ss, gs;
25486
25487 - if (user_mode_vm(regs)) {
25488 + if (user_mode(regs)) {
25489 sp = regs->sp;
25490 ss = regs->ss & 0xffff;
25491 - gs = get_user_gs(regs);
25492 } else {
25493 sp = kernel_stack_pointer(regs);
25494 savesegment(ss, ss);
25495 - savesegment(gs, gs);
25496 }
25497 + gs = get_user_gs(regs);
25498
25499 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
25500 (u16)regs->cs, regs->ip, regs->flags,
25501 - smp_processor_id());
25502 + raw_smp_processor_id());
25503 print_symbol("EIP is at %s\n", regs->ip);
25504
25505 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
25506 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
25507 int copy_thread(unsigned long clone_flags, unsigned long sp,
25508 unsigned long arg, struct task_struct *p)
25509 {
25510 - struct pt_regs *childregs = task_pt_regs(p);
25511 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
25512 struct task_struct *tsk;
25513 int err;
25514
25515 p->thread.sp = (unsigned long) childregs;
25516 p->thread.sp0 = (unsigned long) (childregs+1);
25517 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25518
25519 if (unlikely(p->flags & PF_KTHREAD)) {
25520 /* kernel thread */
25521 memset(childregs, 0, sizeof(struct pt_regs));
25522 p->thread.ip = (unsigned long) ret_from_kernel_thread;
25523 - task_user_gs(p) = __KERNEL_STACK_CANARY;
25524 - childregs->ds = __USER_DS;
25525 - childregs->es = __USER_DS;
25526 + savesegment(gs, childregs->gs);
25527 + childregs->ds = __KERNEL_DS;
25528 + childregs->es = __KERNEL_DS;
25529 childregs->fs = __KERNEL_PERCPU;
25530 childregs->bx = sp; /* function */
25531 childregs->bp = arg;
25532 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25533 struct thread_struct *prev = &prev_p->thread,
25534 *next = &next_p->thread;
25535 int cpu = smp_processor_id();
25536 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25537 + struct tss_struct *tss = init_tss + cpu;
25538 fpu_switch_t fpu;
25539
25540 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
25541 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25542 */
25543 lazy_save_gs(prev->gs);
25544
25545 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25546 + __set_fs(task_thread_info(next_p)->addr_limit);
25547 +#endif
25548 +
25549 /*
25550 * Load the per-thread Thread-Local Storage descriptor.
25551 */
25552 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25553 */
25554 arch_end_context_switch(next_p);
25555
25556 + this_cpu_write(current_task, next_p);
25557 + this_cpu_write(current_tinfo, &next_p->tinfo);
25558 +
25559 /*
25560 * Restore %gs if needed (which is common)
25561 */
25562 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25563
25564 switch_fpu_finish(next_p, fpu);
25565
25566 - this_cpu_write(current_task, next_p);
25567 -
25568 return prev_p;
25569 }
25570
25571 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
25572 } while (count++ < 16);
25573 return 0;
25574 }
25575 -
25576 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
25577 index bb1dc51..08dda7f 100644
25578 --- a/arch/x86/kernel/process_64.c
25579 +++ b/arch/x86/kernel/process_64.c
25580 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25581 struct pt_regs *childregs;
25582 struct task_struct *me = current;
25583
25584 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
25585 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
25586 childregs = task_pt_regs(p);
25587 p->thread.sp = (unsigned long) childregs;
25588 p->thread.usersp = me->thread.usersp;
25589 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25590 set_tsk_thread_flag(p, TIF_FORK);
25591 p->fpu_counter = 0;
25592 p->thread.io_bitmap_ptr = NULL;
25593 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25594 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
25595 savesegment(es, p->thread.es);
25596 savesegment(ds, p->thread.ds);
25597 + savesegment(ss, p->thread.ss);
25598 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
25599 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
25600
25601 if (unlikely(p->flags & PF_KTHREAD)) {
25602 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25603 struct thread_struct *prev = &prev_p->thread;
25604 struct thread_struct *next = &next_p->thread;
25605 int cpu = smp_processor_id();
25606 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25607 + struct tss_struct *tss = init_tss + cpu;
25608 unsigned fsindex, gsindex;
25609 fpu_switch_t fpu;
25610
25611 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25612 if (unlikely(next->ds | prev->ds))
25613 loadsegment(ds, next->ds);
25614
25615 + savesegment(ss, prev->ss);
25616 + if (unlikely(next->ss != prev->ss))
25617 + loadsegment(ss, next->ss);
25618
25619 /* We must save %fs and %gs before load_TLS() because
25620 * %fs and %gs may be cleared by load_TLS().
25621 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25622 prev->usersp = this_cpu_read(old_rsp);
25623 this_cpu_write(old_rsp, next->usersp);
25624 this_cpu_write(current_task, next_p);
25625 + this_cpu_write(current_tinfo, &next_p->tinfo);
25626
25627 - this_cpu_write(kernel_stack,
25628 - (unsigned long)task_stack_page(next_p) +
25629 - THREAD_SIZE - KERNEL_STACK_OFFSET);
25630 + this_cpu_write(kernel_stack, next->sp0);
25631
25632 /*
25633 * Now maybe reload the debug registers and handle I/O bitmaps
25634 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
25635 if (!p || p == current || p->state == TASK_RUNNING)
25636 return 0;
25637 stack = (unsigned long)task_stack_page(p);
25638 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
25639 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
25640 return 0;
25641 fp = *(u64 *)(p->thread.sp);
25642 do {
25643 - if (fp < (unsigned long)stack ||
25644 - fp >= (unsigned long)stack+THREAD_SIZE)
25645 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
25646 return 0;
25647 ip = *(u64 *)(fp+8);
25648 if (!in_sched_functions(ip))
25649 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
25650 index 7461f50..1334029 100644
25651 --- a/arch/x86/kernel/ptrace.c
25652 +++ b/arch/x86/kernel/ptrace.c
25653 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
25654 {
25655 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
25656 unsigned long sp = (unsigned long)&regs->sp;
25657 - struct thread_info *tinfo;
25658
25659 - if (context == (sp & ~(THREAD_SIZE - 1)))
25660 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
25661 return sp;
25662
25663 - tinfo = (struct thread_info *)context;
25664 - if (tinfo->previous_esp)
25665 - return tinfo->previous_esp;
25666 + sp = *(unsigned long *)context;
25667 + if (sp)
25668 + return sp;
25669
25670 return (unsigned long)regs;
25671 }
25672 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
25673 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
25674 {
25675 int i;
25676 - int dr7 = 0;
25677 + unsigned long dr7 = 0;
25678 struct arch_hw_breakpoint *info;
25679
25680 for (i = 0; i < HBP_NUM; i++) {
25681 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
25682 unsigned long addr, unsigned long data)
25683 {
25684 int ret;
25685 - unsigned long __user *datap = (unsigned long __user *)data;
25686 + unsigned long __user *datap = (__force unsigned long __user *)data;
25687
25688 switch (request) {
25689 /* read the word at location addr in the USER area. */
25690 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
25691 if ((int) addr < 0)
25692 return -EIO;
25693 ret = do_get_thread_area(child, addr,
25694 - (struct user_desc __user *)data);
25695 + (__force struct user_desc __user *) data);
25696 break;
25697
25698 case PTRACE_SET_THREAD_AREA:
25699 if ((int) addr < 0)
25700 return -EIO;
25701 ret = do_set_thread_area(child, addr,
25702 - (struct user_desc __user *)data, 0);
25703 + (__force struct user_desc __user *) data, 0);
25704 break;
25705 #endif
25706
25707 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
25708
25709 #ifdef CONFIG_X86_64
25710
25711 -static struct user_regset x86_64_regsets[] __read_mostly = {
25712 +static user_regset_no_const x86_64_regsets[] __read_only = {
25713 [REGSET_GENERAL] = {
25714 .core_note_type = NT_PRSTATUS,
25715 .n = sizeof(struct user_regs_struct) / sizeof(long),
25716 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
25717 #endif /* CONFIG_X86_64 */
25718
25719 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
25720 -static struct user_regset x86_32_regsets[] __read_mostly = {
25721 +static user_regset_no_const x86_32_regsets[] __read_only = {
25722 [REGSET_GENERAL] = {
25723 .core_note_type = NT_PRSTATUS,
25724 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
25725 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
25726 */
25727 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
25728
25729 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25730 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25731 {
25732 #ifdef CONFIG_X86_64
25733 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
25734 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
25735 memset(info, 0, sizeof(*info));
25736 info->si_signo = SIGTRAP;
25737 info->si_code = si_code;
25738 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
25739 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
25740 }
25741
25742 void user_single_step_siginfo(struct task_struct *tsk,
25743 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
25744 # define IS_IA32 0
25745 #endif
25746
25747 +#ifdef CONFIG_GRKERNSEC_SETXID
25748 +extern void gr_delayed_cred_worker(void);
25749 +#endif
25750 +
25751 /*
25752 * We must return the syscall number to actually look up in the table.
25753 * This can be -1L to skip running any syscall at all.
25754 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
25755
25756 user_exit();
25757
25758 +#ifdef CONFIG_GRKERNSEC_SETXID
25759 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25760 + gr_delayed_cred_worker();
25761 +#endif
25762 +
25763 /*
25764 * If we stepped into a sysenter/syscall insn, it trapped in
25765 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
25766 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
25767 */
25768 user_exit();
25769
25770 +#ifdef CONFIG_GRKERNSEC_SETXID
25771 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25772 + gr_delayed_cred_worker();
25773 +#endif
25774 +
25775 audit_syscall_exit(regs);
25776
25777 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
25778 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
25779 index a16bae3..1f65f25 100644
25780 --- a/arch/x86/kernel/pvclock.c
25781 +++ b/arch/x86/kernel/pvclock.c
25782 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
25783 return pv_tsc_khz;
25784 }
25785
25786 -static atomic64_t last_value = ATOMIC64_INIT(0);
25787 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
25788
25789 void pvclock_resume(void)
25790 {
25791 - atomic64_set(&last_value, 0);
25792 + atomic64_set_unchecked(&last_value, 0);
25793 }
25794
25795 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
25796 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
25797 * updating at the same time, and one of them could be slightly behind,
25798 * making the assumption that last_value always go forward fail to hold.
25799 */
25800 - last = atomic64_read(&last_value);
25801 + last = atomic64_read_unchecked(&last_value);
25802 do {
25803 if (ret < last)
25804 return last;
25805 - last = atomic64_cmpxchg(&last_value, last, ret);
25806 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
25807 } while (unlikely(last != ret));
25808
25809 return ret;
25810 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
25811 index 618ce26..ec7e21c 100644
25812 --- a/arch/x86/kernel/reboot.c
25813 +++ b/arch/x86/kernel/reboot.c
25814 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
25815
25816 void __noreturn machine_real_restart(unsigned int type)
25817 {
25818 +
25819 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
25820 + struct desc_struct *gdt;
25821 +#endif
25822 +
25823 local_irq_disable();
25824
25825 /*
25826 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
25827
25828 /* Jump to the identity-mapped low memory code */
25829 #ifdef CONFIG_X86_32
25830 - asm volatile("jmpl *%0" : :
25831 +
25832 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
25833 + gdt = get_cpu_gdt_table(smp_processor_id());
25834 + pax_open_kernel();
25835 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25836 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
25837 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
25838 + loadsegment(ds, __KERNEL_DS);
25839 + loadsegment(es, __KERNEL_DS);
25840 + loadsegment(ss, __KERNEL_DS);
25841 +#endif
25842 +#ifdef CONFIG_PAX_KERNEXEC
25843 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
25844 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
25845 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
25846 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
25847 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
25848 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
25849 +#endif
25850 + pax_close_kernel();
25851 +#endif
25852 +
25853 + asm volatile("ljmpl *%0" : :
25854 "rm" (real_mode_header->machine_real_restart_asm),
25855 "a" (type));
25856 #else
25857 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25858 * try to force a triple fault and then cycle between hitting the keyboard
25859 * controller and doing that
25860 */
25861 -static void native_machine_emergency_restart(void)
25862 +static void __noreturn native_machine_emergency_restart(void)
25863 {
25864 int i;
25865 int attempt = 0;
25866 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
25867 #endif
25868 }
25869
25870 -static void __machine_emergency_restart(int emergency)
25871 +static void __noreturn __machine_emergency_restart(int emergency)
25872 {
25873 reboot_emergency = emergency;
25874 machine_ops.emergency_restart();
25875 }
25876
25877 -static void native_machine_restart(char *__unused)
25878 +static void __noreturn native_machine_restart(char *__unused)
25879 {
25880 pr_notice("machine restart\n");
25881
25882 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25883 __machine_emergency_restart(0);
25884 }
25885
25886 -static void native_machine_halt(void)
25887 +static void __noreturn native_machine_halt(void)
25888 {
25889 /* Stop other cpus and apics */
25890 machine_shutdown();
25891 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25892 stop_this_cpu(NULL);
25893 }
25894
25895 -static void native_machine_power_off(void)
25896 +static void __noreturn native_machine_power_off(void)
25897 {
25898 if (pm_power_off) {
25899 if (!reboot_force)
25900 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25901 }
25902 /* A fallback in case there is no PM info available */
25903 tboot_shutdown(TB_SHUTDOWN_HALT);
25904 + unreachable();
25905 }
25906
25907 -struct machine_ops machine_ops = {
25908 +struct machine_ops machine_ops __read_only = {
25909 .power_off = native_machine_power_off,
25910 .shutdown = native_machine_shutdown,
25911 .emergency_restart = native_machine_emergency_restart,
25912 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25913 index c8e41e9..64049ef 100644
25914 --- a/arch/x86/kernel/reboot_fixups_32.c
25915 +++ b/arch/x86/kernel/reboot_fixups_32.c
25916 @@ -57,7 +57,7 @@ struct device_fixup {
25917 unsigned int vendor;
25918 unsigned int device;
25919 void (*reboot_fixup)(struct pci_dev *);
25920 -};
25921 +} __do_const;
25922
25923 /*
25924 * PCI ids solely used for fixups_table go here
25925 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25926 index 3fd2c69..16ef367 100644
25927 --- a/arch/x86/kernel/relocate_kernel_64.S
25928 +++ b/arch/x86/kernel/relocate_kernel_64.S
25929 @@ -11,6 +11,7 @@
25930 #include <asm/kexec.h>
25931 #include <asm/processor-flags.h>
25932 #include <asm/pgtable_types.h>
25933 +#include <asm/alternative-asm.h>
25934
25935 /*
25936 * Must be relocatable PIC code callable as a C function
25937 @@ -96,8 +97,7 @@ relocate_kernel:
25938
25939 /* jump to identity mapped page */
25940 addq $(identity_mapped - relocate_kernel), %r8
25941 - pushq %r8
25942 - ret
25943 + jmp *%r8
25944
25945 identity_mapped:
25946 /* set return address to 0 if not preserving context */
25947 @@ -167,6 +167,7 @@ identity_mapped:
25948 xorl %r14d, %r14d
25949 xorl %r15d, %r15d
25950
25951 + pax_force_retaddr 0, 1
25952 ret
25953
25954 1:
25955 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25956 index f0de629..a4978a8f 100644
25957 --- a/arch/x86/kernel/setup.c
25958 +++ b/arch/x86/kernel/setup.c
25959 @@ -110,6 +110,7 @@
25960 #include <asm/mce.h>
25961 #include <asm/alternative.h>
25962 #include <asm/prom.h>
25963 +#include <asm/boot.h>
25964
25965 /*
25966 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25967 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25968 #endif
25969
25970
25971 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25972 -__visible unsigned long mmu_cr4_features;
25973 +#ifdef CONFIG_X86_64
25974 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25975 +#elif defined(CONFIG_X86_PAE)
25976 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25977 #else
25978 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25979 +__visible unsigned long mmu_cr4_features __read_only;
25980 #endif
25981
25982 +void set_in_cr4(unsigned long mask)
25983 +{
25984 + unsigned long cr4 = read_cr4();
25985 +
25986 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25987 + return;
25988 +
25989 + pax_open_kernel();
25990 + mmu_cr4_features |= mask;
25991 + pax_close_kernel();
25992 +
25993 + if (trampoline_cr4_features)
25994 + *trampoline_cr4_features = mmu_cr4_features;
25995 + cr4 |= mask;
25996 + write_cr4(cr4);
25997 +}
25998 +EXPORT_SYMBOL(set_in_cr4);
25999 +
26000 +void clear_in_cr4(unsigned long mask)
26001 +{
26002 + unsigned long cr4 = read_cr4();
26003 +
26004 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
26005 + return;
26006 +
26007 + pax_open_kernel();
26008 + mmu_cr4_features &= ~mask;
26009 + pax_close_kernel();
26010 +
26011 + if (trampoline_cr4_features)
26012 + *trampoline_cr4_features = mmu_cr4_features;
26013 + cr4 &= ~mask;
26014 + write_cr4(cr4);
26015 +}
26016 +EXPORT_SYMBOL(clear_in_cr4);
26017 +
26018 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
26019 int bootloader_type, bootloader_version;
26020
26021 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
26022 * area (640->1Mb) as ram even though it is not.
26023 * take them out.
26024 */
26025 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
26026 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
26027
26028 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
26029 }
26030 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
26031 /* called before trim_bios_range() to spare extra sanitize */
26032 static void __init e820_add_kernel_range(void)
26033 {
26034 - u64 start = __pa_symbol(_text);
26035 + u64 start = __pa_symbol(ktla_ktva(_text));
26036 u64 size = __pa_symbol(_end) - start;
26037
26038 /*
26039 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
26040
26041 void __init setup_arch(char **cmdline_p)
26042 {
26043 +#ifdef CONFIG_X86_32
26044 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
26045 +#else
26046 memblock_reserve(__pa_symbol(_text),
26047 (unsigned long)__bss_stop - (unsigned long)_text);
26048 +#endif
26049
26050 early_reserve_initrd();
26051
26052 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
26053
26054 if (!boot_params.hdr.root_flags)
26055 root_mountflags &= ~MS_RDONLY;
26056 - init_mm.start_code = (unsigned long) _text;
26057 - init_mm.end_code = (unsigned long) _etext;
26058 + init_mm.start_code = ktla_ktva((unsigned long) _text);
26059 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
26060 init_mm.end_data = (unsigned long) _edata;
26061 init_mm.brk = _brk_end;
26062
26063 - code_resource.start = __pa_symbol(_text);
26064 - code_resource.end = __pa_symbol(_etext)-1;
26065 - data_resource.start = __pa_symbol(_etext);
26066 + code_resource.start = __pa_symbol(ktla_ktva(_text));
26067 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
26068 + data_resource.start = __pa_symbol(_sdata);
26069 data_resource.end = __pa_symbol(_edata)-1;
26070 bss_resource.start = __pa_symbol(__bss_start);
26071 bss_resource.end = __pa_symbol(__bss_stop)-1;
26072 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
26073 index 5cdff03..80fa283 100644
26074 --- a/arch/x86/kernel/setup_percpu.c
26075 +++ b/arch/x86/kernel/setup_percpu.c
26076 @@ -21,19 +21,17 @@
26077 #include <asm/cpu.h>
26078 #include <asm/stackprotector.h>
26079
26080 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
26081 +#ifdef CONFIG_SMP
26082 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
26083 EXPORT_PER_CPU_SYMBOL(cpu_number);
26084 +#endif
26085
26086 -#ifdef CONFIG_X86_64
26087 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
26088 -#else
26089 -#define BOOT_PERCPU_OFFSET 0
26090 -#endif
26091
26092 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
26093 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
26094
26095 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
26096 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
26097 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
26098 };
26099 EXPORT_SYMBOL(__per_cpu_offset);
26100 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
26101 {
26102 #ifdef CONFIG_NEED_MULTIPLE_NODES
26103 pg_data_t *last = NULL;
26104 - unsigned int cpu;
26105 + int cpu;
26106
26107 for_each_possible_cpu(cpu) {
26108 int node = early_cpu_to_node(cpu);
26109 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
26110 {
26111 #ifdef CONFIG_X86_32
26112 struct desc_struct gdt;
26113 + unsigned long base = per_cpu_offset(cpu);
26114
26115 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
26116 - 0x2 | DESCTYPE_S, 0x8);
26117 - gdt.s = 1;
26118 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
26119 + 0x83 | DESCTYPE_S, 0xC);
26120 write_gdt_entry(get_cpu_gdt_table(cpu),
26121 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
26122 #endif
26123 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
26124 /* alrighty, percpu areas up and running */
26125 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
26126 for_each_possible_cpu(cpu) {
26127 +#ifdef CONFIG_CC_STACKPROTECTOR
26128 +#ifdef CONFIG_X86_32
26129 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
26130 +#endif
26131 +#endif
26132 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
26133 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
26134 per_cpu(cpu_number, cpu) = cpu;
26135 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
26136 */
26137 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
26138 #endif
26139 +#ifdef CONFIG_CC_STACKPROTECTOR
26140 +#ifdef CONFIG_X86_32
26141 + if (!cpu)
26142 + per_cpu(stack_canary.canary, cpu) = canary;
26143 +#endif
26144 +#endif
26145 /*
26146 * Up to this point, the boot CPU has been using .init.data
26147 * area. Reload any changed state for the boot CPU.
26148 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
26149 index 9e5de68..16c53cb 100644
26150 --- a/arch/x86/kernel/signal.c
26151 +++ b/arch/x86/kernel/signal.c
26152 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
26153 * Align the stack pointer according to the i386 ABI,
26154 * i.e. so that on function entry ((sp + 4) & 15) == 0.
26155 */
26156 - sp = ((sp + 4) & -16ul) - 4;
26157 + sp = ((sp - 12) & -16ul) - 4;
26158 #else /* !CONFIG_X86_32 */
26159 sp = round_down(sp, 16) - 8;
26160 #endif
26161 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26162 }
26163
26164 if (current->mm->context.vdso)
26165 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26166 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26167 else
26168 - restorer = &frame->retcode;
26169 + restorer = (void __user *)&frame->retcode;
26170 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26171 restorer = ksig->ka.sa.sa_restorer;
26172
26173 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26174 * reasons and because gdb uses it as a signature to notice
26175 * signal handler stack frames.
26176 */
26177 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
26178 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
26179
26180 if (err)
26181 return -EFAULT;
26182 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26183 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
26184
26185 /* Set up to return from userspace. */
26186 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26187 + if (current->mm->context.vdso)
26188 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26189 + else
26190 + restorer = (void __user *)&frame->retcode;
26191 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26192 restorer = ksig->ka.sa.sa_restorer;
26193 put_user_ex(restorer, &frame->pretcode);
26194 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26195 * reasons and because gdb uses it as a signature to notice
26196 * signal handler stack frames.
26197 */
26198 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
26199 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
26200 } put_user_catch(err);
26201
26202 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
26203 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26204 {
26205 int usig = signr_convert(ksig->sig);
26206 sigset_t *set = sigmask_to_save();
26207 - compat_sigset_t *cset = (compat_sigset_t *) set;
26208 + sigset_t sigcopy;
26209 + compat_sigset_t *cset;
26210 +
26211 + sigcopy = *set;
26212 +
26213 + cset = (compat_sigset_t *) &sigcopy;
26214
26215 /* Set up the stack frame */
26216 if (is_ia32_frame()) {
26217 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26218 } else if (is_x32_frame()) {
26219 return x32_setup_rt_frame(ksig, cset, regs);
26220 } else {
26221 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
26222 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
26223 }
26224 }
26225
26226 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
26227 index 7c3a5a6..f0a8961 100644
26228 --- a/arch/x86/kernel/smp.c
26229 +++ b/arch/x86/kernel/smp.c
26230 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
26231
26232 __setup("nonmi_ipi", nonmi_ipi_setup);
26233
26234 -struct smp_ops smp_ops = {
26235 +struct smp_ops smp_ops __read_only = {
26236 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
26237 .smp_prepare_cpus = native_smp_prepare_cpus,
26238 .smp_cpus_done = native_smp_cpus_done,
26239 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
26240 index 6cacab6..750636a 100644
26241 --- a/arch/x86/kernel/smpboot.c
26242 +++ b/arch/x86/kernel/smpboot.c
26243 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
26244
26245 enable_start_cpu0 = 0;
26246
26247 -#ifdef CONFIG_X86_32
26248 - /* switch away from the initial page table */
26249 - load_cr3(swapper_pg_dir);
26250 - __flush_tlb_all();
26251 -#endif
26252 -
26253 /* otherwise gcc will move up smp_processor_id before the cpu_init */
26254 barrier();
26255 +
26256 + /* switch away from the initial page table */
26257 +#ifdef CONFIG_PAX_PER_CPU_PGD
26258 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
26259 + __flush_tlb_all();
26260 +#elif defined(CONFIG_X86_32)
26261 + load_cr3(swapper_pg_dir);
26262 + __flush_tlb_all();
26263 +#endif
26264 +
26265 /*
26266 * Check TSC synchronization with the BP:
26267 */
26268 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26269 idle->thread.sp = (unsigned long) (((struct pt_regs *)
26270 (THREAD_SIZE + task_stack_page(idle))) - 1);
26271 per_cpu(current_task, cpu) = idle;
26272 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
26273
26274 #ifdef CONFIG_X86_32
26275 /* Stack for startup_32 can be just as for start_secondary onwards */
26276 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26277 #else
26278 clear_tsk_thread_flag(idle, TIF_FORK);
26279 initial_gs = per_cpu_offset(cpu);
26280 - per_cpu(kernel_stack, cpu) =
26281 - (unsigned long)task_stack_page(idle) -
26282 - KERNEL_STACK_OFFSET + THREAD_SIZE;
26283 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
26284 #endif
26285 +
26286 + pax_open_kernel();
26287 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
26288 + pax_close_kernel();
26289 +
26290 initial_code = (unsigned long)start_secondary;
26291 stack_start = idle->thread.sp;
26292
26293 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
26294 /* the FPU context is blank, nobody can own it */
26295 __cpu_disable_lazy_restore(cpu);
26296
26297 +#ifdef CONFIG_PAX_PER_CPU_PGD
26298 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
26299 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26300 + KERNEL_PGD_PTRS);
26301 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
26302 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26303 + KERNEL_PGD_PTRS);
26304 +#endif
26305 +
26306 err = do_boot_cpu(apicid, cpu, tidle);
26307 if (err) {
26308 pr_debug("do_boot_cpu failed %d\n", err);
26309 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
26310 index 9b4d51d..5d28b58 100644
26311 --- a/arch/x86/kernel/step.c
26312 +++ b/arch/x86/kernel/step.c
26313 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26314 struct desc_struct *desc;
26315 unsigned long base;
26316
26317 - seg &= ~7UL;
26318 + seg >>= 3;
26319
26320 mutex_lock(&child->mm->context.lock);
26321 - if (unlikely((seg >> 3) >= child->mm->context.size))
26322 + if (unlikely(seg >= child->mm->context.size))
26323 addr = -1L; /* bogus selector, access would fault */
26324 else {
26325 desc = child->mm->context.ldt + seg;
26326 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26327 addr += base;
26328 }
26329 mutex_unlock(&child->mm->context.lock);
26330 - }
26331 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
26332 + addr = ktla_ktva(addr);
26333
26334 return addr;
26335 }
26336 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
26337 unsigned char opcode[15];
26338 unsigned long addr = convert_ip_to_linear(child, regs);
26339
26340 + if (addr == -EINVAL)
26341 + return 0;
26342 +
26343 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
26344 for (i = 0; i < copied; i++) {
26345 switch (opcode[i]) {
26346 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
26347 new file mode 100644
26348 index 0000000..5877189
26349 --- /dev/null
26350 +++ b/arch/x86/kernel/sys_i386_32.c
26351 @@ -0,0 +1,189 @@
26352 +/*
26353 + * This file contains various random system calls that
26354 + * have a non-standard calling sequence on the Linux/i386
26355 + * platform.
26356 + */
26357 +
26358 +#include <linux/errno.h>
26359 +#include <linux/sched.h>
26360 +#include <linux/mm.h>
26361 +#include <linux/fs.h>
26362 +#include <linux/smp.h>
26363 +#include <linux/sem.h>
26364 +#include <linux/msg.h>
26365 +#include <linux/shm.h>
26366 +#include <linux/stat.h>
26367 +#include <linux/syscalls.h>
26368 +#include <linux/mman.h>
26369 +#include <linux/file.h>
26370 +#include <linux/utsname.h>
26371 +#include <linux/ipc.h>
26372 +#include <linux/elf.h>
26373 +
26374 +#include <linux/uaccess.h>
26375 +#include <linux/unistd.h>
26376 +
26377 +#include <asm/syscalls.h>
26378 +
26379 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
26380 +{
26381 + unsigned long pax_task_size = TASK_SIZE;
26382 +
26383 +#ifdef CONFIG_PAX_SEGMEXEC
26384 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
26385 + pax_task_size = SEGMEXEC_TASK_SIZE;
26386 +#endif
26387 +
26388 + if (flags & MAP_FIXED)
26389 + if (len > pax_task_size || addr > pax_task_size - len)
26390 + return -EINVAL;
26391 +
26392 + return 0;
26393 +}
26394 +
26395 +/*
26396 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
26397 + */
26398 +static unsigned long get_align_mask(void)
26399 +{
26400 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
26401 + return 0;
26402 +
26403 + if (!(current->flags & PF_RANDOMIZE))
26404 + return 0;
26405 +
26406 + return va_align.mask;
26407 +}
26408 +
26409 +unsigned long
26410 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
26411 + unsigned long len, unsigned long pgoff, unsigned long flags)
26412 +{
26413 + struct mm_struct *mm = current->mm;
26414 + struct vm_area_struct *vma;
26415 + unsigned long pax_task_size = TASK_SIZE;
26416 + struct vm_unmapped_area_info info;
26417 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26418 +
26419 +#ifdef CONFIG_PAX_SEGMEXEC
26420 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26421 + pax_task_size = SEGMEXEC_TASK_SIZE;
26422 +#endif
26423 +
26424 + pax_task_size -= PAGE_SIZE;
26425 +
26426 + if (len > pax_task_size)
26427 + return -ENOMEM;
26428 +
26429 + if (flags & MAP_FIXED)
26430 + return addr;
26431 +
26432 +#ifdef CONFIG_PAX_RANDMMAP
26433 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26434 +#endif
26435 +
26436 + if (addr) {
26437 + addr = PAGE_ALIGN(addr);
26438 + if (pax_task_size - len >= addr) {
26439 + vma = find_vma(mm, addr);
26440 + if (check_heap_stack_gap(vma, addr, len, offset))
26441 + return addr;
26442 + }
26443 + }
26444 +
26445 + info.flags = 0;
26446 + info.length = len;
26447 + info.align_mask = filp ? get_align_mask() : 0;
26448 + info.align_offset = pgoff << PAGE_SHIFT;
26449 + info.threadstack_offset = offset;
26450 +
26451 +#ifdef CONFIG_PAX_PAGEEXEC
26452 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
26453 + info.low_limit = 0x00110000UL;
26454 + info.high_limit = mm->start_code;
26455 +
26456 +#ifdef CONFIG_PAX_RANDMMAP
26457 + if (mm->pax_flags & MF_PAX_RANDMMAP)
26458 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
26459 +#endif
26460 +
26461 + if (info.low_limit < info.high_limit) {
26462 + addr = vm_unmapped_area(&info);
26463 + if (!IS_ERR_VALUE(addr))
26464 + return addr;
26465 + }
26466 + } else
26467 +#endif
26468 +
26469 + info.low_limit = mm->mmap_base;
26470 + info.high_limit = pax_task_size;
26471 +
26472 + return vm_unmapped_area(&info);
26473 +}
26474 +
26475 +unsigned long
26476 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26477 + const unsigned long len, const unsigned long pgoff,
26478 + const unsigned long flags)
26479 +{
26480 + struct vm_area_struct *vma;
26481 + struct mm_struct *mm = current->mm;
26482 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
26483 + struct vm_unmapped_area_info info;
26484 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26485 +
26486 +#ifdef CONFIG_PAX_SEGMEXEC
26487 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26488 + pax_task_size = SEGMEXEC_TASK_SIZE;
26489 +#endif
26490 +
26491 + pax_task_size -= PAGE_SIZE;
26492 +
26493 + /* requested length too big for entire address space */
26494 + if (len > pax_task_size)
26495 + return -ENOMEM;
26496 +
26497 + if (flags & MAP_FIXED)
26498 + return addr;
26499 +
26500 +#ifdef CONFIG_PAX_PAGEEXEC
26501 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
26502 + goto bottomup;
26503 +#endif
26504 +
26505 +#ifdef CONFIG_PAX_RANDMMAP
26506 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26507 +#endif
26508 +
26509 + /* requesting a specific address */
26510 + if (addr) {
26511 + addr = PAGE_ALIGN(addr);
26512 + if (pax_task_size - len >= addr) {
26513 + vma = find_vma(mm, addr);
26514 + if (check_heap_stack_gap(vma, addr, len, offset))
26515 + return addr;
26516 + }
26517 + }
26518 +
26519 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
26520 + info.length = len;
26521 + info.low_limit = PAGE_SIZE;
26522 + info.high_limit = mm->mmap_base;
26523 + info.align_mask = filp ? get_align_mask() : 0;
26524 + info.align_offset = pgoff << PAGE_SHIFT;
26525 + info.threadstack_offset = offset;
26526 +
26527 + addr = vm_unmapped_area(&info);
26528 + if (!(addr & ~PAGE_MASK))
26529 + return addr;
26530 + VM_BUG_ON(addr != -ENOMEM);
26531 +
26532 +bottomup:
26533 + /*
26534 + * A failed mmap() very likely causes application failure,
26535 + * so fall back to the bottom-up function here. This scenario
26536 + * can happen with large stack limits and large mmap()
26537 + * allocations.
26538 + */
26539 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
26540 +}
26541 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
26542 index 30277e2..5664a29 100644
26543 --- a/arch/x86/kernel/sys_x86_64.c
26544 +++ b/arch/x86/kernel/sys_x86_64.c
26545 @@ -81,8 +81,8 @@ out:
26546 return error;
26547 }
26548
26549 -static void find_start_end(unsigned long flags, unsigned long *begin,
26550 - unsigned long *end)
26551 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
26552 + unsigned long *begin, unsigned long *end)
26553 {
26554 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
26555 unsigned long new_begin;
26556 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
26557 *begin = new_begin;
26558 }
26559 } else {
26560 - *begin = current->mm->mmap_legacy_base;
26561 + *begin = mm->mmap_legacy_base;
26562 *end = TASK_SIZE;
26563 }
26564 }
26565 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26566 struct vm_area_struct *vma;
26567 struct vm_unmapped_area_info info;
26568 unsigned long begin, end;
26569 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26570
26571 if (flags & MAP_FIXED)
26572 return addr;
26573
26574 - find_start_end(flags, &begin, &end);
26575 + find_start_end(mm, flags, &begin, &end);
26576
26577 if (len > end)
26578 return -ENOMEM;
26579
26580 +#ifdef CONFIG_PAX_RANDMMAP
26581 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26582 +#endif
26583 +
26584 if (addr) {
26585 addr = PAGE_ALIGN(addr);
26586 vma = find_vma(mm, addr);
26587 - if (end - len >= addr &&
26588 - (!vma || addr + len <= vma->vm_start))
26589 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26590 return addr;
26591 }
26592
26593 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26594 info.high_limit = end;
26595 info.align_mask = filp ? get_align_mask() : 0;
26596 info.align_offset = pgoff << PAGE_SHIFT;
26597 + info.threadstack_offset = offset;
26598 return vm_unmapped_area(&info);
26599 }
26600
26601 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26602 struct mm_struct *mm = current->mm;
26603 unsigned long addr = addr0;
26604 struct vm_unmapped_area_info info;
26605 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26606
26607 /* requested length too big for entire address space */
26608 if (len > TASK_SIZE)
26609 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26610 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
26611 goto bottomup;
26612
26613 +#ifdef CONFIG_PAX_RANDMMAP
26614 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26615 +#endif
26616 +
26617 /* requesting a specific address */
26618 if (addr) {
26619 addr = PAGE_ALIGN(addr);
26620 vma = find_vma(mm, addr);
26621 - if (TASK_SIZE - len >= addr &&
26622 - (!vma || addr + len <= vma->vm_start))
26623 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26624 return addr;
26625 }
26626
26627 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26628 info.high_limit = mm->mmap_base;
26629 info.align_mask = filp ? get_align_mask() : 0;
26630 info.align_offset = pgoff << PAGE_SHIFT;
26631 + info.threadstack_offset = offset;
26632 addr = vm_unmapped_area(&info);
26633 if (!(addr & ~PAGE_MASK))
26634 return addr;
26635 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
26636 index 91a4496..1730bff 100644
26637 --- a/arch/x86/kernel/tboot.c
26638 +++ b/arch/x86/kernel/tboot.c
26639 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
26640
26641 void tboot_shutdown(u32 shutdown_type)
26642 {
26643 - void (*shutdown)(void);
26644 + void (* __noreturn shutdown)(void);
26645
26646 if (!tboot_enabled())
26647 return;
26648 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
26649
26650 switch_to_tboot_pt();
26651
26652 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
26653 + shutdown = (void *)tboot->shutdown_entry;
26654 shutdown();
26655
26656 /* should not reach here */
26657 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
26658 return -ENODEV;
26659 }
26660
26661 -static atomic_t ap_wfs_count;
26662 +static atomic_unchecked_t ap_wfs_count;
26663
26664 static int tboot_wait_for_aps(int num_aps)
26665 {
26666 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
26667 {
26668 switch (action) {
26669 case CPU_DYING:
26670 - atomic_inc(&ap_wfs_count);
26671 + atomic_inc_unchecked(&ap_wfs_count);
26672 if (num_online_cpus() == 1)
26673 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
26674 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
26675 return NOTIFY_BAD;
26676 break;
26677 }
26678 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
26679
26680 tboot_create_trampoline();
26681
26682 - atomic_set(&ap_wfs_count, 0);
26683 + atomic_set_unchecked(&ap_wfs_count, 0);
26684 register_hotcpu_notifier(&tboot_cpu_notifier);
26685
26686 #ifdef CONFIG_DEBUG_FS
26687 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
26688 index 24d3c91..d06b473 100644
26689 --- a/arch/x86/kernel/time.c
26690 +++ b/arch/x86/kernel/time.c
26691 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
26692 {
26693 unsigned long pc = instruction_pointer(regs);
26694
26695 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
26696 + if (!user_mode(regs) && in_lock_functions(pc)) {
26697 #ifdef CONFIG_FRAME_POINTER
26698 - return *(unsigned long *)(regs->bp + sizeof(long));
26699 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
26700 #else
26701 unsigned long *sp =
26702 (unsigned long *)kernel_stack_pointer(regs);
26703 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
26704 * or above a saved flags. Eflags has bits 22-31 zero,
26705 * kernel addresses don't.
26706 */
26707 +
26708 +#ifdef CONFIG_PAX_KERNEXEC
26709 + return ktla_ktva(sp[0]);
26710 +#else
26711 if (sp[0] >> 22)
26712 return sp[0];
26713 if (sp[1] >> 22)
26714 return sp[1];
26715 #endif
26716 +
26717 +#endif
26718 }
26719 return pc;
26720 }
26721 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
26722 index f7fec09..9991981 100644
26723 --- a/arch/x86/kernel/tls.c
26724 +++ b/arch/x86/kernel/tls.c
26725 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
26726 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
26727 return -EINVAL;
26728
26729 +#ifdef CONFIG_PAX_SEGMEXEC
26730 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
26731 + return -EINVAL;
26732 +#endif
26733 +
26734 set_tls_desc(p, idx, &info, 1);
26735
26736 return 0;
26737 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
26738
26739 if (kbuf)
26740 info = kbuf;
26741 - else if (__copy_from_user(infobuf, ubuf, count))
26742 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
26743 return -EFAULT;
26744 else
26745 info = infobuf;
26746 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
26747 index 1c113db..287b42e 100644
26748 --- a/arch/x86/kernel/tracepoint.c
26749 +++ b/arch/x86/kernel/tracepoint.c
26750 @@ -9,11 +9,11 @@
26751 #include <linux/atomic.h>
26752
26753 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
26754 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26755 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26756 (unsigned long) trace_idt_table };
26757
26758 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26759 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
26760 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
26761
26762 static int trace_irq_vector_refcount;
26763 static DEFINE_MUTEX(irq_vector_mutex);
26764 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
26765 index 8c8093b..c93f581 100644
26766 --- a/arch/x86/kernel/traps.c
26767 +++ b/arch/x86/kernel/traps.c
26768 @@ -66,7 +66,7 @@
26769 #include <asm/proto.h>
26770
26771 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26772 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
26773 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
26774 #else
26775 #include <asm/processor-flags.h>
26776 #include <asm/setup.h>
26777 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
26778 #endif
26779
26780 /* Must be page-aligned because the real IDT is used in a fixmap. */
26781 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
26782 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
26783
26784 DECLARE_BITMAP(used_vectors, NR_VECTORS);
26785 EXPORT_SYMBOL_GPL(used_vectors);
26786 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
26787 }
26788
26789 static int __kprobes
26790 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26791 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
26792 struct pt_regs *regs, long error_code)
26793 {
26794 #ifdef CONFIG_X86_32
26795 - if (regs->flags & X86_VM_MASK) {
26796 + if (v8086_mode(regs)) {
26797 /*
26798 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
26799 * On nmi (interrupt 2), do_trap should not be called.
26800 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26801 return -1;
26802 }
26803 #endif
26804 - if (!user_mode(regs)) {
26805 + if (!user_mode_novm(regs)) {
26806 if (!fixup_exception(regs)) {
26807 tsk->thread.error_code = error_code;
26808 tsk->thread.trap_nr = trapnr;
26809 +
26810 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26811 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
26812 + str = "PAX: suspicious stack segment fault";
26813 +#endif
26814 +
26815 die(str, regs, error_code);
26816 }
26817 +
26818 +#ifdef CONFIG_PAX_REFCOUNT
26819 + if (trapnr == 4)
26820 + pax_report_refcount_overflow(regs);
26821 +#endif
26822 +
26823 return 0;
26824 }
26825
26826 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26827 }
26828
26829 static void __kprobes
26830 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26831 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
26832 long error_code, siginfo_t *info)
26833 {
26834 struct task_struct *tsk = current;
26835 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26836 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
26837 printk_ratelimit()) {
26838 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
26839 - tsk->comm, tsk->pid, str,
26840 + tsk->comm, task_pid_nr(tsk), str,
26841 regs->ip, regs->sp, error_code);
26842 print_vma_addr(" in ", regs->ip);
26843 pr_cont("\n");
26844 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26845 conditional_sti(regs);
26846
26847 #ifdef CONFIG_X86_32
26848 - if (regs->flags & X86_VM_MASK) {
26849 + if (v8086_mode(regs)) {
26850 local_irq_enable();
26851 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26852 goto exit;
26853 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26854 #endif
26855
26856 tsk = current;
26857 - if (!user_mode(regs)) {
26858 + if (!user_mode_novm(regs)) {
26859 if (fixup_exception(regs))
26860 goto exit;
26861
26862 tsk->thread.error_code = error_code;
26863 tsk->thread.trap_nr = X86_TRAP_GP;
26864 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26865 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26866 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26867 +
26868 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26869 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26870 + die("PAX: suspicious general protection fault", regs, error_code);
26871 + else
26872 +#endif
26873 +
26874 die("general protection fault", regs, error_code);
26875 + }
26876 goto exit;
26877 }
26878
26879 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26880 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26881 + struct mm_struct *mm = tsk->mm;
26882 + unsigned long limit;
26883 +
26884 + down_write(&mm->mmap_sem);
26885 + limit = mm->context.user_cs_limit;
26886 + if (limit < TASK_SIZE) {
26887 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26888 + up_write(&mm->mmap_sem);
26889 + return;
26890 + }
26891 + up_write(&mm->mmap_sem);
26892 + }
26893 +#endif
26894 +
26895 tsk->thread.error_code = error_code;
26896 tsk->thread.trap_nr = X86_TRAP_GP;
26897
26898 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26899 /* It's safe to allow irq's after DR6 has been saved */
26900 preempt_conditional_sti(regs);
26901
26902 - if (regs->flags & X86_VM_MASK) {
26903 + if (v8086_mode(regs)) {
26904 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26905 X86_TRAP_DB);
26906 preempt_conditional_cli(regs);
26907 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26908 * We already checked v86 mode above, so we can check for kernel mode
26909 * by just checking the CPL of CS.
26910 */
26911 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26912 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26913 tsk->thread.debugreg6 &= ~DR_STEP;
26914 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26915 regs->flags &= ~X86_EFLAGS_TF;
26916 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26917 return;
26918 conditional_sti(regs);
26919
26920 - if (!user_mode_vm(regs))
26921 + if (!user_mode(regs))
26922 {
26923 if (!fixup_exception(regs)) {
26924 task->thread.error_code = error_code;
26925 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26926 index 2ed8459..7cf329f 100644
26927 --- a/arch/x86/kernel/uprobes.c
26928 +++ b/arch/x86/kernel/uprobes.c
26929 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26930 int ret = NOTIFY_DONE;
26931
26932 /* We are only interested in userspace traps */
26933 - if (regs && !user_mode_vm(regs))
26934 + if (regs && !user_mode(regs))
26935 return NOTIFY_DONE;
26936
26937 switch (val) {
26938 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26939
26940 if (ncopied != rasize) {
26941 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26942 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26943 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26944
26945 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26946 }
26947 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26948 index b9242ba..50c5edd 100644
26949 --- a/arch/x86/kernel/verify_cpu.S
26950 +++ b/arch/x86/kernel/verify_cpu.S
26951 @@ -20,6 +20,7 @@
26952 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26953 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26954 * arch/x86/kernel/head_32.S: processor startup
26955 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26956 *
26957 * verify_cpu, returns the status of longmode and SSE in register %eax.
26958 * 0: Success 1: Failure
26959 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26960 index e8edcf5..27f9344 100644
26961 --- a/arch/x86/kernel/vm86_32.c
26962 +++ b/arch/x86/kernel/vm86_32.c
26963 @@ -44,6 +44,7 @@
26964 #include <linux/ptrace.h>
26965 #include <linux/audit.h>
26966 #include <linux/stddef.h>
26967 +#include <linux/grsecurity.h>
26968
26969 #include <asm/uaccess.h>
26970 #include <asm/io.h>
26971 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26972 do_exit(SIGSEGV);
26973 }
26974
26975 - tss = &per_cpu(init_tss, get_cpu());
26976 + tss = init_tss + get_cpu();
26977 current->thread.sp0 = current->thread.saved_sp0;
26978 current->thread.sysenter_cs = __KERNEL_CS;
26979 load_sp0(tss, &current->thread);
26980 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26981
26982 if (tsk->thread.saved_sp0)
26983 return -EPERM;
26984 +
26985 +#ifdef CONFIG_GRKERNSEC_VM86
26986 + if (!capable(CAP_SYS_RAWIO)) {
26987 + gr_handle_vm86();
26988 + return -EPERM;
26989 + }
26990 +#endif
26991 +
26992 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26993 offsetof(struct kernel_vm86_struct, vm86plus) -
26994 sizeof(info.regs));
26995 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26996 int tmp;
26997 struct vm86plus_struct __user *v86;
26998
26999 +#ifdef CONFIG_GRKERNSEC_VM86
27000 + if (!capable(CAP_SYS_RAWIO)) {
27001 + gr_handle_vm86();
27002 + return -EPERM;
27003 + }
27004 +#endif
27005 +
27006 tsk = current;
27007 switch (cmd) {
27008 case VM86_REQUEST_IRQ:
27009 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
27010 tsk->thread.saved_fs = info->regs32->fs;
27011 tsk->thread.saved_gs = get_user_gs(info->regs32);
27012
27013 - tss = &per_cpu(init_tss, get_cpu());
27014 + tss = init_tss + get_cpu();
27015 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
27016 if (cpu_has_sep)
27017 tsk->thread.sysenter_cs = 0;
27018 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
27019 goto cannot_handle;
27020 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
27021 goto cannot_handle;
27022 - intr_ptr = (unsigned long __user *) (i << 2);
27023 + intr_ptr = (__force unsigned long __user *) (i << 2);
27024 if (get_user(segoffs, intr_ptr))
27025 goto cannot_handle;
27026 if ((segoffs >> 16) == BIOSSEG)
27027 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
27028 index 10c4f30..65408b9 100644
27029 --- a/arch/x86/kernel/vmlinux.lds.S
27030 +++ b/arch/x86/kernel/vmlinux.lds.S
27031 @@ -26,6 +26,13 @@
27032 #include <asm/page_types.h>
27033 #include <asm/cache.h>
27034 #include <asm/boot.h>
27035 +#include <asm/segment.h>
27036 +
27037 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27038 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
27039 +#else
27040 +#define __KERNEL_TEXT_OFFSET 0
27041 +#endif
27042
27043 #undef i386 /* in case the preprocessor is a 32bit one */
27044
27045 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
27046
27047 PHDRS {
27048 text PT_LOAD FLAGS(5); /* R_E */
27049 +#ifdef CONFIG_X86_32
27050 + module PT_LOAD FLAGS(5); /* R_E */
27051 +#endif
27052 +#ifdef CONFIG_XEN
27053 + rodata PT_LOAD FLAGS(5); /* R_E */
27054 +#else
27055 + rodata PT_LOAD FLAGS(4); /* R__ */
27056 +#endif
27057 data PT_LOAD FLAGS(6); /* RW_ */
27058 -#ifdef CONFIG_X86_64
27059 + init.begin PT_LOAD FLAGS(6); /* RW_ */
27060 #ifdef CONFIG_SMP
27061 percpu PT_LOAD FLAGS(6); /* RW_ */
27062 #endif
27063 + text.init PT_LOAD FLAGS(5); /* R_E */
27064 + text.exit PT_LOAD FLAGS(5); /* R_E */
27065 init PT_LOAD FLAGS(7); /* RWE */
27066 -#endif
27067 note PT_NOTE FLAGS(0); /* ___ */
27068 }
27069
27070 SECTIONS
27071 {
27072 #ifdef CONFIG_X86_32
27073 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
27074 - phys_startup_32 = startup_32 - LOAD_OFFSET;
27075 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
27076 #else
27077 - . = __START_KERNEL;
27078 - phys_startup_64 = startup_64 - LOAD_OFFSET;
27079 + . = __START_KERNEL;
27080 #endif
27081
27082 /* Text and read-only data */
27083 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
27084 - _text = .;
27085 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27086 /* bootstrapping code */
27087 +#ifdef CONFIG_X86_32
27088 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
27089 +#else
27090 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
27091 +#endif
27092 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
27093 + _text = .;
27094 HEAD_TEXT
27095 . = ALIGN(8);
27096 _stext = .;
27097 @@ -104,13 +124,47 @@ SECTIONS
27098 IRQENTRY_TEXT
27099 *(.fixup)
27100 *(.gnu.warning)
27101 - /* End of text section */
27102 - _etext = .;
27103 } :text = 0x9090
27104
27105 - NOTES :text :note
27106 + . += __KERNEL_TEXT_OFFSET;
27107
27108 - EXCEPTION_TABLE(16) :text = 0x9090
27109 +#ifdef CONFIG_X86_32
27110 + . = ALIGN(PAGE_SIZE);
27111 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
27112 +
27113 +#ifdef CONFIG_PAX_KERNEXEC
27114 + MODULES_EXEC_VADDR = .;
27115 + BYTE(0)
27116 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
27117 + . = ALIGN(HPAGE_SIZE) - 1;
27118 + MODULES_EXEC_END = .;
27119 +#endif
27120 +
27121 + } :module
27122 +#endif
27123 +
27124 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
27125 + /* End of text section */
27126 + BYTE(0)
27127 + _etext = . - __KERNEL_TEXT_OFFSET;
27128 + }
27129 +
27130 +#ifdef CONFIG_X86_32
27131 + . = ALIGN(PAGE_SIZE);
27132 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
27133 + . = ALIGN(PAGE_SIZE);
27134 + *(.empty_zero_page)
27135 + *(.initial_pg_fixmap)
27136 + *(.initial_pg_pmd)
27137 + *(.initial_page_table)
27138 + *(.swapper_pg_dir)
27139 + } :rodata
27140 +#endif
27141 +
27142 + . = ALIGN(PAGE_SIZE);
27143 + NOTES :rodata :note
27144 +
27145 + EXCEPTION_TABLE(16) :rodata
27146
27147 #if defined(CONFIG_DEBUG_RODATA)
27148 /* .text should occupy whole number of pages */
27149 @@ -122,16 +176,20 @@ SECTIONS
27150
27151 /* Data */
27152 .data : AT(ADDR(.data) - LOAD_OFFSET) {
27153 +
27154 +#ifdef CONFIG_PAX_KERNEXEC
27155 + . = ALIGN(HPAGE_SIZE);
27156 +#else
27157 + . = ALIGN(PAGE_SIZE);
27158 +#endif
27159 +
27160 /* Start of data section */
27161 _sdata = .;
27162
27163 /* init_task */
27164 INIT_TASK_DATA(THREAD_SIZE)
27165
27166 -#ifdef CONFIG_X86_32
27167 - /* 32 bit has nosave before _edata */
27168 NOSAVE_DATA
27169 -#endif
27170
27171 PAGE_ALIGNED_DATA(PAGE_SIZE)
27172
27173 @@ -172,12 +230,19 @@ SECTIONS
27174 #endif /* CONFIG_X86_64 */
27175
27176 /* Init code and data - will be freed after init */
27177 - . = ALIGN(PAGE_SIZE);
27178 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
27179 + BYTE(0)
27180 +
27181 +#ifdef CONFIG_PAX_KERNEXEC
27182 + . = ALIGN(HPAGE_SIZE);
27183 +#else
27184 + . = ALIGN(PAGE_SIZE);
27185 +#endif
27186 +
27187 __init_begin = .; /* paired with __init_end */
27188 - }
27189 + } :init.begin
27190
27191 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
27192 +#ifdef CONFIG_SMP
27193 /*
27194 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
27195 * output PHDR, so the next output section - .init.text - should
27196 @@ -186,12 +251,27 @@ SECTIONS
27197 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
27198 #endif
27199
27200 - INIT_TEXT_SECTION(PAGE_SIZE)
27201 -#ifdef CONFIG_X86_64
27202 - :init
27203 -#endif
27204 + . = ALIGN(PAGE_SIZE);
27205 + init_begin = .;
27206 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
27207 + VMLINUX_SYMBOL(_sinittext) = .;
27208 + INIT_TEXT
27209 + VMLINUX_SYMBOL(_einittext) = .;
27210 + . = ALIGN(PAGE_SIZE);
27211 + } :text.init
27212
27213 - INIT_DATA_SECTION(16)
27214 + /*
27215 + * .exit.text is discard at runtime, not link time, to deal with
27216 + * references from .altinstructions and .eh_frame
27217 + */
27218 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27219 + EXIT_TEXT
27220 + . = ALIGN(16);
27221 + } :text.exit
27222 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
27223 +
27224 + . = ALIGN(PAGE_SIZE);
27225 + INIT_DATA_SECTION(16) :init
27226
27227 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
27228 __x86_cpu_dev_start = .;
27229 @@ -253,19 +333,12 @@ SECTIONS
27230 }
27231
27232 . = ALIGN(8);
27233 - /*
27234 - * .exit.text is discard at runtime, not link time, to deal with
27235 - * references from .altinstructions and .eh_frame
27236 - */
27237 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
27238 - EXIT_TEXT
27239 - }
27240
27241 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
27242 EXIT_DATA
27243 }
27244
27245 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
27246 +#ifndef CONFIG_SMP
27247 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
27248 #endif
27249
27250 @@ -284,16 +357,10 @@ SECTIONS
27251 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
27252 __smp_locks = .;
27253 *(.smp_locks)
27254 - . = ALIGN(PAGE_SIZE);
27255 __smp_locks_end = .;
27256 + . = ALIGN(PAGE_SIZE);
27257 }
27258
27259 -#ifdef CONFIG_X86_64
27260 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
27261 - NOSAVE_DATA
27262 - }
27263 -#endif
27264 -
27265 /* BSS */
27266 . = ALIGN(PAGE_SIZE);
27267 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
27268 @@ -309,6 +376,7 @@ SECTIONS
27269 __brk_base = .;
27270 . += 64 * 1024; /* 64k alignment slop space */
27271 *(.brk_reservation) /* areas brk users have reserved */
27272 + . = ALIGN(HPAGE_SIZE);
27273 __brk_limit = .;
27274 }
27275
27276 @@ -335,13 +403,12 @@ SECTIONS
27277 * for the boot processor.
27278 */
27279 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
27280 -INIT_PER_CPU(gdt_page);
27281 INIT_PER_CPU(irq_stack_union);
27282
27283 /*
27284 * Build-time check on the image size:
27285 */
27286 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
27287 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
27288 "kernel image bigger than KERNEL_IMAGE_SIZE");
27289
27290 #ifdef CONFIG_SMP
27291 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
27292 index 1f96f93..d5c8f7a 100644
27293 --- a/arch/x86/kernel/vsyscall_64.c
27294 +++ b/arch/x86/kernel/vsyscall_64.c
27295 @@ -56,15 +56,13 @@
27296 DEFINE_VVAR(int, vgetcpu_mode);
27297 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
27298
27299 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
27300 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
27301
27302 static int __init vsyscall_setup(char *str)
27303 {
27304 if (str) {
27305 if (!strcmp("emulate", str))
27306 vsyscall_mode = EMULATE;
27307 - else if (!strcmp("native", str))
27308 - vsyscall_mode = NATIVE;
27309 else if (!strcmp("none", str))
27310 vsyscall_mode = NONE;
27311 else
27312 @@ -323,8 +321,7 @@ do_ret:
27313 return true;
27314
27315 sigsegv:
27316 - force_sig(SIGSEGV, current);
27317 - return true;
27318 + do_group_exit(SIGKILL);
27319 }
27320
27321 /*
27322 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
27323 extern char __vvar_page;
27324 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
27325
27326 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
27327 - vsyscall_mode == NATIVE
27328 - ? PAGE_KERNEL_VSYSCALL
27329 - : PAGE_KERNEL_VVAR);
27330 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
27331 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
27332 (unsigned long)VSYSCALL_START);
27333
27334 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
27335 index b014d94..e775258 100644
27336 --- a/arch/x86/kernel/x8664_ksyms_64.c
27337 +++ b/arch/x86/kernel/x8664_ksyms_64.c
27338 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
27339 EXPORT_SYMBOL(copy_user_generic_unrolled);
27340 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
27341 EXPORT_SYMBOL(__copy_user_nocache);
27342 -EXPORT_SYMBOL(_copy_from_user);
27343 -EXPORT_SYMBOL(_copy_to_user);
27344
27345 EXPORT_SYMBOL(copy_page);
27346 EXPORT_SYMBOL(clear_page);
27347 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
27348 #ifndef CONFIG_PARAVIRT
27349 EXPORT_SYMBOL(native_load_gs_index);
27350 #endif
27351 +
27352 +#ifdef CONFIG_PAX_PER_CPU_PGD
27353 +EXPORT_SYMBOL(cpu_pgd);
27354 +#endif
27355 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
27356 index 8ce0072..431a0e7 100644
27357 --- a/arch/x86/kernel/x86_init.c
27358 +++ b/arch/x86/kernel/x86_init.c
27359 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
27360 static void default_nmi_init(void) { };
27361 static int default_i8042_detect(void) { return 1; };
27362
27363 -struct x86_platform_ops x86_platform = {
27364 +struct x86_platform_ops x86_platform __read_only = {
27365 .calibrate_tsc = native_calibrate_tsc,
27366 .get_wallclock = mach_get_cmos_time,
27367 .set_wallclock = mach_set_rtc_mmss,
27368 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
27369 EXPORT_SYMBOL_GPL(x86_platform);
27370
27371 #if defined(CONFIG_PCI_MSI)
27372 -struct x86_msi_ops x86_msi = {
27373 +struct x86_msi_ops x86_msi __read_only = {
27374 .setup_msi_irqs = native_setup_msi_irqs,
27375 .compose_msi_msg = native_compose_msi_msg,
27376 .teardown_msi_irq = native_teardown_msi_irq,
27377 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
27378 }
27379 #endif
27380
27381 -struct x86_io_apic_ops x86_io_apic_ops = {
27382 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
27383 .init = native_io_apic_init_mappings,
27384 .read = native_io_apic_read,
27385 .write = native_io_apic_write,
27386 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
27387 index 422fd82..c3687ca 100644
27388 --- a/arch/x86/kernel/xsave.c
27389 +++ b/arch/x86/kernel/xsave.c
27390 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
27391 {
27392 int err;
27393
27394 + buf = (struct xsave_struct __user *)____m(buf);
27395 if (use_xsave())
27396 err = xsave_user(buf);
27397 else if (use_fxsr())
27398 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
27399 */
27400 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
27401 {
27402 + buf = (void __user *)____m(buf);
27403 if (use_xsave()) {
27404 if ((unsigned long)buf % 64 || fx_only) {
27405 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
27406 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
27407 index b110fe6..d9c19f2 100644
27408 --- a/arch/x86/kvm/cpuid.c
27409 +++ b/arch/x86/kvm/cpuid.c
27410 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
27411 struct kvm_cpuid2 *cpuid,
27412 struct kvm_cpuid_entry2 __user *entries)
27413 {
27414 - int r;
27415 + int r, i;
27416
27417 r = -E2BIG;
27418 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
27419 goto out;
27420 r = -EFAULT;
27421 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
27422 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27423 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27424 goto out;
27425 + for (i = 0; i < cpuid->nent; ++i) {
27426 + struct kvm_cpuid_entry2 cpuid_entry;
27427 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
27428 + goto out;
27429 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
27430 + }
27431 vcpu->arch.cpuid_nent = cpuid->nent;
27432 kvm_apic_set_version(vcpu);
27433 kvm_x86_ops->cpuid_update(vcpu);
27434 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
27435 struct kvm_cpuid2 *cpuid,
27436 struct kvm_cpuid_entry2 __user *entries)
27437 {
27438 - int r;
27439 + int r, i;
27440
27441 r = -E2BIG;
27442 if (cpuid->nent < vcpu->arch.cpuid_nent)
27443 goto out;
27444 r = -EFAULT;
27445 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
27446 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27447 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27448 goto out;
27449 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
27450 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
27451 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
27452 + goto out;
27453 + }
27454 return 0;
27455
27456 out:
27457 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
27458 index 1673940..4bce95e 100644
27459 --- a/arch/x86/kvm/lapic.c
27460 +++ b/arch/x86/kvm/lapic.c
27461 @@ -55,7 +55,7 @@
27462 #define APIC_BUS_CYCLE_NS 1
27463
27464 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
27465 -#define apic_debug(fmt, arg...)
27466 +#define apic_debug(fmt, arg...) do {} while (0)
27467
27468 #define APIC_LVT_NUM 6
27469 /* 14 is the version for Xeon and Pentium 8.4.8*/
27470 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
27471 index ad75d77..a679d32 100644
27472 --- a/arch/x86/kvm/paging_tmpl.h
27473 +++ b/arch/x86/kvm/paging_tmpl.h
27474 @@ -331,7 +331,7 @@ retry_walk:
27475 if (unlikely(kvm_is_error_hva(host_addr)))
27476 goto error;
27477
27478 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
27479 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
27480 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
27481 goto error;
27482 walker->ptep_user[walker->level - 1] = ptep_user;
27483 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
27484 index c0bc803..6837a50 100644
27485 --- a/arch/x86/kvm/svm.c
27486 +++ b/arch/x86/kvm/svm.c
27487 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
27488 int cpu = raw_smp_processor_id();
27489
27490 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
27491 +
27492 + pax_open_kernel();
27493 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
27494 + pax_close_kernel();
27495 +
27496 load_TR_desc();
27497 }
27498
27499 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
27500 #endif
27501 #endif
27502
27503 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27504 + __set_fs(current_thread_info()->addr_limit);
27505 +#endif
27506 +
27507 reload_tss(vcpu);
27508
27509 local_irq_disable();
27510 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
27511 index 6128914..8be1dd2 100644
27512 --- a/arch/x86/kvm/vmx.c
27513 +++ b/arch/x86/kvm/vmx.c
27514 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
27515 #endif
27516 }
27517
27518 -static void vmcs_clear_bits(unsigned long field, u32 mask)
27519 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
27520 {
27521 vmcs_writel(field, vmcs_readl(field) & ~mask);
27522 }
27523
27524 -static void vmcs_set_bits(unsigned long field, u32 mask)
27525 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
27526 {
27527 vmcs_writel(field, vmcs_readl(field) | mask);
27528 }
27529 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
27530 struct desc_struct *descs;
27531
27532 descs = (void *)gdt->address;
27533 +
27534 + pax_open_kernel();
27535 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
27536 + pax_close_kernel();
27537 +
27538 load_TR_desc();
27539 }
27540
27541 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27542 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
27543 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
27544
27545 +#ifdef CONFIG_PAX_PER_CPU_PGD
27546 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27547 +#endif
27548 +
27549 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
27550 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
27551 vmx->loaded_vmcs->cpu = cpu;
27552 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
27553 * reads and returns guest's timestamp counter "register"
27554 * guest_tsc = host_tsc + tsc_offset -- 21.3
27555 */
27556 -static u64 guest_read_tsc(void)
27557 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
27558 {
27559 u64 host_tsc, tsc_offset;
27560
27561 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
27562 if (!cpu_has_vmx_flexpriority())
27563 flexpriority_enabled = 0;
27564
27565 - if (!cpu_has_vmx_tpr_shadow())
27566 - kvm_x86_ops->update_cr8_intercept = NULL;
27567 + if (!cpu_has_vmx_tpr_shadow()) {
27568 + pax_open_kernel();
27569 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27570 + pax_close_kernel();
27571 + }
27572
27573 if (enable_ept && !cpu_has_vmx_ept_2m_page())
27574 kvm_disable_largepages();
27575 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
27576 if (!cpu_has_vmx_apicv())
27577 enable_apicv = 0;
27578
27579 + pax_open_kernel();
27580 if (enable_apicv)
27581 - kvm_x86_ops->update_cr8_intercept = NULL;
27582 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27583 else {
27584 - kvm_x86_ops->hwapic_irr_update = NULL;
27585 - kvm_x86_ops->deliver_posted_interrupt = NULL;
27586 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27587 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
27588 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
27589 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27590 }
27591 + pax_close_kernel();
27592
27593 if (nested)
27594 nested_vmx_setup_ctls_msrs();
27595 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27596
27597 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
27598 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
27599 +
27600 +#ifndef CONFIG_PAX_PER_CPU_PGD
27601 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27602 +#endif
27603
27604 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
27605 #ifdef CONFIG_X86_64
27606 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27607 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
27608 vmx->host_idt_base = dt.address;
27609
27610 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
27611 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
27612
27613 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
27614 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
27615 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27616 "jmp 2f \n\t"
27617 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
27618 "2: "
27619 +
27620 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27621 + "ljmp %[cs],$3f\n\t"
27622 + "3: "
27623 +#endif
27624 +
27625 /* Save guest registers, load host registers, keep flags */
27626 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
27627 "pop %0 \n\t"
27628 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27629 #endif
27630 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
27631 [wordsize]"i"(sizeof(ulong))
27632 +
27633 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27634 + ,[cs]"i"(__KERNEL_CS)
27635 +#endif
27636 +
27637 : "cc", "memory"
27638 #ifdef CONFIG_X86_64
27639 , "rax", "rbx", "rdi", "rsi"
27640 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27641 if (debugctlmsr)
27642 update_debugctlmsr(debugctlmsr);
27643
27644 -#ifndef CONFIG_X86_64
27645 +#ifdef CONFIG_X86_32
27646 /*
27647 * The sysexit path does not restore ds/es, so we must set them to
27648 * a reasonable value ourselves.
27649 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27650 * may be executed in interrupt context, which saves and restore segments
27651 * around it, nullifying its effect.
27652 */
27653 - loadsegment(ds, __USER_DS);
27654 - loadsegment(es, __USER_DS);
27655 + loadsegment(ds, __KERNEL_DS);
27656 + loadsegment(es, __KERNEL_DS);
27657 + loadsegment(ss, __KERNEL_DS);
27658 +
27659 +#ifdef CONFIG_PAX_KERNEXEC
27660 + loadsegment(fs, __KERNEL_PERCPU);
27661 +#endif
27662 +
27663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27664 + __set_fs(current_thread_info()->addr_limit);
27665 +#endif
27666 +
27667 #endif
27668
27669 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
27670 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
27671 index eb9b9c9..0f30b12 100644
27672 --- a/arch/x86/kvm/x86.c
27673 +++ b/arch/x86/kvm/x86.c
27674 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
27675 {
27676 struct kvm *kvm = vcpu->kvm;
27677 int lm = is_long_mode(vcpu);
27678 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27679 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27680 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27681 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27682 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
27683 : kvm->arch.xen_hvm_config.blob_size_32;
27684 u32 page_num = data & ~PAGE_MASK;
27685 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
27686 if (n < msr_list.nmsrs)
27687 goto out;
27688 r = -EFAULT;
27689 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
27690 + goto out;
27691 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
27692 num_msrs_to_save * sizeof(u32)))
27693 goto out;
27694 @@ -5461,7 +5463,7 @@ static struct notifier_block pvclock_gtod_notifier = {
27695 };
27696 #endif
27697
27698 -int kvm_arch_init(void *opaque)
27699 +int kvm_arch_init(const void *opaque)
27700 {
27701 int r;
27702 struct kvm_x86_ops *ops = opaque;
27703 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
27704 index bdf8532..f63c587 100644
27705 --- a/arch/x86/lguest/boot.c
27706 +++ b/arch/x86/lguest/boot.c
27707 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
27708 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
27709 * Launcher to reboot us.
27710 */
27711 -static void lguest_restart(char *reason)
27712 +static __noreturn void lguest_restart(char *reason)
27713 {
27714 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
27715 + BUG();
27716 }
27717
27718 /*G:050
27719 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
27720 index 00933d5..3a64af9 100644
27721 --- a/arch/x86/lib/atomic64_386_32.S
27722 +++ b/arch/x86/lib/atomic64_386_32.S
27723 @@ -48,6 +48,10 @@ BEGIN(read)
27724 movl (v), %eax
27725 movl 4(v), %edx
27726 RET_ENDP
27727 +BEGIN(read_unchecked)
27728 + movl (v), %eax
27729 + movl 4(v), %edx
27730 +RET_ENDP
27731 #undef v
27732
27733 #define v %esi
27734 @@ -55,6 +59,10 @@ BEGIN(set)
27735 movl %ebx, (v)
27736 movl %ecx, 4(v)
27737 RET_ENDP
27738 +BEGIN(set_unchecked)
27739 + movl %ebx, (v)
27740 + movl %ecx, 4(v)
27741 +RET_ENDP
27742 #undef v
27743
27744 #define v %esi
27745 @@ -70,6 +78,20 @@ RET_ENDP
27746 BEGIN(add)
27747 addl %eax, (v)
27748 adcl %edx, 4(v)
27749 +
27750 +#ifdef CONFIG_PAX_REFCOUNT
27751 + jno 0f
27752 + subl %eax, (v)
27753 + sbbl %edx, 4(v)
27754 + int $4
27755 +0:
27756 + _ASM_EXTABLE(0b, 0b)
27757 +#endif
27758 +
27759 +RET_ENDP
27760 +BEGIN(add_unchecked)
27761 + addl %eax, (v)
27762 + adcl %edx, 4(v)
27763 RET_ENDP
27764 #undef v
27765
27766 @@ -77,6 +99,24 @@ RET_ENDP
27767 BEGIN(add_return)
27768 addl (v), %eax
27769 adcl 4(v), %edx
27770 +
27771 +#ifdef CONFIG_PAX_REFCOUNT
27772 + into
27773 +1234:
27774 + _ASM_EXTABLE(1234b, 2f)
27775 +#endif
27776 +
27777 + movl %eax, (v)
27778 + movl %edx, 4(v)
27779 +
27780 +#ifdef CONFIG_PAX_REFCOUNT
27781 +2:
27782 +#endif
27783 +
27784 +RET_ENDP
27785 +BEGIN(add_return_unchecked)
27786 + addl (v), %eax
27787 + adcl 4(v), %edx
27788 movl %eax, (v)
27789 movl %edx, 4(v)
27790 RET_ENDP
27791 @@ -86,6 +126,20 @@ RET_ENDP
27792 BEGIN(sub)
27793 subl %eax, (v)
27794 sbbl %edx, 4(v)
27795 +
27796 +#ifdef CONFIG_PAX_REFCOUNT
27797 + jno 0f
27798 + addl %eax, (v)
27799 + adcl %edx, 4(v)
27800 + int $4
27801 +0:
27802 + _ASM_EXTABLE(0b, 0b)
27803 +#endif
27804 +
27805 +RET_ENDP
27806 +BEGIN(sub_unchecked)
27807 + subl %eax, (v)
27808 + sbbl %edx, 4(v)
27809 RET_ENDP
27810 #undef v
27811
27812 @@ -96,6 +150,27 @@ BEGIN(sub_return)
27813 sbbl $0, %edx
27814 addl (v), %eax
27815 adcl 4(v), %edx
27816 +
27817 +#ifdef CONFIG_PAX_REFCOUNT
27818 + into
27819 +1234:
27820 + _ASM_EXTABLE(1234b, 2f)
27821 +#endif
27822 +
27823 + movl %eax, (v)
27824 + movl %edx, 4(v)
27825 +
27826 +#ifdef CONFIG_PAX_REFCOUNT
27827 +2:
27828 +#endif
27829 +
27830 +RET_ENDP
27831 +BEGIN(sub_return_unchecked)
27832 + negl %edx
27833 + negl %eax
27834 + sbbl $0, %edx
27835 + addl (v), %eax
27836 + adcl 4(v), %edx
27837 movl %eax, (v)
27838 movl %edx, 4(v)
27839 RET_ENDP
27840 @@ -105,6 +180,20 @@ RET_ENDP
27841 BEGIN(inc)
27842 addl $1, (v)
27843 adcl $0, 4(v)
27844 +
27845 +#ifdef CONFIG_PAX_REFCOUNT
27846 + jno 0f
27847 + subl $1, (v)
27848 + sbbl $0, 4(v)
27849 + int $4
27850 +0:
27851 + _ASM_EXTABLE(0b, 0b)
27852 +#endif
27853 +
27854 +RET_ENDP
27855 +BEGIN(inc_unchecked)
27856 + addl $1, (v)
27857 + adcl $0, 4(v)
27858 RET_ENDP
27859 #undef v
27860
27861 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27862 movl 4(v), %edx
27863 addl $1, %eax
27864 adcl $0, %edx
27865 +
27866 +#ifdef CONFIG_PAX_REFCOUNT
27867 + into
27868 +1234:
27869 + _ASM_EXTABLE(1234b, 2f)
27870 +#endif
27871 +
27872 + movl %eax, (v)
27873 + movl %edx, 4(v)
27874 +
27875 +#ifdef CONFIG_PAX_REFCOUNT
27876 +2:
27877 +#endif
27878 +
27879 +RET_ENDP
27880 +BEGIN(inc_return_unchecked)
27881 + movl (v), %eax
27882 + movl 4(v), %edx
27883 + addl $1, %eax
27884 + adcl $0, %edx
27885 movl %eax, (v)
27886 movl %edx, 4(v)
27887 RET_ENDP
27888 @@ -123,6 +232,20 @@ RET_ENDP
27889 BEGIN(dec)
27890 subl $1, (v)
27891 sbbl $0, 4(v)
27892 +
27893 +#ifdef CONFIG_PAX_REFCOUNT
27894 + jno 0f
27895 + addl $1, (v)
27896 + adcl $0, 4(v)
27897 + int $4
27898 +0:
27899 + _ASM_EXTABLE(0b, 0b)
27900 +#endif
27901 +
27902 +RET_ENDP
27903 +BEGIN(dec_unchecked)
27904 + subl $1, (v)
27905 + sbbl $0, 4(v)
27906 RET_ENDP
27907 #undef v
27908
27909 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27910 movl 4(v), %edx
27911 subl $1, %eax
27912 sbbl $0, %edx
27913 +
27914 +#ifdef CONFIG_PAX_REFCOUNT
27915 + into
27916 +1234:
27917 + _ASM_EXTABLE(1234b, 2f)
27918 +#endif
27919 +
27920 + movl %eax, (v)
27921 + movl %edx, 4(v)
27922 +
27923 +#ifdef CONFIG_PAX_REFCOUNT
27924 +2:
27925 +#endif
27926 +
27927 +RET_ENDP
27928 +BEGIN(dec_return_unchecked)
27929 + movl (v), %eax
27930 + movl 4(v), %edx
27931 + subl $1, %eax
27932 + sbbl $0, %edx
27933 movl %eax, (v)
27934 movl %edx, 4(v)
27935 RET_ENDP
27936 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27937 adcl %edx, %edi
27938 addl (v), %eax
27939 adcl 4(v), %edx
27940 +
27941 +#ifdef CONFIG_PAX_REFCOUNT
27942 + into
27943 +1234:
27944 + _ASM_EXTABLE(1234b, 2f)
27945 +#endif
27946 +
27947 cmpl %eax, %ecx
27948 je 3f
27949 1:
27950 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27951 1:
27952 addl $1, %eax
27953 adcl $0, %edx
27954 +
27955 +#ifdef CONFIG_PAX_REFCOUNT
27956 + into
27957 +1234:
27958 + _ASM_EXTABLE(1234b, 2f)
27959 +#endif
27960 +
27961 movl %eax, (v)
27962 movl %edx, 4(v)
27963 movl $1, %eax
27964 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27965 movl 4(v), %edx
27966 subl $1, %eax
27967 sbbl $0, %edx
27968 +
27969 +#ifdef CONFIG_PAX_REFCOUNT
27970 + into
27971 +1234:
27972 + _ASM_EXTABLE(1234b, 1f)
27973 +#endif
27974 +
27975 js 1f
27976 movl %eax, (v)
27977 movl %edx, 4(v)
27978 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27979 index f5cc9eb..51fa319 100644
27980 --- a/arch/x86/lib/atomic64_cx8_32.S
27981 +++ b/arch/x86/lib/atomic64_cx8_32.S
27982 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27983 CFI_STARTPROC
27984
27985 read64 %ecx
27986 + pax_force_retaddr
27987 ret
27988 CFI_ENDPROC
27989 ENDPROC(atomic64_read_cx8)
27990
27991 +ENTRY(atomic64_read_unchecked_cx8)
27992 + CFI_STARTPROC
27993 +
27994 + read64 %ecx
27995 + pax_force_retaddr
27996 + ret
27997 + CFI_ENDPROC
27998 +ENDPROC(atomic64_read_unchecked_cx8)
27999 +
28000 ENTRY(atomic64_set_cx8)
28001 CFI_STARTPROC
28002
28003 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
28004 cmpxchg8b (%esi)
28005 jne 1b
28006
28007 + pax_force_retaddr
28008 ret
28009 CFI_ENDPROC
28010 ENDPROC(atomic64_set_cx8)
28011
28012 +ENTRY(atomic64_set_unchecked_cx8)
28013 + CFI_STARTPROC
28014 +
28015 +1:
28016 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
28017 + * are atomic on 586 and newer */
28018 + cmpxchg8b (%esi)
28019 + jne 1b
28020 +
28021 + pax_force_retaddr
28022 + ret
28023 + CFI_ENDPROC
28024 +ENDPROC(atomic64_set_unchecked_cx8)
28025 +
28026 ENTRY(atomic64_xchg_cx8)
28027 CFI_STARTPROC
28028
28029 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
28030 cmpxchg8b (%esi)
28031 jne 1b
28032
28033 + pax_force_retaddr
28034 ret
28035 CFI_ENDPROC
28036 ENDPROC(atomic64_xchg_cx8)
28037
28038 -.macro addsub_return func ins insc
28039 -ENTRY(atomic64_\func\()_return_cx8)
28040 +.macro addsub_return func ins insc unchecked=""
28041 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
28042 CFI_STARTPROC
28043 SAVE ebp
28044 SAVE ebx
28045 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
28046 movl %edx, %ecx
28047 \ins\()l %esi, %ebx
28048 \insc\()l %edi, %ecx
28049 +
28050 +.ifb \unchecked
28051 +#ifdef CONFIG_PAX_REFCOUNT
28052 + into
28053 +2:
28054 + _ASM_EXTABLE(2b, 3f)
28055 +#endif
28056 +.endif
28057 +
28058 LOCK_PREFIX
28059 cmpxchg8b (%ebp)
28060 jne 1b
28061 -
28062 -10:
28063 movl %ebx, %eax
28064 movl %ecx, %edx
28065 +
28066 +.ifb \unchecked
28067 +#ifdef CONFIG_PAX_REFCOUNT
28068 +3:
28069 +#endif
28070 +.endif
28071 +
28072 RESTORE edi
28073 RESTORE esi
28074 RESTORE ebx
28075 RESTORE ebp
28076 + pax_force_retaddr
28077 ret
28078 CFI_ENDPROC
28079 -ENDPROC(atomic64_\func\()_return_cx8)
28080 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28081 .endm
28082
28083 addsub_return add add adc
28084 addsub_return sub sub sbb
28085 +addsub_return add add adc _unchecked
28086 +addsub_return sub sub sbb _unchecked
28087
28088 -.macro incdec_return func ins insc
28089 -ENTRY(atomic64_\func\()_return_cx8)
28090 +.macro incdec_return func ins insc unchecked=""
28091 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
28092 CFI_STARTPROC
28093 SAVE ebx
28094
28095 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
28096 movl %edx, %ecx
28097 \ins\()l $1, %ebx
28098 \insc\()l $0, %ecx
28099 +
28100 +.ifb \unchecked
28101 +#ifdef CONFIG_PAX_REFCOUNT
28102 + into
28103 +2:
28104 + _ASM_EXTABLE(2b, 3f)
28105 +#endif
28106 +.endif
28107 +
28108 LOCK_PREFIX
28109 cmpxchg8b (%esi)
28110 jne 1b
28111
28112 -10:
28113 movl %ebx, %eax
28114 movl %ecx, %edx
28115 +
28116 +.ifb \unchecked
28117 +#ifdef CONFIG_PAX_REFCOUNT
28118 +3:
28119 +#endif
28120 +.endif
28121 +
28122 RESTORE ebx
28123 + pax_force_retaddr
28124 ret
28125 CFI_ENDPROC
28126 -ENDPROC(atomic64_\func\()_return_cx8)
28127 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28128 .endm
28129
28130 incdec_return inc add adc
28131 incdec_return dec sub sbb
28132 +incdec_return inc add adc _unchecked
28133 +incdec_return dec sub sbb _unchecked
28134
28135 ENTRY(atomic64_dec_if_positive_cx8)
28136 CFI_STARTPROC
28137 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
28138 movl %edx, %ecx
28139 subl $1, %ebx
28140 sbb $0, %ecx
28141 +
28142 +#ifdef CONFIG_PAX_REFCOUNT
28143 + into
28144 +1234:
28145 + _ASM_EXTABLE(1234b, 2f)
28146 +#endif
28147 +
28148 js 2f
28149 LOCK_PREFIX
28150 cmpxchg8b (%esi)
28151 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
28152 movl %ebx, %eax
28153 movl %ecx, %edx
28154 RESTORE ebx
28155 + pax_force_retaddr
28156 ret
28157 CFI_ENDPROC
28158 ENDPROC(atomic64_dec_if_positive_cx8)
28159 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
28160 movl %edx, %ecx
28161 addl %ebp, %ebx
28162 adcl %edi, %ecx
28163 +
28164 +#ifdef CONFIG_PAX_REFCOUNT
28165 + into
28166 +1234:
28167 + _ASM_EXTABLE(1234b, 3f)
28168 +#endif
28169 +
28170 LOCK_PREFIX
28171 cmpxchg8b (%esi)
28172 jne 1b
28173 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
28174 CFI_ADJUST_CFA_OFFSET -8
28175 RESTORE ebx
28176 RESTORE ebp
28177 + pax_force_retaddr
28178 ret
28179 4:
28180 cmpl %edx, 4(%esp)
28181 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
28182 xorl %ecx, %ecx
28183 addl $1, %ebx
28184 adcl %edx, %ecx
28185 +
28186 +#ifdef CONFIG_PAX_REFCOUNT
28187 + into
28188 +1234:
28189 + _ASM_EXTABLE(1234b, 3f)
28190 +#endif
28191 +
28192 LOCK_PREFIX
28193 cmpxchg8b (%esi)
28194 jne 1b
28195 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
28196 movl $1, %eax
28197 3:
28198 RESTORE ebx
28199 + pax_force_retaddr
28200 ret
28201 CFI_ENDPROC
28202 ENDPROC(atomic64_inc_not_zero_cx8)
28203 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
28204 index e78b8ee..7e173a8 100644
28205 --- a/arch/x86/lib/checksum_32.S
28206 +++ b/arch/x86/lib/checksum_32.S
28207 @@ -29,7 +29,8 @@
28208 #include <asm/dwarf2.h>
28209 #include <asm/errno.h>
28210 #include <asm/asm.h>
28211 -
28212 +#include <asm/segment.h>
28213 +
28214 /*
28215 * computes a partial checksum, e.g. for TCP/UDP fragments
28216 */
28217 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
28218
28219 #define ARGBASE 16
28220 #define FP 12
28221 -
28222 -ENTRY(csum_partial_copy_generic)
28223 +
28224 +ENTRY(csum_partial_copy_generic_to_user)
28225 CFI_STARTPROC
28226 +
28227 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28228 + pushl_cfi %gs
28229 + popl_cfi %es
28230 + jmp csum_partial_copy_generic
28231 +#endif
28232 +
28233 +ENTRY(csum_partial_copy_generic_from_user)
28234 +
28235 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28236 + pushl_cfi %gs
28237 + popl_cfi %ds
28238 +#endif
28239 +
28240 +ENTRY(csum_partial_copy_generic)
28241 subl $4,%esp
28242 CFI_ADJUST_CFA_OFFSET 4
28243 pushl_cfi %edi
28244 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
28245 jmp 4f
28246 SRC(1: movw (%esi), %bx )
28247 addl $2, %esi
28248 -DST( movw %bx, (%edi) )
28249 +DST( movw %bx, %es:(%edi) )
28250 addl $2, %edi
28251 addw %bx, %ax
28252 adcl $0, %eax
28253 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
28254 SRC(1: movl (%esi), %ebx )
28255 SRC( movl 4(%esi), %edx )
28256 adcl %ebx, %eax
28257 -DST( movl %ebx, (%edi) )
28258 +DST( movl %ebx, %es:(%edi) )
28259 adcl %edx, %eax
28260 -DST( movl %edx, 4(%edi) )
28261 +DST( movl %edx, %es:4(%edi) )
28262
28263 SRC( movl 8(%esi), %ebx )
28264 SRC( movl 12(%esi), %edx )
28265 adcl %ebx, %eax
28266 -DST( movl %ebx, 8(%edi) )
28267 +DST( movl %ebx, %es:8(%edi) )
28268 adcl %edx, %eax
28269 -DST( movl %edx, 12(%edi) )
28270 +DST( movl %edx, %es:12(%edi) )
28271
28272 SRC( movl 16(%esi), %ebx )
28273 SRC( movl 20(%esi), %edx )
28274 adcl %ebx, %eax
28275 -DST( movl %ebx, 16(%edi) )
28276 +DST( movl %ebx, %es:16(%edi) )
28277 adcl %edx, %eax
28278 -DST( movl %edx, 20(%edi) )
28279 +DST( movl %edx, %es:20(%edi) )
28280
28281 SRC( movl 24(%esi), %ebx )
28282 SRC( movl 28(%esi), %edx )
28283 adcl %ebx, %eax
28284 -DST( movl %ebx, 24(%edi) )
28285 +DST( movl %ebx, %es:24(%edi) )
28286 adcl %edx, %eax
28287 -DST( movl %edx, 28(%edi) )
28288 +DST( movl %edx, %es:28(%edi) )
28289
28290 lea 32(%esi), %esi
28291 lea 32(%edi), %edi
28292 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
28293 shrl $2, %edx # This clears CF
28294 SRC(3: movl (%esi), %ebx )
28295 adcl %ebx, %eax
28296 -DST( movl %ebx, (%edi) )
28297 +DST( movl %ebx, %es:(%edi) )
28298 lea 4(%esi), %esi
28299 lea 4(%edi), %edi
28300 dec %edx
28301 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
28302 jb 5f
28303 SRC( movw (%esi), %cx )
28304 leal 2(%esi), %esi
28305 -DST( movw %cx, (%edi) )
28306 +DST( movw %cx, %es:(%edi) )
28307 leal 2(%edi), %edi
28308 je 6f
28309 shll $16,%ecx
28310 SRC(5: movb (%esi), %cl )
28311 -DST( movb %cl, (%edi) )
28312 +DST( movb %cl, %es:(%edi) )
28313 6: addl %ecx, %eax
28314 adcl $0, %eax
28315 7:
28316 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
28317
28318 6001:
28319 movl ARGBASE+20(%esp), %ebx # src_err_ptr
28320 - movl $-EFAULT, (%ebx)
28321 + movl $-EFAULT, %ss:(%ebx)
28322
28323 # zero the complete destination - computing the rest
28324 # is too much work
28325 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
28326
28327 6002:
28328 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28329 - movl $-EFAULT,(%ebx)
28330 + movl $-EFAULT,%ss:(%ebx)
28331 jmp 5000b
28332
28333 .previous
28334
28335 + pushl_cfi %ss
28336 + popl_cfi %ds
28337 + pushl_cfi %ss
28338 + popl_cfi %es
28339 popl_cfi %ebx
28340 CFI_RESTORE ebx
28341 popl_cfi %esi
28342 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
28343 popl_cfi %ecx # equivalent to addl $4,%esp
28344 ret
28345 CFI_ENDPROC
28346 -ENDPROC(csum_partial_copy_generic)
28347 +ENDPROC(csum_partial_copy_generic_to_user)
28348
28349 #else
28350
28351 /* Version for PentiumII/PPro */
28352
28353 #define ROUND1(x) \
28354 + nop; nop; nop; \
28355 SRC(movl x(%esi), %ebx ) ; \
28356 addl %ebx, %eax ; \
28357 - DST(movl %ebx, x(%edi) ) ;
28358 + DST(movl %ebx, %es:x(%edi)) ;
28359
28360 #define ROUND(x) \
28361 + nop; nop; nop; \
28362 SRC(movl x(%esi), %ebx ) ; \
28363 adcl %ebx, %eax ; \
28364 - DST(movl %ebx, x(%edi) ) ;
28365 + DST(movl %ebx, %es:x(%edi)) ;
28366
28367 #define ARGBASE 12
28368 -
28369 -ENTRY(csum_partial_copy_generic)
28370 +
28371 +ENTRY(csum_partial_copy_generic_to_user)
28372 CFI_STARTPROC
28373 +
28374 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28375 + pushl_cfi %gs
28376 + popl_cfi %es
28377 + jmp csum_partial_copy_generic
28378 +#endif
28379 +
28380 +ENTRY(csum_partial_copy_generic_from_user)
28381 +
28382 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28383 + pushl_cfi %gs
28384 + popl_cfi %ds
28385 +#endif
28386 +
28387 +ENTRY(csum_partial_copy_generic)
28388 pushl_cfi %ebx
28389 CFI_REL_OFFSET ebx, 0
28390 pushl_cfi %edi
28391 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
28392 subl %ebx, %edi
28393 lea -1(%esi),%edx
28394 andl $-32,%edx
28395 - lea 3f(%ebx,%ebx), %ebx
28396 + lea 3f(%ebx,%ebx,2), %ebx
28397 testl %esi, %esi
28398 jmp *%ebx
28399 1: addl $64,%esi
28400 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
28401 jb 5f
28402 SRC( movw (%esi), %dx )
28403 leal 2(%esi), %esi
28404 -DST( movw %dx, (%edi) )
28405 +DST( movw %dx, %es:(%edi) )
28406 leal 2(%edi), %edi
28407 je 6f
28408 shll $16,%edx
28409 5:
28410 SRC( movb (%esi), %dl )
28411 -DST( movb %dl, (%edi) )
28412 +DST( movb %dl, %es:(%edi) )
28413 6: addl %edx, %eax
28414 adcl $0, %eax
28415 7:
28416 .section .fixup, "ax"
28417 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
28418 - movl $-EFAULT, (%ebx)
28419 + movl $-EFAULT, %ss:(%ebx)
28420 # zero the complete destination (computing the rest is too much work)
28421 movl ARGBASE+8(%esp),%edi # dst
28422 movl ARGBASE+12(%esp),%ecx # len
28423 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
28424 rep; stosb
28425 jmp 7b
28426 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28427 - movl $-EFAULT, (%ebx)
28428 + movl $-EFAULT, %ss:(%ebx)
28429 jmp 7b
28430 .previous
28431
28432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28433 + pushl_cfi %ss
28434 + popl_cfi %ds
28435 + pushl_cfi %ss
28436 + popl_cfi %es
28437 +#endif
28438 +
28439 popl_cfi %esi
28440 CFI_RESTORE esi
28441 popl_cfi %edi
28442 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
28443 CFI_RESTORE ebx
28444 ret
28445 CFI_ENDPROC
28446 -ENDPROC(csum_partial_copy_generic)
28447 +ENDPROC(csum_partial_copy_generic_to_user)
28448
28449 #undef ROUND
28450 #undef ROUND1
28451 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
28452 index f2145cf..cea889d 100644
28453 --- a/arch/x86/lib/clear_page_64.S
28454 +++ b/arch/x86/lib/clear_page_64.S
28455 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
28456 movl $4096/8,%ecx
28457 xorl %eax,%eax
28458 rep stosq
28459 + pax_force_retaddr
28460 ret
28461 CFI_ENDPROC
28462 ENDPROC(clear_page_c)
28463 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
28464 movl $4096,%ecx
28465 xorl %eax,%eax
28466 rep stosb
28467 + pax_force_retaddr
28468 ret
28469 CFI_ENDPROC
28470 ENDPROC(clear_page_c_e)
28471 @@ -43,6 +45,7 @@ ENTRY(clear_page)
28472 leaq 64(%rdi),%rdi
28473 jnz .Lloop
28474 nop
28475 + pax_force_retaddr
28476 ret
28477 CFI_ENDPROC
28478 .Lclear_page_end:
28479 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
28480
28481 #include <asm/cpufeature.h>
28482
28483 - .section .altinstr_replacement,"ax"
28484 + .section .altinstr_replacement,"a"
28485 1: .byte 0xeb /* jmp <disp8> */
28486 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
28487 2: .byte 0xeb /* jmp <disp8> */
28488 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
28489 index 1e572c5..2a162cd 100644
28490 --- a/arch/x86/lib/cmpxchg16b_emu.S
28491 +++ b/arch/x86/lib/cmpxchg16b_emu.S
28492 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
28493
28494 popf
28495 mov $1, %al
28496 + pax_force_retaddr
28497 ret
28498
28499 not_same:
28500 popf
28501 xor %al,%al
28502 + pax_force_retaddr
28503 ret
28504
28505 CFI_ENDPROC
28506 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
28507 index 176cca6..e0d658e 100644
28508 --- a/arch/x86/lib/copy_page_64.S
28509 +++ b/arch/x86/lib/copy_page_64.S
28510 @@ -9,6 +9,7 @@ copy_page_rep:
28511 CFI_STARTPROC
28512 movl $4096/8, %ecx
28513 rep movsq
28514 + pax_force_retaddr
28515 ret
28516 CFI_ENDPROC
28517 ENDPROC(copy_page_rep)
28518 @@ -24,8 +25,8 @@ ENTRY(copy_page)
28519 CFI_ADJUST_CFA_OFFSET 2*8
28520 movq %rbx, (%rsp)
28521 CFI_REL_OFFSET rbx, 0
28522 - movq %r12, 1*8(%rsp)
28523 - CFI_REL_OFFSET r12, 1*8
28524 + movq %r13, 1*8(%rsp)
28525 + CFI_REL_OFFSET r13, 1*8
28526
28527 movl $(4096/64)-5, %ecx
28528 .p2align 4
28529 @@ -38,7 +39,7 @@ ENTRY(copy_page)
28530 movq 0x8*4(%rsi), %r9
28531 movq 0x8*5(%rsi), %r10
28532 movq 0x8*6(%rsi), %r11
28533 - movq 0x8*7(%rsi), %r12
28534 + movq 0x8*7(%rsi), %r13
28535
28536 prefetcht0 5*64(%rsi)
28537
28538 @@ -49,7 +50,7 @@ ENTRY(copy_page)
28539 movq %r9, 0x8*4(%rdi)
28540 movq %r10, 0x8*5(%rdi)
28541 movq %r11, 0x8*6(%rdi)
28542 - movq %r12, 0x8*7(%rdi)
28543 + movq %r13, 0x8*7(%rdi)
28544
28545 leaq 64 (%rsi), %rsi
28546 leaq 64 (%rdi), %rdi
28547 @@ -68,7 +69,7 @@ ENTRY(copy_page)
28548 movq 0x8*4(%rsi), %r9
28549 movq 0x8*5(%rsi), %r10
28550 movq 0x8*6(%rsi), %r11
28551 - movq 0x8*7(%rsi), %r12
28552 + movq 0x8*7(%rsi), %r13
28553
28554 movq %rax, 0x8*0(%rdi)
28555 movq %rbx, 0x8*1(%rdi)
28556 @@ -77,7 +78,7 @@ ENTRY(copy_page)
28557 movq %r9, 0x8*4(%rdi)
28558 movq %r10, 0x8*5(%rdi)
28559 movq %r11, 0x8*6(%rdi)
28560 - movq %r12, 0x8*7(%rdi)
28561 + movq %r13, 0x8*7(%rdi)
28562
28563 leaq 64(%rdi), %rdi
28564 leaq 64(%rsi), %rsi
28565 @@ -85,10 +86,11 @@ ENTRY(copy_page)
28566
28567 movq (%rsp), %rbx
28568 CFI_RESTORE rbx
28569 - movq 1*8(%rsp), %r12
28570 - CFI_RESTORE r12
28571 + movq 1*8(%rsp), %r13
28572 + CFI_RESTORE r13
28573 addq $2*8, %rsp
28574 CFI_ADJUST_CFA_OFFSET -2*8
28575 + pax_force_retaddr
28576 ret
28577 .Lcopy_page_end:
28578 CFI_ENDPROC
28579 @@ -99,7 +101,7 @@ ENDPROC(copy_page)
28580
28581 #include <asm/cpufeature.h>
28582
28583 - .section .altinstr_replacement,"ax"
28584 + .section .altinstr_replacement,"a"
28585 1: .byte 0xeb /* jmp <disp8> */
28586 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
28587 2:
28588 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
28589 index a30ca15..407412b 100644
28590 --- a/arch/x86/lib/copy_user_64.S
28591 +++ b/arch/x86/lib/copy_user_64.S
28592 @@ -18,31 +18,7 @@
28593 #include <asm/alternative-asm.h>
28594 #include <asm/asm.h>
28595 #include <asm/smap.h>
28596 -
28597 -/*
28598 - * By placing feature2 after feature1 in altinstructions section, we logically
28599 - * implement:
28600 - * If CPU has feature2, jmp to alt2 is used
28601 - * else if CPU has feature1, jmp to alt1 is used
28602 - * else jmp to orig is used.
28603 - */
28604 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
28605 -0:
28606 - .byte 0xe9 /* 32bit jump */
28607 - .long \orig-1f /* by default jump to orig */
28608 -1:
28609 - .section .altinstr_replacement,"ax"
28610 -2: .byte 0xe9 /* near jump with 32bit immediate */
28611 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
28612 -3: .byte 0xe9 /* near jump with 32bit immediate */
28613 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
28614 - .previous
28615 -
28616 - .section .altinstructions,"a"
28617 - altinstruction_entry 0b,2b,\feature1,5,5
28618 - altinstruction_entry 0b,3b,\feature2,5,5
28619 - .previous
28620 - .endm
28621 +#include <asm/pgtable.h>
28622
28623 .macro ALIGN_DESTINATION
28624 #ifdef FIX_ALIGNMENT
28625 @@ -70,52 +46,6 @@
28626 #endif
28627 .endm
28628
28629 -/* Standard copy_to_user with segment limit checking */
28630 -ENTRY(_copy_to_user)
28631 - CFI_STARTPROC
28632 - GET_THREAD_INFO(%rax)
28633 - movq %rdi,%rcx
28634 - addq %rdx,%rcx
28635 - jc bad_to_user
28636 - cmpq TI_addr_limit(%rax),%rcx
28637 - ja bad_to_user
28638 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28639 - copy_user_generic_unrolled,copy_user_generic_string, \
28640 - copy_user_enhanced_fast_string
28641 - CFI_ENDPROC
28642 -ENDPROC(_copy_to_user)
28643 -
28644 -/* Standard copy_from_user with segment limit checking */
28645 -ENTRY(_copy_from_user)
28646 - CFI_STARTPROC
28647 - GET_THREAD_INFO(%rax)
28648 - movq %rsi,%rcx
28649 - addq %rdx,%rcx
28650 - jc bad_from_user
28651 - cmpq TI_addr_limit(%rax),%rcx
28652 - ja bad_from_user
28653 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28654 - copy_user_generic_unrolled,copy_user_generic_string, \
28655 - copy_user_enhanced_fast_string
28656 - CFI_ENDPROC
28657 -ENDPROC(_copy_from_user)
28658 -
28659 - .section .fixup,"ax"
28660 - /* must zero dest */
28661 -ENTRY(bad_from_user)
28662 -bad_from_user:
28663 - CFI_STARTPROC
28664 - movl %edx,%ecx
28665 - xorl %eax,%eax
28666 - rep
28667 - stosb
28668 -bad_to_user:
28669 - movl %edx,%eax
28670 - ret
28671 - CFI_ENDPROC
28672 -ENDPROC(bad_from_user)
28673 - .previous
28674 -
28675 /*
28676 * copy_user_generic_unrolled - memory copy with exception handling.
28677 * This version is for CPUs like P4 that don't have efficient micro
28678 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
28679 */
28680 ENTRY(copy_user_generic_unrolled)
28681 CFI_STARTPROC
28682 + ASM_PAX_OPEN_USERLAND
28683 ASM_STAC
28684 cmpl $8,%edx
28685 jb 20f /* less then 8 bytes, go to byte copy loop */
28686 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
28687 jnz 21b
28688 23: xor %eax,%eax
28689 ASM_CLAC
28690 + ASM_PAX_CLOSE_USERLAND
28691 + pax_force_retaddr
28692 ret
28693
28694 .section .fixup,"ax"
28695 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
28696 */
28697 ENTRY(copy_user_generic_string)
28698 CFI_STARTPROC
28699 + ASM_PAX_OPEN_USERLAND
28700 ASM_STAC
28701 andl %edx,%edx
28702 jz 4f
28703 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
28704 movsb
28705 4: xorl %eax,%eax
28706 ASM_CLAC
28707 + ASM_PAX_CLOSE_USERLAND
28708 + pax_force_retaddr
28709 ret
28710
28711 .section .fixup,"ax"
28712 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
28713 */
28714 ENTRY(copy_user_enhanced_fast_string)
28715 CFI_STARTPROC
28716 + ASM_PAX_OPEN_USERLAND
28717 ASM_STAC
28718 andl %edx,%edx
28719 jz 2f
28720 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
28721 movsb
28722 2: xorl %eax,%eax
28723 ASM_CLAC
28724 + ASM_PAX_CLOSE_USERLAND
28725 + pax_force_retaddr
28726 ret
28727
28728 .section .fixup,"ax"
28729 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
28730 index 6a4f43c..c70fb52 100644
28731 --- a/arch/x86/lib/copy_user_nocache_64.S
28732 +++ b/arch/x86/lib/copy_user_nocache_64.S
28733 @@ -8,6 +8,7 @@
28734
28735 #include <linux/linkage.h>
28736 #include <asm/dwarf2.h>
28737 +#include <asm/alternative-asm.h>
28738
28739 #define FIX_ALIGNMENT 1
28740
28741 @@ -16,6 +17,7 @@
28742 #include <asm/thread_info.h>
28743 #include <asm/asm.h>
28744 #include <asm/smap.h>
28745 +#include <asm/pgtable.h>
28746
28747 .macro ALIGN_DESTINATION
28748 #ifdef FIX_ALIGNMENT
28749 @@ -49,6 +51,16 @@
28750 */
28751 ENTRY(__copy_user_nocache)
28752 CFI_STARTPROC
28753 +
28754 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28755 + mov pax_user_shadow_base,%rcx
28756 + cmp %rcx,%rsi
28757 + jae 1f
28758 + add %rcx,%rsi
28759 +1:
28760 +#endif
28761 +
28762 + ASM_PAX_OPEN_USERLAND
28763 ASM_STAC
28764 cmpl $8,%edx
28765 jb 20f /* less then 8 bytes, go to byte copy loop */
28766 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
28767 jnz 21b
28768 23: xorl %eax,%eax
28769 ASM_CLAC
28770 + ASM_PAX_CLOSE_USERLAND
28771 sfence
28772 + pax_force_retaddr
28773 ret
28774
28775 .section .fixup,"ax"
28776 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
28777 index 2419d5f..fe52d0e 100644
28778 --- a/arch/x86/lib/csum-copy_64.S
28779 +++ b/arch/x86/lib/csum-copy_64.S
28780 @@ -9,6 +9,7 @@
28781 #include <asm/dwarf2.h>
28782 #include <asm/errno.h>
28783 #include <asm/asm.h>
28784 +#include <asm/alternative-asm.h>
28785
28786 /*
28787 * Checksum copy with exception handling.
28788 @@ -56,8 +57,8 @@ ENTRY(csum_partial_copy_generic)
28789 CFI_ADJUST_CFA_OFFSET 7*8
28790 movq %rbx, 2*8(%rsp)
28791 CFI_REL_OFFSET rbx, 2*8
28792 - movq %r12, 3*8(%rsp)
28793 - CFI_REL_OFFSET r12, 3*8
28794 + movq %r15, 3*8(%rsp)
28795 + CFI_REL_OFFSET r15, 3*8
28796 movq %r14, 4*8(%rsp)
28797 CFI_REL_OFFSET r14, 4*8
28798 movq %r13, 5*8(%rsp)
28799 @@ -72,16 +73,16 @@ ENTRY(csum_partial_copy_generic)
28800 movl %edx, %ecx
28801
28802 xorl %r9d, %r9d
28803 - movq %rcx, %r12
28804 + movq %rcx, %r15
28805
28806 - shrq $6, %r12
28807 + shrq $6, %r15
28808 jz .Lhandle_tail /* < 64 */
28809
28810 clc
28811
28812 /* main loop. clear in 64 byte blocks */
28813 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
28814 - /* r11: temp3, rdx: temp4, r12 loopcnt */
28815 + /* r11: temp3, rdx: temp4, r15 loopcnt */
28816 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
28817 .p2align 4
28818 .Lloop:
28819 @@ -115,7 +116,7 @@ ENTRY(csum_partial_copy_generic)
28820 adcq %r14, %rax
28821 adcq %r13, %rax
28822
28823 - decl %r12d
28824 + decl %r15d
28825
28826 dest
28827 movq %rbx, (%rsi)
28828 @@ -210,8 +211,8 @@ ENTRY(csum_partial_copy_generic)
28829 .Lende:
28830 movq 2*8(%rsp), %rbx
28831 CFI_RESTORE rbx
28832 - movq 3*8(%rsp), %r12
28833 - CFI_RESTORE r12
28834 + movq 3*8(%rsp), %r15
28835 + CFI_RESTORE r15
28836 movq 4*8(%rsp), %r14
28837 CFI_RESTORE r14
28838 movq 5*8(%rsp), %r13
28839 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
28840 CFI_RESTORE rbp
28841 addq $7*8, %rsp
28842 CFI_ADJUST_CFA_OFFSET -7*8
28843 + pax_force_retaddr
28844 ret
28845 CFI_RESTORE_STATE
28846
28847 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28848 index 7609e0e..b449b98 100644
28849 --- a/arch/x86/lib/csum-wrappers_64.c
28850 +++ b/arch/x86/lib/csum-wrappers_64.c
28851 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28852 len -= 2;
28853 }
28854 }
28855 + pax_open_userland();
28856 stac();
28857 - isum = csum_partial_copy_generic((__force const void *)src,
28858 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28859 dst, len, isum, errp, NULL);
28860 clac();
28861 + pax_close_userland();
28862 if (unlikely(*errp))
28863 goto out_err;
28864
28865 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28866 }
28867
28868 *errp = 0;
28869 + pax_open_userland();
28870 stac();
28871 - ret = csum_partial_copy_generic(src, (void __force *)dst,
28872 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28873 len, isum, NULL, errp);
28874 clac();
28875 + pax_close_userland();
28876 return ret;
28877 }
28878 EXPORT_SYMBOL(csum_partial_copy_to_user);
28879 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28880 index a451235..1daa956 100644
28881 --- a/arch/x86/lib/getuser.S
28882 +++ b/arch/x86/lib/getuser.S
28883 @@ -33,17 +33,40 @@
28884 #include <asm/thread_info.h>
28885 #include <asm/asm.h>
28886 #include <asm/smap.h>
28887 +#include <asm/segment.h>
28888 +#include <asm/pgtable.h>
28889 +#include <asm/alternative-asm.h>
28890 +
28891 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28892 +#define __copyuser_seg gs;
28893 +#else
28894 +#define __copyuser_seg
28895 +#endif
28896
28897 .text
28898 ENTRY(__get_user_1)
28899 CFI_STARTPROC
28900 +
28901 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28902 GET_THREAD_INFO(%_ASM_DX)
28903 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28904 jae bad_get_user
28905 ASM_STAC
28906 -1: movzbl (%_ASM_AX),%edx
28907 +
28908 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28909 + mov pax_user_shadow_base,%_ASM_DX
28910 + cmp %_ASM_DX,%_ASM_AX
28911 + jae 1234f
28912 + add %_ASM_DX,%_ASM_AX
28913 +1234:
28914 +#endif
28915 +
28916 +#endif
28917 +
28918 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28919 xor %eax,%eax
28920 ASM_CLAC
28921 + pax_force_retaddr
28922 ret
28923 CFI_ENDPROC
28924 ENDPROC(__get_user_1)
28925 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28926 ENTRY(__get_user_2)
28927 CFI_STARTPROC
28928 add $1,%_ASM_AX
28929 +
28930 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28931 jc bad_get_user
28932 GET_THREAD_INFO(%_ASM_DX)
28933 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28934 jae bad_get_user
28935 ASM_STAC
28936 -2: movzwl -1(%_ASM_AX),%edx
28937 +
28938 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28939 + mov pax_user_shadow_base,%_ASM_DX
28940 + cmp %_ASM_DX,%_ASM_AX
28941 + jae 1234f
28942 + add %_ASM_DX,%_ASM_AX
28943 +1234:
28944 +#endif
28945 +
28946 +#endif
28947 +
28948 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28949 xor %eax,%eax
28950 ASM_CLAC
28951 + pax_force_retaddr
28952 ret
28953 CFI_ENDPROC
28954 ENDPROC(__get_user_2)
28955 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28956 ENTRY(__get_user_4)
28957 CFI_STARTPROC
28958 add $3,%_ASM_AX
28959 +
28960 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28961 jc bad_get_user
28962 GET_THREAD_INFO(%_ASM_DX)
28963 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28964 jae bad_get_user
28965 ASM_STAC
28966 -3: movl -3(%_ASM_AX),%edx
28967 +
28968 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28969 + mov pax_user_shadow_base,%_ASM_DX
28970 + cmp %_ASM_DX,%_ASM_AX
28971 + jae 1234f
28972 + add %_ASM_DX,%_ASM_AX
28973 +1234:
28974 +#endif
28975 +
28976 +#endif
28977 +
28978 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28979 xor %eax,%eax
28980 ASM_CLAC
28981 + pax_force_retaddr
28982 ret
28983 CFI_ENDPROC
28984 ENDPROC(__get_user_4)
28985 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28986 GET_THREAD_INFO(%_ASM_DX)
28987 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28988 jae bad_get_user
28989 +
28990 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28991 + mov pax_user_shadow_base,%_ASM_DX
28992 + cmp %_ASM_DX,%_ASM_AX
28993 + jae 1234f
28994 + add %_ASM_DX,%_ASM_AX
28995 +1234:
28996 +#endif
28997 +
28998 ASM_STAC
28999 4: movq -7(%_ASM_AX),%rdx
29000 xor %eax,%eax
29001 ASM_CLAC
29002 + pax_force_retaddr
29003 ret
29004 #else
29005 add $7,%_ASM_AX
29006 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
29007 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
29008 jae bad_get_user_8
29009 ASM_STAC
29010 -4: movl -7(%_ASM_AX),%edx
29011 -5: movl -3(%_ASM_AX),%ecx
29012 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
29013 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
29014 xor %eax,%eax
29015 ASM_CLAC
29016 + pax_force_retaddr
29017 ret
29018 #endif
29019 CFI_ENDPROC
29020 @@ -113,6 +175,7 @@ bad_get_user:
29021 xor %edx,%edx
29022 mov $(-EFAULT),%_ASM_AX
29023 ASM_CLAC
29024 + pax_force_retaddr
29025 ret
29026 CFI_ENDPROC
29027 END(bad_get_user)
29028 @@ -124,6 +187,7 @@ bad_get_user_8:
29029 xor %ecx,%ecx
29030 mov $(-EFAULT),%_ASM_AX
29031 ASM_CLAC
29032 + pax_force_retaddr
29033 ret
29034 CFI_ENDPROC
29035 END(bad_get_user_8)
29036 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
29037 index 54fcffe..7be149e 100644
29038 --- a/arch/x86/lib/insn.c
29039 +++ b/arch/x86/lib/insn.c
29040 @@ -20,8 +20,10 @@
29041
29042 #ifdef __KERNEL__
29043 #include <linux/string.h>
29044 +#include <asm/pgtable_types.h>
29045 #else
29046 #include <string.h>
29047 +#define ktla_ktva(addr) addr
29048 #endif
29049 #include <asm/inat.h>
29050 #include <asm/insn.h>
29051 @@ -53,8 +55,8 @@
29052 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
29053 {
29054 memset(insn, 0, sizeof(*insn));
29055 - insn->kaddr = kaddr;
29056 - insn->next_byte = kaddr;
29057 + insn->kaddr = ktla_ktva(kaddr);
29058 + insn->next_byte = ktla_ktva(kaddr);
29059 insn->x86_64 = x86_64 ? 1 : 0;
29060 insn->opnd_bytes = 4;
29061 if (x86_64)
29062 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
29063 index 05a95e7..326f2fa 100644
29064 --- a/arch/x86/lib/iomap_copy_64.S
29065 +++ b/arch/x86/lib/iomap_copy_64.S
29066 @@ -17,6 +17,7 @@
29067
29068 #include <linux/linkage.h>
29069 #include <asm/dwarf2.h>
29070 +#include <asm/alternative-asm.h>
29071
29072 /*
29073 * override generic version in lib/iomap_copy.c
29074 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
29075 CFI_STARTPROC
29076 movl %edx,%ecx
29077 rep movsd
29078 + pax_force_retaddr
29079 ret
29080 CFI_ENDPROC
29081 ENDPROC(__iowrite32_copy)
29082 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
29083 index 56313a3..0db417e 100644
29084 --- a/arch/x86/lib/memcpy_64.S
29085 +++ b/arch/x86/lib/memcpy_64.S
29086 @@ -24,7 +24,7 @@
29087 * This gets patched over the unrolled variant (below) via the
29088 * alternative instructions framework:
29089 */
29090 - .section .altinstr_replacement, "ax", @progbits
29091 + .section .altinstr_replacement, "a", @progbits
29092 .Lmemcpy_c:
29093 movq %rdi, %rax
29094 movq %rdx, %rcx
29095 @@ -33,6 +33,7 @@
29096 rep movsq
29097 movl %edx, %ecx
29098 rep movsb
29099 + pax_force_retaddr
29100 ret
29101 .Lmemcpy_e:
29102 .previous
29103 @@ -44,11 +45,12 @@
29104 * This gets patched over the unrolled variant (below) via the
29105 * alternative instructions framework:
29106 */
29107 - .section .altinstr_replacement, "ax", @progbits
29108 + .section .altinstr_replacement, "a", @progbits
29109 .Lmemcpy_c_e:
29110 movq %rdi, %rax
29111 movq %rdx, %rcx
29112 rep movsb
29113 + pax_force_retaddr
29114 ret
29115 .Lmemcpy_e_e:
29116 .previous
29117 @@ -136,6 +138,7 @@ ENTRY(memcpy)
29118 movq %r9, 1*8(%rdi)
29119 movq %r10, -2*8(%rdi, %rdx)
29120 movq %r11, -1*8(%rdi, %rdx)
29121 + pax_force_retaddr
29122 retq
29123 .p2align 4
29124 .Lless_16bytes:
29125 @@ -148,6 +151,7 @@ ENTRY(memcpy)
29126 movq -1*8(%rsi, %rdx), %r9
29127 movq %r8, 0*8(%rdi)
29128 movq %r9, -1*8(%rdi, %rdx)
29129 + pax_force_retaddr
29130 retq
29131 .p2align 4
29132 .Lless_8bytes:
29133 @@ -161,6 +165,7 @@ ENTRY(memcpy)
29134 movl -4(%rsi, %rdx), %r8d
29135 movl %ecx, (%rdi)
29136 movl %r8d, -4(%rdi, %rdx)
29137 + pax_force_retaddr
29138 retq
29139 .p2align 4
29140 .Lless_3bytes:
29141 @@ -179,6 +184,7 @@ ENTRY(memcpy)
29142 movb %cl, (%rdi)
29143
29144 .Lend:
29145 + pax_force_retaddr
29146 retq
29147 CFI_ENDPROC
29148 ENDPROC(memcpy)
29149 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
29150 index 65268a6..dd1de11 100644
29151 --- a/arch/x86/lib/memmove_64.S
29152 +++ b/arch/x86/lib/memmove_64.S
29153 @@ -202,14 +202,16 @@ ENTRY(memmove)
29154 movb (%rsi), %r11b
29155 movb %r11b, (%rdi)
29156 13:
29157 + pax_force_retaddr
29158 retq
29159 CFI_ENDPROC
29160
29161 - .section .altinstr_replacement,"ax"
29162 + .section .altinstr_replacement,"a"
29163 .Lmemmove_begin_forward_efs:
29164 /* Forward moving data. */
29165 movq %rdx, %rcx
29166 rep movsb
29167 + pax_force_retaddr
29168 retq
29169 .Lmemmove_end_forward_efs:
29170 .previous
29171 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
29172 index 2dcb380..2eb79fe 100644
29173 --- a/arch/x86/lib/memset_64.S
29174 +++ b/arch/x86/lib/memset_64.S
29175 @@ -16,7 +16,7 @@
29176 *
29177 * rax original destination
29178 */
29179 - .section .altinstr_replacement, "ax", @progbits
29180 + .section .altinstr_replacement, "a", @progbits
29181 .Lmemset_c:
29182 movq %rdi,%r9
29183 movq %rdx,%rcx
29184 @@ -30,6 +30,7 @@
29185 movl %edx,%ecx
29186 rep stosb
29187 movq %r9,%rax
29188 + pax_force_retaddr
29189 ret
29190 .Lmemset_e:
29191 .previous
29192 @@ -45,13 +46,14 @@
29193 *
29194 * rax original destination
29195 */
29196 - .section .altinstr_replacement, "ax", @progbits
29197 + .section .altinstr_replacement, "a", @progbits
29198 .Lmemset_c_e:
29199 movq %rdi,%r9
29200 movb %sil,%al
29201 movq %rdx,%rcx
29202 rep stosb
29203 movq %r9,%rax
29204 + pax_force_retaddr
29205 ret
29206 .Lmemset_e_e:
29207 .previous
29208 @@ -118,6 +120,7 @@ ENTRY(__memset)
29209
29210 .Lende:
29211 movq %r10,%rax
29212 + pax_force_retaddr
29213 ret
29214
29215 CFI_RESTORE_STATE
29216 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
29217 index c9f2d9b..e7fd2c0 100644
29218 --- a/arch/x86/lib/mmx_32.c
29219 +++ b/arch/x86/lib/mmx_32.c
29220 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29221 {
29222 void *p;
29223 int i;
29224 + unsigned long cr0;
29225
29226 if (unlikely(in_interrupt()))
29227 return __memcpy(to, from, len);
29228 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29229 kernel_fpu_begin();
29230
29231 __asm__ __volatile__ (
29232 - "1: prefetch (%0)\n" /* This set is 28 bytes */
29233 - " prefetch 64(%0)\n"
29234 - " prefetch 128(%0)\n"
29235 - " prefetch 192(%0)\n"
29236 - " prefetch 256(%0)\n"
29237 + "1: prefetch (%1)\n" /* This set is 28 bytes */
29238 + " prefetch 64(%1)\n"
29239 + " prefetch 128(%1)\n"
29240 + " prefetch 192(%1)\n"
29241 + " prefetch 256(%1)\n"
29242 "2: \n"
29243 ".section .fixup, \"ax\"\n"
29244 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29245 + "3: \n"
29246 +
29247 +#ifdef CONFIG_PAX_KERNEXEC
29248 + " movl %%cr0, %0\n"
29249 + " movl %0, %%eax\n"
29250 + " andl $0xFFFEFFFF, %%eax\n"
29251 + " movl %%eax, %%cr0\n"
29252 +#endif
29253 +
29254 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29255 +
29256 +#ifdef CONFIG_PAX_KERNEXEC
29257 + " movl %0, %%cr0\n"
29258 +#endif
29259 +
29260 " jmp 2b\n"
29261 ".previous\n"
29262 _ASM_EXTABLE(1b, 3b)
29263 - : : "r" (from));
29264 + : "=&r" (cr0) : "r" (from) : "ax");
29265
29266 for ( ; i > 5; i--) {
29267 __asm__ __volatile__ (
29268 - "1: prefetch 320(%0)\n"
29269 - "2: movq (%0), %%mm0\n"
29270 - " movq 8(%0), %%mm1\n"
29271 - " movq 16(%0), %%mm2\n"
29272 - " movq 24(%0), %%mm3\n"
29273 - " movq %%mm0, (%1)\n"
29274 - " movq %%mm1, 8(%1)\n"
29275 - " movq %%mm2, 16(%1)\n"
29276 - " movq %%mm3, 24(%1)\n"
29277 - " movq 32(%0), %%mm0\n"
29278 - " movq 40(%0), %%mm1\n"
29279 - " movq 48(%0), %%mm2\n"
29280 - " movq 56(%0), %%mm3\n"
29281 - " movq %%mm0, 32(%1)\n"
29282 - " movq %%mm1, 40(%1)\n"
29283 - " movq %%mm2, 48(%1)\n"
29284 - " movq %%mm3, 56(%1)\n"
29285 + "1: prefetch 320(%1)\n"
29286 + "2: movq (%1), %%mm0\n"
29287 + " movq 8(%1), %%mm1\n"
29288 + " movq 16(%1), %%mm2\n"
29289 + " movq 24(%1), %%mm3\n"
29290 + " movq %%mm0, (%2)\n"
29291 + " movq %%mm1, 8(%2)\n"
29292 + " movq %%mm2, 16(%2)\n"
29293 + " movq %%mm3, 24(%2)\n"
29294 + " movq 32(%1), %%mm0\n"
29295 + " movq 40(%1), %%mm1\n"
29296 + " movq 48(%1), %%mm2\n"
29297 + " movq 56(%1), %%mm3\n"
29298 + " movq %%mm0, 32(%2)\n"
29299 + " movq %%mm1, 40(%2)\n"
29300 + " movq %%mm2, 48(%2)\n"
29301 + " movq %%mm3, 56(%2)\n"
29302 ".section .fixup, \"ax\"\n"
29303 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29304 + "3:\n"
29305 +
29306 +#ifdef CONFIG_PAX_KERNEXEC
29307 + " movl %%cr0, %0\n"
29308 + " movl %0, %%eax\n"
29309 + " andl $0xFFFEFFFF, %%eax\n"
29310 + " movl %%eax, %%cr0\n"
29311 +#endif
29312 +
29313 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29314 +
29315 +#ifdef CONFIG_PAX_KERNEXEC
29316 + " movl %0, %%cr0\n"
29317 +#endif
29318 +
29319 " jmp 2b\n"
29320 ".previous\n"
29321 _ASM_EXTABLE(1b, 3b)
29322 - : : "r" (from), "r" (to) : "memory");
29323 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29324
29325 from += 64;
29326 to += 64;
29327 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
29328 static void fast_copy_page(void *to, void *from)
29329 {
29330 int i;
29331 + unsigned long cr0;
29332
29333 kernel_fpu_begin();
29334
29335 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
29336 * but that is for later. -AV
29337 */
29338 __asm__ __volatile__(
29339 - "1: prefetch (%0)\n"
29340 - " prefetch 64(%0)\n"
29341 - " prefetch 128(%0)\n"
29342 - " prefetch 192(%0)\n"
29343 - " prefetch 256(%0)\n"
29344 + "1: prefetch (%1)\n"
29345 + " prefetch 64(%1)\n"
29346 + " prefetch 128(%1)\n"
29347 + " prefetch 192(%1)\n"
29348 + " prefetch 256(%1)\n"
29349 "2: \n"
29350 ".section .fixup, \"ax\"\n"
29351 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29352 + "3: \n"
29353 +
29354 +#ifdef CONFIG_PAX_KERNEXEC
29355 + " movl %%cr0, %0\n"
29356 + " movl %0, %%eax\n"
29357 + " andl $0xFFFEFFFF, %%eax\n"
29358 + " movl %%eax, %%cr0\n"
29359 +#endif
29360 +
29361 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29362 +
29363 +#ifdef CONFIG_PAX_KERNEXEC
29364 + " movl %0, %%cr0\n"
29365 +#endif
29366 +
29367 " jmp 2b\n"
29368 ".previous\n"
29369 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29370 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29371
29372 for (i = 0; i < (4096-320)/64; i++) {
29373 __asm__ __volatile__ (
29374 - "1: prefetch 320(%0)\n"
29375 - "2: movq (%0), %%mm0\n"
29376 - " movntq %%mm0, (%1)\n"
29377 - " movq 8(%0), %%mm1\n"
29378 - " movntq %%mm1, 8(%1)\n"
29379 - " movq 16(%0), %%mm2\n"
29380 - " movntq %%mm2, 16(%1)\n"
29381 - " movq 24(%0), %%mm3\n"
29382 - " movntq %%mm3, 24(%1)\n"
29383 - " movq 32(%0), %%mm4\n"
29384 - " movntq %%mm4, 32(%1)\n"
29385 - " movq 40(%0), %%mm5\n"
29386 - " movntq %%mm5, 40(%1)\n"
29387 - " movq 48(%0), %%mm6\n"
29388 - " movntq %%mm6, 48(%1)\n"
29389 - " movq 56(%0), %%mm7\n"
29390 - " movntq %%mm7, 56(%1)\n"
29391 + "1: prefetch 320(%1)\n"
29392 + "2: movq (%1), %%mm0\n"
29393 + " movntq %%mm0, (%2)\n"
29394 + " movq 8(%1), %%mm1\n"
29395 + " movntq %%mm1, 8(%2)\n"
29396 + " movq 16(%1), %%mm2\n"
29397 + " movntq %%mm2, 16(%2)\n"
29398 + " movq 24(%1), %%mm3\n"
29399 + " movntq %%mm3, 24(%2)\n"
29400 + " movq 32(%1), %%mm4\n"
29401 + " movntq %%mm4, 32(%2)\n"
29402 + " movq 40(%1), %%mm5\n"
29403 + " movntq %%mm5, 40(%2)\n"
29404 + " movq 48(%1), %%mm6\n"
29405 + " movntq %%mm6, 48(%2)\n"
29406 + " movq 56(%1), %%mm7\n"
29407 + " movntq %%mm7, 56(%2)\n"
29408 ".section .fixup, \"ax\"\n"
29409 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29410 + "3:\n"
29411 +
29412 +#ifdef CONFIG_PAX_KERNEXEC
29413 + " movl %%cr0, %0\n"
29414 + " movl %0, %%eax\n"
29415 + " andl $0xFFFEFFFF, %%eax\n"
29416 + " movl %%eax, %%cr0\n"
29417 +#endif
29418 +
29419 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29420 +
29421 +#ifdef CONFIG_PAX_KERNEXEC
29422 + " movl %0, %%cr0\n"
29423 +#endif
29424 +
29425 " jmp 2b\n"
29426 ".previous\n"
29427 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
29428 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29429
29430 from += 64;
29431 to += 64;
29432 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
29433 static void fast_copy_page(void *to, void *from)
29434 {
29435 int i;
29436 + unsigned long cr0;
29437
29438 kernel_fpu_begin();
29439
29440 __asm__ __volatile__ (
29441 - "1: prefetch (%0)\n"
29442 - " prefetch 64(%0)\n"
29443 - " prefetch 128(%0)\n"
29444 - " prefetch 192(%0)\n"
29445 - " prefetch 256(%0)\n"
29446 + "1: prefetch (%1)\n"
29447 + " prefetch 64(%1)\n"
29448 + " prefetch 128(%1)\n"
29449 + " prefetch 192(%1)\n"
29450 + " prefetch 256(%1)\n"
29451 "2: \n"
29452 ".section .fixup, \"ax\"\n"
29453 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29454 + "3: \n"
29455 +
29456 +#ifdef CONFIG_PAX_KERNEXEC
29457 + " movl %%cr0, %0\n"
29458 + " movl %0, %%eax\n"
29459 + " andl $0xFFFEFFFF, %%eax\n"
29460 + " movl %%eax, %%cr0\n"
29461 +#endif
29462 +
29463 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29464 +
29465 +#ifdef CONFIG_PAX_KERNEXEC
29466 + " movl %0, %%cr0\n"
29467 +#endif
29468 +
29469 " jmp 2b\n"
29470 ".previous\n"
29471 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29472 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29473
29474 for (i = 0; i < 4096/64; i++) {
29475 __asm__ __volatile__ (
29476 - "1: prefetch 320(%0)\n"
29477 - "2: movq (%0), %%mm0\n"
29478 - " movq 8(%0), %%mm1\n"
29479 - " movq 16(%0), %%mm2\n"
29480 - " movq 24(%0), %%mm3\n"
29481 - " movq %%mm0, (%1)\n"
29482 - " movq %%mm1, 8(%1)\n"
29483 - " movq %%mm2, 16(%1)\n"
29484 - " movq %%mm3, 24(%1)\n"
29485 - " movq 32(%0), %%mm0\n"
29486 - " movq 40(%0), %%mm1\n"
29487 - " movq 48(%0), %%mm2\n"
29488 - " movq 56(%0), %%mm3\n"
29489 - " movq %%mm0, 32(%1)\n"
29490 - " movq %%mm1, 40(%1)\n"
29491 - " movq %%mm2, 48(%1)\n"
29492 - " movq %%mm3, 56(%1)\n"
29493 + "1: prefetch 320(%1)\n"
29494 + "2: movq (%1), %%mm0\n"
29495 + " movq 8(%1), %%mm1\n"
29496 + " movq 16(%1), %%mm2\n"
29497 + " movq 24(%1), %%mm3\n"
29498 + " movq %%mm0, (%2)\n"
29499 + " movq %%mm1, 8(%2)\n"
29500 + " movq %%mm2, 16(%2)\n"
29501 + " movq %%mm3, 24(%2)\n"
29502 + " movq 32(%1), %%mm0\n"
29503 + " movq 40(%1), %%mm1\n"
29504 + " movq 48(%1), %%mm2\n"
29505 + " movq 56(%1), %%mm3\n"
29506 + " movq %%mm0, 32(%2)\n"
29507 + " movq %%mm1, 40(%2)\n"
29508 + " movq %%mm2, 48(%2)\n"
29509 + " movq %%mm3, 56(%2)\n"
29510 ".section .fixup, \"ax\"\n"
29511 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29512 + "3:\n"
29513 +
29514 +#ifdef CONFIG_PAX_KERNEXEC
29515 + " movl %%cr0, %0\n"
29516 + " movl %0, %%eax\n"
29517 + " andl $0xFFFEFFFF, %%eax\n"
29518 + " movl %%eax, %%cr0\n"
29519 +#endif
29520 +
29521 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29522 +
29523 +#ifdef CONFIG_PAX_KERNEXEC
29524 + " movl %0, %%cr0\n"
29525 +#endif
29526 +
29527 " jmp 2b\n"
29528 ".previous\n"
29529 _ASM_EXTABLE(1b, 3b)
29530 - : : "r" (from), "r" (to) : "memory");
29531 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29532
29533 from += 64;
29534 to += 64;
29535 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
29536 index f6d13ee..d789440 100644
29537 --- a/arch/x86/lib/msr-reg.S
29538 +++ b/arch/x86/lib/msr-reg.S
29539 @@ -3,6 +3,7 @@
29540 #include <asm/dwarf2.h>
29541 #include <asm/asm.h>
29542 #include <asm/msr.h>
29543 +#include <asm/alternative-asm.h>
29544
29545 #ifdef CONFIG_X86_64
29546 /*
29547 @@ -37,6 +38,7 @@ ENTRY(\op\()_safe_regs)
29548 movl %edi, 28(%r10)
29549 popq_cfi %rbp
29550 popq_cfi %rbx
29551 + pax_force_retaddr
29552 ret
29553 3:
29554 CFI_RESTORE_STATE
29555 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
29556 index fc6ba17..d4d989d 100644
29557 --- a/arch/x86/lib/putuser.S
29558 +++ b/arch/x86/lib/putuser.S
29559 @@ -16,7 +16,9 @@
29560 #include <asm/errno.h>
29561 #include <asm/asm.h>
29562 #include <asm/smap.h>
29563 -
29564 +#include <asm/segment.h>
29565 +#include <asm/pgtable.h>
29566 +#include <asm/alternative-asm.h>
29567
29568 /*
29569 * __put_user_X
29570 @@ -30,57 +32,125 @@
29571 * as they get called from within inline assembly.
29572 */
29573
29574 -#define ENTER CFI_STARTPROC ; \
29575 - GET_THREAD_INFO(%_ASM_BX)
29576 -#define EXIT ASM_CLAC ; \
29577 - ret ; \
29578 +#define ENTER CFI_STARTPROC
29579 +#define EXIT ASM_CLAC ; \
29580 + pax_force_retaddr ; \
29581 + ret ; \
29582 CFI_ENDPROC
29583
29584 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29585 +#define _DEST %_ASM_CX,%_ASM_BX
29586 +#else
29587 +#define _DEST %_ASM_CX
29588 +#endif
29589 +
29590 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29591 +#define __copyuser_seg gs;
29592 +#else
29593 +#define __copyuser_seg
29594 +#endif
29595 +
29596 .text
29597 ENTRY(__put_user_1)
29598 ENTER
29599 +
29600 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29601 + GET_THREAD_INFO(%_ASM_BX)
29602 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
29603 jae bad_put_user
29604 ASM_STAC
29605 -1: movb %al,(%_ASM_CX)
29606 +
29607 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29608 + mov pax_user_shadow_base,%_ASM_BX
29609 + cmp %_ASM_BX,%_ASM_CX
29610 + jb 1234f
29611 + xor %ebx,%ebx
29612 +1234:
29613 +#endif
29614 +
29615 +#endif
29616 +
29617 +1: __copyuser_seg movb %al,(_DEST)
29618 xor %eax,%eax
29619 EXIT
29620 ENDPROC(__put_user_1)
29621
29622 ENTRY(__put_user_2)
29623 ENTER
29624 +
29625 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29626 + GET_THREAD_INFO(%_ASM_BX)
29627 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29628 sub $1,%_ASM_BX
29629 cmp %_ASM_BX,%_ASM_CX
29630 jae bad_put_user
29631 ASM_STAC
29632 -2: movw %ax,(%_ASM_CX)
29633 +
29634 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29635 + mov pax_user_shadow_base,%_ASM_BX
29636 + cmp %_ASM_BX,%_ASM_CX
29637 + jb 1234f
29638 + xor %ebx,%ebx
29639 +1234:
29640 +#endif
29641 +
29642 +#endif
29643 +
29644 +2: __copyuser_seg movw %ax,(_DEST)
29645 xor %eax,%eax
29646 EXIT
29647 ENDPROC(__put_user_2)
29648
29649 ENTRY(__put_user_4)
29650 ENTER
29651 +
29652 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29653 + GET_THREAD_INFO(%_ASM_BX)
29654 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29655 sub $3,%_ASM_BX
29656 cmp %_ASM_BX,%_ASM_CX
29657 jae bad_put_user
29658 ASM_STAC
29659 -3: movl %eax,(%_ASM_CX)
29660 +
29661 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29662 + mov pax_user_shadow_base,%_ASM_BX
29663 + cmp %_ASM_BX,%_ASM_CX
29664 + jb 1234f
29665 + xor %ebx,%ebx
29666 +1234:
29667 +#endif
29668 +
29669 +#endif
29670 +
29671 +3: __copyuser_seg movl %eax,(_DEST)
29672 xor %eax,%eax
29673 EXIT
29674 ENDPROC(__put_user_4)
29675
29676 ENTRY(__put_user_8)
29677 ENTER
29678 +
29679 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29680 + GET_THREAD_INFO(%_ASM_BX)
29681 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29682 sub $7,%_ASM_BX
29683 cmp %_ASM_BX,%_ASM_CX
29684 jae bad_put_user
29685 ASM_STAC
29686 -4: mov %_ASM_AX,(%_ASM_CX)
29687 +
29688 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29689 + mov pax_user_shadow_base,%_ASM_BX
29690 + cmp %_ASM_BX,%_ASM_CX
29691 + jb 1234f
29692 + xor %ebx,%ebx
29693 +1234:
29694 +#endif
29695 +
29696 +#endif
29697 +
29698 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29699 #ifdef CONFIG_X86_32
29700 -5: movl %edx,4(%_ASM_CX)
29701 +5: __copyuser_seg movl %edx,4(_DEST)
29702 #endif
29703 xor %eax,%eax
29704 EXIT
29705 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29706 index 1cad221..de671ee 100644
29707 --- a/arch/x86/lib/rwlock.S
29708 +++ b/arch/x86/lib/rwlock.S
29709 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29710 FRAME
29711 0: LOCK_PREFIX
29712 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29713 +
29714 +#ifdef CONFIG_PAX_REFCOUNT
29715 + jno 1234f
29716 + LOCK_PREFIX
29717 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29718 + int $4
29719 +1234:
29720 + _ASM_EXTABLE(1234b, 1234b)
29721 +#endif
29722 +
29723 1: rep; nop
29724 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29725 jne 1b
29726 LOCK_PREFIX
29727 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29728 +
29729 +#ifdef CONFIG_PAX_REFCOUNT
29730 + jno 1234f
29731 + LOCK_PREFIX
29732 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29733 + int $4
29734 +1234:
29735 + _ASM_EXTABLE(1234b, 1234b)
29736 +#endif
29737 +
29738 jnz 0b
29739 ENDFRAME
29740 + pax_force_retaddr
29741 ret
29742 CFI_ENDPROC
29743 END(__write_lock_failed)
29744 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29745 FRAME
29746 0: LOCK_PREFIX
29747 READ_LOCK_SIZE(inc) (%__lock_ptr)
29748 +
29749 +#ifdef CONFIG_PAX_REFCOUNT
29750 + jno 1234f
29751 + LOCK_PREFIX
29752 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29753 + int $4
29754 +1234:
29755 + _ASM_EXTABLE(1234b, 1234b)
29756 +#endif
29757 +
29758 1: rep; nop
29759 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29760 js 1b
29761 LOCK_PREFIX
29762 READ_LOCK_SIZE(dec) (%__lock_ptr)
29763 +
29764 +#ifdef CONFIG_PAX_REFCOUNT
29765 + jno 1234f
29766 + LOCK_PREFIX
29767 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29768 + int $4
29769 +1234:
29770 + _ASM_EXTABLE(1234b, 1234b)
29771 +#endif
29772 +
29773 js 0b
29774 ENDFRAME
29775 + pax_force_retaddr
29776 ret
29777 CFI_ENDPROC
29778 END(__read_lock_failed)
29779 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29780 index 5dff5f0..cadebf4 100644
29781 --- a/arch/x86/lib/rwsem.S
29782 +++ b/arch/x86/lib/rwsem.S
29783 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29784 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29785 CFI_RESTORE __ASM_REG(dx)
29786 restore_common_regs
29787 + pax_force_retaddr
29788 ret
29789 CFI_ENDPROC
29790 ENDPROC(call_rwsem_down_read_failed)
29791 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29792 movq %rax,%rdi
29793 call rwsem_down_write_failed
29794 restore_common_regs
29795 + pax_force_retaddr
29796 ret
29797 CFI_ENDPROC
29798 ENDPROC(call_rwsem_down_write_failed)
29799 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29800 movq %rax,%rdi
29801 call rwsem_wake
29802 restore_common_regs
29803 -1: ret
29804 +1: pax_force_retaddr
29805 + ret
29806 CFI_ENDPROC
29807 ENDPROC(call_rwsem_wake)
29808
29809 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29810 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29811 CFI_RESTORE __ASM_REG(dx)
29812 restore_common_regs
29813 + pax_force_retaddr
29814 ret
29815 CFI_ENDPROC
29816 ENDPROC(call_rwsem_downgrade_wake)
29817 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29818 index a63efd6..8149fbe 100644
29819 --- a/arch/x86/lib/thunk_64.S
29820 +++ b/arch/x86/lib/thunk_64.S
29821 @@ -8,6 +8,7 @@
29822 #include <linux/linkage.h>
29823 #include <asm/dwarf2.h>
29824 #include <asm/calling.h>
29825 +#include <asm/alternative-asm.h>
29826
29827 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29828 .macro THUNK name, func, put_ret_addr_in_rdi=0
29829 @@ -15,11 +16,11 @@
29830 \name:
29831 CFI_STARTPROC
29832
29833 - /* this one pushes 9 elems, the next one would be %rIP */
29834 - SAVE_ARGS
29835 + /* this one pushes 15+1 elems, the next one would be %rIP */
29836 + SAVE_ARGS 8
29837
29838 .if \put_ret_addr_in_rdi
29839 - movq_cfi_restore 9*8, rdi
29840 + movq_cfi_restore RIP, rdi
29841 .endif
29842
29843 call \func
29844 @@ -38,8 +39,9 @@
29845
29846 /* SAVE_ARGS below is used only for the .cfi directives it contains. */
29847 CFI_STARTPROC
29848 - SAVE_ARGS
29849 + SAVE_ARGS 8
29850 restore:
29851 - RESTORE_ARGS
29852 + RESTORE_ARGS 1,8
29853 + pax_force_retaddr
29854 ret
29855 CFI_ENDPROC
29856 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29857 index 3eb18ac..4b22130 100644
29858 --- a/arch/x86/lib/usercopy_32.c
29859 +++ b/arch/x86/lib/usercopy_32.c
29860 @@ -42,11 +42,13 @@ do { \
29861 int __d0; \
29862 might_fault(); \
29863 __asm__ __volatile__( \
29864 + __COPYUSER_SET_ES \
29865 ASM_STAC "\n" \
29866 "0: rep; stosl\n" \
29867 " movl %2,%0\n" \
29868 "1: rep; stosb\n" \
29869 "2: " ASM_CLAC "\n" \
29870 + __COPYUSER_RESTORE_ES \
29871 ".section .fixup,\"ax\"\n" \
29872 "3: lea 0(%2,%0,4),%0\n" \
29873 " jmp 2b\n" \
29874 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29875
29876 #ifdef CONFIG_X86_INTEL_USERCOPY
29877 static unsigned long
29878 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29879 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29880 {
29881 int d0, d1;
29882 __asm__ __volatile__(
29883 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29884 " .align 2,0x90\n"
29885 "3: movl 0(%4), %%eax\n"
29886 "4: movl 4(%4), %%edx\n"
29887 - "5: movl %%eax, 0(%3)\n"
29888 - "6: movl %%edx, 4(%3)\n"
29889 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29890 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29891 "7: movl 8(%4), %%eax\n"
29892 "8: movl 12(%4),%%edx\n"
29893 - "9: movl %%eax, 8(%3)\n"
29894 - "10: movl %%edx, 12(%3)\n"
29895 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29896 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29897 "11: movl 16(%4), %%eax\n"
29898 "12: movl 20(%4), %%edx\n"
29899 - "13: movl %%eax, 16(%3)\n"
29900 - "14: movl %%edx, 20(%3)\n"
29901 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29902 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29903 "15: movl 24(%4), %%eax\n"
29904 "16: movl 28(%4), %%edx\n"
29905 - "17: movl %%eax, 24(%3)\n"
29906 - "18: movl %%edx, 28(%3)\n"
29907 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29908 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29909 "19: movl 32(%4), %%eax\n"
29910 "20: movl 36(%4), %%edx\n"
29911 - "21: movl %%eax, 32(%3)\n"
29912 - "22: movl %%edx, 36(%3)\n"
29913 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29914 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29915 "23: movl 40(%4), %%eax\n"
29916 "24: movl 44(%4), %%edx\n"
29917 - "25: movl %%eax, 40(%3)\n"
29918 - "26: movl %%edx, 44(%3)\n"
29919 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29920 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29921 "27: movl 48(%4), %%eax\n"
29922 "28: movl 52(%4), %%edx\n"
29923 - "29: movl %%eax, 48(%3)\n"
29924 - "30: movl %%edx, 52(%3)\n"
29925 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29926 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29927 "31: movl 56(%4), %%eax\n"
29928 "32: movl 60(%4), %%edx\n"
29929 - "33: movl %%eax, 56(%3)\n"
29930 - "34: movl %%edx, 60(%3)\n"
29931 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29932 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29933 " addl $-64, %0\n"
29934 " addl $64, %4\n"
29935 " addl $64, %3\n"
29936 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29937 " shrl $2, %0\n"
29938 " andl $3, %%eax\n"
29939 " cld\n"
29940 + __COPYUSER_SET_ES
29941 "99: rep; movsl\n"
29942 "36: movl %%eax, %0\n"
29943 "37: rep; movsb\n"
29944 "100:\n"
29945 + __COPYUSER_RESTORE_ES
29946 + ".section .fixup,\"ax\"\n"
29947 + "101: lea 0(%%eax,%0,4),%0\n"
29948 + " jmp 100b\n"
29949 + ".previous\n"
29950 + _ASM_EXTABLE(1b,100b)
29951 + _ASM_EXTABLE(2b,100b)
29952 + _ASM_EXTABLE(3b,100b)
29953 + _ASM_EXTABLE(4b,100b)
29954 + _ASM_EXTABLE(5b,100b)
29955 + _ASM_EXTABLE(6b,100b)
29956 + _ASM_EXTABLE(7b,100b)
29957 + _ASM_EXTABLE(8b,100b)
29958 + _ASM_EXTABLE(9b,100b)
29959 + _ASM_EXTABLE(10b,100b)
29960 + _ASM_EXTABLE(11b,100b)
29961 + _ASM_EXTABLE(12b,100b)
29962 + _ASM_EXTABLE(13b,100b)
29963 + _ASM_EXTABLE(14b,100b)
29964 + _ASM_EXTABLE(15b,100b)
29965 + _ASM_EXTABLE(16b,100b)
29966 + _ASM_EXTABLE(17b,100b)
29967 + _ASM_EXTABLE(18b,100b)
29968 + _ASM_EXTABLE(19b,100b)
29969 + _ASM_EXTABLE(20b,100b)
29970 + _ASM_EXTABLE(21b,100b)
29971 + _ASM_EXTABLE(22b,100b)
29972 + _ASM_EXTABLE(23b,100b)
29973 + _ASM_EXTABLE(24b,100b)
29974 + _ASM_EXTABLE(25b,100b)
29975 + _ASM_EXTABLE(26b,100b)
29976 + _ASM_EXTABLE(27b,100b)
29977 + _ASM_EXTABLE(28b,100b)
29978 + _ASM_EXTABLE(29b,100b)
29979 + _ASM_EXTABLE(30b,100b)
29980 + _ASM_EXTABLE(31b,100b)
29981 + _ASM_EXTABLE(32b,100b)
29982 + _ASM_EXTABLE(33b,100b)
29983 + _ASM_EXTABLE(34b,100b)
29984 + _ASM_EXTABLE(35b,100b)
29985 + _ASM_EXTABLE(36b,100b)
29986 + _ASM_EXTABLE(37b,100b)
29987 + _ASM_EXTABLE(99b,101b)
29988 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29989 + : "1"(to), "2"(from), "0"(size)
29990 + : "eax", "edx", "memory");
29991 + return size;
29992 +}
29993 +
29994 +static unsigned long
29995 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29996 +{
29997 + int d0, d1;
29998 + __asm__ __volatile__(
29999 + " .align 2,0x90\n"
30000 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
30001 + " cmpl $67, %0\n"
30002 + " jbe 3f\n"
30003 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
30004 + " .align 2,0x90\n"
30005 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
30006 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
30007 + "5: movl %%eax, 0(%3)\n"
30008 + "6: movl %%edx, 4(%3)\n"
30009 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
30010 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
30011 + "9: movl %%eax, 8(%3)\n"
30012 + "10: movl %%edx, 12(%3)\n"
30013 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
30014 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
30015 + "13: movl %%eax, 16(%3)\n"
30016 + "14: movl %%edx, 20(%3)\n"
30017 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
30018 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
30019 + "17: movl %%eax, 24(%3)\n"
30020 + "18: movl %%edx, 28(%3)\n"
30021 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
30022 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
30023 + "21: movl %%eax, 32(%3)\n"
30024 + "22: movl %%edx, 36(%3)\n"
30025 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
30026 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
30027 + "25: movl %%eax, 40(%3)\n"
30028 + "26: movl %%edx, 44(%3)\n"
30029 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
30030 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
30031 + "29: movl %%eax, 48(%3)\n"
30032 + "30: movl %%edx, 52(%3)\n"
30033 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
30034 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
30035 + "33: movl %%eax, 56(%3)\n"
30036 + "34: movl %%edx, 60(%3)\n"
30037 + " addl $-64, %0\n"
30038 + " addl $64, %4\n"
30039 + " addl $64, %3\n"
30040 + " cmpl $63, %0\n"
30041 + " ja 1b\n"
30042 + "35: movl %0, %%eax\n"
30043 + " shrl $2, %0\n"
30044 + " andl $3, %%eax\n"
30045 + " cld\n"
30046 + "99: rep; "__copyuser_seg" movsl\n"
30047 + "36: movl %%eax, %0\n"
30048 + "37: rep; "__copyuser_seg" movsb\n"
30049 + "100:\n"
30050 ".section .fixup,\"ax\"\n"
30051 "101: lea 0(%%eax,%0,4),%0\n"
30052 " jmp 100b\n"
30053 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
30054 int d0, d1;
30055 __asm__ __volatile__(
30056 " .align 2,0x90\n"
30057 - "0: movl 32(%4), %%eax\n"
30058 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30059 " cmpl $67, %0\n"
30060 " jbe 2f\n"
30061 - "1: movl 64(%4), %%eax\n"
30062 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30063 " .align 2,0x90\n"
30064 - "2: movl 0(%4), %%eax\n"
30065 - "21: movl 4(%4), %%edx\n"
30066 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30067 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30068 " movl %%eax, 0(%3)\n"
30069 " movl %%edx, 4(%3)\n"
30070 - "3: movl 8(%4), %%eax\n"
30071 - "31: movl 12(%4),%%edx\n"
30072 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30073 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30074 " movl %%eax, 8(%3)\n"
30075 " movl %%edx, 12(%3)\n"
30076 - "4: movl 16(%4), %%eax\n"
30077 - "41: movl 20(%4), %%edx\n"
30078 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30079 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30080 " movl %%eax, 16(%3)\n"
30081 " movl %%edx, 20(%3)\n"
30082 - "10: movl 24(%4), %%eax\n"
30083 - "51: movl 28(%4), %%edx\n"
30084 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30085 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30086 " movl %%eax, 24(%3)\n"
30087 " movl %%edx, 28(%3)\n"
30088 - "11: movl 32(%4), %%eax\n"
30089 - "61: movl 36(%4), %%edx\n"
30090 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30091 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30092 " movl %%eax, 32(%3)\n"
30093 " movl %%edx, 36(%3)\n"
30094 - "12: movl 40(%4), %%eax\n"
30095 - "71: movl 44(%4), %%edx\n"
30096 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30097 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30098 " movl %%eax, 40(%3)\n"
30099 " movl %%edx, 44(%3)\n"
30100 - "13: movl 48(%4), %%eax\n"
30101 - "81: movl 52(%4), %%edx\n"
30102 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30103 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30104 " movl %%eax, 48(%3)\n"
30105 " movl %%edx, 52(%3)\n"
30106 - "14: movl 56(%4), %%eax\n"
30107 - "91: movl 60(%4), %%edx\n"
30108 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30109 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30110 " movl %%eax, 56(%3)\n"
30111 " movl %%edx, 60(%3)\n"
30112 " addl $-64, %0\n"
30113 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
30114 " shrl $2, %0\n"
30115 " andl $3, %%eax\n"
30116 " cld\n"
30117 - "6: rep; movsl\n"
30118 + "6: rep; "__copyuser_seg" movsl\n"
30119 " movl %%eax,%0\n"
30120 - "7: rep; movsb\n"
30121 + "7: rep; "__copyuser_seg" movsb\n"
30122 "8:\n"
30123 ".section .fixup,\"ax\"\n"
30124 "9: lea 0(%%eax,%0,4),%0\n"
30125 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30126
30127 __asm__ __volatile__(
30128 " .align 2,0x90\n"
30129 - "0: movl 32(%4), %%eax\n"
30130 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30131 " cmpl $67, %0\n"
30132 " jbe 2f\n"
30133 - "1: movl 64(%4), %%eax\n"
30134 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30135 " .align 2,0x90\n"
30136 - "2: movl 0(%4), %%eax\n"
30137 - "21: movl 4(%4), %%edx\n"
30138 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30139 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30140 " movnti %%eax, 0(%3)\n"
30141 " movnti %%edx, 4(%3)\n"
30142 - "3: movl 8(%4), %%eax\n"
30143 - "31: movl 12(%4),%%edx\n"
30144 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30145 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30146 " movnti %%eax, 8(%3)\n"
30147 " movnti %%edx, 12(%3)\n"
30148 - "4: movl 16(%4), %%eax\n"
30149 - "41: movl 20(%4), %%edx\n"
30150 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30151 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30152 " movnti %%eax, 16(%3)\n"
30153 " movnti %%edx, 20(%3)\n"
30154 - "10: movl 24(%4), %%eax\n"
30155 - "51: movl 28(%4), %%edx\n"
30156 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30157 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30158 " movnti %%eax, 24(%3)\n"
30159 " movnti %%edx, 28(%3)\n"
30160 - "11: movl 32(%4), %%eax\n"
30161 - "61: movl 36(%4), %%edx\n"
30162 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30163 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30164 " movnti %%eax, 32(%3)\n"
30165 " movnti %%edx, 36(%3)\n"
30166 - "12: movl 40(%4), %%eax\n"
30167 - "71: movl 44(%4), %%edx\n"
30168 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30169 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30170 " movnti %%eax, 40(%3)\n"
30171 " movnti %%edx, 44(%3)\n"
30172 - "13: movl 48(%4), %%eax\n"
30173 - "81: movl 52(%4), %%edx\n"
30174 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30175 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30176 " movnti %%eax, 48(%3)\n"
30177 " movnti %%edx, 52(%3)\n"
30178 - "14: movl 56(%4), %%eax\n"
30179 - "91: movl 60(%4), %%edx\n"
30180 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30181 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30182 " movnti %%eax, 56(%3)\n"
30183 " movnti %%edx, 60(%3)\n"
30184 " addl $-64, %0\n"
30185 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30186 " shrl $2, %0\n"
30187 " andl $3, %%eax\n"
30188 " cld\n"
30189 - "6: rep; movsl\n"
30190 + "6: rep; "__copyuser_seg" movsl\n"
30191 " movl %%eax,%0\n"
30192 - "7: rep; movsb\n"
30193 + "7: rep; "__copyuser_seg" movsb\n"
30194 "8:\n"
30195 ".section .fixup,\"ax\"\n"
30196 "9: lea 0(%%eax,%0,4),%0\n"
30197 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
30198
30199 __asm__ __volatile__(
30200 " .align 2,0x90\n"
30201 - "0: movl 32(%4), %%eax\n"
30202 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30203 " cmpl $67, %0\n"
30204 " jbe 2f\n"
30205 - "1: movl 64(%4), %%eax\n"
30206 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30207 " .align 2,0x90\n"
30208 - "2: movl 0(%4), %%eax\n"
30209 - "21: movl 4(%4), %%edx\n"
30210 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30211 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30212 " movnti %%eax, 0(%3)\n"
30213 " movnti %%edx, 4(%3)\n"
30214 - "3: movl 8(%4), %%eax\n"
30215 - "31: movl 12(%4),%%edx\n"
30216 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30217 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30218 " movnti %%eax, 8(%3)\n"
30219 " movnti %%edx, 12(%3)\n"
30220 - "4: movl 16(%4), %%eax\n"
30221 - "41: movl 20(%4), %%edx\n"
30222 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30223 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30224 " movnti %%eax, 16(%3)\n"
30225 " movnti %%edx, 20(%3)\n"
30226 - "10: movl 24(%4), %%eax\n"
30227 - "51: movl 28(%4), %%edx\n"
30228 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30229 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30230 " movnti %%eax, 24(%3)\n"
30231 " movnti %%edx, 28(%3)\n"
30232 - "11: movl 32(%4), %%eax\n"
30233 - "61: movl 36(%4), %%edx\n"
30234 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30235 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30236 " movnti %%eax, 32(%3)\n"
30237 " movnti %%edx, 36(%3)\n"
30238 - "12: movl 40(%4), %%eax\n"
30239 - "71: movl 44(%4), %%edx\n"
30240 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30241 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30242 " movnti %%eax, 40(%3)\n"
30243 " movnti %%edx, 44(%3)\n"
30244 - "13: movl 48(%4), %%eax\n"
30245 - "81: movl 52(%4), %%edx\n"
30246 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30247 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30248 " movnti %%eax, 48(%3)\n"
30249 " movnti %%edx, 52(%3)\n"
30250 - "14: movl 56(%4), %%eax\n"
30251 - "91: movl 60(%4), %%edx\n"
30252 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30253 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30254 " movnti %%eax, 56(%3)\n"
30255 " movnti %%edx, 60(%3)\n"
30256 " addl $-64, %0\n"
30257 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
30258 " shrl $2, %0\n"
30259 " andl $3, %%eax\n"
30260 " cld\n"
30261 - "6: rep; movsl\n"
30262 + "6: rep; "__copyuser_seg" movsl\n"
30263 " movl %%eax,%0\n"
30264 - "7: rep; movsb\n"
30265 + "7: rep; "__copyuser_seg" movsb\n"
30266 "8:\n"
30267 ".section .fixup,\"ax\"\n"
30268 "9: lea 0(%%eax,%0,4),%0\n"
30269 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
30270 */
30271 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
30272 unsigned long size);
30273 -unsigned long __copy_user_intel(void __user *to, const void *from,
30274 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
30275 + unsigned long size);
30276 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
30277 unsigned long size);
30278 unsigned long __copy_user_zeroing_intel_nocache(void *to,
30279 const void __user *from, unsigned long size);
30280 #endif /* CONFIG_X86_INTEL_USERCOPY */
30281
30282 /* Generic arbitrary sized copy. */
30283 -#define __copy_user(to, from, size) \
30284 +#define __copy_user(to, from, size, prefix, set, restore) \
30285 do { \
30286 int __d0, __d1, __d2; \
30287 __asm__ __volatile__( \
30288 + set \
30289 " cmp $7,%0\n" \
30290 " jbe 1f\n" \
30291 " movl %1,%0\n" \
30292 " negl %0\n" \
30293 " andl $7,%0\n" \
30294 " subl %0,%3\n" \
30295 - "4: rep; movsb\n" \
30296 + "4: rep; "prefix"movsb\n" \
30297 " movl %3,%0\n" \
30298 " shrl $2,%0\n" \
30299 " andl $3,%3\n" \
30300 " .align 2,0x90\n" \
30301 - "0: rep; movsl\n" \
30302 + "0: rep; "prefix"movsl\n" \
30303 " movl %3,%0\n" \
30304 - "1: rep; movsb\n" \
30305 + "1: rep; "prefix"movsb\n" \
30306 "2:\n" \
30307 + restore \
30308 ".section .fixup,\"ax\"\n" \
30309 "5: addl %3,%0\n" \
30310 " jmp 2b\n" \
30311 @@ -538,14 +650,14 @@ do { \
30312 " negl %0\n" \
30313 " andl $7,%0\n" \
30314 " subl %0,%3\n" \
30315 - "4: rep; movsb\n" \
30316 + "4: rep; "__copyuser_seg"movsb\n" \
30317 " movl %3,%0\n" \
30318 " shrl $2,%0\n" \
30319 " andl $3,%3\n" \
30320 " .align 2,0x90\n" \
30321 - "0: rep; movsl\n" \
30322 + "0: rep; "__copyuser_seg"movsl\n" \
30323 " movl %3,%0\n" \
30324 - "1: rep; movsb\n" \
30325 + "1: rep; "__copyuser_seg"movsb\n" \
30326 "2:\n" \
30327 ".section .fixup,\"ax\"\n" \
30328 "5: addl %3,%0\n" \
30329 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
30330 {
30331 stac();
30332 if (movsl_is_ok(to, from, n))
30333 - __copy_user(to, from, n);
30334 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
30335 else
30336 - n = __copy_user_intel(to, from, n);
30337 + n = __generic_copy_to_user_intel(to, from, n);
30338 clac();
30339 return n;
30340 }
30341 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
30342 {
30343 stac();
30344 if (movsl_is_ok(to, from, n))
30345 - __copy_user(to, from, n);
30346 + __copy_user(to, from, n, __copyuser_seg, "", "");
30347 else
30348 - n = __copy_user_intel((void __user *)to,
30349 - (const void *)from, n);
30350 + n = __generic_copy_from_user_intel(to, from, n);
30351 clac();
30352 return n;
30353 }
30354 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
30355 if (n > 64 && cpu_has_xmm2)
30356 n = __copy_user_intel_nocache(to, from, n);
30357 else
30358 - __copy_user(to, from, n);
30359 + __copy_user(to, from, n, __copyuser_seg, "", "");
30360 #else
30361 - __copy_user(to, from, n);
30362 + __copy_user(to, from, n, __copyuser_seg, "", "");
30363 #endif
30364 clac();
30365 return n;
30366 }
30367 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
30368
30369 -/**
30370 - * copy_to_user: - Copy a block of data into user space.
30371 - * @to: Destination address, in user space.
30372 - * @from: Source address, in kernel space.
30373 - * @n: Number of bytes to copy.
30374 - *
30375 - * Context: User context only. This function may sleep.
30376 - *
30377 - * Copy data from kernel space to user space.
30378 - *
30379 - * Returns number of bytes that could not be copied.
30380 - * On success, this will be zero.
30381 - */
30382 -unsigned long
30383 -copy_to_user(void __user *to, const void *from, unsigned long n)
30384 +#ifdef CONFIG_PAX_MEMORY_UDEREF
30385 +void __set_fs(mm_segment_t x)
30386 {
30387 - if (access_ok(VERIFY_WRITE, to, n))
30388 - n = __copy_to_user(to, from, n);
30389 - return n;
30390 + switch (x.seg) {
30391 + case 0:
30392 + loadsegment(gs, 0);
30393 + break;
30394 + case TASK_SIZE_MAX:
30395 + loadsegment(gs, __USER_DS);
30396 + break;
30397 + case -1UL:
30398 + loadsegment(gs, __KERNEL_DS);
30399 + break;
30400 + default:
30401 + BUG();
30402 + }
30403 }
30404 -EXPORT_SYMBOL(copy_to_user);
30405 +EXPORT_SYMBOL(__set_fs);
30406
30407 -/**
30408 - * copy_from_user: - Copy a block of data from user space.
30409 - * @to: Destination address, in kernel space.
30410 - * @from: Source address, in user space.
30411 - * @n: Number of bytes to copy.
30412 - *
30413 - * Context: User context only. This function may sleep.
30414 - *
30415 - * Copy data from user space to kernel space.
30416 - *
30417 - * Returns number of bytes that could not be copied.
30418 - * On success, this will be zero.
30419 - *
30420 - * If some data could not be copied, this function will pad the copied
30421 - * data to the requested size using zero bytes.
30422 - */
30423 -unsigned long
30424 -_copy_from_user(void *to, const void __user *from, unsigned long n)
30425 +void set_fs(mm_segment_t x)
30426 {
30427 - if (access_ok(VERIFY_READ, from, n))
30428 - n = __copy_from_user(to, from, n);
30429 - else
30430 - memset(to, 0, n);
30431 - return n;
30432 + current_thread_info()->addr_limit = x;
30433 + __set_fs(x);
30434 }
30435 -EXPORT_SYMBOL(_copy_from_user);
30436 +EXPORT_SYMBOL(set_fs);
30437 +#endif
30438 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
30439 index c905e89..01ab928 100644
30440 --- a/arch/x86/lib/usercopy_64.c
30441 +++ b/arch/x86/lib/usercopy_64.c
30442 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30443 might_fault();
30444 /* no memory constraint because it doesn't change any memory gcc knows
30445 about */
30446 + pax_open_userland();
30447 stac();
30448 asm volatile(
30449 " testq %[size8],%[size8]\n"
30450 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30451 _ASM_EXTABLE(0b,3b)
30452 _ASM_EXTABLE(1b,2b)
30453 : [size8] "=&c"(size), [dst] "=&D" (__d0)
30454 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
30455 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
30456 [zero] "r" (0UL), [eight] "r" (8UL));
30457 clac();
30458 + pax_close_userland();
30459 return size;
30460 }
30461 EXPORT_SYMBOL(__clear_user);
30462 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
30463 }
30464 EXPORT_SYMBOL(clear_user);
30465
30466 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
30467 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
30468 {
30469 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
30470 - return copy_user_generic((__force void *)to, (__force void *)from, len);
30471 - }
30472 - return len;
30473 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
30474 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
30475 + return len;
30476 }
30477 EXPORT_SYMBOL(copy_in_user);
30478
30479 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
30480 * it is not necessary to optimize tail handling.
30481 */
30482 __visible unsigned long
30483 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30484 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
30485 {
30486 char c;
30487 unsigned zero_len;
30488
30489 + clac();
30490 + pax_close_userland();
30491 for (; len; --len, to++) {
30492 if (__get_user_nocheck(c, from++, sizeof(char)))
30493 break;
30494 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30495 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
30496 if (__put_user_nocheck(c, to++, sizeof(char)))
30497 break;
30498 - clac();
30499 return len;
30500 }
30501 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
30502 index 23d8e5f..9ccc13a 100644
30503 --- a/arch/x86/mm/Makefile
30504 +++ b/arch/x86/mm/Makefile
30505 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
30506 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
30507
30508 obj-$(CONFIG_MEMTEST) += memtest.o
30509 +
30510 +quote:="
30511 +obj-$(CONFIG_X86_64) += uderef_64.o
30512 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
30513 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
30514 index 903ec1e..c4166b2 100644
30515 --- a/arch/x86/mm/extable.c
30516 +++ b/arch/x86/mm/extable.c
30517 @@ -6,12 +6,24 @@
30518 static inline unsigned long
30519 ex_insn_addr(const struct exception_table_entry *x)
30520 {
30521 - return (unsigned long)&x->insn + x->insn;
30522 + unsigned long reloc = 0;
30523 +
30524 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30525 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30526 +#endif
30527 +
30528 + return (unsigned long)&x->insn + x->insn + reloc;
30529 }
30530 static inline unsigned long
30531 ex_fixup_addr(const struct exception_table_entry *x)
30532 {
30533 - return (unsigned long)&x->fixup + x->fixup;
30534 + unsigned long reloc = 0;
30535 +
30536 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30537 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30538 +#endif
30539 +
30540 + return (unsigned long)&x->fixup + x->fixup + reloc;
30541 }
30542
30543 int fixup_exception(struct pt_regs *regs)
30544 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
30545 unsigned long new_ip;
30546
30547 #ifdef CONFIG_PNPBIOS
30548 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
30549 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
30550 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
30551 extern u32 pnp_bios_is_utter_crap;
30552 pnp_bios_is_utter_crap = 1;
30553 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
30554 i += 4;
30555 p->fixup -= i;
30556 i += 4;
30557 +
30558 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30559 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
30560 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30561 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30562 +#endif
30563 +
30564 }
30565 }
30566
30567 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
30568 index 3aaeffc..42ea9fb 100644
30569 --- a/arch/x86/mm/fault.c
30570 +++ b/arch/x86/mm/fault.c
30571 @@ -14,11 +14,18 @@
30572 #include <linux/hugetlb.h> /* hstate_index_to_shift */
30573 #include <linux/prefetch.h> /* prefetchw */
30574 #include <linux/context_tracking.h> /* exception_enter(), ... */
30575 +#include <linux/unistd.h>
30576 +#include <linux/compiler.h>
30577
30578 #include <asm/traps.h> /* dotraplinkage, ... */
30579 #include <asm/pgalloc.h> /* pgd_*(), ... */
30580 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
30581 #include <asm/fixmap.h> /* VSYSCALL_START */
30582 +#include <asm/tlbflush.h>
30583 +
30584 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30585 +#include <asm/stacktrace.h>
30586 +#endif
30587
30588 /*
30589 * Page fault error code bits:
30590 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
30591 int ret = 0;
30592
30593 /* kprobe_running() needs smp_processor_id() */
30594 - if (kprobes_built_in() && !user_mode_vm(regs)) {
30595 + if (kprobes_built_in() && !user_mode(regs)) {
30596 preempt_disable();
30597 if (kprobe_running() && kprobe_fault_handler(regs, 14))
30598 ret = 1;
30599 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
30600 return !instr_lo || (instr_lo>>1) == 1;
30601 case 0x00:
30602 /* Prefetch instruction is 0x0F0D or 0x0F18 */
30603 - if (probe_kernel_address(instr, opcode))
30604 + if (user_mode(regs)) {
30605 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30606 + return 0;
30607 + } else if (probe_kernel_address(instr, opcode))
30608 return 0;
30609
30610 *prefetch = (instr_lo == 0xF) &&
30611 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
30612 while (instr < max_instr) {
30613 unsigned char opcode;
30614
30615 - if (probe_kernel_address(instr, opcode))
30616 + if (user_mode(regs)) {
30617 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30618 + break;
30619 + } else if (probe_kernel_address(instr, opcode))
30620 break;
30621
30622 instr++;
30623 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
30624 force_sig_info(si_signo, &info, tsk);
30625 }
30626
30627 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30628 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
30629 +#endif
30630 +
30631 +#ifdef CONFIG_PAX_EMUTRAMP
30632 +static int pax_handle_fetch_fault(struct pt_regs *regs);
30633 +#endif
30634 +
30635 +#ifdef CONFIG_PAX_PAGEEXEC
30636 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
30637 +{
30638 + pgd_t *pgd;
30639 + pud_t *pud;
30640 + pmd_t *pmd;
30641 +
30642 + pgd = pgd_offset(mm, address);
30643 + if (!pgd_present(*pgd))
30644 + return NULL;
30645 + pud = pud_offset(pgd, address);
30646 + if (!pud_present(*pud))
30647 + return NULL;
30648 + pmd = pmd_offset(pud, address);
30649 + if (!pmd_present(*pmd))
30650 + return NULL;
30651 + return pmd;
30652 +}
30653 +#endif
30654 +
30655 DEFINE_SPINLOCK(pgd_lock);
30656 LIST_HEAD(pgd_list);
30657
30658 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30659 for (address = VMALLOC_START & PMD_MASK;
30660 address >= TASK_SIZE && address < FIXADDR_TOP;
30661 address += PMD_SIZE) {
30662 +
30663 +#ifdef CONFIG_PAX_PER_CPU_PGD
30664 + unsigned long cpu;
30665 +#else
30666 struct page *page;
30667 +#endif
30668
30669 spin_lock(&pgd_lock);
30670 +
30671 +#ifdef CONFIG_PAX_PER_CPU_PGD
30672 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30673 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30674 + pmd_t *ret;
30675 +
30676 + ret = vmalloc_sync_one(pgd, address);
30677 + if (!ret)
30678 + break;
30679 + pgd = get_cpu_pgd(cpu, kernel);
30680 +#else
30681 list_for_each_entry(page, &pgd_list, lru) {
30682 + pgd_t *pgd;
30683 spinlock_t *pgt_lock;
30684 pmd_t *ret;
30685
30686 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30687 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30688
30689 spin_lock(pgt_lock);
30690 - ret = vmalloc_sync_one(page_address(page), address);
30691 + pgd = page_address(page);
30692 +#endif
30693 +
30694 + ret = vmalloc_sync_one(pgd, address);
30695 +
30696 +#ifndef CONFIG_PAX_PER_CPU_PGD
30697 spin_unlock(pgt_lock);
30698 +#endif
30699
30700 if (!ret)
30701 break;
30702 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30703 * an interrupt in the middle of a task switch..
30704 */
30705 pgd_paddr = read_cr3();
30706 +
30707 +#ifdef CONFIG_PAX_PER_CPU_PGD
30708 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30709 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30710 +#endif
30711 +
30712 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30713 if (!pmd_k)
30714 return -1;
30715 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30716 * happen within a race in page table update. In the later
30717 * case just flush:
30718 */
30719 - pgd = pgd_offset(current->active_mm, address);
30720 +
30721 pgd_ref = pgd_offset_k(address);
30722 if (pgd_none(*pgd_ref))
30723 return -1;
30724
30725 +#ifdef CONFIG_PAX_PER_CPU_PGD
30726 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30727 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30728 + if (pgd_none(*pgd)) {
30729 + set_pgd(pgd, *pgd_ref);
30730 + arch_flush_lazy_mmu_mode();
30731 + } else {
30732 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30733 + }
30734 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30735 +#else
30736 + pgd = pgd_offset(current->active_mm, address);
30737 +#endif
30738 +
30739 if (pgd_none(*pgd)) {
30740 set_pgd(pgd, *pgd_ref);
30741 arch_flush_lazy_mmu_mode();
30742 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30743 static int is_errata100(struct pt_regs *regs, unsigned long address)
30744 {
30745 #ifdef CONFIG_X86_64
30746 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30747 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30748 return 1;
30749 #endif
30750 return 0;
30751 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30752 }
30753
30754 static const char nx_warning[] = KERN_CRIT
30755 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30756 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30757
30758 static void
30759 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30760 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30761 if (!oops_may_print())
30762 return;
30763
30764 - if (error_code & PF_INSTR) {
30765 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30766 unsigned int level;
30767
30768 pte_t *pte = lookup_address(address, &level);
30769
30770 if (pte && pte_present(*pte) && !pte_exec(*pte))
30771 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30772 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30773 }
30774
30775 +#ifdef CONFIG_PAX_KERNEXEC
30776 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30777 + if (current->signal->curr_ip)
30778 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30779 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30780 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30781 + else
30782 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30783 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30784 + }
30785 +#endif
30786 +
30787 printk(KERN_ALERT "BUG: unable to handle kernel ");
30788 if (address < PAGE_SIZE)
30789 printk(KERN_CONT "NULL pointer dereference");
30790 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30791 return;
30792 }
30793 #endif
30794 +
30795 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30796 + if (pax_is_fetch_fault(regs, error_code, address)) {
30797 +
30798 +#ifdef CONFIG_PAX_EMUTRAMP
30799 + switch (pax_handle_fetch_fault(regs)) {
30800 + case 2:
30801 + return;
30802 + }
30803 +#endif
30804 +
30805 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30806 + do_group_exit(SIGKILL);
30807 + }
30808 +#endif
30809 +
30810 /* Kernel addresses are always protection faults: */
30811 if (address >= TASK_SIZE)
30812 error_code |= PF_PROT;
30813 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30814 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30815 printk(KERN_ERR
30816 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30817 - tsk->comm, tsk->pid, address);
30818 + tsk->comm, task_pid_nr(tsk), address);
30819 code = BUS_MCEERR_AR;
30820 }
30821 #endif
30822 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30823 return 1;
30824 }
30825
30826 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30827 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30828 +{
30829 + pte_t *pte;
30830 + pmd_t *pmd;
30831 + spinlock_t *ptl;
30832 + unsigned char pte_mask;
30833 +
30834 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30835 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30836 + return 0;
30837 +
30838 + /* PaX: it's our fault, let's handle it if we can */
30839 +
30840 + /* PaX: take a look at read faults before acquiring any locks */
30841 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30842 + /* instruction fetch attempt from a protected page in user mode */
30843 + up_read(&mm->mmap_sem);
30844 +
30845 +#ifdef CONFIG_PAX_EMUTRAMP
30846 + switch (pax_handle_fetch_fault(regs)) {
30847 + case 2:
30848 + return 1;
30849 + }
30850 +#endif
30851 +
30852 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30853 + do_group_exit(SIGKILL);
30854 + }
30855 +
30856 + pmd = pax_get_pmd(mm, address);
30857 + if (unlikely(!pmd))
30858 + return 0;
30859 +
30860 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30861 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30862 + pte_unmap_unlock(pte, ptl);
30863 + return 0;
30864 + }
30865 +
30866 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30867 + /* write attempt to a protected page in user mode */
30868 + pte_unmap_unlock(pte, ptl);
30869 + return 0;
30870 + }
30871 +
30872 +#ifdef CONFIG_SMP
30873 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30874 +#else
30875 + if (likely(address > get_limit(regs->cs)))
30876 +#endif
30877 + {
30878 + set_pte(pte, pte_mkread(*pte));
30879 + __flush_tlb_one(address);
30880 + pte_unmap_unlock(pte, ptl);
30881 + up_read(&mm->mmap_sem);
30882 + return 1;
30883 + }
30884 +
30885 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30886 +
30887 + /*
30888 + * PaX: fill DTLB with user rights and retry
30889 + */
30890 + __asm__ __volatile__ (
30891 + "orb %2,(%1)\n"
30892 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30893 +/*
30894 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30895 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30896 + * page fault when examined during a TLB load attempt. this is true not only
30897 + * for PTEs holding a non-present entry but also present entries that will
30898 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30899 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30900 + * for our target pages since their PTEs are simply not in the TLBs at all.
30901 +
30902 + * the best thing in omitting it is that we gain around 15-20% speed in the
30903 + * fast path of the page fault handler and can get rid of tracing since we
30904 + * can no longer flush unintended entries.
30905 + */
30906 + "invlpg (%0)\n"
30907 +#endif
30908 + __copyuser_seg"testb $0,(%0)\n"
30909 + "xorb %3,(%1)\n"
30910 + :
30911 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30912 + : "memory", "cc");
30913 + pte_unmap_unlock(pte, ptl);
30914 + up_read(&mm->mmap_sem);
30915 + return 1;
30916 +}
30917 +#endif
30918 +
30919 /*
30920 * Handle a spurious fault caused by a stale TLB entry.
30921 *
30922 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30923 static inline int
30924 access_error(unsigned long error_code, struct vm_area_struct *vma)
30925 {
30926 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30927 + return 1;
30928 +
30929 if (error_code & PF_WRITE) {
30930 /* write, present and write, not present: */
30931 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30932 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30933 if (error_code & PF_USER)
30934 return false;
30935
30936 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30937 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30938 return false;
30939
30940 return true;
30941 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30942 /* Get the faulting address: */
30943 address = read_cr2();
30944
30945 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30946 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30947 + if (!search_exception_tables(regs->ip)) {
30948 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30949 + bad_area_nosemaphore(regs, error_code, address);
30950 + return;
30951 + }
30952 + if (address < pax_user_shadow_base) {
30953 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30954 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30955 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30956 + } else
30957 + address -= pax_user_shadow_base;
30958 + }
30959 +#endif
30960 +
30961 /*
30962 * Detect and handle instructions that would cause a page fault for
30963 * both a tracked kernel page and a userspace page.
30964 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30965 * User-mode registers count as a user access even for any
30966 * potential system fault or CPU buglet:
30967 */
30968 - if (user_mode_vm(regs)) {
30969 + if (user_mode(regs)) {
30970 local_irq_enable();
30971 error_code |= PF_USER;
30972 flags |= FAULT_FLAG_USER;
30973 @@ -1135,6 +1359,11 @@ retry:
30974 might_sleep();
30975 }
30976
30977 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30978 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30979 + return;
30980 +#endif
30981 +
30982 vma = find_vma(mm, address);
30983 if (unlikely(!vma)) {
30984 bad_area(regs, error_code, address);
30985 @@ -1146,18 +1375,24 @@ retry:
30986 bad_area(regs, error_code, address);
30987 return;
30988 }
30989 - if (error_code & PF_USER) {
30990 - /*
30991 - * Accessing the stack below %sp is always a bug.
30992 - * The large cushion allows instructions like enter
30993 - * and pusha to work. ("enter $65535, $31" pushes
30994 - * 32 pointers and then decrements %sp by 65535.)
30995 - */
30996 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30997 - bad_area(regs, error_code, address);
30998 - return;
30999 - }
31000 + /*
31001 + * Accessing the stack below %sp is always a bug.
31002 + * The large cushion allows instructions like enter
31003 + * and pusha to work. ("enter $65535, $31" pushes
31004 + * 32 pointers and then decrements %sp by 65535.)
31005 + */
31006 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
31007 + bad_area(regs, error_code, address);
31008 + return;
31009 }
31010 +
31011 +#ifdef CONFIG_PAX_SEGMEXEC
31012 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
31013 + bad_area(regs, error_code, address);
31014 + return;
31015 + }
31016 +#endif
31017 +
31018 if (unlikely(expand_stack(vma, address))) {
31019 bad_area(regs, error_code, address);
31020 return;
31021 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
31022 __do_page_fault(regs, error_code);
31023 exception_exit(prev_state);
31024 }
31025 +
31026 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31027 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
31028 +{
31029 + struct mm_struct *mm = current->mm;
31030 + unsigned long ip = regs->ip;
31031 +
31032 + if (v8086_mode(regs))
31033 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
31034 +
31035 +#ifdef CONFIG_PAX_PAGEEXEC
31036 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
31037 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
31038 + return true;
31039 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
31040 + return true;
31041 + return false;
31042 + }
31043 +#endif
31044 +
31045 +#ifdef CONFIG_PAX_SEGMEXEC
31046 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
31047 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
31048 + return true;
31049 + return false;
31050 + }
31051 +#endif
31052 +
31053 + return false;
31054 +}
31055 +#endif
31056 +
31057 +#ifdef CONFIG_PAX_EMUTRAMP
31058 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
31059 +{
31060 + int err;
31061 +
31062 + do { /* PaX: libffi trampoline emulation */
31063 + unsigned char mov, jmp;
31064 + unsigned int addr1, addr2;
31065 +
31066 +#ifdef CONFIG_X86_64
31067 + if ((regs->ip + 9) >> 32)
31068 + break;
31069 +#endif
31070 +
31071 + err = get_user(mov, (unsigned char __user *)regs->ip);
31072 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31073 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31074 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31075 +
31076 + if (err)
31077 + break;
31078 +
31079 + if (mov == 0xB8 && jmp == 0xE9) {
31080 + regs->ax = addr1;
31081 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31082 + return 2;
31083 + }
31084 + } while (0);
31085 +
31086 + do { /* PaX: gcc trampoline emulation #1 */
31087 + unsigned char mov1, mov2;
31088 + unsigned short jmp;
31089 + unsigned int addr1, addr2;
31090 +
31091 +#ifdef CONFIG_X86_64
31092 + if ((regs->ip + 11) >> 32)
31093 + break;
31094 +#endif
31095 +
31096 + err = get_user(mov1, (unsigned char __user *)regs->ip);
31097 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31098 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
31099 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31100 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
31101 +
31102 + if (err)
31103 + break;
31104 +
31105 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
31106 + regs->cx = addr1;
31107 + regs->ax = addr2;
31108 + regs->ip = addr2;
31109 + return 2;
31110 + }
31111 + } while (0);
31112 +
31113 + do { /* PaX: gcc trampoline emulation #2 */
31114 + unsigned char mov, jmp;
31115 + unsigned int addr1, addr2;
31116 +
31117 +#ifdef CONFIG_X86_64
31118 + if ((regs->ip + 9) >> 32)
31119 + break;
31120 +#endif
31121 +
31122 + err = get_user(mov, (unsigned char __user *)regs->ip);
31123 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31124 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31125 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31126 +
31127 + if (err)
31128 + break;
31129 +
31130 + if (mov == 0xB9 && jmp == 0xE9) {
31131 + regs->cx = addr1;
31132 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31133 + return 2;
31134 + }
31135 + } while (0);
31136 +
31137 + return 1; /* PaX in action */
31138 +}
31139 +
31140 +#ifdef CONFIG_X86_64
31141 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
31142 +{
31143 + int err;
31144 +
31145 + do { /* PaX: libffi trampoline emulation */
31146 + unsigned short mov1, mov2, jmp1;
31147 + unsigned char stcclc, jmp2;
31148 + unsigned long addr1, addr2;
31149 +
31150 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31151 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31152 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31153 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31154 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
31155 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
31156 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
31157 +
31158 + if (err)
31159 + break;
31160 +
31161 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31162 + regs->r11 = addr1;
31163 + regs->r10 = addr2;
31164 + if (stcclc == 0xF8)
31165 + regs->flags &= ~X86_EFLAGS_CF;
31166 + else
31167 + regs->flags |= X86_EFLAGS_CF;
31168 + regs->ip = addr1;
31169 + return 2;
31170 + }
31171 + } while (0);
31172 +
31173 + do { /* PaX: gcc trampoline emulation #1 */
31174 + unsigned short mov1, mov2, jmp1;
31175 + unsigned char jmp2;
31176 + unsigned int addr1;
31177 + unsigned long addr2;
31178 +
31179 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31180 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
31181 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
31182 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
31183 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
31184 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
31185 +
31186 + if (err)
31187 + break;
31188 +
31189 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31190 + regs->r11 = addr1;
31191 + regs->r10 = addr2;
31192 + regs->ip = addr1;
31193 + return 2;
31194 + }
31195 + } while (0);
31196 +
31197 + do { /* PaX: gcc trampoline emulation #2 */
31198 + unsigned short mov1, mov2, jmp1;
31199 + unsigned char jmp2;
31200 + unsigned long addr1, addr2;
31201 +
31202 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31203 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31204 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31205 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31206 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
31207 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
31208 +
31209 + if (err)
31210 + break;
31211 +
31212 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31213 + regs->r11 = addr1;
31214 + regs->r10 = addr2;
31215 + regs->ip = addr1;
31216 + return 2;
31217 + }
31218 + } while (0);
31219 +
31220 + return 1; /* PaX in action */
31221 +}
31222 +#endif
31223 +
31224 +/*
31225 + * PaX: decide what to do with offenders (regs->ip = fault address)
31226 + *
31227 + * returns 1 when task should be killed
31228 + * 2 when gcc trampoline was detected
31229 + */
31230 +static int pax_handle_fetch_fault(struct pt_regs *regs)
31231 +{
31232 + if (v8086_mode(regs))
31233 + return 1;
31234 +
31235 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
31236 + return 1;
31237 +
31238 +#ifdef CONFIG_X86_32
31239 + return pax_handle_fetch_fault_32(regs);
31240 +#else
31241 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
31242 + return pax_handle_fetch_fault_32(regs);
31243 + else
31244 + return pax_handle_fetch_fault_64(regs);
31245 +#endif
31246 +}
31247 +#endif
31248 +
31249 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31250 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
31251 +{
31252 + long i;
31253 +
31254 + printk(KERN_ERR "PAX: bytes at PC: ");
31255 + for (i = 0; i < 20; i++) {
31256 + unsigned char c;
31257 + if (get_user(c, (unsigned char __force_user *)pc+i))
31258 + printk(KERN_CONT "?? ");
31259 + else
31260 + printk(KERN_CONT "%02x ", c);
31261 + }
31262 + printk("\n");
31263 +
31264 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
31265 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
31266 + unsigned long c;
31267 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
31268 +#ifdef CONFIG_X86_32
31269 + printk(KERN_CONT "???????? ");
31270 +#else
31271 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
31272 + printk(KERN_CONT "???????? ???????? ");
31273 + else
31274 + printk(KERN_CONT "???????????????? ");
31275 +#endif
31276 + } else {
31277 +#ifdef CONFIG_X86_64
31278 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
31279 + printk(KERN_CONT "%08x ", (unsigned int)c);
31280 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
31281 + } else
31282 +#endif
31283 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
31284 + }
31285 + }
31286 + printk("\n");
31287 +}
31288 +#endif
31289 +
31290 +/**
31291 + * probe_kernel_write(): safely attempt to write to a location
31292 + * @dst: address to write to
31293 + * @src: pointer to the data that shall be written
31294 + * @size: size of the data chunk
31295 + *
31296 + * Safely write to address @dst from the buffer at @src. If a kernel fault
31297 + * happens, handle that and return -EFAULT.
31298 + */
31299 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
31300 +{
31301 + long ret;
31302 + mm_segment_t old_fs = get_fs();
31303 +
31304 + set_fs(KERNEL_DS);
31305 + pagefault_disable();
31306 + pax_open_kernel();
31307 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
31308 + pax_close_kernel();
31309 + pagefault_enable();
31310 + set_fs(old_fs);
31311 +
31312 + return ret ? -EFAULT : 0;
31313 +}
31314 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
31315 index 0596e8e..9de0b1c 100644
31316 --- a/arch/x86/mm/gup.c
31317 +++ b/arch/x86/mm/gup.c
31318 @@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
31319 addr = start;
31320 len = (unsigned long) nr_pages << PAGE_SHIFT;
31321 end = start + len;
31322 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31323 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31324 (void __user *)start, len)))
31325 return 0;
31326
31327 @@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
31328 goto slow_irqon;
31329 #endif
31330
31331 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31332 + (void __user *)start, len)))
31333 + return 0;
31334 +
31335 /*
31336 * XXX: batch / limit 'nr', to avoid large irq off latency
31337 * needs some instrumenting to determine the common sizes used by
31338 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
31339 index 4500142..53a363c 100644
31340 --- a/arch/x86/mm/highmem_32.c
31341 +++ b/arch/x86/mm/highmem_32.c
31342 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
31343 idx = type + KM_TYPE_NR*smp_processor_id();
31344 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31345 BUG_ON(!pte_none(*(kmap_pte-idx)));
31346 +
31347 + pax_open_kernel();
31348 set_pte(kmap_pte-idx, mk_pte(page, prot));
31349 + pax_close_kernel();
31350 +
31351 arch_flush_lazy_mmu_mode();
31352
31353 return (void *)vaddr;
31354 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
31355 index 9d980d8..6bbfacb 100644
31356 --- a/arch/x86/mm/hugetlbpage.c
31357 +++ b/arch/x86/mm/hugetlbpage.c
31358 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
31359 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
31360 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
31361 unsigned long addr, unsigned long len,
31362 - unsigned long pgoff, unsigned long flags)
31363 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31364 {
31365 struct hstate *h = hstate_file(file);
31366 struct vm_unmapped_area_info info;
31367 -
31368 +
31369 info.flags = 0;
31370 info.length = len;
31371 info.low_limit = TASK_UNMAPPED_BASE;
31372 +
31373 +#ifdef CONFIG_PAX_RANDMMAP
31374 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31375 + info.low_limit += current->mm->delta_mmap;
31376 +#endif
31377 +
31378 info.high_limit = TASK_SIZE;
31379 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31380 info.align_offset = 0;
31381 + info.threadstack_offset = offset;
31382 return vm_unmapped_area(&info);
31383 }
31384
31385 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31386 unsigned long addr0, unsigned long len,
31387 - unsigned long pgoff, unsigned long flags)
31388 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31389 {
31390 struct hstate *h = hstate_file(file);
31391 struct vm_unmapped_area_info info;
31392 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31393 info.high_limit = current->mm->mmap_base;
31394 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31395 info.align_offset = 0;
31396 + info.threadstack_offset = offset;
31397 addr = vm_unmapped_area(&info);
31398
31399 /*
31400 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31401 VM_BUG_ON(addr != -ENOMEM);
31402 info.flags = 0;
31403 info.low_limit = TASK_UNMAPPED_BASE;
31404 +
31405 +#ifdef CONFIG_PAX_RANDMMAP
31406 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31407 + info.low_limit += current->mm->delta_mmap;
31408 +#endif
31409 +
31410 info.high_limit = TASK_SIZE;
31411 addr = vm_unmapped_area(&info);
31412 }
31413 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31414 struct hstate *h = hstate_file(file);
31415 struct mm_struct *mm = current->mm;
31416 struct vm_area_struct *vma;
31417 + unsigned long pax_task_size = TASK_SIZE;
31418 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
31419
31420 if (len & ~huge_page_mask(h))
31421 return -EINVAL;
31422 - if (len > TASK_SIZE)
31423 +
31424 +#ifdef CONFIG_PAX_SEGMEXEC
31425 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31426 + pax_task_size = SEGMEXEC_TASK_SIZE;
31427 +#endif
31428 +
31429 + pax_task_size -= PAGE_SIZE;
31430 +
31431 + if (len > pax_task_size)
31432 return -ENOMEM;
31433
31434 if (flags & MAP_FIXED) {
31435 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31436 return addr;
31437 }
31438
31439 +#ifdef CONFIG_PAX_RANDMMAP
31440 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31441 +#endif
31442 +
31443 if (addr) {
31444 addr = ALIGN(addr, huge_page_size(h));
31445 vma = find_vma(mm, addr);
31446 - if (TASK_SIZE - len >= addr &&
31447 - (!vma || addr + len <= vma->vm_start))
31448 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
31449 return addr;
31450 }
31451 if (mm->get_unmapped_area == arch_get_unmapped_area)
31452 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
31453 - pgoff, flags);
31454 + pgoff, flags, offset);
31455 else
31456 return hugetlb_get_unmapped_area_topdown(file, addr, len,
31457 - pgoff, flags);
31458 + pgoff, flags, offset);
31459 }
31460
31461 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
31462 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
31463 index 04664cd..dae6e5d 100644
31464 --- a/arch/x86/mm/init.c
31465 +++ b/arch/x86/mm/init.c
31466 @@ -4,6 +4,7 @@
31467 #include <linux/swap.h>
31468 #include <linux/memblock.h>
31469 #include <linux/bootmem.h> /* for max_low_pfn */
31470 +#include <linux/tboot.h>
31471
31472 #include <asm/cacheflush.h>
31473 #include <asm/e820.h>
31474 @@ -17,6 +18,8 @@
31475 #include <asm/proto.h>
31476 #include <asm/dma.h> /* for MAX_DMA_PFN */
31477 #include <asm/microcode.h>
31478 +#include <asm/desc.h>
31479 +#include <asm/bios_ebda.h>
31480
31481 #include "mm_internal.h"
31482
31483 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
31484 early_ioremap_page_table_range_init();
31485 #endif
31486
31487 +#ifdef CONFIG_PAX_PER_CPU_PGD
31488 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
31489 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31490 + KERNEL_PGD_PTRS);
31491 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
31492 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31493 + KERNEL_PGD_PTRS);
31494 + load_cr3(get_cpu_pgd(0, kernel));
31495 +#else
31496 load_cr3(swapper_pg_dir);
31497 +#endif
31498 +
31499 __flush_tlb_all();
31500
31501 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
31502 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
31503 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
31504 * mmio resources as well as potential bios/acpi data regions.
31505 */
31506 +
31507 +#ifdef CONFIG_GRKERNSEC_KMEM
31508 +static unsigned int ebda_start __read_only;
31509 +static unsigned int ebda_end __read_only;
31510 +#endif
31511 +
31512 int devmem_is_allowed(unsigned long pagenr)
31513 {
31514 - if (pagenr < 256)
31515 +#ifdef CONFIG_GRKERNSEC_KMEM
31516 + /* allow BDA */
31517 + if (!pagenr)
31518 return 1;
31519 + /* allow EBDA */
31520 + if (pagenr >= ebda_start && pagenr < ebda_end)
31521 + return 1;
31522 + /* if tboot is in use, allow access to its hardcoded serial log range */
31523 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
31524 + return 1;
31525 +#else
31526 + if (!pagenr)
31527 + return 1;
31528 +#ifdef CONFIG_VM86
31529 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
31530 + return 1;
31531 +#endif
31532 +#endif
31533 +
31534 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
31535 + return 1;
31536 +#ifdef CONFIG_GRKERNSEC_KMEM
31537 + /* throw out everything else below 1MB */
31538 + if (pagenr <= 256)
31539 + return 0;
31540 +#endif
31541 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
31542 return 0;
31543 if (!page_is_ram(pagenr))
31544 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
31545 #endif
31546 }
31547
31548 +#ifdef CONFIG_GRKERNSEC_KMEM
31549 +static inline void gr_init_ebda(void)
31550 +{
31551 + unsigned int ebda_addr;
31552 + unsigned int ebda_size = 0;
31553 +
31554 + ebda_addr = get_bios_ebda();
31555 + if (ebda_addr) {
31556 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
31557 + ebda_size <<= 10;
31558 + }
31559 + if (ebda_addr && ebda_size) {
31560 + ebda_start = ebda_addr >> PAGE_SHIFT;
31561 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
31562 + } else {
31563 + ebda_start = 0x9f000 >> PAGE_SHIFT;
31564 + ebda_end = 0xa0000 >> PAGE_SHIFT;
31565 + }
31566 +}
31567 +#else
31568 +static inline void gr_init_ebda(void) { }
31569 +#endif
31570 +
31571 void free_initmem(void)
31572 {
31573 +#ifdef CONFIG_PAX_KERNEXEC
31574 +#ifdef CONFIG_X86_32
31575 + /* PaX: limit KERNEL_CS to actual size */
31576 + unsigned long addr, limit;
31577 + struct desc_struct d;
31578 + int cpu;
31579 +#else
31580 + pgd_t *pgd;
31581 + pud_t *pud;
31582 + pmd_t *pmd;
31583 + unsigned long addr, end;
31584 +#endif
31585 +#endif
31586 +
31587 + gr_init_ebda();
31588 +
31589 +#ifdef CONFIG_PAX_KERNEXEC
31590 +#ifdef CONFIG_X86_32
31591 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
31592 + limit = (limit - 1UL) >> PAGE_SHIFT;
31593 +
31594 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
31595 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
31596 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
31597 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
31598 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
31599 + }
31600 +
31601 + /* PaX: make KERNEL_CS read-only */
31602 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
31603 + if (!paravirt_enabled())
31604 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
31605 +/*
31606 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
31607 + pgd = pgd_offset_k(addr);
31608 + pud = pud_offset(pgd, addr);
31609 + pmd = pmd_offset(pud, addr);
31610 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31611 + }
31612 +*/
31613 +#ifdef CONFIG_X86_PAE
31614 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
31615 +/*
31616 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
31617 + pgd = pgd_offset_k(addr);
31618 + pud = pud_offset(pgd, addr);
31619 + pmd = pmd_offset(pud, addr);
31620 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31621 + }
31622 +*/
31623 +#endif
31624 +
31625 +#ifdef CONFIG_MODULES
31626 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
31627 +#endif
31628 +
31629 +#else
31630 + /* PaX: make kernel code/rodata read-only, rest non-executable */
31631 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
31632 + pgd = pgd_offset_k(addr);
31633 + pud = pud_offset(pgd, addr);
31634 + pmd = pmd_offset(pud, addr);
31635 + if (!pmd_present(*pmd))
31636 + continue;
31637 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
31638 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31639 + else
31640 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31641 + }
31642 +
31643 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
31644 + end = addr + KERNEL_IMAGE_SIZE;
31645 + for (; addr < end; addr += PMD_SIZE) {
31646 + pgd = pgd_offset_k(addr);
31647 + pud = pud_offset(pgd, addr);
31648 + pmd = pmd_offset(pud, addr);
31649 + if (!pmd_present(*pmd))
31650 + continue;
31651 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
31652 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31653 + }
31654 +#endif
31655 +
31656 + flush_tlb_all();
31657 +#endif
31658 +
31659 free_init_pages("unused kernel",
31660 (unsigned long)(&__init_begin),
31661 (unsigned long)(&__init_end));
31662 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31663 index 4287f1f..3b99c71 100644
31664 --- a/arch/x86/mm/init_32.c
31665 +++ b/arch/x86/mm/init_32.c
31666 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31667 bool __read_mostly __vmalloc_start_set = false;
31668
31669 /*
31670 - * Creates a middle page table and puts a pointer to it in the
31671 - * given global directory entry. This only returns the gd entry
31672 - * in non-PAE compilation mode, since the middle layer is folded.
31673 - */
31674 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31675 -{
31676 - pud_t *pud;
31677 - pmd_t *pmd_table;
31678 -
31679 -#ifdef CONFIG_X86_PAE
31680 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31681 - pmd_table = (pmd_t *)alloc_low_page();
31682 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31683 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31684 - pud = pud_offset(pgd, 0);
31685 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31686 -
31687 - return pmd_table;
31688 - }
31689 -#endif
31690 - pud = pud_offset(pgd, 0);
31691 - pmd_table = pmd_offset(pud, 0);
31692 -
31693 - return pmd_table;
31694 -}
31695 -
31696 -/*
31697 * Create a page table and place a pointer to it in a middle page
31698 * directory entry:
31699 */
31700 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31701 pte_t *page_table = (pte_t *)alloc_low_page();
31702
31703 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31704 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31705 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31706 +#else
31707 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31708 +#endif
31709 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31710 }
31711
31712 return pte_offset_kernel(pmd, 0);
31713 }
31714
31715 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31716 +{
31717 + pud_t *pud;
31718 + pmd_t *pmd_table;
31719 +
31720 + pud = pud_offset(pgd, 0);
31721 + pmd_table = pmd_offset(pud, 0);
31722 +
31723 + return pmd_table;
31724 +}
31725 +
31726 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31727 {
31728 int pgd_idx = pgd_index(vaddr);
31729 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31730 int pgd_idx, pmd_idx;
31731 unsigned long vaddr;
31732 pgd_t *pgd;
31733 + pud_t *pud;
31734 pmd_t *pmd;
31735 pte_t *pte = NULL;
31736 unsigned long count = page_table_range_init_count(start, end);
31737 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31738 pgd = pgd_base + pgd_idx;
31739
31740 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31741 - pmd = one_md_table_init(pgd);
31742 - pmd = pmd + pmd_index(vaddr);
31743 + pud = pud_offset(pgd, vaddr);
31744 + pmd = pmd_offset(pud, vaddr);
31745 +
31746 +#ifdef CONFIG_X86_PAE
31747 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31748 +#endif
31749 +
31750 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31751 pmd++, pmd_idx++) {
31752 pte = page_table_kmap_check(one_page_table_init(pmd),
31753 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31754 }
31755 }
31756
31757 -static inline int is_kernel_text(unsigned long addr)
31758 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31759 {
31760 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31761 - return 1;
31762 - return 0;
31763 + if ((start > ktla_ktva((unsigned long)_etext) ||
31764 + end <= ktla_ktva((unsigned long)_stext)) &&
31765 + (start > ktla_ktva((unsigned long)_einittext) ||
31766 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31767 +
31768 +#ifdef CONFIG_ACPI_SLEEP
31769 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31770 +#endif
31771 +
31772 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31773 + return 0;
31774 + return 1;
31775 }
31776
31777 /*
31778 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31779 unsigned long last_map_addr = end;
31780 unsigned long start_pfn, end_pfn;
31781 pgd_t *pgd_base = swapper_pg_dir;
31782 - int pgd_idx, pmd_idx, pte_ofs;
31783 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31784 unsigned long pfn;
31785 pgd_t *pgd;
31786 + pud_t *pud;
31787 pmd_t *pmd;
31788 pte_t *pte;
31789 unsigned pages_2m, pages_4k;
31790 @@ -291,8 +295,13 @@ repeat:
31791 pfn = start_pfn;
31792 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31793 pgd = pgd_base + pgd_idx;
31794 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31795 - pmd = one_md_table_init(pgd);
31796 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31797 + pud = pud_offset(pgd, 0);
31798 + pmd = pmd_offset(pud, 0);
31799 +
31800 +#ifdef CONFIG_X86_PAE
31801 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31802 +#endif
31803
31804 if (pfn >= end_pfn)
31805 continue;
31806 @@ -304,14 +313,13 @@ repeat:
31807 #endif
31808 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31809 pmd++, pmd_idx++) {
31810 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31811 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31812
31813 /*
31814 * Map with big pages if possible, otherwise
31815 * create normal page tables:
31816 */
31817 if (use_pse) {
31818 - unsigned int addr2;
31819 pgprot_t prot = PAGE_KERNEL_LARGE;
31820 /*
31821 * first pass will use the same initial
31822 @@ -322,11 +330,7 @@ repeat:
31823 _PAGE_PSE);
31824
31825 pfn &= PMD_MASK >> PAGE_SHIFT;
31826 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31827 - PAGE_OFFSET + PAGE_SIZE-1;
31828 -
31829 - if (is_kernel_text(addr) ||
31830 - is_kernel_text(addr2))
31831 + if (is_kernel_text(address, address + PMD_SIZE))
31832 prot = PAGE_KERNEL_LARGE_EXEC;
31833
31834 pages_2m++;
31835 @@ -343,7 +347,7 @@ repeat:
31836 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31837 pte += pte_ofs;
31838 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31839 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31840 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31841 pgprot_t prot = PAGE_KERNEL;
31842 /*
31843 * first pass will use the same initial
31844 @@ -351,7 +355,7 @@ repeat:
31845 */
31846 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31847
31848 - if (is_kernel_text(addr))
31849 + if (is_kernel_text(address, address + PAGE_SIZE))
31850 prot = PAGE_KERNEL_EXEC;
31851
31852 pages_4k++;
31853 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31854
31855 pud = pud_offset(pgd, va);
31856 pmd = pmd_offset(pud, va);
31857 - if (!pmd_present(*pmd))
31858 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31859 break;
31860
31861 /* should not be large page here */
31862 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31863
31864 static void __init pagetable_init(void)
31865 {
31866 - pgd_t *pgd_base = swapper_pg_dir;
31867 -
31868 - permanent_kmaps_init(pgd_base);
31869 + permanent_kmaps_init(swapper_pg_dir);
31870 }
31871
31872 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31873 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31874 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31875
31876 /* user-defined highmem size */
31877 @@ -787,10 +789,10 @@ void __init mem_init(void)
31878 ((unsigned long)&__init_end -
31879 (unsigned long)&__init_begin) >> 10,
31880
31881 - (unsigned long)&_etext, (unsigned long)&_edata,
31882 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31883 + (unsigned long)&_sdata, (unsigned long)&_edata,
31884 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31885
31886 - (unsigned long)&_text, (unsigned long)&_etext,
31887 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31888 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31889
31890 /*
31891 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31892 if (!kernel_set_to_readonly)
31893 return;
31894
31895 + start = ktla_ktva(start);
31896 pr_debug("Set kernel text: %lx - %lx for read write\n",
31897 start, start+size);
31898
31899 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31900 if (!kernel_set_to_readonly)
31901 return;
31902
31903 + start = ktla_ktva(start);
31904 pr_debug("Set kernel text: %lx - %lx for read only\n",
31905 start, start+size);
31906
31907 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31908 unsigned long start = PFN_ALIGN(_text);
31909 unsigned long size = PFN_ALIGN(_etext) - start;
31910
31911 + start = ktla_ktva(start);
31912 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31913 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31914 size >> 10);
31915 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31916 index 104d56a..62ba13f1 100644
31917 --- a/arch/x86/mm/init_64.c
31918 +++ b/arch/x86/mm/init_64.c
31919 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31920 * around without checking the pgd every time.
31921 */
31922
31923 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31924 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31925 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31926
31927 int force_personality32;
31928 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31929
31930 for (address = start; address <= end; address += PGDIR_SIZE) {
31931 const pgd_t *pgd_ref = pgd_offset_k(address);
31932 +
31933 +#ifdef CONFIG_PAX_PER_CPU_PGD
31934 + unsigned long cpu;
31935 +#else
31936 struct page *page;
31937 +#endif
31938
31939 if (pgd_none(*pgd_ref))
31940 continue;
31941
31942 spin_lock(&pgd_lock);
31943 +
31944 +#ifdef CONFIG_PAX_PER_CPU_PGD
31945 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31946 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31947 +
31948 + if (pgd_none(*pgd))
31949 + set_pgd(pgd, *pgd_ref);
31950 + else
31951 + BUG_ON(pgd_page_vaddr(*pgd)
31952 + != pgd_page_vaddr(*pgd_ref));
31953 + pgd = pgd_offset_cpu(cpu, kernel, address);
31954 +#else
31955 list_for_each_entry(page, &pgd_list, lru) {
31956 pgd_t *pgd;
31957 spinlock_t *pgt_lock;
31958 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31959 /* the pgt_lock only for Xen */
31960 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31961 spin_lock(pgt_lock);
31962 +#endif
31963
31964 if (pgd_none(*pgd))
31965 set_pgd(pgd, *pgd_ref);
31966 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31967 BUG_ON(pgd_page_vaddr(*pgd)
31968 != pgd_page_vaddr(*pgd_ref));
31969
31970 +#ifndef CONFIG_PAX_PER_CPU_PGD
31971 spin_unlock(pgt_lock);
31972 +#endif
31973 +
31974 }
31975 spin_unlock(&pgd_lock);
31976 }
31977 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31978 {
31979 if (pgd_none(*pgd)) {
31980 pud_t *pud = (pud_t *)spp_getpage();
31981 - pgd_populate(&init_mm, pgd, pud);
31982 + pgd_populate_kernel(&init_mm, pgd, pud);
31983 if (pud != pud_offset(pgd, 0))
31984 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31985 pud, pud_offset(pgd, 0));
31986 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31987 {
31988 if (pud_none(*pud)) {
31989 pmd_t *pmd = (pmd_t *) spp_getpage();
31990 - pud_populate(&init_mm, pud, pmd);
31991 + pud_populate_kernel(&init_mm, pud, pmd);
31992 if (pmd != pmd_offset(pud, 0))
31993 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31994 pmd, pmd_offset(pud, 0));
31995 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31996 pmd = fill_pmd(pud, vaddr);
31997 pte = fill_pte(pmd, vaddr);
31998
31999 + pax_open_kernel();
32000 set_pte(pte, new_pte);
32001 + pax_close_kernel();
32002
32003 /*
32004 * It's enough to flush this one mapping.
32005 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
32006 pgd = pgd_offset_k((unsigned long)__va(phys));
32007 if (pgd_none(*pgd)) {
32008 pud = (pud_t *) spp_getpage();
32009 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
32010 - _PAGE_USER));
32011 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
32012 }
32013 pud = pud_offset(pgd, (unsigned long)__va(phys));
32014 if (pud_none(*pud)) {
32015 pmd = (pmd_t *) spp_getpage();
32016 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
32017 - _PAGE_USER));
32018 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
32019 }
32020 pmd = pmd_offset(pud, phys);
32021 BUG_ON(!pmd_none(*pmd));
32022 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
32023 prot);
32024
32025 spin_lock(&init_mm.page_table_lock);
32026 - pud_populate(&init_mm, pud, pmd);
32027 + pud_populate_kernel(&init_mm, pud, pmd);
32028 spin_unlock(&init_mm.page_table_lock);
32029 }
32030 __flush_tlb_all();
32031 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
32032 page_size_mask);
32033
32034 spin_lock(&init_mm.page_table_lock);
32035 - pgd_populate(&init_mm, pgd, pud);
32036 + pgd_populate_kernel(&init_mm, pgd, pud);
32037 spin_unlock(&init_mm.page_table_lock);
32038 pgd_changed = true;
32039 }
32040 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
32041 static struct vm_area_struct gate_vma = {
32042 .vm_start = VSYSCALL_START,
32043 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
32044 - .vm_page_prot = PAGE_READONLY_EXEC,
32045 - .vm_flags = VM_READ | VM_EXEC
32046 + .vm_page_prot = PAGE_READONLY,
32047 + .vm_flags = VM_READ
32048 };
32049
32050 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
32051 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
32052
32053 const char *arch_vma_name(struct vm_area_struct *vma)
32054 {
32055 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
32056 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
32057 return "[vdso]";
32058 if (vma == &gate_vma)
32059 return "[vsyscall]";
32060 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
32061 index 7b179b4..6bd17777 100644
32062 --- a/arch/x86/mm/iomap_32.c
32063 +++ b/arch/x86/mm/iomap_32.c
32064 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
32065 type = kmap_atomic_idx_push();
32066 idx = type + KM_TYPE_NR * smp_processor_id();
32067 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
32068 +
32069 + pax_open_kernel();
32070 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
32071 + pax_close_kernel();
32072 +
32073 arch_flush_lazy_mmu_mode();
32074
32075 return (void *)vaddr;
32076 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
32077 index 799580c..72f9fe0 100644
32078 --- a/arch/x86/mm/ioremap.c
32079 +++ b/arch/x86/mm/ioremap.c
32080 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
32081 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
32082 int is_ram = page_is_ram(pfn);
32083
32084 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
32085 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
32086 return NULL;
32087 WARN_ON_ONCE(is_ram);
32088 }
32089 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
32090 *
32091 * Caller must ensure there is only one unmapping for the same pointer.
32092 */
32093 -void iounmap(volatile void __iomem *addr)
32094 +void iounmap(const volatile void __iomem *addr)
32095 {
32096 struct vm_struct *p, *o;
32097
32098 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
32099
32100 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
32101 if (page_is_ram(start >> PAGE_SHIFT))
32102 +#ifdef CONFIG_HIGHMEM
32103 + if ((start >> PAGE_SHIFT) < max_low_pfn)
32104 +#endif
32105 return __va(phys);
32106
32107 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
32108 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
32109 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
32110 {
32111 if (page_is_ram(phys >> PAGE_SHIFT))
32112 +#ifdef CONFIG_HIGHMEM
32113 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
32114 +#endif
32115 return;
32116
32117 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
32118 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
32119 early_param("early_ioremap_debug", early_ioremap_debug_setup);
32120
32121 static __initdata int after_paging_init;
32122 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
32123 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
32124
32125 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
32126 {
32127 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
32128 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
32129
32130 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
32131 - memset(bm_pte, 0, sizeof(bm_pte));
32132 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
32133 + pmd_populate_user(&init_mm, pmd, bm_pte);
32134
32135 /*
32136 * The boot-ioremap range spans multiple pmds, for which
32137 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
32138 index d87dd6d..bf3fa66 100644
32139 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
32140 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
32141 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
32142 * memory (e.g. tracked pages)? For now, we need this to avoid
32143 * invoking kmemcheck for PnP BIOS calls.
32144 */
32145 - if (regs->flags & X86_VM_MASK)
32146 + if (v8086_mode(regs))
32147 return false;
32148 - if (regs->cs != __KERNEL_CS)
32149 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
32150 return false;
32151
32152 pte = kmemcheck_pte_lookup(address);
32153 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
32154 index 25e7e13..1964579 100644
32155 --- a/arch/x86/mm/mmap.c
32156 +++ b/arch/x86/mm/mmap.c
32157 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
32158 * Leave an at least ~128 MB hole with possible stack randomization.
32159 */
32160 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
32161 -#define MAX_GAP (TASK_SIZE/6*5)
32162 +#define MAX_GAP (pax_task_size/6*5)
32163
32164 static int mmap_is_legacy(void)
32165 {
32166 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
32167 return rnd << PAGE_SHIFT;
32168 }
32169
32170 -static unsigned long mmap_base(void)
32171 +static unsigned long mmap_base(struct mm_struct *mm)
32172 {
32173 unsigned long gap = rlimit(RLIMIT_STACK);
32174 + unsigned long pax_task_size = TASK_SIZE;
32175 +
32176 +#ifdef CONFIG_PAX_SEGMEXEC
32177 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32178 + pax_task_size = SEGMEXEC_TASK_SIZE;
32179 +#endif
32180
32181 if (gap < MIN_GAP)
32182 gap = MIN_GAP;
32183 else if (gap > MAX_GAP)
32184 gap = MAX_GAP;
32185
32186 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
32187 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
32188 }
32189
32190 /*
32191 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
32192 * does, but not when emulating X86_32
32193 */
32194 -static unsigned long mmap_legacy_base(void)
32195 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
32196 {
32197 - if (mmap_is_ia32())
32198 + if (mmap_is_ia32()) {
32199 +
32200 +#ifdef CONFIG_PAX_SEGMEXEC
32201 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32202 + return SEGMEXEC_TASK_UNMAPPED_BASE;
32203 + else
32204 +#endif
32205 +
32206 return TASK_UNMAPPED_BASE;
32207 - else
32208 + } else
32209 return TASK_UNMAPPED_BASE + mmap_rnd();
32210 }
32211
32212 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
32213 */
32214 void arch_pick_mmap_layout(struct mm_struct *mm)
32215 {
32216 - mm->mmap_legacy_base = mmap_legacy_base();
32217 - mm->mmap_base = mmap_base();
32218 + mm->mmap_legacy_base = mmap_legacy_base(mm);
32219 + mm->mmap_base = mmap_base(mm);
32220 +
32221 +#ifdef CONFIG_PAX_RANDMMAP
32222 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
32223 + mm->mmap_legacy_base += mm->delta_mmap;
32224 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
32225 + }
32226 +#endif
32227
32228 if (mmap_is_legacy()) {
32229 mm->mmap_base = mm->mmap_legacy_base;
32230 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
32231 index 0057a7a..95c7edd 100644
32232 --- a/arch/x86/mm/mmio-mod.c
32233 +++ b/arch/x86/mm/mmio-mod.c
32234 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
32235 break;
32236 default:
32237 {
32238 - unsigned char *ip = (unsigned char *)instptr;
32239 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
32240 my_trace->opcode = MMIO_UNKNOWN_OP;
32241 my_trace->width = 0;
32242 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
32243 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
32244 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32245 void __iomem *addr)
32246 {
32247 - static atomic_t next_id;
32248 + static atomic_unchecked_t next_id;
32249 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
32250 /* These are page-unaligned. */
32251 struct mmiotrace_map map = {
32252 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32253 .private = trace
32254 },
32255 .phys = offset,
32256 - .id = atomic_inc_return(&next_id)
32257 + .id = atomic_inc_return_unchecked(&next_id)
32258 };
32259 map.map_id = trace->id;
32260
32261 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
32262 ioremap_trace_core(offset, size, addr);
32263 }
32264
32265 -static void iounmap_trace_core(volatile void __iomem *addr)
32266 +static void iounmap_trace_core(const volatile void __iomem *addr)
32267 {
32268 struct mmiotrace_map map = {
32269 .phys = 0,
32270 @@ -328,7 +328,7 @@ not_enabled:
32271 }
32272 }
32273
32274 -void mmiotrace_iounmap(volatile void __iomem *addr)
32275 +void mmiotrace_iounmap(const volatile void __iomem *addr)
32276 {
32277 might_sleep();
32278 if (is_enabled()) /* recheck and proper locking in *_core() */
32279 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
32280 index 8bf93ba..dbcd670 100644
32281 --- a/arch/x86/mm/numa.c
32282 +++ b/arch/x86/mm/numa.c
32283 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
32284 return true;
32285 }
32286
32287 -static int __init numa_register_memblks(struct numa_meminfo *mi)
32288 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
32289 {
32290 unsigned long uninitialized_var(pfn_align);
32291 int i, nid;
32292 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
32293 index d0b1773..4c3327c 100644
32294 --- a/arch/x86/mm/pageattr-test.c
32295 +++ b/arch/x86/mm/pageattr-test.c
32296 @@ -36,7 +36,7 @@ enum {
32297
32298 static int pte_testbit(pte_t pte)
32299 {
32300 - return pte_flags(pte) & _PAGE_UNUSED1;
32301 + return pte_flags(pte) & _PAGE_CPA_TEST;
32302 }
32303
32304 struct split_state {
32305 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
32306 index bb32480..75f2f5e 100644
32307 --- a/arch/x86/mm/pageattr.c
32308 +++ b/arch/x86/mm/pageattr.c
32309 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32310 */
32311 #ifdef CONFIG_PCI_BIOS
32312 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
32313 - pgprot_val(forbidden) |= _PAGE_NX;
32314 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32315 #endif
32316
32317 /*
32318 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32319 * Does not cover __inittext since that is gone later on. On
32320 * 64bit we do not enforce !NX on the low mapping
32321 */
32322 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
32323 - pgprot_val(forbidden) |= _PAGE_NX;
32324 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
32325 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32326
32327 +#ifdef CONFIG_DEBUG_RODATA
32328 /*
32329 * The .rodata section needs to be read-only. Using the pfn
32330 * catches all aliases.
32331 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32332 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
32333 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
32334 pgprot_val(forbidden) |= _PAGE_RW;
32335 +#endif
32336
32337 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
32338 /*
32339 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32340 }
32341 #endif
32342
32343 +#ifdef CONFIG_PAX_KERNEXEC
32344 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
32345 + pgprot_val(forbidden) |= _PAGE_RW;
32346 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32347 + }
32348 +#endif
32349 +
32350 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
32351
32352 return prot;
32353 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
32354 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
32355 {
32356 /* change init_mm */
32357 + pax_open_kernel();
32358 set_pte_atomic(kpte, pte);
32359 +
32360 #ifdef CONFIG_X86_32
32361 if (!SHARED_KERNEL_PMD) {
32362 +
32363 +#ifdef CONFIG_PAX_PER_CPU_PGD
32364 + unsigned long cpu;
32365 +#else
32366 struct page *page;
32367 +#endif
32368
32369 +#ifdef CONFIG_PAX_PER_CPU_PGD
32370 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32371 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
32372 +#else
32373 list_for_each_entry(page, &pgd_list, lru) {
32374 - pgd_t *pgd;
32375 + pgd_t *pgd = (pgd_t *)page_address(page);
32376 +#endif
32377 +
32378 pud_t *pud;
32379 pmd_t *pmd;
32380
32381 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
32382 + pgd += pgd_index(address);
32383 pud = pud_offset(pgd, address);
32384 pmd = pmd_offset(pud, address);
32385 set_pte_atomic((pte_t *)pmd, pte);
32386 }
32387 }
32388 #endif
32389 + pax_close_kernel();
32390 }
32391
32392 static int
32393 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
32394 index 6574388..87e9bef 100644
32395 --- a/arch/x86/mm/pat.c
32396 +++ b/arch/x86/mm/pat.c
32397 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
32398
32399 if (!entry) {
32400 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
32401 - current->comm, current->pid, start, end - 1);
32402 + current->comm, task_pid_nr(current), start, end - 1);
32403 return -EINVAL;
32404 }
32405
32406 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
32407
32408 while (cursor < to) {
32409 if (!devmem_is_allowed(pfn)) {
32410 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
32411 - current->comm, from, to - 1);
32412 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
32413 + current->comm, from, to - 1, cursor);
32414 return 0;
32415 }
32416 cursor += PAGE_SIZE;
32417 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
32418 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
32419 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
32420 "for [mem %#010Lx-%#010Lx]\n",
32421 - current->comm, current->pid,
32422 + current->comm, task_pid_nr(current),
32423 cattr_name(flags),
32424 base, (unsigned long long)(base + size-1));
32425 return -EINVAL;
32426 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32427 flags = lookup_memtype(paddr);
32428 if (want_flags != flags) {
32429 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
32430 - current->comm, current->pid,
32431 + current->comm, task_pid_nr(current),
32432 cattr_name(want_flags),
32433 (unsigned long long)paddr,
32434 (unsigned long long)(paddr + size - 1),
32435 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32436 free_memtype(paddr, paddr + size);
32437 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
32438 " for [mem %#010Lx-%#010Lx], got %s\n",
32439 - current->comm, current->pid,
32440 + current->comm, task_pid_nr(current),
32441 cattr_name(want_flags),
32442 (unsigned long long)paddr,
32443 (unsigned long long)(paddr + size - 1),
32444 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
32445 index 415f6c4..d319983 100644
32446 --- a/arch/x86/mm/pat_rbtree.c
32447 +++ b/arch/x86/mm/pat_rbtree.c
32448 @@ -160,7 +160,7 @@ success:
32449
32450 failure:
32451 printk(KERN_INFO "%s:%d conflicting memory types "
32452 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
32453 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
32454 end, cattr_name(found_type), cattr_name(match->type));
32455 return -EBUSY;
32456 }
32457 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
32458 index 9f0614d..92ae64a 100644
32459 --- a/arch/x86/mm/pf_in.c
32460 +++ b/arch/x86/mm/pf_in.c
32461 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
32462 int i;
32463 enum reason_type rv = OTHERS;
32464
32465 - p = (unsigned char *)ins_addr;
32466 + p = (unsigned char *)ktla_ktva(ins_addr);
32467 p += skip_prefix(p, &prf);
32468 p += get_opcode(p, &opcode);
32469
32470 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
32471 struct prefix_bits prf;
32472 int i;
32473
32474 - p = (unsigned char *)ins_addr;
32475 + p = (unsigned char *)ktla_ktva(ins_addr);
32476 p += skip_prefix(p, &prf);
32477 p += get_opcode(p, &opcode);
32478
32479 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
32480 struct prefix_bits prf;
32481 int i;
32482
32483 - p = (unsigned char *)ins_addr;
32484 + p = (unsigned char *)ktla_ktva(ins_addr);
32485 p += skip_prefix(p, &prf);
32486 p += get_opcode(p, &opcode);
32487
32488 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
32489 struct prefix_bits prf;
32490 int i;
32491
32492 - p = (unsigned char *)ins_addr;
32493 + p = (unsigned char *)ktla_ktva(ins_addr);
32494 p += skip_prefix(p, &prf);
32495 p += get_opcode(p, &opcode);
32496 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
32497 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
32498 struct prefix_bits prf;
32499 int i;
32500
32501 - p = (unsigned char *)ins_addr;
32502 + p = (unsigned char *)ktla_ktva(ins_addr);
32503 p += skip_prefix(p, &prf);
32504 p += get_opcode(p, &opcode);
32505 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
32506 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
32507 index dfa537a..fd45c64 100644
32508 --- a/arch/x86/mm/pgtable.c
32509 +++ b/arch/x86/mm/pgtable.c
32510 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
32511 list_del(&page->lru);
32512 }
32513
32514 -#define UNSHARED_PTRS_PER_PGD \
32515 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32516 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32517 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
32518
32519 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
32520 +{
32521 + unsigned int count = USER_PGD_PTRS;
32522
32523 + if (!pax_user_shadow_base)
32524 + return;
32525 +
32526 + while (count--)
32527 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
32528 +}
32529 +#endif
32530 +
32531 +#ifdef CONFIG_PAX_PER_CPU_PGD
32532 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
32533 +{
32534 + unsigned int count = USER_PGD_PTRS;
32535 +
32536 + while (count--) {
32537 + pgd_t pgd;
32538 +
32539 +#ifdef CONFIG_X86_64
32540 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
32541 +#else
32542 + pgd = *src++;
32543 +#endif
32544 +
32545 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32546 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
32547 +#endif
32548 +
32549 + *dst++ = pgd;
32550 + }
32551 +
32552 +}
32553 +#endif
32554 +
32555 +#ifdef CONFIG_X86_64
32556 +#define pxd_t pud_t
32557 +#define pyd_t pgd_t
32558 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
32559 +#define pxd_free(mm, pud) pud_free((mm), (pud))
32560 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
32561 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
32562 +#define PYD_SIZE PGDIR_SIZE
32563 +#else
32564 +#define pxd_t pmd_t
32565 +#define pyd_t pud_t
32566 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
32567 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
32568 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
32569 +#define pyd_offset(mm, address) pud_offset((mm), (address))
32570 +#define PYD_SIZE PUD_SIZE
32571 +#endif
32572 +
32573 +#ifdef CONFIG_PAX_PER_CPU_PGD
32574 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
32575 +static inline void pgd_dtor(pgd_t *pgd) {}
32576 +#else
32577 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
32578 {
32579 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
32580 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
32581 pgd_list_del(pgd);
32582 spin_unlock(&pgd_lock);
32583 }
32584 +#endif
32585
32586 /*
32587 * List of all pgd's needed for non-PAE so it can invalidate entries
32588 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
32589 * -- nyc
32590 */
32591
32592 -#ifdef CONFIG_X86_PAE
32593 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
32594 /*
32595 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
32596 * updating the top-level pagetable entries to guarantee the
32597 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
32598 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
32599 * and initialize the kernel pmds here.
32600 */
32601 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
32602 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32603
32604 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32605 {
32606 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32607 */
32608 flush_tlb_mm(mm);
32609 }
32610 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
32611 +#define PREALLOCATED_PXDS USER_PGD_PTRS
32612 #else /* !CONFIG_X86_PAE */
32613
32614 /* No need to prepopulate any pagetable entries in non-PAE modes. */
32615 -#define PREALLOCATED_PMDS 0
32616 +#define PREALLOCATED_PXDS 0
32617
32618 #endif /* CONFIG_X86_PAE */
32619
32620 -static void free_pmds(pmd_t *pmds[])
32621 +static void free_pxds(pxd_t *pxds[])
32622 {
32623 int i;
32624
32625 - for(i = 0; i < PREALLOCATED_PMDS; i++)
32626 - if (pmds[i])
32627 - free_page((unsigned long)pmds[i]);
32628 + for(i = 0; i < PREALLOCATED_PXDS; i++)
32629 + if (pxds[i])
32630 + free_page((unsigned long)pxds[i]);
32631 }
32632
32633 -static int preallocate_pmds(pmd_t *pmds[])
32634 +static int preallocate_pxds(pxd_t *pxds[])
32635 {
32636 int i;
32637 bool failed = false;
32638
32639 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32640 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
32641 - if (pmd == NULL)
32642 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32643 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
32644 + if (pxd == NULL)
32645 failed = true;
32646 - pmds[i] = pmd;
32647 + pxds[i] = pxd;
32648 }
32649
32650 if (failed) {
32651 - free_pmds(pmds);
32652 + free_pxds(pxds);
32653 return -ENOMEM;
32654 }
32655
32656 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
32657 * preallocate which never got a corresponding vma will need to be
32658 * freed manually.
32659 */
32660 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32661 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32662 {
32663 int i;
32664
32665 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32666 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32667 pgd_t pgd = pgdp[i];
32668
32669 if (pgd_val(pgd) != 0) {
32670 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32671 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32672
32673 - pgdp[i] = native_make_pgd(0);
32674 + set_pgd(pgdp + i, native_make_pgd(0));
32675
32676 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32677 - pmd_free(mm, pmd);
32678 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32679 + pxd_free(mm, pxd);
32680 }
32681 }
32682 }
32683
32684 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32685 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32686 {
32687 - pud_t *pud;
32688 + pyd_t *pyd;
32689 int i;
32690
32691 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32692 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32693 return;
32694
32695 - pud = pud_offset(pgd, 0);
32696 -
32697 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32698 - pmd_t *pmd = pmds[i];
32699 +#ifdef CONFIG_X86_64
32700 + pyd = pyd_offset(mm, 0L);
32701 +#else
32702 + pyd = pyd_offset(pgd, 0L);
32703 +#endif
32704
32705 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32706 + pxd_t *pxd = pxds[i];
32707 if (i >= KERNEL_PGD_BOUNDARY)
32708 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32709 - sizeof(pmd_t) * PTRS_PER_PMD);
32710 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32711 + sizeof(pxd_t) * PTRS_PER_PMD);
32712
32713 - pud_populate(mm, pud, pmd);
32714 + pyd_populate(mm, pyd, pxd);
32715 }
32716 }
32717
32718 pgd_t *pgd_alloc(struct mm_struct *mm)
32719 {
32720 pgd_t *pgd;
32721 - pmd_t *pmds[PREALLOCATED_PMDS];
32722 + pxd_t *pxds[PREALLOCATED_PXDS];
32723
32724 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32725
32726 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32727
32728 mm->pgd = pgd;
32729
32730 - if (preallocate_pmds(pmds) != 0)
32731 + if (preallocate_pxds(pxds) != 0)
32732 goto out_free_pgd;
32733
32734 if (paravirt_pgd_alloc(mm) != 0)
32735 - goto out_free_pmds;
32736 + goto out_free_pxds;
32737
32738 /*
32739 * Make sure that pre-populating the pmds is atomic with
32740 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32741 spin_lock(&pgd_lock);
32742
32743 pgd_ctor(mm, pgd);
32744 - pgd_prepopulate_pmd(mm, pgd, pmds);
32745 + pgd_prepopulate_pxd(mm, pgd, pxds);
32746
32747 spin_unlock(&pgd_lock);
32748
32749 return pgd;
32750
32751 -out_free_pmds:
32752 - free_pmds(pmds);
32753 +out_free_pxds:
32754 + free_pxds(pxds);
32755 out_free_pgd:
32756 free_page((unsigned long)pgd);
32757 out:
32758 @@ -300,7 +363,7 @@ out:
32759
32760 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32761 {
32762 - pgd_mop_up_pmds(mm, pgd);
32763 + pgd_mop_up_pxds(mm, pgd);
32764 pgd_dtor(pgd);
32765 paravirt_pgd_free(mm, pgd);
32766 free_page((unsigned long)pgd);
32767 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32768 index a69bcb8..19068ab 100644
32769 --- a/arch/x86/mm/pgtable_32.c
32770 +++ b/arch/x86/mm/pgtable_32.c
32771 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32772 return;
32773 }
32774 pte = pte_offset_kernel(pmd, vaddr);
32775 +
32776 + pax_open_kernel();
32777 if (pte_val(pteval))
32778 set_pte_at(&init_mm, vaddr, pte, pteval);
32779 else
32780 pte_clear(&init_mm, vaddr, pte);
32781 + pax_close_kernel();
32782
32783 /*
32784 * It's enough to flush this one mapping.
32785 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32786 index e666cbb..61788c45 100644
32787 --- a/arch/x86/mm/physaddr.c
32788 +++ b/arch/x86/mm/physaddr.c
32789 @@ -10,7 +10,7 @@
32790 #ifdef CONFIG_X86_64
32791
32792 #ifdef CONFIG_DEBUG_VIRTUAL
32793 -unsigned long __phys_addr(unsigned long x)
32794 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32795 {
32796 unsigned long y = x - __START_KERNEL_map;
32797
32798 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32799 #else
32800
32801 #ifdef CONFIG_DEBUG_VIRTUAL
32802 -unsigned long __phys_addr(unsigned long x)
32803 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32804 {
32805 unsigned long phys_addr = x - PAGE_OFFSET;
32806 /* VMALLOC_* aren't constants */
32807 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32808 index 90555bf..f5f1828 100644
32809 --- a/arch/x86/mm/setup_nx.c
32810 +++ b/arch/x86/mm/setup_nx.c
32811 @@ -5,8 +5,10 @@
32812 #include <asm/pgtable.h>
32813 #include <asm/proto.h>
32814
32815 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32816 static int disable_nx;
32817
32818 +#ifndef CONFIG_PAX_PAGEEXEC
32819 /*
32820 * noexec = on|off
32821 *
32822 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32823 return 0;
32824 }
32825 early_param("noexec", noexec_setup);
32826 +#endif
32827 +
32828 +#endif
32829
32830 void x86_configure_nx(void)
32831 {
32832 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32833 if (cpu_has_nx && !disable_nx)
32834 __supported_pte_mask |= _PAGE_NX;
32835 else
32836 +#endif
32837 __supported_pte_mask &= ~_PAGE_NX;
32838 }
32839
32840 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32841 index ae699b3..f1b2ad2 100644
32842 --- a/arch/x86/mm/tlb.c
32843 +++ b/arch/x86/mm/tlb.c
32844 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32845 BUG();
32846 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32847 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32848 +
32849 +#ifndef CONFIG_PAX_PER_CPU_PGD
32850 load_cr3(swapper_pg_dir);
32851 +#endif
32852 +
32853 }
32854 }
32855 EXPORT_SYMBOL_GPL(leave_mm);
32856 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32857 new file mode 100644
32858 index 0000000..dace51c
32859 --- /dev/null
32860 +++ b/arch/x86/mm/uderef_64.c
32861 @@ -0,0 +1,37 @@
32862 +#include <linux/mm.h>
32863 +#include <asm/pgtable.h>
32864 +#include <asm/uaccess.h>
32865 +
32866 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32867 +/* PaX: due to the special call convention these functions must
32868 + * - remain leaf functions under all configurations,
32869 + * - never be called directly, only dereferenced from the wrappers.
32870 + */
32871 +void __pax_open_userland(void)
32872 +{
32873 + unsigned int cpu;
32874 +
32875 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32876 + return;
32877 +
32878 + cpu = raw_get_cpu();
32879 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32880 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32881 + raw_put_cpu_no_resched();
32882 +}
32883 +EXPORT_SYMBOL(__pax_open_userland);
32884 +
32885 +void __pax_close_userland(void)
32886 +{
32887 + unsigned int cpu;
32888 +
32889 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32890 + return;
32891 +
32892 + cpu = raw_get_cpu();
32893 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32894 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32895 + raw_put_cpu_no_resched();
32896 +}
32897 +EXPORT_SYMBOL(__pax_close_userland);
32898 +#endif
32899 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32900 index 877b9a1..a8ecf42 100644
32901 --- a/arch/x86/net/bpf_jit.S
32902 +++ b/arch/x86/net/bpf_jit.S
32903 @@ -9,6 +9,7 @@
32904 */
32905 #include <linux/linkage.h>
32906 #include <asm/dwarf2.h>
32907 +#include <asm/alternative-asm.h>
32908
32909 /*
32910 * Calling convention :
32911 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32912 jle bpf_slow_path_word
32913 mov (SKBDATA,%rsi),%eax
32914 bswap %eax /* ntohl() */
32915 + pax_force_retaddr
32916 ret
32917
32918 sk_load_half:
32919 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32920 jle bpf_slow_path_half
32921 movzwl (SKBDATA,%rsi),%eax
32922 rol $8,%ax # ntohs()
32923 + pax_force_retaddr
32924 ret
32925
32926 sk_load_byte:
32927 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32928 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32929 jle bpf_slow_path_byte
32930 movzbl (SKBDATA,%rsi),%eax
32931 + pax_force_retaddr
32932 ret
32933
32934 /**
32935 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32936 movzbl (SKBDATA,%rsi),%ebx
32937 and $15,%bl
32938 shl $2,%bl
32939 + pax_force_retaddr
32940 ret
32941
32942 /* rsi contains offset and can be scratched */
32943 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32944 js bpf_error
32945 mov -12(%rbp),%eax
32946 bswap %eax
32947 + pax_force_retaddr
32948 ret
32949
32950 bpf_slow_path_half:
32951 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32952 mov -12(%rbp),%ax
32953 rol $8,%ax
32954 movzwl %ax,%eax
32955 + pax_force_retaddr
32956 ret
32957
32958 bpf_slow_path_byte:
32959 bpf_slow_path_common(1)
32960 js bpf_error
32961 movzbl -12(%rbp),%eax
32962 + pax_force_retaddr
32963 ret
32964
32965 bpf_slow_path_byte_msh:
32966 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32967 and $15,%al
32968 shl $2,%al
32969 xchg %eax,%ebx
32970 + pax_force_retaddr
32971 ret
32972
32973 #define sk_negative_common(SIZE) \
32974 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32975 sk_negative_common(4)
32976 mov (%rax), %eax
32977 bswap %eax
32978 + pax_force_retaddr
32979 ret
32980
32981 bpf_slow_path_half_neg:
32982 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32983 mov (%rax),%ax
32984 rol $8,%ax
32985 movzwl %ax,%eax
32986 + pax_force_retaddr
32987 ret
32988
32989 bpf_slow_path_byte_neg:
32990 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32991 .globl sk_load_byte_negative_offset
32992 sk_negative_common(1)
32993 movzbl (%rax), %eax
32994 + pax_force_retaddr
32995 ret
32996
32997 bpf_slow_path_byte_msh_neg:
32998 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32999 and $15,%al
33000 shl $2,%al
33001 xchg %eax,%ebx
33002 + pax_force_retaddr
33003 ret
33004
33005 bpf_error:
33006 @@ -197,4 +210,5 @@ bpf_error:
33007 xor %eax,%eax
33008 mov -8(%rbp),%rbx
33009 leaveq
33010 + pax_force_retaddr
33011 ret
33012 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
33013 index 26328e8..8dfe0d5 100644
33014 --- a/arch/x86/net/bpf_jit_comp.c
33015 +++ b/arch/x86/net/bpf_jit_comp.c
33016 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
33017 return ptr + len;
33018 }
33019
33020 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33021 +#define MAX_INSTR_CODE_SIZE 96
33022 +#else
33023 +#define MAX_INSTR_CODE_SIZE 64
33024 +#endif
33025 +
33026 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
33027
33028 #define EMIT1(b1) EMIT(b1, 1)
33029 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
33030 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
33031 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
33032 +
33033 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33034 +/* original constant will appear in ecx */
33035 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
33036 +do { \
33037 + /* mov ecx, randkey */ \
33038 + EMIT1(0xb9); \
33039 + EMIT(_key, 4); \
33040 + /* xor ecx, randkey ^ off */ \
33041 + EMIT2(0x81, 0xf1); \
33042 + EMIT((_key) ^ (_off), 4); \
33043 +} while (0)
33044 +
33045 +#define EMIT1_off32(b1, _off) \
33046 +do { \
33047 + switch (b1) { \
33048 + case 0x05: /* add eax, imm32 */ \
33049 + case 0x2d: /* sub eax, imm32 */ \
33050 + case 0x25: /* and eax, imm32 */ \
33051 + case 0x0d: /* or eax, imm32 */ \
33052 + case 0xb8: /* mov eax, imm32 */ \
33053 + case 0x35: /* xor eax, imm32 */ \
33054 + case 0x3d: /* cmp eax, imm32 */ \
33055 + case 0xa9: /* test eax, imm32 */ \
33056 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33057 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
33058 + break; \
33059 + case 0xbb: /* mov ebx, imm32 */ \
33060 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33061 + /* mov ebx, ecx */ \
33062 + EMIT2(0x89, 0xcb); \
33063 + break; \
33064 + case 0xbe: /* mov esi, imm32 */ \
33065 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33066 + /* mov esi, ecx */ \
33067 + EMIT2(0x89, 0xce); \
33068 + break; \
33069 + case 0xe8: /* call rel imm32, always to known funcs */ \
33070 + EMIT1(b1); \
33071 + EMIT(_off, 4); \
33072 + break; \
33073 + case 0xe9: /* jmp rel imm32 */ \
33074 + EMIT1(b1); \
33075 + EMIT(_off, 4); \
33076 + /* prevent fall-through, we're not called if off = 0 */ \
33077 + EMIT(0xcccccccc, 4); \
33078 + EMIT(0xcccccccc, 4); \
33079 + break; \
33080 + default: \
33081 + BUILD_BUG(); \
33082 + } \
33083 +} while (0)
33084 +
33085 +#define EMIT2_off32(b1, b2, _off) \
33086 +do { \
33087 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
33088 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
33089 + EMIT(randkey, 4); \
33090 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
33091 + EMIT((_off) - randkey, 4); \
33092 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
33093 + DILUTE_CONST_SEQUENCE(_off, randkey); \
33094 + /* imul eax, ecx */ \
33095 + EMIT3(0x0f, 0xaf, 0xc1); \
33096 + } else { \
33097 + BUILD_BUG(); \
33098 + } \
33099 +} while (0)
33100 +#else
33101 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
33102 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
33103 +#endif
33104
33105 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
33106 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
33107 @@ -91,6 +168,24 @@ do { \
33108 #define X86_JBE 0x76
33109 #define X86_JA 0x77
33110
33111 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33112 +#define APPEND_FLOW_VERIFY() \
33113 +do { \
33114 + /* mov ecx, randkey */ \
33115 + EMIT1(0xb9); \
33116 + EMIT(randkey, 4); \
33117 + /* cmp ecx, randkey */ \
33118 + EMIT2(0x81, 0xf9); \
33119 + EMIT(randkey, 4); \
33120 + /* jz after 8 int 3s */ \
33121 + EMIT2(0x74, 0x08); \
33122 + EMIT(0xcccccccc, 4); \
33123 + EMIT(0xcccccccc, 4); \
33124 +} while (0)
33125 +#else
33126 +#define APPEND_FLOW_VERIFY() do { } while (0)
33127 +#endif
33128 +
33129 #define EMIT_COND_JMP(op, offset) \
33130 do { \
33131 if (is_near(offset)) \
33132 @@ -98,6 +193,7 @@ do { \
33133 else { \
33134 EMIT2(0x0f, op + 0x10); \
33135 EMIT(offset, 4); /* jxx .+off32 */ \
33136 + APPEND_FLOW_VERIFY(); \
33137 } \
33138 } while (0)
33139
33140 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
33141 return -1;
33142 }
33143
33144 -struct bpf_binary_header {
33145 - unsigned int pages;
33146 - /* Note : for security reasons, bpf code will follow a randomly
33147 - * sized amount of int3 instructions
33148 - */
33149 - u8 image[];
33150 -};
33151 -
33152 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
33153 +/* Note : for security reasons, bpf code will follow a randomly
33154 + * sized amount of int3 instructions
33155 + */
33156 +static u8 *bpf_alloc_binary(unsigned int proglen,
33157 u8 **image_ptr)
33158 {
33159 unsigned int sz, hole;
33160 - struct bpf_binary_header *header;
33161 + u8 *header;
33162
33163 /* Most of BPF filters are really small,
33164 * but if some of them fill a page, allow at least
33165 * 128 extra bytes to insert a random section of int3
33166 */
33167 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
33168 - header = module_alloc(sz);
33169 + sz = round_up(proglen + 128, PAGE_SIZE);
33170 + header = module_alloc_exec(sz);
33171 if (!header)
33172 return NULL;
33173
33174 + pax_open_kernel();
33175 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
33176 + pax_close_kernel();
33177
33178 - header->pages = sz / PAGE_SIZE;
33179 - hole = sz - (proglen + sizeof(*header));
33180 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
33181
33182 /* insert a random number of int3 instructions before BPF code */
33183 - *image_ptr = &header->image[prandom_u32() % hole];
33184 + *image_ptr = &header[prandom_u32() % hole];
33185 return header;
33186 }
33187
33188 void bpf_jit_compile(struct sk_filter *fp)
33189 {
33190 - u8 temp[64];
33191 + u8 temp[MAX_INSTR_CODE_SIZE];
33192 u8 *prog;
33193 unsigned int proglen, oldproglen = 0;
33194 int ilen, i;
33195 int t_offset, f_offset;
33196 u8 t_op, f_op, seen = 0, pass;
33197 u8 *image = NULL;
33198 - struct bpf_binary_header *header = NULL;
33199 + u8 *header = NULL;
33200 u8 *func;
33201 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
33202 unsigned int cleanup_addr; /* epilogue code offset */
33203 unsigned int *addrs;
33204 const struct sock_filter *filter = fp->insns;
33205 int flen = fp->len;
33206 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33207 + unsigned int randkey;
33208 +#endif
33209
33210 if (!bpf_jit_enable)
33211 return;
33212 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
33213 if (addrs == NULL)
33214 return;
33215
33216 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33217 + randkey = get_random_int();
33218 +#endif
33219 +
33220 /* Before first pass, make a rough estimation of addrs[]
33221 - * each bpf instruction is translated to less than 64 bytes
33222 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
33223 */
33224 for (proglen = 0, i = 0; i < flen; i++) {
33225 - proglen += 64;
33226 + proglen += MAX_INSTR_CODE_SIZE;
33227 addrs[i] = proglen;
33228 }
33229 cleanup_addr = proglen; /* epilogue address */
33230 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
33231 case BPF_S_ALU_MUL_K: /* A *= K */
33232 if (is_imm8(K))
33233 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
33234 - else {
33235 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
33236 - EMIT(K, 4);
33237 - }
33238 + else
33239 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
33240 break;
33241 case BPF_S_ALU_DIV_X: /* A /= X; */
33242 seen |= SEEN_XREG;
33243 @@ -359,15 +456,29 @@ void bpf_jit_compile(struct sk_filter *fp)
33244 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
33245 break;
33246 case BPF_S_ALU_MOD_K: /* A %= K; */
33247 + if (K == 1) {
33248 + CLEAR_A();
33249 + break;
33250 + }
33251 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
33252 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33253 + DILUTE_CONST_SEQUENCE(K, randkey);
33254 +#else
33255 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
33256 +#endif
33257 EMIT2(0xf7, 0xf1); /* div %ecx */
33258 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
33259 break;
33260 - case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
33261 - EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
33262 - EMIT(K, 4);
33263 - EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
33264 + case BPF_S_ALU_DIV_K: /* A /= K */
33265 + if (K == 1)
33266 + break;
33267 + EMIT2(0x31, 0xd2); /* xor %edx,%edx */
33268 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33269 + DILUTE_CONST_SEQUENCE(K, randkey);
33270 +#else
33271 + EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
33272 +#endif
33273 + EMIT2(0xf7, 0xf1); /* div %ecx */
33274 break;
33275 case BPF_S_ALU_AND_X:
33276 seen |= SEEN_XREG;
33277 @@ -637,8 +748,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
33278 if (is_imm8(K)) {
33279 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
33280 } else {
33281 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
33282 - EMIT(K, 4);
33283 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
33284 }
33285 } else {
33286 EMIT2(0x89,0xde); /* mov %ebx,%esi */
33287 @@ -728,10 +838,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33288 if (unlikely(proglen + ilen > oldproglen)) {
33289 pr_err("bpb_jit_compile fatal error\n");
33290 kfree(addrs);
33291 - module_free(NULL, header);
33292 + module_free_exec(NULL, image);
33293 return;
33294 }
33295 + pax_open_kernel();
33296 memcpy(image + proglen, temp, ilen);
33297 + pax_close_kernel();
33298 }
33299 proglen += ilen;
33300 addrs[i] = proglen;
33301 @@ -764,7 +876,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33302
33303 if (image) {
33304 bpf_flush_icache(header, image + proglen);
33305 - set_memory_ro((unsigned long)header, header->pages);
33306 fp->bpf_func = (void *)image;
33307 }
33308 out:
33309 @@ -776,10 +887,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
33310 {
33311 struct sk_filter *fp = container_of(work, struct sk_filter, work);
33312 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
33313 - struct bpf_binary_header *header = (void *)addr;
33314
33315 - set_memory_rw(addr, header->pages);
33316 - module_free(NULL, header);
33317 + set_memory_rw(addr, 1);
33318 + module_free_exec(NULL, (void *)addr);
33319 kfree(fp);
33320 }
33321
33322 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
33323 index d6aa6e8..266395a 100644
33324 --- a/arch/x86/oprofile/backtrace.c
33325 +++ b/arch/x86/oprofile/backtrace.c
33326 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
33327 struct stack_frame_ia32 *fp;
33328 unsigned long bytes;
33329
33330 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33331 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33332 if (bytes != sizeof(bufhead))
33333 return NULL;
33334
33335 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
33336 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
33337
33338 oprofile_add_trace(bufhead[0].return_address);
33339
33340 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
33341 struct stack_frame bufhead[2];
33342 unsigned long bytes;
33343
33344 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33345 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33346 if (bytes != sizeof(bufhead))
33347 return NULL;
33348
33349 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
33350 {
33351 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
33352
33353 - if (!user_mode_vm(regs)) {
33354 + if (!user_mode(regs)) {
33355 unsigned long stack = kernel_stack_pointer(regs);
33356 if (depth)
33357 dump_trace(NULL, regs, (unsigned long *)stack, 0,
33358 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
33359 index 6890d84..1dad1f1 100644
33360 --- a/arch/x86/oprofile/nmi_int.c
33361 +++ b/arch/x86/oprofile/nmi_int.c
33362 @@ -23,6 +23,7 @@
33363 #include <asm/nmi.h>
33364 #include <asm/msr.h>
33365 #include <asm/apic.h>
33366 +#include <asm/pgtable.h>
33367
33368 #include "op_counter.h"
33369 #include "op_x86_model.h"
33370 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
33371 if (ret)
33372 return ret;
33373
33374 - if (!model->num_virt_counters)
33375 - model->num_virt_counters = model->num_counters;
33376 + if (!model->num_virt_counters) {
33377 + pax_open_kernel();
33378 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
33379 + pax_close_kernel();
33380 + }
33381
33382 mux_init(ops);
33383
33384 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
33385 index 50d86c0..7985318 100644
33386 --- a/arch/x86/oprofile/op_model_amd.c
33387 +++ b/arch/x86/oprofile/op_model_amd.c
33388 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
33389 num_counters = AMD64_NUM_COUNTERS;
33390 }
33391
33392 - op_amd_spec.num_counters = num_counters;
33393 - op_amd_spec.num_controls = num_counters;
33394 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33395 + pax_open_kernel();
33396 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
33397 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
33398 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33399 + pax_close_kernel();
33400
33401 return 0;
33402 }
33403 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
33404 index d90528e..0127e2b 100644
33405 --- a/arch/x86/oprofile/op_model_ppro.c
33406 +++ b/arch/x86/oprofile/op_model_ppro.c
33407 @@ -19,6 +19,7 @@
33408 #include <asm/msr.h>
33409 #include <asm/apic.h>
33410 #include <asm/nmi.h>
33411 +#include <asm/pgtable.h>
33412
33413 #include "op_x86_model.h"
33414 #include "op_counter.h"
33415 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
33416
33417 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
33418
33419 - op_arch_perfmon_spec.num_counters = num_counters;
33420 - op_arch_perfmon_spec.num_controls = num_counters;
33421 + pax_open_kernel();
33422 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
33423 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
33424 + pax_close_kernel();
33425 }
33426
33427 static int arch_perfmon_init(struct oprofile_operations *ignore)
33428 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
33429 index 71e8a67..6a313bb 100644
33430 --- a/arch/x86/oprofile/op_x86_model.h
33431 +++ b/arch/x86/oprofile/op_x86_model.h
33432 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
33433 void (*switch_ctrl)(struct op_x86_model_spec const *model,
33434 struct op_msrs const * const msrs);
33435 #endif
33436 -};
33437 +} __do_const;
33438
33439 struct op_counter_config;
33440
33441 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
33442 index 372e9b8..e775a6c 100644
33443 --- a/arch/x86/pci/irq.c
33444 +++ b/arch/x86/pci/irq.c
33445 @@ -50,7 +50,7 @@ struct irq_router {
33446 struct irq_router_handler {
33447 u16 vendor;
33448 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
33449 -};
33450 +} __do_const;
33451
33452 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
33453 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
33454 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
33455 return 0;
33456 }
33457
33458 -static __initdata struct irq_router_handler pirq_routers[] = {
33459 +static __initconst const struct irq_router_handler pirq_routers[] = {
33460 { PCI_VENDOR_ID_INTEL, intel_router_probe },
33461 { PCI_VENDOR_ID_AL, ali_router_probe },
33462 { PCI_VENDOR_ID_ITE, ite_router_probe },
33463 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
33464 static void __init pirq_find_router(struct irq_router *r)
33465 {
33466 struct irq_routing_table *rt = pirq_table;
33467 - struct irq_router_handler *h;
33468 + const struct irq_router_handler *h;
33469
33470 #ifdef CONFIG_PCI_BIOS
33471 if (!rt->signature) {
33472 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
33473 return 0;
33474 }
33475
33476 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
33477 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
33478 {
33479 .callback = fix_broken_hp_bios_irq9,
33480 .ident = "HP Pavilion N5400 Series Laptop",
33481 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
33482 index 903fded..94b0d88 100644
33483 --- a/arch/x86/pci/mrst.c
33484 +++ b/arch/x86/pci/mrst.c
33485 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
33486 pr_info("Intel MID platform detected, using MID PCI ops\n");
33487 pci_mmcfg_late_init();
33488 pcibios_enable_irq = mrst_pci_irq_enable;
33489 - pci_root_ops = pci_mrst_ops;
33490 + pax_open_kernel();
33491 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
33492 + pax_close_kernel();
33493 pci_soc_mode = 1;
33494 /* Continue with standard init */
33495 return 1;
33496 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
33497 index c77b24a..c979855 100644
33498 --- a/arch/x86/pci/pcbios.c
33499 +++ b/arch/x86/pci/pcbios.c
33500 @@ -79,7 +79,7 @@ union bios32 {
33501 static struct {
33502 unsigned long address;
33503 unsigned short segment;
33504 -} bios32_indirect = { 0, __KERNEL_CS };
33505 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
33506
33507 /*
33508 * Returns the entry point for the given service, NULL on error
33509 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
33510 unsigned long length; /* %ecx */
33511 unsigned long entry; /* %edx */
33512 unsigned long flags;
33513 + struct desc_struct d, *gdt;
33514
33515 local_irq_save(flags);
33516 - __asm__("lcall *(%%edi); cld"
33517 +
33518 + gdt = get_cpu_gdt_table(smp_processor_id());
33519 +
33520 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
33521 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33522 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
33523 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33524 +
33525 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
33526 : "=a" (return_code),
33527 "=b" (address),
33528 "=c" (length),
33529 "=d" (entry)
33530 : "0" (service),
33531 "1" (0),
33532 - "D" (&bios32_indirect));
33533 + "D" (&bios32_indirect),
33534 + "r"(__PCIBIOS_DS)
33535 + : "memory");
33536 +
33537 + pax_open_kernel();
33538 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
33539 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
33540 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
33541 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
33542 + pax_close_kernel();
33543 +
33544 local_irq_restore(flags);
33545
33546 switch (return_code) {
33547 - case 0:
33548 - return address + entry;
33549 - case 0x80: /* Not present */
33550 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33551 - return 0;
33552 - default: /* Shouldn't happen */
33553 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33554 - service, return_code);
33555 + case 0: {
33556 + int cpu;
33557 + unsigned char flags;
33558 +
33559 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
33560 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
33561 + printk(KERN_WARNING "bios32_service: not valid\n");
33562 return 0;
33563 + }
33564 + address = address + PAGE_OFFSET;
33565 + length += 16UL; /* some BIOSs underreport this... */
33566 + flags = 4;
33567 + if (length >= 64*1024*1024) {
33568 + length >>= PAGE_SHIFT;
33569 + flags |= 8;
33570 + }
33571 +
33572 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33573 + gdt = get_cpu_gdt_table(cpu);
33574 + pack_descriptor(&d, address, length, 0x9b, flags);
33575 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33576 + pack_descriptor(&d, address, length, 0x93, flags);
33577 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33578 + }
33579 + return entry;
33580 + }
33581 + case 0x80: /* Not present */
33582 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33583 + return 0;
33584 + default: /* Shouldn't happen */
33585 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33586 + service, return_code);
33587 + return 0;
33588 }
33589 }
33590
33591 static struct {
33592 unsigned long address;
33593 unsigned short segment;
33594 -} pci_indirect = { 0, __KERNEL_CS };
33595 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
33596
33597 -static int pci_bios_present;
33598 +static int pci_bios_present __read_only;
33599
33600 static int check_pcibios(void)
33601 {
33602 @@ -131,11 +174,13 @@ static int check_pcibios(void)
33603 unsigned long flags, pcibios_entry;
33604
33605 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
33606 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
33607 + pci_indirect.address = pcibios_entry;
33608
33609 local_irq_save(flags);
33610 - __asm__(
33611 - "lcall *(%%edi); cld\n\t"
33612 + __asm__("movw %w6, %%ds\n\t"
33613 + "lcall *%%ss:(%%edi); cld\n\t"
33614 + "push %%ss\n\t"
33615 + "pop %%ds\n\t"
33616 "jc 1f\n\t"
33617 "xor %%ah, %%ah\n"
33618 "1:"
33619 @@ -144,7 +189,8 @@ static int check_pcibios(void)
33620 "=b" (ebx),
33621 "=c" (ecx)
33622 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
33623 - "D" (&pci_indirect)
33624 + "D" (&pci_indirect),
33625 + "r" (__PCIBIOS_DS)
33626 : "memory");
33627 local_irq_restore(flags);
33628
33629 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33630
33631 switch (len) {
33632 case 1:
33633 - __asm__("lcall *(%%esi); cld\n\t"
33634 + __asm__("movw %w6, %%ds\n\t"
33635 + "lcall *%%ss:(%%esi); cld\n\t"
33636 + "push %%ss\n\t"
33637 + "pop %%ds\n\t"
33638 "jc 1f\n\t"
33639 "xor %%ah, %%ah\n"
33640 "1:"
33641 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33642 : "1" (PCIBIOS_READ_CONFIG_BYTE),
33643 "b" (bx),
33644 "D" ((long)reg),
33645 - "S" (&pci_indirect));
33646 + "S" (&pci_indirect),
33647 + "r" (__PCIBIOS_DS));
33648 /*
33649 * Zero-extend the result beyond 8 bits, do not trust the
33650 * BIOS having done it:
33651 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33652 *value &= 0xff;
33653 break;
33654 case 2:
33655 - __asm__("lcall *(%%esi); cld\n\t"
33656 + __asm__("movw %w6, %%ds\n\t"
33657 + "lcall *%%ss:(%%esi); cld\n\t"
33658 + "push %%ss\n\t"
33659 + "pop %%ds\n\t"
33660 "jc 1f\n\t"
33661 "xor %%ah, %%ah\n"
33662 "1:"
33663 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33664 : "1" (PCIBIOS_READ_CONFIG_WORD),
33665 "b" (bx),
33666 "D" ((long)reg),
33667 - "S" (&pci_indirect));
33668 + "S" (&pci_indirect),
33669 + "r" (__PCIBIOS_DS));
33670 /*
33671 * Zero-extend the result beyond 16 bits, do not trust the
33672 * BIOS having done it:
33673 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33674 *value &= 0xffff;
33675 break;
33676 case 4:
33677 - __asm__("lcall *(%%esi); cld\n\t"
33678 + __asm__("movw %w6, %%ds\n\t"
33679 + "lcall *%%ss:(%%esi); cld\n\t"
33680 + "push %%ss\n\t"
33681 + "pop %%ds\n\t"
33682 "jc 1f\n\t"
33683 "xor %%ah, %%ah\n"
33684 "1:"
33685 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33686 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33687 "b" (bx),
33688 "D" ((long)reg),
33689 - "S" (&pci_indirect));
33690 + "S" (&pci_indirect),
33691 + "r" (__PCIBIOS_DS));
33692 break;
33693 }
33694
33695 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33696
33697 switch (len) {
33698 case 1:
33699 - __asm__("lcall *(%%esi); cld\n\t"
33700 + __asm__("movw %w6, %%ds\n\t"
33701 + "lcall *%%ss:(%%esi); cld\n\t"
33702 + "push %%ss\n\t"
33703 + "pop %%ds\n\t"
33704 "jc 1f\n\t"
33705 "xor %%ah, %%ah\n"
33706 "1:"
33707 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33708 "c" (value),
33709 "b" (bx),
33710 "D" ((long)reg),
33711 - "S" (&pci_indirect));
33712 + "S" (&pci_indirect),
33713 + "r" (__PCIBIOS_DS));
33714 break;
33715 case 2:
33716 - __asm__("lcall *(%%esi); cld\n\t"
33717 + __asm__("movw %w6, %%ds\n\t"
33718 + "lcall *%%ss:(%%esi); cld\n\t"
33719 + "push %%ss\n\t"
33720 + "pop %%ds\n\t"
33721 "jc 1f\n\t"
33722 "xor %%ah, %%ah\n"
33723 "1:"
33724 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33725 "c" (value),
33726 "b" (bx),
33727 "D" ((long)reg),
33728 - "S" (&pci_indirect));
33729 + "S" (&pci_indirect),
33730 + "r" (__PCIBIOS_DS));
33731 break;
33732 case 4:
33733 - __asm__("lcall *(%%esi); cld\n\t"
33734 + __asm__("movw %w6, %%ds\n\t"
33735 + "lcall *%%ss:(%%esi); cld\n\t"
33736 + "push %%ss\n\t"
33737 + "pop %%ds\n\t"
33738 "jc 1f\n\t"
33739 "xor %%ah, %%ah\n"
33740 "1:"
33741 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33742 "c" (value),
33743 "b" (bx),
33744 "D" ((long)reg),
33745 - "S" (&pci_indirect));
33746 + "S" (&pci_indirect),
33747 + "r" (__PCIBIOS_DS));
33748 break;
33749 }
33750
33751 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33752
33753 DBG("PCI: Fetching IRQ routing table... ");
33754 __asm__("push %%es\n\t"
33755 + "movw %w8, %%ds\n\t"
33756 "push %%ds\n\t"
33757 "pop %%es\n\t"
33758 - "lcall *(%%esi); cld\n\t"
33759 + "lcall *%%ss:(%%esi); cld\n\t"
33760 "pop %%es\n\t"
33761 + "push %%ss\n\t"
33762 + "pop %%ds\n"
33763 "jc 1f\n\t"
33764 "xor %%ah, %%ah\n"
33765 "1:"
33766 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33767 "1" (0),
33768 "D" ((long) &opt),
33769 "S" (&pci_indirect),
33770 - "m" (opt)
33771 + "m" (opt),
33772 + "r" (__PCIBIOS_DS)
33773 : "memory");
33774 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33775 if (ret & 0xff00)
33776 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33777 {
33778 int ret;
33779
33780 - __asm__("lcall *(%%esi); cld\n\t"
33781 + __asm__("movw %w5, %%ds\n\t"
33782 + "lcall *%%ss:(%%esi); cld\n\t"
33783 + "push %%ss\n\t"
33784 + "pop %%ds\n"
33785 "jc 1f\n\t"
33786 "xor %%ah, %%ah\n"
33787 "1:"
33788 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33789 : "0" (PCIBIOS_SET_PCI_HW_INT),
33790 "b" ((dev->bus->number << 8) | dev->devfn),
33791 "c" ((irq << 8) | (pin + 10)),
33792 - "S" (&pci_indirect));
33793 + "S" (&pci_indirect),
33794 + "r" (__PCIBIOS_DS));
33795 return !(ret & 0xff00);
33796 }
33797 EXPORT_SYMBOL(pcibios_set_irq_routing);
33798 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33799 index 40e4469..d915bf9 100644
33800 --- a/arch/x86/platform/efi/efi_32.c
33801 +++ b/arch/x86/platform/efi/efi_32.c
33802 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33803 {
33804 struct desc_ptr gdt_descr;
33805
33806 +#ifdef CONFIG_PAX_KERNEXEC
33807 + struct desc_struct d;
33808 +#endif
33809 +
33810 local_irq_save(efi_rt_eflags);
33811
33812 load_cr3(initial_page_table);
33813 __flush_tlb_all();
33814
33815 +#ifdef CONFIG_PAX_KERNEXEC
33816 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33817 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33818 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33819 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33820 +#endif
33821 +
33822 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33823 gdt_descr.size = GDT_SIZE - 1;
33824 load_gdt(&gdt_descr);
33825 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33826 {
33827 struct desc_ptr gdt_descr;
33828
33829 +#ifdef CONFIG_PAX_KERNEXEC
33830 + struct desc_struct d;
33831 +
33832 + memset(&d, 0, sizeof d);
33833 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33834 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33835 +#endif
33836 +
33837 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33838 gdt_descr.size = GDT_SIZE - 1;
33839 load_gdt(&gdt_descr);
33840
33841 +#ifdef CONFIG_PAX_PER_CPU_PGD
33842 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33843 +#else
33844 load_cr3(swapper_pg_dir);
33845 +#endif
33846 +
33847 __flush_tlb_all();
33848
33849 local_irq_restore(efi_rt_eflags);
33850 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33851 index 39a0e7f1..872396e 100644
33852 --- a/arch/x86/platform/efi/efi_64.c
33853 +++ b/arch/x86/platform/efi/efi_64.c
33854 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33855 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33856 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33857 }
33858 +
33859 +#ifdef CONFIG_PAX_PER_CPU_PGD
33860 + load_cr3(swapper_pg_dir);
33861 +#endif
33862 +
33863 __flush_tlb_all();
33864 }
33865
33866 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33867 for (pgd = 0; pgd < n_pgds; pgd++)
33868 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33869 kfree(save_pgd);
33870 +
33871 +#ifdef CONFIG_PAX_PER_CPU_PGD
33872 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33873 +#endif
33874 +
33875 __flush_tlb_all();
33876 local_irq_restore(efi_flags);
33877 early_code_mapping_set_exec(0);
33878 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33879 index fbe66e6..eae5e38 100644
33880 --- a/arch/x86/platform/efi/efi_stub_32.S
33881 +++ b/arch/x86/platform/efi/efi_stub_32.S
33882 @@ -6,7 +6,9 @@
33883 */
33884
33885 #include <linux/linkage.h>
33886 +#include <linux/init.h>
33887 #include <asm/page_types.h>
33888 +#include <asm/segment.h>
33889
33890 /*
33891 * efi_call_phys(void *, ...) is a function with variable parameters.
33892 @@ -20,7 +22,7 @@
33893 * service functions will comply with gcc calling convention, too.
33894 */
33895
33896 -.text
33897 +__INIT
33898 ENTRY(efi_call_phys)
33899 /*
33900 * 0. The function can only be called in Linux kernel. So CS has been
33901 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33902 * The mapping of lower virtual memory has been created in prelog and
33903 * epilog.
33904 */
33905 - movl $1f, %edx
33906 - subl $__PAGE_OFFSET, %edx
33907 - jmp *%edx
33908 +#ifdef CONFIG_PAX_KERNEXEC
33909 + movl $(__KERNEXEC_EFI_DS), %edx
33910 + mov %edx, %ds
33911 + mov %edx, %es
33912 + mov %edx, %ss
33913 + addl $2f,(1f)
33914 + ljmp *(1f)
33915 +
33916 +__INITDATA
33917 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33918 +.previous
33919 +
33920 +2:
33921 + subl $2b,(1b)
33922 +#else
33923 + jmp 1f-__PAGE_OFFSET
33924 1:
33925 +#endif
33926
33927 /*
33928 * 2. Now on the top of stack is the return
33929 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33930 * parameter 2, ..., param n. To make things easy, we save the return
33931 * address of efi_call_phys in a global variable.
33932 */
33933 - popl %edx
33934 - movl %edx, saved_return_addr
33935 - /* get the function pointer into ECX*/
33936 - popl %ecx
33937 - movl %ecx, efi_rt_function_ptr
33938 - movl $2f, %edx
33939 - subl $__PAGE_OFFSET, %edx
33940 - pushl %edx
33941 + popl (saved_return_addr)
33942 + popl (efi_rt_function_ptr)
33943
33944 /*
33945 * 3. Clear PG bit in %CR0.
33946 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33947 /*
33948 * 5. Call the physical function.
33949 */
33950 - jmp *%ecx
33951 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33952
33953 -2:
33954 /*
33955 * 6. After EFI runtime service returns, control will return to
33956 * following instruction. We'd better readjust stack pointer first.
33957 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33958 movl %cr0, %edx
33959 orl $0x80000000, %edx
33960 movl %edx, %cr0
33961 - jmp 1f
33962 -1:
33963 +
33964 /*
33965 * 8. Now restore the virtual mode from flat mode by
33966 * adding EIP with PAGE_OFFSET.
33967 */
33968 - movl $1f, %edx
33969 - jmp *%edx
33970 +#ifdef CONFIG_PAX_KERNEXEC
33971 + movl $(__KERNEL_DS), %edx
33972 + mov %edx, %ds
33973 + mov %edx, %es
33974 + mov %edx, %ss
33975 + ljmp $(__KERNEL_CS),$1f
33976 +#else
33977 + jmp 1f+__PAGE_OFFSET
33978 +#endif
33979 1:
33980
33981 /*
33982 * 9. Balance the stack. And because EAX contain the return value,
33983 * we'd better not clobber it.
33984 */
33985 - leal efi_rt_function_ptr, %edx
33986 - movl (%edx), %ecx
33987 - pushl %ecx
33988 + pushl (efi_rt_function_ptr)
33989
33990 /*
33991 - * 10. Push the saved return address onto the stack and return.
33992 + * 10. Return to the saved return address.
33993 */
33994 - leal saved_return_addr, %edx
33995 - movl (%edx), %ecx
33996 - pushl %ecx
33997 - ret
33998 + jmpl *(saved_return_addr)
33999 ENDPROC(efi_call_phys)
34000 .previous
34001
34002 -.data
34003 +__INITDATA
34004 saved_return_addr:
34005 .long 0
34006 efi_rt_function_ptr:
34007 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
34008 index 4c07cca..2c8427d 100644
34009 --- a/arch/x86/platform/efi/efi_stub_64.S
34010 +++ b/arch/x86/platform/efi/efi_stub_64.S
34011 @@ -7,6 +7,7 @@
34012 */
34013
34014 #include <linux/linkage.h>
34015 +#include <asm/alternative-asm.h>
34016
34017 #define SAVE_XMM \
34018 mov %rsp, %rax; \
34019 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
34020 call *%rdi
34021 addq $32, %rsp
34022 RESTORE_XMM
34023 + pax_force_retaddr 0, 1
34024 ret
34025 ENDPROC(efi_call0)
34026
34027 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
34028 call *%rdi
34029 addq $32, %rsp
34030 RESTORE_XMM
34031 + pax_force_retaddr 0, 1
34032 ret
34033 ENDPROC(efi_call1)
34034
34035 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
34036 call *%rdi
34037 addq $32, %rsp
34038 RESTORE_XMM
34039 + pax_force_retaddr 0, 1
34040 ret
34041 ENDPROC(efi_call2)
34042
34043 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
34044 call *%rdi
34045 addq $32, %rsp
34046 RESTORE_XMM
34047 + pax_force_retaddr 0, 1
34048 ret
34049 ENDPROC(efi_call3)
34050
34051 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
34052 call *%rdi
34053 addq $32, %rsp
34054 RESTORE_XMM
34055 + pax_force_retaddr 0, 1
34056 ret
34057 ENDPROC(efi_call4)
34058
34059 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
34060 call *%rdi
34061 addq $48, %rsp
34062 RESTORE_XMM
34063 + pax_force_retaddr 0, 1
34064 ret
34065 ENDPROC(efi_call5)
34066
34067 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
34068 call *%rdi
34069 addq $48, %rsp
34070 RESTORE_XMM
34071 + pax_force_retaddr 0, 1
34072 ret
34073 ENDPROC(efi_call6)
34074 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
34075 index 3ca5957..7909c18 100644
34076 --- a/arch/x86/platform/mrst/mrst.c
34077 +++ b/arch/x86/platform/mrst/mrst.c
34078 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
34079 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
34080 int sfi_mrtc_num;
34081
34082 -static void mrst_power_off(void)
34083 +static __noreturn void mrst_power_off(void)
34084 {
34085 + BUG();
34086 }
34087
34088 -static void mrst_reboot(void)
34089 +static __noreturn void mrst_reboot(void)
34090 {
34091 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
34092 + BUG();
34093 }
34094
34095 /* parse all the mtimer info to a static mtimer array */
34096 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
34097 index d6ee929..3637cb5 100644
34098 --- a/arch/x86/platform/olpc/olpc_dt.c
34099 +++ b/arch/x86/platform/olpc/olpc_dt.c
34100 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
34101 return res;
34102 }
34103
34104 -static struct of_pdt_ops prom_olpc_ops __initdata = {
34105 +static struct of_pdt_ops prom_olpc_ops __initconst = {
34106 .nextprop = olpc_dt_nextprop,
34107 .getproplen = olpc_dt_getproplen,
34108 .getproperty = olpc_dt_getproperty,
34109 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
34110 index 424f4c9..f2a2988 100644
34111 --- a/arch/x86/power/cpu.c
34112 +++ b/arch/x86/power/cpu.c
34113 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
34114 static void fix_processor_context(void)
34115 {
34116 int cpu = smp_processor_id();
34117 - struct tss_struct *t = &per_cpu(init_tss, cpu);
34118 -#ifdef CONFIG_X86_64
34119 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
34120 - tss_desc tss;
34121 -#endif
34122 + struct tss_struct *t = init_tss + cpu;
34123 +
34124 set_tss_desc(cpu, t); /*
34125 * This just modifies memory; should not be
34126 * necessary. But... This is necessary, because
34127 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
34128 */
34129
34130 #ifdef CONFIG_X86_64
34131 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
34132 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
34133 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
34134 -
34135 syscall_init(); /* This sets MSR_*STAR and related */
34136 #endif
34137 load_TR_desc(); /* This does ltr */
34138 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
34139 index a44f457..9140171 100644
34140 --- a/arch/x86/realmode/init.c
34141 +++ b/arch/x86/realmode/init.c
34142 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
34143 __va(real_mode_header->trampoline_header);
34144
34145 #ifdef CONFIG_X86_32
34146 - trampoline_header->start = __pa_symbol(startup_32_smp);
34147 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
34148 +
34149 +#ifdef CONFIG_PAX_KERNEXEC
34150 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
34151 +#endif
34152 +
34153 + trampoline_header->boot_cs = __BOOT_CS;
34154 trampoline_header->gdt_limit = __BOOT_DS + 7;
34155 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
34156 #else
34157 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
34158 *trampoline_cr4_features = read_cr4();
34159
34160 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
34161 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
34162 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
34163 trampoline_pgd[511] = init_level4_pgt[511].pgd;
34164 #endif
34165 }
34166 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
34167 index 9cac825..4890b25 100644
34168 --- a/arch/x86/realmode/rm/Makefile
34169 +++ b/arch/x86/realmode/rm/Makefile
34170 @@ -79,5 +79,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
34171 $(call cc-option, -fno-unit-at-a-time)) \
34172 $(call cc-option, -fno-stack-protector) \
34173 $(call cc-option, -mpreferred-stack-boundary=2)
34174 +ifdef CONSTIFY_PLUGIN
34175 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
34176 +endif
34177 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
34178 GCOV_PROFILE := n
34179 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
34180 index a28221d..93c40f1 100644
34181 --- a/arch/x86/realmode/rm/header.S
34182 +++ b/arch/x86/realmode/rm/header.S
34183 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
34184 #endif
34185 /* APM/BIOS reboot */
34186 .long pa_machine_real_restart_asm
34187 -#ifdef CONFIG_X86_64
34188 +#ifdef CONFIG_X86_32
34189 + .long __KERNEL_CS
34190 +#else
34191 .long __KERNEL32_CS
34192 #endif
34193 END(real_mode_header)
34194 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
34195 index c1b2791..f9e31c7 100644
34196 --- a/arch/x86/realmode/rm/trampoline_32.S
34197 +++ b/arch/x86/realmode/rm/trampoline_32.S
34198 @@ -25,6 +25,12 @@
34199 #include <asm/page_types.h>
34200 #include "realmode.h"
34201
34202 +#ifdef CONFIG_PAX_KERNEXEC
34203 +#define ta(X) (X)
34204 +#else
34205 +#define ta(X) (pa_ ## X)
34206 +#endif
34207 +
34208 .text
34209 .code16
34210
34211 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
34212
34213 cli # We should be safe anyway
34214
34215 - movl tr_start, %eax # where we need to go
34216 -
34217 movl $0xA5A5A5A5, trampoline_status
34218 # write marker for master knows we're running
34219
34220 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
34221 movw $1, %dx # protected mode (PE) bit
34222 lmsw %dx # into protected mode
34223
34224 - ljmpl $__BOOT_CS, $pa_startup_32
34225 + ljmpl *(trampoline_header)
34226
34227 .section ".text32","ax"
34228 .code32
34229 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
34230 .balign 8
34231 GLOBAL(trampoline_header)
34232 tr_start: .space 4
34233 - tr_gdt_pad: .space 2
34234 + tr_boot_cs: .space 2
34235 tr_gdt: .space 6
34236 END(trampoline_header)
34237
34238 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
34239 index bb360dc..d0fd8f8 100644
34240 --- a/arch/x86/realmode/rm/trampoline_64.S
34241 +++ b/arch/x86/realmode/rm/trampoline_64.S
34242 @@ -94,6 +94,7 @@ ENTRY(startup_32)
34243 movl %edx, %gs
34244
34245 movl pa_tr_cr4, %eax
34246 + andl $~X86_CR4_PCIDE, %eax
34247 movl %eax, %cr4 # Enable PAE mode
34248
34249 # Setup trampoline 4 level pagetables
34250 @@ -107,7 +108,7 @@ ENTRY(startup_32)
34251 wrmsr
34252
34253 # Enable paging and in turn activate Long Mode
34254 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
34255 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
34256 movl %eax, %cr0
34257
34258 /*
34259 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
34260 index e812034..c747134 100644
34261 --- a/arch/x86/tools/Makefile
34262 +++ b/arch/x86/tools/Makefile
34263 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
34264
34265 $(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
34266
34267 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
34268 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
34269 hostprogs-y += relocs
34270 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
34271 relocs: $(obj)/relocs
34272 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
34273 index f7bab68..b6d9886 100644
34274 --- a/arch/x86/tools/relocs.c
34275 +++ b/arch/x86/tools/relocs.c
34276 @@ -1,5 +1,7 @@
34277 /* This is included from relocs_32/64.c */
34278
34279 +#include "../../../include/generated/autoconf.h"
34280 +
34281 #define ElfW(type) _ElfW(ELF_BITS, type)
34282 #define _ElfW(bits, type) __ElfW(bits, type)
34283 #define __ElfW(bits, type) Elf##bits##_##type
34284 @@ -11,6 +13,7 @@
34285 #define Elf_Sym ElfW(Sym)
34286
34287 static Elf_Ehdr ehdr;
34288 +static Elf_Phdr *phdr;
34289
34290 struct relocs {
34291 uint32_t *offset;
34292 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
34293 }
34294 }
34295
34296 +static void read_phdrs(FILE *fp)
34297 +{
34298 + unsigned int i;
34299 +
34300 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
34301 + if (!phdr) {
34302 + die("Unable to allocate %d program headers\n",
34303 + ehdr.e_phnum);
34304 + }
34305 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
34306 + die("Seek to %d failed: %s\n",
34307 + ehdr.e_phoff, strerror(errno));
34308 + }
34309 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
34310 + die("Cannot read ELF program headers: %s\n",
34311 + strerror(errno));
34312 + }
34313 + for(i = 0; i < ehdr.e_phnum; i++) {
34314 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
34315 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
34316 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
34317 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
34318 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
34319 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
34320 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
34321 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
34322 + }
34323 +
34324 +}
34325 +
34326 static void read_shdrs(FILE *fp)
34327 {
34328 - int i;
34329 + unsigned int i;
34330 Elf_Shdr shdr;
34331
34332 secs = calloc(ehdr.e_shnum, sizeof(struct section));
34333 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
34334
34335 static void read_strtabs(FILE *fp)
34336 {
34337 - int i;
34338 + unsigned int i;
34339 for (i = 0; i < ehdr.e_shnum; i++) {
34340 struct section *sec = &secs[i];
34341 if (sec->shdr.sh_type != SHT_STRTAB) {
34342 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
34343
34344 static void read_symtabs(FILE *fp)
34345 {
34346 - int i,j;
34347 + unsigned int i,j;
34348 for (i = 0; i < ehdr.e_shnum; i++) {
34349 struct section *sec = &secs[i];
34350 if (sec->shdr.sh_type != SHT_SYMTAB) {
34351 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
34352 }
34353
34354
34355 -static void read_relocs(FILE *fp)
34356 +static void read_relocs(FILE *fp, int use_real_mode)
34357 {
34358 - int i,j;
34359 + unsigned int i,j;
34360 + uint32_t base;
34361 +
34362 for (i = 0; i < ehdr.e_shnum; i++) {
34363 struct section *sec = &secs[i];
34364 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34365 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
34366 die("Cannot read symbol table: %s\n",
34367 strerror(errno));
34368 }
34369 + base = 0;
34370 +
34371 +#ifdef CONFIG_X86_32
34372 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
34373 + if (phdr[j].p_type != PT_LOAD )
34374 + continue;
34375 + 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)
34376 + continue;
34377 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
34378 + break;
34379 + }
34380 +#endif
34381 +
34382 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
34383 Elf_Rel *rel = &sec->reltab[j];
34384 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
34385 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
34386 rel->r_info = elf_xword_to_cpu(rel->r_info);
34387 #if (SHT_REL_TYPE == SHT_RELA)
34388 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
34389 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
34390
34391 static void print_absolute_symbols(void)
34392 {
34393 - int i;
34394 + unsigned int i;
34395 const char *format;
34396
34397 if (ELF_BITS == 64)
34398 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
34399 for (i = 0; i < ehdr.e_shnum; i++) {
34400 struct section *sec = &secs[i];
34401 char *sym_strtab;
34402 - int j;
34403 + unsigned int j;
34404
34405 if (sec->shdr.sh_type != SHT_SYMTAB) {
34406 continue;
34407 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
34408
34409 static void print_absolute_relocs(void)
34410 {
34411 - int i, printed = 0;
34412 + unsigned int i, printed = 0;
34413 const char *format;
34414
34415 if (ELF_BITS == 64)
34416 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
34417 struct section *sec_applies, *sec_symtab;
34418 char *sym_strtab;
34419 Elf_Sym *sh_symtab;
34420 - int j;
34421 + unsigned int j;
34422 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34423 continue;
34424 }
34425 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
34426 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
34427 Elf_Sym *sym, const char *symname))
34428 {
34429 - int i;
34430 + unsigned int i;
34431 /* Walk through the relocations */
34432 for (i = 0; i < ehdr.e_shnum; i++) {
34433 char *sym_strtab;
34434 Elf_Sym *sh_symtab;
34435 struct section *sec_applies, *sec_symtab;
34436 - int j;
34437 + unsigned int j;
34438 struct section *sec = &secs[i];
34439
34440 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34441 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34442 {
34443 unsigned r_type = ELF32_R_TYPE(rel->r_info);
34444 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
34445 + char *sym_strtab = sec->link->link->strtab;
34446 +
34447 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
34448 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
34449 + return 0;
34450 +
34451 +#ifdef CONFIG_PAX_KERNEXEC
34452 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
34453 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
34454 + return 0;
34455 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
34456 + return 0;
34457 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
34458 + return 0;
34459 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
34460 + return 0;
34461 +#endif
34462
34463 switch (r_type) {
34464 case R_386_NONE:
34465 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
34466
34467 static void emit_relocs(int as_text, int use_real_mode)
34468 {
34469 - int i;
34470 + unsigned int i;
34471 int (*write_reloc)(uint32_t, FILE *) = write32;
34472 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34473 const char *symname);
34474 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
34475 {
34476 regex_init(use_real_mode);
34477 read_ehdr(fp);
34478 + read_phdrs(fp);
34479 read_shdrs(fp);
34480 read_strtabs(fp);
34481 read_symtabs(fp);
34482 - read_relocs(fp);
34483 + read_relocs(fp, use_real_mode);
34484 if (ELF_BITS == 64)
34485 percpu_init();
34486 if (show_absolute_syms) {
34487 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
34488 index 80ffa5b..a33bd15 100644
34489 --- a/arch/x86/um/tls_32.c
34490 +++ b/arch/x86/um/tls_32.c
34491 @@ -260,7 +260,7 @@ out:
34492 if (unlikely(task == current &&
34493 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
34494 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
34495 - "without flushed TLS.", current->pid);
34496 + "without flushed TLS.", task_pid_nr(current));
34497 }
34498
34499 return 0;
34500 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
34501 index fd14be1..e3c79c0 100644
34502 --- a/arch/x86/vdso/Makefile
34503 +++ b/arch/x86/vdso/Makefile
34504 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
34505 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
34506 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
34507
34508 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34509 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34510 GCOV_PROFILE := n
34511
34512 #
34513 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
34514 index d6bfb87..876ee18 100644
34515 --- a/arch/x86/vdso/vdso32-setup.c
34516 +++ b/arch/x86/vdso/vdso32-setup.c
34517 @@ -25,6 +25,7 @@
34518 #include <asm/tlbflush.h>
34519 #include <asm/vdso.h>
34520 #include <asm/proto.h>
34521 +#include <asm/mman.h>
34522
34523 enum {
34524 VDSO_DISABLED = 0,
34525 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
34526 void enable_sep_cpu(void)
34527 {
34528 int cpu = get_cpu();
34529 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
34530 + struct tss_struct *tss = init_tss + cpu;
34531
34532 if (!boot_cpu_has(X86_FEATURE_SEP)) {
34533 put_cpu();
34534 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
34535 gate_vma.vm_start = FIXADDR_USER_START;
34536 gate_vma.vm_end = FIXADDR_USER_END;
34537 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
34538 - gate_vma.vm_page_prot = __P101;
34539 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
34540
34541 return 0;
34542 }
34543 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34544 if (compat)
34545 addr = VDSO_HIGH_BASE;
34546 else {
34547 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
34548 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
34549 if (IS_ERR_VALUE(addr)) {
34550 ret = addr;
34551 goto up_fail;
34552 }
34553 }
34554
34555 - current->mm->context.vdso = (void *)addr;
34556 + current->mm->context.vdso = addr;
34557
34558 if (compat_uses_vma || !compat) {
34559 /*
34560 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34561 }
34562
34563 current_thread_info()->sysenter_return =
34564 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34565 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34566
34567 up_fail:
34568 if (ret)
34569 - current->mm->context.vdso = NULL;
34570 + current->mm->context.vdso = 0;
34571
34572 up_write(&mm->mmap_sem);
34573
34574 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
34575
34576 const char *arch_vma_name(struct vm_area_struct *vma)
34577 {
34578 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
34579 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
34580 return "[vdso]";
34581 +
34582 +#ifdef CONFIG_PAX_SEGMEXEC
34583 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
34584 + return "[vdso]";
34585 +#endif
34586 +
34587 return NULL;
34588 }
34589
34590 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
34591 * Check to see if the corresponding task was created in compat vdso
34592 * mode.
34593 */
34594 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
34595 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
34596 return &gate_vma;
34597 return NULL;
34598 }
34599 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
34600 index 431e875..cbb23f3 100644
34601 --- a/arch/x86/vdso/vma.c
34602 +++ b/arch/x86/vdso/vma.c
34603 @@ -16,8 +16,6 @@
34604 #include <asm/vdso.h>
34605 #include <asm/page.h>
34606
34607 -unsigned int __read_mostly vdso_enabled = 1;
34608 -
34609 extern char vdso_start[], vdso_end[];
34610 extern unsigned short vdso_sync_cpuid;
34611
34612 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
34613 * unaligned here as a result of stack start randomization.
34614 */
34615 addr = PAGE_ALIGN(addr);
34616 - addr = align_vdso_addr(addr);
34617
34618 return addr;
34619 }
34620 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
34621 unsigned size)
34622 {
34623 struct mm_struct *mm = current->mm;
34624 - unsigned long addr;
34625 + unsigned long addr = 0;
34626 int ret;
34627
34628 - if (!vdso_enabled)
34629 - return 0;
34630 -
34631 down_write(&mm->mmap_sem);
34632 +
34633 +#ifdef CONFIG_PAX_RANDMMAP
34634 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34635 +#endif
34636 +
34637 addr = vdso_addr(mm->start_stack, size);
34638 + addr = align_vdso_addr(addr);
34639 addr = get_unmapped_area(NULL, addr, size, 0, 0);
34640 if (IS_ERR_VALUE(addr)) {
34641 ret = addr;
34642 goto up_fail;
34643 }
34644
34645 - current->mm->context.vdso = (void *)addr;
34646 + mm->context.vdso = addr;
34647
34648 ret = install_special_mapping(mm, addr, size,
34649 VM_READ|VM_EXEC|
34650 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
34651 pages);
34652 - if (ret) {
34653 - current->mm->context.vdso = NULL;
34654 - goto up_fail;
34655 - }
34656 + if (ret)
34657 + mm->context.vdso = 0;
34658
34659 up_fail:
34660 up_write(&mm->mmap_sem);
34661 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34662 vdsox32_size);
34663 }
34664 #endif
34665 -
34666 -static __init int vdso_setup(char *s)
34667 -{
34668 - vdso_enabled = simple_strtoul(s, NULL, 0);
34669 - return 0;
34670 -}
34671 -__setup("vdso=", vdso_setup);
34672 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34673 index fa6ade7..73da73a5 100644
34674 --- a/arch/x86/xen/enlighten.c
34675 +++ b/arch/x86/xen/enlighten.c
34676 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34677
34678 struct shared_info xen_dummy_shared_info;
34679
34680 -void *xen_initial_gdt;
34681 -
34682 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34683 __read_mostly int xen_have_vector_callback;
34684 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34685 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34686 {
34687 unsigned long va = dtr->address;
34688 unsigned int size = dtr->size + 1;
34689 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34690 - unsigned long frames[pages];
34691 + unsigned long frames[65536 / PAGE_SIZE];
34692 int f;
34693
34694 /*
34695 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34696 {
34697 unsigned long va = dtr->address;
34698 unsigned int size = dtr->size + 1;
34699 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34700 - unsigned long frames[pages];
34701 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34702 int f;
34703
34704 /*
34705 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34706 * 8-byte entries, or 16 4k pages..
34707 */
34708
34709 - BUG_ON(size > 65536);
34710 + BUG_ON(size > GDT_SIZE);
34711 BUG_ON(va & ~PAGE_MASK);
34712
34713 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34714 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34715 return 0;
34716 }
34717
34718 -static void set_xen_basic_apic_ops(void)
34719 +static void __init set_xen_basic_apic_ops(void)
34720 {
34721 apic->read = xen_apic_read;
34722 apic->write = xen_apic_write;
34723 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34724 #endif
34725 };
34726
34727 -static void xen_reboot(int reason)
34728 +static __noreturn void xen_reboot(int reason)
34729 {
34730 struct sched_shutdown r = { .reason = reason };
34731
34732 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34733 - BUG();
34734 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34735 + BUG();
34736 }
34737
34738 -static void xen_restart(char *msg)
34739 +static __noreturn void xen_restart(char *msg)
34740 {
34741 xen_reboot(SHUTDOWN_reboot);
34742 }
34743
34744 -static void xen_emergency_restart(void)
34745 +static __noreturn void xen_emergency_restart(void)
34746 {
34747 xen_reboot(SHUTDOWN_reboot);
34748 }
34749
34750 -static void xen_machine_halt(void)
34751 +static __noreturn void xen_machine_halt(void)
34752 {
34753 xen_reboot(SHUTDOWN_poweroff);
34754 }
34755
34756 -static void xen_machine_power_off(void)
34757 +static __noreturn void xen_machine_power_off(void)
34758 {
34759 if (pm_power_off)
34760 pm_power_off();
34761 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34762 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34763
34764 /* Work out if we support NX */
34765 - x86_configure_nx();
34766 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34767 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34768 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34769 + unsigned l, h;
34770 +
34771 + __supported_pte_mask |= _PAGE_NX;
34772 + rdmsr(MSR_EFER, l, h);
34773 + l |= EFER_NX;
34774 + wrmsr(MSR_EFER, l, h);
34775 + }
34776 +#endif
34777
34778 xen_setup_features();
34779
34780 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34781
34782 machine_ops = xen_machine_ops;
34783
34784 - /*
34785 - * The only reliable way to retain the initial address of the
34786 - * percpu gdt_page is to remember it here, so we can go and
34787 - * mark it RW later, when the initial percpu area is freed.
34788 - */
34789 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34790 -
34791 xen_smp_init();
34792
34793 #ifdef CONFIG_ACPI_NUMA
34794 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34795 index fdc3ba2..23cae00 100644
34796 --- a/arch/x86/xen/mmu.c
34797 +++ b/arch/x86/xen/mmu.c
34798 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34799 return val;
34800 }
34801
34802 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34803 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34804 {
34805 if (val & _PAGE_PRESENT) {
34806 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34807 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34808 /* L3_k[510] -> level2_kernel_pgt
34809 * L3_i[511] -> level2_fixmap_pgt */
34810 convert_pfn_mfn(level3_kernel_pgt);
34811 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34812 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34813 + convert_pfn_mfn(level3_vmemmap_pgt);
34814
34815 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34816 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34817 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34818 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34819 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34820 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34821 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34822 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34823 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34824 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34825 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34826 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34827 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34828 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34829
34830 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34831 pv_mmu_ops.set_pud = xen_set_pud;
34832 #if PAGETABLE_LEVELS == 4
34833 pv_mmu_ops.set_pgd = xen_set_pgd;
34834 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34835 #endif
34836
34837 /* This will work as long as patching hasn't happened yet
34838 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34839 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34840 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34841 .set_pgd = xen_set_pgd_hyper,
34842 + .set_pgd_batched = xen_set_pgd_hyper,
34843
34844 .alloc_pud = xen_alloc_pmd_init,
34845 .release_pud = xen_release_pmd_init,
34846 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34847 index 31d0475..51af671 100644
34848 --- a/arch/x86/xen/smp.c
34849 +++ b/arch/x86/xen/smp.c
34850 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34851 native_smp_prepare_boot_cpu();
34852
34853 if (xen_pv_domain()) {
34854 - /* We've switched to the "real" per-cpu gdt, so make sure the
34855 - old memory can be recycled */
34856 - make_lowmem_page_readwrite(xen_initial_gdt);
34857 -
34858 #ifdef CONFIG_X86_32
34859 /*
34860 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34861 * expects __USER_DS
34862 */
34863 - loadsegment(ds, __USER_DS);
34864 - loadsegment(es, __USER_DS);
34865 + loadsegment(ds, __KERNEL_DS);
34866 + loadsegment(es, __KERNEL_DS);
34867 #endif
34868
34869 xen_filter_cpu_maps();
34870 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34871 ctxt->user_regs.ss = __KERNEL_DS;
34872 #ifdef CONFIG_X86_32
34873 ctxt->user_regs.fs = __KERNEL_PERCPU;
34874 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34875 + savesegment(gs, ctxt->user_regs.gs);
34876 #else
34877 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34878 #endif
34879 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34880
34881 {
34882 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34883 - ctxt->user_regs.ds = __USER_DS;
34884 - ctxt->user_regs.es = __USER_DS;
34885 + ctxt->user_regs.ds = __KERNEL_DS;
34886 + ctxt->user_regs.es = __KERNEL_DS;
34887
34888 xen_copy_trap_info(ctxt->trap_ctxt);
34889
34890 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34891 int rc;
34892
34893 per_cpu(current_task, cpu) = idle;
34894 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34895 #ifdef CONFIG_X86_32
34896 irq_ctx_init(cpu);
34897 #else
34898 clear_tsk_thread_flag(idle, TIF_FORK);
34899 - per_cpu(kernel_stack, cpu) =
34900 - (unsigned long)task_stack_page(idle) -
34901 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34902 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34903 #endif
34904 xen_setup_runstate_info(cpu);
34905 xen_setup_timer(cpu);
34906 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34907
34908 void __init xen_smp_init(void)
34909 {
34910 - smp_ops = xen_smp_ops;
34911 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34912 xen_fill_possible_map();
34913 }
34914
34915 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34916 index 33ca6e4..0ded929 100644
34917 --- a/arch/x86/xen/xen-asm_32.S
34918 +++ b/arch/x86/xen/xen-asm_32.S
34919 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34920 ESP_OFFSET=4 # bytes pushed onto stack
34921
34922 /*
34923 - * Store vcpu_info pointer for easy access. Do it this way to
34924 - * avoid having to reload %fs
34925 + * Store vcpu_info pointer for easy access.
34926 */
34927 #ifdef CONFIG_SMP
34928 - GET_THREAD_INFO(%eax)
34929 - movl %ss:TI_cpu(%eax), %eax
34930 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34931 - mov %ss:xen_vcpu(%eax), %eax
34932 + push %fs
34933 + mov $(__KERNEL_PERCPU), %eax
34934 + mov %eax, %fs
34935 + mov PER_CPU_VAR(xen_vcpu), %eax
34936 + pop %fs
34937 #else
34938 movl %ss:xen_vcpu, %eax
34939 #endif
34940 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34941 index 7faed58..ba4427c 100644
34942 --- a/arch/x86/xen/xen-head.S
34943 +++ b/arch/x86/xen/xen-head.S
34944 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34945 #ifdef CONFIG_X86_32
34946 mov %esi,xen_start_info
34947 mov $init_thread_union+THREAD_SIZE,%esp
34948 +#ifdef CONFIG_SMP
34949 + movl $cpu_gdt_table,%edi
34950 + movl $__per_cpu_load,%eax
34951 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34952 + rorl $16,%eax
34953 + movb %al,__KERNEL_PERCPU + 4(%edi)
34954 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34955 + movl $__per_cpu_end - 1,%eax
34956 + subl $__per_cpu_start,%eax
34957 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34958 +#endif
34959 #else
34960 mov %rsi,xen_start_info
34961 mov $init_thread_union+THREAD_SIZE,%rsp
34962 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34963 index 95f8c61..611d6e8 100644
34964 --- a/arch/x86/xen/xen-ops.h
34965 +++ b/arch/x86/xen/xen-ops.h
34966 @@ -10,8 +10,6 @@
34967 extern const char xen_hypervisor_callback[];
34968 extern const char xen_failsafe_callback[];
34969
34970 -extern void *xen_initial_gdt;
34971 -
34972 struct trap_info;
34973 void xen_copy_trap_info(struct trap_info *traps);
34974
34975 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34976 index 525bd3d..ef888b1 100644
34977 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34978 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34979 @@ -119,9 +119,9 @@
34980 ----------------------------------------------------------------------*/
34981
34982 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34983 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34984 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34985 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34986 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34987
34988 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34989 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34990 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34991 index 2f33760..835e50a 100644
34992 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34993 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34994 @@ -11,6 +11,7 @@
34995 #ifndef _XTENSA_CORE_H
34996 #define _XTENSA_CORE_H
34997
34998 +#include <linux/const.h>
34999
35000 /****************************************************************************
35001 Parameters Useful for Any Code, USER or PRIVILEGED
35002 @@ -112,9 +113,9 @@
35003 ----------------------------------------------------------------------*/
35004
35005 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
35006 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
35007 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
35008 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
35009 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
35010
35011 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
35012 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
35013 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
35014 index af00795..2bb8105 100644
35015 --- a/arch/xtensa/variants/s6000/include/variant/core.h
35016 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
35017 @@ -11,6 +11,7 @@
35018 #ifndef _XTENSA_CORE_CONFIGURATION_H
35019 #define _XTENSA_CORE_CONFIGURATION_H
35020
35021 +#include <linux/const.h>
35022
35023 /****************************************************************************
35024 Parameters Useful for Any Code, USER or PRIVILEGED
35025 @@ -118,9 +119,9 @@
35026 ----------------------------------------------------------------------*/
35027
35028 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
35029 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
35030 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
35031 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
35032 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
35033
35034 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
35035 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
35036 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
35037 index 4e491d9..c8e18e4 100644
35038 --- a/block/blk-cgroup.c
35039 +++ b/block/blk-cgroup.c
35040 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
35041 static struct cgroup_subsys_state *
35042 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
35043 {
35044 - static atomic64_t id_seq = ATOMIC64_INIT(0);
35045 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
35046 struct blkcg *blkcg;
35047
35048 if (!parent_css) {
35049 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
35050
35051 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
35052 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
35053 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
35054 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
35055 done:
35056 spin_lock_init(&blkcg->lock);
35057 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
35058 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
35059 index 4b8d9b54..a7178c0 100644
35060 --- a/block/blk-iopoll.c
35061 +++ b/block/blk-iopoll.c
35062 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
35063 }
35064 EXPORT_SYMBOL(blk_iopoll_complete);
35065
35066 -static void blk_iopoll_softirq(struct softirq_action *h)
35067 +static __latent_entropy void blk_iopoll_softirq(void)
35068 {
35069 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
35070 int rearm = 0, budget = blk_iopoll_budget;
35071 diff --git a/block/blk-map.c b/block/blk-map.c
35072 index 623e1cd..ca1e109 100644
35073 --- a/block/blk-map.c
35074 +++ b/block/blk-map.c
35075 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
35076 if (!len || !kbuf)
35077 return -EINVAL;
35078
35079 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
35080 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
35081 if (do_copy)
35082 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
35083 else
35084 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
35085 index ec9e606..3f38839 100644
35086 --- a/block/blk-softirq.c
35087 +++ b/block/blk-softirq.c
35088 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
35089 * Softirq action handler - move entries to local list and loop over them
35090 * while passing them to the queue registered handler.
35091 */
35092 -static void blk_done_softirq(struct softirq_action *h)
35093 +static __latent_entropy void blk_done_softirq(void)
35094 {
35095 struct list_head *cpu_list, local_list;
35096
35097 diff --git a/block/bsg.c b/block/bsg.c
35098 index 420a5a9..23834aa 100644
35099 --- a/block/bsg.c
35100 +++ b/block/bsg.c
35101 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
35102 struct sg_io_v4 *hdr, struct bsg_device *bd,
35103 fmode_t has_write_perm)
35104 {
35105 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35106 + unsigned char *cmdptr;
35107 +
35108 if (hdr->request_len > BLK_MAX_CDB) {
35109 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
35110 if (!rq->cmd)
35111 return -ENOMEM;
35112 - }
35113 + cmdptr = rq->cmd;
35114 + } else
35115 + cmdptr = tmpcmd;
35116
35117 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
35118 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
35119 hdr->request_len))
35120 return -EFAULT;
35121
35122 + if (cmdptr != rq->cmd)
35123 + memcpy(rq->cmd, cmdptr, hdr->request_len);
35124 +
35125 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
35126 if (blk_verify_command(rq->cmd, has_write_perm))
35127 return -EPERM;
35128 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
35129 index fbd5a67..5d631b5 100644
35130 --- a/block/compat_ioctl.c
35131 +++ b/block/compat_ioctl.c
35132 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
35133 err |= __get_user(f->spec1, &uf->spec1);
35134 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
35135 err |= __get_user(name, &uf->name);
35136 - f->name = compat_ptr(name);
35137 + f->name = (void __force_kernel *)compat_ptr(name);
35138 if (err) {
35139 err = -EFAULT;
35140 goto out;
35141 diff --git a/block/genhd.c b/block/genhd.c
35142 index 791f419..89f21c4 100644
35143 --- a/block/genhd.c
35144 +++ b/block/genhd.c
35145 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
35146
35147 /*
35148 * Register device numbers dev..(dev+range-1)
35149 - * range must be nonzero
35150 + * Noop if @range is zero.
35151 * The hash chain is sorted on range, so that subranges can override.
35152 */
35153 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
35154 struct kobject *(*probe)(dev_t, int *, void *),
35155 int (*lock)(dev_t, void *), void *data)
35156 {
35157 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
35158 + if (range)
35159 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
35160 }
35161
35162 EXPORT_SYMBOL(blk_register_region);
35163
35164 +/* undo blk_register_region(), noop if @range is zero */
35165 void blk_unregister_region(dev_t devt, unsigned long range)
35166 {
35167 - kobj_unmap(bdev_map, devt, range);
35168 + if (range)
35169 + kobj_unmap(bdev_map, devt, range);
35170 }
35171
35172 EXPORT_SYMBOL(blk_unregister_region);
35173 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
35174 index a8287b4..241a48e 100644
35175 --- a/block/partitions/efi.c
35176 +++ b/block/partitions/efi.c
35177 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
35178 if (!gpt)
35179 return NULL;
35180
35181 + if (!le32_to_cpu(gpt->num_partition_entries))
35182 + return NULL;
35183 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
35184 + if (!pte)
35185 + return NULL;
35186 +
35187 count = le32_to_cpu(gpt->num_partition_entries) *
35188 le32_to_cpu(gpt->sizeof_partition_entry);
35189 - if (!count)
35190 - return NULL;
35191 - pte = kmalloc(count, GFP_KERNEL);
35192 - if (!pte)
35193 - return NULL;
35194 -
35195 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
35196 (u8 *) pte, count) < count) {
35197 kfree(pte);
35198 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
35199 index a5ffcc9..e057498 100644
35200 --- a/block/scsi_ioctl.c
35201 +++ b/block/scsi_ioctl.c
35202 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
35203 return put_user(0, p);
35204 }
35205
35206 -static int sg_get_timeout(struct request_queue *q)
35207 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
35208 {
35209 return jiffies_to_clock_t(q->sg_timeout);
35210 }
35211 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
35212 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
35213 struct sg_io_hdr *hdr, fmode_t mode)
35214 {
35215 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
35216 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35217 + unsigned char *cmdptr;
35218 +
35219 + if (rq->cmd != rq->__cmd)
35220 + cmdptr = rq->cmd;
35221 + else
35222 + cmdptr = tmpcmd;
35223 +
35224 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
35225 return -EFAULT;
35226 +
35227 + if (cmdptr != rq->cmd)
35228 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
35229 +
35230 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
35231 return -EPERM;
35232
35233 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35234 int err;
35235 unsigned int in_len, out_len, bytes, opcode, cmdlen;
35236 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
35237 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35238 + unsigned char *cmdptr;
35239
35240 if (!sic)
35241 return -EINVAL;
35242 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35243 */
35244 err = -EFAULT;
35245 rq->cmd_len = cmdlen;
35246 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
35247 +
35248 + if (rq->cmd != rq->__cmd)
35249 + cmdptr = rq->cmd;
35250 + else
35251 + cmdptr = tmpcmd;
35252 +
35253 + if (copy_from_user(cmdptr, sic->data, cmdlen))
35254 goto error;
35255
35256 + if (rq->cmd != cmdptr)
35257 + memcpy(rq->cmd, cmdptr, cmdlen);
35258 +
35259 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
35260 goto error;
35261
35262 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
35263 index 7bdd61b..afec999 100644
35264 --- a/crypto/cryptd.c
35265 +++ b/crypto/cryptd.c
35266 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
35267
35268 struct cryptd_blkcipher_request_ctx {
35269 crypto_completion_t complete;
35270 -};
35271 +} __no_const;
35272
35273 struct cryptd_hash_ctx {
35274 struct crypto_shash *child;
35275 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
35276
35277 struct cryptd_aead_request_ctx {
35278 crypto_completion_t complete;
35279 -};
35280 +} __no_const;
35281
35282 static void cryptd_queue_worker(struct work_struct *work);
35283
35284 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
35285 index f8c920c..ab2cb5a 100644
35286 --- a/crypto/pcrypt.c
35287 +++ b/crypto/pcrypt.c
35288 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
35289 int ret;
35290
35291 pinst->kobj.kset = pcrypt_kset;
35292 - ret = kobject_add(&pinst->kobj, NULL, name);
35293 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
35294 if (!ret)
35295 kobject_uevent(&pinst->kobj, KOBJ_ADD);
35296
35297 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
35298 index f220d64..d359ad6 100644
35299 --- a/drivers/acpi/apei/apei-internal.h
35300 +++ b/drivers/acpi/apei/apei-internal.h
35301 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
35302 struct apei_exec_ins_type {
35303 u32 flags;
35304 apei_exec_ins_func_t run;
35305 -};
35306 +} __do_const;
35307
35308 struct apei_exec_context {
35309 u32 ip;
35310 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
35311 index 33dc6a0..4b24b47 100644
35312 --- a/drivers/acpi/apei/cper.c
35313 +++ b/drivers/acpi/apei/cper.c
35314 @@ -39,12 +39,12 @@
35315 */
35316 u64 cper_next_record_id(void)
35317 {
35318 - static atomic64_t seq;
35319 + static atomic64_unchecked_t seq;
35320
35321 - if (!atomic64_read(&seq))
35322 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
35323 + if (!atomic64_read_unchecked(&seq))
35324 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
35325
35326 - return atomic64_inc_return(&seq);
35327 + return atomic64_inc_return_unchecked(&seq);
35328 }
35329 EXPORT_SYMBOL_GPL(cper_next_record_id);
35330
35331 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
35332 index 8ec37bb..b0716e5 100644
35333 --- a/drivers/acpi/apei/ghes.c
35334 +++ b/drivers/acpi/apei/ghes.c
35335 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
35336 const struct acpi_hest_generic *generic,
35337 const struct acpi_hest_generic_status *estatus)
35338 {
35339 - static atomic_t seqno;
35340 + static atomic_unchecked_t seqno;
35341 unsigned int curr_seqno;
35342 char pfx_seq[64];
35343
35344 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
35345 else
35346 pfx = KERN_ERR;
35347 }
35348 - curr_seqno = atomic_inc_return(&seqno);
35349 + curr_seqno = atomic_inc_return_unchecked(&seqno);
35350 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
35351 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
35352 pfx_seq, generic->header.source_id);
35353 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
35354 index a83e3c6..c3d617f 100644
35355 --- a/drivers/acpi/bgrt.c
35356 +++ b/drivers/acpi/bgrt.c
35357 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
35358 if (!bgrt_image)
35359 return -ENODEV;
35360
35361 - bin_attr_image.private = bgrt_image;
35362 - bin_attr_image.size = bgrt_image_size;
35363 + pax_open_kernel();
35364 + *(void **)&bin_attr_image.private = bgrt_image;
35365 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
35366 + pax_close_kernel();
35367
35368 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
35369 if (!bgrt_kobj)
35370 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
35371 index 9515f18..4b149c9 100644
35372 --- a/drivers/acpi/blacklist.c
35373 +++ b/drivers/acpi/blacklist.c
35374 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
35375 u32 is_critical_error;
35376 };
35377
35378 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
35379 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
35380
35381 /*
35382 * POLICY: If *anything* doesn't work, put it on the blacklist.
35383 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
35384 return 0;
35385 }
35386
35387 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
35388 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
35389 {
35390 .callback = dmi_disable_osi_vista,
35391 .ident = "Fujitsu Siemens",
35392 diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
35393 index 12b62f2..dc2aac8 100644
35394 --- a/drivers/acpi/custom_method.c
35395 +++ b/drivers/acpi/custom_method.c
35396 @@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
35397 struct acpi_table_header table;
35398 acpi_status status;
35399
35400 +#ifdef CONFIG_GRKERNSEC_KMEM
35401 + return -EPERM;
35402 +#endif
35403 +
35404 if (!(*ppos)) {
35405 /* parse the table header to get the table length */
35406 if (count <= sizeof(struct acpi_table_header))
35407 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
35408 index c7414a5..d5afd71 100644
35409 --- a/drivers/acpi/processor_idle.c
35410 +++ b/drivers/acpi/processor_idle.c
35411 @@ -966,7 +966,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
35412 {
35413 int i, count = CPUIDLE_DRIVER_STATE_START;
35414 struct acpi_processor_cx *cx;
35415 - struct cpuidle_state *state;
35416 + cpuidle_state_no_const *state;
35417 struct cpuidle_driver *drv = &acpi_idle_driver;
35418
35419 if (!pr->flags.power_setup_done)
35420 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
35421 index 05306a5..733d1f0 100644
35422 --- a/drivers/acpi/sysfs.c
35423 +++ b/drivers/acpi/sysfs.c
35424 @@ -423,11 +423,11 @@ static u32 num_counters;
35425 static struct attribute **all_attrs;
35426 static u32 acpi_gpe_count;
35427
35428 -static struct attribute_group interrupt_stats_attr_group = {
35429 +static attribute_group_no_const interrupt_stats_attr_group = {
35430 .name = "interrupts",
35431 };
35432
35433 -static struct kobj_attribute *counter_attrs;
35434 +static kobj_attribute_no_const *counter_attrs;
35435
35436 static void delete_gpe_attr_array(void)
35437 {
35438 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
35439 index cfb7447..98f2149 100644
35440 --- a/drivers/ata/libahci.c
35441 +++ b/drivers/ata/libahci.c
35442 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
35443 }
35444 EXPORT_SYMBOL_GPL(ahci_kick_engine);
35445
35446 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35447 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35448 struct ata_taskfile *tf, int is_cmd, u16 flags,
35449 unsigned long timeout_msec)
35450 {
35451 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
35452 index 2c2780a..5ebc310 100644
35453 --- a/drivers/ata/libata-core.c
35454 +++ b/drivers/ata/libata-core.c
35455 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
35456 static void ata_dev_xfermask(struct ata_device *dev);
35457 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
35458
35459 -atomic_t ata_print_id = ATOMIC_INIT(0);
35460 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
35461
35462 struct ata_force_param {
35463 const char *name;
35464 @@ -4823,7 +4823,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
35465 struct ata_port *ap;
35466 unsigned int tag;
35467
35468 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35469 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35470 ap = qc->ap;
35471
35472 qc->flags = 0;
35473 @@ -4839,7 +4839,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
35474 struct ata_port *ap;
35475 struct ata_link *link;
35476
35477 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35478 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35479 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
35480 ap = qc->ap;
35481 link = qc->dev->link;
35482 @@ -5958,6 +5958,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35483 return;
35484
35485 spin_lock(&lock);
35486 + pax_open_kernel();
35487
35488 for (cur = ops->inherits; cur; cur = cur->inherits) {
35489 void **inherit = (void **)cur;
35490 @@ -5971,8 +5972,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35491 if (IS_ERR(*pp))
35492 *pp = NULL;
35493
35494 - ops->inherits = NULL;
35495 + *(struct ata_port_operations **)&ops->inherits = NULL;
35496
35497 + pax_close_kernel();
35498 spin_unlock(&lock);
35499 }
35500
35501 @@ -6165,7 +6167,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
35502
35503 /* give ports names and add SCSI hosts */
35504 for (i = 0; i < host->n_ports; i++) {
35505 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
35506 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
35507 host->ports[i]->local_port_no = i + 1;
35508 }
35509
35510 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
35511 index 377eb88..8591b44 100644
35512 --- a/drivers/ata/libata-scsi.c
35513 +++ b/drivers/ata/libata-scsi.c
35514 @@ -4135,7 +4135,7 @@ int ata_sas_port_init(struct ata_port *ap)
35515
35516 if (rc)
35517 return rc;
35518 - ap->print_id = atomic_inc_return(&ata_print_id);
35519 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
35520 return 0;
35521 }
35522 EXPORT_SYMBOL_GPL(ata_sas_port_init);
35523 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
35524 index 45b5ab3..98446b8 100644
35525 --- a/drivers/ata/libata.h
35526 +++ b/drivers/ata/libata.h
35527 @@ -53,7 +53,7 @@ enum {
35528 ATA_DNXFER_QUIET = (1 << 31),
35529 };
35530
35531 -extern atomic_t ata_print_id;
35532 +extern atomic_unchecked_t ata_print_id;
35533 extern int atapi_passthru16;
35534 extern int libata_fua;
35535 extern int libata_noacpi;
35536 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
35537 index 853f610..97d24da 100644
35538 --- a/drivers/ata/pata_arasan_cf.c
35539 +++ b/drivers/ata/pata_arasan_cf.c
35540 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
35541 /* Handle platform specific quirks */
35542 if (quirk) {
35543 if (quirk & CF_BROKEN_PIO) {
35544 - ap->ops->set_piomode = NULL;
35545 + pax_open_kernel();
35546 + *(void **)&ap->ops->set_piomode = NULL;
35547 + pax_close_kernel();
35548 ap->pio_mask = 0;
35549 }
35550 if (quirk & CF_BROKEN_MWDMA)
35551 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
35552 index f9b983a..887b9d8 100644
35553 --- a/drivers/atm/adummy.c
35554 +++ b/drivers/atm/adummy.c
35555 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
35556 vcc->pop(vcc, skb);
35557 else
35558 dev_kfree_skb_any(skb);
35559 - atomic_inc(&vcc->stats->tx);
35560 + atomic_inc_unchecked(&vcc->stats->tx);
35561
35562 return 0;
35563 }
35564 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
35565 index 62a7607..cc4be104 100644
35566 --- a/drivers/atm/ambassador.c
35567 +++ b/drivers/atm/ambassador.c
35568 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
35569 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
35570
35571 // VC layer stats
35572 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35573 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35574
35575 // free the descriptor
35576 kfree (tx_descr);
35577 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35578 dump_skb ("<<<", vc, skb);
35579
35580 // VC layer stats
35581 - atomic_inc(&atm_vcc->stats->rx);
35582 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35583 __net_timestamp(skb);
35584 // end of our responsibility
35585 atm_vcc->push (atm_vcc, skb);
35586 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35587 } else {
35588 PRINTK (KERN_INFO, "dropped over-size frame");
35589 // should we count this?
35590 - atomic_inc(&atm_vcc->stats->rx_drop);
35591 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35592 }
35593
35594 } else {
35595 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
35596 }
35597
35598 if (check_area (skb->data, skb->len)) {
35599 - atomic_inc(&atm_vcc->stats->tx_err);
35600 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
35601 return -ENOMEM; // ?
35602 }
35603
35604 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
35605 index 0e3f8f9..765a7a5 100644
35606 --- a/drivers/atm/atmtcp.c
35607 +++ b/drivers/atm/atmtcp.c
35608 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35609 if (vcc->pop) vcc->pop(vcc,skb);
35610 else dev_kfree_skb(skb);
35611 if (dev_data) return 0;
35612 - atomic_inc(&vcc->stats->tx_err);
35613 + atomic_inc_unchecked(&vcc->stats->tx_err);
35614 return -ENOLINK;
35615 }
35616 size = skb->len+sizeof(struct atmtcp_hdr);
35617 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35618 if (!new_skb) {
35619 if (vcc->pop) vcc->pop(vcc,skb);
35620 else dev_kfree_skb(skb);
35621 - atomic_inc(&vcc->stats->tx_err);
35622 + atomic_inc_unchecked(&vcc->stats->tx_err);
35623 return -ENOBUFS;
35624 }
35625 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
35626 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35627 if (vcc->pop) vcc->pop(vcc,skb);
35628 else dev_kfree_skb(skb);
35629 out_vcc->push(out_vcc,new_skb);
35630 - atomic_inc(&vcc->stats->tx);
35631 - atomic_inc(&out_vcc->stats->rx);
35632 + atomic_inc_unchecked(&vcc->stats->tx);
35633 + atomic_inc_unchecked(&out_vcc->stats->rx);
35634 return 0;
35635 }
35636
35637 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35638 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
35639 read_unlock(&vcc_sklist_lock);
35640 if (!out_vcc) {
35641 - atomic_inc(&vcc->stats->tx_err);
35642 + atomic_inc_unchecked(&vcc->stats->tx_err);
35643 goto done;
35644 }
35645 skb_pull(skb,sizeof(struct atmtcp_hdr));
35646 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35647 __net_timestamp(new_skb);
35648 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
35649 out_vcc->push(out_vcc,new_skb);
35650 - atomic_inc(&vcc->stats->tx);
35651 - atomic_inc(&out_vcc->stats->rx);
35652 + atomic_inc_unchecked(&vcc->stats->tx);
35653 + atomic_inc_unchecked(&out_vcc->stats->rx);
35654 done:
35655 if (vcc->pop) vcc->pop(vcc,skb);
35656 else dev_kfree_skb(skb);
35657 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
35658 index b1955ba..b179940 100644
35659 --- a/drivers/atm/eni.c
35660 +++ b/drivers/atm/eni.c
35661 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
35662 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
35663 vcc->dev->number);
35664 length = 0;
35665 - atomic_inc(&vcc->stats->rx_err);
35666 + atomic_inc_unchecked(&vcc->stats->rx_err);
35667 }
35668 else {
35669 length = ATM_CELL_SIZE-1; /* no HEC */
35670 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35671 size);
35672 }
35673 eff = length = 0;
35674 - atomic_inc(&vcc->stats->rx_err);
35675 + atomic_inc_unchecked(&vcc->stats->rx_err);
35676 }
35677 else {
35678 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
35679 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35680 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
35681 vcc->dev->number,vcc->vci,length,size << 2,descr);
35682 length = eff = 0;
35683 - atomic_inc(&vcc->stats->rx_err);
35684 + atomic_inc_unchecked(&vcc->stats->rx_err);
35685 }
35686 }
35687 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
35688 @@ -767,7 +767,7 @@ rx_dequeued++;
35689 vcc->push(vcc,skb);
35690 pushed++;
35691 }
35692 - atomic_inc(&vcc->stats->rx);
35693 + atomic_inc_unchecked(&vcc->stats->rx);
35694 }
35695 wake_up(&eni_dev->rx_wait);
35696 }
35697 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
35698 PCI_DMA_TODEVICE);
35699 if (vcc->pop) vcc->pop(vcc,skb);
35700 else dev_kfree_skb_irq(skb);
35701 - atomic_inc(&vcc->stats->tx);
35702 + atomic_inc_unchecked(&vcc->stats->tx);
35703 wake_up(&eni_dev->tx_wait);
35704 dma_complete++;
35705 }
35706 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35707 index b41c948..a002b17 100644
35708 --- a/drivers/atm/firestream.c
35709 +++ b/drivers/atm/firestream.c
35710 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35711 }
35712 }
35713
35714 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35715 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35716
35717 fs_dprintk (FS_DEBUG_TXMEM, "i");
35718 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35719 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35720 #endif
35721 skb_put (skb, qe->p1 & 0xffff);
35722 ATM_SKB(skb)->vcc = atm_vcc;
35723 - atomic_inc(&atm_vcc->stats->rx);
35724 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35725 __net_timestamp(skb);
35726 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35727 atm_vcc->push (atm_vcc, skb);
35728 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35729 kfree (pe);
35730 }
35731 if (atm_vcc)
35732 - atomic_inc(&atm_vcc->stats->rx_drop);
35733 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35734 break;
35735 case 0x1f: /* Reassembly abort: no buffers. */
35736 /* Silently increment error counter. */
35737 if (atm_vcc)
35738 - atomic_inc(&atm_vcc->stats->rx_drop);
35739 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35740 break;
35741 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35742 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35743 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35744 index 204814e..cede831 100644
35745 --- a/drivers/atm/fore200e.c
35746 +++ b/drivers/atm/fore200e.c
35747 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35748 #endif
35749 /* check error condition */
35750 if (*entry->status & STATUS_ERROR)
35751 - atomic_inc(&vcc->stats->tx_err);
35752 + atomic_inc_unchecked(&vcc->stats->tx_err);
35753 else
35754 - atomic_inc(&vcc->stats->tx);
35755 + atomic_inc_unchecked(&vcc->stats->tx);
35756 }
35757 }
35758
35759 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35760 if (skb == NULL) {
35761 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35762
35763 - atomic_inc(&vcc->stats->rx_drop);
35764 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35765 return -ENOMEM;
35766 }
35767
35768 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35769
35770 dev_kfree_skb_any(skb);
35771
35772 - atomic_inc(&vcc->stats->rx_drop);
35773 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35774 return -ENOMEM;
35775 }
35776
35777 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35778
35779 vcc->push(vcc, skb);
35780 - atomic_inc(&vcc->stats->rx);
35781 + atomic_inc_unchecked(&vcc->stats->rx);
35782
35783 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35784
35785 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35786 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35787 fore200e->atm_dev->number,
35788 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35789 - atomic_inc(&vcc->stats->rx_err);
35790 + atomic_inc_unchecked(&vcc->stats->rx_err);
35791 }
35792 }
35793
35794 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35795 goto retry_here;
35796 }
35797
35798 - atomic_inc(&vcc->stats->tx_err);
35799 + atomic_inc_unchecked(&vcc->stats->tx_err);
35800
35801 fore200e->tx_sat++;
35802 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35803 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35804 index 8557adc..3fb5d55 100644
35805 --- a/drivers/atm/he.c
35806 +++ b/drivers/atm/he.c
35807 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35808
35809 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35810 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35811 - atomic_inc(&vcc->stats->rx_drop);
35812 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35813 goto return_host_buffers;
35814 }
35815
35816 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35817 RBRQ_LEN_ERR(he_dev->rbrq_head)
35818 ? "LEN_ERR" : "",
35819 vcc->vpi, vcc->vci);
35820 - atomic_inc(&vcc->stats->rx_err);
35821 + atomic_inc_unchecked(&vcc->stats->rx_err);
35822 goto return_host_buffers;
35823 }
35824
35825 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35826 vcc->push(vcc, skb);
35827 spin_lock(&he_dev->global_lock);
35828
35829 - atomic_inc(&vcc->stats->rx);
35830 + atomic_inc_unchecked(&vcc->stats->rx);
35831
35832 return_host_buffers:
35833 ++pdus_assembled;
35834 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35835 tpd->vcc->pop(tpd->vcc, tpd->skb);
35836 else
35837 dev_kfree_skb_any(tpd->skb);
35838 - atomic_inc(&tpd->vcc->stats->tx_err);
35839 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35840 }
35841 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35842 return;
35843 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35844 vcc->pop(vcc, skb);
35845 else
35846 dev_kfree_skb_any(skb);
35847 - atomic_inc(&vcc->stats->tx_err);
35848 + atomic_inc_unchecked(&vcc->stats->tx_err);
35849 return -EINVAL;
35850 }
35851
35852 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35853 vcc->pop(vcc, skb);
35854 else
35855 dev_kfree_skb_any(skb);
35856 - atomic_inc(&vcc->stats->tx_err);
35857 + atomic_inc_unchecked(&vcc->stats->tx_err);
35858 return -EINVAL;
35859 }
35860 #endif
35861 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35862 vcc->pop(vcc, skb);
35863 else
35864 dev_kfree_skb_any(skb);
35865 - atomic_inc(&vcc->stats->tx_err);
35866 + atomic_inc_unchecked(&vcc->stats->tx_err);
35867 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35868 return -ENOMEM;
35869 }
35870 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35871 vcc->pop(vcc, skb);
35872 else
35873 dev_kfree_skb_any(skb);
35874 - atomic_inc(&vcc->stats->tx_err);
35875 + atomic_inc_unchecked(&vcc->stats->tx_err);
35876 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35877 return -ENOMEM;
35878 }
35879 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35880 __enqueue_tpd(he_dev, tpd, cid);
35881 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35882
35883 - atomic_inc(&vcc->stats->tx);
35884 + atomic_inc_unchecked(&vcc->stats->tx);
35885
35886 return 0;
35887 }
35888 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35889 index 1dc0519..1aadaf7 100644
35890 --- a/drivers/atm/horizon.c
35891 +++ b/drivers/atm/horizon.c
35892 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35893 {
35894 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35895 // VC layer stats
35896 - atomic_inc(&vcc->stats->rx);
35897 + atomic_inc_unchecked(&vcc->stats->rx);
35898 __net_timestamp(skb);
35899 // end of our responsibility
35900 vcc->push (vcc, skb);
35901 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35902 dev->tx_iovec = NULL;
35903
35904 // VC layer stats
35905 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35906 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35907
35908 // free the skb
35909 hrz_kfree_skb (skb);
35910 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35911 index 1bdf104..9dc44b1 100644
35912 --- a/drivers/atm/idt77252.c
35913 +++ b/drivers/atm/idt77252.c
35914 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35915 else
35916 dev_kfree_skb(skb);
35917
35918 - atomic_inc(&vcc->stats->tx);
35919 + atomic_inc_unchecked(&vcc->stats->tx);
35920 }
35921
35922 atomic_dec(&scq->used);
35923 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35924 if ((sb = dev_alloc_skb(64)) == NULL) {
35925 printk("%s: Can't allocate buffers for aal0.\n",
35926 card->name);
35927 - atomic_add(i, &vcc->stats->rx_drop);
35928 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35929 break;
35930 }
35931 if (!atm_charge(vcc, sb->truesize)) {
35932 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35933 card->name);
35934 - atomic_add(i - 1, &vcc->stats->rx_drop);
35935 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35936 dev_kfree_skb(sb);
35937 break;
35938 }
35939 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35940 ATM_SKB(sb)->vcc = vcc;
35941 __net_timestamp(sb);
35942 vcc->push(vcc, sb);
35943 - atomic_inc(&vcc->stats->rx);
35944 + atomic_inc_unchecked(&vcc->stats->rx);
35945
35946 cell += ATM_CELL_PAYLOAD;
35947 }
35948 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35949 "(CDC: %08x)\n",
35950 card->name, len, rpp->len, readl(SAR_REG_CDC));
35951 recycle_rx_pool_skb(card, rpp);
35952 - atomic_inc(&vcc->stats->rx_err);
35953 + atomic_inc_unchecked(&vcc->stats->rx_err);
35954 return;
35955 }
35956 if (stat & SAR_RSQE_CRC) {
35957 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35958 recycle_rx_pool_skb(card, rpp);
35959 - atomic_inc(&vcc->stats->rx_err);
35960 + atomic_inc_unchecked(&vcc->stats->rx_err);
35961 return;
35962 }
35963 if (skb_queue_len(&rpp->queue) > 1) {
35964 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35965 RXPRINTK("%s: Can't alloc RX skb.\n",
35966 card->name);
35967 recycle_rx_pool_skb(card, rpp);
35968 - atomic_inc(&vcc->stats->rx_err);
35969 + atomic_inc_unchecked(&vcc->stats->rx_err);
35970 return;
35971 }
35972 if (!atm_charge(vcc, skb->truesize)) {
35973 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35974 __net_timestamp(skb);
35975
35976 vcc->push(vcc, skb);
35977 - atomic_inc(&vcc->stats->rx);
35978 + atomic_inc_unchecked(&vcc->stats->rx);
35979
35980 return;
35981 }
35982 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35983 __net_timestamp(skb);
35984
35985 vcc->push(vcc, skb);
35986 - atomic_inc(&vcc->stats->rx);
35987 + atomic_inc_unchecked(&vcc->stats->rx);
35988
35989 if (skb->truesize > SAR_FB_SIZE_3)
35990 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35991 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35992 if (vcc->qos.aal != ATM_AAL0) {
35993 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35994 card->name, vpi, vci);
35995 - atomic_inc(&vcc->stats->rx_drop);
35996 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35997 goto drop;
35998 }
35999
36000 if ((sb = dev_alloc_skb(64)) == NULL) {
36001 printk("%s: Can't allocate buffers for AAL0.\n",
36002 card->name);
36003 - atomic_inc(&vcc->stats->rx_err);
36004 + atomic_inc_unchecked(&vcc->stats->rx_err);
36005 goto drop;
36006 }
36007
36008 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
36009 ATM_SKB(sb)->vcc = vcc;
36010 __net_timestamp(sb);
36011 vcc->push(vcc, sb);
36012 - atomic_inc(&vcc->stats->rx);
36013 + atomic_inc_unchecked(&vcc->stats->rx);
36014
36015 drop:
36016 skb_pull(queue, 64);
36017 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
36018
36019 if (vc == NULL) {
36020 printk("%s: NULL connection in send().\n", card->name);
36021 - atomic_inc(&vcc->stats->tx_err);
36022 + atomic_inc_unchecked(&vcc->stats->tx_err);
36023 dev_kfree_skb(skb);
36024 return -EINVAL;
36025 }
36026 if (!test_bit(VCF_TX, &vc->flags)) {
36027 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
36028 - atomic_inc(&vcc->stats->tx_err);
36029 + atomic_inc_unchecked(&vcc->stats->tx_err);
36030 dev_kfree_skb(skb);
36031 return -EINVAL;
36032 }
36033 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
36034 break;
36035 default:
36036 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
36037 - atomic_inc(&vcc->stats->tx_err);
36038 + atomic_inc_unchecked(&vcc->stats->tx_err);
36039 dev_kfree_skb(skb);
36040 return -EINVAL;
36041 }
36042
36043 if (skb_shinfo(skb)->nr_frags != 0) {
36044 printk("%s: No scatter-gather yet.\n", card->name);
36045 - atomic_inc(&vcc->stats->tx_err);
36046 + atomic_inc_unchecked(&vcc->stats->tx_err);
36047 dev_kfree_skb(skb);
36048 return -EINVAL;
36049 }
36050 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
36051
36052 err = queue_skb(card, vc, skb, oam);
36053 if (err) {
36054 - atomic_inc(&vcc->stats->tx_err);
36055 + atomic_inc_unchecked(&vcc->stats->tx_err);
36056 dev_kfree_skb(skb);
36057 return err;
36058 }
36059 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
36060 skb = dev_alloc_skb(64);
36061 if (!skb) {
36062 printk("%s: Out of memory in send_oam().\n", card->name);
36063 - atomic_inc(&vcc->stats->tx_err);
36064 + atomic_inc_unchecked(&vcc->stats->tx_err);
36065 return -ENOMEM;
36066 }
36067 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
36068 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
36069 index 4217f29..88f547a 100644
36070 --- a/drivers/atm/iphase.c
36071 +++ b/drivers/atm/iphase.c
36072 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
36073 status = (u_short) (buf_desc_ptr->desc_mode);
36074 if (status & (RX_CER | RX_PTE | RX_OFL))
36075 {
36076 - atomic_inc(&vcc->stats->rx_err);
36077 + atomic_inc_unchecked(&vcc->stats->rx_err);
36078 IF_ERR(printk("IA: bad packet, dropping it");)
36079 if (status & RX_CER) {
36080 IF_ERR(printk(" cause: packet CRC error\n");)
36081 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
36082 len = dma_addr - buf_addr;
36083 if (len > iadev->rx_buf_sz) {
36084 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
36085 - atomic_inc(&vcc->stats->rx_err);
36086 + atomic_inc_unchecked(&vcc->stats->rx_err);
36087 goto out_free_desc;
36088 }
36089
36090 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
36091 ia_vcc = INPH_IA_VCC(vcc);
36092 if (ia_vcc == NULL)
36093 {
36094 - atomic_inc(&vcc->stats->rx_err);
36095 + atomic_inc_unchecked(&vcc->stats->rx_err);
36096 atm_return(vcc, skb->truesize);
36097 dev_kfree_skb_any(skb);
36098 goto INCR_DLE;
36099 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
36100 if ((length > iadev->rx_buf_sz) || (length >
36101 (skb->len - sizeof(struct cpcs_trailer))))
36102 {
36103 - atomic_inc(&vcc->stats->rx_err);
36104 + atomic_inc_unchecked(&vcc->stats->rx_err);
36105 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
36106 length, skb->len);)
36107 atm_return(vcc, skb->truesize);
36108 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
36109
36110 IF_RX(printk("rx_dle_intr: skb push");)
36111 vcc->push(vcc,skb);
36112 - atomic_inc(&vcc->stats->rx);
36113 + atomic_inc_unchecked(&vcc->stats->rx);
36114 iadev->rx_pkt_cnt++;
36115 }
36116 INCR_DLE:
36117 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
36118 {
36119 struct k_sonet_stats *stats;
36120 stats = &PRIV(_ia_dev[board])->sonet_stats;
36121 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
36122 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
36123 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
36124 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
36125 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
36126 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
36127 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
36128 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
36129 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
36130 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
36131 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
36132 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
36133 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
36134 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
36135 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
36136 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
36137 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
36138 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
36139 }
36140 ia_cmds.status = 0;
36141 break;
36142 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36143 if ((desc == 0) || (desc > iadev->num_tx_desc))
36144 {
36145 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
36146 - atomic_inc(&vcc->stats->tx);
36147 + atomic_inc_unchecked(&vcc->stats->tx);
36148 if (vcc->pop)
36149 vcc->pop(vcc, skb);
36150 else
36151 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36152 ATM_DESC(skb) = vcc->vci;
36153 skb_queue_tail(&iadev->tx_dma_q, skb);
36154
36155 - atomic_inc(&vcc->stats->tx);
36156 + atomic_inc_unchecked(&vcc->stats->tx);
36157 iadev->tx_pkt_cnt++;
36158 /* Increment transaction counter */
36159 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
36160
36161 #if 0
36162 /* add flow control logic */
36163 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
36164 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
36165 if (iavcc->vc_desc_cnt > 10) {
36166 vcc->tx_quota = vcc->tx_quota * 3 / 4;
36167 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
36168 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
36169 index fa7d701..1e404c7 100644
36170 --- a/drivers/atm/lanai.c
36171 +++ b/drivers/atm/lanai.c
36172 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
36173 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
36174 lanai_endtx(lanai, lvcc);
36175 lanai_free_skb(lvcc->tx.atmvcc, skb);
36176 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
36177 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
36178 }
36179
36180 /* Try to fill the buffer - don't call unless there is backlog */
36181 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
36182 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
36183 __net_timestamp(skb);
36184 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
36185 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
36186 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
36187 out:
36188 lvcc->rx.buf.ptr = end;
36189 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
36190 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36191 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
36192 "vcc %d\n", lanai->number, (unsigned int) s, vci);
36193 lanai->stats.service_rxnotaal5++;
36194 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36195 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36196 return 0;
36197 }
36198 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
36199 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36200 int bytes;
36201 read_unlock(&vcc_sklist_lock);
36202 DPRINTK("got trashed rx pdu on vci %d\n", vci);
36203 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36204 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36205 lvcc->stats.x.aal5.service_trash++;
36206 bytes = (SERVICE_GET_END(s) * 16) -
36207 (((unsigned long) lvcc->rx.buf.ptr) -
36208 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36209 }
36210 if (s & SERVICE_STREAM) {
36211 read_unlock(&vcc_sklist_lock);
36212 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36213 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36214 lvcc->stats.x.aal5.service_stream++;
36215 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
36216 "PDU on VCI %d!\n", lanai->number, vci);
36217 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36218 return 0;
36219 }
36220 DPRINTK("got rx crc error on vci %d\n", vci);
36221 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36222 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36223 lvcc->stats.x.aal5.service_rxcrc++;
36224 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
36225 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
36226 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
36227 index 5aca5f4..ce3a6b0 100644
36228 --- a/drivers/atm/nicstar.c
36229 +++ b/drivers/atm/nicstar.c
36230 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36231 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
36232 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
36233 card->index);
36234 - atomic_inc(&vcc->stats->tx_err);
36235 + atomic_inc_unchecked(&vcc->stats->tx_err);
36236 dev_kfree_skb_any(skb);
36237 return -EINVAL;
36238 }
36239 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36240 if (!vc->tx) {
36241 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
36242 card->index);
36243 - atomic_inc(&vcc->stats->tx_err);
36244 + atomic_inc_unchecked(&vcc->stats->tx_err);
36245 dev_kfree_skb_any(skb);
36246 return -EINVAL;
36247 }
36248 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36249 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
36250 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
36251 card->index);
36252 - atomic_inc(&vcc->stats->tx_err);
36253 + atomic_inc_unchecked(&vcc->stats->tx_err);
36254 dev_kfree_skb_any(skb);
36255 return -EINVAL;
36256 }
36257
36258 if (skb_shinfo(skb)->nr_frags != 0) {
36259 printk("nicstar%d: No scatter-gather yet.\n", card->index);
36260 - atomic_inc(&vcc->stats->tx_err);
36261 + atomic_inc_unchecked(&vcc->stats->tx_err);
36262 dev_kfree_skb_any(skb);
36263 return -EINVAL;
36264 }
36265 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36266 }
36267
36268 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
36269 - atomic_inc(&vcc->stats->tx_err);
36270 + atomic_inc_unchecked(&vcc->stats->tx_err);
36271 dev_kfree_skb_any(skb);
36272 return -EIO;
36273 }
36274 - atomic_inc(&vcc->stats->tx);
36275 + atomic_inc_unchecked(&vcc->stats->tx);
36276
36277 return 0;
36278 }
36279 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36280 printk
36281 ("nicstar%d: Can't allocate buffers for aal0.\n",
36282 card->index);
36283 - atomic_add(i, &vcc->stats->rx_drop);
36284 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
36285 break;
36286 }
36287 if (!atm_charge(vcc, sb->truesize)) {
36288 RXPRINTK
36289 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
36290 card->index);
36291 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36292 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36293 dev_kfree_skb_any(sb);
36294 break;
36295 }
36296 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36297 ATM_SKB(sb)->vcc = vcc;
36298 __net_timestamp(sb);
36299 vcc->push(vcc, sb);
36300 - atomic_inc(&vcc->stats->rx);
36301 + atomic_inc_unchecked(&vcc->stats->rx);
36302 cell += ATM_CELL_PAYLOAD;
36303 }
36304
36305 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36306 if (iovb == NULL) {
36307 printk("nicstar%d: Out of iovec buffers.\n",
36308 card->index);
36309 - atomic_inc(&vcc->stats->rx_drop);
36310 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36311 recycle_rx_buf(card, skb);
36312 return;
36313 }
36314 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36315 small or large buffer itself. */
36316 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
36317 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
36318 - atomic_inc(&vcc->stats->rx_err);
36319 + atomic_inc_unchecked(&vcc->stats->rx_err);
36320 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36321 NS_MAX_IOVECS);
36322 NS_PRV_IOVCNT(iovb) = 0;
36323 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36324 ("nicstar%d: Expected a small buffer, and this is not one.\n",
36325 card->index);
36326 which_list(card, skb);
36327 - atomic_inc(&vcc->stats->rx_err);
36328 + atomic_inc_unchecked(&vcc->stats->rx_err);
36329 recycle_rx_buf(card, skb);
36330 vc->rx_iov = NULL;
36331 recycle_iov_buf(card, iovb);
36332 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36333 ("nicstar%d: Expected a large buffer, and this is not one.\n",
36334 card->index);
36335 which_list(card, skb);
36336 - atomic_inc(&vcc->stats->rx_err);
36337 + atomic_inc_unchecked(&vcc->stats->rx_err);
36338 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36339 NS_PRV_IOVCNT(iovb));
36340 vc->rx_iov = NULL;
36341 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36342 printk(" - PDU size mismatch.\n");
36343 else
36344 printk(".\n");
36345 - atomic_inc(&vcc->stats->rx_err);
36346 + atomic_inc_unchecked(&vcc->stats->rx_err);
36347 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36348 NS_PRV_IOVCNT(iovb));
36349 vc->rx_iov = NULL;
36350 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36351 /* skb points to a small buffer */
36352 if (!atm_charge(vcc, skb->truesize)) {
36353 push_rxbufs(card, skb);
36354 - atomic_inc(&vcc->stats->rx_drop);
36355 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36356 } else {
36357 skb_put(skb, len);
36358 dequeue_sm_buf(card, skb);
36359 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36360 ATM_SKB(skb)->vcc = vcc;
36361 __net_timestamp(skb);
36362 vcc->push(vcc, skb);
36363 - atomic_inc(&vcc->stats->rx);
36364 + atomic_inc_unchecked(&vcc->stats->rx);
36365 }
36366 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
36367 struct sk_buff *sb;
36368 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36369 if (len <= NS_SMBUFSIZE) {
36370 if (!atm_charge(vcc, sb->truesize)) {
36371 push_rxbufs(card, sb);
36372 - atomic_inc(&vcc->stats->rx_drop);
36373 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36374 } else {
36375 skb_put(sb, len);
36376 dequeue_sm_buf(card, sb);
36377 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36378 ATM_SKB(sb)->vcc = vcc;
36379 __net_timestamp(sb);
36380 vcc->push(vcc, sb);
36381 - atomic_inc(&vcc->stats->rx);
36382 + atomic_inc_unchecked(&vcc->stats->rx);
36383 }
36384
36385 push_rxbufs(card, skb);
36386 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36387
36388 if (!atm_charge(vcc, skb->truesize)) {
36389 push_rxbufs(card, skb);
36390 - atomic_inc(&vcc->stats->rx_drop);
36391 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36392 } else {
36393 dequeue_lg_buf(card, skb);
36394 #ifdef NS_USE_DESTRUCTORS
36395 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36396 ATM_SKB(skb)->vcc = vcc;
36397 __net_timestamp(skb);
36398 vcc->push(vcc, skb);
36399 - atomic_inc(&vcc->stats->rx);
36400 + atomic_inc_unchecked(&vcc->stats->rx);
36401 }
36402
36403 push_rxbufs(card, sb);
36404 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36405 printk
36406 ("nicstar%d: Out of huge buffers.\n",
36407 card->index);
36408 - atomic_inc(&vcc->stats->rx_drop);
36409 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36410 recycle_iovec_rx_bufs(card,
36411 (struct iovec *)
36412 iovb->data,
36413 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36414 card->hbpool.count++;
36415 } else
36416 dev_kfree_skb_any(hb);
36417 - atomic_inc(&vcc->stats->rx_drop);
36418 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36419 } else {
36420 /* Copy the small buffer to the huge buffer */
36421 sb = (struct sk_buff *)iov->iov_base;
36422 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36423 #endif /* NS_USE_DESTRUCTORS */
36424 __net_timestamp(hb);
36425 vcc->push(vcc, hb);
36426 - atomic_inc(&vcc->stats->rx);
36427 + atomic_inc_unchecked(&vcc->stats->rx);
36428 }
36429 }
36430
36431 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
36432 index 32784d1..4a8434a 100644
36433 --- a/drivers/atm/solos-pci.c
36434 +++ b/drivers/atm/solos-pci.c
36435 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
36436 }
36437 atm_charge(vcc, skb->truesize);
36438 vcc->push(vcc, skb);
36439 - atomic_inc(&vcc->stats->rx);
36440 + atomic_inc_unchecked(&vcc->stats->rx);
36441 break;
36442
36443 case PKT_STATUS:
36444 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
36445 vcc = SKB_CB(oldskb)->vcc;
36446
36447 if (vcc) {
36448 - atomic_inc(&vcc->stats->tx);
36449 + atomic_inc_unchecked(&vcc->stats->tx);
36450 solos_pop(vcc, oldskb);
36451 } else {
36452 dev_kfree_skb_irq(oldskb);
36453 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
36454 index 0215934..ce9f5b1 100644
36455 --- a/drivers/atm/suni.c
36456 +++ b/drivers/atm/suni.c
36457 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
36458
36459
36460 #define ADD_LIMITED(s,v) \
36461 - atomic_add((v),&stats->s); \
36462 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
36463 + atomic_add_unchecked((v),&stats->s); \
36464 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
36465
36466
36467 static void suni_hz(unsigned long from_timer)
36468 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
36469 index 5120a96..e2572bd 100644
36470 --- a/drivers/atm/uPD98402.c
36471 +++ b/drivers/atm/uPD98402.c
36472 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
36473 struct sonet_stats tmp;
36474 int error = 0;
36475
36476 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36477 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36478 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
36479 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
36480 if (zero && !error) {
36481 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
36482
36483
36484 #define ADD_LIMITED(s,v) \
36485 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
36486 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
36487 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36488 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
36489 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
36490 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36491
36492
36493 static void stat_event(struct atm_dev *dev)
36494 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
36495 if (reason & uPD98402_INT_PFM) stat_event(dev);
36496 if (reason & uPD98402_INT_PCO) {
36497 (void) GET(PCOCR); /* clear interrupt cause */
36498 - atomic_add(GET(HECCT),
36499 + atomic_add_unchecked(GET(HECCT),
36500 &PRIV(dev)->sonet_stats.uncorr_hcs);
36501 }
36502 if ((reason & uPD98402_INT_RFO) &&
36503 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
36504 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
36505 uPD98402_INT_LOS),PIMR); /* enable them */
36506 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
36507 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36508 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
36509 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
36510 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36511 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
36512 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
36513 return 0;
36514 }
36515
36516 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
36517 index 969c3c2..9b72956 100644
36518 --- a/drivers/atm/zatm.c
36519 +++ b/drivers/atm/zatm.c
36520 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36521 }
36522 if (!size) {
36523 dev_kfree_skb_irq(skb);
36524 - if (vcc) atomic_inc(&vcc->stats->rx_err);
36525 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
36526 continue;
36527 }
36528 if (!atm_charge(vcc,skb->truesize)) {
36529 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36530 skb->len = size;
36531 ATM_SKB(skb)->vcc = vcc;
36532 vcc->push(vcc,skb);
36533 - atomic_inc(&vcc->stats->rx);
36534 + atomic_inc_unchecked(&vcc->stats->rx);
36535 }
36536 zout(pos & 0xffff,MTA(mbx));
36537 #if 0 /* probably a stupid idea */
36538 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
36539 skb_queue_head(&zatm_vcc->backlog,skb);
36540 break;
36541 }
36542 - atomic_inc(&vcc->stats->tx);
36543 + atomic_inc_unchecked(&vcc->stats->tx);
36544 wake_up(&zatm_vcc->tx_wait);
36545 }
36546
36547 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
36548 index 4c289ab..de1c333 100644
36549 --- a/drivers/base/bus.c
36550 +++ b/drivers/base/bus.c
36551 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
36552 return -EINVAL;
36553
36554 mutex_lock(&subsys->p->mutex);
36555 - list_add_tail(&sif->node, &subsys->p->interfaces);
36556 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
36557 if (sif->add_dev) {
36558 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36559 while ((dev = subsys_dev_iter_next(&iter)))
36560 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
36561 subsys = sif->subsys;
36562
36563 mutex_lock(&subsys->p->mutex);
36564 - list_del_init(&sif->node);
36565 + pax_list_del_init((struct list_head *)&sif->node);
36566 if (sif->remove_dev) {
36567 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36568 while ((dev = subsys_dev_iter_next(&iter)))
36569 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
36570 index 7413d06..79155fa 100644
36571 --- a/drivers/base/devtmpfs.c
36572 +++ b/drivers/base/devtmpfs.c
36573 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
36574 if (!thread)
36575 return 0;
36576
36577 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
36578 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
36579 if (err)
36580 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
36581 else
36582 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
36583 *err = sys_unshare(CLONE_NEWNS);
36584 if (*err)
36585 goto out;
36586 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
36587 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
36588 if (*err)
36589 goto out;
36590 - sys_chdir("/.."); /* will traverse into overmounted root */
36591 - sys_chroot(".");
36592 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
36593 + sys_chroot((char __force_user *)".");
36594 complete(&setup_done);
36595 while (1) {
36596 spin_lock(&req_lock);
36597 diff --git a/drivers/base/node.c b/drivers/base/node.c
36598 index bc9f43b..29703b8 100644
36599 --- a/drivers/base/node.c
36600 +++ b/drivers/base/node.c
36601 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
36602 struct node_attr {
36603 struct device_attribute attr;
36604 enum node_states state;
36605 -};
36606 +} __do_const;
36607
36608 static ssize_t show_node_state(struct device *dev,
36609 struct device_attribute *attr, char *buf)
36610 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
36611 index bfb8955..42c9b9a 100644
36612 --- a/drivers/base/power/domain.c
36613 +++ b/drivers/base/power/domain.c
36614 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
36615 {
36616 struct cpuidle_driver *cpuidle_drv;
36617 struct gpd_cpu_data *cpu_data;
36618 - struct cpuidle_state *idle_state;
36619 + cpuidle_state_no_const *idle_state;
36620 int ret = 0;
36621
36622 if (IS_ERR_OR_NULL(genpd) || state < 0)
36623 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
36624 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
36625 {
36626 struct gpd_cpu_data *cpu_data;
36627 - struct cpuidle_state *idle_state;
36628 + cpuidle_state_no_const *idle_state;
36629 int ret = 0;
36630
36631 if (IS_ERR_OR_NULL(genpd))
36632 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
36633 index 03e089a..0e9560c 100644
36634 --- a/drivers/base/power/sysfs.c
36635 +++ b/drivers/base/power/sysfs.c
36636 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
36637 return -EIO;
36638 }
36639 }
36640 - return sprintf(buf, p);
36641 + return sprintf(buf, "%s", p);
36642 }
36643
36644 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
36645 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
36646 index 2d56f41..8830f19 100644
36647 --- a/drivers/base/power/wakeup.c
36648 +++ b/drivers/base/power/wakeup.c
36649 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
36650 * They need to be modified together atomically, so it's better to use one
36651 * atomic variable to hold them both.
36652 */
36653 -static atomic_t combined_event_count = ATOMIC_INIT(0);
36654 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
36655
36656 #define IN_PROGRESS_BITS (sizeof(int) * 4)
36657 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
36658
36659 static void split_counters(unsigned int *cnt, unsigned int *inpr)
36660 {
36661 - unsigned int comb = atomic_read(&combined_event_count);
36662 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
36663
36664 *cnt = (comb >> IN_PROGRESS_BITS);
36665 *inpr = comb & MAX_IN_PROGRESS;
36666 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
36667 ws->start_prevent_time = ws->last_time;
36668
36669 /* Increment the counter of events in progress. */
36670 - cec = atomic_inc_return(&combined_event_count);
36671 + cec = atomic_inc_return_unchecked(&combined_event_count);
36672
36673 trace_wakeup_source_activate(ws->name, cec);
36674 }
36675 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
36676 * Increment the counter of registered wakeup events and decrement the
36677 * couter of wakeup events in progress simultaneously.
36678 */
36679 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
36680 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
36681 trace_wakeup_source_deactivate(ws->name, cec);
36682
36683 split_counters(&cnt, &inpr);
36684 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
36685 index e8d11b6..7b1b36f 100644
36686 --- a/drivers/base/syscore.c
36687 +++ b/drivers/base/syscore.c
36688 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
36689 void register_syscore_ops(struct syscore_ops *ops)
36690 {
36691 mutex_lock(&syscore_ops_lock);
36692 - list_add_tail(&ops->node, &syscore_ops_list);
36693 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
36694 mutex_unlock(&syscore_ops_lock);
36695 }
36696 EXPORT_SYMBOL_GPL(register_syscore_ops);
36697 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
36698 void unregister_syscore_ops(struct syscore_ops *ops)
36699 {
36700 mutex_lock(&syscore_ops_lock);
36701 - list_del(&ops->node);
36702 + pax_list_del((struct list_head *)&ops->node);
36703 mutex_unlock(&syscore_ops_lock);
36704 }
36705 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36706 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36707 index edfa251..1734d4d 100644
36708 --- a/drivers/block/cciss.c
36709 +++ b/drivers/block/cciss.c
36710 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
36711 while (!list_empty(&h->reqQ)) {
36712 c = list_entry(h->reqQ.next, CommandList_struct, list);
36713 /* can't do anything if fifo is full */
36714 - if ((h->access.fifo_full(h))) {
36715 + if ((h->access->fifo_full(h))) {
36716 dev_warn(&h->pdev->dev, "fifo full\n");
36717 break;
36718 }
36719 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
36720 h->Qdepth--;
36721
36722 /* Tell the controller execute command */
36723 - h->access.submit_command(h, c);
36724 + h->access->submit_command(h, c);
36725
36726 /* Put job onto the completed Q */
36727 addQ(&h->cmpQ, c);
36728 @@ -3447,17 +3447,17 @@ startio:
36729
36730 static inline unsigned long get_next_completion(ctlr_info_t *h)
36731 {
36732 - return h->access.command_completed(h);
36733 + return h->access->command_completed(h);
36734 }
36735
36736 static inline int interrupt_pending(ctlr_info_t *h)
36737 {
36738 - return h->access.intr_pending(h);
36739 + return h->access->intr_pending(h);
36740 }
36741
36742 static inline long interrupt_not_for_us(ctlr_info_t *h)
36743 {
36744 - return ((h->access.intr_pending(h) == 0) ||
36745 + return ((h->access->intr_pending(h) == 0) ||
36746 (h->interrupts_enabled == 0));
36747 }
36748
36749 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36750 u32 a;
36751
36752 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36753 - return h->access.command_completed(h);
36754 + return h->access->command_completed(h);
36755
36756 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36757 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36758 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36759 trans_support & CFGTBL_Trans_use_short_tags);
36760
36761 /* Change the access methods to the performant access methods */
36762 - h->access = SA5_performant_access;
36763 + h->access = &SA5_performant_access;
36764 h->transMethod = CFGTBL_Trans_Performant;
36765
36766 return;
36767 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36768 if (prod_index < 0)
36769 return -ENODEV;
36770 h->product_name = products[prod_index].product_name;
36771 - h->access = *(products[prod_index].access);
36772 + h->access = products[prod_index].access;
36773
36774 if (cciss_board_disabled(h)) {
36775 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36776 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36777 }
36778
36779 /* make sure the board interrupts are off */
36780 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36781 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36782 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36783 if (rc)
36784 goto clean2;
36785 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36786 * fake ones to scoop up any residual completions.
36787 */
36788 spin_lock_irqsave(&h->lock, flags);
36789 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36790 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36791 spin_unlock_irqrestore(&h->lock, flags);
36792 free_irq(h->intr[h->intr_mode], h);
36793 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36794 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36795 dev_info(&h->pdev->dev, "Board READY.\n");
36796 dev_info(&h->pdev->dev,
36797 "Waiting for stale completions to drain.\n");
36798 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36799 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36800 msleep(10000);
36801 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36802 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36803
36804 rc = controller_reset_failed(h->cfgtable);
36805 if (rc)
36806 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36807 cciss_scsi_setup(h);
36808
36809 /* Turn the interrupts on so we can service requests */
36810 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36811 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36812
36813 /* Get the firmware version */
36814 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36815 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36816 kfree(flush_buf);
36817 if (return_code != IO_OK)
36818 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36819 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36820 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36821 free_irq(h->intr[h->intr_mode], h);
36822 }
36823
36824 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36825 index 7fda30e..eb5dfe0 100644
36826 --- a/drivers/block/cciss.h
36827 +++ b/drivers/block/cciss.h
36828 @@ -101,7 +101,7 @@ struct ctlr_info
36829 /* information about each logical volume */
36830 drive_info_struct *drv[CISS_MAX_LUN];
36831
36832 - struct access_method access;
36833 + struct access_method *access;
36834
36835 /* queue and queue Info */
36836 struct list_head reqQ;
36837 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36838 index 2b94403..fd6ad1f 100644
36839 --- a/drivers/block/cpqarray.c
36840 +++ b/drivers/block/cpqarray.c
36841 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36842 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36843 goto Enomem4;
36844 }
36845 - hba[i]->access.set_intr_mask(hba[i], 0);
36846 + hba[i]->access->set_intr_mask(hba[i], 0);
36847 if (request_irq(hba[i]->intr, do_ida_intr,
36848 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36849 {
36850 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36851 add_timer(&hba[i]->timer);
36852
36853 /* Enable IRQ now that spinlock and rate limit timer are set up */
36854 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36855 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36856
36857 for(j=0; j<NWD; j++) {
36858 struct gendisk *disk = ida_gendisk[i][j];
36859 @@ -694,7 +694,7 @@ DBGINFO(
36860 for(i=0; i<NR_PRODUCTS; i++) {
36861 if (board_id == products[i].board_id) {
36862 c->product_name = products[i].product_name;
36863 - c->access = *(products[i].access);
36864 + c->access = products[i].access;
36865 break;
36866 }
36867 }
36868 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36869 hba[ctlr]->intr = intr;
36870 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36871 hba[ctlr]->product_name = products[j].product_name;
36872 - hba[ctlr]->access = *(products[j].access);
36873 + hba[ctlr]->access = products[j].access;
36874 hba[ctlr]->ctlr = ctlr;
36875 hba[ctlr]->board_id = board_id;
36876 hba[ctlr]->pci_dev = NULL; /* not PCI */
36877 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36878
36879 while((c = h->reqQ) != NULL) {
36880 /* Can't do anything if we're busy */
36881 - if (h->access.fifo_full(h) == 0)
36882 + if (h->access->fifo_full(h) == 0)
36883 return;
36884
36885 /* Get the first entry from the request Q */
36886 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36887 h->Qdepth--;
36888
36889 /* Tell the controller to do our bidding */
36890 - h->access.submit_command(h, c);
36891 + h->access->submit_command(h, c);
36892
36893 /* Get onto the completion Q */
36894 addQ(&h->cmpQ, c);
36895 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36896 unsigned long flags;
36897 __u32 a,a1;
36898
36899 - istat = h->access.intr_pending(h);
36900 + istat = h->access->intr_pending(h);
36901 /* Is this interrupt for us? */
36902 if (istat == 0)
36903 return IRQ_NONE;
36904 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36905 */
36906 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36907 if (istat & FIFO_NOT_EMPTY) {
36908 - while((a = h->access.command_completed(h))) {
36909 + while((a = h->access->command_completed(h))) {
36910 a1 = a; a &= ~3;
36911 if ((c = h->cmpQ) == NULL)
36912 {
36913 @@ -1448,11 +1448,11 @@ static int sendcmd(
36914 /*
36915 * Disable interrupt
36916 */
36917 - info_p->access.set_intr_mask(info_p, 0);
36918 + info_p->access->set_intr_mask(info_p, 0);
36919 /* Make sure there is room in the command FIFO */
36920 /* Actually it should be completely empty at this time. */
36921 for (i = 200000; i > 0; i--) {
36922 - temp = info_p->access.fifo_full(info_p);
36923 + temp = info_p->access->fifo_full(info_p);
36924 if (temp != 0) {
36925 break;
36926 }
36927 @@ -1465,7 +1465,7 @@ DBG(
36928 /*
36929 * Send the cmd
36930 */
36931 - info_p->access.submit_command(info_p, c);
36932 + info_p->access->submit_command(info_p, c);
36933 complete = pollcomplete(ctlr);
36934
36935 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36936 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36937 * we check the new geometry. Then turn interrupts back on when
36938 * we're done.
36939 */
36940 - host->access.set_intr_mask(host, 0);
36941 + host->access->set_intr_mask(host, 0);
36942 getgeometry(ctlr);
36943 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36944 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36945
36946 for(i=0; i<NWD; i++) {
36947 struct gendisk *disk = ida_gendisk[ctlr][i];
36948 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36949 /* Wait (up to 2 seconds) for a command to complete */
36950
36951 for (i = 200000; i > 0; i--) {
36952 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36953 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36954 if (done == 0) {
36955 udelay(10); /* a short fixed delay */
36956 } else
36957 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36958 index be73e9d..7fbf140 100644
36959 --- a/drivers/block/cpqarray.h
36960 +++ b/drivers/block/cpqarray.h
36961 @@ -99,7 +99,7 @@ struct ctlr_info {
36962 drv_info_t drv[NWD];
36963 struct proc_dir_entry *proc;
36964
36965 - struct access_method access;
36966 + struct access_method *access;
36967
36968 cmdlist_t *reqQ;
36969 cmdlist_t *cmpQ;
36970 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36971 index 2d7f608..11245fe 100644
36972 --- a/drivers/block/drbd/drbd_int.h
36973 +++ b/drivers/block/drbd/drbd_int.h
36974 @@ -582,7 +582,7 @@ struct drbd_epoch {
36975 struct drbd_tconn *tconn;
36976 struct list_head list;
36977 unsigned int barrier_nr;
36978 - atomic_t epoch_size; /* increased on every request added. */
36979 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36980 atomic_t active; /* increased on every req. added, and dec on every finished. */
36981 unsigned long flags;
36982 };
36983 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36984 unsigned int al_tr_number;
36985 int al_tr_cycle;
36986 wait_queue_head_t seq_wait;
36987 - atomic_t packet_seq;
36988 + atomic_unchecked_t packet_seq;
36989 unsigned int peer_seq;
36990 spinlock_t peer_seq_lock;
36991 unsigned int minor;
36992 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36993 char __user *uoptval;
36994 int err;
36995
36996 - uoptval = (char __user __force *)optval;
36997 + uoptval = (char __force_user *)optval;
36998
36999 set_fs(KERNEL_DS);
37000 if (level == SOL_SOCKET)
37001 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
37002 index 55635ed..40e837c 100644
37003 --- a/drivers/block/drbd/drbd_main.c
37004 +++ b/drivers/block/drbd/drbd_main.c
37005 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
37006 p->sector = sector;
37007 p->block_id = block_id;
37008 p->blksize = blksize;
37009 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
37010 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
37011 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
37012 }
37013
37014 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
37015 return -EIO;
37016 p->sector = cpu_to_be64(req->i.sector);
37017 p->block_id = (unsigned long)req;
37018 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
37019 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
37020 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
37021 if (mdev->state.conn >= C_SYNC_SOURCE &&
37022 mdev->state.conn <= C_PAUSED_SYNC_T)
37023 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
37024 {
37025 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
37026
37027 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
37028 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
37029 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
37030 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
37031 kfree(tconn->current_epoch);
37032
37033 idr_destroy(&tconn->volumes);
37034 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
37035 index 8cc1e64..ba7ffa9 100644
37036 --- a/drivers/block/drbd/drbd_nl.c
37037 +++ b/drivers/block/drbd/drbd_nl.c
37038 @@ -3440,7 +3440,7 @@ out:
37039
37040 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
37041 {
37042 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
37043 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
37044 struct sk_buff *msg;
37045 struct drbd_genlmsghdr *d_out;
37046 unsigned seq;
37047 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
37048 return;
37049 }
37050
37051 - seq = atomic_inc_return(&drbd_genl_seq);
37052 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
37053 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
37054 if (!msg)
37055 goto failed;
37056 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
37057 index cc29cd3..d4b058b 100644
37058 --- a/drivers/block/drbd/drbd_receiver.c
37059 +++ b/drivers/block/drbd/drbd_receiver.c
37060 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
37061 {
37062 int err;
37063
37064 - atomic_set(&mdev->packet_seq, 0);
37065 + atomic_set_unchecked(&mdev->packet_seq, 0);
37066 mdev->peer_seq = 0;
37067
37068 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
37069 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
37070 do {
37071 next_epoch = NULL;
37072
37073 - epoch_size = atomic_read(&epoch->epoch_size);
37074 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
37075
37076 switch (ev & ~EV_CLEANUP) {
37077 case EV_PUT:
37078 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
37079 rv = FE_DESTROYED;
37080 } else {
37081 epoch->flags = 0;
37082 - atomic_set(&epoch->epoch_size, 0);
37083 + atomic_set_unchecked(&epoch->epoch_size, 0);
37084 /* atomic_set(&epoch->active, 0); is already zero */
37085 if (rv == FE_STILL_LIVE)
37086 rv = FE_RECYCLED;
37087 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
37088 conn_wait_active_ee_empty(tconn);
37089 drbd_flush(tconn);
37090
37091 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
37092 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
37093 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
37094 if (epoch)
37095 break;
37096 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
37097 }
37098
37099 epoch->flags = 0;
37100 - atomic_set(&epoch->epoch_size, 0);
37101 + atomic_set_unchecked(&epoch->epoch_size, 0);
37102 atomic_set(&epoch->active, 0);
37103
37104 spin_lock(&tconn->epoch_lock);
37105 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
37106 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
37107 list_add(&epoch->list, &tconn->current_epoch->list);
37108 tconn->current_epoch = epoch;
37109 tconn->epochs++;
37110 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
37111
37112 err = wait_for_and_update_peer_seq(mdev, peer_seq);
37113 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
37114 - atomic_inc(&tconn->current_epoch->epoch_size);
37115 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
37116 err2 = drbd_drain_block(mdev, pi->size);
37117 if (!err)
37118 err = err2;
37119 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
37120
37121 spin_lock(&tconn->epoch_lock);
37122 peer_req->epoch = tconn->current_epoch;
37123 - atomic_inc(&peer_req->epoch->epoch_size);
37124 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
37125 atomic_inc(&peer_req->epoch->active);
37126 spin_unlock(&tconn->epoch_lock);
37127
37128 @@ -4347,7 +4347,7 @@ struct data_cmd {
37129 int expect_payload;
37130 size_t pkt_size;
37131 int (*fn)(struct drbd_tconn *, struct packet_info *);
37132 -};
37133 +} __do_const;
37134
37135 static struct data_cmd drbd_cmd_handler[] = {
37136 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
37137 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
37138 if (!list_empty(&tconn->current_epoch->list))
37139 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
37140 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
37141 - atomic_set(&tconn->current_epoch->epoch_size, 0);
37142 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
37143 tconn->send.seen_any_write_yet = false;
37144
37145 conn_info(tconn, "Connection closed\n");
37146 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
37147 struct asender_cmd {
37148 size_t pkt_size;
37149 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
37150 -};
37151 +} __do_const;
37152
37153 static struct asender_cmd asender_tbl[] = {
37154 [P_PING] = { 0, got_Ping },
37155 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
37156 index c8dac73..1800093 100644
37157 --- a/drivers/block/loop.c
37158 +++ b/drivers/block/loop.c
37159 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
37160
37161 file_start_write(file);
37162 set_fs(get_ds());
37163 - bw = file->f_op->write(file, buf, len, &pos);
37164 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
37165 set_fs(old_fs);
37166 file_end_write(file);
37167 if (likely(bw == len))
37168 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
37169 index 5618847..5a46f3b 100644
37170 --- a/drivers/block/pktcdvd.c
37171 +++ b/drivers/block/pktcdvd.c
37172 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
37173
37174 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
37175 {
37176 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
37177 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
37178 }
37179
37180 /*
37181 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
37182 return -EROFS;
37183 }
37184 pd->settings.fp = ti.fp;
37185 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
37186 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
37187
37188 if (ti.nwa_v) {
37189 pd->nwa = be32_to_cpu(ti.next_writable);
37190 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
37191 index 60abf59..80789e1 100644
37192 --- a/drivers/bluetooth/btwilink.c
37193 +++ b/drivers/bluetooth/btwilink.c
37194 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
37195
37196 static int bt_ti_probe(struct platform_device *pdev)
37197 {
37198 - static struct ti_st *hst;
37199 + struct ti_st *hst;
37200 struct hci_dev *hdev;
37201 int err;
37202
37203 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
37204 index 2009266..7be9ca2 100644
37205 --- a/drivers/bus/arm-cci.c
37206 +++ b/drivers/bus/arm-cci.c
37207 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
37208
37209 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
37210
37211 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
37212 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
37213 if (!ports)
37214 return -ENOMEM;
37215
37216 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
37217 index 8a3aff7..d7538c2 100644
37218 --- a/drivers/cdrom/cdrom.c
37219 +++ b/drivers/cdrom/cdrom.c
37220 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
37221 ENSURE(reset, CDC_RESET);
37222 ENSURE(generic_packet, CDC_GENERIC_PACKET);
37223 cdi->mc_flags = 0;
37224 - cdo->n_minors = 0;
37225 cdi->options = CDO_USE_FFLAGS;
37226
37227 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
37228 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
37229 else
37230 cdi->cdda_method = CDDA_OLD;
37231
37232 - if (!cdo->generic_packet)
37233 - cdo->generic_packet = cdrom_dummy_generic_packet;
37234 + if (!cdo->generic_packet) {
37235 + pax_open_kernel();
37236 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
37237 + pax_close_kernel();
37238 + }
37239
37240 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
37241 mutex_lock(&cdrom_mutex);
37242 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
37243 if (cdi->exit)
37244 cdi->exit(cdi);
37245
37246 - cdi->ops->n_minors--;
37247 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
37248 }
37249
37250 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
37251 */
37252 nr = nframes;
37253 do {
37254 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37255 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37256 if (cgc.buffer)
37257 break;
37258
37259 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
37260 struct cdrom_device_info *cdi;
37261 int ret;
37262
37263 - ret = scnprintf(info + *pos, max_size - *pos, header);
37264 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
37265 if (!ret)
37266 return 1;
37267
37268 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
37269 index 5980cb9..6d7bd7e 100644
37270 --- a/drivers/cdrom/gdrom.c
37271 +++ b/drivers/cdrom/gdrom.c
37272 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
37273 .audio_ioctl = gdrom_audio_ioctl,
37274 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
37275 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
37276 - .n_minors = 1,
37277 };
37278
37279 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
37280 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
37281 index 1421997..33f5d6d 100644
37282 --- a/drivers/char/Kconfig
37283 +++ b/drivers/char/Kconfig
37284 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
37285
37286 config DEVKMEM
37287 bool "/dev/kmem virtual device support"
37288 - default y
37289 + default n
37290 + depends on !GRKERNSEC_KMEM
37291 help
37292 Say Y here if you want to support the /dev/kmem device. The
37293 /dev/kmem device is rarely used, but can be used for certain
37294 @@ -570,6 +571,7 @@ config DEVPORT
37295 bool
37296 depends on !M68K
37297 depends on ISA || PCI
37298 + depends on !GRKERNSEC_KMEM
37299 default y
37300
37301 source "drivers/s390/char/Kconfig"
37302 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
37303 index a48e05b..6bac831 100644
37304 --- a/drivers/char/agp/compat_ioctl.c
37305 +++ b/drivers/char/agp/compat_ioctl.c
37306 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
37307 return -ENOMEM;
37308 }
37309
37310 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
37311 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
37312 sizeof(*usegment) * ureserve.seg_count)) {
37313 kfree(usegment);
37314 kfree(ksegment);
37315 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
37316 index 1b19239..b87b143 100644
37317 --- a/drivers/char/agp/frontend.c
37318 +++ b/drivers/char/agp/frontend.c
37319 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37320 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
37321 return -EFAULT;
37322
37323 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
37324 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
37325 return -EFAULT;
37326
37327 client = agp_find_client_by_pid(reserve.pid);
37328 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37329 if (segment == NULL)
37330 return -ENOMEM;
37331
37332 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
37333 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
37334 sizeof(struct agp_segment) * reserve.seg_count)) {
37335 kfree(segment);
37336 return -EFAULT;
37337 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
37338 index 4f94375..413694e 100644
37339 --- a/drivers/char/genrtc.c
37340 +++ b/drivers/char/genrtc.c
37341 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
37342 switch (cmd) {
37343
37344 case RTC_PLL_GET:
37345 + memset(&pll, 0, sizeof(pll));
37346 if (get_rtc_pll(&pll))
37347 return -EINVAL;
37348 else
37349 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
37350 index 448ce5e..3a76625 100644
37351 --- a/drivers/char/hpet.c
37352 +++ b/drivers/char/hpet.c
37353 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
37354 }
37355
37356 static int
37357 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
37358 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
37359 struct hpet_info *info)
37360 {
37361 struct hpet_timer __iomem *timer;
37362 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
37363 index 86fe45c..c0ea948 100644
37364 --- a/drivers/char/hw_random/intel-rng.c
37365 +++ b/drivers/char/hw_random/intel-rng.c
37366 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
37367
37368 if (no_fwh_detect)
37369 return -ENODEV;
37370 - printk(warning);
37371 + printk("%s", warning);
37372 return -EBUSY;
37373 }
37374
37375 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
37376 index ec4e10f..f2a763b 100644
37377 --- a/drivers/char/ipmi/ipmi_msghandler.c
37378 +++ b/drivers/char/ipmi/ipmi_msghandler.c
37379 @@ -420,7 +420,7 @@ struct ipmi_smi {
37380 struct proc_dir_entry *proc_dir;
37381 char proc_dir_name[10];
37382
37383 - atomic_t stats[IPMI_NUM_STATS];
37384 + atomic_unchecked_t stats[IPMI_NUM_STATS];
37385
37386 /*
37387 * run_to_completion duplicate of smb_info, smi_info
37388 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
37389
37390
37391 #define ipmi_inc_stat(intf, stat) \
37392 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
37393 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
37394 #define ipmi_get_stat(intf, stat) \
37395 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
37396 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
37397
37398 static int is_lan_addr(struct ipmi_addr *addr)
37399 {
37400 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
37401 INIT_LIST_HEAD(&intf->cmd_rcvrs);
37402 init_waitqueue_head(&intf->waitq);
37403 for (i = 0; i < IPMI_NUM_STATS; i++)
37404 - atomic_set(&intf->stats[i], 0);
37405 + atomic_set_unchecked(&intf->stats[i], 0);
37406
37407 intf->proc_dir = NULL;
37408
37409 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
37410 index 15e4a60..b046093 100644
37411 --- a/drivers/char/ipmi/ipmi_si_intf.c
37412 +++ b/drivers/char/ipmi/ipmi_si_intf.c
37413 @@ -280,7 +280,7 @@ struct smi_info {
37414 unsigned char slave_addr;
37415
37416 /* Counters and things for the proc filesystem. */
37417 - atomic_t stats[SI_NUM_STATS];
37418 + atomic_unchecked_t stats[SI_NUM_STATS];
37419
37420 struct task_struct *thread;
37421
37422 @@ -289,9 +289,9 @@ struct smi_info {
37423 };
37424
37425 #define smi_inc_stat(smi, stat) \
37426 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
37427 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
37428 #define smi_get_stat(smi, stat) \
37429 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
37430 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
37431
37432 #define SI_MAX_PARMS 4
37433
37434 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
37435 atomic_set(&new_smi->req_events, 0);
37436 new_smi->run_to_completion = 0;
37437 for (i = 0; i < SI_NUM_STATS; i++)
37438 - atomic_set(&new_smi->stats[i], 0);
37439 + atomic_set_unchecked(&new_smi->stats[i], 0);
37440
37441 new_smi->interrupt_disabled = 1;
37442 atomic_set(&new_smi->stop_operation, 0);
37443 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
37444 index f895a8c..2bc9147 100644
37445 --- a/drivers/char/mem.c
37446 +++ b/drivers/char/mem.c
37447 @@ -18,6 +18,7 @@
37448 #include <linux/raw.h>
37449 #include <linux/tty.h>
37450 #include <linux/capability.h>
37451 +#include <linux/security.h>
37452 #include <linux/ptrace.h>
37453 #include <linux/device.h>
37454 #include <linux/highmem.h>
37455 @@ -37,6 +38,10 @@
37456
37457 #define DEVPORT_MINOR 4
37458
37459 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37460 +extern const struct file_operations grsec_fops;
37461 +#endif
37462 +
37463 static inline unsigned long size_inside_page(unsigned long start,
37464 unsigned long size)
37465 {
37466 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37467
37468 while (cursor < to) {
37469 if (!devmem_is_allowed(pfn)) {
37470 +#ifdef CONFIG_GRKERNSEC_KMEM
37471 + gr_handle_mem_readwrite(from, to);
37472 +#else
37473 printk(KERN_INFO
37474 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
37475 current->comm, from, to);
37476 +#endif
37477 return 0;
37478 }
37479 cursor += PAGE_SIZE;
37480 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37481 }
37482 return 1;
37483 }
37484 +#elif defined(CONFIG_GRKERNSEC_KMEM)
37485 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37486 +{
37487 + return 0;
37488 +}
37489 #else
37490 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37491 {
37492 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37493
37494 while (count > 0) {
37495 unsigned long remaining;
37496 + char *temp;
37497
37498 sz = size_inside_page(p, count);
37499
37500 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37501 if (!ptr)
37502 return -EFAULT;
37503
37504 - remaining = copy_to_user(buf, ptr, sz);
37505 +#ifdef CONFIG_PAX_USERCOPY
37506 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37507 + if (!temp) {
37508 + unxlate_dev_mem_ptr(p, ptr);
37509 + return -ENOMEM;
37510 + }
37511 + memcpy(temp, ptr, sz);
37512 +#else
37513 + temp = ptr;
37514 +#endif
37515 +
37516 + remaining = copy_to_user(buf, temp, sz);
37517 +
37518 +#ifdef CONFIG_PAX_USERCOPY
37519 + kfree(temp);
37520 +#endif
37521 +
37522 unxlate_dev_mem_ptr(p, ptr);
37523 if (remaining)
37524 return -EFAULT;
37525 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37526 size_t count, loff_t *ppos)
37527 {
37528 unsigned long p = *ppos;
37529 - ssize_t low_count, read, sz;
37530 + ssize_t low_count, read, sz, err = 0;
37531 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
37532 - int err = 0;
37533
37534 read = 0;
37535 if (p < (unsigned long) high_memory) {
37536 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37537 }
37538 #endif
37539 while (low_count > 0) {
37540 + char *temp;
37541 +
37542 sz = size_inside_page(p, low_count);
37543
37544 /*
37545 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37546 */
37547 kbuf = xlate_dev_kmem_ptr((char *)p);
37548
37549 - if (copy_to_user(buf, kbuf, sz))
37550 +#ifdef CONFIG_PAX_USERCOPY
37551 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37552 + if (!temp)
37553 + return -ENOMEM;
37554 + memcpy(temp, kbuf, sz);
37555 +#else
37556 + temp = kbuf;
37557 +#endif
37558 +
37559 + err = copy_to_user(buf, temp, sz);
37560 +
37561 +#ifdef CONFIG_PAX_USERCOPY
37562 + kfree(temp);
37563 +#endif
37564 +
37565 + if (err)
37566 return -EFAULT;
37567 buf += sz;
37568 p += sz;
37569 @@ -822,6 +869,9 @@ static const struct memdev {
37570 #ifdef CONFIG_PRINTK
37571 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
37572 #endif
37573 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37574 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
37575 +#endif
37576 };
37577
37578 static int memory_open(struct inode *inode, struct file *filp)
37579 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
37580 continue;
37581
37582 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
37583 - NULL, devlist[minor].name);
37584 + NULL, "%s", devlist[minor].name);
37585 }
37586
37587 return tty_init();
37588 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
37589 index 9df78e2..01ba9ae 100644
37590 --- a/drivers/char/nvram.c
37591 +++ b/drivers/char/nvram.c
37592 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
37593
37594 spin_unlock_irq(&rtc_lock);
37595
37596 - if (copy_to_user(buf, contents, tmp - contents))
37597 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
37598 return -EFAULT;
37599
37600 *ppos = i;
37601 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
37602 index d39cca6..8c1e269 100644
37603 --- a/drivers/char/pcmcia/synclink_cs.c
37604 +++ b/drivers/char/pcmcia/synclink_cs.c
37605 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37606
37607 if (debug_level >= DEBUG_LEVEL_INFO)
37608 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
37609 - __FILE__, __LINE__, info->device_name, port->count);
37610 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
37611
37612 - WARN_ON(!port->count);
37613 + WARN_ON(!atomic_read(&port->count));
37614
37615 if (tty_port_close_start(port, tty, filp) == 0)
37616 goto cleanup;
37617 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37618 cleanup:
37619 if (debug_level >= DEBUG_LEVEL_INFO)
37620 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
37621 - tty->driver->name, port->count);
37622 + tty->driver->name, atomic_read(&port->count));
37623 }
37624
37625 /* Wait until the transmitter is empty.
37626 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37627
37628 if (debug_level >= DEBUG_LEVEL_INFO)
37629 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
37630 - __FILE__, __LINE__, tty->driver->name, port->count);
37631 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
37632
37633 /* If port is closing, signal caller to try again */
37634 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
37635 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37636 goto cleanup;
37637 }
37638 spin_lock(&port->lock);
37639 - port->count++;
37640 + atomic_inc(&port->count);
37641 spin_unlock(&port->lock);
37642 spin_unlock_irqrestore(&info->netlock, flags);
37643
37644 - if (port->count == 1) {
37645 + if (atomic_read(&port->count) == 1) {
37646 /* 1st open on this device, init hardware */
37647 retval = startup(info, tty);
37648 if (retval < 0)
37649 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
37650 unsigned short new_crctype;
37651
37652 /* return error if TTY interface open */
37653 - if (info->port.count)
37654 + if (atomic_read(&info->port.count))
37655 return -EBUSY;
37656
37657 switch (encoding)
37658 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
37659
37660 /* arbitrate between network and tty opens */
37661 spin_lock_irqsave(&info->netlock, flags);
37662 - if (info->port.count != 0 || info->netcount != 0) {
37663 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
37664 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
37665 spin_unlock_irqrestore(&info->netlock, flags);
37666 return -EBUSY;
37667 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37668 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
37669
37670 /* return error if TTY interface open */
37671 - if (info->port.count)
37672 + if (atomic_read(&info->port.count))
37673 return -EBUSY;
37674
37675 if (cmd != SIOCWANDEV)
37676 diff --git a/drivers/char/random.c b/drivers/char/random.c
37677 index 7a744d3..895af8f 100644
37678 --- a/drivers/char/random.c
37679 +++ b/drivers/char/random.c
37680 @@ -269,8 +269,13 @@
37681 /*
37682 * Configuration information
37683 */
37684 +#ifdef CONFIG_GRKERNSEC_RANDNET
37685 +#define INPUT_POOL_WORDS 512
37686 +#define OUTPUT_POOL_WORDS 128
37687 +#else
37688 #define INPUT_POOL_WORDS 128
37689 #define OUTPUT_POOL_WORDS 32
37690 +#endif
37691 #define SEC_XFER_SIZE 512
37692 #define EXTRACT_SIZE 10
37693
37694 @@ -310,10 +315,17 @@ static struct poolinfo {
37695 int poolwords;
37696 int tap1, tap2, tap3, tap4, tap5;
37697 } poolinfo_table[] = {
37698 +#ifdef CONFIG_GRKERNSEC_RANDNET
37699 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
37700 + { 512, 411, 308, 208, 104, 1 },
37701 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
37702 + { 128, 103, 76, 51, 25, 1 },
37703 +#else
37704 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
37705 { 128, 103, 76, 51, 25, 1 },
37706 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
37707 { 32, 26, 20, 14, 7, 1 },
37708 +#endif
37709 #if 0
37710 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
37711 { 2048, 1638, 1231, 819, 411, 1 },
37712 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
37713 input_rotate += i ? 7 : 14;
37714 }
37715
37716 - ACCESS_ONCE(r->input_rotate) = input_rotate;
37717 - ACCESS_ONCE(r->add_ptr) = i;
37718 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
37719 + ACCESS_ONCE_RW(r->add_ptr) = i;
37720 smp_wmb();
37721
37722 if (out)
37723 @@ -603,8 +615,11 @@ retry:
37724
37725 if (!r->initialized && nbits > 0) {
37726 r->entropy_total += nbits;
37727 - if (r->entropy_total > 128)
37728 + if (r->entropy_total > 128) {
37729 r->initialized = 1;
37730 + if (r == &nonblocking_pool)
37731 + prandom_reseed_late();
37732 + }
37733 }
37734
37735 trace_credit_entropy_bits(r->name, nbits, entropy_count,
37736 @@ -1029,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
37737
37738 extract_buf(r, tmp);
37739 i = min_t(int, nbytes, EXTRACT_SIZE);
37740 - if (copy_to_user(buf, tmp, i)) {
37741 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37742 ret = -EFAULT;
37743 break;
37744 }
37745 @@ -1365,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37746 #include <linux/sysctl.h>
37747
37748 static int min_read_thresh = 8, min_write_thresh;
37749 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37750 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37751 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37752 static char sysctl_bootid[16];
37753
37754 @@ -1381,7 +1396,7 @@ static char sysctl_bootid[16];
37755 static int proc_do_uuid(struct ctl_table *table, int write,
37756 void __user *buffer, size_t *lenp, loff_t *ppos)
37757 {
37758 - struct ctl_table fake_table;
37759 + ctl_table_no_const fake_table;
37760 unsigned char buf[64], tmp_uuid[16], *uuid;
37761
37762 uuid = table->data;
37763 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37764 index 7cc1fe22..b602d6b 100644
37765 --- a/drivers/char/sonypi.c
37766 +++ b/drivers/char/sonypi.c
37767 @@ -54,6 +54,7 @@
37768
37769 #include <asm/uaccess.h>
37770 #include <asm/io.h>
37771 +#include <asm/local.h>
37772
37773 #include <linux/sonypi.h>
37774
37775 @@ -490,7 +491,7 @@ static struct sonypi_device {
37776 spinlock_t fifo_lock;
37777 wait_queue_head_t fifo_proc_list;
37778 struct fasync_struct *fifo_async;
37779 - int open_count;
37780 + local_t open_count;
37781 int model;
37782 struct input_dev *input_jog_dev;
37783 struct input_dev *input_key_dev;
37784 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37785 static int sonypi_misc_release(struct inode *inode, struct file *file)
37786 {
37787 mutex_lock(&sonypi_device.lock);
37788 - sonypi_device.open_count--;
37789 + local_dec(&sonypi_device.open_count);
37790 mutex_unlock(&sonypi_device.lock);
37791 return 0;
37792 }
37793 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37794 {
37795 mutex_lock(&sonypi_device.lock);
37796 /* Flush input queue on first open */
37797 - if (!sonypi_device.open_count)
37798 + if (!local_read(&sonypi_device.open_count))
37799 kfifo_reset(&sonypi_device.fifo);
37800 - sonypi_device.open_count++;
37801 + local_inc(&sonypi_device.open_count);
37802 mutex_unlock(&sonypi_device.lock);
37803
37804 return 0;
37805 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37806 index 64420b3..5c40b56 100644
37807 --- a/drivers/char/tpm/tpm_acpi.c
37808 +++ b/drivers/char/tpm/tpm_acpi.c
37809 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37810 virt = acpi_os_map_memory(start, len);
37811 if (!virt) {
37812 kfree(log->bios_event_log);
37813 + log->bios_event_log = NULL;
37814 printk("%s: ERROR - Unable to map memory\n", __func__);
37815 return -EIO;
37816 }
37817
37818 - memcpy_fromio(log->bios_event_log, virt, len);
37819 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37820
37821 acpi_os_unmap_memory(virt, len);
37822 return 0;
37823 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37824 index 84ddc55..1d32f1e 100644
37825 --- a/drivers/char/tpm/tpm_eventlog.c
37826 +++ b/drivers/char/tpm/tpm_eventlog.c
37827 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37828 event = addr;
37829
37830 if ((event->event_type == 0 && event->event_size == 0) ||
37831 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37832 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37833 return NULL;
37834
37835 return addr;
37836 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37837 return NULL;
37838
37839 if ((event->event_type == 0 && event->event_size == 0) ||
37840 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37841 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37842 return NULL;
37843
37844 (*pos)++;
37845 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37846 int i;
37847
37848 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37849 - seq_putc(m, data[i]);
37850 + if (!seq_putc(m, data[i]))
37851 + return -EFAULT;
37852
37853 return 0;
37854 }
37855 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37856 index b79cf3e..de172d64f 100644
37857 --- a/drivers/char/virtio_console.c
37858 +++ b/drivers/char/virtio_console.c
37859 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37860 if (to_user) {
37861 ssize_t ret;
37862
37863 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37864 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37865 if (ret)
37866 return -EFAULT;
37867 } else {
37868 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37869 if (!port_has_data(port) && !port->host_connected)
37870 return 0;
37871
37872 - return fill_readbuf(port, ubuf, count, true);
37873 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37874 }
37875
37876 static int wait_port_writable(struct port *port, bool nonblock)
37877 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37878 index a33f46f..a720eed 100644
37879 --- a/drivers/clk/clk-composite.c
37880 +++ b/drivers/clk/clk-composite.c
37881 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37882 struct clk *clk;
37883 struct clk_init_data init;
37884 struct clk_composite *composite;
37885 - struct clk_ops *clk_composite_ops;
37886 + clk_ops_no_const *clk_composite_ops;
37887
37888 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37889 if (!composite) {
37890 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37891 index 81dd31a..ef5c542 100644
37892 --- a/drivers/clk/socfpga/clk.c
37893 +++ b/drivers/clk/socfpga/clk.c
37894 @@ -22,6 +22,7 @@
37895 #include <linux/clk-provider.h>
37896 #include <linux/io.h>
37897 #include <linux/of.h>
37898 +#include <asm/pgtable.h>
37899
37900 /* Clock Manager offsets */
37901 #define CLKMGR_CTRL 0x0
37902 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37903 streq(clk_name, "periph_pll") ||
37904 streq(clk_name, "sdram_pll")) {
37905 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37906 - clk_pll_ops.enable = clk_gate_ops.enable;
37907 - clk_pll_ops.disable = clk_gate_ops.disable;
37908 + pax_open_kernel();
37909 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37910 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37911 + pax_close_kernel();
37912 }
37913
37914 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37915 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37916 return parent_rate / div;
37917 }
37918
37919 -static struct clk_ops gateclk_ops = {
37920 +static clk_ops_no_const gateclk_ops __read_only = {
37921 .recalc_rate = socfpga_clk_recalc_rate,
37922 .get_parent = socfpga_clk_get_parent,
37923 .set_parent = socfpga_clk_set_parent,
37924 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37925 index 506fd23..01a593f 100644
37926 --- a/drivers/cpufreq/acpi-cpufreq.c
37927 +++ b/drivers/cpufreq/acpi-cpufreq.c
37928 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37929 return sprintf(buf, "%u\n", boost_enabled);
37930 }
37931
37932 -static struct global_attr global_boost = __ATTR(boost, 0644,
37933 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37934 show_global_boost,
37935 store_global_boost);
37936
37937 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37938 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37939 per_cpu(acfreq_data, cpu) = data;
37940
37941 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37942 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37943 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37944 + pax_open_kernel();
37945 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37946 + pax_close_kernel();
37947 + }
37948
37949 result = acpi_processor_register_performance(data->acpi_data, cpu);
37950 if (result)
37951 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37952 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37953 break;
37954 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37955 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37956 + pax_open_kernel();
37957 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37958 + pax_close_kernel();
37959 policy->cur = get_cur_freq_on_cpu(cpu);
37960 break;
37961 default:
37962 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37963 index 04548f7..457a342 100644
37964 --- a/drivers/cpufreq/cpufreq.c
37965 +++ b/drivers/cpufreq/cpufreq.c
37966 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37967 return NOTIFY_OK;
37968 }
37969
37970 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37971 +static struct notifier_block cpufreq_cpu_notifier = {
37972 .notifier_call = cpufreq_cpu_callback,
37973 };
37974
37975 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37976
37977 pr_debug("trying to register driver %s\n", driver_data->name);
37978
37979 - if (driver_data->setpolicy)
37980 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37981 + if (driver_data->setpolicy) {
37982 + pax_open_kernel();
37983 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37984 + pax_close_kernel();
37985 + }
37986
37987 write_lock_irqsave(&cpufreq_driver_lock, flags);
37988 if (cpufreq_driver) {
37989 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37990 index 0806c31..6a73276 100644
37991 --- a/drivers/cpufreq/cpufreq_governor.c
37992 +++ b/drivers/cpufreq/cpufreq_governor.c
37993 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37994 struct dbs_data *dbs_data;
37995 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37996 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37997 - struct od_ops *od_ops = NULL;
37998 + const struct od_ops *od_ops = NULL;
37999 struct od_dbs_tuners *od_tuners = NULL;
38000 struct cs_dbs_tuners *cs_tuners = NULL;
38001 struct cpu_dbs_common_info *cpu_cdbs;
38002 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
38003
38004 if ((cdata->governor == GOV_CONSERVATIVE) &&
38005 (!policy->governor->initialized)) {
38006 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
38007 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
38008
38009 cpufreq_register_notifier(cs_ops->notifier_block,
38010 CPUFREQ_TRANSITION_NOTIFIER);
38011 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
38012
38013 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
38014 (policy->governor->initialized == 1)) {
38015 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
38016 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
38017
38018 cpufreq_unregister_notifier(cs_ops->notifier_block,
38019 CPUFREQ_TRANSITION_NOTIFIER);
38020 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
38021 index 88cd39f..87f0393 100644
38022 --- a/drivers/cpufreq/cpufreq_governor.h
38023 +++ b/drivers/cpufreq/cpufreq_governor.h
38024 @@ -202,7 +202,7 @@ struct common_dbs_data {
38025 void (*exit)(struct dbs_data *dbs_data);
38026
38027 /* Governor specific ops, see below */
38028 - void *gov_ops;
38029 + const void *gov_ops;
38030 };
38031
38032 /* Governor Per policy data */
38033 @@ -222,7 +222,7 @@ struct od_ops {
38034 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
38035 unsigned int freq_next, unsigned int relation);
38036 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
38037 -};
38038 +} __no_const;
38039
38040 struct cs_ops {
38041 struct notifier_block *notifier_block;
38042 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
38043 index 32f26f6..feb657b 100644
38044 --- a/drivers/cpufreq/cpufreq_ondemand.c
38045 +++ b/drivers/cpufreq/cpufreq_ondemand.c
38046 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
38047
38048 define_get_cpu_dbs_routines(od_cpu_dbs_info);
38049
38050 -static struct od_ops od_ops = {
38051 +static struct od_ops od_ops __read_only = {
38052 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
38053 .powersave_bias_target = generic_powersave_bias_target,
38054 .freq_increase = dbs_freq_increase,
38055 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
38056 (struct cpufreq_policy *, unsigned int, unsigned int),
38057 unsigned int powersave_bias)
38058 {
38059 - od_ops.powersave_bias_target = f;
38060 + pax_open_kernel();
38061 + *(void **)&od_ops.powersave_bias_target = f;
38062 + pax_close_kernel();
38063 od_set_powersave_bias(powersave_bias);
38064 }
38065 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
38066
38067 void od_unregister_powersave_bias_handler(void)
38068 {
38069 - od_ops.powersave_bias_target = generic_powersave_bias_target;
38070 + pax_open_kernel();
38071 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
38072 + pax_close_kernel();
38073 od_set_powersave_bias(0);
38074 }
38075 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
38076 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
38077 index 4cf0d28..5830372 100644
38078 --- a/drivers/cpufreq/cpufreq_stats.c
38079 +++ b/drivers/cpufreq/cpufreq_stats.c
38080 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
38081 }
38082
38083 /* priority=1 so this will get called before cpufreq_remove_dev */
38084 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
38085 +static struct notifier_block cpufreq_stat_cpu_notifier = {
38086 .notifier_call = cpufreq_stat_cpu_callback,
38087 .priority = 1,
38088 };
38089 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
38090 index 2f0a2a6..93d728e 100644
38091 --- a/drivers/cpufreq/p4-clockmod.c
38092 +++ b/drivers/cpufreq/p4-clockmod.c
38093 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
38094 case 0x0F: /* Core Duo */
38095 case 0x16: /* Celeron Core */
38096 case 0x1C: /* Atom */
38097 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
38098 + pax_open_kernel();
38099 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
38100 + pax_close_kernel();
38101 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
38102 case 0x0D: /* Pentium M (Dothan) */
38103 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
38104 + pax_open_kernel();
38105 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
38106 + pax_close_kernel();
38107 /* fall through */
38108 case 0x09: /* Pentium M (Banias) */
38109 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
38110 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
38111
38112 /* on P-4s, the TSC runs with constant frequency independent whether
38113 * throttling is active or not. */
38114 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
38115 + pax_open_kernel();
38116 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
38117 + pax_close_kernel();
38118
38119 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
38120 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
38121 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
38122 index ac76b48..2445bc6 100644
38123 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
38124 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
38125 @@ -18,14 +18,12 @@
38126 #include <asm/head.h>
38127 #include <asm/timer.h>
38128
38129 -static struct cpufreq_driver *cpufreq_us3_driver;
38130 -
38131 struct us3_freq_percpu_info {
38132 struct cpufreq_frequency_table table[4];
38133 };
38134
38135 /* Indexed by cpu number. */
38136 -static struct us3_freq_percpu_info *us3_freq_table;
38137 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
38138
38139 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
38140 * in the Safari config register.
38141 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
38142
38143 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
38144 {
38145 - if (cpufreq_us3_driver)
38146 - us3_set_cpu_divider_index(policy, 0);
38147 + us3_set_cpu_divider_index(policy->cpu, 0);
38148
38149 return 0;
38150 }
38151
38152 +static int __init us3_freq_init(void);
38153 +static void __exit us3_freq_exit(void);
38154 +
38155 +static struct cpufreq_driver cpufreq_us3_driver = {
38156 + .init = us3_freq_cpu_init,
38157 + .verify = us3_freq_verify,
38158 + .target = us3_freq_target,
38159 + .get = us3_freq_get,
38160 + .exit = us3_freq_cpu_exit,
38161 + .owner = THIS_MODULE,
38162 + .name = "UltraSPARC-III",
38163 +
38164 +};
38165 +
38166 static int __init us3_freq_init(void)
38167 {
38168 unsigned long manuf, impl, ver;
38169 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
38170 (impl == CHEETAH_IMPL ||
38171 impl == CHEETAH_PLUS_IMPL ||
38172 impl == JAGUAR_IMPL ||
38173 - impl == PANTHER_IMPL)) {
38174 - struct cpufreq_driver *driver;
38175 -
38176 - ret = -ENOMEM;
38177 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
38178 - if (!driver)
38179 - goto err_out;
38180 -
38181 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
38182 - GFP_KERNEL);
38183 - if (!us3_freq_table)
38184 - goto err_out;
38185 -
38186 - driver->init = us3_freq_cpu_init;
38187 - driver->verify = us3_freq_verify;
38188 - driver->target = us3_freq_target;
38189 - driver->get = us3_freq_get;
38190 - driver->exit = us3_freq_cpu_exit;
38191 - strcpy(driver->name, "UltraSPARC-III");
38192 -
38193 - cpufreq_us3_driver = driver;
38194 - ret = cpufreq_register_driver(driver);
38195 - if (ret)
38196 - goto err_out;
38197 -
38198 - return 0;
38199 -
38200 -err_out:
38201 - if (driver) {
38202 - kfree(driver);
38203 - cpufreq_us3_driver = NULL;
38204 - }
38205 - kfree(us3_freq_table);
38206 - us3_freq_table = NULL;
38207 - return ret;
38208 - }
38209 + impl == PANTHER_IMPL))
38210 + return cpufreq_register_driver(&cpufreq_us3_driver);
38211
38212 return -ENODEV;
38213 }
38214
38215 static void __exit us3_freq_exit(void)
38216 {
38217 - if (cpufreq_us3_driver) {
38218 - cpufreq_unregister_driver(cpufreq_us3_driver);
38219 - kfree(cpufreq_us3_driver);
38220 - cpufreq_us3_driver = NULL;
38221 - kfree(us3_freq_table);
38222 - us3_freq_table = NULL;
38223 - }
38224 + cpufreq_unregister_driver(&cpufreq_us3_driver);
38225 }
38226
38227 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
38228 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
38229 index f897d51..15da295 100644
38230 --- a/drivers/cpufreq/speedstep-centrino.c
38231 +++ b/drivers/cpufreq/speedstep-centrino.c
38232 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
38233 !cpu_has(cpu, X86_FEATURE_EST))
38234 return -ENODEV;
38235
38236 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
38237 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38238 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
38239 + pax_open_kernel();
38240 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38241 + pax_close_kernel();
38242 + }
38243
38244 if (policy->cpu != 0)
38245 return -ENODEV;
38246 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
38247 index 22c07fb..9dff5ac 100644
38248 --- a/drivers/cpuidle/cpuidle.c
38249 +++ b/drivers/cpuidle/cpuidle.c
38250 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
38251
38252 static void poll_idle_init(struct cpuidle_driver *drv)
38253 {
38254 - struct cpuidle_state *state = &drv->states[0];
38255 + cpuidle_state_no_const *state = &drv->states[0];
38256
38257 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
38258 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
38259 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
38260 index ea2f8e7..70ac501 100644
38261 --- a/drivers/cpuidle/governor.c
38262 +++ b/drivers/cpuidle/governor.c
38263 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
38264 mutex_lock(&cpuidle_lock);
38265 if (__cpuidle_find_governor(gov->name) == NULL) {
38266 ret = 0;
38267 - list_add_tail(&gov->governor_list, &cpuidle_governors);
38268 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
38269 if (!cpuidle_curr_governor ||
38270 cpuidle_curr_governor->rating < gov->rating)
38271 cpuidle_switch_governor(gov);
38272 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
38273 new_gov = cpuidle_replace_governor(gov->rating);
38274 cpuidle_switch_governor(new_gov);
38275 }
38276 - list_del(&gov->governor_list);
38277 + pax_list_del((struct list_head *)&gov->governor_list);
38278 mutex_unlock(&cpuidle_lock);
38279 }
38280
38281 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
38282 index 8739cc0..dc859d0 100644
38283 --- a/drivers/cpuidle/sysfs.c
38284 +++ b/drivers/cpuidle/sysfs.c
38285 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
38286 NULL
38287 };
38288
38289 -static struct attribute_group cpuidle_attr_group = {
38290 +static attribute_group_no_const cpuidle_attr_group = {
38291 .attrs = cpuidle_default_attrs,
38292 .name = "cpuidle",
38293 };
38294 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
38295 index 12fea3e..1e28f47 100644
38296 --- a/drivers/crypto/hifn_795x.c
38297 +++ b/drivers/crypto/hifn_795x.c
38298 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
38299 MODULE_PARM_DESC(hifn_pll_ref,
38300 "PLL reference clock (pci[freq] or ext[freq], default ext)");
38301
38302 -static atomic_t hifn_dev_number;
38303 +static atomic_unchecked_t hifn_dev_number;
38304
38305 #define ACRYPTO_OP_DECRYPT 0
38306 #define ACRYPTO_OP_ENCRYPT 1
38307 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
38308 goto err_out_disable_pci_device;
38309
38310 snprintf(name, sizeof(name), "hifn%d",
38311 - atomic_inc_return(&hifn_dev_number)-1);
38312 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
38313
38314 err = pci_request_regions(pdev, name);
38315 if (err)
38316 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
38317 index c99c00d..990a4b2 100644
38318 --- a/drivers/devfreq/devfreq.c
38319 +++ b/drivers/devfreq/devfreq.c
38320 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
38321 goto err_out;
38322 }
38323
38324 - list_add(&governor->node, &devfreq_governor_list);
38325 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
38326
38327 list_for_each_entry(devfreq, &devfreq_list, node) {
38328 int ret = 0;
38329 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
38330 }
38331 }
38332
38333 - list_del(&governor->node);
38334 + pax_list_del((struct list_head *)&governor->node);
38335 err_out:
38336 mutex_unlock(&devfreq_list_lock);
38337
38338 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
38339 index 1069e88..dfcd642 100644
38340 --- a/drivers/dma/sh/shdmac.c
38341 +++ b/drivers/dma/sh/shdmac.c
38342 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
38343 return ret;
38344 }
38345
38346 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
38347 +static struct notifier_block sh_dmae_nmi_notifier = {
38348 .notifier_call = sh_dmae_nmi_handler,
38349
38350 /* Run before NMI debug handler and KGDB */
38351 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
38352 index 211021d..201d47f 100644
38353 --- a/drivers/edac/edac_device.c
38354 +++ b/drivers/edac/edac_device.c
38355 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
38356 */
38357 int edac_device_alloc_index(void)
38358 {
38359 - static atomic_t device_indexes = ATOMIC_INIT(0);
38360 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
38361
38362 - return atomic_inc_return(&device_indexes) - 1;
38363 + return atomic_inc_return_unchecked(&device_indexes) - 1;
38364 }
38365 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
38366
38367 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
38368 index 9f7e0e60..348c875 100644
38369 --- a/drivers/edac/edac_mc_sysfs.c
38370 +++ b/drivers/edac/edac_mc_sysfs.c
38371 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
38372 struct dev_ch_attribute {
38373 struct device_attribute attr;
38374 int channel;
38375 -};
38376 +} __do_const;
38377
38378 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
38379 struct dev_ch_attribute dev_attr_legacy_##_name = \
38380 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
38381 }
38382
38383 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
38384 + pax_open_kernel();
38385 if (mci->get_sdram_scrub_rate) {
38386 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38387 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38388 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38389 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38390 }
38391 if (mci->set_sdram_scrub_rate) {
38392 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38393 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38394 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38395 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38396 }
38397 + pax_close_kernel();
38398 err = device_create_file(&mci->dev,
38399 &dev_attr_sdram_scrub_rate);
38400 if (err) {
38401 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
38402 index dd370f9..0281629 100644
38403 --- a/drivers/edac/edac_pci.c
38404 +++ b/drivers/edac/edac_pci.c
38405 @@ -29,7 +29,7 @@
38406
38407 static DEFINE_MUTEX(edac_pci_ctls_mutex);
38408 static LIST_HEAD(edac_pci_list);
38409 -static atomic_t pci_indexes = ATOMIC_INIT(0);
38410 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
38411
38412 /*
38413 * edac_pci_alloc_ctl_info
38414 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
38415 */
38416 int edac_pci_alloc_index(void)
38417 {
38418 - return atomic_inc_return(&pci_indexes) - 1;
38419 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
38420 }
38421 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
38422
38423 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
38424 index e8658e4..22746d6 100644
38425 --- a/drivers/edac/edac_pci_sysfs.c
38426 +++ b/drivers/edac/edac_pci_sysfs.c
38427 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
38428 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
38429 static int edac_pci_poll_msec = 1000; /* one second workq period */
38430
38431 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
38432 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
38433 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
38434 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
38435
38436 static struct kobject *edac_pci_top_main_kobj;
38437 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
38438 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
38439 void *value;
38440 ssize_t(*show) (void *, char *);
38441 ssize_t(*store) (void *, const char *, size_t);
38442 -};
38443 +} __do_const;
38444
38445 /* Set of show/store abstract level functions for PCI Parity object */
38446 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
38447 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38448 edac_printk(KERN_CRIT, EDAC_PCI,
38449 "Signaled System Error on %s\n",
38450 pci_name(dev));
38451 - atomic_inc(&pci_nonparity_count);
38452 + atomic_inc_unchecked(&pci_nonparity_count);
38453 }
38454
38455 if (status & (PCI_STATUS_PARITY)) {
38456 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38457 "Master Data Parity Error on %s\n",
38458 pci_name(dev));
38459
38460 - atomic_inc(&pci_parity_count);
38461 + atomic_inc_unchecked(&pci_parity_count);
38462 }
38463
38464 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38465 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38466 "Detected Parity Error on %s\n",
38467 pci_name(dev));
38468
38469 - atomic_inc(&pci_parity_count);
38470 + atomic_inc_unchecked(&pci_parity_count);
38471 }
38472 }
38473
38474 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38475 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
38476 "Signaled System Error on %s\n",
38477 pci_name(dev));
38478 - atomic_inc(&pci_nonparity_count);
38479 + atomic_inc_unchecked(&pci_nonparity_count);
38480 }
38481
38482 if (status & (PCI_STATUS_PARITY)) {
38483 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38484 "Master Data Parity Error on "
38485 "%s\n", pci_name(dev));
38486
38487 - atomic_inc(&pci_parity_count);
38488 + atomic_inc_unchecked(&pci_parity_count);
38489 }
38490
38491 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38492 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38493 "Detected Parity Error on %s\n",
38494 pci_name(dev));
38495
38496 - atomic_inc(&pci_parity_count);
38497 + atomic_inc_unchecked(&pci_parity_count);
38498 }
38499 }
38500 }
38501 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
38502 if (!check_pci_errors)
38503 return;
38504
38505 - before_count = atomic_read(&pci_parity_count);
38506 + before_count = atomic_read_unchecked(&pci_parity_count);
38507
38508 /* scan all PCI devices looking for a Parity Error on devices and
38509 * bridges.
38510 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
38511 /* Only if operator has selected panic on PCI Error */
38512 if (edac_pci_get_panic_on_pe()) {
38513 /* If the count is different 'after' from 'before' */
38514 - if (before_count != atomic_read(&pci_parity_count))
38515 + if (before_count != atomic_read_unchecked(&pci_parity_count))
38516 panic("EDAC: PCI Parity Error");
38517 }
38518 }
38519 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
38520 index 51b7e3a..aa8a3e8 100644
38521 --- a/drivers/edac/mce_amd.h
38522 +++ b/drivers/edac/mce_amd.h
38523 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
38524 bool (*mc0_mce)(u16, u8);
38525 bool (*mc1_mce)(u16, u8);
38526 bool (*mc2_mce)(u16, u8);
38527 -};
38528 +} __no_const;
38529
38530 void amd_report_gart_errors(bool);
38531 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
38532 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
38533 index 57ea7f4..af06b76 100644
38534 --- a/drivers/firewire/core-card.c
38535 +++ b/drivers/firewire/core-card.c
38536 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
38537 const struct fw_card_driver *driver,
38538 struct device *device)
38539 {
38540 - static atomic_t index = ATOMIC_INIT(-1);
38541 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
38542
38543 - card->index = atomic_inc_return(&index);
38544 + card->index = atomic_inc_return_unchecked(&index);
38545 card->driver = driver;
38546 card->device = device;
38547 card->current_tlabel = 0;
38548 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
38549
38550 void fw_core_remove_card(struct fw_card *card)
38551 {
38552 - struct fw_card_driver dummy_driver = dummy_driver_template;
38553 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
38554
38555 card->driver->update_phy_reg(card, 4,
38556 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
38557 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
38558 index de4aa40..49ab1f2 100644
38559 --- a/drivers/firewire/core-device.c
38560 +++ b/drivers/firewire/core-device.c
38561 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
38562 struct config_rom_attribute {
38563 struct device_attribute attr;
38564 u32 key;
38565 -};
38566 +} __do_const;
38567
38568 static ssize_t show_immediate(struct device *dev,
38569 struct device_attribute *dattr, char *buf)
38570 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
38571 index e5af0e3..d318058 100644
38572 --- a/drivers/firewire/core-transaction.c
38573 +++ b/drivers/firewire/core-transaction.c
38574 @@ -38,6 +38,7 @@
38575 #include <linux/timer.h>
38576 #include <linux/types.h>
38577 #include <linux/workqueue.h>
38578 +#include <linux/sched.h>
38579
38580 #include <asm/byteorder.h>
38581
38582 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
38583 index 515a42c..5ecf3ba 100644
38584 --- a/drivers/firewire/core.h
38585 +++ b/drivers/firewire/core.h
38586 @@ -111,6 +111,7 @@ struct fw_card_driver {
38587
38588 int (*stop_iso)(struct fw_iso_context *ctx);
38589 };
38590 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
38591
38592 void fw_card_initialize(struct fw_card *card,
38593 const struct fw_card_driver *driver, struct device *device);
38594 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38595 index 94a58a0..f5eba42 100644
38596 --- a/drivers/firmware/dmi-id.c
38597 +++ b/drivers/firmware/dmi-id.c
38598 @@ -16,7 +16,7 @@
38599 struct dmi_device_attribute{
38600 struct device_attribute dev_attr;
38601 int field;
38602 -};
38603 +} __do_const;
38604 #define to_dmi_dev_attr(_dev_attr) \
38605 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38606
38607 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38608 index fa0affb..aa448eb 100644
38609 --- a/drivers/firmware/dmi_scan.c
38610 +++ b/drivers/firmware/dmi_scan.c
38611 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38612 if (buf == NULL)
38613 return -1;
38614
38615 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38616 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38617
38618 iounmap(buf);
38619 return 0;
38620 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38621 index 5145fa3..0d3babd 100644
38622 --- a/drivers/firmware/efi/efi.c
38623 +++ b/drivers/firmware/efi/efi.c
38624 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38625 };
38626
38627 static struct efivars generic_efivars;
38628 -static struct efivar_operations generic_ops;
38629 +static efivar_operations_no_const generic_ops __read_only;
38630
38631 static int generic_ops_register(void)
38632 {
38633 - generic_ops.get_variable = efi.get_variable;
38634 - generic_ops.set_variable = efi.set_variable;
38635 - generic_ops.get_next_variable = efi.get_next_variable;
38636 - generic_ops.query_variable_store = efi_query_variable_store;
38637 + pax_open_kernel();
38638 + *(void **)&generic_ops.get_variable = efi.get_variable;
38639 + *(void **)&generic_ops.set_variable = efi.set_variable;
38640 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38641 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38642 + pax_close_kernel();
38643
38644 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38645 }
38646 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38647 index 8c5a61a..cf07bd0 100644
38648 --- a/drivers/firmware/efi/efivars.c
38649 +++ b/drivers/firmware/efi/efivars.c
38650 @@ -456,7 +456,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38651 static int
38652 create_efivars_bin_attributes(void)
38653 {
38654 - struct bin_attribute *attr;
38655 + bin_attribute_no_const *attr;
38656 int error;
38657
38658 /* new_var */
38659 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38660 index 2a90ba6..07f3733 100644
38661 --- a/drivers/firmware/google/memconsole.c
38662 +++ b/drivers/firmware/google/memconsole.c
38663 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38664 if (!found_memconsole())
38665 return -ENODEV;
38666
38667 - memconsole_bin_attr.size = memconsole_length;
38668 + pax_open_kernel();
38669 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38670 + pax_close_kernel();
38671
38672 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38673
38674 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38675 index 814addb..0937d7f 100644
38676 --- a/drivers/gpio/gpio-ich.c
38677 +++ b/drivers/gpio/gpio-ich.c
38678 @@ -71,7 +71,7 @@ struct ichx_desc {
38679 /* Some chipsets have quirks, let these use their own request/get */
38680 int (*request)(struct gpio_chip *chip, unsigned offset);
38681 int (*get)(struct gpio_chip *chip, unsigned offset);
38682 -};
38683 +} __do_const;
38684
38685 static struct {
38686 spinlock_t lock;
38687 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38688 index 9902732..64b62dd 100644
38689 --- a/drivers/gpio/gpio-vr41xx.c
38690 +++ b/drivers/gpio/gpio-vr41xx.c
38691 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38692 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38693 maskl, pendl, maskh, pendh);
38694
38695 - atomic_inc(&irq_err_count);
38696 + atomic_inc_unchecked(&irq_err_count);
38697
38698 return -EINVAL;
38699 }
38700 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38701 index c722c3b..2ec6040 100644
38702 --- a/drivers/gpu/drm/drm_crtc_helper.c
38703 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38704 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38705 struct drm_crtc *tmp;
38706 int crtc_mask = 1;
38707
38708 - WARN(!crtc, "checking null crtc?\n");
38709 + BUG_ON(!crtc);
38710
38711 dev = crtc->dev;
38712
38713 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38714 index fe58d08..07bc38e 100644
38715 --- a/drivers/gpu/drm/drm_drv.c
38716 +++ b/drivers/gpu/drm/drm_drv.c
38717 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
38718 atomic_set(&dev->vma_count, 0);
38719
38720 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38721 - atomic_set(&dev->counts[i], 0);
38722 + atomic_set_unchecked(&dev->counts[i], 0);
38723
38724 dev->sigdata.lock = NULL;
38725
38726 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
38727 /**
38728 * Copy and IOCTL return string to user space
38729 */
38730 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38731 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38732 {
38733 int len;
38734
38735 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
38736 struct drm_file *file_priv = filp->private_data;
38737 struct drm_device *dev;
38738 const struct drm_ioctl_desc *ioctl = NULL;
38739 - drm_ioctl_t *func;
38740 + drm_ioctl_no_const_t func;
38741 unsigned int nr = DRM_IOCTL_NR(cmd);
38742 int retcode = -EINVAL;
38743 char stack_kdata[128];
38744 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
38745 return -ENODEV;
38746
38747 atomic_inc(&dev->ioctl_count);
38748 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38749 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38750 ++file_priv->ioctl_count;
38751
38752 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38753 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38754 index 3f84277..c627c54 100644
38755 --- a/drivers/gpu/drm/drm_fops.c
38756 +++ b/drivers/gpu/drm/drm_fops.c
38757 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
38758 if (drm_device_is_unplugged(dev))
38759 return -ENODEV;
38760
38761 - if (!dev->open_count++)
38762 + if (local_inc_return(&dev->open_count) == 1)
38763 need_setup = 1;
38764 mutex_lock(&dev->struct_mutex);
38765 old_imapping = inode->i_mapping;
38766 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38767 retcode = drm_open_helper(inode, filp, dev);
38768 if (retcode)
38769 goto err_undo;
38770 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38771 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38772 if (need_setup) {
38773 retcode = drm_setup(dev);
38774 if (retcode)
38775 @@ -128,7 +128,7 @@ err_undo:
38776 iput(container_of(dev->dev_mapping, struct inode, i_data));
38777 dev->dev_mapping = old_mapping;
38778 mutex_unlock(&dev->struct_mutex);
38779 - dev->open_count--;
38780 + local_dec(&dev->open_count);
38781 return retcode;
38782 }
38783 EXPORT_SYMBOL(drm_open);
38784 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38785
38786 mutex_lock(&drm_global_mutex);
38787
38788 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38789 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38790
38791 if (dev->driver->preclose)
38792 dev->driver->preclose(dev, file_priv);
38793 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38794 * Begin inline drm_release
38795 */
38796
38797 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38798 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38799 task_pid_nr(current),
38800 (long)old_encode_dev(file_priv->minor->device),
38801 - dev->open_count);
38802 + local_read(&dev->open_count));
38803
38804 /* Release any auth tokens that might point to this file_priv,
38805 (do that under the drm_global_mutex) */
38806 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38807 * End inline drm_release
38808 */
38809
38810 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38811 - if (!--dev->open_count) {
38812 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38813 + if (local_dec_and_test(&dev->open_count)) {
38814 if (atomic_read(&dev->ioctl_count)) {
38815 DRM_ERROR("Device busy: %d\n",
38816 atomic_read(&dev->ioctl_count));
38817 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38818 index f731116..629842c 100644
38819 --- a/drivers/gpu/drm/drm_global.c
38820 +++ b/drivers/gpu/drm/drm_global.c
38821 @@ -36,7 +36,7 @@
38822 struct drm_global_item {
38823 struct mutex mutex;
38824 void *object;
38825 - int refcount;
38826 + atomic_t refcount;
38827 };
38828
38829 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38830 @@ -49,7 +49,7 @@ void drm_global_init(void)
38831 struct drm_global_item *item = &glob[i];
38832 mutex_init(&item->mutex);
38833 item->object = NULL;
38834 - item->refcount = 0;
38835 + atomic_set(&item->refcount, 0);
38836 }
38837 }
38838
38839 @@ -59,7 +59,7 @@ void drm_global_release(void)
38840 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38841 struct drm_global_item *item = &glob[i];
38842 BUG_ON(item->object != NULL);
38843 - BUG_ON(item->refcount != 0);
38844 + BUG_ON(atomic_read(&item->refcount) != 0);
38845 }
38846 }
38847
38848 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38849 void *object;
38850
38851 mutex_lock(&item->mutex);
38852 - if (item->refcount == 0) {
38853 + if (atomic_read(&item->refcount) == 0) {
38854 item->object = kzalloc(ref->size, GFP_KERNEL);
38855 if (unlikely(item->object == NULL)) {
38856 ret = -ENOMEM;
38857 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38858 goto out_err;
38859
38860 }
38861 - ++item->refcount;
38862 + atomic_inc(&item->refcount);
38863 ref->object = item->object;
38864 object = item->object;
38865 mutex_unlock(&item->mutex);
38866 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38867 struct drm_global_item *item = &glob[ref->global_type];
38868
38869 mutex_lock(&item->mutex);
38870 - BUG_ON(item->refcount == 0);
38871 + BUG_ON(atomic_read(&item->refcount) == 0);
38872 BUG_ON(ref->object != item->object);
38873 - if (--item->refcount == 0) {
38874 + if (atomic_dec_and_test(&item->refcount)) {
38875 ref->release(ref);
38876 item->object = NULL;
38877 }
38878 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38879 index 5329832..b503f49 100644
38880 --- a/drivers/gpu/drm/drm_info.c
38881 +++ b/drivers/gpu/drm/drm_info.c
38882 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38883 struct drm_local_map *map;
38884 struct drm_map_list *r_list;
38885
38886 - /* Hardcoded from _DRM_FRAME_BUFFER,
38887 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38888 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38889 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38890 + static const char * const types[] = {
38891 + [_DRM_FRAME_BUFFER] = "FB",
38892 + [_DRM_REGISTERS] = "REG",
38893 + [_DRM_SHM] = "SHM",
38894 + [_DRM_AGP] = "AGP",
38895 + [_DRM_SCATTER_GATHER] = "SG",
38896 + [_DRM_CONSISTENT] = "PCI",
38897 + [_DRM_GEM] = "GEM" };
38898 const char *type;
38899 int i;
38900
38901 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38902 map = r_list->map;
38903 if (!map)
38904 continue;
38905 - if (map->type < 0 || map->type > 5)
38906 + if (map->type >= ARRAY_SIZE(types))
38907 type = "??";
38908 else
38909 type = types[map->type];
38910 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38911 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38912 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38913 vma->vm_flags & VM_IO ? 'i' : '-',
38914 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38915 + 0);
38916 +#else
38917 vma->vm_pgoff);
38918 +#endif
38919
38920 #if defined(__i386__)
38921 pgprot = pgprot_val(vma->vm_page_prot);
38922 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38923 index 2f4c434..dd12cd2 100644
38924 --- a/drivers/gpu/drm/drm_ioc32.c
38925 +++ b/drivers/gpu/drm/drm_ioc32.c
38926 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38927 request = compat_alloc_user_space(nbytes);
38928 if (!access_ok(VERIFY_WRITE, request, nbytes))
38929 return -EFAULT;
38930 - list = (struct drm_buf_desc *) (request + 1);
38931 + list = (struct drm_buf_desc __user *) (request + 1);
38932
38933 if (__put_user(count, &request->count)
38934 || __put_user(list, &request->list))
38935 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38936 request = compat_alloc_user_space(nbytes);
38937 if (!access_ok(VERIFY_WRITE, request, nbytes))
38938 return -EFAULT;
38939 - list = (struct drm_buf_pub *) (request + 1);
38940 + list = (struct drm_buf_pub __user *) (request + 1);
38941
38942 if (__put_user(count, &request->count)
38943 || __put_user(list, &request->list))
38944 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38945 return 0;
38946 }
38947
38948 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38949 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38950 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38951 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38952 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38953 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38954 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38955 {
38956 unsigned int nr = DRM_IOCTL_NR(cmd);
38957 - drm_ioctl_compat_t *fn;
38958 int ret;
38959
38960 /* Assume that ioctls without an explicit compat routine will just
38961 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38962 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38963 return drm_ioctl(filp, cmd, arg);
38964
38965 - fn = drm_compat_ioctls[nr];
38966 -
38967 - if (fn != NULL)
38968 - ret = (*fn) (filp, cmd, arg);
38969 + if (drm_compat_ioctls[nr] != NULL)
38970 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38971 else
38972 ret = drm_ioctl(filp, cmd, arg);
38973
38974 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38975 index d752c96..fe08455 100644
38976 --- a/drivers/gpu/drm/drm_lock.c
38977 +++ b/drivers/gpu/drm/drm_lock.c
38978 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38979 if (drm_lock_take(&master->lock, lock->context)) {
38980 master->lock.file_priv = file_priv;
38981 master->lock.lock_time = jiffies;
38982 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38983 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38984 break; /* Got lock */
38985 }
38986
38987 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38988 return -EINVAL;
38989 }
38990
38991 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38992 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38993
38994 if (drm_lock_free(&master->lock, lock->context)) {
38995 /* FIXME: Should really bail out here. */
38996 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38997 index 39d8645..59e06fa 100644
38998 --- a/drivers/gpu/drm/drm_stub.c
38999 +++ b/drivers/gpu/drm/drm_stub.c
39000 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
39001
39002 drm_device_set_unplugged(dev);
39003
39004 - if (dev->open_count == 0) {
39005 + if (local_read(&dev->open_count) == 0) {
39006 drm_put_dev(dev);
39007 }
39008 mutex_unlock(&drm_global_mutex);
39009 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
39010 index 2290b3b..22056a1 100644
39011 --- a/drivers/gpu/drm/drm_sysfs.c
39012 +++ b/drivers/gpu/drm/drm_sysfs.c
39013 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
39014 int drm_sysfs_device_add(struct drm_minor *minor)
39015 {
39016 int err;
39017 - char *minor_str;
39018 + const char *minor_str;
39019
39020 minor->kdev.parent = minor->dev->dev;
39021
39022 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
39023 index ab1892eb..d7009ca 100644
39024 --- a/drivers/gpu/drm/i810/i810_dma.c
39025 +++ b/drivers/gpu/drm/i810/i810_dma.c
39026 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
39027 dma->buflist[vertex->idx],
39028 vertex->discard, vertex->used);
39029
39030 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
39031 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
39032 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
39033 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
39034 sarea_priv->last_enqueue = dev_priv->counter - 1;
39035 sarea_priv->last_dispatch = (int)hw_status[5];
39036
39037 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
39038 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
39039 mc->last_render);
39040
39041 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
39042 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
39043 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
39044 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
39045 sarea_priv->last_enqueue = dev_priv->counter - 1;
39046 sarea_priv->last_dispatch = (int)hw_status[5];
39047
39048 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
39049 index d4d16ed..8fb0b51 100644
39050 --- a/drivers/gpu/drm/i810/i810_drv.h
39051 +++ b/drivers/gpu/drm/i810/i810_drv.h
39052 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
39053 int page_flipping;
39054
39055 wait_queue_head_t irq_queue;
39056 - atomic_t irq_received;
39057 - atomic_t irq_emitted;
39058 + atomic_unchecked_t irq_received;
39059 + atomic_unchecked_t irq_emitted;
39060
39061 int front_offset;
39062 } drm_i810_private_t;
39063 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
39064 index a6f4cb5..6b2beb2 100644
39065 --- a/drivers/gpu/drm/i915/i915_debugfs.c
39066 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
39067 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
39068 I915_READ(GTIMR));
39069 }
39070 seq_printf(m, "Interrupts received: %d\n",
39071 - atomic_read(&dev_priv->irq_received));
39072 + atomic_read_unchecked(&dev_priv->irq_received));
39073 for_each_ring(ring, dev_priv, i) {
39074 if (IS_GEN6(dev) || IS_GEN7(dev)) {
39075 seq_printf(m,
39076 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
39077 index 5a25f24..5af2004 100644
39078 --- a/drivers/gpu/drm/i915/i915_dma.c
39079 +++ b/drivers/gpu/drm/i915/i915_dma.c
39080 @@ -1271,7 +1271,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
39081 bool can_switch;
39082
39083 spin_lock(&dev->count_lock);
39084 - can_switch = (dev->open_count == 0);
39085 + can_switch = (local_read(&dev->open_count) == 0);
39086 spin_unlock(&dev->count_lock);
39087 return can_switch;
39088 }
39089 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
39090 index ab0f2c0..53c1bda 100644
39091 --- a/drivers/gpu/drm/i915/i915_drv.h
39092 +++ b/drivers/gpu/drm/i915/i915_drv.h
39093 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
39094 drm_dma_handle_t *status_page_dmah;
39095 struct resource mch_res;
39096
39097 - atomic_t irq_received;
39098 + atomic_unchecked_t irq_received;
39099
39100 /* protects the irq masks */
39101 spinlock_t irq_lock;
39102 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
39103 index bf34577..3fd2ffa 100644
39104 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
39105 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
39106 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
39107
39108 static int
39109 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
39110 - int count)
39111 + unsigned int count)
39112 {
39113 - int i;
39114 + unsigned int i;
39115 int relocs_total = 0;
39116 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
39117
39118 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
39119 index 3c59584..500f2e9 100644
39120 --- a/drivers/gpu/drm/i915/i915_ioc32.c
39121 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
39122 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
39123 (unsigned long)request);
39124 }
39125
39126 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
39127 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
39128 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
39129 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
39130 [DRM_I915_GETPARAM] = compat_i915_getparam,
39131 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
39132 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39133 {
39134 unsigned int nr = DRM_IOCTL_NR(cmd);
39135 - drm_ioctl_compat_t *fn = NULL;
39136 int ret;
39137
39138 if (nr < DRM_COMMAND_BASE)
39139 return drm_compat_ioctl(filp, cmd, arg);
39140
39141 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
39142 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
39143 -
39144 - if (fn != NULL)
39145 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
39146 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
39147 ret = (*fn) (filp, cmd, arg);
39148 - else
39149 + } else
39150 ret = drm_ioctl(filp, cmd, arg);
39151
39152 return ret;
39153 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
39154 index 4b91228..590c643 100644
39155 --- a/drivers/gpu/drm/i915/i915_irq.c
39156 +++ b/drivers/gpu/drm/i915/i915_irq.c
39157 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
39158 int pipe;
39159 u32 pipe_stats[I915_MAX_PIPES];
39160
39161 - atomic_inc(&dev_priv->irq_received);
39162 + atomic_inc_unchecked(&dev_priv->irq_received);
39163
39164 while (true) {
39165 iir = I915_READ(VLV_IIR);
39166 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
39167 irqreturn_t ret = IRQ_NONE;
39168 bool err_int_reenable = false;
39169
39170 - atomic_inc(&dev_priv->irq_received);
39171 + atomic_inc_unchecked(&dev_priv->irq_received);
39172
39173 /* We get interrupts on unclaimed registers, so check for this before we
39174 * do any I915_{READ,WRITE}. */
39175 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
39176 {
39177 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39178
39179 - atomic_set(&dev_priv->irq_received, 0);
39180 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39181
39182 I915_WRITE(HWSTAM, 0xeffe);
39183
39184 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
39185 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39186 int pipe;
39187
39188 - atomic_set(&dev_priv->irq_received, 0);
39189 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39190
39191 /* VLV magic */
39192 I915_WRITE(VLV_IMR, 0);
39193 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
39194 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39195 int pipe;
39196
39197 - atomic_set(&dev_priv->irq_received, 0);
39198 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39199
39200 for_each_pipe(pipe)
39201 I915_WRITE(PIPESTAT(pipe), 0);
39202 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
39203 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39204 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39205
39206 - atomic_inc(&dev_priv->irq_received);
39207 + atomic_inc_unchecked(&dev_priv->irq_received);
39208
39209 iir = I915_READ16(IIR);
39210 if (iir == 0)
39211 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
39212 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39213 int pipe;
39214
39215 - atomic_set(&dev_priv->irq_received, 0);
39216 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39217
39218 if (I915_HAS_HOTPLUG(dev)) {
39219 I915_WRITE(PORT_HOTPLUG_EN, 0);
39220 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
39221 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39222 int pipe, ret = IRQ_NONE;
39223
39224 - atomic_inc(&dev_priv->irq_received);
39225 + atomic_inc_unchecked(&dev_priv->irq_received);
39226
39227 iir = I915_READ(IIR);
39228 do {
39229 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
39230 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39231 int pipe;
39232
39233 - atomic_set(&dev_priv->irq_received, 0);
39234 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39235
39236 I915_WRITE(PORT_HOTPLUG_EN, 0);
39237 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
39238 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
39239 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39240 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39241
39242 - atomic_inc(&dev_priv->irq_received);
39243 + atomic_inc_unchecked(&dev_priv->irq_received);
39244
39245 iir = I915_READ(IIR);
39246
39247 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
39248 index aad6f7b..dcc91447 100644
39249 --- a/drivers/gpu/drm/i915/intel_display.c
39250 +++ b/drivers/gpu/drm/i915/intel_display.c
39251 @@ -10019,13 +10019,13 @@ struct intel_quirk {
39252 int subsystem_vendor;
39253 int subsystem_device;
39254 void (*hook)(struct drm_device *dev);
39255 -};
39256 +} __do_const;
39257
39258 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
39259 struct intel_dmi_quirk {
39260 void (*hook)(struct drm_device *dev);
39261 const struct dmi_system_id (*dmi_id_list)[];
39262 -};
39263 +} __do_const;
39264
39265 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39266 {
39267 @@ -10033,18 +10033,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39268 return 1;
39269 }
39270
39271 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39272 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
39273 {
39274 - .dmi_id_list = &(const struct dmi_system_id[]) {
39275 - {
39276 - .callback = intel_dmi_reverse_brightness,
39277 - .ident = "NCR Corporation",
39278 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39279 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
39280 - },
39281 - },
39282 - { } /* terminating entry */
39283 + .callback = intel_dmi_reverse_brightness,
39284 + .ident = "NCR Corporation",
39285 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39286 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
39287 },
39288 + },
39289 + { } /* terminating entry */
39290 +};
39291 +
39292 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39293 + {
39294 + .dmi_id_list = &intel_dmi_quirks_table,
39295 .hook = quirk_invert_brightness,
39296 },
39297 };
39298 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
39299 index ca4bc54..ee598a2 100644
39300 --- a/drivers/gpu/drm/mga/mga_drv.h
39301 +++ b/drivers/gpu/drm/mga/mga_drv.h
39302 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
39303 u32 clear_cmd;
39304 u32 maccess;
39305
39306 - atomic_t vbl_received; /**< Number of vblanks received. */
39307 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
39308 wait_queue_head_t fence_queue;
39309 - atomic_t last_fence_retired;
39310 + atomic_unchecked_t last_fence_retired;
39311 u32 next_fence_to_post;
39312
39313 unsigned int fb_cpp;
39314 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
39315 index 709e90d..89a1c0d 100644
39316 --- a/drivers/gpu/drm/mga/mga_ioc32.c
39317 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
39318 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
39319 return 0;
39320 }
39321
39322 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
39323 +drm_ioctl_compat_t mga_compat_ioctls[] = {
39324 [DRM_MGA_INIT] = compat_mga_init,
39325 [DRM_MGA_GETPARAM] = compat_mga_getparam,
39326 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
39327 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
39328 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39329 {
39330 unsigned int nr = DRM_IOCTL_NR(cmd);
39331 - drm_ioctl_compat_t *fn = NULL;
39332 int ret;
39333
39334 if (nr < DRM_COMMAND_BASE)
39335 return drm_compat_ioctl(filp, cmd, arg);
39336
39337 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
39338 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39339 -
39340 - if (fn != NULL)
39341 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
39342 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39343 ret = (*fn) (filp, cmd, arg);
39344 - else
39345 + } else
39346 ret = drm_ioctl(filp, cmd, arg);
39347
39348 return ret;
39349 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
39350 index 598c281..60d590e 100644
39351 --- a/drivers/gpu/drm/mga/mga_irq.c
39352 +++ b/drivers/gpu/drm/mga/mga_irq.c
39353 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
39354 if (crtc != 0)
39355 return 0;
39356
39357 - return atomic_read(&dev_priv->vbl_received);
39358 + return atomic_read_unchecked(&dev_priv->vbl_received);
39359 }
39360
39361
39362 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39363 /* VBLANK interrupt */
39364 if (status & MGA_VLINEPEN) {
39365 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
39366 - atomic_inc(&dev_priv->vbl_received);
39367 + atomic_inc_unchecked(&dev_priv->vbl_received);
39368 drm_handle_vblank(dev, 0);
39369 handled = 1;
39370 }
39371 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39372 if ((prim_start & ~0x03) != (prim_end & ~0x03))
39373 MGA_WRITE(MGA_PRIMEND, prim_end);
39374
39375 - atomic_inc(&dev_priv->last_fence_retired);
39376 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
39377 DRM_WAKEUP(&dev_priv->fence_queue);
39378 handled = 1;
39379 }
39380 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
39381 * using fences.
39382 */
39383 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
39384 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
39385 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
39386 - *sequence) <= (1 << 23)));
39387
39388 *sequence = cur_fence;
39389 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
39390 index 3e72876..d1c15ad 100644
39391 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
39392 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
39393 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
39394 struct bit_table {
39395 const char id;
39396 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
39397 -};
39398 +} __no_const;
39399
39400 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
39401
39402 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
39403 index 994fd6e..6e12565 100644
39404 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
39405 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
39406 @@ -94,7 +94,6 @@ struct nouveau_drm {
39407 struct drm_global_reference mem_global_ref;
39408 struct ttm_bo_global_ref bo_global_ref;
39409 struct ttm_bo_device bdev;
39410 - atomic_t validate_sequence;
39411 int (*move)(struct nouveau_channel *,
39412 struct ttm_buffer_object *,
39413 struct ttm_mem_reg *, struct ttm_mem_reg *);
39414 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39415 index c1a7e5a..38b8539 100644
39416 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39417 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39418 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
39419 unsigned long arg)
39420 {
39421 unsigned int nr = DRM_IOCTL_NR(cmd);
39422 - drm_ioctl_compat_t *fn = NULL;
39423 + drm_ioctl_compat_t fn = NULL;
39424 int ret;
39425
39426 if (nr < DRM_COMMAND_BASE)
39427 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
39428 index 81638d7..2e45854 100644
39429 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
39430 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
39431 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
39432 bool can_switch;
39433
39434 spin_lock(&dev->count_lock);
39435 - can_switch = (dev->open_count == 0);
39436 + can_switch = (local_read(&dev->open_count) == 0);
39437 spin_unlock(&dev->count_lock);
39438 return can_switch;
39439 }
39440 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
39441 index eb89653..613cf71 100644
39442 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
39443 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
39444 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
39445 int ret;
39446
39447 mutex_lock(&qdev->async_io_mutex);
39448 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39449 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39450 if (qdev->last_sent_io_cmd > irq_num) {
39451 if (intr)
39452 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39453 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39454 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39455 else
39456 ret = wait_event_timeout(qdev->io_cmd_event,
39457 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39458 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39459 /* 0 is timeout, just bail the "hw" has gone away */
39460 if (ret <= 0)
39461 goto out;
39462 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39463 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39464 }
39465 outb(val, addr);
39466 qdev->last_sent_io_cmd = irq_num + 1;
39467 if (intr)
39468 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39469 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39470 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39471 else
39472 ret = wait_event_timeout(qdev->io_cmd_event,
39473 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39474 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39475 out:
39476 if (ret > 0)
39477 ret = 0;
39478 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
39479 index c3c2bbd..bc3c0fb 100644
39480 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
39481 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
39482 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
39483 struct drm_info_node *node = (struct drm_info_node *) m->private;
39484 struct qxl_device *qdev = node->minor->dev->dev_private;
39485
39486 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
39487 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
39488 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
39489 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
39490 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
39491 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
39492 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
39493 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
39494 seq_printf(m, "%d\n", qdev->irq_received_error);
39495 return 0;
39496 }
39497 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
39498 index f7c9add..fb971d2 100644
39499 --- a/drivers/gpu/drm/qxl/qxl_drv.h
39500 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
39501 @@ -290,10 +290,10 @@ struct qxl_device {
39502 unsigned int last_sent_io_cmd;
39503
39504 /* interrupt handling */
39505 - atomic_t irq_received;
39506 - atomic_t irq_received_display;
39507 - atomic_t irq_received_cursor;
39508 - atomic_t irq_received_io_cmd;
39509 + atomic_unchecked_t irq_received;
39510 + atomic_unchecked_t irq_received_display;
39511 + atomic_unchecked_t irq_received_cursor;
39512 + atomic_unchecked_t irq_received_io_cmd;
39513 unsigned irq_received_error;
39514 wait_queue_head_t display_event;
39515 wait_queue_head_t cursor_event;
39516 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
39517 index 21393dc..329f3a9 100644
39518 --- a/drivers/gpu/drm/qxl/qxl_irq.c
39519 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
39520 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
39521
39522 pending = xchg(&qdev->ram_header->int_pending, 0);
39523
39524 - atomic_inc(&qdev->irq_received);
39525 + atomic_inc_unchecked(&qdev->irq_received);
39526
39527 if (pending & QXL_INTERRUPT_DISPLAY) {
39528 - atomic_inc(&qdev->irq_received_display);
39529 + atomic_inc_unchecked(&qdev->irq_received_display);
39530 wake_up_all(&qdev->display_event);
39531 qxl_queue_garbage_collect(qdev, false);
39532 }
39533 if (pending & QXL_INTERRUPT_CURSOR) {
39534 - atomic_inc(&qdev->irq_received_cursor);
39535 + atomic_inc_unchecked(&qdev->irq_received_cursor);
39536 wake_up_all(&qdev->cursor_event);
39537 }
39538 if (pending & QXL_INTERRUPT_IO_CMD) {
39539 - atomic_inc(&qdev->irq_received_io_cmd);
39540 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
39541 wake_up_all(&qdev->io_cmd_event);
39542 }
39543 if (pending & QXL_INTERRUPT_ERROR) {
39544 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
39545 init_waitqueue_head(&qdev->io_cmd_event);
39546 INIT_WORK(&qdev->client_monitors_config_work,
39547 qxl_client_monitors_config_work_func);
39548 - atomic_set(&qdev->irq_received, 0);
39549 - atomic_set(&qdev->irq_received_display, 0);
39550 - atomic_set(&qdev->irq_received_cursor, 0);
39551 - atomic_set(&qdev->irq_received_io_cmd, 0);
39552 + atomic_set_unchecked(&qdev->irq_received, 0);
39553 + atomic_set_unchecked(&qdev->irq_received_display, 0);
39554 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
39555 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
39556 qdev->irq_received_error = 0;
39557 ret = drm_irq_install(qdev->ddev);
39558 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
39559 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
39560 index 037786d..2a95e33 100644
39561 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
39562 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
39563 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
39564 }
39565 }
39566
39567 -static struct vm_operations_struct qxl_ttm_vm_ops;
39568 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
39569 static const struct vm_operations_struct *ttm_vm_ops;
39570
39571 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39572 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
39573 return r;
39574 if (unlikely(ttm_vm_ops == NULL)) {
39575 ttm_vm_ops = vma->vm_ops;
39576 + pax_open_kernel();
39577 qxl_ttm_vm_ops = *ttm_vm_ops;
39578 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
39579 + pax_close_kernel();
39580 }
39581 vma->vm_ops = &qxl_ttm_vm_ops;
39582 return 0;
39583 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
39584 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
39585 {
39586 #if defined(CONFIG_DEBUG_FS)
39587 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
39588 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
39589 - unsigned i;
39590 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
39591 + {
39592 + .name = "qxl_mem_mm",
39593 + .show = &qxl_mm_dump_table,
39594 + },
39595 + {
39596 + .name = "qxl_surf_mm",
39597 + .show = &qxl_mm_dump_table,
39598 + }
39599 + };
39600
39601 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
39602 - if (i == 0)
39603 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
39604 - else
39605 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
39606 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
39607 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
39608 - qxl_mem_types_list[i].driver_features = 0;
39609 - if (i == 0)
39610 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39611 - else
39612 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39613 + pax_open_kernel();
39614 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39615 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39616 + pax_close_kernel();
39617
39618 - }
39619 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
39620 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
39621 #else
39622 return 0;
39623 #endif
39624 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
39625 index c451257..0ad2134 100644
39626 --- a/drivers/gpu/drm/r128/r128_cce.c
39627 +++ b/drivers/gpu/drm/r128/r128_cce.c
39628 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
39629
39630 /* GH: Simple idle check.
39631 */
39632 - atomic_set(&dev_priv->idle_count, 0);
39633 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39634
39635 /* We don't support anything other than bus-mastering ring mode,
39636 * but the ring can be in either AGP or PCI space for the ring
39637 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
39638 index 56eb5e3..c4ec43d 100644
39639 --- a/drivers/gpu/drm/r128/r128_drv.h
39640 +++ b/drivers/gpu/drm/r128/r128_drv.h
39641 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
39642 int is_pci;
39643 unsigned long cce_buffers_offset;
39644
39645 - atomic_t idle_count;
39646 + atomic_unchecked_t idle_count;
39647
39648 int page_flipping;
39649 int current_page;
39650 u32 crtc_offset;
39651 u32 crtc_offset_cntl;
39652
39653 - atomic_t vbl_received;
39654 + atomic_unchecked_t vbl_received;
39655
39656 u32 color_fmt;
39657 unsigned int front_offset;
39658 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
39659 index a954c54..9cc595c 100644
39660 --- a/drivers/gpu/drm/r128/r128_ioc32.c
39661 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
39662 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39663 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39664 }
39665
39666 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39667 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39668 [DRM_R128_INIT] = compat_r128_init,
39669 [DRM_R128_DEPTH] = compat_r128_depth,
39670 [DRM_R128_STIPPLE] = compat_r128_stipple,
39671 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39672 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39673 {
39674 unsigned int nr = DRM_IOCTL_NR(cmd);
39675 - drm_ioctl_compat_t *fn = NULL;
39676 int ret;
39677
39678 if (nr < DRM_COMMAND_BASE)
39679 return drm_compat_ioctl(filp, cmd, arg);
39680
39681 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39682 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39683 -
39684 - if (fn != NULL)
39685 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39686 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39687 ret = (*fn) (filp, cmd, arg);
39688 - else
39689 + } else
39690 ret = drm_ioctl(filp, cmd, arg);
39691
39692 return ret;
39693 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39694 index 2ea4f09..d391371 100644
39695 --- a/drivers/gpu/drm/r128/r128_irq.c
39696 +++ b/drivers/gpu/drm/r128/r128_irq.c
39697 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39698 if (crtc != 0)
39699 return 0;
39700
39701 - return atomic_read(&dev_priv->vbl_received);
39702 + return atomic_read_unchecked(&dev_priv->vbl_received);
39703 }
39704
39705 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39706 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39707 /* VBLANK interrupt */
39708 if (status & R128_CRTC_VBLANK_INT) {
39709 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39710 - atomic_inc(&dev_priv->vbl_received);
39711 + atomic_inc_unchecked(&dev_priv->vbl_received);
39712 drm_handle_vblank(dev, 0);
39713 return IRQ_HANDLED;
39714 }
39715 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39716 index 01dd9ae..6352f04 100644
39717 --- a/drivers/gpu/drm/r128/r128_state.c
39718 +++ b/drivers/gpu/drm/r128/r128_state.c
39719 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39720
39721 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39722 {
39723 - if (atomic_read(&dev_priv->idle_count) == 0)
39724 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39725 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39726 else
39727 - atomic_set(&dev_priv->idle_count, 0);
39728 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39729 }
39730
39731 #endif
39732 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39733 index af85299..ed9ac8d 100644
39734 --- a/drivers/gpu/drm/radeon/mkregtable.c
39735 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39736 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39737 regex_t mask_rex;
39738 regmatch_t match[4];
39739 char buf[1024];
39740 - size_t end;
39741 + long end;
39742 int len;
39743 int done = 0;
39744 int r;
39745 unsigned o;
39746 struct offset *offset;
39747 char last_reg_s[10];
39748 - int last_reg;
39749 + unsigned long last_reg;
39750
39751 if (regcomp
39752 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39753 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39754 index 841d0e0..9eaa268 100644
39755 --- a/drivers/gpu/drm/radeon/radeon_device.c
39756 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39757 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39758 bool can_switch;
39759
39760 spin_lock(&dev->count_lock);
39761 - can_switch = (dev->open_count == 0);
39762 + can_switch = (local_read(&dev->open_count) == 0);
39763 spin_unlock(&dev->count_lock);
39764 return can_switch;
39765 }
39766 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39767 index b369d42..8dd04eb 100644
39768 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39769 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39770 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39771
39772 /* SW interrupt */
39773 wait_queue_head_t swi_queue;
39774 - atomic_t swi_emitted;
39775 + atomic_unchecked_t swi_emitted;
39776 int vblank_crtc;
39777 uint32_t irq_enable_reg;
39778 uint32_t r500_disp_irq_reg;
39779 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39780 index c180df8..5fd8186 100644
39781 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39782 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39783 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39784 request = compat_alloc_user_space(sizeof(*request));
39785 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39786 || __put_user(req32.param, &request->param)
39787 - || __put_user((void __user *)(unsigned long)req32.value,
39788 + || __put_user((unsigned long)req32.value,
39789 &request->value))
39790 return -EFAULT;
39791
39792 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39793 #define compat_radeon_cp_setparam NULL
39794 #endif /* X86_64 || IA64 */
39795
39796 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39797 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39798 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39799 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39800 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39801 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39802 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39803 {
39804 unsigned int nr = DRM_IOCTL_NR(cmd);
39805 - drm_ioctl_compat_t *fn = NULL;
39806 int ret;
39807
39808 if (nr < DRM_COMMAND_BASE)
39809 return drm_compat_ioctl(filp, cmd, arg);
39810
39811 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39812 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39813 -
39814 - if (fn != NULL)
39815 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39816 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39817 ret = (*fn) (filp, cmd, arg);
39818 - else
39819 + } else
39820 ret = drm_ioctl(filp, cmd, arg);
39821
39822 return ret;
39823 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39824 index 8d68e97..9dcfed8 100644
39825 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39826 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39827 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39828 unsigned int ret;
39829 RING_LOCALS;
39830
39831 - atomic_inc(&dev_priv->swi_emitted);
39832 - ret = atomic_read(&dev_priv->swi_emitted);
39833 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39834 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39835
39836 BEGIN_RING(4);
39837 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39838 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39839 drm_radeon_private_t *dev_priv =
39840 (drm_radeon_private_t *) dev->dev_private;
39841
39842 - atomic_set(&dev_priv->swi_emitted, 0);
39843 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39844 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39845
39846 dev->max_vblank_count = 0x001fffff;
39847 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39848 index 4d20910..6726b6d 100644
39849 --- a/drivers/gpu/drm/radeon/radeon_state.c
39850 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39851 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39852 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39853 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39854
39855 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39856 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39857 sarea_priv->nbox * sizeof(depth_boxes[0])))
39858 return -EFAULT;
39859
39860 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39861 {
39862 drm_radeon_private_t *dev_priv = dev->dev_private;
39863 drm_radeon_getparam_t *param = data;
39864 - int value;
39865 + int value = 0;
39866
39867 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39868
39869 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39870 index 71245d6..94c556d 100644
39871 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39872 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39873 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39874 man->size = size >> PAGE_SHIFT;
39875 }
39876
39877 -static struct vm_operations_struct radeon_ttm_vm_ops;
39878 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39879 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39880
39881 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39882 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39883 }
39884 if (unlikely(ttm_vm_ops == NULL)) {
39885 ttm_vm_ops = vma->vm_ops;
39886 + pax_open_kernel();
39887 radeon_ttm_vm_ops = *ttm_vm_ops;
39888 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39889 + pax_close_kernel();
39890 }
39891 vma->vm_ops = &radeon_ttm_vm_ops;
39892 return 0;
39893 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39894 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39895 {
39896 #if defined(CONFIG_DEBUG_FS)
39897 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39898 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39899 - unsigned i;
39900 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39901 + {
39902 + .name = "radeon_vram_mm",
39903 + .show = &radeon_mm_dump_table,
39904 + },
39905 + {
39906 + .name = "radeon_gtt_mm",
39907 + .show = &radeon_mm_dump_table,
39908 + },
39909 + {
39910 + .name = "ttm_page_pool",
39911 + .show = &ttm_page_alloc_debugfs,
39912 + },
39913 + {
39914 + .name = "ttm_dma_page_pool",
39915 + .show = &ttm_dma_page_alloc_debugfs,
39916 + },
39917 + };
39918 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39919
39920 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39921 - if (i == 0)
39922 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39923 - else
39924 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39925 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39926 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39927 - radeon_mem_types_list[i].driver_features = 0;
39928 - if (i == 0)
39929 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39930 - else
39931 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39932 -
39933 - }
39934 - /* Add ttm page pool to debugfs */
39935 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39936 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39937 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39938 - radeon_mem_types_list[i].driver_features = 0;
39939 - radeon_mem_types_list[i++].data = NULL;
39940 + pax_open_kernel();
39941 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39942 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39943 + pax_close_kernel();
39944 #ifdef CONFIG_SWIOTLB
39945 - if (swiotlb_nr_tbl()) {
39946 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39947 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39948 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39949 - radeon_mem_types_list[i].driver_features = 0;
39950 - radeon_mem_types_list[i++].data = NULL;
39951 - }
39952 + if (swiotlb_nr_tbl())
39953 + i++;
39954 #endif
39955 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39956
39957 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39958 index 3c38f0a..13816e3 100644
39959 --- a/drivers/gpu/drm/radeon/rs690.c
39960 +++ b/drivers/gpu/drm/radeon/rs690.c
39961 @@ -355,9 +355,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39962 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39963 rdev->pm.sideport_bandwidth.full)
39964 max_bandwidth = rdev->pm.sideport_bandwidth;
39965 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39966 + read_delay_latency.full = dfixed_const(800 * 1000);
39967 read_delay_latency.full = dfixed_div(read_delay_latency,
39968 rdev->pm.igp_sideport_mclk);
39969 + a.full = dfixed_const(370);
39970 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39971 } else {
39972 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39973 rdev->pm.k8_bandwidth.full)
39974 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39975 index dbc2def..0a9f710 100644
39976 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39977 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39978 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39979 zone->glob = glob;
39980 glob->zone_kernel = zone;
39981 ret = kobject_init_and_add(
39982 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39983 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39984 if (unlikely(ret != 0)) {
39985 kobject_put(&zone->kobj);
39986 return ret;
39987 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39988 zone->glob = glob;
39989 glob->zone_dma32 = zone;
39990 ret = kobject_init_and_add(
39991 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39992 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39993 if (unlikely(ret != 0)) {
39994 kobject_put(&zone->kobj);
39995 return ret;
39996 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39997 index 863bef9..cba15cf 100644
39998 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39999 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
40000 @@ -391,9 +391,9 @@ out:
40001 static unsigned long
40002 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
40003 {
40004 - static atomic_t start_pool = ATOMIC_INIT(0);
40005 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
40006 unsigned i;
40007 - unsigned pool_offset = atomic_add_return(1, &start_pool);
40008 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
40009 struct ttm_page_pool *pool;
40010 int shrink_pages = sc->nr_to_scan;
40011 unsigned long freed = 0;
40012 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
40013 index 97e9d61..bf23c461 100644
40014 --- a/drivers/gpu/drm/udl/udl_fb.c
40015 +++ b/drivers/gpu/drm/udl/udl_fb.c
40016 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
40017 fb_deferred_io_cleanup(info);
40018 kfree(info->fbdefio);
40019 info->fbdefio = NULL;
40020 - info->fbops->fb_mmap = udl_fb_mmap;
40021 }
40022
40023 pr_warn("released /dev/fb%d user=%d count=%d\n",
40024 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
40025 index a811ef2..ff99b05 100644
40026 --- a/drivers/gpu/drm/via/via_drv.h
40027 +++ b/drivers/gpu/drm/via/via_drv.h
40028 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
40029 typedef uint32_t maskarray_t[5];
40030
40031 typedef struct drm_via_irq {
40032 - atomic_t irq_received;
40033 + atomic_unchecked_t irq_received;
40034 uint32_t pending_mask;
40035 uint32_t enable_mask;
40036 wait_queue_head_t irq_queue;
40037 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
40038 struct timeval last_vblank;
40039 int last_vblank_valid;
40040 unsigned usec_per_vblank;
40041 - atomic_t vbl_received;
40042 + atomic_unchecked_t vbl_received;
40043 drm_via_state_t hc_state;
40044 char pci_buf[VIA_PCI_BUF_SIZE];
40045 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
40046 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
40047 index ac98964..5dbf512 100644
40048 --- a/drivers/gpu/drm/via/via_irq.c
40049 +++ b/drivers/gpu/drm/via/via_irq.c
40050 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
40051 if (crtc != 0)
40052 return 0;
40053
40054 - return atomic_read(&dev_priv->vbl_received);
40055 + return atomic_read_unchecked(&dev_priv->vbl_received);
40056 }
40057
40058 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
40059 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
40060
40061 status = VIA_READ(VIA_REG_INTERRUPT);
40062 if (status & VIA_IRQ_VBLANK_PENDING) {
40063 - atomic_inc(&dev_priv->vbl_received);
40064 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
40065 + atomic_inc_unchecked(&dev_priv->vbl_received);
40066 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
40067 do_gettimeofday(&cur_vblank);
40068 if (dev_priv->last_vblank_valid) {
40069 dev_priv->usec_per_vblank =
40070 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
40071 dev_priv->last_vblank = cur_vblank;
40072 dev_priv->last_vblank_valid = 1;
40073 }
40074 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
40075 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
40076 DRM_DEBUG("US per vblank is: %u\n",
40077 dev_priv->usec_per_vblank);
40078 }
40079 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
40080
40081 for (i = 0; i < dev_priv->num_irqs; ++i) {
40082 if (status & cur_irq->pending_mask) {
40083 - atomic_inc(&cur_irq->irq_received);
40084 + atomic_inc_unchecked(&cur_irq->irq_received);
40085 DRM_WAKEUP(&cur_irq->irq_queue);
40086 handled = 1;
40087 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
40088 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
40089 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
40090 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
40091 masks[irq][4]));
40092 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
40093 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
40094 } else {
40095 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
40096 (((cur_irq_sequence =
40097 - atomic_read(&cur_irq->irq_received)) -
40098 + atomic_read_unchecked(&cur_irq->irq_received)) -
40099 *sequence) <= (1 << 23)));
40100 }
40101 *sequence = cur_irq_sequence;
40102 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
40103 }
40104
40105 for (i = 0; i < dev_priv->num_irqs; ++i) {
40106 - atomic_set(&cur_irq->irq_received, 0);
40107 + atomic_set_unchecked(&cur_irq->irq_received, 0);
40108 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
40109 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
40110 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
40111 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
40112 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
40113 case VIA_IRQ_RELATIVE:
40114 irqwait->request.sequence +=
40115 - atomic_read(&cur_irq->irq_received);
40116 + atomic_read_unchecked(&cur_irq->irq_received);
40117 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
40118 case VIA_IRQ_ABSOLUTE:
40119 break;
40120 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
40121 index 150ec64..f5165f2 100644
40122 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
40123 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
40124 @@ -290,7 +290,7 @@ struct vmw_private {
40125 * Fencing and IRQs.
40126 */
40127
40128 - atomic_t marker_seq;
40129 + atomic_unchecked_t marker_seq;
40130 wait_queue_head_t fence_queue;
40131 wait_queue_head_t fifo_queue;
40132 int fence_queue_waiters; /* Protected by hw_mutex */
40133 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40134 index 3eb1486..0a47ee9 100644
40135 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40136 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40137 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
40138 (unsigned int) min,
40139 (unsigned int) fifo->capabilities);
40140
40141 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
40142 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
40143 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
40144 vmw_marker_queue_init(&fifo->marker_queue);
40145 return vmw_fifo_send_fence(dev_priv, &dummy);
40146 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
40147 if (reserveable)
40148 iowrite32(bytes, fifo_mem +
40149 SVGA_FIFO_RESERVED);
40150 - return fifo_mem + (next_cmd >> 2);
40151 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
40152 } else {
40153 need_bounce = true;
40154 }
40155 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40156
40157 fm = vmw_fifo_reserve(dev_priv, bytes);
40158 if (unlikely(fm == NULL)) {
40159 - *seqno = atomic_read(&dev_priv->marker_seq);
40160 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40161 ret = -ENOMEM;
40162 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
40163 false, 3*HZ);
40164 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40165 }
40166
40167 do {
40168 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
40169 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
40170 } while (*seqno == 0);
40171
40172 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
40173 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40174 index c509d40..3b640c3 100644
40175 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40176 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40177 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
40178 int ret;
40179
40180 num_clips = arg->num_clips;
40181 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40182 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40183
40184 if (unlikely(num_clips == 0))
40185 return 0;
40186 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
40187 int ret;
40188
40189 num_clips = arg->num_clips;
40190 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40191 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40192
40193 if (unlikely(num_clips == 0))
40194 return 0;
40195 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40196 index 4640adb..e1384ed 100644
40197 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40198 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40199 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
40200 * emitted. Then the fence is stale and signaled.
40201 */
40202
40203 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
40204 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
40205 > VMW_FENCE_WRAP);
40206
40207 return ret;
40208 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
40209
40210 if (fifo_idle)
40211 down_read(&fifo_state->rwsem);
40212 - signal_seq = atomic_read(&dev_priv->marker_seq);
40213 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
40214 ret = 0;
40215
40216 for (;;) {
40217 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40218 index 8a8725c2..afed796 100644
40219 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40220 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40221 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
40222 while (!vmw_lag_lt(queue, us)) {
40223 spin_lock(&queue->lock);
40224 if (list_empty(&queue->head))
40225 - seqno = atomic_read(&dev_priv->marker_seq);
40226 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40227 else {
40228 marker = list_first_entry(&queue->head,
40229 struct vmw_marker, head);
40230 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
40231 index b1a05ad..1c9d899 100644
40232 --- a/drivers/gpu/host1x/drm/dc.c
40233 +++ b/drivers/gpu/host1x/drm/dc.c
40234 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
40235 }
40236
40237 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
40238 - dc->debugfs_files[i].data = dc;
40239 + *(void **)&dc->debugfs_files[i].data = dc;
40240
40241 err = drm_debugfs_create_files(dc->debugfs_files,
40242 ARRAY_SIZE(debugfs_files),
40243 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
40244 index ec0ae2d..dc0780b 100644
40245 --- a/drivers/gpu/vga/vga_switcheroo.c
40246 +++ b/drivers/gpu/vga/vga_switcheroo.c
40247 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
40248
40249 /* this version is for the case where the power switch is separate
40250 to the device being powered down. */
40251 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
40252 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
40253 {
40254 /* copy over all the bus versions */
40255 if (dev->bus && dev->bus->pm) {
40256 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
40257 return ret;
40258 }
40259
40260 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
40261 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
40262 {
40263 /* copy over all the bus versions */
40264 if (dev->bus && dev->bus->pm) {
40265 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
40266 index aedfe50..1dc929b 100644
40267 --- a/drivers/hid/hid-core.c
40268 +++ b/drivers/hid/hid-core.c
40269 @@ -2416,7 +2416,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
40270
40271 int hid_add_device(struct hid_device *hdev)
40272 {
40273 - static atomic_t id = ATOMIC_INIT(0);
40274 + static atomic_unchecked_t id = ATOMIC_INIT(0);
40275 int ret;
40276
40277 if (WARN_ON(hdev->status & HID_STAT_ADDED))
40278 @@ -2450,7 +2450,7 @@ int hid_add_device(struct hid_device *hdev)
40279 /* XXX hack, any other cleaner solution after the driver core
40280 * is converted to allow more than 20 bytes as the device name? */
40281 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
40282 - hdev->vendor, hdev->product, atomic_inc_return(&id));
40283 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
40284
40285 hid_debug_register(hdev, dev_name(&hdev->dev));
40286 ret = device_add(&hdev->dev);
40287 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
40288 index c13fb5b..55a3802 100644
40289 --- a/drivers/hid/hid-wiimote-debug.c
40290 +++ b/drivers/hid/hid-wiimote-debug.c
40291 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
40292 else if (size == 0)
40293 return -EIO;
40294
40295 - if (copy_to_user(u, buf, size))
40296 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
40297 return -EFAULT;
40298
40299 *off += size;
40300 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
40301 index cedc6da..2c3da2a 100644
40302 --- a/drivers/hid/uhid.c
40303 +++ b/drivers/hid/uhid.c
40304 @@ -47,7 +47,7 @@ struct uhid_device {
40305 struct mutex report_lock;
40306 wait_queue_head_t report_wait;
40307 atomic_t report_done;
40308 - atomic_t report_id;
40309 + atomic_unchecked_t report_id;
40310 struct uhid_event report_buf;
40311 };
40312
40313 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
40314
40315 spin_lock_irqsave(&uhid->qlock, flags);
40316 ev->type = UHID_FEATURE;
40317 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
40318 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
40319 ev->u.feature.rnum = rnum;
40320 ev->u.feature.rtype = report_type;
40321
40322 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
40323 spin_lock_irqsave(&uhid->qlock, flags);
40324
40325 /* id for old report; drop it silently */
40326 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
40327 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
40328 goto unlock;
40329 if (atomic_read(&uhid->report_done))
40330 goto unlock;
40331 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
40332 index 6de6c98..18319e9 100644
40333 --- a/drivers/hv/channel.c
40334 +++ b/drivers/hv/channel.c
40335 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
40336 int ret = 0;
40337 int t;
40338
40339 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
40340 - atomic_inc(&vmbus_connection.next_gpadl_handle);
40341 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
40342 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
40343
40344 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
40345 if (ret)
40346 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
40347 index 88f4096..e50452e 100644
40348 --- a/drivers/hv/hv.c
40349 +++ b/drivers/hv/hv.c
40350 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
40351 u64 output_address = (output) ? virt_to_phys(output) : 0;
40352 u32 output_address_hi = output_address >> 32;
40353 u32 output_address_lo = output_address & 0xFFFFFFFF;
40354 - void *hypercall_page = hv_context.hypercall_page;
40355 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
40356
40357 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
40358 "=a"(hv_status_lo) : "d" (control_hi),
40359 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
40360 index 7e17a54..a50a33d 100644
40361 --- a/drivers/hv/hv_balloon.c
40362 +++ b/drivers/hv/hv_balloon.c
40363 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
40364
40365 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
40366 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
40367 -static atomic_t trans_id = ATOMIC_INIT(0);
40368 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
40369
40370 static int dm_ring_size = (5 * PAGE_SIZE);
40371
40372 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
40373 pr_info("Memory hot add failed\n");
40374
40375 dm->state = DM_INITIALIZED;
40376 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40377 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40378 vmbus_sendpacket(dm->dev->channel, &resp,
40379 sizeof(struct dm_hot_add_response),
40380 (unsigned long)NULL,
40381 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
40382 memset(&status, 0, sizeof(struct dm_status));
40383 status.hdr.type = DM_STATUS_REPORT;
40384 status.hdr.size = sizeof(struct dm_status);
40385 - status.hdr.trans_id = atomic_inc_return(&trans_id);
40386 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40387
40388 /*
40389 * The host expects the guest to report free memory.
40390 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
40391 * send the status. This can happen if we were interrupted
40392 * after we picked our transaction ID.
40393 */
40394 - if (status.hdr.trans_id != atomic_read(&trans_id))
40395 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
40396 return;
40397
40398 vmbus_sendpacket(dm->dev->channel, &status,
40399 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
40400 */
40401
40402 do {
40403 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
40404 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40405 ret = vmbus_sendpacket(dm_device.dev->channel,
40406 bl_resp,
40407 bl_resp->hdr.size,
40408 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
40409
40410 memset(&resp, 0, sizeof(struct dm_unballoon_response));
40411 resp.hdr.type = DM_UNBALLOON_RESPONSE;
40412 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40413 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40414 resp.hdr.size = sizeof(struct dm_unballoon_response);
40415
40416 vmbus_sendpacket(dm_device.dev->channel, &resp,
40417 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
40418 memset(&version_req, 0, sizeof(struct dm_version_request));
40419 version_req.hdr.type = DM_VERSION_REQUEST;
40420 version_req.hdr.size = sizeof(struct dm_version_request);
40421 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40422 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40423 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
40424 version_req.is_last_attempt = 1;
40425
40426 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40427 memset(&version_req, 0, sizeof(struct dm_version_request));
40428 version_req.hdr.type = DM_VERSION_REQUEST;
40429 version_req.hdr.size = sizeof(struct dm_version_request);
40430 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40431 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40432 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40433 version_req.is_last_attempt = 0;
40434
40435 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40436 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40437 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40438 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40439 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40440 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40441
40442 cap_msg.caps.cap_bits.balloon = 1;
40443 cap_msg.caps.cap_bits.hot_add = 1;
40444 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40445 index d84918f..7f38f9f 100644
40446 --- a/drivers/hv/hyperv_vmbus.h
40447 +++ b/drivers/hv/hyperv_vmbus.h
40448 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
40449 struct vmbus_connection {
40450 enum vmbus_connect_state conn_state;
40451
40452 - atomic_t next_gpadl_handle;
40453 + atomic_unchecked_t next_gpadl_handle;
40454
40455 /*
40456 * Represents channel interrupts. Each bit position represents a
40457 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40458 index f9fe46f..356b119 100644
40459 --- a/drivers/hv/vmbus_drv.c
40460 +++ b/drivers/hv/vmbus_drv.c
40461 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40462 {
40463 int ret = 0;
40464
40465 - static atomic_t device_num = ATOMIC_INIT(0);
40466 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40467
40468 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40469 - atomic_inc_return(&device_num));
40470 + atomic_inc_return_unchecked(&device_num));
40471
40472 child_device_obj->device.bus = &hv_bus;
40473 child_device_obj->device.parent = &hv_acpi_dev->dev;
40474 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40475 index a9e3d01..9dd246e 100644
40476 --- a/drivers/hwmon/acpi_power_meter.c
40477 +++ b/drivers/hwmon/acpi_power_meter.c
40478 @@ -117,7 +117,7 @@ struct sensor_template {
40479 struct device_attribute *devattr,
40480 const char *buf, size_t count);
40481 int index;
40482 -};
40483 +} __do_const;
40484
40485 /* Averaging interval */
40486 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40487 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40488 struct sensor_template *attrs)
40489 {
40490 struct device *dev = &resource->acpi_dev->dev;
40491 - struct sensor_device_attribute *sensors =
40492 + sensor_device_attribute_no_const *sensors =
40493 &resource->sensors[resource->num_sensors];
40494 int res = 0;
40495
40496 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40497 index 3288f13..71cfb4e 100644
40498 --- a/drivers/hwmon/applesmc.c
40499 +++ b/drivers/hwmon/applesmc.c
40500 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40501 {
40502 struct applesmc_node_group *grp;
40503 struct applesmc_dev_attr *node;
40504 - struct attribute *attr;
40505 + attribute_no_const *attr;
40506 int ret, i;
40507
40508 for (grp = groups; grp->format; grp++) {
40509 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40510 index b25c643..a13460d 100644
40511 --- a/drivers/hwmon/asus_atk0110.c
40512 +++ b/drivers/hwmon/asus_atk0110.c
40513 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40514 struct atk_sensor_data {
40515 struct list_head list;
40516 struct atk_data *data;
40517 - struct device_attribute label_attr;
40518 - struct device_attribute input_attr;
40519 - struct device_attribute limit1_attr;
40520 - struct device_attribute limit2_attr;
40521 + device_attribute_no_const label_attr;
40522 + device_attribute_no_const input_attr;
40523 + device_attribute_no_const limit1_attr;
40524 + device_attribute_no_const limit2_attr;
40525 char label_attr_name[ATTR_NAME_SIZE];
40526 char input_attr_name[ATTR_NAME_SIZE];
40527 char limit1_attr_name[ATTR_NAME_SIZE];
40528 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40529 static struct device_attribute atk_name_attr =
40530 __ATTR(name, 0444, atk_name_show, NULL);
40531
40532 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40533 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40534 sysfs_show_func show)
40535 {
40536 sysfs_attr_init(&attr->attr);
40537 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40538 index 78be661..4dd032f 100644
40539 --- a/drivers/hwmon/coretemp.c
40540 +++ b/drivers/hwmon/coretemp.c
40541 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
40542 return NOTIFY_OK;
40543 }
40544
40545 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40546 +static struct notifier_block coretemp_cpu_notifier = {
40547 .notifier_call = coretemp_cpu_callback,
40548 };
40549
40550 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40551 index 632f1dc..57e6a58 100644
40552 --- a/drivers/hwmon/ibmaem.c
40553 +++ b/drivers/hwmon/ibmaem.c
40554 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40555 struct aem_rw_sensor_template *rw)
40556 {
40557 struct device *dev = &data->pdev->dev;
40558 - struct sensor_device_attribute *sensors = data->sensors;
40559 + sensor_device_attribute_no_const *sensors = data->sensors;
40560 int err;
40561
40562 /* Set up read-only sensors */
40563 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40564 index 708081b..fe2d4ab 100644
40565 --- a/drivers/hwmon/iio_hwmon.c
40566 +++ b/drivers/hwmon/iio_hwmon.c
40567 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40568 {
40569 struct device *dev = &pdev->dev;
40570 struct iio_hwmon_state *st;
40571 - struct sensor_device_attribute *a;
40572 + sensor_device_attribute_no_const *a;
40573 int ret, i;
40574 int in_i = 1, temp_i = 1, curr_i = 1;
40575 enum iio_chan_type type;
40576 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
40577 index 6eb03ce..bea7e3e 100644
40578 --- a/drivers/hwmon/nct6775.c
40579 +++ b/drivers/hwmon/nct6775.c
40580 @@ -936,10 +936,10 @@ static struct attribute_group *
40581 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
40582 int repeat)
40583 {
40584 - struct attribute_group *group;
40585 + attribute_group_no_const *group;
40586 struct sensor_device_attr_u *su;
40587 - struct sensor_device_attribute *a;
40588 - struct sensor_device_attribute_2 *a2;
40589 + sensor_device_attribute_no_const *a;
40590 + sensor_device_attribute_2_no_const *a2;
40591 struct attribute **attrs;
40592 struct sensor_device_template **t;
40593 int err, i, j, count;
40594 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40595 index 9319fcf..189ff45 100644
40596 --- a/drivers/hwmon/pmbus/pmbus_core.c
40597 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40598 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40599 return 0;
40600 }
40601
40602 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40603 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40604 const char *name,
40605 umode_t mode,
40606 ssize_t (*show)(struct device *dev,
40607 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40608 dev_attr->store = store;
40609 }
40610
40611 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40612 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40613 const char *name,
40614 umode_t mode,
40615 ssize_t (*show)(struct device *dev,
40616 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40617 u16 reg, u8 mask)
40618 {
40619 struct pmbus_boolean *boolean;
40620 - struct sensor_device_attribute *a;
40621 + sensor_device_attribute_no_const *a;
40622
40623 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40624 if (!boolean)
40625 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40626 bool update, bool readonly)
40627 {
40628 struct pmbus_sensor *sensor;
40629 - struct device_attribute *a;
40630 + device_attribute_no_const *a;
40631
40632 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40633 if (!sensor)
40634 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40635 const char *lstring, int index)
40636 {
40637 struct pmbus_label *label;
40638 - struct device_attribute *a;
40639 + device_attribute_no_const *a;
40640
40641 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40642 if (!label)
40643 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40644 index 97cd45a..ac54d8b 100644
40645 --- a/drivers/hwmon/sht15.c
40646 +++ b/drivers/hwmon/sht15.c
40647 @@ -169,7 +169,7 @@ struct sht15_data {
40648 int supply_uv;
40649 bool supply_uv_valid;
40650 struct work_struct update_supply_work;
40651 - atomic_t interrupt_handled;
40652 + atomic_unchecked_t interrupt_handled;
40653 };
40654
40655 /**
40656 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40657 ret = gpio_direction_input(data->pdata->gpio_data);
40658 if (ret)
40659 return ret;
40660 - atomic_set(&data->interrupt_handled, 0);
40661 + atomic_set_unchecked(&data->interrupt_handled, 0);
40662
40663 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40664 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40665 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40666 /* Only relevant if the interrupt hasn't occurred. */
40667 - if (!atomic_read(&data->interrupt_handled))
40668 + if (!atomic_read_unchecked(&data->interrupt_handled))
40669 schedule_work(&data->read_work);
40670 }
40671 ret = wait_event_timeout(data->wait_queue,
40672 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40673
40674 /* First disable the interrupt */
40675 disable_irq_nosync(irq);
40676 - atomic_inc(&data->interrupt_handled);
40677 + atomic_inc_unchecked(&data->interrupt_handled);
40678 /* Then schedule a reading work struct */
40679 if (data->state != SHT15_READING_NOTHING)
40680 schedule_work(&data->read_work);
40681 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40682 * If not, then start the interrupt again - care here as could
40683 * have gone low in meantime so verify it hasn't!
40684 */
40685 - atomic_set(&data->interrupt_handled, 0);
40686 + atomic_set_unchecked(&data->interrupt_handled, 0);
40687 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40688 /* If still not occurred or another handler was scheduled */
40689 if (gpio_get_value(data->pdata->gpio_data)
40690 - || atomic_read(&data->interrupt_handled))
40691 + || atomic_read_unchecked(&data->interrupt_handled))
40692 return;
40693 }
40694
40695 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40696 index 38944e9..ae9e5ed 100644
40697 --- a/drivers/hwmon/via-cputemp.c
40698 +++ b/drivers/hwmon/via-cputemp.c
40699 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40700 return NOTIFY_OK;
40701 }
40702
40703 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40704 +static struct notifier_block via_cputemp_cpu_notifier = {
40705 .notifier_call = via_cputemp_cpu_callback,
40706 };
40707
40708 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40709 index 07f01ac..d79ad3d 100644
40710 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40711 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40712 @@ -43,7 +43,7 @@
40713 extern struct i2c_adapter amd756_smbus;
40714
40715 static struct i2c_adapter *s4882_adapter;
40716 -static struct i2c_algorithm *s4882_algo;
40717 +static i2c_algorithm_no_const *s4882_algo;
40718
40719 /* Wrapper access functions for multiplexed SMBus */
40720 static DEFINE_MUTEX(amd756_lock);
40721 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
40722 index dae3ddf..26e21d1 100644
40723 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
40724 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
40725 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
40726 /* usb layer */
40727
40728 /* Send command to device, and get response. */
40729 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40730 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40731 {
40732 int ret = 0;
40733 int actual;
40734 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40735 index 2ca268d..c6acbdf 100644
40736 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40737 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40738 @@ -41,7 +41,7 @@
40739 extern struct i2c_adapter *nforce2_smbus;
40740
40741 static struct i2c_adapter *s4985_adapter;
40742 -static struct i2c_algorithm *s4985_algo;
40743 +static i2c_algorithm_no_const *s4985_algo;
40744
40745 /* Wrapper access functions for multiplexed SMBus */
40746 static DEFINE_MUTEX(nforce2_lock);
40747 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40748 index c3ccdea..5b3dc1a 100644
40749 --- a/drivers/i2c/i2c-dev.c
40750 +++ b/drivers/i2c/i2c-dev.c
40751 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40752 break;
40753 }
40754
40755 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40756 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40757 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40758 if (IS_ERR(rdwr_pa[i].buf)) {
40759 res = PTR_ERR(rdwr_pa[i].buf);
40760 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40761 index 0b510ba..4fbb5085 100644
40762 --- a/drivers/ide/ide-cd.c
40763 +++ b/drivers/ide/ide-cd.c
40764 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40765 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40766 if ((unsigned long)buf & alignment
40767 || blk_rq_bytes(rq) & q->dma_pad_mask
40768 - || object_is_on_stack(buf))
40769 + || object_starts_on_stack(buf))
40770 drive->dma = 0;
40771 }
40772 }
40773 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40774 index f95c697..0a1b05c 100644
40775 --- a/drivers/iio/industrialio-core.c
40776 +++ b/drivers/iio/industrialio-core.c
40777 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40778 }
40779
40780 static
40781 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40782 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40783 const char *postfix,
40784 struct iio_chan_spec const *chan,
40785 ssize_t (*readfunc)(struct device *dev,
40786 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40787 index 784b97c..c9ceadf 100644
40788 --- a/drivers/infiniband/core/cm.c
40789 +++ b/drivers/infiniband/core/cm.c
40790 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40791
40792 struct cm_counter_group {
40793 struct kobject obj;
40794 - atomic_long_t counter[CM_ATTR_COUNT];
40795 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40796 };
40797
40798 struct cm_counter_attribute {
40799 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40800 struct ib_mad_send_buf *msg = NULL;
40801 int ret;
40802
40803 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40804 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40805 counter[CM_REQ_COUNTER]);
40806
40807 /* Quick state check to discard duplicate REQs. */
40808 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40809 if (!cm_id_priv)
40810 return;
40811
40812 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40813 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40814 counter[CM_REP_COUNTER]);
40815 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40816 if (ret)
40817 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40818 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40819 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40820 spin_unlock_irq(&cm_id_priv->lock);
40821 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40822 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40823 counter[CM_RTU_COUNTER]);
40824 goto out;
40825 }
40826 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40827 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40828 dreq_msg->local_comm_id);
40829 if (!cm_id_priv) {
40830 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40831 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40832 counter[CM_DREQ_COUNTER]);
40833 cm_issue_drep(work->port, work->mad_recv_wc);
40834 return -EINVAL;
40835 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40836 case IB_CM_MRA_REP_RCVD:
40837 break;
40838 case IB_CM_TIMEWAIT:
40839 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40840 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40841 counter[CM_DREQ_COUNTER]);
40842 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40843 goto unlock;
40844 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40845 cm_free_msg(msg);
40846 goto deref;
40847 case IB_CM_DREQ_RCVD:
40848 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40849 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40850 counter[CM_DREQ_COUNTER]);
40851 goto unlock;
40852 default:
40853 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40854 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40855 cm_id_priv->msg, timeout)) {
40856 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40857 - atomic_long_inc(&work->port->
40858 + atomic_long_inc_unchecked(&work->port->
40859 counter_group[CM_RECV_DUPLICATES].
40860 counter[CM_MRA_COUNTER]);
40861 goto out;
40862 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40863 break;
40864 case IB_CM_MRA_REQ_RCVD:
40865 case IB_CM_MRA_REP_RCVD:
40866 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40867 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40868 counter[CM_MRA_COUNTER]);
40869 /* fall through */
40870 default:
40871 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40872 case IB_CM_LAP_IDLE:
40873 break;
40874 case IB_CM_MRA_LAP_SENT:
40875 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40876 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40877 counter[CM_LAP_COUNTER]);
40878 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40879 goto unlock;
40880 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40881 cm_free_msg(msg);
40882 goto deref;
40883 case IB_CM_LAP_RCVD:
40884 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40885 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40886 counter[CM_LAP_COUNTER]);
40887 goto unlock;
40888 default:
40889 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40890 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40891 if (cur_cm_id_priv) {
40892 spin_unlock_irq(&cm.lock);
40893 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40894 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40895 counter[CM_SIDR_REQ_COUNTER]);
40896 goto out; /* Duplicate message. */
40897 }
40898 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40899 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40900 msg->retries = 1;
40901
40902 - atomic_long_add(1 + msg->retries,
40903 + atomic_long_add_unchecked(1 + msg->retries,
40904 &port->counter_group[CM_XMIT].counter[attr_index]);
40905 if (msg->retries)
40906 - atomic_long_add(msg->retries,
40907 + atomic_long_add_unchecked(msg->retries,
40908 &port->counter_group[CM_XMIT_RETRIES].
40909 counter[attr_index]);
40910
40911 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40912 }
40913
40914 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40915 - atomic_long_inc(&port->counter_group[CM_RECV].
40916 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40917 counter[attr_id - CM_ATTR_ID_OFFSET]);
40918
40919 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40920 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40921 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40922
40923 return sprintf(buf, "%ld\n",
40924 - atomic_long_read(&group->counter[cm_attr->index]));
40925 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40926 }
40927
40928 static const struct sysfs_ops cm_counter_ops = {
40929 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40930 index 9f5ad7c..588cd84 100644
40931 --- a/drivers/infiniband/core/fmr_pool.c
40932 +++ b/drivers/infiniband/core/fmr_pool.c
40933 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40934
40935 struct task_struct *thread;
40936
40937 - atomic_t req_ser;
40938 - atomic_t flush_ser;
40939 + atomic_unchecked_t req_ser;
40940 + atomic_unchecked_t flush_ser;
40941
40942 wait_queue_head_t force_wait;
40943 };
40944 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40945 struct ib_fmr_pool *pool = pool_ptr;
40946
40947 do {
40948 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40949 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40950 ib_fmr_batch_release(pool);
40951
40952 - atomic_inc(&pool->flush_ser);
40953 + atomic_inc_unchecked(&pool->flush_ser);
40954 wake_up_interruptible(&pool->force_wait);
40955
40956 if (pool->flush_function)
40957 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40958 }
40959
40960 set_current_state(TASK_INTERRUPTIBLE);
40961 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40962 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40963 !kthread_should_stop())
40964 schedule();
40965 __set_current_state(TASK_RUNNING);
40966 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40967 pool->dirty_watermark = params->dirty_watermark;
40968 pool->dirty_len = 0;
40969 spin_lock_init(&pool->pool_lock);
40970 - atomic_set(&pool->req_ser, 0);
40971 - atomic_set(&pool->flush_ser, 0);
40972 + atomic_set_unchecked(&pool->req_ser, 0);
40973 + atomic_set_unchecked(&pool->flush_ser, 0);
40974 init_waitqueue_head(&pool->force_wait);
40975
40976 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40977 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40978 }
40979 spin_unlock_irq(&pool->pool_lock);
40980
40981 - serial = atomic_inc_return(&pool->req_ser);
40982 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40983 wake_up_process(pool->thread);
40984
40985 if (wait_event_interruptible(pool->force_wait,
40986 - atomic_read(&pool->flush_ser) - serial >= 0))
40987 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40988 return -EINTR;
40989
40990 return 0;
40991 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40992 } else {
40993 list_add_tail(&fmr->list, &pool->dirty_list);
40994 if (++pool->dirty_len >= pool->dirty_watermark) {
40995 - atomic_inc(&pool->req_ser);
40996 + atomic_inc_unchecked(&pool->req_ser);
40997 wake_up_process(pool->thread);
40998 }
40999 }
41000 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
41001 index 4cb8eb2..146bf60 100644
41002 --- a/drivers/infiniband/hw/cxgb4/mem.c
41003 +++ b/drivers/infiniband/hw/cxgb4/mem.c
41004 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
41005 int err;
41006 struct fw_ri_tpte tpt;
41007 u32 stag_idx;
41008 - static atomic_t key;
41009 + static atomic_unchecked_t key;
41010
41011 if (c4iw_fatal_error(rdev))
41012 return -EIO;
41013 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
41014 if (rdev->stats.stag.cur > rdev->stats.stag.max)
41015 rdev->stats.stag.max = rdev->stats.stag.cur;
41016 mutex_unlock(&rdev->stats.lock);
41017 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
41018 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
41019 }
41020 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
41021 __func__, stag_state, type, pdid, stag_idx);
41022 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
41023 index 79b3dbc..96e5fcc 100644
41024 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
41025 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
41026 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
41027 struct ib_atomic_eth *ateth;
41028 struct ipath_ack_entry *e;
41029 u64 vaddr;
41030 - atomic64_t *maddr;
41031 + atomic64_unchecked_t *maddr;
41032 u64 sdata;
41033 u32 rkey;
41034 u8 next;
41035 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
41036 IB_ACCESS_REMOTE_ATOMIC)))
41037 goto nack_acc_unlck;
41038 /* Perform atomic OP and save result. */
41039 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
41040 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
41041 sdata = be64_to_cpu(ateth->swap_data);
41042 e = &qp->s_ack_queue[qp->r_head_ack_queue];
41043 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
41044 - (u64) atomic64_add_return(sdata, maddr) - sdata :
41045 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
41046 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
41047 be64_to_cpu(ateth->compare_data),
41048 sdata);
41049 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
41050 index 1f95bba..9530f87 100644
41051 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
41052 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
41053 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
41054 unsigned long flags;
41055 struct ib_wc wc;
41056 u64 sdata;
41057 - atomic64_t *maddr;
41058 + atomic64_unchecked_t *maddr;
41059 enum ib_wc_status send_status;
41060
41061 /*
41062 @@ -382,11 +382,11 @@ again:
41063 IB_ACCESS_REMOTE_ATOMIC)))
41064 goto acc_err;
41065 /* Perform atomic OP and save result. */
41066 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
41067 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
41068 sdata = wqe->wr.wr.atomic.compare_add;
41069 *(u64 *) sqp->s_sge.sge.vaddr =
41070 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
41071 - (u64) atomic64_add_return(sdata, maddr) - sdata :
41072 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
41073 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
41074 sdata, wqe->wr.wr.atomic.swap);
41075 goto send_comp;
41076 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
41077 index f2a3f48..673ec79 100644
41078 --- a/drivers/infiniband/hw/mlx4/mad.c
41079 +++ b/drivers/infiniband/hw/mlx4/mad.c
41080 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
41081
41082 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
41083 {
41084 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
41085 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
41086 cpu_to_be64(0xff00000000000000LL);
41087 }
41088
41089 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
41090 index 25b2cdf..099ff97 100644
41091 --- a/drivers/infiniband/hw/mlx4/mcg.c
41092 +++ b/drivers/infiniband/hw/mlx4/mcg.c
41093 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
41094 {
41095 char name[20];
41096
41097 - atomic_set(&ctx->tid, 0);
41098 + atomic_set_unchecked(&ctx->tid, 0);
41099 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
41100 ctx->mcg_wq = create_singlethread_workqueue(name);
41101 if (!ctx->mcg_wq)
41102 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
41103 index 036b663..c9a8c73 100644
41104 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
41105 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
41106 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
41107 struct list_head mcg_mgid0_list;
41108 struct workqueue_struct *mcg_wq;
41109 struct mlx4_ib_demux_pv_ctx **tun;
41110 - atomic_t tid;
41111 + atomic_unchecked_t tid;
41112 int flushing; /* flushing the work queue */
41113 };
41114
41115 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
41116 index 9d3e5c1..6f166df 100644
41117 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
41118 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
41119 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
41120 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
41121 }
41122
41123 -int mthca_QUERY_FW(struct mthca_dev *dev)
41124 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
41125 {
41126 struct mthca_mailbox *mailbox;
41127 u32 *outbox;
41128 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41129 CMD_TIME_CLASS_B);
41130 }
41131
41132 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41133 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41134 int num_mtt)
41135 {
41136 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
41137 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
41138 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
41139 }
41140
41141 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41142 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41143 int eq_num)
41144 {
41145 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
41146 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
41147 CMD_TIME_CLASS_B);
41148 }
41149
41150 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
41151 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
41152 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
41153 void *in_mad, void *response_mad)
41154 {
41155 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
41156 index 87897b9..7e79542 100644
41157 --- a/drivers/infiniband/hw/mthca/mthca_main.c
41158 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
41159 @@ -692,7 +692,7 @@ err_close:
41160 return err;
41161 }
41162
41163 -static int mthca_setup_hca(struct mthca_dev *dev)
41164 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
41165 {
41166 int err;
41167
41168 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
41169 index ed9a989..6aa5dc2 100644
41170 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
41171 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
41172 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
41173 * through the bitmaps)
41174 */
41175
41176 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41177 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41178 {
41179 int o;
41180 int m;
41181 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
41182 return key;
41183 }
41184
41185 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41186 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41187 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
41188 {
41189 struct mthca_mailbox *mailbox;
41190 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
41191 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
41192 }
41193
41194 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41195 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41196 u64 *buffer_list, int buffer_size_shift,
41197 int list_len, u64 iova, u64 total_size,
41198 u32 access, struct mthca_mr *mr)
41199 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
41200 index 5b71d43..35a9e14 100644
41201 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
41202 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
41203 @@ -763,7 +763,7 @@ unlock:
41204 return 0;
41205 }
41206
41207 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41208 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41209 {
41210 struct mthca_dev *dev = to_mdev(ibcq->device);
41211 struct mthca_cq *cq = to_mcq(ibcq);
41212 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
41213 index 4291410..d2ab1fb 100644
41214 --- a/drivers/infiniband/hw/nes/nes.c
41215 +++ b/drivers/infiniband/hw/nes/nes.c
41216 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
41217 LIST_HEAD(nes_adapter_list);
41218 static LIST_HEAD(nes_dev_list);
41219
41220 -atomic_t qps_destroyed;
41221 +atomic_unchecked_t qps_destroyed;
41222
41223 static unsigned int ee_flsh_adapter;
41224 static unsigned int sysfs_nonidx_addr;
41225 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
41226 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
41227 struct nes_adapter *nesadapter = nesdev->nesadapter;
41228
41229 - atomic_inc(&qps_destroyed);
41230 + atomic_inc_unchecked(&qps_destroyed);
41231
41232 /* Free the control structures */
41233
41234 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
41235 index 33cc589..3bd6538 100644
41236 --- a/drivers/infiniband/hw/nes/nes.h
41237 +++ b/drivers/infiniband/hw/nes/nes.h
41238 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
41239 extern unsigned int wqm_quanta;
41240 extern struct list_head nes_adapter_list;
41241
41242 -extern atomic_t cm_connects;
41243 -extern atomic_t cm_accepts;
41244 -extern atomic_t cm_disconnects;
41245 -extern atomic_t cm_closes;
41246 -extern atomic_t cm_connecteds;
41247 -extern atomic_t cm_connect_reqs;
41248 -extern atomic_t cm_rejects;
41249 -extern atomic_t mod_qp_timouts;
41250 -extern atomic_t qps_created;
41251 -extern atomic_t qps_destroyed;
41252 -extern atomic_t sw_qps_destroyed;
41253 +extern atomic_unchecked_t cm_connects;
41254 +extern atomic_unchecked_t cm_accepts;
41255 +extern atomic_unchecked_t cm_disconnects;
41256 +extern atomic_unchecked_t cm_closes;
41257 +extern atomic_unchecked_t cm_connecteds;
41258 +extern atomic_unchecked_t cm_connect_reqs;
41259 +extern atomic_unchecked_t cm_rejects;
41260 +extern atomic_unchecked_t mod_qp_timouts;
41261 +extern atomic_unchecked_t qps_created;
41262 +extern atomic_unchecked_t qps_destroyed;
41263 +extern atomic_unchecked_t sw_qps_destroyed;
41264 extern u32 mh_detected;
41265 extern u32 mh_pauses_sent;
41266 extern u32 cm_packets_sent;
41267 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
41268 extern u32 cm_packets_received;
41269 extern u32 cm_packets_dropped;
41270 extern u32 cm_packets_retrans;
41271 -extern atomic_t cm_listens_created;
41272 -extern atomic_t cm_listens_destroyed;
41273 +extern atomic_unchecked_t cm_listens_created;
41274 +extern atomic_unchecked_t cm_listens_destroyed;
41275 extern u32 cm_backlog_drops;
41276 -extern atomic_t cm_loopbacks;
41277 -extern atomic_t cm_nodes_created;
41278 -extern atomic_t cm_nodes_destroyed;
41279 -extern atomic_t cm_accel_dropped_pkts;
41280 -extern atomic_t cm_resets_recvd;
41281 -extern atomic_t pau_qps_created;
41282 -extern atomic_t pau_qps_destroyed;
41283 +extern atomic_unchecked_t cm_loopbacks;
41284 +extern atomic_unchecked_t cm_nodes_created;
41285 +extern atomic_unchecked_t cm_nodes_destroyed;
41286 +extern atomic_unchecked_t cm_accel_dropped_pkts;
41287 +extern atomic_unchecked_t cm_resets_recvd;
41288 +extern atomic_unchecked_t pau_qps_created;
41289 +extern atomic_unchecked_t pau_qps_destroyed;
41290
41291 extern u32 int_mod_timer_init;
41292 extern u32 int_mod_cq_depth_256;
41293 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
41294 index 6b29249..57081dd 100644
41295 --- a/drivers/infiniband/hw/nes/nes_cm.c
41296 +++ b/drivers/infiniband/hw/nes/nes_cm.c
41297 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
41298 u32 cm_packets_retrans;
41299 u32 cm_packets_created;
41300 u32 cm_packets_received;
41301 -atomic_t cm_listens_created;
41302 -atomic_t cm_listens_destroyed;
41303 +atomic_unchecked_t cm_listens_created;
41304 +atomic_unchecked_t cm_listens_destroyed;
41305 u32 cm_backlog_drops;
41306 -atomic_t cm_loopbacks;
41307 -atomic_t cm_nodes_created;
41308 -atomic_t cm_nodes_destroyed;
41309 -atomic_t cm_accel_dropped_pkts;
41310 -atomic_t cm_resets_recvd;
41311 +atomic_unchecked_t cm_loopbacks;
41312 +atomic_unchecked_t cm_nodes_created;
41313 +atomic_unchecked_t cm_nodes_destroyed;
41314 +atomic_unchecked_t cm_accel_dropped_pkts;
41315 +atomic_unchecked_t cm_resets_recvd;
41316
41317 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
41318 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
41319 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
41320
41321 static struct nes_cm_core *g_cm_core;
41322
41323 -atomic_t cm_connects;
41324 -atomic_t cm_accepts;
41325 -atomic_t cm_disconnects;
41326 -atomic_t cm_closes;
41327 -atomic_t cm_connecteds;
41328 -atomic_t cm_connect_reqs;
41329 -atomic_t cm_rejects;
41330 +atomic_unchecked_t cm_connects;
41331 +atomic_unchecked_t cm_accepts;
41332 +atomic_unchecked_t cm_disconnects;
41333 +atomic_unchecked_t cm_closes;
41334 +atomic_unchecked_t cm_connecteds;
41335 +atomic_unchecked_t cm_connect_reqs;
41336 +atomic_unchecked_t cm_rejects;
41337
41338 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
41339 {
41340 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
41341 kfree(listener);
41342 listener = NULL;
41343 ret = 0;
41344 - atomic_inc(&cm_listens_destroyed);
41345 + atomic_inc_unchecked(&cm_listens_destroyed);
41346 } else {
41347 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
41348 }
41349 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
41350 cm_node->rem_mac);
41351
41352 add_hte_node(cm_core, cm_node);
41353 - atomic_inc(&cm_nodes_created);
41354 + atomic_inc_unchecked(&cm_nodes_created);
41355
41356 return cm_node;
41357 }
41358 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
41359 }
41360
41361 atomic_dec(&cm_core->node_cnt);
41362 - atomic_inc(&cm_nodes_destroyed);
41363 + atomic_inc_unchecked(&cm_nodes_destroyed);
41364 nesqp = cm_node->nesqp;
41365 if (nesqp) {
41366 nesqp->cm_node = NULL;
41367 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
41368
41369 static void drop_packet(struct sk_buff *skb)
41370 {
41371 - atomic_inc(&cm_accel_dropped_pkts);
41372 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41373 dev_kfree_skb_any(skb);
41374 }
41375
41376 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
41377 {
41378
41379 int reset = 0; /* whether to send reset in case of err.. */
41380 - atomic_inc(&cm_resets_recvd);
41381 + atomic_inc_unchecked(&cm_resets_recvd);
41382 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
41383 " refcnt=%d\n", cm_node, cm_node->state,
41384 atomic_read(&cm_node->ref_count));
41385 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
41386 rem_ref_cm_node(cm_node->cm_core, cm_node);
41387 return NULL;
41388 }
41389 - atomic_inc(&cm_loopbacks);
41390 + atomic_inc_unchecked(&cm_loopbacks);
41391 loopbackremotenode->loopbackpartner = cm_node;
41392 loopbackremotenode->tcp_cntxt.rcv_wscale =
41393 NES_CM_DEFAULT_RCV_WND_SCALE;
41394 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
41395 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
41396 else {
41397 rem_ref_cm_node(cm_core, cm_node);
41398 - atomic_inc(&cm_accel_dropped_pkts);
41399 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41400 dev_kfree_skb_any(skb);
41401 }
41402 break;
41403 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41404
41405 if ((cm_id) && (cm_id->event_handler)) {
41406 if (issue_disconn) {
41407 - atomic_inc(&cm_disconnects);
41408 + atomic_inc_unchecked(&cm_disconnects);
41409 cm_event.event = IW_CM_EVENT_DISCONNECT;
41410 cm_event.status = disconn_status;
41411 cm_event.local_addr = cm_id->local_addr;
41412 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41413 }
41414
41415 if (issue_close) {
41416 - atomic_inc(&cm_closes);
41417 + atomic_inc_unchecked(&cm_closes);
41418 nes_disconnect(nesqp, 1);
41419
41420 cm_id->provider_data = nesqp;
41421 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41422
41423 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
41424 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
41425 - atomic_inc(&cm_accepts);
41426 + atomic_inc_unchecked(&cm_accepts);
41427
41428 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
41429 netdev_refcnt_read(nesvnic->netdev));
41430 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
41431 struct nes_cm_core *cm_core;
41432 u8 *start_buff;
41433
41434 - atomic_inc(&cm_rejects);
41435 + atomic_inc_unchecked(&cm_rejects);
41436 cm_node = (struct nes_cm_node *)cm_id->provider_data;
41437 loopback = cm_node->loopbackpartner;
41438 cm_core = cm_node->cm_core;
41439 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41440 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
41441 ntohs(laddr->sin_port));
41442
41443 - atomic_inc(&cm_connects);
41444 + atomic_inc_unchecked(&cm_connects);
41445 nesqp->active_conn = 1;
41446
41447 /* cache the cm_id in the qp */
41448 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
41449 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
41450 return err;
41451 }
41452 - atomic_inc(&cm_listens_created);
41453 + atomic_inc_unchecked(&cm_listens_created);
41454 }
41455
41456 cm_id->add_ref(cm_id);
41457 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
41458
41459 if (nesqp->destroyed)
41460 return;
41461 - atomic_inc(&cm_connecteds);
41462 + atomic_inc_unchecked(&cm_connecteds);
41463 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
41464 " local port 0x%04X. jiffies = %lu.\n",
41465 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
41466 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
41467
41468 cm_id->add_ref(cm_id);
41469 ret = cm_id->event_handler(cm_id, &cm_event);
41470 - atomic_inc(&cm_closes);
41471 + atomic_inc_unchecked(&cm_closes);
41472 cm_event.event = IW_CM_EVENT_CLOSE;
41473 cm_event.status = 0;
41474 cm_event.provider_data = cm_id->provider_data;
41475 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
41476 return;
41477 cm_id = cm_node->cm_id;
41478
41479 - atomic_inc(&cm_connect_reqs);
41480 + atomic_inc_unchecked(&cm_connect_reqs);
41481 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41482 cm_node, cm_id, jiffies);
41483
41484 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
41485 return;
41486 cm_id = cm_node->cm_id;
41487
41488 - atomic_inc(&cm_connect_reqs);
41489 + atomic_inc_unchecked(&cm_connect_reqs);
41490 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41491 cm_node, cm_id, jiffies);
41492
41493 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
41494 index 4166452..fc952c3 100644
41495 --- a/drivers/infiniband/hw/nes/nes_mgt.c
41496 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
41497 @@ -40,8 +40,8 @@
41498 #include "nes.h"
41499 #include "nes_mgt.h"
41500
41501 -atomic_t pau_qps_created;
41502 -atomic_t pau_qps_destroyed;
41503 +atomic_unchecked_t pau_qps_created;
41504 +atomic_unchecked_t pau_qps_destroyed;
41505
41506 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
41507 {
41508 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
41509 {
41510 struct sk_buff *skb;
41511 unsigned long flags;
41512 - atomic_inc(&pau_qps_destroyed);
41513 + atomic_inc_unchecked(&pau_qps_destroyed);
41514
41515 /* Free packets that have not yet been forwarded */
41516 /* Lock is acquired by skb_dequeue when removing the skb */
41517 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
41518 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
41519 skb_queue_head_init(&nesqp->pau_list);
41520 spin_lock_init(&nesqp->pau_lock);
41521 - atomic_inc(&pau_qps_created);
41522 + atomic_inc_unchecked(&pau_qps_created);
41523 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
41524 }
41525
41526 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
41527 index 49eb511..a774366 100644
41528 --- a/drivers/infiniband/hw/nes/nes_nic.c
41529 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41530 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41531 target_stat_values[++index] = mh_detected;
41532 target_stat_values[++index] = mh_pauses_sent;
41533 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41534 - target_stat_values[++index] = atomic_read(&cm_connects);
41535 - target_stat_values[++index] = atomic_read(&cm_accepts);
41536 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41537 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41538 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41539 - target_stat_values[++index] = atomic_read(&cm_rejects);
41540 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41541 - target_stat_values[++index] = atomic_read(&qps_created);
41542 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41543 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41544 - target_stat_values[++index] = atomic_read(&cm_closes);
41545 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41546 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41547 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41548 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41549 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41550 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41551 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41552 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41553 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41554 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41555 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41556 target_stat_values[++index] = cm_packets_sent;
41557 target_stat_values[++index] = cm_packets_bounced;
41558 target_stat_values[++index] = cm_packets_created;
41559 target_stat_values[++index] = cm_packets_received;
41560 target_stat_values[++index] = cm_packets_dropped;
41561 target_stat_values[++index] = cm_packets_retrans;
41562 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41563 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41564 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41565 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41566 target_stat_values[++index] = cm_backlog_drops;
41567 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41568 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41569 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41570 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41571 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41572 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41573 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41574 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41575 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41576 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41577 target_stat_values[++index] = nesadapter->free_4kpbl;
41578 target_stat_values[++index] = nesadapter->free_256pbl;
41579 target_stat_values[++index] = int_mod_timer_init;
41580 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41581 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41582 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41583 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41584 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41585 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41586 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41587 }
41588
41589 /**
41590 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41591 index 5b53ca5..443da3c 100644
41592 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41593 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41594 @@ -46,9 +46,9 @@
41595
41596 #include <rdma/ib_umem.h>
41597
41598 -atomic_t mod_qp_timouts;
41599 -atomic_t qps_created;
41600 -atomic_t sw_qps_destroyed;
41601 +atomic_unchecked_t mod_qp_timouts;
41602 +atomic_unchecked_t qps_created;
41603 +atomic_unchecked_t sw_qps_destroyed;
41604
41605 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41606
41607 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41608 if (init_attr->create_flags)
41609 return ERR_PTR(-EINVAL);
41610
41611 - atomic_inc(&qps_created);
41612 + atomic_inc_unchecked(&qps_created);
41613 switch (init_attr->qp_type) {
41614 case IB_QPT_RC:
41615 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41616 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41617 struct iw_cm_event cm_event;
41618 int ret = 0;
41619
41620 - atomic_inc(&sw_qps_destroyed);
41621 + atomic_inc_unchecked(&sw_qps_destroyed);
41622 nesqp->destroyed = 1;
41623
41624 /* Blow away the connection if it exists. */
41625 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41626 index 1946101..09766d2 100644
41627 --- a/drivers/infiniband/hw/qib/qib.h
41628 +++ b/drivers/infiniband/hw/qib/qib.h
41629 @@ -52,6 +52,7 @@
41630 #include <linux/kref.h>
41631 #include <linux/sched.h>
41632 #include <linux/kthread.h>
41633 +#include <linux/slab.h>
41634
41635 #include "qib_common.h"
41636 #include "qib_verbs.h"
41637 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41638 index 922a7fe..bb035db 100644
41639 --- a/drivers/input/gameport/gameport.c
41640 +++ b/drivers/input/gameport/gameport.c
41641 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41642 */
41643 static void gameport_init_port(struct gameport *gameport)
41644 {
41645 - static atomic_t gameport_no = ATOMIC_INIT(0);
41646 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41647
41648 __module_get(THIS_MODULE);
41649
41650 mutex_init(&gameport->drv_mutex);
41651 device_initialize(&gameport->dev);
41652 dev_set_name(&gameport->dev, "gameport%lu",
41653 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41654 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41655 gameport->dev.bus = &gameport_bus;
41656 gameport->dev.release = gameport_release_port;
41657 if (gameport->parent)
41658 diff --git a/drivers/input/input.c b/drivers/input/input.c
41659 index 74f4798..d9f7168 100644
41660 --- a/drivers/input/input.c
41661 +++ b/drivers/input/input.c
41662 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
41663 */
41664 struct input_dev *input_allocate_device(void)
41665 {
41666 - static atomic_t input_no = ATOMIC_INIT(0);
41667 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41668 struct input_dev *dev;
41669
41670 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
41671 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
41672 INIT_LIST_HEAD(&dev->node);
41673
41674 dev_set_name(&dev->dev, "input%ld",
41675 - (unsigned long) atomic_inc_return(&input_no) - 1);
41676 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41677
41678 __module_get(THIS_MODULE);
41679 }
41680 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41681 index 04c69af..5f92d00 100644
41682 --- a/drivers/input/joystick/sidewinder.c
41683 +++ b/drivers/input/joystick/sidewinder.c
41684 @@ -30,6 +30,7 @@
41685 #include <linux/kernel.h>
41686 #include <linux/module.h>
41687 #include <linux/slab.h>
41688 +#include <linux/sched.h>
41689 #include <linux/init.h>
41690 #include <linux/input.h>
41691 #include <linux/gameport.h>
41692 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41693 index 75e3b10..fb390fd 100644
41694 --- a/drivers/input/joystick/xpad.c
41695 +++ b/drivers/input/joystick/xpad.c
41696 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41697
41698 static int xpad_led_probe(struct usb_xpad *xpad)
41699 {
41700 - static atomic_t led_seq = ATOMIC_INIT(0);
41701 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41702 long led_no;
41703 struct xpad_led *led;
41704 struct led_classdev *led_cdev;
41705 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41706 if (!led)
41707 return -ENOMEM;
41708
41709 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41710 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41711
41712 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41713 led->xpad = xpad;
41714 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41715 index e204f26..8459f15 100644
41716 --- a/drivers/input/misc/ims-pcu.c
41717 +++ b/drivers/input/misc/ims-pcu.c
41718 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41719
41720 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41721 {
41722 - static atomic_t device_no = ATOMIC_INIT(0);
41723 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41724
41725 const struct ims_pcu_device_info *info;
41726 u8 device_id;
41727 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41728 }
41729
41730 /* Device appears to be operable, complete initialization */
41731 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41732 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41733
41734 error = ims_pcu_setup_backlight(pcu);
41735 if (error)
41736 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41737 index 2f0b39d..7370f13 100644
41738 --- a/drivers/input/mouse/psmouse.h
41739 +++ b/drivers/input/mouse/psmouse.h
41740 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41741 ssize_t (*set)(struct psmouse *psmouse, void *data,
41742 const char *buf, size_t count);
41743 bool protect;
41744 -};
41745 +} __do_const;
41746 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41747
41748 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41749 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41750 index 4c842c3..590b0bf 100644
41751 --- a/drivers/input/mousedev.c
41752 +++ b/drivers/input/mousedev.c
41753 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41754
41755 spin_unlock_irq(&client->packet_lock);
41756
41757 - if (copy_to_user(buffer, data, count))
41758 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41759 return -EFAULT;
41760
41761 return count;
41762 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41763 index 2b56855..5a55837 100644
41764 --- a/drivers/input/serio/serio.c
41765 +++ b/drivers/input/serio/serio.c
41766 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41767 */
41768 static void serio_init_port(struct serio *serio)
41769 {
41770 - static atomic_t serio_no = ATOMIC_INIT(0);
41771 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41772
41773 __module_get(THIS_MODULE);
41774
41775 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41776 mutex_init(&serio->drv_mutex);
41777 device_initialize(&serio->dev);
41778 dev_set_name(&serio->dev, "serio%ld",
41779 - (long)atomic_inc_return(&serio_no) - 1);
41780 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41781 serio->dev.bus = &serio_bus;
41782 serio->dev.release = serio_release_port;
41783 serio->dev.groups = serio_device_attr_groups;
41784 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41785 index 59df2e7..8f1cafb 100644
41786 --- a/drivers/input/serio/serio_raw.c
41787 +++ b/drivers/input/serio/serio_raw.c
41788 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41789
41790 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41791 {
41792 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41793 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41794 struct serio_raw *serio_raw;
41795 int err;
41796
41797 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41798 }
41799
41800 snprintf(serio_raw->name, sizeof(serio_raw->name),
41801 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41802 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41803 kref_init(&serio_raw->kref);
41804 INIT_LIST_HEAD(&serio_raw->client_list);
41805 init_waitqueue_head(&serio_raw->wait);
41806 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41807 index fbe9ca7..dbee61d 100644
41808 --- a/drivers/iommu/iommu.c
41809 +++ b/drivers/iommu/iommu.c
41810 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41811 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41812 {
41813 bus_register_notifier(bus, &iommu_bus_nb);
41814 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41815 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41816 }
41817
41818 /**
41819 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41820 index 39f81ae..2660096 100644
41821 --- a/drivers/iommu/irq_remapping.c
41822 +++ b/drivers/iommu/irq_remapping.c
41823 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41824 void panic_if_irq_remap(const char *msg)
41825 {
41826 if (irq_remapping_enabled)
41827 - panic(msg);
41828 + panic("%s", msg);
41829 }
41830
41831 static void ir_ack_apic_edge(struct irq_data *data)
41832 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41833
41834 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41835 {
41836 - chip->irq_print_chip = ir_print_prefix;
41837 - chip->irq_ack = ir_ack_apic_edge;
41838 - chip->irq_eoi = ir_ack_apic_level;
41839 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41840 + pax_open_kernel();
41841 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41842 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41843 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41844 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41845 + pax_close_kernel();
41846 }
41847
41848 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41849 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41850 index d0e9480..d2b6340 100644
41851 --- a/drivers/irqchip/irq-gic.c
41852 +++ b/drivers/irqchip/irq-gic.c
41853 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41854 * Supported arch specific GIC irq extension.
41855 * Default make them NULL.
41856 */
41857 -struct irq_chip gic_arch_extn = {
41858 +irq_chip_no_const gic_arch_extn = {
41859 .irq_eoi = NULL,
41860 .irq_mask = NULL,
41861 .irq_unmask = NULL,
41862 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41863 chained_irq_exit(chip, desc);
41864 }
41865
41866 -static struct irq_chip gic_chip = {
41867 +static irq_chip_no_const gic_chip __read_only = {
41868 .name = "GIC",
41869 .irq_mask = gic_mask_irq,
41870 .irq_unmask = gic_unmask_irq,
41871 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41872 index ac6f72b..81150f2 100644
41873 --- a/drivers/isdn/capi/capi.c
41874 +++ b/drivers/isdn/capi/capi.c
41875 @@ -81,8 +81,8 @@ struct capiminor {
41876
41877 struct capi20_appl *ap;
41878 u32 ncci;
41879 - atomic_t datahandle;
41880 - atomic_t msgid;
41881 + atomic_unchecked_t datahandle;
41882 + atomic_unchecked_t msgid;
41883
41884 struct tty_port port;
41885 int ttyinstop;
41886 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41887 capimsg_setu16(s, 2, mp->ap->applid);
41888 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41889 capimsg_setu8 (s, 5, CAPI_RESP);
41890 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41891 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41892 capimsg_setu32(s, 8, mp->ncci);
41893 capimsg_setu16(s, 12, datahandle);
41894 }
41895 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41896 mp->outbytes -= len;
41897 spin_unlock_bh(&mp->outlock);
41898
41899 - datahandle = atomic_inc_return(&mp->datahandle);
41900 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41901 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41902 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41903 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41904 capimsg_setu16(skb->data, 2, mp->ap->applid);
41905 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41906 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41907 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41908 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41909 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41910 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41911 capimsg_setu16(skb->data, 16, len); /* Data length */
41912 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41913 index 600c79b..3752bab 100644
41914 --- a/drivers/isdn/gigaset/interface.c
41915 +++ b/drivers/isdn/gigaset/interface.c
41916 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41917 }
41918 tty->driver_data = cs;
41919
41920 - ++cs->port.count;
41921 + atomic_inc(&cs->port.count);
41922
41923 - if (cs->port.count == 1) {
41924 + if (atomic_read(&cs->port.count) == 1) {
41925 tty_port_tty_set(&cs->port, tty);
41926 cs->port.low_latency = 1;
41927 }
41928 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41929
41930 if (!cs->connected)
41931 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41932 - else if (!cs->port.count)
41933 + else if (!atomic_read(&cs->port.count))
41934 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41935 - else if (!--cs->port.count)
41936 + else if (!atomic_dec_return(&cs->port.count))
41937 tty_port_tty_set(&cs->port, NULL);
41938
41939 mutex_unlock(&cs->mutex);
41940 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41941 index d0a41cb..f0cdb8c 100644
41942 --- a/drivers/isdn/gigaset/usb-gigaset.c
41943 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41944 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41945 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41946 memcpy(cs->hw.usb->bchars, buf, 6);
41947 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41948 - 0, 0, &buf, 6, 2000);
41949 + 0, 0, buf, 6, 2000);
41950 }
41951
41952 static void gigaset_freebcshw(struct bc_state *bcs)
41953 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41954 index 4d9b195..455075c 100644
41955 --- a/drivers/isdn/hardware/avm/b1.c
41956 +++ b/drivers/isdn/hardware/avm/b1.c
41957 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41958 }
41959 if (left) {
41960 if (t4file->user) {
41961 - if (copy_from_user(buf, dp, left))
41962 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41963 return -EFAULT;
41964 } else {
41965 memcpy(buf, dp, left);
41966 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41967 }
41968 if (left) {
41969 if (config->user) {
41970 - if (copy_from_user(buf, dp, left))
41971 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41972 return -EFAULT;
41973 } else {
41974 memcpy(buf, dp, left);
41975 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41976 index 9bb12ba..d4262f7 100644
41977 --- a/drivers/isdn/i4l/isdn_common.c
41978 +++ b/drivers/isdn/i4l/isdn_common.c
41979 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41980 } else
41981 return -EINVAL;
41982 case IIOCDBGVAR:
41983 + if (!capable(CAP_SYS_RAWIO))
41984 + return -EPERM;
41985 if (arg) {
41986 if (copy_to_user(argp, &dev, sizeof(ulong)))
41987 return -EFAULT;
41988 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41989 index 3c5f249..5fac4d0 100644
41990 --- a/drivers/isdn/i4l/isdn_tty.c
41991 +++ b/drivers/isdn/i4l/isdn_tty.c
41992 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41993
41994 #ifdef ISDN_DEBUG_MODEM_OPEN
41995 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41996 - port->count);
41997 + atomic_read(&port->count));
41998 #endif
41999 - port->count++;
42000 + atomic_inc(&port->count);
42001 port->tty = tty;
42002 /*
42003 * Start up serial port
42004 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42005 #endif
42006 return;
42007 }
42008 - if ((tty->count == 1) && (port->count != 1)) {
42009 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
42010 /*
42011 * Uh, oh. tty->count is 1, which means that the tty
42012 * structure will be freed. Info->count should always
42013 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42014 * serial port won't be shutdown.
42015 */
42016 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
42017 - "info->count is %d\n", port->count);
42018 - port->count = 1;
42019 + "info->count is %d\n", atomic_read(&port->count));
42020 + atomic_set(&port->count, 1);
42021 }
42022 - if (--port->count < 0) {
42023 + if (atomic_dec_return(&port->count) < 0) {
42024 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
42025 - info->line, port->count);
42026 - port->count = 0;
42027 + info->line, atomic_read(&port->count));
42028 + atomic_set(&port->count, 0);
42029 }
42030 - if (port->count) {
42031 + if (atomic_read(&port->count)) {
42032 #ifdef ISDN_DEBUG_MODEM_OPEN
42033 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
42034 #endif
42035 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
42036 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
42037 return;
42038 isdn_tty_shutdown(info);
42039 - port->count = 0;
42040 + atomic_set(&port->count, 0);
42041 port->flags &= ~ASYNC_NORMAL_ACTIVE;
42042 port->tty = NULL;
42043 wake_up_interruptible(&port->open_wait);
42044 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
42045 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
42046 modem_info *info = &dev->mdm.info[i];
42047
42048 - if (info->port.count == 0)
42049 + if (atomic_read(&info->port.count) == 0)
42050 continue;
42051 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
42052 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
42053 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
42054 index e74df7c..03a03ba 100644
42055 --- a/drivers/isdn/icn/icn.c
42056 +++ b/drivers/isdn/icn/icn.c
42057 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
42058 if (count > len)
42059 count = len;
42060 if (user) {
42061 - if (copy_from_user(msg, buf, count))
42062 + if (count > sizeof msg || copy_from_user(msg, buf, count))
42063 return -EFAULT;
42064 } else
42065 memcpy(msg, buf, count);
42066 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
42067 index a4f05c5..1433bc5 100644
42068 --- a/drivers/isdn/mISDN/dsp_cmx.c
42069 +++ b/drivers/isdn/mISDN/dsp_cmx.c
42070 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
42071 static u16 dsp_count; /* last sample count */
42072 static int dsp_count_valid; /* if we have last sample count */
42073
42074 -void
42075 +void __intentional_overflow(-1)
42076 dsp_cmx_send(void *arg)
42077 {
42078 struct dsp_conf *conf;
42079 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
42080 index d93e245..e7ece6b 100644
42081 --- a/drivers/leds/leds-clevo-mail.c
42082 +++ b/drivers/leds/leds-clevo-mail.c
42083 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
42084 * detected as working, but in reality it is not) as low as
42085 * possible.
42086 */
42087 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
42088 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
42089 {
42090 .callback = clevo_mail_led_dmi_callback,
42091 .ident = "Clevo D410J",
42092 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
42093 index 5b8f938..b73d657 100644
42094 --- a/drivers/leds/leds-ss4200.c
42095 +++ b/drivers/leds/leds-ss4200.c
42096 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
42097 * detected as working, but in reality it is not) as low as
42098 * possible.
42099 */
42100 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
42101 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
42102 {
42103 .callback = ss4200_led_dmi_callback,
42104 .ident = "Intel SS4200-E",
42105 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
42106 index 0bf1e4e..b4bf44e 100644
42107 --- a/drivers/lguest/core.c
42108 +++ b/drivers/lguest/core.c
42109 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
42110 * The end address needs +1 because __get_vm_area allocates an
42111 * extra guard page, so we need space for that.
42112 */
42113 +
42114 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
42115 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42116 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
42117 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42118 +#else
42119 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42120 VM_ALLOC, switcher_addr, switcher_addr
42121 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42122 +#endif
42123 +
42124 if (!switcher_vma) {
42125 err = -ENOMEM;
42126 printk("lguest: could not map switcher pages high\n");
42127 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
42128 * Now the Switcher is mapped at the right address, we can't fail!
42129 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
42130 */
42131 - memcpy(switcher_vma->addr, start_switcher_text,
42132 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42133 end_switcher_text - start_switcher_text);
42134
42135 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42136 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42137 index bfb39bb..08a603b 100644
42138 --- a/drivers/lguest/page_tables.c
42139 +++ b/drivers/lguest/page_tables.c
42140 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42141 /*:*/
42142
42143 #ifdef CONFIG_X86_PAE
42144 -static void release_pmd(pmd_t *spmd)
42145 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42146 {
42147 /* If the entry's not present, there's nothing to release. */
42148 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42149 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42150 index 5169239..47cb4db 100644
42151 --- a/drivers/lguest/x86/core.c
42152 +++ b/drivers/lguest/x86/core.c
42153 @@ -59,7 +59,7 @@ static struct {
42154 /* Offset from where switcher.S was compiled to where we've copied it */
42155 static unsigned long switcher_offset(void)
42156 {
42157 - return switcher_addr - (unsigned long)start_switcher_text;
42158 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42159 }
42160
42161 /* This cpu's struct lguest_pages (after the Switcher text page) */
42162 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42163 * These copies are pretty cheap, so we do them unconditionally: */
42164 /* Save the current Host top-level page directory.
42165 */
42166 +
42167 +#ifdef CONFIG_PAX_PER_CPU_PGD
42168 + pages->state.host_cr3 = read_cr3();
42169 +#else
42170 pages->state.host_cr3 = __pa(current->mm->pgd);
42171 +#endif
42172 +
42173 /*
42174 * Set up the Guest's page tables to see this CPU's pages (and no
42175 * other CPU's pages).
42176 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42177 * compiled-in switcher code and the high-mapped copy we just made.
42178 */
42179 for (i = 0; i < IDT_ENTRIES; i++)
42180 - default_idt_entries[i] += switcher_offset();
42181 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42182
42183 /*
42184 * Set up the Switcher's per-cpu areas.
42185 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42186 * it will be undisturbed when we switch. To change %cs and jump we
42187 * need this structure to feed to Intel's "lcall" instruction.
42188 */
42189 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42190 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42191 lguest_entry.segment = LGUEST_CS;
42192
42193 /*
42194 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42195 index 40634b0..4f5855e 100644
42196 --- a/drivers/lguest/x86/switcher_32.S
42197 +++ b/drivers/lguest/x86/switcher_32.S
42198 @@ -87,6 +87,7 @@
42199 #include <asm/page.h>
42200 #include <asm/segment.h>
42201 #include <asm/lguest.h>
42202 +#include <asm/processor-flags.h>
42203
42204 // We mark the start of the code to copy
42205 // It's placed in .text tho it's never run here
42206 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42207 // Changes type when we load it: damn Intel!
42208 // For after we switch over our page tables
42209 // That entry will be read-only: we'd crash.
42210 +
42211 +#ifdef CONFIG_PAX_KERNEXEC
42212 + mov %cr0, %edx
42213 + xor $X86_CR0_WP, %edx
42214 + mov %edx, %cr0
42215 +#endif
42216 +
42217 movl $(GDT_ENTRY_TSS*8), %edx
42218 ltr %dx
42219
42220 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42221 // Let's clear it again for our return.
42222 // The GDT descriptor of the Host
42223 // Points to the table after two "size" bytes
42224 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42225 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42226 // Clear "used" from type field (byte 5, bit 2)
42227 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42228 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42229 +
42230 +#ifdef CONFIG_PAX_KERNEXEC
42231 + mov %cr0, %eax
42232 + xor $X86_CR0_WP, %eax
42233 + mov %eax, %cr0
42234 +#endif
42235
42236 // Once our page table's switched, the Guest is live!
42237 // The Host fades as we run this final step.
42238 @@ -295,13 +309,12 @@ deliver_to_host:
42239 // I consulted gcc, and it gave
42240 // These instructions, which I gladly credit:
42241 leal (%edx,%ebx,8), %eax
42242 - movzwl (%eax),%edx
42243 - movl 4(%eax), %eax
42244 - xorw %ax, %ax
42245 - orl %eax, %edx
42246 + movl 4(%eax), %edx
42247 + movw (%eax), %dx
42248 // Now the address of the handler's in %edx
42249 // We call it now: its "iret" drops us home.
42250 - jmp *%edx
42251 + ljmp $__KERNEL_CS, $1f
42252 +1: jmp *%edx
42253
42254 // Every interrupt can come to us here
42255 // But we must truly tell each apart.
42256 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42257 index 0003992..854bbce 100644
42258 --- a/drivers/md/bcache/closure.h
42259 +++ b/drivers/md/bcache/closure.h
42260 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42261 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42262 struct workqueue_struct *wq)
42263 {
42264 - BUG_ON(object_is_on_stack(cl));
42265 + BUG_ON(object_starts_on_stack(cl));
42266 closure_set_ip(cl);
42267 cl->fn = fn;
42268 cl->wq = wq;
42269 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42270 index 547c4c5..5be1de4 100644
42271 --- a/drivers/md/bcache/super.c
42272 +++ b/drivers/md/bcache/super.c
42273 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42274 err:
42275 closure_sync(&op.cl);
42276 /* XXX: test this, it's broken */
42277 - bch_cache_set_error(c, err);
42278 + bch_cache_set_error(c, "%s", err);
42279 }
42280
42281 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42282 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42283 index a7fd821..9dcf6c3 100644
42284 --- a/drivers/md/bitmap.c
42285 +++ b/drivers/md/bitmap.c
42286 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42287 chunk_kb ? "KB" : "B");
42288 if (bitmap->storage.file) {
42289 seq_printf(seq, ", file: ");
42290 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42291 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42292 }
42293
42294 seq_printf(seq, "\n");
42295 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42296 index afe0814..8cf3794 100644
42297 --- a/drivers/md/dm-ioctl.c
42298 +++ b/drivers/md/dm-ioctl.c
42299 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42300 cmd == DM_LIST_VERSIONS_CMD)
42301 return 0;
42302
42303 - if ((cmd == DM_DEV_CREATE_CMD)) {
42304 + if (cmd == DM_DEV_CREATE_CMD) {
42305 if (!*param->name) {
42306 DMWARN("name not supplied when creating device");
42307 return -EINVAL;
42308 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42309 index 9584443..9fc9ac9 100644
42310 --- a/drivers/md/dm-raid1.c
42311 +++ b/drivers/md/dm-raid1.c
42312 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42313
42314 struct mirror {
42315 struct mirror_set *ms;
42316 - atomic_t error_count;
42317 + atomic_unchecked_t error_count;
42318 unsigned long error_type;
42319 struct dm_dev *dev;
42320 sector_t offset;
42321 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42322 struct mirror *m;
42323
42324 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42325 - if (!atomic_read(&m->error_count))
42326 + if (!atomic_read_unchecked(&m->error_count))
42327 return m;
42328
42329 return NULL;
42330 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42331 * simple way to tell if a device has encountered
42332 * errors.
42333 */
42334 - atomic_inc(&m->error_count);
42335 + atomic_inc_unchecked(&m->error_count);
42336
42337 if (test_and_set_bit(error_type, &m->error_type))
42338 return;
42339 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42340 struct mirror *m = get_default_mirror(ms);
42341
42342 do {
42343 - if (likely(!atomic_read(&m->error_count)))
42344 + if (likely(!atomic_read_unchecked(&m->error_count)))
42345 return m;
42346
42347 if (m-- == ms->mirror)
42348 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42349 {
42350 struct mirror *default_mirror = get_default_mirror(m->ms);
42351
42352 - return !atomic_read(&default_mirror->error_count);
42353 + return !atomic_read_unchecked(&default_mirror->error_count);
42354 }
42355
42356 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42357 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42358 */
42359 if (likely(region_in_sync(ms, region, 1)))
42360 m = choose_mirror(ms, bio->bi_sector);
42361 - else if (m && atomic_read(&m->error_count))
42362 + else if (m && atomic_read_unchecked(&m->error_count))
42363 m = NULL;
42364
42365 if (likely(m))
42366 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42367 }
42368
42369 ms->mirror[mirror].ms = ms;
42370 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42371 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42372 ms->mirror[mirror].error_type = 0;
42373 ms->mirror[mirror].offset = offset;
42374
42375 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
42376 */
42377 static char device_status_char(struct mirror *m)
42378 {
42379 - if (!atomic_read(&(m->error_count)))
42380 + if (!atomic_read_unchecked(&(m->error_count)))
42381 return 'A';
42382
42383 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42384 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
42385 index 28a9012..9c0f6a5 100644
42386 --- a/drivers/md/dm-stats.c
42387 +++ b/drivers/md/dm-stats.c
42388 @@ -382,7 +382,7 @@ do_sync_free:
42389 synchronize_rcu_expedited();
42390 dm_stat_free(&s->rcu_head);
42391 } else {
42392 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
42393 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
42394 call_rcu(&s->rcu_head, dm_stat_free);
42395 }
42396 return 0;
42397 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
42398 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
42399 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
42400 ));
42401 - ACCESS_ONCE(last->last_sector) = end_sector;
42402 - ACCESS_ONCE(last->last_rw) = bi_rw;
42403 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
42404 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
42405 }
42406
42407 rcu_read_lock();
42408 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42409 index 73c1712..7347292 100644
42410 --- a/drivers/md/dm-stripe.c
42411 +++ b/drivers/md/dm-stripe.c
42412 @@ -21,7 +21,7 @@ struct stripe {
42413 struct dm_dev *dev;
42414 sector_t physical_start;
42415
42416 - atomic_t error_count;
42417 + atomic_unchecked_t error_count;
42418 };
42419
42420 struct stripe_c {
42421 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42422 kfree(sc);
42423 return r;
42424 }
42425 - atomic_set(&(sc->stripe[i].error_count), 0);
42426 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42427 }
42428
42429 ti->private = sc;
42430 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42431 DMEMIT("%d ", sc->stripes);
42432 for (i = 0; i < sc->stripes; i++) {
42433 DMEMIT("%s ", sc->stripe[i].dev->name);
42434 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42435 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42436 'D' : 'A';
42437 }
42438 buffer[i] = '\0';
42439 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42440 */
42441 for (i = 0; i < sc->stripes; i++)
42442 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42443 - atomic_inc(&(sc->stripe[i].error_count));
42444 - if (atomic_read(&(sc->stripe[i].error_count)) <
42445 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42446 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42447 DM_IO_ERROR_THRESHOLD)
42448 schedule_work(&sc->trigger_event);
42449 }
42450 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42451 index 20a8cc0..5447b11 100644
42452 --- a/drivers/md/dm-table.c
42453 +++ b/drivers/md/dm-table.c
42454 @@ -291,7 +291,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42455 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42456 struct mapped_device *md)
42457 {
42458 - static char *_claim_ptr = "I belong to device-mapper";
42459 + static char _claim_ptr[] = "I belong to device-mapper";
42460 struct block_device *bdev;
42461
42462 int r;
42463 @@ -359,7 +359,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42464 if (!dev_size)
42465 return 0;
42466
42467 - if ((start >= dev_size) || (start + len > dev_size)) {
42468 + if ((start >= dev_size) || (len > dev_size - start)) {
42469 DMWARN("%s: %s too small for target: "
42470 "start=%llu, len=%llu, dev_size=%llu",
42471 dm_device_name(ti->table->md), bdevname(bdev, b),
42472 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42473 index 8a30ad5..72792d3 100644
42474 --- a/drivers/md/dm-thin-metadata.c
42475 +++ b/drivers/md/dm-thin-metadata.c
42476 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42477 {
42478 pmd->info.tm = pmd->tm;
42479 pmd->info.levels = 2;
42480 - pmd->info.value_type.context = pmd->data_sm;
42481 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42482 pmd->info.value_type.size = sizeof(__le64);
42483 pmd->info.value_type.inc = data_block_inc;
42484 pmd->info.value_type.dec = data_block_dec;
42485 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42486
42487 pmd->bl_info.tm = pmd->tm;
42488 pmd->bl_info.levels = 1;
42489 - pmd->bl_info.value_type.context = pmd->data_sm;
42490 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42491 pmd->bl_info.value_type.size = sizeof(__le64);
42492 pmd->bl_info.value_type.inc = data_block_inc;
42493 pmd->bl_info.value_type.dec = data_block_dec;
42494 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42495 index b3e26c7..1efca94 100644
42496 --- a/drivers/md/dm.c
42497 +++ b/drivers/md/dm.c
42498 @@ -179,9 +179,9 @@ struct mapped_device {
42499 /*
42500 * Event handling.
42501 */
42502 - atomic_t event_nr;
42503 + atomic_unchecked_t event_nr;
42504 wait_queue_head_t eventq;
42505 - atomic_t uevent_seq;
42506 + atomic_unchecked_t uevent_seq;
42507 struct list_head uevent_list;
42508 spinlock_t uevent_lock; /* Protect access to uevent_list */
42509
42510 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
42511 spin_lock_init(&md->deferred_lock);
42512 atomic_set(&md->holders, 1);
42513 atomic_set(&md->open_count, 0);
42514 - atomic_set(&md->event_nr, 0);
42515 - atomic_set(&md->uevent_seq, 0);
42516 + atomic_set_unchecked(&md->event_nr, 0);
42517 + atomic_set_unchecked(&md->uevent_seq, 0);
42518 INIT_LIST_HEAD(&md->uevent_list);
42519 spin_lock_init(&md->uevent_lock);
42520
42521 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
42522
42523 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42524
42525 - atomic_inc(&md->event_nr);
42526 + atomic_inc_unchecked(&md->event_nr);
42527 wake_up(&md->eventq);
42528 }
42529
42530 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42531
42532 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42533 {
42534 - return atomic_add_return(1, &md->uevent_seq);
42535 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42536 }
42537
42538 uint32_t dm_get_event_nr(struct mapped_device *md)
42539 {
42540 - return atomic_read(&md->event_nr);
42541 + return atomic_read_unchecked(&md->event_nr);
42542 }
42543
42544 int dm_wait_event(struct mapped_device *md, int event_nr)
42545 {
42546 return wait_event_interruptible(md->eventq,
42547 - (event_nr != atomic_read(&md->event_nr)));
42548 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42549 }
42550
42551 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42552 diff --git a/drivers/md/md.c b/drivers/md/md.c
42553 index ba46d97..f8f5019 100644
42554 --- a/drivers/md/md.c
42555 +++ b/drivers/md/md.c
42556 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42557 * start build, activate spare
42558 */
42559 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42560 -static atomic_t md_event_count;
42561 +static atomic_unchecked_t md_event_count;
42562 void md_new_event(struct mddev *mddev)
42563 {
42564 - atomic_inc(&md_event_count);
42565 + atomic_inc_unchecked(&md_event_count);
42566 wake_up(&md_event_waiters);
42567 }
42568 EXPORT_SYMBOL_GPL(md_new_event);
42569 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42570 */
42571 static void md_new_event_inintr(struct mddev *mddev)
42572 {
42573 - atomic_inc(&md_event_count);
42574 + atomic_inc_unchecked(&md_event_count);
42575 wake_up(&md_event_waiters);
42576 }
42577
42578 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42579 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42580 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42581 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42582 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42583 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42584
42585 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42586 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42587 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42588 else
42589 sb->resync_offset = cpu_to_le64(0);
42590
42591 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42592 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42593
42594 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42595 sb->size = cpu_to_le64(mddev->dev_sectors);
42596 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42597 static ssize_t
42598 errors_show(struct md_rdev *rdev, char *page)
42599 {
42600 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42601 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42602 }
42603
42604 static ssize_t
42605 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42606 char *e;
42607 unsigned long n = simple_strtoul(buf, &e, 10);
42608 if (*buf && (*e == 0 || *e == '\n')) {
42609 - atomic_set(&rdev->corrected_errors, n);
42610 + atomic_set_unchecked(&rdev->corrected_errors, n);
42611 return len;
42612 }
42613 return -EINVAL;
42614 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42615 rdev->sb_loaded = 0;
42616 rdev->bb_page = NULL;
42617 atomic_set(&rdev->nr_pending, 0);
42618 - atomic_set(&rdev->read_errors, 0);
42619 - atomic_set(&rdev->corrected_errors, 0);
42620 + atomic_set_unchecked(&rdev->read_errors, 0);
42621 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42622
42623 INIT_LIST_HEAD(&rdev->same_set);
42624 init_waitqueue_head(&rdev->blocked_wait);
42625 @@ -7043,7 +7043,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42626
42627 spin_unlock(&pers_lock);
42628 seq_printf(seq, "\n");
42629 - seq->poll_event = atomic_read(&md_event_count);
42630 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42631 return 0;
42632 }
42633 if (v == (void*)2) {
42634 @@ -7146,7 +7146,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42635 return error;
42636
42637 seq = file->private_data;
42638 - seq->poll_event = atomic_read(&md_event_count);
42639 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42640 return error;
42641 }
42642
42643 @@ -7160,7 +7160,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42644 /* always allow read */
42645 mask = POLLIN | POLLRDNORM;
42646
42647 - if (seq->poll_event != atomic_read(&md_event_count))
42648 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42649 mask |= POLLERR | POLLPRI;
42650 return mask;
42651 }
42652 @@ -7204,7 +7204,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42653 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42654 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42655 (int)part_stat_read(&disk->part0, sectors[1]) -
42656 - atomic_read(&disk->sync_io);
42657 + atomic_read_unchecked(&disk->sync_io);
42658 /* sync IO will cause sync_io to increase before the disk_stats
42659 * as sync_io is counted when a request starts, and
42660 * disk_stats is counted when it completes.
42661 diff --git a/drivers/md/md.h b/drivers/md/md.h
42662 index 608050c..6e77db5d 100644
42663 --- a/drivers/md/md.h
42664 +++ b/drivers/md/md.h
42665 @@ -94,13 +94,13 @@ struct md_rdev {
42666 * only maintained for arrays that
42667 * support hot removal
42668 */
42669 - atomic_t read_errors; /* number of consecutive read errors that
42670 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42671 * we have tried to ignore.
42672 */
42673 struct timespec last_read_error; /* monotonic time since our
42674 * last read error
42675 */
42676 - atomic_t corrected_errors; /* number of corrected read errors,
42677 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42678 * for reporting to userspace and storing
42679 * in superblock.
42680 */
42681 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42682
42683 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42684 {
42685 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42686 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42687 }
42688
42689 struct md_personality
42690 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42691 index 3e6d115..ffecdeb 100644
42692 --- a/drivers/md/persistent-data/dm-space-map.h
42693 +++ b/drivers/md/persistent-data/dm-space-map.h
42694 @@ -71,6 +71,7 @@ struct dm_space_map {
42695 dm_sm_threshold_fn fn,
42696 void *context);
42697 };
42698 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42699
42700 /*----------------------------------------------------------------*/
42701
42702 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42703 index aacf6bf..67d63f2 100644
42704 --- a/drivers/md/raid1.c
42705 +++ b/drivers/md/raid1.c
42706 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42707 if (r1_sync_page_io(rdev, sect, s,
42708 bio->bi_io_vec[idx].bv_page,
42709 READ) != 0)
42710 - atomic_add(s, &rdev->corrected_errors);
42711 + atomic_add_unchecked(s, &rdev->corrected_errors);
42712 }
42713 sectors -= s;
42714 sect += s;
42715 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42716 test_bit(In_sync, &rdev->flags)) {
42717 if (r1_sync_page_io(rdev, sect, s,
42718 conf->tmppage, READ)) {
42719 - atomic_add(s, &rdev->corrected_errors);
42720 + atomic_add_unchecked(s, &rdev->corrected_errors);
42721 printk(KERN_INFO
42722 "md/raid1:%s: read error corrected "
42723 "(%d sectors at %llu on %s)\n",
42724 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42725 index 73dc8a3..859d581f6 100644
42726 --- a/drivers/md/raid10.c
42727 +++ b/drivers/md/raid10.c
42728 @@ -1319,7 +1319,7 @@ read_again:
42729 /* Could not read all from this device, so we will
42730 * need another r10_bio.
42731 */
42732 - sectors_handled = (r10_bio->sectors + max_sectors
42733 + sectors_handled = (r10_bio->sector + max_sectors
42734 - bio->bi_sector);
42735 r10_bio->sectors = max_sectors;
42736 spin_lock_irq(&conf->device_lock);
42737 @@ -1327,7 +1327,7 @@ read_again:
42738 bio->bi_phys_segments = 2;
42739 else
42740 bio->bi_phys_segments++;
42741 - spin_unlock(&conf->device_lock);
42742 + spin_unlock_irq(&conf->device_lock);
42743 /* Cannot call generic_make_request directly
42744 * as that will be queued in __generic_make_request
42745 * and subsequent mempool_alloc might block
42746 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42747 /* The write handler will notice the lack of
42748 * R10BIO_Uptodate and record any errors etc
42749 */
42750 - atomic_add(r10_bio->sectors,
42751 + atomic_add_unchecked(r10_bio->sectors,
42752 &conf->mirrors[d].rdev->corrected_errors);
42753
42754 /* for reconstruct, we always reschedule after a read.
42755 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42756 {
42757 struct timespec cur_time_mon;
42758 unsigned long hours_since_last;
42759 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42760 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42761
42762 ktime_get_ts(&cur_time_mon);
42763
42764 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42765 * overflowing the shift of read_errors by hours_since_last.
42766 */
42767 if (hours_since_last >= 8 * sizeof(read_errors))
42768 - atomic_set(&rdev->read_errors, 0);
42769 + atomic_set_unchecked(&rdev->read_errors, 0);
42770 else
42771 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42772 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42773 }
42774
42775 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42776 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42777 return;
42778
42779 check_decay_read_errors(mddev, rdev);
42780 - atomic_inc(&rdev->read_errors);
42781 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42782 + atomic_inc_unchecked(&rdev->read_errors);
42783 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42784 char b[BDEVNAME_SIZE];
42785 bdevname(rdev->bdev, b);
42786
42787 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42788 "md/raid10:%s: %s: Raid device exceeded "
42789 "read_error threshold [cur %d:max %d]\n",
42790 mdname(mddev), b,
42791 - atomic_read(&rdev->read_errors), max_read_errors);
42792 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42793 printk(KERN_NOTICE
42794 "md/raid10:%s: %s: Failing raid device\n",
42795 mdname(mddev), b);
42796 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42797 sect +
42798 choose_data_offset(r10_bio, rdev)),
42799 bdevname(rdev->bdev, b));
42800 - atomic_add(s, &rdev->corrected_errors);
42801 + atomic_add_unchecked(s, &rdev->corrected_errors);
42802 }
42803
42804 rdev_dec_pending(rdev, mddev);
42805 @@ -3220,10 +3220,6 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
42806 if (j == conf->copies) {
42807 /* Cannot recover, so abort the recovery or
42808 * record a bad block */
42809 - put_buf(r10_bio);
42810 - if (rb2)
42811 - atomic_dec(&rb2->remaining);
42812 - r10_bio = rb2;
42813 if (any_working) {
42814 /* problem is that there are bad blocks
42815 * on other device(s)
42816 @@ -3255,6 +3251,10 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
42817 mirror->recovery_disabled
42818 = mddev->recovery_disabled;
42819 }
42820 + put_buf(r10_bio);
42821 + if (rb2)
42822 + atomic_dec(&rb2->remaining);
42823 + r10_bio = rb2;
42824 break;
42825 }
42826 }
42827 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42828 index 8a0665d..b322118 100644
42829 --- a/drivers/md/raid5.c
42830 +++ b/drivers/md/raid5.c
42831 @@ -1887,21 +1887,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42832 mdname(conf->mddev), STRIPE_SECTORS,
42833 (unsigned long long)s,
42834 bdevname(rdev->bdev, b));
42835 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42836 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42837 clear_bit(R5_ReadError, &sh->dev[i].flags);
42838 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42839 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42840 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42841
42842 - if (atomic_read(&rdev->read_errors))
42843 - atomic_set(&rdev->read_errors, 0);
42844 + if (atomic_read_unchecked(&rdev->read_errors))
42845 + atomic_set_unchecked(&rdev->read_errors, 0);
42846 } else {
42847 const char *bdn = bdevname(rdev->bdev, b);
42848 int retry = 0;
42849 int set_bad = 0;
42850
42851 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42852 - atomic_inc(&rdev->read_errors);
42853 + atomic_inc_unchecked(&rdev->read_errors);
42854 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42855 printk_ratelimited(
42856 KERN_WARNING
42857 @@ -1929,7 +1929,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42858 mdname(conf->mddev),
42859 (unsigned long long)s,
42860 bdn);
42861 - } else if (atomic_read(&rdev->read_errors)
42862 + } else if (atomic_read_unchecked(&rdev->read_errors)
42863 > conf->max_nr_stripes)
42864 printk(KERN_WARNING
42865 "md/raid:%s: Too many read errors, failing device %s.\n",
42866 @@ -3502,7 +3502,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
42867 */
42868 set_bit(R5_Insync, &dev->flags);
42869
42870 - if (rdev && test_bit(R5_WriteError, &dev->flags)) {
42871 + if (test_bit(R5_WriteError, &dev->flags)) {
42872 /* This flag does not apply to '.replacement'
42873 * only to .rdev, so make sure to check that*/
42874 struct md_rdev *rdev2 = rcu_dereference(
42875 @@ -3515,7 +3515,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
42876 } else
42877 clear_bit(R5_WriteError, &dev->flags);
42878 }
42879 - if (rdev && test_bit(R5_MadeGood, &dev->flags)) {
42880 + if (test_bit(R5_MadeGood, &dev->flags)) {
42881 /* This flag does not apply to '.replacement'
42882 * only to .rdev, so make sure to check that*/
42883 struct md_rdev *rdev2 = rcu_dereference(
42884 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42885 index 401ef64..836e563 100644
42886 --- a/drivers/media/dvb-core/dvbdev.c
42887 +++ b/drivers/media/dvb-core/dvbdev.c
42888 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42889 const struct dvb_device *template, void *priv, int type)
42890 {
42891 struct dvb_device *dvbdev;
42892 - struct file_operations *dvbdevfops;
42893 + file_operations_no_const *dvbdevfops;
42894 struct device *clsdev;
42895 int minor;
42896 int id;
42897 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42898 index 9b6c3bb..baeb5c7 100644
42899 --- a/drivers/media/dvb-frontends/dib3000.h
42900 +++ b/drivers/media/dvb-frontends/dib3000.h
42901 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42902 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42903 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42904 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42905 -};
42906 +} __no_const;
42907
42908 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42909 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42910 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42911 index ecf21d9..b992428d 100644
42912 --- a/drivers/media/pci/cx88/cx88-video.c
42913 +++ b/drivers/media/pci/cx88/cx88-video.c
42914 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42915
42916 /* ------------------------------------------------------------------ */
42917
42918 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42919 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42920 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42921 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42922 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42923 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42924
42925 module_param_array(video_nr, int, NULL, 0444);
42926 module_param_array(vbi_nr, int, NULL, 0444);
42927 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42928 index c08ae3e..eb59af1 100644
42929 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42930 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42931 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42932 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42933
42934 /* ivtv instance counter */
42935 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42936 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42937
42938 /* Parameter declarations */
42939 static int cardtype[IVTV_MAX_CARDS];
42940 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42941 index dfd0a21..6bbb465 100644
42942 --- a/drivers/media/platform/omap/omap_vout.c
42943 +++ b/drivers/media/platform/omap/omap_vout.c
42944 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42945 OMAP_VIDEO2,
42946 };
42947
42948 -static struct videobuf_queue_ops video_vbq_ops;
42949 /* Variables configurable through module params*/
42950 static u32 video1_numbuffers = 3;
42951 static u32 video2_numbuffers = 3;
42952 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42953 {
42954 struct videobuf_queue *q;
42955 struct omap_vout_device *vout = NULL;
42956 + static struct videobuf_queue_ops video_vbq_ops = {
42957 + .buf_setup = omap_vout_buffer_setup,
42958 + .buf_prepare = omap_vout_buffer_prepare,
42959 + .buf_release = omap_vout_buffer_release,
42960 + .buf_queue = omap_vout_buffer_queue,
42961 + };
42962
42963 vout = video_drvdata(file);
42964 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42965 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42966 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42967
42968 q = &vout->vbq;
42969 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42970 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42971 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42972 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42973 spin_lock_init(&vout->vbq_lock);
42974
42975 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42976 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42977 index 04e6490..2df65bf 100644
42978 --- a/drivers/media/platform/s5p-tv/mixer.h
42979 +++ b/drivers/media/platform/s5p-tv/mixer.h
42980 @@ -156,7 +156,7 @@ struct mxr_layer {
42981 /** layer index (unique identifier) */
42982 int idx;
42983 /** callbacks for layer methods */
42984 - struct mxr_layer_ops ops;
42985 + struct mxr_layer_ops *ops;
42986 /** format array */
42987 const struct mxr_format **fmt_array;
42988 /** size of format array */
42989 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42990 index b93a21f..2535195 100644
42991 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42992 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42993 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42994 {
42995 struct mxr_layer *layer;
42996 int ret;
42997 - struct mxr_layer_ops ops = {
42998 + static struct mxr_layer_ops ops = {
42999 .release = mxr_graph_layer_release,
43000 .buffer_set = mxr_graph_buffer_set,
43001 .stream_set = mxr_graph_stream_set,
43002 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
43003 index b713403..53cb5ad 100644
43004 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
43005 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
43006 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
43007 layer->update_buf = next;
43008 }
43009
43010 - layer->ops.buffer_set(layer, layer->update_buf);
43011 + layer->ops->buffer_set(layer, layer->update_buf);
43012
43013 if (done && done != layer->shadow_buf)
43014 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
43015 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
43016 index 641b1f0..49cff30 100644
43017 --- a/drivers/media/platform/s5p-tv/mixer_video.c
43018 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
43019 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
43020 layer->geo.src.height = layer->geo.src.full_height;
43021
43022 mxr_geometry_dump(mdev, &layer->geo);
43023 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43024 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43025 mxr_geometry_dump(mdev, &layer->geo);
43026 }
43027
43028 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
43029 layer->geo.dst.full_width = mbus_fmt.width;
43030 layer->geo.dst.full_height = mbus_fmt.height;
43031 layer->geo.dst.field = mbus_fmt.field;
43032 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43033 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
43034
43035 mxr_geometry_dump(mdev, &layer->geo);
43036 }
43037 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
43038 /* set source size to highest accepted value */
43039 geo->src.full_width = max(geo->dst.full_width, pix->width);
43040 geo->src.full_height = max(geo->dst.full_height, pix->height);
43041 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43042 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43043 mxr_geometry_dump(mdev, &layer->geo);
43044 /* set cropping to total visible screen */
43045 geo->src.width = pix->width;
43046 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
43047 geo->src.x_offset = 0;
43048 geo->src.y_offset = 0;
43049 /* assure consistency of geometry */
43050 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43051 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43052 mxr_geometry_dump(mdev, &layer->geo);
43053 /* set full size to lowest possible value */
43054 geo->src.full_width = 0;
43055 geo->src.full_height = 0;
43056 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43057 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43058 mxr_geometry_dump(mdev, &layer->geo);
43059
43060 /* returning results */
43061 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
43062 target->width = s->r.width;
43063 target->height = s->r.height;
43064
43065 - layer->ops.fix_geometry(layer, stage, s->flags);
43066 + layer->ops->fix_geometry(layer, stage, s->flags);
43067
43068 /* retrieve update selection rectangle */
43069 res.left = target->x_offset;
43070 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
43071 mxr_output_get(mdev);
43072
43073 mxr_layer_update_output(layer);
43074 - layer->ops.format_set(layer);
43075 + layer->ops->format_set(layer);
43076 /* enabling layer in hardware */
43077 spin_lock_irqsave(&layer->enq_slock, flags);
43078 layer->state = MXR_LAYER_STREAMING;
43079 spin_unlock_irqrestore(&layer->enq_slock, flags);
43080
43081 - layer->ops.stream_set(layer, MXR_ENABLE);
43082 + layer->ops->stream_set(layer, MXR_ENABLE);
43083 mxr_streamer_get(mdev);
43084
43085 return 0;
43086 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
43087 spin_unlock_irqrestore(&layer->enq_slock, flags);
43088
43089 /* disabling layer in hardware */
43090 - layer->ops.stream_set(layer, MXR_DISABLE);
43091 + layer->ops->stream_set(layer, MXR_DISABLE);
43092 /* remove one streamer */
43093 mxr_streamer_put(mdev);
43094 /* allow changes in output configuration */
43095 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
43096
43097 void mxr_layer_release(struct mxr_layer *layer)
43098 {
43099 - if (layer->ops.release)
43100 - layer->ops.release(layer);
43101 + if (layer->ops->release)
43102 + layer->ops->release(layer);
43103 }
43104
43105 void mxr_base_layer_release(struct mxr_layer *layer)
43106 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
43107
43108 layer->mdev = mdev;
43109 layer->idx = idx;
43110 - layer->ops = *ops;
43111 + layer->ops = ops;
43112
43113 spin_lock_init(&layer->enq_slock);
43114 INIT_LIST_HEAD(&layer->enq_list);
43115 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43116 index 3d13a63..da31bf1 100644
43117 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43118 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43119 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
43120 {
43121 struct mxr_layer *layer;
43122 int ret;
43123 - struct mxr_layer_ops ops = {
43124 + static struct mxr_layer_ops ops = {
43125 .release = mxr_vp_layer_release,
43126 .buffer_set = mxr_vp_buffer_set,
43127 .stream_set = mxr_vp_stream_set,
43128 diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
43129 index 1d3f119..75f40bb 100644
43130 --- a/drivers/media/platform/vivi.c
43131 +++ b/drivers/media/platform/vivi.c
43132 @@ -58,8 +58,8 @@ MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
43133 MODULE_LICENSE("Dual BSD/GPL");
43134 MODULE_VERSION(VIVI_VERSION);
43135
43136 -static unsigned video_nr = -1;
43137 -module_param(video_nr, uint, 0644);
43138 +static int video_nr = -1;
43139 +module_param(video_nr, int, 0644);
43140 MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
43141
43142 static unsigned n_devs = 1;
43143 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
43144 index 545c04c..a14bded 100644
43145 --- a/drivers/media/radio/radio-cadet.c
43146 +++ b/drivers/media/radio/radio-cadet.c
43147 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43148 unsigned char readbuf[RDS_BUFFER];
43149 int i = 0;
43150
43151 + if (count > RDS_BUFFER)
43152 + return -EFAULT;
43153 mutex_lock(&dev->lock);
43154 if (dev->rdsstat == 0)
43155 cadet_start_rds(dev);
43156 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43157 while (i < count && dev->rdsin != dev->rdsout)
43158 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
43159
43160 - if (i && copy_to_user(data, readbuf, i))
43161 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
43162 i = -EFAULT;
43163 unlock:
43164 mutex_unlock(&dev->lock);
43165 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
43166 index 5236035..c622c74 100644
43167 --- a/drivers/media/radio/radio-maxiradio.c
43168 +++ b/drivers/media/radio/radio-maxiradio.c
43169 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
43170 /* TEA5757 pin mappings */
43171 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
43172
43173 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
43174 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
43175
43176 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
43177 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
43178 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
43179 index b914772..7ddbf9b 100644
43180 --- a/drivers/media/radio/radio-shark.c
43181 +++ b/drivers/media/radio/radio-shark.c
43182 @@ -79,7 +79,7 @@ struct shark_device {
43183 u32 last_val;
43184 };
43185
43186 -static atomic_t shark_instance = ATOMIC_INIT(0);
43187 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43188
43189 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43190 {
43191 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43192 index 9fb6697..f167415 100644
43193 --- a/drivers/media/radio/radio-shark2.c
43194 +++ b/drivers/media/radio/radio-shark2.c
43195 @@ -74,7 +74,7 @@ struct shark_device {
43196 u8 *transfer_buffer;
43197 };
43198
43199 -static atomic_t shark_instance = ATOMIC_INIT(0);
43200 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43201
43202 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43203 {
43204 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43205 index 9c9084c..a9e8dfb 100644
43206 --- a/drivers/media/radio/radio-si476x.c
43207 +++ b/drivers/media/radio/radio-si476x.c
43208 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43209 struct si476x_radio *radio;
43210 struct v4l2_ctrl *ctrl;
43211
43212 - static atomic_t instance = ATOMIC_INIT(0);
43213 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43214
43215 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43216 if (!radio)
43217 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43218 index 46da365..3ba4206 100644
43219 --- a/drivers/media/rc/rc-main.c
43220 +++ b/drivers/media/rc/rc-main.c
43221 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43222 int rc_register_device(struct rc_dev *dev)
43223 {
43224 static bool raw_init = false; /* raw decoders loaded? */
43225 - static atomic_t devno = ATOMIC_INIT(0);
43226 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43227 struct rc_map *rc_map;
43228 const char *path;
43229 int rc;
43230 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
43231 */
43232 mutex_lock(&dev->lock);
43233
43234 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43235 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43236 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43237 dev_set_drvdata(&dev->dev, dev);
43238 rc = device_add(&dev->dev);
43239 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43240 index 20e345d..da56fe4 100644
43241 --- a/drivers/media/usb/dvb-usb/cxusb.c
43242 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43243 @@ -1101,7 +1101,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43244
43245 struct dib0700_adapter_state {
43246 int (*set_param_save) (struct dvb_frontend *);
43247 -};
43248 +} __no_const;
43249
43250 static int dib7070_set_param_override(struct dvb_frontend *fe)
43251 {
43252 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43253 index 71b22f5..a63b33f 100644
43254 --- a/drivers/media/usb/dvb-usb/dw2102.c
43255 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43256 @@ -121,7 +121,7 @@ struct su3000_state {
43257
43258 struct s6x0_state {
43259 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43260 -};
43261 +} __no_const;
43262
43263 /* debug */
43264 static int dvb_usb_dw2102_debug;
43265 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43266 index 8f7a6a4..59502dd 100644
43267 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43268 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43269 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43270 __u32 reserved;
43271 };
43272
43273 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43274 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43275 enum v4l2_memory memory)
43276 {
43277 void __user *up_pln;
43278 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43279 return 0;
43280 }
43281
43282 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43283 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43284 enum v4l2_memory memory)
43285 {
43286 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43287 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43288 put_user(kp->start_block, &up->start_block) ||
43289 put_user(kp->blocks, &up->blocks) ||
43290 put_user(tmp, &up->edid) ||
43291 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43292 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43293 return -EFAULT;
43294 return 0;
43295 }
43296 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43297 index 02d1b63..5fd6b16 100644
43298 --- a/drivers/media/v4l2-core/v4l2-device.c
43299 +++ b/drivers/media/v4l2-core/v4l2-device.c
43300 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43301 EXPORT_SYMBOL_GPL(v4l2_device_put);
43302
43303 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43304 - atomic_t *instance)
43305 + atomic_unchecked_t *instance)
43306 {
43307 - int num = atomic_inc_return(instance) - 1;
43308 + int num = atomic_inc_return_unchecked(instance) - 1;
43309 int len = strlen(basename);
43310
43311 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43312 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43313 index 68e6b5e..d8b923e 100644
43314 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43315 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43316 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43317 struct file *file, void *fh, void *p);
43318 } u;
43319 void (*debug)(const void *arg, bool write_only);
43320 -};
43321 +} __do_const;
43322 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43323
43324 /* This control needs a priority check */
43325 #define INFO_FL_PRIO (1 << 0)
43326 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43327 struct video_device *vfd = video_devdata(file);
43328 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43329 bool write_only = false;
43330 - struct v4l2_ioctl_info default_info;
43331 + v4l2_ioctl_info_no_const default_info;
43332 const struct v4l2_ioctl_info *info;
43333 void *fh = file->private_data;
43334 struct v4l2_fh *vfh = NULL;
43335 @@ -2194,7 +2195,7 @@ done:
43336 }
43337
43338 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43339 - void * __user *user_ptr, void ***kernel_ptr)
43340 + void __user **user_ptr, void ***kernel_ptr)
43341 {
43342 int ret = 0;
43343
43344 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43345 ret = -EINVAL;
43346 break;
43347 }
43348 - *user_ptr = (void __user *)buf->m.planes;
43349 + *user_ptr = (void __force_user *)buf->m.planes;
43350 *kernel_ptr = (void *)&buf->m.planes;
43351 *array_size = sizeof(struct v4l2_plane) * buf->length;
43352 ret = 1;
43353 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43354 ret = -EINVAL;
43355 break;
43356 }
43357 - *user_ptr = (void __user *)ctrls->controls;
43358 + *user_ptr = (void __force_user *)ctrls->controls;
43359 *kernel_ptr = (void *)&ctrls->controls;
43360 *array_size = sizeof(struct v4l2_ext_control)
43361 * ctrls->count;
43362 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43363 index 767ff4d..c69d259 100644
43364 --- a/drivers/message/fusion/mptbase.c
43365 +++ b/drivers/message/fusion/mptbase.c
43366 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43367 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43368 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43369
43370 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43371 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43372 +#else
43373 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43374 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43375 +#endif
43376 +
43377 /*
43378 * Rounding UP to nearest 4-kB boundary here...
43379 */
43380 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43381 ioc->facts.GlobalCredits);
43382
43383 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43384 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43385 + NULL, NULL);
43386 +#else
43387 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43388 +#endif
43389 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43390 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43391 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43392 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43393 index dd239bd..689c4f7 100644
43394 --- a/drivers/message/fusion/mptsas.c
43395 +++ b/drivers/message/fusion/mptsas.c
43396 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43397 return 0;
43398 }
43399
43400 +static inline void
43401 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43402 +{
43403 + if (phy_info->port_details) {
43404 + phy_info->port_details->rphy = rphy;
43405 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43406 + ioc->name, rphy));
43407 + }
43408 +
43409 + if (rphy) {
43410 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43411 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43412 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43413 + ioc->name, rphy, rphy->dev.release));
43414 + }
43415 +}
43416 +
43417 /* no mutex */
43418 static void
43419 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43420 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43421 return NULL;
43422 }
43423
43424 -static inline void
43425 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43426 -{
43427 - if (phy_info->port_details) {
43428 - phy_info->port_details->rphy = rphy;
43429 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43430 - ioc->name, rphy));
43431 - }
43432 -
43433 - if (rphy) {
43434 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43435 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43436 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43437 - ioc->name, rphy, rphy->dev.release));
43438 - }
43439 -}
43440 -
43441 static inline struct sas_port *
43442 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43443 {
43444 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43445 index 727819c..ad74694 100644
43446 --- a/drivers/message/fusion/mptscsih.c
43447 +++ b/drivers/message/fusion/mptscsih.c
43448 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43449
43450 h = shost_priv(SChost);
43451
43452 - if (h) {
43453 - if (h->info_kbuf == NULL)
43454 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43455 - return h->info_kbuf;
43456 - h->info_kbuf[0] = '\0';
43457 + if (!h)
43458 + return NULL;
43459
43460 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43461 - h->info_kbuf[size-1] = '\0';
43462 - }
43463 + if (h->info_kbuf == NULL)
43464 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43465 + return h->info_kbuf;
43466 + h->info_kbuf[0] = '\0';
43467 +
43468 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43469 + h->info_kbuf[size-1] = '\0';
43470
43471 return h->info_kbuf;
43472 }
43473 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43474 index b7d87cd..3fb36da 100644
43475 --- a/drivers/message/i2o/i2o_proc.c
43476 +++ b/drivers/message/i2o/i2o_proc.c
43477 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43478 "Array Controller Device"
43479 };
43480
43481 -static char *chtostr(char *tmp, u8 *chars, int n)
43482 -{
43483 - tmp[0] = 0;
43484 - return strncat(tmp, (char *)chars, n);
43485 -}
43486 -
43487 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43488 char *group)
43489 {
43490 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43491 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43492 {
43493 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43494 - static u32 work32[5];
43495 - static u8 *work8 = (u8 *) work32;
43496 - static u16 *work16 = (u16 *) work32;
43497 + u32 work32[5];
43498 + u8 *work8 = (u8 *) work32;
43499 + u16 *work16 = (u16 *) work32;
43500 int token;
43501 u32 hwcap;
43502
43503 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43504 } *result;
43505
43506 i2o_exec_execute_ddm_table ddm_table;
43507 - char tmp[28 + 1];
43508
43509 result = kmalloc(sizeof(*result), GFP_KERNEL);
43510 if (!result)
43511 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43512
43513 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43514 seq_printf(seq, "%-#8x", ddm_table.module_id);
43515 - seq_printf(seq, "%-29s",
43516 - chtostr(tmp, ddm_table.module_name_version, 28));
43517 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43518 seq_printf(seq, "%9d ", ddm_table.data_size);
43519 seq_printf(seq, "%8d", ddm_table.code_size);
43520
43521 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43522
43523 i2o_driver_result_table *result;
43524 i2o_driver_store_table *dst;
43525 - char tmp[28 + 1];
43526
43527 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43528 if (result == NULL)
43529 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43530
43531 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43532 seq_printf(seq, "%-#8x", dst->module_id);
43533 - seq_printf(seq, "%-29s",
43534 - chtostr(tmp, dst->module_name_version, 28));
43535 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43536 + seq_printf(seq, "%-.28s", dst->module_name_version);
43537 + seq_printf(seq, "%-.8s", dst->date);
43538 seq_printf(seq, "%8d ", dst->module_size);
43539 seq_printf(seq, "%8d ", dst->mpb_size);
43540 seq_printf(seq, "0x%04x", dst->module_flags);
43541 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43542 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43543 {
43544 struct i2o_device *d = (struct i2o_device *)seq->private;
43545 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43546 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43547 // == (allow) 512d bytes (max)
43548 - static u16 *work16 = (u16 *) work32;
43549 + u16 *work16 = (u16 *) work32;
43550 int token;
43551 - char tmp[16 + 1];
43552
43553 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43554
43555 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43556 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43557 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43558 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43559 - seq_printf(seq, "Vendor info : %s\n",
43560 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43561 - seq_printf(seq, "Product info : %s\n",
43562 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43563 - seq_printf(seq, "Description : %s\n",
43564 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43565 - seq_printf(seq, "Product rev. : %s\n",
43566 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43567 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43568 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43569 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43570 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43571
43572 seq_printf(seq, "Serial number : ");
43573 print_serial_number(seq, (u8 *) (work32 + 16),
43574 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43575 u8 pad[256]; // allow up to 256 byte (max) serial number
43576 } result;
43577
43578 - char tmp[24 + 1];
43579 -
43580 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43581
43582 if (token < 0) {
43583 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43584 }
43585
43586 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43587 - seq_printf(seq, "Module name : %s\n",
43588 - chtostr(tmp, result.module_name, 24));
43589 - seq_printf(seq, "Module revision : %s\n",
43590 - chtostr(tmp, result.module_rev, 8));
43591 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43592 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43593
43594 seq_printf(seq, "Serial number : ");
43595 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43596 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43597 u8 instance_number[4];
43598 } result;
43599
43600 - char tmp[64 + 1];
43601 -
43602 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43603
43604 if (token < 0) {
43605 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43606 return 0;
43607 }
43608
43609 - seq_printf(seq, "Device name : %s\n",
43610 - chtostr(tmp, result.device_name, 64));
43611 - seq_printf(seq, "Service name : %s\n",
43612 - chtostr(tmp, result.service_name, 64));
43613 - seq_printf(seq, "Physical name : %s\n",
43614 - chtostr(tmp, result.physical_location, 64));
43615 - seq_printf(seq, "Instance number : %s\n",
43616 - chtostr(tmp, result.instance_number, 4));
43617 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43618 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43619 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43620 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43621
43622 return 0;
43623 }
43624 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43625 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43626 {
43627 struct i2o_device *d = (struct i2o_device *)seq->private;
43628 - static u32 work32[12];
43629 - static u16 *work16 = (u16 *) work32;
43630 - static u8 *work8 = (u8 *) work32;
43631 + u32 work32[12];
43632 + u16 *work16 = (u16 *) work32;
43633 + u8 *work8 = (u8 *) work32;
43634 int token;
43635
43636 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43637 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43638 index a8c08f3..155fe3d 100644
43639 --- a/drivers/message/i2o/iop.c
43640 +++ b/drivers/message/i2o/iop.c
43641 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43642
43643 spin_lock_irqsave(&c->context_list_lock, flags);
43644
43645 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43646 - atomic_inc(&c->context_list_counter);
43647 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43648 + atomic_inc_unchecked(&c->context_list_counter);
43649
43650 - entry->context = atomic_read(&c->context_list_counter);
43651 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43652
43653 list_add(&entry->list, &c->context_list);
43654
43655 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43656
43657 #if BITS_PER_LONG == 64
43658 spin_lock_init(&c->context_list_lock);
43659 - atomic_set(&c->context_list_counter, 0);
43660 + atomic_set_unchecked(&c->context_list_counter, 0);
43661 INIT_LIST_HEAD(&c->context_list);
43662 #endif
43663
43664 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43665 index fcbb2e9..2635e11 100644
43666 --- a/drivers/mfd/janz-cmodio.c
43667 +++ b/drivers/mfd/janz-cmodio.c
43668 @@ -13,6 +13,7 @@
43669
43670 #include <linux/kernel.h>
43671 #include <linux/module.h>
43672 +#include <linux/slab.h>
43673 #include <linux/init.h>
43674 #include <linux/pci.h>
43675 #include <linux/interrupt.h>
43676 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43677 index de7fb80..7c1b931 100644
43678 --- a/drivers/mfd/max8925-i2c.c
43679 +++ b/drivers/mfd/max8925-i2c.c
43680 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43681 const struct i2c_device_id *id)
43682 {
43683 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
43684 - static struct max8925_chip *chip;
43685 + struct max8925_chip *chip;
43686 struct device_node *node = client->dev.of_node;
43687
43688 if (node && !pdata) {
43689 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43690 index d792772..cd73ba3 100644
43691 --- a/drivers/mfd/tps65910.c
43692 +++ b/drivers/mfd/tps65910.c
43693 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43694 struct tps65910_platform_data *pdata)
43695 {
43696 int ret = 0;
43697 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43698 + struct regmap_irq_chip *tps6591x_irqs_chip;
43699
43700 if (!irq) {
43701 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43702 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43703 index 9aa6d1e..1631bfc 100644
43704 --- a/drivers/mfd/twl4030-irq.c
43705 +++ b/drivers/mfd/twl4030-irq.c
43706 @@ -35,6 +35,7 @@
43707 #include <linux/of.h>
43708 #include <linux/irqdomain.h>
43709 #include <linux/i2c/twl.h>
43710 +#include <asm/pgtable.h>
43711
43712 #include "twl-core.h"
43713
43714 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43715 * Install an irq handler for each of the SIH modules;
43716 * clone dummy irq_chip since PIH can't *do* anything
43717 */
43718 - twl4030_irq_chip = dummy_irq_chip;
43719 - twl4030_irq_chip.name = "twl4030";
43720 + pax_open_kernel();
43721 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43722 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43723
43724 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43725 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43726 + pax_close_kernel();
43727
43728 for (i = irq_base; i < irq_end; i++) {
43729 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43730 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43731 index 464419b..64bae8d 100644
43732 --- a/drivers/misc/c2port/core.c
43733 +++ b/drivers/misc/c2port/core.c
43734 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
43735 goto error_idr_alloc;
43736 c2dev->id = ret;
43737
43738 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43739 + pax_open_kernel();
43740 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43741 + pax_close_kernel();
43742
43743 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
43744 "c2port%d", c2dev->id);
43745 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43746 index 36f5d52..32311c3 100644
43747 --- a/drivers/misc/kgdbts.c
43748 +++ b/drivers/misc/kgdbts.c
43749 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43750 char before[BREAK_INSTR_SIZE];
43751 char after[BREAK_INSTR_SIZE];
43752
43753 - probe_kernel_read(before, (char *)kgdbts_break_test,
43754 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43755 BREAK_INSTR_SIZE);
43756 init_simple_test();
43757 ts.tst = plant_and_detach_test;
43758 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43759 /* Activate test with initial breakpoint */
43760 if (!is_early)
43761 kgdb_breakpoint();
43762 - probe_kernel_read(after, (char *)kgdbts_break_test,
43763 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43764 BREAK_INSTR_SIZE);
43765 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43766 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43767 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43768 index 036effe..b3a6336 100644
43769 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43770 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43771 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43772 * the lid is closed. This leads to interrupts as soon as a little move
43773 * is done.
43774 */
43775 - atomic_inc(&lis3->count);
43776 + atomic_inc_unchecked(&lis3->count);
43777
43778 wake_up_interruptible(&lis3->misc_wait);
43779 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43780 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43781 if (lis3->pm_dev)
43782 pm_runtime_get_sync(lis3->pm_dev);
43783
43784 - atomic_set(&lis3->count, 0);
43785 + atomic_set_unchecked(&lis3->count, 0);
43786 return 0;
43787 }
43788
43789 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43790 add_wait_queue(&lis3->misc_wait, &wait);
43791 while (true) {
43792 set_current_state(TASK_INTERRUPTIBLE);
43793 - data = atomic_xchg(&lis3->count, 0);
43794 + data = atomic_xchg_unchecked(&lis3->count, 0);
43795 if (data)
43796 break;
43797
43798 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43799 struct lis3lv02d, miscdev);
43800
43801 poll_wait(file, &lis3->misc_wait, wait);
43802 - if (atomic_read(&lis3->count))
43803 + if (atomic_read_unchecked(&lis3->count))
43804 return POLLIN | POLLRDNORM;
43805 return 0;
43806 }
43807 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43808 index c439c82..1f20f57 100644
43809 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43810 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43811 @@ -297,7 +297,7 @@ struct lis3lv02d {
43812 struct input_polled_dev *idev; /* input device */
43813 struct platform_device *pdev; /* platform device */
43814 struct regulator_bulk_data regulators[2];
43815 - atomic_t count; /* interrupt count after last read */
43816 + atomic_unchecked_t count; /* interrupt count after last read */
43817 union axis_conversion ac; /* hw -> logical axis */
43818 int mapped_btns[3];
43819
43820 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43821 index 2f30bad..c4c13d0 100644
43822 --- a/drivers/misc/sgi-gru/gruhandles.c
43823 +++ b/drivers/misc/sgi-gru/gruhandles.c
43824 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43825 unsigned long nsec;
43826
43827 nsec = CLKS2NSEC(clks);
43828 - atomic_long_inc(&mcs_op_statistics[op].count);
43829 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43830 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43831 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43832 if (mcs_op_statistics[op].max < nsec)
43833 mcs_op_statistics[op].max = nsec;
43834 }
43835 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43836 index 4f76359..cdfcb2e 100644
43837 --- a/drivers/misc/sgi-gru/gruprocfs.c
43838 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43839 @@ -32,9 +32,9 @@
43840
43841 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43842
43843 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43844 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43845 {
43846 - unsigned long val = atomic_long_read(v);
43847 + unsigned long val = atomic_long_read_unchecked(v);
43848
43849 seq_printf(s, "%16lu %s\n", val, id);
43850 }
43851 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43852
43853 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43854 for (op = 0; op < mcsop_last; op++) {
43855 - count = atomic_long_read(&mcs_op_statistics[op].count);
43856 - total = atomic_long_read(&mcs_op_statistics[op].total);
43857 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43858 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43859 max = mcs_op_statistics[op].max;
43860 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43861 count ? total / count : 0, max);
43862 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43863 index 5c3ce24..4915ccb 100644
43864 --- a/drivers/misc/sgi-gru/grutables.h
43865 +++ b/drivers/misc/sgi-gru/grutables.h
43866 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43867 * GRU statistics.
43868 */
43869 struct gru_stats_s {
43870 - atomic_long_t vdata_alloc;
43871 - atomic_long_t vdata_free;
43872 - atomic_long_t gts_alloc;
43873 - atomic_long_t gts_free;
43874 - atomic_long_t gms_alloc;
43875 - atomic_long_t gms_free;
43876 - atomic_long_t gts_double_allocate;
43877 - atomic_long_t assign_context;
43878 - atomic_long_t assign_context_failed;
43879 - atomic_long_t free_context;
43880 - atomic_long_t load_user_context;
43881 - atomic_long_t load_kernel_context;
43882 - atomic_long_t lock_kernel_context;
43883 - atomic_long_t unlock_kernel_context;
43884 - atomic_long_t steal_user_context;
43885 - atomic_long_t steal_kernel_context;
43886 - atomic_long_t steal_context_failed;
43887 - atomic_long_t nopfn;
43888 - atomic_long_t asid_new;
43889 - atomic_long_t asid_next;
43890 - atomic_long_t asid_wrap;
43891 - atomic_long_t asid_reuse;
43892 - atomic_long_t intr;
43893 - atomic_long_t intr_cbr;
43894 - atomic_long_t intr_tfh;
43895 - atomic_long_t intr_spurious;
43896 - atomic_long_t intr_mm_lock_failed;
43897 - atomic_long_t call_os;
43898 - atomic_long_t call_os_wait_queue;
43899 - atomic_long_t user_flush_tlb;
43900 - atomic_long_t user_unload_context;
43901 - atomic_long_t user_exception;
43902 - atomic_long_t set_context_option;
43903 - atomic_long_t check_context_retarget_intr;
43904 - atomic_long_t check_context_unload;
43905 - atomic_long_t tlb_dropin;
43906 - atomic_long_t tlb_preload_page;
43907 - atomic_long_t tlb_dropin_fail_no_asid;
43908 - atomic_long_t tlb_dropin_fail_upm;
43909 - atomic_long_t tlb_dropin_fail_invalid;
43910 - atomic_long_t tlb_dropin_fail_range_active;
43911 - atomic_long_t tlb_dropin_fail_idle;
43912 - atomic_long_t tlb_dropin_fail_fmm;
43913 - atomic_long_t tlb_dropin_fail_no_exception;
43914 - atomic_long_t tfh_stale_on_fault;
43915 - atomic_long_t mmu_invalidate_range;
43916 - atomic_long_t mmu_invalidate_page;
43917 - atomic_long_t flush_tlb;
43918 - atomic_long_t flush_tlb_gru;
43919 - atomic_long_t flush_tlb_gru_tgh;
43920 - atomic_long_t flush_tlb_gru_zero_asid;
43921 + atomic_long_unchecked_t vdata_alloc;
43922 + atomic_long_unchecked_t vdata_free;
43923 + atomic_long_unchecked_t gts_alloc;
43924 + atomic_long_unchecked_t gts_free;
43925 + atomic_long_unchecked_t gms_alloc;
43926 + atomic_long_unchecked_t gms_free;
43927 + atomic_long_unchecked_t gts_double_allocate;
43928 + atomic_long_unchecked_t assign_context;
43929 + atomic_long_unchecked_t assign_context_failed;
43930 + atomic_long_unchecked_t free_context;
43931 + atomic_long_unchecked_t load_user_context;
43932 + atomic_long_unchecked_t load_kernel_context;
43933 + atomic_long_unchecked_t lock_kernel_context;
43934 + atomic_long_unchecked_t unlock_kernel_context;
43935 + atomic_long_unchecked_t steal_user_context;
43936 + atomic_long_unchecked_t steal_kernel_context;
43937 + atomic_long_unchecked_t steal_context_failed;
43938 + atomic_long_unchecked_t nopfn;
43939 + atomic_long_unchecked_t asid_new;
43940 + atomic_long_unchecked_t asid_next;
43941 + atomic_long_unchecked_t asid_wrap;
43942 + atomic_long_unchecked_t asid_reuse;
43943 + atomic_long_unchecked_t intr;
43944 + atomic_long_unchecked_t intr_cbr;
43945 + atomic_long_unchecked_t intr_tfh;
43946 + atomic_long_unchecked_t intr_spurious;
43947 + atomic_long_unchecked_t intr_mm_lock_failed;
43948 + atomic_long_unchecked_t call_os;
43949 + atomic_long_unchecked_t call_os_wait_queue;
43950 + atomic_long_unchecked_t user_flush_tlb;
43951 + atomic_long_unchecked_t user_unload_context;
43952 + atomic_long_unchecked_t user_exception;
43953 + atomic_long_unchecked_t set_context_option;
43954 + atomic_long_unchecked_t check_context_retarget_intr;
43955 + atomic_long_unchecked_t check_context_unload;
43956 + atomic_long_unchecked_t tlb_dropin;
43957 + atomic_long_unchecked_t tlb_preload_page;
43958 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43959 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43960 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43961 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43962 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43963 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43964 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43965 + atomic_long_unchecked_t tfh_stale_on_fault;
43966 + atomic_long_unchecked_t mmu_invalidate_range;
43967 + atomic_long_unchecked_t mmu_invalidate_page;
43968 + atomic_long_unchecked_t flush_tlb;
43969 + atomic_long_unchecked_t flush_tlb_gru;
43970 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43971 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43972
43973 - atomic_long_t copy_gpa;
43974 - atomic_long_t read_gpa;
43975 + atomic_long_unchecked_t copy_gpa;
43976 + atomic_long_unchecked_t read_gpa;
43977
43978 - atomic_long_t mesq_receive;
43979 - atomic_long_t mesq_receive_none;
43980 - atomic_long_t mesq_send;
43981 - atomic_long_t mesq_send_failed;
43982 - atomic_long_t mesq_noop;
43983 - atomic_long_t mesq_send_unexpected_error;
43984 - atomic_long_t mesq_send_lb_overflow;
43985 - atomic_long_t mesq_send_qlimit_reached;
43986 - atomic_long_t mesq_send_amo_nacked;
43987 - atomic_long_t mesq_send_put_nacked;
43988 - atomic_long_t mesq_page_overflow;
43989 - atomic_long_t mesq_qf_locked;
43990 - atomic_long_t mesq_qf_noop_not_full;
43991 - atomic_long_t mesq_qf_switch_head_failed;
43992 - atomic_long_t mesq_qf_unexpected_error;
43993 - atomic_long_t mesq_noop_unexpected_error;
43994 - atomic_long_t mesq_noop_lb_overflow;
43995 - atomic_long_t mesq_noop_qlimit_reached;
43996 - atomic_long_t mesq_noop_amo_nacked;
43997 - atomic_long_t mesq_noop_put_nacked;
43998 - atomic_long_t mesq_noop_page_overflow;
43999 + atomic_long_unchecked_t mesq_receive;
44000 + atomic_long_unchecked_t mesq_receive_none;
44001 + atomic_long_unchecked_t mesq_send;
44002 + atomic_long_unchecked_t mesq_send_failed;
44003 + atomic_long_unchecked_t mesq_noop;
44004 + atomic_long_unchecked_t mesq_send_unexpected_error;
44005 + atomic_long_unchecked_t mesq_send_lb_overflow;
44006 + atomic_long_unchecked_t mesq_send_qlimit_reached;
44007 + atomic_long_unchecked_t mesq_send_amo_nacked;
44008 + atomic_long_unchecked_t mesq_send_put_nacked;
44009 + atomic_long_unchecked_t mesq_page_overflow;
44010 + atomic_long_unchecked_t mesq_qf_locked;
44011 + atomic_long_unchecked_t mesq_qf_noop_not_full;
44012 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
44013 + atomic_long_unchecked_t mesq_qf_unexpected_error;
44014 + atomic_long_unchecked_t mesq_noop_unexpected_error;
44015 + atomic_long_unchecked_t mesq_noop_lb_overflow;
44016 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
44017 + atomic_long_unchecked_t mesq_noop_amo_nacked;
44018 + atomic_long_unchecked_t mesq_noop_put_nacked;
44019 + atomic_long_unchecked_t mesq_noop_page_overflow;
44020
44021 };
44022
44023 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
44024 tghop_invalidate, mcsop_last};
44025
44026 struct mcs_op_statistic {
44027 - atomic_long_t count;
44028 - atomic_long_t total;
44029 + atomic_long_unchecked_t count;
44030 + atomic_long_unchecked_t total;
44031 unsigned long max;
44032 };
44033
44034 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
44035
44036 #define STAT(id) do { \
44037 if (gru_options & OPT_STATS) \
44038 - atomic_long_inc(&gru_stats.id); \
44039 + atomic_long_inc_unchecked(&gru_stats.id); \
44040 } while (0)
44041
44042 #ifdef CONFIG_SGI_GRU_DEBUG
44043 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
44044 index c862cd4..0d176fe 100644
44045 --- a/drivers/misc/sgi-xp/xp.h
44046 +++ b/drivers/misc/sgi-xp/xp.h
44047 @@ -288,7 +288,7 @@ struct xpc_interface {
44048 xpc_notify_func, void *);
44049 void (*received) (short, int, void *);
44050 enum xp_retval (*partid_to_nasids) (short, void *);
44051 -};
44052 +} __no_const;
44053
44054 extern struct xpc_interface xpc_interface;
44055
44056 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
44057 index b94d5f7..7f494c5 100644
44058 --- a/drivers/misc/sgi-xp/xpc.h
44059 +++ b/drivers/misc/sgi-xp/xpc.h
44060 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
44061 void (*received_payload) (struct xpc_channel *, void *);
44062 void (*notify_senders_of_disconnect) (struct xpc_channel *);
44063 };
44064 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
44065
44066 /* struct xpc_partition act_state values (for XPC HB) */
44067
44068 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
44069 /* found in xpc_main.c */
44070 extern struct device *xpc_part;
44071 extern struct device *xpc_chan;
44072 -extern struct xpc_arch_operations xpc_arch_ops;
44073 +extern xpc_arch_operations_no_const xpc_arch_ops;
44074 extern int xpc_disengage_timelimit;
44075 extern int xpc_disengage_timedout;
44076 extern int xpc_activate_IRQ_rcvd;
44077 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
44078 index 82dc574..8539ab2 100644
44079 --- a/drivers/misc/sgi-xp/xpc_main.c
44080 +++ b/drivers/misc/sgi-xp/xpc_main.c
44081 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
44082 .notifier_call = xpc_system_die,
44083 };
44084
44085 -struct xpc_arch_operations xpc_arch_ops;
44086 +xpc_arch_operations_no_const xpc_arch_ops;
44087
44088 /*
44089 * Timer function to enforce the timelimit on the partition disengage.
44090 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
44091
44092 if (((die_args->trapnr == X86_TRAP_MF) ||
44093 (die_args->trapnr == X86_TRAP_XF)) &&
44094 - !user_mode_vm(die_args->regs))
44095 + !user_mode(die_args->regs))
44096 xpc_die_deactivate();
44097
44098 break;
44099 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
44100 index ef18348..1b53cf0 100644
44101 --- a/drivers/mmc/core/mmc_ops.c
44102 +++ b/drivers/mmc/core/mmc_ops.c
44103 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
44104 void *data_buf;
44105 int is_on_stack;
44106
44107 - is_on_stack = object_is_on_stack(buf);
44108 + is_on_stack = object_starts_on_stack(buf);
44109 if (is_on_stack) {
44110 /*
44111 * dma onto stack is unsafe/nonportable, but callers to this
44112 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
44113 index 81b2994..dce857e 100644
44114 --- a/drivers/mmc/host/dw_mmc.h
44115 +++ b/drivers/mmc/host/dw_mmc.h
44116 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
44117 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
44118 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
44119 int (*parse_dt)(struct dw_mci *host);
44120 -};
44121 +} __do_const;
44122 #endif /* _DW_MMC_H_ */
44123 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
44124 index c3785ed..1984c44 100644
44125 --- a/drivers/mmc/host/mmci.c
44126 +++ b/drivers/mmc/host/mmci.c
44127 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
44128 }
44129
44130 if (variant->busy_detect) {
44131 - mmci_ops.card_busy = mmci_card_busy;
44132 + pax_open_kernel();
44133 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
44134 + pax_close_kernel();
44135 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
44136 }
44137
44138 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
44139 index 6debda9..2ba7427 100644
44140 --- a/drivers/mmc/host/sdhci-s3c.c
44141 +++ b/drivers/mmc/host/sdhci-s3c.c
44142 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
44143 * we can use overriding functions instead of default.
44144 */
44145 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
44146 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44147 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44148 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44149 + pax_open_kernel();
44150 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44151 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44152 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44153 + pax_close_kernel();
44154 }
44155
44156 /* It supports additional host capabilities if needed */
44157 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
44158 index 096993f..f02c23b 100644
44159 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
44160 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
44161 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
44162 size_t totlen = 0, thislen;
44163 int ret = 0;
44164 size_t buflen = 0;
44165 - static char *buffer;
44166 + char *buffer;
44167
44168 if (!ECCBUF_SIZE) {
44169 /* We should fall back to a general writev implementation.
44170 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
44171 index 2ed2bb3..2d0b82e 100644
44172 --- a/drivers/mtd/nand/denali.c
44173 +++ b/drivers/mtd/nand/denali.c
44174 @@ -24,6 +24,7 @@
44175 #include <linux/slab.h>
44176 #include <linux/mtd/mtd.h>
44177 #include <linux/module.h>
44178 +#include <linux/slab.h>
44179
44180 #include "denali.h"
44181
44182 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
44183 index 51b9d6a..52af9a7 100644
44184 --- a/drivers/mtd/nftlmount.c
44185 +++ b/drivers/mtd/nftlmount.c
44186 @@ -24,6 +24,7 @@
44187 #include <asm/errno.h>
44188 #include <linux/delay.h>
44189 #include <linux/slab.h>
44190 +#include <linux/sched.h>
44191 #include <linux/mtd/mtd.h>
44192 #include <linux/mtd/nand.h>
44193 #include <linux/mtd/nftl.h>
44194 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44195 index 4b8e895..6b3c498 100644
44196 --- a/drivers/mtd/sm_ftl.c
44197 +++ b/drivers/mtd/sm_ftl.c
44198 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44199 #define SM_CIS_VENDOR_OFFSET 0x59
44200 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44201 {
44202 - struct attribute_group *attr_group;
44203 + attribute_group_no_const *attr_group;
44204 struct attribute **attributes;
44205 struct sm_sysfs_attribute *vendor_attribute;
44206
44207 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44208 index dd8057d..22aaf36 100644
44209 --- a/drivers/net/bonding/bond_main.c
44210 +++ b/drivers/net/bonding/bond_main.c
44211 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
44212 return tx_queues;
44213 }
44214
44215 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44216 +static struct rtnl_link_ops bond_link_ops = {
44217 .kind = "bond",
44218 .priv_size = sizeof(struct bonding),
44219 .setup = bond_setup,
44220 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
44221
44222 bond_destroy_debugfs();
44223
44224 - rtnl_link_unregister(&bond_link_ops);
44225 unregister_pernet_subsys(&bond_net_ops);
44226 + rtnl_link_unregister(&bond_link_ops);
44227
44228 #ifdef CONFIG_NET_POLL_CONTROLLER
44229 /*
44230 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44231 index f92f001..0b2f9bf 100644
44232 --- a/drivers/net/ethernet/8390/ax88796.c
44233 +++ b/drivers/net/ethernet/8390/ax88796.c
44234 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44235 if (ax->plat->reg_offsets)
44236 ei_local->reg_offset = ax->plat->reg_offsets;
44237 else {
44238 + resource_size_t _mem_size = mem_size;
44239 + do_div(_mem_size, 0x18);
44240 ei_local->reg_offset = ax->reg_offsets;
44241 for (ret = 0; ret < 0x18; ret++)
44242 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44243 + ax->reg_offsets[ret] = _mem_size * ret;
44244 }
44245
44246 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44247 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44248 index da8fcaa..f4b5d3b 100644
44249 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44250 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44251 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44252 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44253 {
44254 /* RX_MODE controlling object */
44255 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44256 + bnx2x_init_rx_mode_obj(bp);
44257
44258 /* multicast configuration controlling object */
44259 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44260 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44261 index 9fbeee5..5e3e37a 100644
44262 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44263 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44264 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44265 return rc;
44266 }
44267
44268 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44269 - struct bnx2x_rx_mode_obj *o)
44270 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44271 {
44272 if (CHIP_IS_E1x(bp)) {
44273 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44274 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44275 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44276 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44277 } else {
44278 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44279 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44280 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44281 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44282 }
44283 }
44284
44285 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44286 index 658f4e3..15074a6 100644
44287 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44288 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44289 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44290
44291 /********************* RX MODE ****************/
44292
44293 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44294 - struct bnx2x_rx_mode_obj *o);
44295 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44296
44297 /**
44298 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44299 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44300 index 7025780..e55a71c 100644
44301 --- a/drivers/net/ethernet/broadcom/tg3.h
44302 +++ b/drivers/net/ethernet/broadcom/tg3.h
44303 @@ -147,6 +147,7 @@
44304 #define CHIPREV_ID_5750_A0 0x4000
44305 #define CHIPREV_ID_5750_A1 0x4001
44306 #define CHIPREV_ID_5750_A3 0x4003
44307 +#define CHIPREV_ID_5750_C1 0x4201
44308 #define CHIPREV_ID_5750_C2 0x4202
44309 #define CHIPREV_ID_5752_A0_HW 0x5000
44310 #define CHIPREV_ID_5752_A0 0x6000
44311 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44312 index 8cffcdf..aadf043 100644
44313 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44314 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44315 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44316 */
44317 struct l2t_skb_cb {
44318 arp_failure_handler_func arp_failure_handler;
44319 -};
44320 +} __no_const;
44321
44322 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44323
44324 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44325 index c73cabd..cd278b1 100644
44326 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44327 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44328 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
44329
44330 int i;
44331 struct adapter *ap = netdev2adap(dev);
44332 - static const unsigned int *reg_ranges;
44333 + const unsigned int *reg_ranges;
44334 int arr_size = 0, buf_size = 0;
44335
44336 if (is_t4(ap->chip)) {
44337 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44338 index 263b92c..f05134b 100644
44339 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44340 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44341 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44342 for (i=0; i<ETH_ALEN; i++) {
44343 tmp.addr[i] = dev->dev_addr[i];
44344 }
44345 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44346 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44347 break;
44348
44349 case DE4X5_SET_HWADDR: /* Set the hardware address */
44350 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44351 spin_lock_irqsave(&lp->lock, flags);
44352 memcpy(&statbuf, &lp->pktStats, ioc->len);
44353 spin_unlock_irqrestore(&lp->lock, flags);
44354 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44355 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44356 return -EFAULT;
44357 break;
44358 }
44359 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44360 index 2c38cc4..0323f6e 100644
44361 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44362 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44363 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44364
44365 if (wrapped)
44366 newacc += 65536;
44367 - ACCESS_ONCE(*acc) = newacc;
44368 + ACCESS_ONCE_RW(*acc) = newacc;
44369 }
44370
44371 static void populate_erx_stats(struct be_adapter *adapter,
44372 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44373 index 212f44b..fb69959 100644
44374 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44375 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44376 @@ -31,6 +31,8 @@
44377 #include <linux/netdevice.h>
44378 #include <linux/phy.h>
44379 #include <linux/platform_device.h>
44380 +#include <linux/interrupt.h>
44381 +#include <linux/irqreturn.h>
44382 #include <net/ip.h>
44383
44384 #include "ftgmac100.h"
44385 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44386 index 8be5b40..081bc1b 100644
44387 --- a/drivers/net/ethernet/faraday/ftmac100.c
44388 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44389 @@ -31,6 +31,8 @@
44390 #include <linux/module.h>
44391 #include <linux/netdevice.h>
44392 #include <linux/platform_device.h>
44393 +#include <linux/interrupt.h>
44394 +#include <linux/irqreturn.h>
44395
44396 #include "ftmac100.h"
44397
44398 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44399 index 5184e2a..acb28c3 100644
44400 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44401 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44402 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44403 }
44404
44405 /* update the base incval used to calculate frequency adjustment */
44406 - ACCESS_ONCE(adapter->base_incval) = incval;
44407 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44408 smp_mb();
44409
44410 /* need lock to prevent incorrect read while modifying cyclecounter */
44411 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44412 index fbe5363..266b4e3 100644
44413 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44414 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44415 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44416 struct __vxge_hw_fifo *fifo;
44417 struct vxge_hw_fifo_config *config;
44418 u32 txdl_size, txdl_per_memblock;
44419 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44420 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44421 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44422 + };
44423 +
44424 struct __vxge_hw_virtualpath *vpath;
44425
44426 if ((vp == NULL) || (attr == NULL)) {
44427 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44428 goto exit;
44429 }
44430
44431 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44432 -
44433 fifo->mempool =
44434 __vxge_hw_mempool_create(vpath->hldev,
44435 fifo->config->memblock_size,
44436 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44437 index f09e787..f3916a8 100644
44438 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44439 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44440 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
44441
44442 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
44443 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
44444 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44445 + pax_open_kernel();
44446 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44447 + pax_close_kernel();
44448 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44449 } else {
44450 return -EIO;
44451 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44452 index 0248a4c..9648d96 100644
44453 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44454 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44455 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44456 case QLCNIC_NON_PRIV_FUNC:
44457 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44458 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44459 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44460 + pax_open_kernel();
44461 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44462 + pax_close_kernel();
44463 break;
44464 case QLCNIC_PRIV_FUNC:
44465 ahw->op_mode = QLCNIC_PRIV_FUNC;
44466 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44467 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44468 + pax_open_kernel();
44469 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44470 + pax_close_kernel();
44471 break;
44472 case QLCNIC_MGMT_FUNC:
44473 ahw->op_mode = QLCNIC_MGMT_FUNC;
44474 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44475 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44476 + pax_open_kernel();
44477 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44478 + pax_close_kernel();
44479 break;
44480 default:
44481 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44482 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44483 index 1551360..ed6510f 100644
44484 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44485 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44486 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44487 struct qlcnic_dump_entry *entry;
44488 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44489 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44490 - static const struct qlcnic_dump_operations *fw_dump_ops;
44491 + const struct qlcnic_dump_operations *fw_dump_ops;
44492 struct device *dev = &adapter->pdev->dev;
44493 struct qlcnic_hardware_context *ahw;
44494 void *temp_buffer;
44495 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44496 index fb3f8dc..9d2ff38 100644
44497 --- a/drivers/net/ethernet/realtek/r8169.c
44498 +++ b/drivers/net/ethernet/realtek/r8169.c
44499 @@ -759,22 +759,22 @@ struct rtl8169_private {
44500 struct mdio_ops {
44501 void (*write)(struct rtl8169_private *, int, int);
44502 int (*read)(struct rtl8169_private *, int);
44503 - } mdio_ops;
44504 + } __no_const mdio_ops;
44505
44506 struct pll_power_ops {
44507 void (*down)(struct rtl8169_private *);
44508 void (*up)(struct rtl8169_private *);
44509 - } pll_power_ops;
44510 + } __no_const pll_power_ops;
44511
44512 struct jumbo_ops {
44513 void (*enable)(struct rtl8169_private *);
44514 void (*disable)(struct rtl8169_private *);
44515 - } jumbo_ops;
44516 + } __no_const jumbo_ops;
44517
44518 struct csi_ops {
44519 void (*write)(struct rtl8169_private *, int, int);
44520 u32 (*read)(struct rtl8169_private *, int);
44521 - } csi_ops;
44522 + } __no_const csi_ops;
44523
44524 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44525 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44526 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44527 index 3dd39dc..85efa46 100644
44528 --- a/drivers/net/ethernet/sfc/ptp.c
44529 +++ b/drivers/net/ethernet/sfc/ptp.c
44530 @@ -541,7 +541,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44531 ptp->start.dma_addr);
44532
44533 /* Clear flag that signals MC ready */
44534 - ACCESS_ONCE(*start) = 0;
44535 + ACCESS_ONCE_RW(*start) = 0;
44536 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44537 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44538 EFX_BUG_ON_PARANOID(rc);
44539 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44540 index 50617c5..b13724c 100644
44541 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44542 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44543 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44544
44545 writel(value, ioaddr + MMC_CNTRL);
44546
44547 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44548 - MMC_CNTRL, value);
44549 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44550 +// MMC_CNTRL, value);
44551 }
44552
44553 /* To mask all all interrupts.*/
44554 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44555 index e6fe0d8..2b7d752 100644
44556 --- a/drivers/net/hyperv/hyperv_net.h
44557 +++ b/drivers/net/hyperv/hyperv_net.h
44558 @@ -101,7 +101,7 @@ struct rndis_device {
44559
44560 enum rndis_device_state state;
44561 bool link_state;
44562 - atomic_t new_req_id;
44563 + atomic_unchecked_t new_req_id;
44564
44565 spinlock_t request_lock;
44566 struct list_head req_list;
44567 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44568 index 0775f0a..d4fb316 100644
44569 --- a/drivers/net/hyperv/rndis_filter.c
44570 +++ b/drivers/net/hyperv/rndis_filter.c
44571 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44572 * template
44573 */
44574 set = &rndis_msg->msg.set_req;
44575 - set->req_id = atomic_inc_return(&dev->new_req_id);
44576 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44577
44578 /* Add to the request list */
44579 spin_lock_irqsave(&dev->request_lock, flags);
44580 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44581
44582 /* Setup the rndis set */
44583 halt = &request->request_msg.msg.halt_req;
44584 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44585 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44586
44587 /* Ignore return since this msg is optional. */
44588 rndis_filter_send_request(dev, request);
44589 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44590 index bf0d55e..82bcfbd1 100644
44591 --- a/drivers/net/ieee802154/fakehard.c
44592 +++ b/drivers/net/ieee802154/fakehard.c
44593 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44594 phy->transmit_power = 0xbf;
44595
44596 dev->netdev_ops = &fake_ops;
44597 - dev->ml_priv = &fake_mlme;
44598 + dev->ml_priv = (void *)&fake_mlme;
44599
44600 priv = netdev_priv(dev);
44601 priv->phy = phy;
44602 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44603 index 9bf46bd..bfdaa84 100644
44604 --- a/drivers/net/macvlan.c
44605 +++ b/drivers/net/macvlan.c
44606 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44607 int macvlan_link_register(struct rtnl_link_ops *ops)
44608 {
44609 /* common fields */
44610 - ops->priv_size = sizeof(struct macvlan_dev);
44611 - ops->validate = macvlan_validate;
44612 - ops->maxtype = IFLA_MACVLAN_MAX;
44613 - ops->policy = macvlan_policy;
44614 - ops->changelink = macvlan_changelink;
44615 - ops->get_size = macvlan_get_size;
44616 - ops->fill_info = macvlan_fill_info;
44617 + pax_open_kernel();
44618 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44619 + *(void **)&ops->validate = macvlan_validate;
44620 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44621 + *(const void **)&ops->policy = macvlan_policy;
44622 + *(void **)&ops->changelink = macvlan_changelink;
44623 + *(void **)&ops->get_size = macvlan_get_size;
44624 + *(void **)&ops->fill_info = macvlan_fill_info;
44625 + pax_close_kernel();
44626
44627 return rtnl_link_register(ops);
44628 };
44629 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44630 return NOTIFY_DONE;
44631 }
44632
44633 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44634 +static struct notifier_block macvlan_notifier_block = {
44635 .notifier_call = macvlan_device_event,
44636 };
44637
44638 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44639 index 5895e4d..0343d45 100644
44640 --- a/drivers/net/macvtap.c
44641 +++ b/drivers/net/macvtap.c
44642 @@ -1182,7 +1182,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44643 return NOTIFY_DONE;
44644 }
44645
44646 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44647 +static struct notifier_block macvtap_notifier_block = {
44648 .notifier_call = macvtap_device_event,
44649 };
44650
44651 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44652 index daec9b0..6428fcb 100644
44653 --- a/drivers/net/phy/mdio-bitbang.c
44654 +++ b/drivers/net/phy/mdio-bitbang.c
44655 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44656 struct mdiobb_ctrl *ctrl = bus->priv;
44657
44658 module_put(ctrl->ops->owner);
44659 + mdiobus_unregister(bus);
44660 mdiobus_free(bus);
44661 }
44662 EXPORT_SYMBOL(free_mdio_bitbang);
44663 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44664 index 72ff14b..11d442d 100644
44665 --- a/drivers/net/ppp/ppp_generic.c
44666 +++ b/drivers/net/ppp/ppp_generic.c
44667 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44668 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44669 struct ppp_stats stats;
44670 struct ppp_comp_stats cstats;
44671 - char *vers;
44672
44673 switch (cmd) {
44674 case SIOCGPPPSTATS:
44675 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44676 break;
44677
44678 case SIOCGPPPVER:
44679 - vers = PPP_VERSION;
44680 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44681 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44682 break;
44683 err = 0;
44684 break;
44685 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44686 index 1252d9c..80e660b 100644
44687 --- a/drivers/net/slip/slhc.c
44688 +++ b/drivers/net/slip/slhc.c
44689 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44690 register struct tcphdr *thp;
44691 register struct iphdr *ip;
44692 register struct cstate *cs;
44693 - int len, hdrlen;
44694 + long len, hdrlen;
44695 unsigned char *cp = icp;
44696
44697 /* We've got a compressed packet; read the change byte */
44698 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44699 index 6327df2..e6e1ebe 100644
44700 --- a/drivers/net/team/team.c
44701 +++ b/drivers/net/team/team.c
44702 @@ -2873,7 +2873,7 @@ static int team_device_event(struct notifier_block *unused,
44703 return NOTIFY_DONE;
44704 }
44705
44706 -static struct notifier_block team_notifier_block __read_mostly = {
44707 +static struct notifier_block team_notifier_block = {
44708 .notifier_call = team_device_event,
44709 };
44710
44711 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44712 index 7c8343a..80d1e69 100644
44713 --- a/drivers/net/tun.c
44714 +++ b/drivers/net/tun.c
44715 @@ -1838,7 +1838,7 @@ unlock:
44716 }
44717
44718 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44719 - unsigned long arg, int ifreq_len)
44720 + unsigned long arg, size_t ifreq_len)
44721 {
44722 struct tun_file *tfile = file->private_data;
44723 struct tun_struct *tun;
44724 @@ -1851,6 +1851,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44725 unsigned int ifindex;
44726 int ret;
44727
44728 + if (ifreq_len > sizeof ifr)
44729 + return -EFAULT;
44730 +
44731 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44732 if (copy_from_user(&ifr, argp, ifreq_len))
44733 return -EFAULT;
44734 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44735 index 86292e6..8d34433 100644
44736 --- a/drivers/net/usb/hso.c
44737 +++ b/drivers/net/usb/hso.c
44738 @@ -71,7 +71,7 @@
44739 #include <asm/byteorder.h>
44740 #include <linux/serial_core.h>
44741 #include <linux/serial.h>
44742 -
44743 +#include <asm/local.h>
44744
44745 #define MOD_AUTHOR "Option Wireless"
44746 #define MOD_DESCRIPTION "USB High Speed Option driver"
44747 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44748 struct urb *urb;
44749
44750 urb = serial->rx_urb[0];
44751 - if (serial->port.count > 0) {
44752 + if (atomic_read(&serial->port.count) > 0) {
44753 count = put_rxbuf_data(urb, serial);
44754 if (count == -1)
44755 return;
44756 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44757 DUMP1(urb->transfer_buffer, urb->actual_length);
44758
44759 /* Anyone listening? */
44760 - if (serial->port.count == 0)
44761 + if (atomic_read(&serial->port.count) == 0)
44762 return;
44763
44764 if (status == 0) {
44765 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44766 tty_port_tty_set(&serial->port, tty);
44767
44768 /* check for port already opened, if not set the termios */
44769 - serial->port.count++;
44770 - if (serial->port.count == 1) {
44771 + if (atomic_inc_return(&serial->port.count) == 1) {
44772 serial->rx_state = RX_IDLE;
44773 /* Force default termio settings */
44774 _hso_serial_set_termios(tty, NULL);
44775 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44776 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44777 if (result) {
44778 hso_stop_serial_device(serial->parent);
44779 - serial->port.count--;
44780 + atomic_dec(&serial->port.count);
44781 kref_put(&serial->parent->ref, hso_serial_ref_free);
44782 }
44783 } else {
44784 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44785
44786 /* reset the rts and dtr */
44787 /* do the actual close */
44788 - serial->port.count--;
44789 + atomic_dec(&serial->port.count);
44790
44791 - if (serial->port.count <= 0) {
44792 - serial->port.count = 0;
44793 + if (atomic_read(&serial->port.count) <= 0) {
44794 + atomic_set(&serial->port.count, 0);
44795 tty_port_tty_set(&serial->port, NULL);
44796 if (!usb_gone)
44797 hso_stop_serial_device(serial->parent);
44798 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44799
44800 /* the actual setup */
44801 spin_lock_irqsave(&serial->serial_lock, flags);
44802 - if (serial->port.count)
44803 + if (atomic_read(&serial->port.count))
44804 _hso_serial_set_termios(tty, old);
44805 else
44806 tty->termios = *old;
44807 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44808 D1("Pending read interrupt on port %d\n", i);
44809 spin_lock(&serial->serial_lock);
44810 if (serial->rx_state == RX_IDLE &&
44811 - serial->port.count > 0) {
44812 + atomic_read(&serial->port.count) > 0) {
44813 /* Setup and send a ctrl req read on
44814 * port i */
44815 if (!serial->rx_urb_filled[0]) {
44816 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44817 /* Start all serial ports */
44818 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44819 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44820 - if (dev2ser(serial_table[i])->port.count) {
44821 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44822 result =
44823 hso_start_serial_device(serial_table[i], GFP_NOIO);
44824 hso_kick_transmit(dev2ser(serial_table[i]));
44825 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44826 index a79e9d3..78cd4fa 100644
44827 --- a/drivers/net/usb/sierra_net.c
44828 +++ b/drivers/net/usb/sierra_net.c
44829 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44830 /* atomic counter partially included in MAC address to make sure 2 devices
44831 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44832 */
44833 -static atomic_t iface_counter = ATOMIC_INIT(0);
44834 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44835
44836 /*
44837 * SYNC Timer Delay definition used to set the expiry time
44838 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44839 dev->net->netdev_ops = &sierra_net_device_ops;
44840
44841 /* change MAC addr to include, ifacenum, and to be unique */
44842 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44843 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44844 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44845
44846 /* we will have to manufacture ethernet headers, prepare template */
44847 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44848 index 1462368..578941c 100644
44849 --- a/drivers/net/vxlan.c
44850 +++ b/drivers/net/vxlan.c
44851 @@ -2615,7 +2615,7 @@ nla_put_failure:
44852 return -EMSGSIZE;
44853 }
44854
44855 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44856 +static struct rtnl_link_ops vxlan_link_ops = {
44857 .kind = "vxlan",
44858 .maxtype = IFLA_VXLAN_MAX,
44859 .policy = vxlan_policy,
44860 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44861 index 0b60295..b8bfa5b 100644
44862 --- a/drivers/net/wimax/i2400m/rx.c
44863 +++ b/drivers/net/wimax/i2400m/rx.c
44864 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44865 if (i2400m->rx_roq == NULL)
44866 goto error_roq_alloc;
44867
44868 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44869 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44870 GFP_KERNEL);
44871 if (rd == NULL) {
44872 result = -ENOMEM;
44873 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44874 index 7fe1964..7016de0 100644
44875 --- a/drivers/net/wireless/airo.c
44876 +++ b/drivers/net/wireless/airo.c
44877 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44878 struct airo_info *ai = dev->ml_priv;
44879 int ridcode;
44880 int enabled;
44881 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44882 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44883 unsigned char *iobuf;
44884
44885 /* Only super-user can write RIDs */
44886 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44887 index 34c8a33..3261fdc 100644
44888 --- a/drivers/net/wireless/at76c50x-usb.c
44889 +++ b/drivers/net/wireless/at76c50x-usb.c
44890 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44891 }
44892
44893 /* Convert timeout from the DFU status to jiffies */
44894 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44895 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44896 {
44897 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44898 | (s->poll_timeout[1] << 8)
44899 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44900 index ef3329e..c28ff5d 100644
44901 --- a/drivers/net/wireless/ath/ath10k/htc.c
44902 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44903 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44904 /* registered target arrival callback from the HIF layer */
44905 int ath10k_htc_init(struct ath10k *ar)
44906 {
44907 - struct ath10k_hif_cb htc_callbacks;
44908 + static struct ath10k_hif_cb htc_callbacks = {
44909 + .rx_completion = ath10k_htc_rx_completion_handler,
44910 + .tx_completion = ath10k_htc_tx_completion_handler,
44911 + };
44912 struct ath10k_htc_ep *ep = NULL;
44913 struct ath10k_htc *htc = &ar->htc;
44914
44915 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44916 ath10k_htc_reset_endpoint_states(htc);
44917
44918 /* setup HIF layer callbacks */
44919 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44920 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44921 htc->ar = ar;
44922
44923 /* Get HIF default pipe for HTC message exchange */
44924 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44925 index e1dd8c7..9f91b3f 100644
44926 --- a/drivers/net/wireless/ath/ath10k/htc.h
44927 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44928 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44929
44930 struct ath10k_htc_ops {
44931 void (*target_send_suspend_complete)(struct ath10k *ar);
44932 -};
44933 +} __no_const;
44934
44935 struct ath10k_htc_ep_ops {
44936 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44937 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44938 -};
44939 +} __no_const;
44940
44941 /* service connection information */
44942 struct ath10k_htc_svc_conn_req {
44943 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44944 index a366d6b..b6f28f8 100644
44945 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44946 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44947 @@ -218,8 +218,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44948 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44949 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44950
44951 - ACCESS_ONCE(ads->ds_link) = i->link;
44952 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44953 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44954 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44955
44956 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44957 ctl6 = SM(i->keytype, AR_EncrType);
44958 @@ -233,26 +233,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44959
44960 if ((i->is_first || i->is_last) &&
44961 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44962 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44963 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44964 | set11nTries(i->rates, 1)
44965 | set11nTries(i->rates, 2)
44966 | set11nTries(i->rates, 3)
44967 | (i->dur_update ? AR_DurUpdateEna : 0)
44968 | SM(0, AR_BurstDur);
44969
44970 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44971 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44972 | set11nRate(i->rates, 1)
44973 | set11nRate(i->rates, 2)
44974 | set11nRate(i->rates, 3);
44975 } else {
44976 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44977 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44978 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44979 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44980 }
44981
44982 if (!i->is_first) {
44983 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44984 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44985 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44986 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44987 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44988 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44989 return;
44990 }
44991
44992 @@ -277,7 +277,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44993 break;
44994 }
44995
44996 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44997 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44998 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44999 | SM(i->txpower, AR_XmitPower)
45000 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
45001 @@ -287,19 +287,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45002 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
45003 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
45004
45005 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
45006 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
45007 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
45008 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
45009
45010 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
45011 return;
45012
45013 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
45014 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
45015 | set11nPktDurRTSCTS(i->rates, 1);
45016
45017 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
45018 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
45019 | set11nPktDurRTSCTS(i->rates, 3);
45020
45021 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
45022 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
45023 | set11nRateFlags(i->rates, 1)
45024 | set11nRateFlags(i->rates, 2)
45025 | set11nRateFlags(i->rates, 3)
45026 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45027 index f6c5c1b..6058354 100644
45028 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45029 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45030 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45031 (i->qcu << AR_TxQcuNum_S) | desc_len;
45032
45033 checksum += val;
45034 - ACCESS_ONCE(ads->info) = val;
45035 + ACCESS_ONCE_RW(ads->info) = val;
45036
45037 checksum += i->link;
45038 - ACCESS_ONCE(ads->link) = i->link;
45039 + ACCESS_ONCE_RW(ads->link) = i->link;
45040
45041 checksum += i->buf_addr[0];
45042 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
45043 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
45044 checksum += i->buf_addr[1];
45045 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
45046 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
45047 checksum += i->buf_addr[2];
45048 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
45049 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
45050 checksum += i->buf_addr[3];
45051 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
45052 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
45053
45054 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
45055 - ACCESS_ONCE(ads->ctl3) = val;
45056 + ACCESS_ONCE_RW(ads->ctl3) = val;
45057 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
45058 - ACCESS_ONCE(ads->ctl5) = val;
45059 + ACCESS_ONCE_RW(ads->ctl5) = val;
45060 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
45061 - ACCESS_ONCE(ads->ctl7) = val;
45062 + ACCESS_ONCE_RW(ads->ctl7) = val;
45063 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
45064 - ACCESS_ONCE(ads->ctl9) = val;
45065 + ACCESS_ONCE_RW(ads->ctl9) = val;
45066
45067 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
45068 - ACCESS_ONCE(ads->ctl10) = checksum;
45069 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
45070
45071 if (i->is_first || i->is_last) {
45072 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
45073 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
45074 | set11nTries(i->rates, 1)
45075 | set11nTries(i->rates, 2)
45076 | set11nTries(i->rates, 3)
45077 | (i->dur_update ? AR_DurUpdateEna : 0)
45078 | SM(0, AR_BurstDur);
45079
45080 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
45081 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
45082 | set11nRate(i->rates, 1)
45083 | set11nRate(i->rates, 2)
45084 | set11nRate(i->rates, 3);
45085 } else {
45086 - ACCESS_ONCE(ads->ctl13) = 0;
45087 - ACCESS_ONCE(ads->ctl14) = 0;
45088 + ACCESS_ONCE_RW(ads->ctl13) = 0;
45089 + ACCESS_ONCE_RW(ads->ctl14) = 0;
45090 }
45091
45092 ads->ctl20 = 0;
45093 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45094
45095 ctl17 = SM(i->keytype, AR_EncrType);
45096 if (!i->is_first) {
45097 - ACCESS_ONCE(ads->ctl11) = 0;
45098 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
45099 - ACCESS_ONCE(ads->ctl15) = 0;
45100 - ACCESS_ONCE(ads->ctl16) = 0;
45101 - ACCESS_ONCE(ads->ctl17) = ctl17;
45102 - ACCESS_ONCE(ads->ctl18) = 0;
45103 - ACCESS_ONCE(ads->ctl19) = 0;
45104 + ACCESS_ONCE_RW(ads->ctl11) = 0;
45105 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
45106 + ACCESS_ONCE_RW(ads->ctl15) = 0;
45107 + ACCESS_ONCE_RW(ads->ctl16) = 0;
45108 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
45109 + ACCESS_ONCE_RW(ads->ctl18) = 0;
45110 + ACCESS_ONCE_RW(ads->ctl19) = 0;
45111 return;
45112 }
45113
45114 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45115 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45116 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
45117 | SM(i->txpower, AR_XmitPower)
45118 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
45119 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45120 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
45121 ctl12 |= SM(val, AR_PAPRDChainMask);
45122
45123 - ACCESS_ONCE(ads->ctl12) = ctl12;
45124 - ACCESS_ONCE(ads->ctl17) = ctl17;
45125 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
45126 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
45127
45128 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45129 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45130 | set11nPktDurRTSCTS(i->rates, 1);
45131
45132 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45133 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45134 | set11nPktDurRTSCTS(i->rates, 3);
45135
45136 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
45137 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
45138 | set11nRateFlags(i->rates, 1)
45139 | set11nRateFlags(i->rates, 2)
45140 | set11nRateFlags(i->rates, 3)
45141 | SM(i->rtscts_rate, AR_RTSCTSRate);
45142
45143 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
45144 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
45145 }
45146
45147 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
45148 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
45149 index 69a907b..91e071c 100644
45150 --- a/drivers/net/wireless/ath/ath9k/hw.h
45151 +++ b/drivers/net/wireless/ath/ath9k/hw.h
45152 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
45153
45154 /* ANI */
45155 void (*ani_cache_ini_regs)(struct ath_hw *ah);
45156 -};
45157 +} __no_const;
45158
45159 /**
45160 * struct ath_spec_scan - parameters for Atheros spectral scan
45161 @@ -729,7 +729,7 @@ struct ath_hw_ops {
45162 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
45163 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
45164 #endif
45165 -};
45166 +} __no_const;
45167
45168 struct ath_nf_limits {
45169 s16 max;
45170 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
45171 index 92190da..f3a4c4c 100644
45172 --- a/drivers/net/wireless/b43/phy_lp.c
45173 +++ b/drivers/net/wireless/b43/phy_lp.c
45174 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
45175 {
45176 struct ssb_bus *bus = dev->dev->sdev->bus;
45177
45178 - static const struct b206x_channel *chandata = NULL;
45179 + const struct b206x_channel *chandata = NULL;
45180 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
45181 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
45182 u16 old_comm15, scale;
45183 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45184 index 9581d07..84f6a76 100644
45185 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45186 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45187 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45188 */
45189 if (il3945_mod_params.disable_hw_scan) {
45190 D_INFO("Disabling hw_scan\n");
45191 - il3945_mac_ops.hw_scan = NULL;
45192 + pax_open_kernel();
45193 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45194 + pax_close_kernel();
45195 }
45196
45197 D_INFO("*** LOAD DRIVER ***\n");
45198 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45199 index d94f8ab..5b568c8 100644
45200 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45201 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45202 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45203 {
45204 struct iwl_priv *priv = file->private_data;
45205 char buf[64];
45206 - int buf_size;
45207 + size_t buf_size;
45208 u32 offset, len;
45209
45210 memset(buf, 0, sizeof(buf));
45211 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45212 struct iwl_priv *priv = file->private_data;
45213
45214 char buf[8];
45215 - int buf_size;
45216 + size_t buf_size;
45217 u32 reset_flag;
45218
45219 memset(buf, 0, sizeof(buf));
45220 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45221 {
45222 struct iwl_priv *priv = file->private_data;
45223 char buf[8];
45224 - int buf_size;
45225 + size_t buf_size;
45226 int ht40;
45227
45228 memset(buf, 0, sizeof(buf));
45229 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45230 {
45231 struct iwl_priv *priv = file->private_data;
45232 char buf[8];
45233 - int buf_size;
45234 + size_t buf_size;
45235 int value;
45236
45237 memset(buf, 0, sizeof(buf));
45238 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45239 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45240 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45241
45242 -static const char *fmt_value = " %-30s %10u\n";
45243 -static const char *fmt_hex = " %-30s 0x%02X\n";
45244 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45245 -static const char *fmt_header =
45246 +static const char fmt_value[] = " %-30s %10u\n";
45247 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45248 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45249 +static const char fmt_header[] =
45250 "%-32s current cumulative delta max\n";
45251
45252 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45253 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45254 {
45255 struct iwl_priv *priv = file->private_data;
45256 char buf[8];
45257 - int buf_size;
45258 + size_t buf_size;
45259 int clear;
45260
45261 memset(buf, 0, sizeof(buf));
45262 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45263 {
45264 struct iwl_priv *priv = file->private_data;
45265 char buf[8];
45266 - int buf_size;
45267 + size_t buf_size;
45268 int trace;
45269
45270 memset(buf, 0, sizeof(buf));
45271 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45272 {
45273 struct iwl_priv *priv = file->private_data;
45274 char buf[8];
45275 - int buf_size;
45276 + size_t buf_size;
45277 int missed;
45278
45279 memset(buf, 0, sizeof(buf));
45280 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45281
45282 struct iwl_priv *priv = file->private_data;
45283 char buf[8];
45284 - int buf_size;
45285 + size_t buf_size;
45286 int plcp;
45287
45288 memset(buf, 0, sizeof(buf));
45289 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45290
45291 struct iwl_priv *priv = file->private_data;
45292 char buf[8];
45293 - int buf_size;
45294 + size_t buf_size;
45295 int flush;
45296
45297 memset(buf, 0, sizeof(buf));
45298 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45299
45300 struct iwl_priv *priv = file->private_data;
45301 char buf[8];
45302 - int buf_size;
45303 + size_t buf_size;
45304 int rts;
45305
45306 if (!priv->cfg->ht_params)
45307 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45308 {
45309 struct iwl_priv *priv = file->private_data;
45310 char buf[8];
45311 - int buf_size;
45312 + size_t buf_size;
45313
45314 memset(buf, 0, sizeof(buf));
45315 buf_size = min(count, sizeof(buf) - 1);
45316 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45317 struct iwl_priv *priv = file->private_data;
45318 u32 event_log_flag;
45319 char buf[8];
45320 - int buf_size;
45321 + size_t buf_size;
45322
45323 /* check that the interface is up */
45324 if (!iwl_is_ready(priv))
45325 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45326 struct iwl_priv *priv = file->private_data;
45327 char buf[8];
45328 u32 calib_disabled;
45329 - int buf_size;
45330 + size_t buf_size;
45331
45332 memset(buf, 0, sizeof(buf));
45333 buf_size = min(count, sizeof(buf) - 1);
45334 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45335 index 7aad766..06addb4 100644
45336 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45337 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45338 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45339 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45340 {
45341 struct iwl_nvm_data *data = priv->nvm_data;
45342 - char *debug_msg;
45343 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45344
45345 if (data->sku_cap_11n_enable &&
45346 !priv->cfg->ht_params) {
45347 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45348 return -EINVAL;
45349 }
45350
45351 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45352 IWL_DEBUG_INFO(priv, debug_msg,
45353 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45354 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45355 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45356 index 6bc3100..dd1b80d 100644
45357 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45358 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45359 @@ -1249,7 +1249,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45360 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45361
45362 char buf[8];
45363 - int buf_size;
45364 + size_t buf_size;
45365 u32 reset_flag;
45366
45367 memset(buf, 0, sizeof(buf));
45368 @@ -1270,7 +1270,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45369 {
45370 struct iwl_trans *trans = file->private_data;
45371 char buf[8];
45372 - int buf_size;
45373 + size_t buf_size;
45374 int csr;
45375
45376 memset(buf, 0, sizeof(buf));
45377 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45378 index 2cd3f54..e936f90 100644
45379 --- a/drivers/net/wireless/mac80211_hwsim.c
45380 +++ b/drivers/net/wireless/mac80211_hwsim.c
45381 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
45382
45383 if (channels > 1) {
45384 hwsim_if_comb.num_different_channels = channels;
45385 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45386 - mac80211_hwsim_ops.cancel_hw_scan =
45387 - mac80211_hwsim_cancel_hw_scan;
45388 - mac80211_hwsim_ops.sw_scan_start = NULL;
45389 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45390 - mac80211_hwsim_ops.remain_on_channel =
45391 - mac80211_hwsim_roc;
45392 - mac80211_hwsim_ops.cancel_remain_on_channel =
45393 - mac80211_hwsim_croc;
45394 - mac80211_hwsim_ops.add_chanctx =
45395 - mac80211_hwsim_add_chanctx;
45396 - mac80211_hwsim_ops.remove_chanctx =
45397 - mac80211_hwsim_remove_chanctx;
45398 - mac80211_hwsim_ops.change_chanctx =
45399 - mac80211_hwsim_change_chanctx;
45400 - mac80211_hwsim_ops.assign_vif_chanctx =
45401 - mac80211_hwsim_assign_vif_chanctx;
45402 - mac80211_hwsim_ops.unassign_vif_chanctx =
45403 - mac80211_hwsim_unassign_vif_chanctx;
45404 + pax_open_kernel();
45405 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45406 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45407 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45408 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45409 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45410 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45411 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45412 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45413 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45414 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45415 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45416 + pax_close_kernel();
45417 }
45418
45419 spin_lock_init(&hwsim_radio_lock);
45420 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45421 index 8169a85..7fa3b47 100644
45422 --- a/drivers/net/wireless/rndis_wlan.c
45423 +++ b/drivers/net/wireless/rndis_wlan.c
45424 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45425
45426 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45427
45428 - if (rts_threshold < 0 || rts_threshold > 2347)
45429 + if (rts_threshold > 2347)
45430 rts_threshold = 2347;
45431
45432 tmp = cpu_to_le32(rts_threshold);
45433 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45434 index fe4c572..99dedfa 100644
45435 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45436 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45437 @@ -387,7 +387,7 @@ struct rt2x00_intf {
45438 * for hardware which doesn't support hardware
45439 * sequence counting.
45440 */
45441 - atomic_t seqno;
45442 + atomic_unchecked_t seqno;
45443 };
45444
45445 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45446 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45447 index 66a2db8..70cad04 100644
45448 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45449 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45450 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45451 * sequence counter given by mac80211.
45452 */
45453 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45454 - seqno = atomic_add_return(0x10, &intf->seqno);
45455 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45456 else
45457 - seqno = atomic_read(&intf->seqno);
45458 + seqno = atomic_read_unchecked(&intf->seqno);
45459
45460 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45461 hdr->seq_ctrl |= cpu_to_le16(seqno);
45462 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45463 index e2b3d9c..67a5184 100644
45464 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45465 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45466 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45467
45468 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45469
45470 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45471 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45472 + pax_open_kernel();
45473 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45474 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45475 + pax_close_kernel();
45476
45477 wl1251_info("using dedicated interrupt line");
45478 } else {
45479 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45480 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45481 + pax_open_kernel();
45482 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45483 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45484 + pax_close_kernel();
45485
45486 wl1251_info("using SDIO interrupt");
45487 }
45488 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45489 index 1c627da..69f7d17 100644
45490 --- a/drivers/net/wireless/ti/wl12xx/main.c
45491 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45492 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45493 sizeof(wl->conf.mem));
45494
45495 /* read data preparation is only needed by wl127x */
45496 - wl->ops->prepare_read = wl127x_prepare_read;
45497 + pax_open_kernel();
45498 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45499 + pax_close_kernel();
45500
45501 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45502 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45503 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45504 sizeof(wl->conf.mem));
45505
45506 /* read data preparation is only needed by wl127x */
45507 - wl->ops->prepare_read = wl127x_prepare_read;
45508 + pax_open_kernel();
45509 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45510 + pax_close_kernel();
45511
45512 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45513 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45514 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45515 index 7aa0eb8..5a9ef38 100644
45516 --- a/drivers/net/wireless/ti/wl18xx/main.c
45517 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45518 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45519 }
45520
45521 if (!checksum_param) {
45522 - wl18xx_ops.set_rx_csum = NULL;
45523 - wl18xx_ops.init_vif = NULL;
45524 + pax_open_kernel();
45525 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45526 + *(void **)&wl18xx_ops.init_vif = NULL;
45527 + pax_close_kernel();
45528 }
45529
45530 /* Enable 11a Band only if we have 5G antennas */
45531 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45532 index 7ef0b4a..ff65c28 100644
45533 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45534 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45535 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45536 {
45537 struct zd_usb *usb = urb->context;
45538 struct zd_usb_interrupt *intr = &usb->intr;
45539 - int len;
45540 + unsigned int len;
45541 u16 int_num;
45542
45543 ZD_ASSERT(in_interrupt());
45544 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45545 index 59f95d8..53e0e7f 100644
45546 --- a/drivers/nfc/nfcwilink.c
45547 +++ b/drivers/nfc/nfcwilink.c
45548 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45549
45550 static int nfcwilink_probe(struct platform_device *pdev)
45551 {
45552 - static struct nfcwilink *drv;
45553 + struct nfcwilink *drv;
45554 int rc;
45555 __u32 protocols;
45556
45557 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45558 index d93b2b6..ae50401 100644
45559 --- a/drivers/oprofile/buffer_sync.c
45560 +++ b/drivers/oprofile/buffer_sync.c
45561 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45562 if (cookie == NO_COOKIE)
45563 offset = pc;
45564 if (cookie == INVALID_COOKIE) {
45565 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45566 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45567 offset = pc;
45568 }
45569 if (cookie != last_cookie) {
45570 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45571 /* add userspace sample */
45572
45573 if (!mm) {
45574 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45575 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45576 return 0;
45577 }
45578
45579 cookie = lookup_dcookie(mm, s->eip, &offset);
45580
45581 if (cookie == INVALID_COOKIE) {
45582 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45583 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45584 return 0;
45585 }
45586
45587 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45588 /* ignore backtraces if failed to add a sample */
45589 if (state == sb_bt_start) {
45590 state = sb_bt_ignore;
45591 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45592 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45593 }
45594 }
45595 release_mm(mm);
45596 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45597 index c0cc4e7..44d4e54 100644
45598 --- a/drivers/oprofile/event_buffer.c
45599 +++ b/drivers/oprofile/event_buffer.c
45600 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45601 }
45602
45603 if (buffer_pos == buffer_size) {
45604 - atomic_inc(&oprofile_stats.event_lost_overflow);
45605 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45606 return;
45607 }
45608
45609 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45610 index ed2c3ec..deda85a 100644
45611 --- a/drivers/oprofile/oprof.c
45612 +++ b/drivers/oprofile/oprof.c
45613 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45614 if (oprofile_ops.switch_events())
45615 return;
45616
45617 - atomic_inc(&oprofile_stats.multiplex_counter);
45618 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45619 start_switch_worker();
45620 }
45621
45622 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45623 index ee2cfce..7f8f699 100644
45624 --- a/drivers/oprofile/oprofile_files.c
45625 +++ b/drivers/oprofile/oprofile_files.c
45626 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45627
45628 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45629
45630 -static ssize_t timeout_read(struct file *file, char __user *buf,
45631 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45632 size_t count, loff_t *offset)
45633 {
45634 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45635 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45636 index 59659ce..6c860a0 100644
45637 --- a/drivers/oprofile/oprofile_stats.c
45638 +++ b/drivers/oprofile/oprofile_stats.c
45639 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45640 cpu_buf->sample_invalid_eip = 0;
45641 }
45642
45643 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45644 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45645 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45646 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45647 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45648 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45649 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45650 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45651 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45652 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45653 }
45654
45655
45656 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45657 index 1fc622b..8c48fc3 100644
45658 --- a/drivers/oprofile/oprofile_stats.h
45659 +++ b/drivers/oprofile/oprofile_stats.h
45660 @@ -13,11 +13,11 @@
45661 #include <linux/atomic.h>
45662
45663 struct oprofile_stat_struct {
45664 - atomic_t sample_lost_no_mm;
45665 - atomic_t sample_lost_no_mapping;
45666 - atomic_t bt_lost_no_mapping;
45667 - atomic_t event_lost_overflow;
45668 - atomic_t multiplex_counter;
45669 + atomic_unchecked_t sample_lost_no_mm;
45670 + atomic_unchecked_t sample_lost_no_mapping;
45671 + atomic_unchecked_t bt_lost_no_mapping;
45672 + atomic_unchecked_t event_lost_overflow;
45673 + atomic_unchecked_t multiplex_counter;
45674 };
45675
45676 extern struct oprofile_stat_struct oprofile_stats;
45677 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45678 index 3f49345..c750d0b 100644
45679 --- a/drivers/oprofile/oprofilefs.c
45680 +++ b/drivers/oprofile/oprofilefs.c
45681 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
45682
45683 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45684 {
45685 - atomic_t *val = file->private_data;
45686 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45687 + atomic_unchecked_t *val = file->private_data;
45688 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45689 }
45690
45691
45692 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
45693
45694
45695 int oprofilefs_create_ro_atomic(struct dentry *root,
45696 - char const *name, atomic_t *val)
45697 + char const *name, atomic_unchecked_t *val)
45698 {
45699 return __oprofilefs_create_file(root, name,
45700 &atomic_ro_fops, 0444, val);
45701 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45702 index 61be1d9..dec05d7 100644
45703 --- a/drivers/oprofile/timer_int.c
45704 +++ b/drivers/oprofile/timer_int.c
45705 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45706 return NOTIFY_OK;
45707 }
45708
45709 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45710 +static struct notifier_block oprofile_cpu_notifier = {
45711 .notifier_call = oprofile_cpu_notify,
45712 };
45713
45714 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45715 index 92ed045..62d39bd7 100644
45716 --- a/drivers/parport/procfs.c
45717 +++ b/drivers/parport/procfs.c
45718 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45719
45720 *ppos += len;
45721
45722 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45723 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45724 }
45725
45726 #ifdef CONFIG_PARPORT_1284
45727 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45728
45729 *ppos += len;
45730
45731 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45732 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45733 }
45734 #endif /* IEEE1284.3 support. */
45735
45736 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45737 index 2f5786c..61ab4d1 100644
45738 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45739 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45740 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
45741 goto init_cleanup;
45742 }
45743
45744 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45745 + pax_open_kernel();
45746 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45747 + pax_close_kernel();
45748 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45749
45750 return retval;
45751 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45752 index a6a71c4..c91097b 100644
45753 --- a/drivers/pci/hotplug/cpcihp_generic.c
45754 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45755 @@ -73,7 +73,6 @@ static u16 port;
45756 static unsigned int enum_bit;
45757 static u8 enum_mask;
45758
45759 -static struct cpci_hp_controller_ops generic_hpc_ops;
45760 static struct cpci_hp_controller generic_hpc;
45761
45762 static int __init validate_parameters(void)
45763 @@ -139,6 +138,10 @@ static int query_enum(void)
45764 return ((value & enum_mask) == enum_mask);
45765 }
45766
45767 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45768 + .query_enum = query_enum,
45769 +};
45770 +
45771 static int __init cpcihp_generic_init(void)
45772 {
45773 int status;
45774 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45775 pci_dev_put(dev);
45776
45777 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45778 - generic_hpc_ops.query_enum = query_enum;
45779 generic_hpc.ops = &generic_hpc_ops;
45780
45781 status = cpci_hp_register_controller(&generic_hpc);
45782 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45783 index 449b4bb..257e2e8 100644
45784 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45785 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45786 @@ -59,7 +59,6 @@
45787 /* local variables */
45788 static bool debug;
45789 static bool poll;
45790 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45791 static struct cpci_hp_controller zt5550_hpc;
45792
45793 /* Primary cPCI bus bridge device */
45794 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45795 return 0;
45796 }
45797
45798 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45799 + .query_enum = zt5550_hc_query_enum,
45800 +};
45801 +
45802 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45803 {
45804 int status;
45805 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45806 dbg("returned from zt5550_hc_config");
45807
45808 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45809 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45810 zt5550_hpc.ops = &zt5550_hpc_ops;
45811 if(!poll) {
45812 zt5550_hpc.irq = hc_dev->irq;
45813 zt5550_hpc.irq_flags = IRQF_SHARED;
45814 zt5550_hpc.dev_id = hc_dev;
45815
45816 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45817 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45818 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45819 + pax_open_kernel();
45820 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45821 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45822 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45823 + pax_open_kernel();
45824 } else {
45825 info("using ENUM# polling mode");
45826 }
45827 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45828 index 76ba8a1..20ca857 100644
45829 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45830 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45831 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45832
45833 void compaq_nvram_init (void __iomem *rom_start)
45834 {
45835 +
45836 +#ifndef CONFIG_PAX_KERNEXEC
45837 if (rom_start) {
45838 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45839 }
45840 +#endif
45841 +
45842 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45843
45844 /* initialize our int15 lock */
45845 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45846 index ec20f74..c1d961e 100644
45847 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45848 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45849 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45850 return -EINVAL;
45851 }
45852
45853 - slot->ops->owner = owner;
45854 - slot->ops->mod_name = mod_name;
45855 + pax_open_kernel();
45856 + *(struct module **)&slot->ops->owner = owner;
45857 + *(const char **)&slot->ops->mod_name = mod_name;
45858 + pax_close_kernel();
45859
45860 mutex_lock(&pci_hp_mutex);
45861 /*
45862 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45863 index f4a18f5..ff2463c 100644
45864 --- a/drivers/pci/hotplug/pciehp_core.c
45865 +++ b/drivers/pci/hotplug/pciehp_core.c
45866 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45867 struct slot *slot = ctrl->slot;
45868 struct hotplug_slot *hotplug = NULL;
45869 struct hotplug_slot_info *info = NULL;
45870 - struct hotplug_slot_ops *ops = NULL;
45871 + hotplug_slot_ops_no_const *ops = NULL;
45872 char name[SLOT_NAME_SIZE];
45873 int retval = -ENOMEM;
45874
45875 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45876 index 7128cfd..a0640d6 100644
45877 --- a/drivers/pci/pci-sysfs.c
45878 +++ b/drivers/pci/pci-sysfs.c
45879 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45880 {
45881 /* allocate attribute structure, piggyback attribute name */
45882 int name_len = write_combine ? 13 : 10;
45883 - struct bin_attribute *res_attr;
45884 + bin_attribute_no_const *res_attr;
45885 int retval;
45886
45887 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45888 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45889 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45890 {
45891 int retval;
45892 - struct bin_attribute *attr;
45893 + bin_attribute_no_const *attr;
45894
45895 /* If the device has VPD, try to expose it in sysfs. */
45896 if (dev->vpd) {
45897 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45898 {
45899 int retval;
45900 int rom_size = 0;
45901 - struct bin_attribute *attr;
45902 + bin_attribute_no_const *attr;
45903
45904 if (!sysfs_initialized)
45905 return -EACCES;
45906 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45907 index 8a00c06..18a9715 100644
45908 --- a/drivers/pci/pci.h
45909 +++ b/drivers/pci/pci.h
45910 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45911 struct pci_vpd {
45912 unsigned int len;
45913 const struct pci_vpd_ops *ops;
45914 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45915 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45916 };
45917
45918 int pci_vpd_pci22_init(struct pci_dev *dev);
45919 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45920 index 403a443..034e050 100644
45921 --- a/drivers/pci/pcie/aspm.c
45922 +++ b/drivers/pci/pcie/aspm.c
45923 @@ -27,9 +27,9 @@
45924 #define MODULE_PARAM_PREFIX "pcie_aspm."
45925
45926 /* Note: those are not register definitions */
45927 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45928 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45929 -#define ASPM_STATE_L1 (4) /* L1 state */
45930 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45931 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45932 +#define ASPM_STATE_L1 (4U) /* L1 state */
45933 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45934 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45935
45936 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45937 index 7ef0f86..17b710f 100644
45938 --- a/drivers/pci/probe.c
45939 +++ b/drivers/pci/probe.c
45940 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45941 struct pci_bus_region region, inverted_region;
45942 bool bar_too_big = false, bar_disabled = false;
45943
45944 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45945 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45946
45947 /* No printks while decoding is disabled! */
45948 if (!dev->mmio_always_on) {
45949 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45950 index cdc7836..528635c 100644
45951 --- a/drivers/pci/proc.c
45952 +++ b/drivers/pci/proc.c
45953 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45954 static int __init pci_proc_init(void)
45955 {
45956 struct pci_dev *dev = NULL;
45957 +
45958 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45959 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45960 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45961 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45962 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45963 +#endif
45964 +#else
45965 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45966 +#endif
45967 proc_create("devices", 0, proc_bus_pci_dir,
45968 &proc_bus_pci_dev_operations);
45969 proc_initialized = 1;
45970 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
45971 index 19c313b..ed28b38 100644
45972 --- a/drivers/platform/x86/asus-wmi.c
45973 +++ b/drivers/platform/x86/asus-wmi.c
45974 @@ -1618,6 +1618,10 @@ static int show_dsts(struct seq_file *m, void *data)
45975 int err;
45976 u32 retval = -1;
45977
45978 +#ifdef CONFIG_GRKERNSEC_KMEM
45979 + return -EPERM;
45980 +#endif
45981 +
45982 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
45983
45984 if (err < 0)
45985 @@ -1634,6 +1638,10 @@ static int show_devs(struct seq_file *m, void *data)
45986 int err;
45987 u32 retval = -1;
45988
45989 +#ifdef CONFIG_GRKERNSEC_KMEM
45990 + return -EPERM;
45991 +#endif
45992 +
45993 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
45994 &retval);
45995
45996 @@ -1658,6 +1666,10 @@ static int show_call(struct seq_file *m, void *data)
45997 union acpi_object *obj;
45998 acpi_status status;
45999
46000 +#ifdef CONFIG_GRKERNSEC_KMEM
46001 + return -EPERM;
46002 +#endif
46003 +
46004 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
46005 1, asus->debug.method_id,
46006 &input, &output);
46007 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
46008 index 3e5b4497..dcdfb70 100644
46009 --- a/drivers/platform/x86/chromeos_laptop.c
46010 +++ b/drivers/platform/x86/chromeos_laptop.c
46011 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
46012 return 0;
46013 }
46014
46015 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
46016 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
46017 {
46018 .ident = "Samsung Series 5 550 - Touchpad",
46019 .matches = {
46020 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
46021 index 62f8030..c7f2a45 100644
46022 --- a/drivers/platform/x86/msi-laptop.c
46023 +++ b/drivers/platform/x86/msi-laptop.c
46024 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
46025
46026 if (!quirks->ec_read_only) {
46027 /* allow userland write sysfs file */
46028 - dev_attr_bluetooth.store = store_bluetooth;
46029 - dev_attr_wlan.store = store_wlan;
46030 - dev_attr_threeg.store = store_threeg;
46031 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
46032 - dev_attr_wlan.attr.mode |= S_IWUSR;
46033 - dev_attr_threeg.attr.mode |= S_IWUSR;
46034 + pax_open_kernel();
46035 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
46036 + *(void **)&dev_attr_wlan.store = store_wlan;
46037 + *(void **)&dev_attr_threeg.store = store_threeg;
46038 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
46039 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
46040 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
46041 + pax_close_kernel();
46042 }
46043
46044 /* disable hardware control by fn key */
46045 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
46046 index 70222f2..8c8ce66 100644
46047 --- a/drivers/platform/x86/msi-wmi.c
46048 +++ b/drivers/platform/x86/msi-wmi.c
46049 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
46050 static void msi_wmi_notify(u32 value, void *context)
46051 {
46052 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
46053 - static struct key_entry *key;
46054 + struct key_entry *key;
46055 union acpi_object *obj;
46056 acpi_status status;
46057
46058 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
46059 index 3484dd2..13ee730 100644
46060 --- a/drivers/platform/x86/sony-laptop.c
46061 +++ b/drivers/platform/x86/sony-laptop.c
46062 @@ -2448,7 +2448,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
46063 }
46064
46065 /* High speed charging function */
46066 -static struct device_attribute *hsc_handle;
46067 +static device_attribute_no_const *hsc_handle;
46068
46069 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
46070 struct device_attribute *attr,
46071 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
46072 index 4e86e97..04d50d1 100644
46073 --- a/drivers/platform/x86/thinkpad_acpi.c
46074 +++ b/drivers/platform/x86/thinkpad_acpi.c
46075 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
46076 return 0;
46077 }
46078
46079 -void static hotkey_mask_warn_incomplete_mask(void)
46080 +static void hotkey_mask_warn_incomplete_mask(void)
46081 {
46082 /* log only what the user can fix... */
46083 const u32 wantedmask = hotkey_driver_mask &
46084 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
46085 }
46086 }
46087
46088 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46089 - struct tp_nvram_state *newn,
46090 - const u32 event_mask)
46091 -{
46092 -
46093 #define TPACPI_COMPARE_KEY(__scancode, __member) \
46094 do { \
46095 if ((event_mask & (1 << __scancode)) && \
46096 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46097 tpacpi_hotkey_send_key(__scancode); \
46098 } while (0)
46099
46100 - void issue_volchange(const unsigned int oldvol,
46101 - const unsigned int newvol)
46102 - {
46103 - unsigned int i = oldvol;
46104 +static void issue_volchange(const unsigned int oldvol,
46105 + const unsigned int newvol,
46106 + const u32 event_mask)
46107 +{
46108 + unsigned int i = oldvol;
46109
46110 - while (i > newvol) {
46111 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
46112 - i--;
46113 - }
46114 - while (i < newvol) {
46115 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
46116 - i++;
46117 - }
46118 + while (i > newvol) {
46119 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
46120 + i--;
46121 }
46122 + while (i < newvol) {
46123 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
46124 + i++;
46125 + }
46126 +}
46127
46128 - void issue_brightnesschange(const unsigned int oldbrt,
46129 - const unsigned int newbrt)
46130 - {
46131 - unsigned int i = oldbrt;
46132 +static void issue_brightnesschange(const unsigned int oldbrt,
46133 + const unsigned int newbrt,
46134 + const u32 event_mask)
46135 +{
46136 + unsigned int i = oldbrt;
46137
46138 - while (i > newbrt) {
46139 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
46140 - i--;
46141 - }
46142 - while (i < newbrt) {
46143 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46144 - i++;
46145 - }
46146 + while (i > newbrt) {
46147 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
46148 + i--;
46149 + }
46150 + while (i < newbrt) {
46151 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46152 + i++;
46153 }
46154 +}
46155
46156 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46157 + struct tp_nvram_state *newn,
46158 + const u32 event_mask)
46159 +{
46160 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
46161 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
46162 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
46163 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46164 oldn->volume_level != newn->volume_level) {
46165 /* recently muted, or repeated mute keypress, or
46166 * multiple presses ending in mute */
46167 - issue_volchange(oldn->volume_level, newn->volume_level);
46168 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
46169 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
46170 }
46171 } else {
46172 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46173 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
46174 }
46175 if (oldn->volume_level != newn->volume_level) {
46176 - issue_volchange(oldn->volume_level, newn->volume_level);
46177 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
46178 } else if (oldn->volume_toggle != newn->volume_toggle) {
46179 /* repeated vol up/down keypress at end of scale ? */
46180 if (newn->volume_level == 0)
46181 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46182 /* handle brightness */
46183 if (oldn->brightness_level != newn->brightness_level) {
46184 issue_brightnesschange(oldn->brightness_level,
46185 - newn->brightness_level);
46186 + newn->brightness_level,
46187 + event_mask);
46188 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
46189 /* repeated key presses that didn't change state */
46190 if (newn->brightness_level == 0)
46191 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46192 && !tp_features.bright_unkfw)
46193 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46194 }
46195 +}
46196
46197 #undef TPACPI_COMPARE_KEY
46198 #undef TPACPI_MAY_SEND_KEY
46199 -}
46200
46201 /*
46202 * Polling driver
46203 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
46204 index 769d265..a3a05ca 100644
46205 --- a/drivers/pnp/pnpbios/bioscalls.c
46206 +++ b/drivers/pnp/pnpbios/bioscalls.c
46207 @@ -58,7 +58,7 @@ do { \
46208 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
46209 } while(0)
46210
46211 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
46212 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
46213 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
46214
46215 /*
46216 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46217
46218 cpu = get_cpu();
46219 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
46220 +
46221 + pax_open_kernel();
46222 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
46223 + pax_close_kernel();
46224
46225 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
46226 spin_lock_irqsave(&pnp_bios_lock, flags);
46227 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46228 :"memory");
46229 spin_unlock_irqrestore(&pnp_bios_lock, flags);
46230
46231 + pax_open_kernel();
46232 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
46233 + pax_close_kernel();
46234 +
46235 put_cpu();
46236
46237 /* If we get here and this is set then the PnP BIOS faulted on us. */
46238 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
46239 return status;
46240 }
46241
46242 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
46243 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
46244 {
46245 int i;
46246
46247 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46248 pnp_bios_callpoint.offset = header->fields.pm16offset;
46249 pnp_bios_callpoint.segment = PNP_CS16;
46250
46251 + pax_open_kernel();
46252 +
46253 for_each_possible_cpu(i) {
46254 struct desc_struct *gdt = get_cpu_gdt_table(i);
46255 if (!gdt)
46256 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46257 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46258 (unsigned long)__va(header->fields.pm16dseg));
46259 }
46260 +
46261 + pax_close_kernel();
46262 }
46263 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46264 index d95e101..67f0c3f 100644
46265 --- a/drivers/pnp/resource.c
46266 +++ b/drivers/pnp/resource.c
46267 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46268 return 1;
46269
46270 /* check if the resource is valid */
46271 - if (*irq < 0 || *irq > 15)
46272 + if (*irq > 15)
46273 return 0;
46274
46275 /* check if the resource is reserved */
46276 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46277 return 1;
46278
46279 /* check if the resource is valid */
46280 - if (*dma < 0 || *dma == 4 || *dma > 7)
46281 + if (*dma == 4 || *dma > 7)
46282 return 0;
46283
46284 /* check if the resource is reserved */
46285 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46286 index 0c52e2a..3421ab7 100644
46287 --- a/drivers/power/pda_power.c
46288 +++ b/drivers/power/pda_power.c
46289 @@ -37,7 +37,11 @@ static int polling;
46290
46291 #if IS_ENABLED(CONFIG_USB_PHY)
46292 static struct usb_phy *transceiver;
46293 -static struct notifier_block otg_nb;
46294 +static int otg_handle_notification(struct notifier_block *nb,
46295 + unsigned long event, void *unused);
46296 +static struct notifier_block otg_nb = {
46297 + .notifier_call = otg_handle_notification
46298 +};
46299 #endif
46300
46301 static struct regulator *ac_draw;
46302 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46303
46304 #if IS_ENABLED(CONFIG_USB_PHY)
46305 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46306 - otg_nb.notifier_call = otg_handle_notification;
46307 ret = usb_register_notifier(transceiver, &otg_nb);
46308 if (ret) {
46309 dev_err(dev, "failure to register otg notifier\n");
46310 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46311 index cc439fd..8fa30df 100644
46312 --- a/drivers/power/power_supply.h
46313 +++ b/drivers/power/power_supply.h
46314 @@ -16,12 +16,12 @@ struct power_supply;
46315
46316 #ifdef CONFIG_SYSFS
46317
46318 -extern void power_supply_init_attrs(struct device_type *dev_type);
46319 +extern void power_supply_init_attrs(void);
46320 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46321
46322 #else
46323
46324 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46325 +static inline void power_supply_init_attrs(void) {}
46326 #define power_supply_uevent NULL
46327
46328 #endif /* CONFIG_SYSFS */
46329 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46330 index 557af94..84dc1fe 100644
46331 --- a/drivers/power/power_supply_core.c
46332 +++ b/drivers/power/power_supply_core.c
46333 @@ -24,7 +24,10 @@
46334 struct class *power_supply_class;
46335 EXPORT_SYMBOL_GPL(power_supply_class);
46336
46337 -static struct device_type power_supply_dev_type;
46338 +extern const struct attribute_group *power_supply_attr_groups[];
46339 +static struct device_type power_supply_dev_type = {
46340 + .groups = power_supply_attr_groups,
46341 +};
46342
46343 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46344 struct power_supply *supply)
46345 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
46346 return PTR_ERR(power_supply_class);
46347
46348 power_supply_class->dev_uevent = power_supply_uevent;
46349 - power_supply_init_attrs(&power_supply_dev_type);
46350 + power_supply_init_attrs();
46351
46352 return 0;
46353 }
46354 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46355 index 44420d1..967126e 100644
46356 --- a/drivers/power/power_supply_sysfs.c
46357 +++ b/drivers/power/power_supply_sysfs.c
46358 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46359 .is_visible = power_supply_attr_is_visible,
46360 };
46361
46362 -static const struct attribute_group *power_supply_attr_groups[] = {
46363 +const struct attribute_group *power_supply_attr_groups[] = {
46364 &power_supply_attr_group,
46365 NULL,
46366 };
46367
46368 -void power_supply_init_attrs(struct device_type *dev_type)
46369 +void power_supply_init_attrs(void)
46370 {
46371 int i;
46372
46373 - dev_type->groups = power_supply_attr_groups;
46374 -
46375 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46376 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46377 }
46378 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46379 index a01b8b3..37c2afe 100644
46380 --- a/drivers/regulator/core.c
46381 +++ b/drivers/regulator/core.c
46382 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46383 {
46384 const struct regulation_constraints *constraints = NULL;
46385 const struct regulator_init_data *init_data;
46386 - static atomic_t regulator_no = ATOMIC_INIT(0);
46387 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46388 struct regulator_dev *rdev;
46389 struct device *dev;
46390 int ret, i;
46391 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46392 rdev->dev.of_node = config->of_node;
46393 rdev->dev.parent = dev;
46394 dev_set_name(&rdev->dev, "regulator.%d",
46395 - atomic_inc_return(&regulator_no) - 1);
46396 + atomic_inc_return_unchecked(&regulator_no) - 1);
46397 ret = device_register(&rdev->dev);
46398 if (ret != 0) {
46399 put_device(&rdev->dev);
46400 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46401 index 144bcac..d20e7db 100644
46402 --- a/drivers/regulator/max8660.c
46403 +++ b/drivers/regulator/max8660.c
46404 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
46405 max8660->shadow_regs[MAX8660_OVER1] = 5;
46406 } else {
46407 /* Otherwise devices can be toggled via software */
46408 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46409 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46410 + pax_open_kernel();
46411 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46412 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46413 + pax_close_kernel();
46414 }
46415
46416 /*
46417 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46418 index 5b77ab7..a62f061 100644
46419 --- a/drivers/regulator/max8973-regulator.c
46420 +++ b/drivers/regulator/max8973-regulator.c
46421 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46422 if (!pdata || !pdata->enable_ext_control) {
46423 max->desc.enable_reg = MAX8973_VOUT;
46424 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46425 - max->ops.enable = regulator_enable_regmap;
46426 - max->ops.disable = regulator_disable_regmap;
46427 - max->ops.is_enabled = regulator_is_enabled_regmap;
46428 + pax_open_kernel();
46429 + *(void **)&max->ops.enable = regulator_enable_regmap;
46430 + *(void **)&max->ops.disable = regulator_disable_regmap;
46431 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46432 + pax_close_kernel();
46433 }
46434
46435 if (pdata) {
46436 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46437 index 1037e07..e64dea1 100644
46438 --- a/drivers/regulator/mc13892-regulator.c
46439 +++ b/drivers/regulator/mc13892-regulator.c
46440 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46441 }
46442 mc13xxx_unlock(mc13892);
46443
46444 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46445 + pax_open_kernel();
46446 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46447 = mc13892_vcam_set_mode;
46448 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46449 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46450 = mc13892_vcam_get_mode;
46451 + pax_close_kernel();
46452
46453 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46454 ARRAY_SIZE(mc13892_regulators));
46455 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46456 index 24e733c..bfbaa3e 100644
46457 --- a/drivers/rtc/rtc-cmos.c
46458 +++ b/drivers/rtc/rtc-cmos.c
46459 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46460 hpet_rtc_timer_init();
46461
46462 /* export at least the first block of NVRAM */
46463 - nvram.size = address_space - NVRAM_OFFSET;
46464 + pax_open_kernel();
46465 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46466 + pax_close_kernel();
46467 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46468 if (retval < 0) {
46469 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46470 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46471 index d049393..bb20be0 100644
46472 --- a/drivers/rtc/rtc-dev.c
46473 +++ b/drivers/rtc/rtc-dev.c
46474 @@ -16,6 +16,7 @@
46475 #include <linux/module.h>
46476 #include <linux/rtc.h>
46477 #include <linux/sched.h>
46478 +#include <linux/grsecurity.h>
46479 #include "rtc-core.h"
46480
46481 static dev_t rtc_devt;
46482 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46483 if (copy_from_user(&tm, uarg, sizeof(tm)))
46484 return -EFAULT;
46485
46486 + gr_log_timechange();
46487 +
46488 return rtc_set_time(rtc, &tm);
46489
46490 case RTC_PIE_ON:
46491 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46492 index ca18fd1..055e42d 100644
46493 --- a/drivers/rtc/rtc-ds1307.c
46494 +++ b/drivers/rtc/rtc-ds1307.c
46495 @@ -107,7 +107,7 @@ struct ds1307 {
46496 u8 offset; /* register's offset */
46497 u8 regs[11];
46498 u16 nvram_offset;
46499 - struct bin_attribute *nvram;
46500 + bin_attribute_no_const *nvram;
46501 enum ds_type type;
46502 unsigned long flags;
46503 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46504 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46505 index fcb0329..d77b7f2 100644
46506 --- a/drivers/rtc/rtc-m48t59.c
46507 +++ b/drivers/rtc/rtc-m48t59.c
46508 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46509 if (IS_ERR(m48t59->rtc))
46510 return PTR_ERR(m48t59->rtc);
46511
46512 - m48t59_nvram_attr.size = pdata->offset;
46513 + pax_open_kernel();
46514 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46515 + pax_close_kernel();
46516
46517 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46518 if (ret)
46519 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46520 index 14b5f8d..cc9bd26 100644
46521 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46522 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46523 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46524 for (bit = 0; bit < 8; bit++) {
46525
46526 if ((pci_status[i] & (0x1 << bit)) != 0) {
46527 - static const char *s;
46528 + const char *s;
46529
46530 s = pci_status_strings[bit];
46531 if (i == 7/*TARG*/ && bit == 3)
46532 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46533
46534 for (bit = 0; bit < 8; bit++) {
46535
46536 - if ((split_status[i] & (0x1 << bit)) != 0) {
46537 - static const char *s;
46538 -
46539 - s = split_status_strings[bit];
46540 - printk(s, ahd_name(ahd),
46541 + if ((split_status[i] & (0x1 << bit)) != 0)
46542 + printk(split_status_strings[bit], ahd_name(ahd),
46543 split_status_source[i]);
46544 - }
46545
46546 if (i > 1)
46547 continue;
46548
46549 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46550 - static const char *s;
46551 -
46552 - s = split_status_strings[bit];
46553 - printk(s, ahd_name(ahd), "SG");
46554 - }
46555 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46556 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46557 }
46558 }
46559 /*
46560 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46561 index e693af6..2e525b6 100644
46562 --- a/drivers/scsi/bfa/bfa_fcpim.h
46563 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46564 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46565
46566 struct bfa_itn_s {
46567 bfa_isr_func_t isr;
46568 -};
46569 +} __no_const;
46570
46571 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46572 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46573 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46574 index 90814fe..4384138 100644
46575 --- a/drivers/scsi/bfa/bfa_ioc.h
46576 +++ b/drivers/scsi/bfa/bfa_ioc.h
46577 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46578 bfa_ioc_disable_cbfn_t disable_cbfn;
46579 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46580 bfa_ioc_reset_cbfn_t reset_cbfn;
46581 -};
46582 +} __no_const;
46583
46584 /*
46585 * IOC event notification mechanism.
46586 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46587 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46588 enum bfi_ioc_state fwstate);
46589 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46590 -};
46591 +} __no_const;
46592
46593 /*
46594 * Queue element to wait for room in request queue. FIFO order is
46595 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46596 index c9382d6..6619864 100644
46597 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46598 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46599 @@ -33,8 +33,8 @@
46600 */
46601 #include "libfcoe.h"
46602
46603 -static atomic_t ctlr_num;
46604 -static atomic_t fcf_num;
46605 +static atomic_unchecked_t ctlr_num;
46606 +static atomic_unchecked_t fcf_num;
46607
46608 /*
46609 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46610 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46611 if (!ctlr)
46612 goto out;
46613
46614 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46615 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46616 ctlr->f = f;
46617 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46618 INIT_LIST_HEAD(&ctlr->fcfs);
46619 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46620 fcf->dev.parent = &ctlr->dev;
46621 fcf->dev.bus = &fcoe_bus_type;
46622 fcf->dev.type = &fcoe_fcf_device_type;
46623 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46624 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46625 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46626
46627 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46628 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46629 {
46630 int error;
46631
46632 - atomic_set(&ctlr_num, 0);
46633 - atomic_set(&fcf_num, 0);
46634 + atomic_set_unchecked(&ctlr_num, 0);
46635 + atomic_set_unchecked(&fcf_num, 0);
46636
46637 error = bus_register(&fcoe_bus_type);
46638 if (error)
46639 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46640 index 3cafe0d..f1e87f8 100644
46641 --- a/drivers/scsi/hosts.c
46642 +++ b/drivers/scsi/hosts.c
46643 @@ -42,7 +42,7 @@
46644 #include "scsi_logging.h"
46645
46646
46647 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46648 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46649
46650
46651 static void scsi_host_cls_release(struct device *dev)
46652 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46653 * subtract one because we increment first then return, but we need to
46654 * know what the next host number was before increment
46655 */
46656 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46657 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46658 shost->dma_channel = 0xff;
46659
46660 /* These three are default values which can be overridden */
46661 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46662 index 0eb0940..3ca9b79 100644
46663 --- a/drivers/scsi/hpsa.c
46664 +++ b/drivers/scsi/hpsa.c
46665 @@ -579,7 +579,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46666 unsigned long flags;
46667
46668 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46669 - return h->access.command_completed(h, q);
46670 + return h->access->command_completed(h, q);
46671
46672 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46673 a = rq->head[rq->current_entry];
46674 @@ -3445,7 +3445,7 @@ static void start_io(struct ctlr_info *h)
46675 while (!list_empty(&h->reqQ)) {
46676 c = list_entry(h->reqQ.next, struct CommandList, list);
46677 /* can't do anything if fifo is full */
46678 - if ((h->access.fifo_full(h))) {
46679 + if ((h->access->fifo_full(h))) {
46680 dev_warn(&h->pdev->dev, "fifo full\n");
46681 break;
46682 }
46683 @@ -3467,7 +3467,7 @@ static void start_io(struct ctlr_info *h)
46684
46685 /* Tell the controller execute command */
46686 spin_unlock_irqrestore(&h->lock, flags);
46687 - h->access.submit_command(h, c);
46688 + h->access->submit_command(h, c);
46689 spin_lock_irqsave(&h->lock, flags);
46690 }
46691 spin_unlock_irqrestore(&h->lock, flags);
46692 @@ -3475,17 +3475,17 @@ static void start_io(struct ctlr_info *h)
46693
46694 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46695 {
46696 - return h->access.command_completed(h, q);
46697 + return h->access->command_completed(h, q);
46698 }
46699
46700 static inline bool interrupt_pending(struct ctlr_info *h)
46701 {
46702 - return h->access.intr_pending(h);
46703 + return h->access->intr_pending(h);
46704 }
46705
46706 static inline long interrupt_not_for_us(struct ctlr_info *h)
46707 {
46708 - return (h->access.intr_pending(h) == 0) ||
46709 + return (h->access->intr_pending(h) == 0) ||
46710 (h->interrupts_enabled == 0);
46711 }
46712
46713 @@ -4387,7 +4387,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46714 if (prod_index < 0)
46715 return -ENODEV;
46716 h->product_name = products[prod_index].product_name;
46717 - h->access = *(products[prod_index].access);
46718 + h->access = products[prod_index].access;
46719
46720 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46721 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46722 @@ -4669,7 +4669,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46723
46724 assert_spin_locked(&lockup_detector_lock);
46725 remove_ctlr_from_lockup_detector_list(h);
46726 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46727 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46728 spin_lock_irqsave(&h->lock, flags);
46729 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46730 spin_unlock_irqrestore(&h->lock, flags);
46731 @@ -4846,7 +4846,7 @@ reinit_after_soft_reset:
46732 }
46733
46734 /* make sure the board interrupts are off */
46735 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46736 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46737
46738 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46739 goto clean2;
46740 @@ -4880,7 +4880,7 @@ reinit_after_soft_reset:
46741 * fake ones to scoop up any residual completions.
46742 */
46743 spin_lock_irqsave(&h->lock, flags);
46744 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46745 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46746 spin_unlock_irqrestore(&h->lock, flags);
46747 free_irqs(h);
46748 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46749 @@ -4899,9 +4899,9 @@ reinit_after_soft_reset:
46750 dev_info(&h->pdev->dev, "Board READY.\n");
46751 dev_info(&h->pdev->dev,
46752 "Waiting for stale completions to drain.\n");
46753 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46754 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46755 msleep(10000);
46756 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46757 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46758
46759 rc = controller_reset_failed(h->cfgtable);
46760 if (rc)
46761 @@ -4922,7 +4922,7 @@ reinit_after_soft_reset:
46762 }
46763
46764 /* Turn the interrupts on so we can service requests */
46765 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46766 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46767
46768 hpsa_hba_inquiry(h);
46769 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46770 @@ -4977,7 +4977,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46771 * To write all data in the battery backed cache to disks
46772 */
46773 hpsa_flush_cache(h);
46774 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46775 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46776 hpsa_free_irqs_and_disable_msix(h);
46777 }
46778
46779 @@ -5145,7 +5145,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46780 return;
46781 }
46782 /* Change the access methods to the performant access methods */
46783 - h->access = SA5_performant_access;
46784 + h->access = &SA5_performant_access;
46785 h->transMethod = CFGTBL_Trans_Performant;
46786 }
46787
46788 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46789 index bc85e72..ae04a39 100644
46790 --- a/drivers/scsi/hpsa.h
46791 +++ b/drivers/scsi/hpsa.h
46792 @@ -79,7 +79,7 @@ struct ctlr_info {
46793 unsigned int msix_vector;
46794 unsigned int msi_vector;
46795 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46796 - struct access_method access;
46797 + struct access_method *access;
46798
46799 /* queue and queue Info */
46800 struct list_head reqQ;
46801 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46802 index 5879929..32b241d 100644
46803 --- a/drivers/scsi/libfc/fc_exch.c
46804 +++ b/drivers/scsi/libfc/fc_exch.c
46805 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46806 u16 pool_max_index;
46807
46808 struct {
46809 - atomic_t no_free_exch;
46810 - atomic_t no_free_exch_xid;
46811 - atomic_t xid_not_found;
46812 - atomic_t xid_busy;
46813 - atomic_t seq_not_found;
46814 - atomic_t non_bls_resp;
46815 + atomic_unchecked_t no_free_exch;
46816 + atomic_unchecked_t no_free_exch_xid;
46817 + atomic_unchecked_t xid_not_found;
46818 + atomic_unchecked_t xid_busy;
46819 + atomic_unchecked_t seq_not_found;
46820 + atomic_unchecked_t non_bls_resp;
46821 } stats;
46822 };
46823
46824 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46825 /* allocate memory for exchange */
46826 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46827 if (!ep) {
46828 - atomic_inc(&mp->stats.no_free_exch);
46829 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46830 goto out;
46831 }
46832 memset(ep, 0, sizeof(*ep));
46833 @@ -797,7 +797,7 @@ out:
46834 return ep;
46835 err:
46836 spin_unlock_bh(&pool->lock);
46837 - atomic_inc(&mp->stats.no_free_exch_xid);
46838 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46839 mempool_free(ep, mp->ep_pool);
46840 return NULL;
46841 }
46842 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46843 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46844 ep = fc_exch_find(mp, xid);
46845 if (!ep) {
46846 - atomic_inc(&mp->stats.xid_not_found);
46847 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46848 reject = FC_RJT_OX_ID;
46849 goto out;
46850 }
46851 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46852 ep = fc_exch_find(mp, xid);
46853 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46854 if (ep) {
46855 - atomic_inc(&mp->stats.xid_busy);
46856 + atomic_inc_unchecked(&mp->stats.xid_busy);
46857 reject = FC_RJT_RX_ID;
46858 goto rel;
46859 }
46860 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46861 }
46862 xid = ep->xid; /* get our XID */
46863 } else if (!ep) {
46864 - atomic_inc(&mp->stats.xid_not_found);
46865 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46866 reject = FC_RJT_RX_ID; /* XID not found */
46867 goto out;
46868 }
46869 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46870 } else {
46871 sp = &ep->seq;
46872 if (sp->id != fh->fh_seq_id) {
46873 - atomic_inc(&mp->stats.seq_not_found);
46874 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46875 if (f_ctl & FC_FC_END_SEQ) {
46876 /*
46877 * Update sequence_id based on incoming last
46878 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46879
46880 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46881 if (!ep) {
46882 - atomic_inc(&mp->stats.xid_not_found);
46883 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46884 goto out;
46885 }
46886 if (ep->esb_stat & ESB_ST_COMPLETE) {
46887 - atomic_inc(&mp->stats.xid_not_found);
46888 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46889 goto rel;
46890 }
46891 if (ep->rxid == FC_XID_UNKNOWN)
46892 ep->rxid = ntohs(fh->fh_rx_id);
46893 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46894 - atomic_inc(&mp->stats.xid_not_found);
46895 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46896 goto rel;
46897 }
46898 if (ep->did != ntoh24(fh->fh_s_id) &&
46899 ep->did != FC_FID_FLOGI) {
46900 - atomic_inc(&mp->stats.xid_not_found);
46901 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46902 goto rel;
46903 }
46904 sof = fr_sof(fp);
46905 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46906 sp->ssb_stat |= SSB_ST_RESP;
46907 sp->id = fh->fh_seq_id;
46908 } else if (sp->id != fh->fh_seq_id) {
46909 - atomic_inc(&mp->stats.seq_not_found);
46910 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46911 goto rel;
46912 }
46913
46914 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46915 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46916
46917 if (!sp)
46918 - atomic_inc(&mp->stats.xid_not_found);
46919 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46920 else
46921 - atomic_inc(&mp->stats.non_bls_resp);
46922 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46923
46924 fc_frame_free(fp);
46925 }
46926 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46927
46928 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46929 mp = ema->mp;
46930 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46931 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46932 st->fc_no_free_exch_xid +=
46933 - atomic_read(&mp->stats.no_free_exch_xid);
46934 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46935 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46936 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46937 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46938 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46939 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46940 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46941 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46942 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46943 }
46944 }
46945 EXPORT_SYMBOL(fc_exch_update_stats);
46946 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46947 index d289583..b745eec 100644
46948 --- a/drivers/scsi/libsas/sas_ata.c
46949 +++ b/drivers/scsi/libsas/sas_ata.c
46950 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46951 .postreset = ata_std_postreset,
46952 .error_handler = ata_std_error_handler,
46953 .post_internal_cmd = sas_ata_post_internal,
46954 - .qc_defer = ata_std_qc_defer,
46955 + .qc_defer = ata_std_qc_defer,
46956 .qc_prep = ata_noop_qc_prep,
46957 .qc_issue = sas_ata_qc_issue,
46958 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46959 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46960 index 4e1b75c..0bbdfa9 100644
46961 --- a/drivers/scsi/lpfc/lpfc.h
46962 +++ b/drivers/scsi/lpfc/lpfc.h
46963 @@ -432,7 +432,7 @@ struct lpfc_vport {
46964 struct dentry *debug_nodelist;
46965 struct dentry *vport_debugfs_root;
46966 struct lpfc_debugfs_trc *disc_trc;
46967 - atomic_t disc_trc_cnt;
46968 + atomic_unchecked_t disc_trc_cnt;
46969 #endif
46970 uint8_t stat_data_enabled;
46971 uint8_t stat_data_blocked;
46972 @@ -865,8 +865,8 @@ struct lpfc_hba {
46973 struct timer_list fabric_block_timer;
46974 unsigned long bit_flags;
46975 #define FABRIC_COMANDS_BLOCKED 0
46976 - atomic_t num_rsrc_err;
46977 - atomic_t num_cmd_success;
46978 + atomic_unchecked_t num_rsrc_err;
46979 + atomic_unchecked_t num_cmd_success;
46980 unsigned long last_rsrc_error_time;
46981 unsigned long last_ramp_down_time;
46982 unsigned long last_ramp_up_time;
46983 @@ -902,7 +902,7 @@ struct lpfc_hba {
46984
46985 struct dentry *debug_slow_ring_trc;
46986 struct lpfc_debugfs_trc *slow_ring_trc;
46987 - atomic_t slow_ring_trc_cnt;
46988 + atomic_unchecked_t slow_ring_trc_cnt;
46989 /* iDiag debugfs sub-directory */
46990 struct dentry *idiag_root;
46991 struct dentry *idiag_pci_cfg;
46992 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46993 index 60084e6..0e2e700 100644
46994 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46995 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46996 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46997
46998 #include <linux/debugfs.h>
46999
47000 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
47001 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
47002 static unsigned long lpfc_debugfs_start_time = 0L;
47003
47004 /* iDiag */
47005 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
47006 lpfc_debugfs_enable = 0;
47007
47008 len = 0;
47009 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
47010 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
47011 (lpfc_debugfs_max_disc_trc - 1);
47012 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
47013 dtp = vport->disc_trc + i;
47014 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
47015 lpfc_debugfs_enable = 0;
47016
47017 len = 0;
47018 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
47019 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
47020 (lpfc_debugfs_max_slow_ring_trc - 1);
47021 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
47022 dtp = phba->slow_ring_trc + i;
47023 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
47024 !vport || !vport->disc_trc)
47025 return;
47026
47027 - index = atomic_inc_return(&vport->disc_trc_cnt) &
47028 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
47029 (lpfc_debugfs_max_disc_trc - 1);
47030 dtp = vport->disc_trc + index;
47031 dtp->fmt = fmt;
47032 dtp->data1 = data1;
47033 dtp->data2 = data2;
47034 dtp->data3 = data3;
47035 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
47036 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
47037 dtp->jif = jiffies;
47038 #endif
47039 return;
47040 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
47041 !phba || !phba->slow_ring_trc)
47042 return;
47043
47044 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
47045 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
47046 (lpfc_debugfs_max_slow_ring_trc - 1);
47047 dtp = phba->slow_ring_trc + index;
47048 dtp->fmt = fmt;
47049 dtp->data1 = data1;
47050 dtp->data2 = data2;
47051 dtp->data3 = data3;
47052 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
47053 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
47054 dtp->jif = jiffies;
47055 #endif
47056 return;
47057 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
47058 "slow_ring buffer\n");
47059 goto debug_failed;
47060 }
47061 - atomic_set(&phba->slow_ring_trc_cnt, 0);
47062 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
47063 memset(phba->slow_ring_trc, 0,
47064 (sizeof(struct lpfc_debugfs_trc) *
47065 lpfc_debugfs_max_slow_ring_trc));
47066 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
47067 "buffer\n");
47068 goto debug_failed;
47069 }
47070 - atomic_set(&vport->disc_trc_cnt, 0);
47071 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
47072
47073 snprintf(name, sizeof(name), "discovery_trace");
47074 vport->debug_disc_trc =
47075 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
47076 index 647f5bf..d0068b9 100644
47077 --- a/drivers/scsi/lpfc/lpfc_init.c
47078 +++ b/drivers/scsi/lpfc/lpfc_init.c
47079 @@ -10952,8 +10952,10 @@ lpfc_init(void)
47080 "misc_register returned with status %d", error);
47081
47082 if (lpfc_enable_npiv) {
47083 - lpfc_transport_functions.vport_create = lpfc_vport_create;
47084 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
47085 + pax_open_kernel();
47086 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
47087 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
47088 + pax_close_kernel();
47089 }
47090 lpfc_transport_template =
47091 fc_attach_transport(&lpfc_transport_functions);
47092 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
47093 index c913e8c..d34a119 100644
47094 --- a/drivers/scsi/lpfc/lpfc_scsi.c
47095 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
47096 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
47097 uint32_t evt_posted;
47098
47099 spin_lock_irqsave(&phba->hbalock, flags);
47100 - atomic_inc(&phba->num_rsrc_err);
47101 + atomic_inc_unchecked(&phba->num_rsrc_err);
47102 phba->last_rsrc_error_time = jiffies;
47103
47104 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
47105 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
47106 unsigned long flags;
47107 struct lpfc_hba *phba = vport->phba;
47108 uint32_t evt_posted;
47109 - atomic_inc(&phba->num_cmd_success);
47110 + atomic_inc_unchecked(&phba->num_cmd_success);
47111
47112 if (vport->cfg_lun_queue_depth <= queue_depth)
47113 return;
47114 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
47115 unsigned long num_rsrc_err, num_cmd_success;
47116 int i;
47117
47118 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
47119 - num_cmd_success = atomic_read(&phba->num_cmd_success);
47120 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
47121 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
47122
47123 /*
47124 * The error and success command counters are global per
47125 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
47126 }
47127 }
47128 lpfc_destroy_vport_work_array(phba, vports);
47129 - atomic_set(&phba->num_rsrc_err, 0);
47130 - atomic_set(&phba->num_cmd_success, 0);
47131 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
47132 + atomic_set_unchecked(&phba->num_cmd_success, 0);
47133 }
47134
47135 /**
47136 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
47137 }
47138 }
47139 lpfc_destroy_vport_work_array(phba, vports);
47140 - atomic_set(&phba->num_rsrc_err, 0);
47141 - atomic_set(&phba->num_cmd_success, 0);
47142 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
47143 + atomic_set_unchecked(&phba->num_cmd_success, 0);
47144 }
47145
47146 /**
47147 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
47148 index 7f0af4f..193ac3e 100644
47149 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
47150 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
47151 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
47152 {
47153 struct scsi_device *sdev = to_scsi_device(dev);
47154 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
47155 - static struct _raid_device *raid_device;
47156 + struct _raid_device *raid_device;
47157 unsigned long flags;
47158 Mpi2RaidVolPage0_t vol_pg0;
47159 Mpi2ConfigReply_t mpi_reply;
47160 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
47161 {
47162 struct scsi_device *sdev = to_scsi_device(dev);
47163 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
47164 - static struct _raid_device *raid_device;
47165 + struct _raid_device *raid_device;
47166 unsigned long flags;
47167 Mpi2RaidVolPage0_t vol_pg0;
47168 Mpi2ConfigReply_t mpi_reply;
47169 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
47170 struct fw_event_work *fw_event)
47171 {
47172 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
47173 - static struct _raid_device *raid_device;
47174 + struct _raid_device *raid_device;
47175 unsigned long flags;
47176 u16 handle;
47177
47178 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
47179 u64 sas_address;
47180 struct _sas_device *sas_device;
47181 struct _sas_node *expander_device;
47182 - static struct _raid_device *raid_device;
47183 + struct _raid_device *raid_device;
47184 u8 retry_count;
47185 unsigned long flags;
47186
47187 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
47188 index a38f71b..f3bc572 100644
47189 --- a/drivers/scsi/pmcraid.c
47190 +++ b/drivers/scsi/pmcraid.c
47191 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
47192 res->scsi_dev = scsi_dev;
47193 scsi_dev->hostdata = res;
47194 res->change_detected = 0;
47195 - atomic_set(&res->read_failures, 0);
47196 - atomic_set(&res->write_failures, 0);
47197 + atomic_set_unchecked(&res->read_failures, 0);
47198 + atomic_set_unchecked(&res->write_failures, 0);
47199 rc = 0;
47200 }
47201 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
47202 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
47203
47204 /* If this was a SCSI read/write command keep count of errors */
47205 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
47206 - atomic_inc(&res->read_failures);
47207 + atomic_inc_unchecked(&res->read_failures);
47208 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
47209 - atomic_inc(&res->write_failures);
47210 + atomic_inc_unchecked(&res->write_failures);
47211
47212 if (!RES_IS_GSCSI(res->cfg_entry) &&
47213 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
47214 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
47215 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47216 * hrrq_id assigned here in queuecommand
47217 */
47218 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47219 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47220 pinstance->num_hrrq;
47221 cmd->cmd_done = pmcraid_io_done;
47222
47223 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
47224 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47225 * hrrq_id assigned here in queuecommand
47226 */
47227 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47228 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47229 pinstance->num_hrrq;
47230
47231 if (request_size) {
47232 @@ -4484,7 +4484,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
47233
47234 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
47235 /* add resources only after host is added into system */
47236 - if (!atomic_read(&pinstance->expose_resources))
47237 + if (!atomic_read_unchecked(&pinstance->expose_resources))
47238 return;
47239
47240 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
47241 @@ -5311,8 +5311,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
47242 init_waitqueue_head(&pinstance->reset_wait_q);
47243
47244 atomic_set(&pinstance->outstanding_cmds, 0);
47245 - atomic_set(&pinstance->last_message_id, 0);
47246 - atomic_set(&pinstance->expose_resources, 0);
47247 + atomic_set_unchecked(&pinstance->last_message_id, 0);
47248 + atomic_set_unchecked(&pinstance->expose_resources, 0);
47249
47250 INIT_LIST_HEAD(&pinstance->free_res_q);
47251 INIT_LIST_HEAD(&pinstance->used_res_q);
47252 @@ -6025,7 +6025,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
47253 /* Schedule worker thread to handle CCN and take care of adding and
47254 * removing devices to OS
47255 */
47256 - atomic_set(&pinstance->expose_resources, 1);
47257 + atomic_set_unchecked(&pinstance->expose_resources, 1);
47258 schedule_work(&pinstance->worker_q);
47259 return rc;
47260
47261 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
47262 index e1d150f..6c6df44 100644
47263 --- a/drivers/scsi/pmcraid.h
47264 +++ b/drivers/scsi/pmcraid.h
47265 @@ -748,7 +748,7 @@ struct pmcraid_instance {
47266 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
47267
47268 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
47269 - atomic_t last_message_id;
47270 + atomic_unchecked_t last_message_id;
47271
47272 /* configuration table */
47273 struct pmcraid_config_table *cfg_table;
47274 @@ -777,7 +777,7 @@ struct pmcraid_instance {
47275 atomic_t outstanding_cmds;
47276
47277 /* should add/delete resources to mid-layer now ?*/
47278 - atomic_t expose_resources;
47279 + atomic_unchecked_t expose_resources;
47280
47281
47282
47283 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47284 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47285 };
47286 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47287 - atomic_t read_failures; /* count of failed READ commands */
47288 - atomic_t write_failures; /* count of failed WRITE commands */
47289 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47290 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47291
47292 /* To indicate add/delete/modify during CCN */
47293 u8 change_detected;
47294 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47295 index 5f174b8..98d32b0 100644
47296 --- a/drivers/scsi/qla2xxx/qla_attr.c
47297 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47298 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47299 return 0;
47300 }
47301
47302 -struct fc_function_template qla2xxx_transport_functions = {
47303 +fc_function_template_no_const qla2xxx_transport_functions = {
47304
47305 .show_host_node_name = 1,
47306 .show_host_port_name = 1,
47307 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47308 .bsg_timeout = qla24xx_bsg_timeout,
47309 };
47310
47311 -struct fc_function_template qla2xxx_transport_vport_functions = {
47312 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47313
47314 .show_host_node_name = 1,
47315 .show_host_port_name = 1,
47316 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47317 index 4446bf5..9a3574d 100644
47318 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47319 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47320 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47321 struct device_attribute;
47322 extern struct device_attribute *qla2x00_host_attrs[];
47323 struct fc_function_template;
47324 -extern struct fc_function_template qla2xxx_transport_functions;
47325 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47326 +extern fc_function_template_no_const qla2xxx_transport_functions;
47327 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47328 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47329 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47330 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47331 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47332 index 9f01bbb..5e1dcee 100644
47333 --- a/drivers/scsi/qla2xxx/qla_os.c
47334 +++ b/drivers/scsi/qla2xxx/qla_os.c
47335 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47336 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47337 /* Ok, a 64bit DMA mask is applicable. */
47338 ha->flags.enable_64bit_addressing = 1;
47339 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47340 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47341 + pax_open_kernel();
47342 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47343 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47344 + pax_close_kernel();
47345 return;
47346 }
47347 }
47348 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47349 index 41327d4..feb03d479 100644
47350 --- a/drivers/scsi/qla4xxx/ql4_def.h
47351 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47352 @@ -296,7 +296,7 @@ struct ddb_entry {
47353 * (4000 only) */
47354 atomic_t relogin_timer; /* Max Time to wait for
47355 * relogin to complete */
47356 - atomic_t relogin_retry_count; /* Num of times relogin has been
47357 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47358 * retried */
47359 uint32_t default_time2wait; /* Default Min time between
47360 * relogins (+aens) */
47361 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47362 index f8a0a26..ec03cee 100644
47363 --- a/drivers/scsi/qla4xxx/ql4_os.c
47364 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47365 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47366 */
47367 if (!iscsi_is_session_online(cls_sess)) {
47368 /* Reset retry relogin timer */
47369 - atomic_inc(&ddb_entry->relogin_retry_count);
47370 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47371 DEBUG2(ql4_printk(KERN_INFO, ha,
47372 "%s: index[%d] relogin timed out-retrying"
47373 " relogin (%d), retry (%d)\n", __func__,
47374 ddb_entry->fw_ddb_index,
47375 - atomic_read(&ddb_entry->relogin_retry_count),
47376 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47377 ddb_entry->default_time2wait + 4));
47378 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47379 atomic_set(&ddb_entry->retry_relogin_timer,
47380 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47381
47382 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47383 atomic_set(&ddb_entry->relogin_timer, 0);
47384 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47385 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47386 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47387 ddb_entry->default_relogin_timeout =
47388 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47389 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47390 index eaa808e..95f8841 100644
47391 --- a/drivers/scsi/scsi.c
47392 +++ b/drivers/scsi/scsi.c
47393 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47394 unsigned long timeout;
47395 int rtn = 0;
47396
47397 - atomic_inc(&cmd->device->iorequest_cnt);
47398 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47399
47400 /* check if the device is still usable */
47401 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47402 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47403 index d1549b7..2f60767 100644
47404 --- a/drivers/scsi/scsi_lib.c
47405 +++ b/drivers/scsi/scsi_lib.c
47406 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47407 shost = sdev->host;
47408 scsi_init_cmd_errh(cmd);
47409 cmd->result = DID_NO_CONNECT << 16;
47410 - atomic_inc(&cmd->device->iorequest_cnt);
47411 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47412
47413 /*
47414 * SCSI request completion path will do scsi_device_unbusy(),
47415 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
47416
47417 INIT_LIST_HEAD(&cmd->eh_entry);
47418
47419 - atomic_inc(&cmd->device->iodone_cnt);
47420 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47421 if (cmd->result)
47422 - atomic_inc(&cmd->device->ioerr_cnt);
47423 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47424
47425 disposition = scsi_decide_disposition(cmd);
47426 if (disposition != SUCCESS &&
47427 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47428 index 40c6394..62356c2 100644
47429 --- a/drivers/scsi/scsi_sysfs.c
47430 +++ b/drivers/scsi/scsi_sysfs.c
47431 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47432 char *buf) \
47433 { \
47434 struct scsi_device *sdev = to_scsi_device(dev); \
47435 - unsigned long long count = atomic_read(&sdev->field); \
47436 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47437 return snprintf(buf, 20, "0x%llx\n", count); \
47438 } \
47439 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47440 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47441 index 84a1fdf..693b0d6 100644
47442 --- a/drivers/scsi/scsi_tgt_lib.c
47443 +++ b/drivers/scsi/scsi_tgt_lib.c
47444 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47445 int err;
47446
47447 dprintk("%lx %u\n", uaddr, len);
47448 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47449 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47450 if (err) {
47451 /*
47452 * TODO: need to fixup sg_tablesize, max_segment_size,
47453 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47454 index 4628fd5..a94a1c2 100644
47455 --- a/drivers/scsi/scsi_transport_fc.c
47456 +++ b/drivers/scsi/scsi_transport_fc.c
47457 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47458 * Netlink Infrastructure
47459 */
47460
47461 -static atomic_t fc_event_seq;
47462 +static atomic_unchecked_t fc_event_seq;
47463
47464 /**
47465 * fc_get_event_number - Obtain the next sequential FC event number
47466 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47467 u32
47468 fc_get_event_number(void)
47469 {
47470 - return atomic_add_return(1, &fc_event_seq);
47471 + return atomic_add_return_unchecked(1, &fc_event_seq);
47472 }
47473 EXPORT_SYMBOL(fc_get_event_number);
47474
47475 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47476 {
47477 int error;
47478
47479 - atomic_set(&fc_event_seq, 0);
47480 + atomic_set_unchecked(&fc_event_seq, 0);
47481
47482 error = transport_class_register(&fc_host_class);
47483 if (error)
47484 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47485 char *cp;
47486
47487 *val = simple_strtoul(buf, &cp, 0);
47488 - if ((*cp && (*cp != '\n')) || (*val < 0))
47489 + if (*cp && (*cp != '\n'))
47490 return -EINVAL;
47491 /*
47492 * Check for overflow; dev_loss_tmo is u32
47493 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47494 index e4a989f..293090c 100644
47495 --- a/drivers/scsi/scsi_transport_iscsi.c
47496 +++ b/drivers/scsi/scsi_transport_iscsi.c
47497 @@ -79,7 +79,7 @@ struct iscsi_internal {
47498 struct transport_container session_cont;
47499 };
47500
47501 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47502 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47503 static struct workqueue_struct *iscsi_eh_timer_workq;
47504
47505 static DEFINE_IDA(iscsi_sess_ida);
47506 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47507 int err;
47508
47509 ihost = shost->shost_data;
47510 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47511 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47512
47513 if (target_id == ISCSI_MAX_TARGET) {
47514 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47515 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
47516 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47517 ISCSI_TRANSPORT_VERSION);
47518
47519 - atomic_set(&iscsi_session_nr, 0);
47520 + atomic_set_unchecked(&iscsi_session_nr, 0);
47521
47522 err = class_register(&iscsi_transport_class);
47523 if (err)
47524 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47525 index f379c7f..e8fc69c 100644
47526 --- a/drivers/scsi/scsi_transport_srp.c
47527 +++ b/drivers/scsi/scsi_transport_srp.c
47528 @@ -33,7 +33,7 @@
47529 #include "scsi_transport_srp_internal.h"
47530
47531 struct srp_host_attrs {
47532 - atomic_t next_port_id;
47533 + atomic_unchecked_t next_port_id;
47534 };
47535 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47536
47537 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47538 struct Scsi_Host *shost = dev_to_shost(dev);
47539 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47540
47541 - atomic_set(&srp_host->next_port_id, 0);
47542 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47543 return 0;
47544 }
47545
47546 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47547 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47548 rport->roles = ids->roles;
47549
47550 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47551 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47552 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47553
47554 transport_setup_device(&rport->dev);
47555 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47556 index dbc024b..6e3b837 100644
47557 --- a/drivers/scsi/sd.c
47558 +++ b/drivers/scsi/sd.c
47559 @@ -2943,7 +2943,7 @@ static int sd_probe(struct device *dev)
47560 sdkp->disk = gd;
47561 sdkp->index = index;
47562 atomic_set(&sdkp->openers, 0);
47563 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47564 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47565
47566 if (!sdp->request_queue->rq_timeout) {
47567 if (sdp->type != TYPE_MOD)
47568 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47569 index df5e961..df6b97f 100644
47570 --- a/drivers/scsi/sg.c
47571 +++ b/drivers/scsi/sg.c
47572 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47573 sdp->disk->disk_name,
47574 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47575 NULL,
47576 - (char *)arg);
47577 + (char __user *)arg);
47578 case BLKTRACESTART:
47579 return blk_trace_startstop(sdp->device->request_queue, 1);
47580 case BLKTRACESTOP:
47581 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47582 index 9e039c6..ae9e800 100644
47583 --- a/drivers/spi/spi.c
47584 +++ b/drivers/spi/spi.c
47585 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
47586 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47587
47588 /* portable code must never pass more than 32 bytes */
47589 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47590 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47591
47592 static u8 *buf;
47593
47594 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47595 index 2c61783..4d49e4e 100644
47596 --- a/drivers/staging/android/timed_output.c
47597 +++ b/drivers/staging/android/timed_output.c
47598 @@ -25,7 +25,7 @@
47599 #include "timed_output.h"
47600
47601 static struct class *timed_output_class;
47602 -static atomic_t device_count;
47603 +static atomic_unchecked_t device_count;
47604
47605 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47606 char *buf)
47607 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
47608 timed_output_class = class_create(THIS_MODULE, "timed_output");
47609 if (IS_ERR(timed_output_class))
47610 return PTR_ERR(timed_output_class);
47611 - atomic_set(&device_count, 0);
47612 + atomic_set_unchecked(&device_count, 0);
47613 timed_output_class->dev_groups = timed_output_groups;
47614 }
47615
47616 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47617 if (ret < 0)
47618 return ret;
47619
47620 - tdev->index = atomic_inc_return(&device_count);
47621 + tdev->index = atomic_inc_return_unchecked(&device_count);
47622 tdev->dev = device_create(timed_output_class, NULL,
47623 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47624 if (IS_ERR(tdev->dev))
47625 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
47626 index 0247a20..cb9595c 100644
47627 --- a/drivers/staging/gdm724x/gdm_tty.c
47628 +++ b/drivers/staging/gdm724x/gdm_tty.c
47629 @@ -45,7 +45,7 @@
47630 #define gdm_tty_send_control(n, r, v, d, l) (\
47631 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
47632
47633 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
47634 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
47635
47636 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
47637 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
47638 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
47639 index ef5064e..fce01db 100644
47640 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
47641 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
47642 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
47643 return 0;
47644 }
47645
47646 -sfw_test_client_ops_t brw_test_client;
47647 -void brw_init_test_client(void)
47648 -{
47649 - brw_test_client.tso_init = brw_client_init;
47650 - brw_test_client.tso_fini = brw_client_fini;
47651 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
47652 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
47653 +sfw_test_client_ops_t brw_test_client = {
47654 + .tso_init = brw_client_init,
47655 + .tso_fini = brw_client_fini,
47656 + .tso_prep_rpc = brw_client_prep_rpc,
47657 + .tso_done_rpc = brw_client_done_rpc,
47658 };
47659
47660 srpc_service_t brw_test_service;
47661 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
47662 index 483c785..e1a2a7b 100644
47663 --- a/drivers/staging/lustre/lnet/selftest/framework.c
47664 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
47665 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
47666
47667 extern sfw_test_client_ops_t ping_test_client;
47668 extern srpc_service_t ping_test_service;
47669 -extern void ping_init_test_client(void);
47670 extern void ping_init_test_service(void);
47671
47672 extern sfw_test_client_ops_t brw_test_client;
47673 extern srpc_service_t brw_test_service;
47674 -extern void brw_init_test_client(void);
47675 extern void brw_init_test_service(void);
47676
47677
47678 @@ -1684,12 +1682,10 @@ sfw_startup (void)
47679 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
47680 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
47681
47682 - brw_init_test_client();
47683 brw_init_test_service();
47684 rc = sfw_register_test(&brw_test_service, &brw_test_client);
47685 LASSERT (rc == 0);
47686
47687 - ping_init_test_client();
47688 ping_init_test_service();
47689 rc = sfw_register_test(&ping_test_service, &ping_test_client);
47690 LASSERT (rc == 0);
47691 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
47692 index f0f9194..b589047 100644
47693 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
47694 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
47695 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
47696 return 0;
47697 }
47698
47699 -sfw_test_client_ops_t ping_test_client;
47700 -void ping_init_test_client(void)
47701 -{
47702 - ping_test_client.tso_init = ping_client_init;
47703 - ping_test_client.tso_fini = ping_client_fini;
47704 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
47705 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
47706 -}
47707 +sfw_test_client_ops_t ping_test_client = {
47708 + .tso_init = ping_client_init,
47709 + .tso_fini = ping_client_fini,
47710 + .tso_prep_rpc = ping_client_prep_rpc,
47711 + .tso_done_rpc = ping_client_done_rpc,
47712 +};
47713
47714 srpc_service_t ping_test_service;
47715 void ping_init_test_service(void)
47716 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47717 index 7020d9c..0d3b580 100644
47718 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
47719 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47720 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
47721 ldlm_completion_callback lcs_completion;
47722 ldlm_blocking_callback lcs_blocking;
47723 ldlm_glimpse_callback lcs_glimpse;
47724 -};
47725 +} __no_const;
47726
47727 /* ldlm_lockd.c */
47728 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
47729 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
47730 index a612255..9a9e2dd 100644
47731 --- a/drivers/staging/lustre/lustre/include/obd.h
47732 +++ b/drivers/staging/lustre/lustre/include/obd.h
47733 @@ -1417,7 +1417,7 @@ struct md_ops {
47734 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
47735 * wrapper function in include/linux/obd_class.h.
47736 */
47737 -};
47738 +} __no_const;
47739
47740 struct lsm_operations {
47741 void (*lsm_free)(struct lov_stripe_md *);
47742 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47743 index fc6c977..df1f956 100644
47744 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47745 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47746 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
47747 int LL_PROC_PROTO(proc_console_max_delay_cs)
47748 {
47749 int rc, max_delay_cs;
47750 - ctl_table_t dummy = *table;
47751 + ctl_table_no_const dummy = *table;
47752 cfs_duration_t d;
47753
47754 dummy.data = &max_delay_cs;
47755 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
47756 int LL_PROC_PROTO(proc_console_min_delay_cs)
47757 {
47758 int rc, min_delay_cs;
47759 - ctl_table_t dummy = *table;
47760 + ctl_table_no_const dummy = *table;
47761 cfs_duration_t d;
47762
47763 dummy.data = &min_delay_cs;
47764 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
47765 int LL_PROC_PROTO(proc_console_backoff)
47766 {
47767 int rc, backoff;
47768 - ctl_table_t dummy = *table;
47769 + ctl_table_no_const dummy = *table;
47770
47771 dummy.data = &backoff;
47772 dummy.proc_handler = &proc_dointvec;
47773 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47774 index 3675020..e80d92c 100644
47775 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47776 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47777 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47778
47779 static int solo_sysfs_init(struct solo_dev *solo_dev)
47780 {
47781 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47782 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47783 struct device *dev = &solo_dev->dev;
47784 const char *driver;
47785 int i;
47786 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47787 index 3335941..2b26186 100644
47788 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47789 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47790 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47791
47792 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47793 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47794 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47795 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47796 if (p2m_id < 0)
47797 p2m_id = -p2m_id;
47798 }
47799 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47800 index 6f91d2e..3f011d2 100644
47801 --- a/drivers/staging/media/solo6x10/solo6x10.h
47802 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47803 @@ -238,7 +238,7 @@ struct solo_dev {
47804
47805 /* P2M DMA Engine */
47806 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47807 - atomic_t p2m_count;
47808 + atomic_unchecked_t p2m_count;
47809 int p2m_jiffies;
47810 unsigned int p2m_timeouts;
47811
47812 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47813 index e14a1bb..9cb9bbe 100644
47814 --- a/drivers/staging/octeon/ethernet-rx.c
47815 +++ b/drivers/staging/octeon/ethernet-rx.c
47816 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47817 /* Increment RX stats for virtual ports */
47818 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47819 #ifdef CONFIG_64BIT
47820 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47821 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47822 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47823 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47824 #else
47825 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47826 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47827 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47828 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47829 #endif
47830 }
47831 netif_receive_skb(skb);
47832 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47833 dev->name);
47834 */
47835 #ifdef CONFIG_64BIT
47836 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47837 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47838 #else
47839 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47840 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47841 #endif
47842 dev_kfree_skb_irq(skb);
47843 }
47844 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47845 index c3a90e7..023619a 100644
47846 --- a/drivers/staging/octeon/ethernet.c
47847 +++ b/drivers/staging/octeon/ethernet.c
47848 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47849 * since the RX tasklet also increments it.
47850 */
47851 #ifdef CONFIG_64BIT
47852 - atomic64_add(rx_status.dropped_packets,
47853 - (atomic64_t *)&priv->stats.rx_dropped);
47854 + atomic64_add_unchecked(rx_status.dropped_packets,
47855 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47856 #else
47857 - atomic_add(rx_status.dropped_packets,
47858 - (atomic_t *)&priv->stats.rx_dropped);
47859 + atomic_add_unchecked(rx_status.dropped_packets,
47860 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47861 #endif
47862 }
47863
47864 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47865 index 439c3c9..2d74293 100644
47866 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47867 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47868 @@ -271,7 +271,7 @@ struct hal_ops {
47869 s32 (*c2h_handler)(struct adapter *padapter,
47870 struct c2h_evt_hdr *c2h_evt);
47871 c2h_id_filter c2h_id_filter_ccx;
47872 -};
47873 +} __no_const;
47874
47875 enum rt_eeprom_type {
47876 EEPROM_93C46,
47877 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47878 index eb6f0e5..e6a0958 100644
47879 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47880 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47881 @@ -126,7 +126,7 @@ struct _io_ops {
47882 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47883 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47884 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47885 -};
47886 +} __no_const;
47887
47888 struct io_req {
47889 struct list_head list;
47890 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47891 index dc23395..cf7e9b1 100644
47892 --- a/drivers/staging/rtl8712/rtl871x_io.h
47893 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47894 @@ -108,7 +108,7 @@ struct _io_ops {
47895 u8 *pmem);
47896 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47897 u8 *pmem);
47898 -};
47899 +} __no_const;
47900
47901 struct io_req {
47902 struct list_head list;
47903 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47904 index 1f5088b..0e59820 100644
47905 --- a/drivers/staging/sbe-2t3e3/netdev.c
47906 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47907 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47908 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47909
47910 if (rlen)
47911 - if (copy_to_user(data, &resp, rlen))
47912 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47913 return -EFAULT;
47914
47915 return 0;
47916 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47917 index a863a98..d272795 100644
47918 --- a/drivers/staging/usbip/vhci.h
47919 +++ b/drivers/staging/usbip/vhci.h
47920 @@ -83,7 +83,7 @@ struct vhci_hcd {
47921 unsigned resuming:1;
47922 unsigned long re_timeout;
47923
47924 - atomic_t seqnum;
47925 + atomic_unchecked_t seqnum;
47926
47927 /*
47928 * NOTE:
47929 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47930 index d7974cb..d78076b 100644
47931 --- a/drivers/staging/usbip/vhci_hcd.c
47932 +++ b/drivers/staging/usbip/vhci_hcd.c
47933 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47934
47935 spin_lock(&vdev->priv_lock);
47936
47937 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47938 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47939 if (priv->seqnum == 0xffff)
47940 dev_info(&urb->dev->dev, "seqnum max\n");
47941
47942 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47943 return -ENOMEM;
47944 }
47945
47946 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47947 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47948 if (unlink->seqnum == 0xffff)
47949 pr_info("seqnum max\n");
47950
47951 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47952 vdev->rhport = rhport;
47953 }
47954
47955 - atomic_set(&vhci->seqnum, 0);
47956 + atomic_set_unchecked(&vhci->seqnum, 0);
47957 spin_lock_init(&vhci->lock);
47958
47959 hcd->power_budget = 0; /* no limit */
47960 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47961 index d07fcb5..358e1e1 100644
47962 --- a/drivers/staging/usbip/vhci_rx.c
47963 +++ b/drivers/staging/usbip/vhci_rx.c
47964 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47965 if (!urb) {
47966 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47967 pr_info("max seqnum %d\n",
47968 - atomic_read(&the_controller->seqnum));
47969 + atomic_read_unchecked(&the_controller->seqnum));
47970 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47971 return;
47972 }
47973 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47974 index 8acff44..bdb2fca 100644
47975 --- a/drivers/staging/vt6655/hostap.c
47976 +++ b/drivers/staging/vt6655/hostap.c
47977 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47978 *
47979 */
47980
47981 +static net_device_ops_no_const apdev_netdev_ops;
47982 +
47983 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47984 {
47985 PSDevice apdev_priv;
47986 struct net_device *dev = pDevice->dev;
47987 int ret;
47988 - const struct net_device_ops apdev_netdev_ops = {
47989 - .ndo_start_xmit = pDevice->tx_80211,
47990 - };
47991
47992 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47993
47994 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47995 *apdev_priv = *pDevice;
47996 eth_hw_addr_inherit(pDevice->apdev, dev);
47997
47998 + /* only half broken now */
47999 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
48000 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
48001
48002 pDevice->apdev->type = ARPHRD_IEEE80211;
48003 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
48004 index c699a30..b90a5fd 100644
48005 --- a/drivers/staging/vt6656/hostap.c
48006 +++ b/drivers/staging/vt6656/hostap.c
48007 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
48008 *
48009 */
48010
48011 +static net_device_ops_no_const apdev_netdev_ops;
48012 +
48013 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
48014 {
48015 struct vnt_private *apdev_priv;
48016 struct net_device *dev = pDevice->dev;
48017 int ret;
48018 - const struct net_device_ops apdev_netdev_ops = {
48019 - .ndo_start_xmit = pDevice->tx_80211,
48020 - };
48021
48022 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
48023
48024 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
48025 *apdev_priv = *pDevice;
48026 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
48027
48028 + /* only half broken now */
48029 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
48030 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
48031
48032 pDevice->apdev->type = ARPHRD_IEEE80211;
48033 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
48034 index e51b09a..5ebac31 100644
48035 --- a/drivers/target/sbp/sbp_target.c
48036 +++ b/drivers/target/sbp/sbp_target.c
48037 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
48038
48039 #define SESSION_MAINTENANCE_INTERVAL HZ
48040
48041 -static atomic_t login_id = ATOMIC_INIT(0);
48042 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
48043
48044 static void session_maintenance_work(struct work_struct *);
48045 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
48046 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
48047 login->lun = se_lun;
48048 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
48049 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
48050 - login->login_id = atomic_inc_return(&login_id);
48051 + login->login_id = atomic_inc_return_unchecked(&login_id);
48052
48053 login->tgt_agt = sbp_target_agent_register(login);
48054 if (IS_ERR(login->tgt_agt)) {
48055 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
48056 index e5e3965..a7b487c 100644
48057 --- a/drivers/target/target_core_device.c
48058 +++ b/drivers/target/target_core_device.c
48059 @@ -1436,7 +1436,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
48060 spin_lock_init(&dev->se_tmr_lock);
48061 spin_lock_init(&dev->qf_cmd_lock);
48062 sema_init(&dev->caw_sem, 1);
48063 - atomic_set(&dev->dev_ordered_id, 0);
48064 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
48065 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
48066 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
48067 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
48068 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
48069 index 0b0009b..215e88e 100644
48070 --- a/drivers/target/target_core_transport.c
48071 +++ b/drivers/target/target_core_transport.c
48072 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
48073 * Used to determine when ORDERED commands should go from
48074 * Dormant to Active status.
48075 */
48076 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
48077 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
48078 smp_mb__after_atomic_inc();
48079 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
48080 cmd->se_ordered_id, cmd->sam_task_attr,
48081 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
48082 index 33f83fe..d80f8e1 100644
48083 --- a/drivers/tty/cyclades.c
48084 +++ b/drivers/tty/cyclades.c
48085 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
48086 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
48087 info->port.count);
48088 #endif
48089 - info->port.count++;
48090 + atomic_inc(&info->port.count);
48091 #ifdef CY_DEBUG_COUNT
48092 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
48093 - current->pid, info->port.count);
48094 + current->pid, atomic_read(&info->port.count));
48095 #endif
48096
48097 /*
48098 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
48099 for (j = 0; j < cy_card[i].nports; j++) {
48100 info = &cy_card[i].ports[j];
48101
48102 - if (info->port.count) {
48103 + if (atomic_read(&info->port.count)) {
48104 /* XXX is the ldisc num worth this? */
48105 struct tty_struct *tty;
48106 struct tty_ldisc *ld;
48107 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
48108 index 9eba119..5070303 100644
48109 --- a/drivers/tty/hvc/hvc_console.c
48110 +++ b/drivers/tty/hvc/hvc_console.c
48111 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
48112
48113 spin_lock_irqsave(&hp->port.lock, flags);
48114 /* Check and then increment for fast path open. */
48115 - if (hp->port.count++ > 0) {
48116 + if (atomic_inc_return(&hp->port.count) > 1) {
48117 spin_unlock_irqrestore(&hp->port.lock, flags);
48118 hvc_kick();
48119 return 0;
48120 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
48121
48122 spin_lock_irqsave(&hp->port.lock, flags);
48123
48124 - if (--hp->port.count == 0) {
48125 + if (atomic_dec_return(&hp->port.count) == 0) {
48126 spin_unlock_irqrestore(&hp->port.lock, flags);
48127 /* We are done with the tty pointer now. */
48128 tty_port_tty_set(&hp->port, NULL);
48129 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
48130 */
48131 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
48132 } else {
48133 - if (hp->port.count < 0)
48134 + if (atomic_read(&hp->port.count) < 0)
48135 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
48136 - hp->vtermno, hp->port.count);
48137 + hp->vtermno, atomic_read(&hp->port.count));
48138 spin_unlock_irqrestore(&hp->port.lock, flags);
48139 }
48140 }
48141 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
48142 * open->hangup case this can be called after the final close so prevent
48143 * that from happening for now.
48144 */
48145 - if (hp->port.count <= 0) {
48146 + if (atomic_read(&hp->port.count) <= 0) {
48147 spin_unlock_irqrestore(&hp->port.lock, flags);
48148 return;
48149 }
48150
48151 - hp->port.count = 0;
48152 + atomic_set(&hp->port.count, 0);
48153 spin_unlock_irqrestore(&hp->port.lock, flags);
48154 tty_port_tty_set(&hp->port, NULL);
48155
48156 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
48157 return -EPIPE;
48158
48159 /* FIXME what's this (unprotected) check for? */
48160 - if (hp->port.count <= 0)
48161 + if (atomic_read(&hp->port.count) <= 0)
48162 return -EIO;
48163
48164 spin_lock_irqsave(&hp->lock, flags);
48165 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
48166 index 81e939e..95ead10 100644
48167 --- a/drivers/tty/hvc/hvcs.c
48168 +++ b/drivers/tty/hvc/hvcs.c
48169 @@ -83,6 +83,7 @@
48170 #include <asm/hvcserver.h>
48171 #include <asm/uaccess.h>
48172 #include <asm/vio.h>
48173 +#include <asm/local.h>
48174
48175 /*
48176 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
48177 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
48178
48179 spin_lock_irqsave(&hvcsd->lock, flags);
48180
48181 - if (hvcsd->port.count > 0) {
48182 + if (atomic_read(&hvcsd->port.count) > 0) {
48183 spin_unlock_irqrestore(&hvcsd->lock, flags);
48184 printk(KERN_INFO "HVCS: vterm state unchanged. "
48185 "The hvcs device node is still in use.\n");
48186 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
48187 }
48188 }
48189
48190 - hvcsd->port.count = 0;
48191 + atomic_set(&hvcsd->port.count, 0);
48192 hvcsd->port.tty = tty;
48193 tty->driver_data = hvcsd;
48194
48195 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
48196 unsigned long flags;
48197
48198 spin_lock_irqsave(&hvcsd->lock, flags);
48199 - hvcsd->port.count++;
48200 + atomic_inc(&hvcsd->port.count);
48201 hvcsd->todo_mask |= HVCS_SCHED_READ;
48202 spin_unlock_irqrestore(&hvcsd->lock, flags);
48203
48204 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
48205 hvcsd = tty->driver_data;
48206
48207 spin_lock_irqsave(&hvcsd->lock, flags);
48208 - if (--hvcsd->port.count == 0) {
48209 + if (atomic_dec_and_test(&hvcsd->port.count)) {
48210
48211 vio_disable_interrupts(hvcsd->vdev);
48212
48213 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
48214
48215 free_irq(irq, hvcsd);
48216 return;
48217 - } else if (hvcsd->port.count < 0) {
48218 + } else if (atomic_read(&hvcsd->port.count) < 0) {
48219 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
48220 " is missmanaged.\n",
48221 - hvcsd->vdev->unit_address, hvcsd->port.count);
48222 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
48223 }
48224
48225 spin_unlock_irqrestore(&hvcsd->lock, flags);
48226 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
48227
48228 spin_lock_irqsave(&hvcsd->lock, flags);
48229 /* Preserve this so that we know how many kref refs to put */
48230 - temp_open_count = hvcsd->port.count;
48231 + temp_open_count = atomic_read(&hvcsd->port.count);
48232
48233 /*
48234 * Don't kref put inside the spinlock because the destruction
48235 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
48236 tty->driver_data = NULL;
48237 hvcsd->port.tty = NULL;
48238
48239 - hvcsd->port.count = 0;
48240 + atomic_set(&hvcsd->port.count, 0);
48241
48242 /* This will drop any buffered data on the floor which is OK in a hangup
48243 * scenario. */
48244 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
48245 * the middle of a write operation? This is a crummy place to do this
48246 * but we want to keep it all in the spinlock.
48247 */
48248 - if (hvcsd->port.count <= 0) {
48249 + if (atomic_read(&hvcsd->port.count) <= 0) {
48250 spin_unlock_irqrestore(&hvcsd->lock, flags);
48251 return -ENODEV;
48252 }
48253 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
48254 {
48255 struct hvcs_struct *hvcsd = tty->driver_data;
48256
48257 - if (!hvcsd || hvcsd->port.count <= 0)
48258 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
48259 return 0;
48260
48261 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
48262 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
48263 index 4190199..48f2920 100644
48264 --- a/drivers/tty/hvc/hvsi.c
48265 +++ b/drivers/tty/hvc/hvsi.c
48266 @@ -85,7 +85,7 @@ struct hvsi_struct {
48267 int n_outbuf;
48268 uint32_t vtermno;
48269 uint32_t virq;
48270 - atomic_t seqno; /* HVSI packet sequence number */
48271 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
48272 uint16_t mctrl;
48273 uint8_t state; /* HVSI protocol state */
48274 uint8_t flags;
48275 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
48276
48277 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
48278 packet.hdr.len = sizeof(struct hvsi_query_response);
48279 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48280 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48281 packet.verb = VSV_SEND_VERSION_NUMBER;
48282 packet.u.version = HVSI_VERSION;
48283 packet.query_seqno = query_seqno+1;
48284 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
48285
48286 packet.hdr.type = VS_QUERY_PACKET_HEADER;
48287 packet.hdr.len = sizeof(struct hvsi_query);
48288 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48289 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48290 packet.verb = verb;
48291
48292 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
48293 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
48294 int wrote;
48295
48296 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
48297 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48298 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48299 packet.hdr.len = sizeof(struct hvsi_control);
48300 packet.verb = VSV_SET_MODEM_CTL;
48301 packet.mask = HVSI_TSDTR;
48302 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
48303 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
48304
48305 packet.hdr.type = VS_DATA_PACKET_HEADER;
48306 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48307 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48308 packet.hdr.len = count + sizeof(struct hvsi_header);
48309 memcpy(&packet.data, buf, count);
48310
48311 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
48312 struct hvsi_control packet __ALIGNED__;
48313
48314 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
48315 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48316 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48317 packet.hdr.len = 6;
48318 packet.verb = VSV_CLOSE_PROTOCOL;
48319
48320 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
48321 index ac27671..0f627ee 100644
48322 --- a/drivers/tty/hvc/hvsi_lib.c
48323 +++ b/drivers/tty/hvc/hvsi_lib.c
48324 @@ -9,7 +9,7 @@
48325
48326 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
48327 {
48328 - packet->seqno = atomic_inc_return(&pv->seqno);
48329 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
48330
48331 /* Assumes that always succeeds, works in practice */
48332 return pv->put_chars(pv->termno, (char *)packet, packet->len);
48333 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
48334
48335 /* Reset state */
48336 pv->established = 0;
48337 - atomic_set(&pv->seqno, 0);
48338 + atomic_set_unchecked(&pv->seqno, 0);
48339
48340 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
48341
48342 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
48343 pv->mctrl_update = 0;
48344 q.hdr.type = VS_QUERY_PACKET_HEADER;
48345 q.hdr.len = sizeof(struct hvsi_query);
48346 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
48347 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
48348 q.verb = VSV_SEND_MODEM_CTL_STATUS;
48349 rc = hvsi_send_packet(pv, &q.hdr);
48350 if (rc <= 0) {
48351 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
48352 index 8fd72ff..34a0bed 100644
48353 --- a/drivers/tty/ipwireless/tty.c
48354 +++ b/drivers/tty/ipwireless/tty.c
48355 @@ -29,6 +29,7 @@
48356 #include <linux/tty_driver.h>
48357 #include <linux/tty_flip.h>
48358 #include <linux/uaccess.h>
48359 +#include <asm/local.h>
48360
48361 #include "tty.h"
48362 #include "network.h"
48363 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48364 mutex_unlock(&tty->ipw_tty_mutex);
48365 return -ENODEV;
48366 }
48367 - if (tty->port.count == 0)
48368 + if (atomic_read(&tty->port.count) == 0)
48369 tty->tx_bytes_queued = 0;
48370
48371 - tty->port.count++;
48372 + atomic_inc(&tty->port.count);
48373
48374 tty->port.tty = linux_tty;
48375 linux_tty->driver_data = tty;
48376 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48377
48378 static void do_ipw_close(struct ipw_tty *tty)
48379 {
48380 - tty->port.count--;
48381 -
48382 - if (tty->port.count == 0) {
48383 + if (atomic_dec_return(&tty->port.count) == 0) {
48384 struct tty_struct *linux_tty = tty->port.tty;
48385
48386 if (linux_tty != NULL) {
48387 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
48388 return;
48389
48390 mutex_lock(&tty->ipw_tty_mutex);
48391 - if (tty->port.count == 0) {
48392 + if (atomic_read(&tty->port.count) == 0) {
48393 mutex_unlock(&tty->ipw_tty_mutex);
48394 return;
48395 }
48396 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
48397
48398 mutex_lock(&tty->ipw_tty_mutex);
48399
48400 - if (!tty->port.count) {
48401 + if (!atomic_read(&tty->port.count)) {
48402 mutex_unlock(&tty->ipw_tty_mutex);
48403 return;
48404 }
48405 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
48406 return -ENODEV;
48407
48408 mutex_lock(&tty->ipw_tty_mutex);
48409 - if (!tty->port.count) {
48410 + if (!atomic_read(&tty->port.count)) {
48411 mutex_unlock(&tty->ipw_tty_mutex);
48412 return -EINVAL;
48413 }
48414 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
48415 if (!tty)
48416 return -ENODEV;
48417
48418 - if (!tty->port.count)
48419 + if (!atomic_read(&tty->port.count))
48420 return -EINVAL;
48421
48422 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
48423 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
48424 if (!tty)
48425 return 0;
48426
48427 - if (!tty->port.count)
48428 + if (!atomic_read(&tty->port.count))
48429 return 0;
48430
48431 return tty->tx_bytes_queued;
48432 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48433 if (!tty)
48434 return -ENODEV;
48435
48436 - if (!tty->port.count)
48437 + if (!atomic_read(&tty->port.count))
48438 return -EINVAL;
48439
48440 return get_control_lines(tty);
48441 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48442 if (!tty)
48443 return -ENODEV;
48444
48445 - if (!tty->port.count)
48446 + if (!atomic_read(&tty->port.count))
48447 return -EINVAL;
48448
48449 return set_control_lines(tty, set, clear);
48450 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48451 if (!tty)
48452 return -ENODEV;
48453
48454 - if (!tty->port.count)
48455 + if (!atomic_read(&tty->port.count))
48456 return -EINVAL;
48457
48458 /* FIXME: Exactly how is the tty object locked here .. */
48459 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48460 * are gone */
48461 mutex_lock(&ttyj->ipw_tty_mutex);
48462 }
48463 - while (ttyj->port.count)
48464 + while (atomic_read(&ttyj->port.count))
48465 do_ipw_close(ttyj);
48466 ipwireless_disassociate_network_ttys(network,
48467 ttyj->channel_idx);
48468 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48469 index 1deaca4..c8582d4 100644
48470 --- a/drivers/tty/moxa.c
48471 +++ b/drivers/tty/moxa.c
48472 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48473 }
48474
48475 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48476 - ch->port.count++;
48477 + atomic_inc(&ch->port.count);
48478 tty->driver_data = ch;
48479 tty_port_tty_set(&ch->port, tty);
48480 mutex_lock(&ch->port.mutex);
48481 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48482 index c0f76da..d974c32 100644
48483 --- a/drivers/tty/n_gsm.c
48484 +++ b/drivers/tty/n_gsm.c
48485 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48486 spin_lock_init(&dlci->lock);
48487 mutex_init(&dlci->mutex);
48488 dlci->fifo = &dlci->_fifo;
48489 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48490 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48491 kfree(dlci);
48492 return NULL;
48493 }
48494 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48495 struct gsm_dlci *dlci = tty->driver_data;
48496 struct tty_port *port = &dlci->port;
48497
48498 - port->count++;
48499 + atomic_inc(&port->count);
48500 dlci_get(dlci);
48501 dlci_get(dlci->gsm->dlci[0]);
48502 mux_get(dlci->gsm);
48503 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48504 index d4a89db..dbe8d8c 100644
48505 --- a/drivers/tty/n_tty.c
48506 +++ b/drivers/tty/n_tty.c
48507 @@ -114,7 +114,7 @@ struct n_tty_data {
48508 int minimum_to_wake;
48509
48510 /* consumer-published */
48511 - size_t read_tail;
48512 + size_t read_tail __intentional_overflow(-1);
48513 size_t line_start;
48514
48515 /* protected by output lock */
48516 @@ -2509,6 +2509,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48517 {
48518 *ops = tty_ldisc_N_TTY;
48519 ops->owner = NULL;
48520 - ops->refcount = ops->flags = 0;
48521 + atomic_set(&ops->refcount, 0);
48522 + ops->flags = 0;
48523 }
48524 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48525 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48526 index 25c9bc7..24077b7 100644
48527 --- a/drivers/tty/pty.c
48528 +++ b/drivers/tty/pty.c
48529 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
48530 panic("Couldn't register Unix98 pts driver");
48531
48532 /* Now create the /dev/ptmx special device */
48533 + pax_open_kernel();
48534 tty_default_fops(&ptmx_fops);
48535 - ptmx_fops.open = ptmx_open;
48536 + *(void **)&ptmx_fops.open = ptmx_open;
48537 + pax_close_kernel();
48538
48539 cdev_init(&ptmx_cdev, &ptmx_fops);
48540 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48541 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48542 index 354564e..fe50d9a 100644
48543 --- a/drivers/tty/rocket.c
48544 +++ b/drivers/tty/rocket.c
48545 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48546 tty->driver_data = info;
48547 tty_port_tty_set(port, tty);
48548
48549 - if (port->count++ == 0) {
48550 + if (atomic_inc_return(&port->count) == 1) {
48551 atomic_inc(&rp_num_ports_open);
48552
48553 #ifdef ROCKET_DEBUG_OPEN
48554 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48555 #endif
48556 }
48557 #ifdef ROCKET_DEBUG_OPEN
48558 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48559 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48560 #endif
48561
48562 /*
48563 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48564 spin_unlock_irqrestore(&info->port.lock, flags);
48565 return;
48566 }
48567 - if (info->port.count)
48568 + if (atomic_read(&info->port.count))
48569 atomic_dec(&rp_num_ports_open);
48570 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48571 spin_unlock_irqrestore(&info->port.lock, flags);
48572 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48573 index 1274499..f541382 100644
48574 --- a/drivers/tty/serial/ioc4_serial.c
48575 +++ b/drivers/tty/serial/ioc4_serial.c
48576 @@ -437,7 +437,7 @@ struct ioc4_soft {
48577 } is_intr_info[MAX_IOC4_INTR_ENTS];
48578
48579 /* Number of entries active in the above array */
48580 - atomic_t is_num_intrs;
48581 + atomic_unchecked_t is_num_intrs;
48582 } is_intr_type[IOC4_NUM_INTR_TYPES];
48583
48584 /* is_ir_lock must be held while
48585 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48586 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48587 || (type == IOC4_OTHER_INTR_TYPE)));
48588
48589 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48590 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48591 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48592
48593 /* Save off the lower level interrupt handler */
48594 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48595
48596 soft = arg;
48597 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48598 - num_intrs = (int)atomic_read(
48599 + num_intrs = (int)atomic_read_unchecked(
48600 &soft->is_intr_type[intr_type].is_num_intrs);
48601
48602 this_mir = this_ir = pending_intrs(soft, intr_type);
48603 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48604 index a260cde..6b2b5ce 100644
48605 --- a/drivers/tty/serial/kgdboc.c
48606 +++ b/drivers/tty/serial/kgdboc.c
48607 @@ -24,8 +24,9 @@
48608 #define MAX_CONFIG_LEN 40
48609
48610 static struct kgdb_io kgdboc_io_ops;
48611 +static struct kgdb_io kgdboc_io_ops_console;
48612
48613 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48614 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48615 static int configured = -1;
48616
48617 static char config[MAX_CONFIG_LEN];
48618 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48619 kgdboc_unregister_kbd();
48620 if (configured == 1)
48621 kgdb_unregister_io_module(&kgdboc_io_ops);
48622 + else if (configured == 2)
48623 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48624 }
48625
48626 static int configure_kgdboc(void)
48627 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48628 int err;
48629 char *cptr = config;
48630 struct console *cons;
48631 + int is_console = 0;
48632
48633 err = kgdboc_option_setup(config);
48634 if (err || !strlen(config) || isspace(config[0]))
48635 goto noconfig;
48636
48637 err = -ENODEV;
48638 - kgdboc_io_ops.is_console = 0;
48639 kgdb_tty_driver = NULL;
48640
48641 kgdboc_use_kms = 0;
48642 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48643 int idx;
48644 if (cons->device && cons->device(cons, &idx) == p &&
48645 idx == tty_line) {
48646 - kgdboc_io_ops.is_console = 1;
48647 + is_console = 1;
48648 break;
48649 }
48650 cons = cons->next;
48651 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48652 kgdb_tty_line = tty_line;
48653
48654 do_register:
48655 - err = kgdb_register_io_module(&kgdboc_io_ops);
48656 + if (is_console) {
48657 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48658 + configured = 2;
48659 + } else {
48660 + err = kgdb_register_io_module(&kgdboc_io_ops);
48661 + configured = 1;
48662 + }
48663 if (err)
48664 goto noconfig;
48665
48666 @@ -205,8 +214,6 @@ do_register:
48667 if (err)
48668 goto nmi_con_failed;
48669
48670 - configured = 1;
48671 -
48672 return 0;
48673
48674 nmi_con_failed:
48675 @@ -223,7 +230,7 @@ noconfig:
48676 static int __init init_kgdboc(void)
48677 {
48678 /* Already configured? */
48679 - if (configured == 1)
48680 + if (configured >= 1)
48681 return 0;
48682
48683 return configure_kgdboc();
48684 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48685 if (config[len - 1] == '\n')
48686 config[len - 1] = '\0';
48687
48688 - if (configured == 1)
48689 + if (configured >= 1)
48690 cleanup_kgdboc();
48691
48692 /* Go and configure with the new params. */
48693 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48694 .post_exception = kgdboc_post_exp_handler,
48695 };
48696
48697 +static struct kgdb_io kgdboc_io_ops_console = {
48698 + .name = "kgdboc",
48699 + .read_char = kgdboc_get_char,
48700 + .write_char = kgdboc_put_char,
48701 + .pre_exception = kgdboc_pre_exp_handler,
48702 + .post_exception = kgdboc_post_exp_handler,
48703 + .is_console = 1
48704 +};
48705 +
48706 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48707 /* This is only available if kgdboc is a built in for early debugging */
48708 static int __init kgdboc_early_init(char *opt)
48709 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48710 index b5d779c..3622cfe 100644
48711 --- a/drivers/tty/serial/msm_serial.c
48712 +++ b/drivers/tty/serial/msm_serial.c
48713 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
48714 .cons = MSM_CONSOLE,
48715 };
48716
48717 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48718 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48719
48720 static const struct of_device_id msm_uartdm_table[] = {
48721 { .compatible = "qcom,msm-uartdm" },
48722 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48723 int irq;
48724
48725 if (pdev->id == -1)
48726 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48727 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48728
48729 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48730 return -ENXIO;
48731 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48732 index f3dfa19..342f2ff 100644
48733 --- a/drivers/tty/serial/samsung.c
48734 +++ b/drivers/tty/serial/samsung.c
48735 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48736 }
48737 }
48738
48739 +static int s3c64xx_serial_startup(struct uart_port *port);
48740 static int s3c24xx_serial_startup(struct uart_port *port)
48741 {
48742 struct s3c24xx_uart_port *ourport = to_ourport(port);
48743 int ret;
48744
48745 + /* Startup sequence is different for s3c64xx and higher SoC's */
48746 + if (s3c24xx_serial_has_interrupt_mask(port))
48747 + return s3c64xx_serial_startup(port);
48748 +
48749 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48750 port->mapbase, port->membase);
48751
48752 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48753 /* setup info for port */
48754 port->dev = &platdev->dev;
48755
48756 - /* Startup sequence is different for s3c64xx and higher SoC's */
48757 - if (s3c24xx_serial_has_interrupt_mask(port))
48758 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48759 -
48760 port->uartclk = 1;
48761
48762 if (cfg->uart_flags & UPF_CONS_FLOW) {
48763 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48764 index 0f02351..07c59c5 100644
48765 --- a/drivers/tty/serial/serial_core.c
48766 +++ b/drivers/tty/serial/serial_core.c
48767 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48768 uart_flush_buffer(tty);
48769 uart_shutdown(tty, state);
48770 spin_lock_irqsave(&port->lock, flags);
48771 - port->count = 0;
48772 + atomic_set(&port->count, 0);
48773 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48774 spin_unlock_irqrestore(&port->lock, flags);
48775 tty_port_tty_set(port, NULL);
48776 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48777 goto end;
48778 }
48779
48780 - port->count++;
48781 + atomic_inc(&port->count);
48782 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48783 retval = -ENXIO;
48784 goto err_dec_count;
48785 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48786 /*
48787 * Make sure the device is in D0 state.
48788 */
48789 - if (port->count == 1)
48790 + if (atomic_read(&port->count) == 1)
48791 uart_change_pm(state, UART_PM_STATE_ON);
48792
48793 /*
48794 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48795 end:
48796 return retval;
48797 err_dec_count:
48798 - port->count--;
48799 + atomic_inc(&port->count);
48800 mutex_unlock(&port->mutex);
48801 goto end;
48802 }
48803 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48804 index e1ce141..6d4ed80 100644
48805 --- a/drivers/tty/synclink.c
48806 +++ b/drivers/tty/synclink.c
48807 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48808
48809 if (debug_level >= DEBUG_LEVEL_INFO)
48810 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48811 - __FILE__,__LINE__, info->device_name, info->port.count);
48812 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48813
48814 if (tty_port_close_start(&info->port, tty, filp) == 0)
48815 goto cleanup;
48816 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48817 cleanup:
48818 if (debug_level >= DEBUG_LEVEL_INFO)
48819 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48820 - tty->driver->name, info->port.count);
48821 + tty->driver->name, atomic_read(&info->port.count));
48822
48823 } /* end of mgsl_close() */
48824
48825 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48826
48827 mgsl_flush_buffer(tty);
48828 shutdown(info);
48829 -
48830 - info->port.count = 0;
48831 +
48832 + atomic_set(&info->port.count, 0);
48833 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48834 info->port.tty = NULL;
48835
48836 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48837
48838 if (debug_level >= DEBUG_LEVEL_INFO)
48839 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48840 - __FILE__,__LINE__, tty->driver->name, port->count );
48841 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48842
48843 spin_lock_irqsave(&info->irq_spinlock, flags);
48844 if (!tty_hung_up_p(filp)) {
48845 extra_count = true;
48846 - port->count--;
48847 + atomic_dec(&port->count);
48848 }
48849 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48850 port->blocked_open++;
48851 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48852
48853 if (debug_level >= DEBUG_LEVEL_INFO)
48854 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48855 - __FILE__,__LINE__, tty->driver->name, port->count );
48856 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48857
48858 tty_unlock(tty);
48859 schedule();
48860 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48861
48862 /* FIXME: Racy on hangup during close wait */
48863 if (extra_count)
48864 - port->count++;
48865 + atomic_inc(&port->count);
48866 port->blocked_open--;
48867
48868 if (debug_level >= DEBUG_LEVEL_INFO)
48869 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48870 - __FILE__,__LINE__, tty->driver->name, port->count );
48871 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48872
48873 if (!retval)
48874 port->flags |= ASYNC_NORMAL_ACTIVE;
48875 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48876
48877 if (debug_level >= DEBUG_LEVEL_INFO)
48878 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48879 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48880 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48881
48882 /* If port is closing, signal caller to try again */
48883 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48884 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48885 spin_unlock_irqrestore(&info->netlock, flags);
48886 goto cleanup;
48887 }
48888 - info->port.count++;
48889 + atomic_inc(&info->port.count);
48890 spin_unlock_irqrestore(&info->netlock, flags);
48891
48892 - if (info->port.count == 1) {
48893 + if (atomic_read(&info->port.count) == 1) {
48894 /* 1st open on this device, init hardware */
48895 retval = startup(info);
48896 if (retval < 0)
48897 @@ -3446,8 +3446,8 @@ cleanup:
48898 if (retval) {
48899 if (tty->count == 1)
48900 info->port.tty = NULL; /* tty layer will release tty struct */
48901 - if(info->port.count)
48902 - info->port.count--;
48903 + if (atomic_read(&info->port.count))
48904 + atomic_dec(&info->port.count);
48905 }
48906
48907 return retval;
48908 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48909 unsigned short new_crctype;
48910
48911 /* return error if TTY interface open */
48912 - if (info->port.count)
48913 + if (atomic_read(&info->port.count))
48914 return -EBUSY;
48915
48916 switch (encoding)
48917 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48918
48919 /* arbitrate between network and tty opens */
48920 spin_lock_irqsave(&info->netlock, flags);
48921 - if (info->port.count != 0 || info->netcount != 0) {
48922 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48923 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48924 spin_unlock_irqrestore(&info->netlock, flags);
48925 return -EBUSY;
48926 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48927 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48928
48929 /* return error if TTY interface open */
48930 - if (info->port.count)
48931 + if (atomic_read(&info->port.count))
48932 return -EBUSY;
48933
48934 if (cmd != SIOCWANDEV)
48935 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48936 index 1abf946..1ee34fc 100644
48937 --- a/drivers/tty/synclink_gt.c
48938 +++ b/drivers/tty/synclink_gt.c
48939 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48940 tty->driver_data = info;
48941 info->port.tty = tty;
48942
48943 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48944 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48945
48946 /* If port is closing, signal caller to try again */
48947 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48948 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48949 mutex_unlock(&info->port.mutex);
48950 goto cleanup;
48951 }
48952 - info->port.count++;
48953 + atomic_inc(&info->port.count);
48954 spin_unlock_irqrestore(&info->netlock, flags);
48955
48956 - if (info->port.count == 1) {
48957 + if (atomic_read(&info->port.count) == 1) {
48958 /* 1st open on this device, init hardware */
48959 retval = startup(info);
48960 if (retval < 0) {
48961 @@ -715,8 +715,8 @@ cleanup:
48962 if (retval) {
48963 if (tty->count == 1)
48964 info->port.tty = NULL; /* tty layer will release tty struct */
48965 - if(info->port.count)
48966 - info->port.count--;
48967 + if(atomic_read(&info->port.count))
48968 + atomic_dec(&info->port.count);
48969 }
48970
48971 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48972 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48973
48974 if (sanity_check(info, tty->name, "close"))
48975 return;
48976 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48977 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48978
48979 if (tty_port_close_start(&info->port, tty, filp) == 0)
48980 goto cleanup;
48981 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48982 tty_port_close_end(&info->port, tty);
48983 info->port.tty = NULL;
48984 cleanup:
48985 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48986 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48987 }
48988
48989 static void hangup(struct tty_struct *tty)
48990 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48991 shutdown(info);
48992
48993 spin_lock_irqsave(&info->port.lock, flags);
48994 - info->port.count = 0;
48995 + atomic_set(&info->port.count, 0);
48996 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48997 info->port.tty = NULL;
48998 spin_unlock_irqrestore(&info->port.lock, flags);
48999 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
49000 unsigned short new_crctype;
49001
49002 /* return error if TTY interface open */
49003 - if (info->port.count)
49004 + if (atomic_read(&info->port.count))
49005 return -EBUSY;
49006
49007 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
49008 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
49009
49010 /* arbitrate between network and tty opens */
49011 spin_lock_irqsave(&info->netlock, flags);
49012 - if (info->port.count != 0 || info->netcount != 0) {
49013 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
49014 DBGINFO(("%s hdlc_open busy\n", dev->name));
49015 spin_unlock_irqrestore(&info->netlock, flags);
49016 return -EBUSY;
49017 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
49018 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
49019
49020 /* return error if TTY interface open */
49021 - if (info->port.count)
49022 + if (atomic_read(&info->port.count))
49023 return -EBUSY;
49024
49025 if (cmd != SIOCWANDEV)
49026 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
49027 if (port == NULL)
49028 continue;
49029 spin_lock(&port->lock);
49030 - if ((port->port.count || port->netcount) &&
49031 + if ((atomic_read(&port->port.count) || port->netcount) &&
49032 port->pending_bh && !port->bh_running &&
49033 !port->bh_requested) {
49034 DBGISR(("%s bh queued\n", port->device_name));
49035 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
49036 spin_lock_irqsave(&info->lock, flags);
49037 if (!tty_hung_up_p(filp)) {
49038 extra_count = true;
49039 - port->count--;
49040 + atomic_dec(&port->count);
49041 }
49042 spin_unlock_irqrestore(&info->lock, flags);
49043 port->blocked_open++;
49044 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
49045 remove_wait_queue(&port->open_wait, &wait);
49046
49047 if (extra_count)
49048 - port->count++;
49049 + atomic_inc(&port->count);
49050 port->blocked_open--;
49051
49052 if (!retval)
49053 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
49054 index dc6e969..5dc8786 100644
49055 --- a/drivers/tty/synclinkmp.c
49056 +++ b/drivers/tty/synclinkmp.c
49057 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
49058
49059 if (debug_level >= DEBUG_LEVEL_INFO)
49060 printk("%s(%d):%s open(), old ref count = %d\n",
49061 - __FILE__,__LINE__,tty->driver->name, info->port.count);
49062 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
49063
49064 /* If port is closing, signal caller to try again */
49065 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
49066 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
49067 spin_unlock_irqrestore(&info->netlock, flags);
49068 goto cleanup;
49069 }
49070 - info->port.count++;
49071 + atomic_inc(&info->port.count);
49072 spin_unlock_irqrestore(&info->netlock, flags);
49073
49074 - if (info->port.count == 1) {
49075 + if (atomic_read(&info->port.count) == 1) {
49076 /* 1st open on this device, init hardware */
49077 retval = startup(info);
49078 if (retval < 0)
49079 @@ -796,8 +796,8 @@ cleanup:
49080 if (retval) {
49081 if (tty->count == 1)
49082 info->port.tty = NULL; /* tty layer will release tty struct */
49083 - if(info->port.count)
49084 - info->port.count--;
49085 + if(atomic_read(&info->port.count))
49086 + atomic_dec(&info->port.count);
49087 }
49088
49089 return retval;
49090 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
49091
49092 if (debug_level >= DEBUG_LEVEL_INFO)
49093 printk("%s(%d):%s close() entry, count=%d\n",
49094 - __FILE__,__LINE__, info->device_name, info->port.count);
49095 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
49096
49097 if (tty_port_close_start(&info->port, tty, filp) == 0)
49098 goto cleanup;
49099 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
49100 cleanup:
49101 if (debug_level >= DEBUG_LEVEL_INFO)
49102 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
49103 - tty->driver->name, info->port.count);
49104 + tty->driver->name, atomic_read(&info->port.count));
49105 }
49106
49107 /* Called by tty_hangup() when a hangup is signaled.
49108 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
49109 shutdown(info);
49110
49111 spin_lock_irqsave(&info->port.lock, flags);
49112 - info->port.count = 0;
49113 + atomic_set(&info->port.count, 0);
49114 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
49115 info->port.tty = NULL;
49116 spin_unlock_irqrestore(&info->port.lock, flags);
49117 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
49118 unsigned short new_crctype;
49119
49120 /* return error if TTY interface open */
49121 - if (info->port.count)
49122 + if (atomic_read(&info->port.count))
49123 return -EBUSY;
49124
49125 switch (encoding)
49126 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
49127
49128 /* arbitrate between network and tty opens */
49129 spin_lock_irqsave(&info->netlock, flags);
49130 - if (info->port.count != 0 || info->netcount != 0) {
49131 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
49132 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
49133 spin_unlock_irqrestore(&info->netlock, flags);
49134 return -EBUSY;
49135 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
49136 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
49137
49138 /* return error if TTY interface open */
49139 - if (info->port.count)
49140 + if (atomic_read(&info->port.count))
49141 return -EBUSY;
49142
49143 if (cmd != SIOCWANDEV)
49144 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
49145 * do not request bottom half processing if the
49146 * device is not open in a normal mode.
49147 */
49148 - if ( port && (port->port.count || port->netcount) &&
49149 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
49150 port->pending_bh && !port->bh_running &&
49151 !port->bh_requested ) {
49152 if ( debug_level >= DEBUG_LEVEL_ISR )
49153 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
49154
49155 if (debug_level >= DEBUG_LEVEL_INFO)
49156 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
49157 - __FILE__,__LINE__, tty->driver->name, port->count );
49158 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
49159
49160 spin_lock_irqsave(&info->lock, flags);
49161 if (!tty_hung_up_p(filp)) {
49162 extra_count = true;
49163 - port->count--;
49164 + atomic_dec(&port->count);
49165 }
49166 spin_unlock_irqrestore(&info->lock, flags);
49167 port->blocked_open++;
49168 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
49169
49170 if (debug_level >= DEBUG_LEVEL_INFO)
49171 printk("%s(%d):%s block_til_ready() count=%d\n",
49172 - __FILE__,__LINE__, tty->driver->name, port->count );
49173 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
49174
49175 tty_unlock(tty);
49176 schedule();
49177 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
49178 remove_wait_queue(&port->open_wait, &wait);
49179
49180 if (extra_count)
49181 - port->count++;
49182 + atomic_inc(&port->count);
49183 port->blocked_open--;
49184
49185 if (debug_level >= DEBUG_LEVEL_INFO)
49186 printk("%s(%d):%s block_til_ready() after, count=%d\n",
49187 - __FILE__,__LINE__, tty->driver->name, port->count );
49188 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
49189
49190 if (!retval)
49191 port->flags |= ASYNC_NORMAL_ACTIVE;
49192 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
49193 index 40a9fe9..a3f10cc 100644
49194 --- a/drivers/tty/sysrq.c
49195 +++ b/drivers/tty/sysrq.c
49196 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
49197 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
49198 size_t count, loff_t *ppos)
49199 {
49200 - if (count) {
49201 + if (count && capable(CAP_SYS_ADMIN)) {
49202 char c;
49203
49204 if (get_user(c, buf))
49205 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
49206 index c74a00a..02cf211a 100644
49207 --- a/drivers/tty/tty_io.c
49208 +++ b/drivers/tty/tty_io.c
49209 @@ -3474,7 +3474,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
49210
49211 void tty_default_fops(struct file_operations *fops)
49212 {
49213 - *fops = tty_fops;
49214 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
49215 }
49216
49217 /*
49218 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
49219 index 6458e11..6cfc218 100644
49220 --- a/drivers/tty/tty_ldisc.c
49221 +++ b/drivers/tty/tty_ldisc.c
49222 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
49223 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49224 tty_ldiscs[disc] = new_ldisc;
49225 new_ldisc->num = disc;
49226 - new_ldisc->refcount = 0;
49227 + atomic_set(&new_ldisc->refcount, 0);
49228 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
49229
49230 return ret;
49231 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
49232 return -EINVAL;
49233
49234 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49235 - if (tty_ldiscs[disc]->refcount)
49236 + if (atomic_read(&tty_ldiscs[disc]->refcount))
49237 ret = -EBUSY;
49238 else
49239 tty_ldiscs[disc] = NULL;
49240 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
49241 if (ldops) {
49242 ret = ERR_PTR(-EAGAIN);
49243 if (try_module_get(ldops->owner)) {
49244 - ldops->refcount++;
49245 + atomic_inc(&ldops->refcount);
49246 ret = ldops;
49247 }
49248 }
49249 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
49250 unsigned long flags;
49251
49252 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49253 - ldops->refcount--;
49254 + atomic_dec(&ldops->refcount);
49255 module_put(ldops->owner);
49256 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
49257 }
49258 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
49259 index f597e88..b7f68ed 100644
49260 --- a/drivers/tty/tty_port.c
49261 +++ b/drivers/tty/tty_port.c
49262 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
49263 unsigned long flags;
49264
49265 spin_lock_irqsave(&port->lock, flags);
49266 - port->count = 0;
49267 + atomic_set(&port->count, 0);
49268 port->flags &= ~ASYNC_NORMAL_ACTIVE;
49269 tty = port->tty;
49270 if (tty)
49271 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49272 /* The port lock protects the port counts */
49273 spin_lock_irqsave(&port->lock, flags);
49274 if (!tty_hung_up_p(filp))
49275 - port->count--;
49276 + atomic_dec(&port->count);
49277 port->blocked_open++;
49278 spin_unlock_irqrestore(&port->lock, flags);
49279
49280 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49281 we must not mess that up further */
49282 spin_lock_irqsave(&port->lock, flags);
49283 if (!tty_hung_up_p(filp))
49284 - port->count++;
49285 + atomic_inc(&port->count);
49286 port->blocked_open--;
49287 if (retval == 0)
49288 port->flags |= ASYNC_NORMAL_ACTIVE;
49289 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
49290 return 0;
49291 }
49292
49293 - if (tty->count == 1 && port->count != 1) {
49294 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
49295 printk(KERN_WARNING
49296 "tty_port_close_start: tty->count = 1 port count = %d.\n",
49297 - port->count);
49298 - port->count = 1;
49299 + atomic_read(&port->count));
49300 + atomic_set(&port->count, 1);
49301 }
49302 - if (--port->count < 0) {
49303 + if (atomic_dec_return(&port->count) < 0) {
49304 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
49305 - port->count);
49306 - port->count = 0;
49307 + atomic_read(&port->count));
49308 + atomic_set(&port->count, 0);
49309 }
49310
49311 - if (port->count) {
49312 + if (atomic_read(&port->count)) {
49313 spin_unlock_irqrestore(&port->lock, flags);
49314 if (port->ops->drop)
49315 port->ops->drop(port);
49316 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
49317 {
49318 spin_lock_irq(&port->lock);
49319 if (!tty_hung_up_p(filp))
49320 - ++port->count;
49321 + atomic_inc(&port->count);
49322 spin_unlock_irq(&port->lock);
49323 tty_port_tty_set(port, tty);
49324
49325 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
49326 index d0e3a44..5f8b754 100644
49327 --- a/drivers/tty/vt/keyboard.c
49328 +++ b/drivers/tty/vt/keyboard.c
49329 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
49330 kbd->kbdmode == VC_OFF) &&
49331 value != KVAL(K_SAK))
49332 return; /* SAK is allowed even in raw mode */
49333 +
49334 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
49335 + {
49336 + void *func = fn_handler[value];
49337 + if (func == fn_show_state || func == fn_show_ptregs ||
49338 + func == fn_show_mem)
49339 + return;
49340 + }
49341 +#endif
49342 +
49343 fn_handler[value](vc);
49344 }
49345
49346 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49347 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
49348 return -EFAULT;
49349
49350 - if (!capable(CAP_SYS_TTY_CONFIG))
49351 - perm = 0;
49352 -
49353 switch (cmd) {
49354 case KDGKBENT:
49355 /* Ensure another thread doesn't free it under us */
49356 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49357 spin_unlock_irqrestore(&kbd_event_lock, flags);
49358 return put_user(val, &user_kbe->kb_value);
49359 case KDSKBENT:
49360 + if (!capable(CAP_SYS_TTY_CONFIG))
49361 + perm = 0;
49362 +
49363 if (!perm)
49364 return -EPERM;
49365 if (!i && v == K_NOSUCHMAP) {
49366 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49367 int i, j, k;
49368 int ret;
49369
49370 - if (!capable(CAP_SYS_TTY_CONFIG))
49371 - perm = 0;
49372 -
49373 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
49374 if (!kbs) {
49375 ret = -ENOMEM;
49376 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49377 kfree(kbs);
49378 return ((p && *p) ? -EOVERFLOW : 0);
49379 case KDSKBSENT:
49380 + if (!capable(CAP_SYS_TTY_CONFIG))
49381 + perm = 0;
49382 +
49383 if (!perm) {
49384 ret = -EPERM;
49385 goto reterr;
49386 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
49387 index 0e808cf..d7d274b 100644
49388 --- a/drivers/uio/uio.c
49389 +++ b/drivers/uio/uio.c
49390 @@ -25,6 +25,7 @@
49391 #include <linux/kobject.h>
49392 #include <linux/cdev.h>
49393 #include <linux/uio_driver.h>
49394 +#include <asm/local.h>
49395
49396 #define UIO_MAX_DEVICES (1U << MINORBITS)
49397
49398 @@ -32,7 +33,7 @@ struct uio_device {
49399 struct module *owner;
49400 struct device *dev;
49401 int minor;
49402 - atomic_t event;
49403 + atomic_unchecked_t event;
49404 struct fasync_struct *async_queue;
49405 wait_queue_head_t wait;
49406 struct uio_info *info;
49407 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
49408 struct device_attribute *attr, char *buf)
49409 {
49410 struct uio_device *idev = dev_get_drvdata(dev);
49411 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
49412 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
49413 }
49414 static DEVICE_ATTR_RO(event);
49415
49416 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
49417 {
49418 struct uio_device *idev = info->uio_dev;
49419
49420 - atomic_inc(&idev->event);
49421 + atomic_inc_unchecked(&idev->event);
49422 wake_up_interruptible(&idev->wait);
49423 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
49424 }
49425 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
49426 }
49427
49428 listener->dev = idev;
49429 - listener->event_count = atomic_read(&idev->event);
49430 + listener->event_count = atomic_read_unchecked(&idev->event);
49431 filep->private_data = listener;
49432
49433 if (idev->info->open) {
49434 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49435 return -EIO;
49436
49437 poll_wait(filep, &idev->wait, wait);
49438 - if (listener->event_count != atomic_read(&idev->event))
49439 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49440 return POLLIN | POLLRDNORM;
49441 return 0;
49442 }
49443 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49444 do {
49445 set_current_state(TASK_INTERRUPTIBLE);
49446
49447 - event_count = atomic_read(&idev->event);
49448 + event_count = atomic_read_unchecked(&idev->event);
49449 if (event_count != listener->event_count) {
49450 if (copy_to_user(buf, &event_count, count))
49451 retval = -EFAULT;
49452 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
49453 static int uio_find_mem_index(struct vm_area_struct *vma)
49454 {
49455 struct uio_device *idev = vma->vm_private_data;
49456 + unsigned long size;
49457
49458 if (vma->vm_pgoff < MAX_UIO_MAPS) {
49459 - if (idev->info->mem[vma->vm_pgoff].size == 0)
49460 + size = idev->info->mem[vma->vm_pgoff].size;
49461 + if (size == 0)
49462 + return -1;
49463 + if (vma->vm_end - vma->vm_start > size)
49464 return -1;
49465 return (int)vma->vm_pgoff;
49466 }
49467 @@ -647,6 +652,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
49468 return -EINVAL;
49469 mem = idev->info->mem + mi;
49470
49471 + if (mem->addr & ~PAGE_MASK)
49472 + return -ENODEV;
49473 if (vma->vm_end - vma->vm_start > mem->size)
49474 return -EINVAL;
49475
49476 @@ -818,7 +825,7 @@ int __uio_register_device(struct module *owner,
49477 idev->owner = owner;
49478 idev->info = info;
49479 init_waitqueue_head(&idev->wait);
49480 - atomic_set(&idev->event, 0);
49481 + atomic_set_unchecked(&idev->event, 0);
49482
49483 ret = uio_get_minor(idev);
49484 if (ret)
49485 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49486 index 8a7eb77..c00402f 100644
49487 --- a/drivers/usb/atm/cxacru.c
49488 +++ b/drivers/usb/atm/cxacru.c
49489 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49490 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49491 if (ret < 2)
49492 return -EINVAL;
49493 - if (index < 0 || index > 0x7f)
49494 + if (index > 0x7f)
49495 return -EINVAL;
49496 pos += tmp;
49497
49498 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49499 index 25a7bfc..57f3cf5 100644
49500 --- a/drivers/usb/atm/usbatm.c
49501 +++ b/drivers/usb/atm/usbatm.c
49502 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49503 if (printk_ratelimit())
49504 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49505 __func__, vpi, vci);
49506 - atomic_inc(&vcc->stats->rx_err);
49507 + atomic_inc_unchecked(&vcc->stats->rx_err);
49508 return;
49509 }
49510
49511 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49512 if (length > ATM_MAX_AAL5_PDU) {
49513 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49514 __func__, length, vcc);
49515 - atomic_inc(&vcc->stats->rx_err);
49516 + atomic_inc_unchecked(&vcc->stats->rx_err);
49517 goto out;
49518 }
49519
49520 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49521 if (sarb->len < pdu_length) {
49522 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49523 __func__, pdu_length, sarb->len, vcc);
49524 - atomic_inc(&vcc->stats->rx_err);
49525 + atomic_inc_unchecked(&vcc->stats->rx_err);
49526 goto out;
49527 }
49528
49529 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49530 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49531 __func__, vcc);
49532 - atomic_inc(&vcc->stats->rx_err);
49533 + atomic_inc_unchecked(&vcc->stats->rx_err);
49534 goto out;
49535 }
49536
49537 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49538 if (printk_ratelimit())
49539 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49540 __func__, length);
49541 - atomic_inc(&vcc->stats->rx_drop);
49542 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49543 goto out;
49544 }
49545
49546 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49547
49548 vcc->push(vcc, skb);
49549
49550 - atomic_inc(&vcc->stats->rx);
49551 + atomic_inc_unchecked(&vcc->stats->rx);
49552 out:
49553 skb_trim(sarb, 0);
49554 }
49555 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
49556 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49557
49558 usbatm_pop(vcc, skb);
49559 - atomic_inc(&vcc->stats->tx);
49560 + atomic_inc_unchecked(&vcc->stats->tx);
49561
49562 skb = skb_dequeue(&instance->sndqueue);
49563 }
49564 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49565 if (!left--)
49566 return sprintf(page,
49567 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49568 - atomic_read(&atm_dev->stats.aal5.tx),
49569 - atomic_read(&atm_dev->stats.aal5.tx_err),
49570 - atomic_read(&atm_dev->stats.aal5.rx),
49571 - atomic_read(&atm_dev->stats.aal5.rx_err),
49572 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49573 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49574 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49575 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49576 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49577 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49578
49579 if (!left--) {
49580 if (instance->disconnected)
49581 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49582 index 2a3bbdf..91d72cf 100644
49583 --- a/drivers/usb/core/devices.c
49584 +++ b/drivers/usb/core/devices.c
49585 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49586 * time it gets called.
49587 */
49588 static struct device_connect_event {
49589 - atomic_t count;
49590 + atomic_unchecked_t count;
49591 wait_queue_head_t wait;
49592 } device_event = {
49593 .count = ATOMIC_INIT(1),
49594 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49595
49596 void usbfs_conn_disc_event(void)
49597 {
49598 - atomic_add(2, &device_event.count);
49599 + atomic_add_unchecked(2, &device_event.count);
49600 wake_up(&device_event.wait);
49601 }
49602
49603 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49604
49605 poll_wait(file, &device_event.wait, wait);
49606
49607 - event_count = atomic_read(&device_event.count);
49608 + event_count = atomic_read_unchecked(&device_event.count);
49609 if (file->f_version != event_count) {
49610 file->f_version = event_count;
49611 return POLLIN | POLLRDNORM;
49612 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
49613 index 71dc5d7..d4c488f 100644
49614 --- a/drivers/usb/core/devio.c
49615 +++ b/drivers/usb/core/devio.c
49616 @@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49617 struct dev_state *ps = file->private_data;
49618 struct usb_device *dev = ps->dev;
49619 ssize_t ret = 0;
49620 - unsigned len;
49621 + size_t len;
49622 loff_t pos;
49623 int i;
49624
49625 @@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49626 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
49627 struct usb_config_descriptor *config =
49628 (struct usb_config_descriptor *)dev->rawdescriptors[i];
49629 - unsigned int length = le16_to_cpu(config->wTotalLength);
49630 + size_t length = le16_to_cpu(config->wTotalLength);
49631
49632 if (*ppos < pos + length) {
49633
49634 /* The descriptor may claim to be longer than it
49635 * really is. Here is the actual allocated length. */
49636 - unsigned alloclen =
49637 + size_t alloclen =
49638 le16_to_cpu(dev->config[i].desc.wTotalLength);
49639
49640 - len = length - (*ppos - pos);
49641 + len = length + pos - *ppos;
49642 if (len > nbytes)
49643 len = nbytes;
49644
49645 /* Simply don't write (skip over) unallocated parts */
49646 if (alloclen > (*ppos - pos)) {
49647 - alloclen -= (*ppos - pos);
49648 + alloclen = alloclen + pos - *ppos;
49649 if (copy_to_user(buf,
49650 dev->rawdescriptors[i] + (*ppos - pos),
49651 min(len, alloclen))) {
49652 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49653 index f20a044..d1059aa 100644
49654 --- a/drivers/usb/core/hcd.c
49655 +++ b/drivers/usb/core/hcd.c
49656 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49657 */
49658 usb_get_urb(urb);
49659 atomic_inc(&urb->use_count);
49660 - atomic_inc(&urb->dev->urbnum);
49661 + atomic_inc_unchecked(&urb->dev->urbnum);
49662 usbmon_urb_submit(&hcd->self, urb);
49663
49664 /* NOTE requirements on root-hub callers (usbfs and the hub
49665 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49666 urb->hcpriv = NULL;
49667 INIT_LIST_HEAD(&urb->urb_list);
49668 atomic_dec(&urb->use_count);
49669 - atomic_dec(&urb->dev->urbnum);
49670 + atomic_dec_unchecked(&urb->dev->urbnum);
49671 if (atomic_read(&urb->reject))
49672 wake_up(&usb_kill_urb_queue);
49673 usb_put_urb(urb);
49674 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49675 index c5c3667..e54e5cd 100644
49676 --- a/drivers/usb/core/hub.c
49677 +++ b/drivers/usb/core/hub.c
49678 @@ -27,6 +27,7 @@
49679 #include <linux/freezer.h>
49680 #include <linux/random.h>
49681 #include <linux/pm_qos.h>
49682 +#include <linux/grsecurity.h>
49683
49684 #include <asm/uaccess.h>
49685 #include <asm/byteorder.h>
49686 @@ -4467,6 +4468,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49687 goto done;
49688 return;
49689 }
49690 +
49691 + if (gr_handle_new_usb())
49692 + goto done;
49693 +
49694 if (hub_is_superspeed(hub->hdev))
49695 unit_load = 150;
49696 else
49697 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49698 index 82927e1..4993dbf 100644
49699 --- a/drivers/usb/core/message.c
49700 +++ b/drivers/usb/core/message.c
49701 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49702 * Return: If successful, the number of bytes transferred. Otherwise, a negative
49703 * error number.
49704 */
49705 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49706 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49707 __u8 requesttype, __u16 value, __u16 index, void *data,
49708 __u16 size, int timeout)
49709 {
49710 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
49711 * If successful, 0. Otherwise a negative error number. The number of actual
49712 * bytes transferred will be stored in the @actual_length paramater.
49713 */
49714 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49715 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49716 void *data, int len, int *actual_length, int timeout)
49717 {
49718 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
49719 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
49720 * bytes transferred will be stored in the @actual_length paramater.
49721 *
49722 */
49723 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49724 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49725 void *data, int len, int *actual_length, int timeout)
49726 {
49727 struct urb *urb;
49728 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49729 index ca516ac..6c36ee4 100644
49730 --- a/drivers/usb/core/sysfs.c
49731 +++ b/drivers/usb/core/sysfs.c
49732 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
49733 struct usb_device *udev;
49734
49735 udev = to_usb_device(dev);
49736 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49737 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49738 }
49739 static DEVICE_ATTR_RO(urbnum);
49740
49741 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49742 index 0a6ee2e..6f8d7e8 100644
49743 --- a/drivers/usb/core/usb.c
49744 +++ b/drivers/usb/core/usb.c
49745 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49746 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49747 dev->state = USB_STATE_ATTACHED;
49748 dev->lpm_disable_count = 1;
49749 - atomic_set(&dev->urbnum, 0);
49750 + atomic_set_unchecked(&dev->urbnum, 0);
49751
49752 INIT_LIST_HEAD(&dev->ep0.urb_list);
49753 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49754 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49755 index 02e44fc..3c4fe64 100644
49756 --- a/drivers/usb/dwc3/gadget.c
49757 +++ b/drivers/usb/dwc3/gadget.c
49758 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49759 if (!usb_endpoint_xfer_isoc(desc))
49760 return 0;
49761
49762 - memset(&trb_link, 0, sizeof(trb_link));
49763 -
49764 /* Link TRB for ISOC. The HWO bit is never reset */
49765 trb_st_hw = &dep->trb_pool[0];
49766
49767 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49768 index 5e29dde..eca992f 100644
49769 --- a/drivers/usb/early/ehci-dbgp.c
49770 +++ b/drivers/usb/early/ehci-dbgp.c
49771 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49772
49773 #ifdef CONFIG_KGDB
49774 static struct kgdb_io kgdbdbgp_io_ops;
49775 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49776 +static struct kgdb_io kgdbdbgp_io_ops_console;
49777 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49778 #else
49779 #define dbgp_kgdb_mode (0)
49780 #endif
49781 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49782 .write_char = kgdbdbgp_write_char,
49783 };
49784
49785 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49786 + .name = "kgdbdbgp",
49787 + .read_char = kgdbdbgp_read_char,
49788 + .write_char = kgdbdbgp_write_char,
49789 + .is_console = 1
49790 +};
49791 +
49792 static int kgdbdbgp_wait_time;
49793
49794 static int __init kgdbdbgp_parse_config(char *str)
49795 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49796 ptr++;
49797 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49798 }
49799 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49800 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49801 + if (early_dbgp_console.index != -1)
49802 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49803 + else
49804 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49805
49806 return 0;
49807 }
49808 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49809 index b369292..9f3ba40 100644
49810 --- a/drivers/usb/gadget/u_serial.c
49811 +++ b/drivers/usb/gadget/u_serial.c
49812 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49813 spin_lock_irq(&port->port_lock);
49814
49815 /* already open? Great. */
49816 - if (port->port.count) {
49817 + if (atomic_read(&port->port.count)) {
49818 status = 0;
49819 - port->port.count++;
49820 + atomic_inc(&port->port.count);
49821
49822 /* currently opening/closing? wait ... */
49823 } else if (port->openclose) {
49824 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49825 tty->driver_data = port;
49826 port->port.tty = tty;
49827
49828 - port->port.count = 1;
49829 + atomic_set(&port->port.count, 1);
49830 port->openclose = false;
49831
49832 /* if connected, start the I/O stream */
49833 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49834
49835 spin_lock_irq(&port->port_lock);
49836
49837 - if (port->port.count != 1) {
49838 - if (port->port.count == 0)
49839 + if (atomic_read(&port->port.count) != 1) {
49840 + if (atomic_read(&port->port.count) == 0)
49841 WARN_ON(1);
49842 else
49843 - --port->port.count;
49844 + atomic_dec(&port->port.count);
49845 goto exit;
49846 }
49847
49848 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49849 * and sleep if necessary
49850 */
49851 port->openclose = true;
49852 - port->port.count = 0;
49853 + atomic_set(&port->port.count, 0);
49854
49855 gser = port->port_usb;
49856 if (gser && gser->disconnect)
49857 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49858 int cond;
49859
49860 spin_lock_irq(&port->port_lock);
49861 - cond = (port->port.count == 0) && !port->openclose;
49862 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49863 spin_unlock_irq(&port->port_lock);
49864 return cond;
49865 }
49866 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49867 /* if it's already open, start I/O ... and notify the serial
49868 * protocol about open/close status (connect/disconnect).
49869 */
49870 - if (port->port.count) {
49871 + if (atomic_read(&port->port.count)) {
49872 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49873 gs_start_io(port);
49874 if (gser->connect)
49875 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49876
49877 port->port_usb = NULL;
49878 gser->ioport = NULL;
49879 - if (port->port.count > 0 || port->openclose) {
49880 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49881 wake_up_interruptible(&port->drain_wait);
49882 if (port->port.tty)
49883 tty_hangup(port->port.tty);
49884 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49885
49886 /* finally, free any unused/unusable I/O buffers */
49887 spin_lock_irqsave(&port->port_lock, flags);
49888 - if (port->port.count == 0 && !port->openclose)
49889 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49890 gs_buf_free(&port->port_write_buf);
49891 gs_free_requests(gser->out, &port->read_pool, NULL);
49892 gs_free_requests(gser->out, &port->read_queue, NULL);
49893 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
49894 index 835fc08..f8b22bf 100644
49895 --- a/drivers/usb/host/ehci-hub.c
49896 +++ b/drivers/usb/host/ehci-hub.c
49897 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
49898 urb->transfer_flags = URB_DIR_IN;
49899 usb_get_urb(urb);
49900 atomic_inc(&urb->use_count);
49901 - atomic_inc(&urb->dev->urbnum);
49902 + atomic_inc_unchecked(&urb->dev->urbnum);
49903 urb->setup_dma = dma_map_single(
49904 hcd->self.controller,
49905 urb->setup_packet,
49906 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49907 urb->status = -EINPROGRESS;
49908 usb_get_urb(urb);
49909 atomic_inc(&urb->use_count);
49910 - atomic_inc(&urb->dev->urbnum);
49911 + atomic_inc_unchecked(&urb->dev->urbnum);
49912 retval = submit_single_step_set_feature(hcd, urb, 0);
49913 if (!retval && !wait_for_completion_timeout(&done,
49914 msecs_to_jiffies(2000))) {
49915 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49916 index ba6a5d6..f88f7f3 100644
49917 --- a/drivers/usb/misc/appledisplay.c
49918 +++ b/drivers/usb/misc/appledisplay.c
49919 @@ -83,7 +83,7 @@ struct appledisplay {
49920 spinlock_t lock;
49921 };
49922
49923 -static atomic_t count_displays = ATOMIC_INIT(0);
49924 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49925 static struct workqueue_struct *wq;
49926
49927 static void appledisplay_complete(struct urb *urb)
49928 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49929
49930 /* Register backlight device */
49931 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49932 - atomic_inc_return(&count_displays) - 1);
49933 + atomic_inc_return_unchecked(&count_displays) - 1);
49934 memset(&props, 0, sizeof(struct backlight_properties));
49935 props.type = BACKLIGHT_RAW;
49936 props.max_brightness = 0xff;
49937 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49938 index c69bb50..215ef37 100644
49939 --- a/drivers/usb/serial/console.c
49940 +++ b/drivers/usb/serial/console.c
49941 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49942
49943 info->port = port;
49944
49945 - ++port->port.count;
49946 + atomic_inc(&port->port.count);
49947 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49948 if (serial->type->set_termios) {
49949 /*
49950 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49951 }
49952 /* Now that any required fake tty operations are completed restore
49953 * the tty port count */
49954 - --port->port.count;
49955 + atomic_dec(&port->port.count);
49956 /* The console is special in terms of closing the device so
49957 * indicate this port is now acting as a system console. */
49958 port->port.console = 1;
49959 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49960 free_tty:
49961 kfree(tty);
49962 reset_open_count:
49963 - port->port.count = 0;
49964 + atomic_set(&port->port.count, 0);
49965 usb_autopm_put_interface(serial->interface);
49966 error_get_interface:
49967 usb_serial_put(serial);
49968 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49969 static void usb_console_write(struct console *co,
49970 const char *buf, unsigned count)
49971 {
49972 - static struct usbcons_info *info = &usbcons_info;
49973 + struct usbcons_info *info = &usbcons_info;
49974 struct usb_serial_port *port = info->port;
49975 struct usb_serial *serial;
49976 int retval = -ENODEV;
49977 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49978 index 75f70f0..d467e1a 100644
49979 --- a/drivers/usb/storage/usb.h
49980 +++ b/drivers/usb/storage/usb.h
49981 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49982 __u8 useProtocol;
49983 __u8 useTransport;
49984 int (*initFunction)(struct us_data *);
49985 -};
49986 +} __do_const;
49987
49988
49989 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49990 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49991 index cf250c2..ad9d904 100644
49992 --- a/drivers/usb/wusbcore/wa-hc.h
49993 +++ b/drivers/usb/wusbcore/wa-hc.h
49994 @@ -199,7 +199,7 @@ struct wahc {
49995 spinlock_t xfer_list_lock;
49996 struct work_struct xfer_enqueue_work;
49997 struct work_struct xfer_error_work;
49998 - atomic_t xfer_id_count;
49999 + atomic_unchecked_t xfer_id_count;
50000 };
50001
50002
50003 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
50004 spin_lock_init(&wa->xfer_list_lock);
50005 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
50006 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
50007 - atomic_set(&wa->xfer_id_count, 1);
50008 + atomic_set_unchecked(&wa->xfer_id_count, 1);
50009 }
50010
50011 /**
50012 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
50013 index 3dcf66f..8faaf6e 100644
50014 --- a/drivers/usb/wusbcore/wa-xfer.c
50015 +++ b/drivers/usb/wusbcore/wa-xfer.c
50016 @@ -300,7 +300,7 @@ out:
50017 */
50018 static void wa_xfer_id_init(struct wa_xfer *xfer)
50019 {
50020 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
50021 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
50022 }
50023
50024 /*
50025 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
50026 index 1eab4ac..e21efc9 100644
50027 --- a/drivers/vfio/vfio.c
50028 +++ b/drivers/vfio/vfio.c
50029 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
50030 return 0;
50031
50032 /* TODO Prevent device auto probing */
50033 - WARN("Device %s added to live group %d!\n", dev_name(dev),
50034 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
50035 iommu_group_id(group->iommu_group));
50036
50037 return 0;
50038 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
50039 index 5174eba..86e764a 100644
50040 --- a/drivers/vhost/vringh.c
50041 +++ b/drivers/vhost/vringh.c
50042 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
50043
50044 static inline int putu16_kern(u16 *p, u16 val)
50045 {
50046 - ACCESS_ONCE(*p) = val;
50047 + ACCESS_ONCE_RW(*p) = val;
50048 return 0;
50049 }
50050
50051 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
50052 index e43401a..dd49b3f 100644
50053 --- a/drivers/video/arcfb.c
50054 +++ b/drivers/video/arcfb.c
50055 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
50056 return -ENOSPC;
50057
50058 err = 0;
50059 - if ((count + p) > fbmemlength) {
50060 + if (count > (fbmemlength - p)) {
50061 count = fbmemlength - p;
50062 err = -ENOSPC;
50063 }
50064 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
50065 index a4dfe8c..297ddd9 100644
50066 --- a/drivers/video/aty/aty128fb.c
50067 +++ b/drivers/video/aty/aty128fb.c
50068 @@ -149,7 +149,7 @@ enum {
50069 };
50070
50071 /* Must match above enum */
50072 -static char * const r128_family[] = {
50073 +static const char * const r128_family[] = {
50074 "AGP",
50075 "PCI",
50076 "PRO AGP",
50077 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
50078 index 9b0f12c..024673d 100644
50079 --- a/drivers/video/aty/atyfb_base.c
50080 +++ b/drivers/video/aty/atyfb_base.c
50081 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
50082 par->accel_flags = var->accel_flags; /* hack */
50083
50084 if (var->accel_flags) {
50085 - info->fbops->fb_sync = atyfb_sync;
50086 + pax_open_kernel();
50087 + *(void **)&info->fbops->fb_sync = atyfb_sync;
50088 + pax_close_kernel();
50089 info->flags &= ~FBINFO_HWACCEL_DISABLED;
50090 } else {
50091 - info->fbops->fb_sync = NULL;
50092 + pax_open_kernel();
50093 + *(void **)&info->fbops->fb_sync = NULL;
50094 + pax_close_kernel();
50095 info->flags |= FBINFO_HWACCEL_DISABLED;
50096 }
50097
50098 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
50099 index 95ec042..e6affdd 100644
50100 --- a/drivers/video/aty/mach64_cursor.c
50101 +++ b/drivers/video/aty/mach64_cursor.c
50102 @@ -7,6 +7,7 @@
50103 #include <linux/string.h>
50104
50105 #include <asm/io.h>
50106 +#include <asm/pgtable.h>
50107
50108 #ifdef __sparc__
50109 #include <asm/fbio.h>
50110 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
50111 info->sprite.buf_align = 16; /* and 64 lines tall. */
50112 info->sprite.flags = FB_PIXMAP_IO;
50113
50114 - info->fbops->fb_cursor = atyfb_cursor;
50115 + pax_open_kernel();
50116 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
50117 + pax_close_kernel();
50118
50119 return 0;
50120 }
50121 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
50122 index bca6ccc..252107e 100644
50123 --- a/drivers/video/backlight/kb3886_bl.c
50124 +++ b/drivers/video/backlight/kb3886_bl.c
50125 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
50126 static unsigned long kb3886bl_flags;
50127 #define KB3886BL_SUSPENDED 0x01
50128
50129 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
50130 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
50131 {
50132 .ident = "Sahara Touch-iT",
50133 .matches = {
50134 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
50135 index 900aa4e..6d49418 100644
50136 --- a/drivers/video/fb_defio.c
50137 +++ b/drivers/video/fb_defio.c
50138 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
50139
50140 BUG_ON(!fbdefio);
50141 mutex_init(&fbdefio->lock);
50142 - info->fbops->fb_mmap = fb_deferred_io_mmap;
50143 + pax_open_kernel();
50144 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
50145 + pax_close_kernel();
50146 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
50147 INIT_LIST_HEAD(&fbdefio->pagelist);
50148 if (fbdefio->delay == 0) /* set a default of 1 s */
50149 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
50150 page->mapping = NULL;
50151 }
50152
50153 - info->fbops->fb_mmap = NULL;
50154 + *(void **)&info->fbops->fb_mmap = NULL;
50155 mutex_destroy(&fbdefio->lock);
50156 }
50157 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
50158 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
50159 index dacaf74..8478a46 100644
50160 --- a/drivers/video/fbmem.c
50161 +++ b/drivers/video/fbmem.c
50162 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
50163 image->dx += image->width + 8;
50164 }
50165 } else if (rotate == FB_ROTATE_UD) {
50166 - for (x = 0; x < num && image->dx >= 0; x++) {
50167 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
50168 info->fbops->fb_imageblit(info, image);
50169 image->dx -= image->width + 8;
50170 }
50171 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
50172 image->dy += image->height + 8;
50173 }
50174 } else if (rotate == FB_ROTATE_CCW) {
50175 - for (x = 0; x < num && image->dy >= 0; x++) {
50176 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
50177 info->fbops->fb_imageblit(info, image);
50178 image->dy -= image->height + 8;
50179 }
50180 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
50181 return -EFAULT;
50182 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
50183 return -EINVAL;
50184 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
50185 + if (con2fb.framebuffer >= FB_MAX)
50186 return -EINVAL;
50187 if (!registered_fb[con2fb.framebuffer])
50188 request_module("fb%d", con2fb.framebuffer);
50189 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
50190 index 8d456dc..b4fa44b 100644
50191 --- a/drivers/video/hyperv_fb.c
50192 +++ b/drivers/video/hyperv_fb.c
50193 @@ -233,7 +233,7 @@ static uint screen_fb_size;
50194 static inline int synthvid_send(struct hv_device *hdev,
50195 struct synthvid_msg *msg)
50196 {
50197 - static atomic64_t request_id = ATOMIC64_INIT(0);
50198 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
50199 int ret;
50200
50201 msg->pipe_hdr.type = PIPE_MSG_DATA;
50202 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
50203
50204 ret = vmbus_sendpacket(hdev->channel, msg,
50205 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
50206 - atomic64_inc_return(&request_id),
50207 + atomic64_inc_return_unchecked(&request_id),
50208 VM_PKT_DATA_INBAND, 0);
50209
50210 if (ret)
50211 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
50212 index 7672d2e..b56437f 100644
50213 --- a/drivers/video/i810/i810_accel.c
50214 +++ b/drivers/video/i810/i810_accel.c
50215 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
50216 }
50217 }
50218 printk("ringbuffer lockup!!!\n");
50219 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
50220 i810_report_error(mmio);
50221 par->dev_flags |= LOCKUP;
50222 info->pixmap.scan_align = 1;
50223 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
50224 index 3c14e43..2630570 100644
50225 --- a/drivers/video/logo/logo_linux_clut224.ppm
50226 +++ b/drivers/video/logo/logo_linux_clut224.ppm
50227 @@ -2,1603 +2,1123 @@ P3
50228 # Standard 224-color Linux logo
50229 80 80
50230 255
50231 - 0 0 0 0 0 0 0 0 0 0 0 0
50232 - 0 0 0 0 0 0 0 0 0 0 0 0
50233 - 0 0 0 0 0 0 0 0 0 0 0 0
50234 - 0 0 0 0 0 0 0 0 0 0 0 0
50235 - 0 0 0 0 0 0 0 0 0 0 0 0
50236 - 0 0 0 0 0 0 0 0 0 0 0 0
50237 - 0 0 0 0 0 0 0 0 0 0 0 0
50238 - 0 0 0 0 0 0 0 0 0 0 0 0
50239 - 0 0 0 0 0 0 0 0 0 0 0 0
50240 - 6 6 6 6 6 6 10 10 10 10 10 10
50241 - 10 10 10 6 6 6 6 6 6 6 6 6
50242 - 0 0 0 0 0 0 0 0 0 0 0 0
50243 - 0 0 0 0 0 0 0 0 0 0 0 0
50244 - 0 0 0 0 0 0 0 0 0 0 0 0
50245 - 0 0 0 0 0 0 0 0 0 0 0 0
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 0 0 0 0 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 0 0 0 0 0 0 0 0 0 0 0 0
50254 - 0 0 0 0 0 0 0 0 0 0 0 0
50255 - 0 0 0 0 0 0 0 0 0 0 0 0
50256 - 0 0 0 0 0 0 0 0 0 0 0 0
50257 - 0 0 0 0 0 0 0 0 0 0 0 0
50258 - 0 0 0 0 0 0 0 0 0 0 0 0
50259 - 0 0 0 6 6 6 10 10 10 14 14 14
50260 - 22 22 22 26 26 26 30 30 30 34 34 34
50261 - 30 30 30 30 30 30 26 26 26 18 18 18
50262 - 14 14 14 10 10 10 6 6 6 0 0 0
50263 - 0 0 0 0 0 0 0 0 0 0 0 0
50264 - 0 0 0 0 0 0 0 0 0 0 0 0
50265 - 0 0 0 0 0 0 0 0 0 0 0 0
50266 - 0 0 0 0 0 0 0 0 0 0 0 0
50267 - 0 0 0 0 0 0 0 0 0 0 0 0
50268 - 0 0 0 0 0 0 0 0 0 0 0 0
50269 - 0 0 0 0 0 0 0 0 0 0 0 0
50270 - 0 0 0 0 0 0 0 0 0 0 0 0
50271 - 0 0 0 0 0 0 0 0 0 0 0 0
50272 - 0 0 0 0 0 1 0 0 1 0 0 0
50273 - 0 0 0 0 0 0 0 0 0 0 0 0
50274 - 0 0 0 0 0 0 0 0 0 0 0 0
50275 - 0 0 0 0 0 0 0 0 0 0 0 0
50276 - 0 0 0 0 0 0 0 0 0 0 0 0
50277 - 0 0 0 0 0 0 0 0 0 0 0 0
50278 - 0 0 0 0 0 0 0 0 0 0 0 0
50279 - 6 6 6 14 14 14 26 26 26 42 42 42
50280 - 54 54 54 66 66 66 78 78 78 78 78 78
50281 - 78 78 78 74 74 74 66 66 66 54 54 54
50282 - 42 42 42 26 26 26 18 18 18 10 10 10
50283 - 6 6 6 0 0 0 0 0 0 0 0 0
50284 - 0 0 0 0 0 0 0 0 0 0 0 0
50285 - 0 0 0 0 0 0 0 0 0 0 0 0
50286 - 0 0 0 0 0 0 0 0 0 0 0 0
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 0 0 0
50289 - 0 0 0 0 0 0 0 0 0 0 0 0
50290 - 0 0 0 0 0 0 0 0 0 0 0 0
50291 - 0 0 0 0 0 0 0 0 0 0 0 0
50292 - 0 0 1 0 0 0 0 0 0 0 0 0
50293 - 0 0 0 0 0 0 0 0 0 0 0 0
50294 - 0 0 0 0 0 0 0 0 0 0 0 0
50295 - 0 0 0 0 0 0 0 0 0 0 0 0
50296 - 0 0 0 0 0 0 0 0 0 0 0 0
50297 - 0 0 0 0 0 0 0 0 0 0 0 0
50298 - 0 0 0 0 0 0 0 0 0 10 10 10
50299 - 22 22 22 42 42 42 66 66 66 86 86 86
50300 - 66 66 66 38 38 38 38 38 38 22 22 22
50301 - 26 26 26 34 34 34 54 54 54 66 66 66
50302 - 86 86 86 70 70 70 46 46 46 26 26 26
50303 - 14 14 14 6 6 6 0 0 0 0 0 0
50304 - 0 0 0 0 0 0 0 0 0 0 0 0
50305 - 0 0 0 0 0 0 0 0 0 0 0 0
50306 - 0 0 0 0 0 0 0 0 0 0 0 0
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 0 0 0
50309 - 0 0 0 0 0 0 0 0 0 0 0 0
50310 - 0 0 0 0 0 0 0 0 0 0 0 0
50311 - 0 0 0 0 0 0 0 0 0 0 0 0
50312 - 0 0 1 0 0 1 0 0 1 0 0 0
50313 - 0 0 0 0 0 0 0 0 0 0 0 0
50314 - 0 0 0 0 0 0 0 0 0 0 0 0
50315 - 0 0 0 0 0 0 0 0 0 0 0 0
50316 - 0 0 0 0 0 0 0 0 0 0 0 0
50317 - 0 0 0 0 0 0 0 0 0 0 0 0
50318 - 0 0 0 0 0 0 10 10 10 26 26 26
50319 - 50 50 50 82 82 82 58 58 58 6 6 6
50320 - 2 2 6 2 2 6 2 2 6 2 2 6
50321 - 2 2 6 2 2 6 2 2 6 2 2 6
50322 - 6 6 6 54 54 54 86 86 86 66 66 66
50323 - 38 38 38 18 18 18 6 6 6 0 0 0
50324 - 0 0 0 0 0 0 0 0 0 0 0 0
50325 - 0 0 0 0 0 0 0 0 0 0 0 0
50326 - 0 0 0 0 0 0 0 0 0 0 0 0
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 0 0 0
50329 - 0 0 0 0 0 0 0 0 0 0 0 0
50330 - 0 0 0 0 0 0 0 0 0 0 0 0
50331 - 0 0 0 0 0 0 0 0 0 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 0 0 0
50333 - 0 0 0 0 0 0 0 0 0 0 0 0
50334 - 0 0 0 0 0 0 0 0 0 0 0 0
50335 - 0 0 0 0 0 0 0 0 0 0 0 0
50336 - 0 0 0 0 0 0 0 0 0 0 0 0
50337 - 0 0 0 0 0 0 0 0 0 0 0 0
50338 - 0 0 0 6 6 6 22 22 22 50 50 50
50339 - 78 78 78 34 34 34 2 2 6 2 2 6
50340 - 2 2 6 2 2 6 2 2 6 2 2 6
50341 - 2 2 6 2 2 6 2 2 6 2 2 6
50342 - 2 2 6 2 2 6 6 6 6 70 70 70
50343 - 78 78 78 46 46 46 22 22 22 6 6 6
50344 - 0 0 0 0 0 0 0 0 0 0 0 0
50345 - 0 0 0 0 0 0 0 0 0 0 0 0
50346 - 0 0 0 0 0 0 0 0 0 0 0 0
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 0 0 0 0 0 0
50349 - 0 0 0 0 0 0 0 0 0 0 0 0
50350 - 0 0 0 0 0 0 0 0 0 0 0 0
50351 - 0 0 0 0 0 0 0 0 0 0 0 0
50352 - 0 0 1 0 0 1 0 0 1 0 0 0
50353 - 0 0 0 0 0 0 0 0 0 0 0 0
50354 - 0 0 0 0 0 0 0 0 0 0 0 0
50355 - 0 0 0 0 0 0 0 0 0 0 0 0
50356 - 0 0 0 0 0 0 0 0 0 0 0 0
50357 - 0 0 0 0 0 0 0 0 0 0 0 0
50358 - 6 6 6 18 18 18 42 42 42 82 82 82
50359 - 26 26 26 2 2 6 2 2 6 2 2 6
50360 - 2 2 6 2 2 6 2 2 6 2 2 6
50361 - 2 2 6 2 2 6 2 2 6 14 14 14
50362 - 46 46 46 34 34 34 6 6 6 2 2 6
50363 - 42 42 42 78 78 78 42 42 42 18 18 18
50364 - 6 6 6 0 0 0 0 0 0 0 0 0
50365 - 0 0 0 0 0 0 0 0 0 0 0 0
50366 - 0 0 0 0 0 0 0 0 0 0 0 0
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 0 0 0 0 0 0
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 0 0 0 0
50371 - 0 0 0 0 0 0 0 0 0 0 0 0
50372 - 0 0 1 0 0 0 0 0 1 0 0 0
50373 - 0 0 0 0 0 0 0 0 0 0 0 0
50374 - 0 0 0 0 0 0 0 0 0 0 0 0
50375 - 0 0 0 0 0 0 0 0 0 0 0 0
50376 - 0 0 0 0 0 0 0 0 0 0 0 0
50377 - 0 0 0 0 0 0 0 0 0 0 0 0
50378 - 10 10 10 30 30 30 66 66 66 58 58 58
50379 - 2 2 6 2 2 6 2 2 6 2 2 6
50380 - 2 2 6 2 2 6 2 2 6 2 2 6
50381 - 2 2 6 2 2 6 2 2 6 26 26 26
50382 - 86 86 86 101 101 101 46 46 46 10 10 10
50383 - 2 2 6 58 58 58 70 70 70 34 34 34
50384 - 10 10 10 0 0 0 0 0 0 0 0 0
50385 - 0 0 0 0 0 0 0 0 0 0 0 0
50386 - 0 0 0 0 0 0 0 0 0 0 0 0
50387 - 0 0 0 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 0 0 0 0 0 0 0 0 0
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 1 0 0 1 0 0 1 0 0 0
50393 - 0 0 0 0 0 0 0 0 0 0 0 0
50394 - 0 0 0 0 0 0 0 0 0 0 0 0
50395 - 0 0 0 0 0 0 0 0 0 0 0 0
50396 - 0 0 0 0 0 0 0 0 0 0 0 0
50397 - 0 0 0 0 0 0 0 0 0 0 0 0
50398 - 14 14 14 42 42 42 86 86 86 10 10 10
50399 - 2 2 6 2 2 6 2 2 6 2 2 6
50400 - 2 2 6 2 2 6 2 2 6 2 2 6
50401 - 2 2 6 2 2 6 2 2 6 30 30 30
50402 - 94 94 94 94 94 94 58 58 58 26 26 26
50403 - 2 2 6 6 6 6 78 78 78 54 54 54
50404 - 22 22 22 6 6 6 0 0 0 0 0 0
50405 - 0 0 0 0 0 0 0 0 0 0 0 0
50406 - 0 0 0 0 0 0 0 0 0 0 0 0
50407 - 0 0 0 0 0 0 0 0 0 0 0 0
50408 - 0 0 0 0 0 0 0 0 0 0 0 0
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 0 0 0 0
50411 - 0 0 0 0 0 0 0 0 0 0 0 0
50412 - 0 0 0 0 0 0 0 0 0 0 0 0
50413 - 0 0 0 0 0 0 0 0 0 0 0 0
50414 - 0 0 0 0 0 0 0 0 0 0 0 0
50415 - 0 0 0 0 0 0 0 0 0 0 0 0
50416 - 0 0 0 0 0 0 0 0 0 0 0 0
50417 - 0 0 0 0 0 0 0 0 0 6 6 6
50418 - 22 22 22 62 62 62 62 62 62 2 2 6
50419 - 2 2 6 2 2 6 2 2 6 2 2 6
50420 - 2 2 6 2 2 6 2 2 6 2 2 6
50421 - 2 2 6 2 2 6 2 2 6 26 26 26
50422 - 54 54 54 38 38 38 18 18 18 10 10 10
50423 - 2 2 6 2 2 6 34 34 34 82 82 82
50424 - 38 38 38 14 14 14 0 0 0 0 0 0
50425 - 0 0 0 0 0 0 0 0 0 0 0 0
50426 - 0 0 0 0 0 0 0 0 0 0 0 0
50427 - 0 0 0 0 0 0 0 0 0 0 0 0
50428 - 0 0 0 0 0 0 0 0 0 0 0 0
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 0 0 0 0
50431 - 0 0 0 0 0 0 0 0 0 0 0 0
50432 - 0 0 0 0 0 1 0 0 1 0 0 0
50433 - 0 0 0 0 0 0 0 0 0 0 0 0
50434 - 0 0 0 0 0 0 0 0 0 0 0 0
50435 - 0 0 0 0 0 0 0 0 0 0 0 0
50436 - 0 0 0 0 0 0 0 0 0 0 0 0
50437 - 0 0 0 0 0 0 0 0 0 6 6 6
50438 - 30 30 30 78 78 78 30 30 30 2 2 6
50439 - 2 2 6 2 2 6 2 2 6 2 2 6
50440 - 2 2 6 2 2 6 2 2 6 2 2 6
50441 - 2 2 6 2 2 6 2 2 6 10 10 10
50442 - 10 10 10 2 2 6 2 2 6 2 2 6
50443 - 2 2 6 2 2 6 2 2 6 78 78 78
50444 - 50 50 50 18 18 18 6 6 6 0 0 0
50445 - 0 0 0 0 0 0 0 0 0 0 0 0
50446 - 0 0 0 0 0 0 0 0 0 0 0 0
50447 - 0 0 0 0 0 0 0 0 0 0 0 0
50448 - 0 0 0 0 0 0 0 0 0 0 0 0
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 0 0 0 0
50451 - 0 0 0 0 0 0 0 0 0 0 0 0
50452 - 0 0 1 0 0 0 0 0 0 0 0 0
50453 - 0 0 0 0 0 0 0 0 0 0 0 0
50454 - 0 0 0 0 0 0 0 0 0 0 0 0
50455 - 0 0 0 0 0 0 0 0 0 0 0 0
50456 - 0 0 0 0 0 0 0 0 0 0 0 0
50457 - 0 0 0 0 0 0 0 0 0 10 10 10
50458 - 38 38 38 86 86 86 14 14 14 2 2 6
50459 - 2 2 6 2 2 6 2 2 6 2 2 6
50460 - 2 2 6 2 2 6 2 2 6 2 2 6
50461 - 2 2 6 2 2 6 2 2 6 2 2 6
50462 - 2 2 6 2 2 6 2 2 6 2 2 6
50463 - 2 2 6 2 2 6 2 2 6 54 54 54
50464 - 66 66 66 26 26 26 6 6 6 0 0 0
50465 - 0 0 0 0 0 0 0 0 0 0 0 0
50466 - 0 0 0 0 0 0 0 0 0 0 0 0
50467 - 0 0 0 0 0 0 0 0 0 0 0 0
50468 - 0 0 0 0 0 0 0 0 0 0 0 0
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 0 0 0 0 0 0 0 0 0 0 0 0
50472 - 0 0 0 0 0 1 0 0 1 0 0 0
50473 - 0 0 0 0 0 0 0 0 0 0 0 0
50474 - 0 0 0 0 0 0 0 0 0 0 0 0
50475 - 0 0 0 0 0 0 0 0 0 0 0 0
50476 - 0 0 0 0 0 0 0 0 0 0 0 0
50477 - 0 0 0 0 0 0 0 0 0 14 14 14
50478 - 42 42 42 82 82 82 2 2 6 2 2 6
50479 - 2 2 6 6 6 6 10 10 10 2 2 6
50480 - 2 2 6 2 2 6 2 2 6 2 2 6
50481 - 2 2 6 2 2 6 2 2 6 6 6 6
50482 - 14 14 14 10 10 10 2 2 6 2 2 6
50483 - 2 2 6 2 2 6 2 2 6 18 18 18
50484 - 82 82 82 34 34 34 10 10 10 0 0 0
50485 - 0 0 0 0 0 0 0 0 0 0 0 0
50486 - 0 0 0 0 0 0 0 0 0 0 0 0
50487 - 0 0 0 0 0 0 0 0 0 0 0 0
50488 - 0 0 0 0 0 0 0 0 0 0 0 0
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 0 0 0 0 0 0 0 0 0 0 0 0
50492 - 0 0 1 0 0 0 0 0 0 0 0 0
50493 - 0 0 0 0 0 0 0 0 0 0 0 0
50494 - 0 0 0 0 0 0 0 0 0 0 0 0
50495 - 0 0 0 0 0 0 0 0 0 0 0 0
50496 - 0 0 0 0 0 0 0 0 0 0 0 0
50497 - 0 0 0 0 0 0 0 0 0 14 14 14
50498 - 46 46 46 86 86 86 2 2 6 2 2 6
50499 - 6 6 6 6 6 6 22 22 22 34 34 34
50500 - 6 6 6 2 2 6 2 2 6 2 2 6
50501 - 2 2 6 2 2 6 18 18 18 34 34 34
50502 - 10 10 10 50 50 50 22 22 22 2 2 6
50503 - 2 2 6 2 2 6 2 2 6 10 10 10
50504 - 86 86 86 42 42 42 14 14 14 0 0 0
50505 - 0 0 0 0 0 0 0 0 0 0 0 0
50506 - 0 0 0 0 0 0 0 0 0 0 0 0
50507 - 0 0 0 0 0 0 0 0 0 0 0 0
50508 - 0 0 0 0 0 0 0 0 0 0 0 0
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 0 0 0
50511 - 0 0 0 0 0 0 0 0 0 0 0 0
50512 - 0 0 1 0 0 1 0 0 1 0 0 0
50513 - 0 0 0 0 0 0 0 0 0 0 0 0
50514 - 0 0 0 0 0 0 0 0 0 0 0 0
50515 - 0 0 0 0 0 0 0 0 0 0 0 0
50516 - 0 0 0 0 0 0 0 0 0 0 0 0
50517 - 0 0 0 0 0 0 0 0 0 14 14 14
50518 - 46 46 46 86 86 86 2 2 6 2 2 6
50519 - 38 38 38 116 116 116 94 94 94 22 22 22
50520 - 22 22 22 2 2 6 2 2 6 2 2 6
50521 - 14 14 14 86 86 86 138 138 138 162 162 162
50522 -154 154 154 38 38 38 26 26 26 6 6 6
50523 - 2 2 6 2 2 6 2 2 6 2 2 6
50524 - 86 86 86 46 46 46 14 14 14 0 0 0
50525 - 0 0 0 0 0 0 0 0 0 0 0 0
50526 - 0 0 0 0 0 0 0 0 0 0 0 0
50527 - 0 0 0 0 0 0 0 0 0 0 0 0
50528 - 0 0 0 0 0 0 0 0 0 0 0 0
50529 - 0 0 0 0 0 0 0 0 0 0 0 0
50530 - 0 0 0 0 0 0 0 0 0 0 0 0
50531 - 0 0 0 0 0 0 0 0 0 0 0 0
50532 - 0 0 0 0 0 0 0 0 0 0 0 0
50533 - 0 0 0 0 0 0 0 0 0 0 0 0
50534 - 0 0 0 0 0 0 0 0 0 0 0 0
50535 - 0 0 0 0 0 0 0 0 0 0 0 0
50536 - 0 0 0 0 0 0 0 0 0 0 0 0
50537 - 0 0 0 0 0 0 0 0 0 14 14 14
50538 - 46 46 46 86 86 86 2 2 6 14 14 14
50539 -134 134 134 198 198 198 195 195 195 116 116 116
50540 - 10 10 10 2 2 6 2 2 6 6 6 6
50541 -101 98 89 187 187 187 210 210 210 218 218 218
50542 -214 214 214 134 134 134 14 14 14 6 6 6
50543 - 2 2 6 2 2 6 2 2 6 2 2 6
50544 - 86 86 86 50 50 50 18 18 18 6 6 6
50545 - 0 0 0 0 0 0 0 0 0 0 0 0
50546 - 0 0 0 0 0 0 0 0 0 0 0 0
50547 - 0 0 0 0 0 0 0 0 0 0 0 0
50548 - 0 0 0 0 0 0 0 0 0 0 0 0
50549 - 0 0 0 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 0 0 0
50551 - 0 0 0 0 0 0 0 0 1 0 0 0
50552 - 0 0 1 0 0 1 0 0 1 0 0 0
50553 - 0 0 0 0 0 0 0 0 0 0 0 0
50554 - 0 0 0 0 0 0 0 0 0 0 0 0
50555 - 0 0 0 0 0 0 0 0 0 0 0 0
50556 - 0 0 0 0 0 0 0 0 0 0 0 0
50557 - 0 0 0 0 0 0 0 0 0 14 14 14
50558 - 46 46 46 86 86 86 2 2 6 54 54 54
50559 -218 218 218 195 195 195 226 226 226 246 246 246
50560 - 58 58 58 2 2 6 2 2 6 30 30 30
50561 -210 210 210 253 253 253 174 174 174 123 123 123
50562 -221 221 221 234 234 234 74 74 74 2 2 6
50563 - 2 2 6 2 2 6 2 2 6 2 2 6
50564 - 70 70 70 58 58 58 22 22 22 6 6 6
50565 - 0 0 0 0 0 0 0 0 0 0 0 0
50566 - 0 0 0 0 0 0 0 0 0 0 0 0
50567 - 0 0 0 0 0 0 0 0 0 0 0 0
50568 - 0 0 0 0 0 0 0 0 0 0 0 0
50569 - 0 0 0 0 0 0 0 0 0 0 0 0
50570 - 0 0 0 0 0 0 0 0 0 0 0 0
50571 - 0 0 0 0 0 0 0 0 0 0 0 0
50572 - 0 0 0 0 0 0 0 0 0 0 0 0
50573 - 0 0 0 0 0 0 0 0 0 0 0 0
50574 - 0 0 0 0 0 0 0 0 0 0 0 0
50575 - 0 0 0 0 0 0 0 0 0 0 0 0
50576 - 0 0 0 0 0 0 0 0 0 0 0 0
50577 - 0 0 0 0 0 0 0 0 0 14 14 14
50578 - 46 46 46 82 82 82 2 2 6 106 106 106
50579 -170 170 170 26 26 26 86 86 86 226 226 226
50580 -123 123 123 10 10 10 14 14 14 46 46 46
50581 -231 231 231 190 190 190 6 6 6 70 70 70
50582 - 90 90 90 238 238 238 158 158 158 2 2 6
50583 - 2 2 6 2 2 6 2 2 6 2 2 6
50584 - 70 70 70 58 58 58 22 22 22 6 6 6
50585 - 0 0 0 0 0 0 0 0 0 0 0 0
50586 - 0 0 0 0 0 0 0 0 0 0 0 0
50587 - 0 0 0 0 0 0 0 0 0 0 0 0
50588 - 0 0 0 0 0 0 0 0 0 0 0 0
50589 - 0 0 0 0 0 0 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 0 0 0
50591 - 0 0 0 0 0 0 0 0 1 0 0 0
50592 - 0 0 1 0 0 1 0 0 1 0 0 0
50593 - 0 0 0 0 0 0 0 0 0 0 0 0
50594 - 0 0 0 0 0 0 0 0 0 0 0 0
50595 - 0 0 0 0 0 0 0 0 0 0 0 0
50596 - 0 0 0 0 0 0 0 0 0 0 0 0
50597 - 0 0 0 0 0 0 0 0 0 14 14 14
50598 - 42 42 42 86 86 86 6 6 6 116 116 116
50599 -106 106 106 6 6 6 70 70 70 149 149 149
50600 -128 128 128 18 18 18 38 38 38 54 54 54
50601 -221 221 221 106 106 106 2 2 6 14 14 14
50602 - 46 46 46 190 190 190 198 198 198 2 2 6
50603 - 2 2 6 2 2 6 2 2 6 2 2 6
50604 - 74 74 74 62 62 62 22 22 22 6 6 6
50605 - 0 0 0 0 0 0 0 0 0 0 0 0
50606 - 0 0 0 0 0 0 0 0 0 0 0 0
50607 - 0 0 0 0 0 0 0 0 0 0 0 0
50608 - 0 0 0 0 0 0 0 0 0 0 0 0
50609 - 0 0 0 0 0 0 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 0 0 0
50611 - 0 0 0 0 0 0 0 0 1 0 0 0
50612 - 0 0 1 0 0 0 0 0 1 0 0 0
50613 - 0 0 0 0 0 0 0 0 0 0 0 0
50614 - 0 0 0 0 0 0 0 0 0 0 0 0
50615 - 0 0 0 0 0 0 0 0 0 0 0 0
50616 - 0 0 0 0 0 0 0 0 0 0 0 0
50617 - 0 0 0 0 0 0 0 0 0 14 14 14
50618 - 42 42 42 94 94 94 14 14 14 101 101 101
50619 -128 128 128 2 2 6 18 18 18 116 116 116
50620 -118 98 46 121 92 8 121 92 8 98 78 10
50621 -162 162 162 106 106 106 2 2 6 2 2 6
50622 - 2 2 6 195 195 195 195 195 195 6 6 6
50623 - 2 2 6 2 2 6 2 2 6 2 2 6
50624 - 74 74 74 62 62 62 22 22 22 6 6 6
50625 - 0 0 0 0 0 0 0 0 0 0 0 0
50626 - 0 0 0 0 0 0 0 0 0 0 0 0
50627 - 0 0 0 0 0 0 0 0 0 0 0 0
50628 - 0 0 0 0 0 0 0 0 0 0 0 0
50629 - 0 0 0 0 0 0 0 0 0 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 0 0 0
50631 - 0 0 0 0 0 0 0 0 1 0 0 1
50632 - 0 0 1 0 0 0 0 0 1 0 0 0
50633 - 0 0 0 0 0 0 0 0 0 0 0 0
50634 - 0 0 0 0 0 0 0 0 0 0 0 0
50635 - 0 0 0 0 0 0 0 0 0 0 0 0
50636 - 0 0 0 0 0 0 0 0 0 0 0 0
50637 - 0 0 0 0 0 0 0 0 0 10 10 10
50638 - 38 38 38 90 90 90 14 14 14 58 58 58
50639 -210 210 210 26 26 26 54 38 6 154 114 10
50640 -226 170 11 236 186 11 225 175 15 184 144 12
50641 -215 174 15 175 146 61 37 26 9 2 2 6
50642 - 70 70 70 246 246 246 138 138 138 2 2 6
50643 - 2 2 6 2 2 6 2 2 6 2 2 6
50644 - 70 70 70 66 66 66 26 26 26 6 6 6
50645 - 0 0 0 0 0 0 0 0 0 0 0 0
50646 - 0 0 0 0 0 0 0 0 0 0 0 0
50647 - 0 0 0 0 0 0 0 0 0 0 0 0
50648 - 0 0 0 0 0 0 0 0 0 0 0 0
50649 - 0 0 0 0 0 0 0 0 0 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 0 0 0
50651 - 0 0 0 0 0 0 0 0 0 0 0 0
50652 - 0 0 0 0 0 0 0 0 0 0 0 0
50653 - 0 0 0 0 0 0 0 0 0 0 0 0
50654 - 0 0 0 0 0 0 0 0 0 0 0 0
50655 - 0 0 0 0 0 0 0 0 0 0 0 0
50656 - 0 0 0 0 0 0 0 0 0 0 0 0
50657 - 0 0 0 0 0 0 0 0 0 10 10 10
50658 - 38 38 38 86 86 86 14 14 14 10 10 10
50659 -195 195 195 188 164 115 192 133 9 225 175 15
50660 -239 182 13 234 190 10 232 195 16 232 200 30
50661 -245 207 45 241 208 19 232 195 16 184 144 12
50662 -218 194 134 211 206 186 42 42 42 2 2 6
50663 - 2 2 6 2 2 6 2 2 6 2 2 6
50664 - 50 50 50 74 74 74 30 30 30 6 6 6
50665 - 0 0 0 0 0 0 0 0 0 0 0 0
50666 - 0 0 0 0 0 0 0 0 0 0 0 0
50667 - 0 0 0 0 0 0 0 0 0 0 0 0
50668 - 0 0 0 0 0 0 0 0 0 0 0 0
50669 - 0 0 0 0 0 0 0 0 0 0 0 0
50670 - 0 0 0 0 0 0 0 0 0 0 0 0
50671 - 0 0 0 0 0 0 0 0 0 0 0 0
50672 - 0 0 0 0 0 0 0 0 0 0 0 0
50673 - 0 0 0 0 0 0 0 0 0 0 0 0
50674 - 0 0 0 0 0 0 0 0 0 0 0 0
50675 - 0 0 0 0 0 0 0 0 0 0 0 0
50676 - 0 0 0 0 0 0 0 0 0 0 0 0
50677 - 0 0 0 0 0 0 0 0 0 10 10 10
50678 - 34 34 34 86 86 86 14 14 14 2 2 6
50679 -121 87 25 192 133 9 219 162 10 239 182 13
50680 -236 186 11 232 195 16 241 208 19 244 214 54
50681 -246 218 60 246 218 38 246 215 20 241 208 19
50682 -241 208 19 226 184 13 121 87 25 2 2 6
50683 - 2 2 6 2 2 6 2 2 6 2 2 6
50684 - 50 50 50 82 82 82 34 34 34 10 10 10
50685 - 0 0 0 0 0 0 0 0 0 0 0 0
50686 - 0 0 0 0 0 0 0 0 0 0 0 0
50687 - 0 0 0 0 0 0 0 0 0 0 0 0
50688 - 0 0 0 0 0 0 0 0 0 0 0 0
50689 - 0 0 0 0 0 0 0 0 0 0 0 0
50690 - 0 0 0 0 0 0 0 0 0 0 0 0
50691 - 0 0 0 0 0 0 0 0 0 0 0 0
50692 - 0 0 0 0 0 0 0 0 0 0 0 0
50693 - 0 0 0 0 0 0 0 0 0 0 0 0
50694 - 0 0 0 0 0 0 0 0 0 0 0 0
50695 - 0 0 0 0 0 0 0 0 0 0 0 0
50696 - 0 0 0 0 0 0 0 0 0 0 0 0
50697 - 0 0 0 0 0 0 0 0 0 10 10 10
50698 - 34 34 34 82 82 82 30 30 30 61 42 6
50699 -180 123 7 206 145 10 230 174 11 239 182 13
50700 -234 190 10 238 202 15 241 208 19 246 218 74
50701 -246 218 38 246 215 20 246 215 20 246 215 20
50702 -226 184 13 215 174 15 184 144 12 6 6 6
50703 - 2 2 6 2 2 6 2 2 6 2 2 6
50704 - 26 26 26 94 94 94 42 42 42 14 14 14
50705 - 0 0 0 0 0 0 0 0 0 0 0 0
50706 - 0 0 0 0 0 0 0 0 0 0 0 0
50707 - 0 0 0 0 0 0 0 0 0 0 0 0
50708 - 0 0 0 0 0 0 0 0 0 0 0 0
50709 - 0 0 0 0 0 0 0 0 0 0 0 0
50710 - 0 0 0 0 0 0 0 0 0 0 0 0
50711 - 0 0 0 0 0 0 0 0 0 0 0 0
50712 - 0 0 0 0 0 0 0 0 0 0 0 0
50713 - 0 0 0 0 0 0 0 0 0 0 0 0
50714 - 0 0 0 0 0 0 0 0 0 0 0 0
50715 - 0 0 0 0 0 0 0 0 0 0 0 0
50716 - 0 0 0 0 0 0 0 0 0 0 0 0
50717 - 0 0 0 0 0 0 0 0 0 10 10 10
50718 - 30 30 30 78 78 78 50 50 50 104 69 6
50719 -192 133 9 216 158 10 236 178 12 236 186 11
50720 -232 195 16 241 208 19 244 214 54 245 215 43
50721 -246 215 20 246 215 20 241 208 19 198 155 10
50722 -200 144 11 216 158 10 156 118 10 2 2 6
50723 - 2 2 6 2 2 6 2 2 6 2 2 6
50724 - 6 6 6 90 90 90 54 54 54 18 18 18
50725 - 6 6 6 0 0 0 0 0 0 0 0 0
50726 - 0 0 0 0 0 0 0 0 0 0 0 0
50727 - 0 0 0 0 0 0 0 0 0 0 0 0
50728 - 0 0 0 0 0 0 0 0 0 0 0 0
50729 - 0 0 0 0 0 0 0 0 0 0 0 0
50730 - 0 0 0 0 0 0 0 0 0 0 0 0
50731 - 0 0 0 0 0 0 0 0 0 0 0 0
50732 - 0 0 0 0 0 0 0 0 0 0 0 0
50733 - 0 0 0 0 0 0 0 0 0 0 0 0
50734 - 0 0 0 0 0 0 0 0 0 0 0 0
50735 - 0 0 0 0 0 0 0 0 0 0 0 0
50736 - 0 0 0 0 0 0 0 0 0 0 0 0
50737 - 0 0 0 0 0 0 0 0 0 10 10 10
50738 - 30 30 30 78 78 78 46 46 46 22 22 22
50739 -137 92 6 210 162 10 239 182 13 238 190 10
50740 -238 202 15 241 208 19 246 215 20 246 215 20
50741 -241 208 19 203 166 17 185 133 11 210 150 10
50742 -216 158 10 210 150 10 102 78 10 2 2 6
50743 - 6 6 6 54 54 54 14 14 14 2 2 6
50744 - 2 2 6 62 62 62 74 74 74 30 30 30
50745 - 10 10 10 0 0 0 0 0 0 0 0 0
50746 - 0 0 0 0 0 0 0 0 0 0 0 0
50747 - 0 0 0 0 0 0 0 0 0 0 0 0
50748 - 0 0 0 0 0 0 0 0 0 0 0 0
50749 - 0 0 0 0 0 0 0 0 0 0 0 0
50750 - 0 0 0 0 0 0 0 0 0 0 0 0
50751 - 0 0 0 0 0 0 0 0 0 0 0 0
50752 - 0 0 0 0 0 0 0 0 0 0 0 0
50753 - 0 0 0 0 0 0 0 0 0 0 0 0
50754 - 0 0 0 0 0 0 0 0 0 0 0 0
50755 - 0 0 0 0 0 0 0 0 0 0 0 0
50756 - 0 0 0 0 0 0 0 0 0 0 0 0
50757 - 0 0 0 0 0 0 0 0 0 10 10 10
50758 - 34 34 34 78 78 78 50 50 50 6 6 6
50759 - 94 70 30 139 102 15 190 146 13 226 184 13
50760 -232 200 30 232 195 16 215 174 15 190 146 13
50761 -168 122 10 192 133 9 210 150 10 213 154 11
50762 -202 150 34 182 157 106 101 98 89 2 2 6
50763 - 2 2 6 78 78 78 116 116 116 58 58 58
50764 - 2 2 6 22 22 22 90 90 90 46 46 46
50765 - 18 18 18 6 6 6 0 0 0 0 0 0
50766 - 0 0 0 0 0 0 0 0 0 0 0 0
50767 - 0 0 0 0 0 0 0 0 0 0 0 0
50768 - 0 0 0 0 0 0 0 0 0 0 0 0
50769 - 0 0 0 0 0 0 0 0 0 0 0 0
50770 - 0 0 0 0 0 0 0 0 0 0 0 0
50771 - 0 0 0 0 0 0 0 0 0 0 0 0
50772 - 0 0 0 0 0 0 0 0 0 0 0 0
50773 - 0 0 0 0 0 0 0 0 0 0 0 0
50774 - 0 0 0 0 0 0 0 0 0 0 0 0
50775 - 0 0 0 0 0 0 0 0 0 0 0 0
50776 - 0 0 0 0 0 0 0 0 0 0 0 0
50777 - 0 0 0 0 0 0 0 0 0 10 10 10
50778 - 38 38 38 86 86 86 50 50 50 6 6 6
50779 -128 128 128 174 154 114 156 107 11 168 122 10
50780 -198 155 10 184 144 12 197 138 11 200 144 11
50781 -206 145 10 206 145 10 197 138 11 188 164 115
50782 -195 195 195 198 198 198 174 174 174 14 14 14
50783 - 2 2 6 22 22 22 116 116 116 116 116 116
50784 - 22 22 22 2 2 6 74 74 74 70 70 70
50785 - 30 30 30 10 10 10 0 0 0 0 0 0
50786 - 0 0 0 0 0 0 0 0 0 0 0 0
50787 - 0 0 0 0 0 0 0 0 0 0 0 0
50788 - 0 0 0 0 0 0 0 0 0 0 0 0
50789 - 0 0 0 0 0 0 0 0 0 0 0 0
50790 - 0 0 0 0 0 0 0 0 0 0 0 0
50791 - 0 0 0 0 0 0 0 0 0 0 0 0
50792 - 0 0 0 0 0 0 0 0 0 0 0 0
50793 - 0 0 0 0 0 0 0 0 0 0 0 0
50794 - 0 0 0 0 0 0 0 0 0 0 0 0
50795 - 0 0 0 0 0 0 0 0 0 0 0 0
50796 - 0 0 0 0 0 0 0 0 0 0 0 0
50797 - 0 0 0 0 0 0 6 6 6 18 18 18
50798 - 50 50 50 101 101 101 26 26 26 10 10 10
50799 -138 138 138 190 190 190 174 154 114 156 107 11
50800 -197 138 11 200 144 11 197 138 11 192 133 9
50801 -180 123 7 190 142 34 190 178 144 187 187 187
50802 -202 202 202 221 221 221 214 214 214 66 66 66
50803 - 2 2 6 2 2 6 50 50 50 62 62 62
50804 - 6 6 6 2 2 6 10 10 10 90 90 90
50805 - 50 50 50 18 18 18 6 6 6 0 0 0
50806 - 0 0 0 0 0 0 0 0 0 0 0 0
50807 - 0 0 0 0 0 0 0 0 0 0 0 0
50808 - 0 0 0 0 0 0 0 0 0 0 0 0
50809 - 0 0 0 0 0 0 0 0 0 0 0 0
50810 - 0 0 0 0 0 0 0 0 0 0 0 0
50811 - 0 0 0 0 0 0 0 0 0 0 0 0
50812 - 0 0 0 0 0 0 0 0 0 0 0 0
50813 - 0 0 0 0 0 0 0 0 0 0 0 0
50814 - 0 0 0 0 0 0 0 0 0 0 0 0
50815 - 0 0 0 0 0 0 0 0 0 0 0 0
50816 - 0 0 0 0 0 0 0 0 0 0 0 0
50817 - 0 0 0 0 0 0 10 10 10 34 34 34
50818 - 74 74 74 74 74 74 2 2 6 6 6 6
50819 -144 144 144 198 198 198 190 190 190 178 166 146
50820 -154 121 60 156 107 11 156 107 11 168 124 44
50821 -174 154 114 187 187 187 190 190 190 210 210 210
50822 -246 246 246 253 253 253 253 253 253 182 182 182
50823 - 6 6 6 2 2 6 2 2 6 2 2 6
50824 - 2 2 6 2 2 6 2 2 6 62 62 62
50825 - 74 74 74 34 34 34 14 14 14 0 0 0
50826 - 0 0 0 0 0 0 0 0 0 0 0 0
50827 - 0 0 0 0 0 0 0 0 0 0 0 0
50828 - 0 0 0 0 0 0 0 0 0 0 0 0
50829 - 0 0 0 0 0 0 0 0 0 0 0 0
50830 - 0 0 0 0 0 0 0 0 0 0 0 0
50831 - 0 0 0 0 0 0 0 0 0 0 0 0
50832 - 0 0 0 0 0 0 0 0 0 0 0 0
50833 - 0 0 0 0 0 0 0 0 0 0 0 0
50834 - 0 0 0 0 0 0 0 0 0 0 0 0
50835 - 0 0 0 0 0 0 0 0 0 0 0 0
50836 - 0 0 0 0 0 0 0 0 0 0 0 0
50837 - 0 0 0 10 10 10 22 22 22 54 54 54
50838 - 94 94 94 18 18 18 2 2 6 46 46 46
50839 -234 234 234 221 221 221 190 190 190 190 190 190
50840 -190 190 190 187 187 187 187 187 187 190 190 190
50841 -190 190 190 195 195 195 214 214 214 242 242 242
50842 -253 253 253 253 253 253 253 253 253 253 253 253
50843 - 82 82 82 2 2 6 2 2 6 2 2 6
50844 - 2 2 6 2 2 6 2 2 6 14 14 14
50845 - 86 86 86 54 54 54 22 22 22 6 6 6
50846 - 0 0 0 0 0 0 0 0 0 0 0 0
50847 - 0 0 0 0 0 0 0 0 0 0 0 0
50848 - 0 0 0 0 0 0 0 0 0 0 0 0
50849 - 0 0 0 0 0 0 0 0 0 0 0 0
50850 - 0 0 0 0 0 0 0 0 0 0 0 0
50851 - 0 0 0 0 0 0 0 0 0 0 0 0
50852 - 0 0 0 0 0 0 0 0 0 0 0 0
50853 - 0 0 0 0 0 0 0 0 0 0 0 0
50854 - 0 0 0 0 0 0 0 0 0 0 0 0
50855 - 0 0 0 0 0 0 0 0 0 0 0 0
50856 - 0 0 0 0 0 0 0 0 0 0 0 0
50857 - 6 6 6 18 18 18 46 46 46 90 90 90
50858 - 46 46 46 18 18 18 6 6 6 182 182 182
50859 -253 253 253 246 246 246 206 206 206 190 190 190
50860 -190 190 190 190 190 190 190 190 190 190 190 190
50861 -206 206 206 231 231 231 250 250 250 253 253 253
50862 -253 253 253 253 253 253 253 253 253 253 253 253
50863 -202 202 202 14 14 14 2 2 6 2 2 6
50864 - 2 2 6 2 2 6 2 2 6 2 2 6
50865 - 42 42 42 86 86 86 42 42 42 18 18 18
50866 - 6 6 6 0 0 0 0 0 0 0 0 0
50867 - 0 0 0 0 0 0 0 0 0 0 0 0
50868 - 0 0 0 0 0 0 0 0 0 0 0 0
50869 - 0 0 0 0 0 0 0 0 0 0 0 0
50870 - 0 0 0 0 0 0 0 0 0 0 0 0
50871 - 0 0 0 0 0 0 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 0 0 0 0 0 0 0 0 0
50874 - 0 0 0 0 0 0 0 0 0 0 0 0
50875 - 0 0 0 0 0 0 0 0 0 0 0 0
50876 - 0 0 0 0 0 0 0 0 0 6 6 6
50877 - 14 14 14 38 38 38 74 74 74 66 66 66
50878 - 2 2 6 6 6 6 90 90 90 250 250 250
50879 -253 253 253 253 253 253 238 238 238 198 198 198
50880 -190 190 190 190 190 190 195 195 195 221 221 221
50881 -246 246 246 253 253 253 253 253 253 253 253 253
50882 -253 253 253 253 253 253 253 253 253 253 253 253
50883 -253 253 253 82 82 82 2 2 6 2 2 6
50884 - 2 2 6 2 2 6 2 2 6 2 2 6
50885 - 2 2 6 78 78 78 70 70 70 34 34 34
50886 - 14 14 14 6 6 6 0 0 0 0 0 0
50887 - 0 0 0 0 0 0 0 0 0 0 0 0
50888 - 0 0 0 0 0 0 0 0 0 0 0 0
50889 - 0 0 0 0 0 0 0 0 0 0 0 0
50890 - 0 0 0 0 0 0 0 0 0 0 0 0
50891 - 0 0 0 0 0 0 0 0 0 0 0 0
50892 - 0 0 0 0 0 0 0 0 0 0 0 0
50893 - 0 0 0 0 0 0 0 0 0 0 0 0
50894 - 0 0 0 0 0 0 0 0 0 0 0 0
50895 - 0 0 0 0 0 0 0 0 0 0 0 0
50896 - 0 0 0 0 0 0 0 0 0 14 14 14
50897 - 34 34 34 66 66 66 78 78 78 6 6 6
50898 - 2 2 6 18 18 18 218 218 218 253 253 253
50899 -253 253 253 253 253 253 253 253 253 246 246 246
50900 -226 226 226 231 231 231 246 246 246 253 253 253
50901 -253 253 253 253 253 253 253 253 253 253 253 253
50902 -253 253 253 253 253 253 253 253 253 253 253 253
50903 -253 253 253 178 178 178 2 2 6 2 2 6
50904 - 2 2 6 2 2 6 2 2 6 2 2 6
50905 - 2 2 6 18 18 18 90 90 90 62 62 62
50906 - 30 30 30 10 10 10 0 0 0 0 0 0
50907 - 0 0 0 0 0 0 0 0 0 0 0 0
50908 - 0 0 0 0 0 0 0 0 0 0 0 0
50909 - 0 0 0 0 0 0 0 0 0 0 0 0
50910 - 0 0 0 0 0 0 0 0 0 0 0 0
50911 - 0 0 0 0 0 0 0 0 0 0 0 0
50912 - 0 0 0 0 0 0 0 0 0 0 0 0
50913 - 0 0 0 0 0 0 0 0 0 0 0 0
50914 - 0 0 0 0 0 0 0 0 0 0 0 0
50915 - 0 0 0 0 0 0 0 0 0 0 0 0
50916 - 0 0 0 0 0 0 10 10 10 26 26 26
50917 - 58 58 58 90 90 90 18 18 18 2 2 6
50918 - 2 2 6 110 110 110 253 253 253 253 253 253
50919 -253 253 253 253 253 253 253 253 253 253 253 253
50920 -250 250 250 253 253 253 253 253 253 253 253 253
50921 -253 253 253 253 253 253 253 253 253 253 253 253
50922 -253 253 253 253 253 253 253 253 253 253 253 253
50923 -253 253 253 231 231 231 18 18 18 2 2 6
50924 - 2 2 6 2 2 6 2 2 6 2 2 6
50925 - 2 2 6 2 2 6 18 18 18 94 94 94
50926 - 54 54 54 26 26 26 10 10 10 0 0 0
50927 - 0 0 0 0 0 0 0 0 0 0 0 0
50928 - 0 0 0 0 0 0 0 0 0 0 0 0
50929 - 0 0 0 0 0 0 0 0 0 0 0 0
50930 - 0 0 0 0 0 0 0 0 0 0 0 0
50931 - 0 0 0 0 0 0 0 0 0 0 0 0
50932 - 0 0 0 0 0 0 0 0 0 0 0 0
50933 - 0 0 0 0 0 0 0 0 0 0 0 0
50934 - 0 0 0 0 0 0 0 0 0 0 0 0
50935 - 0 0 0 0 0 0 0 0 0 0 0 0
50936 - 0 0 0 6 6 6 22 22 22 50 50 50
50937 - 90 90 90 26 26 26 2 2 6 2 2 6
50938 - 14 14 14 195 195 195 250 250 250 253 253 253
50939 -253 253 253 253 253 253 253 253 253 253 253 253
50940 -253 253 253 253 253 253 253 253 253 253 253 253
50941 -253 253 253 253 253 253 253 253 253 253 253 253
50942 -253 253 253 253 253 253 253 253 253 253 253 253
50943 -250 250 250 242 242 242 54 54 54 2 2 6
50944 - 2 2 6 2 2 6 2 2 6 2 2 6
50945 - 2 2 6 2 2 6 2 2 6 38 38 38
50946 - 86 86 86 50 50 50 22 22 22 6 6 6
50947 - 0 0 0 0 0 0 0 0 0 0 0 0
50948 - 0 0 0 0 0 0 0 0 0 0 0 0
50949 - 0 0 0 0 0 0 0 0 0 0 0 0
50950 - 0 0 0 0 0 0 0 0 0 0 0 0
50951 - 0 0 0 0 0 0 0 0 0 0 0 0
50952 - 0 0 0 0 0 0 0 0 0 0 0 0
50953 - 0 0 0 0 0 0 0 0 0 0 0 0
50954 - 0 0 0 0 0 0 0 0 0 0 0 0
50955 - 0 0 0 0 0 0 0 0 0 0 0 0
50956 - 6 6 6 14 14 14 38 38 38 82 82 82
50957 - 34 34 34 2 2 6 2 2 6 2 2 6
50958 - 42 42 42 195 195 195 246 246 246 253 253 253
50959 -253 253 253 253 253 253 253 253 253 250 250 250
50960 -242 242 242 242 242 242 250 250 250 253 253 253
50961 -253 253 253 253 253 253 253 253 253 253 253 253
50962 -253 253 253 250 250 250 246 246 246 238 238 238
50963 -226 226 226 231 231 231 101 101 101 6 6 6
50964 - 2 2 6 2 2 6 2 2 6 2 2 6
50965 - 2 2 6 2 2 6 2 2 6 2 2 6
50966 - 38 38 38 82 82 82 42 42 42 14 14 14
50967 - 6 6 6 0 0 0 0 0 0 0 0 0
50968 - 0 0 0 0 0 0 0 0 0 0 0 0
50969 - 0 0 0 0 0 0 0 0 0 0 0 0
50970 - 0 0 0 0 0 0 0 0 0 0 0 0
50971 - 0 0 0 0 0 0 0 0 0 0 0 0
50972 - 0 0 0 0 0 0 0 0 0 0 0 0
50973 - 0 0 0 0 0 0 0 0 0 0 0 0
50974 - 0 0 0 0 0 0 0 0 0 0 0 0
50975 - 0 0 0 0 0 0 0 0 0 0 0 0
50976 - 10 10 10 26 26 26 62 62 62 66 66 66
50977 - 2 2 6 2 2 6 2 2 6 6 6 6
50978 - 70 70 70 170 170 170 206 206 206 234 234 234
50979 -246 246 246 250 250 250 250 250 250 238 238 238
50980 -226 226 226 231 231 231 238 238 238 250 250 250
50981 -250 250 250 250 250 250 246 246 246 231 231 231
50982 -214 214 214 206 206 206 202 202 202 202 202 202
50983 -198 198 198 202 202 202 182 182 182 18 18 18
50984 - 2 2 6 2 2 6 2 2 6 2 2 6
50985 - 2 2 6 2 2 6 2 2 6 2 2 6
50986 - 2 2 6 62 62 62 66 66 66 30 30 30
50987 - 10 10 10 0 0 0 0 0 0 0 0 0
50988 - 0 0 0 0 0 0 0 0 0 0 0 0
50989 - 0 0 0 0 0 0 0 0 0 0 0 0
50990 - 0 0 0 0 0 0 0 0 0 0 0 0
50991 - 0 0 0 0 0 0 0 0 0 0 0 0
50992 - 0 0 0 0 0 0 0 0 0 0 0 0
50993 - 0 0 0 0 0 0 0 0 0 0 0 0
50994 - 0 0 0 0 0 0 0 0 0 0 0 0
50995 - 0 0 0 0 0 0 0 0 0 0 0 0
50996 - 14 14 14 42 42 42 82 82 82 18 18 18
50997 - 2 2 6 2 2 6 2 2 6 10 10 10
50998 - 94 94 94 182 182 182 218 218 218 242 242 242
50999 -250 250 250 253 253 253 253 253 253 250 250 250
51000 -234 234 234 253 253 253 253 253 253 253 253 253
51001 -253 253 253 253 253 253 253 253 253 246 246 246
51002 -238 238 238 226 226 226 210 210 210 202 202 202
51003 -195 195 195 195 195 195 210 210 210 158 158 158
51004 - 6 6 6 14 14 14 50 50 50 14 14 14
51005 - 2 2 6 2 2 6 2 2 6 2 2 6
51006 - 2 2 6 6 6 6 86 86 86 46 46 46
51007 - 18 18 18 6 6 6 0 0 0 0 0 0
51008 - 0 0 0 0 0 0 0 0 0 0 0 0
51009 - 0 0 0 0 0 0 0 0 0 0 0 0
51010 - 0 0 0 0 0 0 0 0 0 0 0 0
51011 - 0 0 0 0 0 0 0 0 0 0 0 0
51012 - 0 0 0 0 0 0 0 0 0 0 0 0
51013 - 0 0 0 0 0 0 0 0 0 0 0 0
51014 - 0 0 0 0 0 0 0 0 0 0 0 0
51015 - 0 0 0 0 0 0 0 0 0 6 6 6
51016 - 22 22 22 54 54 54 70 70 70 2 2 6
51017 - 2 2 6 10 10 10 2 2 6 22 22 22
51018 -166 166 166 231 231 231 250 250 250 253 253 253
51019 -253 253 253 253 253 253 253 253 253 250 250 250
51020 -242 242 242 253 253 253 253 253 253 253 253 253
51021 -253 253 253 253 253 253 253 253 253 253 253 253
51022 -253 253 253 253 253 253 253 253 253 246 246 246
51023 -231 231 231 206 206 206 198 198 198 226 226 226
51024 - 94 94 94 2 2 6 6 6 6 38 38 38
51025 - 30 30 30 2 2 6 2 2 6 2 2 6
51026 - 2 2 6 2 2 6 62 62 62 66 66 66
51027 - 26 26 26 10 10 10 0 0 0 0 0 0
51028 - 0 0 0 0 0 0 0 0 0 0 0 0
51029 - 0 0 0 0 0 0 0 0 0 0 0 0
51030 - 0 0 0 0 0 0 0 0 0 0 0 0
51031 - 0 0 0 0 0 0 0 0 0 0 0 0
51032 - 0 0 0 0 0 0 0 0 0 0 0 0
51033 - 0 0 0 0 0 0 0 0 0 0 0 0
51034 - 0 0 0 0 0 0 0 0 0 0 0 0
51035 - 0 0 0 0 0 0 0 0 0 10 10 10
51036 - 30 30 30 74 74 74 50 50 50 2 2 6
51037 - 26 26 26 26 26 26 2 2 6 106 106 106
51038 -238 238 238 253 253 253 253 253 253 253 253 253
51039 -253 253 253 253 253 253 253 253 253 253 253 253
51040 -253 253 253 253 253 253 253 253 253 253 253 253
51041 -253 253 253 253 253 253 253 253 253 253 253 253
51042 -253 253 253 253 253 253 253 253 253 253 253 253
51043 -253 253 253 246 246 246 218 218 218 202 202 202
51044 -210 210 210 14 14 14 2 2 6 2 2 6
51045 - 30 30 30 22 22 22 2 2 6 2 2 6
51046 - 2 2 6 2 2 6 18 18 18 86 86 86
51047 - 42 42 42 14 14 14 0 0 0 0 0 0
51048 - 0 0 0 0 0 0 0 0 0 0 0 0
51049 - 0 0 0 0 0 0 0 0 0 0 0 0
51050 - 0 0 0 0 0 0 0 0 0 0 0 0
51051 - 0 0 0 0 0 0 0 0 0 0 0 0
51052 - 0 0 0 0 0 0 0 0 0 0 0 0
51053 - 0 0 0 0 0 0 0 0 0 0 0 0
51054 - 0 0 0 0 0 0 0 0 0 0 0 0
51055 - 0 0 0 0 0 0 0 0 0 14 14 14
51056 - 42 42 42 90 90 90 22 22 22 2 2 6
51057 - 42 42 42 2 2 6 18 18 18 218 218 218
51058 -253 253 253 253 253 253 253 253 253 253 253 253
51059 -253 253 253 253 253 253 253 253 253 253 253 253
51060 -253 253 253 253 253 253 253 253 253 253 253 253
51061 -253 253 253 253 253 253 253 253 253 253 253 253
51062 -253 253 253 253 253 253 253 253 253 253 253 253
51063 -253 253 253 253 253 253 250 250 250 221 221 221
51064 -218 218 218 101 101 101 2 2 6 14 14 14
51065 - 18 18 18 38 38 38 10 10 10 2 2 6
51066 - 2 2 6 2 2 6 2 2 6 78 78 78
51067 - 58 58 58 22 22 22 6 6 6 0 0 0
51068 - 0 0 0 0 0 0 0 0 0 0 0 0
51069 - 0 0 0 0 0 0 0 0 0 0 0 0
51070 - 0 0 0 0 0 0 0 0 0 0 0 0
51071 - 0 0 0 0 0 0 0 0 0 0 0 0
51072 - 0 0 0 0 0 0 0 0 0 0 0 0
51073 - 0 0 0 0 0 0 0 0 0 0 0 0
51074 - 0 0 0 0 0 0 0 0 0 0 0 0
51075 - 0 0 0 0 0 0 6 6 6 18 18 18
51076 - 54 54 54 82 82 82 2 2 6 26 26 26
51077 - 22 22 22 2 2 6 123 123 123 253 253 253
51078 -253 253 253 253 253 253 253 253 253 253 253 253
51079 -253 253 253 253 253 253 253 253 253 253 253 253
51080 -253 253 253 253 253 253 253 253 253 253 253 253
51081 -253 253 253 253 253 253 253 253 253 253 253 253
51082 -253 253 253 253 253 253 253 253 253 253 253 253
51083 -253 253 253 253 253 253 253 253 253 250 250 250
51084 -238 238 238 198 198 198 6 6 6 38 38 38
51085 - 58 58 58 26 26 26 38 38 38 2 2 6
51086 - 2 2 6 2 2 6 2 2 6 46 46 46
51087 - 78 78 78 30 30 30 10 10 10 0 0 0
51088 - 0 0 0 0 0 0 0 0 0 0 0 0
51089 - 0 0 0 0 0 0 0 0 0 0 0 0
51090 - 0 0 0 0 0 0 0 0 0 0 0 0
51091 - 0 0 0 0 0 0 0 0 0 0 0 0
51092 - 0 0 0 0 0 0 0 0 0 0 0 0
51093 - 0 0 0 0 0 0 0 0 0 0 0 0
51094 - 0 0 0 0 0 0 0 0 0 0 0 0
51095 - 0 0 0 0 0 0 10 10 10 30 30 30
51096 - 74 74 74 58 58 58 2 2 6 42 42 42
51097 - 2 2 6 22 22 22 231 231 231 253 253 253
51098 -253 253 253 253 253 253 253 253 253 253 253 253
51099 -253 253 253 253 253 253 253 253 253 250 250 250
51100 -253 253 253 253 253 253 253 253 253 253 253 253
51101 -253 253 253 253 253 253 253 253 253 253 253 253
51102 -253 253 253 253 253 253 253 253 253 253 253 253
51103 -253 253 253 253 253 253 253 253 253 253 253 253
51104 -253 253 253 246 246 246 46 46 46 38 38 38
51105 - 42 42 42 14 14 14 38 38 38 14 14 14
51106 - 2 2 6 2 2 6 2 2 6 6 6 6
51107 - 86 86 86 46 46 46 14 14 14 0 0 0
51108 - 0 0 0 0 0 0 0 0 0 0 0 0
51109 - 0 0 0 0 0 0 0 0 0 0 0 0
51110 - 0 0 0 0 0 0 0 0 0 0 0 0
51111 - 0 0 0 0 0 0 0 0 0 0 0 0
51112 - 0 0 0 0 0 0 0 0 0 0 0 0
51113 - 0 0 0 0 0 0 0 0 0 0 0 0
51114 - 0 0 0 0 0 0 0 0 0 0 0 0
51115 - 0 0 0 6 6 6 14 14 14 42 42 42
51116 - 90 90 90 18 18 18 18 18 18 26 26 26
51117 - 2 2 6 116 116 116 253 253 253 253 253 253
51118 -253 253 253 253 253 253 253 253 253 253 253 253
51119 -253 253 253 253 253 253 250 250 250 238 238 238
51120 -253 253 253 253 253 253 253 253 253 253 253 253
51121 -253 253 253 253 253 253 253 253 253 253 253 253
51122 -253 253 253 253 253 253 253 253 253 253 253 253
51123 -253 253 253 253 253 253 253 253 253 253 253 253
51124 -253 253 253 253 253 253 94 94 94 6 6 6
51125 - 2 2 6 2 2 6 10 10 10 34 34 34
51126 - 2 2 6 2 2 6 2 2 6 2 2 6
51127 - 74 74 74 58 58 58 22 22 22 6 6 6
51128 - 0 0 0 0 0 0 0 0 0 0 0 0
51129 - 0 0 0 0 0 0 0 0 0 0 0 0
51130 - 0 0 0 0 0 0 0 0 0 0 0 0
51131 - 0 0 0 0 0 0 0 0 0 0 0 0
51132 - 0 0 0 0 0 0 0 0 0 0 0 0
51133 - 0 0 0 0 0 0 0 0 0 0 0 0
51134 - 0 0 0 0 0 0 0 0 0 0 0 0
51135 - 0 0 0 10 10 10 26 26 26 66 66 66
51136 - 82 82 82 2 2 6 38 38 38 6 6 6
51137 - 14 14 14 210 210 210 253 253 253 253 253 253
51138 -253 253 253 253 253 253 253 253 253 253 253 253
51139 -253 253 253 253 253 253 246 246 246 242 242 242
51140 -253 253 253 253 253 253 253 253 253 253 253 253
51141 -253 253 253 253 253 253 253 253 253 253 253 253
51142 -253 253 253 253 253 253 253 253 253 253 253 253
51143 -253 253 253 253 253 253 253 253 253 253 253 253
51144 -253 253 253 253 253 253 144 144 144 2 2 6
51145 - 2 2 6 2 2 6 2 2 6 46 46 46
51146 - 2 2 6 2 2 6 2 2 6 2 2 6
51147 - 42 42 42 74 74 74 30 30 30 10 10 10
51148 - 0 0 0 0 0 0 0 0 0 0 0 0
51149 - 0 0 0 0 0 0 0 0 0 0 0 0
51150 - 0 0 0 0 0 0 0 0 0 0 0 0
51151 - 0 0 0 0 0 0 0 0 0 0 0 0
51152 - 0 0 0 0 0 0 0 0 0 0 0 0
51153 - 0 0 0 0 0 0 0 0 0 0 0 0
51154 - 0 0 0 0 0 0 0 0 0 0 0 0
51155 - 6 6 6 14 14 14 42 42 42 90 90 90
51156 - 26 26 26 6 6 6 42 42 42 2 2 6
51157 - 74 74 74 250 250 250 253 253 253 253 253 253
51158 -253 253 253 253 253 253 253 253 253 253 253 253
51159 -253 253 253 253 253 253 242 242 242 242 242 242
51160 -253 253 253 253 253 253 253 253 253 253 253 253
51161 -253 253 253 253 253 253 253 253 253 253 253 253
51162 -253 253 253 253 253 253 253 253 253 253 253 253
51163 -253 253 253 253 253 253 253 253 253 253 253 253
51164 -253 253 253 253 253 253 182 182 182 2 2 6
51165 - 2 2 6 2 2 6 2 2 6 46 46 46
51166 - 2 2 6 2 2 6 2 2 6 2 2 6
51167 - 10 10 10 86 86 86 38 38 38 10 10 10
51168 - 0 0 0 0 0 0 0 0 0 0 0 0
51169 - 0 0 0 0 0 0 0 0 0 0 0 0
51170 - 0 0 0 0 0 0 0 0 0 0 0 0
51171 - 0 0 0 0 0 0 0 0 0 0 0 0
51172 - 0 0 0 0 0 0 0 0 0 0 0 0
51173 - 0 0 0 0 0 0 0 0 0 0 0 0
51174 - 0 0 0 0 0 0 0 0 0 0 0 0
51175 - 10 10 10 26 26 26 66 66 66 82 82 82
51176 - 2 2 6 22 22 22 18 18 18 2 2 6
51177 -149 149 149 253 253 253 253 253 253 253 253 253
51178 -253 253 253 253 253 253 253 253 253 253 253 253
51179 -253 253 253 253 253 253 234 234 234 242 242 242
51180 -253 253 253 253 253 253 253 253 253 253 253 253
51181 -253 253 253 253 253 253 253 253 253 253 253 253
51182 -253 253 253 253 253 253 253 253 253 253 253 253
51183 -253 253 253 253 253 253 253 253 253 253 253 253
51184 -253 253 253 253 253 253 206 206 206 2 2 6
51185 - 2 2 6 2 2 6 2 2 6 38 38 38
51186 - 2 2 6 2 2 6 2 2 6 2 2 6
51187 - 6 6 6 86 86 86 46 46 46 14 14 14
51188 - 0 0 0 0 0 0 0 0 0 0 0 0
51189 - 0 0 0 0 0 0 0 0 0 0 0 0
51190 - 0 0 0 0 0 0 0 0 0 0 0 0
51191 - 0 0 0 0 0 0 0 0 0 0 0 0
51192 - 0 0 0 0 0 0 0 0 0 0 0 0
51193 - 0 0 0 0 0 0 0 0 0 0 0 0
51194 - 0 0 0 0 0 0 0 0 0 6 6 6
51195 - 18 18 18 46 46 46 86 86 86 18 18 18
51196 - 2 2 6 34 34 34 10 10 10 6 6 6
51197 -210 210 210 253 253 253 253 253 253 253 253 253
51198 -253 253 253 253 253 253 253 253 253 253 253 253
51199 -253 253 253 253 253 253 234 234 234 242 242 242
51200 -253 253 253 253 253 253 253 253 253 253 253 253
51201 -253 253 253 253 253 253 253 253 253 253 253 253
51202 -253 253 253 253 253 253 253 253 253 253 253 253
51203 -253 253 253 253 253 253 253 253 253 253 253 253
51204 -253 253 253 253 253 253 221 221 221 6 6 6
51205 - 2 2 6 2 2 6 6 6 6 30 30 30
51206 - 2 2 6 2 2 6 2 2 6 2 2 6
51207 - 2 2 6 82 82 82 54 54 54 18 18 18
51208 - 6 6 6 0 0 0 0 0 0 0 0 0
51209 - 0 0 0 0 0 0 0 0 0 0 0 0
51210 - 0 0 0 0 0 0 0 0 0 0 0 0
51211 - 0 0 0 0 0 0 0 0 0 0 0 0
51212 - 0 0 0 0 0 0 0 0 0 0 0 0
51213 - 0 0 0 0 0 0 0 0 0 0 0 0
51214 - 0 0 0 0 0 0 0 0 0 10 10 10
51215 - 26 26 26 66 66 66 62 62 62 2 2 6
51216 - 2 2 6 38 38 38 10 10 10 26 26 26
51217 -238 238 238 253 253 253 253 253 253 253 253 253
51218 -253 253 253 253 253 253 253 253 253 253 253 253
51219 -253 253 253 253 253 253 231 231 231 238 238 238
51220 -253 253 253 253 253 253 253 253 253 253 253 253
51221 -253 253 253 253 253 253 253 253 253 253 253 253
51222 -253 253 253 253 253 253 253 253 253 253 253 253
51223 -253 253 253 253 253 253 253 253 253 253 253 253
51224 -253 253 253 253 253 253 231 231 231 6 6 6
51225 - 2 2 6 2 2 6 10 10 10 30 30 30
51226 - 2 2 6 2 2 6 2 2 6 2 2 6
51227 - 2 2 6 66 66 66 58 58 58 22 22 22
51228 - 6 6 6 0 0 0 0 0 0 0 0 0
51229 - 0 0 0 0 0 0 0 0 0 0 0 0
51230 - 0 0 0 0 0 0 0 0 0 0 0 0
51231 - 0 0 0 0 0 0 0 0 0 0 0 0
51232 - 0 0 0 0 0 0 0 0 0 0 0 0
51233 - 0 0 0 0 0 0 0 0 0 0 0 0
51234 - 0 0 0 0 0 0 0 0 0 10 10 10
51235 - 38 38 38 78 78 78 6 6 6 2 2 6
51236 - 2 2 6 46 46 46 14 14 14 42 42 42
51237 -246 246 246 253 253 253 253 253 253 253 253 253
51238 -253 253 253 253 253 253 253 253 253 253 253 253
51239 -253 253 253 253 253 253 231 231 231 242 242 242
51240 -253 253 253 253 253 253 253 253 253 253 253 253
51241 -253 253 253 253 253 253 253 253 253 253 253 253
51242 -253 253 253 253 253 253 253 253 253 253 253 253
51243 -253 253 253 253 253 253 253 253 253 253 253 253
51244 -253 253 253 253 253 253 234 234 234 10 10 10
51245 - 2 2 6 2 2 6 22 22 22 14 14 14
51246 - 2 2 6 2 2 6 2 2 6 2 2 6
51247 - 2 2 6 66 66 66 62 62 62 22 22 22
51248 - 6 6 6 0 0 0 0 0 0 0 0 0
51249 - 0 0 0 0 0 0 0 0 0 0 0 0
51250 - 0 0 0 0 0 0 0 0 0 0 0 0
51251 - 0 0 0 0 0 0 0 0 0 0 0 0
51252 - 0 0 0 0 0 0 0 0 0 0 0 0
51253 - 0 0 0 0 0 0 0 0 0 0 0 0
51254 - 0 0 0 0 0 0 6 6 6 18 18 18
51255 - 50 50 50 74 74 74 2 2 6 2 2 6
51256 - 14 14 14 70 70 70 34 34 34 62 62 62
51257 -250 250 250 253 253 253 253 253 253 253 253 253
51258 -253 253 253 253 253 253 253 253 253 253 253 253
51259 -253 253 253 253 253 253 231 231 231 246 246 246
51260 -253 253 253 253 253 253 253 253 253 253 253 253
51261 -253 253 253 253 253 253 253 253 253 253 253 253
51262 -253 253 253 253 253 253 253 253 253 253 253 253
51263 -253 253 253 253 253 253 253 253 253 253 253 253
51264 -253 253 253 253 253 253 234 234 234 14 14 14
51265 - 2 2 6 2 2 6 30 30 30 2 2 6
51266 - 2 2 6 2 2 6 2 2 6 2 2 6
51267 - 2 2 6 66 66 66 62 62 62 22 22 22
51268 - 6 6 6 0 0 0 0 0 0 0 0 0
51269 - 0 0 0 0 0 0 0 0 0 0 0 0
51270 - 0 0 0 0 0 0 0 0 0 0 0 0
51271 - 0 0 0 0 0 0 0 0 0 0 0 0
51272 - 0 0 0 0 0 0 0 0 0 0 0 0
51273 - 0 0 0 0 0 0 0 0 0 0 0 0
51274 - 0 0 0 0 0 0 6 6 6 18 18 18
51275 - 54 54 54 62 62 62 2 2 6 2 2 6
51276 - 2 2 6 30 30 30 46 46 46 70 70 70
51277 -250 250 250 253 253 253 253 253 253 253 253 253
51278 -253 253 253 253 253 253 253 253 253 253 253 253
51279 -253 253 253 253 253 253 231 231 231 246 246 246
51280 -253 253 253 253 253 253 253 253 253 253 253 253
51281 -253 253 253 253 253 253 253 253 253 253 253 253
51282 -253 253 253 253 253 253 253 253 253 253 253 253
51283 -253 253 253 253 253 253 253 253 253 253 253 253
51284 -253 253 253 253 253 253 226 226 226 10 10 10
51285 - 2 2 6 6 6 6 30 30 30 2 2 6
51286 - 2 2 6 2 2 6 2 2 6 2 2 6
51287 - 2 2 6 66 66 66 58 58 58 22 22 22
51288 - 6 6 6 0 0 0 0 0 0 0 0 0
51289 - 0 0 0 0 0 0 0 0 0 0 0 0
51290 - 0 0 0 0 0 0 0 0 0 0 0 0
51291 - 0 0 0 0 0 0 0 0 0 0 0 0
51292 - 0 0 0 0 0 0 0 0 0 0 0 0
51293 - 0 0 0 0 0 0 0 0 0 0 0 0
51294 - 0 0 0 0 0 0 6 6 6 22 22 22
51295 - 58 58 58 62 62 62 2 2 6 2 2 6
51296 - 2 2 6 2 2 6 30 30 30 78 78 78
51297 -250 250 250 253 253 253 253 253 253 253 253 253
51298 -253 253 253 253 253 253 253 253 253 253 253 253
51299 -253 253 253 253 253 253 231 231 231 246 246 246
51300 -253 253 253 253 253 253 253 253 253 253 253 253
51301 -253 253 253 253 253 253 253 253 253 253 253 253
51302 -253 253 253 253 253 253 253 253 253 253 253 253
51303 -253 253 253 253 253 253 253 253 253 253 253 253
51304 -253 253 253 253 253 253 206 206 206 2 2 6
51305 - 22 22 22 34 34 34 18 14 6 22 22 22
51306 - 26 26 26 18 18 18 6 6 6 2 2 6
51307 - 2 2 6 82 82 82 54 54 54 18 18 18
51308 - 6 6 6 0 0 0 0 0 0 0 0 0
51309 - 0 0 0 0 0 0 0 0 0 0 0 0
51310 - 0 0 0 0 0 0 0 0 0 0 0 0
51311 - 0 0 0 0 0 0 0 0 0 0 0 0
51312 - 0 0 0 0 0 0 0 0 0 0 0 0
51313 - 0 0 0 0 0 0 0 0 0 0 0 0
51314 - 0 0 0 0 0 0 6 6 6 26 26 26
51315 - 62 62 62 106 106 106 74 54 14 185 133 11
51316 -210 162 10 121 92 8 6 6 6 62 62 62
51317 -238 238 238 253 253 253 253 253 253 253 253 253
51318 -253 253 253 253 253 253 253 253 253 253 253 253
51319 -253 253 253 253 253 253 231 231 231 246 246 246
51320 -253 253 253 253 253 253 253 253 253 253 253 253
51321 -253 253 253 253 253 253 253 253 253 253 253 253
51322 -253 253 253 253 253 253 253 253 253 253 253 253
51323 -253 253 253 253 253 253 253 253 253 253 253 253
51324 -253 253 253 253 253 253 158 158 158 18 18 18
51325 - 14 14 14 2 2 6 2 2 6 2 2 6
51326 - 6 6 6 18 18 18 66 66 66 38 38 38
51327 - 6 6 6 94 94 94 50 50 50 18 18 18
51328 - 6 6 6 0 0 0 0 0 0 0 0 0
51329 - 0 0 0 0 0 0 0 0 0 0 0 0
51330 - 0 0 0 0 0 0 0 0 0 0 0 0
51331 - 0 0 0 0 0 0 0 0 0 0 0 0
51332 - 0 0 0 0 0 0 0 0 0 0 0 0
51333 - 0 0 0 0 0 0 0 0 0 6 6 6
51334 - 10 10 10 10 10 10 18 18 18 38 38 38
51335 - 78 78 78 142 134 106 216 158 10 242 186 14
51336 -246 190 14 246 190 14 156 118 10 10 10 10
51337 - 90 90 90 238 238 238 253 253 253 253 253 253
51338 -253 253 253 253 253 253 253 253 253 253 253 253
51339 -253 253 253 253 253 253 231 231 231 250 250 250
51340 -253 253 253 253 253 253 253 253 253 253 253 253
51341 -253 253 253 253 253 253 253 253 253 253 253 253
51342 -253 253 253 253 253 253 253 253 253 253 253 253
51343 -253 253 253 253 253 253 253 253 253 246 230 190
51344 -238 204 91 238 204 91 181 142 44 37 26 9
51345 - 2 2 6 2 2 6 2 2 6 2 2 6
51346 - 2 2 6 2 2 6 38 38 38 46 46 46
51347 - 26 26 26 106 106 106 54 54 54 18 18 18
51348 - 6 6 6 0 0 0 0 0 0 0 0 0
51349 - 0 0 0 0 0 0 0 0 0 0 0 0
51350 - 0 0 0 0 0 0 0 0 0 0 0 0
51351 - 0 0 0 0 0 0 0 0 0 0 0 0
51352 - 0 0 0 0 0 0 0 0 0 0 0 0
51353 - 0 0 0 6 6 6 14 14 14 22 22 22
51354 - 30 30 30 38 38 38 50 50 50 70 70 70
51355 -106 106 106 190 142 34 226 170 11 242 186 14
51356 -246 190 14 246 190 14 246 190 14 154 114 10
51357 - 6 6 6 74 74 74 226 226 226 253 253 253
51358 -253 253 253 253 253 253 253 253 253 253 253 253
51359 -253 253 253 253 253 253 231 231 231 250 250 250
51360 -253 253 253 253 253 253 253 253 253 253 253 253
51361 -253 253 253 253 253 253 253 253 253 253 253 253
51362 -253 253 253 253 253 253 253 253 253 253 253 253
51363 -253 253 253 253 253 253 253 253 253 228 184 62
51364 -241 196 14 241 208 19 232 195 16 38 30 10
51365 - 2 2 6 2 2 6 2 2 6 2 2 6
51366 - 2 2 6 6 6 6 30 30 30 26 26 26
51367 -203 166 17 154 142 90 66 66 66 26 26 26
51368 - 6 6 6 0 0 0 0 0 0 0 0 0
51369 - 0 0 0 0 0 0 0 0 0 0 0 0
51370 - 0 0 0 0 0 0 0 0 0 0 0 0
51371 - 0 0 0 0 0 0 0 0 0 0 0 0
51372 - 0 0 0 0 0 0 0 0 0 0 0 0
51373 - 6 6 6 18 18 18 38 38 38 58 58 58
51374 - 78 78 78 86 86 86 101 101 101 123 123 123
51375 -175 146 61 210 150 10 234 174 13 246 186 14
51376 -246 190 14 246 190 14 246 190 14 238 190 10
51377 -102 78 10 2 2 6 46 46 46 198 198 198
51378 -253 253 253 253 253 253 253 253 253 253 253 253
51379 -253 253 253 253 253 253 234 234 234 242 242 242
51380 -253 253 253 253 253 253 253 253 253 253 253 253
51381 -253 253 253 253 253 253 253 253 253 253 253 253
51382 -253 253 253 253 253 253 253 253 253 253 253 253
51383 -253 253 253 253 253 253 253 253 253 224 178 62
51384 -242 186 14 241 196 14 210 166 10 22 18 6
51385 - 2 2 6 2 2 6 2 2 6 2 2 6
51386 - 2 2 6 2 2 6 6 6 6 121 92 8
51387 -238 202 15 232 195 16 82 82 82 34 34 34
51388 - 10 10 10 0 0 0 0 0 0 0 0 0
51389 - 0 0 0 0 0 0 0 0 0 0 0 0
51390 - 0 0 0 0 0 0 0 0 0 0 0 0
51391 - 0 0 0 0 0 0 0 0 0 0 0 0
51392 - 0 0 0 0 0 0 0 0 0 0 0 0
51393 - 14 14 14 38 38 38 70 70 70 154 122 46
51394 -190 142 34 200 144 11 197 138 11 197 138 11
51395 -213 154 11 226 170 11 242 186 14 246 190 14
51396 -246 190 14 246 190 14 246 190 14 246 190 14
51397 -225 175 15 46 32 6 2 2 6 22 22 22
51398 -158 158 158 250 250 250 253 253 253 253 253 253
51399 -253 253 253 253 253 253 253 253 253 253 253 253
51400 -253 253 253 253 253 253 253 253 253 253 253 253
51401 -253 253 253 253 253 253 253 253 253 253 253 253
51402 -253 253 253 253 253 253 253 253 253 253 253 253
51403 -253 253 253 250 250 250 242 242 242 224 178 62
51404 -239 182 13 236 186 11 213 154 11 46 32 6
51405 - 2 2 6 2 2 6 2 2 6 2 2 6
51406 - 2 2 6 2 2 6 61 42 6 225 175 15
51407 -238 190 10 236 186 11 112 100 78 42 42 42
51408 - 14 14 14 0 0 0 0 0 0 0 0 0
51409 - 0 0 0 0 0 0 0 0 0 0 0 0
51410 - 0 0 0 0 0 0 0 0 0 0 0 0
51411 - 0 0 0 0 0 0 0 0 0 0 0 0
51412 - 0 0 0 0 0 0 0 0 0 6 6 6
51413 - 22 22 22 54 54 54 154 122 46 213 154 11
51414 -226 170 11 230 174 11 226 170 11 226 170 11
51415 -236 178 12 242 186 14 246 190 14 246 190 14
51416 -246 190 14 246 190 14 246 190 14 246 190 14
51417 -241 196 14 184 144 12 10 10 10 2 2 6
51418 - 6 6 6 116 116 116 242 242 242 253 253 253
51419 -253 253 253 253 253 253 253 253 253 253 253 253
51420 -253 253 253 253 253 253 253 253 253 253 253 253
51421 -253 253 253 253 253 253 253 253 253 253 253 253
51422 -253 253 253 253 253 253 253 253 253 253 253 253
51423 -253 253 253 231 231 231 198 198 198 214 170 54
51424 -236 178 12 236 178 12 210 150 10 137 92 6
51425 - 18 14 6 2 2 6 2 2 6 2 2 6
51426 - 6 6 6 70 47 6 200 144 11 236 178 12
51427 -239 182 13 239 182 13 124 112 88 58 58 58
51428 - 22 22 22 6 6 6 0 0 0 0 0 0
51429 - 0 0 0 0 0 0 0 0 0 0 0 0
51430 - 0 0 0 0 0 0 0 0 0 0 0 0
51431 - 0 0 0 0 0 0 0 0 0 0 0 0
51432 - 0 0 0 0 0 0 0 0 0 10 10 10
51433 - 30 30 30 70 70 70 180 133 36 226 170 11
51434 -239 182 13 242 186 14 242 186 14 246 186 14
51435 -246 190 14 246 190 14 246 190 14 246 190 14
51436 -246 190 14 246 190 14 246 190 14 246 190 14
51437 -246 190 14 232 195 16 98 70 6 2 2 6
51438 - 2 2 6 2 2 6 66 66 66 221 221 221
51439 -253 253 253 253 253 253 253 253 253 253 253 253
51440 -253 253 253 253 253 253 253 253 253 253 253 253
51441 -253 253 253 253 253 253 253 253 253 253 253 253
51442 -253 253 253 253 253 253 253 253 253 253 253 253
51443 -253 253 253 206 206 206 198 198 198 214 166 58
51444 -230 174 11 230 174 11 216 158 10 192 133 9
51445 -163 110 8 116 81 8 102 78 10 116 81 8
51446 -167 114 7 197 138 11 226 170 11 239 182 13
51447 -242 186 14 242 186 14 162 146 94 78 78 78
51448 - 34 34 34 14 14 14 6 6 6 0 0 0
51449 - 0 0 0 0 0 0 0 0 0 0 0 0
51450 - 0 0 0 0 0 0 0 0 0 0 0 0
51451 - 0 0 0 0 0 0 0 0 0 0 0 0
51452 - 0 0 0 0 0 0 0 0 0 6 6 6
51453 - 30 30 30 78 78 78 190 142 34 226 170 11
51454 -239 182 13 246 190 14 246 190 14 246 190 14
51455 -246 190 14 246 190 14 246 190 14 246 190 14
51456 -246 190 14 246 190 14 246 190 14 246 190 14
51457 -246 190 14 241 196 14 203 166 17 22 18 6
51458 - 2 2 6 2 2 6 2 2 6 38 38 38
51459 -218 218 218 253 253 253 253 253 253 253 253 253
51460 -253 253 253 253 253 253 253 253 253 253 253 253
51461 -253 253 253 253 253 253 253 253 253 253 253 253
51462 -253 253 253 253 253 253 253 253 253 253 253 253
51463 -250 250 250 206 206 206 198 198 198 202 162 69
51464 -226 170 11 236 178 12 224 166 10 210 150 10
51465 -200 144 11 197 138 11 192 133 9 197 138 11
51466 -210 150 10 226 170 11 242 186 14 246 190 14
51467 -246 190 14 246 186 14 225 175 15 124 112 88
51468 - 62 62 62 30 30 30 14 14 14 6 6 6
51469 - 0 0 0 0 0 0 0 0 0 0 0 0
51470 - 0 0 0 0 0 0 0 0 0 0 0 0
51471 - 0 0 0 0 0 0 0 0 0 0 0 0
51472 - 0 0 0 0 0 0 0 0 0 10 10 10
51473 - 30 30 30 78 78 78 174 135 50 224 166 10
51474 -239 182 13 246 190 14 246 190 14 246 190 14
51475 -246 190 14 246 190 14 246 190 14 246 190 14
51476 -246 190 14 246 190 14 246 190 14 246 190 14
51477 -246 190 14 246 190 14 241 196 14 139 102 15
51478 - 2 2 6 2 2 6 2 2 6 2 2 6
51479 - 78 78 78 250 250 250 253 253 253 253 253 253
51480 -253 253 253 253 253 253 253 253 253 253 253 253
51481 -253 253 253 253 253 253 253 253 253 253 253 253
51482 -253 253 253 253 253 253 253 253 253 253 253 253
51483 -250 250 250 214 214 214 198 198 198 190 150 46
51484 -219 162 10 236 178 12 234 174 13 224 166 10
51485 -216 158 10 213 154 11 213 154 11 216 158 10
51486 -226 170 11 239 182 13 246 190 14 246 190 14
51487 -246 190 14 246 190 14 242 186 14 206 162 42
51488 -101 101 101 58 58 58 30 30 30 14 14 14
51489 - 6 6 6 0 0 0 0 0 0 0 0 0
51490 - 0 0 0 0 0 0 0 0 0 0 0 0
51491 - 0 0 0 0 0 0 0 0 0 0 0 0
51492 - 0 0 0 0 0 0 0 0 0 10 10 10
51493 - 30 30 30 74 74 74 174 135 50 216 158 10
51494 -236 178 12 246 190 14 246 190 14 246 190 14
51495 -246 190 14 246 190 14 246 190 14 246 190 14
51496 -246 190 14 246 190 14 246 190 14 246 190 14
51497 -246 190 14 246 190 14 241 196 14 226 184 13
51498 - 61 42 6 2 2 6 2 2 6 2 2 6
51499 - 22 22 22 238 238 238 253 253 253 253 253 253
51500 -253 253 253 253 253 253 253 253 253 253 253 253
51501 -253 253 253 253 253 253 253 253 253 253 253 253
51502 -253 253 253 253 253 253 253 253 253 253 253 253
51503 -253 253 253 226 226 226 187 187 187 180 133 36
51504 -216 158 10 236 178 12 239 182 13 236 178 12
51505 -230 174 11 226 170 11 226 170 11 230 174 11
51506 -236 178 12 242 186 14 246 190 14 246 190 14
51507 -246 190 14 246 190 14 246 186 14 239 182 13
51508 -206 162 42 106 106 106 66 66 66 34 34 34
51509 - 14 14 14 6 6 6 0 0 0 0 0 0
51510 - 0 0 0 0 0 0 0 0 0 0 0 0
51511 - 0 0 0 0 0 0 0 0 0 0 0 0
51512 - 0 0 0 0 0 0 0 0 0 6 6 6
51513 - 26 26 26 70 70 70 163 133 67 213 154 11
51514 -236 178 12 246 190 14 246 190 14 246 190 14
51515 -246 190 14 246 190 14 246 190 14 246 190 14
51516 -246 190 14 246 190 14 246 190 14 246 190 14
51517 -246 190 14 246 190 14 246 190 14 241 196 14
51518 -190 146 13 18 14 6 2 2 6 2 2 6
51519 - 46 46 46 246 246 246 253 253 253 253 253 253
51520 -253 253 253 253 253 253 253 253 253 253 253 253
51521 -253 253 253 253 253 253 253 253 253 253 253 253
51522 -253 253 253 253 253 253 253 253 253 253 253 253
51523 -253 253 253 221 221 221 86 86 86 156 107 11
51524 -216 158 10 236 178 12 242 186 14 246 186 14
51525 -242 186 14 239 182 13 239 182 13 242 186 14
51526 -242 186 14 246 186 14 246 190 14 246 190 14
51527 -246 190 14 246 190 14 246 190 14 246 190 14
51528 -242 186 14 225 175 15 142 122 72 66 66 66
51529 - 30 30 30 10 10 10 0 0 0 0 0 0
51530 - 0 0 0 0 0 0 0 0 0 0 0 0
51531 - 0 0 0 0 0 0 0 0 0 0 0 0
51532 - 0 0 0 0 0 0 0 0 0 6 6 6
51533 - 26 26 26 70 70 70 163 133 67 210 150 10
51534 -236 178 12 246 190 14 246 190 14 246 190 14
51535 -246 190 14 246 190 14 246 190 14 246 190 14
51536 -246 190 14 246 190 14 246 190 14 246 190 14
51537 -246 190 14 246 190 14 246 190 14 246 190 14
51538 -232 195 16 121 92 8 34 34 34 106 106 106
51539 -221 221 221 253 253 253 253 253 253 253 253 253
51540 -253 253 253 253 253 253 253 253 253 253 253 253
51541 -253 253 253 253 253 253 253 253 253 253 253 253
51542 -253 253 253 253 253 253 253 253 253 253 253 253
51543 -242 242 242 82 82 82 18 14 6 163 110 8
51544 -216 158 10 236 178 12 242 186 14 246 190 14
51545 -246 190 14 246 190 14 246 190 14 246 190 14
51546 -246 190 14 246 190 14 246 190 14 246 190 14
51547 -246 190 14 246 190 14 246 190 14 246 190 14
51548 -246 190 14 246 190 14 242 186 14 163 133 67
51549 - 46 46 46 18 18 18 6 6 6 0 0 0
51550 - 0 0 0 0 0 0 0 0 0 0 0 0
51551 - 0 0 0 0 0 0 0 0 0 0 0 0
51552 - 0 0 0 0 0 0 0 0 0 10 10 10
51553 - 30 30 30 78 78 78 163 133 67 210 150 10
51554 -236 178 12 246 186 14 246 190 14 246 190 14
51555 -246 190 14 246 190 14 246 190 14 246 190 14
51556 -246 190 14 246 190 14 246 190 14 246 190 14
51557 -246 190 14 246 190 14 246 190 14 246 190 14
51558 -241 196 14 215 174 15 190 178 144 253 253 253
51559 -253 253 253 253 253 253 253 253 253 253 253 253
51560 -253 253 253 253 253 253 253 253 253 253 253 253
51561 -253 253 253 253 253 253 253 253 253 253 253 253
51562 -253 253 253 253 253 253 253 253 253 218 218 218
51563 - 58 58 58 2 2 6 22 18 6 167 114 7
51564 -216 158 10 236 178 12 246 186 14 246 190 14
51565 -246 190 14 246 190 14 246 190 14 246 190 14
51566 -246 190 14 246 190 14 246 190 14 246 190 14
51567 -246 190 14 246 190 14 246 190 14 246 190 14
51568 -246 190 14 246 186 14 242 186 14 190 150 46
51569 - 54 54 54 22 22 22 6 6 6 0 0 0
51570 - 0 0 0 0 0 0 0 0 0 0 0 0
51571 - 0 0 0 0 0 0 0 0 0 0 0 0
51572 - 0 0 0 0 0 0 0 0 0 14 14 14
51573 - 38 38 38 86 86 86 180 133 36 213 154 11
51574 -236 178 12 246 186 14 246 190 14 246 190 14
51575 -246 190 14 246 190 14 246 190 14 246 190 14
51576 -246 190 14 246 190 14 246 190 14 246 190 14
51577 -246 190 14 246 190 14 246 190 14 246 190 14
51578 -246 190 14 232 195 16 190 146 13 214 214 214
51579 -253 253 253 253 253 253 253 253 253 253 253 253
51580 -253 253 253 253 253 253 253 253 253 253 253 253
51581 -253 253 253 253 253 253 253 253 253 253 253 253
51582 -253 253 253 250 250 250 170 170 170 26 26 26
51583 - 2 2 6 2 2 6 37 26 9 163 110 8
51584 -219 162 10 239 182 13 246 186 14 246 190 14
51585 -246 190 14 246 190 14 246 190 14 246 190 14
51586 -246 190 14 246 190 14 246 190 14 246 190 14
51587 -246 190 14 246 190 14 246 190 14 246 190 14
51588 -246 186 14 236 178 12 224 166 10 142 122 72
51589 - 46 46 46 18 18 18 6 6 6 0 0 0
51590 - 0 0 0 0 0 0 0 0 0 0 0 0
51591 - 0 0 0 0 0 0 0 0 0 0 0 0
51592 - 0 0 0 0 0 0 6 6 6 18 18 18
51593 - 50 50 50 109 106 95 192 133 9 224 166 10
51594 -242 186 14 246 190 14 246 190 14 246 190 14
51595 -246 190 14 246 190 14 246 190 14 246 190 14
51596 -246 190 14 246 190 14 246 190 14 246 190 14
51597 -246 190 14 246 190 14 246 190 14 246 190 14
51598 -242 186 14 226 184 13 210 162 10 142 110 46
51599 -226 226 226 253 253 253 253 253 253 253 253 253
51600 -253 253 253 253 253 253 253 253 253 253 253 253
51601 -253 253 253 253 253 253 253 253 253 253 253 253
51602 -198 198 198 66 66 66 2 2 6 2 2 6
51603 - 2 2 6 2 2 6 50 34 6 156 107 11
51604 -219 162 10 239 182 13 246 186 14 246 190 14
51605 -246 190 14 246 190 14 246 190 14 246 190 14
51606 -246 190 14 246 190 14 246 190 14 246 190 14
51607 -246 190 14 246 190 14 246 190 14 242 186 14
51608 -234 174 13 213 154 11 154 122 46 66 66 66
51609 - 30 30 30 10 10 10 0 0 0 0 0 0
51610 - 0 0 0 0 0 0 0 0 0 0 0 0
51611 - 0 0 0 0 0 0 0 0 0 0 0 0
51612 - 0 0 0 0 0 0 6 6 6 22 22 22
51613 - 58 58 58 154 121 60 206 145 10 234 174 13
51614 -242 186 14 246 186 14 246 190 14 246 190 14
51615 -246 190 14 246 190 14 246 190 14 246 190 14
51616 -246 190 14 246 190 14 246 190 14 246 190 14
51617 -246 190 14 246 190 14 246 190 14 246 190 14
51618 -246 186 14 236 178 12 210 162 10 163 110 8
51619 - 61 42 6 138 138 138 218 218 218 250 250 250
51620 -253 253 253 253 253 253 253 253 253 250 250 250
51621 -242 242 242 210 210 210 144 144 144 66 66 66
51622 - 6 6 6 2 2 6 2 2 6 2 2 6
51623 - 2 2 6 2 2 6 61 42 6 163 110 8
51624 -216 158 10 236 178 12 246 190 14 246 190 14
51625 -246 190 14 246 190 14 246 190 14 246 190 14
51626 -246 190 14 246 190 14 246 190 14 246 190 14
51627 -246 190 14 239 182 13 230 174 11 216 158 10
51628 -190 142 34 124 112 88 70 70 70 38 38 38
51629 - 18 18 18 6 6 6 0 0 0 0 0 0
51630 - 0 0 0 0 0 0 0 0 0 0 0 0
51631 - 0 0 0 0 0 0 0 0 0 0 0 0
51632 - 0 0 0 0 0 0 6 6 6 22 22 22
51633 - 62 62 62 168 124 44 206 145 10 224 166 10
51634 -236 178 12 239 182 13 242 186 14 242 186 14
51635 -246 186 14 246 190 14 246 190 14 246 190 14
51636 -246 190 14 246 190 14 246 190 14 246 190 14
51637 -246 190 14 246 190 14 246 190 14 246 190 14
51638 -246 190 14 236 178 12 216 158 10 175 118 6
51639 - 80 54 7 2 2 6 6 6 6 30 30 30
51640 - 54 54 54 62 62 62 50 50 50 38 38 38
51641 - 14 14 14 2 2 6 2 2 6 2 2 6
51642 - 2 2 6 2 2 6 2 2 6 2 2 6
51643 - 2 2 6 6 6 6 80 54 7 167 114 7
51644 -213 154 11 236 178 12 246 190 14 246 190 14
51645 -246 190 14 246 190 14 246 190 14 246 190 14
51646 -246 190 14 242 186 14 239 182 13 239 182 13
51647 -230 174 11 210 150 10 174 135 50 124 112 88
51648 - 82 82 82 54 54 54 34 34 34 18 18 18
51649 - 6 6 6 0 0 0 0 0 0 0 0 0
51650 - 0 0 0 0 0 0 0 0 0 0 0 0
51651 - 0 0 0 0 0 0 0 0 0 0 0 0
51652 - 0 0 0 0 0 0 6 6 6 18 18 18
51653 - 50 50 50 158 118 36 192 133 9 200 144 11
51654 -216 158 10 219 162 10 224 166 10 226 170 11
51655 -230 174 11 236 178 12 239 182 13 239 182 13
51656 -242 186 14 246 186 14 246 190 14 246 190 14
51657 -246 190 14 246 190 14 246 190 14 246 190 14
51658 -246 186 14 230 174 11 210 150 10 163 110 8
51659 -104 69 6 10 10 10 2 2 6 2 2 6
51660 - 2 2 6 2 2 6 2 2 6 2 2 6
51661 - 2 2 6 2 2 6 2 2 6 2 2 6
51662 - 2 2 6 2 2 6 2 2 6 2 2 6
51663 - 2 2 6 6 6 6 91 60 6 167 114 7
51664 -206 145 10 230 174 11 242 186 14 246 190 14
51665 -246 190 14 246 190 14 246 186 14 242 186 14
51666 -239 182 13 230 174 11 224 166 10 213 154 11
51667 -180 133 36 124 112 88 86 86 86 58 58 58
51668 - 38 38 38 22 22 22 10 10 10 6 6 6
51669 - 0 0 0 0 0 0 0 0 0 0 0 0
51670 - 0 0 0 0 0 0 0 0 0 0 0 0
51671 - 0 0 0 0 0 0 0 0 0 0 0 0
51672 - 0 0 0 0 0 0 0 0 0 14 14 14
51673 - 34 34 34 70 70 70 138 110 50 158 118 36
51674 -167 114 7 180 123 7 192 133 9 197 138 11
51675 -200 144 11 206 145 10 213 154 11 219 162 10
51676 -224 166 10 230 174 11 239 182 13 242 186 14
51677 -246 186 14 246 186 14 246 186 14 246 186 14
51678 -239 182 13 216 158 10 185 133 11 152 99 6
51679 -104 69 6 18 14 6 2 2 6 2 2 6
51680 - 2 2 6 2 2 6 2 2 6 2 2 6
51681 - 2 2 6 2 2 6 2 2 6 2 2 6
51682 - 2 2 6 2 2 6 2 2 6 2 2 6
51683 - 2 2 6 6 6 6 80 54 7 152 99 6
51684 -192 133 9 219 162 10 236 178 12 239 182 13
51685 -246 186 14 242 186 14 239 182 13 236 178 12
51686 -224 166 10 206 145 10 192 133 9 154 121 60
51687 - 94 94 94 62 62 62 42 42 42 22 22 22
51688 - 14 14 14 6 6 6 0 0 0 0 0 0
51689 - 0 0 0 0 0 0 0 0 0 0 0 0
51690 - 0 0 0 0 0 0 0 0 0 0 0 0
51691 - 0 0 0 0 0 0 0 0 0 0 0 0
51692 - 0 0 0 0 0 0 0 0 0 6 6 6
51693 - 18 18 18 34 34 34 58 58 58 78 78 78
51694 -101 98 89 124 112 88 142 110 46 156 107 11
51695 -163 110 8 167 114 7 175 118 6 180 123 7
51696 -185 133 11 197 138 11 210 150 10 219 162 10
51697 -226 170 11 236 178 12 236 178 12 234 174 13
51698 -219 162 10 197 138 11 163 110 8 130 83 6
51699 - 91 60 6 10 10 10 2 2 6 2 2 6
51700 - 18 18 18 38 38 38 38 38 38 38 38 38
51701 - 38 38 38 38 38 38 38 38 38 38 38 38
51702 - 38 38 38 38 38 38 26 26 26 2 2 6
51703 - 2 2 6 6 6 6 70 47 6 137 92 6
51704 -175 118 6 200 144 11 219 162 10 230 174 11
51705 -234 174 13 230 174 11 219 162 10 210 150 10
51706 -192 133 9 163 110 8 124 112 88 82 82 82
51707 - 50 50 50 30 30 30 14 14 14 6 6 6
51708 - 0 0 0 0 0 0 0 0 0 0 0 0
51709 - 0 0 0 0 0 0 0 0 0 0 0 0
51710 - 0 0 0 0 0 0 0 0 0 0 0 0
51711 - 0 0 0 0 0 0 0 0 0 0 0 0
51712 - 0 0 0 0 0 0 0 0 0 0 0 0
51713 - 6 6 6 14 14 14 22 22 22 34 34 34
51714 - 42 42 42 58 58 58 74 74 74 86 86 86
51715 -101 98 89 122 102 70 130 98 46 121 87 25
51716 -137 92 6 152 99 6 163 110 8 180 123 7
51717 -185 133 11 197 138 11 206 145 10 200 144 11
51718 -180 123 7 156 107 11 130 83 6 104 69 6
51719 - 50 34 6 54 54 54 110 110 110 101 98 89
51720 - 86 86 86 82 82 82 78 78 78 78 78 78
51721 - 78 78 78 78 78 78 78 78 78 78 78 78
51722 - 78 78 78 82 82 82 86 86 86 94 94 94
51723 -106 106 106 101 101 101 86 66 34 124 80 6
51724 -156 107 11 180 123 7 192 133 9 200 144 11
51725 -206 145 10 200 144 11 192 133 9 175 118 6
51726 -139 102 15 109 106 95 70 70 70 42 42 42
51727 - 22 22 22 10 10 10 0 0 0 0 0 0
51728 - 0 0 0 0 0 0 0 0 0 0 0 0
51729 - 0 0 0 0 0 0 0 0 0 0 0 0
51730 - 0 0 0 0 0 0 0 0 0 0 0 0
51731 - 0 0 0 0 0 0 0 0 0 0 0 0
51732 - 0 0 0 0 0 0 0 0 0 0 0 0
51733 - 0 0 0 0 0 0 6 6 6 10 10 10
51734 - 14 14 14 22 22 22 30 30 30 38 38 38
51735 - 50 50 50 62 62 62 74 74 74 90 90 90
51736 -101 98 89 112 100 78 121 87 25 124 80 6
51737 -137 92 6 152 99 6 152 99 6 152 99 6
51738 -138 86 6 124 80 6 98 70 6 86 66 30
51739 -101 98 89 82 82 82 58 58 58 46 46 46
51740 - 38 38 38 34 34 34 34 34 34 34 34 34
51741 - 34 34 34 34 34 34 34 34 34 34 34 34
51742 - 34 34 34 34 34 34 38 38 38 42 42 42
51743 - 54 54 54 82 82 82 94 86 76 91 60 6
51744 -134 86 6 156 107 11 167 114 7 175 118 6
51745 -175 118 6 167 114 7 152 99 6 121 87 25
51746 -101 98 89 62 62 62 34 34 34 18 18 18
51747 - 6 6 6 0 0 0 0 0 0 0 0 0
51748 - 0 0 0 0 0 0 0 0 0 0 0 0
51749 - 0 0 0 0 0 0 0 0 0 0 0 0
51750 - 0 0 0 0 0 0 0 0 0 0 0 0
51751 - 0 0 0 0 0 0 0 0 0 0 0 0
51752 - 0 0 0 0 0 0 0 0 0 0 0 0
51753 - 0 0 0 0 0 0 0 0 0 0 0 0
51754 - 0 0 0 6 6 6 6 6 6 10 10 10
51755 - 18 18 18 22 22 22 30 30 30 42 42 42
51756 - 50 50 50 66 66 66 86 86 86 101 98 89
51757 -106 86 58 98 70 6 104 69 6 104 69 6
51758 -104 69 6 91 60 6 82 62 34 90 90 90
51759 - 62 62 62 38 38 38 22 22 22 14 14 14
51760 - 10 10 10 10 10 10 10 10 10 10 10 10
51761 - 10 10 10 10 10 10 6 6 6 10 10 10
51762 - 10 10 10 10 10 10 10 10 10 14 14 14
51763 - 22 22 22 42 42 42 70 70 70 89 81 66
51764 - 80 54 7 104 69 6 124 80 6 137 92 6
51765 -134 86 6 116 81 8 100 82 52 86 86 86
51766 - 58 58 58 30 30 30 14 14 14 6 6 6
51767 - 0 0 0 0 0 0 0 0 0 0 0 0
51768 - 0 0 0 0 0 0 0 0 0 0 0 0
51769 - 0 0 0 0 0 0 0 0 0 0 0 0
51770 - 0 0 0 0 0 0 0 0 0 0 0 0
51771 - 0 0 0 0 0 0 0 0 0 0 0 0
51772 - 0 0 0 0 0 0 0 0 0 0 0 0
51773 - 0 0 0 0 0 0 0 0 0 0 0 0
51774 - 0 0 0 0 0 0 0 0 0 0 0 0
51775 - 0 0 0 6 6 6 10 10 10 14 14 14
51776 - 18 18 18 26 26 26 38 38 38 54 54 54
51777 - 70 70 70 86 86 86 94 86 76 89 81 66
51778 - 89 81 66 86 86 86 74 74 74 50 50 50
51779 - 30 30 30 14 14 14 6 6 6 0 0 0
51780 - 0 0 0 0 0 0 0 0 0 0 0 0
51781 - 0 0 0 0 0 0 0 0 0 0 0 0
51782 - 0 0 0 0 0 0 0 0 0 0 0 0
51783 - 6 6 6 18 18 18 34 34 34 58 58 58
51784 - 82 82 82 89 81 66 89 81 66 89 81 66
51785 - 94 86 66 94 86 76 74 74 74 50 50 50
51786 - 26 26 26 14 14 14 6 6 6 0 0 0
51787 - 0 0 0 0 0 0 0 0 0 0 0 0
51788 - 0 0 0 0 0 0 0 0 0 0 0 0
51789 - 0 0 0 0 0 0 0 0 0 0 0 0
51790 - 0 0 0 0 0 0 0 0 0 0 0 0
51791 - 0 0 0 0 0 0 0 0 0 0 0 0
51792 - 0 0 0 0 0 0 0 0 0 0 0 0
51793 - 0 0 0 0 0 0 0 0 0 0 0 0
51794 - 0 0 0 0 0 0 0 0 0 0 0 0
51795 - 0 0 0 0 0 0 0 0 0 0 0 0
51796 - 6 6 6 6 6 6 14 14 14 18 18 18
51797 - 30 30 30 38 38 38 46 46 46 54 54 54
51798 - 50 50 50 42 42 42 30 30 30 18 18 18
51799 - 10 10 10 0 0 0 0 0 0 0 0 0
51800 - 0 0 0 0 0 0 0 0 0 0 0 0
51801 - 0 0 0 0 0 0 0 0 0 0 0 0
51802 - 0 0 0 0 0 0 0 0 0 0 0 0
51803 - 0 0 0 6 6 6 14 14 14 26 26 26
51804 - 38 38 38 50 50 50 58 58 58 58 58 58
51805 - 54 54 54 42 42 42 30 30 30 18 18 18
51806 - 10 10 10 0 0 0 0 0 0 0 0 0
51807 - 0 0 0 0 0 0 0 0 0 0 0 0
51808 - 0 0 0 0 0 0 0 0 0 0 0 0
51809 - 0 0 0 0 0 0 0 0 0 0 0 0
51810 - 0 0 0 0 0 0 0 0 0 0 0 0
51811 - 0 0 0 0 0 0 0 0 0 0 0 0
51812 - 0 0 0 0 0 0 0 0 0 0 0 0
51813 - 0 0 0 0 0 0 0 0 0 0 0 0
51814 - 0 0 0 0 0 0 0 0 0 0 0 0
51815 - 0 0 0 0 0 0 0 0 0 0 0 0
51816 - 0 0 0 0 0 0 0 0 0 6 6 6
51817 - 6 6 6 10 10 10 14 14 14 18 18 18
51818 - 18 18 18 14 14 14 10 10 10 6 6 6
51819 - 0 0 0 0 0 0 0 0 0 0 0 0
51820 - 0 0 0 0 0 0 0 0 0 0 0 0
51821 - 0 0 0 0 0 0 0 0 0 0 0 0
51822 - 0 0 0 0 0 0 0 0 0 0 0 0
51823 - 0 0 0 0 0 0 0 0 0 6 6 6
51824 - 14 14 14 18 18 18 22 22 22 22 22 22
51825 - 18 18 18 14 14 14 10 10 10 6 6 6
51826 - 0 0 0 0 0 0 0 0 0 0 0 0
51827 - 0 0 0 0 0 0 0 0 0 0 0 0
51828 - 0 0 0 0 0 0 0 0 0 0 0 0
51829 - 0 0 0 0 0 0 0 0 0 0 0 0
51830 - 0 0 0 0 0 0 0 0 0 0 0 0
51831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51844 +4 4 4 4 4 4
51845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51858 +4 4 4 4 4 4
51859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51872 +4 4 4 4 4 4
51873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51886 +4 4 4 4 4 4
51887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51900 +4 4 4 4 4 4
51901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51914 +4 4 4 4 4 4
51915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51919 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51920 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51924 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51925 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51926 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51928 +4 4 4 4 4 4
51929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51933 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51934 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51935 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51938 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51939 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51940 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51941 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51942 +4 4 4 4 4 4
51943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51947 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51948 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51949 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51952 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51953 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51954 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51955 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51956 +4 4 4 4 4 4
51957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51960 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51961 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51962 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51963 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51965 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51966 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51967 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51968 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51969 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51970 +4 4 4 4 4 4
51971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51974 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51975 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51976 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51977 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51978 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51979 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51980 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51981 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51982 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51983 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51984 +4 4 4 4 4 4
51985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51988 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51989 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51990 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51991 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51992 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51993 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51994 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51995 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51996 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51997 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51998 +4 4 4 4 4 4
51999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52001 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
52002 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
52003 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
52004 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
52005 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
52006 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
52007 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
52008 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
52009 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
52010 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
52011 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
52012 +4 4 4 4 4 4
52013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52015 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
52016 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
52017 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
52018 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
52019 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
52020 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
52021 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
52022 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
52023 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
52024 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
52025 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
52026 +4 4 4 4 4 4
52027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52029 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
52030 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
52031 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
52032 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
52033 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
52034 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
52035 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
52036 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
52037 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
52038 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
52039 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
52040 +4 4 4 4 4 4
52041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52043 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
52044 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
52045 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
52046 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
52047 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
52048 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
52049 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
52050 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
52051 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
52052 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
52053 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
52054 +4 4 4 4 4 4
52055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52056 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
52057 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
52058 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
52059 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
52060 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
52061 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
52062 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
52063 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
52064 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
52065 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
52066 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
52067 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
52068 +4 4 4 4 4 4
52069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52070 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
52071 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
52072 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
52073 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52074 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
52075 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
52076 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
52077 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
52078 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
52079 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
52080 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
52081 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
52082 +0 0 0 4 4 4
52083 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
52084 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
52085 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
52086 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
52087 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
52088 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
52089 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
52090 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
52091 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
52092 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
52093 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
52094 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
52095 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
52096 +2 0 0 0 0 0
52097 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
52098 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
52099 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
52100 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
52101 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
52102 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
52103 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
52104 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
52105 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
52106 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
52107 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
52108 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
52109 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
52110 +37 38 37 0 0 0
52111 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
52112 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
52113 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
52114 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
52115 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
52116 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
52117 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
52118 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
52119 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
52120 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
52121 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
52122 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
52123 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
52124 +85 115 134 4 0 0
52125 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
52126 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
52127 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
52128 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
52129 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
52130 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
52131 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
52132 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
52133 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
52134 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
52135 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
52136 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
52137 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
52138 +60 73 81 4 0 0
52139 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
52140 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
52141 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
52142 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
52143 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
52144 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
52145 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
52146 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
52147 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
52148 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
52149 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
52150 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
52151 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
52152 +16 19 21 4 0 0
52153 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
52154 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
52155 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
52156 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
52157 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
52158 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
52159 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
52160 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
52161 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
52162 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
52163 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
52164 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
52165 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
52166 +4 0 0 4 3 3
52167 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
52168 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
52169 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
52170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
52171 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
52172 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
52173 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
52174 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
52175 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
52176 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
52177 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
52178 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
52179 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
52180 +3 2 2 4 4 4
52181 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
52182 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
52183 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
52184 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
52185 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
52186 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
52187 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52188 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
52189 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
52190 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
52191 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
52192 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
52193 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
52194 +4 4 4 4 4 4
52195 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
52196 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
52197 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
52198 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
52199 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
52200 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
52201 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
52202 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
52203 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
52204 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
52205 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
52206 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
52207 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
52208 +4 4 4 4 4 4
52209 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
52210 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
52211 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
52212 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
52213 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
52214 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52215 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
52216 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
52217 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
52218 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
52219 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
52220 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
52221 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
52222 +5 5 5 5 5 5
52223 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
52224 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
52225 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
52226 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
52227 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
52228 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52229 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
52230 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
52231 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
52232 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
52233 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
52234 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
52235 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52236 +5 5 5 4 4 4
52237 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
52238 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
52239 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
52240 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
52241 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52242 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
52243 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
52244 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
52245 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
52246 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
52247 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
52248 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52250 +4 4 4 4 4 4
52251 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
52252 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
52253 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
52254 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
52255 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
52256 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52257 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52258 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
52259 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
52260 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
52261 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
52262 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
52263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52264 +4 4 4 4 4 4
52265 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
52266 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
52267 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
52268 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
52269 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52270 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
52271 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
52272 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
52273 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
52274 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
52275 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
52276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52278 +4 4 4 4 4 4
52279 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
52280 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
52281 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
52282 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
52283 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52284 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52285 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52286 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
52287 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
52288 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
52289 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
52290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52292 +4 4 4 4 4 4
52293 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
52294 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
52295 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
52296 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
52297 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52298 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
52299 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52300 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
52301 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
52302 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
52303 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52306 +4 4 4 4 4 4
52307 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
52308 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
52309 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
52310 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
52311 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52312 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
52313 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
52314 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
52315 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
52316 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
52317 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
52318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52320 +4 4 4 4 4 4
52321 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
52322 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
52323 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
52324 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
52325 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52326 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
52327 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
52328 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
52329 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
52330 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
52331 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
52332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52334 +4 4 4 4 4 4
52335 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
52336 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
52337 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
52338 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52339 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
52340 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
52341 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
52342 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
52343 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
52344 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
52345 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52348 +4 4 4 4 4 4
52349 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
52350 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
52351 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
52352 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52353 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52354 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
52355 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
52356 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
52357 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
52358 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
52359 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52362 +4 4 4 4 4 4
52363 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
52364 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
52365 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52366 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52367 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52368 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
52369 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
52370 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
52371 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
52372 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
52373 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52376 +4 4 4 4 4 4
52377 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
52378 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
52379 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52380 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52381 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52382 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
52383 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
52384 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
52385 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52386 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52387 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52390 +4 4 4 4 4 4
52391 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52392 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
52393 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52394 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
52395 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
52396 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
52397 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
52398 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
52399 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52400 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52401 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52404 +4 4 4 4 4 4
52405 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52406 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
52407 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52408 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
52409 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52410 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
52411 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
52412 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
52413 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52414 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52415 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52418 +4 4 4 4 4 4
52419 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
52420 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
52421 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52422 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
52423 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
52424 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
52425 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
52426 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
52427 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52428 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52429 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52432 +4 4 4 4 4 4
52433 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
52434 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
52435 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52436 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
52437 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
52438 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
52439 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
52440 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
52441 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52442 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52443 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52446 +4 4 4 4 4 4
52447 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52448 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
52449 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52450 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
52451 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
52452 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
52453 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
52454 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
52455 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52456 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52457 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52460 +4 4 4 4 4 4
52461 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
52462 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
52463 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52464 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
52465 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
52466 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
52467 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
52468 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
52469 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
52470 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52471 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52474 +4 4 4 4 4 4
52475 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52476 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
52477 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
52478 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
52479 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
52480 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
52481 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
52482 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
52483 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52484 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52485 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52488 +4 4 4 4 4 4
52489 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52490 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
52491 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52492 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
52493 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
52494 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
52495 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
52496 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
52497 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52498 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52499 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52502 +4 4 4 4 4 4
52503 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52504 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
52505 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
52506 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
52507 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
52508 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
52509 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52510 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
52511 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52512 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52513 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52516 +4 4 4 4 4 4
52517 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52518 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
52519 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
52520 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52521 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
52522 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
52523 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52524 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
52525 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52526 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52527 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52530 +4 4 4 4 4 4
52531 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52532 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
52533 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
52534 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
52535 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
52536 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
52537 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
52538 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
52539 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
52540 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52541 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52544 +4 4 4 4 4 4
52545 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52546 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
52547 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
52548 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
52549 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
52550 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
52551 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
52552 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
52553 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
52554 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52555 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52558 +4 4 4 4 4 4
52559 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
52560 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
52561 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
52562 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
52563 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52564 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
52565 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
52566 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
52567 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
52568 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52569 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52572 +4 4 4 4 4 4
52573 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52574 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
52575 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
52576 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
52577 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
52578 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
52579 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
52580 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
52581 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
52582 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52583 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52586 +4 4 4 4 4 4
52587 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
52588 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
52589 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
52590 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
52591 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
52592 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
52593 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
52594 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
52595 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
52596 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
52597 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52600 +4 4 4 4 4 4
52601 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
52602 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52603 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
52604 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
52605 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
52606 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
52607 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
52608 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
52609 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
52610 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
52611 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52614 +4 4 4 4 4 4
52615 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
52616 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52617 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
52618 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
52619 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
52620 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
52621 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52622 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
52623 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
52624 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
52625 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52628 +4 4 4 4 4 4
52629 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
52630 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
52631 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
52632 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
52633 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
52634 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
52635 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
52636 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
52637 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
52638 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
52639 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52642 +4 4 4 4 4 4
52643 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
52644 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
52645 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52646 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
52647 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
52648 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
52649 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
52650 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
52651 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
52652 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
52653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52656 +4 4 4 4 4 4
52657 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52658 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
52659 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
52660 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
52661 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
52662 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
52663 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
52664 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
52665 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
52666 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52670 +4 4 4 4 4 4
52671 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
52672 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
52673 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
52674 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
52675 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
52676 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
52677 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
52678 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
52679 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
52680 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52684 +4 4 4 4 4 4
52685 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
52686 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
52687 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
52688 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
52689 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
52690 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
52691 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
52692 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
52693 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52694 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52698 +4 4 4 4 4 4
52699 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
52700 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52701 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
52702 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52703 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
52704 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
52705 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
52706 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
52707 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
52708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52712 +4 4 4 4 4 4
52713 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
52714 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
52715 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
52716 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
52717 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
52718 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
52719 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
52720 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
52721 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
52722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52726 +4 4 4 4 4 4
52727 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52728 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
52729 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
52730 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
52731 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
52732 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
52733 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
52734 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
52735 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52740 +4 4 4 4 4 4
52741 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
52742 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
52743 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52744 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
52745 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
52746 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
52747 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
52748 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
52749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52754 +4 4 4 4 4 4
52755 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52756 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
52757 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
52758 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
52759 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
52760 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
52761 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
52762 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52768 +4 4 4 4 4 4
52769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52770 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
52771 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52772 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
52773 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
52774 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
52775 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
52776 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
52777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52782 +4 4 4 4 4 4
52783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52784 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
52785 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
52786 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
52787 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
52788 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
52789 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
52790 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
52791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52796 +4 4 4 4 4 4
52797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52798 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52799 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52800 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52801 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52802 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52803 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52804 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52810 +4 4 4 4 4 4
52811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52813 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52814 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52815 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52816 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52817 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52818 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52824 +4 4 4 4 4 4
52825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52828 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52829 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52830 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52831 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
52832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52838 +4 4 4 4 4 4
52839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52842 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52843 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52844 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52845 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52852 +4 4 4 4 4 4
52853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52856 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52857 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52858 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52859 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52866 +4 4 4 4 4 4
52867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52870 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52871 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52872 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52873 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52880 +4 4 4 4 4 4
52881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52885 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52886 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52887 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52894 +4 4 4 4 4 4
52895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52899 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52900 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52901 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52908 +4 4 4 4 4 4
52909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52913 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52914 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52915 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52922 +4 4 4 4 4 4
52923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52927 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52928 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52936 +4 4 4 4 4 4
52937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52941 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52942 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52950 +4 4 4 4 4 4
52951 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52952 index fe92eed..106e085 100644
52953 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52954 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52955 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52956 struct mb862xxfb_par *par = info->par;
52957
52958 if (info->var.bits_per_pixel == 32) {
52959 - info->fbops->fb_fillrect = cfb_fillrect;
52960 - info->fbops->fb_copyarea = cfb_copyarea;
52961 - info->fbops->fb_imageblit = cfb_imageblit;
52962 + pax_open_kernel();
52963 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52964 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52965 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52966 + pax_close_kernel();
52967 } else {
52968 outreg(disp, GC_L0EM, 3);
52969 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52970 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52971 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52972 + pax_open_kernel();
52973 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52974 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52975 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52976 + pax_close_kernel();
52977 }
52978 outreg(draw, GDC_REG_DRAW_BASE, 0);
52979 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52980 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52981 index ff22871..b129bed 100644
52982 --- a/drivers/video/nvidia/nvidia.c
52983 +++ b/drivers/video/nvidia/nvidia.c
52984 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52985 info->fix.line_length = (info->var.xres_virtual *
52986 info->var.bits_per_pixel) >> 3;
52987 if (info->var.accel_flags) {
52988 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52989 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52990 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52991 - info->fbops->fb_sync = nvidiafb_sync;
52992 + pax_open_kernel();
52993 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52994 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52995 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52996 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52997 + pax_close_kernel();
52998 info->pixmap.scan_align = 4;
52999 info->flags &= ~FBINFO_HWACCEL_DISABLED;
53000 info->flags |= FBINFO_READS_FAST;
53001 NVResetGraphics(info);
53002 } else {
53003 - info->fbops->fb_imageblit = cfb_imageblit;
53004 - info->fbops->fb_fillrect = cfb_fillrect;
53005 - info->fbops->fb_copyarea = cfb_copyarea;
53006 - info->fbops->fb_sync = NULL;
53007 + pax_open_kernel();
53008 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
53009 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
53010 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
53011 + *(void **)&info->fbops->fb_sync = NULL;
53012 + pax_close_kernel();
53013 info->pixmap.scan_align = 1;
53014 info->flags |= FBINFO_HWACCEL_DISABLED;
53015 info->flags &= ~FBINFO_READS_FAST;
53016 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
53017 info->pixmap.size = 8 * 1024;
53018 info->pixmap.flags = FB_PIXMAP_SYSTEM;
53019
53020 - if (!hwcur)
53021 - info->fbops->fb_cursor = NULL;
53022 + if (!hwcur) {
53023 + pax_open_kernel();
53024 + *(void **)&info->fbops->fb_cursor = NULL;
53025 + pax_close_kernel();
53026 + }
53027
53028 info->var.accel_flags = (!noaccel);
53029
53030 diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
53031 index fafe7c9..93197b9 100644
53032 --- a/drivers/video/omap2/dss/display.c
53033 +++ b/drivers/video/omap2/dss/display.c
53034 @@ -137,12 +137,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
53035 snprintf(dssdev->alias, sizeof(dssdev->alias),
53036 "display%d", disp_num_counter++);
53037
53038 + pax_open_kernel();
53039 if (drv && drv->get_resolution == NULL)
53040 - drv->get_resolution = omapdss_default_get_resolution;
53041 + *(void **)&drv->get_resolution = omapdss_default_get_resolution;
53042 if (drv && drv->get_recommended_bpp == NULL)
53043 - drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
53044 + *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
53045 if (drv && drv->get_timings == NULL)
53046 - drv->get_timings = omapdss_default_get_timings;
53047 + *(void **)&drv->get_timings = omapdss_default_get_timings;
53048 + pax_close_kernel();
53049
53050 mutex_lock(&panel_list_mutex);
53051 list_add_tail(&dssdev->panel_list, &panel_list);
53052 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
53053 index 05c2dc3..ea1f391 100644
53054 --- a/drivers/video/s1d13xxxfb.c
53055 +++ b/drivers/video/s1d13xxxfb.c
53056 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
53057
53058 switch(prod_id) {
53059 case S1D13506_PROD_ID: /* activate acceleration */
53060 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
53061 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
53062 + pax_open_kernel();
53063 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
53064 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
53065 + pax_close_kernel();
53066 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
53067 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
53068 break;
53069 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
53070 index e188ada..aac63c8 100644
53071 --- a/drivers/video/smscufx.c
53072 +++ b/drivers/video/smscufx.c
53073 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
53074 fb_deferred_io_cleanup(info);
53075 kfree(info->fbdefio);
53076 info->fbdefio = NULL;
53077 - info->fbops->fb_mmap = ufx_ops_mmap;
53078 + pax_open_kernel();
53079 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
53080 + pax_close_kernel();
53081 }
53082
53083 pr_debug("released /dev/fb%d user=%d count=%d",
53084 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
53085 index d2e5bc3..4cb05d1 100644
53086 --- a/drivers/video/udlfb.c
53087 +++ b/drivers/video/udlfb.c
53088 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
53089 dlfb_urb_completion(urb);
53090
53091 error:
53092 - atomic_add(bytes_sent, &dev->bytes_sent);
53093 - atomic_add(bytes_identical, &dev->bytes_identical);
53094 - atomic_add(width*height*2, &dev->bytes_rendered);
53095 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
53096 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
53097 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
53098 end_cycles = get_cycles();
53099 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
53100 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
53101 >> 10)), /* Kcycles */
53102 &dev->cpu_kcycles_used);
53103
53104 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
53105 dlfb_urb_completion(urb);
53106
53107 error:
53108 - atomic_add(bytes_sent, &dev->bytes_sent);
53109 - atomic_add(bytes_identical, &dev->bytes_identical);
53110 - atomic_add(bytes_rendered, &dev->bytes_rendered);
53111 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
53112 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
53113 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
53114 end_cycles = get_cycles();
53115 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
53116 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
53117 >> 10)), /* Kcycles */
53118 &dev->cpu_kcycles_used);
53119 }
53120 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
53121 fb_deferred_io_cleanup(info);
53122 kfree(info->fbdefio);
53123 info->fbdefio = NULL;
53124 - info->fbops->fb_mmap = dlfb_ops_mmap;
53125 + pax_open_kernel();
53126 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
53127 + pax_close_kernel();
53128 }
53129
53130 pr_warn("released /dev/fb%d user=%d count=%d\n",
53131 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
53132 struct fb_info *fb_info = dev_get_drvdata(fbdev);
53133 struct dlfb_data *dev = fb_info->par;
53134 return snprintf(buf, PAGE_SIZE, "%u\n",
53135 - atomic_read(&dev->bytes_rendered));
53136 + atomic_read_unchecked(&dev->bytes_rendered));
53137 }
53138
53139 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
53140 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
53141 struct fb_info *fb_info = dev_get_drvdata(fbdev);
53142 struct dlfb_data *dev = fb_info->par;
53143 return snprintf(buf, PAGE_SIZE, "%u\n",
53144 - atomic_read(&dev->bytes_identical));
53145 + atomic_read_unchecked(&dev->bytes_identical));
53146 }
53147
53148 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
53149 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
53150 struct fb_info *fb_info = dev_get_drvdata(fbdev);
53151 struct dlfb_data *dev = fb_info->par;
53152 return snprintf(buf, PAGE_SIZE, "%u\n",
53153 - atomic_read(&dev->bytes_sent));
53154 + atomic_read_unchecked(&dev->bytes_sent));
53155 }
53156
53157 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
53158 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
53159 struct fb_info *fb_info = dev_get_drvdata(fbdev);
53160 struct dlfb_data *dev = fb_info->par;
53161 return snprintf(buf, PAGE_SIZE, "%u\n",
53162 - atomic_read(&dev->cpu_kcycles_used));
53163 + atomic_read_unchecked(&dev->cpu_kcycles_used));
53164 }
53165
53166 static ssize_t edid_show(
53167 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
53168 struct fb_info *fb_info = dev_get_drvdata(fbdev);
53169 struct dlfb_data *dev = fb_info->par;
53170
53171 - atomic_set(&dev->bytes_rendered, 0);
53172 - atomic_set(&dev->bytes_identical, 0);
53173 - atomic_set(&dev->bytes_sent, 0);
53174 - atomic_set(&dev->cpu_kcycles_used, 0);
53175 + atomic_set_unchecked(&dev->bytes_rendered, 0);
53176 + atomic_set_unchecked(&dev->bytes_identical, 0);
53177 + atomic_set_unchecked(&dev->bytes_sent, 0);
53178 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
53179
53180 return count;
53181 }
53182 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
53183 index 7aec6f3..e3b2d55 100644
53184 --- a/drivers/video/uvesafb.c
53185 +++ b/drivers/video/uvesafb.c
53186 @@ -19,6 +19,7 @@
53187 #include <linux/io.h>
53188 #include <linux/mutex.h>
53189 #include <linux/slab.h>
53190 +#include <linux/moduleloader.h>
53191 #include <video/edid.h>
53192 #include <video/uvesafb.h>
53193 #ifdef CONFIG_X86
53194 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
53195 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
53196 par->pmi_setpal = par->ypan = 0;
53197 } else {
53198 +
53199 +#ifdef CONFIG_PAX_KERNEXEC
53200 +#ifdef CONFIG_MODULES
53201 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
53202 +#endif
53203 + if (!par->pmi_code) {
53204 + par->pmi_setpal = par->ypan = 0;
53205 + return 0;
53206 + }
53207 +#endif
53208 +
53209 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
53210 + task->t.regs.edi);
53211 +
53212 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53213 + pax_open_kernel();
53214 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
53215 + pax_close_kernel();
53216 +
53217 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
53218 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
53219 +#else
53220 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
53221 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
53222 +#endif
53223 +
53224 printk(KERN_INFO "uvesafb: protected mode interface info at "
53225 "%04x:%04x\n",
53226 (u16)task->t.regs.es, (u16)task->t.regs.edi);
53227 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
53228 par->ypan = ypan;
53229
53230 if (par->pmi_setpal || par->ypan) {
53231 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
53232 if (__supported_pte_mask & _PAGE_NX) {
53233 par->pmi_setpal = par->ypan = 0;
53234 printk(KERN_WARNING "uvesafb: NX protection is active, "
53235 "better not use the PMI.\n");
53236 - } else {
53237 + } else
53238 +#endif
53239 uvesafb_vbe_getpmi(task, par);
53240 - }
53241 }
53242 #else
53243 /* The protected mode interface is not available on non-x86. */
53244 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
53245 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
53246
53247 /* Disable blanking if the user requested so. */
53248 - if (!blank)
53249 - info->fbops->fb_blank = NULL;
53250 + if (!blank) {
53251 + pax_open_kernel();
53252 + *(void **)&info->fbops->fb_blank = NULL;
53253 + pax_close_kernel();
53254 + }
53255
53256 /*
53257 * Find out how much IO memory is required for the mode with
53258 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
53259 info->flags = FBINFO_FLAG_DEFAULT |
53260 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
53261
53262 - if (!par->ypan)
53263 - info->fbops->fb_pan_display = NULL;
53264 + if (!par->ypan) {
53265 + pax_open_kernel();
53266 + *(void **)&info->fbops->fb_pan_display = NULL;
53267 + pax_close_kernel();
53268 + }
53269 }
53270
53271 static void uvesafb_init_mtrr(struct fb_info *info)
53272 @@ -1796,6 +1826,11 @@ out:
53273 if (par->vbe_modes)
53274 kfree(par->vbe_modes);
53275
53276 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53277 + if (par->pmi_code)
53278 + module_free_exec(NULL, par->pmi_code);
53279 +#endif
53280 +
53281 framebuffer_release(info);
53282 return err;
53283 }
53284 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
53285 kfree(par->vbe_state_orig);
53286 if (par->vbe_state_saved)
53287 kfree(par->vbe_state_saved);
53288 +
53289 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53290 + if (par->pmi_code)
53291 + module_free_exec(NULL, par->pmi_code);
53292 +#endif
53293 +
53294 }
53295
53296 framebuffer_release(info);
53297 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
53298 index bd83233..7d8a5aa 100644
53299 --- a/drivers/video/vesafb.c
53300 +++ b/drivers/video/vesafb.c
53301 @@ -9,6 +9,7 @@
53302 */
53303
53304 #include <linux/module.h>
53305 +#include <linux/moduleloader.h>
53306 #include <linux/kernel.h>
53307 #include <linux/errno.h>
53308 #include <linux/string.h>
53309 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
53310 static int vram_total; /* Set total amount of memory */
53311 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
53312 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
53313 -static void (*pmi_start)(void) __read_mostly;
53314 -static void (*pmi_pal) (void) __read_mostly;
53315 +static void (*pmi_start)(void) __read_only;
53316 +static void (*pmi_pal) (void) __read_only;
53317 static int depth __read_mostly;
53318 static int vga_compat __read_mostly;
53319 /* --------------------------------------------------------------------- */
53320 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
53321 unsigned int size_remap;
53322 unsigned int size_total;
53323 char *option = NULL;
53324 + void *pmi_code = NULL;
53325
53326 /* ignore error return of fb_get_options */
53327 fb_get_options("vesafb", &option);
53328 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
53329 size_remap = size_total;
53330 vesafb_fix.smem_len = size_remap;
53331
53332 -#ifndef __i386__
53333 - screen_info.vesapm_seg = 0;
53334 -#endif
53335 -
53336 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
53337 printk(KERN_WARNING
53338 "vesafb: cannot reserve video memory at 0x%lx\n",
53339 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
53340 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
53341 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
53342
53343 +#ifdef __i386__
53344 +
53345 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53346 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
53347 + if (!pmi_code)
53348 +#elif !defined(CONFIG_PAX_KERNEXEC)
53349 + if (0)
53350 +#endif
53351 +
53352 +#endif
53353 + screen_info.vesapm_seg = 0;
53354 +
53355 if (screen_info.vesapm_seg) {
53356 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
53357 - screen_info.vesapm_seg,screen_info.vesapm_off);
53358 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
53359 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
53360 }
53361
53362 if (screen_info.vesapm_seg < 0xc000)
53363 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
53364
53365 if (ypan || pmi_setpal) {
53366 unsigned short *pmi_base;
53367 +
53368 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
53369 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
53370 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
53371 +
53372 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53373 + pax_open_kernel();
53374 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
53375 +#else
53376 + pmi_code = pmi_base;
53377 +#endif
53378 +
53379 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
53380 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
53381 +
53382 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53383 + pmi_start = ktva_ktla(pmi_start);
53384 + pmi_pal = ktva_ktla(pmi_pal);
53385 + pax_close_kernel();
53386 +#endif
53387 +
53388 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
53389 if (pmi_base[3]) {
53390 printk(KERN_INFO "vesafb: pmi: ports = ");
53391 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
53392 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
53393 (ypan ? FBINFO_HWACCEL_YPAN : 0);
53394
53395 - if (!ypan)
53396 - info->fbops->fb_pan_display = NULL;
53397 + if (!ypan) {
53398 + pax_open_kernel();
53399 + *(void **)&info->fbops->fb_pan_display = NULL;
53400 + pax_close_kernel();
53401 + }
53402
53403 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
53404 err = -ENOMEM;
53405 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
53406 info->node, info->fix.id);
53407 return 0;
53408 err:
53409 +
53410 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53411 + module_free_exec(NULL, pmi_code);
53412 +#endif
53413 +
53414 if (info->screen_base)
53415 iounmap(info->screen_base);
53416 framebuffer_release(info);
53417 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
53418 index 88714ae..16c2e11 100644
53419 --- a/drivers/video/via/via_clock.h
53420 +++ b/drivers/video/via/via_clock.h
53421 @@ -56,7 +56,7 @@ struct via_clock {
53422
53423 void (*set_engine_pll_state)(u8 state);
53424 void (*set_engine_pll)(struct via_pll_config config);
53425 -};
53426 +} __no_const;
53427
53428
53429 static inline u32 get_pll_internal_frequency(u32 ref_freq,
53430 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
53431 index fef20db..d28b1ab 100644
53432 --- a/drivers/xen/xenfs/xenstored.c
53433 +++ b/drivers/xen/xenfs/xenstored.c
53434 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
53435 static int xsd_kva_open(struct inode *inode, struct file *file)
53436 {
53437 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
53438 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53439 + NULL);
53440 +#else
53441 xen_store_interface);
53442 +#endif
53443 +
53444 if (!file->private_data)
53445 return -ENOMEM;
53446 return 0;
53447 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
53448 index 9ff073f..05cef23 100644
53449 --- a/fs/9p/vfs_addr.c
53450 +++ b/fs/9p/vfs_addr.c
53451 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
53452
53453 retval = v9fs_file_write_internal(inode,
53454 v9inode->writeback_fid,
53455 - (__force const char __user *)buffer,
53456 + (const char __force_user *)buffer,
53457 len, &offset, 0);
53458 if (retval > 0)
53459 retval = 0;
53460 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
53461 index 94de6d1..8d81256 100644
53462 --- a/fs/9p/vfs_inode.c
53463 +++ b/fs/9p/vfs_inode.c
53464 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
53465 void
53466 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53467 {
53468 - char *s = nd_get_link(nd);
53469 + const char *s = nd_get_link(nd);
53470
53471 p9_debug(P9_DEBUG_VFS, " %s %s\n",
53472 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
53473 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
53474 index 370b24c..ff0be7b 100644
53475 --- a/fs/Kconfig.binfmt
53476 +++ b/fs/Kconfig.binfmt
53477 @@ -103,7 +103,7 @@ config HAVE_AOUT
53478
53479 config BINFMT_AOUT
53480 tristate "Kernel support for a.out and ECOFF binaries"
53481 - depends on HAVE_AOUT
53482 + depends on HAVE_AOUT && BROKEN
53483 ---help---
53484 A.out (Assembler.OUTput) is a set of formats for libraries and
53485 executables used in the earliest versions of UNIX. Linux used
53486 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
53487 index 789bc25..fafaeea 100644
53488 --- a/fs/afs/inode.c
53489 +++ b/fs/afs/inode.c
53490 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53491 struct afs_vnode *vnode;
53492 struct super_block *sb;
53493 struct inode *inode;
53494 - static atomic_t afs_autocell_ino;
53495 + static atomic_unchecked_t afs_autocell_ino;
53496
53497 _enter("{%x:%u},%*.*s,",
53498 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
53499 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53500 data.fid.unique = 0;
53501 data.fid.vnode = 0;
53502
53503 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
53504 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
53505 afs_iget5_autocell_test, afs_iget5_set,
53506 &data);
53507 if (!inode) {
53508 diff --git a/fs/aio.c b/fs/aio.c
53509 index 062a5f6..e5618e0 100644
53510 --- a/fs/aio.c
53511 +++ b/fs/aio.c
53512 @@ -374,7 +374,7 @@ static int aio_setup_ring(struct kioctx *ctx)
53513 size += sizeof(struct io_event) * nr_events;
53514
53515 nr_pages = PFN_UP(size);
53516 - if (nr_pages < 0)
53517 + if (nr_pages <= 0)
53518 return -EINVAL;
53519
53520 file = aio_private_file(ctx, nr_pages);
53521 diff --git a/fs/attr.c b/fs/attr.c
53522 index 1449adb..a2038c2 100644
53523 --- a/fs/attr.c
53524 +++ b/fs/attr.c
53525 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
53526 unsigned long limit;
53527
53528 limit = rlimit(RLIMIT_FSIZE);
53529 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
53530 if (limit != RLIM_INFINITY && offset > limit)
53531 goto out_sig;
53532 if (offset > inode->i_sb->s_maxbytes)
53533 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
53534 index 689e40d..515cac5 100644
53535 --- a/fs/autofs4/waitq.c
53536 +++ b/fs/autofs4/waitq.c
53537 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
53538 {
53539 unsigned long sigpipe, flags;
53540 mm_segment_t fs;
53541 - const char *data = (const char *)addr;
53542 + const char __user *data = (const char __force_user *)addr;
53543 ssize_t wr = 0;
53544
53545 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
53546 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
53547 return 1;
53548 }
53549
53550 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53551 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
53552 +#endif
53553 +
53554 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53555 enum autofs_notify notify)
53556 {
53557 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53558
53559 /* If this is a direct mount request create a dummy name */
53560 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
53561 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53562 + /* this name does get written to userland via autofs4_write() */
53563 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
53564 +#else
53565 qstr.len = sprintf(name, "%p", dentry);
53566 +#endif
53567 else {
53568 qstr.len = autofs4_getpath(sbi, dentry, &name);
53569 if (!qstr.len) {
53570 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
53571 index 2722387..56059b5 100644
53572 --- a/fs/befs/endian.h
53573 +++ b/fs/befs/endian.h
53574 @@ -11,7 +11,7 @@
53575
53576 #include <asm/byteorder.h>
53577
53578 -static inline u64
53579 +static inline u64 __intentional_overflow(-1)
53580 fs64_to_cpu(const struct super_block *sb, fs64 n)
53581 {
53582 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53583 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
53584 return (__force fs64)cpu_to_be64(n);
53585 }
53586
53587 -static inline u32
53588 +static inline u32 __intentional_overflow(-1)
53589 fs32_to_cpu(const struct super_block *sb, fs32 n)
53590 {
53591 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53592 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
53593 return (__force fs32)cpu_to_be32(n);
53594 }
53595
53596 -static inline u16
53597 +static inline u16 __intentional_overflow(-1)
53598 fs16_to_cpu(const struct super_block *sb, fs16 n)
53599 {
53600 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53601 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
53602 index e9c75e2..1baece1 100644
53603 --- a/fs/befs/linuxvfs.c
53604 +++ b/fs/befs/linuxvfs.c
53605 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53606 {
53607 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
53608 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
53609 - char *link = nd_get_link(nd);
53610 + const char *link = nd_get_link(nd);
53611 if (!IS_ERR(link))
53612 kfree(link);
53613 }
53614 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
53615 index 89dec7f..361b0d75 100644
53616 --- a/fs/binfmt_aout.c
53617 +++ b/fs/binfmt_aout.c
53618 @@ -16,6 +16,7 @@
53619 #include <linux/string.h>
53620 #include <linux/fs.h>
53621 #include <linux/file.h>
53622 +#include <linux/security.h>
53623 #include <linux/stat.h>
53624 #include <linux/fcntl.h>
53625 #include <linux/ptrace.h>
53626 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
53627 #endif
53628 # define START_STACK(u) ((void __user *)u.start_stack)
53629
53630 + memset(&dump, 0, sizeof(dump));
53631 +
53632 fs = get_fs();
53633 set_fs(KERNEL_DS);
53634 has_dumped = 1;
53635 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
53636
53637 /* If the size of the dump file exceeds the rlimit, then see what would happen
53638 if we wrote the stack, but not the data area. */
53639 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
53640 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
53641 dump.u_dsize = 0;
53642
53643 /* Make sure we have enough room to write the stack and data areas. */
53644 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
53645 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
53646 dump.u_ssize = 0;
53647
53648 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
53649 rlim = rlimit(RLIMIT_DATA);
53650 if (rlim >= RLIM_INFINITY)
53651 rlim = ~0;
53652 +
53653 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
53654 if (ex.a_data + ex.a_bss > rlim)
53655 return -ENOMEM;
53656
53657 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
53658
53659 install_exec_creds(bprm);
53660
53661 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53662 + current->mm->pax_flags = 0UL;
53663 +#endif
53664 +
53665 +#ifdef CONFIG_PAX_PAGEEXEC
53666 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
53667 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
53668 +
53669 +#ifdef CONFIG_PAX_EMUTRAMP
53670 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
53671 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
53672 +#endif
53673 +
53674 +#ifdef CONFIG_PAX_MPROTECT
53675 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
53676 + current->mm->pax_flags |= MF_PAX_MPROTECT;
53677 +#endif
53678 +
53679 + }
53680 +#endif
53681 +
53682 if (N_MAGIC(ex) == OMAGIC) {
53683 unsigned long text_addr, map_size;
53684 loff_t pos;
53685 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
53686 }
53687
53688 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
53689 - PROT_READ | PROT_WRITE | PROT_EXEC,
53690 + PROT_READ | PROT_WRITE,
53691 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
53692 fd_offset + ex.a_text);
53693 if (error != N_DATADDR(ex)) {
53694 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
53695 index 4c94a79..9d5fb56 100644
53696 --- a/fs/binfmt_elf.c
53697 +++ b/fs/binfmt_elf.c
53698 @@ -34,6 +34,7 @@
53699 #include <linux/utsname.h>
53700 #include <linux/coredump.h>
53701 #include <linux/sched.h>
53702 +#include <linux/xattr.h>
53703 #include <asm/uaccess.h>
53704 #include <asm/param.h>
53705 #include <asm/page.h>
53706 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
53707 #define elf_core_dump NULL
53708 #endif
53709
53710 +#ifdef CONFIG_PAX_MPROTECT
53711 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
53712 +#endif
53713 +
53714 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53715 +static void elf_handle_mmap(struct file *file);
53716 +#endif
53717 +
53718 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
53719 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
53720 #else
53721 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
53722 .load_binary = load_elf_binary,
53723 .load_shlib = load_elf_library,
53724 .core_dump = elf_core_dump,
53725 +
53726 +#ifdef CONFIG_PAX_MPROTECT
53727 + .handle_mprotect= elf_handle_mprotect,
53728 +#endif
53729 +
53730 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53731 + .handle_mmap = elf_handle_mmap,
53732 +#endif
53733 +
53734 .min_coredump = ELF_EXEC_PAGESIZE,
53735 };
53736
53737 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
53738
53739 static int set_brk(unsigned long start, unsigned long end)
53740 {
53741 + unsigned long e = end;
53742 +
53743 start = ELF_PAGEALIGN(start);
53744 end = ELF_PAGEALIGN(end);
53745 if (end > start) {
53746 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
53747 if (BAD_ADDR(addr))
53748 return addr;
53749 }
53750 - current->mm->start_brk = current->mm->brk = end;
53751 + current->mm->start_brk = current->mm->brk = e;
53752 return 0;
53753 }
53754
53755 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53756 elf_addr_t __user *u_rand_bytes;
53757 const char *k_platform = ELF_PLATFORM;
53758 const char *k_base_platform = ELF_BASE_PLATFORM;
53759 - unsigned char k_rand_bytes[16];
53760 + u32 k_rand_bytes[4];
53761 int items;
53762 elf_addr_t *elf_info;
53763 int ei_index = 0;
53764 const struct cred *cred = current_cred();
53765 struct vm_area_struct *vma;
53766 + unsigned long saved_auxv[AT_VECTOR_SIZE];
53767
53768 /*
53769 * In some cases (e.g. Hyper-Threading), we want to avoid L1
53770 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53771 * Generate 16 random bytes for userspace PRNG seeding.
53772 */
53773 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
53774 - u_rand_bytes = (elf_addr_t __user *)
53775 - STACK_ALLOC(p, sizeof(k_rand_bytes));
53776 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
53777 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
53778 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
53779 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
53780 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
53781 + u_rand_bytes = (elf_addr_t __user *) p;
53782 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
53783 return -EFAULT;
53784
53785 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53786 return -EFAULT;
53787 current->mm->env_end = p;
53788
53789 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
53790 +
53791 /* Put the elf_info on the stack in the right place. */
53792 sp = (elf_addr_t __user *)envp + 1;
53793 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53794 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53795 return -EFAULT;
53796 return 0;
53797 }
53798 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53799 an ELF header */
53800
53801 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53802 - struct file *interpreter, unsigned long *interp_map_addr,
53803 - unsigned long no_base)
53804 + struct file *interpreter, unsigned long no_base)
53805 {
53806 struct elf_phdr *elf_phdata;
53807 struct elf_phdr *eppnt;
53808 - unsigned long load_addr = 0;
53809 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53810 int load_addr_set = 0;
53811 unsigned long last_bss = 0, elf_bss = 0;
53812 - unsigned long error = ~0UL;
53813 + unsigned long error = -EINVAL;
53814 unsigned long total_size;
53815 int retval, i, size;
53816
53817 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53818 goto out_close;
53819 }
53820
53821 +#ifdef CONFIG_PAX_SEGMEXEC
53822 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53823 + pax_task_size = SEGMEXEC_TASK_SIZE;
53824 +#endif
53825 +
53826 eppnt = elf_phdata;
53827 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53828 if (eppnt->p_type == PT_LOAD) {
53829 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53830 map_addr = elf_map(interpreter, load_addr + vaddr,
53831 eppnt, elf_prot, elf_type, total_size);
53832 total_size = 0;
53833 - if (!*interp_map_addr)
53834 - *interp_map_addr = map_addr;
53835 error = map_addr;
53836 if (BAD_ADDR(map_addr))
53837 goto out_close;
53838 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53839 k = load_addr + eppnt->p_vaddr;
53840 if (BAD_ADDR(k) ||
53841 eppnt->p_filesz > eppnt->p_memsz ||
53842 - eppnt->p_memsz > TASK_SIZE ||
53843 - TASK_SIZE - eppnt->p_memsz < k) {
53844 + eppnt->p_memsz > pax_task_size ||
53845 + pax_task_size - eppnt->p_memsz < k) {
53846 error = -ENOMEM;
53847 goto out_close;
53848 }
53849 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53850 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
53851
53852 /* Map the last of the bss segment */
53853 - error = vm_brk(elf_bss, last_bss - elf_bss);
53854 - if (BAD_ADDR(error))
53855 - goto out_close;
53856 + if (last_bss > elf_bss) {
53857 + error = vm_brk(elf_bss, last_bss - elf_bss);
53858 + if (BAD_ADDR(error))
53859 + goto out_close;
53860 + }
53861 }
53862
53863 error = load_addr;
53864 @@ -538,6 +569,336 @@ out:
53865 return error;
53866 }
53867
53868 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53869 +#ifdef CONFIG_PAX_SOFTMODE
53870 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53871 +{
53872 + unsigned long pax_flags = 0UL;
53873 +
53874 +#ifdef CONFIG_PAX_PAGEEXEC
53875 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53876 + pax_flags |= MF_PAX_PAGEEXEC;
53877 +#endif
53878 +
53879 +#ifdef CONFIG_PAX_SEGMEXEC
53880 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53881 + pax_flags |= MF_PAX_SEGMEXEC;
53882 +#endif
53883 +
53884 +#ifdef CONFIG_PAX_EMUTRAMP
53885 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53886 + pax_flags |= MF_PAX_EMUTRAMP;
53887 +#endif
53888 +
53889 +#ifdef CONFIG_PAX_MPROTECT
53890 + if (elf_phdata->p_flags & PF_MPROTECT)
53891 + pax_flags |= MF_PAX_MPROTECT;
53892 +#endif
53893 +
53894 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53895 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53896 + pax_flags |= MF_PAX_RANDMMAP;
53897 +#endif
53898 +
53899 + return pax_flags;
53900 +}
53901 +#endif
53902 +
53903 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53904 +{
53905 + unsigned long pax_flags = 0UL;
53906 +
53907 +#ifdef CONFIG_PAX_PAGEEXEC
53908 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53909 + pax_flags |= MF_PAX_PAGEEXEC;
53910 +#endif
53911 +
53912 +#ifdef CONFIG_PAX_SEGMEXEC
53913 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53914 + pax_flags |= MF_PAX_SEGMEXEC;
53915 +#endif
53916 +
53917 +#ifdef CONFIG_PAX_EMUTRAMP
53918 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53919 + pax_flags |= MF_PAX_EMUTRAMP;
53920 +#endif
53921 +
53922 +#ifdef CONFIG_PAX_MPROTECT
53923 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53924 + pax_flags |= MF_PAX_MPROTECT;
53925 +#endif
53926 +
53927 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53928 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53929 + pax_flags |= MF_PAX_RANDMMAP;
53930 +#endif
53931 +
53932 + return pax_flags;
53933 +}
53934 +#endif
53935 +
53936 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53937 +#ifdef CONFIG_PAX_SOFTMODE
53938 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53939 +{
53940 + unsigned long pax_flags = 0UL;
53941 +
53942 +#ifdef CONFIG_PAX_PAGEEXEC
53943 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53944 + pax_flags |= MF_PAX_PAGEEXEC;
53945 +#endif
53946 +
53947 +#ifdef CONFIG_PAX_SEGMEXEC
53948 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53949 + pax_flags |= MF_PAX_SEGMEXEC;
53950 +#endif
53951 +
53952 +#ifdef CONFIG_PAX_EMUTRAMP
53953 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53954 + pax_flags |= MF_PAX_EMUTRAMP;
53955 +#endif
53956 +
53957 +#ifdef CONFIG_PAX_MPROTECT
53958 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53959 + pax_flags |= MF_PAX_MPROTECT;
53960 +#endif
53961 +
53962 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53963 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53964 + pax_flags |= MF_PAX_RANDMMAP;
53965 +#endif
53966 +
53967 + return pax_flags;
53968 +}
53969 +#endif
53970 +
53971 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53972 +{
53973 + unsigned long pax_flags = 0UL;
53974 +
53975 +#ifdef CONFIG_PAX_PAGEEXEC
53976 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53977 + pax_flags |= MF_PAX_PAGEEXEC;
53978 +#endif
53979 +
53980 +#ifdef CONFIG_PAX_SEGMEXEC
53981 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53982 + pax_flags |= MF_PAX_SEGMEXEC;
53983 +#endif
53984 +
53985 +#ifdef CONFIG_PAX_EMUTRAMP
53986 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53987 + pax_flags |= MF_PAX_EMUTRAMP;
53988 +#endif
53989 +
53990 +#ifdef CONFIG_PAX_MPROTECT
53991 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53992 + pax_flags |= MF_PAX_MPROTECT;
53993 +#endif
53994 +
53995 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53996 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53997 + pax_flags |= MF_PAX_RANDMMAP;
53998 +#endif
53999 +
54000 + return pax_flags;
54001 +}
54002 +#endif
54003 +
54004 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54005 +static unsigned long pax_parse_defaults(void)
54006 +{
54007 + unsigned long pax_flags = 0UL;
54008 +
54009 +#ifdef CONFIG_PAX_SOFTMODE
54010 + if (pax_softmode)
54011 + return pax_flags;
54012 +#endif
54013 +
54014 +#ifdef CONFIG_PAX_PAGEEXEC
54015 + pax_flags |= MF_PAX_PAGEEXEC;
54016 +#endif
54017 +
54018 +#ifdef CONFIG_PAX_SEGMEXEC
54019 + pax_flags |= MF_PAX_SEGMEXEC;
54020 +#endif
54021 +
54022 +#ifdef CONFIG_PAX_MPROTECT
54023 + pax_flags |= MF_PAX_MPROTECT;
54024 +#endif
54025 +
54026 +#ifdef CONFIG_PAX_RANDMMAP
54027 + if (randomize_va_space)
54028 + pax_flags |= MF_PAX_RANDMMAP;
54029 +#endif
54030 +
54031 + return pax_flags;
54032 +}
54033 +
54034 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
54035 +{
54036 + unsigned long pax_flags = PAX_PARSE_FLAGS_FALLBACK;
54037 +
54038 +#ifdef CONFIG_PAX_EI_PAX
54039 +
54040 +#ifdef CONFIG_PAX_SOFTMODE
54041 + if (pax_softmode)
54042 + return pax_flags;
54043 +#endif
54044 +
54045 + pax_flags = 0UL;
54046 +
54047 +#ifdef CONFIG_PAX_PAGEEXEC
54048 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
54049 + pax_flags |= MF_PAX_PAGEEXEC;
54050 +#endif
54051 +
54052 +#ifdef CONFIG_PAX_SEGMEXEC
54053 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
54054 + pax_flags |= MF_PAX_SEGMEXEC;
54055 +#endif
54056 +
54057 +#ifdef CONFIG_PAX_EMUTRAMP
54058 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
54059 + pax_flags |= MF_PAX_EMUTRAMP;
54060 +#endif
54061 +
54062 +#ifdef CONFIG_PAX_MPROTECT
54063 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
54064 + pax_flags |= MF_PAX_MPROTECT;
54065 +#endif
54066 +
54067 +#ifdef CONFIG_PAX_ASLR
54068 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
54069 + pax_flags |= MF_PAX_RANDMMAP;
54070 +#endif
54071 +
54072 +#endif
54073 +
54074 + return pax_flags;
54075 +
54076 +}
54077 +
54078 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
54079 +{
54080 +
54081 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54082 + unsigned long i;
54083 +
54084 + for (i = 0UL; i < elf_ex->e_phnum; i++)
54085 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
54086 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
54087 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
54088 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
54089 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
54090 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
54091 + return PAX_PARSE_FLAGS_FALLBACK;
54092 +
54093 +#ifdef CONFIG_PAX_SOFTMODE
54094 + if (pax_softmode)
54095 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
54096 + else
54097 +#endif
54098 +
54099 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
54100 + break;
54101 + }
54102 +#endif
54103 +
54104 + return PAX_PARSE_FLAGS_FALLBACK;
54105 +}
54106 +
54107 +static unsigned long pax_parse_xattr_pax(struct file * const file)
54108 +{
54109 +
54110 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
54111 + ssize_t xattr_size, i;
54112 + unsigned char xattr_value[sizeof("pemrs") - 1];
54113 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
54114 +
54115 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
54116 + if (xattr_size < 0 || xattr_size > sizeof xattr_value)
54117 + return PAX_PARSE_FLAGS_FALLBACK;
54118 +
54119 + for (i = 0; i < xattr_size; i++)
54120 + switch (xattr_value[i]) {
54121 + default:
54122 + return PAX_PARSE_FLAGS_FALLBACK;
54123 +
54124 +#define parse_flag(option1, option2, flag) \
54125 + case option1: \
54126 + if (pax_flags_hardmode & MF_PAX_##flag) \
54127 + return PAX_PARSE_FLAGS_FALLBACK;\
54128 + pax_flags_hardmode |= MF_PAX_##flag; \
54129 + break; \
54130 + case option2: \
54131 + if (pax_flags_softmode & MF_PAX_##flag) \
54132 + return PAX_PARSE_FLAGS_FALLBACK;\
54133 + pax_flags_softmode |= MF_PAX_##flag; \
54134 + break;
54135 +
54136 + parse_flag('p', 'P', PAGEEXEC);
54137 + parse_flag('e', 'E', EMUTRAMP);
54138 + parse_flag('m', 'M', MPROTECT);
54139 + parse_flag('r', 'R', RANDMMAP);
54140 + parse_flag('s', 'S', SEGMEXEC);
54141 +
54142 +#undef parse_flag
54143 + }
54144 +
54145 + if (pax_flags_hardmode & pax_flags_softmode)
54146 + return PAX_PARSE_FLAGS_FALLBACK;
54147 +
54148 +#ifdef CONFIG_PAX_SOFTMODE
54149 + if (pax_softmode)
54150 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
54151 + else
54152 +#endif
54153 +
54154 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
54155 +#else
54156 + return PAX_PARSE_FLAGS_FALLBACK;
54157 +#endif
54158 +
54159 +}
54160 +
54161 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
54162 +{
54163 + unsigned long pax_flags, ei_pax_flags, pt_pax_flags, xattr_pax_flags;
54164 +
54165 + pax_flags = pax_parse_defaults();
54166 + ei_pax_flags = pax_parse_ei_pax(elf_ex);
54167 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
54168 + xattr_pax_flags = pax_parse_xattr_pax(file);
54169 +
54170 + if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
54171 + xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK &&
54172 + pt_pax_flags != xattr_pax_flags)
54173 + return -EINVAL;
54174 + if (xattr_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
54175 + pax_flags = xattr_pax_flags;
54176 + else if (pt_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
54177 + pax_flags = pt_pax_flags;
54178 + else if (ei_pax_flags != PAX_PARSE_FLAGS_FALLBACK)
54179 + pax_flags = ei_pax_flags;
54180 +
54181 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
54182 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54183 + if ((__supported_pte_mask & _PAGE_NX))
54184 + pax_flags &= ~MF_PAX_SEGMEXEC;
54185 + else
54186 + pax_flags &= ~MF_PAX_PAGEEXEC;
54187 + }
54188 +#endif
54189 +
54190 + if (0 > pax_check_flags(&pax_flags))
54191 + return -EINVAL;
54192 +
54193 + current->mm->pax_flags = pax_flags;
54194 + return 0;
54195 +}
54196 +#endif
54197 +
54198 /*
54199 * These are the functions used to load ELF style executables and shared
54200 * libraries. There is no binary dependent code anywhere else.
54201 @@ -554,6 +915,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
54202 {
54203 unsigned int random_variable = 0;
54204
54205 +#ifdef CONFIG_PAX_RANDUSTACK
54206 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
54207 + return stack_top - current->mm->delta_stack;
54208 +#endif
54209 +
54210 if ((current->flags & PF_RANDOMIZE) &&
54211 !(current->personality & ADDR_NO_RANDOMIZE)) {
54212 random_variable = get_random_int() & STACK_RND_MASK;
54213 @@ -572,7 +938,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
54214 unsigned long load_addr = 0, load_bias = 0;
54215 int load_addr_set = 0;
54216 char * elf_interpreter = NULL;
54217 - unsigned long error;
54218 + unsigned long error = 0;
54219 struct elf_phdr *elf_ppnt, *elf_phdata;
54220 unsigned long elf_bss, elf_brk;
54221 int retval, i;
54222 @@ -582,12 +948,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
54223 unsigned long start_code, end_code, start_data, end_data;
54224 unsigned long reloc_func_desc __maybe_unused = 0;
54225 int executable_stack = EXSTACK_DEFAULT;
54226 - unsigned long def_flags = 0;
54227 struct pt_regs *regs = current_pt_regs();
54228 struct {
54229 struct elfhdr elf_ex;
54230 struct elfhdr interp_elf_ex;
54231 } *loc;
54232 + unsigned long pax_task_size;
54233
54234 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
54235 if (!loc) {
54236 @@ -723,11 +1089,82 @@ static int load_elf_binary(struct linux_binprm *bprm)
54237 goto out_free_dentry;
54238
54239 /* OK, This is the point of no return */
54240 - current->mm->def_flags = def_flags;
54241 + current->mm->def_flags = 0;
54242
54243 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
54244 may depend on the personality. */
54245 SET_PERSONALITY(loc->elf_ex);
54246 +
54247 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54248 + current->mm->pax_flags = 0UL;
54249 +#endif
54250 +
54251 +#ifdef CONFIG_PAX_DLRESOLVE
54252 + current->mm->call_dl_resolve = 0UL;
54253 +#endif
54254 +
54255 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
54256 + current->mm->call_syscall = 0UL;
54257 +#endif
54258 +
54259 +#ifdef CONFIG_PAX_ASLR
54260 + current->mm->delta_mmap = 0UL;
54261 + current->mm->delta_stack = 0UL;
54262 +#endif
54263 +
54264 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54265 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
54266 + send_sig(SIGKILL, current, 0);
54267 + goto out_free_dentry;
54268 + }
54269 +#endif
54270 +
54271 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54272 + pax_set_initial_flags(bprm);
54273 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
54274 + if (pax_set_initial_flags_func)
54275 + (pax_set_initial_flags_func)(bprm);
54276 +#endif
54277 +
54278 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
54279 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
54280 + current->mm->context.user_cs_limit = PAGE_SIZE;
54281 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
54282 + }
54283 +#endif
54284 +
54285 +#ifdef CONFIG_PAX_SEGMEXEC
54286 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
54287 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
54288 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
54289 + pax_task_size = SEGMEXEC_TASK_SIZE;
54290 + current->mm->def_flags |= VM_NOHUGEPAGE;
54291 + } else
54292 +#endif
54293 +
54294 + pax_task_size = TASK_SIZE;
54295 +
54296 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
54297 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54298 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
54299 + put_cpu();
54300 + }
54301 +#endif
54302 +
54303 +#ifdef CONFIG_PAX_ASLR
54304 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54305 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
54306 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
54307 + }
54308 +#endif
54309 +
54310 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54311 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54312 + executable_stack = EXSTACK_DISABLE_X;
54313 + current->personality &= ~READ_IMPLIES_EXEC;
54314 + } else
54315 +#endif
54316 +
54317 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
54318 current->personality |= READ_IMPLIES_EXEC;
54319
54320 @@ -817,6 +1254,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
54321 #else
54322 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
54323 #endif
54324 +
54325 +#ifdef CONFIG_PAX_RANDMMAP
54326 + /* PaX: randomize base address at the default exe base if requested */
54327 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
54328 +#ifdef CONFIG_SPARC64
54329 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
54330 +#else
54331 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
54332 +#endif
54333 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
54334 + elf_flags |= MAP_FIXED;
54335 + }
54336 +#endif
54337 +
54338 }
54339
54340 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
54341 @@ -849,9 +1300,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
54342 * allowed task size. Note that p_filesz must always be
54343 * <= p_memsz so it is only necessary to check p_memsz.
54344 */
54345 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54346 - elf_ppnt->p_memsz > TASK_SIZE ||
54347 - TASK_SIZE - elf_ppnt->p_memsz < k) {
54348 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54349 + elf_ppnt->p_memsz > pax_task_size ||
54350 + pax_task_size - elf_ppnt->p_memsz < k) {
54351 /* set_brk can never work. Avoid overflows. */
54352 send_sig(SIGKILL, current, 0);
54353 retval = -EINVAL;
54354 @@ -890,17 +1341,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
54355 goto out_free_dentry;
54356 }
54357 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
54358 - send_sig(SIGSEGV, current, 0);
54359 - retval = -EFAULT; /* Nobody gets to see this, but.. */
54360 - goto out_free_dentry;
54361 + /*
54362 + * This bss-zeroing can fail if the ELF
54363 + * file specifies odd protections. So
54364 + * we don't check the return value
54365 + */
54366 }
54367
54368 +#ifdef CONFIG_PAX_RANDMMAP
54369 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54370 + unsigned long start, size, flags;
54371 + vm_flags_t vm_flags;
54372 +
54373 + start = ELF_PAGEALIGN(elf_brk);
54374 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
54375 + flags = MAP_FIXED | MAP_PRIVATE;
54376 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
54377 +
54378 + down_write(&current->mm->mmap_sem);
54379 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
54380 + retval = -ENOMEM;
54381 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
54382 +// if (current->personality & ADDR_NO_RANDOMIZE)
54383 +// vm_flags |= VM_READ | VM_MAYREAD;
54384 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
54385 + retval = IS_ERR_VALUE(start) ? start : 0;
54386 + }
54387 + up_write(&current->mm->mmap_sem);
54388 + if (retval == 0)
54389 + retval = set_brk(start + size, start + size + PAGE_SIZE);
54390 + if (retval < 0) {
54391 + send_sig(SIGKILL, current, 0);
54392 + goto out_free_dentry;
54393 + }
54394 + }
54395 +#endif
54396 +
54397 if (elf_interpreter) {
54398 - unsigned long interp_map_addr = 0;
54399 -
54400 elf_entry = load_elf_interp(&loc->interp_elf_ex,
54401 interpreter,
54402 - &interp_map_addr,
54403 load_bias);
54404 if (!IS_ERR((void *)elf_entry)) {
54405 /*
54406 @@ -1122,7 +1601,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
54407 * Decide what to dump of a segment, part, all or none.
54408 */
54409 static unsigned long vma_dump_size(struct vm_area_struct *vma,
54410 - unsigned long mm_flags)
54411 + unsigned long mm_flags, long signr)
54412 {
54413 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
54414
54415 @@ -1160,7 +1639,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
54416 if (vma->vm_file == NULL)
54417 return 0;
54418
54419 - if (FILTER(MAPPED_PRIVATE))
54420 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
54421 goto whole;
54422
54423 /*
54424 @@ -1385,9 +1864,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
54425 {
54426 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
54427 int i = 0;
54428 - do
54429 + do {
54430 i += 2;
54431 - while (auxv[i - 2] != AT_NULL);
54432 + } while (auxv[i - 2] != AT_NULL);
54433 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
54434 }
54435
54436 @@ -1396,7 +1875,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
54437 {
54438 mm_segment_t old_fs = get_fs();
54439 set_fs(KERNEL_DS);
54440 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
54441 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
54442 set_fs(old_fs);
54443 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
54444 }
54445 @@ -2023,14 +2502,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
54446 }
54447
54448 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
54449 - unsigned long mm_flags)
54450 + struct coredump_params *cprm)
54451 {
54452 struct vm_area_struct *vma;
54453 size_t size = 0;
54454
54455 for (vma = first_vma(current, gate_vma); vma != NULL;
54456 vma = next_vma(vma, gate_vma))
54457 - size += vma_dump_size(vma, mm_flags);
54458 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54459 return size;
54460 }
54461
54462 @@ -2123,7 +2602,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54463
54464 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
54465
54466 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
54467 + offset += elf_core_vma_data_size(gate_vma, cprm);
54468 offset += elf_core_extra_data_size();
54469 e_shoff = offset;
54470
54471 @@ -2137,10 +2616,12 @@ static int elf_core_dump(struct coredump_params *cprm)
54472 offset = dataoff;
54473
54474 size += sizeof(*elf);
54475 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54476 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
54477 goto end_coredump;
54478
54479 size += sizeof(*phdr4note);
54480 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54481 if (size > cprm->limit
54482 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
54483 goto end_coredump;
54484 @@ -2154,7 +2635,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54485 phdr.p_offset = offset;
54486 phdr.p_vaddr = vma->vm_start;
54487 phdr.p_paddr = 0;
54488 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
54489 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54490 phdr.p_memsz = vma->vm_end - vma->vm_start;
54491 offset += phdr.p_filesz;
54492 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
54493 @@ -2165,6 +2646,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54494 phdr.p_align = ELF_EXEC_PAGESIZE;
54495
54496 size += sizeof(phdr);
54497 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54498 if (size > cprm->limit
54499 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
54500 goto end_coredump;
54501 @@ -2189,7 +2671,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54502 unsigned long addr;
54503 unsigned long end;
54504
54505 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
54506 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54507
54508 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
54509 struct page *page;
54510 @@ -2198,6 +2680,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54511 page = get_dump_page(addr);
54512 if (page) {
54513 void *kaddr = kmap(page);
54514 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
54515 stop = ((size += PAGE_SIZE) > cprm->limit) ||
54516 !dump_write(cprm->file, kaddr,
54517 PAGE_SIZE);
54518 @@ -2215,6 +2698,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54519
54520 if (e_phnum == PN_XNUM) {
54521 size += sizeof(*shdr4extnum);
54522 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54523 if (size > cprm->limit
54524 || !dump_write(cprm->file, shdr4extnum,
54525 sizeof(*shdr4extnum)))
54526 @@ -2235,6 +2719,167 @@ out:
54527
54528 #endif /* CONFIG_ELF_CORE */
54529
54530 +#ifdef CONFIG_PAX_MPROTECT
54531 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
54532 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
54533 + * we'll remove VM_MAYWRITE for good on RELRO segments.
54534 + *
54535 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
54536 + * basis because we want to allow the common case and not the special ones.
54537 + */
54538 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
54539 +{
54540 + struct elfhdr elf_h;
54541 + struct elf_phdr elf_p;
54542 + unsigned long i;
54543 + unsigned long oldflags;
54544 + bool is_textrel_rw, is_textrel_rx, is_relro;
54545 +
54546 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
54547 + return;
54548 +
54549 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
54550 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
54551 +
54552 +#ifdef CONFIG_PAX_ELFRELOCS
54553 + /* possible TEXTREL */
54554 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
54555 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
54556 +#else
54557 + is_textrel_rw = false;
54558 + is_textrel_rx = false;
54559 +#endif
54560 +
54561 + /* possible RELRO */
54562 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
54563 +
54564 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
54565 + return;
54566 +
54567 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54568 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54569 +
54570 +#ifdef CONFIG_PAX_ETEXECRELOCS
54571 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54572 +#else
54573 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
54574 +#endif
54575 +
54576 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54577 + !elf_check_arch(&elf_h) ||
54578 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54579 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54580 + return;
54581 +
54582 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54583 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54584 + return;
54585 + switch (elf_p.p_type) {
54586 + case PT_DYNAMIC:
54587 + if (!is_textrel_rw && !is_textrel_rx)
54588 + continue;
54589 + i = 0UL;
54590 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
54591 + elf_dyn dyn;
54592 +
54593 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
54594 + break;
54595 + if (dyn.d_tag == DT_NULL)
54596 + break;
54597 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
54598 + gr_log_textrel(vma);
54599 + if (is_textrel_rw)
54600 + vma->vm_flags |= VM_MAYWRITE;
54601 + else
54602 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
54603 + vma->vm_flags &= ~VM_MAYWRITE;
54604 + break;
54605 + }
54606 + i++;
54607 + }
54608 + is_textrel_rw = false;
54609 + is_textrel_rx = false;
54610 + continue;
54611 +
54612 + case PT_GNU_RELRO:
54613 + if (!is_relro)
54614 + continue;
54615 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
54616 + vma->vm_flags &= ~VM_MAYWRITE;
54617 + is_relro = false;
54618 + continue;
54619 +
54620 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54621 + case PT_PAX_FLAGS: {
54622 + const char *msg_mprotect = "", *msg_emutramp = "";
54623 + char *buffer_lib, *buffer_exe;
54624 +
54625 + if (elf_p.p_flags & PF_NOMPROTECT)
54626 + msg_mprotect = "MPROTECT disabled";
54627 +
54628 +#ifdef CONFIG_PAX_EMUTRAMP
54629 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
54630 + msg_emutramp = "EMUTRAMP enabled";
54631 +#endif
54632 +
54633 + if (!msg_mprotect[0] && !msg_emutramp[0])
54634 + continue;
54635 +
54636 + if (!printk_ratelimit())
54637 + continue;
54638 +
54639 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
54640 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
54641 + if (buffer_lib && buffer_exe) {
54642 + char *path_lib, *path_exe;
54643 +
54644 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
54645 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
54646 +
54647 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
54648 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
54649 +
54650 + }
54651 + free_page((unsigned long)buffer_exe);
54652 + free_page((unsigned long)buffer_lib);
54653 + continue;
54654 + }
54655 +#endif
54656 +
54657 + }
54658 + }
54659 +}
54660 +#endif
54661 +
54662 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
54663 +
54664 +extern int grsec_enable_log_rwxmaps;
54665 +
54666 +static void elf_handle_mmap(struct file *file)
54667 +{
54668 + struct elfhdr elf_h;
54669 + struct elf_phdr elf_p;
54670 + unsigned long i;
54671 +
54672 + if (!grsec_enable_log_rwxmaps)
54673 + return;
54674 +
54675 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54676 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54677 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
54678 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54679 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54680 + return;
54681 +
54682 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54683 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54684 + return;
54685 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
54686 + gr_log_ptgnustack(file);
54687 + }
54688 +}
54689 +#endif
54690 +
54691 static int __init init_elf_binfmt(void)
54692 {
54693 register_binfmt(&elf_format);
54694 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
54695 index d50bbe5..af3b649 100644
54696 --- a/fs/binfmt_flat.c
54697 +++ b/fs/binfmt_flat.c
54698 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
54699 realdatastart = (unsigned long) -ENOMEM;
54700 printk("Unable to allocate RAM for process data, errno %d\n",
54701 (int)-realdatastart);
54702 + down_write(&current->mm->mmap_sem);
54703 vm_munmap(textpos, text_len);
54704 + up_write(&current->mm->mmap_sem);
54705 ret = realdatastart;
54706 goto err;
54707 }
54708 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54709 }
54710 if (IS_ERR_VALUE(result)) {
54711 printk("Unable to read data+bss, errno %d\n", (int)-result);
54712 + down_write(&current->mm->mmap_sem);
54713 vm_munmap(textpos, text_len);
54714 vm_munmap(realdatastart, len);
54715 + up_write(&current->mm->mmap_sem);
54716 ret = result;
54717 goto err;
54718 }
54719 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54720 }
54721 if (IS_ERR_VALUE(result)) {
54722 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
54723 + down_write(&current->mm->mmap_sem);
54724 vm_munmap(textpos, text_len + data_len + extra +
54725 MAX_SHARED_LIBS * sizeof(unsigned long));
54726 + up_write(&current->mm->mmap_sem);
54727 ret = result;
54728 goto err;
54729 }
54730 diff --git a/fs/bio.c b/fs/bio.c
54731 index ea5035d..a2932eb 100644
54732 --- a/fs/bio.c
54733 +++ b/fs/bio.c
54734 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
54735 /*
54736 * Overflow, abort
54737 */
54738 - if (end < start)
54739 + if (end < start || end - start > INT_MAX - nr_pages)
54740 return ERR_PTR(-EINVAL);
54741
54742 nr_pages += end - start;
54743 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
54744 /*
54745 * Overflow, abort
54746 */
54747 - if (end < start)
54748 + if (end < start || end - start > INT_MAX - nr_pages)
54749 return ERR_PTR(-EINVAL);
54750
54751 nr_pages += end - start;
54752 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
54753 const int read = bio_data_dir(bio) == READ;
54754 struct bio_map_data *bmd = bio->bi_private;
54755 int i;
54756 - char *p = bmd->sgvecs[0].iov_base;
54757 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
54758
54759 bio_for_each_segment_all(bvec, bio, i) {
54760 char *addr = page_address(bvec->bv_page);
54761 diff --git a/fs/block_dev.c b/fs/block_dev.c
54762 index 1e86823..8e34695 100644
54763 --- a/fs/block_dev.c
54764 +++ b/fs/block_dev.c
54765 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
54766 else if (bdev->bd_contains == bdev)
54767 return true; /* is a whole device which isn't held */
54768
54769 - else if (whole->bd_holder == bd_may_claim)
54770 + else if (whole->bd_holder == (void *)bd_may_claim)
54771 return true; /* is a partition of a device that is being partitioned */
54772 else if (whole->bd_holder != NULL)
54773 return false; /* is a partition of a held device */
54774 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
54775 index b544a44..f3fb987 100644
54776 --- a/fs/btrfs/ctree.c
54777 +++ b/fs/btrfs/ctree.c
54778 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
54779 free_extent_buffer(buf);
54780 add_root_to_dirty_list(root);
54781 } else {
54782 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
54783 - parent_start = parent->start;
54784 - else
54785 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
54786 + if (parent)
54787 + parent_start = parent->start;
54788 + else
54789 + parent_start = 0;
54790 + } else
54791 parent_start = 0;
54792
54793 WARN_ON(trans->transid != btrfs_header_generation(parent));
54794 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
54795 index cbd9523..5cca781 100644
54796 --- a/fs/btrfs/delayed-inode.c
54797 +++ b/fs/btrfs/delayed-inode.c
54798 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
54799
54800 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
54801 {
54802 - int seq = atomic_inc_return(&delayed_root->items_seq);
54803 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
54804 if ((atomic_dec_return(&delayed_root->items) <
54805 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
54806 waitqueue_active(&delayed_root->wait))
54807 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
54808 static int refs_newer(struct btrfs_delayed_root *delayed_root,
54809 int seq, int count)
54810 {
54811 - int val = atomic_read(&delayed_root->items_seq);
54812 + int val = atomic_read_unchecked(&delayed_root->items_seq);
54813
54814 if (val < seq || val >= seq + count)
54815 return 1;
54816 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54817 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54818 return;
54819
54820 - seq = atomic_read(&delayed_root->items_seq);
54821 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54822
54823 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54824 int ret;
54825 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54826 index a4b38f9..f86a509 100644
54827 --- a/fs/btrfs/delayed-inode.h
54828 +++ b/fs/btrfs/delayed-inode.h
54829 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54830 */
54831 struct list_head prepare_list;
54832 atomic_t items; /* for delayed items */
54833 - atomic_t items_seq; /* for delayed items */
54834 + atomic_unchecked_t items_seq; /* for delayed items */
54835 int nodes; /* for delayed nodes */
54836 wait_queue_head_t wait;
54837 };
54838 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54839 struct btrfs_delayed_root *delayed_root)
54840 {
54841 atomic_set(&delayed_root->items, 0);
54842 - atomic_set(&delayed_root->items_seq, 0);
54843 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54844 delayed_root->nodes = 0;
54845 spin_lock_init(&delayed_root->lock);
54846 init_waitqueue_head(&delayed_root->wait);
54847 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54848 index 8747feb..ad1655c 100644
54849 --- a/fs/btrfs/ioctl.c
54850 +++ b/fs/btrfs/ioctl.c
54851 @@ -3465,9 +3465,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54852 for (i = 0; i < num_types; i++) {
54853 struct btrfs_space_info *tmp;
54854
54855 + /* Don't copy in more than we allocated */
54856 if (!slot_count)
54857 break;
54858
54859 + slot_count--;
54860 +
54861 info = NULL;
54862 rcu_read_lock();
54863 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54864 @@ -3489,10 +3492,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54865 memcpy(dest, &space, sizeof(space));
54866 dest++;
54867 space_args.total_spaces++;
54868 - slot_count--;
54869 }
54870 - if (!slot_count)
54871 - break;
54872 }
54873 up_read(&info->groups_sem);
54874 }
54875 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54876 index e913328..a34fb36 100644
54877 --- a/fs/btrfs/super.c
54878 +++ b/fs/btrfs/super.c
54879 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54880 function, line, errstr);
54881 return;
54882 }
54883 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54884 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54885 /* Wake up anybody who may be waiting on this transaction */
54886 wake_up(&root->fs_info->transaction_wait);
54887 wake_up(&root->fs_info->transaction_blocked_wait);
54888 diff --git a/fs/buffer.c b/fs/buffer.c
54889 index 6024877..7bd000a 100644
54890 --- a/fs/buffer.c
54891 +++ b/fs/buffer.c
54892 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
54893 bh_cachep = kmem_cache_create("buffer_head",
54894 sizeof(struct buffer_head), 0,
54895 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54896 - SLAB_MEM_SPREAD),
54897 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54898 NULL);
54899
54900 /*
54901 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54902 index 622f469..e8d2d55 100644
54903 --- a/fs/cachefiles/bind.c
54904 +++ b/fs/cachefiles/bind.c
54905 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54906 args);
54907
54908 /* start by checking things over */
54909 - ASSERT(cache->fstop_percent >= 0 &&
54910 - cache->fstop_percent < cache->fcull_percent &&
54911 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54912 cache->fcull_percent < cache->frun_percent &&
54913 cache->frun_percent < 100);
54914
54915 - ASSERT(cache->bstop_percent >= 0 &&
54916 - cache->bstop_percent < cache->bcull_percent &&
54917 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54918 cache->bcull_percent < cache->brun_percent &&
54919 cache->brun_percent < 100);
54920
54921 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54922 index 0a1467b..6a53245 100644
54923 --- a/fs/cachefiles/daemon.c
54924 +++ b/fs/cachefiles/daemon.c
54925 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54926 if (n > buflen)
54927 return -EMSGSIZE;
54928
54929 - if (copy_to_user(_buffer, buffer, n) != 0)
54930 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54931 return -EFAULT;
54932
54933 return n;
54934 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54935 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54936 return -EIO;
54937
54938 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54939 + if (datalen > PAGE_SIZE - 1)
54940 return -EOPNOTSUPP;
54941
54942 /* drag the command string into the kernel so we can parse it */
54943 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54944 if (args[0] != '%' || args[1] != '\0')
54945 return -EINVAL;
54946
54947 - if (fstop < 0 || fstop >= cache->fcull_percent)
54948 + if (fstop >= cache->fcull_percent)
54949 return cachefiles_daemon_range_error(cache, args);
54950
54951 cache->fstop_percent = fstop;
54952 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54953 if (args[0] != '%' || args[1] != '\0')
54954 return -EINVAL;
54955
54956 - if (bstop < 0 || bstop >= cache->bcull_percent)
54957 + if (bstop >= cache->bcull_percent)
54958 return cachefiles_daemon_range_error(cache, args);
54959
54960 cache->bstop_percent = bstop;
54961 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54962 index 5349473..d6c0b93 100644
54963 --- a/fs/cachefiles/internal.h
54964 +++ b/fs/cachefiles/internal.h
54965 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54966 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54967 struct rb_root active_nodes; /* active nodes (can't be culled) */
54968 rwlock_t active_lock; /* lock for active_nodes */
54969 - atomic_t gravecounter; /* graveyard uniquifier */
54970 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54971 unsigned frun_percent; /* when to stop culling (% files) */
54972 unsigned fcull_percent; /* when to start culling (% files) */
54973 unsigned fstop_percent; /* when to stop allocating (% files) */
54974 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54975 * proc.c
54976 */
54977 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54978 -extern atomic_t cachefiles_lookup_histogram[HZ];
54979 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54980 -extern atomic_t cachefiles_create_histogram[HZ];
54981 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54982 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54983 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54984
54985 extern int __init cachefiles_proc_init(void);
54986 extern void cachefiles_proc_cleanup(void);
54987 static inline
54988 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54989 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54990 {
54991 unsigned long jif = jiffies - start_jif;
54992 if (jif >= HZ)
54993 jif = HZ - 1;
54994 - atomic_inc(&histogram[jif]);
54995 + atomic_inc_unchecked(&histogram[jif]);
54996 }
54997
54998 #else
54999 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
55000 index f4a08d7..5aa4599 100644
55001 --- a/fs/cachefiles/namei.c
55002 +++ b/fs/cachefiles/namei.c
55003 @@ -317,7 +317,7 @@ try_again:
55004 /* first step is to make up a grave dentry in the graveyard */
55005 sprintf(nbuffer, "%08x%08x",
55006 (uint32_t) get_seconds(),
55007 - (uint32_t) atomic_inc_return(&cache->gravecounter));
55008 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
55009
55010 /* do the multiway lock magic */
55011 trap = lock_rename(cache->graveyard, dir);
55012 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
55013 index eccd339..4c1d995 100644
55014 --- a/fs/cachefiles/proc.c
55015 +++ b/fs/cachefiles/proc.c
55016 @@ -14,9 +14,9 @@
55017 #include <linux/seq_file.h>
55018 #include "internal.h"
55019
55020 -atomic_t cachefiles_lookup_histogram[HZ];
55021 -atomic_t cachefiles_mkdir_histogram[HZ];
55022 -atomic_t cachefiles_create_histogram[HZ];
55023 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
55024 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
55025 +atomic_unchecked_t cachefiles_create_histogram[HZ];
55026
55027 /*
55028 * display the latency histogram
55029 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
55030 return 0;
55031 default:
55032 index = (unsigned long) v - 3;
55033 - x = atomic_read(&cachefiles_lookup_histogram[index]);
55034 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
55035 - z = atomic_read(&cachefiles_create_histogram[index]);
55036 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
55037 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
55038 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
55039 if (x == 0 && y == 0 && z == 0)
55040 return 0;
55041
55042 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
55043 index ebaff36..7e3ea26 100644
55044 --- a/fs/cachefiles/rdwr.c
55045 +++ b/fs/cachefiles/rdwr.c
55046 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
55047 old_fs = get_fs();
55048 set_fs(KERNEL_DS);
55049 ret = file->f_op->write(
55050 - file, (const void __user *) data, len, &pos);
55051 + file, (const void __force_user *) data, len, &pos);
55052 set_fs(old_fs);
55053 kunmap(page);
55054 file_end_write(file);
55055 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
55056 index 868b61d..58835a5 100644
55057 --- a/fs/ceph/dir.c
55058 +++ b/fs/ceph/dir.c
55059 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
55060 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
55061 struct ceph_mds_client *mdsc = fsc->mdsc;
55062 unsigned frag = fpos_frag(ctx->pos);
55063 - int off = fpos_off(ctx->pos);
55064 + unsigned int off = fpos_off(ctx->pos);
55065 int err;
55066 u32 ftype;
55067 struct ceph_mds_reply_info_parsed *rinfo;
55068 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
55069 index 6a0951e..03fac6d 100644
55070 --- a/fs/ceph/super.c
55071 +++ b/fs/ceph/super.c
55072 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
55073 /*
55074 * construct our own bdi so we can control readahead, etc.
55075 */
55076 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
55077 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
55078
55079 static int ceph_register_bdi(struct super_block *sb,
55080 struct ceph_fs_client *fsc)
55081 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
55082 default_backing_dev_info.ra_pages;
55083
55084 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
55085 - atomic_long_inc_return(&bdi_seq));
55086 + atomic_long_inc_return_unchecked(&bdi_seq));
55087 if (!err)
55088 sb->s_bdi = &fsc->backing_dev_info;
55089 return err;
55090 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
55091 index f3ac415..3d2420c 100644
55092 --- a/fs/cifs/cifs_debug.c
55093 +++ b/fs/cifs/cifs_debug.c
55094 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
55095
55096 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
55097 #ifdef CONFIG_CIFS_STATS2
55098 - atomic_set(&totBufAllocCount, 0);
55099 - atomic_set(&totSmBufAllocCount, 0);
55100 + atomic_set_unchecked(&totBufAllocCount, 0);
55101 + atomic_set_unchecked(&totSmBufAllocCount, 0);
55102 #endif /* CONFIG_CIFS_STATS2 */
55103 spin_lock(&cifs_tcp_ses_lock);
55104 list_for_each(tmp1, &cifs_tcp_ses_list) {
55105 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
55106 tcon = list_entry(tmp3,
55107 struct cifs_tcon,
55108 tcon_list);
55109 - atomic_set(&tcon->num_smbs_sent, 0);
55110 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
55111 if (server->ops->clear_stats)
55112 server->ops->clear_stats(tcon);
55113 }
55114 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
55115 smBufAllocCount.counter, cifs_min_small);
55116 #ifdef CONFIG_CIFS_STATS2
55117 seq_printf(m, "Total Large %d Small %d Allocations\n",
55118 - atomic_read(&totBufAllocCount),
55119 - atomic_read(&totSmBufAllocCount));
55120 + atomic_read_unchecked(&totBufAllocCount),
55121 + atomic_read_unchecked(&totSmBufAllocCount));
55122 #endif /* CONFIG_CIFS_STATS2 */
55123
55124 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
55125 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
55126 if (tcon->need_reconnect)
55127 seq_puts(m, "\tDISCONNECTED ");
55128 seq_printf(m, "\nSMBs: %d",
55129 - atomic_read(&tcon->num_smbs_sent));
55130 + atomic_read_unchecked(&tcon->num_smbs_sent));
55131 if (server->ops->print_stats)
55132 server->ops->print_stats(m, tcon);
55133 }
55134 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
55135 index 77fc5e1..e3d13e6 100644
55136 --- a/fs/cifs/cifsfs.c
55137 +++ b/fs/cifs/cifsfs.c
55138 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
55139 */
55140 cifs_req_cachep = kmem_cache_create("cifs_request",
55141 CIFSMaxBufSize + max_hdr_size, 0,
55142 - SLAB_HWCACHE_ALIGN, NULL);
55143 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
55144 if (cifs_req_cachep == NULL)
55145 return -ENOMEM;
55146
55147 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
55148 efficient to alloc 1 per page off the slab compared to 17K (5page)
55149 alloc of large cifs buffers even when page debugging is on */
55150 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
55151 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
55152 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
55153 NULL);
55154 if (cifs_sm_req_cachep == NULL) {
55155 mempool_destroy(cifs_req_poolp);
55156 @@ -1168,8 +1168,8 @@ init_cifs(void)
55157 atomic_set(&bufAllocCount, 0);
55158 atomic_set(&smBufAllocCount, 0);
55159 #ifdef CONFIG_CIFS_STATS2
55160 - atomic_set(&totBufAllocCount, 0);
55161 - atomic_set(&totSmBufAllocCount, 0);
55162 + atomic_set_unchecked(&totBufAllocCount, 0);
55163 + atomic_set_unchecked(&totSmBufAllocCount, 0);
55164 #endif /* CONFIG_CIFS_STATS2 */
55165
55166 atomic_set(&midCount, 0);
55167 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
55168 index c8e03f8..75362f6 100644
55169 --- a/fs/cifs/cifsglob.h
55170 +++ b/fs/cifs/cifsglob.h
55171 @@ -758,35 +758,35 @@ struct cifs_tcon {
55172 __u16 Flags; /* optional support bits */
55173 enum statusEnum tidStatus;
55174 #ifdef CONFIG_CIFS_STATS
55175 - atomic_t num_smbs_sent;
55176 + atomic_unchecked_t num_smbs_sent;
55177 union {
55178 struct {
55179 - atomic_t num_writes;
55180 - atomic_t num_reads;
55181 - atomic_t num_flushes;
55182 - atomic_t num_oplock_brks;
55183 - atomic_t num_opens;
55184 - atomic_t num_closes;
55185 - atomic_t num_deletes;
55186 - atomic_t num_mkdirs;
55187 - atomic_t num_posixopens;
55188 - atomic_t num_posixmkdirs;
55189 - atomic_t num_rmdirs;
55190 - atomic_t num_renames;
55191 - atomic_t num_t2renames;
55192 - atomic_t num_ffirst;
55193 - atomic_t num_fnext;
55194 - atomic_t num_fclose;
55195 - atomic_t num_hardlinks;
55196 - atomic_t num_symlinks;
55197 - atomic_t num_locks;
55198 - atomic_t num_acl_get;
55199 - atomic_t num_acl_set;
55200 + atomic_unchecked_t num_writes;
55201 + atomic_unchecked_t num_reads;
55202 + atomic_unchecked_t num_flushes;
55203 + atomic_unchecked_t num_oplock_brks;
55204 + atomic_unchecked_t num_opens;
55205 + atomic_unchecked_t num_closes;
55206 + atomic_unchecked_t num_deletes;
55207 + atomic_unchecked_t num_mkdirs;
55208 + atomic_unchecked_t num_posixopens;
55209 + atomic_unchecked_t num_posixmkdirs;
55210 + atomic_unchecked_t num_rmdirs;
55211 + atomic_unchecked_t num_renames;
55212 + atomic_unchecked_t num_t2renames;
55213 + atomic_unchecked_t num_ffirst;
55214 + atomic_unchecked_t num_fnext;
55215 + atomic_unchecked_t num_fclose;
55216 + atomic_unchecked_t num_hardlinks;
55217 + atomic_unchecked_t num_symlinks;
55218 + atomic_unchecked_t num_locks;
55219 + atomic_unchecked_t num_acl_get;
55220 + atomic_unchecked_t num_acl_set;
55221 } cifs_stats;
55222 #ifdef CONFIG_CIFS_SMB2
55223 struct {
55224 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
55225 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
55226 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
55227 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
55228 } smb2_stats;
55229 #endif /* CONFIG_CIFS_SMB2 */
55230 } stats;
55231 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
55232 }
55233
55234 #ifdef CONFIG_CIFS_STATS
55235 -#define cifs_stats_inc atomic_inc
55236 +#define cifs_stats_inc atomic_inc_unchecked
55237
55238 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
55239 unsigned int bytes)
55240 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
55241 /* Various Debug counters */
55242 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
55243 #ifdef CONFIG_CIFS_STATS2
55244 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
55245 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
55246 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
55247 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
55248 #endif
55249 GLOBAL_EXTERN atomic_t smBufAllocCount;
55250 GLOBAL_EXTERN atomic_t midCount;
55251 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
55252 index 7ddddf2..2e12dbc 100644
55253 --- a/fs/cifs/file.c
55254 +++ b/fs/cifs/file.c
55255 @@ -1900,10 +1900,14 @@ static int cifs_writepages(struct address_space *mapping,
55256 index = mapping->writeback_index; /* Start from prev offset */
55257 end = -1;
55258 } else {
55259 - index = wbc->range_start >> PAGE_CACHE_SHIFT;
55260 - end = wbc->range_end >> PAGE_CACHE_SHIFT;
55261 - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
55262 + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
55263 range_whole = true;
55264 + index = 0;
55265 + end = ULONG_MAX;
55266 + } else {
55267 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
55268 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
55269 + }
55270 scanned = true;
55271 }
55272 retry:
55273 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
55274 index 477e53b..7a32216 100644
55275 --- a/fs/cifs/link.c
55276 +++ b/fs/cifs/link.c
55277 @@ -620,7 +620,7 @@ symlink_exit:
55278
55279 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
55280 {
55281 - char *p = nd_get_link(nd);
55282 + const char *p = nd_get_link(nd);
55283 if (!IS_ERR(p))
55284 kfree(p);
55285 }
55286 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
55287 index 138a011..cf9e13a 100644
55288 --- a/fs/cifs/misc.c
55289 +++ b/fs/cifs/misc.c
55290 @@ -170,7 +170,7 @@ cifs_buf_get(void)
55291 memset(ret_buf, 0, buf_size + 3);
55292 atomic_inc(&bufAllocCount);
55293 #ifdef CONFIG_CIFS_STATS2
55294 - atomic_inc(&totBufAllocCount);
55295 + atomic_inc_unchecked(&totBufAllocCount);
55296 #endif /* CONFIG_CIFS_STATS2 */
55297 }
55298
55299 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
55300 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
55301 atomic_inc(&smBufAllocCount);
55302 #ifdef CONFIG_CIFS_STATS2
55303 - atomic_inc(&totSmBufAllocCount);
55304 + atomic_inc_unchecked(&totSmBufAllocCount);
55305 #endif /* CONFIG_CIFS_STATS2 */
55306
55307 }
55308 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
55309 index e50554b..c011413 100644
55310 --- a/fs/cifs/smb1ops.c
55311 +++ b/fs/cifs/smb1ops.c
55312 @@ -609,27 +609,27 @@ static void
55313 cifs_clear_stats(struct cifs_tcon *tcon)
55314 {
55315 #ifdef CONFIG_CIFS_STATS
55316 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
55317 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
55318 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
55319 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55320 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
55321 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
55322 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55323 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
55324 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
55325 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
55326 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
55327 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
55328 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
55329 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
55330 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
55331 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
55332 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
55333 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
55334 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
55335 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
55336 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
55337 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
55338 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
55339 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
55340 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55341 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
55342 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
55343 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55344 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
55345 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
55346 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
55347 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
55348 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
55349 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
55350 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
55351 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
55352 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
55353 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
55354 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
55355 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
55356 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
55357 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
55358 #endif
55359 }
55360
55361 @@ -638,36 +638,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55362 {
55363 #ifdef CONFIG_CIFS_STATS
55364 seq_printf(m, " Oplocks breaks: %d",
55365 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
55366 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
55367 seq_printf(m, "\nReads: %d Bytes: %llu",
55368 - atomic_read(&tcon->stats.cifs_stats.num_reads),
55369 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
55370 (long long)(tcon->bytes_read));
55371 seq_printf(m, "\nWrites: %d Bytes: %llu",
55372 - atomic_read(&tcon->stats.cifs_stats.num_writes),
55373 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
55374 (long long)(tcon->bytes_written));
55375 seq_printf(m, "\nFlushes: %d",
55376 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
55377 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
55378 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
55379 - atomic_read(&tcon->stats.cifs_stats.num_locks),
55380 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
55381 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
55382 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
55383 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
55384 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
55385 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
55386 - atomic_read(&tcon->stats.cifs_stats.num_opens),
55387 - atomic_read(&tcon->stats.cifs_stats.num_closes),
55388 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
55389 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
55390 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
55391 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
55392 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
55393 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
55394 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
55395 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
55396 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
55397 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
55398 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
55399 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
55400 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
55401 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
55402 seq_printf(m, "\nRenames: %d T2 Renames %d",
55403 - atomic_read(&tcon->stats.cifs_stats.num_renames),
55404 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
55405 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
55406 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
55407 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
55408 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
55409 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
55410 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
55411 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
55412 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
55413 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
55414 #endif
55415 }
55416
55417 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
55418 index 861b332..5506392 100644
55419 --- a/fs/cifs/smb2ops.c
55420 +++ b/fs/cifs/smb2ops.c
55421 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
55422 #ifdef CONFIG_CIFS_STATS
55423 int i;
55424 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
55425 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55426 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55427 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55428 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55429 }
55430 #endif
55431 }
55432 @@ -311,65 +311,65 @@ static void
55433 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55434 {
55435 #ifdef CONFIG_CIFS_STATS
55436 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55437 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55438 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55439 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55440 seq_printf(m, "\nNegotiates: %d sent %d failed",
55441 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
55442 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
55443 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
55444 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
55445 seq_printf(m, "\nSessionSetups: %d sent %d failed",
55446 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
55447 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
55448 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
55449 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
55450 seq_printf(m, "\nLogoffs: %d sent %d failed",
55451 - atomic_read(&sent[SMB2_LOGOFF_HE]),
55452 - atomic_read(&failed[SMB2_LOGOFF_HE]));
55453 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
55454 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
55455 seq_printf(m, "\nTreeConnects: %d sent %d failed",
55456 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
55457 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
55458 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
55459 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
55460 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
55461 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
55462 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
55463 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
55464 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
55465 seq_printf(m, "\nCreates: %d sent %d failed",
55466 - atomic_read(&sent[SMB2_CREATE_HE]),
55467 - atomic_read(&failed[SMB2_CREATE_HE]));
55468 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
55469 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
55470 seq_printf(m, "\nCloses: %d sent %d failed",
55471 - atomic_read(&sent[SMB2_CLOSE_HE]),
55472 - atomic_read(&failed[SMB2_CLOSE_HE]));
55473 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
55474 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
55475 seq_printf(m, "\nFlushes: %d sent %d failed",
55476 - atomic_read(&sent[SMB2_FLUSH_HE]),
55477 - atomic_read(&failed[SMB2_FLUSH_HE]));
55478 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
55479 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
55480 seq_printf(m, "\nReads: %d sent %d failed",
55481 - atomic_read(&sent[SMB2_READ_HE]),
55482 - atomic_read(&failed[SMB2_READ_HE]));
55483 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
55484 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
55485 seq_printf(m, "\nWrites: %d sent %d failed",
55486 - atomic_read(&sent[SMB2_WRITE_HE]),
55487 - atomic_read(&failed[SMB2_WRITE_HE]));
55488 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
55489 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
55490 seq_printf(m, "\nLocks: %d sent %d failed",
55491 - atomic_read(&sent[SMB2_LOCK_HE]),
55492 - atomic_read(&failed[SMB2_LOCK_HE]));
55493 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
55494 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
55495 seq_printf(m, "\nIOCTLs: %d sent %d failed",
55496 - atomic_read(&sent[SMB2_IOCTL_HE]),
55497 - atomic_read(&failed[SMB2_IOCTL_HE]));
55498 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
55499 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
55500 seq_printf(m, "\nCancels: %d sent %d failed",
55501 - atomic_read(&sent[SMB2_CANCEL_HE]),
55502 - atomic_read(&failed[SMB2_CANCEL_HE]));
55503 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
55504 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
55505 seq_printf(m, "\nEchos: %d sent %d failed",
55506 - atomic_read(&sent[SMB2_ECHO_HE]),
55507 - atomic_read(&failed[SMB2_ECHO_HE]));
55508 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
55509 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
55510 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
55511 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
55512 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
55513 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
55514 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
55515 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
55516 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
55517 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
55518 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
55519 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
55520 seq_printf(m, "\nQueryInfos: %d sent %d failed",
55521 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
55522 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
55523 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
55524 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
55525 seq_printf(m, "\nSetInfos: %d sent %d failed",
55526 - atomic_read(&sent[SMB2_SET_INFO_HE]),
55527 - atomic_read(&failed[SMB2_SET_INFO_HE]));
55528 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
55529 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
55530 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
55531 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
55532 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
55533 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
55534 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
55535 #endif
55536 }
55537
55538 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
55539 index edccb52..16bc6db 100644
55540 --- a/fs/cifs/smb2pdu.c
55541 +++ b/fs/cifs/smb2pdu.c
55542 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
55543 default:
55544 cifs_dbg(VFS, "info level %u isn't supported\n",
55545 srch_inf->info_level);
55546 - rc = -EINVAL;
55547 - goto qdir_exit;
55548 + return -EINVAL;
55549 }
55550
55551 req->FileIndex = cpu_to_le32(index);
55552 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
55553 index 1da168c..8bc7ff6 100644
55554 --- a/fs/coda/cache.c
55555 +++ b/fs/coda/cache.c
55556 @@ -24,7 +24,7 @@
55557 #include "coda_linux.h"
55558 #include "coda_cache.h"
55559
55560 -static atomic_t permission_epoch = ATOMIC_INIT(0);
55561 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
55562
55563 /* replace or extend an acl cache hit */
55564 void coda_cache_enter(struct inode *inode, int mask)
55565 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
55566 struct coda_inode_info *cii = ITOC(inode);
55567
55568 spin_lock(&cii->c_lock);
55569 - cii->c_cached_epoch = atomic_read(&permission_epoch);
55570 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
55571 if (!uid_eq(cii->c_uid, current_fsuid())) {
55572 cii->c_uid = current_fsuid();
55573 cii->c_cached_perm = mask;
55574 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
55575 {
55576 struct coda_inode_info *cii = ITOC(inode);
55577 spin_lock(&cii->c_lock);
55578 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
55579 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
55580 spin_unlock(&cii->c_lock);
55581 }
55582
55583 /* remove all acl caches */
55584 void coda_cache_clear_all(struct super_block *sb)
55585 {
55586 - atomic_inc(&permission_epoch);
55587 + atomic_inc_unchecked(&permission_epoch);
55588 }
55589
55590
55591 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
55592 spin_lock(&cii->c_lock);
55593 hit = (mask & cii->c_cached_perm) == mask &&
55594 uid_eq(cii->c_uid, current_fsuid()) &&
55595 - cii->c_cached_epoch == atomic_read(&permission_epoch);
55596 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
55597 spin_unlock(&cii->c_lock);
55598
55599 return hit;
55600 diff --git a/fs/compat.c b/fs/compat.c
55601 index 6af20de..fec3fbb 100644
55602 --- a/fs/compat.c
55603 +++ b/fs/compat.c
55604 @@ -54,7 +54,7 @@
55605 #include <asm/ioctls.h>
55606 #include "internal.h"
55607
55608 -int compat_log = 1;
55609 +int compat_log = 0;
55610
55611 int compat_printk(const char *fmt, ...)
55612 {
55613 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
55614
55615 set_fs(KERNEL_DS);
55616 /* The __user pointer cast is valid because of the set_fs() */
55617 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
55618 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
55619 set_fs(oldfs);
55620 /* truncating is ok because it's a user address */
55621 if (!ret)
55622 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
55623 goto out;
55624
55625 ret = -EINVAL;
55626 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
55627 + if (nr_segs > UIO_MAXIOV)
55628 goto out;
55629 if (nr_segs > fast_segs) {
55630 ret = -ENOMEM;
55631 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
55632 struct compat_readdir_callback {
55633 struct dir_context ctx;
55634 struct compat_old_linux_dirent __user *dirent;
55635 + struct file * file;
55636 int result;
55637 };
55638
55639 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
55640 buf->result = -EOVERFLOW;
55641 return -EOVERFLOW;
55642 }
55643 +
55644 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55645 + return 0;
55646 +
55647 buf->result++;
55648 dirent = buf->dirent;
55649 if (!access_ok(VERIFY_WRITE, dirent,
55650 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
55651 if (!f.file)
55652 return -EBADF;
55653
55654 + buf.file = f.file;
55655 error = iterate_dir(f.file, &buf.ctx);
55656 if (buf.result)
55657 error = buf.result;
55658 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
55659 struct dir_context ctx;
55660 struct compat_linux_dirent __user *current_dir;
55661 struct compat_linux_dirent __user *previous;
55662 + struct file * file;
55663 int count;
55664 int error;
55665 };
55666 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
55667 buf->error = -EOVERFLOW;
55668 return -EOVERFLOW;
55669 }
55670 +
55671 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55672 + return 0;
55673 +
55674 dirent = buf->previous;
55675 if (dirent) {
55676 if (__put_user(offset, &dirent->d_off))
55677 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55678 if (!f.file)
55679 return -EBADF;
55680
55681 + buf.file = f.file;
55682 error = iterate_dir(f.file, &buf.ctx);
55683 if (error >= 0)
55684 error = buf.error;
55685 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
55686 struct dir_context ctx;
55687 struct linux_dirent64 __user *current_dir;
55688 struct linux_dirent64 __user *previous;
55689 + struct file * file;
55690 int count;
55691 int error;
55692 };
55693 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
55694 buf->error = -EINVAL; /* only used if we fail.. */
55695 if (reclen > buf->count)
55696 return -EINVAL;
55697 +
55698 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55699 + return 0;
55700 +
55701 dirent = buf->previous;
55702
55703 if (dirent) {
55704 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
55705 if (!f.file)
55706 return -EBADF;
55707
55708 + buf.file = f.file;
55709 error = iterate_dir(f.file, &buf.ctx);
55710 if (error >= 0)
55711 error = buf.error;
55712 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
55713 index a81147e..20bf2b5 100644
55714 --- a/fs/compat_binfmt_elf.c
55715 +++ b/fs/compat_binfmt_elf.c
55716 @@ -30,11 +30,13 @@
55717 #undef elf_phdr
55718 #undef elf_shdr
55719 #undef elf_note
55720 +#undef elf_dyn
55721 #undef elf_addr_t
55722 #define elfhdr elf32_hdr
55723 #define elf_phdr elf32_phdr
55724 #define elf_shdr elf32_shdr
55725 #define elf_note elf32_note
55726 +#define elf_dyn Elf32_Dyn
55727 #define elf_addr_t Elf32_Addr
55728
55729 /*
55730 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
55731 index 5d19acf..9ab093b 100644
55732 --- a/fs/compat_ioctl.c
55733 +++ b/fs/compat_ioctl.c
55734 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
55735 return -EFAULT;
55736 if (__get_user(udata, &ss32->iomem_base))
55737 return -EFAULT;
55738 - ss.iomem_base = compat_ptr(udata);
55739 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
55740 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
55741 __get_user(ss.port_high, &ss32->port_high))
55742 return -EFAULT;
55743 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
55744 for (i = 0; i < nmsgs; i++) {
55745 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
55746 return -EFAULT;
55747 - if (get_user(datap, &umsgs[i].buf) ||
55748 - put_user(compat_ptr(datap), &tmsgs[i].buf))
55749 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
55750 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
55751 return -EFAULT;
55752 }
55753 return sys_ioctl(fd, cmd, (unsigned long)tdata);
55754 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
55755 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
55756 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
55757 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
55758 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55759 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55760 return -EFAULT;
55761
55762 return ioctl_preallocate(file, p);
55763 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
55764 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
55765 {
55766 unsigned int a, b;
55767 - a = *(unsigned int *)p;
55768 - b = *(unsigned int *)q;
55769 + a = *(const unsigned int *)p;
55770 + b = *(const unsigned int *)q;
55771 if (a > b)
55772 return 1;
55773 if (a < b)
55774 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
55775 index 511d415..319d0e5 100644
55776 --- a/fs/configfs/dir.c
55777 +++ b/fs/configfs/dir.c
55778 @@ -1558,7 +1558,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55779 }
55780 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
55781 struct configfs_dirent *next;
55782 - const char *name;
55783 + const unsigned char * name;
55784 + char d_name[sizeof(next->s_dentry->d_iname)];
55785 int len;
55786 struct inode *inode = NULL;
55787
55788 @@ -1567,7 +1568,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55789 continue;
55790
55791 name = configfs_get_name(next);
55792 - len = strlen(name);
55793 + if (next->s_dentry && name == next->s_dentry->d_iname) {
55794 + len = next->s_dentry->d_name.len;
55795 + memcpy(d_name, name, len);
55796 + name = d_name;
55797 + } else
55798 + len = strlen(name);
55799
55800 /*
55801 * We'll have a dentry and an inode for
55802 diff --git a/fs/coredump.c b/fs/coredump.c
55803 index 9bdeca1..2a9b08d 100644
55804 --- a/fs/coredump.c
55805 +++ b/fs/coredump.c
55806 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
55807 struct pipe_inode_info *pipe = file->private_data;
55808
55809 pipe_lock(pipe);
55810 - pipe->readers++;
55811 - pipe->writers--;
55812 + atomic_inc(&pipe->readers);
55813 + atomic_dec(&pipe->writers);
55814 wake_up_interruptible_sync(&pipe->wait);
55815 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55816 pipe_unlock(pipe);
55817 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
55818 * We actually want wait_event_freezable() but then we need
55819 * to clear TIF_SIGPENDING and improve dump_interrupted().
55820 */
55821 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
55822 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
55823
55824 pipe_lock(pipe);
55825 - pipe->readers--;
55826 - pipe->writers++;
55827 + atomic_dec(&pipe->readers);
55828 + atomic_inc(&pipe->writers);
55829 pipe_unlock(pipe);
55830 }
55831
55832 @@ -499,7 +499,9 @@ void do_coredump(siginfo_t *siginfo)
55833 struct files_struct *displaced;
55834 bool need_nonrelative = false;
55835 bool core_dumped = false;
55836 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55837 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55838 + long signr = siginfo->si_signo;
55839 + int dumpable;
55840 struct coredump_params cprm = {
55841 .siginfo = siginfo,
55842 .regs = signal_pt_regs(),
55843 @@ -512,12 +514,17 @@ void do_coredump(siginfo_t *siginfo)
55844 .mm_flags = mm->flags,
55845 };
55846
55847 - audit_core_dumps(siginfo->si_signo);
55848 + audit_core_dumps(signr);
55849 +
55850 + dumpable = __get_dumpable(cprm.mm_flags);
55851 +
55852 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55853 + gr_handle_brute_attach(dumpable);
55854
55855 binfmt = mm->binfmt;
55856 if (!binfmt || !binfmt->core_dump)
55857 goto fail;
55858 - if (!__get_dumpable(cprm.mm_flags))
55859 + if (!dumpable)
55860 goto fail;
55861
55862 cred = prepare_creds();
55863 @@ -536,7 +543,7 @@ void do_coredump(siginfo_t *siginfo)
55864 need_nonrelative = true;
55865 }
55866
55867 - retval = coredump_wait(siginfo->si_signo, &core_state);
55868 + retval = coredump_wait(signr, &core_state);
55869 if (retval < 0)
55870 goto fail_creds;
55871
55872 @@ -579,7 +586,7 @@ void do_coredump(siginfo_t *siginfo)
55873 }
55874 cprm.limit = RLIM_INFINITY;
55875
55876 - dump_count = atomic_inc_return(&core_dump_count);
55877 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55878 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55879 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55880 task_tgid_vnr(current), current->comm);
55881 @@ -611,6 +618,8 @@ void do_coredump(siginfo_t *siginfo)
55882 } else {
55883 struct inode *inode;
55884
55885 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55886 +
55887 if (cprm.limit < binfmt->min_coredump)
55888 goto fail_unlock;
55889
55890 @@ -669,7 +678,7 @@ close_fail:
55891 filp_close(cprm.file, NULL);
55892 fail_dropcount:
55893 if (ispipe)
55894 - atomic_dec(&core_dump_count);
55895 + atomic_dec_unchecked(&core_dump_count);
55896 fail_unlock:
55897 kfree(cn.corename);
55898 coredump_finish(mm, core_dumped);
55899 @@ -689,7 +698,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55900 {
55901 return !dump_interrupted() &&
55902 access_ok(VERIFY_READ, addr, nr) &&
55903 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55904 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55905 }
55906 EXPORT_SYMBOL(dump_write);
55907
55908 diff --git a/fs/dcache.c b/fs/dcache.c
55909 index 89f9671..d2dce57 100644
55910 --- a/fs/dcache.c
55911 +++ b/fs/dcache.c
55912 @@ -1570,7 +1570,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
55913 */
55914 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
55915 if (name->len > DNAME_INLINE_LEN-1) {
55916 - dname = kmalloc(name->len + 1, GFP_KERNEL);
55917 + dname = kmalloc(round_up(name->len + 1, sizeof(unsigned long)), GFP_KERNEL);
55918 if (!dname) {
55919 kmem_cache_free(dentry_cache, dentry);
55920 return NULL;
55921 @@ -2893,6 +2893,7 @@ static int prepend_path(const struct path *path,
55922 restart:
55923 bptr = *buffer;
55924 blen = *buflen;
55925 + error = 0;
55926 dentry = path->dentry;
55927 vfsmnt = path->mnt;
55928 mnt = real_mount(vfsmnt);
55929 @@ -3432,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
55930 mempages -= reserve;
55931
55932 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55933 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55934 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55935 + SLAB_NO_SANITIZE, NULL);
55936
55937 dcache_init();
55938 inode_init();
55939 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55940 index c7c83ff..bda9461 100644
55941 --- a/fs/debugfs/inode.c
55942 +++ b/fs/debugfs/inode.c
55943 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55944 */
55945 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55946 {
55947 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55948 + return __create_file(name, S_IFDIR | S_IRWXU,
55949 +#else
55950 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55951 +#endif
55952 parent, NULL, NULL);
55953 }
55954 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55955 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55956 index 67e9b63..a9adb68 100644
55957 --- a/fs/ecryptfs/inode.c
55958 +++ b/fs/ecryptfs/inode.c
55959 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55960 old_fs = get_fs();
55961 set_fs(get_ds());
55962 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55963 - (char __user *)lower_buf,
55964 + (char __force_user *)lower_buf,
55965 PATH_MAX);
55966 set_fs(old_fs);
55967 if (rc < 0)
55968 @@ -706,7 +706,7 @@ out:
55969 static void
55970 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55971 {
55972 - char *buf = nd_get_link(nd);
55973 + const char *buf = nd_get_link(nd);
55974 if (!IS_ERR(buf)) {
55975 /* Free the char* */
55976 kfree(buf);
55977 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55978 index e4141f2..d8263e8 100644
55979 --- a/fs/ecryptfs/miscdev.c
55980 +++ b/fs/ecryptfs/miscdev.c
55981 @@ -304,7 +304,7 @@ check_list:
55982 goto out_unlock_msg_ctx;
55983 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55984 if (msg_ctx->msg) {
55985 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55986 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55987 goto out_unlock_msg_ctx;
55988 i += packet_length_size;
55989 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55990 diff --git a/fs/exec.c b/fs/exec.c
55991 index bb8afc1..2f5087e 100644
55992 --- a/fs/exec.c
55993 +++ b/fs/exec.c
55994 @@ -55,8 +55,20 @@
55995 #include <linux/pipe_fs_i.h>
55996 #include <linux/oom.h>
55997 #include <linux/compat.h>
55998 +#include <linux/random.h>
55999 +#include <linux/seq_file.h>
56000 +#include <linux/coredump.h>
56001 +#include <linux/mman.h>
56002 +
56003 +#ifdef CONFIG_PAX_REFCOUNT
56004 +#include <linux/kallsyms.h>
56005 +#include <linux/kdebug.h>
56006 +#endif
56007 +
56008 +#include <trace/events/fs.h>
56009
56010 #include <asm/uaccess.h>
56011 +#include <asm/sections.h>
56012 #include <asm/mmu_context.h>
56013 #include <asm/tlb.h>
56014
56015 @@ -66,19 +78,34 @@
56016
56017 #include <trace/events/sched.h>
56018
56019 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
56020 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
56021 +{
56022 + 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");
56023 +}
56024 +#endif
56025 +
56026 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
56027 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
56028 +EXPORT_SYMBOL(pax_set_initial_flags_func);
56029 +#endif
56030 +
56031 int suid_dumpable = 0;
56032
56033 static LIST_HEAD(formats);
56034 static DEFINE_RWLOCK(binfmt_lock);
56035
56036 +extern int gr_process_kernel_exec_ban(void);
56037 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
56038 +
56039 void __register_binfmt(struct linux_binfmt * fmt, int insert)
56040 {
56041 BUG_ON(!fmt);
56042 if (WARN_ON(!fmt->load_binary))
56043 return;
56044 write_lock(&binfmt_lock);
56045 - insert ? list_add(&fmt->lh, &formats) :
56046 - list_add_tail(&fmt->lh, &formats);
56047 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
56048 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
56049 write_unlock(&binfmt_lock);
56050 }
56051
56052 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
56053 void unregister_binfmt(struct linux_binfmt * fmt)
56054 {
56055 write_lock(&binfmt_lock);
56056 - list_del(&fmt->lh);
56057 + pax_list_del((struct list_head *)&fmt->lh);
56058 write_unlock(&binfmt_lock);
56059 }
56060
56061 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
56062 int write)
56063 {
56064 struct page *page;
56065 - int ret;
56066
56067 -#ifdef CONFIG_STACK_GROWSUP
56068 - if (write) {
56069 - ret = expand_downwards(bprm->vma, pos);
56070 - if (ret < 0)
56071 - return NULL;
56072 - }
56073 -#endif
56074 - ret = get_user_pages(current, bprm->mm, pos,
56075 - 1, write, 1, &page, NULL);
56076 - if (ret <= 0)
56077 + if (0 > expand_downwards(bprm->vma, pos))
56078 + return NULL;
56079 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
56080 return NULL;
56081
56082 if (write) {
56083 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
56084 if (size <= ARG_MAX)
56085 return page;
56086
56087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56088 + // only allow 512KB for argv+env on suid/sgid binaries
56089 + // to prevent easy ASLR exhaustion
56090 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
56091 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
56092 + (size > (512 * 1024))) {
56093 + put_page(page);
56094 + return NULL;
56095 + }
56096 +#endif
56097 +
56098 /*
56099 * Limit to 1/4-th the stack size for the argv+env strings.
56100 * This ensures that:
56101 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
56102 vma->vm_end = STACK_TOP_MAX;
56103 vma->vm_start = vma->vm_end - PAGE_SIZE;
56104 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
56105 +
56106 +#ifdef CONFIG_PAX_SEGMEXEC
56107 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
56108 +#endif
56109 +
56110 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
56111 INIT_LIST_HEAD(&vma->anon_vma_chain);
56112
56113 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
56114 mm->stack_vm = mm->total_vm = 1;
56115 up_write(&mm->mmap_sem);
56116 bprm->p = vma->vm_end - sizeof(void *);
56117 +
56118 +#ifdef CONFIG_PAX_RANDUSTACK
56119 + if (randomize_va_space)
56120 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
56121 +#endif
56122 +
56123 return 0;
56124 err:
56125 up_write(&mm->mmap_sem);
56126 @@ -399,7 +440,7 @@ struct user_arg_ptr {
56127 } ptr;
56128 };
56129
56130 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
56131 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
56132 {
56133 const char __user *native;
56134
56135 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
56136 compat_uptr_t compat;
56137
56138 if (get_user(compat, argv.ptr.compat + nr))
56139 - return ERR_PTR(-EFAULT);
56140 + return (const char __force_user *)ERR_PTR(-EFAULT);
56141
56142 return compat_ptr(compat);
56143 }
56144 #endif
56145
56146 if (get_user(native, argv.ptr.native + nr))
56147 - return ERR_PTR(-EFAULT);
56148 + return (const char __force_user *)ERR_PTR(-EFAULT);
56149
56150 return native;
56151 }
56152 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
56153 if (!p)
56154 break;
56155
56156 - if (IS_ERR(p))
56157 + if (IS_ERR((const char __force_kernel *)p))
56158 return -EFAULT;
56159
56160 if (i >= max)
56161 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
56162
56163 ret = -EFAULT;
56164 str = get_user_arg_ptr(argv, argc);
56165 - if (IS_ERR(str))
56166 + if (IS_ERR((const char __force_kernel *)str))
56167 goto out;
56168
56169 len = strnlen_user(str, MAX_ARG_STRLEN);
56170 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
56171 int r;
56172 mm_segment_t oldfs = get_fs();
56173 struct user_arg_ptr argv = {
56174 - .ptr.native = (const char __user *const __user *)__argv,
56175 + .ptr.native = (const char __force_user * const __force_user *)__argv,
56176 };
56177
56178 set_fs(KERNEL_DS);
56179 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
56180 unsigned long new_end = old_end - shift;
56181 struct mmu_gather tlb;
56182
56183 - BUG_ON(new_start > new_end);
56184 + if (new_start >= new_end || new_start < mmap_min_addr)
56185 + return -ENOMEM;
56186
56187 /*
56188 * ensure there are no vmas between where we want to go
56189 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
56190 if (vma != find_vma(mm, new_start))
56191 return -EFAULT;
56192
56193 +#ifdef CONFIG_PAX_SEGMEXEC
56194 + BUG_ON(pax_find_mirror_vma(vma));
56195 +#endif
56196 +
56197 /*
56198 * cover the whole range: [new_start, old_end)
56199 */
56200 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
56201 stack_top = arch_align_stack(stack_top);
56202 stack_top = PAGE_ALIGN(stack_top);
56203
56204 - if (unlikely(stack_top < mmap_min_addr) ||
56205 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
56206 - return -ENOMEM;
56207 -
56208 stack_shift = vma->vm_end - stack_top;
56209
56210 bprm->p -= stack_shift;
56211 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
56212 bprm->exec -= stack_shift;
56213
56214 down_write(&mm->mmap_sem);
56215 +
56216 + /* Move stack pages down in memory. */
56217 + if (stack_shift) {
56218 + ret = shift_arg_pages(vma, stack_shift);
56219 + if (ret)
56220 + goto out_unlock;
56221 + }
56222 +
56223 vm_flags = VM_STACK_FLAGS;
56224
56225 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56226 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
56227 + vm_flags &= ~VM_EXEC;
56228 +
56229 +#ifdef CONFIG_PAX_MPROTECT
56230 + if (mm->pax_flags & MF_PAX_MPROTECT)
56231 + vm_flags &= ~VM_MAYEXEC;
56232 +#endif
56233 +
56234 + }
56235 +#endif
56236 +
56237 /*
56238 * Adjust stack execute permissions; explicitly enable for
56239 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
56240 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
56241 goto out_unlock;
56242 BUG_ON(prev != vma);
56243
56244 - /* Move stack pages down in memory. */
56245 - if (stack_shift) {
56246 - ret = shift_arg_pages(vma, stack_shift);
56247 - if (ret)
56248 - goto out_unlock;
56249 - }
56250 -
56251 /* mprotect_fixup is overkill to remove the temporary stack flags */
56252 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
56253
56254 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
56255 #endif
56256 current->mm->start_stack = bprm->p;
56257 ret = expand_stack(vma, stack_base);
56258 +
56259 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
56260 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
56261 + unsigned long size;
56262 + vm_flags_t vm_flags;
56263 +
56264 + size = STACK_TOP - vma->vm_end;
56265 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
56266 +
56267 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
56268 +
56269 +#ifdef CONFIG_X86
56270 + if (!ret) {
56271 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
56272 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
56273 + }
56274 +#endif
56275 +
56276 + }
56277 +#endif
56278 +
56279 if (ret)
56280 ret = -EFAULT;
56281
56282 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
56283
56284 fsnotify_open(file);
56285
56286 + trace_open_exec(name);
56287 +
56288 err = deny_write_access(file);
56289 if (err)
56290 goto exit;
56291 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
56292 old_fs = get_fs();
56293 set_fs(get_ds());
56294 /* The cast to a user pointer is valid due to the set_fs() */
56295 - result = vfs_read(file, (void __user *)addr, count, &pos);
56296 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
56297 set_fs(old_fs);
56298 return result;
56299 }
56300 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
56301 }
56302 rcu_read_unlock();
56303
56304 - if (p->fs->users > n_fs) {
56305 + if (atomic_read(&p->fs->users) > n_fs) {
56306 bprm->unsafe |= LSM_UNSAFE_SHARE;
56307 } else {
56308 res = -EAGAIN;
56309 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
56310 return ret;
56311 }
56312
56313 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56314 +static DEFINE_PER_CPU(u64, exec_counter);
56315 +static int __init init_exec_counters(void)
56316 +{
56317 + unsigned int cpu;
56318 +
56319 + for_each_possible_cpu(cpu) {
56320 + per_cpu(exec_counter, cpu) = (u64)cpu;
56321 + }
56322 +
56323 + return 0;
56324 +}
56325 +early_initcall(init_exec_counters);
56326 +static inline void increment_exec_counter(void)
56327 +{
56328 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
56329 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
56330 +}
56331 +#else
56332 +static inline void increment_exec_counter(void) {}
56333 +#endif
56334 +
56335 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
56336 + struct user_arg_ptr argv);
56337 +
56338 /*
56339 * sys_execve() executes a new program.
56340 */
56341 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
56342 struct user_arg_ptr argv,
56343 struct user_arg_ptr envp)
56344 {
56345 +#ifdef CONFIG_GRKERNSEC
56346 + struct file *old_exec_file;
56347 + struct acl_subject_label *old_acl;
56348 + struct rlimit old_rlim[RLIM_NLIMITS];
56349 +#endif
56350 struct linux_binprm *bprm;
56351 struct file *file;
56352 struct files_struct *displaced;
56353 bool clear_in_exec;
56354 int retval;
56355
56356 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
56357 +
56358 /*
56359 * We move the actual failure in case of RLIMIT_NPROC excess from
56360 * set*uid() to execve() because too many poorly written programs
56361 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
56362 if (IS_ERR(file))
56363 goto out_unmark;
56364
56365 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
56366 + retval = -EPERM;
56367 + goto out_file;
56368 + }
56369 +
56370 sched_exec();
56371
56372 bprm->file = file;
56373 bprm->filename = filename;
56374 bprm->interp = filename;
56375
56376 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
56377 + retval = -EACCES;
56378 + goto out_file;
56379 + }
56380 +
56381 retval = bprm_mm_init(bprm);
56382 if (retval)
56383 goto out_file;
56384 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
56385 if (retval < 0)
56386 goto out;
56387
56388 +#ifdef CONFIG_GRKERNSEC
56389 + old_acl = current->acl;
56390 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
56391 + old_exec_file = current->exec_file;
56392 + get_file(file);
56393 + current->exec_file = file;
56394 +#endif
56395 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56396 + /* limit suid stack to 8MB
56397 + * we saved the old limits above and will restore them if this exec fails
56398 + */
56399 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
56400 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
56401 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
56402 +#endif
56403 +
56404 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
56405 + retval = -EPERM;
56406 + goto out_fail;
56407 + }
56408 +
56409 + if (!gr_tpe_allow(file)) {
56410 + retval = -EACCES;
56411 + goto out_fail;
56412 + }
56413 +
56414 + if (gr_check_crash_exec(file)) {
56415 + retval = -EACCES;
56416 + goto out_fail;
56417 + }
56418 +
56419 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
56420 + bprm->unsafe);
56421 + if (retval < 0)
56422 + goto out_fail;
56423 +
56424 retval = copy_strings_kernel(1, &bprm->filename, bprm);
56425 if (retval < 0)
56426 - goto out;
56427 + goto out_fail;
56428
56429 bprm->exec = bprm->p;
56430 retval = copy_strings(bprm->envc, envp, bprm);
56431 if (retval < 0)
56432 - goto out;
56433 + goto out_fail;
56434
56435 retval = copy_strings(bprm->argc, argv, bprm);
56436 if (retval < 0)
56437 - goto out;
56438 + goto out_fail;
56439 +
56440 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
56441 +
56442 + gr_handle_exec_args(bprm, argv);
56443
56444 retval = exec_binprm(bprm);
56445 if (retval < 0)
56446 - goto out;
56447 + goto out_fail;
56448 +#ifdef CONFIG_GRKERNSEC
56449 + if (old_exec_file)
56450 + fput(old_exec_file);
56451 +#endif
56452
56453 /* execve succeeded */
56454 +
56455 + increment_exec_counter();
56456 current->fs->in_exec = 0;
56457 current->in_execve = 0;
56458 acct_update_integrals(current);
56459 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
56460 put_files_struct(displaced);
56461 return retval;
56462
56463 +out_fail:
56464 +#ifdef CONFIG_GRKERNSEC
56465 + current->acl = old_acl;
56466 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
56467 + fput(current->exec_file);
56468 + current->exec_file = old_exec_file;
56469 +#endif
56470 +
56471 out:
56472 if (bprm->mm) {
56473 acct_arg_size(bprm, 0);
56474 @@ -1706,3 +1880,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
56475 return error;
56476 }
56477 #endif
56478 +
56479 +int pax_check_flags(unsigned long *flags)
56480 +{
56481 + int retval = 0;
56482 +
56483 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
56484 + if (*flags & MF_PAX_SEGMEXEC)
56485 + {
56486 + *flags &= ~MF_PAX_SEGMEXEC;
56487 + retval = -EINVAL;
56488 + }
56489 +#endif
56490 +
56491 + if ((*flags & MF_PAX_PAGEEXEC)
56492 +
56493 +#ifdef CONFIG_PAX_PAGEEXEC
56494 + && (*flags & MF_PAX_SEGMEXEC)
56495 +#endif
56496 +
56497 + )
56498 + {
56499 + *flags &= ~MF_PAX_PAGEEXEC;
56500 + retval = -EINVAL;
56501 + }
56502 +
56503 + if ((*flags & MF_PAX_MPROTECT)
56504 +
56505 +#ifdef CONFIG_PAX_MPROTECT
56506 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56507 +#endif
56508 +
56509 + )
56510 + {
56511 + *flags &= ~MF_PAX_MPROTECT;
56512 + retval = -EINVAL;
56513 + }
56514 +
56515 + if ((*flags & MF_PAX_EMUTRAMP)
56516 +
56517 +#ifdef CONFIG_PAX_EMUTRAMP
56518 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56519 +#endif
56520 +
56521 + )
56522 + {
56523 + *flags &= ~MF_PAX_EMUTRAMP;
56524 + retval = -EINVAL;
56525 + }
56526 +
56527 + return retval;
56528 +}
56529 +
56530 +EXPORT_SYMBOL(pax_check_flags);
56531 +
56532 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56533 +char *pax_get_path(const struct path *path, char *buf, int buflen)
56534 +{
56535 + char *pathname = d_path(path, buf, buflen);
56536 +
56537 + if (IS_ERR(pathname))
56538 + goto toolong;
56539 +
56540 + pathname = mangle_path(buf, pathname, "\t\n\\");
56541 + if (!pathname)
56542 + goto toolong;
56543 +
56544 + *pathname = 0;
56545 + return buf;
56546 +
56547 +toolong:
56548 + return "<path too long>";
56549 +}
56550 +EXPORT_SYMBOL(pax_get_path);
56551 +
56552 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
56553 +{
56554 + struct task_struct *tsk = current;
56555 + struct mm_struct *mm = current->mm;
56556 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
56557 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
56558 + char *path_exec = NULL;
56559 + char *path_fault = NULL;
56560 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
56561 + siginfo_t info = { };
56562 +
56563 + if (buffer_exec && buffer_fault) {
56564 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
56565 +
56566 + down_read(&mm->mmap_sem);
56567 + vma = mm->mmap;
56568 + while (vma && (!vma_exec || !vma_fault)) {
56569 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
56570 + vma_exec = vma;
56571 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
56572 + vma_fault = vma;
56573 + vma = vma->vm_next;
56574 + }
56575 + if (vma_exec)
56576 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
56577 + if (vma_fault) {
56578 + start = vma_fault->vm_start;
56579 + end = vma_fault->vm_end;
56580 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
56581 + if (vma_fault->vm_file)
56582 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
56583 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
56584 + path_fault = "<heap>";
56585 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
56586 + path_fault = "<stack>";
56587 + else
56588 + path_fault = "<anonymous mapping>";
56589 + }
56590 + up_read(&mm->mmap_sem);
56591 + }
56592 + if (tsk->signal->curr_ip)
56593 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
56594 + else
56595 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
56596 + 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),
56597 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
56598 + free_page((unsigned long)buffer_exec);
56599 + free_page((unsigned long)buffer_fault);
56600 + pax_report_insns(regs, pc, sp);
56601 + info.si_signo = SIGKILL;
56602 + info.si_errno = 0;
56603 + info.si_code = SI_KERNEL;
56604 + info.si_pid = 0;
56605 + info.si_uid = 0;
56606 + do_coredump(&info);
56607 +}
56608 +#endif
56609 +
56610 +#ifdef CONFIG_PAX_REFCOUNT
56611 +void pax_report_refcount_overflow(struct pt_regs *regs)
56612 +{
56613 + if (current->signal->curr_ip)
56614 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
56615 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
56616 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56617 + else
56618 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
56619 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56620 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
56621 + preempt_disable();
56622 + show_regs(regs);
56623 + preempt_enable();
56624 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
56625 +}
56626 +#endif
56627 +
56628 +#ifdef CONFIG_PAX_USERCOPY
56629 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
56630 +static noinline int check_stack_object(const void *obj, unsigned long len)
56631 +{
56632 + const void * const stack = task_stack_page(current);
56633 + const void * const stackend = stack + THREAD_SIZE;
56634 +
56635 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56636 + const void *frame = NULL;
56637 + const void *oldframe;
56638 +#endif
56639 +
56640 + if (obj + len < obj)
56641 + return -1;
56642 +
56643 + if (obj + len <= stack || stackend <= obj)
56644 + return 0;
56645 +
56646 + if (obj < stack || stackend < obj + len)
56647 + return -1;
56648 +
56649 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56650 + oldframe = __builtin_frame_address(1);
56651 + if (oldframe)
56652 + frame = __builtin_frame_address(2);
56653 + /*
56654 + low ----------------------------------------------> high
56655 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
56656 + ^----------------^
56657 + allow copies only within here
56658 + */
56659 + while (stack <= frame && frame < stackend) {
56660 + /* if obj + len extends past the last frame, this
56661 + check won't pass and the next frame will be 0,
56662 + causing us to bail out and correctly report
56663 + the copy as invalid
56664 + */
56665 + if (obj + len <= frame)
56666 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
56667 + oldframe = frame;
56668 + frame = *(const void * const *)frame;
56669 + }
56670 + return -1;
56671 +#else
56672 + return 1;
56673 +#endif
56674 +}
56675 +
56676 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
56677 +{
56678 + if (current->signal->curr_ip)
56679 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56680 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56681 + else
56682 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56683 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56684 + dump_stack();
56685 + gr_handle_kernel_exploit();
56686 + do_group_exit(SIGKILL);
56687 +}
56688 +#endif
56689 +
56690 +#ifdef CONFIG_PAX_USERCOPY
56691 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
56692 +{
56693 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
56694 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
56695 +#ifdef CONFIG_MODULES
56696 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
56697 +#else
56698 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
56699 +#endif
56700 +
56701 +#else
56702 + unsigned long textlow = (unsigned long)_stext;
56703 + unsigned long texthigh = (unsigned long)_etext;
56704 +
56705 +#ifdef CONFIG_X86_64
56706 + /* check against linear mapping as well */
56707 + if (high > (unsigned long)__va(__pa(textlow)) &&
56708 + low <= (unsigned long)__va(__pa(texthigh)))
56709 + return true;
56710 +#endif
56711 +
56712 +#endif
56713 +
56714 + if (high <= textlow || low > texthigh)
56715 + return false;
56716 + else
56717 + return true;
56718 +}
56719 +#endif
56720 +
56721 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
56722 +{
56723 +
56724 +#ifdef CONFIG_PAX_USERCOPY
56725 + const char *type;
56726 +
56727 + if (!n)
56728 + return;
56729 +
56730 + type = check_heap_object(ptr, n);
56731 + if (!type) {
56732 + int ret = check_stack_object(ptr, n);
56733 + if (ret == 1 || ret == 2)
56734 + return;
56735 + if (ret == 0) {
56736 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
56737 + type = "<kernel text>";
56738 + else
56739 + return;
56740 + } else
56741 + type = "<process stack>";
56742 + }
56743 +
56744 + pax_report_usercopy(ptr, n, to_user, type);
56745 +#endif
56746 +
56747 +}
56748 +EXPORT_SYMBOL(__check_object_size);
56749 +
56750 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
56751 +void pax_track_stack(void)
56752 +{
56753 + unsigned long sp = (unsigned long)&sp;
56754 + if (sp < current_thread_info()->lowest_stack &&
56755 + sp > (unsigned long)task_stack_page(current))
56756 + current_thread_info()->lowest_stack = sp;
56757 +}
56758 +EXPORT_SYMBOL(pax_track_stack);
56759 +#endif
56760 +
56761 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
56762 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
56763 +{
56764 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
56765 + dump_stack();
56766 + do_group_exit(SIGKILL);
56767 +}
56768 +EXPORT_SYMBOL(report_size_overflow);
56769 +#endif
56770 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
56771 index 9f9992b..8b59411 100644
56772 --- a/fs/ext2/balloc.c
56773 +++ b/fs/ext2/balloc.c
56774 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
56775
56776 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56777 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56778 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56779 + if (free_blocks < root_blocks + 1 &&
56780 !uid_eq(sbi->s_resuid, current_fsuid()) &&
56781 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56782 - !in_group_p (sbi->s_resgid))) {
56783 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56784 return 0;
56785 }
56786 return 1;
56787 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
56788 index 2d7557d..14e38f94 100644
56789 --- a/fs/ext2/xattr.c
56790 +++ b/fs/ext2/xattr.c
56791 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
56792 struct buffer_head *bh = NULL;
56793 struct ext2_xattr_entry *entry;
56794 char *end;
56795 - size_t rest = buffer_size;
56796 + size_t rest = buffer_size, total_size = 0;
56797 int error;
56798
56799 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
56800 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
56801 buffer += size;
56802 }
56803 rest -= size;
56804 + total_size += size;
56805 }
56806 }
56807 - error = buffer_size - rest; /* total size */
56808 + error = total_size;
56809
56810 cleanup:
56811 brelse(bh);
56812 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
56813 index 22548f5..41521d8 100644
56814 --- a/fs/ext3/balloc.c
56815 +++ b/fs/ext3/balloc.c
56816 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
56817
56818 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56819 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56820 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56821 + if (free_blocks < root_blocks + 1 &&
56822 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
56823 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56824 - !in_group_p (sbi->s_resgid))) {
56825 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56826 return 0;
56827 }
56828 return 1;
56829 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
56830 index b1fc963..881228c 100644
56831 --- a/fs/ext3/xattr.c
56832 +++ b/fs/ext3/xattr.c
56833 @@ -330,7 +330,7 @@ static int
56834 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56835 char *buffer, size_t buffer_size)
56836 {
56837 - size_t rest = buffer_size;
56838 + size_t rest = buffer_size, total_size = 0;
56839
56840 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
56841 const struct xattr_handler *handler =
56842 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56843 buffer += size;
56844 }
56845 rest -= size;
56846 + total_size += size;
56847 }
56848 }
56849 - return buffer_size - rest;
56850 + return total_size;
56851 }
56852
56853 static int
56854 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56855 index dc5d572..4c21f8e 100644
56856 --- a/fs/ext4/balloc.c
56857 +++ b/fs/ext4/balloc.c
56858 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56859 /* Hm, nope. Are (enough) root reserved clusters available? */
56860 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56861 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56862 - capable(CAP_SYS_RESOURCE) ||
56863 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56864 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56865 + capable_nolog(CAP_SYS_RESOURCE)) {
56866
56867 if (free_clusters >= (nclusters + dirty_clusters +
56868 resv_clusters))
56869 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56870 index 745faaa..a072816 100644
56871 --- a/fs/ext4/ext4.h
56872 +++ b/fs/ext4/ext4.h
56873 @@ -1266,19 +1266,19 @@ struct ext4_sb_info {
56874 unsigned long s_mb_last_start;
56875
56876 /* stats for buddy allocator */
56877 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56878 - atomic_t s_bal_success; /* we found long enough chunks */
56879 - atomic_t s_bal_allocated; /* in blocks */
56880 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56881 - atomic_t s_bal_goals; /* goal hits */
56882 - atomic_t s_bal_breaks; /* too long searches */
56883 - atomic_t s_bal_2orders; /* 2^order hits */
56884 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56885 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56886 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56887 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56888 + atomic_unchecked_t s_bal_goals; /* goal hits */
56889 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56890 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56891 spinlock_t s_bal_lock;
56892 unsigned long s_mb_buddies_generated;
56893 unsigned long long s_mb_generation_time;
56894 - atomic_t s_mb_lost_chunks;
56895 - atomic_t s_mb_preallocated;
56896 - atomic_t s_mb_discarded;
56897 + atomic_unchecked_t s_mb_lost_chunks;
56898 + atomic_unchecked_t s_mb_preallocated;
56899 + atomic_unchecked_t s_mb_discarded;
56900 atomic_t s_lock_busy;
56901
56902 /* locality groups */
56903 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56904 index 04a5c75..09894fa 100644
56905 --- a/fs/ext4/mballoc.c
56906 +++ b/fs/ext4/mballoc.c
56907 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56908 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56909
56910 if (EXT4_SB(sb)->s_mb_stats)
56911 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56912 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56913
56914 break;
56915 }
56916 @@ -2189,7 +2189,7 @@ repeat:
56917 ac->ac_status = AC_STATUS_CONTINUE;
56918 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56919 cr = 3;
56920 - atomic_inc(&sbi->s_mb_lost_chunks);
56921 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56922 goto repeat;
56923 }
56924 }
56925 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
56926 if (sbi->s_mb_stats) {
56927 ext4_msg(sb, KERN_INFO,
56928 "mballoc: %u blocks %u reqs (%u success)",
56929 - atomic_read(&sbi->s_bal_allocated),
56930 - atomic_read(&sbi->s_bal_reqs),
56931 - atomic_read(&sbi->s_bal_success));
56932 + atomic_read_unchecked(&sbi->s_bal_allocated),
56933 + atomic_read_unchecked(&sbi->s_bal_reqs),
56934 + atomic_read_unchecked(&sbi->s_bal_success));
56935 ext4_msg(sb, KERN_INFO,
56936 "mballoc: %u extents scanned, %u goal hits, "
56937 "%u 2^N hits, %u breaks, %u lost",
56938 - atomic_read(&sbi->s_bal_ex_scanned),
56939 - atomic_read(&sbi->s_bal_goals),
56940 - atomic_read(&sbi->s_bal_2orders),
56941 - atomic_read(&sbi->s_bal_breaks),
56942 - atomic_read(&sbi->s_mb_lost_chunks));
56943 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56944 + atomic_read_unchecked(&sbi->s_bal_goals),
56945 + atomic_read_unchecked(&sbi->s_bal_2orders),
56946 + atomic_read_unchecked(&sbi->s_bal_breaks),
56947 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56948 ext4_msg(sb, KERN_INFO,
56949 "mballoc: %lu generated and it took %Lu",
56950 sbi->s_mb_buddies_generated,
56951 sbi->s_mb_generation_time);
56952 ext4_msg(sb, KERN_INFO,
56953 "mballoc: %u preallocated, %u discarded",
56954 - atomic_read(&sbi->s_mb_preallocated),
56955 - atomic_read(&sbi->s_mb_discarded));
56956 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56957 + atomic_read_unchecked(&sbi->s_mb_discarded));
56958 }
56959
56960 free_percpu(sbi->s_locality_groups);
56961 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56962 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56963
56964 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56965 - atomic_inc(&sbi->s_bal_reqs);
56966 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56967 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56968 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56969 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56970 - atomic_inc(&sbi->s_bal_success);
56971 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56972 + atomic_inc_unchecked(&sbi->s_bal_success);
56973 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56974 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56975 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56976 - atomic_inc(&sbi->s_bal_goals);
56977 + atomic_inc_unchecked(&sbi->s_bal_goals);
56978 if (ac->ac_found > sbi->s_mb_max_to_scan)
56979 - atomic_inc(&sbi->s_bal_breaks);
56980 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56981 }
56982
56983 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56984 @@ -3583,7 +3583,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56985 trace_ext4_mb_new_inode_pa(ac, pa);
56986
56987 ext4_mb_use_inode_pa(ac, pa);
56988 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56989 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56990
56991 ei = EXT4_I(ac->ac_inode);
56992 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56993 @@ -3643,7 +3643,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56994 trace_ext4_mb_new_group_pa(ac, pa);
56995
56996 ext4_mb_use_group_pa(ac, pa);
56997 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56998 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56999
57000 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
57001 lg = ac->ac_lg;
57002 @@ -3732,7 +3732,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
57003 * from the bitmap and continue.
57004 */
57005 }
57006 - atomic_add(free, &sbi->s_mb_discarded);
57007 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
57008
57009 return err;
57010 }
57011 @@ -3750,7 +3750,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
57012 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
57013 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
57014 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
57015 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
57016 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
57017 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
57018
57019 return 0;
57020 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
57021 index 214461e..3614c89 100644
57022 --- a/fs/ext4/mmp.c
57023 +++ b/fs/ext4/mmp.c
57024 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
57025 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
57026 const char *function, unsigned int line, const char *msg)
57027 {
57028 - __ext4_warning(sb, function, line, msg);
57029 + __ext4_warning(sb, function, line, "%s", msg);
57030 __ext4_warning(sb, function, line,
57031 "MMP failure info: last update time: %llu, last update "
57032 "node: %s, last update device: %s\n",
57033 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
57034 index b947e0a..c102e3b 100644
57035 --- a/fs/ext4/super.c
57036 +++ b/fs/ext4/super.c
57037 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
57038 }
57039
57040 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
57041 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
57042 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
57043 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
57044
57045 #ifdef CONFIG_QUOTA
57046 @@ -2431,7 +2431,7 @@ struct ext4_attr {
57047 int offset;
57048 int deprecated_val;
57049 } u;
57050 -};
57051 +} __do_const;
57052
57053 static int parse_strtoull(const char *buf,
57054 unsigned long long max, unsigned long long *value)
57055 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
57056 index 1423c48..9c0c6dc 100644
57057 --- a/fs/ext4/xattr.c
57058 +++ b/fs/ext4/xattr.c
57059 @@ -381,7 +381,7 @@ static int
57060 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
57061 char *buffer, size_t buffer_size)
57062 {
57063 - size_t rest = buffer_size;
57064 + size_t rest = buffer_size, total_size = 0;
57065
57066 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
57067 const struct xattr_handler *handler =
57068 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
57069 buffer += size;
57070 }
57071 rest -= size;
57072 + total_size += size;
57073 }
57074 }
57075 - return buffer_size - rest;
57076 + return total_size;
57077 }
57078
57079 static int
57080 diff --git a/fs/fcntl.c b/fs/fcntl.c
57081 index 65343c3..9969dcf 100644
57082 --- a/fs/fcntl.c
57083 +++ b/fs/fcntl.c
57084 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
57085 if (err)
57086 return err;
57087
57088 + if (gr_handle_chroot_fowner(pid, type))
57089 + return -ENOENT;
57090 + if (gr_check_protected_task_fowner(pid, type))
57091 + return -EACCES;
57092 +
57093 f_modown(filp, pid, type, force);
57094 return 0;
57095 }
57096 diff --git a/fs/fhandle.c b/fs/fhandle.c
57097 index 999ff5c..41f4109 100644
57098 --- a/fs/fhandle.c
57099 +++ b/fs/fhandle.c
57100 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
57101 } else
57102 retval = 0;
57103 /* copy the mount id */
57104 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
57105 - sizeof(*mnt_id)) ||
57106 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
57107 copy_to_user(ufh, handle,
57108 sizeof(struct file_handle) + handle_bytes))
57109 retval = -EFAULT;
57110 diff --git a/fs/file.c b/fs/file.c
57111 index 4a78f98..f9a6d25 100644
57112 --- a/fs/file.c
57113 +++ b/fs/file.c
57114 @@ -16,6 +16,7 @@
57115 #include <linux/slab.h>
57116 #include <linux/vmalloc.h>
57117 #include <linux/file.h>
57118 +#include <linux/security.h>
57119 #include <linux/fdtable.h>
57120 #include <linux/bitops.h>
57121 #include <linux/interrupt.h>
57122 @@ -141,7 +142,7 @@ out:
57123 * Return <0 error code on error; 1 on successful completion.
57124 * The files->file_lock should be held on entry, and will be held on exit.
57125 */
57126 -static int expand_fdtable(struct files_struct *files, int nr)
57127 +static int expand_fdtable(struct files_struct *files, unsigned int nr)
57128 __releases(files->file_lock)
57129 __acquires(files->file_lock)
57130 {
57131 @@ -186,7 +187,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
57132 * expanded and execution may have blocked.
57133 * The files->file_lock should be held on entry, and will be held on exit.
57134 */
57135 -static int expand_files(struct files_struct *files, int nr)
57136 +static int expand_files(struct files_struct *files, unsigned int nr)
57137 {
57138 struct fdtable *fdt;
57139
57140 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
57141 if (!file)
57142 return __close_fd(files, fd);
57143
57144 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
57145 if (fd >= rlimit(RLIMIT_NOFILE))
57146 return -EBADF;
57147
57148 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
57149 if (unlikely(oldfd == newfd))
57150 return -EINVAL;
57151
57152 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
57153 if (newfd >= rlimit(RLIMIT_NOFILE))
57154 return -EBADF;
57155
57156 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
57157 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
57158 {
57159 int err;
57160 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
57161 if (from >= rlimit(RLIMIT_NOFILE))
57162 return -EINVAL;
57163 err = alloc_fd(from, flags);
57164 diff --git a/fs/filesystems.c b/fs/filesystems.c
57165 index 92567d9..fcd8cbf 100644
57166 --- a/fs/filesystems.c
57167 +++ b/fs/filesystems.c
57168 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
57169 int len = dot ? dot - name : strlen(name);
57170
57171 fs = __get_fs_type(name, len);
57172 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
57173 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
57174 +#else
57175 if (!fs && (request_module("fs-%.*s", len, name) == 0))
57176 +#endif
57177 fs = __get_fs_type(name, len);
57178
57179 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
57180 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
57181 index d8ac61d..79a36f0 100644
57182 --- a/fs/fs_struct.c
57183 +++ b/fs/fs_struct.c
57184 @@ -4,6 +4,7 @@
57185 #include <linux/path.h>
57186 #include <linux/slab.h>
57187 #include <linux/fs_struct.h>
57188 +#include <linux/grsecurity.h>
57189 #include "internal.h"
57190
57191 /*
57192 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
57193 write_seqcount_begin(&fs->seq);
57194 old_root = fs->root;
57195 fs->root = *path;
57196 + gr_set_chroot_entries(current, path);
57197 write_seqcount_end(&fs->seq);
57198 spin_unlock(&fs->lock);
57199 if (old_root.dentry)
57200 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
57201 int hits = 0;
57202 spin_lock(&fs->lock);
57203 write_seqcount_begin(&fs->seq);
57204 + /* this root replacement is only done by pivot_root,
57205 + leave grsec's chroot tagging alone for this task
57206 + so that a pivoted root isn't treated as a chroot
57207 + */
57208 hits += replace_path(&fs->root, old_root, new_root);
57209 hits += replace_path(&fs->pwd, old_root, new_root);
57210 write_seqcount_end(&fs->seq);
57211 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
57212 task_lock(tsk);
57213 spin_lock(&fs->lock);
57214 tsk->fs = NULL;
57215 - kill = !--fs->users;
57216 + gr_clear_chroot_entries(tsk);
57217 + kill = !atomic_dec_return(&fs->users);
57218 spin_unlock(&fs->lock);
57219 task_unlock(tsk);
57220 if (kill)
57221 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
57222 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
57223 /* We don't need to lock fs - think why ;-) */
57224 if (fs) {
57225 - fs->users = 1;
57226 + atomic_set(&fs->users, 1);
57227 fs->in_exec = 0;
57228 spin_lock_init(&fs->lock);
57229 seqcount_init(&fs->seq);
57230 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
57231 spin_lock(&old->lock);
57232 fs->root = old->root;
57233 path_get(&fs->root);
57234 + /* instead of calling gr_set_chroot_entries here,
57235 + we call it from every caller of this function
57236 + */
57237 fs->pwd = old->pwd;
57238 path_get(&fs->pwd);
57239 spin_unlock(&old->lock);
57240 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
57241
57242 task_lock(current);
57243 spin_lock(&fs->lock);
57244 - kill = !--fs->users;
57245 + kill = !atomic_dec_return(&fs->users);
57246 current->fs = new_fs;
57247 + gr_set_chroot_entries(current, &new_fs->root);
57248 spin_unlock(&fs->lock);
57249 task_unlock(current);
57250
57251 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
57252
57253 int current_umask(void)
57254 {
57255 - return current->fs->umask;
57256 + return current->fs->umask | gr_acl_umask();
57257 }
57258 EXPORT_SYMBOL(current_umask);
57259
57260 /* to be mentioned only in INIT_TASK */
57261 struct fs_struct init_fs = {
57262 - .users = 1,
57263 + .users = ATOMIC_INIT(1),
57264 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
57265 .seq = SEQCNT_ZERO,
57266 .umask = 0022,
57267 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
57268 index b2a86e3..37f425a 100644
57269 --- a/fs/fscache/cookie.c
57270 +++ b/fs/fscache/cookie.c
57271 @@ -19,7 +19,7 @@
57272
57273 struct kmem_cache *fscache_cookie_jar;
57274
57275 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
57276 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
57277
57278 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
57279 static int fscache_alloc_object(struct fscache_cache *cache,
57280 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
57281 parent ? (char *) parent->def->name : "<no-parent>",
57282 def->name, netfs_data);
57283
57284 - fscache_stat(&fscache_n_acquires);
57285 + fscache_stat_unchecked(&fscache_n_acquires);
57286
57287 /* if there's no parent cookie, then we don't create one here either */
57288 if (!parent) {
57289 - fscache_stat(&fscache_n_acquires_null);
57290 + fscache_stat_unchecked(&fscache_n_acquires_null);
57291 _leave(" [no parent]");
57292 return NULL;
57293 }
57294 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
57295 /* allocate and initialise a cookie */
57296 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
57297 if (!cookie) {
57298 - fscache_stat(&fscache_n_acquires_oom);
57299 + fscache_stat_unchecked(&fscache_n_acquires_oom);
57300 _leave(" [ENOMEM]");
57301 return NULL;
57302 }
57303 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57304
57305 switch (cookie->def->type) {
57306 case FSCACHE_COOKIE_TYPE_INDEX:
57307 - fscache_stat(&fscache_n_cookie_index);
57308 + fscache_stat_unchecked(&fscache_n_cookie_index);
57309 break;
57310 case FSCACHE_COOKIE_TYPE_DATAFILE:
57311 - fscache_stat(&fscache_n_cookie_data);
57312 + fscache_stat_unchecked(&fscache_n_cookie_data);
57313 break;
57314 default:
57315 - fscache_stat(&fscache_n_cookie_special);
57316 + fscache_stat_unchecked(&fscache_n_cookie_special);
57317 break;
57318 }
57319
57320 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57321 if (fscache_acquire_non_index_cookie(cookie) < 0) {
57322 atomic_dec(&parent->n_children);
57323 __fscache_cookie_put(cookie);
57324 - fscache_stat(&fscache_n_acquires_nobufs);
57325 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
57326 _leave(" = NULL");
57327 return NULL;
57328 }
57329 }
57330
57331 - fscache_stat(&fscache_n_acquires_ok);
57332 + fscache_stat_unchecked(&fscache_n_acquires_ok);
57333 _leave(" = %p", cookie);
57334 return cookie;
57335 }
57336 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
57337 cache = fscache_select_cache_for_object(cookie->parent);
57338 if (!cache) {
57339 up_read(&fscache_addremove_sem);
57340 - fscache_stat(&fscache_n_acquires_no_cache);
57341 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
57342 _leave(" = -ENOMEDIUM [no cache]");
57343 return -ENOMEDIUM;
57344 }
57345 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
57346 object = cache->ops->alloc_object(cache, cookie);
57347 fscache_stat_d(&fscache_n_cop_alloc_object);
57348 if (IS_ERR(object)) {
57349 - fscache_stat(&fscache_n_object_no_alloc);
57350 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
57351 ret = PTR_ERR(object);
57352 goto error;
57353 }
57354
57355 - fscache_stat(&fscache_n_object_alloc);
57356 + fscache_stat_unchecked(&fscache_n_object_alloc);
57357
57358 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
57359 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
57360
57361 _debug("ALLOC OBJ%x: %s {%lx}",
57362 object->debug_id, cookie->def->name, object->events);
57363 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
57364
57365 _enter("{%s}", cookie->def->name);
57366
57367 - fscache_stat(&fscache_n_invalidates);
57368 + fscache_stat_unchecked(&fscache_n_invalidates);
57369
57370 /* Only permit invalidation of data files. Invalidating an index will
57371 * require the caller to release all its attachments to the tree rooted
57372 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
57373 {
57374 struct fscache_object *object;
57375
57376 - fscache_stat(&fscache_n_updates);
57377 + fscache_stat_unchecked(&fscache_n_updates);
57378
57379 if (!cookie) {
57380 - fscache_stat(&fscache_n_updates_null);
57381 + fscache_stat_unchecked(&fscache_n_updates_null);
57382 _leave(" [no cookie]");
57383 return;
57384 }
57385 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
57386 {
57387 struct fscache_object *object;
57388
57389 - fscache_stat(&fscache_n_relinquishes);
57390 + fscache_stat_unchecked(&fscache_n_relinquishes);
57391 if (retire)
57392 - fscache_stat(&fscache_n_relinquishes_retire);
57393 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
57394
57395 if (!cookie) {
57396 - fscache_stat(&fscache_n_relinquishes_null);
57397 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
57398 _leave(" [no cookie]");
57399 return;
57400 }
57401 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
57402 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
57403 goto inconsistent;
57404
57405 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
57406 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57407
57408 atomic_inc(&cookie->n_active);
57409 if (fscache_submit_op(object, op) < 0)
57410 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
57411 index 4226f66..0fb3f45 100644
57412 --- a/fs/fscache/internal.h
57413 +++ b/fs/fscache/internal.h
57414 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
57415 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
57416 extern int fscache_wait_for_operation_activation(struct fscache_object *,
57417 struct fscache_operation *,
57418 - atomic_t *,
57419 - atomic_t *,
57420 + atomic_unchecked_t *,
57421 + atomic_unchecked_t *,
57422 void (*)(struct fscache_operation *));
57423 extern void fscache_invalidate_writes(struct fscache_cookie *);
57424
57425 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
57426 * stats.c
57427 */
57428 #ifdef CONFIG_FSCACHE_STATS
57429 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57430 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57431 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57432 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57433
57434 -extern atomic_t fscache_n_op_pend;
57435 -extern atomic_t fscache_n_op_run;
57436 -extern atomic_t fscache_n_op_enqueue;
57437 -extern atomic_t fscache_n_op_deferred_release;
57438 -extern atomic_t fscache_n_op_release;
57439 -extern atomic_t fscache_n_op_gc;
57440 -extern atomic_t fscache_n_op_cancelled;
57441 -extern atomic_t fscache_n_op_rejected;
57442 +extern atomic_unchecked_t fscache_n_op_pend;
57443 +extern atomic_unchecked_t fscache_n_op_run;
57444 +extern atomic_unchecked_t fscache_n_op_enqueue;
57445 +extern atomic_unchecked_t fscache_n_op_deferred_release;
57446 +extern atomic_unchecked_t fscache_n_op_release;
57447 +extern atomic_unchecked_t fscache_n_op_gc;
57448 +extern atomic_unchecked_t fscache_n_op_cancelled;
57449 +extern atomic_unchecked_t fscache_n_op_rejected;
57450
57451 -extern atomic_t fscache_n_attr_changed;
57452 -extern atomic_t fscache_n_attr_changed_ok;
57453 -extern atomic_t fscache_n_attr_changed_nobufs;
57454 -extern atomic_t fscache_n_attr_changed_nomem;
57455 -extern atomic_t fscache_n_attr_changed_calls;
57456 +extern atomic_unchecked_t fscache_n_attr_changed;
57457 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
57458 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
57459 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
57460 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
57461
57462 -extern atomic_t fscache_n_allocs;
57463 -extern atomic_t fscache_n_allocs_ok;
57464 -extern atomic_t fscache_n_allocs_wait;
57465 -extern atomic_t fscache_n_allocs_nobufs;
57466 -extern atomic_t fscache_n_allocs_intr;
57467 -extern atomic_t fscache_n_allocs_object_dead;
57468 -extern atomic_t fscache_n_alloc_ops;
57469 -extern atomic_t fscache_n_alloc_op_waits;
57470 +extern atomic_unchecked_t fscache_n_allocs;
57471 +extern atomic_unchecked_t fscache_n_allocs_ok;
57472 +extern atomic_unchecked_t fscache_n_allocs_wait;
57473 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
57474 +extern atomic_unchecked_t fscache_n_allocs_intr;
57475 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
57476 +extern atomic_unchecked_t fscache_n_alloc_ops;
57477 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
57478
57479 -extern atomic_t fscache_n_retrievals;
57480 -extern atomic_t fscache_n_retrievals_ok;
57481 -extern atomic_t fscache_n_retrievals_wait;
57482 -extern atomic_t fscache_n_retrievals_nodata;
57483 -extern atomic_t fscache_n_retrievals_nobufs;
57484 -extern atomic_t fscache_n_retrievals_intr;
57485 -extern atomic_t fscache_n_retrievals_nomem;
57486 -extern atomic_t fscache_n_retrievals_object_dead;
57487 -extern atomic_t fscache_n_retrieval_ops;
57488 -extern atomic_t fscache_n_retrieval_op_waits;
57489 +extern atomic_unchecked_t fscache_n_retrievals;
57490 +extern atomic_unchecked_t fscache_n_retrievals_ok;
57491 +extern atomic_unchecked_t fscache_n_retrievals_wait;
57492 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
57493 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
57494 +extern atomic_unchecked_t fscache_n_retrievals_intr;
57495 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
57496 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
57497 +extern atomic_unchecked_t fscache_n_retrieval_ops;
57498 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
57499
57500 -extern atomic_t fscache_n_stores;
57501 -extern atomic_t fscache_n_stores_ok;
57502 -extern atomic_t fscache_n_stores_again;
57503 -extern atomic_t fscache_n_stores_nobufs;
57504 -extern atomic_t fscache_n_stores_oom;
57505 -extern atomic_t fscache_n_store_ops;
57506 -extern atomic_t fscache_n_store_calls;
57507 -extern atomic_t fscache_n_store_pages;
57508 -extern atomic_t fscache_n_store_radix_deletes;
57509 -extern atomic_t fscache_n_store_pages_over_limit;
57510 +extern atomic_unchecked_t fscache_n_stores;
57511 +extern atomic_unchecked_t fscache_n_stores_ok;
57512 +extern atomic_unchecked_t fscache_n_stores_again;
57513 +extern atomic_unchecked_t fscache_n_stores_nobufs;
57514 +extern atomic_unchecked_t fscache_n_stores_oom;
57515 +extern atomic_unchecked_t fscache_n_store_ops;
57516 +extern atomic_unchecked_t fscache_n_store_calls;
57517 +extern atomic_unchecked_t fscache_n_store_pages;
57518 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
57519 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
57520
57521 -extern atomic_t fscache_n_store_vmscan_not_storing;
57522 -extern atomic_t fscache_n_store_vmscan_gone;
57523 -extern atomic_t fscache_n_store_vmscan_busy;
57524 -extern atomic_t fscache_n_store_vmscan_cancelled;
57525 -extern atomic_t fscache_n_store_vmscan_wait;
57526 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57527 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
57528 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
57529 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57530 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
57531
57532 -extern atomic_t fscache_n_marks;
57533 -extern atomic_t fscache_n_uncaches;
57534 +extern atomic_unchecked_t fscache_n_marks;
57535 +extern atomic_unchecked_t fscache_n_uncaches;
57536
57537 -extern atomic_t fscache_n_acquires;
57538 -extern atomic_t fscache_n_acquires_null;
57539 -extern atomic_t fscache_n_acquires_no_cache;
57540 -extern atomic_t fscache_n_acquires_ok;
57541 -extern atomic_t fscache_n_acquires_nobufs;
57542 -extern atomic_t fscache_n_acquires_oom;
57543 +extern atomic_unchecked_t fscache_n_acquires;
57544 +extern atomic_unchecked_t fscache_n_acquires_null;
57545 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
57546 +extern atomic_unchecked_t fscache_n_acquires_ok;
57547 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
57548 +extern atomic_unchecked_t fscache_n_acquires_oom;
57549
57550 -extern atomic_t fscache_n_invalidates;
57551 -extern atomic_t fscache_n_invalidates_run;
57552 +extern atomic_unchecked_t fscache_n_invalidates;
57553 +extern atomic_unchecked_t fscache_n_invalidates_run;
57554
57555 -extern atomic_t fscache_n_updates;
57556 -extern atomic_t fscache_n_updates_null;
57557 -extern atomic_t fscache_n_updates_run;
57558 +extern atomic_unchecked_t fscache_n_updates;
57559 +extern atomic_unchecked_t fscache_n_updates_null;
57560 +extern atomic_unchecked_t fscache_n_updates_run;
57561
57562 -extern atomic_t fscache_n_relinquishes;
57563 -extern atomic_t fscache_n_relinquishes_null;
57564 -extern atomic_t fscache_n_relinquishes_waitcrt;
57565 -extern atomic_t fscache_n_relinquishes_retire;
57566 +extern atomic_unchecked_t fscache_n_relinquishes;
57567 +extern atomic_unchecked_t fscache_n_relinquishes_null;
57568 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57569 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
57570
57571 -extern atomic_t fscache_n_cookie_index;
57572 -extern atomic_t fscache_n_cookie_data;
57573 -extern atomic_t fscache_n_cookie_special;
57574 +extern atomic_unchecked_t fscache_n_cookie_index;
57575 +extern atomic_unchecked_t fscache_n_cookie_data;
57576 +extern atomic_unchecked_t fscache_n_cookie_special;
57577
57578 -extern atomic_t fscache_n_object_alloc;
57579 -extern atomic_t fscache_n_object_no_alloc;
57580 -extern atomic_t fscache_n_object_lookups;
57581 -extern atomic_t fscache_n_object_lookups_negative;
57582 -extern atomic_t fscache_n_object_lookups_positive;
57583 -extern atomic_t fscache_n_object_lookups_timed_out;
57584 -extern atomic_t fscache_n_object_created;
57585 -extern atomic_t fscache_n_object_avail;
57586 -extern atomic_t fscache_n_object_dead;
57587 +extern atomic_unchecked_t fscache_n_object_alloc;
57588 +extern atomic_unchecked_t fscache_n_object_no_alloc;
57589 +extern atomic_unchecked_t fscache_n_object_lookups;
57590 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
57591 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
57592 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
57593 +extern atomic_unchecked_t fscache_n_object_created;
57594 +extern atomic_unchecked_t fscache_n_object_avail;
57595 +extern atomic_unchecked_t fscache_n_object_dead;
57596
57597 -extern atomic_t fscache_n_checkaux_none;
57598 -extern atomic_t fscache_n_checkaux_okay;
57599 -extern atomic_t fscache_n_checkaux_update;
57600 -extern atomic_t fscache_n_checkaux_obsolete;
57601 +extern atomic_unchecked_t fscache_n_checkaux_none;
57602 +extern atomic_unchecked_t fscache_n_checkaux_okay;
57603 +extern atomic_unchecked_t fscache_n_checkaux_update;
57604 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
57605
57606 extern atomic_t fscache_n_cop_alloc_object;
57607 extern atomic_t fscache_n_cop_lookup_object;
57608 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
57609 atomic_inc(stat);
57610 }
57611
57612 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
57613 +{
57614 + atomic_inc_unchecked(stat);
57615 +}
57616 +
57617 static inline void fscache_stat_d(atomic_t *stat)
57618 {
57619 atomic_dec(stat);
57620 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
57621
57622 #define __fscache_stat(stat) (NULL)
57623 #define fscache_stat(stat) do {} while (0)
57624 +#define fscache_stat_unchecked(stat) do {} while (0)
57625 #define fscache_stat_d(stat) do {} while (0)
57626 #endif
57627
57628 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
57629 index 86d75a6..5f3d7a0 100644
57630 --- a/fs/fscache/object.c
57631 +++ b/fs/fscache/object.c
57632 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57633 _debug("LOOKUP \"%s\" in \"%s\"",
57634 cookie->def->name, object->cache->tag->name);
57635
57636 - fscache_stat(&fscache_n_object_lookups);
57637 + fscache_stat_unchecked(&fscache_n_object_lookups);
57638 fscache_stat(&fscache_n_cop_lookup_object);
57639 ret = object->cache->ops->lookup_object(object);
57640 fscache_stat_d(&fscache_n_cop_lookup_object);
57641 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57642 if (ret == -ETIMEDOUT) {
57643 /* probably stuck behind another object, so move this one to
57644 * the back of the queue */
57645 - fscache_stat(&fscache_n_object_lookups_timed_out);
57646 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
57647 _leave(" [timeout]");
57648 return NO_TRANSIT;
57649 }
57650 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
57651 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
57652
57653 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57654 - fscache_stat(&fscache_n_object_lookups_negative);
57655 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
57656
57657 /* Allow write requests to begin stacking up and read requests to begin
57658 * returning ENODATA.
57659 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
57660 /* if we were still looking up, then we must have a positive lookup
57661 * result, in which case there may be data available */
57662 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57663 - fscache_stat(&fscache_n_object_lookups_positive);
57664 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
57665
57666 /* We do (presumably) have data */
57667 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
57668 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
57669 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
57670 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
57671 } else {
57672 - fscache_stat(&fscache_n_object_created);
57673 + fscache_stat_unchecked(&fscache_n_object_created);
57674 }
57675
57676 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
57677 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
57678 fscache_stat_d(&fscache_n_cop_lookup_complete);
57679
57680 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
57681 - fscache_stat(&fscache_n_object_avail);
57682 + fscache_stat_unchecked(&fscache_n_object_avail);
57683
57684 _leave("");
57685 return transit_to(JUMPSTART_DEPS);
57686 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
57687
57688 /* this just shifts the object release to the work processor */
57689 fscache_put_object(object);
57690 - fscache_stat(&fscache_n_object_dead);
57691 + fscache_stat_unchecked(&fscache_n_object_dead);
57692
57693 _leave("");
57694 return transit_to(OBJECT_DEAD);
57695 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57696 enum fscache_checkaux result;
57697
57698 if (!object->cookie->def->check_aux) {
57699 - fscache_stat(&fscache_n_checkaux_none);
57700 + fscache_stat_unchecked(&fscache_n_checkaux_none);
57701 return FSCACHE_CHECKAUX_OKAY;
57702 }
57703
57704 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57705 switch (result) {
57706 /* entry okay as is */
57707 case FSCACHE_CHECKAUX_OKAY:
57708 - fscache_stat(&fscache_n_checkaux_okay);
57709 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
57710 break;
57711
57712 /* entry requires update */
57713 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
57714 - fscache_stat(&fscache_n_checkaux_update);
57715 + fscache_stat_unchecked(&fscache_n_checkaux_update);
57716 break;
57717
57718 /* entry requires deletion */
57719 case FSCACHE_CHECKAUX_OBSOLETE:
57720 - fscache_stat(&fscache_n_checkaux_obsolete);
57721 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
57722 break;
57723
57724 default:
57725 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
57726 {
57727 const struct fscache_state *s;
57728
57729 - fscache_stat(&fscache_n_invalidates_run);
57730 + fscache_stat_unchecked(&fscache_n_invalidates_run);
57731 fscache_stat(&fscache_n_cop_invalidate_object);
57732 s = _fscache_invalidate_object(object, event);
57733 fscache_stat_d(&fscache_n_cop_invalidate_object);
57734 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
57735 {
57736 _enter("{OBJ%x},%d", object->debug_id, event);
57737
57738 - fscache_stat(&fscache_n_updates_run);
57739 + fscache_stat_unchecked(&fscache_n_updates_run);
57740 fscache_stat(&fscache_n_cop_update_object);
57741 object->cache->ops->update_object(object);
57742 fscache_stat_d(&fscache_n_cop_update_object);
57743 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
57744 index 318071a..379938b 100644
57745 --- a/fs/fscache/operation.c
57746 +++ b/fs/fscache/operation.c
57747 @@ -17,7 +17,7 @@
57748 #include <linux/slab.h>
57749 #include "internal.h"
57750
57751 -atomic_t fscache_op_debug_id;
57752 +atomic_unchecked_t fscache_op_debug_id;
57753 EXPORT_SYMBOL(fscache_op_debug_id);
57754
57755 /**
57756 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
57757 ASSERTCMP(atomic_read(&op->usage), >, 0);
57758 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
57759
57760 - fscache_stat(&fscache_n_op_enqueue);
57761 + fscache_stat_unchecked(&fscache_n_op_enqueue);
57762 switch (op->flags & FSCACHE_OP_TYPE) {
57763 case FSCACHE_OP_ASYNC:
57764 _debug("queue async");
57765 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
57766 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
57767 if (op->processor)
57768 fscache_enqueue_operation(op);
57769 - fscache_stat(&fscache_n_op_run);
57770 + fscache_stat_unchecked(&fscache_n_op_run);
57771 }
57772
57773 /*
57774 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57775 if (object->n_in_progress > 0) {
57776 atomic_inc(&op->usage);
57777 list_add_tail(&op->pend_link, &object->pending_ops);
57778 - fscache_stat(&fscache_n_op_pend);
57779 + fscache_stat_unchecked(&fscache_n_op_pend);
57780 } else if (!list_empty(&object->pending_ops)) {
57781 atomic_inc(&op->usage);
57782 list_add_tail(&op->pend_link, &object->pending_ops);
57783 - fscache_stat(&fscache_n_op_pend);
57784 + fscache_stat_unchecked(&fscache_n_op_pend);
57785 fscache_start_operations(object);
57786 } else {
57787 ASSERTCMP(object->n_in_progress, ==, 0);
57788 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57789 object->n_exclusive++; /* reads and writes must wait */
57790 atomic_inc(&op->usage);
57791 list_add_tail(&op->pend_link, &object->pending_ops);
57792 - fscache_stat(&fscache_n_op_pend);
57793 + fscache_stat_unchecked(&fscache_n_op_pend);
57794 ret = 0;
57795 } else {
57796 /* If we're in any other state, there must have been an I/O
57797 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
57798 if (object->n_exclusive > 0) {
57799 atomic_inc(&op->usage);
57800 list_add_tail(&op->pend_link, &object->pending_ops);
57801 - fscache_stat(&fscache_n_op_pend);
57802 + fscache_stat_unchecked(&fscache_n_op_pend);
57803 } else if (!list_empty(&object->pending_ops)) {
57804 atomic_inc(&op->usage);
57805 list_add_tail(&op->pend_link, &object->pending_ops);
57806 - fscache_stat(&fscache_n_op_pend);
57807 + fscache_stat_unchecked(&fscache_n_op_pend);
57808 fscache_start_operations(object);
57809 } else {
57810 ASSERTCMP(object->n_exclusive, ==, 0);
57811 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
57812 object->n_ops++;
57813 atomic_inc(&op->usage);
57814 list_add_tail(&op->pend_link, &object->pending_ops);
57815 - fscache_stat(&fscache_n_op_pend);
57816 + fscache_stat_unchecked(&fscache_n_op_pend);
57817 ret = 0;
57818 } else if (fscache_object_is_dying(object)) {
57819 - fscache_stat(&fscache_n_op_rejected);
57820 + fscache_stat_unchecked(&fscache_n_op_rejected);
57821 op->state = FSCACHE_OP_ST_CANCELLED;
57822 ret = -ENOBUFS;
57823 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
57824 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
57825 ret = -EBUSY;
57826 if (op->state == FSCACHE_OP_ST_PENDING) {
57827 ASSERT(!list_empty(&op->pend_link));
57828 - fscache_stat(&fscache_n_op_cancelled);
57829 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57830 list_del_init(&op->pend_link);
57831 if (do_cancel)
57832 do_cancel(op);
57833 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
57834 while (!list_empty(&object->pending_ops)) {
57835 op = list_entry(object->pending_ops.next,
57836 struct fscache_operation, pend_link);
57837 - fscache_stat(&fscache_n_op_cancelled);
57838 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57839 list_del_init(&op->pend_link);
57840
57841 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
57842 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
57843 op->state, ==, FSCACHE_OP_ST_CANCELLED);
57844 op->state = FSCACHE_OP_ST_DEAD;
57845
57846 - fscache_stat(&fscache_n_op_release);
57847 + fscache_stat_unchecked(&fscache_n_op_release);
57848
57849 if (op->release) {
57850 op->release(op);
57851 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
57852 * lock, and defer it otherwise */
57853 if (!spin_trylock(&object->lock)) {
57854 _debug("defer put");
57855 - fscache_stat(&fscache_n_op_deferred_release);
57856 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
57857
57858 cache = object->cache;
57859 spin_lock(&cache->op_gc_list_lock);
57860 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
57861
57862 _debug("GC DEFERRED REL OBJ%x OP%x",
57863 object->debug_id, op->debug_id);
57864 - fscache_stat(&fscache_n_op_gc);
57865 + fscache_stat_unchecked(&fscache_n_op_gc);
57866
57867 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57868 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57869 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57870 index 73899c1..ae40c58 100644
57871 --- a/fs/fscache/page.c
57872 +++ b/fs/fscache/page.c
57873 @@ -61,7 +61,7 @@ try_again:
57874 val = radix_tree_lookup(&cookie->stores, page->index);
57875 if (!val) {
57876 rcu_read_unlock();
57877 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57878 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57879 __fscache_uncache_page(cookie, page);
57880 return true;
57881 }
57882 @@ -91,11 +91,11 @@ try_again:
57883 spin_unlock(&cookie->stores_lock);
57884
57885 if (xpage) {
57886 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57887 - fscache_stat(&fscache_n_store_radix_deletes);
57888 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57889 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57890 ASSERTCMP(xpage, ==, page);
57891 } else {
57892 - fscache_stat(&fscache_n_store_vmscan_gone);
57893 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57894 }
57895
57896 wake_up_bit(&cookie->flags, 0);
57897 @@ -110,11 +110,11 @@ page_busy:
57898 * sleeping on memory allocation, so we may need to impose a timeout
57899 * too. */
57900 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
57901 - fscache_stat(&fscache_n_store_vmscan_busy);
57902 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57903 return false;
57904 }
57905
57906 - fscache_stat(&fscache_n_store_vmscan_wait);
57907 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57908 __fscache_wait_on_page_write(cookie, page);
57909 gfp &= ~__GFP_WAIT;
57910 goto try_again;
57911 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57912 FSCACHE_COOKIE_STORING_TAG);
57913 if (!radix_tree_tag_get(&cookie->stores, page->index,
57914 FSCACHE_COOKIE_PENDING_TAG)) {
57915 - fscache_stat(&fscache_n_store_radix_deletes);
57916 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57917 xpage = radix_tree_delete(&cookie->stores, page->index);
57918 }
57919 spin_unlock(&cookie->stores_lock);
57920 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57921
57922 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57923
57924 - fscache_stat(&fscache_n_attr_changed_calls);
57925 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57926
57927 if (fscache_object_is_active(object) &&
57928 fscache_use_cookie(object)) {
57929 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57930
57931 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57932
57933 - fscache_stat(&fscache_n_attr_changed);
57934 + fscache_stat_unchecked(&fscache_n_attr_changed);
57935
57936 op = kzalloc(sizeof(*op), GFP_KERNEL);
57937 if (!op) {
57938 - fscache_stat(&fscache_n_attr_changed_nomem);
57939 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57940 _leave(" = -ENOMEM");
57941 return -ENOMEM;
57942 }
57943 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57944 if (fscache_submit_exclusive_op(object, op) < 0)
57945 goto nobufs;
57946 spin_unlock(&cookie->lock);
57947 - fscache_stat(&fscache_n_attr_changed_ok);
57948 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57949 fscache_put_operation(op);
57950 _leave(" = 0");
57951 return 0;
57952 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57953 nobufs:
57954 spin_unlock(&cookie->lock);
57955 kfree(op);
57956 - fscache_stat(&fscache_n_attr_changed_nobufs);
57957 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57958 _leave(" = %d", -ENOBUFS);
57959 return -ENOBUFS;
57960 }
57961 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57962 /* allocate a retrieval operation and attempt to submit it */
57963 op = kzalloc(sizeof(*op), GFP_NOIO);
57964 if (!op) {
57965 - fscache_stat(&fscache_n_retrievals_nomem);
57966 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57967 return NULL;
57968 }
57969
57970 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57971 return 0;
57972 }
57973
57974 - fscache_stat(&fscache_n_retrievals_wait);
57975 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57976
57977 jif = jiffies;
57978 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57979 fscache_wait_bit_interruptible,
57980 TASK_INTERRUPTIBLE) != 0) {
57981 - fscache_stat(&fscache_n_retrievals_intr);
57982 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57983 _leave(" = -ERESTARTSYS");
57984 return -ERESTARTSYS;
57985 }
57986 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57987 */
57988 int fscache_wait_for_operation_activation(struct fscache_object *object,
57989 struct fscache_operation *op,
57990 - atomic_t *stat_op_waits,
57991 - atomic_t *stat_object_dead,
57992 + atomic_unchecked_t *stat_op_waits,
57993 + atomic_unchecked_t *stat_object_dead,
57994 void (*do_cancel)(struct fscache_operation *))
57995 {
57996 int ret;
57997 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57998
57999 _debug(">>> WT");
58000 if (stat_op_waits)
58001 - fscache_stat(stat_op_waits);
58002 + fscache_stat_unchecked(stat_op_waits);
58003 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
58004 fscache_wait_bit_interruptible,
58005 TASK_INTERRUPTIBLE) != 0) {
58006 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
58007 check_if_dead:
58008 if (op->state == FSCACHE_OP_ST_CANCELLED) {
58009 if (stat_object_dead)
58010 - fscache_stat(stat_object_dead);
58011 + fscache_stat_unchecked(stat_object_dead);
58012 _leave(" = -ENOBUFS [cancelled]");
58013 return -ENOBUFS;
58014 }
58015 @@ -361,7 +361,7 @@ check_if_dead:
58016 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
58017 fscache_cancel_op(op, do_cancel);
58018 if (stat_object_dead)
58019 - fscache_stat(stat_object_dead);
58020 + fscache_stat_unchecked(stat_object_dead);
58021 return -ENOBUFS;
58022 }
58023 return 0;
58024 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
58025
58026 _enter("%p,%p,,,", cookie, page);
58027
58028 - fscache_stat(&fscache_n_retrievals);
58029 + fscache_stat_unchecked(&fscache_n_retrievals);
58030
58031 if (hlist_empty(&cookie->backing_objects))
58032 goto nobufs;
58033 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
58034 goto nobufs_unlock_dec;
58035 spin_unlock(&cookie->lock);
58036
58037 - fscache_stat(&fscache_n_retrieval_ops);
58038 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
58039
58040 /* pin the netfs read context in case we need to do the actual netfs
58041 * read because we've encountered a cache read failure */
58042 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
58043
58044 error:
58045 if (ret == -ENOMEM)
58046 - fscache_stat(&fscache_n_retrievals_nomem);
58047 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
58048 else if (ret == -ERESTARTSYS)
58049 - fscache_stat(&fscache_n_retrievals_intr);
58050 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
58051 else if (ret == -ENODATA)
58052 - fscache_stat(&fscache_n_retrievals_nodata);
58053 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
58054 else if (ret < 0)
58055 - fscache_stat(&fscache_n_retrievals_nobufs);
58056 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
58057 else
58058 - fscache_stat(&fscache_n_retrievals_ok);
58059 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
58060
58061 fscache_put_retrieval(op);
58062 _leave(" = %d", ret);
58063 @@ -480,7 +480,7 @@ nobufs_unlock:
58064 atomic_dec(&cookie->n_active);
58065 kfree(op);
58066 nobufs:
58067 - fscache_stat(&fscache_n_retrievals_nobufs);
58068 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
58069 _leave(" = -ENOBUFS");
58070 return -ENOBUFS;
58071 }
58072 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
58073
58074 _enter("%p,,%d,,,", cookie, *nr_pages);
58075
58076 - fscache_stat(&fscache_n_retrievals);
58077 + fscache_stat_unchecked(&fscache_n_retrievals);
58078
58079 if (hlist_empty(&cookie->backing_objects))
58080 goto nobufs;
58081 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
58082 goto nobufs_unlock_dec;
58083 spin_unlock(&cookie->lock);
58084
58085 - fscache_stat(&fscache_n_retrieval_ops);
58086 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
58087
58088 /* pin the netfs read context in case we need to do the actual netfs
58089 * read because we've encountered a cache read failure */
58090 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
58091
58092 error:
58093 if (ret == -ENOMEM)
58094 - fscache_stat(&fscache_n_retrievals_nomem);
58095 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
58096 else if (ret == -ERESTARTSYS)
58097 - fscache_stat(&fscache_n_retrievals_intr);
58098 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
58099 else if (ret == -ENODATA)
58100 - fscache_stat(&fscache_n_retrievals_nodata);
58101 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
58102 else if (ret < 0)
58103 - fscache_stat(&fscache_n_retrievals_nobufs);
58104 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
58105 else
58106 - fscache_stat(&fscache_n_retrievals_ok);
58107 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
58108
58109 fscache_put_retrieval(op);
58110 _leave(" = %d", ret);
58111 @@ -606,7 +606,7 @@ nobufs_unlock:
58112 atomic_dec(&cookie->n_active);
58113 kfree(op);
58114 nobufs:
58115 - fscache_stat(&fscache_n_retrievals_nobufs);
58116 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
58117 _leave(" = -ENOBUFS");
58118 return -ENOBUFS;
58119 }
58120 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
58121
58122 _enter("%p,%p,,,", cookie, page);
58123
58124 - fscache_stat(&fscache_n_allocs);
58125 + fscache_stat_unchecked(&fscache_n_allocs);
58126
58127 if (hlist_empty(&cookie->backing_objects))
58128 goto nobufs;
58129 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
58130 goto nobufs_unlock;
58131 spin_unlock(&cookie->lock);
58132
58133 - fscache_stat(&fscache_n_alloc_ops);
58134 + fscache_stat_unchecked(&fscache_n_alloc_ops);
58135
58136 ret = fscache_wait_for_operation_activation(
58137 object, &op->op,
58138 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
58139
58140 error:
58141 if (ret == -ERESTARTSYS)
58142 - fscache_stat(&fscache_n_allocs_intr);
58143 + fscache_stat_unchecked(&fscache_n_allocs_intr);
58144 else if (ret < 0)
58145 - fscache_stat(&fscache_n_allocs_nobufs);
58146 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
58147 else
58148 - fscache_stat(&fscache_n_allocs_ok);
58149 + fscache_stat_unchecked(&fscache_n_allocs_ok);
58150
58151 fscache_put_retrieval(op);
58152 _leave(" = %d", ret);
58153 @@ -694,7 +694,7 @@ nobufs_unlock:
58154 atomic_dec(&cookie->n_active);
58155 kfree(op);
58156 nobufs:
58157 - fscache_stat(&fscache_n_allocs_nobufs);
58158 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
58159 _leave(" = -ENOBUFS");
58160 return -ENOBUFS;
58161 }
58162 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
58163
58164 spin_lock(&cookie->stores_lock);
58165
58166 - fscache_stat(&fscache_n_store_calls);
58167 + fscache_stat_unchecked(&fscache_n_store_calls);
58168
58169 /* find a page to store */
58170 page = NULL;
58171 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
58172 page = results[0];
58173 _debug("gang %d [%lx]", n, page->index);
58174 if (page->index > op->store_limit) {
58175 - fscache_stat(&fscache_n_store_pages_over_limit);
58176 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
58177 goto superseded;
58178 }
58179
58180 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
58181 spin_unlock(&cookie->stores_lock);
58182 spin_unlock(&object->lock);
58183
58184 - fscache_stat(&fscache_n_store_pages);
58185 + fscache_stat_unchecked(&fscache_n_store_pages);
58186 fscache_stat(&fscache_n_cop_write_page);
58187 ret = object->cache->ops->write_page(op, page);
58188 fscache_stat_d(&fscache_n_cop_write_page);
58189 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58190 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
58191 ASSERT(PageFsCache(page));
58192
58193 - fscache_stat(&fscache_n_stores);
58194 + fscache_stat_unchecked(&fscache_n_stores);
58195
58196 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
58197 _leave(" = -ENOBUFS [invalidating]");
58198 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58199 spin_unlock(&cookie->stores_lock);
58200 spin_unlock(&object->lock);
58201
58202 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
58203 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
58204 op->store_limit = object->store_limit;
58205
58206 atomic_inc(&cookie->n_active);
58207 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58208
58209 spin_unlock(&cookie->lock);
58210 radix_tree_preload_end();
58211 - fscache_stat(&fscache_n_store_ops);
58212 - fscache_stat(&fscache_n_stores_ok);
58213 + fscache_stat_unchecked(&fscache_n_store_ops);
58214 + fscache_stat_unchecked(&fscache_n_stores_ok);
58215
58216 /* the work queue now carries its own ref on the object */
58217 fscache_put_operation(&op->op);
58218 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58219 return 0;
58220
58221 already_queued:
58222 - fscache_stat(&fscache_n_stores_again);
58223 + fscache_stat_unchecked(&fscache_n_stores_again);
58224 already_pending:
58225 spin_unlock(&cookie->stores_lock);
58226 spin_unlock(&object->lock);
58227 spin_unlock(&cookie->lock);
58228 radix_tree_preload_end();
58229 kfree(op);
58230 - fscache_stat(&fscache_n_stores_ok);
58231 + fscache_stat_unchecked(&fscache_n_stores_ok);
58232 _leave(" = 0");
58233 return 0;
58234
58235 @@ -999,14 +999,14 @@ nobufs:
58236 spin_unlock(&cookie->lock);
58237 radix_tree_preload_end();
58238 kfree(op);
58239 - fscache_stat(&fscache_n_stores_nobufs);
58240 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
58241 _leave(" = -ENOBUFS");
58242 return -ENOBUFS;
58243
58244 nomem_free:
58245 kfree(op);
58246 nomem:
58247 - fscache_stat(&fscache_n_stores_oom);
58248 + fscache_stat_unchecked(&fscache_n_stores_oom);
58249 _leave(" = -ENOMEM");
58250 return -ENOMEM;
58251 }
58252 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
58253 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
58254 ASSERTCMP(page, !=, NULL);
58255
58256 - fscache_stat(&fscache_n_uncaches);
58257 + fscache_stat_unchecked(&fscache_n_uncaches);
58258
58259 /* cache withdrawal may beat us to it */
58260 if (!PageFsCache(page))
58261 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
58262 struct fscache_cookie *cookie = op->op.object->cookie;
58263
58264 #ifdef CONFIG_FSCACHE_STATS
58265 - atomic_inc(&fscache_n_marks);
58266 + atomic_inc_unchecked(&fscache_n_marks);
58267 #endif
58268
58269 _debug("- mark %p{%lx}", page, page->index);
58270 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
58271 index 40d13c7..ddf52b9 100644
58272 --- a/fs/fscache/stats.c
58273 +++ b/fs/fscache/stats.c
58274 @@ -18,99 +18,99 @@
58275 /*
58276 * operation counters
58277 */
58278 -atomic_t fscache_n_op_pend;
58279 -atomic_t fscache_n_op_run;
58280 -atomic_t fscache_n_op_enqueue;
58281 -atomic_t fscache_n_op_requeue;
58282 -atomic_t fscache_n_op_deferred_release;
58283 -atomic_t fscache_n_op_release;
58284 -atomic_t fscache_n_op_gc;
58285 -atomic_t fscache_n_op_cancelled;
58286 -atomic_t fscache_n_op_rejected;
58287 +atomic_unchecked_t fscache_n_op_pend;
58288 +atomic_unchecked_t fscache_n_op_run;
58289 +atomic_unchecked_t fscache_n_op_enqueue;
58290 +atomic_unchecked_t fscache_n_op_requeue;
58291 +atomic_unchecked_t fscache_n_op_deferred_release;
58292 +atomic_unchecked_t fscache_n_op_release;
58293 +atomic_unchecked_t fscache_n_op_gc;
58294 +atomic_unchecked_t fscache_n_op_cancelled;
58295 +atomic_unchecked_t fscache_n_op_rejected;
58296
58297 -atomic_t fscache_n_attr_changed;
58298 -atomic_t fscache_n_attr_changed_ok;
58299 -atomic_t fscache_n_attr_changed_nobufs;
58300 -atomic_t fscache_n_attr_changed_nomem;
58301 -atomic_t fscache_n_attr_changed_calls;
58302 +atomic_unchecked_t fscache_n_attr_changed;
58303 +atomic_unchecked_t fscache_n_attr_changed_ok;
58304 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
58305 +atomic_unchecked_t fscache_n_attr_changed_nomem;
58306 +atomic_unchecked_t fscache_n_attr_changed_calls;
58307
58308 -atomic_t fscache_n_allocs;
58309 -atomic_t fscache_n_allocs_ok;
58310 -atomic_t fscache_n_allocs_wait;
58311 -atomic_t fscache_n_allocs_nobufs;
58312 -atomic_t fscache_n_allocs_intr;
58313 -atomic_t fscache_n_allocs_object_dead;
58314 -atomic_t fscache_n_alloc_ops;
58315 -atomic_t fscache_n_alloc_op_waits;
58316 +atomic_unchecked_t fscache_n_allocs;
58317 +atomic_unchecked_t fscache_n_allocs_ok;
58318 +atomic_unchecked_t fscache_n_allocs_wait;
58319 +atomic_unchecked_t fscache_n_allocs_nobufs;
58320 +atomic_unchecked_t fscache_n_allocs_intr;
58321 +atomic_unchecked_t fscache_n_allocs_object_dead;
58322 +atomic_unchecked_t fscache_n_alloc_ops;
58323 +atomic_unchecked_t fscache_n_alloc_op_waits;
58324
58325 -atomic_t fscache_n_retrievals;
58326 -atomic_t fscache_n_retrievals_ok;
58327 -atomic_t fscache_n_retrievals_wait;
58328 -atomic_t fscache_n_retrievals_nodata;
58329 -atomic_t fscache_n_retrievals_nobufs;
58330 -atomic_t fscache_n_retrievals_intr;
58331 -atomic_t fscache_n_retrievals_nomem;
58332 -atomic_t fscache_n_retrievals_object_dead;
58333 -atomic_t fscache_n_retrieval_ops;
58334 -atomic_t fscache_n_retrieval_op_waits;
58335 +atomic_unchecked_t fscache_n_retrievals;
58336 +atomic_unchecked_t fscache_n_retrievals_ok;
58337 +atomic_unchecked_t fscache_n_retrievals_wait;
58338 +atomic_unchecked_t fscache_n_retrievals_nodata;
58339 +atomic_unchecked_t fscache_n_retrievals_nobufs;
58340 +atomic_unchecked_t fscache_n_retrievals_intr;
58341 +atomic_unchecked_t fscache_n_retrievals_nomem;
58342 +atomic_unchecked_t fscache_n_retrievals_object_dead;
58343 +atomic_unchecked_t fscache_n_retrieval_ops;
58344 +atomic_unchecked_t fscache_n_retrieval_op_waits;
58345
58346 -atomic_t fscache_n_stores;
58347 -atomic_t fscache_n_stores_ok;
58348 -atomic_t fscache_n_stores_again;
58349 -atomic_t fscache_n_stores_nobufs;
58350 -atomic_t fscache_n_stores_oom;
58351 -atomic_t fscache_n_store_ops;
58352 -atomic_t fscache_n_store_calls;
58353 -atomic_t fscache_n_store_pages;
58354 -atomic_t fscache_n_store_radix_deletes;
58355 -atomic_t fscache_n_store_pages_over_limit;
58356 +atomic_unchecked_t fscache_n_stores;
58357 +atomic_unchecked_t fscache_n_stores_ok;
58358 +atomic_unchecked_t fscache_n_stores_again;
58359 +atomic_unchecked_t fscache_n_stores_nobufs;
58360 +atomic_unchecked_t fscache_n_stores_oom;
58361 +atomic_unchecked_t fscache_n_store_ops;
58362 +atomic_unchecked_t fscache_n_store_calls;
58363 +atomic_unchecked_t fscache_n_store_pages;
58364 +atomic_unchecked_t fscache_n_store_radix_deletes;
58365 +atomic_unchecked_t fscache_n_store_pages_over_limit;
58366
58367 -atomic_t fscache_n_store_vmscan_not_storing;
58368 -atomic_t fscache_n_store_vmscan_gone;
58369 -atomic_t fscache_n_store_vmscan_busy;
58370 -atomic_t fscache_n_store_vmscan_cancelled;
58371 -atomic_t fscache_n_store_vmscan_wait;
58372 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
58373 +atomic_unchecked_t fscache_n_store_vmscan_gone;
58374 +atomic_unchecked_t fscache_n_store_vmscan_busy;
58375 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
58376 +atomic_unchecked_t fscache_n_store_vmscan_wait;
58377
58378 -atomic_t fscache_n_marks;
58379 -atomic_t fscache_n_uncaches;
58380 +atomic_unchecked_t fscache_n_marks;
58381 +atomic_unchecked_t fscache_n_uncaches;
58382
58383 -atomic_t fscache_n_acquires;
58384 -atomic_t fscache_n_acquires_null;
58385 -atomic_t fscache_n_acquires_no_cache;
58386 -atomic_t fscache_n_acquires_ok;
58387 -atomic_t fscache_n_acquires_nobufs;
58388 -atomic_t fscache_n_acquires_oom;
58389 +atomic_unchecked_t fscache_n_acquires;
58390 +atomic_unchecked_t fscache_n_acquires_null;
58391 +atomic_unchecked_t fscache_n_acquires_no_cache;
58392 +atomic_unchecked_t fscache_n_acquires_ok;
58393 +atomic_unchecked_t fscache_n_acquires_nobufs;
58394 +atomic_unchecked_t fscache_n_acquires_oom;
58395
58396 -atomic_t fscache_n_invalidates;
58397 -atomic_t fscache_n_invalidates_run;
58398 +atomic_unchecked_t fscache_n_invalidates;
58399 +atomic_unchecked_t fscache_n_invalidates_run;
58400
58401 -atomic_t fscache_n_updates;
58402 -atomic_t fscache_n_updates_null;
58403 -atomic_t fscache_n_updates_run;
58404 +atomic_unchecked_t fscache_n_updates;
58405 +atomic_unchecked_t fscache_n_updates_null;
58406 +atomic_unchecked_t fscache_n_updates_run;
58407
58408 -atomic_t fscache_n_relinquishes;
58409 -atomic_t fscache_n_relinquishes_null;
58410 -atomic_t fscache_n_relinquishes_waitcrt;
58411 -atomic_t fscache_n_relinquishes_retire;
58412 +atomic_unchecked_t fscache_n_relinquishes;
58413 +atomic_unchecked_t fscache_n_relinquishes_null;
58414 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
58415 +atomic_unchecked_t fscache_n_relinquishes_retire;
58416
58417 -atomic_t fscache_n_cookie_index;
58418 -atomic_t fscache_n_cookie_data;
58419 -atomic_t fscache_n_cookie_special;
58420 +atomic_unchecked_t fscache_n_cookie_index;
58421 +atomic_unchecked_t fscache_n_cookie_data;
58422 +atomic_unchecked_t fscache_n_cookie_special;
58423
58424 -atomic_t fscache_n_object_alloc;
58425 -atomic_t fscache_n_object_no_alloc;
58426 -atomic_t fscache_n_object_lookups;
58427 -atomic_t fscache_n_object_lookups_negative;
58428 -atomic_t fscache_n_object_lookups_positive;
58429 -atomic_t fscache_n_object_lookups_timed_out;
58430 -atomic_t fscache_n_object_created;
58431 -atomic_t fscache_n_object_avail;
58432 -atomic_t fscache_n_object_dead;
58433 +atomic_unchecked_t fscache_n_object_alloc;
58434 +atomic_unchecked_t fscache_n_object_no_alloc;
58435 +atomic_unchecked_t fscache_n_object_lookups;
58436 +atomic_unchecked_t fscache_n_object_lookups_negative;
58437 +atomic_unchecked_t fscache_n_object_lookups_positive;
58438 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
58439 +atomic_unchecked_t fscache_n_object_created;
58440 +atomic_unchecked_t fscache_n_object_avail;
58441 +atomic_unchecked_t fscache_n_object_dead;
58442
58443 -atomic_t fscache_n_checkaux_none;
58444 -atomic_t fscache_n_checkaux_okay;
58445 -atomic_t fscache_n_checkaux_update;
58446 -atomic_t fscache_n_checkaux_obsolete;
58447 +atomic_unchecked_t fscache_n_checkaux_none;
58448 +atomic_unchecked_t fscache_n_checkaux_okay;
58449 +atomic_unchecked_t fscache_n_checkaux_update;
58450 +atomic_unchecked_t fscache_n_checkaux_obsolete;
58451
58452 atomic_t fscache_n_cop_alloc_object;
58453 atomic_t fscache_n_cop_lookup_object;
58454 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
58455 seq_puts(m, "FS-Cache statistics\n");
58456
58457 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
58458 - atomic_read(&fscache_n_cookie_index),
58459 - atomic_read(&fscache_n_cookie_data),
58460 - atomic_read(&fscache_n_cookie_special));
58461 + atomic_read_unchecked(&fscache_n_cookie_index),
58462 + atomic_read_unchecked(&fscache_n_cookie_data),
58463 + atomic_read_unchecked(&fscache_n_cookie_special));
58464
58465 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
58466 - atomic_read(&fscache_n_object_alloc),
58467 - atomic_read(&fscache_n_object_no_alloc),
58468 - atomic_read(&fscache_n_object_avail),
58469 - atomic_read(&fscache_n_object_dead));
58470 + atomic_read_unchecked(&fscache_n_object_alloc),
58471 + atomic_read_unchecked(&fscache_n_object_no_alloc),
58472 + atomic_read_unchecked(&fscache_n_object_avail),
58473 + atomic_read_unchecked(&fscache_n_object_dead));
58474 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
58475 - atomic_read(&fscache_n_checkaux_none),
58476 - atomic_read(&fscache_n_checkaux_okay),
58477 - atomic_read(&fscache_n_checkaux_update),
58478 - atomic_read(&fscache_n_checkaux_obsolete));
58479 + atomic_read_unchecked(&fscache_n_checkaux_none),
58480 + atomic_read_unchecked(&fscache_n_checkaux_okay),
58481 + atomic_read_unchecked(&fscache_n_checkaux_update),
58482 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
58483
58484 seq_printf(m, "Pages : mrk=%u unc=%u\n",
58485 - atomic_read(&fscache_n_marks),
58486 - atomic_read(&fscache_n_uncaches));
58487 + atomic_read_unchecked(&fscache_n_marks),
58488 + atomic_read_unchecked(&fscache_n_uncaches));
58489
58490 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
58491 " oom=%u\n",
58492 - atomic_read(&fscache_n_acquires),
58493 - atomic_read(&fscache_n_acquires_null),
58494 - atomic_read(&fscache_n_acquires_no_cache),
58495 - atomic_read(&fscache_n_acquires_ok),
58496 - atomic_read(&fscache_n_acquires_nobufs),
58497 - atomic_read(&fscache_n_acquires_oom));
58498 + atomic_read_unchecked(&fscache_n_acquires),
58499 + atomic_read_unchecked(&fscache_n_acquires_null),
58500 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
58501 + atomic_read_unchecked(&fscache_n_acquires_ok),
58502 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
58503 + atomic_read_unchecked(&fscache_n_acquires_oom));
58504
58505 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
58506 - atomic_read(&fscache_n_object_lookups),
58507 - atomic_read(&fscache_n_object_lookups_negative),
58508 - atomic_read(&fscache_n_object_lookups_positive),
58509 - atomic_read(&fscache_n_object_created),
58510 - atomic_read(&fscache_n_object_lookups_timed_out));
58511 + atomic_read_unchecked(&fscache_n_object_lookups),
58512 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
58513 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
58514 + atomic_read_unchecked(&fscache_n_object_created),
58515 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
58516
58517 seq_printf(m, "Invals : n=%u run=%u\n",
58518 - atomic_read(&fscache_n_invalidates),
58519 - atomic_read(&fscache_n_invalidates_run));
58520 + atomic_read_unchecked(&fscache_n_invalidates),
58521 + atomic_read_unchecked(&fscache_n_invalidates_run));
58522
58523 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
58524 - atomic_read(&fscache_n_updates),
58525 - atomic_read(&fscache_n_updates_null),
58526 - atomic_read(&fscache_n_updates_run));
58527 + atomic_read_unchecked(&fscache_n_updates),
58528 + atomic_read_unchecked(&fscache_n_updates_null),
58529 + atomic_read_unchecked(&fscache_n_updates_run));
58530
58531 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
58532 - atomic_read(&fscache_n_relinquishes),
58533 - atomic_read(&fscache_n_relinquishes_null),
58534 - atomic_read(&fscache_n_relinquishes_waitcrt),
58535 - atomic_read(&fscache_n_relinquishes_retire));
58536 + atomic_read_unchecked(&fscache_n_relinquishes),
58537 + atomic_read_unchecked(&fscache_n_relinquishes_null),
58538 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
58539 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
58540
58541 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
58542 - atomic_read(&fscache_n_attr_changed),
58543 - atomic_read(&fscache_n_attr_changed_ok),
58544 - atomic_read(&fscache_n_attr_changed_nobufs),
58545 - atomic_read(&fscache_n_attr_changed_nomem),
58546 - atomic_read(&fscache_n_attr_changed_calls));
58547 + atomic_read_unchecked(&fscache_n_attr_changed),
58548 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
58549 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
58550 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
58551 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
58552
58553 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
58554 - atomic_read(&fscache_n_allocs),
58555 - atomic_read(&fscache_n_allocs_ok),
58556 - atomic_read(&fscache_n_allocs_wait),
58557 - atomic_read(&fscache_n_allocs_nobufs),
58558 - atomic_read(&fscache_n_allocs_intr));
58559 + atomic_read_unchecked(&fscache_n_allocs),
58560 + atomic_read_unchecked(&fscache_n_allocs_ok),
58561 + atomic_read_unchecked(&fscache_n_allocs_wait),
58562 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
58563 + atomic_read_unchecked(&fscache_n_allocs_intr));
58564 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
58565 - atomic_read(&fscache_n_alloc_ops),
58566 - atomic_read(&fscache_n_alloc_op_waits),
58567 - atomic_read(&fscache_n_allocs_object_dead));
58568 + atomic_read_unchecked(&fscache_n_alloc_ops),
58569 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
58570 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
58571
58572 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
58573 " int=%u oom=%u\n",
58574 - atomic_read(&fscache_n_retrievals),
58575 - atomic_read(&fscache_n_retrievals_ok),
58576 - atomic_read(&fscache_n_retrievals_wait),
58577 - atomic_read(&fscache_n_retrievals_nodata),
58578 - atomic_read(&fscache_n_retrievals_nobufs),
58579 - atomic_read(&fscache_n_retrievals_intr),
58580 - atomic_read(&fscache_n_retrievals_nomem));
58581 + atomic_read_unchecked(&fscache_n_retrievals),
58582 + atomic_read_unchecked(&fscache_n_retrievals_ok),
58583 + atomic_read_unchecked(&fscache_n_retrievals_wait),
58584 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
58585 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
58586 + atomic_read_unchecked(&fscache_n_retrievals_intr),
58587 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
58588 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
58589 - atomic_read(&fscache_n_retrieval_ops),
58590 - atomic_read(&fscache_n_retrieval_op_waits),
58591 - atomic_read(&fscache_n_retrievals_object_dead));
58592 + atomic_read_unchecked(&fscache_n_retrieval_ops),
58593 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
58594 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
58595
58596 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
58597 - atomic_read(&fscache_n_stores),
58598 - atomic_read(&fscache_n_stores_ok),
58599 - atomic_read(&fscache_n_stores_again),
58600 - atomic_read(&fscache_n_stores_nobufs),
58601 - atomic_read(&fscache_n_stores_oom));
58602 + atomic_read_unchecked(&fscache_n_stores),
58603 + atomic_read_unchecked(&fscache_n_stores_ok),
58604 + atomic_read_unchecked(&fscache_n_stores_again),
58605 + atomic_read_unchecked(&fscache_n_stores_nobufs),
58606 + atomic_read_unchecked(&fscache_n_stores_oom));
58607 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
58608 - atomic_read(&fscache_n_store_ops),
58609 - atomic_read(&fscache_n_store_calls),
58610 - atomic_read(&fscache_n_store_pages),
58611 - atomic_read(&fscache_n_store_radix_deletes),
58612 - atomic_read(&fscache_n_store_pages_over_limit));
58613 + atomic_read_unchecked(&fscache_n_store_ops),
58614 + atomic_read_unchecked(&fscache_n_store_calls),
58615 + atomic_read_unchecked(&fscache_n_store_pages),
58616 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
58617 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
58618
58619 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
58620 - atomic_read(&fscache_n_store_vmscan_not_storing),
58621 - atomic_read(&fscache_n_store_vmscan_gone),
58622 - atomic_read(&fscache_n_store_vmscan_busy),
58623 - atomic_read(&fscache_n_store_vmscan_cancelled),
58624 - atomic_read(&fscache_n_store_vmscan_wait));
58625 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
58626 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
58627 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
58628 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
58629 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
58630
58631 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
58632 - atomic_read(&fscache_n_op_pend),
58633 - atomic_read(&fscache_n_op_run),
58634 - atomic_read(&fscache_n_op_enqueue),
58635 - atomic_read(&fscache_n_op_cancelled),
58636 - atomic_read(&fscache_n_op_rejected));
58637 + atomic_read_unchecked(&fscache_n_op_pend),
58638 + atomic_read_unchecked(&fscache_n_op_run),
58639 + atomic_read_unchecked(&fscache_n_op_enqueue),
58640 + atomic_read_unchecked(&fscache_n_op_cancelled),
58641 + atomic_read_unchecked(&fscache_n_op_rejected));
58642 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
58643 - atomic_read(&fscache_n_op_deferred_release),
58644 - atomic_read(&fscache_n_op_release),
58645 - atomic_read(&fscache_n_op_gc));
58646 + atomic_read_unchecked(&fscache_n_op_deferred_release),
58647 + atomic_read_unchecked(&fscache_n_op_release),
58648 + atomic_read_unchecked(&fscache_n_op_gc));
58649
58650 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
58651 atomic_read(&fscache_n_cop_alloc_object),
58652 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
58653 index adbfd66..4b25822 100644
58654 --- a/fs/fuse/cuse.c
58655 +++ b/fs/fuse/cuse.c
58656 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
58657 INIT_LIST_HEAD(&cuse_conntbl[i]);
58658
58659 /* inherit and extend fuse_dev_operations */
58660 - cuse_channel_fops = fuse_dev_operations;
58661 - cuse_channel_fops.owner = THIS_MODULE;
58662 - cuse_channel_fops.open = cuse_channel_open;
58663 - cuse_channel_fops.release = cuse_channel_release;
58664 + pax_open_kernel();
58665 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
58666 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
58667 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
58668 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
58669 + pax_close_kernel();
58670
58671 cuse_class = class_create(THIS_MODULE, "cuse");
58672 if (IS_ERR(cuse_class))
58673 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
58674 index ef74ad5..c9ac759e 100644
58675 --- a/fs/fuse/dev.c
58676 +++ b/fs/fuse/dev.c
58677 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58678 ret = 0;
58679 pipe_lock(pipe);
58680
58681 - if (!pipe->readers) {
58682 + if (!atomic_read(&pipe->readers)) {
58683 send_sig(SIGPIPE, current, 0);
58684 if (!ret)
58685 ret = -EPIPE;
58686 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58687 page_nr++;
58688 ret += buf->len;
58689
58690 - if (pipe->files)
58691 + if (atomic_read(&pipe->files))
58692 do_wakeup = 1;
58693 }
58694
58695 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
58696 index b7989f2..1f72ec4 100644
58697 --- a/fs/fuse/dir.c
58698 +++ b/fs/fuse/dir.c
58699 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
58700 return link;
58701 }
58702
58703 -static void free_link(char *link)
58704 +static void free_link(const char *link)
58705 {
58706 if (!IS_ERR(link))
58707 free_page((unsigned long) link);
58708 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
58709 index 1298766..c964c60 100644
58710 --- a/fs/gfs2/inode.c
58711 +++ b/fs/gfs2/inode.c
58712 @@ -1515,7 +1515,7 @@ out:
58713
58714 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
58715 {
58716 - char *s = nd_get_link(nd);
58717 + const char *s = nd_get_link(nd);
58718 if (!IS_ERR(s))
58719 kfree(s);
58720 }
58721 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
58722 index 2543728..14d7bd4 100644
58723 --- a/fs/hostfs/hostfs_kern.c
58724 +++ b/fs/hostfs/hostfs_kern.c
58725 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
58726
58727 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
58728 {
58729 - char *s = nd_get_link(nd);
58730 + const char *s = nd_get_link(nd);
58731 if (!IS_ERR(s))
58732 __putname(s);
58733 }
58734 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
58735 index d19b30a..ef89c36 100644
58736 --- a/fs/hugetlbfs/inode.c
58737 +++ b/fs/hugetlbfs/inode.c
58738 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58739 struct mm_struct *mm = current->mm;
58740 struct vm_area_struct *vma;
58741 struct hstate *h = hstate_file(file);
58742 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
58743 struct vm_unmapped_area_info info;
58744
58745 if (len & ~huge_page_mask(h))
58746 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58747 return addr;
58748 }
58749
58750 +#ifdef CONFIG_PAX_RANDMMAP
58751 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
58752 +#endif
58753 +
58754 if (addr) {
58755 addr = ALIGN(addr, huge_page_size(h));
58756 vma = find_vma(mm, addr);
58757 - if (TASK_SIZE - len >= addr &&
58758 - (!vma || addr + len <= vma->vm_start))
58759 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
58760 return addr;
58761 }
58762
58763 info.flags = 0;
58764 info.length = len;
58765 info.low_limit = TASK_UNMAPPED_BASE;
58766 +
58767 +#ifdef CONFIG_PAX_RANDMMAP
58768 + if (mm->pax_flags & MF_PAX_RANDMMAP)
58769 + info.low_limit += mm->delta_mmap;
58770 +#endif
58771 +
58772 info.high_limit = TASK_SIZE;
58773 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
58774 info.align_offset = 0;
58775 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
58776 };
58777 MODULE_ALIAS_FS("hugetlbfs");
58778
58779 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58780 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58781
58782 static int can_do_hugetlb_shm(void)
58783 {
58784 diff --git a/fs/inode.c b/fs/inode.c
58785 index b33ba8e..3c79a47 100644
58786 --- a/fs/inode.c
58787 +++ b/fs/inode.c
58788 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
58789
58790 #ifdef CONFIG_SMP
58791 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
58792 - static atomic_t shared_last_ino;
58793 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
58794 + static atomic_unchecked_t shared_last_ino;
58795 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
58796
58797 res = next - LAST_INO_BATCH;
58798 }
58799 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
58800 index 4a6cf28..d3a29d3 100644
58801 --- a/fs/jffs2/erase.c
58802 +++ b/fs/jffs2/erase.c
58803 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
58804 struct jffs2_unknown_node marker = {
58805 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
58806 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58807 - .totlen = cpu_to_je32(c->cleanmarker_size)
58808 + .totlen = cpu_to_je32(c->cleanmarker_size),
58809 + .hdr_crc = cpu_to_je32(0)
58810 };
58811
58812 jffs2_prealloc_raw_node_refs(c, jeb, 1);
58813 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
58814 index a6597d6..41b30ec 100644
58815 --- a/fs/jffs2/wbuf.c
58816 +++ b/fs/jffs2/wbuf.c
58817 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
58818 {
58819 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
58820 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58821 - .totlen = constant_cpu_to_je32(8)
58822 + .totlen = constant_cpu_to_je32(8),
58823 + .hdr_crc = constant_cpu_to_je32(0)
58824 };
58825
58826 /*
58827 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
58828 index 6669aa2..36b033d 100644
58829 --- a/fs/jfs/super.c
58830 +++ b/fs/jfs/super.c
58831 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
58832
58833 jfs_inode_cachep =
58834 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
58835 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
58836 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
58837 init_once);
58838 if (jfs_inode_cachep == NULL)
58839 return -ENOMEM;
58840 diff --git a/fs/libfs.c b/fs/libfs.c
58841 index 193e0c2..7404665 100644
58842 --- a/fs/libfs.c
58843 +++ b/fs/libfs.c
58844 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58845
58846 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
58847 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
58848 + char d_name[sizeof(next->d_iname)];
58849 + const unsigned char *name;
58850 +
58851 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
58852 if (!simple_positive(next)) {
58853 spin_unlock(&next->d_lock);
58854 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58855
58856 spin_unlock(&next->d_lock);
58857 spin_unlock(&dentry->d_lock);
58858 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
58859 + name = next->d_name.name;
58860 + if (name == next->d_iname) {
58861 + memcpy(d_name, name, next->d_name.len);
58862 + name = d_name;
58863 + }
58864 + if (!dir_emit(ctx, name, next->d_name.len,
58865 next->d_inode->i_ino, dt_type(next->d_inode)))
58866 return 0;
58867 spin_lock(&dentry->d_lock);
58868 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58869 index acd3947..1f896e2 100644
58870 --- a/fs/lockd/clntproc.c
58871 +++ b/fs/lockd/clntproc.c
58872 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58873 /*
58874 * Cookie counter for NLM requests
58875 */
58876 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58877 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58878
58879 void nlmclnt_next_cookie(struct nlm_cookie *c)
58880 {
58881 - u32 cookie = atomic_inc_return(&nlm_cookie);
58882 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58883
58884 memcpy(c->data, &cookie, 4);
58885 c->len=4;
58886 diff --git a/fs/locks.c b/fs/locks.c
58887 index b27a300..4156d0b 100644
58888 --- a/fs/locks.c
58889 +++ b/fs/locks.c
58890 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
58891 return;
58892
58893 if (filp->f_op && filp->f_op->flock) {
58894 - struct file_lock fl = {
58895 + struct file_lock flock = {
58896 .fl_pid = current->tgid,
58897 .fl_file = filp,
58898 .fl_flags = FL_FLOCK,
58899 .fl_type = F_UNLCK,
58900 .fl_end = OFFSET_MAX,
58901 };
58902 - filp->f_op->flock(filp, F_SETLKW, &fl);
58903 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58904 - fl.fl_ops->fl_release_private(&fl);
58905 + filp->f_op->flock(filp, F_SETLKW, &flock);
58906 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58907 + flock.fl_ops->fl_release_private(&flock);
58908 }
58909
58910 spin_lock(&inode->i_lock);
58911 diff --git a/fs/namei.c b/fs/namei.c
58912 index 23ac50f..c6757a5 100644
58913 --- a/fs/namei.c
58914 +++ b/fs/namei.c
58915 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58916 if (ret != -EACCES)
58917 return ret;
58918
58919 +#ifdef CONFIG_GRKERNSEC
58920 + /* we'll block if we have to log due to a denied capability use */
58921 + if (mask & MAY_NOT_BLOCK)
58922 + return -ECHILD;
58923 +#endif
58924 +
58925 if (S_ISDIR(inode->i_mode)) {
58926 /* DACs are overridable for directories */
58927 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58928 - return 0;
58929 if (!(mask & MAY_WRITE))
58930 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58931 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58932 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58933 return 0;
58934 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58935 + return 0;
58936 return -EACCES;
58937 }
58938 /*
58939 + * Searching includes executable on directories, else just read.
58940 + */
58941 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58942 + if (mask == MAY_READ)
58943 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58944 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58945 + return 0;
58946 +
58947 + /*
58948 * Read/write DACs are always overridable.
58949 * Executable DACs are overridable when there is
58950 * at least one exec bit set.
58951 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58952 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58953 return 0;
58954
58955 - /*
58956 - * Searching includes executable on directories, else just read.
58957 - */
58958 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58959 - if (mask == MAY_READ)
58960 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58961 - return 0;
58962 -
58963 return -EACCES;
58964 }
58965
58966 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58967 {
58968 struct dentry *dentry = link->dentry;
58969 int error;
58970 - char *s;
58971 + const char *s;
58972
58973 BUG_ON(nd->flags & LOOKUP_RCU);
58974
58975 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58976 if (error)
58977 goto out_put_nd_path;
58978
58979 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58980 + dentry->d_inode, dentry, nd->path.mnt)) {
58981 + error = -EACCES;
58982 + goto out_put_nd_path;
58983 + }
58984 +
58985 nd->last_type = LAST_BIND;
58986 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58987 error = PTR_ERR(*p);
58988 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58989 if (res)
58990 break;
58991 res = walk_component(nd, path, LOOKUP_FOLLOW);
58992 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58993 + res = -EACCES;
58994 put_link(nd, &link, cookie);
58995 } while (res > 0);
58996
58997 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
58998 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58999 {
59000 unsigned long a, b, adata, bdata, mask, hash, len;
59001 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
59002 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
59003
59004 hash = a = 0;
59005 len = -sizeof(unsigned long);
59006 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
59007 if (err)
59008 break;
59009 err = lookup_last(nd, &path);
59010 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
59011 + err = -EACCES;
59012 put_link(nd, &link, cookie);
59013 }
59014 }
59015 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
59016 if (!err)
59017 err = complete_walk(nd);
59018
59019 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
59020 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
59021 + path_put(&nd->path);
59022 + err = -ENOENT;
59023 + }
59024 + }
59025 +
59026 if (!err && nd->flags & LOOKUP_DIRECTORY) {
59027 if (!can_lookup(nd->inode)) {
59028 path_put(&nd->path);
59029 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
59030 retval = path_lookupat(dfd, name->name,
59031 flags | LOOKUP_REVAL, nd);
59032
59033 - if (likely(!retval))
59034 + if (likely(!retval)) {
59035 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
59036 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
59037 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
59038 + path_put(&nd->path);
59039 + return -ENOENT;
59040 + }
59041 + }
59042 + }
59043 return retval;
59044 }
59045
59046 @@ -2587,6 +2619,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
59047 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
59048 return -EPERM;
59049
59050 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
59051 + return -EPERM;
59052 + if (gr_handle_rawio(inode))
59053 + return -EPERM;
59054 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
59055 + return -EACCES;
59056 +
59057 return 0;
59058 }
59059
59060 @@ -2818,7 +2857,7 @@ looked_up:
59061 * cleared otherwise prior to returning.
59062 */
59063 static int lookup_open(struct nameidata *nd, struct path *path,
59064 - struct file *file,
59065 + struct path *link, struct file *file,
59066 const struct open_flags *op,
59067 bool got_write, int *opened)
59068 {
59069 @@ -2853,6 +2892,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
59070 /* Negative dentry, just create the file */
59071 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
59072 umode_t mode = op->mode;
59073 +
59074 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
59075 + error = -EACCES;
59076 + goto out_dput;
59077 + }
59078 +
59079 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
59080 + error = -EACCES;
59081 + goto out_dput;
59082 + }
59083 +
59084 if (!IS_POSIXACL(dir->d_inode))
59085 mode &= ~current_umask();
59086 /*
59087 @@ -2874,6 +2924,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
59088 nd->flags & LOOKUP_EXCL);
59089 if (error)
59090 goto out_dput;
59091 + else
59092 + gr_handle_create(dentry, nd->path.mnt);
59093 }
59094 out_no_open:
59095 path->dentry = dentry;
59096 @@ -2888,7 +2940,7 @@ out_dput:
59097 /*
59098 * Handle the last step of open()
59099 */
59100 -static int do_last(struct nameidata *nd, struct path *path,
59101 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
59102 struct file *file, const struct open_flags *op,
59103 int *opened, struct filename *name)
59104 {
59105 @@ -2938,6 +2990,15 @@ static int do_last(struct nameidata *nd, struct path *path,
59106 if (error)
59107 return error;
59108
59109 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
59110 + error = -ENOENT;
59111 + goto out;
59112 + }
59113 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
59114 + error = -EACCES;
59115 + goto out;
59116 + }
59117 +
59118 audit_inode(name, dir, LOOKUP_PARENT);
59119 error = -EISDIR;
59120 /* trailing slashes? */
59121 @@ -2957,7 +3018,7 @@ retry_lookup:
59122 */
59123 }
59124 mutex_lock(&dir->d_inode->i_mutex);
59125 - error = lookup_open(nd, path, file, op, got_write, opened);
59126 + error = lookup_open(nd, path, link, file, op, got_write, opened);
59127 mutex_unlock(&dir->d_inode->i_mutex);
59128
59129 if (error <= 0) {
59130 @@ -2981,11 +3042,28 @@ retry_lookup:
59131 goto finish_open_created;
59132 }
59133
59134 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
59135 + error = -ENOENT;
59136 + goto exit_dput;
59137 + }
59138 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
59139 + error = -EACCES;
59140 + goto exit_dput;
59141 + }
59142 +
59143 /*
59144 * create/update audit record if it already exists.
59145 */
59146 - if (path->dentry->d_inode)
59147 + if (path->dentry->d_inode) {
59148 + /* only check if O_CREAT is specified, all other checks need to go
59149 + into may_open */
59150 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
59151 + error = -EACCES;
59152 + goto exit_dput;
59153 + }
59154 +
59155 audit_inode(name, path->dentry, 0);
59156 + }
59157
59158 /*
59159 * If atomic_open() acquired write access it is dropped now due to
59160 @@ -3026,6 +3104,11 @@ finish_lookup:
59161 }
59162 }
59163 BUG_ON(inode != path->dentry->d_inode);
59164 + /* if we're resolving a symlink to another symlink */
59165 + if (link && gr_handle_symlink_owner(link, inode)) {
59166 + error = -EACCES;
59167 + goto out;
59168 + }
59169 return 1;
59170 }
59171
59172 @@ -3035,7 +3118,6 @@ finish_lookup:
59173 save_parent.dentry = nd->path.dentry;
59174 save_parent.mnt = mntget(path->mnt);
59175 nd->path.dentry = path->dentry;
59176 -
59177 }
59178 nd->inode = inode;
59179 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
59180 @@ -3045,7 +3127,18 @@ finish_open:
59181 path_put(&save_parent);
59182 return error;
59183 }
59184 +
59185 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
59186 + error = -ENOENT;
59187 + goto out;
59188 + }
59189 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
59190 + error = -EACCES;
59191 + goto out;
59192 + }
59193 +
59194 audit_inode(name, nd->path.dentry, 0);
59195 +
59196 error = -EISDIR;
59197 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
59198 goto out;
59199 @@ -3208,7 +3301,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
59200 if (unlikely(error))
59201 goto out;
59202
59203 - error = do_last(nd, &path, file, op, &opened, pathname);
59204 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
59205 while (unlikely(error > 0)) { /* trailing symlink */
59206 struct path link = path;
59207 void *cookie;
59208 @@ -3226,7 +3319,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
59209 error = follow_link(&link, nd, &cookie);
59210 if (unlikely(error))
59211 break;
59212 - error = do_last(nd, &path, file, op, &opened, pathname);
59213 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
59214 put_link(nd, &link, cookie);
59215 }
59216 out:
59217 @@ -3326,8 +3419,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
59218 goto unlock;
59219
59220 error = -EEXIST;
59221 - if (dentry->d_inode)
59222 + if (dentry->d_inode) {
59223 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
59224 + error = -ENOENT;
59225 + }
59226 goto fail;
59227 + }
59228 /*
59229 * Special case - lookup gave negative, but... we had foo/bar/
59230 * From the vfs_mknod() POV we just have a negative dentry -
59231 @@ -3379,6 +3476,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
59232 }
59233 EXPORT_SYMBOL(user_path_create);
59234
59235 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
59236 +{
59237 + struct filename *tmp = getname(pathname);
59238 + struct dentry *res;
59239 + if (IS_ERR(tmp))
59240 + return ERR_CAST(tmp);
59241 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
59242 + if (IS_ERR(res))
59243 + putname(tmp);
59244 + else
59245 + *to = tmp;
59246 + return res;
59247 +}
59248 +
59249 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
59250 {
59251 int error = may_create(dir, dentry);
59252 @@ -3441,6 +3552,17 @@ retry:
59253
59254 if (!IS_POSIXACL(path.dentry->d_inode))
59255 mode &= ~current_umask();
59256 +
59257 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
59258 + error = -EPERM;
59259 + goto out;
59260 + }
59261 +
59262 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
59263 + error = -EACCES;
59264 + goto out;
59265 + }
59266 +
59267 error = security_path_mknod(&path, dentry, mode, dev);
59268 if (error)
59269 goto out;
59270 @@ -3457,6 +3579,8 @@ retry:
59271 break;
59272 }
59273 out:
59274 + if (!error)
59275 + gr_handle_create(dentry, path.mnt);
59276 done_path_create(&path, dentry);
59277 if (retry_estale(error, lookup_flags)) {
59278 lookup_flags |= LOOKUP_REVAL;
59279 @@ -3509,9 +3633,16 @@ retry:
59280
59281 if (!IS_POSIXACL(path.dentry->d_inode))
59282 mode &= ~current_umask();
59283 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
59284 + error = -EACCES;
59285 + goto out;
59286 + }
59287 error = security_path_mkdir(&path, dentry, mode);
59288 if (!error)
59289 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
59290 + if (!error)
59291 + gr_handle_create(dentry, path.mnt);
59292 +out:
59293 done_path_create(&path, dentry);
59294 if (retry_estale(error, lookup_flags)) {
59295 lookup_flags |= LOOKUP_REVAL;
59296 @@ -3592,6 +3723,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
59297 struct filename *name;
59298 struct dentry *dentry;
59299 struct nameidata nd;
59300 + ino_t saved_ino = 0;
59301 + dev_t saved_dev = 0;
59302 unsigned int lookup_flags = 0;
59303 retry:
59304 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59305 @@ -3624,10 +3757,21 @@ retry:
59306 error = -ENOENT;
59307 goto exit3;
59308 }
59309 +
59310 + saved_ino = dentry->d_inode->i_ino;
59311 + saved_dev = gr_get_dev_from_dentry(dentry);
59312 +
59313 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
59314 + error = -EACCES;
59315 + goto exit3;
59316 + }
59317 +
59318 error = security_path_rmdir(&nd.path, dentry);
59319 if (error)
59320 goto exit3;
59321 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
59322 + if (!error && (saved_dev || saved_ino))
59323 + gr_handle_delete(saved_ino, saved_dev);
59324 exit3:
59325 dput(dentry);
59326 exit2:
59327 @@ -3693,6 +3837,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
59328 struct dentry *dentry;
59329 struct nameidata nd;
59330 struct inode *inode = NULL;
59331 + ino_t saved_ino = 0;
59332 + dev_t saved_dev = 0;
59333 unsigned int lookup_flags = 0;
59334 retry:
59335 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59336 @@ -3719,10 +3865,22 @@ retry:
59337 if (!inode)
59338 goto slashes;
59339 ihold(inode);
59340 +
59341 + if (inode->i_nlink <= 1) {
59342 + saved_ino = inode->i_ino;
59343 + saved_dev = gr_get_dev_from_dentry(dentry);
59344 + }
59345 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
59346 + error = -EACCES;
59347 + goto exit2;
59348 + }
59349 +
59350 error = security_path_unlink(&nd.path, dentry);
59351 if (error)
59352 goto exit2;
59353 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
59354 + if (!error && (saved_ino || saved_dev))
59355 + gr_handle_delete(saved_ino, saved_dev);
59356 exit2:
59357 dput(dentry);
59358 }
59359 @@ -3800,9 +3958,17 @@ retry:
59360 if (IS_ERR(dentry))
59361 goto out_putname;
59362
59363 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
59364 + error = -EACCES;
59365 + goto out;
59366 + }
59367 +
59368 error = security_path_symlink(&path, dentry, from->name);
59369 if (!error)
59370 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
59371 + if (!error)
59372 + gr_handle_create(dentry, path.mnt);
59373 +out:
59374 done_path_create(&path, dentry);
59375 if (retry_estale(error, lookup_flags)) {
59376 lookup_flags |= LOOKUP_REVAL;
59377 @@ -3882,6 +4048,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
59378 {
59379 struct dentry *new_dentry;
59380 struct path old_path, new_path;
59381 + struct filename *to = NULL;
59382 int how = 0;
59383 int error;
59384
59385 @@ -3905,7 +4072,7 @@ retry:
59386 if (error)
59387 return error;
59388
59389 - new_dentry = user_path_create(newdfd, newname, &new_path,
59390 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
59391 (how & LOOKUP_REVAL));
59392 error = PTR_ERR(new_dentry);
59393 if (IS_ERR(new_dentry))
59394 @@ -3917,11 +4084,28 @@ retry:
59395 error = may_linkat(&old_path);
59396 if (unlikely(error))
59397 goto out_dput;
59398 +
59399 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
59400 + old_path.dentry->d_inode,
59401 + old_path.dentry->d_inode->i_mode, to)) {
59402 + error = -EACCES;
59403 + goto out_dput;
59404 + }
59405 +
59406 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
59407 + old_path.dentry, old_path.mnt, to)) {
59408 + error = -EACCES;
59409 + goto out_dput;
59410 + }
59411 +
59412 error = security_path_link(old_path.dentry, &new_path, new_dentry);
59413 if (error)
59414 goto out_dput;
59415 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
59416 + if (!error)
59417 + gr_handle_create(new_dentry, new_path.mnt);
59418 out_dput:
59419 + putname(to);
59420 done_path_create(&new_path, new_dentry);
59421 if (retry_estale(error, how)) {
59422 how |= LOOKUP_REVAL;
59423 @@ -4167,12 +4351,21 @@ retry:
59424 if (new_dentry == trap)
59425 goto exit5;
59426
59427 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
59428 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
59429 + to);
59430 + if (error)
59431 + goto exit5;
59432 +
59433 error = security_path_rename(&oldnd.path, old_dentry,
59434 &newnd.path, new_dentry);
59435 if (error)
59436 goto exit5;
59437 error = vfs_rename(old_dir->d_inode, old_dentry,
59438 new_dir->d_inode, new_dentry);
59439 + if (!error)
59440 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
59441 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
59442 exit5:
59443 dput(new_dentry);
59444 exit4:
59445 @@ -4204,6 +4397,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
59446
59447 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
59448 {
59449 + char tmpbuf[64];
59450 + const char *newlink;
59451 int len;
59452
59453 len = PTR_ERR(link);
59454 @@ -4213,7 +4408,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
59455 len = strlen(link);
59456 if (len > (unsigned) buflen)
59457 len = buflen;
59458 - if (copy_to_user(buffer, link, len))
59459 +
59460 + if (len < sizeof(tmpbuf)) {
59461 + memcpy(tmpbuf, link, len);
59462 + newlink = tmpbuf;
59463 + } else
59464 + newlink = link;
59465 +
59466 + if (copy_to_user(buffer, newlink, len))
59467 len = -EFAULT;
59468 out:
59469 return len;
59470 diff --git a/fs/namespace.c b/fs/namespace.c
59471 index da5c494..a755a54 100644
59472 --- a/fs/namespace.c
59473 +++ b/fs/namespace.c
59474 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
59475 if (!(sb->s_flags & MS_RDONLY))
59476 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
59477 up_write(&sb->s_umount);
59478 +
59479 + gr_log_remount(mnt->mnt_devname, retval);
59480 +
59481 return retval;
59482 }
59483
59484 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
59485 }
59486 br_write_unlock(&vfsmount_lock);
59487 namespace_unlock();
59488 +
59489 + gr_log_unmount(mnt->mnt_devname, retval);
59490 +
59491 return retval;
59492 }
59493
59494 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
59495 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
59496 */
59497
59498 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
59499 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
59500 {
59501 struct path path;
59502 struct mount *mnt;
59503 @@ -1347,7 +1353,7 @@ out:
59504 /*
59505 * The 2.0 compatible umount. No flags.
59506 */
59507 -SYSCALL_DEFINE1(oldumount, char __user *, name)
59508 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
59509 {
59510 return sys_umount(name, 0);
59511 }
59512 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
59513 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
59514 MS_STRICTATIME);
59515
59516 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
59517 + retval = -EPERM;
59518 + goto dput_out;
59519 + }
59520 +
59521 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
59522 + retval = -EPERM;
59523 + goto dput_out;
59524 + }
59525 +
59526 if (flags & MS_REMOUNT)
59527 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
59528 data_page);
59529 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
59530 dev_name, data_page);
59531 dput_out:
59532 path_put(&path);
59533 +
59534 + gr_log_mount(dev_name, dir_name, retval);
59535 +
59536 return retval;
59537 }
59538
59539 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
59540 * number incrementing at 10Ghz will take 12,427 years to wrap which
59541 * is effectively never, so we can ignore the possibility.
59542 */
59543 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
59544 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
59545
59546 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59547 {
59548 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59549 kfree(new_ns);
59550 return ERR_PTR(ret);
59551 }
59552 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
59553 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
59554 atomic_set(&new_ns->count, 1);
59555 new_ns->root = NULL;
59556 INIT_LIST_HEAD(&new_ns->list);
59557 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59558 * Allocate a new namespace structure and populate it with contents
59559 * copied from the namespace of the passed in task structure.
59560 */
59561 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59562 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59563 struct user_namespace *user_ns, struct fs_struct *fs)
59564 {
59565 struct mnt_namespace *new_ns;
59566 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
59567 }
59568 EXPORT_SYMBOL(mount_subtree);
59569
59570 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
59571 - char __user *, type, unsigned long, flags, void __user *, data)
59572 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
59573 + const char __user *, type, unsigned long, flags, void __user *, data)
59574 {
59575 int ret;
59576 char *kernel_type;
59577 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
59578 if (error)
59579 goto out2;
59580
59581 + if (gr_handle_chroot_pivot()) {
59582 + error = -EPERM;
59583 + goto out2;
59584 + }
59585 +
59586 get_fs_root(current->fs, &root);
59587 old_mp = lock_mount(&old);
59588 error = PTR_ERR(old_mp);
59589 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
59590 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
59591 return -EPERM;
59592
59593 - if (fs->users != 1)
59594 + if (atomic_read(&fs->users) != 1)
59595 return -EINVAL;
59596
59597 get_mnt_ns(mnt_ns);
59598 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
59599 index f4ccfe6..a5cf064 100644
59600 --- a/fs/nfs/callback_xdr.c
59601 +++ b/fs/nfs/callback_xdr.c
59602 @@ -51,7 +51,7 @@ struct callback_op {
59603 callback_decode_arg_t decode_args;
59604 callback_encode_res_t encode_res;
59605 long res_maxsize;
59606 -};
59607 +} __do_const;
59608
59609 static struct callback_op callback_ops[];
59610
59611 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
59612 index eda8879..bfc6837 100644
59613 --- a/fs/nfs/inode.c
59614 +++ b/fs/nfs/inode.c
59615 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
59616 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
59617 }
59618
59619 -static atomic_long_t nfs_attr_generation_counter;
59620 +static atomic_long_unchecked_t nfs_attr_generation_counter;
59621
59622 static unsigned long nfs_read_attr_generation_counter(void)
59623 {
59624 - return atomic_long_read(&nfs_attr_generation_counter);
59625 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
59626 }
59627
59628 unsigned long nfs_inc_attr_generation_counter(void)
59629 {
59630 - return atomic_long_inc_return(&nfs_attr_generation_counter);
59631 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
59632 }
59633
59634 void nfs_fattr_init(struct nfs_fattr *fattr)
59635 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
59636 index 419572f..5414a23 100644
59637 --- a/fs/nfsd/nfs4proc.c
59638 +++ b/fs/nfsd/nfs4proc.c
59639 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
59640 nfsd4op_rsize op_rsize_bop;
59641 stateid_getter op_get_currentstateid;
59642 stateid_setter op_set_currentstateid;
59643 -};
59644 +} __do_const;
59645
59646 static struct nfsd4_operation nfsd4_ops[];
59647
59648 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
59649 index ecc735e..79b2d31 100644
59650 --- a/fs/nfsd/nfs4xdr.c
59651 +++ b/fs/nfsd/nfs4xdr.c
59652 @@ -1500,7 +1500,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
59653
59654 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
59655
59656 -static nfsd4_dec nfsd4_dec_ops[] = {
59657 +static const nfsd4_dec nfsd4_dec_ops[] = {
59658 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59659 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59660 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59661 @@ -1540,7 +1540,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
59662 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
59663 };
59664
59665 -static nfsd4_dec nfsd41_dec_ops[] = {
59666 +static const nfsd4_dec nfsd41_dec_ops[] = {
59667 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59668 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59669 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59670 @@ -1602,7 +1602,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
59671 };
59672
59673 struct nfsd4_minorversion_ops {
59674 - nfsd4_dec *decoders;
59675 + const nfsd4_dec *decoders;
59676 int nops;
59677 };
59678
59679 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
59680 index b6af150..f6ec5e3 100644
59681 --- a/fs/nfsd/nfscache.c
59682 +++ b/fs/nfsd/nfscache.c
59683 @@ -547,14 +547,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
59684 {
59685 struct svc_cacherep *rp = rqstp->rq_cacherep;
59686 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
59687 - int len;
59688 + long len;
59689 size_t bufsize = 0;
59690
59691 if (!rp)
59692 return;
59693
59694 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
59695 - len >>= 2;
59696 + if (statp) {
59697 + len = (char*)statp - (char*)resv->iov_base;
59698 + len = resv->iov_len - len;
59699 + len >>= 2;
59700 + }
59701
59702 /* Don't cache excessive amounts of data and XDR failures */
59703 if (!statp || len > (256 >> 2)) {
59704 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
59705 index 72cb28e..5b5f87d 100644
59706 --- a/fs/nfsd/vfs.c
59707 +++ b/fs/nfsd/vfs.c
59708 @@ -993,7 +993,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59709 } else {
59710 oldfs = get_fs();
59711 set_fs(KERNEL_DS);
59712 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
59713 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
59714 set_fs(oldfs);
59715 }
59716
59717 @@ -1080,7 +1080,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59718
59719 /* Write the data. */
59720 oldfs = get_fs(); set_fs(KERNEL_DS);
59721 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
59722 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
59723 set_fs(oldfs);
59724 if (host_err < 0)
59725 goto out_nfserr;
59726 @@ -1626,7 +1626,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
59727 */
59728
59729 oldfs = get_fs(); set_fs(KERNEL_DS);
59730 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
59731 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
59732 set_fs(oldfs);
59733
59734 if (host_err < 0)
59735 diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
59736 index 9f6b486..a1a19163 100644
59737 --- a/fs/nilfs2/segment.c
59738 +++ b/fs/nilfs2/segment.c
59739 @@ -1440,17 +1440,19 @@ static int nilfs_segctor_collect(struct nilfs_sc_info *sci,
59740
59741 nilfs_clear_logs(&sci->sc_segbufs);
59742
59743 - err = nilfs_segctor_extend_segments(sci, nilfs, nadd);
59744 - if (unlikely(err))
59745 - return err;
59746 -
59747 if (sci->sc_stage.flags & NILFS_CF_SUFREED) {
59748 err = nilfs_sufile_cancel_freev(nilfs->ns_sufile,
59749 sci->sc_freesegs,
59750 sci->sc_nfreesegs,
59751 NULL);
59752 WARN_ON(err); /* do not happen */
59753 + sci->sc_stage.flags &= ~NILFS_CF_SUFREED;
59754 }
59755 +
59756 + err = nilfs_segctor_extend_segments(sci, nilfs, nadd);
59757 + if (unlikely(err))
59758 + return err;
59759 +
59760 nadd = min_t(int, nadd << 1, SC_MAX_SEGDELTA);
59761 sci->sc_stage = prev_stage;
59762 }
59763 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
59764 index fea6bd5..8ee9d81 100644
59765 --- a/fs/nls/nls_base.c
59766 +++ b/fs/nls/nls_base.c
59767 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
59768
59769 int register_nls(struct nls_table * nls)
59770 {
59771 - struct nls_table ** tmp = &tables;
59772 + struct nls_table *tmp = tables;
59773
59774 if (nls->next)
59775 return -EBUSY;
59776
59777 spin_lock(&nls_lock);
59778 - while (*tmp) {
59779 - if (nls == *tmp) {
59780 + while (tmp) {
59781 + if (nls == tmp) {
59782 spin_unlock(&nls_lock);
59783 return -EBUSY;
59784 }
59785 - tmp = &(*tmp)->next;
59786 + tmp = tmp->next;
59787 }
59788 - nls->next = tables;
59789 + pax_open_kernel();
59790 + *(struct nls_table **)&nls->next = tables;
59791 + pax_close_kernel();
59792 tables = nls;
59793 spin_unlock(&nls_lock);
59794 return 0;
59795 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
59796
59797 int unregister_nls(struct nls_table * nls)
59798 {
59799 - struct nls_table ** tmp = &tables;
59800 + struct nls_table * const * tmp = &tables;
59801
59802 spin_lock(&nls_lock);
59803 while (*tmp) {
59804 if (nls == *tmp) {
59805 - *tmp = nls->next;
59806 + pax_open_kernel();
59807 + *(struct nls_table **)tmp = nls->next;
59808 + pax_close_kernel();
59809 spin_unlock(&nls_lock);
59810 return 0;
59811 }
59812 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
59813 index 7424929..35f6be5 100644
59814 --- a/fs/nls/nls_euc-jp.c
59815 +++ b/fs/nls/nls_euc-jp.c
59816 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
59817 p_nls = load_nls("cp932");
59818
59819 if (p_nls) {
59820 - table.charset2upper = p_nls->charset2upper;
59821 - table.charset2lower = p_nls->charset2lower;
59822 + pax_open_kernel();
59823 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59824 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59825 + pax_close_kernel();
59826 return register_nls(&table);
59827 }
59828
59829 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
59830 index e7bc1d7..06bd4bb 100644
59831 --- a/fs/nls/nls_koi8-ru.c
59832 +++ b/fs/nls/nls_koi8-ru.c
59833 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
59834 p_nls = load_nls("koi8-u");
59835
59836 if (p_nls) {
59837 - table.charset2upper = p_nls->charset2upper;
59838 - table.charset2lower = p_nls->charset2lower;
59839 + pax_open_kernel();
59840 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59841 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59842 + pax_close_kernel();
59843 return register_nls(&table);
59844 }
59845
59846 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
59847 index e44cb64..4807084 100644
59848 --- a/fs/notify/fanotify/fanotify_user.c
59849 +++ b/fs/notify/fanotify/fanotify_user.c
59850 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
59851
59852 fd = fanotify_event_metadata.fd;
59853 ret = -EFAULT;
59854 - if (copy_to_user(buf, &fanotify_event_metadata,
59855 - fanotify_event_metadata.event_len))
59856 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
59857 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
59858 goto out_close_fd;
59859
59860 ret = prepare_for_access_response(group, event, fd);
59861 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
59862 index 7b51b05..5ea5ef6 100644
59863 --- a/fs/notify/notification.c
59864 +++ b/fs/notify/notification.c
59865 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
59866 * get set to 0 so it will never get 'freed'
59867 */
59868 static struct fsnotify_event *q_overflow_event;
59869 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59870 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59871
59872 /**
59873 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
59874 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59875 */
59876 u32 fsnotify_get_cookie(void)
59877 {
59878 - return atomic_inc_return(&fsnotify_sync_cookie);
59879 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
59880 }
59881 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
59882
59883 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
59884 index 9e38daf..5727cae 100644
59885 --- a/fs/ntfs/dir.c
59886 +++ b/fs/ntfs/dir.c
59887 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
59888 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
59889 ~(s64)(ndir->itype.index.block_size - 1)));
59890 /* Bounds checks. */
59891 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59892 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59893 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59894 "inode 0x%lx or driver bug.", vdir->i_ino);
59895 goto err_out;
59896 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59897 index ea4ba9d..1e13d34 100644
59898 --- a/fs/ntfs/file.c
59899 +++ b/fs/ntfs/file.c
59900 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59901 char *addr;
59902 size_t total = 0;
59903 unsigned len;
59904 - int left;
59905 + unsigned left;
59906
59907 do {
59908 len = PAGE_CACHE_SIZE - ofs;
59909 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59910 index 82650d5..db37dcf 100644
59911 --- a/fs/ntfs/super.c
59912 +++ b/fs/ntfs/super.c
59913 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59914 if (!silent)
59915 ntfs_error(sb, "Primary boot sector is invalid.");
59916 } else if (!silent)
59917 - ntfs_error(sb, read_err_str, "primary");
59918 + ntfs_error(sb, read_err_str, "%s", "primary");
59919 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59920 if (bh_primary)
59921 brelse(bh_primary);
59922 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59923 goto hotfix_primary_boot_sector;
59924 brelse(bh_backup);
59925 } else if (!silent)
59926 - ntfs_error(sb, read_err_str, "backup");
59927 + ntfs_error(sb, read_err_str, "%s", "backup");
59928 /* Try to read NT3.51- backup boot sector. */
59929 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59930 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59931 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59932 "sector.");
59933 brelse(bh_backup);
59934 } else if (!silent)
59935 - ntfs_error(sb, read_err_str, "backup");
59936 + ntfs_error(sb, read_err_str, "%s", "backup");
59937 /* We failed. Cleanup and return. */
59938 if (bh_primary)
59939 brelse(bh_primary);
59940 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59941 index cd5496b..26a1055 100644
59942 --- a/fs/ocfs2/localalloc.c
59943 +++ b/fs/ocfs2/localalloc.c
59944 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59945 goto bail;
59946 }
59947
59948 - atomic_inc(&osb->alloc_stats.moves);
59949 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59950
59951 bail:
59952 if (handle)
59953 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59954 index 3a90347..c40bef8 100644
59955 --- a/fs/ocfs2/ocfs2.h
59956 +++ b/fs/ocfs2/ocfs2.h
59957 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59958
59959 struct ocfs2_alloc_stats
59960 {
59961 - atomic_t moves;
59962 - atomic_t local_data;
59963 - atomic_t bitmap_data;
59964 - atomic_t bg_allocs;
59965 - atomic_t bg_extends;
59966 + atomic_unchecked_t moves;
59967 + atomic_unchecked_t local_data;
59968 + atomic_unchecked_t bitmap_data;
59969 + atomic_unchecked_t bg_allocs;
59970 + atomic_unchecked_t bg_extends;
59971 };
59972
59973 enum ocfs2_local_alloc_state
59974 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59975 index 5397c07..54afc55 100644
59976 --- a/fs/ocfs2/suballoc.c
59977 +++ b/fs/ocfs2/suballoc.c
59978 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59979 mlog_errno(status);
59980 goto bail;
59981 }
59982 - atomic_inc(&osb->alloc_stats.bg_extends);
59983 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59984
59985 /* You should never ask for this much metadata */
59986 BUG_ON(bits_wanted >
59987 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59988 mlog_errno(status);
59989 goto bail;
59990 }
59991 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59992 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59993
59994 *suballoc_loc = res.sr_bg_blkno;
59995 *suballoc_bit_start = res.sr_bit_offset;
59996 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59997 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59998 res->sr_bits);
59999
60000 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
60001 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
60002
60003 BUG_ON(res->sr_bits != 1);
60004
60005 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
60006 mlog_errno(status);
60007 goto bail;
60008 }
60009 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
60010 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
60011
60012 BUG_ON(res.sr_bits != 1);
60013
60014 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
60015 cluster_start,
60016 num_clusters);
60017 if (!status)
60018 - atomic_inc(&osb->alloc_stats.local_data);
60019 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
60020 } else {
60021 if (min_clusters > (osb->bitmap_cpg - 1)) {
60022 /* The only paths asking for contiguousness
60023 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
60024 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
60025 res.sr_bg_blkno,
60026 res.sr_bit_offset);
60027 - atomic_inc(&osb->alloc_stats.bitmap_data);
60028 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
60029 *num_clusters = res.sr_bits;
60030 }
60031 }
60032 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
60033 index d4e81e4..ad89f5f 100644
60034 --- a/fs/ocfs2/super.c
60035 +++ b/fs/ocfs2/super.c
60036 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
60037 "%10s => GlobalAllocs: %d LocalAllocs: %d "
60038 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
60039 "Stats",
60040 - atomic_read(&osb->alloc_stats.bitmap_data),
60041 - atomic_read(&osb->alloc_stats.local_data),
60042 - atomic_read(&osb->alloc_stats.bg_allocs),
60043 - atomic_read(&osb->alloc_stats.moves),
60044 - atomic_read(&osb->alloc_stats.bg_extends));
60045 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
60046 + atomic_read_unchecked(&osb->alloc_stats.local_data),
60047 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
60048 + atomic_read_unchecked(&osb->alloc_stats.moves),
60049 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
60050
60051 out += snprintf(buf + out, len - out,
60052 "%10s => State: %u Descriptor: %llu Size: %u bits "
60053 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
60054 spin_lock_init(&osb->osb_xattr_lock);
60055 ocfs2_init_steal_slots(osb);
60056
60057 - atomic_set(&osb->alloc_stats.moves, 0);
60058 - atomic_set(&osb->alloc_stats.local_data, 0);
60059 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
60060 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
60061 - atomic_set(&osb->alloc_stats.bg_extends, 0);
60062 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
60063 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
60064 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
60065 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
60066 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
60067
60068 /* Copy the blockcheck stats from the superblock probe */
60069 osb->osb_ecc_stats = *stats;
60070 diff --git a/fs/open.c b/fs/open.c
60071 index d420331..2dbb3fd 100644
60072 --- a/fs/open.c
60073 +++ b/fs/open.c
60074 @@ -32,6 +32,8 @@
60075 #include <linux/dnotify.h>
60076 #include <linux/compat.h>
60077
60078 +#define CREATE_TRACE_POINTS
60079 +#include <trace/events/fs.h>
60080 #include "internal.h"
60081
60082 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
60083 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
60084 error = locks_verify_truncate(inode, NULL, length);
60085 if (!error)
60086 error = security_path_truncate(path);
60087 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
60088 + error = -EACCES;
60089 if (!error)
60090 error = do_truncate(path->dentry, length, 0, NULL);
60091
60092 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
60093 error = locks_verify_truncate(inode, f.file, length);
60094 if (!error)
60095 error = security_path_truncate(&f.file->f_path);
60096 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
60097 + error = -EACCES;
60098 if (!error)
60099 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
60100 sb_end_write(inode->i_sb);
60101 @@ -360,6 +366,9 @@ retry:
60102 if (__mnt_is_readonly(path.mnt))
60103 res = -EROFS;
60104
60105 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
60106 + res = -EACCES;
60107 +
60108 out_path_release:
60109 path_put(&path);
60110 if (retry_estale(res, lookup_flags)) {
60111 @@ -391,6 +400,8 @@ retry:
60112 if (error)
60113 goto dput_and_out;
60114
60115 + gr_log_chdir(path.dentry, path.mnt);
60116 +
60117 set_fs_pwd(current->fs, &path);
60118
60119 dput_and_out:
60120 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
60121 goto out_putf;
60122
60123 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
60124 +
60125 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
60126 + error = -EPERM;
60127 +
60128 + if (!error)
60129 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
60130 +
60131 if (!error)
60132 set_fs_pwd(current->fs, &f.file->f_path);
60133 out_putf:
60134 @@ -449,7 +467,13 @@ retry:
60135 if (error)
60136 goto dput_and_out;
60137
60138 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
60139 + goto dput_and_out;
60140 +
60141 set_fs_root(current->fs, &path);
60142 +
60143 + gr_handle_chroot_chdir(&path);
60144 +
60145 error = 0;
60146 dput_and_out:
60147 path_put(&path);
60148 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
60149 if (error)
60150 return error;
60151 mutex_lock(&inode->i_mutex);
60152 +
60153 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
60154 + error = -EACCES;
60155 + goto out_unlock;
60156 + }
60157 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
60158 + error = -EACCES;
60159 + goto out_unlock;
60160 + }
60161 +
60162 error = security_path_chmod(path, mode);
60163 if (error)
60164 goto out_unlock;
60165 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
60166 uid = make_kuid(current_user_ns(), user);
60167 gid = make_kgid(current_user_ns(), group);
60168
60169 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
60170 + return -EACCES;
60171 +
60172 newattrs.ia_valid = ATTR_CTIME;
60173 if (user != (uid_t) -1) {
60174 if (!uid_valid(uid))
60175 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
60176 } else {
60177 fsnotify_open(f);
60178 fd_install(fd, f);
60179 + trace_do_sys_open(tmp->name, flags, mode);
60180 }
60181 }
60182 putname(tmp);
60183 diff --git a/fs/pipe.c b/fs/pipe.c
60184 index 0e0752e..7cfdd50 100644
60185 --- a/fs/pipe.c
60186 +++ b/fs/pipe.c
60187 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
60188
60189 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
60190 {
60191 - if (pipe->files)
60192 + if (atomic_read(&pipe->files))
60193 mutex_lock_nested(&pipe->mutex, subclass);
60194 }
60195
60196 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
60197
60198 void pipe_unlock(struct pipe_inode_info *pipe)
60199 {
60200 - if (pipe->files)
60201 + if (atomic_read(&pipe->files))
60202 mutex_unlock(&pipe->mutex);
60203 }
60204 EXPORT_SYMBOL(pipe_unlock);
60205 @@ -449,9 +449,9 @@ redo:
60206 }
60207 if (bufs) /* More to do? */
60208 continue;
60209 - if (!pipe->writers)
60210 + if (!atomic_read(&pipe->writers))
60211 break;
60212 - if (!pipe->waiting_writers) {
60213 + if (!atomic_read(&pipe->waiting_writers)) {
60214 /* syscall merging: Usually we must not sleep
60215 * if O_NONBLOCK is set, or if we got some data.
60216 * But if a writer sleeps in kernel space, then
60217 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
60218 ret = 0;
60219 __pipe_lock(pipe);
60220
60221 - if (!pipe->readers) {
60222 + if (!atomic_read(&pipe->readers)) {
60223 send_sig(SIGPIPE, current, 0);
60224 ret = -EPIPE;
60225 goto out;
60226 @@ -562,7 +562,7 @@ redo1:
60227 for (;;) {
60228 int bufs;
60229
60230 - if (!pipe->readers) {
60231 + if (!atomic_read(&pipe->readers)) {
60232 send_sig(SIGPIPE, current, 0);
60233 if (!ret)
60234 ret = -EPIPE;
60235 @@ -653,9 +653,9 @@ redo2:
60236 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60237 do_wakeup = 0;
60238 }
60239 - pipe->waiting_writers++;
60240 + atomic_inc(&pipe->waiting_writers);
60241 pipe_wait(pipe);
60242 - pipe->waiting_writers--;
60243 + atomic_dec(&pipe->waiting_writers);
60244 }
60245 out:
60246 __pipe_unlock(pipe);
60247 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60248 mask = 0;
60249 if (filp->f_mode & FMODE_READ) {
60250 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
60251 - if (!pipe->writers && filp->f_version != pipe->w_counter)
60252 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
60253 mask |= POLLHUP;
60254 }
60255
60256 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60257 * Most Unices do not set POLLERR for FIFOs but on Linux they
60258 * behave exactly like pipes for poll().
60259 */
60260 - if (!pipe->readers)
60261 + if (!atomic_read(&pipe->readers))
60262 mask |= POLLERR;
60263 }
60264
60265 @@ -731,7 +731,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
60266 int kill = 0;
60267
60268 spin_lock(&inode->i_lock);
60269 - if (!--pipe->files) {
60270 + if (atomic_dec_and_test(&pipe->files)) {
60271 inode->i_pipe = NULL;
60272 kill = 1;
60273 }
60274 @@ -748,11 +748,11 @@ pipe_release(struct inode *inode, struct file *file)
60275
60276 __pipe_lock(pipe);
60277 if (file->f_mode & FMODE_READ)
60278 - pipe->readers--;
60279 + atomic_dec(&pipe->readers);
60280 if (file->f_mode & FMODE_WRITE)
60281 - pipe->writers--;
60282 + atomic_dec(&pipe->writers);
60283
60284 - if (pipe->readers || pipe->writers) {
60285 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
60286 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
60287 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60288 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
60289 @@ -817,7 +817,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
60290 kfree(pipe);
60291 }
60292
60293 -static struct vfsmount *pipe_mnt __read_mostly;
60294 +struct vfsmount *pipe_mnt __read_mostly;
60295
60296 /*
60297 * pipefs_dname() is called from d_path().
60298 @@ -847,8 +847,9 @@ static struct inode * get_pipe_inode(void)
60299 goto fail_iput;
60300
60301 inode->i_pipe = pipe;
60302 - pipe->files = 2;
60303 - pipe->readers = pipe->writers = 1;
60304 + atomic_set(&pipe->files, 2);
60305 + atomic_set(&pipe->readers, 1);
60306 + atomic_set(&pipe->writers, 1);
60307 inode->i_fop = &pipefifo_fops;
60308
60309 /*
60310 @@ -1027,17 +1028,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
60311 spin_lock(&inode->i_lock);
60312 if (inode->i_pipe) {
60313 pipe = inode->i_pipe;
60314 - pipe->files++;
60315 + atomic_inc(&pipe->files);
60316 spin_unlock(&inode->i_lock);
60317 } else {
60318 spin_unlock(&inode->i_lock);
60319 pipe = alloc_pipe_info();
60320 if (!pipe)
60321 return -ENOMEM;
60322 - pipe->files = 1;
60323 + atomic_set(&pipe->files, 1);
60324 spin_lock(&inode->i_lock);
60325 if (unlikely(inode->i_pipe)) {
60326 - inode->i_pipe->files++;
60327 + atomic_inc(&inode->i_pipe->files);
60328 spin_unlock(&inode->i_lock);
60329 free_pipe_info(pipe);
60330 pipe = inode->i_pipe;
60331 @@ -1062,10 +1063,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
60332 * opened, even when there is no process writing the FIFO.
60333 */
60334 pipe->r_counter++;
60335 - if (pipe->readers++ == 0)
60336 + if (atomic_inc_return(&pipe->readers) == 1)
60337 wake_up_partner(pipe);
60338
60339 - if (!is_pipe && !pipe->writers) {
60340 + if (!is_pipe && !atomic_read(&pipe->writers)) {
60341 if ((filp->f_flags & O_NONBLOCK)) {
60342 /* suppress POLLHUP until we have
60343 * seen a writer */
60344 @@ -1084,14 +1085,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
60345 * errno=ENXIO when there is no process reading the FIFO.
60346 */
60347 ret = -ENXIO;
60348 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
60349 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
60350 goto err;
60351
60352 pipe->w_counter++;
60353 - if (!pipe->writers++)
60354 + if (atomic_inc_return(&pipe->writers) == 1)
60355 wake_up_partner(pipe);
60356
60357 - if (!is_pipe && !pipe->readers) {
60358 + if (!is_pipe && !atomic_read(&pipe->readers)) {
60359 if (wait_for_partner(pipe, &pipe->r_counter))
60360 goto err_wr;
60361 }
60362 @@ -1105,11 +1106,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
60363 * the process can at least talk to itself.
60364 */
60365
60366 - pipe->readers++;
60367 - pipe->writers++;
60368 + atomic_inc(&pipe->readers);
60369 + atomic_inc(&pipe->writers);
60370 pipe->r_counter++;
60371 pipe->w_counter++;
60372 - if (pipe->readers == 1 || pipe->writers == 1)
60373 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
60374 wake_up_partner(pipe);
60375 break;
60376
60377 @@ -1123,13 +1124,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
60378 return 0;
60379
60380 err_rd:
60381 - if (!--pipe->readers)
60382 + if (atomic_dec_and_test(&pipe->readers))
60383 wake_up_interruptible(&pipe->wait);
60384 ret = -ERESTARTSYS;
60385 goto err;
60386
60387 err_wr:
60388 - if (!--pipe->writers)
60389 + if (atomic_dec_and_test(&pipe->writers))
60390 wake_up_interruptible(&pipe->wait);
60391 ret = -ERESTARTSYS;
60392 goto err;
60393 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
60394 index 15af622..0e9f4467 100644
60395 --- a/fs/proc/Kconfig
60396 +++ b/fs/proc/Kconfig
60397 @@ -30,12 +30,12 @@ config PROC_FS
60398
60399 config PROC_KCORE
60400 bool "/proc/kcore support" if !ARM
60401 - depends on PROC_FS && MMU
60402 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
60403
60404 config PROC_VMCORE
60405 bool "/proc/vmcore support"
60406 - depends on PROC_FS && CRASH_DUMP
60407 - default y
60408 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
60409 + default n
60410 help
60411 Exports the dump image of crashed kernel in ELF format.
60412
60413 @@ -59,8 +59,8 @@ config PROC_SYSCTL
60414 limited in memory.
60415
60416 config PROC_PAGE_MONITOR
60417 - default y
60418 - depends on PROC_FS && MMU
60419 + default n
60420 + depends on PROC_FS && MMU && !GRKERNSEC
60421 bool "Enable /proc page monitoring" if EXPERT
60422 help
60423 Various /proc files exist to monitor process memory utilization:
60424 diff --git a/fs/proc/array.c b/fs/proc/array.c
60425 index cbd0f1b..adec3f0 100644
60426 --- a/fs/proc/array.c
60427 +++ b/fs/proc/array.c
60428 @@ -60,6 +60,7 @@
60429 #include <linux/tty.h>
60430 #include <linux/string.h>
60431 #include <linux/mman.h>
60432 +#include <linux/grsecurity.h>
60433 #include <linux/proc_fs.h>
60434 #include <linux/ioport.h>
60435 #include <linux/uaccess.h>
60436 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
60437 seq_putc(m, '\n');
60438 }
60439
60440 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60441 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
60442 +{
60443 + if (p->mm)
60444 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
60445 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
60446 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
60447 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
60448 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
60449 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
60450 + else
60451 + seq_printf(m, "PaX:\t-----\n");
60452 +}
60453 +#endif
60454 +
60455 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60456 struct pid *pid, struct task_struct *task)
60457 {
60458 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60459 task_cpus_allowed(m, task);
60460 cpuset_task_status_allowed(m, task);
60461 task_context_switch_counts(m, task);
60462 +
60463 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60464 + task_pax(m, task);
60465 +#endif
60466 +
60467 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
60468 + task_grsec_rbac(m, task);
60469 +#endif
60470 +
60471 return 0;
60472 }
60473
60474 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60475 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60476 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60477 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60478 +#endif
60479 +
60480 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60481 struct pid *pid, struct task_struct *task, int whole)
60482 {
60483 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60484 char tcomm[sizeof(task->comm)];
60485 unsigned long flags;
60486
60487 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60488 + if (current->exec_id != m->exec_id) {
60489 + gr_log_badprocpid("stat");
60490 + return 0;
60491 + }
60492 +#endif
60493 +
60494 state = *get_task_state(task);
60495 vsize = eip = esp = 0;
60496 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60497 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60498 gtime = task_gtime(task);
60499 }
60500
60501 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60502 + if (PAX_RAND_FLAGS(mm)) {
60503 + eip = 0;
60504 + esp = 0;
60505 + wchan = 0;
60506 + }
60507 +#endif
60508 +#ifdef CONFIG_GRKERNSEC_HIDESYM
60509 + wchan = 0;
60510 + eip =0;
60511 + esp =0;
60512 +#endif
60513 +
60514 /* scale priority and nice values from timeslices to -20..20 */
60515 /* to make it look like a "normal" Unix priority/nice value */
60516 priority = task_prio(task);
60517 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60518 seq_put_decimal_ull(m, ' ', vsize);
60519 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
60520 seq_put_decimal_ull(m, ' ', rsslim);
60521 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60522 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
60523 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
60524 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
60525 +#else
60526 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
60527 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
60528 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
60529 +#endif
60530 seq_put_decimal_ull(m, ' ', esp);
60531 seq_put_decimal_ull(m, ' ', eip);
60532 /* The signal information here is obsolete.
60533 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60534 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
60535 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
60536
60537 - if (mm && permitted) {
60538 + if (mm && permitted
60539 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60540 + && !PAX_RAND_FLAGS(mm)
60541 +#endif
60542 + ) {
60543 seq_put_decimal_ull(m, ' ', mm->start_data);
60544 seq_put_decimal_ull(m, ' ', mm->end_data);
60545 seq_put_decimal_ull(m, ' ', mm->start_brk);
60546 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60547 struct pid *pid, struct task_struct *task)
60548 {
60549 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
60550 - struct mm_struct *mm = get_task_mm(task);
60551 + struct mm_struct *mm;
60552
60553 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60554 + if (current->exec_id != m->exec_id) {
60555 + gr_log_badprocpid("statm");
60556 + return 0;
60557 + }
60558 +#endif
60559 + mm = get_task_mm(task);
60560 if (mm) {
60561 size = task_statm(mm, &shared, &text, &data, &resident);
60562 mmput(mm);
60563 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60564 return 0;
60565 }
60566
60567 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60568 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
60569 +{
60570 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
60571 +}
60572 +#endif
60573 +
60574 #ifdef CONFIG_CHECKPOINT_RESTORE
60575 static struct pid *
60576 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
60577 diff --git a/fs/proc/base.c b/fs/proc/base.c
60578 index 1485e38..8ad4236 100644
60579 --- a/fs/proc/base.c
60580 +++ b/fs/proc/base.c
60581 @@ -113,6 +113,14 @@ struct pid_entry {
60582 union proc_op op;
60583 };
60584
60585 +struct getdents_callback {
60586 + struct linux_dirent __user * current_dir;
60587 + struct linux_dirent __user * previous;
60588 + struct file * file;
60589 + int count;
60590 + int error;
60591 +};
60592 +
60593 #define NOD(NAME, MODE, IOP, FOP, OP) { \
60594 .name = (NAME), \
60595 .len = sizeof(NAME) - 1, \
60596 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
60597 if (!mm->arg_end)
60598 goto out_mm; /* Shh! No looking before we're done */
60599
60600 + if (gr_acl_handle_procpidmem(task))
60601 + goto out_mm;
60602 +
60603 len = mm->arg_end - mm->arg_start;
60604
60605 if (len > PAGE_SIZE)
60606 @@ -237,12 +248,28 @@ out:
60607 return res;
60608 }
60609
60610 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60611 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60612 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60613 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60614 +#endif
60615 +
60616 static int proc_pid_auxv(struct task_struct *task, char *buffer)
60617 {
60618 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
60619 int res = PTR_ERR(mm);
60620 if (mm && !IS_ERR(mm)) {
60621 unsigned int nwords = 0;
60622 +
60623 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60624 + /* allow if we're currently ptracing this task */
60625 + if (PAX_RAND_FLAGS(mm) &&
60626 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
60627 + mmput(mm);
60628 + return 0;
60629 + }
60630 +#endif
60631 +
60632 do {
60633 nwords += 2;
60634 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
60635 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
60636 }
60637
60638
60639 -#ifdef CONFIG_KALLSYMS
60640 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60641 /*
60642 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
60643 * Returns the resolved symbol. If that fails, simply return the address.
60644 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
60645 mutex_unlock(&task->signal->cred_guard_mutex);
60646 }
60647
60648 -#ifdef CONFIG_STACKTRACE
60649 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60650
60651 #define MAX_STACK_TRACE_DEPTH 64
60652
60653 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
60654 return count;
60655 }
60656
60657 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60658 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60659 static int proc_pid_syscall(struct task_struct *task, char *buffer)
60660 {
60661 long nr;
60662 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
60663 /************************************************************************/
60664
60665 /* permission checks */
60666 -static int proc_fd_access_allowed(struct inode *inode)
60667 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
60668 {
60669 struct task_struct *task;
60670 int allowed = 0;
60671 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
60672 */
60673 task = get_proc_task(inode);
60674 if (task) {
60675 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60676 + if (log)
60677 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60678 + else
60679 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60680 put_task_struct(task);
60681 }
60682 return allowed;
60683 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
60684 struct task_struct *task,
60685 int hide_pid_min)
60686 {
60687 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60688 + return false;
60689 +
60690 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60691 + rcu_read_lock();
60692 + {
60693 + const struct cred *tmpcred = current_cred();
60694 + const struct cred *cred = __task_cred(task);
60695 +
60696 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
60697 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60698 + || in_group_p(grsec_proc_gid)
60699 +#endif
60700 + ) {
60701 + rcu_read_unlock();
60702 + return true;
60703 + }
60704 + }
60705 + rcu_read_unlock();
60706 +
60707 + if (!pid->hide_pid)
60708 + return false;
60709 +#endif
60710 +
60711 if (pid->hide_pid < hide_pid_min)
60712 return true;
60713 if (in_group_p(pid->pid_gid))
60714 return true;
60715 +
60716 return ptrace_may_access(task, PTRACE_MODE_READ);
60717 }
60718
60719 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
60720 put_task_struct(task);
60721
60722 if (!has_perms) {
60723 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60724 + {
60725 +#else
60726 if (pid->hide_pid == 2) {
60727 +#endif
60728 /*
60729 * Let's make getdents(), stat(), and open()
60730 * consistent with each other. If a process
60731 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60732 if (!task)
60733 return -ESRCH;
60734
60735 + if (gr_acl_handle_procpidmem(task)) {
60736 + put_task_struct(task);
60737 + return -EPERM;
60738 + }
60739 +
60740 mm = mm_access(task, mode);
60741 put_task_struct(task);
60742
60743 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60744
60745 file->private_data = mm;
60746
60747 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60748 + file->f_version = current->exec_id;
60749 +#endif
60750 +
60751 return 0;
60752 }
60753
60754 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60755 ssize_t copied;
60756 char *page;
60757
60758 +#ifdef CONFIG_GRKERNSEC
60759 + if (write)
60760 + return -EPERM;
60761 +#endif
60762 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60763 + if (file->f_version != current->exec_id) {
60764 + gr_log_badprocpid("mem");
60765 + return 0;
60766 + }
60767 +#endif
60768 +
60769 if (!mm)
60770 return 0;
60771
60772 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60773 goto free;
60774
60775 while (count > 0) {
60776 - int this_len = min_t(int, count, PAGE_SIZE);
60777 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
60778
60779 if (write && copy_from_user(page, buf, this_len)) {
60780 copied = -EFAULT;
60781 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60782 if (!mm)
60783 return 0;
60784
60785 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60786 + if (file->f_version != current->exec_id) {
60787 + gr_log_badprocpid("environ");
60788 + return 0;
60789 + }
60790 +#endif
60791 +
60792 page = (char *)__get_free_page(GFP_TEMPORARY);
60793 if (!page)
60794 return -ENOMEM;
60795 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60796 goto free;
60797 while (count > 0) {
60798 size_t this_len, max_len;
60799 - int retval;
60800 + ssize_t retval;
60801
60802 if (src >= (mm->env_end - mm->env_start))
60803 break;
60804 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
60805 int error = -EACCES;
60806
60807 /* Are we allowed to snoop on the tasks file descriptors? */
60808 - if (!proc_fd_access_allowed(inode))
60809 + if (!proc_fd_access_allowed(inode, 0))
60810 goto out;
60811
60812 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60813 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
60814 struct path path;
60815
60816 /* Are we allowed to snoop on the tasks file descriptors? */
60817 - if (!proc_fd_access_allowed(inode))
60818 - goto out;
60819 + /* logging this is needed for learning on chromium to work properly,
60820 + but we don't want to flood the logs from 'ps' which does a readlink
60821 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
60822 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
60823 + */
60824 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
60825 + if (!proc_fd_access_allowed(inode,0))
60826 + goto out;
60827 + } else {
60828 + if (!proc_fd_access_allowed(inode,1))
60829 + goto out;
60830 + }
60831
60832 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60833 if (error)
60834 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
60835 rcu_read_lock();
60836 cred = __task_cred(task);
60837 inode->i_uid = cred->euid;
60838 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60839 + inode->i_gid = grsec_proc_gid;
60840 +#else
60841 inode->i_gid = cred->egid;
60842 +#endif
60843 rcu_read_unlock();
60844 }
60845 security_task_to_inode(task, inode);
60846 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
60847 return -ENOENT;
60848 }
60849 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60850 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60851 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60852 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60853 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60854 +#endif
60855 task_dumpable(task)) {
60856 cred = __task_cred(task);
60857 stat->uid = cred->euid;
60858 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60859 + stat->gid = grsec_proc_gid;
60860 +#else
60861 stat->gid = cred->egid;
60862 +#endif
60863 }
60864 }
60865 rcu_read_unlock();
60866 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
60867
60868 if (task) {
60869 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60870 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60871 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60872 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60873 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60874 +#endif
60875 task_dumpable(task)) {
60876 rcu_read_lock();
60877 cred = __task_cred(task);
60878 inode->i_uid = cred->euid;
60879 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60880 + inode->i_gid = grsec_proc_gid;
60881 +#else
60882 inode->i_gid = cred->egid;
60883 +#endif
60884 rcu_read_unlock();
60885 } else {
60886 inode->i_uid = GLOBAL_ROOT_UID;
60887 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60888 if (!task)
60889 goto out_no_task;
60890
60891 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60892 + goto out;
60893 +
60894 /*
60895 * Yes, it does not scale. And it should not. Don't add
60896 * new entries into /proc/<tgid>/ without very good reasons.
60897 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
60898 if (!task)
60899 return -ENOENT;
60900
60901 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60902 + goto out;
60903 +
60904 if (!dir_emit_dots(file, ctx))
60905 goto out;
60906
60907 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60908 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60909 #endif
60910 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60911 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60912 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60913 INF("syscall", S_IRUGO, proc_pid_syscall),
60914 #endif
60915 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60916 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60917 #ifdef CONFIG_SECURITY
60918 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60919 #endif
60920 -#ifdef CONFIG_KALLSYMS
60921 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60922 INF("wchan", S_IRUGO, proc_pid_wchan),
60923 #endif
60924 -#ifdef CONFIG_STACKTRACE
60925 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60926 ONE("stack", S_IRUGO, proc_pid_stack),
60927 #endif
60928 #ifdef CONFIG_SCHEDSTATS
60929 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60930 #ifdef CONFIG_HARDWALL
60931 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60932 #endif
60933 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60934 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60935 +#endif
60936 #ifdef CONFIG_USER_NS
60937 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60938 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60939 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
60940 if (!inode)
60941 goto out;
60942
60943 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60944 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60945 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60946 + inode->i_gid = grsec_proc_gid;
60947 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60948 +#else
60949 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60950 +#endif
60951 inode->i_op = &proc_tgid_base_inode_operations;
60952 inode->i_fop = &proc_tgid_base_operations;
60953 inode->i_flags|=S_IMMUTABLE;
60954 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60955 if (!task)
60956 goto out;
60957
60958 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60959 + goto out_put_task;
60960 +
60961 result = proc_pid_instantiate(dir, dentry, task, NULL);
60962 +out_put_task:
60963 put_task_struct(task);
60964 out:
60965 return ERR_PTR(result);
60966 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
60967 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60968 #endif
60969 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60970 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60971 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60972 INF("syscall", S_IRUGO, proc_pid_syscall),
60973 #endif
60974 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60975 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
60976 #ifdef CONFIG_SECURITY
60977 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60978 #endif
60979 -#ifdef CONFIG_KALLSYMS
60980 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60981 INF("wchan", S_IRUGO, proc_pid_wchan),
60982 #endif
60983 -#ifdef CONFIG_STACKTRACE
60984 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60985 ONE("stack", S_IRUGO, proc_pid_stack),
60986 #endif
60987 #ifdef CONFIG_SCHEDSTATS
60988 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60989 index 82676e3..5f8518a 100644
60990 --- a/fs/proc/cmdline.c
60991 +++ b/fs/proc/cmdline.c
60992 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60993
60994 static int __init proc_cmdline_init(void)
60995 {
60996 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60997 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60998 +#else
60999 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
61000 +#endif
61001 return 0;
61002 }
61003 module_init(proc_cmdline_init);
61004 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
61005 index b143471..bb105e5 100644
61006 --- a/fs/proc/devices.c
61007 +++ b/fs/proc/devices.c
61008 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
61009
61010 static int __init proc_devices_init(void)
61011 {
61012 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61013 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
61014 +#else
61015 proc_create("devices", 0, NULL, &proc_devinfo_operations);
61016 +#endif
61017 return 0;
61018 }
61019 module_init(proc_devices_init);
61020 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
61021 index 985ea88..d118a0a 100644
61022 --- a/fs/proc/fd.c
61023 +++ b/fs/proc/fd.c
61024 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
61025 if (!task)
61026 return -ENOENT;
61027
61028 - files = get_files_struct(task);
61029 + if (!gr_acl_handle_procpidmem(task))
61030 + files = get_files_struct(task);
61031 put_task_struct(task);
61032
61033 if (files) {
61034 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
61035 */
61036 int proc_fd_permission(struct inode *inode, int mask)
61037 {
61038 + struct task_struct *task;
61039 int rv = generic_permission(inode, mask);
61040 - if (rv == 0)
61041 - return 0;
61042 +
61043 if (task_tgid(current) == proc_pid(inode))
61044 rv = 0;
61045 +
61046 + task = get_proc_task(inode);
61047 + if (task == NULL)
61048 + return rv;
61049 +
61050 + if (gr_acl_handle_procpidmem(task))
61051 + rv = -EACCES;
61052 +
61053 + put_task_struct(task);
61054 +
61055 return rv;
61056 }
61057
61058 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
61059 index 8eaa1ba..cc6ff42 100644
61060 --- a/fs/proc/inode.c
61061 +++ b/fs/proc/inode.c
61062 @@ -23,11 +23,17 @@
61063 #include <linux/slab.h>
61064 #include <linux/mount.h>
61065 #include <linux/magic.h>
61066 +#include <linux/grsecurity.h>
61067
61068 #include <asm/uaccess.h>
61069
61070 #include "internal.h"
61071
61072 +#ifdef CONFIG_PROC_SYSCTL
61073 +extern const struct inode_operations proc_sys_inode_operations;
61074 +extern const struct inode_operations proc_sys_dir_operations;
61075 +#endif
61076 +
61077 static void proc_evict_inode(struct inode *inode)
61078 {
61079 struct proc_dir_entry *de;
61080 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
61081 ns = PROC_I(inode)->ns.ns;
61082 if (ns_ops && ns)
61083 ns_ops->put(ns);
61084 +
61085 +#ifdef CONFIG_PROC_SYSCTL
61086 + if (inode->i_op == &proc_sys_inode_operations ||
61087 + inode->i_op == &proc_sys_dir_operations)
61088 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
61089 +#endif
61090 +
61091 }
61092
61093 static struct kmem_cache * proc_inode_cachep;
61094 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
61095 if (de->mode) {
61096 inode->i_mode = de->mode;
61097 inode->i_uid = de->uid;
61098 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
61099 + inode->i_gid = grsec_proc_gid;
61100 +#else
61101 inode->i_gid = de->gid;
61102 +#endif
61103 }
61104 if (de->size)
61105 inode->i_size = de->size;
61106 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
61107 index 651d09a..60c73ae 100644
61108 --- a/fs/proc/internal.h
61109 +++ b/fs/proc/internal.h
61110 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
61111 struct pid *, struct task_struct *);
61112 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
61113 struct pid *, struct task_struct *);
61114 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
61115 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
61116 +#endif
61117
61118 /*
61119 * base.c
61120 diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
61121 index 05029c0..7ea1987 100644
61122 --- a/fs/proc/interrupts.c
61123 +++ b/fs/proc/interrupts.c
61124 @@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
61125
61126 static int __init proc_interrupts_init(void)
61127 {
61128 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61129 + proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
61130 +#else
61131 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
61132 +#endif
61133 return 0;
61134 }
61135 module_init(proc_interrupts_init);
61136 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
61137 index 06ea155..9a798c7 100644
61138 --- a/fs/proc/kcore.c
61139 +++ b/fs/proc/kcore.c
61140 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
61141 * the addresses in the elf_phdr on our list.
61142 */
61143 start = kc_offset_to_vaddr(*fpos - elf_buflen);
61144 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
61145 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
61146 + if (tsz > buflen)
61147 tsz = buflen;
61148 -
61149 +
61150 while (buflen) {
61151 struct kcore_list *m;
61152
61153 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
61154 kfree(elf_buf);
61155 } else {
61156 if (kern_addr_valid(start)) {
61157 - unsigned long n;
61158 + char *elf_buf;
61159 + mm_segment_t oldfs;
61160
61161 - n = copy_to_user(buffer, (char *)start, tsz);
61162 - /*
61163 - * We cannot distinguish between fault on source
61164 - * and fault on destination. When this happens
61165 - * we clear too and hope it will trigger the
61166 - * EFAULT again.
61167 - */
61168 - if (n) {
61169 - if (clear_user(buffer + tsz - n,
61170 - n))
61171 + elf_buf = kmalloc(tsz, GFP_KERNEL);
61172 + if (!elf_buf)
61173 + return -ENOMEM;
61174 + oldfs = get_fs();
61175 + set_fs(KERNEL_DS);
61176 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
61177 + set_fs(oldfs);
61178 + if (copy_to_user(buffer, elf_buf, tsz)) {
61179 + kfree(elf_buf);
61180 return -EFAULT;
61181 + }
61182 }
61183 + set_fs(oldfs);
61184 + kfree(elf_buf);
61185 } else {
61186 if (clear_user(buffer, tsz))
61187 return -EFAULT;
61188 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
61189
61190 static int open_kcore(struct inode *inode, struct file *filp)
61191 {
61192 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
61193 + return -EPERM;
61194 +#endif
61195 if (!capable(CAP_SYS_RAWIO))
61196 return -EPERM;
61197 if (kcore_need_update)
61198 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
61199 index 59d85d6..ac6fc05 100644
61200 --- a/fs/proc/meminfo.c
61201 +++ b/fs/proc/meminfo.c
61202 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
61203 vmi.used >> 10,
61204 vmi.largest_chunk >> 10
61205 #ifdef CONFIG_MEMORY_FAILURE
61206 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
61207 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
61208 #endif
61209 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
61210 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
61211 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
61212 index ccfd99b..1b7e255 100644
61213 --- a/fs/proc/nommu.c
61214 +++ b/fs/proc/nommu.c
61215 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
61216 if (len < 1)
61217 len = 1;
61218 seq_printf(m, "%*c", len, ' ');
61219 - seq_path(m, &file->f_path, "");
61220 + seq_path(m, &file->f_path, "\n\\");
61221 }
61222
61223 seq_putc(m, '\n');
61224 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
61225 index 4677bb7..408e936 100644
61226 --- a/fs/proc/proc_net.c
61227 +++ b/fs/proc/proc_net.c
61228 @@ -23,6 +23,7 @@
61229 #include <linux/nsproxy.h>
61230 #include <net/net_namespace.h>
61231 #include <linux/seq_file.h>
61232 +#include <linux/grsecurity.h>
61233
61234 #include "internal.h"
61235
61236 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
61237 struct task_struct *task;
61238 struct nsproxy *ns;
61239 struct net *net = NULL;
61240 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61241 + const struct cred *cred = current_cred();
61242 +#endif
61243 +
61244 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61245 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
61246 + return net;
61247 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61248 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
61249 + return net;
61250 +#endif
61251
61252 rcu_read_lock();
61253 task = pid_task(proc_pid(dir), PIDTYPE_PID);
61254 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
61255 index 7129046..6914844 100644
61256 --- a/fs/proc/proc_sysctl.c
61257 +++ b/fs/proc/proc_sysctl.c
61258 @@ -11,13 +11,21 @@
61259 #include <linux/namei.h>
61260 #include <linux/mm.h>
61261 #include <linux/module.h>
61262 +#include <linux/nsproxy.h>
61263 +#ifdef CONFIG_GRKERNSEC
61264 +#include <net/net_namespace.h>
61265 +#endif
61266 #include "internal.h"
61267
61268 +extern int gr_handle_chroot_sysctl(const int op);
61269 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
61270 + const int op);
61271 +
61272 static const struct dentry_operations proc_sys_dentry_operations;
61273 static const struct file_operations proc_sys_file_operations;
61274 -static const struct inode_operations proc_sys_inode_operations;
61275 +const struct inode_operations proc_sys_inode_operations;
61276 static const struct file_operations proc_sys_dir_file_operations;
61277 -static const struct inode_operations proc_sys_dir_operations;
61278 +const struct inode_operations proc_sys_dir_operations;
61279
61280 void proc_sys_poll_notify(struct ctl_table_poll *poll)
61281 {
61282 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
61283
61284 err = NULL;
61285 d_set_d_op(dentry, &proc_sys_dentry_operations);
61286 +
61287 + gr_handle_proc_create(dentry, inode);
61288 +
61289 d_add(dentry, inode);
61290
61291 out:
61292 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61293 struct inode *inode = file_inode(filp);
61294 struct ctl_table_header *head = grab_header(inode);
61295 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
61296 + int op = write ? MAY_WRITE : MAY_READ;
61297 ssize_t error;
61298 size_t res;
61299
61300 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61301 * and won't be until we finish.
61302 */
61303 error = -EPERM;
61304 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
61305 + if (sysctl_perm(head, table, op))
61306 goto out;
61307
61308 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
61309 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61310 if (!table->proc_handler)
61311 goto out;
61312
61313 +#ifdef CONFIG_GRKERNSEC
61314 + error = -EPERM;
61315 + if (gr_handle_chroot_sysctl(op))
61316 + goto out;
61317 + dget(filp->f_path.dentry);
61318 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
61319 + dput(filp->f_path.dentry);
61320 + goto out;
61321 + }
61322 + dput(filp->f_path.dentry);
61323 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
61324 + goto out;
61325 + if (write) {
61326 + if (current->nsproxy->net_ns != table->extra2) {
61327 + if (!capable(CAP_SYS_ADMIN))
61328 + goto out;
61329 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
61330 + goto out;
61331 + }
61332 +#endif
61333 +
61334 /* careful: calling conventions are nasty here */
61335 res = count;
61336 error = table->proc_handler(table, write, buf, &res, ppos);
61337 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
61338 return false;
61339 } else {
61340 d_set_d_op(child, &proc_sys_dentry_operations);
61341 +
61342 + gr_handle_proc_create(child, inode);
61343 +
61344 d_add(child, inode);
61345 }
61346 } else {
61347 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
61348 if ((*pos)++ < ctx->pos)
61349 return true;
61350
61351 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
61352 + return 0;
61353 +
61354 if (unlikely(S_ISLNK(table->mode)))
61355 res = proc_sys_link_fill_cache(file, ctx, head, table);
61356 else
61357 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
61358 if (IS_ERR(head))
61359 return PTR_ERR(head);
61360
61361 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
61362 + return -ENOENT;
61363 +
61364 generic_fillattr(inode, stat);
61365 if (table)
61366 stat->mode = (stat->mode & S_IFMT) | table->mode;
61367 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
61368 .llseek = generic_file_llseek,
61369 };
61370
61371 -static const struct inode_operations proc_sys_inode_operations = {
61372 +const struct inode_operations proc_sys_inode_operations = {
61373 .permission = proc_sys_permission,
61374 .setattr = proc_sys_setattr,
61375 .getattr = proc_sys_getattr,
61376 };
61377
61378 -static const struct inode_operations proc_sys_dir_operations = {
61379 +const struct inode_operations proc_sys_dir_operations = {
61380 .lookup = proc_sys_lookup,
61381 .permission = proc_sys_permission,
61382 .setattr = proc_sys_setattr,
61383 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
61384 static struct ctl_dir *new_dir(struct ctl_table_set *set,
61385 const char *name, int namelen)
61386 {
61387 - struct ctl_table *table;
61388 + ctl_table_no_const *table;
61389 struct ctl_dir *new;
61390 struct ctl_node *node;
61391 char *new_name;
61392 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
61393 return NULL;
61394
61395 node = (struct ctl_node *)(new + 1);
61396 - table = (struct ctl_table *)(node + 1);
61397 + table = (ctl_table_no_const *)(node + 1);
61398 new_name = (char *)(table + 2);
61399 memcpy(new_name, name, namelen);
61400 new_name[namelen] = '\0';
61401 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
61402 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
61403 struct ctl_table_root *link_root)
61404 {
61405 - struct ctl_table *link_table, *entry, *link;
61406 + ctl_table_no_const *link_table, *link;
61407 + struct ctl_table *entry;
61408 struct ctl_table_header *links;
61409 struct ctl_node *node;
61410 char *link_name;
61411 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
61412 return NULL;
61413
61414 node = (struct ctl_node *)(links + 1);
61415 - link_table = (struct ctl_table *)(node + nr_entries);
61416 + link_table = (ctl_table_no_const *)(node + nr_entries);
61417 link_name = (char *)&link_table[nr_entries + 1];
61418
61419 for (link = link_table, entry = table; entry->procname; link++, entry++) {
61420 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61421 struct ctl_table_header ***subheader, struct ctl_table_set *set,
61422 struct ctl_table *table)
61423 {
61424 - struct ctl_table *ctl_table_arg = NULL;
61425 - struct ctl_table *entry, *files;
61426 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
61427 + struct ctl_table *entry;
61428 int nr_files = 0;
61429 int nr_dirs = 0;
61430 int err = -ENOMEM;
61431 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61432 nr_files++;
61433 }
61434
61435 - files = table;
61436 /* If there are mixed files and directories we need a new table */
61437 if (nr_dirs && nr_files) {
61438 - struct ctl_table *new;
61439 + ctl_table_no_const *new;
61440 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
61441 GFP_KERNEL);
61442 if (!files)
61443 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61444 /* Register everything except a directory full of subdirectories */
61445 if (nr_files || !nr_dirs) {
61446 struct ctl_table_header *header;
61447 - header = __register_sysctl_table(set, path, files);
61448 + header = __register_sysctl_table(set, path, files ? files : table);
61449 if (!header) {
61450 kfree(ctl_table_arg);
61451 goto out;
61452 diff --git a/fs/proc/root.c b/fs/proc/root.c
61453 index 87dbcbe..55e1b4d 100644
61454 --- a/fs/proc/root.c
61455 +++ b/fs/proc/root.c
61456 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
61457 #ifdef CONFIG_PROC_DEVICETREE
61458 proc_device_tree_init();
61459 #endif
61460 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61461 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61462 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
61463 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61464 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
61465 +#endif
61466 +#else
61467 proc_mkdir("bus", NULL);
61468 +#endif
61469 proc_sys_init();
61470 }
61471
61472 diff --git a/fs/proc/self.c b/fs/proc/self.c
61473 index 6b6a993..807cccc 100644
61474 --- a/fs/proc/self.c
61475 +++ b/fs/proc/self.c
61476 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
61477 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
61478 void *cookie)
61479 {
61480 - char *s = nd_get_link(nd);
61481 + const char *s = nd_get_link(nd);
61482 if (!IS_ERR(s))
61483 kfree(s);
61484 }
61485 diff --git a/fs/proc/stat.c b/fs/proc/stat.c
61486 index 1cf86c0..0ee1ca5 100644
61487 --- a/fs/proc/stat.c
61488 +++ b/fs/proc/stat.c
61489 @@ -11,6 +11,7 @@
61490 #include <linux/irqnr.h>
61491 #include <asm/cputime.h>
61492 #include <linux/tick.h>
61493 +#include <linux/grsecurity.h>
61494
61495 #ifndef arch_irq_stat_cpu
61496 #define arch_irq_stat_cpu(cpu) 0
61497 @@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
61498 u64 sum_softirq = 0;
61499 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
61500 struct timespec boottime;
61501 + int unrestricted = 1;
61502 +
61503 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61504 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61505 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
61506 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
61507 + && !in_group_p(grsec_proc_gid)
61508 +#endif
61509 + )
61510 + unrestricted = 0;
61511 +#endif
61512 +#endif
61513
61514 user = nice = system = idle = iowait =
61515 irq = softirq = steal = 0;
61516 @@ -94,6 +107,7 @@ static int show_stat(struct seq_file *p, void *v)
61517 getboottime(&boottime);
61518 jif = boottime.tv_sec;
61519
61520 + if (unrestricted) {
61521 for_each_possible_cpu(i) {
61522 user += kcpustat_cpu(i).cpustat[CPUTIME_USER];
61523 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
61524 @@ -116,6 +130,7 @@ static int show_stat(struct seq_file *p, void *v)
61525 }
61526 }
61527 sum += arch_irq_stat();
61528 + }
61529
61530 seq_puts(p, "cpu ");
61531 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
61532 @@ -131,6 +146,7 @@ static int show_stat(struct seq_file *p, void *v)
61533 seq_putc(p, '\n');
61534
61535 for_each_online_cpu(i) {
61536 + if (unrestricted) {
61537 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
61538 user = kcpustat_cpu(i).cpustat[CPUTIME_USER];
61539 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
61540 @@ -142,6 +158,7 @@ static int show_stat(struct seq_file *p, void *v)
61541 steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
61542 guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
61543 guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
61544 + }
61545 seq_printf(p, "cpu%d", i);
61546 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
61547 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
61548 @@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
61549
61550 /* sum again ? it could be updated? */
61551 for_each_irq_nr(j)
61552 - seq_put_decimal_ull(p, ' ', kstat_irqs(j));
61553 + seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs(j) : 0ULL);
61554
61555 seq_printf(p,
61556 "\nctxt %llu\n"
61557 @@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
61558 "processes %lu\n"
61559 "procs_running %lu\n"
61560 "procs_blocked %lu\n",
61561 - nr_context_switches(),
61562 + unrestricted ? nr_context_switches() : 0ULL,
61563 (unsigned long)jif,
61564 - total_forks,
61565 - nr_running(),
61566 - nr_iowait());
61567 + unrestricted ? total_forks : 0UL,
61568 + unrestricted ? nr_running() : 0UL,
61569 + unrestricted ? nr_iowait() : 0UL);
61570
61571 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
61572
61573 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
61574 index 390bdab..83c1e8a 100644
61575 --- a/fs/proc/task_mmu.c
61576 +++ b/fs/proc/task_mmu.c
61577 @@ -12,12 +12,19 @@
61578 #include <linux/swap.h>
61579 #include <linux/swapops.h>
61580 #include <linux/mmu_notifier.h>
61581 +#include <linux/grsecurity.h>
61582
61583 #include <asm/elf.h>
61584 #include <asm/uaccess.h>
61585 #include <asm/tlbflush.h>
61586 #include "internal.h"
61587
61588 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61589 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
61590 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
61591 + _mm->pax_flags & MF_PAX_SEGMEXEC))
61592 +#endif
61593 +
61594 void task_mem(struct seq_file *m, struct mm_struct *mm)
61595 {
61596 unsigned long data, text, lib, swap;
61597 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61598 "VmExe:\t%8lu kB\n"
61599 "VmLib:\t%8lu kB\n"
61600 "VmPTE:\t%8lu kB\n"
61601 - "VmSwap:\t%8lu kB\n",
61602 - hiwater_vm << (PAGE_SHIFT-10),
61603 + "VmSwap:\t%8lu kB\n"
61604 +
61605 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61606 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
61607 +#endif
61608 +
61609 + ,hiwater_vm << (PAGE_SHIFT-10),
61610 total_vm << (PAGE_SHIFT-10),
61611 mm->locked_vm << (PAGE_SHIFT-10),
61612 mm->pinned_vm << (PAGE_SHIFT-10),
61613 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61614 data << (PAGE_SHIFT-10),
61615 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
61616 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
61617 - swap << (PAGE_SHIFT-10));
61618 + swap << (PAGE_SHIFT-10)
61619 +
61620 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61621 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61622 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
61623 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
61624 +#else
61625 + , mm->context.user_cs_base
61626 + , mm->context.user_cs_limit
61627 +#endif
61628 +#endif
61629 +
61630 + );
61631 }
61632
61633 unsigned long task_vsize(struct mm_struct *mm)
61634 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61635 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
61636 }
61637
61638 - /* We don't show the stack guard page in /proc/maps */
61639 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61640 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
61641 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
61642 +#else
61643 start = vma->vm_start;
61644 - if (stack_guard_page_start(vma, start))
61645 - start += PAGE_SIZE;
61646 end = vma->vm_end;
61647 - if (stack_guard_page_end(vma, end))
61648 - end -= PAGE_SIZE;
61649 +#endif
61650
61651 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
61652 start,
61653 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61654 flags & VM_WRITE ? 'w' : '-',
61655 flags & VM_EXEC ? 'x' : '-',
61656 flags & VM_MAYSHARE ? 's' : 'p',
61657 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61658 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
61659 +#else
61660 pgoff,
61661 +#endif
61662 MAJOR(dev), MINOR(dev), ino, &len);
61663
61664 /*
61665 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61666 */
61667 if (file) {
61668 pad_len_spaces(m, len);
61669 - seq_path(m, &file->f_path, "\n");
61670 + seq_path(m, &file->f_path, "\n\\");
61671 goto done;
61672 }
61673
61674 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61675 * Thread stack in /proc/PID/task/TID/maps or
61676 * the main process stack.
61677 */
61678 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
61679 - vma->vm_end >= mm->start_stack)) {
61680 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
61681 + (vma->vm_start <= mm->start_stack &&
61682 + vma->vm_end >= mm->start_stack)) {
61683 name = "[stack]";
61684 } else {
61685 /* Thread stack in /proc/PID/maps */
61686 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
61687 struct proc_maps_private *priv = m->private;
61688 struct task_struct *task = priv->task;
61689
61690 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61691 + if (current->exec_id != m->exec_id) {
61692 + gr_log_badprocpid("maps");
61693 + return 0;
61694 + }
61695 +#endif
61696 +
61697 show_map_vma(m, vma, is_pid);
61698
61699 if (m->count < m->size) /* vma is copied successfully */
61700 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61701 .private = &mss,
61702 };
61703
61704 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61705 + if (current->exec_id != m->exec_id) {
61706 + gr_log_badprocpid("smaps");
61707 + return 0;
61708 + }
61709 +#endif
61710 memset(&mss, 0, sizeof mss);
61711 - mss.vma = vma;
61712 - /* mmap_sem is held in m_start */
61713 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61714 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61715 -
61716 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61717 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
61718 +#endif
61719 + mss.vma = vma;
61720 + /* mmap_sem is held in m_start */
61721 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61722 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61723 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61724 + }
61725 +#endif
61726 show_map_vma(m, vma, is_pid);
61727
61728 seq_printf(m,
61729 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61730 "KernelPageSize: %8lu kB\n"
61731 "MMUPageSize: %8lu kB\n"
61732 "Locked: %8lu kB\n",
61733 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61734 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
61735 +#else
61736 (vma->vm_end - vma->vm_start) >> 10,
61737 +#endif
61738 mss.resident >> 10,
61739 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
61740 mss.shared_clean >> 10,
61741 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61742 int n;
61743 char buffer[50];
61744
61745 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61746 + if (current->exec_id != m->exec_id) {
61747 + gr_log_badprocpid("numa_maps");
61748 + return 0;
61749 + }
61750 +#endif
61751 +
61752 if (!mm)
61753 return 0;
61754
61755 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61756 if (n < 0)
61757 return n;
61758
61759 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61760 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
61761 +#else
61762 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
61763 +#endif
61764
61765 if (file) {
61766 seq_printf(m, " file=");
61767 - seq_path(m, &file->f_path, "\n\t= ");
61768 + seq_path(m, &file->f_path, "\n\t\\= ");
61769 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
61770 seq_printf(m, " heap");
61771 } else {
61772 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
61773 index 56123a6..5a2f6ec 100644
61774 --- a/fs/proc/task_nommu.c
61775 +++ b/fs/proc/task_nommu.c
61776 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61777 else
61778 bytes += kobjsize(mm);
61779
61780 - if (current->fs && current->fs->users > 1)
61781 + if (current->fs && atomic_read(&current->fs->users) > 1)
61782 sbytes += kobjsize(current->fs);
61783 else
61784 bytes += kobjsize(current->fs);
61785 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
61786
61787 if (file) {
61788 pad_len_spaces(m, len);
61789 - seq_path(m, &file->f_path, "");
61790 + seq_path(m, &file->f_path, "\n\\");
61791 } else if (mm) {
61792 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
61793
61794 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
61795 index 9100d69..f1f9fc9 100644
61796 --- a/fs/proc/vmcore.c
61797 +++ b/fs/proc/vmcore.c
61798 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
61799 nr_bytes = count;
61800
61801 /* If pfn is not ram, return zeros for sparse dump files */
61802 - if (pfn_is_ram(pfn) == 0)
61803 - memset(buf, 0, nr_bytes);
61804 - else {
61805 + if (pfn_is_ram(pfn) == 0) {
61806 + if (userbuf) {
61807 + if (clear_user((char __force_user *)buf, nr_bytes))
61808 + return -EFAULT;
61809 + } else
61810 + memset(buf, 0, nr_bytes);
61811 + } else {
61812 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
61813 offset, userbuf);
61814 if (tmp < 0)
61815 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
61816 if (*fpos < m->offset + m->size) {
61817 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
61818 start = m->paddr + *fpos - m->offset;
61819 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
61820 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
61821 if (tmp < 0)
61822 return tmp;
61823 buflen -= tsz;
61824 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
61825 index b00fcc9..e0c6381 100644
61826 --- a/fs/qnx6/qnx6.h
61827 +++ b/fs/qnx6/qnx6.h
61828 @@ -74,7 +74,7 @@ enum {
61829 BYTESEX_BE,
61830 };
61831
61832 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61833 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61834 {
61835 if (sbi->s_bytesex == BYTESEX_LE)
61836 return le64_to_cpu((__force __le64)n);
61837 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
61838 return (__force __fs64)cpu_to_be64(n);
61839 }
61840
61841 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61842 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61843 {
61844 if (sbi->s_bytesex == BYTESEX_LE)
61845 return le32_to_cpu((__force __le32)n);
61846 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
61847 index 16e8abb..2dcf914 100644
61848 --- a/fs/quota/netlink.c
61849 +++ b/fs/quota/netlink.c
61850 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
61851 void quota_send_warning(struct kqid qid, dev_t dev,
61852 const char warntype)
61853 {
61854 - static atomic_t seq;
61855 + static atomic_unchecked_t seq;
61856 struct sk_buff *skb;
61857 void *msg_head;
61858 int ret;
61859 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
61860 "VFS: Not enough memory to send quota warning.\n");
61861 return;
61862 }
61863 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
61864 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
61865 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
61866 if (!msg_head) {
61867 printk(KERN_ERR
61868 diff --git a/fs/read_write.c b/fs/read_write.c
61869 index e3cd280..a378473 100644
61870 --- a/fs/read_write.c
61871 +++ b/fs/read_write.c
61872 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
61873
61874 old_fs = get_fs();
61875 set_fs(get_ds());
61876 - p = (__force const char __user *)buf;
61877 + p = (const char __force_user *)buf;
61878 if (count > MAX_RW_COUNT)
61879 count = MAX_RW_COUNT;
61880 if (file->f_op->write)
61881 diff --git a/fs/readdir.c b/fs/readdir.c
61882 index 93d71e5..6a14be8 100644
61883 --- a/fs/readdir.c
61884 +++ b/fs/readdir.c
61885 @@ -17,6 +17,7 @@
61886 #include <linux/security.h>
61887 #include <linux/syscalls.h>
61888 #include <linux/unistd.h>
61889 +#include <linux/namei.h>
61890
61891 #include <asm/uaccess.h>
61892
61893 @@ -69,6 +70,7 @@ struct old_linux_dirent {
61894 struct readdir_callback {
61895 struct dir_context ctx;
61896 struct old_linux_dirent __user * dirent;
61897 + struct file * file;
61898 int result;
61899 };
61900
61901 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
61902 buf->result = -EOVERFLOW;
61903 return -EOVERFLOW;
61904 }
61905 +
61906 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61907 + return 0;
61908 +
61909 buf->result++;
61910 dirent = buf->dirent;
61911 if (!access_ok(VERIFY_WRITE, dirent,
61912 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
61913 if (!f.file)
61914 return -EBADF;
61915
61916 + buf.file = f.file;
61917 error = iterate_dir(f.file, &buf.ctx);
61918 if (buf.result)
61919 error = buf.result;
61920 @@ -142,6 +149,7 @@ struct getdents_callback {
61921 struct dir_context ctx;
61922 struct linux_dirent __user * current_dir;
61923 struct linux_dirent __user * previous;
61924 + struct file * file;
61925 int count;
61926 int error;
61927 };
61928 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
61929 buf->error = -EOVERFLOW;
61930 return -EOVERFLOW;
61931 }
61932 +
61933 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61934 + return 0;
61935 +
61936 dirent = buf->previous;
61937 if (dirent) {
61938 if (__put_user(offset, &dirent->d_off))
61939 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61940 if (!f.file)
61941 return -EBADF;
61942
61943 + buf.file = f.file;
61944 error = iterate_dir(f.file, &buf.ctx);
61945 if (error >= 0)
61946 error = buf.error;
61947 @@ -226,6 +239,7 @@ struct getdents_callback64 {
61948 struct dir_context ctx;
61949 struct linux_dirent64 __user * current_dir;
61950 struct linux_dirent64 __user * previous;
61951 + struct file *file;
61952 int count;
61953 int error;
61954 };
61955 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
61956 buf->error = -EINVAL; /* only used if we fail.. */
61957 if (reclen > buf->count)
61958 return -EINVAL;
61959 +
61960 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61961 + return 0;
61962 +
61963 dirent = buf->previous;
61964 if (dirent) {
61965 if (__put_user(offset, &dirent->d_off))
61966 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61967 if (!f.file)
61968 return -EBADF;
61969
61970 + buf.file = f.file;
61971 error = iterate_dir(f.file, &buf.ctx);
61972 if (error >= 0)
61973 error = buf.error;
61974 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
61975 index 2b7882b..1c5ef48 100644
61976 --- a/fs/reiserfs/do_balan.c
61977 +++ b/fs/reiserfs/do_balan.c
61978 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
61979 return;
61980 }
61981
61982 - atomic_inc(&(fs_generation(tb->tb_sb)));
61983 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
61984 do_balance_starts(tb);
61985
61986 /* balance leaf returns 0 except if combining L R and S into
61987 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
61988 index a958444..42b2323 100644
61989 --- a/fs/reiserfs/procfs.c
61990 +++ b/fs/reiserfs/procfs.c
61991 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61992 "SMALL_TAILS " : "NO_TAILS ",
61993 replay_only(sb) ? "REPLAY_ONLY " : "",
61994 convert_reiserfs(sb) ? "CONV " : "",
61995 - atomic_read(&r->s_generation_counter),
61996 + atomic_read_unchecked(&r->s_generation_counter),
61997 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61998 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61999 SF(s_good_search_by_key_reada), SF(s_bmaps),
62000 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
62001 index f8adaee..0eeeeca 100644
62002 --- a/fs/reiserfs/reiserfs.h
62003 +++ b/fs/reiserfs/reiserfs.h
62004 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
62005 /* Comment? -Hans */
62006 wait_queue_head_t s_wait;
62007 /* To be obsoleted soon by per buffer seals.. -Hans */
62008 - atomic_t s_generation_counter; // increased by one every time the
62009 + atomic_unchecked_t s_generation_counter; // increased by one every time the
62010 // tree gets re-balanced
62011 unsigned long s_properties; /* File system properties. Currently holds
62012 on-disk FS format */
62013 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
62014 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
62015
62016 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
62017 -#define get_generation(s) atomic_read (&fs_generation(s))
62018 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
62019 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
62020 #define __fs_changed(gen,s) (gen != get_generation (s))
62021 #define fs_changed(gen,s) \
62022 diff --git a/fs/select.c b/fs/select.c
62023 index dfd5cb1..1754d57 100644
62024 --- a/fs/select.c
62025 +++ b/fs/select.c
62026 @@ -20,6 +20,7 @@
62027 #include <linux/export.h>
62028 #include <linux/slab.h>
62029 #include <linux/poll.h>
62030 +#include <linux/security.h>
62031 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
62032 #include <linux/file.h>
62033 #include <linux/fdtable.h>
62034 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
62035 struct poll_list *walk = head;
62036 unsigned long todo = nfds;
62037
62038 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
62039 if (nfds > rlimit(RLIMIT_NOFILE))
62040 return -EINVAL;
62041
62042 diff --git a/fs/seq_file.c b/fs/seq_file.c
62043 index a290157..ec3211a 100644
62044 --- a/fs/seq_file.c
62045 +++ b/fs/seq_file.c
62046 @@ -10,6 +10,7 @@
62047 #include <linux/seq_file.h>
62048 #include <linux/slab.h>
62049 #include <linux/cred.h>
62050 +#include <linux/sched.h>
62051
62052 #include <asm/uaccess.h>
62053 #include <asm/page.h>
62054 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
62055 #ifdef CONFIG_USER_NS
62056 p->user_ns = file->f_cred->user_ns;
62057 #endif
62058 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
62059 + p->exec_id = current->exec_id;
62060 +#endif
62061
62062 /*
62063 * Wrappers around seq_open(e.g. swaps_open) need to be
62064 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
62065 return 0;
62066 }
62067 if (!m->buf) {
62068 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
62069 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
62070 if (!m->buf)
62071 return -ENOMEM;
62072 }
62073 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
62074 Eoverflow:
62075 m->op->stop(m, p);
62076 kfree(m->buf);
62077 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
62078 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
62079 return !m->buf ? -ENOMEM : -EAGAIN;
62080 }
62081
62082 @@ -152,7 +156,7 @@ Eoverflow:
62083 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
62084 {
62085 struct seq_file *m = file->private_data;
62086 - size_t copied = 0;
62087 + ssize_t copied = 0;
62088 loff_t pos;
62089 size_t n;
62090 void *p;
62091 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
62092
62093 /* grab buffer if we didn't have one */
62094 if (!m->buf) {
62095 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
62096 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
62097 if (!m->buf)
62098 goto Enomem;
62099 }
62100 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
62101 goto Fill;
62102 m->op->stop(m, p);
62103 kfree(m->buf);
62104 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
62105 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
62106 if (!m->buf)
62107 goto Enomem;
62108 m->count = 0;
62109 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
62110 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
62111 void *data)
62112 {
62113 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
62114 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
62115 int res = -ENOMEM;
62116
62117 if (op) {
62118 diff --git a/fs/splice.c b/fs/splice.c
62119 index 3b7ee65..87fc2e4 100644
62120 --- a/fs/splice.c
62121 +++ b/fs/splice.c
62122 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
62123 pipe_lock(pipe);
62124
62125 for (;;) {
62126 - if (!pipe->readers) {
62127 + if (!atomic_read(&pipe->readers)) {
62128 send_sig(SIGPIPE, current, 0);
62129 if (!ret)
62130 ret = -EPIPE;
62131 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
62132 page_nr++;
62133 ret += buf->len;
62134
62135 - if (pipe->files)
62136 + if (atomic_read(&pipe->files))
62137 do_wakeup = 1;
62138
62139 if (!--spd->nr_pages)
62140 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
62141 do_wakeup = 0;
62142 }
62143
62144 - pipe->waiting_writers++;
62145 + atomic_inc(&pipe->waiting_writers);
62146 pipe_wait(pipe);
62147 - pipe->waiting_writers--;
62148 + atomic_dec(&pipe->waiting_writers);
62149 }
62150
62151 pipe_unlock(pipe);
62152 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
62153 old_fs = get_fs();
62154 set_fs(get_ds());
62155 /* The cast to a user pointer is valid due to the set_fs() */
62156 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
62157 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
62158 set_fs(old_fs);
62159
62160 return res;
62161 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
62162 old_fs = get_fs();
62163 set_fs(get_ds());
62164 /* The cast to a user pointer is valid due to the set_fs() */
62165 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
62166 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
62167 set_fs(old_fs);
62168
62169 return res;
62170 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
62171 goto err;
62172
62173 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
62174 - vec[i].iov_base = (void __user *) page_address(page);
62175 + vec[i].iov_base = (void __force_user *) page_address(page);
62176 vec[i].iov_len = this_len;
62177 spd.pages[i] = page;
62178 spd.nr_pages++;
62179 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
62180 ops->release(pipe, buf);
62181 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
62182 pipe->nrbufs--;
62183 - if (pipe->files)
62184 + if (atomic_read(&pipe->files))
62185 sd->need_wakeup = true;
62186 }
62187
62188 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
62189 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
62190 {
62191 while (!pipe->nrbufs) {
62192 - if (!pipe->writers)
62193 + if (!atomic_read(&pipe->writers))
62194 return 0;
62195
62196 - if (!pipe->waiting_writers && sd->num_spliced)
62197 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
62198 return 0;
62199
62200 if (sd->flags & SPLICE_F_NONBLOCK)
62201 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
62202 * out of the pipe right after the splice_to_pipe(). So set
62203 * PIPE_READERS appropriately.
62204 */
62205 - pipe->readers = 1;
62206 + atomic_set(&pipe->readers, 1);
62207
62208 current->splice_pipe = pipe;
62209 }
62210 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
62211
62212 partial[buffers].offset = off;
62213 partial[buffers].len = plen;
62214 + partial[buffers].private = 0;
62215
62216 off = 0;
62217 len -= plen;
62218 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62219 ret = -ERESTARTSYS;
62220 break;
62221 }
62222 - if (!pipe->writers)
62223 + if (!atomic_read(&pipe->writers))
62224 break;
62225 - if (!pipe->waiting_writers) {
62226 + if (!atomic_read(&pipe->waiting_writers)) {
62227 if (flags & SPLICE_F_NONBLOCK) {
62228 ret = -EAGAIN;
62229 break;
62230 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62231 pipe_lock(pipe);
62232
62233 while (pipe->nrbufs >= pipe->buffers) {
62234 - if (!pipe->readers) {
62235 + if (!atomic_read(&pipe->readers)) {
62236 send_sig(SIGPIPE, current, 0);
62237 ret = -EPIPE;
62238 break;
62239 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62240 ret = -ERESTARTSYS;
62241 break;
62242 }
62243 - pipe->waiting_writers++;
62244 + atomic_inc(&pipe->waiting_writers);
62245 pipe_wait(pipe);
62246 - pipe->waiting_writers--;
62247 + atomic_dec(&pipe->waiting_writers);
62248 }
62249
62250 pipe_unlock(pipe);
62251 @@ -1862,14 +1863,14 @@ retry:
62252 pipe_double_lock(ipipe, opipe);
62253
62254 do {
62255 - if (!opipe->readers) {
62256 + if (!atomic_read(&opipe->readers)) {
62257 send_sig(SIGPIPE, current, 0);
62258 if (!ret)
62259 ret = -EPIPE;
62260 break;
62261 }
62262
62263 - if (!ipipe->nrbufs && !ipipe->writers)
62264 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
62265 break;
62266
62267 /*
62268 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
62269 pipe_double_lock(ipipe, opipe);
62270
62271 do {
62272 - if (!opipe->readers) {
62273 + if (!atomic_read(&opipe->readers)) {
62274 send_sig(SIGPIPE, current, 0);
62275 if (!ret)
62276 ret = -EPIPE;
62277 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
62278 * return EAGAIN if we have the potential of some data in the
62279 * future, otherwise just return 0
62280 */
62281 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
62282 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
62283 ret = -EAGAIN;
62284
62285 pipe_unlock(ipipe);
62286 diff --git a/fs/stat.c b/fs/stat.c
62287 index ae0c3ce..9ee641c 100644
62288 --- a/fs/stat.c
62289 +++ b/fs/stat.c
62290 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
62291 stat->gid = inode->i_gid;
62292 stat->rdev = inode->i_rdev;
62293 stat->size = i_size_read(inode);
62294 - stat->atime = inode->i_atime;
62295 - stat->mtime = inode->i_mtime;
62296 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62297 + stat->atime = inode->i_ctime;
62298 + stat->mtime = inode->i_ctime;
62299 + } else {
62300 + stat->atime = inode->i_atime;
62301 + stat->mtime = inode->i_mtime;
62302 + }
62303 stat->ctime = inode->i_ctime;
62304 stat->blksize = (1 << inode->i_blkbits);
62305 stat->blocks = inode->i_blocks;
62306 @@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
62307 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
62308 {
62309 struct inode *inode = path->dentry->d_inode;
62310 + int retval;
62311
62312 - if (inode->i_op->getattr)
62313 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
62314 + if (inode->i_op->getattr) {
62315 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
62316 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62317 + stat->atime = stat->ctime;
62318 + stat->mtime = stat->ctime;
62319 + }
62320 + return retval;
62321 + }
62322
62323 generic_fillattr(inode, stat);
62324 return 0;
62325 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
62326 index c590cab..6dfd6fc 100644
62327 --- a/fs/sysfs/bin.c
62328 +++ b/fs/sysfs/bin.c
62329 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
62330 return ret;
62331 }
62332
62333 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
62334 - void *buf, int len, int write)
62335 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
62336 + void *buf, size_t len, int write)
62337 {
62338 struct file *file = vma->vm_file;
62339 struct bin_buffer *bb = file->private_data;
62340 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
62341 - int ret;
62342 + ssize_t ret;
62343
62344 if (!bb->vm_ops)
62345 return -EINVAL;
62346 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
62347 index 4d83ced..049dc45 100644
62348 --- a/fs/sysfs/dir.c
62349 +++ b/fs/sysfs/dir.c
62350 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
62351 *
62352 * Returns 31 bit hash of ns + name (so it fits in an off_t )
62353 */
62354 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
62355 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
62356 {
62357 unsigned long hash = init_name_hash();
62358 unsigned int len = strlen(name);
62359 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
62360 struct sysfs_dirent *sd;
62361 int rc;
62362
62363 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
62364 + const char *parent_name = parent_sd->s_name;
62365 +
62366 + mode = S_IFDIR | S_IRWXU;
62367 +
62368 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
62369 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
62370 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
62371 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
62372 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
62373 +#endif
62374 +
62375 /* allocate */
62376 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
62377 if (!sd)
62378 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
62379 index 15ef5eb..e474372 100644
62380 --- a/fs/sysfs/file.c
62381 +++ b/fs/sysfs/file.c
62382 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
62383
62384 struct sysfs_open_dirent {
62385 atomic_t refcnt;
62386 - atomic_t event;
62387 + atomic_unchecked_t event;
62388 wait_queue_head_t poll;
62389 struct list_head buffers; /* goes through sysfs_buffer.list */
62390 };
62391 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
62392 if (!sysfs_get_active(attr_sd))
62393 return -ENODEV;
62394
62395 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
62396 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
62397 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
62398
62399 sysfs_put_active(attr_sd);
62400 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
62401 return -ENOMEM;
62402
62403 atomic_set(&new_od->refcnt, 0);
62404 - atomic_set(&new_od->event, 1);
62405 + atomic_set_unchecked(&new_od->event, 1);
62406 init_waitqueue_head(&new_od->poll);
62407 INIT_LIST_HEAD(&new_od->buffers);
62408 goto retry;
62409 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
62410
62411 sysfs_put_active(attr_sd);
62412
62413 - if (buffer->event != atomic_read(&od->event))
62414 + if (buffer->event != atomic_read_unchecked(&od->event))
62415 goto trigger;
62416
62417 return DEFAULT_POLLMASK;
62418 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
62419 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
62420 od = sd->s_attr.open;
62421 if (od) {
62422 - atomic_inc(&od->event);
62423 + atomic_inc_unchecked(&od->event);
62424 wake_up_interruptible(&od->poll);
62425 }
62426 }
62427 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
62428 index 2dd4507..62a215a 100644
62429 --- a/fs/sysfs/symlink.c
62430 +++ b/fs/sysfs/symlink.c
62431 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
62432 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
62433 void *cookie)
62434 {
62435 - char *page = nd_get_link(nd);
62436 + const char *page = nd_get_link(nd);
62437 if (!IS_ERR(page))
62438 free_page((unsigned long)page);
62439 }
62440 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
62441 index 69d4889..a810bd4 100644
62442 --- a/fs/sysv/sysv.h
62443 +++ b/fs/sysv/sysv.h
62444 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
62445 #endif
62446 }
62447
62448 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62449 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62450 {
62451 if (sbi->s_bytesex == BYTESEX_PDP)
62452 return PDP_swab((__force __u32)n);
62453 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
62454 index e18b988..f1d4ad0f 100644
62455 --- a/fs/ubifs/io.c
62456 +++ b/fs/ubifs/io.c
62457 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
62458 return err;
62459 }
62460
62461 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62462 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62463 {
62464 int err;
62465
62466 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
62467 index c175b4d..8f36a16 100644
62468 --- a/fs/udf/misc.c
62469 +++ b/fs/udf/misc.c
62470 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
62471
62472 u8 udf_tag_checksum(const struct tag *t)
62473 {
62474 - u8 *data = (u8 *)t;
62475 + const u8 *data = (const u8 *)t;
62476 u8 checksum = 0;
62477 int i;
62478 for (i = 0; i < sizeof(struct tag); ++i)
62479 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
62480 index 8d974c4..b82f6ec 100644
62481 --- a/fs/ufs/swab.h
62482 +++ b/fs/ufs/swab.h
62483 @@ -22,7 +22,7 @@ enum {
62484 BYTESEX_BE
62485 };
62486
62487 -static inline u64
62488 +static inline u64 __intentional_overflow(-1)
62489 fs64_to_cpu(struct super_block *sbp, __fs64 n)
62490 {
62491 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62492 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
62493 return (__force __fs64)cpu_to_be64(n);
62494 }
62495
62496 -static inline u32
62497 +static inline u32 __intentional_overflow(-1)
62498 fs32_to_cpu(struct super_block *sbp, __fs32 n)
62499 {
62500 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62501 diff --git a/fs/utimes.c b/fs/utimes.c
62502 index f4fb7ec..3fe03c0 100644
62503 --- a/fs/utimes.c
62504 +++ b/fs/utimes.c
62505 @@ -1,6 +1,7 @@
62506 #include <linux/compiler.h>
62507 #include <linux/file.h>
62508 #include <linux/fs.h>
62509 +#include <linux/security.h>
62510 #include <linux/linkage.h>
62511 #include <linux/mount.h>
62512 #include <linux/namei.h>
62513 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
62514 goto mnt_drop_write_and_out;
62515 }
62516 }
62517 +
62518 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
62519 + error = -EACCES;
62520 + goto mnt_drop_write_and_out;
62521 + }
62522 +
62523 mutex_lock(&inode->i_mutex);
62524 error = notify_change(path->dentry, &newattrs);
62525 mutex_unlock(&inode->i_mutex);
62526 diff --git a/fs/xattr.c b/fs/xattr.c
62527 index 3377dff..f394815 100644
62528 --- a/fs/xattr.c
62529 +++ b/fs/xattr.c
62530 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
62531 return rc;
62532 }
62533
62534 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
62535 +ssize_t
62536 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
62537 +{
62538 + struct inode *inode = dentry->d_inode;
62539 + ssize_t error;
62540 +
62541 + error = inode_permission(inode, MAY_EXEC);
62542 + if (error)
62543 + return error;
62544 +
62545 + if (inode->i_op->getxattr)
62546 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
62547 + else
62548 + error = -EOPNOTSUPP;
62549 +
62550 + return error;
62551 +}
62552 +EXPORT_SYMBOL(pax_getxattr);
62553 +#endif
62554 +
62555 ssize_t
62556 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
62557 {
62558 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
62559 * Extended attribute SET operations
62560 */
62561 static long
62562 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
62563 +setxattr(struct path *path, const char __user *name, const void __user *value,
62564 size_t size, int flags)
62565 {
62566 int error;
62567 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
62568 posix_acl_fix_xattr_from_user(kvalue, size);
62569 }
62570
62571 - error = vfs_setxattr(d, kname, kvalue, size, flags);
62572 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
62573 + error = -EACCES;
62574 + goto out;
62575 + }
62576 +
62577 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
62578 out:
62579 if (vvalue)
62580 vfree(vvalue);
62581 @@ -377,7 +403,7 @@ retry:
62582 return error;
62583 error = mnt_want_write(path.mnt);
62584 if (!error) {
62585 - error = setxattr(path.dentry, name, value, size, flags);
62586 + error = setxattr(&path, name, value, size, flags);
62587 mnt_drop_write(path.mnt);
62588 }
62589 path_put(&path);
62590 @@ -401,7 +427,7 @@ retry:
62591 return error;
62592 error = mnt_want_write(path.mnt);
62593 if (!error) {
62594 - error = setxattr(path.dentry, name, value, size, flags);
62595 + error = setxattr(&path, name, value, size, flags);
62596 mnt_drop_write(path.mnt);
62597 }
62598 path_put(&path);
62599 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
62600 const void __user *,value, size_t, size, int, flags)
62601 {
62602 struct fd f = fdget(fd);
62603 - struct dentry *dentry;
62604 int error = -EBADF;
62605
62606 if (!f.file)
62607 return error;
62608 - dentry = f.file->f_path.dentry;
62609 - audit_inode(NULL, dentry, 0);
62610 + audit_inode(NULL, f.file->f_path.dentry, 0);
62611 error = mnt_want_write_file(f.file);
62612 if (!error) {
62613 - error = setxattr(dentry, name, value, size, flags);
62614 + error = setxattr(&f.file->f_path, name, value, size, flags);
62615 mnt_drop_write_file(f.file);
62616 }
62617 fdput(f);
62618 @@ -626,7 +650,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
62619 * Extended attribute REMOVE operations
62620 */
62621 static long
62622 -removexattr(struct dentry *d, const char __user *name)
62623 +removexattr(struct path *path, const char __user *name)
62624 {
62625 int error;
62626 char kname[XATTR_NAME_MAX + 1];
62627 @@ -637,7 +661,10 @@ removexattr(struct dentry *d, const char __user *name)
62628 if (error < 0)
62629 return error;
62630
62631 - return vfs_removexattr(d, kname);
62632 + if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
62633 + return -EACCES;
62634 +
62635 + return vfs_removexattr(path->dentry, kname);
62636 }
62637
62638 SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
62639 @@ -652,7 +679,7 @@ retry:
62640 return error;
62641 error = mnt_want_write(path.mnt);
62642 if (!error) {
62643 - error = removexattr(path.dentry, name);
62644 + error = removexattr(&path, name);
62645 mnt_drop_write(path.mnt);
62646 }
62647 path_put(&path);
62648 @@ -675,7 +702,7 @@ retry:
62649 return error;
62650 error = mnt_want_write(path.mnt);
62651 if (!error) {
62652 - error = removexattr(path.dentry, name);
62653 + error = removexattr(&path, name);
62654 mnt_drop_write(path.mnt);
62655 }
62656 path_put(&path);
62657 @@ -689,16 +716,16 @@ retry:
62658 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
62659 {
62660 struct fd f = fdget(fd);
62661 - struct dentry *dentry;
62662 + struct path *path;
62663 int error = -EBADF;
62664
62665 if (!f.file)
62666 return error;
62667 - dentry = f.file->f_path.dentry;
62668 - audit_inode(NULL, dentry, 0);
62669 + path = &f.file->f_path;
62670 + audit_inode(NULL, path->dentry, 0);
62671 error = mnt_want_write_file(f.file);
62672 if (!error) {
62673 - error = removexattr(dentry, name);
62674 + error = removexattr(path, name);
62675 mnt_drop_write_file(f.file);
62676 }
62677 fdput(f);
62678 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
62679 index 9fbea87..6b19972 100644
62680 --- a/fs/xattr_acl.c
62681 +++ b/fs/xattr_acl.c
62682 @@ -76,8 +76,8 @@ struct posix_acl *
62683 posix_acl_from_xattr(struct user_namespace *user_ns,
62684 const void *value, size_t size)
62685 {
62686 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62687 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62688 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62689 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62690 int count;
62691 struct posix_acl *acl;
62692 struct posix_acl_entry *acl_e;
62693 diff --git a/fs/xfs/xfs_attr_remote.c b/fs/xfs/xfs_attr_remote.c
62694 index 712a502..18180a3 100644
62695 --- a/fs/xfs/xfs_attr_remote.c
62696 +++ b/fs/xfs/xfs_attr_remote.c
62697 @@ -110,7 +110,7 @@ xfs_attr3_rmt_verify(
62698 if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
62699 return false;
62700 if (be32_to_cpu(rmt->rm_offset) +
62701 - be32_to_cpu(rmt->rm_bytes) >= XATTR_SIZE_MAX)
62702 + be32_to_cpu(rmt->rm_bytes) > XATTR_SIZE_MAX)
62703 return false;
62704 if (rmt->rm_owner == 0)
62705 return false;
62706 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
62707 index f47e65c..e7125d9 100644
62708 --- a/fs/xfs/xfs_bmap.c
62709 +++ b/fs/xfs/xfs_bmap.c
62710 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
62711
62712 #else
62713 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
62714 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
62715 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
62716 #endif /* DEBUG */
62717
62718 /*
62719 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
62720 index 8f84153..7ce60d0 100644
62721 --- a/fs/xfs/xfs_dir2_readdir.c
62722 +++ b/fs/xfs/xfs_dir2_readdir.c
62723 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
62724 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
62725 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
62726 ctx->pos = off & 0x7fffffff;
62727 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62728 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
62729 + char name[sfep->namelen];
62730 + memcpy(name, sfep->name, sfep->namelen);
62731 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
62732 + return 0;
62733 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62734 xfs_dir3_get_dtype(mp, filetype)))
62735 return 0;
62736 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
62737 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
62738 index 8c8ef24..689f742 100644
62739 --- a/fs/xfs/xfs_ioctl.c
62740 +++ b/fs/xfs/xfs_ioctl.c
62741 @@ -127,7 +127,7 @@ xfs_find_handle(
62742 }
62743
62744 error = -EFAULT;
62745 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
62746 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
62747 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
62748 goto out_put;
62749
62750 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
62751 index 2b8952d..a60c6be 100644
62752 --- a/fs/xfs/xfs_iops.c
62753 +++ b/fs/xfs/xfs_iops.c
62754 @@ -401,7 +401,7 @@ xfs_vn_put_link(
62755 struct nameidata *nd,
62756 void *p)
62757 {
62758 - char *s = nd_get_link(nd);
62759 + const char *s = nd_get_link(nd);
62760
62761 if (!IS_ERR(s))
62762 kfree(s);
62763 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
62764 new file mode 100644
62765 index 0000000..5b2538b
62766 --- /dev/null
62767 +++ b/grsecurity/Kconfig
62768 @@ -0,0 +1,1116 @@
62769 +#
62770 +# grecurity configuration
62771 +#
62772 +menu "Memory Protections"
62773 +depends on GRKERNSEC
62774 +
62775 +config GRKERNSEC_KMEM
62776 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
62777 + default y if GRKERNSEC_CONFIG_AUTO
62778 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
62779 + help
62780 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
62781 + be written to or read from to modify or leak the contents of the running
62782 + kernel. /dev/port will also not be allowed to be opened, and support
62783 + for /dev/cpu/*/msr and kexec will be removed. If you have module
62784 + support disabled, enabling this will close up six ways that are
62785 + currently used to insert malicious code into the running kernel.
62786 +
62787 + Even with this feature enabled, we still highly recommend that
62788 + you use the RBAC system, as it is still possible for an attacker to
62789 + modify the running kernel through other more obscure methods.
62790 +
62791 + Enabling this feature will prevent the "cpupower" and "powertop" tools
62792 + from working.
62793 +
62794 + It is highly recommended that you say Y here if you meet all the
62795 + conditions above.
62796 +
62797 +config GRKERNSEC_VM86
62798 + bool "Restrict VM86 mode"
62799 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62800 + depends on X86_32
62801 +
62802 + help
62803 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
62804 + make use of a special execution mode on 32bit x86 processors called
62805 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
62806 + video cards and will still work with this option enabled. The purpose
62807 + of the option is to prevent exploitation of emulation errors in
62808 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
62809 + Nearly all users should be able to enable this option.
62810 +
62811 +config GRKERNSEC_IO
62812 + bool "Disable privileged I/O"
62813 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62814 + depends on X86
62815 + select RTC_CLASS
62816 + select RTC_INTF_DEV
62817 + select RTC_DRV_CMOS
62818 +
62819 + help
62820 + If you say Y here, all ioperm and iopl calls will return an error.
62821 + Ioperm and iopl can be used to modify the running kernel.
62822 + Unfortunately, some programs need this access to operate properly,
62823 + the most notable of which are XFree86 and hwclock. hwclock can be
62824 + remedied by having RTC support in the kernel, so real-time
62825 + clock support is enabled if this option is enabled, to ensure
62826 + that hwclock operates correctly.
62827 +
62828 + If you're using XFree86 or a version of Xorg from 2012 or earlier,
62829 + you may not be able to boot into a graphical environment with this
62830 + option enabled. In this case, you should use the RBAC system instead.
62831 +
62832 +config GRKERNSEC_JIT_HARDEN
62833 + bool "Harden BPF JIT against spray attacks"
62834 + default y if GRKERNSEC_CONFIG_AUTO
62835 + depends on BPF_JIT
62836 + help
62837 + If you say Y here, the native code generated by the kernel's Berkeley
62838 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
62839 + attacks that attempt to fit attacker-beneficial instructions in
62840 + 32bit immediate fields of JIT-generated native instructions. The
62841 + attacker will generally aim to cause an unintended instruction sequence
62842 + of JIT-generated native code to execute by jumping into the middle of
62843 + a generated instruction. This feature effectively randomizes the 32bit
62844 + immediate constants present in the generated code to thwart such attacks.
62845 +
62846 + If you're using KERNEXEC, it's recommended that you enable this option
62847 + to supplement the hardening of the kernel.
62848 +
62849 +config GRKERNSEC_PERF_HARDEN
62850 + bool "Disable unprivileged PERF_EVENTS usage by default"
62851 + default y if GRKERNSEC_CONFIG_AUTO
62852 + depends on PERF_EVENTS
62853 + help
62854 + If you say Y here, the range of acceptable values for the
62855 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
62856 + default to a new value: 3. When the sysctl is set to this value, no
62857 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
62858 +
62859 + Though PERF_EVENTS can be used legitimately for performance monitoring
62860 + and low-level application profiling, it is forced on regardless of
62861 + configuration, has been at fault for several vulnerabilities, and
62862 + creates new opportunities for side channels and other information leaks.
62863 +
62864 + This feature puts PERF_EVENTS into a secure default state and permits
62865 + the administrator to change out of it temporarily if unprivileged
62866 + application profiling is needed.
62867 +
62868 +config GRKERNSEC_RAND_THREADSTACK
62869 + bool "Insert random gaps between thread stacks"
62870 + default y if GRKERNSEC_CONFIG_AUTO
62871 + depends on PAX_RANDMMAP && !PPC
62872 + help
62873 + If you say Y here, a random-sized gap will be enforced between allocated
62874 + thread stacks. Glibc's NPTL and other threading libraries that
62875 + pass MAP_STACK to the kernel for thread stack allocation are supported.
62876 + The implementation currently provides 8 bits of entropy for the gap.
62877 +
62878 + Many distributions do not compile threaded remote services with the
62879 + -fstack-check argument to GCC, causing the variable-sized stack-based
62880 + allocator, alloca(), to not probe the stack on allocation. This
62881 + permits an unbounded alloca() to skip over any guard page and potentially
62882 + modify another thread's stack reliably. An enforced random gap
62883 + reduces the reliability of such an attack and increases the chance
62884 + that such a read/write to another thread's stack instead lands in
62885 + an unmapped area, causing a crash and triggering grsecurity's
62886 + anti-bruteforcing logic.
62887 +
62888 +config GRKERNSEC_PROC_MEMMAP
62889 + bool "Harden ASLR against information leaks and entropy reduction"
62890 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
62891 + depends on PAX_NOEXEC || PAX_ASLR
62892 + help
62893 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
62894 + give no information about the addresses of its mappings if
62895 + PaX features that rely on random addresses are enabled on the task.
62896 + In addition to sanitizing this information and disabling other
62897 + dangerous sources of information, this option causes reads of sensitive
62898 + /proc/<pid> entries where the file descriptor was opened in a different
62899 + task than the one performing the read. Such attempts are logged.
62900 + This option also limits argv/env strings for suid/sgid binaries
62901 + to 512KB to prevent a complete exhaustion of the stack entropy provided
62902 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
62903 + binaries to prevent alternative mmap layouts from being abused.
62904 +
62905 + If you use PaX it is essential that you say Y here as it closes up
62906 + several holes that make full ASLR useless locally.
62907 +
62908 +config GRKERNSEC_BRUTE
62909 + bool "Deter exploit bruteforcing"
62910 + default y if GRKERNSEC_CONFIG_AUTO
62911 + help
62912 + If you say Y here, attempts to bruteforce exploits against forking
62913 + daemons such as apache or sshd, as well as against suid/sgid binaries
62914 + will be deterred. When a child of a forking daemon is killed by PaX
62915 + or crashes due to an illegal instruction or other suspicious signal,
62916 + the parent process will be delayed 30 seconds upon every subsequent
62917 + fork until the administrator is able to assess the situation and
62918 + restart the daemon.
62919 + In the suid/sgid case, the attempt is logged, the user has all their
62920 + existing instances of the suid/sgid binary terminated and will
62921 + be unable to execute any suid/sgid binaries for 15 minutes.
62922 +
62923 + It is recommended that you also enable signal logging in the auditing
62924 + section so that logs are generated when a process triggers a suspicious
62925 + signal.
62926 + If the sysctl option is enabled, a sysctl option with name
62927 + "deter_bruteforce" is created.
62928 +
62929 +
62930 +config GRKERNSEC_MODHARDEN
62931 + bool "Harden module auto-loading"
62932 + default y if GRKERNSEC_CONFIG_AUTO
62933 + depends on MODULES
62934 + help
62935 + If you say Y here, module auto-loading in response to use of some
62936 + feature implemented by an unloaded module will be restricted to
62937 + root users. Enabling this option helps defend against attacks
62938 + by unprivileged users who abuse the auto-loading behavior to
62939 + cause a vulnerable module to load that is then exploited.
62940 +
62941 + If this option prevents a legitimate use of auto-loading for a
62942 + non-root user, the administrator can execute modprobe manually
62943 + with the exact name of the module mentioned in the alert log.
62944 + Alternatively, the administrator can add the module to the list
62945 + of modules loaded at boot by modifying init scripts.
62946 +
62947 + Modification of init scripts will most likely be needed on
62948 + Ubuntu servers with encrypted home directory support enabled,
62949 + as the first non-root user logging in will cause the ecb(aes),
62950 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
62951 +
62952 +config GRKERNSEC_HIDESYM
62953 + bool "Hide kernel symbols"
62954 + default y if GRKERNSEC_CONFIG_AUTO
62955 + select PAX_USERCOPY_SLABS
62956 + help
62957 + If you say Y here, getting information on loaded modules, and
62958 + displaying all kernel symbols through a syscall will be restricted
62959 + to users with CAP_SYS_MODULE. For software compatibility reasons,
62960 + /proc/kallsyms will be restricted to the root user. The RBAC
62961 + system can hide that entry even from root.
62962 +
62963 + This option also prevents leaking of kernel addresses through
62964 + several /proc entries.
62965 +
62966 + Note that this option is only effective provided the following
62967 + conditions are met:
62968 + 1) The kernel using grsecurity is not precompiled by some distribution
62969 + 2) You have also enabled GRKERNSEC_DMESG
62970 + 3) You are using the RBAC system and hiding other files such as your
62971 + kernel image and System.map. Alternatively, enabling this option
62972 + causes the permissions on /boot, /lib/modules, and the kernel
62973 + source directory to change at compile time to prevent
62974 + reading by non-root users.
62975 + If the above conditions are met, this option will aid in providing a
62976 + useful protection against local kernel exploitation of overflows
62977 + and arbitrary read/write vulnerabilities.
62978 +
62979 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
62980 + in addition to this feature.
62981 +
62982 +config GRKERNSEC_KERN_LOCKOUT
62983 + bool "Active kernel exploit response"
62984 + default y if GRKERNSEC_CONFIG_AUTO
62985 + depends on X86 || ARM || PPC || SPARC
62986 + help
62987 + If you say Y here, when a PaX alert is triggered due to suspicious
62988 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
62989 + or an OOPS occurs due to bad memory accesses, instead of just
62990 + terminating the offending process (and potentially allowing
62991 + a subsequent exploit from the same user), we will take one of two
62992 + actions:
62993 + If the user was root, we will panic the system
62994 + If the user was non-root, we will log the attempt, terminate
62995 + all processes owned by the user, then prevent them from creating
62996 + any new processes until the system is restarted
62997 + This deters repeated kernel exploitation/bruteforcing attempts
62998 + and is useful for later forensics.
62999 +
63000 +config GRKERNSEC_OLD_ARM_USERLAND
63001 + bool "Old ARM userland compatibility"
63002 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
63003 + help
63004 + If you say Y here, stubs of executable code to perform such operations
63005 + as "compare-exchange" will be placed at fixed locations in the ARM vector
63006 + table. This is unfortunately needed for old ARM userland meant to run
63007 + across a wide range of processors. Without this option enabled,
63008 + the get_tls and data memory barrier stubs will be emulated by the kernel,
63009 + which is enough for Linaro userlands or other userlands designed for v6
63010 + and newer ARM CPUs. It's recommended that you try without this option enabled
63011 + first, and only enable it if your userland does not boot (it will likely fail
63012 + at init time).
63013 +
63014 +endmenu
63015 +menu "Role Based Access Control Options"
63016 +depends on GRKERNSEC
63017 +
63018 +config GRKERNSEC_RBAC_DEBUG
63019 + bool
63020 +
63021 +config GRKERNSEC_NO_RBAC
63022 + bool "Disable RBAC system"
63023 + help
63024 + If you say Y here, the /dev/grsec device will be removed from the kernel,
63025 + preventing the RBAC system from being enabled. You should only say Y
63026 + here if you have no intention of using the RBAC system, so as to prevent
63027 + an attacker with root access from misusing the RBAC system to hide files
63028 + and processes when loadable module support and /dev/[k]mem have been
63029 + locked down.
63030 +
63031 +config GRKERNSEC_ACL_HIDEKERN
63032 + bool "Hide kernel processes"
63033 + help
63034 + If you say Y here, all kernel threads will be hidden to all
63035 + processes but those whose subject has the "view hidden processes"
63036 + flag.
63037 +
63038 +config GRKERNSEC_ACL_MAXTRIES
63039 + int "Maximum tries before password lockout"
63040 + default 3
63041 + help
63042 + This option enforces the maximum number of times a user can attempt
63043 + to authorize themselves with the grsecurity RBAC system before being
63044 + denied the ability to attempt authorization again for a specified time.
63045 + The lower the number, the harder it will be to brute-force a password.
63046 +
63047 +config GRKERNSEC_ACL_TIMEOUT
63048 + int "Time to wait after max password tries, in seconds"
63049 + default 30
63050 + help
63051 + This option specifies the time the user must wait after attempting to
63052 + authorize to the RBAC system with the maximum number of invalid
63053 + passwords. The higher the number, the harder it will be to brute-force
63054 + a password.
63055 +
63056 +endmenu
63057 +menu "Filesystem Protections"
63058 +depends on GRKERNSEC
63059 +
63060 +config GRKERNSEC_PROC
63061 + bool "Proc restrictions"
63062 + default y if GRKERNSEC_CONFIG_AUTO
63063 + help
63064 + If you say Y here, the permissions of the /proc filesystem
63065 + will be altered to enhance system security and privacy. You MUST
63066 + choose either a user only restriction or a user and group restriction.
63067 + Depending upon the option you choose, you can either restrict users to
63068 + see only the processes they themselves run, or choose a group that can
63069 + view all processes and files normally restricted to root if you choose
63070 + the "restrict to user only" option. NOTE: If you're running identd or
63071 + ntpd as a non-root user, you will have to run it as the group you
63072 + specify here.
63073 +
63074 +config GRKERNSEC_PROC_USER
63075 + bool "Restrict /proc to user only"
63076 + depends on GRKERNSEC_PROC
63077 + help
63078 + If you say Y here, non-root users will only be able to view their own
63079 + processes, and restricts them from viewing network-related information,
63080 + and viewing kernel symbol and module information.
63081 +
63082 +config GRKERNSEC_PROC_USERGROUP
63083 + bool "Allow special group"
63084 + default y if GRKERNSEC_CONFIG_AUTO
63085 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
63086 + help
63087 + If you say Y here, you will be able to select a group that will be
63088 + able to view all processes and network-related information. If you've
63089 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
63090 + remain hidden. This option is useful if you want to run identd as
63091 + a non-root user. The group you select may also be chosen at boot time
63092 + via "grsec_proc_gid=" on the kernel commandline.
63093 +
63094 +config GRKERNSEC_PROC_GID
63095 + int "GID for special group"
63096 + depends on GRKERNSEC_PROC_USERGROUP
63097 + default 1001
63098 +
63099 +config GRKERNSEC_PROC_ADD
63100 + bool "Additional restrictions"
63101 + default y if GRKERNSEC_CONFIG_AUTO
63102 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
63103 + help
63104 + If you say Y here, additional restrictions will be placed on
63105 + /proc that keep normal users from viewing device information and
63106 + slabinfo information that could be useful for exploits.
63107 +
63108 +config GRKERNSEC_LINK
63109 + bool "Linking restrictions"
63110 + default y if GRKERNSEC_CONFIG_AUTO
63111 + help
63112 + If you say Y here, /tmp race exploits will be prevented, since users
63113 + will no longer be able to follow symlinks owned by other users in
63114 + world-writable +t directories (e.g. /tmp), unless the owner of the
63115 + symlink is the owner of the directory. users will also not be
63116 + able to hardlink to files they do not own. If the sysctl option is
63117 + enabled, a sysctl option with name "linking_restrictions" is created.
63118 +
63119 +config GRKERNSEC_SYMLINKOWN
63120 + bool "Kernel-enforced SymlinksIfOwnerMatch"
63121 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63122 + help
63123 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
63124 + that prevents it from being used as a security feature. As Apache
63125 + verifies the symlink by performing a stat() against the target of
63126 + the symlink before it is followed, an attacker can setup a symlink
63127 + to point to a same-owned file, then replace the symlink with one
63128 + that targets another user's file just after Apache "validates" the
63129 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
63130 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
63131 + will be in place for the group you specify. If the sysctl option
63132 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
63133 + created.
63134 +
63135 +config GRKERNSEC_SYMLINKOWN_GID
63136 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
63137 + depends on GRKERNSEC_SYMLINKOWN
63138 + default 1006
63139 + help
63140 + Setting this GID determines what group kernel-enforced
63141 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
63142 + is enabled, a sysctl option with name "symlinkown_gid" is created.
63143 +
63144 +config GRKERNSEC_FIFO
63145 + bool "FIFO restrictions"
63146 + default y if GRKERNSEC_CONFIG_AUTO
63147 + help
63148 + If you say Y here, users will not be able to write to FIFOs they don't
63149 + own in world-writable +t directories (e.g. /tmp), unless the owner of
63150 + the FIFO is the same owner of the directory it's held in. If the sysctl
63151 + option is enabled, a sysctl option with name "fifo_restrictions" is
63152 + created.
63153 +
63154 +config GRKERNSEC_SYSFS_RESTRICT
63155 + bool "Sysfs/debugfs restriction"
63156 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
63157 + depends on SYSFS
63158 + help
63159 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
63160 + any filesystem normally mounted under it (e.g. debugfs) will be
63161 + mostly accessible only by root. These filesystems generally provide access
63162 + to hardware and debug information that isn't appropriate for unprivileged
63163 + users of the system. Sysfs and debugfs have also become a large source
63164 + of new vulnerabilities, ranging from infoleaks to local compromise.
63165 + There has been very little oversight with an eye toward security involved
63166 + in adding new exporters of information to these filesystems, so their
63167 + use is discouraged.
63168 + For reasons of compatibility, a few directories have been whitelisted
63169 + for access by non-root users:
63170 + /sys/fs/selinux
63171 + /sys/fs/fuse
63172 + /sys/devices/system/cpu
63173 +
63174 +config GRKERNSEC_ROFS
63175 + bool "Runtime read-only mount protection"
63176 + depends on SYSCTL
63177 + help
63178 + If you say Y here, a sysctl option with name "romount_protect" will
63179 + be created. By setting this option to 1 at runtime, filesystems
63180 + will be protected in the following ways:
63181 + * No new writable mounts will be allowed
63182 + * Existing read-only mounts won't be able to be remounted read/write
63183 + * Write operations will be denied on all block devices
63184 + This option acts independently of grsec_lock: once it is set to 1,
63185 + it cannot be turned off. Therefore, please be mindful of the resulting
63186 + behavior if this option is enabled in an init script on a read-only
63187 + filesystem.
63188 + Also be aware that as with other root-focused features, GRKERNSEC_KMEM
63189 + and GRKERNSEC_IO should be enabled and module loading disabled via
63190 + config or at runtime.
63191 + This feature is mainly intended for secure embedded systems.
63192 +
63193 +
63194 +config GRKERNSEC_DEVICE_SIDECHANNEL
63195 + bool "Eliminate stat/notify-based device sidechannels"
63196 + default y if GRKERNSEC_CONFIG_AUTO
63197 + help
63198 + If you say Y here, timing analyses on block or character
63199 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
63200 + will be thwarted for unprivileged users. If a process without
63201 + CAP_MKNOD stats such a device, the last access and last modify times
63202 + will match the device's create time. No access or modify events
63203 + will be triggered through inotify/dnotify/fanotify for such devices.
63204 + This feature will prevent attacks that may at a minimum
63205 + allow an attacker to determine the administrator's password length.
63206 +
63207 +config GRKERNSEC_CHROOT
63208 + bool "Chroot jail restrictions"
63209 + default y if GRKERNSEC_CONFIG_AUTO
63210 + help
63211 + If you say Y here, you will be able to choose several options that will
63212 + make breaking out of a chrooted jail much more difficult. If you
63213 + encounter no software incompatibilities with the following options, it
63214 + is recommended that you enable each one.
63215 +
63216 +config GRKERNSEC_CHROOT_MOUNT
63217 + bool "Deny mounts"
63218 + default y if GRKERNSEC_CONFIG_AUTO
63219 + depends on GRKERNSEC_CHROOT
63220 + help
63221 + If you say Y here, processes inside a chroot will not be able to
63222 + mount or remount filesystems. If the sysctl option is enabled, a
63223 + sysctl option with name "chroot_deny_mount" is created.
63224 +
63225 +config GRKERNSEC_CHROOT_DOUBLE
63226 + bool "Deny double-chroots"
63227 + default y if GRKERNSEC_CONFIG_AUTO
63228 + depends on GRKERNSEC_CHROOT
63229 + help
63230 + If you say Y here, processes inside a chroot will not be able to chroot
63231 + again outside the chroot. This is a widely used method of breaking
63232 + out of a chroot jail and should not be allowed. If the sysctl
63233 + option is enabled, a sysctl option with name
63234 + "chroot_deny_chroot" is created.
63235 +
63236 +config GRKERNSEC_CHROOT_PIVOT
63237 + bool "Deny pivot_root in chroot"
63238 + default y if GRKERNSEC_CONFIG_AUTO
63239 + depends on GRKERNSEC_CHROOT
63240 + help
63241 + If you say Y here, processes inside a chroot will not be able to use
63242 + a function called pivot_root() that was introduced in Linux 2.3.41. It
63243 + works similar to chroot in that it changes the root filesystem. This
63244 + function could be misused in a chrooted process to attempt to break out
63245 + of the chroot, and therefore should not be allowed. If the sysctl
63246 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
63247 + created.
63248 +
63249 +config GRKERNSEC_CHROOT_CHDIR
63250 + bool "Enforce chdir(\"/\") on all chroots"
63251 + default y if GRKERNSEC_CONFIG_AUTO
63252 + depends on GRKERNSEC_CHROOT
63253 + help
63254 + If you say Y here, the current working directory of all newly-chrooted
63255 + applications will be set to the the root directory of the chroot.
63256 + The man page on chroot(2) states:
63257 + Note that this call does not change the current working
63258 + directory, so that `.' can be outside the tree rooted at
63259 + `/'. In particular, the super-user can escape from a
63260 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
63261 +
63262 + It is recommended that you say Y here, since it's not known to break
63263 + any software. If the sysctl option is enabled, a sysctl option with
63264 + name "chroot_enforce_chdir" is created.
63265 +
63266 +config GRKERNSEC_CHROOT_CHMOD
63267 + bool "Deny (f)chmod +s"
63268 + default y if GRKERNSEC_CONFIG_AUTO
63269 + depends on GRKERNSEC_CHROOT
63270 + help
63271 + If you say Y here, processes inside a chroot will not be able to chmod
63272 + or fchmod files to make them have suid or sgid bits. This protects
63273 + against another published method of breaking a chroot. If the sysctl
63274 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
63275 + created.
63276 +
63277 +config GRKERNSEC_CHROOT_FCHDIR
63278 + bool "Deny fchdir out of chroot"
63279 + default y if GRKERNSEC_CONFIG_AUTO
63280 + depends on GRKERNSEC_CHROOT
63281 + help
63282 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
63283 + to a file descriptor of the chrooting process that points to a directory
63284 + outside the filesystem will be stopped. If the sysctl option
63285 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
63286 +
63287 +config GRKERNSEC_CHROOT_MKNOD
63288 + bool "Deny mknod"
63289 + default y if GRKERNSEC_CONFIG_AUTO
63290 + depends on GRKERNSEC_CHROOT
63291 + help
63292 + If you say Y here, processes inside a chroot will not be allowed to
63293 + mknod. The problem with using mknod inside a chroot is that it
63294 + would allow an attacker to create a device entry that is the same
63295 + as one on the physical root of your system, which could range from
63296 + anything from the console device to a device for your harddrive (which
63297 + they could then use to wipe the drive or steal data). It is recommended
63298 + that you say Y here, unless you run into software incompatibilities.
63299 + If the sysctl option is enabled, a sysctl option with name
63300 + "chroot_deny_mknod" is created.
63301 +
63302 +config GRKERNSEC_CHROOT_SHMAT
63303 + bool "Deny shmat() out of chroot"
63304 + default y if GRKERNSEC_CONFIG_AUTO
63305 + depends on GRKERNSEC_CHROOT
63306 + help
63307 + If you say Y here, processes inside a chroot will not be able to attach
63308 + to shared memory segments that were created outside of the chroot jail.
63309 + It is recommended that you say Y here. If the sysctl option is enabled,
63310 + a sysctl option with name "chroot_deny_shmat" is created.
63311 +
63312 +config GRKERNSEC_CHROOT_UNIX
63313 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
63314 + default y if GRKERNSEC_CONFIG_AUTO
63315 + depends on GRKERNSEC_CHROOT
63316 + help
63317 + If you say Y here, processes inside a chroot will not be able to
63318 + connect to abstract (meaning not belonging to a filesystem) Unix
63319 + domain sockets that were bound outside of a chroot. It is recommended
63320 + that you say Y here. If the sysctl option is enabled, a sysctl option
63321 + with name "chroot_deny_unix" is created.
63322 +
63323 +config GRKERNSEC_CHROOT_FINDTASK
63324 + bool "Protect outside processes"
63325 + default y if GRKERNSEC_CONFIG_AUTO
63326 + depends on GRKERNSEC_CHROOT
63327 + help
63328 + If you say Y here, processes inside a chroot will not be able to
63329 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
63330 + getsid, or view any process outside of the chroot. If the sysctl
63331 + option is enabled, a sysctl option with name "chroot_findtask" is
63332 + created.
63333 +
63334 +config GRKERNSEC_CHROOT_NICE
63335 + bool "Restrict priority changes"
63336 + default y if GRKERNSEC_CONFIG_AUTO
63337 + depends on GRKERNSEC_CHROOT
63338 + help
63339 + If you say Y here, processes inside a chroot will not be able to raise
63340 + the priority of processes in the chroot, or alter the priority of
63341 + processes outside the chroot. This provides more security than simply
63342 + removing CAP_SYS_NICE from the process' capability set. If the
63343 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
63344 + is created.
63345 +
63346 +config GRKERNSEC_CHROOT_SYSCTL
63347 + bool "Deny sysctl writes"
63348 + default y if GRKERNSEC_CONFIG_AUTO
63349 + depends on GRKERNSEC_CHROOT
63350 + help
63351 + If you say Y here, an attacker in a chroot will not be able to
63352 + write to sysctl entries, either by sysctl(2) or through a /proc
63353 + interface. It is strongly recommended that you say Y here. If the
63354 + sysctl option is enabled, a sysctl option with name
63355 + "chroot_deny_sysctl" is created.
63356 +
63357 +config GRKERNSEC_CHROOT_CAPS
63358 + bool "Capability restrictions"
63359 + default y if GRKERNSEC_CONFIG_AUTO
63360 + depends on GRKERNSEC_CHROOT
63361 + help
63362 + If you say Y here, the capabilities on all processes within a
63363 + chroot jail will be lowered to stop module insertion, raw i/o,
63364 + system and net admin tasks, rebooting the system, modifying immutable
63365 + files, modifying IPC owned by another, and changing the system time.
63366 + This is left an option because it can break some apps. Disable this
63367 + if your chrooted apps are having problems performing those kinds of
63368 + tasks. If the sysctl option is enabled, a sysctl option with
63369 + name "chroot_caps" is created.
63370 +
63371 +config GRKERNSEC_CHROOT_INITRD
63372 + bool "Exempt initrd tasks from restrictions"
63373 + default y if GRKERNSEC_CONFIG_AUTO
63374 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
63375 + help
63376 + If you say Y here, tasks started prior to init will be exempted from
63377 + grsecurity's chroot restrictions. This option is mainly meant to
63378 + resolve Plymouth's performing privileged operations unnecessarily
63379 + in a chroot.
63380 +
63381 +endmenu
63382 +menu "Kernel Auditing"
63383 +depends on GRKERNSEC
63384 +
63385 +config GRKERNSEC_AUDIT_GROUP
63386 + bool "Single group for auditing"
63387 + help
63388 + If you say Y here, the exec and chdir logging features will only operate
63389 + on a group you specify. This option is recommended if you only want to
63390 + watch certain users instead of having a large amount of logs from the
63391 + entire system. If the sysctl option is enabled, a sysctl option with
63392 + name "audit_group" is created.
63393 +
63394 +config GRKERNSEC_AUDIT_GID
63395 + int "GID for auditing"
63396 + depends on GRKERNSEC_AUDIT_GROUP
63397 + default 1007
63398 +
63399 +config GRKERNSEC_EXECLOG
63400 + bool "Exec logging"
63401 + help
63402 + If you say Y here, all execve() calls will be logged (since the
63403 + other exec*() calls are frontends to execve(), all execution
63404 + will be logged). Useful for shell-servers that like to keep track
63405 + of their users. If the sysctl option is enabled, a sysctl option with
63406 + name "exec_logging" is created.
63407 + WARNING: This option when enabled will produce a LOT of logs, especially
63408 + on an active system.
63409 +
63410 +config GRKERNSEC_RESLOG
63411 + bool "Resource logging"
63412 + default y if GRKERNSEC_CONFIG_AUTO
63413 + help
63414 + If you say Y here, all attempts to overstep resource limits will
63415 + be logged with the resource name, the requested size, and the current
63416 + limit. It is highly recommended that you say Y here. If the sysctl
63417 + option is enabled, a sysctl option with name "resource_logging" is
63418 + created. If the RBAC system is enabled, the sysctl value is ignored.
63419 +
63420 +config GRKERNSEC_CHROOT_EXECLOG
63421 + bool "Log execs within chroot"
63422 + help
63423 + If you say Y here, all executions inside a chroot jail will be logged
63424 + to syslog. This can cause a large amount of logs if certain
63425 + applications (eg. djb's daemontools) are installed on the system, and
63426 + is therefore left as an option. If the sysctl option is enabled, a
63427 + sysctl option with name "chroot_execlog" is created.
63428 +
63429 +config GRKERNSEC_AUDIT_PTRACE
63430 + bool "Ptrace logging"
63431 + help
63432 + If you say Y here, all attempts to attach to a process via ptrace
63433 + will be logged. If the sysctl option is enabled, a sysctl option
63434 + with name "audit_ptrace" is created.
63435 +
63436 +config GRKERNSEC_AUDIT_CHDIR
63437 + bool "Chdir logging"
63438 + help
63439 + If you say Y here, all chdir() calls will be logged. If the sysctl
63440 + option is enabled, a sysctl option with name "audit_chdir" is created.
63441 +
63442 +config GRKERNSEC_AUDIT_MOUNT
63443 + bool "(Un)Mount logging"
63444 + help
63445 + If you say Y here, all mounts and unmounts will be logged. If the
63446 + sysctl option is enabled, a sysctl option with name "audit_mount" is
63447 + created.
63448 +
63449 +config GRKERNSEC_SIGNAL
63450 + bool "Signal logging"
63451 + default y if GRKERNSEC_CONFIG_AUTO
63452 + help
63453 + If you say Y here, certain important signals will be logged, such as
63454 + SIGSEGV, which will as a result inform you of when a error in a program
63455 + occurred, which in some cases could mean a possible exploit attempt.
63456 + If the sysctl option is enabled, a sysctl option with name
63457 + "signal_logging" is created.
63458 +
63459 +config GRKERNSEC_FORKFAIL
63460 + bool "Fork failure logging"
63461 + help
63462 + If you say Y here, all failed fork() attempts will be logged.
63463 + This could suggest a fork bomb, or someone attempting to overstep
63464 + their process limit. If the sysctl option is enabled, a sysctl option
63465 + with name "forkfail_logging" is created.
63466 +
63467 +config GRKERNSEC_TIME
63468 + bool "Time change logging"
63469 + default y if GRKERNSEC_CONFIG_AUTO
63470 + help
63471 + If you say Y here, any changes of the system clock will be logged.
63472 + If the sysctl option is enabled, a sysctl option with name
63473 + "timechange_logging" is created.
63474 +
63475 +config GRKERNSEC_PROC_IPADDR
63476 + bool "/proc/<pid>/ipaddr support"
63477 + default y if GRKERNSEC_CONFIG_AUTO
63478 + help
63479 + If you say Y here, a new entry will be added to each /proc/<pid>
63480 + directory that contains the IP address of the person using the task.
63481 + The IP is carried across local TCP and AF_UNIX stream sockets.
63482 + This information can be useful for IDS/IPSes to perform remote response
63483 + to a local attack. The entry is readable by only the owner of the
63484 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
63485 + the RBAC system), and thus does not create privacy concerns.
63486 +
63487 +config GRKERNSEC_RWXMAP_LOG
63488 + bool 'Denied RWX mmap/mprotect logging'
63489 + default y if GRKERNSEC_CONFIG_AUTO
63490 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
63491 + help
63492 + If you say Y here, calls to mmap() and mprotect() with explicit
63493 + usage of PROT_WRITE and PROT_EXEC together will be logged when
63494 + denied by the PAX_MPROTECT feature. This feature will also
63495 + log other problematic scenarios that can occur when PAX_MPROTECT
63496 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
63497 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
63498 + is created.
63499 +
63500 +endmenu
63501 +
63502 +menu "Executable Protections"
63503 +depends on GRKERNSEC
63504 +
63505 +config GRKERNSEC_DMESG
63506 + bool "Dmesg(8) restriction"
63507 + default y if GRKERNSEC_CONFIG_AUTO
63508 + help
63509 + If you say Y here, non-root users will not be able to use dmesg(8)
63510 + to view the contents of the kernel's circular log buffer.
63511 + The kernel's log buffer often contains kernel addresses and other
63512 + identifying information useful to an attacker in fingerprinting a
63513 + system for a targeted exploit.
63514 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
63515 + created.
63516 +
63517 +config GRKERNSEC_HARDEN_PTRACE
63518 + bool "Deter ptrace-based process snooping"
63519 + default y if GRKERNSEC_CONFIG_AUTO
63520 + help
63521 + If you say Y here, TTY sniffers and other malicious monitoring
63522 + programs implemented through ptrace will be defeated. If you
63523 + have been using the RBAC system, this option has already been
63524 + enabled for several years for all users, with the ability to make
63525 + fine-grained exceptions.
63526 +
63527 + This option only affects the ability of non-root users to ptrace
63528 + processes that are not a descendent of the ptracing process.
63529 + This means that strace ./binary and gdb ./binary will still work,
63530 + but attaching to arbitrary processes will not. If the sysctl
63531 + option is enabled, a sysctl option with name "harden_ptrace" is
63532 + created.
63533 +
63534 +config GRKERNSEC_PTRACE_READEXEC
63535 + bool "Require read access to ptrace sensitive binaries"
63536 + default y if GRKERNSEC_CONFIG_AUTO
63537 + help
63538 + If you say Y here, unprivileged users will not be able to ptrace unreadable
63539 + binaries. This option is useful in environments that
63540 + remove the read bits (e.g. file mode 4711) from suid binaries to
63541 + prevent infoleaking of their contents. This option adds
63542 + consistency to the use of that file mode, as the binary could normally
63543 + be read out when run without privileges while ptracing.
63544 +
63545 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
63546 + is created.
63547 +
63548 +config GRKERNSEC_SETXID
63549 + bool "Enforce consistent multithreaded privileges"
63550 + default y if GRKERNSEC_CONFIG_AUTO
63551 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
63552 + help
63553 + If you say Y here, a change from a root uid to a non-root uid
63554 + in a multithreaded application will cause the resulting uids,
63555 + gids, supplementary groups, and capabilities in that thread
63556 + to be propagated to the other threads of the process. In most
63557 + cases this is unnecessary, as glibc will emulate this behavior
63558 + on behalf of the application. Other libcs do not act in the
63559 + same way, allowing the other threads of the process to continue
63560 + running with root privileges. If the sysctl option is enabled,
63561 + a sysctl option with name "consistent_setxid" is created.
63562 +
63563 +config GRKERNSEC_HARDEN_IPC
63564 + bool "Disallow access to overly-permissive IPC objects"
63565 + default y if GRKERNSEC_CONFIG_AUTO
63566 + depends on SYSVIPC
63567 + help
63568 + If you say Y here, access to overly-permissive IPC objects (shared
63569 + memory, message queues, and semaphores) will be denied for processes
63570 + given the following criteria beyond normal permission checks:
63571 + 1) If the IPC object is world-accessible and the euid doesn't match
63572 + that of the creator or current uid for the IPC object
63573 + 2) If the IPC object is group-accessible and the egid doesn't
63574 + match that of the creator or current gid for the IPC object
63575 + It's a common error to grant too much permission to these objects,
63576 + with impact ranging from denial of service and information leaking to
63577 + privilege escalation. This feature was developed in response to
63578 + research by Tim Brown:
63579 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
63580 + who found hundreds of such insecure usages. Processes with
63581 + CAP_IPC_OWNER are still permitted to access these IPC objects.
63582 + If the sysctl option is enabled, a sysctl option with name
63583 + "harden_ipc" is created.
63584 +
63585 +config GRKERNSEC_TPE
63586 + bool "Trusted Path Execution (TPE)"
63587 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63588 + help
63589 + If you say Y here, you will be able to choose a gid to add to the
63590 + supplementary groups of users you want to mark as "untrusted."
63591 + These users will not be able to execute any files that are not in
63592 + root-owned directories writable only by root. If the sysctl option
63593 + is enabled, a sysctl option with name "tpe" is created.
63594 +
63595 +config GRKERNSEC_TPE_ALL
63596 + bool "Partially restrict all non-root users"
63597 + depends on GRKERNSEC_TPE
63598 + help
63599 + If you say Y here, all non-root users will be covered under
63600 + a weaker TPE restriction. This is separate from, and in addition to,
63601 + the main TPE options that you have selected elsewhere. Thus, if a
63602 + "trusted" GID is chosen, this restriction applies to even that GID.
63603 + Under this restriction, all non-root users will only be allowed to
63604 + execute files in directories they own that are not group or
63605 + world-writable, or in directories owned by root and writable only by
63606 + root. If the sysctl option is enabled, a sysctl option with name
63607 + "tpe_restrict_all" is created.
63608 +
63609 +config GRKERNSEC_TPE_INVERT
63610 + bool "Invert GID option"
63611 + depends on GRKERNSEC_TPE
63612 + help
63613 + If you say Y here, the group you specify in the TPE configuration will
63614 + decide what group TPE restrictions will be *disabled* for. This
63615 + option is useful if you want TPE restrictions to be applied to most
63616 + users on the system. If the sysctl option is enabled, a sysctl option
63617 + with name "tpe_invert" is created. Unlike other sysctl options, this
63618 + entry will default to on for backward-compatibility.
63619 +
63620 +config GRKERNSEC_TPE_GID
63621 + int
63622 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
63623 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
63624 +
63625 +config GRKERNSEC_TPE_UNTRUSTED_GID
63626 + int "GID for TPE-untrusted users"
63627 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
63628 + default 1005
63629 + help
63630 + Setting this GID determines what group TPE restrictions will be
63631 + *enabled* for. If the sysctl option is enabled, a sysctl option
63632 + with name "tpe_gid" is created.
63633 +
63634 +config GRKERNSEC_TPE_TRUSTED_GID
63635 + int "GID for TPE-trusted users"
63636 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
63637 + default 1005
63638 + help
63639 + Setting this GID determines what group TPE restrictions will be
63640 + *disabled* for. If the sysctl option is enabled, a sysctl option
63641 + with name "tpe_gid" is created.
63642 +
63643 +endmenu
63644 +menu "Network Protections"
63645 +depends on GRKERNSEC
63646 +
63647 +config GRKERNSEC_RANDNET
63648 + bool "Larger entropy pools"
63649 + default y if GRKERNSEC_CONFIG_AUTO
63650 + help
63651 + If you say Y here, the entropy pools used for many features of Linux
63652 + and grsecurity will be doubled in size. Since several grsecurity
63653 + features use additional randomness, it is recommended that you say Y
63654 + here. Saying Y here has a similar effect as modifying
63655 + /proc/sys/kernel/random/poolsize.
63656 +
63657 +config GRKERNSEC_BLACKHOLE
63658 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
63659 + default y if GRKERNSEC_CONFIG_AUTO
63660 + depends on NET
63661 + help
63662 + If you say Y here, neither TCP resets nor ICMP
63663 + destination-unreachable packets will be sent in response to packets
63664 + sent to ports for which no associated listening process exists.
63665 + This feature supports both IPV4 and IPV6 and exempts the
63666 + loopback interface from blackholing. Enabling this feature
63667 + makes a host more resilient to DoS attacks and reduces network
63668 + visibility against scanners.
63669 +
63670 + The blackhole feature as-implemented is equivalent to the FreeBSD
63671 + blackhole feature, as it prevents RST responses to all packets, not
63672 + just SYNs. Under most application behavior this causes no
63673 + problems, but applications (like haproxy) may not close certain
63674 + connections in a way that cleanly terminates them on the remote
63675 + end, leaving the remote host in LAST_ACK state. Because of this
63676 + side-effect and to prevent intentional LAST_ACK DoSes, this
63677 + feature also adds automatic mitigation against such attacks.
63678 + The mitigation drastically reduces the amount of time a socket
63679 + can spend in LAST_ACK state. If you're using haproxy and not
63680 + all servers it connects to have this option enabled, consider
63681 + disabling this feature on the haproxy host.
63682 +
63683 + If the sysctl option is enabled, two sysctl options with names
63684 + "ip_blackhole" and "lastack_retries" will be created.
63685 + While "ip_blackhole" takes the standard zero/non-zero on/off
63686 + toggle, "lastack_retries" uses the same kinds of values as
63687 + "tcp_retries1" and "tcp_retries2". The default value of 4
63688 + prevents a socket from lasting more than 45 seconds in LAST_ACK
63689 + state.
63690 +
63691 +config GRKERNSEC_NO_SIMULT_CONNECT
63692 + bool "Disable TCP Simultaneous Connect"
63693 + default y if GRKERNSEC_CONFIG_AUTO
63694 + depends on NET
63695 + help
63696 + If you say Y here, a feature by Willy Tarreau will be enabled that
63697 + removes a weakness in Linux's strict implementation of TCP that
63698 + allows two clients to connect to each other without either entering
63699 + a listening state. The weakness allows an attacker to easily prevent
63700 + a client from connecting to a known server provided the source port
63701 + for the connection is guessed correctly.
63702 +
63703 + As the weakness could be used to prevent an antivirus or IPS from
63704 + fetching updates, or prevent an SSL gateway from fetching a CRL,
63705 + it should be eliminated by enabling this option. Though Linux is
63706 + one of few operating systems supporting simultaneous connect, it
63707 + has no legitimate use in practice and is rarely supported by firewalls.
63708 +
63709 +config GRKERNSEC_SOCKET
63710 + bool "Socket restrictions"
63711 + depends on NET
63712 + help
63713 + If you say Y here, you will be able to choose from several options.
63714 + If you assign a GID on your system and add it to the supplementary
63715 + groups of users you want to restrict socket access to, this patch
63716 + will perform up to three things, based on the option(s) you choose.
63717 +
63718 +config GRKERNSEC_SOCKET_ALL
63719 + bool "Deny any sockets to group"
63720 + depends on GRKERNSEC_SOCKET
63721 + help
63722 + If you say Y here, you will be able to choose a GID of whose users will
63723 + be unable to connect to other hosts from your machine or run server
63724 + applications from your machine. If the sysctl option is enabled, a
63725 + sysctl option with name "socket_all" is created.
63726 +
63727 +config GRKERNSEC_SOCKET_ALL_GID
63728 + int "GID to deny all sockets for"
63729 + depends on GRKERNSEC_SOCKET_ALL
63730 + default 1004
63731 + help
63732 + Here you can choose the GID to disable socket access for. Remember to
63733 + add the users you want socket access disabled for to the GID
63734 + specified here. If the sysctl option is enabled, a sysctl option
63735 + with name "socket_all_gid" is created.
63736 +
63737 +config GRKERNSEC_SOCKET_CLIENT
63738 + bool "Deny client sockets to group"
63739 + depends on GRKERNSEC_SOCKET
63740 + help
63741 + If you say Y here, you will be able to choose a GID of whose users will
63742 + be unable to connect to other hosts from your machine, but will be
63743 + able to run servers. If this option is enabled, all users in the group
63744 + you specify will have to use passive mode when initiating ftp transfers
63745 + from the shell on your machine. If the sysctl option is enabled, a
63746 + sysctl option with name "socket_client" is created.
63747 +
63748 +config GRKERNSEC_SOCKET_CLIENT_GID
63749 + int "GID to deny client sockets for"
63750 + depends on GRKERNSEC_SOCKET_CLIENT
63751 + default 1003
63752 + help
63753 + Here you can choose the GID to disable client socket access for.
63754 + Remember to add the users you want client socket access disabled for to
63755 + the GID specified here. If the sysctl option is enabled, a sysctl
63756 + option with name "socket_client_gid" is created.
63757 +
63758 +config GRKERNSEC_SOCKET_SERVER
63759 + bool "Deny server sockets to group"
63760 + depends on GRKERNSEC_SOCKET
63761 + help
63762 + If you say Y here, you will be able to choose a GID of whose users will
63763 + be unable to run server applications from your machine. If the sysctl
63764 + option is enabled, a sysctl option with name "socket_server" is created.
63765 +
63766 +config GRKERNSEC_SOCKET_SERVER_GID
63767 + int "GID to deny server sockets for"
63768 + depends on GRKERNSEC_SOCKET_SERVER
63769 + default 1002
63770 + help
63771 + Here you can choose the GID to disable server socket access for.
63772 + Remember to add the users you want server socket access disabled for to
63773 + the GID specified here. If the sysctl option is enabled, a sysctl
63774 + option with name "socket_server_gid" is created.
63775 +
63776 +endmenu
63777 +
63778 +menu "Physical Protections"
63779 +depends on GRKERNSEC
63780 +
63781 +config GRKERNSEC_DENYUSB
63782 + bool "Deny new USB connections after toggle"
63783 + default y if GRKERNSEC_CONFIG_AUTO
63784 + depends on SYSCTL && USB_SUPPORT
63785 + help
63786 + If you say Y here, a new sysctl option with name "deny_new_usb"
63787 + will be created. Setting its value to 1 will prevent any new
63788 + USB devices from being recognized by the OS. Any attempted USB
63789 + device insertion will be logged. This option is intended to be
63790 + used against custom USB devices designed to exploit vulnerabilities
63791 + in various USB device drivers.
63792 +
63793 + For greatest effectiveness, this sysctl should be set after any
63794 + relevant init scripts. This option is safe to enable in distros
63795 + as each user can choose whether or not to toggle the sysctl.
63796 +
63797 +config GRKERNSEC_DENYUSB_FORCE
63798 + bool "Reject all USB devices not connected at boot"
63799 + select USB
63800 + depends on GRKERNSEC_DENYUSB
63801 + help
63802 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
63803 + that doesn't involve a sysctl entry. This option should only be
63804 + enabled if you're sure you want to deny all new USB connections
63805 + at runtime and don't want to modify init scripts. This should not
63806 + be enabled by distros. It forces the core USB code to be built
63807 + into the kernel image so that all devices connected at boot time
63808 + can be recognized and new USB device connections can be prevented
63809 + prior to init running.
63810 +
63811 +endmenu
63812 +
63813 +menu "Sysctl Support"
63814 +depends on GRKERNSEC && SYSCTL
63815 +
63816 +config GRKERNSEC_SYSCTL
63817 + bool "Sysctl support"
63818 + default y if GRKERNSEC_CONFIG_AUTO
63819 + help
63820 + If you say Y here, you will be able to change the options that
63821 + grsecurity runs with at bootup, without having to recompile your
63822 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
63823 + to enable (1) or disable (0) various features. All the sysctl entries
63824 + are mutable until the "grsec_lock" entry is set to a non-zero value.
63825 + All features enabled in the kernel configuration are disabled at boot
63826 + if you do not say Y to the "Turn on features by default" option.
63827 + All options should be set at startup, and the grsec_lock entry should
63828 + be set to a non-zero value after all the options are set.
63829 + *THIS IS EXTREMELY IMPORTANT*
63830 +
63831 +config GRKERNSEC_SYSCTL_DISTRO
63832 + bool "Extra sysctl support for distro makers (READ HELP)"
63833 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
63834 + help
63835 + If you say Y here, additional sysctl options will be created
63836 + for features that affect processes running as root. Therefore,
63837 + it is critical when using this option that the grsec_lock entry be
63838 + enabled after boot. Only distros with prebuilt kernel packages
63839 + with this option enabled that can ensure grsec_lock is enabled
63840 + after boot should use this option.
63841 + *Failure to set grsec_lock after boot makes all grsec features
63842 + this option covers useless*
63843 +
63844 + Currently this option creates the following sysctl entries:
63845 + "Disable Privileged I/O": "disable_priv_io"
63846 +
63847 +config GRKERNSEC_SYSCTL_ON
63848 + bool "Turn on features by default"
63849 + default y if GRKERNSEC_CONFIG_AUTO
63850 + depends on GRKERNSEC_SYSCTL
63851 + help
63852 + If you say Y here, instead of having all features enabled in the
63853 + kernel configuration disabled at boot time, the features will be
63854 + enabled at boot time. It is recommended you say Y here unless
63855 + there is some reason you would want all sysctl-tunable features to
63856 + be disabled by default. As mentioned elsewhere, it is important
63857 + to enable the grsec_lock entry once you have finished modifying
63858 + the sysctl entries.
63859 +
63860 +endmenu
63861 +menu "Logging Options"
63862 +depends on GRKERNSEC
63863 +
63864 +config GRKERNSEC_FLOODTIME
63865 + int "Seconds in between log messages (minimum)"
63866 + default 10
63867 + help
63868 + This option allows you to enforce the number of seconds between
63869 + grsecurity log messages. The default should be suitable for most
63870 + people, however, if you choose to change it, choose a value small enough
63871 + to allow informative logs to be produced, but large enough to
63872 + prevent flooding.
63873 +
63874 +config GRKERNSEC_FLOODBURST
63875 + int "Number of messages in a burst (maximum)"
63876 + default 6
63877 + help
63878 + This option allows you to choose the maximum number of messages allowed
63879 + within the flood time interval you chose in a separate option. The
63880 + default should be suitable for most people, however if you find that
63881 + many of your logs are being interpreted as flooding, you may want to
63882 + raise this value.
63883 +
63884 +endmenu
63885 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
63886 new file mode 100644
63887 index 0000000..85beb79
63888 --- /dev/null
63889 +++ b/grsecurity/Makefile
63890 @@ -0,0 +1,43 @@
63891 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
63892 +# during 2001-2009 it has been completely redesigned by Brad Spengler
63893 +# into an RBAC system
63894 +#
63895 +# All code in this directory and various hooks inserted throughout the kernel
63896 +# are copyright Brad Spengler - Open Source Security, Inc., and released
63897 +# under the GPL v2 or higher
63898 +
63899 +KBUILD_CFLAGS += -Werror
63900 +
63901 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
63902 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
63903 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
63904 + grsec_usb.o grsec_ipc.o
63905 +
63906 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
63907 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
63908 + gracl_learn.o grsec_log.o gracl_policy.o
63909 +ifdef CONFIG_COMPAT
63910 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
63911 +endif
63912 +
63913 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
63914 +
63915 +ifdef CONFIG_NET
63916 +obj-y += grsec_sock.o
63917 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
63918 +endif
63919 +
63920 +ifndef CONFIG_GRKERNSEC
63921 +obj-y += grsec_disabled.o
63922 +endif
63923 +
63924 +ifdef CONFIG_GRKERNSEC_HIDESYM
63925 +extra-y := grsec_hidesym.o
63926 +$(obj)/grsec_hidesym.o:
63927 + @-chmod -f 500 /boot
63928 + @-chmod -f 500 /lib/modules
63929 + @-chmod -f 500 /lib64/modules
63930 + @-chmod -f 500 /lib32/modules
63931 + @-chmod -f 700 .
63932 + @echo ' grsec: protected kernel image paths'
63933 +endif
63934 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
63935 new file mode 100644
63936 index 0000000..90f71ce
63937 --- /dev/null
63938 +++ b/grsecurity/gracl.c
63939 @@ -0,0 +1,2679 @@
63940 +#include <linux/kernel.h>
63941 +#include <linux/module.h>
63942 +#include <linux/sched.h>
63943 +#include <linux/mm.h>
63944 +#include <linux/file.h>
63945 +#include <linux/fs.h>
63946 +#include <linux/namei.h>
63947 +#include <linux/mount.h>
63948 +#include <linux/tty.h>
63949 +#include <linux/proc_fs.h>
63950 +#include <linux/lglock.h>
63951 +#include <linux/slab.h>
63952 +#include <linux/vmalloc.h>
63953 +#include <linux/types.h>
63954 +#include <linux/sysctl.h>
63955 +#include <linux/netdevice.h>
63956 +#include <linux/ptrace.h>
63957 +#include <linux/gracl.h>
63958 +#include <linux/gralloc.h>
63959 +#include <linux/security.h>
63960 +#include <linux/grinternal.h>
63961 +#include <linux/pid_namespace.h>
63962 +#include <linux/stop_machine.h>
63963 +#include <linux/fdtable.h>
63964 +#include <linux/percpu.h>
63965 +#include <linux/lglock.h>
63966 +#include <linux/hugetlb.h>
63967 +#include <linux/posix-timers.h>
63968 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63969 +#include <linux/magic.h>
63970 +#include <linux/pagemap.h>
63971 +#include "../fs/btrfs/async-thread.h"
63972 +#include "../fs/btrfs/ctree.h"
63973 +#include "../fs/btrfs/btrfs_inode.h"
63974 +#endif
63975 +#include "../fs/mount.h"
63976 +
63977 +#include <asm/uaccess.h>
63978 +#include <asm/errno.h>
63979 +#include <asm/mman.h>
63980 +
63981 +#define FOR_EACH_ROLE_START(role) \
63982 + role = running_polstate.role_list; \
63983 + while (role) {
63984 +
63985 +#define FOR_EACH_ROLE_END(role) \
63986 + role = role->prev; \
63987 + }
63988 +
63989 +extern struct lglock vfsmount_lock;
63990 +
63991 +extern struct path gr_real_root;
63992 +
63993 +static struct gr_policy_state running_polstate;
63994 +struct gr_policy_state *polstate = &running_polstate;
63995 +extern struct gr_alloc_state *current_alloc_state;
63996 +
63997 +extern char *gr_shared_page[4];
63998 +DEFINE_RWLOCK(gr_inode_lock);
63999 +
64000 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
64001 +
64002 +#ifdef CONFIG_NET
64003 +extern struct vfsmount *sock_mnt;
64004 +#endif
64005 +
64006 +extern struct vfsmount *pipe_mnt;
64007 +extern struct vfsmount *shm_mnt;
64008 +
64009 +#ifdef CONFIG_HUGETLBFS
64010 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
64011 +#endif
64012 +
64013 +extern u16 acl_sp_role_value;
64014 +extern struct acl_object_label *fakefs_obj_rw;
64015 +extern struct acl_object_label *fakefs_obj_rwx;
64016 +
64017 +int gr_acl_is_enabled(void)
64018 +{
64019 + return (gr_status & GR_READY);
64020 +}
64021 +
64022 +void gr_enable_rbac_system(void)
64023 +{
64024 + pax_open_kernel();
64025 + gr_status |= GR_READY;
64026 + pax_close_kernel();
64027 +}
64028 +
64029 +int gr_rbac_disable(void *unused)
64030 +{
64031 + pax_open_kernel();
64032 + gr_status &= ~GR_READY;
64033 + pax_close_kernel();
64034 +
64035 + return 0;
64036 +}
64037 +
64038 +static inline dev_t __get_dev(const struct dentry *dentry)
64039 +{
64040 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
64041 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
64042 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
64043 + else
64044 +#endif
64045 + return dentry->d_sb->s_dev;
64046 +}
64047 +
64048 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64049 +{
64050 + return __get_dev(dentry);
64051 +}
64052 +
64053 +static char gr_task_roletype_to_char(struct task_struct *task)
64054 +{
64055 + switch (task->role->roletype &
64056 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
64057 + GR_ROLE_SPECIAL)) {
64058 + case GR_ROLE_DEFAULT:
64059 + return 'D';
64060 + case GR_ROLE_USER:
64061 + return 'U';
64062 + case GR_ROLE_GROUP:
64063 + return 'G';
64064 + case GR_ROLE_SPECIAL:
64065 + return 'S';
64066 + }
64067 +
64068 + return 'X';
64069 +}
64070 +
64071 +char gr_roletype_to_char(void)
64072 +{
64073 + return gr_task_roletype_to_char(current);
64074 +}
64075 +
64076 +__inline__ int
64077 +gr_acl_tpe_check(void)
64078 +{
64079 + if (unlikely(!(gr_status & GR_READY)))
64080 + return 0;
64081 + if (current->role->roletype & GR_ROLE_TPE)
64082 + return 1;
64083 + else
64084 + return 0;
64085 +}
64086 +
64087 +int
64088 +gr_handle_rawio(const struct inode *inode)
64089 +{
64090 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64091 + if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
64092 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
64093 + !capable(CAP_SYS_RAWIO))
64094 + return 1;
64095 +#endif
64096 + return 0;
64097 +}
64098 +
64099 +int
64100 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
64101 +{
64102 + if (likely(lena != lenb))
64103 + return 0;
64104 +
64105 + return !memcmp(a, b, lena);
64106 +}
64107 +
64108 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
64109 +{
64110 + *buflen -= namelen;
64111 + if (*buflen < 0)
64112 + return -ENAMETOOLONG;
64113 + *buffer -= namelen;
64114 + memcpy(*buffer, str, namelen);
64115 + return 0;
64116 +}
64117 +
64118 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
64119 +{
64120 + return prepend(buffer, buflen, name->name, name->len);
64121 +}
64122 +
64123 +static int prepend_path(const struct path *path, struct path *root,
64124 + char **buffer, int *buflen)
64125 +{
64126 + struct dentry *dentry = path->dentry;
64127 + struct vfsmount *vfsmnt = path->mnt;
64128 + struct mount *mnt = real_mount(vfsmnt);
64129 + bool slash = false;
64130 + int error = 0;
64131 +
64132 + while (dentry != root->dentry || vfsmnt != root->mnt) {
64133 + struct dentry * parent;
64134 +
64135 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
64136 + /* Global root? */
64137 + if (!mnt_has_parent(mnt)) {
64138 + goto out;
64139 + }
64140 + dentry = mnt->mnt_mountpoint;
64141 + mnt = mnt->mnt_parent;
64142 + vfsmnt = &mnt->mnt;
64143 + continue;
64144 + }
64145 + parent = dentry->d_parent;
64146 + prefetch(parent);
64147 + spin_lock(&dentry->d_lock);
64148 + error = prepend_name(buffer, buflen, &dentry->d_name);
64149 + spin_unlock(&dentry->d_lock);
64150 + if (!error)
64151 + error = prepend(buffer, buflen, "/", 1);
64152 + if (error)
64153 + break;
64154 +
64155 + slash = true;
64156 + dentry = parent;
64157 + }
64158 +
64159 +out:
64160 + if (!error && !slash)
64161 + error = prepend(buffer, buflen, "/", 1);
64162 +
64163 + return error;
64164 +}
64165 +
64166 +/* this must be called with vfsmount_lock and rename_lock held */
64167 +
64168 +static char *__our_d_path(const struct path *path, struct path *root,
64169 + char *buf, int buflen)
64170 +{
64171 + char *res = buf + buflen;
64172 + int error;
64173 +
64174 + prepend(&res, &buflen, "\0", 1);
64175 + error = prepend_path(path, root, &res, &buflen);
64176 + if (error)
64177 + return ERR_PTR(error);
64178 +
64179 + return res;
64180 +}
64181 +
64182 +static char *
64183 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
64184 +{
64185 + char *retval;
64186 +
64187 + retval = __our_d_path(path, root, buf, buflen);
64188 + if (unlikely(IS_ERR(retval)))
64189 + retval = strcpy(buf, "<path too long>");
64190 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
64191 + retval[1] = '\0';
64192 +
64193 + return retval;
64194 +}
64195 +
64196 +static char *
64197 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
64198 + char *buf, int buflen)
64199 +{
64200 + struct path path;
64201 + char *res;
64202 +
64203 + path.dentry = (struct dentry *)dentry;
64204 + path.mnt = (struct vfsmount *)vfsmnt;
64205 +
64206 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
64207 + by the RBAC system */
64208 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
64209 +
64210 + return res;
64211 +}
64212 +
64213 +static char *
64214 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
64215 + char *buf, int buflen)
64216 +{
64217 + char *res;
64218 + struct path path;
64219 + struct path root;
64220 + struct task_struct *reaper = init_pid_ns.child_reaper;
64221 +
64222 + path.dentry = (struct dentry *)dentry;
64223 + path.mnt = (struct vfsmount *)vfsmnt;
64224 +
64225 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
64226 + get_fs_root(reaper->fs, &root);
64227 +
64228 + br_read_lock(&vfsmount_lock);
64229 + write_seqlock(&rename_lock);
64230 + res = gen_full_path(&path, &root, buf, buflen);
64231 + write_sequnlock(&rename_lock);
64232 + br_read_unlock(&vfsmount_lock);
64233 +
64234 + path_put(&root);
64235 + return res;
64236 +}
64237 +
64238 +char *
64239 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
64240 +{
64241 + char *ret;
64242 + br_read_lock(&vfsmount_lock);
64243 + write_seqlock(&rename_lock);
64244 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64245 + PAGE_SIZE);
64246 + write_sequnlock(&rename_lock);
64247 + br_read_unlock(&vfsmount_lock);
64248 + return ret;
64249 +}
64250 +
64251 +static char *
64252 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
64253 +{
64254 + char *ret;
64255 + char *buf;
64256 + int buflen;
64257 +
64258 + br_read_lock(&vfsmount_lock);
64259 + write_seqlock(&rename_lock);
64260 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
64261 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
64262 + buflen = (int)(ret - buf);
64263 + if (buflen >= 5)
64264 + prepend(&ret, &buflen, "/proc", 5);
64265 + else
64266 + ret = strcpy(buf, "<path too long>");
64267 + write_sequnlock(&rename_lock);
64268 + br_read_unlock(&vfsmount_lock);
64269 + return ret;
64270 +}
64271 +
64272 +char *
64273 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
64274 +{
64275 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64276 + PAGE_SIZE);
64277 +}
64278 +
64279 +char *
64280 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
64281 +{
64282 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64283 + PAGE_SIZE);
64284 +}
64285 +
64286 +char *
64287 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
64288 +{
64289 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
64290 + PAGE_SIZE);
64291 +}
64292 +
64293 +char *
64294 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
64295 +{
64296 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
64297 + PAGE_SIZE);
64298 +}
64299 +
64300 +char *
64301 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
64302 +{
64303 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
64304 + PAGE_SIZE);
64305 +}
64306 +
64307 +__inline__ __u32
64308 +to_gr_audit(const __u32 reqmode)
64309 +{
64310 + /* masks off auditable permission flags, then shifts them to create
64311 + auditing flags, and adds the special case of append auditing if
64312 + we're requesting write */
64313 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
64314 +}
64315 +
64316 +struct acl_role_label *
64317 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
64318 + const gid_t gid)
64319 +{
64320 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
64321 + struct acl_role_label *match;
64322 + struct role_allowed_ip *ipp;
64323 + unsigned int x;
64324 + u32 curr_ip = task->signal->saved_ip;
64325 +
64326 + match = state->acl_role_set.r_hash[index];
64327 +
64328 + while (match) {
64329 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
64330 + for (x = 0; x < match->domain_child_num; x++) {
64331 + if (match->domain_children[x] == uid)
64332 + goto found;
64333 + }
64334 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
64335 + break;
64336 + match = match->next;
64337 + }
64338 +found:
64339 + if (match == NULL) {
64340 + try_group:
64341 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
64342 + match = state->acl_role_set.r_hash[index];
64343 +
64344 + while (match) {
64345 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
64346 + for (x = 0; x < match->domain_child_num; x++) {
64347 + if (match->domain_children[x] == gid)
64348 + goto found2;
64349 + }
64350 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
64351 + break;
64352 + match = match->next;
64353 + }
64354 +found2:
64355 + if (match == NULL)
64356 + match = state->default_role;
64357 + if (match->allowed_ips == NULL)
64358 + return match;
64359 + else {
64360 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64361 + if (likely
64362 + ((ntohl(curr_ip) & ipp->netmask) ==
64363 + (ntohl(ipp->addr) & ipp->netmask)))
64364 + return match;
64365 + }
64366 + match = state->default_role;
64367 + }
64368 + } else if (match->allowed_ips == NULL) {
64369 + return match;
64370 + } else {
64371 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64372 + if (likely
64373 + ((ntohl(curr_ip) & ipp->netmask) ==
64374 + (ntohl(ipp->addr) & ipp->netmask)))
64375 + return match;
64376 + }
64377 + goto try_group;
64378 + }
64379 +
64380 + return match;
64381 +}
64382 +
64383 +static struct acl_role_label *
64384 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
64385 + const gid_t gid)
64386 +{
64387 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
64388 +}
64389 +
64390 +struct acl_subject_label *
64391 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
64392 + const struct acl_role_label *role)
64393 +{
64394 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64395 + struct acl_subject_label *match;
64396 +
64397 + match = role->subj_hash[index];
64398 +
64399 + while (match && (match->inode != ino || match->device != dev ||
64400 + (match->mode & GR_DELETED))) {
64401 + match = match->next;
64402 + }
64403 +
64404 + if (match && !(match->mode & GR_DELETED))
64405 + return match;
64406 + else
64407 + return NULL;
64408 +}
64409 +
64410 +struct acl_subject_label *
64411 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
64412 + const struct acl_role_label *role)
64413 +{
64414 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64415 + struct acl_subject_label *match;
64416 +
64417 + match = role->subj_hash[index];
64418 +
64419 + while (match && (match->inode != ino || match->device != dev ||
64420 + !(match->mode & GR_DELETED))) {
64421 + match = match->next;
64422 + }
64423 +
64424 + if (match && (match->mode & GR_DELETED))
64425 + return match;
64426 + else
64427 + return NULL;
64428 +}
64429 +
64430 +static struct acl_object_label *
64431 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
64432 + const struct acl_subject_label *subj)
64433 +{
64434 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64435 + struct acl_object_label *match;
64436 +
64437 + match = subj->obj_hash[index];
64438 +
64439 + while (match && (match->inode != ino || match->device != dev ||
64440 + (match->mode & GR_DELETED))) {
64441 + match = match->next;
64442 + }
64443 +
64444 + if (match && !(match->mode & GR_DELETED))
64445 + return match;
64446 + else
64447 + return NULL;
64448 +}
64449 +
64450 +static struct acl_object_label *
64451 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
64452 + const struct acl_subject_label *subj)
64453 +{
64454 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64455 + struct acl_object_label *match;
64456 +
64457 + match = subj->obj_hash[index];
64458 +
64459 + while (match && (match->inode != ino || match->device != dev ||
64460 + !(match->mode & GR_DELETED))) {
64461 + match = match->next;
64462 + }
64463 +
64464 + if (match && (match->mode & GR_DELETED))
64465 + return match;
64466 +
64467 + match = subj->obj_hash[index];
64468 +
64469 + while (match && (match->inode != ino || match->device != dev ||
64470 + (match->mode & GR_DELETED))) {
64471 + match = match->next;
64472 + }
64473 +
64474 + if (match && !(match->mode & GR_DELETED))
64475 + return match;
64476 + else
64477 + return NULL;
64478 +}
64479 +
64480 +struct name_entry *
64481 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
64482 +{
64483 + unsigned int len = strlen(name);
64484 + unsigned int key = full_name_hash(name, len);
64485 + unsigned int index = key % state->name_set.n_size;
64486 + struct name_entry *match;
64487 +
64488 + match = state->name_set.n_hash[index];
64489 +
64490 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
64491 + match = match->next;
64492 +
64493 + return match;
64494 +}
64495 +
64496 +static struct name_entry *
64497 +lookup_name_entry(const char *name)
64498 +{
64499 + return __lookup_name_entry(&running_polstate, name);
64500 +}
64501 +
64502 +static struct name_entry *
64503 +lookup_name_entry_create(const char *name)
64504 +{
64505 + unsigned int len = strlen(name);
64506 + unsigned int key = full_name_hash(name, len);
64507 + unsigned int index = key % running_polstate.name_set.n_size;
64508 + struct name_entry *match;
64509 +
64510 + match = running_polstate.name_set.n_hash[index];
64511 +
64512 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64513 + !match->deleted))
64514 + match = match->next;
64515 +
64516 + if (match && match->deleted)
64517 + return match;
64518 +
64519 + match = running_polstate.name_set.n_hash[index];
64520 +
64521 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64522 + match->deleted))
64523 + match = match->next;
64524 +
64525 + if (match && !match->deleted)
64526 + return match;
64527 + else
64528 + return NULL;
64529 +}
64530 +
64531 +static struct inodev_entry *
64532 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
64533 +{
64534 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
64535 + struct inodev_entry *match;
64536 +
64537 + match = running_polstate.inodev_set.i_hash[index];
64538 +
64539 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
64540 + match = match->next;
64541 +
64542 + return match;
64543 +}
64544 +
64545 +void
64546 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
64547 +{
64548 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
64549 + state->inodev_set.i_size);
64550 + struct inodev_entry **curr;
64551 +
64552 + entry->prev = NULL;
64553 +
64554 + curr = &state->inodev_set.i_hash[index];
64555 + if (*curr != NULL)
64556 + (*curr)->prev = entry;
64557 +
64558 + entry->next = *curr;
64559 + *curr = entry;
64560 +
64561 + return;
64562 +}
64563 +
64564 +static void
64565 +insert_inodev_entry(struct inodev_entry *entry)
64566 +{
64567 + __insert_inodev_entry(&running_polstate, entry);
64568 +}
64569 +
64570 +void
64571 +insert_acl_obj_label(struct acl_object_label *obj,
64572 + struct acl_subject_label *subj)
64573 +{
64574 + unsigned int index =
64575 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
64576 + struct acl_object_label **curr;
64577 +
64578 + obj->prev = NULL;
64579 +
64580 + curr = &subj->obj_hash[index];
64581 + if (*curr != NULL)
64582 + (*curr)->prev = obj;
64583 +
64584 + obj->next = *curr;
64585 + *curr = obj;
64586 +
64587 + return;
64588 +}
64589 +
64590 +void
64591 +insert_acl_subj_label(struct acl_subject_label *obj,
64592 + struct acl_role_label *role)
64593 +{
64594 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
64595 + struct acl_subject_label **curr;
64596 +
64597 + obj->prev = NULL;
64598 +
64599 + curr = &role->subj_hash[index];
64600 + if (*curr != NULL)
64601 + (*curr)->prev = obj;
64602 +
64603 + obj->next = *curr;
64604 + *curr = obj;
64605 +
64606 + return;
64607 +}
64608 +
64609 +/* derived from glibc fnmatch() 0: match, 1: no match*/
64610 +
64611 +static int
64612 +glob_match(const char *p, const char *n)
64613 +{
64614 + char c;
64615 +
64616 + while ((c = *p++) != '\0') {
64617 + switch (c) {
64618 + case '?':
64619 + if (*n == '\0')
64620 + return 1;
64621 + else if (*n == '/')
64622 + return 1;
64623 + break;
64624 + case '\\':
64625 + if (*n != c)
64626 + return 1;
64627 + break;
64628 + case '*':
64629 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
64630 + if (*n == '/')
64631 + return 1;
64632 + else if (c == '?') {
64633 + if (*n == '\0')
64634 + return 1;
64635 + else
64636 + ++n;
64637 + }
64638 + }
64639 + if (c == '\0') {
64640 + return 0;
64641 + } else {
64642 + const char *endp;
64643 +
64644 + if ((endp = strchr(n, '/')) == NULL)
64645 + endp = n + strlen(n);
64646 +
64647 + if (c == '[') {
64648 + for (--p; n < endp; ++n)
64649 + if (!glob_match(p, n))
64650 + return 0;
64651 + } else if (c == '/') {
64652 + while (*n != '\0' && *n != '/')
64653 + ++n;
64654 + if (*n == '/' && !glob_match(p, n + 1))
64655 + return 0;
64656 + } else {
64657 + for (--p; n < endp; ++n)
64658 + if (*n == c && !glob_match(p, n))
64659 + return 0;
64660 + }
64661 +
64662 + return 1;
64663 + }
64664 + case '[':
64665 + {
64666 + int not;
64667 + char cold;
64668 +
64669 + if (*n == '\0' || *n == '/')
64670 + return 1;
64671 +
64672 + not = (*p == '!' || *p == '^');
64673 + if (not)
64674 + ++p;
64675 +
64676 + c = *p++;
64677 + for (;;) {
64678 + unsigned char fn = (unsigned char)*n;
64679 +
64680 + if (c == '\0')
64681 + return 1;
64682 + else {
64683 + if (c == fn)
64684 + goto matched;
64685 + cold = c;
64686 + c = *p++;
64687 +
64688 + if (c == '-' && *p != ']') {
64689 + unsigned char cend = *p++;
64690 +
64691 + if (cend == '\0')
64692 + return 1;
64693 +
64694 + if (cold <= fn && fn <= cend)
64695 + goto matched;
64696 +
64697 + c = *p++;
64698 + }
64699 + }
64700 +
64701 + if (c == ']')
64702 + break;
64703 + }
64704 + if (!not)
64705 + return 1;
64706 + break;
64707 + matched:
64708 + while (c != ']') {
64709 + if (c == '\0')
64710 + return 1;
64711 +
64712 + c = *p++;
64713 + }
64714 + if (not)
64715 + return 1;
64716 + }
64717 + break;
64718 + default:
64719 + if (c != *n)
64720 + return 1;
64721 + }
64722 +
64723 + ++n;
64724 + }
64725 +
64726 + if (*n == '\0')
64727 + return 0;
64728 +
64729 + if (*n == '/')
64730 + return 0;
64731 +
64732 + return 1;
64733 +}
64734 +
64735 +static struct acl_object_label *
64736 +chk_glob_label(struct acl_object_label *globbed,
64737 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64738 +{
64739 + struct acl_object_label *tmp;
64740 +
64741 + if (*path == NULL)
64742 + *path = gr_to_filename_nolock(dentry, mnt);
64743 +
64744 + tmp = globbed;
64745 +
64746 + while (tmp) {
64747 + if (!glob_match(tmp->filename, *path))
64748 + return tmp;
64749 + tmp = tmp->next;
64750 + }
64751 +
64752 + return NULL;
64753 +}
64754 +
64755 +static struct acl_object_label *
64756 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64757 + const ino_t curr_ino, const dev_t curr_dev,
64758 + const struct acl_subject_label *subj, char **path, const int checkglob)
64759 +{
64760 + struct acl_subject_label *tmpsubj;
64761 + struct acl_object_label *retval;
64762 + struct acl_object_label *retval2;
64763 +
64764 + tmpsubj = (struct acl_subject_label *) subj;
64765 + read_lock(&gr_inode_lock);
64766 + do {
64767 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64768 + if (retval) {
64769 + if (checkglob && retval->globbed) {
64770 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64771 + if (retval2)
64772 + retval = retval2;
64773 + }
64774 + break;
64775 + }
64776 + } while ((tmpsubj = tmpsubj->parent_subject));
64777 + read_unlock(&gr_inode_lock);
64778 +
64779 + return retval;
64780 +}
64781 +
64782 +static __inline__ struct acl_object_label *
64783 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64784 + struct dentry *curr_dentry,
64785 + const struct acl_subject_label *subj, char **path, const int checkglob)
64786 +{
64787 + int newglob = checkglob;
64788 + ino_t inode;
64789 + dev_t device;
64790 +
64791 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64792 + as we don't want a / * rule to match instead of the / object
64793 + don't do this for create lookups that call this function though, since they're looking up
64794 + on the parent and thus need globbing checks on all paths
64795 + */
64796 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64797 + newglob = GR_NO_GLOB;
64798 +
64799 + spin_lock(&curr_dentry->d_lock);
64800 + inode = curr_dentry->d_inode->i_ino;
64801 + device = __get_dev(curr_dentry);
64802 + spin_unlock(&curr_dentry->d_lock);
64803 +
64804 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64805 +}
64806 +
64807 +#ifdef CONFIG_HUGETLBFS
64808 +static inline bool
64809 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64810 +{
64811 + int i;
64812 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64813 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64814 + return true;
64815 + }
64816 +
64817 + return false;
64818 +}
64819 +#endif
64820 +
64821 +static struct acl_object_label *
64822 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64823 + const struct acl_subject_label *subj, char *path, const int checkglob)
64824 +{
64825 + struct dentry *dentry = (struct dentry *) l_dentry;
64826 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64827 + struct mount *real_mnt = real_mount(mnt);
64828 + struct acl_object_label *retval;
64829 + struct dentry *parent;
64830 +
64831 + br_read_lock(&vfsmount_lock);
64832 + write_seqlock(&rename_lock);
64833 +
64834 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64835 +#ifdef CONFIG_NET
64836 + mnt == sock_mnt ||
64837 +#endif
64838 +#ifdef CONFIG_HUGETLBFS
64839 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64840 +#endif
64841 + /* ignore Eric Biederman */
64842 + IS_PRIVATE(l_dentry->d_inode))) {
64843 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64844 + goto out;
64845 + }
64846 +
64847 + for (;;) {
64848 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64849 + break;
64850 +
64851 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64852 + if (!mnt_has_parent(real_mnt))
64853 + break;
64854 +
64855 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64856 + if (retval != NULL)
64857 + goto out;
64858 +
64859 + dentry = real_mnt->mnt_mountpoint;
64860 + real_mnt = real_mnt->mnt_parent;
64861 + mnt = &real_mnt->mnt;
64862 + continue;
64863 + }
64864 +
64865 + parent = dentry->d_parent;
64866 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64867 + if (retval != NULL)
64868 + goto out;
64869 +
64870 + dentry = parent;
64871 + }
64872 +
64873 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64874 +
64875 + /* gr_real_root is pinned so we don't have to hold a reference */
64876 + if (retval == NULL)
64877 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
64878 +out:
64879 + write_sequnlock(&rename_lock);
64880 + br_read_unlock(&vfsmount_lock);
64881 +
64882 + BUG_ON(retval == NULL);
64883 +
64884 + return retval;
64885 +}
64886 +
64887 +static __inline__ struct acl_object_label *
64888 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64889 + const struct acl_subject_label *subj)
64890 +{
64891 + char *path = NULL;
64892 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64893 +}
64894 +
64895 +static __inline__ struct acl_object_label *
64896 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64897 + const struct acl_subject_label *subj)
64898 +{
64899 + char *path = NULL;
64900 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64901 +}
64902 +
64903 +static __inline__ struct acl_object_label *
64904 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64905 + const struct acl_subject_label *subj, char *path)
64906 +{
64907 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64908 +}
64909 +
64910 +struct acl_subject_label *
64911 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64912 + const struct acl_role_label *role)
64913 +{
64914 + struct dentry *dentry = (struct dentry *) l_dentry;
64915 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64916 + struct mount *real_mnt = real_mount(mnt);
64917 + struct acl_subject_label *retval;
64918 + struct dentry *parent;
64919 +
64920 + br_read_lock(&vfsmount_lock);
64921 + write_seqlock(&rename_lock);
64922 +
64923 + for (;;) {
64924 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64925 + break;
64926 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64927 + if (!mnt_has_parent(real_mnt))
64928 + break;
64929 +
64930 + spin_lock(&dentry->d_lock);
64931 + read_lock(&gr_inode_lock);
64932 + retval =
64933 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64934 + __get_dev(dentry), role);
64935 + read_unlock(&gr_inode_lock);
64936 + spin_unlock(&dentry->d_lock);
64937 + if (retval != NULL)
64938 + goto out;
64939 +
64940 + dentry = real_mnt->mnt_mountpoint;
64941 + real_mnt = real_mnt->mnt_parent;
64942 + mnt = &real_mnt->mnt;
64943 + continue;
64944 + }
64945 +
64946 + spin_lock(&dentry->d_lock);
64947 + read_lock(&gr_inode_lock);
64948 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64949 + __get_dev(dentry), role);
64950 + read_unlock(&gr_inode_lock);
64951 + parent = dentry->d_parent;
64952 + spin_unlock(&dentry->d_lock);
64953 +
64954 + if (retval != NULL)
64955 + goto out;
64956 +
64957 + dentry = parent;
64958 + }
64959 +
64960 + spin_lock(&dentry->d_lock);
64961 + read_lock(&gr_inode_lock);
64962 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64963 + __get_dev(dentry), role);
64964 + read_unlock(&gr_inode_lock);
64965 + spin_unlock(&dentry->d_lock);
64966 +
64967 + if (unlikely(retval == NULL)) {
64968 + /* gr_real_root is pinned, we don't need to hold a reference */
64969 + read_lock(&gr_inode_lock);
64970 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
64971 + __get_dev(gr_real_root.dentry), role);
64972 + read_unlock(&gr_inode_lock);
64973 + }
64974 +out:
64975 + write_sequnlock(&rename_lock);
64976 + br_read_unlock(&vfsmount_lock);
64977 +
64978 + BUG_ON(retval == NULL);
64979 +
64980 + return retval;
64981 +}
64982 +
64983 +void
64984 +assign_special_role(const char *rolename)
64985 +{
64986 + struct acl_object_label *obj;
64987 + struct acl_role_label *r;
64988 + struct acl_role_label *assigned = NULL;
64989 + struct task_struct *tsk;
64990 + struct file *filp;
64991 +
64992 + FOR_EACH_ROLE_START(r)
64993 + if (!strcmp(rolename, r->rolename) &&
64994 + (r->roletype & GR_ROLE_SPECIAL)) {
64995 + assigned = r;
64996 + break;
64997 + }
64998 + FOR_EACH_ROLE_END(r)
64999 +
65000 + if (!assigned)
65001 + return;
65002 +
65003 + read_lock(&tasklist_lock);
65004 + read_lock(&grsec_exec_file_lock);
65005 +
65006 + tsk = current->real_parent;
65007 + if (tsk == NULL)
65008 + goto out_unlock;
65009 +
65010 + filp = tsk->exec_file;
65011 + if (filp == NULL)
65012 + goto out_unlock;
65013 +
65014 + tsk->is_writable = 0;
65015 + tsk->inherited = 0;
65016 +
65017 + tsk->acl_sp_role = 1;
65018 + tsk->acl_role_id = ++acl_sp_role_value;
65019 + tsk->role = assigned;
65020 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65021 +
65022 + /* ignore additional mmap checks for processes that are writable
65023 + by the default ACL */
65024 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65025 + if (unlikely(obj->mode & GR_WRITE))
65026 + tsk->is_writable = 1;
65027 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65028 + if (unlikely(obj->mode & GR_WRITE))
65029 + tsk->is_writable = 1;
65030 +
65031 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65032 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
65033 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
65034 +#endif
65035 +
65036 +out_unlock:
65037 + read_unlock(&grsec_exec_file_lock);
65038 + read_unlock(&tasklist_lock);
65039 + return;
65040 +}
65041 +
65042 +
65043 +static void
65044 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
65045 +{
65046 + struct task_struct *task = current;
65047 + const struct cred *cred = current_cred();
65048 +
65049 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
65050 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65051 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65052 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
65053 +
65054 + return;
65055 +}
65056 +
65057 +static void
65058 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
65059 +{
65060 + struct task_struct *task = current;
65061 + const struct cred *cred = current_cred();
65062 +
65063 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
65064 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65065 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65066 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
65067 +
65068 + return;
65069 +}
65070 +
65071 +static void
65072 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
65073 +{
65074 + struct task_struct *task = current;
65075 + const struct cred *cred = current_cred();
65076 +
65077 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
65078 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65079 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65080 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
65081 +
65082 + return;
65083 +}
65084 +
65085 +static void
65086 +gr_set_proc_res(struct task_struct *task)
65087 +{
65088 + struct acl_subject_label *proc;
65089 + unsigned short i;
65090 +
65091 + proc = task->acl;
65092 +
65093 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
65094 + return;
65095 +
65096 + for (i = 0; i < RLIM_NLIMITS; i++) {
65097 + if (!(proc->resmask & (1U << i)))
65098 + continue;
65099 +
65100 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
65101 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
65102 +
65103 + if (i == RLIMIT_CPU)
65104 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
65105 + }
65106 +
65107 + return;
65108 +}
65109 +
65110 +/* both of the below must be called with
65111 + rcu_read_lock();
65112 + read_lock(&tasklist_lock);
65113 + read_lock(&grsec_exec_file_lock);
65114 +*/
65115 +
65116 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
65117 +{
65118 + char *tmpname;
65119 + struct acl_subject_label *tmpsubj;
65120 + struct file *filp;
65121 + struct name_entry *nmatch;
65122 +
65123 + filp = task->exec_file;
65124 + if (filp == NULL)
65125 + return NULL;
65126 +
65127 + /* the following is to apply the correct subject
65128 + on binaries running when the RBAC system
65129 + is enabled, when the binaries have been
65130 + replaced or deleted since their execution
65131 + -----
65132 + when the RBAC system starts, the inode/dev
65133 + from exec_file will be one the RBAC system
65134 + is unaware of. It only knows the inode/dev
65135 + of the present file on disk, or the absence
65136 + of it.
65137 + */
65138 +
65139 + if (filename)
65140 + nmatch = __lookup_name_entry(state, filename);
65141 + else {
65142 + preempt_disable();
65143 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65144 +
65145 + nmatch = __lookup_name_entry(state, tmpname);
65146 + preempt_enable();
65147 + }
65148 + tmpsubj = NULL;
65149 + if (nmatch) {
65150 + if (nmatch->deleted)
65151 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65152 + else
65153 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65154 + }
65155 + /* this also works for the reload case -- if we don't match a potentially inherited subject
65156 + then we fall back to a normal lookup based on the binary's ino/dev
65157 + */
65158 + if (tmpsubj == NULL)
65159 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
65160 +
65161 + return tmpsubj;
65162 +}
65163 +
65164 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
65165 +{
65166 + return __gr_get_subject_for_task(&running_polstate, task, filename);
65167 +}
65168 +
65169 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
65170 +{
65171 + struct acl_object_label *obj;
65172 + struct file *filp;
65173 +
65174 + filp = task->exec_file;
65175 +
65176 + task->acl = subj;
65177 + task->is_writable = 0;
65178 + /* ignore additional mmap checks for processes that are writable
65179 + by the default ACL */
65180 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
65181 + if (unlikely(obj->mode & GR_WRITE))
65182 + task->is_writable = 1;
65183 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65184 + if (unlikely(obj->mode & GR_WRITE))
65185 + task->is_writable = 1;
65186 +
65187 + gr_set_proc_res(task);
65188 +
65189 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65190 + 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);
65191 +#endif
65192 +}
65193 +
65194 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
65195 +{
65196 + __gr_apply_subject_to_task(&running_polstate, task, subj);
65197 +}
65198 +
65199 +__u32
65200 +gr_search_file(const struct dentry * dentry, const __u32 mode,
65201 + const struct vfsmount * mnt)
65202 +{
65203 + __u32 retval = mode;
65204 + struct acl_subject_label *curracl;
65205 + struct acl_object_label *currobj;
65206 +
65207 + if (unlikely(!(gr_status & GR_READY)))
65208 + return (mode & ~GR_AUDITS);
65209 +
65210 + curracl = current->acl;
65211 +
65212 + currobj = chk_obj_label(dentry, mnt, curracl);
65213 + retval = currobj->mode & mode;
65214 +
65215 + /* if we're opening a specified transfer file for writing
65216 + (e.g. /dev/initctl), then transfer our role to init
65217 + */
65218 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
65219 + current->role->roletype & GR_ROLE_PERSIST)) {
65220 + struct task_struct *task = init_pid_ns.child_reaper;
65221 +
65222 + if (task->role != current->role) {
65223 + struct acl_subject_label *subj;
65224 +
65225 + task->acl_sp_role = 0;
65226 + task->acl_role_id = current->acl_role_id;
65227 + task->role = current->role;
65228 + rcu_read_lock();
65229 + read_lock(&grsec_exec_file_lock);
65230 + subj = gr_get_subject_for_task(task, NULL);
65231 + gr_apply_subject_to_task(task, subj);
65232 + read_unlock(&grsec_exec_file_lock);
65233 + rcu_read_unlock();
65234 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
65235 + }
65236 + }
65237 +
65238 + if (unlikely
65239 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
65240 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
65241 + __u32 new_mode = mode;
65242 +
65243 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65244 +
65245 + retval = new_mode;
65246 +
65247 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
65248 + new_mode |= GR_INHERIT;
65249 +
65250 + if (!(mode & GR_NOLEARN))
65251 + gr_log_learn(dentry, mnt, new_mode);
65252 + }
65253 +
65254 + return retval;
65255 +}
65256 +
65257 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
65258 + const struct dentry *parent,
65259 + const struct vfsmount *mnt)
65260 +{
65261 + struct name_entry *match;
65262 + struct acl_object_label *matchpo;
65263 + struct acl_subject_label *curracl;
65264 + char *path;
65265 +
65266 + if (unlikely(!(gr_status & GR_READY)))
65267 + return NULL;
65268 +
65269 + preempt_disable();
65270 + path = gr_to_filename_rbac(new_dentry, mnt);
65271 + match = lookup_name_entry_create(path);
65272 +
65273 + curracl = current->acl;
65274 +
65275 + if (match) {
65276 + read_lock(&gr_inode_lock);
65277 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
65278 + read_unlock(&gr_inode_lock);
65279 +
65280 + if (matchpo) {
65281 + preempt_enable();
65282 + return matchpo;
65283 + }
65284 + }
65285 +
65286 + // lookup parent
65287 +
65288 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
65289 +
65290 + preempt_enable();
65291 + return matchpo;
65292 +}
65293 +
65294 +__u32
65295 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
65296 + const struct vfsmount * mnt, const __u32 mode)
65297 +{
65298 + struct acl_object_label *matchpo;
65299 + __u32 retval;
65300 +
65301 + if (unlikely(!(gr_status & GR_READY)))
65302 + return (mode & ~GR_AUDITS);
65303 +
65304 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
65305 +
65306 + retval = matchpo->mode & mode;
65307 +
65308 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
65309 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65310 + __u32 new_mode = mode;
65311 +
65312 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65313 +
65314 + gr_log_learn(new_dentry, mnt, new_mode);
65315 + return new_mode;
65316 + }
65317 +
65318 + return retval;
65319 +}
65320 +
65321 +__u32
65322 +gr_check_link(const struct dentry * new_dentry,
65323 + const struct dentry * parent_dentry,
65324 + const struct vfsmount * parent_mnt,
65325 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
65326 +{
65327 + struct acl_object_label *obj;
65328 + __u32 oldmode, newmode;
65329 + __u32 needmode;
65330 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
65331 + GR_DELETE | GR_INHERIT;
65332 +
65333 + if (unlikely(!(gr_status & GR_READY)))
65334 + return (GR_CREATE | GR_LINK);
65335 +
65336 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
65337 + oldmode = obj->mode;
65338 +
65339 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
65340 + newmode = obj->mode;
65341 +
65342 + needmode = newmode & checkmodes;
65343 +
65344 + // old name for hardlink must have at least the permissions of the new name
65345 + if ((oldmode & needmode) != needmode)
65346 + goto bad;
65347 +
65348 + // if old name had restrictions/auditing, make sure the new name does as well
65349 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
65350 +
65351 + // don't allow hardlinking of suid/sgid/fcapped files without permission
65352 + if (is_privileged_binary(old_dentry))
65353 + needmode |= GR_SETID;
65354 +
65355 + if ((newmode & needmode) != needmode)
65356 + goto bad;
65357 +
65358 + // enforce minimum permissions
65359 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
65360 + return newmode;
65361 +bad:
65362 + needmode = oldmode;
65363 + if (is_privileged_binary(old_dentry))
65364 + needmode |= GR_SETID;
65365 +
65366 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
65367 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
65368 + return (GR_CREATE | GR_LINK);
65369 + } else if (newmode & GR_SUPPRESS)
65370 + return GR_SUPPRESS;
65371 + else
65372 + return 0;
65373 +}
65374 +
65375 +int
65376 +gr_check_hidden_task(const struct task_struct *task)
65377 +{
65378 + if (unlikely(!(gr_status & GR_READY)))
65379 + return 0;
65380 +
65381 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
65382 + return 1;
65383 +
65384 + return 0;
65385 +}
65386 +
65387 +int
65388 +gr_check_protected_task(const struct task_struct *task)
65389 +{
65390 + if (unlikely(!(gr_status & GR_READY) || !task))
65391 + return 0;
65392 +
65393 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65394 + task->acl != current->acl)
65395 + return 1;
65396 +
65397 + return 0;
65398 +}
65399 +
65400 +int
65401 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65402 +{
65403 + struct task_struct *p;
65404 + int ret = 0;
65405 +
65406 + if (unlikely(!(gr_status & GR_READY) || !pid))
65407 + return ret;
65408 +
65409 + read_lock(&tasklist_lock);
65410 + do_each_pid_task(pid, type, p) {
65411 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65412 + p->acl != current->acl) {
65413 + ret = 1;
65414 + goto out;
65415 + }
65416 + } while_each_pid_task(pid, type, p);
65417 +out:
65418 + read_unlock(&tasklist_lock);
65419 +
65420 + return ret;
65421 +}
65422 +
65423 +void
65424 +gr_copy_label(struct task_struct *tsk)
65425 +{
65426 + struct task_struct *p = current;
65427 +
65428 + tsk->inherited = p->inherited;
65429 + tsk->acl_sp_role = 0;
65430 + tsk->acl_role_id = p->acl_role_id;
65431 + tsk->acl = p->acl;
65432 + tsk->role = p->role;
65433 + tsk->signal->used_accept = 0;
65434 + tsk->signal->curr_ip = p->signal->curr_ip;
65435 + tsk->signal->saved_ip = p->signal->saved_ip;
65436 + if (p->exec_file)
65437 + get_file(p->exec_file);
65438 + tsk->exec_file = p->exec_file;
65439 + tsk->is_writable = p->is_writable;
65440 + if (unlikely(p->signal->used_accept)) {
65441 + p->signal->curr_ip = 0;
65442 + p->signal->saved_ip = 0;
65443 + }
65444 +
65445 + return;
65446 +}
65447 +
65448 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
65449 +
65450 +int
65451 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65452 +{
65453 + unsigned int i;
65454 + __u16 num;
65455 + uid_t *uidlist;
65456 + uid_t curuid;
65457 + int realok = 0;
65458 + int effectiveok = 0;
65459 + int fsok = 0;
65460 + uid_t globalreal, globaleffective, globalfs;
65461 +
65462 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
65463 + struct user_struct *user;
65464 +
65465 + if (!uid_valid(real))
65466 + goto skipit;
65467 +
65468 + /* find user based on global namespace */
65469 +
65470 + globalreal = GR_GLOBAL_UID(real);
65471 +
65472 + user = find_user(make_kuid(&init_user_ns, globalreal));
65473 + if (user == NULL)
65474 + goto skipit;
65475 +
65476 + if (gr_process_kernel_setuid_ban(user)) {
65477 + /* for find_user */
65478 + free_uid(user);
65479 + return 1;
65480 + }
65481 +
65482 + /* for find_user */
65483 + free_uid(user);
65484 +
65485 +skipit:
65486 +#endif
65487 +
65488 + if (unlikely(!(gr_status & GR_READY)))
65489 + return 0;
65490 +
65491 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65492 + gr_log_learn_uid_change(real, effective, fs);
65493 +
65494 + num = current->acl->user_trans_num;
65495 + uidlist = current->acl->user_transitions;
65496 +
65497 + if (uidlist == NULL)
65498 + return 0;
65499 +
65500 + if (!uid_valid(real)) {
65501 + realok = 1;
65502 + globalreal = (uid_t)-1;
65503 + } else {
65504 + globalreal = GR_GLOBAL_UID(real);
65505 + }
65506 + if (!uid_valid(effective)) {
65507 + effectiveok = 1;
65508 + globaleffective = (uid_t)-1;
65509 + } else {
65510 + globaleffective = GR_GLOBAL_UID(effective);
65511 + }
65512 + if (!uid_valid(fs)) {
65513 + fsok = 1;
65514 + globalfs = (uid_t)-1;
65515 + } else {
65516 + globalfs = GR_GLOBAL_UID(fs);
65517 + }
65518 +
65519 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
65520 + for (i = 0; i < num; i++) {
65521 + curuid = uidlist[i];
65522 + if (globalreal == curuid)
65523 + realok = 1;
65524 + if (globaleffective == curuid)
65525 + effectiveok = 1;
65526 + if (globalfs == curuid)
65527 + fsok = 1;
65528 + }
65529 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
65530 + for (i = 0; i < num; i++) {
65531 + curuid = uidlist[i];
65532 + if (globalreal == curuid)
65533 + break;
65534 + if (globaleffective == curuid)
65535 + break;
65536 + if (globalfs == curuid)
65537 + break;
65538 + }
65539 + /* not in deny list */
65540 + if (i == num) {
65541 + realok = 1;
65542 + effectiveok = 1;
65543 + fsok = 1;
65544 + }
65545 + }
65546 +
65547 + if (realok && effectiveok && fsok)
65548 + return 0;
65549 + else {
65550 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65551 + return 1;
65552 + }
65553 +}
65554 +
65555 +int
65556 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65557 +{
65558 + unsigned int i;
65559 + __u16 num;
65560 + gid_t *gidlist;
65561 + gid_t curgid;
65562 + int realok = 0;
65563 + int effectiveok = 0;
65564 + int fsok = 0;
65565 + gid_t globalreal, globaleffective, globalfs;
65566 +
65567 + if (unlikely(!(gr_status & GR_READY)))
65568 + return 0;
65569 +
65570 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65571 + gr_log_learn_gid_change(real, effective, fs);
65572 +
65573 + num = current->acl->group_trans_num;
65574 + gidlist = current->acl->group_transitions;
65575 +
65576 + if (gidlist == NULL)
65577 + return 0;
65578 +
65579 + if (!gid_valid(real)) {
65580 + realok = 1;
65581 + globalreal = (gid_t)-1;
65582 + } else {
65583 + globalreal = GR_GLOBAL_GID(real);
65584 + }
65585 + if (!gid_valid(effective)) {
65586 + effectiveok = 1;
65587 + globaleffective = (gid_t)-1;
65588 + } else {
65589 + globaleffective = GR_GLOBAL_GID(effective);
65590 + }
65591 + if (!gid_valid(fs)) {
65592 + fsok = 1;
65593 + globalfs = (gid_t)-1;
65594 + } else {
65595 + globalfs = GR_GLOBAL_GID(fs);
65596 + }
65597 +
65598 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
65599 + for (i = 0; i < num; i++) {
65600 + curgid = gidlist[i];
65601 + if (globalreal == curgid)
65602 + realok = 1;
65603 + if (globaleffective == curgid)
65604 + effectiveok = 1;
65605 + if (globalfs == curgid)
65606 + fsok = 1;
65607 + }
65608 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
65609 + for (i = 0; i < num; i++) {
65610 + curgid = gidlist[i];
65611 + if (globalreal == curgid)
65612 + break;
65613 + if (globaleffective == curgid)
65614 + break;
65615 + if (globalfs == curgid)
65616 + break;
65617 + }
65618 + /* not in deny list */
65619 + if (i == num) {
65620 + realok = 1;
65621 + effectiveok = 1;
65622 + fsok = 1;
65623 + }
65624 + }
65625 +
65626 + if (realok && effectiveok && fsok)
65627 + return 0;
65628 + else {
65629 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65630 + return 1;
65631 + }
65632 +}
65633 +
65634 +extern int gr_acl_is_capable(const int cap);
65635 +
65636 +void
65637 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
65638 +{
65639 + struct acl_role_label *role = task->role;
65640 + struct acl_subject_label *subj = NULL;
65641 + struct acl_object_label *obj;
65642 + struct file *filp;
65643 + uid_t uid;
65644 + gid_t gid;
65645 +
65646 + if (unlikely(!(gr_status & GR_READY)))
65647 + return;
65648 +
65649 + uid = GR_GLOBAL_UID(kuid);
65650 + gid = GR_GLOBAL_GID(kgid);
65651 +
65652 + filp = task->exec_file;
65653 +
65654 + /* kernel process, we'll give them the kernel role */
65655 + if (unlikely(!filp)) {
65656 + task->role = running_polstate.kernel_role;
65657 + task->acl = running_polstate.kernel_role->root_label;
65658 + return;
65659 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
65660 + /* save the current ip at time of role lookup so that the proper
65661 + IP will be learned for role_allowed_ip */
65662 + task->signal->saved_ip = task->signal->curr_ip;
65663 + role = lookup_acl_role_label(task, uid, gid);
65664 + }
65665 +
65666 + /* don't change the role if we're not a privileged process */
65667 + if (role && task->role != role &&
65668 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
65669 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
65670 + return;
65671 +
65672 + /* perform subject lookup in possibly new role
65673 + we can use this result below in the case where role == task->role
65674 + */
65675 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
65676 +
65677 + /* if we changed uid/gid, but result in the same role
65678 + and are using inheritance, don't lose the inherited subject
65679 + if current subject is other than what normal lookup
65680 + would result in, we arrived via inheritance, don't
65681 + lose subject
65682 + */
65683 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
65684 + (subj == task->acl)))
65685 + task->acl = subj;
65686 +
65687 + /* leave task->inherited unaffected */
65688 +
65689 + task->role = role;
65690 +
65691 + task->is_writable = 0;
65692 +
65693 + /* ignore additional mmap checks for processes that are writable
65694 + by the default ACL */
65695 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65696 + if (unlikely(obj->mode & GR_WRITE))
65697 + task->is_writable = 1;
65698 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65699 + if (unlikely(obj->mode & GR_WRITE))
65700 + task->is_writable = 1;
65701 +
65702 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65703 + 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);
65704 +#endif
65705 +
65706 + gr_set_proc_res(task);
65707 +
65708 + return;
65709 +}
65710 +
65711 +int
65712 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65713 + const int unsafe_flags)
65714 +{
65715 + struct task_struct *task = current;
65716 + struct acl_subject_label *newacl;
65717 + struct acl_object_label *obj;
65718 + __u32 retmode;
65719 +
65720 + if (unlikely(!(gr_status & GR_READY)))
65721 + return 0;
65722 +
65723 + newacl = chk_subj_label(dentry, mnt, task->role);
65724 +
65725 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
65726 + did an exec
65727 + */
65728 + rcu_read_lock();
65729 + read_lock(&tasklist_lock);
65730 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
65731 + (task->parent->acl->mode & GR_POVERRIDE))) {
65732 + read_unlock(&tasklist_lock);
65733 + rcu_read_unlock();
65734 + goto skip_check;
65735 + }
65736 + read_unlock(&tasklist_lock);
65737 + rcu_read_unlock();
65738 +
65739 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
65740 + !(task->role->roletype & GR_ROLE_GOD) &&
65741 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
65742 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65743 + if (unsafe_flags & LSM_UNSAFE_SHARE)
65744 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
65745 + else
65746 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
65747 + return -EACCES;
65748 + }
65749 +
65750 +skip_check:
65751 +
65752 + obj = chk_obj_label(dentry, mnt, task->acl);
65753 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
65754 +
65755 + if (!(task->acl->mode & GR_INHERITLEARN) &&
65756 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
65757 + if (obj->nested)
65758 + task->acl = obj->nested;
65759 + else
65760 + task->acl = newacl;
65761 + task->inherited = 0;
65762 + } else {
65763 + task->inherited = 1;
65764 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
65765 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
65766 + }
65767 +
65768 + task->is_writable = 0;
65769 +
65770 + /* ignore additional mmap checks for processes that are writable
65771 + by the default ACL */
65772 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
65773 + if (unlikely(obj->mode & GR_WRITE))
65774 + task->is_writable = 1;
65775 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
65776 + if (unlikely(obj->mode & GR_WRITE))
65777 + task->is_writable = 1;
65778 +
65779 + gr_set_proc_res(task);
65780 +
65781 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65782 + 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);
65783 +#endif
65784 + return 0;
65785 +}
65786 +
65787 +/* always called with valid inodev ptr */
65788 +static void
65789 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
65790 +{
65791 + struct acl_object_label *matchpo;
65792 + struct acl_subject_label *matchps;
65793 + struct acl_subject_label *subj;
65794 + struct acl_role_label *role;
65795 + unsigned int x;
65796 +
65797 + FOR_EACH_ROLE_START(role)
65798 + FOR_EACH_SUBJECT_START(role, subj, x)
65799 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65800 + matchpo->mode |= GR_DELETED;
65801 + FOR_EACH_SUBJECT_END(subj,x)
65802 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65803 + /* nested subjects aren't in the role's subj_hash table */
65804 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65805 + matchpo->mode |= GR_DELETED;
65806 + FOR_EACH_NESTED_SUBJECT_END(subj)
65807 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
65808 + matchps->mode |= GR_DELETED;
65809 + FOR_EACH_ROLE_END(role)
65810 +
65811 + inodev->nentry->deleted = 1;
65812 +
65813 + return;
65814 +}
65815 +
65816 +void
65817 +gr_handle_delete(const ino_t ino, const dev_t dev)
65818 +{
65819 + struct inodev_entry *inodev;
65820 +
65821 + if (unlikely(!(gr_status & GR_READY)))
65822 + return;
65823 +
65824 + write_lock(&gr_inode_lock);
65825 + inodev = lookup_inodev_entry(ino, dev);
65826 + if (inodev != NULL)
65827 + do_handle_delete(inodev, ino, dev);
65828 + write_unlock(&gr_inode_lock);
65829 +
65830 + return;
65831 +}
65832 +
65833 +static void
65834 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65835 + const ino_t newinode, const dev_t newdevice,
65836 + struct acl_subject_label *subj)
65837 +{
65838 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65839 + struct acl_object_label *match;
65840 +
65841 + match = subj->obj_hash[index];
65842 +
65843 + while (match && (match->inode != oldinode ||
65844 + match->device != olddevice ||
65845 + !(match->mode & GR_DELETED)))
65846 + match = match->next;
65847 +
65848 + if (match && (match->inode == oldinode)
65849 + && (match->device == olddevice)
65850 + && (match->mode & GR_DELETED)) {
65851 + if (match->prev == NULL) {
65852 + subj->obj_hash[index] = match->next;
65853 + if (match->next != NULL)
65854 + match->next->prev = NULL;
65855 + } else {
65856 + match->prev->next = match->next;
65857 + if (match->next != NULL)
65858 + match->next->prev = match->prev;
65859 + }
65860 + match->prev = NULL;
65861 + match->next = NULL;
65862 + match->inode = newinode;
65863 + match->device = newdevice;
65864 + match->mode &= ~GR_DELETED;
65865 +
65866 + insert_acl_obj_label(match, subj);
65867 + }
65868 +
65869 + return;
65870 +}
65871 +
65872 +static void
65873 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65874 + const ino_t newinode, const dev_t newdevice,
65875 + struct acl_role_label *role)
65876 +{
65877 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65878 + struct acl_subject_label *match;
65879 +
65880 + match = role->subj_hash[index];
65881 +
65882 + while (match && (match->inode != oldinode ||
65883 + match->device != olddevice ||
65884 + !(match->mode & GR_DELETED)))
65885 + match = match->next;
65886 +
65887 + if (match && (match->inode == oldinode)
65888 + && (match->device == olddevice)
65889 + && (match->mode & GR_DELETED)) {
65890 + if (match->prev == NULL) {
65891 + role->subj_hash[index] = match->next;
65892 + if (match->next != NULL)
65893 + match->next->prev = NULL;
65894 + } else {
65895 + match->prev->next = match->next;
65896 + if (match->next != NULL)
65897 + match->next->prev = match->prev;
65898 + }
65899 + match->prev = NULL;
65900 + match->next = NULL;
65901 + match->inode = newinode;
65902 + match->device = newdevice;
65903 + match->mode &= ~GR_DELETED;
65904 +
65905 + insert_acl_subj_label(match, role);
65906 + }
65907 +
65908 + return;
65909 +}
65910 +
65911 +static void
65912 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65913 + const ino_t newinode, const dev_t newdevice)
65914 +{
65915 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
65916 + struct inodev_entry *match;
65917 +
65918 + match = running_polstate.inodev_set.i_hash[index];
65919 +
65920 + while (match && (match->nentry->inode != oldinode ||
65921 + match->nentry->device != olddevice || !match->nentry->deleted))
65922 + match = match->next;
65923 +
65924 + if (match && (match->nentry->inode == oldinode)
65925 + && (match->nentry->device == olddevice) &&
65926 + match->nentry->deleted) {
65927 + if (match->prev == NULL) {
65928 + running_polstate.inodev_set.i_hash[index] = match->next;
65929 + if (match->next != NULL)
65930 + match->next->prev = NULL;
65931 + } else {
65932 + match->prev->next = match->next;
65933 + if (match->next != NULL)
65934 + match->next->prev = match->prev;
65935 + }
65936 + match->prev = NULL;
65937 + match->next = NULL;
65938 + match->nentry->inode = newinode;
65939 + match->nentry->device = newdevice;
65940 + match->nentry->deleted = 0;
65941 +
65942 + insert_inodev_entry(match);
65943 + }
65944 +
65945 + return;
65946 +}
65947 +
65948 +static void
65949 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65950 +{
65951 + struct acl_subject_label *subj;
65952 + struct acl_role_label *role;
65953 + unsigned int x;
65954 +
65955 + FOR_EACH_ROLE_START(role)
65956 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65957 +
65958 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65959 + if ((subj->inode == ino) && (subj->device == dev)) {
65960 + subj->inode = ino;
65961 + subj->device = dev;
65962 + }
65963 + /* nested subjects aren't in the role's subj_hash table */
65964 + update_acl_obj_label(matchn->inode, matchn->device,
65965 + ino, dev, subj);
65966 + FOR_EACH_NESTED_SUBJECT_END(subj)
65967 + FOR_EACH_SUBJECT_START(role, subj, x)
65968 + update_acl_obj_label(matchn->inode, matchn->device,
65969 + ino, dev, subj);
65970 + FOR_EACH_SUBJECT_END(subj,x)
65971 + FOR_EACH_ROLE_END(role)
65972 +
65973 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65974 +
65975 + return;
65976 +}
65977 +
65978 +static void
65979 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65980 + const struct vfsmount *mnt)
65981 +{
65982 + ino_t ino = dentry->d_inode->i_ino;
65983 + dev_t dev = __get_dev(dentry);
65984 +
65985 + __do_handle_create(matchn, ino, dev);
65986 +
65987 + return;
65988 +}
65989 +
65990 +void
65991 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65992 +{
65993 + struct name_entry *matchn;
65994 +
65995 + if (unlikely(!(gr_status & GR_READY)))
65996 + return;
65997 +
65998 + preempt_disable();
65999 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
66000 +
66001 + if (unlikely((unsigned long)matchn)) {
66002 + write_lock(&gr_inode_lock);
66003 + do_handle_create(matchn, dentry, mnt);
66004 + write_unlock(&gr_inode_lock);
66005 + }
66006 + preempt_enable();
66007 +
66008 + return;
66009 +}
66010 +
66011 +void
66012 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
66013 +{
66014 + struct name_entry *matchn;
66015 +
66016 + if (unlikely(!(gr_status & GR_READY)))
66017 + return;
66018 +
66019 + preempt_disable();
66020 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
66021 +
66022 + if (unlikely((unsigned long)matchn)) {
66023 + write_lock(&gr_inode_lock);
66024 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
66025 + write_unlock(&gr_inode_lock);
66026 + }
66027 + preempt_enable();
66028 +
66029 + return;
66030 +}
66031 +
66032 +void
66033 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
66034 + struct dentry *old_dentry,
66035 + struct dentry *new_dentry,
66036 + struct vfsmount *mnt, const __u8 replace)
66037 +{
66038 + struct name_entry *matchn;
66039 + struct inodev_entry *inodev;
66040 + struct inode *inode = new_dentry->d_inode;
66041 + ino_t old_ino = old_dentry->d_inode->i_ino;
66042 + dev_t old_dev = __get_dev(old_dentry);
66043 +
66044 + /* vfs_rename swaps the name and parent link for old_dentry and
66045 + new_dentry
66046 + at this point, old_dentry has the new name, parent link, and inode
66047 + for the renamed file
66048 + if a file is being replaced by a rename, new_dentry has the inode
66049 + and name for the replaced file
66050 + */
66051 +
66052 + if (unlikely(!(gr_status & GR_READY)))
66053 + return;
66054 +
66055 + preempt_disable();
66056 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
66057 +
66058 + /* we wouldn't have to check d_inode if it weren't for
66059 + NFS silly-renaming
66060 + */
66061 +
66062 + write_lock(&gr_inode_lock);
66063 + if (unlikely(replace && inode)) {
66064 + ino_t new_ino = inode->i_ino;
66065 + dev_t new_dev = __get_dev(new_dentry);
66066 +
66067 + inodev = lookup_inodev_entry(new_ino, new_dev);
66068 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
66069 + do_handle_delete(inodev, new_ino, new_dev);
66070 + }
66071 +
66072 + inodev = lookup_inodev_entry(old_ino, old_dev);
66073 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
66074 + do_handle_delete(inodev, old_ino, old_dev);
66075 +
66076 + if (unlikely((unsigned long)matchn))
66077 + do_handle_create(matchn, old_dentry, mnt);
66078 +
66079 + write_unlock(&gr_inode_lock);
66080 + preempt_enable();
66081 +
66082 + return;
66083 +}
66084 +
66085 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
66086 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
66087 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
66088 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
66089 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
66090 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
66091 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
66092 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
66093 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
66094 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
66095 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
66096 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
66097 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
66098 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
66099 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
66100 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
66101 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
66102 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
66103 +};
66104 +
66105 +void
66106 +gr_learn_resource(const struct task_struct *task,
66107 + const int res, const unsigned long wanted, const int gt)
66108 +{
66109 + struct acl_subject_label *acl;
66110 + const struct cred *cred;
66111 +
66112 + if (unlikely((gr_status & GR_READY) &&
66113 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
66114 + goto skip_reslog;
66115 +
66116 + gr_log_resource(task, res, wanted, gt);
66117 +skip_reslog:
66118 +
66119 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
66120 + return;
66121 +
66122 + acl = task->acl;
66123 +
66124 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
66125 + !(acl->resmask & (1U << (unsigned short) res))))
66126 + return;
66127 +
66128 + if (wanted >= acl->res[res].rlim_cur) {
66129 + unsigned long res_add;
66130 +
66131 + res_add = wanted + res_learn_bumps[res];
66132 +
66133 + acl->res[res].rlim_cur = res_add;
66134 +
66135 + if (wanted > acl->res[res].rlim_max)
66136 + acl->res[res].rlim_max = res_add;
66137 +
66138 + /* only log the subject filename, since resource logging is supported for
66139 + single-subject learning only */
66140 + rcu_read_lock();
66141 + cred = __task_cred(task);
66142 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66143 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
66144 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
66145 + "", (unsigned long) res, &task->signal->saved_ip);
66146 + rcu_read_unlock();
66147 + }
66148 +
66149 + return;
66150 +}
66151 +EXPORT_SYMBOL(gr_learn_resource);
66152 +#endif
66153 +
66154 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
66155 +void
66156 +pax_set_initial_flags(struct linux_binprm *bprm)
66157 +{
66158 + struct task_struct *task = current;
66159 + struct acl_subject_label *proc;
66160 + unsigned long flags;
66161 +
66162 + if (unlikely(!(gr_status & GR_READY)))
66163 + return;
66164 +
66165 + flags = pax_get_flags(task);
66166 +
66167 + proc = task->acl;
66168 +
66169 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
66170 + flags &= ~MF_PAX_PAGEEXEC;
66171 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
66172 + flags &= ~MF_PAX_SEGMEXEC;
66173 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
66174 + flags &= ~MF_PAX_RANDMMAP;
66175 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
66176 + flags &= ~MF_PAX_EMUTRAMP;
66177 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
66178 + flags &= ~MF_PAX_MPROTECT;
66179 +
66180 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
66181 + flags |= MF_PAX_PAGEEXEC;
66182 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
66183 + flags |= MF_PAX_SEGMEXEC;
66184 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
66185 + flags |= MF_PAX_RANDMMAP;
66186 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
66187 + flags |= MF_PAX_EMUTRAMP;
66188 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
66189 + flags |= MF_PAX_MPROTECT;
66190 +
66191 + pax_set_flags(task, flags);
66192 +
66193 + return;
66194 +}
66195 +#endif
66196 +
66197 +int
66198 +gr_handle_proc_ptrace(struct task_struct *task)
66199 +{
66200 + struct file *filp;
66201 + struct task_struct *tmp = task;
66202 + struct task_struct *curtemp = current;
66203 + __u32 retmode;
66204 +
66205 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66206 + if (unlikely(!(gr_status & GR_READY)))
66207 + return 0;
66208 +#endif
66209 +
66210 + read_lock(&tasklist_lock);
66211 + read_lock(&grsec_exec_file_lock);
66212 + filp = task->exec_file;
66213 +
66214 + while (task_pid_nr(tmp) > 0) {
66215 + if (tmp == curtemp)
66216 + break;
66217 + tmp = tmp->real_parent;
66218 + }
66219 +
66220 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66221 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
66222 + read_unlock(&grsec_exec_file_lock);
66223 + read_unlock(&tasklist_lock);
66224 + return 1;
66225 + }
66226 +
66227 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66228 + if (!(gr_status & GR_READY)) {
66229 + read_unlock(&grsec_exec_file_lock);
66230 + read_unlock(&tasklist_lock);
66231 + return 0;
66232 + }
66233 +#endif
66234 +
66235 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66236 + read_unlock(&grsec_exec_file_lock);
66237 + read_unlock(&tasklist_lock);
66238 +
66239 + if (retmode & GR_NOPTRACE)
66240 + return 1;
66241 +
66242 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66243 + && (current->acl != task->acl || (current->acl != current->role->root_label
66244 + && task_pid_nr(current) != task_pid_nr(task))))
66245 + return 1;
66246 +
66247 + return 0;
66248 +}
66249 +
66250 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66251 +{
66252 + if (unlikely(!(gr_status & GR_READY)))
66253 + return;
66254 +
66255 + if (!(current->role->roletype & GR_ROLE_GOD))
66256 + return;
66257 +
66258 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66259 + p->role->rolename, gr_task_roletype_to_char(p),
66260 + p->acl->filename);
66261 +}
66262 +
66263 +int
66264 +gr_handle_ptrace(struct task_struct *task, const long request)
66265 +{
66266 + struct task_struct *tmp = task;
66267 + struct task_struct *curtemp = current;
66268 + __u32 retmode;
66269 +
66270 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66271 + if (unlikely(!(gr_status & GR_READY)))
66272 + return 0;
66273 +#endif
66274 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66275 + read_lock(&tasklist_lock);
66276 + while (task_pid_nr(tmp) > 0) {
66277 + if (tmp == curtemp)
66278 + break;
66279 + tmp = tmp->real_parent;
66280 + }
66281 +
66282 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66283 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66284 + read_unlock(&tasklist_lock);
66285 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66286 + return 1;
66287 + }
66288 + read_unlock(&tasklist_lock);
66289 + }
66290 +
66291 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66292 + if (!(gr_status & GR_READY))
66293 + return 0;
66294 +#endif
66295 +
66296 + read_lock(&grsec_exec_file_lock);
66297 + if (unlikely(!task->exec_file)) {
66298 + read_unlock(&grsec_exec_file_lock);
66299 + return 0;
66300 + }
66301 +
66302 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66303 + read_unlock(&grsec_exec_file_lock);
66304 +
66305 + if (retmode & GR_NOPTRACE) {
66306 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66307 + return 1;
66308 + }
66309 +
66310 + if (retmode & GR_PTRACERD) {
66311 + switch (request) {
66312 + case PTRACE_SEIZE:
66313 + case PTRACE_POKETEXT:
66314 + case PTRACE_POKEDATA:
66315 + case PTRACE_POKEUSR:
66316 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66317 + case PTRACE_SETREGS:
66318 + case PTRACE_SETFPREGS:
66319 +#endif
66320 +#ifdef CONFIG_X86
66321 + case PTRACE_SETFPXREGS:
66322 +#endif
66323 +#ifdef CONFIG_ALTIVEC
66324 + case PTRACE_SETVRREGS:
66325 +#endif
66326 + return 1;
66327 + default:
66328 + return 0;
66329 + }
66330 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66331 + !(current->role->roletype & GR_ROLE_GOD) &&
66332 + (current->acl != task->acl)) {
66333 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66334 + return 1;
66335 + }
66336 +
66337 + return 0;
66338 +}
66339 +
66340 +static int is_writable_mmap(const struct file *filp)
66341 +{
66342 + struct task_struct *task = current;
66343 + struct acl_object_label *obj, *obj2;
66344 +
66345 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66346 + !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))) {
66347 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
66348 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66349 + task->role->root_label);
66350 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66351 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66352 + return 1;
66353 + }
66354 + }
66355 + return 0;
66356 +}
66357 +
66358 +int
66359 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66360 +{
66361 + __u32 mode;
66362 +
66363 + if (unlikely(!file || !(prot & PROT_EXEC)))
66364 + return 1;
66365 +
66366 + if (is_writable_mmap(file))
66367 + return 0;
66368 +
66369 + mode =
66370 + gr_search_file(file->f_path.dentry,
66371 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66372 + file->f_path.mnt);
66373 +
66374 + if (!gr_tpe_allow(file))
66375 + return 0;
66376 +
66377 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66378 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66379 + return 0;
66380 + } else if (unlikely(!(mode & GR_EXEC))) {
66381 + return 0;
66382 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66383 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66384 + return 1;
66385 + }
66386 +
66387 + return 1;
66388 +}
66389 +
66390 +int
66391 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66392 +{
66393 + __u32 mode;
66394 +
66395 + if (unlikely(!file || !(prot & PROT_EXEC)))
66396 + return 1;
66397 +
66398 + if (is_writable_mmap(file))
66399 + return 0;
66400 +
66401 + mode =
66402 + gr_search_file(file->f_path.dentry,
66403 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66404 + file->f_path.mnt);
66405 +
66406 + if (!gr_tpe_allow(file))
66407 + return 0;
66408 +
66409 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66410 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66411 + return 0;
66412 + } else if (unlikely(!(mode & GR_EXEC))) {
66413 + return 0;
66414 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66415 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66416 + return 1;
66417 + }
66418 +
66419 + return 1;
66420 +}
66421 +
66422 +void
66423 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66424 +{
66425 + unsigned long runtime;
66426 + unsigned long cputime;
66427 + unsigned int wday, cday;
66428 + __u8 whr, chr;
66429 + __u8 wmin, cmin;
66430 + __u8 wsec, csec;
66431 + struct timespec timeval;
66432 +
66433 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66434 + !(task->acl->mode & GR_PROCACCT)))
66435 + return;
66436 +
66437 + do_posix_clock_monotonic_gettime(&timeval);
66438 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66439 + wday = runtime / (3600 * 24);
66440 + runtime -= wday * (3600 * 24);
66441 + whr = runtime / 3600;
66442 + runtime -= whr * 3600;
66443 + wmin = runtime / 60;
66444 + runtime -= wmin * 60;
66445 + wsec = runtime;
66446 +
66447 + cputime = (task->utime + task->stime) / HZ;
66448 + cday = cputime / (3600 * 24);
66449 + cputime -= cday * (3600 * 24);
66450 + chr = cputime / 3600;
66451 + cputime -= chr * 3600;
66452 + cmin = cputime / 60;
66453 + cputime -= cmin * 60;
66454 + csec = cputime;
66455 +
66456 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66457 +
66458 + return;
66459 +}
66460 +
66461 +#ifdef CONFIG_TASKSTATS
66462 +int gr_is_taskstats_denied(int pid)
66463 +{
66464 + struct task_struct *task;
66465 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66466 + const struct cred *cred;
66467 +#endif
66468 + int ret = 0;
66469 +
66470 + /* restrict taskstats viewing to un-chrooted root users
66471 + who have the 'view' subject flag if the RBAC system is enabled
66472 + */
66473 +
66474 + rcu_read_lock();
66475 + read_lock(&tasklist_lock);
66476 + task = find_task_by_vpid(pid);
66477 + if (task) {
66478 +#ifdef CONFIG_GRKERNSEC_CHROOT
66479 + if (proc_is_chrooted(task))
66480 + ret = -EACCES;
66481 +#endif
66482 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66483 + cred = __task_cred(task);
66484 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66485 + if (gr_is_global_nonroot(cred->uid))
66486 + ret = -EACCES;
66487 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66488 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66489 + ret = -EACCES;
66490 +#endif
66491 +#endif
66492 + if (gr_status & GR_READY) {
66493 + if (!(task->acl->mode & GR_VIEW))
66494 + ret = -EACCES;
66495 + }
66496 + } else
66497 + ret = -ENOENT;
66498 +
66499 + read_unlock(&tasklist_lock);
66500 + rcu_read_unlock();
66501 +
66502 + return ret;
66503 +}
66504 +#endif
66505 +
66506 +/* AUXV entries are filled via a descendant of search_binary_handler
66507 + after we've already applied the subject for the target
66508 +*/
66509 +int gr_acl_enable_at_secure(void)
66510 +{
66511 + if (unlikely(!(gr_status & GR_READY)))
66512 + return 0;
66513 +
66514 + if (current->acl->mode & GR_ATSECURE)
66515 + return 1;
66516 +
66517 + return 0;
66518 +}
66519 +
66520 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66521 +{
66522 + struct task_struct *task = current;
66523 + struct dentry *dentry = file->f_path.dentry;
66524 + struct vfsmount *mnt = file->f_path.mnt;
66525 + struct acl_object_label *obj, *tmp;
66526 + struct acl_subject_label *subj;
66527 + unsigned int bufsize;
66528 + int is_not_root;
66529 + char *path;
66530 + dev_t dev = __get_dev(dentry);
66531 +
66532 + if (unlikely(!(gr_status & GR_READY)))
66533 + return 1;
66534 +
66535 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66536 + return 1;
66537 +
66538 + /* ignore Eric Biederman */
66539 + if (IS_PRIVATE(dentry->d_inode))
66540 + return 1;
66541 +
66542 + subj = task->acl;
66543 + read_lock(&gr_inode_lock);
66544 + do {
66545 + obj = lookup_acl_obj_label(ino, dev, subj);
66546 + if (obj != NULL) {
66547 + read_unlock(&gr_inode_lock);
66548 + return (obj->mode & GR_FIND) ? 1 : 0;
66549 + }
66550 + } while ((subj = subj->parent_subject));
66551 + read_unlock(&gr_inode_lock);
66552 +
66553 + /* this is purely an optimization since we're looking for an object
66554 + for the directory we're doing a readdir on
66555 + if it's possible for any globbed object to match the entry we're
66556 + filling into the directory, then the object we find here will be
66557 + an anchor point with attached globbed objects
66558 + */
66559 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66560 + if (obj->globbed == NULL)
66561 + return (obj->mode & GR_FIND) ? 1 : 0;
66562 +
66563 + is_not_root = ((obj->filename[0] == '/') &&
66564 + (obj->filename[1] == '\0')) ? 0 : 1;
66565 + bufsize = PAGE_SIZE - namelen - is_not_root;
66566 +
66567 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66568 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66569 + return 1;
66570 +
66571 + preempt_disable();
66572 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66573 + bufsize);
66574 +
66575 + bufsize = strlen(path);
66576 +
66577 + /* if base is "/", don't append an additional slash */
66578 + if (is_not_root)
66579 + *(path + bufsize) = '/';
66580 + memcpy(path + bufsize + is_not_root, name, namelen);
66581 + *(path + bufsize + namelen + is_not_root) = '\0';
66582 +
66583 + tmp = obj->globbed;
66584 + while (tmp) {
66585 + if (!glob_match(tmp->filename, path)) {
66586 + preempt_enable();
66587 + return (tmp->mode & GR_FIND) ? 1 : 0;
66588 + }
66589 + tmp = tmp->next;
66590 + }
66591 + preempt_enable();
66592 + return (obj->mode & GR_FIND) ? 1 : 0;
66593 +}
66594 +
66595 +void gr_put_exec_file(struct task_struct *task)
66596 +{
66597 + struct file *filp;
66598 +
66599 + write_lock(&grsec_exec_file_lock);
66600 + filp = task->exec_file;
66601 + task->exec_file = NULL;
66602 + write_unlock(&grsec_exec_file_lock);
66603 +
66604 + if (filp)
66605 + fput(filp);
66606 +
66607 + return;
66608 +}
66609 +
66610 +
66611 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66612 +EXPORT_SYMBOL(gr_acl_is_enabled);
66613 +#endif
66614 +#ifdef CONFIG_SECURITY
66615 +EXPORT_SYMBOL(gr_check_user_change);
66616 +EXPORT_SYMBOL(gr_check_group_change);
66617 +#endif
66618 +
66619 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66620 new file mode 100644
66621 index 0000000..18ffbbd
66622 --- /dev/null
66623 +++ b/grsecurity/gracl_alloc.c
66624 @@ -0,0 +1,105 @@
66625 +#include <linux/kernel.h>
66626 +#include <linux/mm.h>
66627 +#include <linux/slab.h>
66628 +#include <linux/vmalloc.h>
66629 +#include <linux/gracl.h>
66630 +#include <linux/grsecurity.h>
66631 +
66632 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
66633 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
66634 +
66635 +static __inline__ int
66636 +alloc_pop(void)
66637 +{
66638 + if (current_alloc_state->alloc_stack_next == 1)
66639 + return 0;
66640 +
66641 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
66642 +
66643 + current_alloc_state->alloc_stack_next--;
66644 +
66645 + return 1;
66646 +}
66647 +
66648 +static __inline__ int
66649 +alloc_push(void *buf)
66650 +{
66651 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
66652 + return 1;
66653 +
66654 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
66655 +
66656 + current_alloc_state->alloc_stack_next++;
66657 +
66658 + return 0;
66659 +}
66660 +
66661 +void *
66662 +acl_alloc(unsigned long len)
66663 +{
66664 + void *ret = NULL;
66665 +
66666 + if (!len || len > PAGE_SIZE)
66667 + goto out;
66668 +
66669 + ret = kmalloc(len, GFP_KERNEL);
66670 +
66671 + if (ret) {
66672 + if (alloc_push(ret)) {
66673 + kfree(ret);
66674 + ret = NULL;
66675 + }
66676 + }
66677 +
66678 +out:
66679 + return ret;
66680 +}
66681 +
66682 +void *
66683 +acl_alloc_num(unsigned long num, unsigned long len)
66684 +{
66685 + if (!len || (num > (PAGE_SIZE / len)))
66686 + return NULL;
66687 +
66688 + return acl_alloc(num * len);
66689 +}
66690 +
66691 +void
66692 +acl_free_all(void)
66693 +{
66694 + if (!current_alloc_state->alloc_stack)
66695 + return;
66696 +
66697 + while (alloc_pop()) ;
66698 +
66699 + if (current_alloc_state->alloc_stack) {
66700 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66701 + kfree(current_alloc_state->alloc_stack);
66702 + else
66703 + vfree(current_alloc_state->alloc_stack);
66704 + }
66705 +
66706 + current_alloc_state->alloc_stack = NULL;
66707 + current_alloc_state->alloc_stack_size = 1;
66708 + current_alloc_state->alloc_stack_next = 1;
66709 +
66710 + return;
66711 +}
66712 +
66713 +int
66714 +acl_alloc_stack_init(unsigned long size)
66715 +{
66716 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66717 + current_alloc_state->alloc_stack =
66718 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66719 + else
66720 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
66721 +
66722 + current_alloc_state->alloc_stack_size = size;
66723 + current_alloc_state->alloc_stack_next = 1;
66724 +
66725 + if (!current_alloc_state->alloc_stack)
66726 + return 0;
66727 + else
66728 + return 1;
66729 +}
66730 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66731 new file mode 100644
66732 index 0000000..bdd51ea
66733 --- /dev/null
66734 +++ b/grsecurity/gracl_cap.c
66735 @@ -0,0 +1,110 @@
66736 +#include <linux/kernel.h>
66737 +#include <linux/module.h>
66738 +#include <linux/sched.h>
66739 +#include <linux/gracl.h>
66740 +#include <linux/grsecurity.h>
66741 +#include <linux/grinternal.h>
66742 +
66743 +extern const char *captab_log[];
66744 +extern int captab_log_entries;
66745 +
66746 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66747 +{
66748 + struct acl_subject_label *curracl;
66749 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66750 + kernel_cap_t cap_audit = __cap_empty_set;
66751 +
66752 + if (!gr_acl_is_enabled())
66753 + return 1;
66754 +
66755 + curracl = task->acl;
66756 +
66757 + cap_drop = curracl->cap_lower;
66758 + cap_mask = curracl->cap_mask;
66759 + cap_audit = curracl->cap_invert_audit;
66760 +
66761 + while ((curracl = curracl->parent_subject)) {
66762 + /* if the cap isn't specified in the current computed mask but is specified in the
66763 + current level subject, and is lowered in the current level subject, then add
66764 + it to the set of dropped capabilities
66765 + otherwise, add the current level subject's mask to the current computed mask
66766 + */
66767 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66768 + cap_raise(cap_mask, cap);
66769 + if (cap_raised(curracl->cap_lower, cap))
66770 + cap_raise(cap_drop, cap);
66771 + if (cap_raised(curracl->cap_invert_audit, cap))
66772 + cap_raise(cap_audit, cap);
66773 + }
66774 + }
66775 +
66776 + if (!cap_raised(cap_drop, cap)) {
66777 + if (cap_raised(cap_audit, cap))
66778 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66779 + return 1;
66780 + }
66781 +
66782 + curracl = task->acl;
66783 +
66784 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66785 + && cap_raised(cred->cap_effective, cap)) {
66786 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66787 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66788 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66789 + gr_to_filename(task->exec_file->f_path.dentry,
66790 + task->exec_file->f_path.mnt) : curracl->filename,
66791 + curracl->filename, 0UL,
66792 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66793 + return 1;
66794 + }
66795 +
66796 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66797 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66798 +
66799 + return 0;
66800 +}
66801 +
66802 +int
66803 +gr_acl_is_capable(const int cap)
66804 +{
66805 + return gr_task_acl_is_capable(current, current_cred(), cap);
66806 +}
66807 +
66808 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66809 +{
66810 + struct acl_subject_label *curracl;
66811 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66812 +
66813 + if (!gr_acl_is_enabled())
66814 + return 1;
66815 +
66816 + curracl = task->acl;
66817 +
66818 + cap_drop = curracl->cap_lower;
66819 + cap_mask = curracl->cap_mask;
66820 +
66821 + while ((curracl = curracl->parent_subject)) {
66822 + /* if the cap isn't specified in the current computed mask but is specified in the
66823 + current level subject, and is lowered in the current level subject, then add
66824 + it to the set of dropped capabilities
66825 + otherwise, add the current level subject's mask to the current computed mask
66826 + */
66827 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66828 + cap_raise(cap_mask, cap);
66829 + if (cap_raised(curracl->cap_lower, cap))
66830 + cap_raise(cap_drop, cap);
66831 + }
66832 + }
66833 +
66834 + if (!cap_raised(cap_drop, cap))
66835 + return 1;
66836 +
66837 + return 0;
66838 +}
66839 +
66840 +int
66841 +gr_acl_is_capable_nolog(const int cap)
66842 +{
66843 + return gr_task_acl_is_capable_nolog(current, cap);
66844 +}
66845 +
66846 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66847 new file mode 100644
66848 index 0000000..ca25605
66849 --- /dev/null
66850 +++ b/grsecurity/gracl_compat.c
66851 @@ -0,0 +1,270 @@
66852 +#include <linux/kernel.h>
66853 +#include <linux/gracl.h>
66854 +#include <linux/compat.h>
66855 +#include <linux/gracl_compat.h>
66856 +
66857 +#include <asm/uaccess.h>
66858 +
66859 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66860 +{
66861 + struct gr_arg_wrapper_compat uwrapcompat;
66862 +
66863 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66864 + return -EFAULT;
66865 +
66866 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
66867 + (uwrapcompat.version != 0x2901)) ||
66868 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66869 + return -EINVAL;
66870 +
66871 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66872 + uwrap->version = uwrapcompat.version;
66873 + uwrap->size = sizeof(struct gr_arg);
66874 +
66875 + return 0;
66876 +}
66877 +
66878 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66879 +{
66880 + struct gr_arg_compat argcompat;
66881 +
66882 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66883 + return -EFAULT;
66884 +
66885 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66886 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66887 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66888 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66889 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66890 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66891 +
66892 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66893 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66894 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66895 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66896 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66897 + arg->segv_device = argcompat.segv_device;
66898 + arg->segv_inode = argcompat.segv_inode;
66899 + arg->segv_uid = argcompat.segv_uid;
66900 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66901 + arg->mode = argcompat.mode;
66902 +
66903 + return 0;
66904 +}
66905 +
66906 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66907 +{
66908 + struct acl_object_label_compat objcompat;
66909 +
66910 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66911 + return -EFAULT;
66912 +
66913 + obj->filename = compat_ptr(objcompat.filename);
66914 + obj->inode = objcompat.inode;
66915 + obj->device = objcompat.device;
66916 + obj->mode = objcompat.mode;
66917 +
66918 + obj->nested = compat_ptr(objcompat.nested);
66919 + obj->globbed = compat_ptr(objcompat.globbed);
66920 +
66921 + obj->prev = compat_ptr(objcompat.prev);
66922 + obj->next = compat_ptr(objcompat.next);
66923 +
66924 + return 0;
66925 +}
66926 +
66927 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66928 +{
66929 + unsigned int i;
66930 + struct acl_subject_label_compat subjcompat;
66931 +
66932 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66933 + return -EFAULT;
66934 +
66935 + subj->filename = compat_ptr(subjcompat.filename);
66936 + subj->inode = subjcompat.inode;
66937 + subj->device = subjcompat.device;
66938 + subj->mode = subjcompat.mode;
66939 + subj->cap_mask = subjcompat.cap_mask;
66940 + subj->cap_lower = subjcompat.cap_lower;
66941 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66942 +
66943 + for (i = 0; i < GR_NLIMITS; i++) {
66944 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66945 + subj->res[i].rlim_cur = RLIM_INFINITY;
66946 + else
66947 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66948 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66949 + subj->res[i].rlim_max = RLIM_INFINITY;
66950 + else
66951 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66952 + }
66953 + subj->resmask = subjcompat.resmask;
66954 +
66955 + subj->user_trans_type = subjcompat.user_trans_type;
66956 + subj->group_trans_type = subjcompat.group_trans_type;
66957 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66958 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66959 + subj->user_trans_num = subjcompat.user_trans_num;
66960 + subj->group_trans_num = subjcompat.group_trans_num;
66961 +
66962 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66963 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66964 + subj->ip_type = subjcompat.ip_type;
66965 + subj->ips = compat_ptr(subjcompat.ips);
66966 + subj->ip_num = subjcompat.ip_num;
66967 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66968 +
66969 + subj->crashes = subjcompat.crashes;
66970 + subj->expires = subjcompat.expires;
66971 +
66972 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66973 + subj->hash = compat_ptr(subjcompat.hash);
66974 + subj->prev = compat_ptr(subjcompat.prev);
66975 + subj->next = compat_ptr(subjcompat.next);
66976 +
66977 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66978 + subj->obj_hash_size = subjcompat.obj_hash_size;
66979 + subj->pax_flags = subjcompat.pax_flags;
66980 +
66981 + return 0;
66982 +}
66983 +
66984 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66985 +{
66986 + struct acl_role_label_compat rolecompat;
66987 +
66988 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66989 + return -EFAULT;
66990 +
66991 + role->rolename = compat_ptr(rolecompat.rolename);
66992 + role->uidgid = rolecompat.uidgid;
66993 + role->roletype = rolecompat.roletype;
66994 +
66995 + role->auth_attempts = rolecompat.auth_attempts;
66996 + role->expires = rolecompat.expires;
66997 +
66998 + role->root_label = compat_ptr(rolecompat.root_label);
66999 + role->hash = compat_ptr(rolecompat.hash);
67000 +
67001 + role->prev = compat_ptr(rolecompat.prev);
67002 + role->next = compat_ptr(rolecompat.next);
67003 +
67004 + role->transitions = compat_ptr(rolecompat.transitions);
67005 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
67006 + role->domain_children = compat_ptr(rolecompat.domain_children);
67007 + role->domain_child_num = rolecompat.domain_child_num;
67008 +
67009 + role->umask = rolecompat.umask;
67010 +
67011 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
67012 + role->subj_hash_size = rolecompat.subj_hash_size;
67013 +
67014 + return 0;
67015 +}
67016 +
67017 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67018 +{
67019 + struct role_allowed_ip_compat roleip_compat;
67020 +
67021 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
67022 + return -EFAULT;
67023 +
67024 + roleip->addr = roleip_compat.addr;
67025 + roleip->netmask = roleip_compat.netmask;
67026 +
67027 + roleip->prev = compat_ptr(roleip_compat.prev);
67028 + roleip->next = compat_ptr(roleip_compat.next);
67029 +
67030 + return 0;
67031 +}
67032 +
67033 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
67034 +{
67035 + struct role_transition_compat trans_compat;
67036 +
67037 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
67038 + return -EFAULT;
67039 +
67040 + trans->rolename = compat_ptr(trans_compat.rolename);
67041 +
67042 + trans->prev = compat_ptr(trans_compat.prev);
67043 + trans->next = compat_ptr(trans_compat.next);
67044 +
67045 + return 0;
67046 +
67047 +}
67048 +
67049 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
67050 +{
67051 + struct gr_hash_struct_compat hash_compat;
67052 +
67053 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
67054 + return -EFAULT;
67055 +
67056 + hash->table = compat_ptr(hash_compat.table);
67057 + hash->nametable = compat_ptr(hash_compat.nametable);
67058 + hash->first = compat_ptr(hash_compat.first);
67059 +
67060 + hash->table_size = hash_compat.table_size;
67061 + hash->used_size = hash_compat.used_size;
67062 +
67063 + hash->type = hash_compat.type;
67064 +
67065 + return 0;
67066 +}
67067 +
67068 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
67069 +{
67070 + compat_uptr_t ptrcompat;
67071 +
67072 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
67073 + return -EFAULT;
67074 +
67075 + *(void **)ptr = compat_ptr(ptrcompat);
67076 +
67077 + return 0;
67078 +}
67079 +
67080 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
67081 +{
67082 + struct acl_ip_label_compat ip_compat;
67083 +
67084 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
67085 + return -EFAULT;
67086 +
67087 + ip->iface = compat_ptr(ip_compat.iface);
67088 + ip->addr = ip_compat.addr;
67089 + ip->netmask = ip_compat.netmask;
67090 + ip->low = ip_compat.low;
67091 + ip->high = ip_compat.high;
67092 + ip->mode = ip_compat.mode;
67093 + ip->type = ip_compat.type;
67094 +
67095 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
67096 +
67097 + ip->prev = compat_ptr(ip_compat.prev);
67098 + ip->next = compat_ptr(ip_compat.next);
67099 +
67100 + return 0;
67101 +}
67102 +
67103 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67104 +{
67105 + struct sprole_pw_compat pw_compat;
67106 +
67107 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
67108 + return -EFAULT;
67109 +
67110 + pw->rolename = compat_ptr(pw_compat.rolename);
67111 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
67112 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
67113 +
67114 + return 0;
67115 +}
67116 +
67117 +size_t get_gr_arg_wrapper_size_compat(void)
67118 +{
67119 + return sizeof(struct gr_arg_wrapper_compat);
67120 +}
67121 +
67122 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
67123 new file mode 100644
67124 index 0000000..deb6f3b
67125 --- /dev/null
67126 +++ b/grsecurity/gracl_fs.c
67127 @@ -0,0 +1,437 @@
67128 +#include <linux/kernel.h>
67129 +#include <linux/sched.h>
67130 +#include <linux/types.h>
67131 +#include <linux/fs.h>
67132 +#include <linux/file.h>
67133 +#include <linux/stat.h>
67134 +#include <linux/grsecurity.h>
67135 +#include <linux/grinternal.h>
67136 +#include <linux/gracl.h>
67137 +
67138 +umode_t
67139 +gr_acl_umask(void)
67140 +{
67141 + if (unlikely(!gr_acl_is_enabled()))
67142 + return 0;
67143 +
67144 + return current->role->umask;
67145 +}
67146 +
67147 +__u32
67148 +gr_acl_handle_hidden_file(const struct dentry * dentry,
67149 + const struct vfsmount * mnt)
67150 +{
67151 + __u32 mode;
67152 +
67153 + if (unlikely(!dentry->d_inode))
67154 + return GR_FIND;
67155 +
67156 + mode =
67157 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
67158 +
67159 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
67160 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
67161 + return mode;
67162 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
67163 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
67164 + return 0;
67165 + } else if (unlikely(!(mode & GR_FIND)))
67166 + return 0;
67167 +
67168 + return GR_FIND;
67169 +}
67170 +
67171 +__u32
67172 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
67173 + int acc_mode)
67174 +{
67175 + __u32 reqmode = GR_FIND;
67176 + __u32 mode;
67177 +
67178 + if (unlikely(!dentry->d_inode))
67179 + return reqmode;
67180 +
67181 + if (acc_mode & MAY_APPEND)
67182 + reqmode |= GR_APPEND;
67183 + else if (acc_mode & MAY_WRITE)
67184 + reqmode |= GR_WRITE;
67185 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
67186 + reqmode |= GR_READ;
67187 +
67188 + mode =
67189 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67190 + mnt);
67191 +
67192 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67193 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
67194 + reqmode & GR_READ ? " reading" : "",
67195 + reqmode & GR_WRITE ? " writing" : reqmode &
67196 + GR_APPEND ? " appending" : "");
67197 + return reqmode;
67198 + } else
67199 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67200 + {
67201 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
67202 + reqmode & GR_READ ? " reading" : "",
67203 + reqmode & GR_WRITE ? " writing" : reqmode &
67204 + GR_APPEND ? " appending" : "");
67205 + return 0;
67206 + } else if (unlikely((mode & reqmode) != reqmode))
67207 + return 0;
67208 +
67209 + return reqmode;
67210 +}
67211 +
67212 +__u32
67213 +gr_acl_handle_creat(const struct dentry * dentry,
67214 + const struct dentry * p_dentry,
67215 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
67216 + const int imode)
67217 +{
67218 + __u32 reqmode = GR_WRITE | GR_CREATE;
67219 + __u32 mode;
67220 +
67221 + if (acc_mode & MAY_APPEND)
67222 + reqmode |= GR_APPEND;
67223 + // if a directory was required or the directory already exists, then
67224 + // don't count this open as a read
67225 + if ((acc_mode & MAY_READ) &&
67226 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
67227 + reqmode |= GR_READ;
67228 + if ((open_flags & O_CREAT) &&
67229 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67230 + reqmode |= GR_SETID;
67231 +
67232 + mode =
67233 + gr_check_create(dentry, p_dentry, p_mnt,
67234 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67235 +
67236 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67237 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67238 + reqmode & GR_READ ? " reading" : "",
67239 + reqmode & GR_WRITE ? " writing" : reqmode &
67240 + GR_APPEND ? " appending" : "");
67241 + return reqmode;
67242 + } else
67243 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67244 + {
67245 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67246 + reqmode & GR_READ ? " reading" : "",
67247 + reqmode & GR_WRITE ? " writing" : reqmode &
67248 + GR_APPEND ? " appending" : "");
67249 + return 0;
67250 + } else if (unlikely((mode & reqmode) != reqmode))
67251 + return 0;
67252 +
67253 + return reqmode;
67254 +}
67255 +
67256 +__u32
67257 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67258 + const int fmode)
67259 +{
67260 + __u32 mode, reqmode = GR_FIND;
67261 +
67262 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67263 + reqmode |= GR_EXEC;
67264 + if (fmode & S_IWOTH)
67265 + reqmode |= GR_WRITE;
67266 + if (fmode & S_IROTH)
67267 + reqmode |= GR_READ;
67268 +
67269 + mode =
67270 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67271 + mnt);
67272 +
67273 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67274 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67275 + reqmode & GR_READ ? " reading" : "",
67276 + reqmode & GR_WRITE ? " writing" : "",
67277 + reqmode & GR_EXEC ? " executing" : "");
67278 + return reqmode;
67279 + } else
67280 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67281 + {
67282 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67283 + reqmode & GR_READ ? " reading" : "",
67284 + reqmode & GR_WRITE ? " writing" : "",
67285 + reqmode & GR_EXEC ? " executing" : "");
67286 + return 0;
67287 + } else if (unlikely((mode & reqmode) != reqmode))
67288 + return 0;
67289 +
67290 + return reqmode;
67291 +}
67292 +
67293 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67294 +{
67295 + __u32 mode;
67296 +
67297 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67298 +
67299 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67300 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67301 + return mode;
67302 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67303 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67304 + return 0;
67305 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67306 + return 0;
67307 +
67308 + return (reqmode);
67309 +}
67310 +
67311 +__u32
67312 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67313 +{
67314 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67315 +}
67316 +
67317 +__u32
67318 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67319 +{
67320 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67321 +}
67322 +
67323 +__u32
67324 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67325 +{
67326 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67327 +}
67328 +
67329 +__u32
67330 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67331 +{
67332 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67333 +}
67334 +
67335 +__u32
67336 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67337 + umode_t *modeptr)
67338 +{
67339 + umode_t mode;
67340 +
67341 + *modeptr &= ~gr_acl_umask();
67342 + mode = *modeptr;
67343 +
67344 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67345 + return 1;
67346 +
67347 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67348 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67349 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67350 + GR_CHMOD_ACL_MSG);
67351 + } else {
67352 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67353 + }
67354 +}
67355 +
67356 +__u32
67357 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67358 +{
67359 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67360 +}
67361 +
67362 +__u32
67363 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67364 +{
67365 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67366 +}
67367 +
67368 +__u32
67369 +gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
67370 +{
67371 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
67372 +}
67373 +
67374 +__u32
67375 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67376 +{
67377 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67378 +}
67379 +
67380 +__u32
67381 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67382 +{
67383 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67384 + GR_UNIXCONNECT_ACL_MSG);
67385 +}
67386 +
67387 +/* hardlinks require at minimum create and link permission,
67388 + any additional privilege required is based on the
67389 + privilege of the file being linked to
67390 +*/
67391 +__u32
67392 +gr_acl_handle_link(const struct dentry * new_dentry,
67393 + const struct dentry * parent_dentry,
67394 + const struct vfsmount * parent_mnt,
67395 + const struct dentry * old_dentry,
67396 + const struct vfsmount * old_mnt, const struct filename *to)
67397 +{
67398 + __u32 mode;
67399 + __u32 needmode = GR_CREATE | GR_LINK;
67400 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67401 +
67402 + mode =
67403 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67404 + old_mnt);
67405 +
67406 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67407 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67408 + return mode;
67409 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67410 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67411 + return 0;
67412 + } else if (unlikely((mode & needmode) != needmode))
67413 + return 0;
67414 +
67415 + return 1;
67416 +}
67417 +
67418 +__u32
67419 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67420 + const struct dentry * parent_dentry,
67421 + const struct vfsmount * parent_mnt, const struct filename *from)
67422 +{
67423 + __u32 needmode = GR_WRITE | GR_CREATE;
67424 + __u32 mode;
67425 +
67426 + mode =
67427 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67428 + GR_CREATE | GR_AUDIT_CREATE |
67429 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67430 +
67431 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67432 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67433 + return mode;
67434 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67435 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67436 + return 0;
67437 + } else if (unlikely((mode & needmode) != needmode))
67438 + return 0;
67439 +
67440 + return (GR_WRITE | GR_CREATE);
67441 +}
67442 +
67443 +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)
67444 +{
67445 + __u32 mode;
67446 +
67447 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67448 +
67449 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67450 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67451 + return mode;
67452 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67453 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67454 + return 0;
67455 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67456 + return 0;
67457 +
67458 + return (reqmode);
67459 +}
67460 +
67461 +__u32
67462 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67463 + const struct dentry * parent_dentry,
67464 + const struct vfsmount * parent_mnt,
67465 + const int mode)
67466 +{
67467 + __u32 reqmode = GR_WRITE | GR_CREATE;
67468 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67469 + reqmode |= GR_SETID;
67470 +
67471 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67472 + reqmode, GR_MKNOD_ACL_MSG);
67473 +}
67474 +
67475 +__u32
67476 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67477 + const struct dentry *parent_dentry,
67478 + const struct vfsmount *parent_mnt)
67479 +{
67480 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67481 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67482 +}
67483 +
67484 +#define RENAME_CHECK_SUCCESS(old, new) \
67485 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67486 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67487 +
67488 +int
67489 +gr_acl_handle_rename(struct dentry *new_dentry,
67490 + struct dentry *parent_dentry,
67491 + const struct vfsmount *parent_mnt,
67492 + struct dentry *old_dentry,
67493 + struct inode *old_parent_inode,
67494 + struct vfsmount *old_mnt, const struct filename *newname)
67495 +{
67496 + __u32 comp1, comp2;
67497 + int error = 0;
67498 +
67499 + if (unlikely(!gr_acl_is_enabled()))
67500 + return 0;
67501 +
67502 + if (!new_dentry->d_inode) {
67503 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67504 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67505 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67506 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67507 + GR_DELETE | GR_AUDIT_DELETE |
67508 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67509 + GR_SUPPRESS, old_mnt);
67510 + } else {
67511 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67512 + GR_CREATE | GR_DELETE |
67513 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67514 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67515 + GR_SUPPRESS, parent_mnt);
67516 + comp2 =
67517 + gr_search_file(old_dentry,
67518 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67519 + GR_DELETE | GR_AUDIT_DELETE |
67520 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67521 + }
67522 +
67523 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67524 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67525 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67526 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67527 + && !(comp2 & GR_SUPPRESS)) {
67528 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67529 + error = -EACCES;
67530 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67531 + error = -EACCES;
67532 +
67533 + return error;
67534 +}
67535 +
67536 +void
67537 +gr_acl_handle_exit(void)
67538 +{
67539 + u16 id;
67540 + char *rolename;
67541 +
67542 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67543 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67544 + id = current->acl_role_id;
67545 + rolename = current->role->rolename;
67546 + gr_set_acls(1);
67547 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67548 + }
67549 +
67550 + gr_put_exec_file(current);
67551 + return;
67552 +}
67553 +
67554 +int
67555 +gr_acl_handle_procpidmem(const struct task_struct *task)
67556 +{
67557 + if (unlikely(!gr_acl_is_enabled()))
67558 + return 0;
67559 +
67560 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67561 + return -EACCES;
67562 +
67563 + return 0;
67564 +}
67565 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67566 new file mode 100644
67567 index 0000000..f056b81
67568 --- /dev/null
67569 +++ b/grsecurity/gracl_ip.c
67570 @@ -0,0 +1,386 @@
67571 +#include <linux/kernel.h>
67572 +#include <asm/uaccess.h>
67573 +#include <asm/errno.h>
67574 +#include <net/sock.h>
67575 +#include <linux/file.h>
67576 +#include <linux/fs.h>
67577 +#include <linux/net.h>
67578 +#include <linux/in.h>
67579 +#include <linux/skbuff.h>
67580 +#include <linux/ip.h>
67581 +#include <linux/udp.h>
67582 +#include <linux/types.h>
67583 +#include <linux/sched.h>
67584 +#include <linux/netdevice.h>
67585 +#include <linux/inetdevice.h>
67586 +#include <linux/gracl.h>
67587 +#include <linux/grsecurity.h>
67588 +#include <linux/grinternal.h>
67589 +
67590 +#define GR_BIND 0x01
67591 +#define GR_CONNECT 0x02
67592 +#define GR_INVERT 0x04
67593 +#define GR_BINDOVERRIDE 0x08
67594 +#define GR_CONNECTOVERRIDE 0x10
67595 +#define GR_SOCK_FAMILY 0x20
67596 +
67597 +static const char * gr_protocols[IPPROTO_MAX] = {
67598 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67599 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67600 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67601 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67602 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67603 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67604 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67605 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67606 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67607 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67608 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67609 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67610 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67611 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67612 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67613 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67614 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67615 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67616 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67617 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67618 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67619 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67620 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67621 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67622 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67623 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67624 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67625 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67626 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67627 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67628 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67629 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67630 + };
67631 +
67632 +static const char * gr_socktypes[SOCK_MAX] = {
67633 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67634 + "unknown:7", "unknown:8", "unknown:9", "packet"
67635 + };
67636 +
67637 +static const char * gr_sockfamilies[AF_MAX+1] = {
67638 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67639 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67640 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67641 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67642 + };
67643 +
67644 +const char *
67645 +gr_proto_to_name(unsigned char proto)
67646 +{
67647 + return gr_protocols[proto];
67648 +}
67649 +
67650 +const char *
67651 +gr_socktype_to_name(unsigned char type)
67652 +{
67653 + return gr_socktypes[type];
67654 +}
67655 +
67656 +const char *
67657 +gr_sockfamily_to_name(unsigned char family)
67658 +{
67659 + return gr_sockfamilies[family];
67660 +}
67661 +
67662 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67663 +
67664 +int
67665 +gr_search_socket(const int domain, const int type, const int protocol)
67666 +{
67667 + struct acl_subject_label *curr;
67668 + const struct cred *cred = current_cred();
67669 +
67670 + if (unlikely(!gr_acl_is_enabled()))
67671 + goto exit;
67672 +
67673 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67674 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67675 + goto exit; // let the kernel handle it
67676 +
67677 + curr = current->acl;
67678 +
67679 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67680 + /* the family is allowed, if this is PF_INET allow it only if
67681 + the extra sock type/protocol checks pass */
67682 + if (domain == PF_INET)
67683 + goto inet_check;
67684 + goto exit;
67685 + } else {
67686 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67687 + __u32 fakeip = 0;
67688 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67689 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67690 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67691 + gr_to_filename(current->exec_file->f_path.dentry,
67692 + current->exec_file->f_path.mnt) :
67693 + curr->filename, curr->filename,
67694 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67695 + &current->signal->saved_ip);
67696 + goto exit;
67697 + }
67698 + goto exit_fail;
67699 + }
67700 +
67701 +inet_check:
67702 + /* the rest of this checking is for IPv4 only */
67703 + if (!curr->ips)
67704 + goto exit;
67705 +
67706 + if ((curr->ip_type & (1U << type)) &&
67707 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67708 + goto exit;
67709 +
67710 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67711 + /* we don't place acls on raw sockets , and sometimes
67712 + dgram/ip sockets are opened for ioctl and not
67713 + bind/connect, so we'll fake a bind learn log */
67714 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67715 + __u32 fakeip = 0;
67716 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67717 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67718 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67719 + gr_to_filename(current->exec_file->f_path.dentry,
67720 + current->exec_file->f_path.mnt) :
67721 + curr->filename, curr->filename,
67722 + &fakeip, 0, type,
67723 + protocol, GR_CONNECT, &current->signal->saved_ip);
67724 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67725 + __u32 fakeip = 0;
67726 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67727 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67728 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67729 + gr_to_filename(current->exec_file->f_path.dentry,
67730 + current->exec_file->f_path.mnt) :
67731 + curr->filename, curr->filename,
67732 + &fakeip, 0, type,
67733 + protocol, GR_BIND, &current->signal->saved_ip);
67734 + }
67735 + /* we'll log when they use connect or bind */
67736 + goto exit;
67737 + }
67738 +
67739 +exit_fail:
67740 + if (domain == PF_INET)
67741 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67742 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67743 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67744 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67745 + gr_socktype_to_name(type), protocol);
67746 +
67747 + return 0;
67748 +exit:
67749 + return 1;
67750 +}
67751 +
67752 +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)
67753 +{
67754 + if ((ip->mode & mode) &&
67755 + (ip_port >= ip->low) &&
67756 + (ip_port <= ip->high) &&
67757 + ((ntohl(ip_addr) & our_netmask) ==
67758 + (ntohl(our_addr) & our_netmask))
67759 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67760 + && (ip->type & (1U << type))) {
67761 + if (ip->mode & GR_INVERT)
67762 + return 2; // specifically denied
67763 + else
67764 + return 1; // allowed
67765 + }
67766 +
67767 + return 0; // not specifically allowed, may continue parsing
67768 +}
67769 +
67770 +static int
67771 +gr_search_connectbind(const int full_mode, struct sock *sk,
67772 + struct sockaddr_in *addr, const int type)
67773 +{
67774 + char iface[IFNAMSIZ] = {0};
67775 + struct acl_subject_label *curr;
67776 + struct acl_ip_label *ip;
67777 + struct inet_sock *isk;
67778 + struct net_device *dev;
67779 + struct in_device *idev;
67780 + unsigned long i;
67781 + int ret;
67782 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67783 + __u32 ip_addr = 0;
67784 + __u32 our_addr;
67785 + __u32 our_netmask;
67786 + char *p;
67787 + __u16 ip_port = 0;
67788 + const struct cred *cred = current_cred();
67789 +
67790 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67791 + return 0;
67792 +
67793 + curr = current->acl;
67794 + isk = inet_sk(sk);
67795 +
67796 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67797 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67798 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67799 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67800 + struct sockaddr_in saddr;
67801 + int err;
67802 +
67803 + saddr.sin_family = AF_INET;
67804 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67805 + saddr.sin_port = isk->inet_sport;
67806 +
67807 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67808 + if (err)
67809 + return err;
67810 +
67811 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67812 + if (err)
67813 + return err;
67814 + }
67815 +
67816 + if (!curr->ips)
67817 + return 0;
67818 +
67819 + ip_addr = addr->sin_addr.s_addr;
67820 + ip_port = ntohs(addr->sin_port);
67821 +
67822 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67823 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67824 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67825 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67826 + gr_to_filename(current->exec_file->f_path.dentry,
67827 + current->exec_file->f_path.mnt) :
67828 + curr->filename, curr->filename,
67829 + &ip_addr, ip_port, type,
67830 + sk->sk_protocol, mode, &current->signal->saved_ip);
67831 + return 0;
67832 + }
67833 +
67834 + for (i = 0; i < curr->ip_num; i++) {
67835 + ip = *(curr->ips + i);
67836 + if (ip->iface != NULL) {
67837 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67838 + p = strchr(iface, ':');
67839 + if (p != NULL)
67840 + *p = '\0';
67841 + dev = dev_get_by_name(sock_net(sk), iface);
67842 + if (dev == NULL)
67843 + continue;
67844 + idev = in_dev_get(dev);
67845 + if (idev == NULL) {
67846 + dev_put(dev);
67847 + continue;
67848 + }
67849 + rcu_read_lock();
67850 + for_ifa(idev) {
67851 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67852 + our_addr = ifa->ifa_address;
67853 + our_netmask = 0xffffffff;
67854 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67855 + if (ret == 1) {
67856 + rcu_read_unlock();
67857 + in_dev_put(idev);
67858 + dev_put(dev);
67859 + return 0;
67860 + } else if (ret == 2) {
67861 + rcu_read_unlock();
67862 + in_dev_put(idev);
67863 + dev_put(dev);
67864 + goto denied;
67865 + }
67866 + }
67867 + } endfor_ifa(idev);
67868 + rcu_read_unlock();
67869 + in_dev_put(idev);
67870 + dev_put(dev);
67871 + } else {
67872 + our_addr = ip->addr;
67873 + our_netmask = ip->netmask;
67874 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67875 + if (ret == 1)
67876 + return 0;
67877 + else if (ret == 2)
67878 + goto denied;
67879 + }
67880 + }
67881 +
67882 +denied:
67883 + if (mode == GR_BIND)
67884 + 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));
67885 + else if (mode == GR_CONNECT)
67886 + 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));
67887 +
67888 + return -EACCES;
67889 +}
67890 +
67891 +int
67892 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67893 +{
67894 + /* always allow disconnection of dgram sockets with connect */
67895 + if (addr->sin_family == AF_UNSPEC)
67896 + return 0;
67897 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67898 +}
67899 +
67900 +int
67901 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67902 +{
67903 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67904 +}
67905 +
67906 +int gr_search_listen(struct socket *sock)
67907 +{
67908 + struct sock *sk = sock->sk;
67909 + struct sockaddr_in addr;
67910 +
67911 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67912 + addr.sin_port = inet_sk(sk)->inet_sport;
67913 +
67914 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67915 +}
67916 +
67917 +int gr_search_accept(struct socket *sock)
67918 +{
67919 + struct sock *sk = sock->sk;
67920 + struct sockaddr_in addr;
67921 +
67922 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67923 + addr.sin_port = inet_sk(sk)->inet_sport;
67924 +
67925 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67926 +}
67927 +
67928 +int
67929 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67930 +{
67931 + if (addr)
67932 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67933 + else {
67934 + struct sockaddr_in sin;
67935 + const struct inet_sock *inet = inet_sk(sk);
67936 +
67937 + sin.sin_addr.s_addr = inet->inet_daddr;
67938 + sin.sin_port = inet->inet_dport;
67939 +
67940 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67941 + }
67942 +}
67943 +
67944 +int
67945 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67946 +{
67947 + struct sockaddr_in sin;
67948 +
67949 + if (unlikely(skb->len < sizeof (struct udphdr)))
67950 + return 0; // skip this packet
67951 +
67952 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67953 + sin.sin_port = udp_hdr(skb)->source;
67954 +
67955 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67956 +}
67957 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67958 new file mode 100644
67959 index 0000000..25f54ef
67960 --- /dev/null
67961 +++ b/grsecurity/gracl_learn.c
67962 @@ -0,0 +1,207 @@
67963 +#include <linux/kernel.h>
67964 +#include <linux/mm.h>
67965 +#include <linux/sched.h>
67966 +#include <linux/poll.h>
67967 +#include <linux/string.h>
67968 +#include <linux/file.h>
67969 +#include <linux/types.h>
67970 +#include <linux/vmalloc.h>
67971 +#include <linux/grinternal.h>
67972 +
67973 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67974 + size_t count, loff_t *ppos);
67975 +extern int gr_acl_is_enabled(void);
67976 +
67977 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67978 +static int gr_learn_attached;
67979 +
67980 +/* use a 512k buffer */
67981 +#define LEARN_BUFFER_SIZE (512 * 1024)
67982 +
67983 +static DEFINE_SPINLOCK(gr_learn_lock);
67984 +static DEFINE_MUTEX(gr_learn_user_mutex);
67985 +
67986 +/* we need to maintain two buffers, so that the kernel context of grlearn
67987 + uses a semaphore around the userspace copying, and the other kernel contexts
67988 + use a spinlock when copying into the buffer, since they cannot sleep
67989 +*/
67990 +static char *learn_buffer;
67991 +static char *learn_buffer_user;
67992 +static int learn_buffer_len;
67993 +static int learn_buffer_user_len;
67994 +
67995 +static ssize_t
67996 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67997 +{
67998 + DECLARE_WAITQUEUE(wait, current);
67999 + ssize_t retval = 0;
68000 +
68001 + add_wait_queue(&learn_wait, &wait);
68002 + set_current_state(TASK_INTERRUPTIBLE);
68003 + do {
68004 + mutex_lock(&gr_learn_user_mutex);
68005 + spin_lock(&gr_learn_lock);
68006 + if (learn_buffer_len)
68007 + break;
68008 + spin_unlock(&gr_learn_lock);
68009 + mutex_unlock(&gr_learn_user_mutex);
68010 + if (file->f_flags & O_NONBLOCK) {
68011 + retval = -EAGAIN;
68012 + goto out;
68013 + }
68014 + if (signal_pending(current)) {
68015 + retval = -ERESTARTSYS;
68016 + goto out;
68017 + }
68018 +
68019 + schedule();
68020 + } while (1);
68021 +
68022 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
68023 + learn_buffer_user_len = learn_buffer_len;
68024 + retval = learn_buffer_len;
68025 + learn_buffer_len = 0;
68026 +
68027 + spin_unlock(&gr_learn_lock);
68028 +
68029 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
68030 + retval = -EFAULT;
68031 +
68032 + mutex_unlock(&gr_learn_user_mutex);
68033 +out:
68034 + set_current_state(TASK_RUNNING);
68035 + remove_wait_queue(&learn_wait, &wait);
68036 + return retval;
68037 +}
68038 +
68039 +static unsigned int
68040 +poll_learn(struct file * file, poll_table * wait)
68041 +{
68042 + poll_wait(file, &learn_wait, wait);
68043 +
68044 + if (learn_buffer_len)
68045 + return (POLLIN | POLLRDNORM);
68046 +
68047 + return 0;
68048 +}
68049 +
68050 +void
68051 +gr_clear_learn_entries(void)
68052 +{
68053 + char *tmp;
68054 +
68055 + mutex_lock(&gr_learn_user_mutex);
68056 + spin_lock(&gr_learn_lock);
68057 + tmp = learn_buffer;
68058 + learn_buffer = NULL;
68059 + spin_unlock(&gr_learn_lock);
68060 + if (tmp)
68061 + vfree(tmp);
68062 + if (learn_buffer_user != NULL) {
68063 + vfree(learn_buffer_user);
68064 + learn_buffer_user = NULL;
68065 + }
68066 + learn_buffer_len = 0;
68067 + mutex_unlock(&gr_learn_user_mutex);
68068 +
68069 + return;
68070 +}
68071 +
68072 +void
68073 +gr_add_learn_entry(const char *fmt, ...)
68074 +{
68075 + va_list args;
68076 + unsigned int len;
68077 +
68078 + if (!gr_learn_attached)
68079 + return;
68080 +
68081 + spin_lock(&gr_learn_lock);
68082 +
68083 + /* leave a gap at the end so we know when it's "full" but don't have to
68084 + compute the exact length of the string we're trying to append
68085 + */
68086 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
68087 + spin_unlock(&gr_learn_lock);
68088 + wake_up_interruptible(&learn_wait);
68089 + return;
68090 + }
68091 + if (learn_buffer == NULL) {
68092 + spin_unlock(&gr_learn_lock);
68093 + return;
68094 + }
68095 +
68096 + va_start(args, fmt);
68097 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
68098 + va_end(args);
68099 +
68100 + learn_buffer_len += len + 1;
68101 +
68102 + spin_unlock(&gr_learn_lock);
68103 + wake_up_interruptible(&learn_wait);
68104 +
68105 + return;
68106 +}
68107 +
68108 +static int
68109 +open_learn(struct inode *inode, struct file *file)
68110 +{
68111 + if (file->f_mode & FMODE_READ && gr_learn_attached)
68112 + return -EBUSY;
68113 + if (file->f_mode & FMODE_READ) {
68114 + int retval = 0;
68115 + mutex_lock(&gr_learn_user_mutex);
68116 + if (learn_buffer == NULL)
68117 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
68118 + if (learn_buffer_user == NULL)
68119 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
68120 + if (learn_buffer == NULL) {
68121 + retval = -ENOMEM;
68122 + goto out_error;
68123 + }
68124 + if (learn_buffer_user == NULL) {
68125 + retval = -ENOMEM;
68126 + goto out_error;
68127 + }
68128 + learn_buffer_len = 0;
68129 + learn_buffer_user_len = 0;
68130 + gr_learn_attached = 1;
68131 +out_error:
68132 + mutex_unlock(&gr_learn_user_mutex);
68133 + return retval;
68134 + }
68135 + return 0;
68136 +}
68137 +
68138 +static int
68139 +close_learn(struct inode *inode, struct file *file)
68140 +{
68141 + if (file->f_mode & FMODE_READ) {
68142 + char *tmp = NULL;
68143 + mutex_lock(&gr_learn_user_mutex);
68144 + spin_lock(&gr_learn_lock);
68145 + tmp = learn_buffer;
68146 + learn_buffer = NULL;
68147 + spin_unlock(&gr_learn_lock);
68148 + if (tmp)
68149 + vfree(tmp);
68150 + if (learn_buffer_user != NULL) {
68151 + vfree(learn_buffer_user);
68152 + learn_buffer_user = NULL;
68153 + }
68154 + learn_buffer_len = 0;
68155 + learn_buffer_user_len = 0;
68156 + gr_learn_attached = 0;
68157 + mutex_unlock(&gr_learn_user_mutex);
68158 + }
68159 +
68160 + return 0;
68161 +}
68162 +
68163 +const struct file_operations grsec_fops = {
68164 + .read = read_learn,
68165 + .write = write_grsec_handler,
68166 + .open = open_learn,
68167 + .release = close_learn,
68168 + .poll = poll_learn,
68169 +};
68170 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
68171 new file mode 100644
68172 index 0000000..361a099
68173 --- /dev/null
68174 +++ b/grsecurity/gracl_policy.c
68175 @@ -0,0 +1,1782 @@
68176 +#include <linux/kernel.h>
68177 +#include <linux/module.h>
68178 +#include <linux/sched.h>
68179 +#include <linux/mm.h>
68180 +#include <linux/file.h>
68181 +#include <linux/fs.h>
68182 +#include <linux/namei.h>
68183 +#include <linux/mount.h>
68184 +#include <linux/tty.h>
68185 +#include <linux/proc_fs.h>
68186 +#include <linux/lglock.h>
68187 +#include <linux/slab.h>
68188 +#include <linux/vmalloc.h>
68189 +#include <linux/types.h>
68190 +#include <linux/sysctl.h>
68191 +#include <linux/netdevice.h>
68192 +#include <linux/ptrace.h>
68193 +#include <linux/gracl.h>
68194 +#include <linux/gralloc.h>
68195 +#include <linux/security.h>
68196 +#include <linux/grinternal.h>
68197 +#include <linux/pid_namespace.h>
68198 +#include <linux/stop_machine.h>
68199 +#include <linux/fdtable.h>
68200 +#include <linux/percpu.h>
68201 +#include <linux/lglock.h>
68202 +#include <linux/hugetlb.h>
68203 +#include <linux/posix-timers.h>
68204 +#include "../fs/mount.h"
68205 +
68206 +#include <asm/uaccess.h>
68207 +#include <asm/errno.h>
68208 +#include <asm/mman.h>
68209 +
68210 +extern struct gr_policy_state *polstate;
68211 +
68212 +#define FOR_EACH_ROLE_START(role) \
68213 + role = polstate->role_list; \
68214 + while (role) {
68215 +
68216 +#define FOR_EACH_ROLE_END(role) \
68217 + role = role->prev; \
68218 + }
68219 +
68220 +struct path gr_real_root;
68221 +
68222 +extern struct gr_alloc_state *current_alloc_state;
68223 +
68224 +u16 acl_sp_role_value;
68225 +
68226 +static DEFINE_MUTEX(gr_dev_mutex);
68227 +
68228 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
68229 +extern void gr_clear_learn_entries(void);
68230 +
68231 +static struct gr_arg gr_usermode;
68232 +static unsigned char gr_system_salt[GR_SALT_LEN];
68233 +static unsigned char gr_system_sum[GR_SHA_LEN];
68234 +
68235 +static unsigned int gr_auth_attempts = 0;
68236 +static unsigned long gr_auth_expires = 0UL;
68237 +
68238 +struct acl_object_label *fakefs_obj_rw;
68239 +struct acl_object_label *fakefs_obj_rwx;
68240 +
68241 +extern int gr_init_uidset(void);
68242 +extern void gr_free_uidset(void);
68243 +extern void gr_remove_uid(uid_t uid);
68244 +extern int gr_find_uid(uid_t uid);
68245 +
68246 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
68247 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
68248 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
68249 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
68250 +extern struct acl_role_label *__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid, const gid_t gid);
68251 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
68252 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
68253 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
68254 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
68255 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
68256 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
68257 +extern void assign_special_role(const char *rolename);
68258 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
68259 +extern int gr_rbac_disable(void *unused);
68260 +extern void gr_enable_rbac_system(void);
68261 +
68262 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
68263 +{
68264 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
68265 + return -EFAULT;
68266 +
68267 + return 0;
68268 +}
68269 +
68270 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
68271 +{
68272 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
68273 + return -EFAULT;
68274 +
68275 + return 0;
68276 +}
68277 +
68278 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
68279 +{
68280 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
68281 + return -EFAULT;
68282 +
68283 + return 0;
68284 +}
68285 +
68286 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
68287 +{
68288 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
68289 + return -EFAULT;
68290 +
68291 + return 0;
68292 +}
68293 +
68294 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
68295 +{
68296 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
68297 + return -EFAULT;
68298 +
68299 + return 0;
68300 +}
68301 +
68302 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
68303 +{
68304 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
68305 + return -EFAULT;
68306 +
68307 + return 0;
68308 +}
68309 +
68310 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
68311 +{
68312 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
68313 + return -EFAULT;
68314 +
68315 + return 0;
68316 +}
68317 +
68318 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
68319 +{
68320 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
68321 + return -EFAULT;
68322 +
68323 + return 0;
68324 +}
68325 +
68326 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
68327 +{
68328 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
68329 + return -EFAULT;
68330 +
68331 + return 0;
68332 +}
68333 +
68334 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
68335 +{
68336 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
68337 + return -EFAULT;
68338 +
68339 + if (((uwrap->version != GRSECURITY_VERSION) &&
68340 + (uwrap->version != 0x2901)) ||
68341 + (uwrap->size != sizeof(struct gr_arg)))
68342 + return -EINVAL;
68343 +
68344 + return 0;
68345 +}
68346 +
68347 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
68348 +{
68349 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
68350 + return -EFAULT;
68351 +
68352 + return 0;
68353 +}
68354 +
68355 +static size_t get_gr_arg_wrapper_size_normal(void)
68356 +{
68357 + return sizeof(struct gr_arg_wrapper);
68358 +}
68359 +
68360 +#ifdef CONFIG_COMPAT
68361 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
68362 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
68363 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
68364 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
68365 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
68366 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
68367 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
68368 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
68369 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
68370 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
68371 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
68372 +extern size_t get_gr_arg_wrapper_size_compat(void);
68373 +
68374 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
68375 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
68376 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
68377 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
68378 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
68379 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
68380 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
68381 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
68382 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
68383 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
68384 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
68385 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
68386 +
68387 +#else
68388 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
68389 +#define copy_gr_arg copy_gr_arg_normal
68390 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
68391 +#define copy_acl_object_label copy_acl_object_label_normal
68392 +#define copy_acl_subject_label copy_acl_subject_label_normal
68393 +#define copy_acl_role_label copy_acl_role_label_normal
68394 +#define copy_acl_ip_label copy_acl_ip_label_normal
68395 +#define copy_pointer_from_array copy_pointer_from_array_normal
68396 +#define copy_sprole_pw copy_sprole_pw_normal
68397 +#define copy_role_transition copy_role_transition_normal
68398 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
68399 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
68400 +#endif
68401 +
68402 +static struct acl_subject_label *
68403 +lookup_subject_map(const struct acl_subject_label *userp)
68404 +{
68405 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
68406 + struct subject_map *match;
68407 +
68408 + match = polstate->subj_map_set.s_hash[index];
68409 +
68410 + while (match && match->user != userp)
68411 + match = match->next;
68412 +
68413 + if (match != NULL)
68414 + return match->kernel;
68415 + else
68416 + return NULL;
68417 +}
68418 +
68419 +static void
68420 +insert_subj_map_entry(struct subject_map *subjmap)
68421 +{
68422 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
68423 + struct subject_map **curr;
68424 +
68425 + subjmap->prev = NULL;
68426 +
68427 + curr = &polstate->subj_map_set.s_hash[index];
68428 + if (*curr != NULL)
68429 + (*curr)->prev = subjmap;
68430 +
68431 + subjmap->next = *curr;
68432 + *curr = subjmap;
68433 +
68434 + return;
68435 +}
68436 +
68437 +static void
68438 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
68439 +{
68440 + unsigned int index =
68441 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
68442 + struct acl_role_label **curr;
68443 + struct acl_role_label *tmp, *tmp2;
68444 +
68445 + curr = &polstate->acl_role_set.r_hash[index];
68446 +
68447 + /* simple case, slot is empty, just set it to our role */
68448 + if (*curr == NULL) {
68449 + *curr = role;
68450 + } else {
68451 + /* example:
68452 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
68453 + 2 -> 3
68454 + */
68455 + /* first check to see if we can already be reached via this slot */
68456 + tmp = *curr;
68457 + while (tmp && tmp != role)
68458 + tmp = tmp->next;
68459 + if (tmp == role) {
68460 + /* we don't need to add ourselves to this slot's chain */
68461 + return;
68462 + }
68463 + /* we need to add ourselves to this chain, two cases */
68464 + if (role->next == NULL) {
68465 + /* simple case, append the current chain to our role */
68466 + role->next = *curr;
68467 + *curr = role;
68468 + } else {
68469 + /* 1 -> 2 -> 3 -> 4
68470 + 2 -> 3 -> 4
68471 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
68472 + */
68473 + /* trickier case: walk our role's chain until we find
68474 + the role for the start of the current slot's chain */
68475 + tmp = role;
68476 + tmp2 = *curr;
68477 + while (tmp->next && tmp->next != tmp2)
68478 + tmp = tmp->next;
68479 + if (tmp->next == tmp2) {
68480 + /* from example above, we found 3, so just
68481 + replace this slot's chain with ours */
68482 + *curr = role;
68483 + } else {
68484 + /* we didn't find a subset of our role's chain
68485 + in the current slot's chain, so append their
68486 + chain to ours, and set us as the first role in
68487 + the slot's chain
68488 +
68489 + we could fold this case with the case above,
68490 + but making it explicit for clarity
68491 + */
68492 + tmp->next = tmp2;
68493 + *curr = role;
68494 + }
68495 + }
68496 + }
68497 +
68498 + return;
68499 +}
68500 +
68501 +static void
68502 +insert_acl_role_label(struct acl_role_label *role)
68503 +{
68504 + int i;
68505 +
68506 + if (polstate->role_list == NULL) {
68507 + polstate->role_list = role;
68508 + role->prev = NULL;
68509 + } else {
68510 + role->prev = polstate->role_list;
68511 + polstate->role_list = role;
68512 + }
68513 +
68514 + /* used for hash chains */
68515 + role->next = NULL;
68516 +
68517 + if (role->roletype & GR_ROLE_DOMAIN) {
68518 + for (i = 0; i < role->domain_child_num; i++)
68519 + __insert_acl_role_label(role, role->domain_children[i]);
68520 + } else
68521 + __insert_acl_role_label(role, role->uidgid);
68522 +}
68523 +
68524 +static int
68525 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
68526 +{
68527 + struct name_entry **curr, *nentry;
68528 + struct inodev_entry *ientry;
68529 + unsigned int len = strlen(name);
68530 + unsigned int key = full_name_hash(name, len);
68531 + unsigned int index = key % polstate->name_set.n_size;
68532 +
68533 + curr = &polstate->name_set.n_hash[index];
68534 +
68535 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
68536 + curr = &((*curr)->next);
68537 +
68538 + if (*curr != NULL)
68539 + return 1;
68540 +
68541 + nentry = acl_alloc(sizeof (struct name_entry));
68542 + if (nentry == NULL)
68543 + return 0;
68544 + ientry = acl_alloc(sizeof (struct inodev_entry));
68545 + if (ientry == NULL)
68546 + return 0;
68547 + ientry->nentry = nentry;
68548 +
68549 + nentry->key = key;
68550 + nentry->name = name;
68551 + nentry->inode = inode;
68552 + nentry->device = device;
68553 + nentry->len = len;
68554 + nentry->deleted = deleted;
68555 +
68556 + nentry->prev = NULL;
68557 + curr = &polstate->name_set.n_hash[index];
68558 + if (*curr != NULL)
68559 + (*curr)->prev = nentry;
68560 + nentry->next = *curr;
68561 + *curr = nentry;
68562 +
68563 + /* insert us into the table searchable by inode/dev */
68564 + __insert_inodev_entry(polstate, ientry);
68565 +
68566 + return 1;
68567 +}
68568 +
68569 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
68570 +
68571 +static void *
68572 +create_table(__u32 * len, int elementsize)
68573 +{
68574 + unsigned int table_sizes[] = {
68575 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
68576 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
68577 + 4194301, 8388593, 16777213, 33554393, 67108859
68578 + };
68579 + void *newtable = NULL;
68580 + unsigned int pwr = 0;
68581 +
68582 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
68583 + table_sizes[pwr] <= *len)
68584 + pwr++;
68585 +
68586 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
68587 + return newtable;
68588 +
68589 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
68590 + newtable =
68591 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
68592 + else
68593 + newtable = vmalloc(table_sizes[pwr] * elementsize);
68594 +
68595 + *len = table_sizes[pwr];
68596 +
68597 + return newtable;
68598 +}
68599 +
68600 +static int
68601 +init_variables(const struct gr_arg *arg, bool reload)
68602 +{
68603 + struct task_struct *reaper = init_pid_ns.child_reaper;
68604 + unsigned int stacksize;
68605 +
68606 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
68607 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
68608 + polstate->name_set.n_size = arg->role_db.num_objects;
68609 + polstate->inodev_set.i_size = arg->role_db.num_objects;
68610 +
68611 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
68612 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
68613 + return 1;
68614 +
68615 + if (!reload) {
68616 + if (!gr_init_uidset())
68617 + return 1;
68618 + }
68619 +
68620 + /* set up the stack that holds allocation info */
68621 +
68622 + stacksize = arg->role_db.num_pointers + 5;
68623 +
68624 + if (!acl_alloc_stack_init(stacksize))
68625 + return 1;
68626 +
68627 + if (!reload) {
68628 + /* grab reference for the real root dentry and vfsmount */
68629 + get_fs_root(reaper->fs, &gr_real_root);
68630 +
68631 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68632 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(gr_real_root.dentry), gr_real_root.dentry->d_inode->i_ino);
68633 +#endif
68634 +
68635 + fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68636 + if (fakefs_obj_rw == NULL)
68637 + return 1;
68638 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
68639 +
68640 + fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68641 + if (fakefs_obj_rwx == NULL)
68642 + return 1;
68643 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
68644 + }
68645 +
68646 + polstate->subj_map_set.s_hash =
68647 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
68648 + polstate->acl_role_set.r_hash =
68649 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
68650 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
68651 + polstate->inodev_set.i_hash =
68652 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
68653 +
68654 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
68655 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
68656 + return 1;
68657 +
68658 + memset(polstate->subj_map_set.s_hash, 0,
68659 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
68660 + memset(polstate->acl_role_set.r_hash, 0,
68661 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
68662 + memset(polstate->name_set.n_hash, 0,
68663 + sizeof (struct name_entry *) * polstate->name_set.n_size);
68664 + memset(polstate->inodev_set.i_hash, 0,
68665 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
68666 +
68667 + return 0;
68668 +}
68669 +
68670 +/* free information not needed after startup
68671 + currently contains user->kernel pointer mappings for subjects
68672 +*/
68673 +
68674 +static void
68675 +free_init_variables(void)
68676 +{
68677 + __u32 i;
68678 +
68679 + if (polstate->subj_map_set.s_hash) {
68680 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
68681 + if (polstate->subj_map_set.s_hash[i]) {
68682 + kfree(polstate->subj_map_set.s_hash[i]);
68683 + polstate->subj_map_set.s_hash[i] = NULL;
68684 + }
68685 + }
68686 +
68687 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
68688 + PAGE_SIZE)
68689 + kfree(polstate->subj_map_set.s_hash);
68690 + else
68691 + vfree(polstate->subj_map_set.s_hash);
68692 + }
68693 +
68694 + return;
68695 +}
68696 +
68697 +static void
68698 +free_variables(bool reload)
68699 +{
68700 + struct acl_subject_label *s;
68701 + struct acl_role_label *r;
68702 + struct task_struct *task, *task2;
68703 + unsigned int x;
68704 +
68705 + if (!reload) {
68706 + gr_clear_learn_entries();
68707 +
68708 + read_lock(&tasklist_lock);
68709 + do_each_thread(task2, task) {
68710 + task->acl_sp_role = 0;
68711 + task->acl_role_id = 0;
68712 + task->inherited = 0;
68713 + task->acl = NULL;
68714 + task->role = NULL;
68715 + } while_each_thread(task2, task);
68716 + read_unlock(&tasklist_lock);
68717 +
68718 + kfree(fakefs_obj_rw);
68719 + fakefs_obj_rw = NULL;
68720 + kfree(fakefs_obj_rwx);
68721 + fakefs_obj_rwx = NULL;
68722 +
68723 + /* release the reference to the real root dentry and vfsmount */
68724 + path_put(&gr_real_root);
68725 + memset(&gr_real_root, 0, sizeof(gr_real_root));
68726 + }
68727 +
68728 + /* free all object hash tables */
68729 +
68730 + FOR_EACH_ROLE_START(r)
68731 + if (r->subj_hash == NULL)
68732 + goto next_role;
68733 + FOR_EACH_SUBJECT_START(r, s, x)
68734 + if (s->obj_hash == NULL)
68735 + break;
68736 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68737 + kfree(s->obj_hash);
68738 + else
68739 + vfree(s->obj_hash);
68740 + FOR_EACH_SUBJECT_END(s, x)
68741 + FOR_EACH_NESTED_SUBJECT_START(r, s)
68742 + if (s->obj_hash == NULL)
68743 + break;
68744 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68745 + kfree(s->obj_hash);
68746 + else
68747 + vfree(s->obj_hash);
68748 + FOR_EACH_NESTED_SUBJECT_END(s)
68749 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
68750 + kfree(r->subj_hash);
68751 + else
68752 + vfree(r->subj_hash);
68753 + r->subj_hash = NULL;
68754 +next_role:
68755 + FOR_EACH_ROLE_END(r)
68756 +
68757 + acl_free_all();
68758 +
68759 + if (polstate->acl_role_set.r_hash) {
68760 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
68761 + PAGE_SIZE)
68762 + kfree(polstate->acl_role_set.r_hash);
68763 + else
68764 + vfree(polstate->acl_role_set.r_hash);
68765 + }
68766 + if (polstate->name_set.n_hash) {
68767 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
68768 + PAGE_SIZE)
68769 + kfree(polstate->name_set.n_hash);
68770 + else
68771 + vfree(polstate->name_set.n_hash);
68772 + }
68773 +
68774 + if (polstate->inodev_set.i_hash) {
68775 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
68776 + PAGE_SIZE)
68777 + kfree(polstate->inodev_set.i_hash);
68778 + else
68779 + vfree(polstate->inodev_set.i_hash);
68780 + }
68781 +
68782 + if (!reload)
68783 + gr_free_uidset();
68784 +
68785 + memset(&polstate->name_set, 0, sizeof (struct name_db));
68786 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
68787 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
68788 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
68789 +
68790 + polstate->default_role = NULL;
68791 + polstate->kernel_role = NULL;
68792 + polstate->role_list = NULL;
68793 +
68794 + return;
68795 +}
68796 +
68797 +static struct acl_subject_label *
68798 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
68799 +
68800 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
68801 +{
68802 + unsigned int len = strnlen_user(*name, maxlen);
68803 + char *tmp;
68804 +
68805 + if (!len || len >= maxlen)
68806 + return -EINVAL;
68807 +
68808 + if ((tmp = (char *) acl_alloc(len)) == NULL)
68809 + return -ENOMEM;
68810 +
68811 + if (copy_from_user(tmp, *name, len))
68812 + return -EFAULT;
68813 +
68814 + tmp[len-1] = '\0';
68815 + *name = tmp;
68816 +
68817 + return 0;
68818 +}
68819 +
68820 +static int
68821 +copy_user_glob(struct acl_object_label *obj)
68822 +{
68823 + struct acl_object_label *g_tmp, **guser;
68824 + int error;
68825 +
68826 + if (obj->globbed == NULL)
68827 + return 0;
68828 +
68829 + guser = &obj->globbed;
68830 + while (*guser) {
68831 + g_tmp = (struct acl_object_label *)
68832 + acl_alloc(sizeof (struct acl_object_label));
68833 + if (g_tmp == NULL)
68834 + return -ENOMEM;
68835 +
68836 + if (copy_acl_object_label(g_tmp, *guser))
68837 + return -EFAULT;
68838 +
68839 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
68840 + if (error)
68841 + return error;
68842 +
68843 + *guser = g_tmp;
68844 + guser = &(g_tmp->next);
68845 + }
68846 +
68847 + return 0;
68848 +}
68849 +
68850 +static int
68851 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
68852 + struct acl_role_label *role)
68853 +{
68854 + struct acl_object_label *o_tmp;
68855 + int ret;
68856 +
68857 + while (userp) {
68858 + if ((o_tmp = (struct acl_object_label *)
68859 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
68860 + return -ENOMEM;
68861 +
68862 + if (copy_acl_object_label(o_tmp, userp))
68863 + return -EFAULT;
68864 +
68865 + userp = o_tmp->prev;
68866 +
68867 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
68868 + if (ret)
68869 + return ret;
68870 +
68871 + insert_acl_obj_label(o_tmp, subj);
68872 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
68873 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
68874 + return -ENOMEM;
68875 +
68876 + ret = copy_user_glob(o_tmp);
68877 + if (ret)
68878 + return ret;
68879 +
68880 + if (o_tmp->nested) {
68881 + int already_copied;
68882 +
68883 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
68884 + if (IS_ERR(o_tmp->nested))
68885 + return PTR_ERR(o_tmp->nested);
68886 +
68887 + /* insert into nested subject list if we haven't copied this one yet
68888 + to prevent duplicate entries */
68889 + if (!already_copied) {
68890 + o_tmp->nested->next = role->hash->first;
68891 + role->hash->first = o_tmp->nested;
68892 + }
68893 + }
68894 + }
68895 +
68896 + return 0;
68897 +}
68898 +
68899 +static __u32
68900 +count_user_subjs(struct acl_subject_label *userp)
68901 +{
68902 + struct acl_subject_label s_tmp;
68903 + __u32 num = 0;
68904 +
68905 + while (userp) {
68906 + if (copy_acl_subject_label(&s_tmp, userp))
68907 + break;
68908 +
68909 + userp = s_tmp.prev;
68910 + }
68911 +
68912 + return num;
68913 +}
68914 +
68915 +static int
68916 +copy_user_allowedips(struct acl_role_label *rolep)
68917 +{
68918 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
68919 +
68920 + ruserip = rolep->allowed_ips;
68921 +
68922 + while (ruserip) {
68923 + rlast = rtmp;
68924 +
68925 + if ((rtmp = (struct role_allowed_ip *)
68926 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
68927 + return -ENOMEM;
68928 +
68929 + if (copy_role_allowed_ip(rtmp, ruserip))
68930 + return -EFAULT;
68931 +
68932 + ruserip = rtmp->prev;
68933 +
68934 + if (!rlast) {
68935 + rtmp->prev = NULL;
68936 + rolep->allowed_ips = rtmp;
68937 + } else {
68938 + rlast->next = rtmp;
68939 + rtmp->prev = rlast;
68940 + }
68941 +
68942 + if (!ruserip)
68943 + rtmp->next = NULL;
68944 + }
68945 +
68946 + return 0;
68947 +}
68948 +
68949 +static int
68950 +copy_user_transitions(struct acl_role_label *rolep)
68951 +{
68952 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
68953 + int error;
68954 +
68955 + rusertp = rolep->transitions;
68956 +
68957 + while (rusertp) {
68958 + rlast = rtmp;
68959 +
68960 + if ((rtmp = (struct role_transition *)
68961 + acl_alloc(sizeof (struct role_transition))) == NULL)
68962 + return -ENOMEM;
68963 +
68964 + if (copy_role_transition(rtmp, rusertp))
68965 + return -EFAULT;
68966 +
68967 + rusertp = rtmp->prev;
68968 +
68969 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
68970 + if (error)
68971 + return error;
68972 +
68973 + if (!rlast) {
68974 + rtmp->prev = NULL;
68975 + rolep->transitions = rtmp;
68976 + } else {
68977 + rlast->next = rtmp;
68978 + rtmp->prev = rlast;
68979 + }
68980 +
68981 + if (!rusertp)
68982 + rtmp->next = NULL;
68983 + }
68984 +
68985 + return 0;
68986 +}
68987 +
68988 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
68989 +{
68990 + struct acl_object_label o_tmp;
68991 + __u32 num = 0;
68992 +
68993 + while (userp) {
68994 + if (copy_acl_object_label(&o_tmp, userp))
68995 + break;
68996 +
68997 + userp = o_tmp.prev;
68998 + num++;
68999 + }
69000 +
69001 + return num;
69002 +}
69003 +
69004 +static struct acl_subject_label *
69005 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
69006 +{
69007 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
69008 + __u32 num_objs;
69009 + struct acl_ip_label **i_tmp, *i_utmp2;
69010 + struct gr_hash_struct ghash;
69011 + struct subject_map *subjmap;
69012 + unsigned int i_num;
69013 + int err;
69014 +
69015 + if (already_copied != NULL)
69016 + *already_copied = 0;
69017 +
69018 + s_tmp = lookup_subject_map(userp);
69019 +
69020 + /* we've already copied this subject into the kernel, just return
69021 + the reference to it, and don't copy it over again
69022 + */
69023 + if (s_tmp) {
69024 + if (already_copied != NULL)
69025 + *already_copied = 1;
69026 + return(s_tmp);
69027 + }
69028 +
69029 + if ((s_tmp = (struct acl_subject_label *)
69030 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
69031 + return ERR_PTR(-ENOMEM);
69032 +
69033 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
69034 + if (subjmap == NULL)
69035 + return ERR_PTR(-ENOMEM);
69036 +
69037 + subjmap->user = userp;
69038 + subjmap->kernel = s_tmp;
69039 + insert_subj_map_entry(subjmap);
69040 +
69041 + if (copy_acl_subject_label(s_tmp, userp))
69042 + return ERR_PTR(-EFAULT);
69043 +
69044 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
69045 + if (err)
69046 + return ERR_PTR(err);
69047 +
69048 + if (!strcmp(s_tmp->filename, "/"))
69049 + role->root_label = s_tmp;
69050 +
69051 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
69052 + return ERR_PTR(-EFAULT);
69053 +
69054 + /* copy user and group transition tables */
69055 +
69056 + if (s_tmp->user_trans_num) {
69057 + uid_t *uidlist;
69058 +
69059 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
69060 + if (uidlist == NULL)
69061 + return ERR_PTR(-ENOMEM);
69062 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
69063 + return ERR_PTR(-EFAULT);
69064 +
69065 + s_tmp->user_transitions = uidlist;
69066 + }
69067 +
69068 + if (s_tmp->group_trans_num) {
69069 + gid_t *gidlist;
69070 +
69071 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
69072 + if (gidlist == NULL)
69073 + return ERR_PTR(-ENOMEM);
69074 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
69075 + return ERR_PTR(-EFAULT);
69076 +
69077 + s_tmp->group_transitions = gidlist;
69078 + }
69079 +
69080 + /* set up object hash table */
69081 + num_objs = count_user_objs(ghash.first);
69082 +
69083 + s_tmp->obj_hash_size = num_objs;
69084 + s_tmp->obj_hash =
69085 + (struct acl_object_label **)
69086 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
69087 +
69088 + if (!s_tmp->obj_hash)
69089 + return ERR_PTR(-ENOMEM);
69090 +
69091 + memset(s_tmp->obj_hash, 0,
69092 + s_tmp->obj_hash_size *
69093 + sizeof (struct acl_object_label *));
69094 +
69095 + /* add in objects */
69096 + err = copy_user_objs(ghash.first, s_tmp, role);
69097 +
69098 + if (err)
69099 + return ERR_PTR(err);
69100 +
69101 + /* set pointer for parent subject */
69102 + if (s_tmp->parent_subject) {
69103 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
69104 +
69105 + if (IS_ERR(s_tmp2))
69106 + return s_tmp2;
69107 +
69108 + s_tmp->parent_subject = s_tmp2;
69109 + }
69110 +
69111 + /* add in ip acls */
69112 +
69113 + if (!s_tmp->ip_num) {
69114 + s_tmp->ips = NULL;
69115 + goto insert;
69116 + }
69117 +
69118 + i_tmp =
69119 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
69120 + sizeof (struct acl_ip_label *));
69121 +
69122 + if (!i_tmp)
69123 + return ERR_PTR(-ENOMEM);
69124 +
69125 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
69126 + *(i_tmp + i_num) =
69127 + (struct acl_ip_label *)
69128 + acl_alloc(sizeof (struct acl_ip_label));
69129 + if (!*(i_tmp + i_num))
69130 + return ERR_PTR(-ENOMEM);
69131 +
69132 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
69133 + return ERR_PTR(-EFAULT);
69134 +
69135 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
69136 + return ERR_PTR(-EFAULT);
69137 +
69138 + if ((*(i_tmp + i_num))->iface == NULL)
69139 + continue;
69140 +
69141 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
69142 + if (err)
69143 + return ERR_PTR(err);
69144 + }
69145 +
69146 + s_tmp->ips = i_tmp;
69147 +
69148 +insert:
69149 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
69150 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
69151 + return ERR_PTR(-ENOMEM);
69152 +
69153 + return s_tmp;
69154 +}
69155 +
69156 +static int
69157 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
69158 +{
69159 + struct acl_subject_label s_pre;
69160 + struct acl_subject_label * ret;
69161 + int err;
69162 +
69163 + while (userp) {
69164 + if (copy_acl_subject_label(&s_pre, userp))
69165 + return -EFAULT;
69166 +
69167 + ret = do_copy_user_subj(userp, role, NULL);
69168 +
69169 + err = PTR_ERR(ret);
69170 + if (IS_ERR(ret))
69171 + return err;
69172 +
69173 + insert_acl_subj_label(ret, role);
69174 +
69175 + userp = s_pre.prev;
69176 + }
69177 +
69178 + return 0;
69179 +}
69180 +
69181 +static int
69182 +copy_user_acl(struct gr_arg *arg)
69183 +{
69184 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
69185 + struct acl_subject_label *subj_list;
69186 + struct sprole_pw *sptmp;
69187 + struct gr_hash_struct *ghash;
69188 + uid_t *domainlist;
69189 + unsigned int r_num;
69190 + int err = 0;
69191 + __u16 i;
69192 + __u32 num_subjs;
69193 +
69194 + /* we need a default and kernel role */
69195 + if (arg->role_db.num_roles < 2)
69196 + return -EINVAL;
69197 +
69198 + /* copy special role authentication info from userspace */
69199 +
69200 + polstate->num_sprole_pws = arg->num_sprole_pws;
69201 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
69202 +
69203 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
69204 + return -ENOMEM;
69205 +
69206 + for (i = 0; i < polstate->num_sprole_pws; i++) {
69207 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
69208 + if (!sptmp)
69209 + return -ENOMEM;
69210 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
69211 + return -EFAULT;
69212 +
69213 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
69214 + if (err)
69215 + return err;
69216 +
69217 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
69218 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
69219 +#endif
69220 +
69221 + polstate->acl_special_roles[i] = sptmp;
69222 + }
69223 +
69224 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
69225 +
69226 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
69227 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
69228 +
69229 + if (!r_tmp)
69230 + return -ENOMEM;
69231 +
69232 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
69233 + return -EFAULT;
69234 +
69235 + if (copy_acl_role_label(r_tmp, r_utmp2))
69236 + return -EFAULT;
69237 +
69238 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
69239 + if (err)
69240 + return err;
69241 +
69242 + if (!strcmp(r_tmp->rolename, "default")
69243 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
69244 + polstate->default_role = r_tmp;
69245 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
69246 + polstate->kernel_role = r_tmp;
69247 + }
69248 +
69249 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
69250 + return -ENOMEM;
69251 +
69252 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
69253 + return -EFAULT;
69254 +
69255 + r_tmp->hash = ghash;
69256 +
69257 + num_subjs = count_user_subjs(r_tmp->hash->first);
69258 +
69259 + r_tmp->subj_hash_size = num_subjs;
69260 + r_tmp->subj_hash =
69261 + (struct acl_subject_label **)
69262 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
69263 +
69264 + if (!r_tmp->subj_hash)
69265 + return -ENOMEM;
69266 +
69267 + err = copy_user_allowedips(r_tmp);
69268 + if (err)
69269 + return err;
69270 +
69271 + /* copy domain info */
69272 + if (r_tmp->domain_children != NULL) {
69273 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
69274 + if (domainlist == NULL)
69275 + return -ENOMEM;
69276 +
69277 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
69278 + return -EFAULT;
69279 +
69280 + r_tmp->domain_children = domainlist;
69281 + }
69282 +
69283 + err = copy_user_transitions(r_tmp);
69284 + if (err)
69285 + return err;
69286 +
69287 + memset(r_tmp->subj_hash, 0,
69288 + r_tmp->subj_hash_size *
69289 + sizeof (struct acl_subject_label *));
69290 +
69291 + /* acquire the list of subjects, then NULL out
69292 + the list prior to parsing the subjects for this role,
69293 + as during this parsing the list is replaced with a list
69294 + of *nested* subjects for the role
69295 + */
69296 + subj_list = r_tmp->hash->first;
69297 +
69298 + /* set nested subject list to null */
69299 + r_tmp->hash->first = NULL;
69300 +
69301 + err = copy_user_subjs(subj_list, r_tmp);
69302 +
69303 + if (err)
69304 + return err;
69305 +
69306 + insert_acl_role_label(r_tmp);
69307 + }
69308 +
69309 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
69310 + return -EINVAL;
69311 +
69312 + return err;
69313 +}
69314 +
69315 +static int gracl_reload_apply_policies(void *reload)
69316 +{
69317 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
69318 + struct task_struct *task, *task2;
69319 + struct acl_role_label *role, *rtmp;
69320 + struct acl_subject_label *subj;
69321 + const struct cred *cred;
69322 + int role_applied;
69323 + int ret = 0;
69324 +
69325 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
69326 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
69327 +
69328 + /* first make sure we'll be able to apply the new policy cleanly */
69329 + do_each_thread(task2, task) {
69330 + if (task->exec_file == NULL)
69331 + continue;
69332 + role_applied = 0;
69333 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
69334 + /* preserve special roles */
69335 + FOR_EACH_ROLE_START(role)
69336 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
69337 + rtmp = task->role;
69338 + task->role = role;
69339 + role_applied = 1;
69340 + break;
69341 + }
69342 + FOR_EACH_ROLE_END(role)
69343 + }
69344 + if (!role_applied) {
69345 + cred = __task_cred(task);
69346 + rtmp = task->role;
69347 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69348 + }
69349 + /* this handles non-nested inherited subjects, nested subjects will still
69350 + be dropped currently */
69351 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
69352 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
69353 + /* change the role back so that we've made no modifications to the policy */
69354 + task->role = rtmp;
69355 +
69356 + if (subj == NULL || task->tmpacl == NULL) {
69357 + ret = -EINVAL;
69358 + goto out;
69359 + }
69360 + } while_each_thread(task2, task);
69361 +
69362 + /* now actually apply the policy */
69363 +
69364 + do_each_thread(task2, task) {
69365 + if (task->exec_file) {
69366 + role_applied = 0;
69367 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
69368 + /* preserve special roles */
69369 + FOR_EACH_ROLE_START(role)
69370 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
69371 + task->role = role;
69372 + role_applied = 1;
69373 + break;
69374 + }
69375 + FOR_EACH_ROLE_END(role)
69376 + }
69377 + if (!role_applied) {
69378 + cred = __task_cred(task);
69379 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69380 + }
69381 + /* this handles non-nested inherited subjects, nested subjects will still
69382 + be dropped currently */
69383 + if (!reload_state->oldmode && task->inherited)
69384 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
69385 + else {
69386 + /* looked up and tagged to the task previously */
69387 + subj = task->tmpacl;
69388 + }
69389 + /* subj will be non-null */
69390 + __gr_apply_subject_to_task(polstate, task, subj);
69391 + if (reload_state->oldmode) {
69392 + task->acl_role_id = 0;
69393 + task->acl_sp_role = 0;
69394 + task->inherited = 0;
69395 + }
69396 + } else {
69397 + // it's a kernel process
69398 + task->role = polstate->kernel_role;
69399 + task->acl = polstate->kernel_role->root_label;
69400 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69401 + task->acl->mode &= ~GR_PROCFIND;
69402 +#endif
69403 + }
69404 + } while_each_thread(task2, task);
69405 +
69406 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
69407 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
69408 +
69409 +out:
69410 +
69411 + return ret;
69412 +}
69413 +
69414 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
69415 +{
69416 + struct gr_reload_state new_reload_state = { };
69417 + int err;
69418 +
69419 + new_reload_state.oldpolicy_ptr = polstate;
69420 + new_reload_state.oldalloc_ptr = current_alloc_state;
69421 + new_reload_state.oldmode = oldmode;
69422 +
69423 + current_alloc_state = &new_reload_state.newalloc;
69424 + polstate = &new_reload_state.newpolicy;
69425 +
69426 + /* everything relevant is now saved off, copy in the new policy */
69427 + if (init_variables(args, true)) {
69428 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
69429 + err = -ENOMEM;
69430 + goto error;
69431 + }
69432 +
69433 + err = copy_user_acl(args);
69434 + free_init_variables();
69435 + if (err)
69436 + goto error;
69437 + /* the new policy is copied in, with the old policy available via saved_state
69438 + first go through applying roles, making sure to preserve special roles
69439 + then apply new subjects, making sure to preserve inherited and nested subjects,
69440 + though currently only inherited subjects will be preserved
69441 + */
69442 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
69443 + if (err)
69444 + goto error;
69445 +
69446 + /* we've now applied the new policy, so restore the old policy state to free it */
69447 + polstate = &new_reload_state.oldpolicy;
69448 + current_alloc_state = &new_reload_state.oldalloc;
69449 + free_variables(true);
69450 +
69451 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
69452 + to running_polstate/current_alloc_state inside stop_machine
69453 + */
69454 + err = 0;
69455 + goto out;
69456 +error:
69457 + /* on error of loading the new policy, we'll just keep the previous
69458 + policy set around
69459 + */
69460 + free_variables(true);
69461 +
69462 + /* doesn't affect runtime, but maintains consistent state */
69463 +out:
69464 + polstate = new_reload_state.oldpolicy_ptr;
69465 + current_alloc_state = new_reload_state.oldalloc_ptr;
69466 +
69467 + return err;
69468 +}
69469 +
69470 +static int
69471 +gracl_init(struct gr_arg *args)
69472 +{
69473 + int error = 0;
69474 +
69475 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
69476 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
69477 +
69478 + if (init_variables(args, false)) {
69479 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
69480 + error = -ENOMEM;
69481 + goto out;
69482 + }
69483 +
69484 + error = copy_user_acl(args);
69485 + free_init_variables();
69486 + if (error)
69487 + goto out;
69488 +
69489 + error = gr_set_acls(0);
69490 + if (error)
69491 + goto out;
69492 +
69493 + gr_enable_rbac_system();
69494 +
69495 + return 0;
69496 +
69497 +out:
69498 + free_variables(false);
69499 + return error;
69500 +}
69501 +
69502 +static int
69503 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
69504 + unsigned char **sum)
69505 +{
69506 + struct acl_role_label *r;
69507 + struct role_allowed_ip *ipp;
69508 + struct role_transition *trans;
69509 + unsigned int i;
69510 + int found = 0;
69511 + u32 curr_ip = current->signal->curr_ip;
69512 +
69513 + current->signal->saved_ip = curr_ip;
69514 +
69515 + /* check transition table */
69516 +
69517 + for (trans = current->role->transitions; trans; trans = trans->next) {
69518 + if (!strcmp(rolename, trans->rolename)) {
69519 + found = 1;
69520 + break;
69521 + }
69522 + }
69523 +
69524 + if (!found)
69525 + return 0;
69526 +
69527 + /* handle special roles that do not require authentication
69528 + and check ip */
69529 +
69530 + FOR_EACH_ROLE_START(r)
69531 + if (!strcmp(rolename, r->rolename) &&
69532 + (r->roletype & GR_ROLE_SPECIAL)) {
69533 + found = 0;
69534 + if (r->allowed_ips != NULL) {
69535 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
69536 + if ((ntohl(curr_ip) & ipp->netmask) ==
69537 + (ntohl(ipp->addr) & ipp->netmask))
69538 + found = 1;
69539 + }
69540 + } else
69541 + found = 2;
69542 + if (!found)
69543 + return 0;
69544 +
69545 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
69546 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
69547 + *salt = NULL;
69548 + *sum = NULL;
69549 + return 1;
69550 + }
69551 + }
69552 + FOR_EACH_ROLE_END(r)
69553 +
69554 + for (i = 0; i < polstate->num_sprole_pws; i++) {
69555 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
69556 + *salt = polstate->acl_special_roles[i]->salt;
69557 + *sum = polstate->acl_special_roles[i]->sum;
69558 + return 1;
69559 + }
69560 + }
69561 +
69562 + return 0;
69563 +}
69564 +
69565 +int gr_check_secure_terminal(struct task_struct *task)
69566 +{
69567 + struct task_struct *p, *p2, *p3;
69568 + struct files_struct *files;
69569 + struct fdtable *fdt;
69570 + struct file *our_file = NULL, *file;
69571 + int i;
69572 +
69573 + if (task->signal->tty == NULL)
69574 + return 1;
69575 +
69576 + files = get_files_struct(task);
69577 + if (files != NULL) {
69578 + rcu_read_lock();
69579 + fdt = files_fdtable(files);
69580 + for (i=0; i < fdt->max_fds; i++) {
69581 + file = fcheck_files(files, i);
69582 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
69583 + get_file(file);
69584 + our_file = file;
69585 + }
69586 + }
69587 + rcu_read_unlock();
69588 + put_files_struct(files);
69589 + }
69590 +
69591 + if (our_file == NULL)
69592 + return 1;
69593 +
69594 + read_lock(&tasklist_lock);
69595 + do_each_thread(p2, p) {
69596 + files = get_files_struct(p);
69597 + if (files == NULL ||
69598 + (p->signal && p->signal->tty == task->signal->tty)) {
69599 + if (files != NULL)
69600 + put_files_struct(files);
69601 + continue;
69602 + }
69603 + rcu_read_lock();
69604 + fdt = files_fdtable(files);
69605 + for (i=0; i < fdt->max_fds; i++) {
69606 + file = fcheck_files(files, i);
69607 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
69608 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
69609 + p3 = task;
69610 + while (task_pid_nr(p3) > 0) {
69611 + if (p3 == p)
69612 + break;
69613 + p3 = p3->real_parent;
69614 + }
69615 + if (p3 == p)
69616 + break;
69617 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
69618 + gr_handle_alertkill(p);
69619 + rcu_read_unlock();
69620 + put_files_struct(files);
69621 + read_unlock(&tasklist_lock);
69622 + fput(our_file);
69623 + return 0;
69624 + }
69625 + }
69626 + rcu_read_unlock();
69627 + put_files_struct(files);
69628 + } while_each_thread(p2, p);
69629 + read_unlock(&tasklist_lock);
69630 +
69631 + fput(our_file);
69632 + return 1;
69633 +}
69634 +
69635 +ssize_t
69636 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
69637 +{
69638 + struct gr_arg_wrapper uwrap;
69639 + unsigned char *sprole_salt = NULL;
69640 + unsigned char *sprole_sum = NULL;
69641 + int error = 0;
69642 + int error2 = 0;
69643 + size_t req_count = 0;
69644 + unsigned char oldmode = 0;
69645 +
69646 + mutex_lock(&gr_dev_mutex);
69647 +
69648 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
69649 + error = -EPERM;
69650 + goto out;
69651 + }
69652 +
69653 +#ifdef CONFIG_COMPAT
69654 + pax_open_kernel();
69655 + if (is_compat_task()) {
69656 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
69657 + copy_gr_arg = &copy_gr_arg_compat;
69658 + copy_acl_object_label = &copy_acl_object_label_compat;
69659 + copy_acl_subject_label = &copy_acl_subject_label_compat;
69660 + copy_acl_role_label = &copy_acl_role_label_compat;
69661 + copy_acl_ip_label = &copy_acl_ip_label_compat;
69662 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
69663 + copy_role_transition = &copy_role_transition_compat;
69664 + copy_sprole_pw = &copy_sprole_pw_compat;
69665 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
69666 + copy_pointer_from_array = &copy_pointer_from_array_compat;
69667 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
69668 + } else {
69669 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
69670 + copy_gr_arg = &copy_gr_arg_normal;
69671 + copy_acl_object_label = &copy_acl_object_label_normal;
69672 + copy_acl_subject_label = &copy_acl_subject_label_normal;
69673 + copy_acl_role_label = &copy_acl_role_label_normal;
69674 + copy_acl_ip_label = &copy_acl_ip_label_normal;
69675 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
69676 + copy_role_transition = &copy_role_transition_normal;
69677 + copy_sprole_pw = &copy_sprole_pw_normal;
69678 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
69679 + copy_pointer_from_array = &copy_pointer_from_array_normal;
69680 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
69681 + }
69682 + pax_close_kernel();
69683 +#endif
69684 +
69685 + req_count = get_gr_arg_wrapper_size();
69686 +
69687 + if (count != req_count) {
69688 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
69689 + error = -EINVAL;
69690 + goto out;
69691 + }
69692 +
69693 +
69694 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
69695 + gr_auth_expires = 0;
69696 + gr_auth_attempts = 0;
69697 + }
69698 +
69699 + error = copy_gr_arg_wrapper(buf, &uwrap);
69700 + if (error)
69701 + goto out;
69702 +
69703 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
69704 + if (error)
69705 + goto out;
69706 +
69707 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69708 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69709 + time_after(gr_auth_expires, get_seconds())) {
69710 + error = -EBUSY;
69711 + goto out;
69712 + }
69713 +
69714 + /* if non-root trying to do anything other than use a special role,
69715 + do not attempt authentication, do not count towards authentication
69716 + locking
69717 + */
69718 +
69719 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
69720 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69721 + gr_is_global_nonroot(current_uid())) {
69722 + error = -EPERM;
69723 + goto out;
69724 + }
69725 +
69726 + /* ensure pw and special role name are null terminated */
69727 +
69728 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
69729 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
69730 +
69731 + /* Okay.
69732 + * We have our enough of the argument structure..(we have yet
69733 + * to copy_from_user the tables themselves) . Copy the tables
69734 + * only if we need them, i.e. for loading operations. */
69735 +
69736 + switch (gr_usermode.mode) {
69737 + case GR_STATUS:
69738 + if (gr_acl_is_enabled()) {
69739 + error = 1;
69740 + if (!gr_check_secure_terminal(current))
69741 + error = 3;
69742 + } else
69743 + error = 2;
69744 + goto out;
69745 + case GR_SHUTDOWN:
69746 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69747 + stop_machine(gr_rbac_disable, NULL, NULL);
69748 + free_variables(false);
69749 + memset(&gr_usermode, 0, sizeof(gr_usermode));
69750 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
69751 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
69752 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
69753 + } else if (gr_acl_is_enabled()) {
69754 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
69755 + error = -EPERM;
69756 + } else {
69757 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
69758 + error = -EAGAIN;
69759 + }
69760 + break;
69761 + case GR_ENABLE:
69762 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
69763 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
69764 + else {
69765 + if (gr_acl_is_enabled())
69766 + error = -EAGAIN;
69767 + else
69768 + error = error2;
69769 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
69770 + }
69771 + break;
69772 + case GR_OLDRELOAD:
69773 + oldmode = 1;
69774 + case GR_RELOAD:
69775 + if (!gr_acl_is_enabled()) {
69776 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
69777 + error = -EAGAIN;
69778 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69779 + error2 = gracl_reload(&gr_usermode, oldmode);
69780 + if (!error2)
69781 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
69782 + else {
69783 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69784 + error = error2;
69785 + }
69786 + } else {
69787 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69788 + error = -EPERM;
69789 + }
69790 + break;
69791 + case GR_SEGVMOD:
69792 + if (unlikely(!gr_acl_is_enabled())) {
69793 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
69794 + error = -EAGAIN;
69795 + break;
69796 + }
69797 +
69798 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69799 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
69800 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
69801 + struct acl_subject_label *segvacl;
69802 + segvacl =
69803 + lookup_acl_subj_label(gr_usermode.segv_inode,
69804 + gr_usermode.segv_device,
69805 + current->role);
69806 + if (segvacl) {
69807 + segvacl->crashes = 0;
69808 + segvacl->expires = 0;
69809 + }
69810 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
69811 + gr_remove_uid(gr_usermode.segv_uid);
69812 + }
69813 + } else {
69814 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
69815 + error = -EPERM;
69816 + }
69817 + break;
69818 + case GR_SPROLE:
69819 + case GR_SPROLEPAM:
69820 + if (unlikely(!gr_acl_is_enabled())) {
69821 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
69822 + error = -EAGAIN;
69823 + break;
69824 + }
69825 +
69826 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
69827 + current->role->expires = 0;
69828 + current->role->auth_attempts = 0;
69829 + }
69830 +
69831 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69832 + time_after(current->role->expires, get_seconds())) {
69833 + error = -EBUSY;
69834 + goto out;
69835 + }
69836 +
69837 + if (lookup_special_role_auth
69838 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
69839 + && ((!sprole_salt && !sprole_sum)
69840 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
69841 + char *p = "";
69842 + assign_special_role(gr_usermode.sp_role);
69843 + read_lock(&tasklist_lock);
69844 + if (current->real_parent)
69845 + p = current->real_parent->role->rolename;
69846 + read_unlock(&tasklist_lock);
69847 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
69848 + p, acl_sp_role_value);
69849 + } else {
69850 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
69851 + error = -EPERM;
69852 + if(!(current->role->auth_attempts++))
69853 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69854 +
69855 + goto out;
69856 + }
69857 + break;
69858 + case GR_UNSPROLE:
69859 + if (unlikely(!gr_acl_is_enabled())) {
69860 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
69861 + error = -EAGAIN;
69862 + break;
69863 + }
69864 +
69865 + if (current->role->roletype & GR_ROLE_SPECIAL) {
69866 + char *p = "";
69867 + int i = 0;
69868 +
69869 + read_lock(&tasklist_lock);
69870 + if (current->real_parent) {
69871 + p = current->real_parent->role->rolename;
69872 + i = current->real_parent->acl_role_id;
69873 + }
69874 + read_unlock(&tasklist_lock);
69875 +
69876 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
69877 + gr_set_acls(1);
69878 + } else {
69879 + error = -EPERM;
69880 + goto out;
69881 + }
69882 + break;
69883 + default:
69884 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
69885 + error = -EINVAL;
69886 + break;
69887 + }
69888 +
69889 + if (error != -EPERM)
69890 + goto out;
69891 +
69892 + if(!(gr_auth_attempts++))
69893 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69894 +
69895 + out:
69896 + mutex_unlock(&gr_dev_mutex);
69897 +
69898 + if (!error)
69899 + error = req_count;
69900 +
69901 + return error;
69902 +}
69903 +
69904 +int
69905 +gr_set_acls(const int type)
69906 +{
69907 + struct task_struct *task, *task2;
69908 + struct acl_role_label *role = current->role;
69909 + struct acl_subject_label *subj;
69910 + __u16 acl_role_id = current->acl_role_id;
69911 + const struct cred *cred;
69912 + int ret;
69913 +
69914 + rcu_read_lock();
69915 + read_lock(&tasklist_lock);
69916 + read_lock(&grsec_exec_file_lock);
69917 + do_each_thread(task2, task) {
69918 + /* check to see if we're called from the exit handler,
69919 + if so, only replace ACLs that have inherited the admin
69920 + ACL */
69921 +
69922 + if (type && (task->role != role ||
69923 + task->acl_role_id != acl_role_id))
69924 + continue;
69925 +
69926 + task->acl_role_id = 0;
69927 + task->acl_sp_role = 0;
69928 + task->inherited = 0;
69929 +
69930 + if (task->exec_file) {
69931 + cred = __task_cred(task);
69932 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69933 + subj = __gr_get_subject_for_task(polstate, task, NULL);
69934 + if (subj == NULL) {
69935 + ret = -EINVAL;
69936 + read_unlock(&grsec_exec_file_lock);
69937 + read_unlock(&tasklist_lock);
69938 + rcu_read_unlock();
69939 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
69940 + return ret;
69941 + }
69942 + __gr_apply_subject_to_task(polstate, task, subj);
69943 + } else {
69944 + // it's a kernel process
69945 + task->role = polstate->kernel_role;
69946 + task->acl = polstate->kernel_role->root_label;
69947 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69948 + task->acl->mode &= ~GR_PROCFIND;
69949 +#endif
69950 + }
69951 + } while_each_thread(task2, task);
69952 + read_unlock(&grsec_exec_file_lock);
69953 + read_unlock(&tasklist_lock);
69954 + rcu_read_unlock();
69955 +
69956 + return 0;
69957 +}
69958 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
69959 new file mode 100644
69960 index 0000000..39645c9
69961 --- /dev/null
69962 +++ b/grsecurity/gracl_res.c
69963 @@ -0,0 +1,68 @@
69964 +#include <linux/kernel.h>
69965 +#include <linux/sched.h>
69966 +#include <linux/gracl.h>
69967 +#include <linux/grinternal.h>
69968 +
69969 +static const char *restab_log[] = {
69970 + [RLIMIT_CPU] = "RLIMIT_CPU",
69971 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
69972 + [RLIMIT_DATA] = "RLIMIT_DATA",
69973 + [RLIMIT_STACK] = "RLIMIT_STACK",
69974 + [RLIMIT_CORE] = "RLIMIT_CORE",
69975 + [RLIMIT_RSS] = "RLIMIT_RSS",
69976 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
69977 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
69978 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
69979 + [RLIMIT_AS] = "RLIMIT_AS",
69980 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
69981 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
69982 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
69983 + [RLIMIT_NICE] = "RLIMIT_NICE",
69984 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
69985 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
69986 + [GR_CRASH_RES] = "RLIMIT_CRASH"
69987 +};
69988 +
69989 +void
69990 +gr_log_resource(const struct task_struct *task,
69991 + const int res, const unsigned long wanted, const int gt)
69992 +{
69993 + const struct cred *cred;
69994 + unsigned long rlim;
69995 +
69996 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
69997 + return;
69998 +
69999 + // not yet supported resource
70000 + if (unlikely(!restab_log[res]))
70001 + return;
70002 +
70003 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
70004 + rlim = task_rlimit_max(task, res);
70005 + else
70006 + rlim = task_rlimit(task, res);
70007 +
70008 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
70009 + return;
70010 +
70011 + rcu_read_lock();
70012 + cred = __task_cred(task);
70013 +
70014 + if (res == RLIMIT_NPROC &&
70015 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
70016 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
70017 + goto out_rcu_unlock;
70018 + else if (res == RLIMIT_MEMLOCK &&
70019 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
70020 + goto out_rcu_unlock;
70021 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
70022 + goto out_rcu_unlock;
70023 + rcu_read_unlock();
70024 +
70025 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
70026 +
70027 + return;
70028 +out_rcu_unlock:
70029 + rcu_read_unlock();
70030 + return;
70031 +}
70032 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
70033 new file mode 100644
70034 index 0000000..2040e61
70035 --- /dev/null
70036 +++ b/grsecurity/gracl_segv.c
70037 @@ -0,0 +1,313 @@
70038 +#include <linux/kernel.h>
70039 +#include <linux/mm.h>
70040 +#include <asm/uaccess.h>
70041 +#include <asm/errno.h>
70042 +#include <asm/mman.h>
70043 +#include <net/sock.h>
70044 +#include <linux/file.h>
70045 +#include <linux/fs.h>
70046 +#include <linux/net.h>
70047 +#include <linux/in.h>
70048 +#include <linux/slab.h>
70049 +#include <linux/types.h>
70050 +#include <linux/sched.h>
70051 +#include <linux/timer.h>
70052 +#include <linux/gracl.h>
70053 +#include <linux/grsecurity.h>
70054 +#include <linux/grinternal.h>
70055 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
70056 +#include <linux/magic.h>
70057 +#include <linux/pagemap.h>
70058 +#include "../fs/btrfs/async-thread.h"
70059 +#include "../fs/btrfs/ctree.h"
70060 +#include "../fs/btrfs/btrfs_inode.h"
70061 +#endif
70062 +
70063 +static struct crash_uid *uid_set;
70064 +static unsigned short uid_used;
70065 +static DEFINE_SPINLOCK(gr_uid_lock);
70066 +extern rwlock_t gr_inode_lock;
70067 +extern struct acl_subject_label *
70068 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
70069 + struct acl_role_label *role);
70070 +
70071 +static inline dev_t __get_dev(const struct dentry *dentry)
70072 +{
70073 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
70074 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
70075 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
70076 + else
70077 +#endif
70078 + return dentry->d_sb->s_dev;
70079 +}
70080 +
70081 +int
70082 +gr_init_uidset(void)
70083 +{
70084 + uid_set =
70085 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
70086 + uid_used = 0;
70087 +
70088 + return uid_set ? 1 : 0;
70089 +}
70090 +
70091 +void
70092 +gr_free_uidset(void)
70093 +{
70094 + if (uid_set) {
70095 + struct crash_uid *tmpset;
70096 + spin_lock(&gr_uid_lock);
70097 + tmpset = uid_set;
70098 + uid_set = NULL;
70099 + uid_used = 0;
70100 + spin_unlock(&gr_uid_lock);
70101 + if (tmpset)
70102 + kfree(tmpset);
70103 + }
70104 +
70105 + return;
70106 +}
70107 +
70108 +int
70109 +gr_find_uid(const uid_t uid)
70110 +{
70111 + struct crash_uid *tmp = uid_set;
70112 + uid_t buid;
70113 + int low = 0, high = uid_used - 1, mid;
70114 +
70115 + while (high >= low) {
70116 + mid = (low + high) >> 1;
70117 + buid = tmp[mid].uid;
70118 + if (buid == uid)
70119 + return mid;
70120 + if (buid > uid)
70121 + high = mid - 1;
70122 + if (buid < uid)
70123 + low = mid + 1;
70124 + }
70125 +
70126 + return -1;
70127 +}
70128 +
70129 +static __inline__ void
70130 +gr_insertsort(void)
70131 +{
70132 + unsigned short i, j;
70133 + struct crash_uid index;
70134 +
70135 + for (i = 1; i < uid_used; i++) {
70136 + index = uid_set[i];
70137 + j = i;
70138 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
70139 + uid_set[j] = uid_set[j - 1];
70140 + j--;
70141 + }
70142 + uid_set[j] = index;
70143 + }
70144 +
70145 + return;
70146 +}
70147 +
70148 +static __inline__ void
70149 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
70150 +{
70151 + int loc;
70152 + uid_t uid = GR_GLOBAL_UID(kuid);
70153 +
70154 + if (uid_used == GR_UIDTABLE_MAX)
70155 + return;
70156 +
70157 + loc = gr_find_uid(uid);
70158 +
70159 + if (loc >= 0) {
70160 + uid_set[loc].expires = expires;
70161 + return;
70162 + }
70163 +
70164 + uid_set[uid_used].uid = uid;
70165 + uid_set[uid_used].expires = expires;
70166 + uid_used++;
70167 +
70168 + gr_insertsort();
70169 +
70170 + return;
70171 +}
70172 +
70173 +void
70174 +gr_remove_uid(const unsigned short loc)
70175 +{
70176 + unsigned short i;
70177 +
70178 + for (i = loc + 1; i < uid_used; i++)
70179 + uid_set[i - 1] = uid_set[i];
70180 +
70181 + uid_used--;
70182 +
70183 + return;
70184 +}
70185 +
70186 +int
70187 +gr_check_crash_uid(const kuid_t kuid)
70188 +{
70189 + int loc;
70190 + int ret = 0;
70191 + uid_t uid;
70192 +
70193 + if (unlikely(!gr_acl_is_enabled()))
70194 + return 0;
70195 +
70196 + uid = GR_GLOBAL_UID(kuid);
70197 +
70198 + spin_lock(&gr_uid_lock);
70199 + loc = gr_find_uid(uid);
70200 +
70201 + if (loc < 0)
70202 + goto out_unlock;
70203 +
70204 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
70205 + gr_remove_uid(loc);
70206 + else
70207 + ret = 1;
70208 +
70209 +out_unlock:
70210 + spin_unlock(&gr_uid_lock);
70211 + return ret;
70212 +}
70213 +
70214 +static __inline__ int
70215 +proc_is_setxid(const struct cred *cred)
70216 +{
70217 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
70218 + !uid_eq(cred->uid, cred->fsuid))
70219 + return 1;
70220 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
70221 + !gid_eq(cred->gid, cred->fsgid))
70222 + return 1;
70223 +
70224 + return 0;
70225 +}
70226 +
70227 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
70228 +
70229 +void
70230 +gr_handle_crash(struct task_struct *task, const int sig)
70231 +{
70232 + struct acl_subject_label *curr;
70233 + struct task_struct *tsk, *tsk2;
70234 + const struct cred *cred;
70235 + const struct cred *cred2;
70236 +
70237 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
70238 + return;
70239 +
70240 + if (unlikely(!gr_acl_is_enabled()))
70241 + return;
70242 +
70243 + curr = task->acl;
70244 +
70245 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
70246 + return;
70247 +
70248 + if (time_before_eq(curr->expires, get_seconds())) {
70249 + curr->expires = 0;
70250 + curr->crashes = 0;
70251 + }
70252 +
70253 + curr->crashes++;
70254 +
70255 + if (!curr->expires)
70256 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
70257 +
70258 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
70259 + time_after(curr->expires, get_seconds())) {
70260 + rcu_read_lock();
70261 + cred = __task_cred(task);
70262 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
70263 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
70264 + spin_lock(&gr_uid_lock);
70265 + gr_insert_uid(cred->uid, curr->expires);
70266 + spin_unlock(&gr_uid_lock);
70267 + curr->expires = 0;
70268 + curr->crashes = 0;
70269 + read_lock(&tasklist_lock);
70270 + do_each_thread(tsk2, tsk) {
70271 + cred2 = __task_cred(tsk);
70272 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
70273 + gr_fake_force_sig(SIGKILL, tsk);
70274 + } while_each_thread(tsk2, tsk);
70275 + read_unlock(&tasklist_lock);
70276 + } else {
70277 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
70278 + read_lock(&tasklist_lock);
70279 + read_lock(&grsec_exec_file_lock);
70280 + do_each_thread(tsk2, tsk) {
70281 + if (likely(tsk != task)) {
70282 + // if this thread has the same subject as the one that triggered
70283 + // RES_CRASH and it's the same binary, kill it
70284 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
70285 + gr_fake_force_sig(SIGKILL, tsk);
70286 + }
70287 + } while_each_thread(tsk2, tsk);
70288 + read_unlock(&grsec_exec_file_lock);
70289 + read_unlock(&tasklist_lock);
70290 + }
70291 + rcu_read_unlock();
70292 + }
70293 +
70294 + return;
70295 +}
70296 +
70297 +int
70298 +gr_check_crash_exec(const struct file *filp)
70299 +{
70300 + struct acl_subject_label *curr;
70301 +
70302 + if (unlikely(!gr_acl_is_enabled()))
70303 + return 0;
70304 +
70305 + read_lock(&gr_inode_lock);
70306 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
70307 + __get_dev(filp->f_path.dentry),
70308 + current->role);
70309 + read_unlock(&gr_inode_lock);
70310 +
70311 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
70312 + (!curr->crashes && !curr->expires))
70313 + return 0;
70314 +
70315 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
70316 + time_after(curr->expires, get_seconds()))
70317 + return 1;
70318 + else if (time_before_eq(curr->expires, get_seconds())) {
70319 + curr->crashes = 0;
70320 + curr->expires = 0;
70321 + }
70322 +
70323 + return 0;
70324 +}
70325 +
70326 +void
70327 +gr_handle_alertkill(struct task_struct *task)
70328 +{
70329 + struct acl_subject_label *curracl;
70330 + __u32 curr_ip;
70331 + struct task_struct *p, *p2;
70332 +
70333 + if (unlikely(!gr_acl_is_enabled()))
70334 + return;
70335 +
70336 + curracl = task->acl;
70337 + curr_ip = task->signal->curr_ip;
70338 +
70339 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
70340 + read_lock(&tasklist_lock);
70341 + do_each_thread(p2, p) {
70342 + if (p->signal->curr_ip == curr_ip)
70343 + gr_fake_force_sig(SIGKILL, p);
70344 + } while_each_thread(p2, p);
70345 + read_unlock(&tasklist_lock);
70346 + } else if (curracl->mode & GR_KILLPROC)
70347 + gr_fake_force_sig(SIGKILL, task);
70348 +
70349 + return;
70350 +}
70351 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
70352 new file mode 100644
70353 index 0000000..98011b0
70354 --- /dev/null
70355 +++ b/grsecurity/gracl_shm.c
70356 @@ -0,0 +1,40 @@
70357 +#include <linux/kernel.h>
70358 +#include <linux/mm.h>
70359 +#include <linux/sched.h>
70360 +#include <linux/file.h>
70361 +#include <linux/ipc.h>
70362 +#include <linux/gracl.h>
70363 +#include <linux/grsecurity.h>
70364 +#include <linux/grinternal.h>
70365 +
70366 +int
70367 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70368 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70369 +{
70370 + struct task_struct *task;
70371 +
70372 + if (!gr_acl_is_enabled())
70373 + return 1;
70374 +
70375 + rcu_read_lock();
70376 + read_lock(&tasklist_lock);
70377 +
70378 + task = find_task_by_vpid(shm_cprid);
70379 +
70380 + if (unlikely(!task))
70381 + task = find_task_by_vpid(shm_lapid);
70382 +
70383 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
70384 + (task_pid_nr(task) == shm_lapid)) &&
70385 + (task->acl->mode & GR_PROTSHM) &&
70386 + (task->acl != current->acl))) {
70387 + read_unlock(&tasklist_lock);
70388 + rcu_read_unlock();
70389 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
70390 + return 0;
70391 + }
70392 + read_unlock(&tasklist_lock);
70393 + rcu_read_unlock();
70394 +
70395 + return 1;
70396 +}
70397 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
70398 new file mode 100644
70399 index 0000000..bc0be01
70400 --- /dev/null
70401 +++ b/grsecurity/grsec_chdir.c
70402 @@ -0,0 +1,19 @@
70403 +#include <linux/kernel.h>
70404 +#include <linux/sched.h>
70405 +#include <linux/fs.h>
70406 +#include <linux/file.h>
70407 +#include <linux/grsecurity.h>
70408 +#include <linux/grinternal.h>
70409 +
70410 +void
70411 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
70412 +{
70413 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70414 + if ((grsec_enable_chdir && grsec_enable_group &&
70415 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
70416 + !grsec_enable_group)) {
70417 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
70418 + }
70419 +#endif
70420 + return;
70421 +}
70422 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
70423 new file mode 100644
70424 index 0000000..e10b319
70425 --- /dev/null
70426 +++ b/grsecurity/grsec_chroot.c
70427 @@ -0,0 +1,370 @@
70428 +#include <linux/kernel.h>
70429 +#include <linux/module.h>
70430 +#include <linux/sched.h>
70431 +#include <linux/file.h>
70432 +#include <linux/fs.h>
70433 +#include <linux/mount.h>
70434 +#include <linux/types.h>
70435 +#include "../fs/mount.h"
70436 +#include <linux/grsecurity.h>
70437 +#include <linux/grinternal.h>
70438 +
70439 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70440 +int gr_init_ran;
70441 +#endif
70442 +
70443 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
70444 +{
70445 +#ifdef CONFIG_GRKERNSEC
70446 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
70447 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
70448 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70449 + && gr_init_ran
70450 +#endif
70451 + )
70452 + task->gr_is_chrooted = 1;
70453 + else {
70454 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70455 + if (task_pid_nr(task) == 1 && !gr_init_ran)
70456 + gr_init_ran = 1;
70457 +#endif
70458 + task->gr_is_chrooted = 0;
70459 + }
70460 +
70461 + task->gr_chroot_dentry = path->dentry;
70462 +#endif
70463 + return;
70464 +}
70465 +
70466 +void gr_clear_chroot_entries(struct task_struct *task)
70467 +{
70468 +#ifdef CONFIG_GRKERNSEC
70469 + task->gr_is_chrooted = 0;
70470 + task->gr_chroot_dentry = NULL;
70471 +#endif
70472 + return;
70473 +}
70474 +
70475 +int
70476 +gr_handle_chroot_unix(const pid_t pid)
70477 +{
70478 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70479 + struct task_struct *p;
70480 +
70481 + if (unlikely(!grsec_enable_chroot_unix))
70482 + return 1;
70483 +
70484 + if (likely(!proc_is_chrooted(current)))
70485 + return 1;
70486 +
70487 + rcu_read_lock();
70488 + read_lock(&tasklist_lock);
70489 + p = find_task_by_vpid_unrestricted(pid);
70490 + if (unlikely(p && !have_same_root(current, p))) {
70491 + read_unlock(&tasklist_lock);
70492 + rcu_read_unlock();
70493 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
70494 + return 0;
70495 + }
70496 + read_unlock(&tasklist_lock);
70497 + rcu_read_unlock();
70498 +#endif
70499 + return 1;
70500 +}
70501 +
70502 +int
70503 +gr_handle_chroot_nice(void)
70504 +{
70505 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70506 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
70507 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
70508 + return -EPERM;
70509 + }
70510 +#endif
70511 + return 0;
70512 +}
70513 +
70514 +int
70515 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
70516 +{
70517 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70518 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
70519 + && proc_is_chrooted(current)) {
70520 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
70521 + return -EACCES;
70522 + }
70523 +#endif
70524 + return 0;
70525 +}
70526 +
70527 +int
70528 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
70529 +{
70530 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70531 + struct task_struct *p;
70532 + int ret = 0;
70533 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
70534 + return ret;
70535 +
70536 + read_lock(&tasklist_lock);
70537 + do_each_pid_task(pid, type, p) {
70538 + if (!have_same_root(current, p)) {
70539 + ret = 1;
70540 + goto out;
70541 + }
70542 + } while_each_pid_task(pid, type, p);
70543 +out:
70544 + read_unlock(&tasklist_lock);
70545 + return ret;
70546 +#endif
70547 + return 0;
70548 +}
70549 +
70550 +int
70551 +gr_pid_is_chrooted(struct task_struct *p)
70552 +{
70553 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70554 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
70555 + return 0;
70556 +
70557 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
70558 + !have_same_root(current, p)) {
70559 + return 1;
70560 + }
70561 +#endif
70562 + return 0;
70563 +}
70564 +
70565 +EXPORT_SYMBOL(gr_pid_is_chrooted);
70566 +
70567 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
70568 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
70569 +{
70570 + struct path path, currentroot;
70571 + int ret = 0;
70572 +
70573 + path.dentry = (struct dentry *)u_dentry;
70574 + path.mnt = (struct vfsmount *)u_mnt;
70575 + get_fs_root(current->fs, &currentroot);
70576 + if (path_is_under(&path, &currentroot))
70577 + ret = 1;
70578 + path_put(&currentroot);
70579 +
70580 + return ret;
70581 +}
70582 +#endif
70583 +
70584 +int
70585 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
70586 +{
70587 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70588 + if (!grsec_enable_chroot_fchdir)
70589 + return 1;
70590 +
70591 + if (!proc_is_chrooted(current))
70592 + return 1;
70593 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
70594 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
70595 + return 0;
70596 + }
70597 +#endif
70598 + return 1;
70599 +}
70600 +
70601 +int
70602 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70603 + const time_t shm_createtime)
70604 +{
70605 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70606 + struct task_struct *p;
70607 + time_t starttime;
70608 +
70609 + if (unlikely(!grsec_enable_chroot_shmat))
70610 + return 1;
70611 +
70612 + if (likely(!proc_is_chrooted(current)))
70613 + return 1;
70614 +
70615 + rcu_read_lock();
70616 + read_lock(&tasklist_lock);
70617 +
70618 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
70619 + starttime = p->start_time.tv_sec;
70620 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
70621 + if (have_same_root(current, p)) {
70622 + goto allow;
70623 + } else {
70624 + read_unlock(&tasklist_lock);
70625 + rcu_read_unlock();
70626 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70627 + return 0;
70628 + }
70629 + }
70630 + /* creator exited, pid reuse, fall through to next check */
70631 + }
70632 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
70633 + if (unlikely(!have_same_root(current, p))) {
70634 + read_unlock(&tasklist_lock);
70635 + rcu_read_unlock();
70636 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70637 + return 0;
70638 + }
70639 + }
70640 +
70641 +allow:
70642 + read_unlock(&tasklist_lock);
70643 + rcu_read_unlock();
70644 +#endif
70645 + return 1;
70646 +}
70647 +
70648 +void
70649 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
70650 +{
70651 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70652 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
70653 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
70654 +#endif
70655 + return;
70656 +}
70657 +
70658 +int
70659 +gr_handle_chroot_mknod(const struct dentry *dentry,
70660 + const struct vfsmount *mnt, const int mode)
70661 +{
70662 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70663 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
70664 + proc_is_chrooted(current)) {
70665 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
70666 + return -EPERM;
70667 + }
70668 +#endif
70669 + return 0;
70670 +}
70671 +
70672 +int
70673 +gr_handle_chroot_mount(const struct dentry *dentry,
70674 + const struct vfsmount *mnt, const char *dev_name)
70675 +{
70676 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70677 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
70678 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
70679 + return -EPERM;
70680 + }
70681 +#endif
70682 + return 0;
70683 +}
70684 +
70685 +int
70686 +gr_handle_chroot_pivot(void)
70687 +{
70688 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70689 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
70690 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
70691 + return -EPERM;
70692 + }
70693 +#endif
70694 + return 0;
70695 +}
70696 +
70697 +int
70698 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
70699 +{
70700 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70701 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
70702 + !gr_is_outside_chroot(dentry, mnt)) {
70703 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
70704 + return -EPERM;
70705 + }
70706 +#endif
70707 + return 0;
70708 +}
70709 +
70710 +extern const char *captab_log[];
70711 +extern int captab_log_entries;
70712 +
70713 +int
70714 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70715 +{
70716 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70717 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70718 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70719 + if (cap_raised(chroot_caps, cap)) {
70720 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
70721 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
70722 + }
70723 + return 0;
70724 + }
70725 + }
70726 +#endif
70727 + return 1;
70728 +}
70729 +
70730 +int
70731 +gr_chroot_is_capable(const int cap)
70732 +{
70733 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70734 + return gr_task_chroot_is_capable(current, current_cred(), cap);
70735 +#endif
70736 + return 1;
70737 +}
70738 +
70739 +int
70740 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
70741 +{
70742 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70743 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70744 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70745 + if (cap_raised(chroot_caps, cap)) {
70746 + return 0;
70747 + }
70748 + }
70749 +#endif
70750 + return 1;
70751 +}
70752 +
70753 +int
70754 +gr_chroot_is_capable_nolog(const int cap)
70755 +{
70756 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70757 + return gr_task_chroot_is_capable_nolog(current, cap);
70758 +#endif
70759 + return 1;
70760 +}
70761 +
70762 +int
70763 +gr_handle_chroot_sysctl(const int op)
70764 +{
70765 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70766 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
70767 + proc_is_chrooted(current))
70768 + return -EACCES;
70769 +#endif
70770 + return 0;
70771 +}
70772 +
70773 +void
70774 +gr_handle_chroot_chdir(const struct path *path)
70775 +{
70776 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70777 + if (grsec_enable_chroot_chdir)
70778 + set_fs_pwd(current->fs, path);
70779 +#endif
70780 + return;
70781 +}
70782 +
70783 +int
70784 +gr_handle_chroot_chmod(const struct dentry *dentry,
70785 + const struct vfsmount *mnt, const int mode)
70786 +{
70787 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70788 + /* allow chmod +s on directories, but not files */
70789 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
70790 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
70791 + proc_is_chrooted(current)) {
70792 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
70793 + return -EPERM;
70794 + }
70795 +#endif
70796 + return 0;
70797 +}
70798 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
70799 new file mode 100644
70800 index 0000000..52b3e30
70801 --- /dev/null
70802 +++ b/grsecurity/grsec_disabled.c
70803 @@ -0,0 +1,433 @@
70804 +#include <linux/kernel.h>
70805 +#include <linux/module.h>
70806 +#include <linux/sched.h>
70807 +#include <linux/file.h>
70808 +#include <linux/fs.h>
70809 +#include <linux/kdev_t.h>
70810 +#include <linux/net.h>
70811 +#include <linux/in.h>
70812 +#include <linux/ip.h>
70813 +#include <linux/skbuff.h>
70814 +#include <linux/sysctl.h>
70815 +
70816 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70817 +void
70818 +pax_set_initial_flags(struct linux_binprm *bprm)
70819 +{
70820 + return;
70821 +}
70822 +#endif
70823 +
70824 +#ifdef CONFIG_SYSCTL
70825 +__u32
70826 +gr_handle_sysctl(const struct ctl_table * table, const int op)
70827 +{
70828 + return 0;
70829 +}
70830 +#endif
70831 +
70832 +#ifdef CONFIG_TASKSTATS
70833 +int gr_is_taskstats_denied(int pid)
70834 +{
70835 + return 0;
70836 +}
70837 +#endif
70838 +
70839 +int
70840 +gr_acl_is_enabled(void)
70841 +{
70842 + return 0;
70843 +}
70844 +
70845 +void
70846 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
70847 +{
70848 + return;
70849 +}
70850 +
70851 +int
70852 +gr_handle_rawio(const struct inode *inode)
70853 +{
70854 + return 0;
70855 +}
70856 +
70857 +void
70858 +gr_acl_handle_psacct(struct task_struct *task, const long code)
70859 +{
70860 + return;
70861 +}
70862 +
70863 +int
70864 +gr_handle_ptrace(struct task_struct *task, const long request)
70865 +{
70866 + return 0;
70867 +}
70868 +
70869 +int
70870 +gr_handle_proc_ptrace(struct task_struct *task)
70871 +{
70872 + return 0;
70873 +}
70874 +
70875 +int
70876 +gr_set_acls(const int type)
70877 +{
70878 + return 0;
70879 +}
70880 +
70881 +int
70882 +gr_check_hidden_task(const struct task_struct *tsk)
70883 +{
70884 + return 0;
70885 +}
70886 +
70887 +int
70888 +gr_check_protected_task(const struct task_struct *task)
70889 +{
70890 + return 0;
70891 +}
70892 +
70893 +int
70894 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
70895 +{
70896 + return 0;
70897 +}
70898 +
70899 +void
70900 +gr_copy_label(struct task_struct *tsk)
70901 +{
70902 + return;
70903 +}
70904 +
70905 +void
70906 +gr_set_pax_flags(struct task_struct *task)
70907 +{
70908 + return;
70909 +}
70910 +
70911 +int
70912 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
70913 + const int unsafe_share)
70914 +{
70915 + return 0;
70916 +}
70917 +
70918 +void
70919 +gr_handle_delete(const ino_t ino, const dev_t dev)
70920 +{
70921 + return;
70922 +}
70923 +
70924 +void
70925 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
70926 +{
70927 + return;
70928 +}
70929 +
70930 +void
70931 +gr_handle_crash(struct task_struct *task, const int sig)
70932 +{
70933 + return;
70934 +}
70935 +
70936 +int
70937 +gr_check_crash_exec(const struct file *filp)
70938 +{
70939 + return 0;
70940 +}
70941 +
70942 +int
70943 +gr_check_crash_uid(const kuid_t uid)
70944 +{
70945 + return 0;
70946 +}
70947 +
70948 +void
70949 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70950 + struct dentry *old_dentry,
70951 + struct dentry *new_dentry,
70952 + struct vfsmount *mnt, const __u8 replace)
70953 +{
70954 + return;
70955 +}
70956 +
70957 +int
70958 +gr_search_socket(const int family, const int type, const int protocol)
70959 +{
70960 + return 1;
70961 +}
70962 +
70963 +int
70964 +gr_search_connectbind(const int mode, const struct socket *sock,
70965 + const struct sockaddr_in *addr)
70966 +{
70967 + return 0;
70968 +}
70969 +
70970 +void
70971 +gr_handle_alertkill(struct task_struct *task)
70972 +{
70973 + return;
70974 +}
70975 +
70976 +__u32
70977 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
70978 +{
70979 + return 1;
70980 +}
70981 +
70982 +__u32
70983 +gr_acl_handle_hidden_file(const struct dentry * dentry,
70984 + const struct vfsmount * mnt)
70985 +{
70986 + return 1;
70987 +}
70988 +
70989 +__u32
70990 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
70991 + int acc_mode)
70992 +{
70993 + return 1;
70994 +}
70995 +
70996 +__u32
70997 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70998 +{
70999 + return 1;
71000 +}
71001 +
71002 +__u32
71003 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
71004 +{
71005 + return 1;
71006 +}
71007 +
71008 +int
71009 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
71010 + unsigned int *vm_flags)
71011 +{
71012 + return 1;
71013 +}
71014 +
71015 +__u32
71016 +gr_acl_handle_truncate(const struct dentry * dentry,
71017 + const struct vfsmount * mnt)
71018 +{
71019 + return 1;
71020 +}
71021 +
71022 +__u32
71023 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
71024 +{
71025 + return 1;
71026 +}
71027 +
71028 +__u32
71029 +gr_acl_handle_access(const struct dentry * dentry,
71030 + const struct vfsmount * mnt, const int fmode)
71031 +{
71032 + return 1;
71033 +}
71034 +
71035 +__u32
71036 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
71037 + umode_t *mode)
71038 +{
71039 + return 1;
71040 +}
71041 +
71042 +__u32
71043 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
71044 +{
71045 + return 1;
71046 +}
71047 +
71048 +__u32
71049 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
71050 +{
71051 + return 1;
71052 +}
71053 +
71054 +__u32
71055 +gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
71056 +{
71057 + return 1;
71058 +}
71059 +
71060 +void
71061 +grsecurity_init(void)
71062 +{
71063 + return;
71064 +}
71065 +
71066 +umode_t gr_acl_umask(void)
71067 +{
71068 + return 0;
71069 +}
71070 +
71071 +__u32
71072 +gr_acl_handle_mknod(const struct dentry * new_dentry,
71073 + const struct dentry * parent_dentry,
71074 + const struct vfsmount * parent_mnt,
71075 + const int mode)
71076 +{
71077 + return 1;
71078 +}
71079 +
71080 +__u32
71081 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
71082 + const struct dentry * parent_dentry,
71083 + const struct vfsmount * parent_mnt)
71084 +{
71085 + return 1;
71086 +}
71087 +
71088 +__u32
71089 +gr_acl_handle_symlink(const struct dentry * new_dentry,
71090 + const struct dentry * parent_dentry,
71091 + const struct vfsmount * parent_mnt, const struct filename *from)
71092 +{
71093 + return 1;
71094 +}
71095 +
71096 +__u32
71097 +gr_acl_handle_link(const struct dentry * new_dentry,
71098 + const struct dentry * parent_dentry,
71099 + const struct vfsmount * parent_mnt,
71100 + const struct dentry * old_dentry,
71101 + const struct vfsmount * old_mnt, const struct filename *to)
71102 +{
71103 + return 1;
71104 +}
71105 +
71106 +int
71107 +gr_acl_handle_rename(const struct dentry *new_dentry,
71108 + const struct dentry *parent_dentry,
71109 + const struct vfsmount *parent_mnt,
71110 + const struct dentry *old_dentry,
71111 + const struct inode *old_parent_inode,
71112 + const struct vfsmount *old_mnt, const struct filename *newname)
71113 +{
71114 + return 0;
71115 +}
71116 +
71117 +int
71118 +gr_acl_handle_filldir(const struct file *file, const char *name,
71119 + const int namelen, const ino_t ino)
71120 +{
71121 + return 1;
71122 +}
71123 +
71124 +int
71125 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
71126 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
71127 +{
71128 + return 1;
71129 +}
71130 +
71131 +int
71132 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
71133 +{
71134 + return 0;
71135 +}
71136 +
71137 +int
71138 +gr_search_accept(const struct socket *sock)
71139 +{
71140 + return 0;
71141 +}
71142 +
71143 +int
71144 +gr_search_listen(const struct socket *sock)
71145 +{
71146 + return 0;
71147 +}
71148 +
71149 +int
71150 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
71151 +{
71152 + return 0;
71153 +}
71154 +
71155 +__u32
71156 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
71157 +{
71158 + return 1;
71159 +}
71160 +
71161 +__u32
71162 +gr_acl_handle_creat(const struct dentry * dentry,
71163 + const struct dentry * p_dentry,
71164 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
71165 + const int imode)
71166 +{
71167 + return 1;
71168 +}
71169 +
71170 +void
71171 +gr_acl_handle_exit(void)
71172 +{
71173 + return;
71174 +}
71175 +
71176 +int
71177 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
71178 +{
71179 + return 1;
71180 +}
71181 +
71182 +void
71183 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
71184 +{
71185 + return;
71186 +}
71187 +
71188 +int
71189 +gr_acl_handle_procpidmem(const struct task_struct *task)
71190 +{
71191 + return 0;
71192 +}
71193 +
71194 +int
71195 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
71196 +{
71197 + return 0;
71198 +}
71199 +
71200 +int
71201 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
71202 +{
71203 + return 0;
71204 +}
71205 +
71206 +int
71207 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
71208 +{
71209 + return 0;
71210 +}
71211 +
71212 +int
71213 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
71214 +{
71215 + return 0;
71216 +}
71217 +
71218 +int gr_acl_enable_at_secure(void)
71219 +{
71220 + return 0;
71221 +}
71222 +
71223 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
71224 +{
71225 + return dentry->d_sb->s_dev;
71226 +}
71227 +
71228 +void gr_put_exec_file(struct task_struct *task)
71229 +{
71230 + return;
71231 +}
71232 +
71233 +#ifdef CONFIG_SECURITY
71234 +EXPORT_SYMBOL(gr_check_user_change);
71235 +EXPORT_SYMBOL(gr_check_group_change);
71236 +#endif
71237 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
71238 new file mode 100644
71239 index 0000000..387032b
71240 --- /dev/null
71241 +++ b/grsecurity/grsec_exec.c
71242 @@ -0,0 +1,187 @@
71243 +#include <linux/kernel.h>
71244 +#include <linux/sched.h>
71245 +#include <linux/file.h>
71246 +#include <linux/binfmts.h>
71247 +#include <linux/fs.h>
71248 +#include <linux/types.h>
71249 +#include <linux/grdefs.h>
71250 +#include <linux/grsecurity.h>
71251 +#include <linux/grinternal.h>
71252 +#include <linux/capability.h>
71253 +#include <linux/module.h>
71254 +#include <linux/compat.h>
71255 +
71256 +#include <asm/uaccess.h>
71257 +
71258 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71259 +static char gr_exec_arg_buf[132];
71260 +static DEFINE_MUTEX(gr_exec_arg_mutex);
71261 +#endif
71262 +
71263 +struct user_arg_ptr {
71264 +#ifdef CONFIG_COMPAT
71265 + bool is_compat;
71266 +#endif
71267 + union {
71268 + const char __user *const __user *native;
71269 +#ifdef CONFIG_COMPAT
71270 + const compat_uptr_t __user *compat;
71271 +#endif
71272 + } ptr;
71273 +};
71274 +
71275 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
71276 +
71277 +void
71278 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
71279 +{
71280 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71281 + char *grarg = gr_exec_arg_buf;
71282 + unsigned int i, x, execlen = 0;
71283 + char c;
71284 +
71285 + if (!((grsec_enable_execlog && grsec_enable_group &&
71286 + in_group_p(grsec_audit_gid))
71287 + || (grsec_enable_execlog && !grsec_enable_group)))
71288 + return;
71289 +
71290 + mutex_lock(&gr_exec_arg_mutex);
71291 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
71292 +
71293 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
71294 + const char __user *p;
71295 + unsigned int len;
71296 +
71297 + p = get_user_arg_ptr(argv, i);
71298 + if (IS_ERR(p))
71299 + goto log;
71300 +
71301 + len = strnlen_user(p, 128 - execlen);
71302 + if (len > 128 - execlen)
71303 + len = 128 - execlen;
71304 + else if (len > 0)
71305 + len--;
71306 + if (copy_from_user(grarg + execlen, p, len))
71307 + goto log;
71308 +
71309 + /* rewrite unprintable characters */
71310 + for (x = 0; x < len; x++) {
71311 + c = *(grarg + execlen + x);
71312 + if (c < 32 || c > 126)
71313 + *(grarg + execlen + x) = ' ';
71314 + }
71315 +
71316 + execlen += len;
71317 + *(grarg + execlen) = ' ';
71318 + *(grarg + execlen + 1) = '\0';
71319 + execlen++;
71320 + }
71321 +
71322 + log:
71323 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
71324 + bprm->file->f_path.mnt, grarg);
71325 + mutex_unlock(&gr_exec_arg_mutex);
71326 +#endif
71327 + return;
71328 +}
71329 +
71330 +#ifdef CONFIG_GRKERNSEC
71331 +extern int gr_acl_is_capable(const int cap);
71332 +extern int gr_acl_is_capable_nolog(const int cap);
71333 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
71334 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
71335 +extern int gr_chroot_is_capable(const int cap);
71336 +extern int gr_chroot_is_capable_nolog(const int cap);
71337 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
71338 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
71339 +#endif
71340 +
71341 +const char *captab_log[] = {
71342 + "CAP_CHOWN",
71343 + "CAP_DAC_OVERRIDE",
71344 + "CAP_DAC_READ_SEARCH",
71345 + "CAP_FOWNER",
71346 + "CAP_FSETID",
71347 + "CAP_KILL",
71348 + "CAP_SETGID",
71349 + "CAP_SETUID",
71350 + "CAP_SETPCAP",
71351 + "CAP_LINUX_IMMUTABLE",
71352 + "CAP_NET_BIND_SERVICE",
71353 + "CAP_NET_BROADCAST",
71354 + "CAP_NET_ADMIN",
71355 + "CAP_NET_RAW",
71356 + "CAP_IPC_LOCK",
71357 + "CAP_IPC_OWNER",
71358 + "CAP_SYS_MODULE",
71359 + "CAP_SYS_RAWIO",
71360 + "CAP_SYS_CHROOT",
71361 + "CAP_SYS_PTRACE",
71362 + "CAP_SYS_PACCT",
71363 + "CAP_SYS_ADMIN",
71364 + "CAP_SYS_BOOT",
71365 + "CAP_SYS_NICE",
71366 + "CAP_SYS_RESOURCE",
71367 + "CAP_SYS_TIME",
71368 + "CAP_SYS_TTY_CONFIG",
71369 + "CAP_MKNOD",
71370 + "CAP_LEASE",
71371 + "CAP_AUDIT_WRITE",
71372 + "CAP_AUDIT_CONTROL",
71373 + "CAP_SETFCAP",
71374 + "CAP_MAC_OVERRIDE",
71375 + "CAP_MAC_ADMIN",
71376 + "CAP_SYSLOG",
71377 + "CAP_WAKE_ALARM"
71378 +};
71379 +
71380 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
71381 +
71382 +int gr_is_capable(const int cap)
71383 +{
71384 +#ifdef CONFIG_GRKERNSEC
71385 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
71386 + return 1;
71387 + return 0;
71388 +#else
71389 + return 1;
71390 +#endif
71391 +}
71392 +
71393 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
71394 +{
71395 +#ifdef CONFIG_GRKERNSEC
71396 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
71397 + return 1;
71398 + return 0;
71399 +#else
71400 + return 1;
71401 +#endif
71402 +}
71403 +
71404 +int gr_is_capable_nolog(const int cap)
71405 +{
71406 +#ifdef CONFIG_GRKERNSEC
71407 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
71408 + return 1;
71409 + return 0;
71410 +#else
71411 + return 1;
71412 +#endif
71413 +}
71414 +
71415 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
71416 +{
71417 +#ifdef CONFIG_GRKERNSEC
71418 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
71419 + return 1;
71420 + return 0;
71421 +#else
71422 + return 1;
71423 +#endif
71424 +}
71425 +
71426 +EXPORT_SYMBOL(gr_is_capable);
71427 +EXPORT_SYMBOL(gr_is_capable_nolog);
71428 +EXPORT_SYMBOL(gr_task_is_capable);
71429 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
71430 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
71431 new file mode 100644
71432 index 0000000..06cc6ea
71433 --- /dev/null
71434 +++ b/grsecurity/grsec_fifo.c
71435 @@ -0,0 +1,24 @@
71436 +#include <linux/kernel.h>
71437 +#include <linux/sched.h>
71438 +#include <linux/fs.h>
71439 +#include <linux/file.h>
71440 +#include <linux/grinternal.h>
71441 +
71442 +int
71443 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
71444 + const struct dentry *dir, const int flag, const int acc_mode)
71445 +{
71446 +#ifdef CONFIG_GRKERNSEC_FIFO
71447 + const struct cred *cred = current_cred();
71448 +
71449 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
71450 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
71451 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
71452 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
71453 + if (!inode_permission(dentry->d_inode, acc_mode))
71454 + 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));
71455 + return -EACCES;
71456 + }
71457 +#endif
71458 + return 0;
71459 +}
71460 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
71461 new file mode 100644
71462 index 0000000..8ca18bf
71463 --- /dev/null
71464 +++ b/grsecurity/grsec_fork.c
71465 @@ -0,0 +1,23 @@
71466 +#include <linux/kernel.h>
71467 +#include <linux/sched.h>
71468 +#include <linux/grsecurity.h>
71469 +#include <linux/grinternal.h>
71470 +#include <linux/errno.h>
71471 +
71472 +void
71473 +gr_log_forkfail(const int retval)
71474 +{
71475 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71476 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
71477 + switch (retval) {
71478 + case -EAGAIN:
71479 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
71480 + break;
71481 + case -ENOMEM:
71482 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
71483 + break;
71484 + }
71485 + }
71486 +#endif
71487 + return;
71488 +}
71489 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
71490 new file mode 100644
71491 index 0000000..a88e901
71492 --- /dev/null
71493 +++ b/grsecurity/grsec_init.c
71494 @@ -0,0 +1,272 @@
71495 +#include <linux/kernel.h>
71496 +#include <linux/sched.h>
71497 +#include <linux/mm.h>
71498 +#include <linux/gracl.h>
71499 +#include <linux/slab.h>
71500 +#include <linux/vmalloc.h>
71501 +#include <linux/percpu.h>
71502 +#include <linux/module.h>
71503 +
71504 +int grsec_enable_ptrace_readexec;
71505 +int grsec_enable_setxid;
71506 +int grsec_enable_symlinkown;
71507 +kgid_t grsec_symlinkown_gid;
71508 +int grsec_enable_brute;
71509 +int grsec_enable_link;
71510 +int grsec_enable_dmesg;
71511 +int grsec_enable_harden_ptrace;
71512 +int grsec_enable_harden_ipc;
71513 +int grsec_enable_fifo;
71514 +int grsec_enable_execlog;
71515 +int grsec_enable_signal;
71516 +int grsec_enable_forkfail;
71517 +int grsec_enable_audit_ptrace;
71518 +int grsec_enable_time;
71519 +int grsec_enable_group;
71520 +kgid_t grsec_audit_gid;
71521 +int grsec_enable_chdir;
71522 +int grsec_enable_mount;
71523 +int grsec_enable_rofs;
71524 +int grsec_deny_new_usb;
71525 +int grsec_enable_chroot_findtask;
71526 +int grsec_enable_chroot_mount;
71527 +int grsec_enable_chroot_shmat;
71528 +int grsec_enable_chroot_fchdir;
71529 +int grsec_enable_chroot_double;
71530 +int grsec_enable_chroot_pivot;
71531 +int grsec_enable_chroot_chdir;
71532 +int grsec_enable_chroot_chmod;
71533 +int grsec_enable_chroot_mknod;
71534 +int grsec_enable_chroot_nice;
71535 +int grsec_enable_chroot_execlog;
71536 +int grsec_enable_chroot_caps;
71537 +int grsec_enable_chroot_sysctl;
71538 +int grsec_enable_chroot_unix;
71539 +int grsec_enable_tpe;
71540 +kgid_t grsec_tpe_gid;
71541 +int grsec_enable_blackhole;
71542 +#ifdef CONFIG_IPV6_MODULE
71543 +EXPORT_SYMBOL(grsec_enable_blackhole);
71544 +#endif
71545 +int grsec_lastack_retries;
71546 +int grsec_enable_tpe_all;
71547 +int grsec_enable_tpe_invert;
71548 +int grsec_enable_socket_all;
71549 +kgid_t grsec_socket_all_gid;
71550 +int grsec_enable_socket_client;
71551 +kgid_t grsec_socket_client_gid;
71552 +int grsec_enable_socket_server;
71553 +kgid_t grsec_socket_server_gid;
71554 +int grsec_resource_logging;
71555 +int grsec_disable_privio;
71556 +int grsec_enable_log_rwxmaps;
71557 +int grsec_lock;
71558 +
71559 +DEFINE_SPINLOCK(grsec_alert_lock);
71560 +unsigned long grsec_alert_wtime = 0;
71561 +unsigned long grsec_alert_fyet = 0;
71562 +
71563 +DEFINE_SPINLOCK(grsec_audit_lock);
71564 +
71565 +DEFINE_RWLOCK(grsec_exec_file_lock);
71566 +
71567 +char *gr_shared_page[4];
71568 +
71569 +char *gr_alert_log_fmt;
71570 +char *gr_audit_log_fmt;
71571 +char *gr_alert_log_buf;
71572 +char *gr_audit_log_buf;
71573 +
71574 +void __init
71575 +grsecurity_init(void)
71576 +{
71577 + int j;
71578 + /* create the per-cpu shared pages */
71579 +
71580 +#ifdef CONFIG_X86
71581 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
71582 +#endif
71583 +
71584 + for (j = 0; j < 4; j++) {
71585 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
71586 + if (gr_shared_page[j] == NULL) {
71587 + panic("Unable to allocate grsecurity shared page");
71588 + return;
71589 + }
71590 + }
71591 +
71592 + /* allocate log buffers */
71593 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
71594 + if (!gr_alert_log_fmt) {
71595 + panic("Unable to allocate grsecurity alert log format buffer");
71596 + return;
71597 + }
71598 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
71599 + if (!gr_audit_log_fmt) {
71600 + panic("Unable to allocate grsecurity audit log format buffer");
71601 + return;
71602 + }
71603 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71604 + if (!gr_alert_log_buf) {
71605 + panic("Unable to allocate grsecurity alert log buffer");
71606 + return;
71607 + }
71608 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71609 + if (!gr_audit_log_buf) {
71610 + panic("Unable to allocate grsecurity audit log buffer");
71611 + return;
71612 + }
71613 +
71614 +#ifdef CONFIG_GRKERNSEC_IO
71615 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
71616 + grsec_disable_privio = 1;
71617 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71618 + grsec_disable_privio = 1;
71619 +#else
71620 + grsec_disable_privio = 0;
71621 +#endif
71622 +#endif
71623 +
71624 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71625 + /* for backward compatibility, tpe_invert always defaults to on if
71626 + enabled in the kernel
71627 + */
71628 + grsec_enable_tpe_invert = 1;
71629 +#endif
71630 +
71631 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71632 +#ifndef CONFIG_GRKERNSEC_SYSCTL
71633 + grsec_lock = 1;
71634 +#endif
71635 +
71636 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71637 + grsec_enable_log_rwxmaps = 1;
71638 +#endif
71639 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71640 + grsec_enable_group = 1;
71641 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
71642 +#endif
71643 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71644 + grsec_enable_ptrace_readexec = 1;
71645 +#endif
71646 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71647 + grsec_enable_chdir = 1;
71648 +#endif
71649 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71650 + grsec_enable_harden_ptrace = 1;
71651 +#endif
71652 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71653 + grsec_enable_harden_ipc = 1;
71654 +#endif
71655 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71656 + grsec_enable_mount = 1;
71657 +#endif
71658 +#ifdef CONFIG_GRKERNSEC_LINK
71659 + grsec_enable_link = 1;
71660 +#endif
71661 +#ifdef CONFIG_GRKERNSEC_BRUTE
71662 + grsec_enable_brute = 1;
71663 +#endif
71664 +#ifdef CONFIG_GRKERNSEC_DMESG
71665 + grsec_enable_dmesg = 1;
71666 +#endif
71667 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71668 + grsec_enable_blackhole = 1;
71669 + grsec_lastack_retries = 4;
71670 +#endif
71671 +#ifdef CONFIG_GRKERNSEC_FIFO
71672 + grsec_enable_fifo = 1;
71673 +#endif
71674 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71675 + grsec_enable_execlog = 1;
71676 +#endif
71677 +#ifdef CONFIG_GRKERNSEC_SETXID
71678 + grsec_enable_setxid = 1;
71679 +#endif
71680 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71681 + grsec_enable_signal = 1;
71682 +#endif
71683 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71684 + grsec_enable_forkfail = 1;
71685 +#endif
71686 +#ifdef CONFIG_GRKERNSEC_TIME
71687 + grsec_enable_time = 1;
71688 +#endif
71689 +#ifdef CONFIG_GRKERNSEC_RESLOG
71690 + grsec_resource_logging = 1;
71691 +#endif
71692 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71693 + grsec_enable_chroot_findtask = 1;
71694 +#endif
71695 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71696 + grsec_enable_chroot_unix = 1;
71697 +#endif
71698 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71699 + grsec_enable_chroot_mount = 1;
71700 +#endif
71701 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71702 + grsec_enable_chroot_fchdir = 1;
71703 +#endif
71704 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71705 + grsec_enable_chroot_shmat = 1;
71706 +#endif
71707 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71708 + grsec_enable_audit_ptrace = 1;
71709 +#endif
71710 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71711 + grsec_enable_chroot_double = 1;
71712 +#endif
71713 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71714 + grsec_enable_chroot_pivot = 1;
71715 +#endif
71716 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71717 + grsec_enable_chroot_chdir = 1;
71718 +#endif
71719 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71720 + grsec_enable_chroot_chmod = 1;
71721 +#endif
71722 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71723 + grsec_enable_chroot_mknod = 1;
71724 +#endif
71725 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71726 + grsec_enable_chroot_nice = 1;
71727 +#endif
71728 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71729 + grsec_enable_chroot_execlog = 1;
71730 +#endif
71731 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71732 + grsec_enable_chroot_caps = 1;
71733 +#endif
71734 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71735 + grsec_enable_chroot_sysctl = 1;
71736 +#endif
71737 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71738 + grsec_enable_symlinkown = 1;
71739 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
71740 +#endif
71741 +#ifdef CONFIG_GRKERNSEC_TPE
71742 + grsec_enable_tpe = 1;
71743 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
71744 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71745 + grsec_enable_tpe_all = 1;
71746 +#endif
71747 +#endif
71748 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71749 + grsec_enable_socket_all = 1;
71750 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
71751 +#endif
71752 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71753 + grsec_enable_socket_client = 1;
71754 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
71755 +#endif
71756 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71757 + grsec_enable_socket_server = 1;
71758 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
71759 +#endif
71760 +#endif
71761 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
71762 + grsec_deny_new_usb = 1;
71763 +#endif
71764 +
71765 + return;
71766 +}
71767 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
71768 new file mode 100644
71769 index 0000000..78d1680
71770 --- /dev/null
71771 +++ b/grsecurity/grsec_ipc.c
71772 @@ -0,0 +1,48 @@
71773 +#include <linux/kernel.h>
71774 +#include <linux/mm.h>
71775 +#include <linux/sched.h>
71776 +#include <linux/file.h>
71777 +#include <linux/ipc.h>
71778 +#include <linux/ipc_namespace.h>
71779 +#include <linux/grsecurity.h>
71780 +#include <linux/grinternal.h>
71781 +
71782 +int
71783 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
71784 +{
71785 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71786 + int write;
71787 + int orig_granted_mode;
71788 + kuid_t euid;
71789 + kgid_t egid;
71790 +
71791 + if (!grsec_enable_harden_ipc)
71792 + return 0;
71793 +
71794 + euid = current_euid();
71795 + egid = current_egid();
71796 +
71797 + write = requested_mode & 00002;
71798 + orig_granted_mode = ipcp->mode;
71799 +
71800 + if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
71801 + orig_granted_mode >>= 6;
71802 + else {
71803 + /* if likely wrong permissions, lock to user */
71804 + if (orig_granted_mode & 0007)
71805 + orig_granted_mode = 0;
71806 + /* otherwise do a egid-only check */
71807 + else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
71808 + orig_granted_mode >>= 3;
71809 + /* otherwise, no access */
71810 + else
71811 + orig_granted_mode = 0;
71812 + }
71813 + if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
71814 + !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
71815 + gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
71816 + return 0;
71817 + }
71818 +#endif
71819 + return 1;
71820 +}
71821 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
71822 new file mode 100644
71823 index 0000000..5e05e20
71824 --- /dev/null
71825 +++ b/grsecurity/grsec_link.c
71826 @@ -0,0 +1,58 @@
71827 +#include <linux/kernel.h>
71828 +#include <linux/sched.h>
71829 +#include <linux/fs.h>
71830 +#include <linux/file.h>
71831 +#include <linux/grinternal.h>
71832 +
71833 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
71834 +{
71835 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71836 + const struct inode *link_inode = link->dentry->d_inode;
71837 +
71838 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
71839 + /* ignore root-owned links, e.g. /proc/self */
71840 + gr_is_global_nonroot(link_inode->i_uid) && target &&
71841 + !uid_eq(link_inode->i_uid, target->i_uid)) {
71842 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
71843 + return 1;
71844 + }
71845 +#endif
71846 + return 0;
71847 +}
71848 +
71849 +int
71850 +gr_handle_follow_link(const struct inode *parent,
71851 + const struct inode *inode,
71852 + const struct dentry *dentry, const struct vfsmount *mnt)
71853 +{
71854 +#ifdef CONFIG_GRKERNSEC_LINK
71855 + const struct cred *cred = current_cred();
71856 +
71857 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
71858 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
71859 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
71860 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
71861 + return -EACCES;
71862 + }
71863 +#endif
71864 + return 0;
71865 +}
71866 +
71867 +int
71868 +gr_handle_hardlink(const struct dentry *dentry,
71869 + const struct vfsmount *mnt,
71870 + struct inode *inode, const int mode, const struct filename *to)
71871 +{
71872 +#ifdef CONFIG_GRKERNSEC_LINK
71873 + const struct cred *cred = current_cred();
71874 +
71875 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
71876 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
71877 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
71878 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
71879 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
71880 + return -EPERM;
71881 + }
71882 +#endif
71883 + return 0;
71884 +}
71885 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
71886 new file mode 100644
71887 index 0000000..dbe0a6b
71888 --- /dev/null
71889 +++ b/grsecurity/grsec_log.c
71890 @@ -0,0 +1,341 @@
71891 +#include <linux/kernel.h>
71892 +#include <linux/sched.h>
71893 +#include <linux/file.h>
71894 +#include <linux/tty.h>
71895 +#include <linux/fs.h>
71896 +#include <linux/mm.h>
71897 +#include <linux/grinternal.h>
71898 +
71899 +#ifdef CONFIG_TREE_PREEMPT_RCU
71900 +#define DISABLE_PREEMPT() preempt_disable()
71901 +#define ENABLE_PREEMPT() preempt_enable()
71902 +#else
71903 +#define DISABLE_PREEMPT()
71904 +#define ENABLE_PREEMPT()
71905 +#endif
71906 +
71907 +#define BEGIN_LOCKS(x) \
71908 + DISABLE_PREEMPT(); \
71909 + rcu_read_lock(); \
71910 + read_lock(&tasklist_lock); \
71911 + read_lock(&grsec_exec_file_lock); \
71912 + if (x != GR_DO_AUDIT) \
71913 + spin_lock(&grsec_alert_lock); \
71914 + else \
71915 + spin_lock(&grsec_audit_lock)
71916 +
71917 +#define END_LOCKS(x) \
71918 + if (x != GR_DO_AUDIT) \
71919 + spin_unlock(&grsec_alert_lock); \
71920 + else \
71921 + spin_unlock(&grsec_audit_lock); \
71922 + read_unlock(&grsec_exec_file_lock); \
71923 + read_unlock(&tasklist_lock); \
71924 + rcu_read_unlock(); \
71925 + ENABLE_PREEMPT(); \
71926 + if (x == GR_DONT_AUDIT) \
71927 + gr_handle_alertkill(current)
71928 +
71929 +enum {
71930 + FLOODING,
71931 + NO_FLOODING
71932 +};
71933 +
71934 +extern char *gr_alert_log_fmt;
71935 +extern char *gr_audit_log_fmt;
71936 +extern char *gr_alert_log_buf;
71937 +extern char *gr_audit_log_buf;
71938 +
71939 +static int gr_log_start(int audit)
71940 +{
71941 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
71942 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
71943 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71944 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
71945 + unsigned long curr_secs = get_seconds();
71946 +
71947 + if (audit == GR_DO_AUDIT)
71948 + goto set_fmt;
71949 +
71950 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
71951 + grsec_alert_wtime = curr_secs;
71952 + grsec_alert_fyet = 0;
71953 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
71954 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
71955 + grsec_alert_fyet++;
71956 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
71957 + grsec_alert_wtime = curr_secs;
71958 + grsec_alert_fyet++;
71959 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
71960 + return FLOODING;
71961 + }
71962 + else return FLOODING;
71963 +
71964 +set_fmt:
71965 +#endif
71966 + memset(buf, 0, PAGE_SIZE);
71967 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
71968 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
71969 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71970 + } else if (current->signal->curr_ip) {
71971 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
71972 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
71973 + } else if (gr_acl_is_enabled()) {
71974 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
71975 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71976 + } else {
71977 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
71978 + strcpy(buf, fmt);
71979 + }
71980 +
71981 + return NO_FLOODING;
71982 +}
71983 +
71984 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71985 + __attribute__ ((format (printf, 2, 0)));
71986 +
71987 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71988 +{
71989 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71990 + unsigned int len = strlen(buf);
71991 +
71992 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71993 +
71994 + return;
71995 +}
71996 +
71997 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71998 + __attribute__ ((format (printf, 2, 3)));
71999 +
72000 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
72001 +{
72002 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
72003 + unsigned int len = strlen(buf);
72004 + va_list ap;
72005 +
72006 + va_start(ap, msg);
72007 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
72008 + va_end(ap);
72009 +
72010 + return;
72011 +}
72012 +
72013 +static void gr_log_end(int audit, int append_default)
72014 +{
72015 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
72016 + if (append_default) {
72017 + struct task_struct *task = current;
72018 + struct task_struct *parent = task->real_parent;
72019 + const struct cred *cred = __task_cred(task);
72020 + const struct cred *pcred = __task_cred(parent);
72021 + unsigned int len = strlen(buf);
72022 +
72023 + 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));
72024 + }
72025 +
72026 + printk("%s\n", buf);
72027 +
72028 + return;
72029 +}
72030 +
72031 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
72032 +{
72033 + int logtype;
72034 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
72035 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
72036 + void *voidptr = NULL;
72037 + int num1 = 0, num2 = 0;
72038 + unsigned long ulong1 = 0, ulong2 = 0;
72039 + struct dentry *dentry = NULL;
72040 + struct vfsmount *mnt = NULL;
72041 + struct file *file = NULL;
72042 + struct task_struct *task = NULL;
72043 + struct vm_area_struct *vma = NULL;
72044 + const struct cred *cred, *pcred;
72045 + va_list ap;
72046 +
72047 + BEGIN_LOCKS(audit);
72048 + logtype = gr_log_start(audit);
72049 + if (logtype == FLOODING) {
72050 + END_LOCKS(audit);
72051 + return;
72052 + }
72053 + va_start(ap, argtypes);
72054 + switch (argtypes) {
72055 + case GR_TTYSNIFF:
72056 + task = va_arg(ap, struct task_struct *);
72057 + 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));
72058 + break;
72059 + case GR_SYSCTL_HIDDEN:
72060 + str1 = va_arg(ap, char *);
72061 + gr_log_middle_varargs(audit, msg, result, str1);
72062 + break;
72063 + case GR_RBAC:
72064 + dentry = va_arg(ap, struct dentry *);
72065 + mnt = va_arg(ap, struct vfsmount *);
72066 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
72067 + break;
72068 + case GR_RBAC_STR:
72069 + dentry = va_arg(ap, struct dentry *);
72070 + mnt = va_arg(ap, struct vfsmount *);
72071 + str1 = va_arg(ap, char *);
72072 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
72073 + break;
72074 + case GR_STR_RBAC:
72075 + str1 = va_arg(ap, char *);
72076 + dentry = va_arg(ap, struct dentry *);
72077 + mnt = va_arg(ap, struct vfsmount *);
72078 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
72079 + break;
72080 + case GR_RBAC_MODE2:
72081 + dentry = va_arg(ap, struct dentry *);
72082 + mnt = va_arg(ap, struct vfsmount *);
72083 + str1 = va_arg(ap, char *);
72084 + str2 = va_arg(ap, char *);
72085 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
72086 + break;
72087 + case GR_RBAC_MODE3:
72088 + dentry = va_arg(ap, struct dentry *);
72089 + mnt = va_arg(ap, struct vfsmount *);
72090 + str1 = va_arg(ap, char *);
72091 + str2 = va_arg(ap, char *);
72092 + str3 = va_arg(ap, char *);
72093 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
72094 + break;
72095 + case GR_FILENAME:
72096 + dentry = va_arg(ap, struct dentry *);
72097 + mnt = va_arg(ap, struct vfsmount *);
72098 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
72099 + break;
72100 + case GR_STR_FILENAME:
72101 + str1 = va_arg(ap, char *);
72102 + dentry = va_arg(ap, struct dentry *);
72103 + mnt = va_arg(ap, struct vfsmount *);
72104 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
72105 + break;
72106 + case GR_FILENAME_STR:
72107 + dentry = va_arg(ap, struct dentry *);
72108 + mnt = va_arg(ap, struct vfsmount *);
72109 + str1 = va_arg(ap, char *);
72110 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
72111 + break;
72112 + case GR_FILENAME_TWO_INT:
72113 + dentry = va_arg(ap, struct dentry *);
72114 + mnt = va_arg(ap, struct vfsmount *);
72115 + num1 = va_arg(ap, int);
72116 + num2 = va_arg(ap, int);
72117 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
72118 + break;
72119 + case GR_FILENAME_TWO_INT_STR:
72120 + dentry = va_arg(ap, struct dentry *);
72121 + mnt = va_arg(ap, struct vfsmount *);
72122 + num1 = va_arg(ap, int);
72123 + num2 = va_arg(ap, int);
72124 + str1 = va_arg(ap, char *);
72125 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
72126 + break;
72127 + case GR_TEXTREL:
72128 + file = va_arg(ap, struct file *);
72129 + ulong1 = va_arg(ap, unsigned long);
72130 + ulong2 = va_arg(ap, unsigned long);
72131 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
72132 + break;
72133 + case GR_PTRACE:
72134 + task = va_arg(ap, struct task_struct *);
72135 + 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));
72136 + break;
72137 + case GR_RESOURCE:
72138 + task = va_arg(ap, struct task_struct *);
72139 + cred = __task_cred(task);
72140 + pcred = __task_cred(task->real_parent);
72141 + ulong1 = va_arg(ap, unsigned long);
72142 + str1 = va_arg(ap, char *);
72143 + ulong2 = va_arg(ap, unsigned long);
72144 + 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));
72145 + break;
72146 + case GR_CAP:
72147 + task = va_arg(ap, struct task_struct *);
72148 + cred = __task_cred(task);
72149 + pcred = __task_cred(task->real_parent);
72150 + str1 = va_arg(ap, char *);
72151 + 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));
72152 + break;
72153 + case GR_SIG:
72154 + str1 = va_arg(ap, char *);
72155 + voidptr = va_arg(ap, void *);
72156 + gr_log_middle_varargs(audit, msg, str1, voidptr);
72157 + break;
72158 + case GR_SIG2:
72159 + task = va_arg(ap, struct task_struct *);
72160 + cred = __task_cred(task);
72161 + pcred = __task_cred(task->real_parent);
72162 + num1 = va_arg(ap, int);
72163 + 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));
72164 + break;
72165 + case GR_CRASH1:
72166 + task = va_arg(ap, struct task_struct *);
72167 + cred = __task_cred(task);
72168 + pcred = __task_cred(task->real_parent);
72169 + ulong1 = va_arg(ap, unsigned long);
72170 + 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);
72171 + break;
72172 + case GR_CRASH2:
72173 + task = va_arg(ap, struct task_struct *);
72174 + cred = __task_cred(task);
72175 + pcred = __task_cred(task->real_parent);
72176 + ulong1 = va_arg(ap, unsigned long);
72177 + 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);
72178 + break;
72179 + case GR_RWXMAP:
72180 + file = va_arg(ap, struct file *);
72181 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
72182 + break;
72183 + case GR_RWXMAPVMA:
72184 + vma = va_arg(ap, struct vm_area_struct *);
72185 + if (vma->vm_file)
72186 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
72187 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
72188 + str1 = "<stack>";
72189 + else if (vma->vm_start <= current->mm->brk &&
72190 + vma->vm_end >= current->mm->start_brk)
72191 + str1 = "<heap>";
72192 + else
72193 + str1 = "<anonymous mapping>";
72194 + gr_log_middle_varargs(audit, msg, str1);
72195 + break;
72196 + case GR_PSACCT:
72197 + {
72198 + unsigned int wday, cday;
72199 + __u8 whr, chr;
72200 + __u8 wmin, cmin;
72201 + __u8 wsec, csec;
72202 + char cur_tty[64] = { 0 };
72203 + char parent_tty[64] = { 0 };
72204 +
72205 + task = va_arg(ap, struct task_struct *);
72206 + wday = va_arg(ap, unsigned int);
72207 + cday = va_arg(ap, unsigned int);
72208 + whr = va_arg(ap, int);
72209 + chr = va_arg(ap, int);
72210 + wmin = va_arg(ap, int);
72211 + cmin = va_arg(ap, int);
72212 + wsec = va_arg(ap, int);
72213 + csec = va_arg(ap, int);
72214 + ulong1 = va_arg(ap, unsigned long);
72215 + cred = __task_cred(task);
72216 + pcred = __task_cred(task->real_parent);
72217 +
72218 + 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));
72219 + }
72220 + break;
72221 + default:
72222 + gr_log_middle(audit, msg, ap);
72223 + }
72224 + va_end(ap);
72225 + // these don't need DEFAULTSECARGS printed on the end
72226 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
72227 + gr_log_end(audit, 0);
72228 + else
72229 + gr_log_end(audit, 1);
72230 + END_LOCKS(audit);
72231 +}
72232 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
72233 new file mode 100644
72234 index 0000000..f536303
72235 --- /dev/null
72236 +++ b/grsecurity/grsec_mem.c
72237 @@ -0,0 +1,40 @@
72238 +#include <linux/kernel.h>
72239 +#include <linux/sched.h>
72240 +#include <linux/mm.h>
72241 +#include <linux/mman.h>
72242 +#include <linux/grinternal.h>
72243 +
72244 +void
72245 +gr_handle_ioperm(void)
72246 +{
72247 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
72248 + return;
72249 +}
72250 +
72251 +void
72252 +gr_handle_iopl(void)
72253 +{
72254 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
72255 + return;
72256 +}
72257 +
72258 +void
72259 +gr_handle_mem_readwrite(u64 from, u64 to)
72260 +{
72261 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
72262 + return;
72263 +}
72264 +
72265 +void
72266 +gr_handle_vm86(void)
72267 +{
72268 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
72269 + return;
72270 +}
72271 +
72272 +void
72273 +gr_log_badprocpid(const char *entry)
72274 +{
72275 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
72276 + return;
72277 +}
72278 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
72279 new file mode 100644
72280 index 0000000..cd9e124
72281 --- /dev/null
72282 +++ b/grsecurity/grsec_mount.c
72283 @@ -0,0 +1,65 @@
72284 +#include <linux/kernel.h>
72285 +#include <linux/sched.h>
72286 +#include <linux/mount.h>
72287 +#include <linux/major.h>
72288 +#include <linux/grsecurity.h>
72289 +#include <linux/grinternal.h>
72290 +
72291 +void
72292 +gr_log_remount(const char *devname, const int retval)
72293 +{
72294 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72295 + if (grsec_enable_mount && (retval >= 0))
72296 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
72297 +#endif
72298 + return;
72299 +}
72300 +
72301 +void
72302 +gr_log_unmount(const char *devname, const int retval)
72303 +{
72304 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72305 + if (grsec_enable_mount && (retval >= 0))
72306 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
72307 +#endif
72308 + return;
72309 +}
72310 +
72311 +void
72312 +gr_log_mount(const char *from, const char *to, const int retval)
72313 +{
72314 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72315 + if (grsec_enable_mount && (retval >= 0))
72316 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
72317 +#endif
72318 + return;
72319 +}
72320 +
72321 +int
72322 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
72323 +{
72324 +#ifdef CONFIG_GRKERNSEC_ROFS
72325 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
72326 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
72327 + return -EPERM;
72328 + } else
72329 + return 0;
72330 +#endif
72331 + return 0;
72332 +}
72333 +
72334 +int
72335 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
72336 +{
72337 +#ifdef CONFIG_GRKERNSEC_ROFS
72338 + struct inode *inode = dentry->d_inode;
72339 +
72340 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
72341 + inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
72342 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
72343 + return -EPERM;
72344 + } else
72345 + return 0;
72346 +#endif
72347 + return 0;
72348 +}
72349 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
72350 new file mode 100644
72351 index 0000000..6ee9d50
72352 --- /dev/null
72353 +++ b/grsecurity/grsec_pax.c
72354 @@ -0,0 +1,45 @@
72355 +#include <linux/kernel.h>
72356 +#include <linux/sched.h>
72357 +#include <linux/mm.h>
72358 +#include <linux/file.h>
72359 +#include <linux/grinternal.h>
72360 +#include <linux/grsecurity.h>
72361 +
72362 +void
72363 +gr_log_textrel(struct vm_area_struct * vma)
72364 +{
72365 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72366 + if (grsec_enable_log_rwxmaps)
72367 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
72368 +#endif
72369 + return;
72370 +}
72371 +
72372 +void gr_log_ptgnustack(struct file *file)
72373 +{
72374 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72375 + if (grsec_enable_log_rwxmaps)
72376 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
72377 +#endif
72378 + return;
72379 +}
72380 +
72381 +void
72382 +gr_log_rwxmmap(struct file *file)
72383 +{
72384 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72385 + if (grsec_enable_log_rwxmaps)
72386 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
72387 +#endif
72388 + return;
72389 +}
72390 +
72391 +void
72392 +gr_log_rwxmprotect(struct vm_area_struct *vma)
72393 +{
72394 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72395 + if (grsec_enable_log_rwxmaps)
72396 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
72397 +#endif
72398 + return;
72399 +}
72400 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
72401 new file mode 100644
72402 index 0000000..f7f29aa
72403 --- /dev/null
72404 +++ b/grsecurity/grsec_ptrace.c
72405 @@ -0,0 +1,30 @@
72406 +#include <linux/kernel.h>
72407 +#include <linux/sched.h>
72408 +#include <linux/grinternal.h>
72409 +#include <linux/security.h>
72410 +
72411 +void
72412 +gr_audit_ptrace(struct task_struct *task)
72413 +{
72414 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72415 + if (grsec_enable_audit_ptrace)
72416 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
72417 +#endif
72418 + return;
72419 +}
72420 +
72421 +int
72422 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
72423 +{
72424 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72425 + const struct dentry *dentry = file->f_path.dentry;
72426 + const struct vfsmount *mnt = file->f_path.mnt;
72427 +
72428 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
72429 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
72430 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
72431 + return -EACCES;
72432 + }
72433 +#endif
72434 + return 0;
72435 +}
72436 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
72437 new file mode 100644
72438 index 0000000..3860c7e
72439 --- /dev/null
72440 +++ b/grsecurity/grsec_sig.c
72441 @@ -0,0 +1,236 @@
72442 +#include <linux/kernel.h>
72443 +#include <linux/sched.h>
72444 +#include <linux/fs.h>
72445 +#include <linux/delay.h>
72446 +#include <linux/grsecurity.h>
72447 +#include <linux/grinternal.h>
72448 +#include <linux/hardirq.h>
72449 +
72450 +char *signames[] = {
72451 + [SIGSEGV] = "Segmentation fault",
72452 + [SIGILL] = "Illegal instruction",
72453 + [SIGABRT] = "Abort",
72454 + [SIGBUS] = "Invalid alignment/Bus error"
72455 +};
72456 +
72457 +void
72458 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
72459 +{
72460 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72461 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
72462 + (sig == SIGABRT) || (sig == SIGBUS))) {
72463 + if (task_pid_nr(t) == task_pid_nr(current)) {
72464 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
72465 + } else {
72466 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
72467 + }
72468 + }
72469 +#endif
72470 + return;
72471 +}
72472 +
72473 +int
72474 +gr_handle_signal(const struct task_struct *p, const int sig)
72475 +{
72476 +#ifdef CONFIG_GRKERNSEC
72477 + /* ignore the 0 signal for protected task checks */
72478 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
72479 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
72480 + return -EPERM;
72481 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
72482 + return -EPERM;
72483 + }
72484 +#endif
72485 + return 0;
72486 +}
72487 +
72488 +#ifdef CONFIG_GRKERNSEC
72489 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
72490 +
72491 +int gr_fake_force_sig(int sig, struct task_struct *t)
72492 +{
72493 + unsigned long int flags;
72494 + int ret, blocked, ignored;
72495 + struct k_sigaction *action;
72496 +
72497 + spin_lock_irqsave(&t->sighand->siglock, flags);
72498 + action = &t->sighand->action[sig-1];
72499 + ignored = action->sa.sa_handler == SIG_IGN;
72500 + blocked = sigismember(&t->blocked, sig);
72501 + if (blocked || ignored) {
72502 + action->sa.sa_handler = SIG_DFL;
72503 + if (blocked) {
72504 + sigdelset(&t->blocked, sig);
72505 + recalc_sigpending_and_wake(t);
72506 + }
72507 + }
72508 + if (action->sa.sa_handler == SIG_DFL)
72509 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
72510 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
72511 +
72512 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
72513 +
72514 + return ret;
72515 +}
72516 +#endif
72517 +
72518 +#define GR_USER_BAN_TIME (15 * 60)
72519 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
72520 +
72521 +void gr_handle_brute_attach(int dumpable)
72522 +{
72523 +#ifdef CONFIG_GRKERNSEC_BRUTE
72524 + struct task_struct *p = current;
72525 + kuid_t uid = GLOBAL_ROOT_UID;
72526 + int daemon = 0;
72527 +
72528 + if (!grsec_enable_brute)
72529 + return;
72530 +
72531 + rcu_read_lock();
72532 + read_lock(&tasklist_lock);
72533 + read_lock(&grsec_exec_file_lock);
72534 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
72535 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
72536 + p->real_parent->brute = 1;
72537 + daemon = 1;
72538 + } else {
72539 + const struct cred *cred = __task_cred(p), *cred2;
72540 + struct task_struct *tsk, *tsk2;
72541 +
72542 + if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
72543 + struct user_struct *user;
72544 +
72545 + uid = cred->uid;
72546 +
72547 + /* this is put upon execution past expiration */
72548 + user = find_user(uid);
72549 + if (user == NULL)
72550 + goto unlock;
72551 + user->suid_banned = 1;
72552 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
72553 + if (user->suid_ban_expires == ~0UL)
72554 + user->suid_ban_expires--;
72555 +
72556 + /* only kill other threads of the same binary, from the same user */
72557 + do_each_thread(tsk2, tsk) {
72558 + cred2 = __task_cred(tsk);
72559 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
72560 + gr_fake_force_sig(SIGKILL, tsk);
72561 + } while_each_thread(tsk2, tsk);
72562 + }
72563 + }
72564 +unlock:
72565 + read_unlock(&grsec_exec_file_lock);
72566 + read_unlock(&tasklist_lock);
72567 + rcu_read_unlock();
72568 +
72569 + if (gr_is_global_nonroot(uid))
72570 + 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);
72571 + else if (daemon)
72572 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
72573 +
72574 +#endif
72575 + return;
72576 +}
72577 +
72578 +void gr_handle_brute_check(void)
72579 +{
72580 +#ifdef CONFIG_GRKERNSEC_BRUTE
72581 + struct task_struct *p = current;
72582 +
72583 + if (unlikely(p->brute)) {
72584 + if (!grsec_enable_brute)
72585 + p->brute = 0;
72586 + else if (time_before(get_seconds(), p->brute_expires))
72587 + msleep(30 * 1000);
72588 + }
72589 +#endif
72590 + return;
72591 +}
72592 +
72593 +void gr_handle_kernel_exploit(void)
72594 +{
72595 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72596 + const struct cred *cred;
72597 + struct task_struct *tsk, *tsk2;
72598 + struct user_struct *user;
72599 + kuid_t uid;
72600 +
72601 + if (in_irq() || in_serving_softirq() || in_nmi())
72602 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
72603 +
72604 + uid = current_uid();
72605 +
72606 + if (gr_is_global_root(uid))
72607 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
72608 + else {
72609 + /* kill all the processes of this user, hold a reference
72610 + to their creds struct, and prevent them from creating
72611 + another process until system reset
72612 + */
72613 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
72614 + GR_GLOBAL_UID(uid));
72615 + /* we intentionally leak this ref */
72616 + user = get_uid(current->cred->user);
72617 + if (user)
72618 + user->kernel_banned = 1;
72619 +
72620 + /* kill all processes of this user */
72621 + read_lock(&tasklist_lock);
72622 + do_each_thread(tsk2, tsk) {
72623 + cred = __task_cred(tsk);
72624 + if (uid_eq(cred->uid, uid))
72625 + gr_fake_force_sig(SIGKILL, tsk);
72626 + } while_each_thread(tsk2, tsk);
72627 + read_unlock(&tasklist_lock);
72628 + }
72629 +#endif
72630 +}
72631 +
72632 +#ifdef CONFIG_GRKERNSEC_BRUTE
72633 +static bool suid_ban_expired(struct user_struct *user)
72634 +{
72635 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
72636 + user->suid_banned = 0;
72637 + user->suid_ban_expires = 0;
72638 + free_uid(user);
72639 + return true;
72640 + }
72641 +
72642 + return false;
72643 +}
72644 +#endif
72645 +
72646 +int gr_process_kernel_exec_ban(void)
72647 +{
72648 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72649 + if (unlikely(current->cred->user->kernel_banned))
72650 + return -EPERM;
72651 +#endif
72652 + return 0;
72653 +}
72654 +
72655 +int gr_process_kernel_setuid_ban(struct user_struct *user)
72656 +{
72657 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72658 + if (unlikely(user->kernel_banned))
72659 + gr_fake_force_sig(SIGKILL, current);
72660 +#endif
72661 + return 0;
72662 +}
72663 +
72664 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
72665 +{
72666 +#ifdef CONFIG_GRKERNSEC_BRUTE
72667 + struct user_struct *user = current->cred->user;
72668 + if (unlikely(user->suid_banned)) {
72669 + if (suid_ban_expired(user))
72670 + return 0;
72671 + /* disallow execution of suid binaries only */
72672 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
72673 + return -EPERM;
72674 + }
72675 +#endif
72676 + return 0;
72677 +}
72678 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
72679 new file mode 100644
72680 index 0000000..4030d57
72681 --- /dev/null
72682 +++ b/grsecurity/grsec_sock.c
72683 @@ -0,0 +1,244 @@
72684 +#include <linux/kernel.h>
72685 +#include <linux/module.h>
72686 +#include <linux/sched.h>
72687 +#include <linux/file.h>
72688 +#include <linux/net.h>
72689 +#include <linux/in.h>
72690 +#include <linux/ip.h>
72691 +#include <net/sock.h>
72692 +#include <net/inet_sock.h>
72693 +#include <linux/grsecurity.h>
72694 +#include <linux/grinternal.h>
72695 +#include <linux/gracl.h>
72696 +
72697 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
72698 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
72699 +
72700 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
72701 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
72702 +
72703 +#ifdef CONFIG_UNIX_MODULE
72704 +EXPORT_SYMBOL(gr_acl_handle_unix);
72705 +EXPORT_SYMBOL(gr_acl_handle_mknod);
72706 +EXPORT_SYMBOL(gr_handle_chroot_unix);
72707 +EXPORT_SYMBOL(gr_handle_create);
72708 +#endif
72709 +
72710 +#ifdef CONFIG_GRKERNSEC
72711 +#define gr_conn_table_size 32749
72712 +struct conn_table_entry {
72713 + struct conn_table_entry *next;
72714 + struct signal_struct *sig;
72715 +};
72716 +
72717 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
72718 +DEFINE_SPINLOCK(gr_conn_table_lock);
72719 +
72720 +extern const char * gr_socktype_to_name(unsigned char type);
72721 +extern const char * gr_proto_to_name(unsigned char proto);
72722 +extern const char * gr_sockfamily_to_name(unsigned char family);
72723 +
72724 +static __inline__ int
72725 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
72726 +{
72727 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
72728 +}
72729 +
72730 +static __inline__ int
72731 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
72732 + __u16 sport, __u16 dport)
72733 +{
72734 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
72735 + sig->gr_sport == sport && sig->gr_dport == dport))
72736 + return 1;
72737 + else
72738 + return 0;
72739 +}
72740 +
72741 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
72742 +{
72743 + struct conn_table_entry **match;
72744 + unsigned int index;
72745 +
72746 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72747 + sig->gr_sport, sig->gr_dport,
72748 + gr_conn_table_size);
72749 +
72750 + newent->sig = sig;
72751 +
72752 + match = &gr_conn_table[index];
72753 + newent->next = *match;
72754 + *match = newent;
72755 +
72756 + return;
72757 +}
72758 +
72759 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
72760 +{
72761 + struct conn_table_entry *match, *last = NULL;
72762 + unsigned int index;
72763 +
72764 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72765 + sig->gr_sport, sig->gr_dport,
72766 + gr_conn_table_size);
72767 +
72768 + match = gr_conn_table[index];
72769 + while (match && !conn_match(match->sig,
72770 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
72771 + sig->gr_dport)) {
72772 + last = match;
72773 + match = match->next;
72774 + }
72775 +
72776 + if (match) {
72777 + if (last)
72778 + last->next = match->next;
72779 + else
72780 + gr_conn_table[index] = NULL;
72781 + kfree(match);
72782 + }
72783 +
72784 + return;
72785 +}
72786 +
72787 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
72788 + __u16 sport, __u16 dport)
72789 +{
72790 + struct conn_table_entry *match;
72791 + unsigned int index;
72792 +
72793 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
72794 +
72795 + match = gr_conn_table[index];
72796 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
72797 + match = match->next;
72798 +
72799 + if (match)
72800 + return match->sig;
72801 + else
72802 + return NULL;
72803 +}
72804 +
72805 +#endif
72806 +
72807 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
72808 +{
72809 +#ifdef CONFIG_GRKERNSEC
72810 + struct signal_struct *sig = task->signal;
72811 + struct conn_table_entry *newent;
72812 +
72813 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
72814 + if (newent == NULL)
72815 + return;
72816 + /* no bh lock needed since we are called with bh disabled */
72817 + spin_lock(&gr_conn_table_lock);
72818 + gr_del_task_from_ip_table_nolock(sig);
72819 + sig->gr_saddr = inet->inet_rcv_saddr;
72820 + sig->gr_daddr = inet->inet_daddr;
72821 + sig->gr_sport = inet->inet_sport;
72822 + sig->gr_dport = inet->inet_dport;
72823 + gr_add_to_task_ip_table_nolock(sig, newent);
72824 + spin_unlock(&gr_conn_table_lock);
72825 +#endif
72826 + return;
72827 +}
72828 +
72829 +void gr_del_task_from_ip_table(struct task_struct *task)
72830 +{
72831 +#ifdef CONFIG_GRKERNSEC
72832 + spin_lock_bh(&gr_conn_table_lock);
72833 + gr_del_task_from_ip_table_nolock(task->signal);
72834 + spin_unlock_bh(&gr_conn_table_lock);
72835 +#endif
72836 + return;
72837 +}
72838 +
72839 +void
72840 +gr_attach_curr_ip(const struct sock *sk)
72841 +{
72842 +#ifdef CONFIG_GRKERNSEC
72843 + struct signal_struct *p, *set;
72844 + const struct inet_sock *inet = inet_sk(sk);
72845 +
72846 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
72847 + return;
72848 +
72849 + set = current->signal;
72850 +
72851 + spin_lock_bh(&gr_conn_table_lock);
72852 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
72853 + inet->inet_dport, inet->inet_sport);
72854 + if (unlikely(p != NULL)) {
72855 + set->curr_ip = p->curr_ip;
72856 + set->used_accept = 1;
72857 + gr_del_task_from_ip_table_nolock(p);
72858 + spin_unlock_bh(&gr_conn_table_lock);
72859 + return;
72860 + }
72861 + spin_unlock_bh(&gr_conn_table_lock);
72862 +
72863 + set->curr_ip = inet->inet_daddr;
72864 + set->used_accept = 1;
72865 +#endif
72866 + return;
72867 +}
72868 +
72869 +int
72870 +gr_handle_sock_all(const int family, const int type, const int protocol)
72871 +{
72872 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72873 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
72874 + (family != AF_UNIX)) {
72875 + if (family == AF_INET)
72876 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
72877 + else
72878 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
72879 + return -EACCES;
72880 + }
72881 +#endif
72882 + return 0;
72883 +}
72884 +
72885 +int
72886 +gr_handle_sock_server(const struct sockaddr *sck)
72887 +{
72888 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72889 + if (grsec_enable_socket_server &&
72890 + in_group_p(grsec_socket_server_gid) &&
72891 + sck && (sck->sa_family != AF_UNIX) &&
72892 + (sck->sa_family != AF_LOCAL)) {
72893 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72894 + return -EACCES;
72895 + }
72896 +#endif
72897 + return 0;
72898 +}
72899 +
72900 +int
72901 +gr_handle_sock_server_other(const struct sock *sck)
72902 +{
72903 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72904 + if (grsec_enable_socket_server &&
72905 + in_group_p(grsec_socket_server_gid) &&
72906 + sck && (sck->sk_family != AF_UNIX) &&
72907 + (sck->sk_family != AF_LOCAL)) {
72908 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72909 + return -EACCES;
72910 + }
72911 +#endif
72912 + return 0;
72913 +}
72914 +
72915 +int
72916 +gr_handle_sock_client(const struct sockaddr *sck)
72917 +{
72918 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72919 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
72920 + sck && (sck->sa_family != AF_UNIX) &&
72921 + (sck->sa_family != AF_LOCAL)) {
72922 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
72923 + return -EACCES;
72924 + }
72925 +#endif
72926 + return 0;
72927 +}
72928 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
72929 new file mode 100644
72930 index 0000000..8159888
72931 --- /dev/null
72932 +++ b/grsecurity/grsec_sysctl.c
72933 @@ -0,0 +1,479 @@
72934 +#include <linux/kernel.h>
72935 +#include <linux/sched.h>
72936 +#include <linux/sysctl.h>
72937 +#include <linux/grsecurity.h>
72938 +#include <linux/grinternal.h>
72939 +
72940 +int
72941 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
72942 +{
72943 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72944 + if (dirname == NULL || name == NULL)
72945 + return 0;
72946 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
72947 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
72948 + return -EACCES;
72949 + }
72950 +#endif
72951 + return 0;
72952 +}
72953 +
72954 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
72955 +static int __maybe_unused __read_only one = 1;
72956 +#endif
72957 +
72958 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
72959 + defined(CONFIG_GRKERNSEC_DENYUSB)
72960 +struct ctl_table grsecurity_table[] = {
72961 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72962 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
72963 +#ifdef CONFIG_GRKERNSEC_IO
72964 + {
72965 + .procname = "disable_priv_io",
72966 + .data = &grsec_disable_privio,
72967 + .maxlen = sizeof(int),
72968 + .mode = 0600,
72969 + .proc_handler = &proc_dointvec,
72970 + },
72971 +#endif
72972 +#endif
72973 +#ifdef CONFIG_GRKERNSEC_LINK
72974 + {
72975 + .procname = "linking_restrictions",
72976 + .data = &grsec_enable_link,
72977 + .maxlen = sizeof(int),
72978 + .mode = 0600,
72979 + .proc_handler = &proc_dointvec,
72980 + },
72981 +#endif
72982 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
72983 + {
72984 + .procname = "enforce_symlinksifowner",
72985 + .data = &grsec_enable_symlinkown,
72986 + .maxlen = sizeof(int),
72987 + .mode = 0600,
72988 + .proc_handler = &proc_dointvec,
72989 + },
72990 + {
72991 + .procname = "symlinkown_gid",
72992 + .data = &grsec_symlinkown_gid,
72993 + .maxlen = sizeof(int),
72994 + .mode = 0600,
72995 + .proc_handler = &proc_dointvec,
72996 + },
72997 +#endif
72998 +#ifdef CONFIG_GRKERNSEC_BRUTE
72999 + {
73000 + .procname = "deter_bruteforce",
73001 + .data = &grsec_enable_brute,
73002 + .maxlen = sizeof(int),
73003 + .mode = 0600,
73004 + .proc_handler = &proc_dointvec,
73005 + },
73006 +#endif
73007 +#ifdef CONFIG_GRKERNSEC_FIFO
73008 + {
73009 + .procname = "fifo_restrictions",
73010 + .data = &grsec_enable_fifo,
73011 + .maxlen = sizeof(int),
73012 + .mode = 0600,
73013 + .proc_handler = &proc_dointvec,
73014 + },
73015 +#endif
73016 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
73017 + {
73018 + .procname = "ptrace_readexec",
73019 + .data = &grsec_enable_ptrace_readexec,
73020 + .maxlen = sizeof(int),
73021 + .mode = 0600,
73022 + .proc_handler = &proc_dointvec,
73023 + },
73024 +#endif
73025 +#ifdef CONFIG_GRKERNSEC_SETXID
73026 + {
73027 + .procname = "consistent_setxid",
73028 + .data = &grsec_enable_setxid,
73029 + .maxlen = sizeof(int),
73030 + .mode = 0600,
73031 + .proc_handler = &proc_dointvec,
73032 + },
73033 +#endif
73034 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
73035 + {
73036 + .procname = "ip_blackhole",
73037 + .data = &grsec_enable_blackhole,
73038 + .maxlen = sizeof(int),
73039 + .mode = 0600,
73040 + .proc_handler = &proc_dointvec,
73041 + },
73042 + {
73043 + .procname = "lastack_retries",
73044 + .data = &grsec_lastack_retries,
73045 + .maxlen = sizeof(int),
73046 + .mode = 0600,
73047 + .proc_handler = &proc_dointvec,
73048 + },
73049 +#endif
73050 +#ifdef CONFIG_GRKERNSEC_EXECLOG
73051 + {
73052 + .procname = "exec_logging",
73053 + .data = &grsec_enable_execlog,
73054 + .maxlen = sizeof(int),
73055 + .mode = 0600,
73056 + .proc_handler = &proc_dointvec,
73057 + },
73058 +#endif
73059 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
73060 + {
73061 + .procname = "rwxmap_logging",
73062 + .data = &grsec_enable_log_rwxmaps,
73063 + .maxlen = sizeof(int),
73064 + .mode = 0600,
73065 + .proc_handler = &proc_dointvec,
73066 + },
73067 +#endif
73068 +#ifdef CONFIG_GRKERNSEC_SIGNAL
73069 + {
73070 + .procname = "signal_logging",
73071 + .data = &grsec_enable_signal,
73072 + .maxlen = sizeof(int),
73073 + .mode = 0600,
73074 + .proc_handler = &proc_dointvec,
73075 + },
73076 +#endif
73077 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
73078 + {
73079 + .procname = "forkfail_logging",
73080 + .data = &grsec_enable_forkfail,
73081 + .maxlen = sizeof(int),
73082 + .mode = 0600,
73083 + .proc_handler = &proc_dointvec,
73084 + },
73085 +#endif
73086 +#ifdef CONFIG_GRKERNSEC_TIME
73087 + {
73088 + .procname = "timechange_logging",
73089 + .data = &grsec_enable_time,
73090 + .maxlen = sizeof(int),
73091 + .mode = 0600,
73092 + .proc_handler = &proc_dointvec,
73093 + },
73094 +#endif
73095 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
73096 + {
73097 + .procname = "chroot_deny_shmat",
73098 + .data = &grsec_enable_chroot_shmat,
73099 + .maxlen = sizeof(int),
73100 + .mode = 0600,
73101 + .proc_handler = &proc_dointvec,
73102 + },
73103 +#endif
73104 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
73105 + {
73106 + .procname = "chroot_deny_unix",
73107 + .data = &grsec_enable_chroot_unix,
73108 + .maxlen = sizeof(int),
73109 + .mode = 0600,
73110 + .proc_handler = &proc_dointvec,
73111 + },
73112 +#endif
73113 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
73114 + {
73115 + .procname = "chroot_deny_mount",
73116 + .data = &grsec_enable_chroot_mount,
73117 + .maxlen = sizeof(int),
73118 + .mode = 0600,
73119 + .proc_handler = &proc_dointvec,
73120 + },
73121 +#endif
73122 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
73123 + {
73124 + .procname = "chroot_deny_fchdir",
73125 + .data = &grsec_enable_chroot_fchdir,
73126 + .maxlen = sizeof(int),
73127 + .mode = 0600,
73128 + .proc_handler = &proc_dointvec,
73129 + },
73130 +#endif
73131 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
73132 + {
73133 + .procname = "chroot_deny_chroot",
73134 + .data = &grsec_enable_chroot_double,
73135 + .maxlen = sizeof(int),
73136 + .mode = 0600,
73137 + .proc_handler = &proc_dointvec,
73138 + },
73139 +#endif
73140 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
73141 + {
73142 + .procname = "chroot_deny_pivot",
73143 + .data = &grsec_enable_chroot_pivot,
73144 + .maxlen = sizeof(int),
73145 + .mode = 0600,
73146 + .proc_handler = &proc_dointvec,
73147 + },
73148 +#endif
73149 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
73150 + {
73151 + .procname = "chroot_enforce_chdir",
73152 + .data = &grsec_enable_chroot_chdir,
73153 + .maxlen = sizeof(int),
73154 + .mode = 0600,
73155 + .proc_handler = &proc_dointvec,
73156 + },
73157 +#endif
73158 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
73159 + {
73160 + .procname = "chroot_deny_chmod",
73161 + .data = &grsec_enable_chroot_chmod,
73162 + .maxlen = sizeof(int),
73163 + .mode = 0600,
73164 + .proc_handler = &proc_dointvec,
73165 + },
73166 +#endif
73167 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
73168 + {
73169 + .procname = "chroot_deny_mknod",
73170 + .data = &grsec_enable_chroot_mknod,
73171 + .maxlen = sizeof(int),
73172 + .mode = 0600,
73173 + .proc_handler = &proc_dointvec,
73174 + },
73175 +#endif
73176 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
73177 + {
73178 + .procname = "chroot_restrict_nice",
73179 + .data = &grsec_enable_chroot_nice,
73180 + .maxlen = sizeof(int),
73181 + .mode = 0600,
73182 + .proc_handler = &proc_dointvec,
73183 + },
73184 +#endif
73185 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
73186 + {
73187 + .procname = "chroot_execlog",
73188 + .data = &grsec_enable_chroot_execlog,
73189 + .maxlen = sizeof(int),
73190 + .mode = 0600,
73191 + .proc_handler = &proc_dointvec,
73192 + },
73193 +#endif
73194 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
73195 + {
73196 + .procname = "chroot_caps",
73197 + .data = &grsec_enable_chroot_caps,
73198 + .maxlen = sizeof(int),
73199 + .mode = 0600,
73200 + .proc_handler = &proc_dointvec,
73201 + },
73202 +#endif
73203 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
73204 + {
73205 + .procname = "chroot_deny_sysctl",
73206 + .data = &grsec_enable_chroot_sysctl,
73207 + .maxlen = sizeof(int),
73208 + .mode = 0600,
73209 + .proc_handler = &proc_dointvec,
73210 + },
73211 +#endif
73212 +#ifdef CONFIG_GRKERNSEC_TPE
73213 + {
73214 + .procname = "tpe",
73215 + .data = &grsec_enable_tpe,
73216 + .maxlen = sizeof(int),
73217 + .mode = 0600,
73218 + .proc_handler = &proc_dointvec,
73219 + },
73220 + {
73221 + .procname = "tpe_gid",
73222 + .data = &grsec_tpe_gid,
73223 + .maxlen = sizeof(int),
73224 + .mode = 0600,
73225 + .proc_handler = &proc_dointvec,
73226 + },
73227 +#endif
73228 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
73229 + {
73230 + .procname = "tpe_invert",
73231 + .data = &grsec_enable_tpe_invert,
73232 + .maxlen = sizeof(int),
73233 + .mode = 0600,
73234 + .proc_handler = &proc_dointvec,
73235 + },
73236 +#endif
73237 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
73238 + {
73239 + .procname = "tpe_restrict_all",
73240 + .data = &grsec_enable_tpe_all,
73241 + .maxlen = sizeof(int),
73242 + .mode = 0600,
73243 + .proc_handler = &proc_dointvec,
73244 + },
73245 +#endif
73246 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
73247 + {
73248 + .procname = "socket_all",
73249 + .data = &grsec_enable_socket_all,
73250 + .maxlen = sizeof(int),
73251 + .mode = 0600,
73252 + .proc_handler = &proc_dointvec,
73253 + },
73254 + {
73255 + .procname = "socket_all_gid",
73256 + .data = &grsec_socket_all_gid,
73257 + .maxlen = sizeof(int),
73258 + .mode = 0600,
73259 + .proc_handler = &proc_dointvec,
73260 + },
73261 +#endif
73262 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
73263 + {
73264 + .procname = "socket_client",
73265 + .data = &grsec_enable_socket_client,
73266 + .maxlen = sizeof(int),
73267 + .mode = 0600,
73268 + .proc_handler = &proc_dointvec,
73269 + },
73270 + {
73271 + .procname = "socket_client_gid",
73272 + .data = &grsec_socket_client_gid,
73273 + .maxlen = sizeof(int),
73274 + .mode = 0600,
73275 + .proc_handler = &proc_dointvec,
73276 + },
73277 +#endif
73278 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
73279 + {
73280 + .procname = "socket_server",
73281 + .data = &grsec_enable_socket_server,
73282 + .maxlen = sizeof(int),
73283 + .mode = 0600,
73284 + .proc_handler = &proc_dointvec,
73285 + },
73286 + {
73287 + .procname = "socket_server_gid",
73288 + .data = &grsec_socket_server_gid,
73289 + .maxlen = sizeof(int),
73290 + .mode = 0600,
73291 + .proc_handler = &proc_dointvec,
73292 + },
73293 +#endif
73294 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
73295 + {
73296 + .procname = "audit_group",
73297 + .data = &grsec_enable_group,
73298 + .maxlen = sizeof(int),
73299 + .mode = 0600,
73300 + .proc_handler = &proc_dointvec,
73301 + },
73302 + {
73303 + .procname = "audit_gid",
73304 + .data = &grsec_audit_gid,
73305 + .maxlen = sizeof(int),
73306 + .mode = 0600,
73307 + .proc_handler = &proc_dointvec,
73308 + },
73309 +#endif
73310 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
73311 + {
73312 + .procname = "audit_chdir",
73313 + .data = &grsec_enable_chdir,
73314 + .maxlen = sizeof(int),
73315 + .mode = 0600,
73316 + .proc_handler = &proc_dointvec,
73317 + },
73318 +#endif
73319 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
73320 + {
73321 + .procname = "audit_mount",
73322 + .data = &grsec_enable_mount,
73323 + .maxlen = sizeof(int),
73324 + .mode = 0600,
73325 + .proc_handler = &proc_dointvec,
73326 + },
73327 +#endif
73328 +#ifdef CONFIG_GRKERNSEC_DMESG
73329 + {
73330 + .procname = "dmesg",
73331 + .data = &grsec_enable_dmesg,
73332 + .maxlen = sizeof(int),
73333 + .mode = 0600,
73334 + .proc_handler = &proc_dointvec,
73335 + },
73336 +#endif
73337 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
73338 + {
73339 + .procname = "chroot_findtask",
73340 + .data = &grsec_enable_chroot_findtask,
73341 + .maxlen = sizeof(int),
73342 + .mode = 0600,
73343 + .proc_handler = &proc_dointvec,
73344 + },
73345 +#endif
73346 +#ifdef CONFIG_GRKERNSEC_RESLOG
73347 + {
73348 + .procname = "resource_logging",
73349 + .data = &grsec_resource_logging,
73350 + .maxlen = sizeof(int),
73351 + .mode = 0600,
73352 + .proc_handler = &proc_dointvec,
73353 + },
73354 +#endif
73355 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
73356 + {
73357 + .procname = "audit_ptrace",
73358 + .data = &grsec_enable_audit_ptrace,
73359 + .maxlen = sizeof(int),
73360 + .mode = 0600,
73361 + .proc_handler = &proc_dointvec,
73362 + },
73363 +#endif
73364 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
73365 + {
73366 + .procname = "harden_ptrace",
73367 + .data = &grsec_enable_harden_ptrace,
73368 + .maxlen = sizeof(int),
73369 + .mode = 0600,
73370 + .proc_handler = &proc_dointvec,
73371 + },
73372 +#endif
73373 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
73374 + {
73375 + .procname = "harden_ipc",
73376 + .data = &grsec_enable_harden_ipc,
73377 + .maxlen = sizeof(int),
73378 + .mode = 0600,
73379 + .proc_handler = &proc_dointvec,
73380 + },
73381 +#endif
73382 + {
73383 + .procname = "grsec_lock",
73384 + .data = &grsec_lock,
73385 + .maxlen = sizeof(int),
73386 + .mode = 0600,
73387 + .proc_handler = &proc_dointvec,
73388 + },
73389 +#endif
73390 +#ifdef CONFIG_GRKERNSEC_ROFS
73391 + {
73392 + .procname = "romount_protect",
73393 + .data = &grsec_enable_rofs,
73394 + .maxlen = sizeof(int),
73395 + .mode = 0600,
73396 + .proc_handler = &proc_dointvec_minmax,
73397 + .extra1 = &one,
73398 + .extra2 = &one,
73399 + },
73400 +#endif
73401 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
73402 + {
73403 + .procname = "deny_new_usb",
73404 + .data = &grsec_deny_new_usb,
73405 + .maxlen = sizeof(int),
73406 + .mode = 0600,
73407 + .proc_handler = &proc_dointvec,
73408 + },
73409 +#endif
73410 + { }
73411 +};
73412 +#endif
73413 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
73414 new file mode 100644
73415 index 0000000..0dc13c3
73416 --- /dev/null
73417 +++ b/grsecurity/grsec_time.c
73418 @@ -0,0 +1,16 @@
73419 +#include <linux/kernel.h>
73420 +#include <linux/sched.h>
73421 +#include <linux/grinternal.h>
73422 +#include <linux/module.h>
73423 +
73424 +void
73425 +gr_log_timechange(void)
73426 +{
73427 +#ifdef CONFIG_GRKERNSEC_TIME
73428 + if (grsec_enable_time)
73429 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
73430 +#endif
73431 + return;
73432 +}
73433 +
73434 +EXPORT_SYMBOL(gr_log_timechange);
73435 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
73436 new file mode 100644
73437 index 0000000..ee57dcf
73438 --- /dev/null
73439 +++ b/grsecurity/grsec_tpe.c
73440 @@ -0,0 +1,73 @@
73441 +#include <linux/kernel.h>
73442 +#include <linux/sched.h>
73443 +#include <linux/file.h>
73444 +#include <linux/fs.h>
73445 +#include <linux/grinternal.h>
73446 +
73447 +extern int gr_acl_tpe_check(void);
73448 +
73449 +int
73450 +gr_tpe_allow(const struct file *file)
73451 +{
73452 +#ifdef CONFIG_GRKERNSEC
73453 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
73454 + const struct cred *cred = current_cred();
73455 + char *msg = NULL;
73456 + char *msg2 = NULL;
73457 +
73458 + // never restrict root
73459 + if (gr_is_global_root(cred->uid))
73460 + return 1;
73461 +
73462 + if (grsec_enable_tpe) {
73463 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
73464 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
73465 + msg = "not being in trusted group";
73466 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
73467 + msg = "being in untrusted group";
73468 +#else
73469 + if (in_group_p(grsec_tpe_gid))
73470 + msg = "being in untrusted group";
73471 +#endif
73472 + }
73473 + if (!msg && gr_acl_tpe_check())
73474 + msg = "being in untrusted role";
73475 +
73476 + // not in any affected group/role
73477 + if (!msg)
73478 + goto next_check;
73479 +
73480 + if (gr_is_global_nonroot(inode->i_uid))
73481 + msg2 = "file in non-root-owned directory";
73482 + else if (inode->i_mode & S_IWOTH)
73483 + msg2 = "file in world-writable directory";
73484 + else if (inode->i_mode & S_IWGRP)
73485 + msg2 = "file in group-writable directory";
73486 +
73487 + if (msg && msg2) {
73488 + char fullmsg[70] = {0};
73489 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
73490 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
73491 + return 0;
73492 + }
73493 + msg = NULL;
73494 +next_check:
73495 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
73496 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
73497 + return 1;
73498 +
73499 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
73500 + msg = "directory not owned by user";
73501 + else if (inode->i_mode & S_IWOTH)
73502 + msg = "file in world-writable directory";
73503 + else if (inode->i_mode & S_IWGRP)
73504 + msg = "file in group-writable directory";
73505 +
73506 + if (msg) {
73507 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
73508 + return 0;
73509 + }
73510 +#endif
73511 +#endif
73512 + return 1;
73513 +}
73514 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
73515 new file mode 100644
73516 index 0000000..ae02d8e
73517 --- /dev/null
73518 +++ b/grsecurity/grsec_usb.c
73519 @@ -0,0 +1,15 @@
73520 +#include <linux/kernel.h>
73521 +#include <linux/grinternal.h>
73522 +#include <linux/module.h>
73523 +
73524 +int gr_handle_new_usb(void)
73525 +{
73526 +#ifdef CONFIG_GRKERNSEC_DENYUSB
73527 + if (grsec_deny_new_usb) {
73528 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
73529 + return 1;
73530 + }
73531 +#endif
73532 + return 0;
73533 +}
73534 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
73535 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
73536 new file mode 100644
73537 index 0000000..9f7b1ac
73538 --- /dev/null
73539 +++ b/grsecurity/grsum.c
73540 @@ -0,0 +1,61 @@
73541 +#include <linux/err.h>
73542 +#include <linux/kernel.h>
73543 +#include <linux/sched.h>
73544 +#include <linux/mm.h>
73545 +#include <linux/scatterlist.h>
73546 +#include <linux/crypto.h>
73547 +#include <linux/gracl.h>
73548 +
73549 +
73550 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
73551 +#error "crypto and sha256 must be built into the kernel"
73552 +#endif
73553 +
73554 +int
73555 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
73556 +{
73557 + char *p;
73558 + struct crypto_hash *tfm;
73559 + struct hash_desc desc;
73560 + struct scatterlist sg;
73561 + unsigned char temp_sum[GR_SHA_LEN];
73562 + volatile int retval = 0;
73563 + volatile int dummy = 0;
73564 + unsigned int i;
73565 +
73566 + sg_init_table(&sg, 1);
73567 +
73568 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
73569 + if (IS_ERR(tfm)) {
73570 + /* should never happen, since sha256 should be built in */
73571 + return 1;
73572 + }
73573 +
73574 + desc.tfm = tfm;
73575 + desc.flags = 0;
73576 +
73577 + crypto_hash_init(&desc);
73578 +
73579 + p = salt;
73580 + sg_set_buf(&sg, p, GR_SALT_LEN);
73581 + crypto_hash_update(&desc, &sg, sg.length);
73582 +
73583 + p = entry->pw;
73584 + sg_set_buf(&sg, p, strlen(p));
73585 +
73586 + crypto_hash_update(&desc, &sg, sg.length);
73587 +
73588 + crypto_hash_final(&desc, temp_sum);
73589 +
73590 + memset(entry->pw, 0, GR_PW_LEN);
73591 +
73592 + for (i = 0; i < GR_SHA_LEN; i++)
73593 + if (sum[i] != temp_sum[i])
73594 + retval = 1;
73595 + else
73596 + dummy = 1; // waste a cycle
73597 +
73598 + crypto_free_hash(tfm);
73599 +
73600 + return retval;
73601 +}
73602 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
73603 index 77ff547..181834f 100644
73604 --- a/include/asm-generic/4level-fixup.h
73605 +++ b/include/asm-generic/4level-fixup.h
73606 @@ -13,8 +13,10 @@
73607 #define pmd_alloc(mm, pud, address) \
73608 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
73609 NULL: pmd_offset(pud, address))
73610 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
73611
73612 #define pud_alloc(mm, pgd, address) (pgd)
73613 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
73614 #define pud_offset(pgd, start) (pgd)
73615 #define pud_none(pud) 0
73616 #define pud_bad(pud) 0
73617 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
73618 index b7babf0..97f4c4f 100644
73619 --- a/include/asm-generic/atomic-long.h
73620 +++ b/include/asm-generic/atomic-long.h
73621 @@ -22,6 +22,12 @@
73622
73623 typedef atomic64_t atomic_long_t;
73624
73625 +#ifdef CONFIG_PAX_REFCOUNT
73626 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
73627 +#else
73628 +typedef atomic64_t atomic_long_unchecked_t;
73629 +#endif
73630 +
73631 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
73632
73633 static inline long atomic_long_read(atomic_long_t *l)
73634 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73635 return (long)atomic64_read(v);
73636 }
73637
73638 +#ifdef CONFIG_PAX_REFCOUNT
73639 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73640 +{
73641 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73642 +
73643 + return (long)atomic64_read_unchecked(v);
73644 +}
73645 +#endif
73646 +
73647 static inline void atomic_long_set(atomic_long_t *l, long i)
73648 {
73649 atomic64_t *v = (atomic64_t *)l;
73650 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73651 atomic64_set(v, i);
73652 }
73653
73654 +#ifdef CONFIG_PAX_REFCOUNT
73655 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73656 +{
73657 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73658 +
73659 + atomic64_set_unchecked(v, i);
73660 +}
73661 +#endif
73662 +
73663 static inline void atomic_long_inc(atomic_long_t *l)
73664 {
73665 atomic64_t *v = (atomic64_t *)l;
73666 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73667 atomic64_inc(v);
73668 }
73669
73670 +#ifdef CONFIG_PAX_REFCOUNT
73671 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73672 +{
73673 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73674 +
73675 + atomic64_inc_unchecked(v);
73676 +}
73677 +#endif
73678 +
73679 static inline void atomic_long_dec(atomic_long_t *l)
73680 {
73681 atomic64_t *v = (atomic64_t *)l;
73682 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73683 atomic64_dec(v);
73684 }
73685
73686 +#ifdef CONFIG_PAX_REFCOUNT
73687 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73688 +{
73689 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73690 +
73691 + atomic64_dec_unchecked(v);
73692 +}
73693 +#endif
73694 +
73695 static inline void atomic_long_add(long i, atomic_long_t *l)
73696 {
73697 atomic64_t *v = (atomic64_t *)l;
73698 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73699 atomic64_add(i, v);
73700 }
73701
73702 +#ifdef CONFIG_PAX_REFCOUNT
73703 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73704 +{
73705 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73706 +
73707 + atomic64_add_unchecked(i, v);
73708 +}
73709 +#endif
73710 +
73711 static inline void atomic_long_sub(long i, atomic_long_t *l)
73712 {
73713 atomic64_t *v = (atomic64_t *)l;
73714 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73715 atomic64_sub(i, v);
73716 }
73717
73718 +#ifdef CONFIG_PAX_REFCOUNT
73719 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73720 +{
73721 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73722 +
73723 + atomic64_sub_unchecked(i, v);
73724 +}
73725 +#endif
73726 +
73727 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73728 {
73729 atomic64_t *v = (atomic64_t *)l;
73730 @@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
73731 return atomic64_add_negative(i, v);
73732 }
73733
73734 -static inline long atomic_long_add_return(long i, atomic_long_t *l)
73735 +static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
73736 {
73737 atomic64_t *v = (atomic64_t *)l;
73738
73739 return (long)atomic64_add_return(i, v);
73740 }
73741
73742 +#ifdef CONFIG_PAX_REFCOUNT
73743 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73744 +{
73745 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73746 +
73747 + return (long)atomic64_add_return_unchecked(i, v);
73748 +}
73749 +#endif
73750 +
73751 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73752 {
73753 atomic64_t *v = (atomic64_t *)l;
73754 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73755 return (long)atomic64_inc_return(v);
73756 }
73757
73758 +#ifdef CONFIG_PAX_REFCOUNT
73759 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73760 +{
73761 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73762 +
73763 + return (long)atomic64_inc_return_unchecked(v);
73764 +}
73765 +#endif
73766 +
73767 static inline long atomic_long_dec_return(atomic_long_t *l)
73768 {
73769 atomic64_t *v = (atomic64_t *)l;
73770 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73771
73772 typedef atomic_t atomic_long_t;
73773
73774 +#ifdef CONFIG_PAX_REFCOUNT
73775 +typedef atomic_unchecked_t atomic_long_unchecked_t;
73776 +#else
73777 +typedef atomic_t atomic_long_unchecked_t;
73778 +#endif
73779 +
73780 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
73781 static inline long atomic_long_read(atomic_long_t *l)
73782 {
73783 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73784 return (long)atomic_read(v);
73785 }
73786
73787 +#ifdef CONFIG_PAX_REFCOUNT
73788 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73789 +{
73790 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73791 +
73792 + return (long)atomic_read_unchecked(v);
73793 +}
73794 +#endif
73795 +
73796 static inline void atomic_long_set(atomic_long_t *l, long i)
73797 {
73798 atomic_t *v = (atomic_t *)l;
73799 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73800 atomic_set(v, i);
73801 }
73802
73803 +#ifdef CONFIG_PAX_REFCOUNT
73804 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73805 +{
73806 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73807 +
73808 + atomic_set_unchecked(v, i);
73809 +}
73810 +#endif
73811 +
73812 static inline void atomic_long_inc(atomic_long_t *l)
73813 {
73814 atomic_t *v = (atomic_t *)l;
73815 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73816 atomic_inc(v);
73817 }
73818
73819 +#ifdef CONFIG_PAX_REFCOUNT
73820 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73821 +{
73822 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73823 +
73824 + atomic_inc_unchecked(v);
73825 +}
73826 +#endif
73827 +
73828 static inline void atomic_long_dec(atomic_long_t *l)
73829 {
73830 atomic_t *v = (atomic_t *)l;
73831 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73832 atomic_dec(v);
73833 }
73834
73835 +#ifdef CONFIG_PAX_REFCOUNT
73836 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73837 +{
73838 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73839 +
73840 + atomic_dec_unchecked(v);
73841 +}
73842 +#endif
73843 +
73844 static inline void atomic_long_add(long i, atomic_long_t *l)
73845 {
73846 atomic_t *v = (atomic_t *)l;
73847 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73848 atomic_add(i, v);
73849 }
73850
73851 +#ifdef CONFIG_PAX_REFCOUNT
73852 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73853 +{
73854 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73855 +
73856 + atomic_add_unchecked(i, v);
73857 +}
73858 +#endif
73859 +
73860 static inline void atomic_long_sub(long i, atomic_long_t *l)
73861 {
73862 atomic_t *v = (atomic_t *)l;
73863 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73864 atomic_sub(i, v);
73865 }
73866
73867 +#ifdef CONFIG_PAX_REFCOUNT
73868 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73869 +{
73870 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73871 +
73872 + atomic_sub_unchecked(i, v);
73873 +}
73874 +#endif
73875 +
73876 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73877 {
73878 atomic_t *v = (atomic_t *)l;
73879 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
73880 return (long)atomic_add_return(i, v);
73881 }
73882
73883 +#ifdef CONFIG_PAX_REFCOUNT
73884 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73885 +{
73886 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73887 +
73888 + return (long)atomic_add_return_unchecked(i, v);
73889 +}
73890 +
73891 +#endif
73892 +
73893 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73894 {
73895 atomic_t *v = (atomic_t *)l;
73896 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73897 return (long)atomic_inc_return(v);
73898 }
73899
73900 +#ifdef CONFIG_PAX_REFCOUNT
73901 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73902 +{
73903 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73904 +
73905 + return (long)atomic_inc_return_unchecked(v);
73906 +}
73907 +#endif
73908 +
73909 static inline long atomic_long_dec_return(atomic_long_t *l)
73910 {
73911 atomic_t *v = (atomic_t *)l;
73912 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73913
73914 #endif /* BITS_PER_LONG == 64 */
73915
73916 +#ifdef CONFIG_PAX_REFCOUNT
73917 +static inline void pax_refcount_needs_these_functions(void)
73918 +{
73919 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
73920 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
73921 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
73922 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
73923 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
73924 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
73925 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
73926 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
73927 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
73928 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
73929 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
73930 +#ifdef CONFIG_X86
73931 + atomic_clear_mask_unchecked(0, NULL);
73932 + atomic_set_mask_unchecked(0, NULL);
73933 +#endif
73934 +
73935 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
73936 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
73937 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
73938 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
73939 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
73940 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
73941 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
73942 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
73943 +}
73944 +#else
73945 +#define atomic_read_unchecked(v) atomic_read(v)
73946 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
73947 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
73948 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
73949 +#define atomic_inc_unchecked(v) atomic_inc(v)
73950 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
73951 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
73952 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
73953 +#define atomic_dec_unchecked(v) atomic_dec(v)
73954 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
73955 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
73956 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
73957 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
73958 +
73959 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
73960 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
73961 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
73962 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
73963 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
73964 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
73965 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
73966 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
73967 +#endif
73968 +
73969 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
73970 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
73971 index 33bd2de..f31bff97 100644
73972 --- a/include/asm-generic/atomic.h
73973 +++ b/include/asm-generic/atomic.h
73974 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
73975 * Atomically clears the bits set in @mask from @v
73976 */
73977 #ifndef atomic_clear_mask
73978 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
73979 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
73980 {
73981 unsigned long flags;
73982
73983 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
73984 index b18ce4f..2ee2843 100644
73985 --- a/include/asm-generic/atomic64.h
73986 +++ b/include/asm-generic/atomic64.h
73987 @@ -16,6 +16,8 @@ typedef struct {
73988 long long counter;
73989 } atomic64_t;
73990
73991 +typedef atomic64_t atomic64_unchecked_t;
73992 +
73993 #define ATOMIC64_INIT(i) { (i) }
73994
73995 extern long long atomic64_read(const atomic64_t *v);
73996 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
73997 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
73998 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
73999
74000 +#define atomic64_read_unchecked(v) atomic64_read(v)
74001 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
74002 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
74003 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
74004 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
74005 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
74006 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
74007 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
74008 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
74009 +
74010 #endif /* _ASM_GENERIC_ATOMIC64_H */
74011 diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
74012 index a60a7cc..0fe12f2 100644
74013 --- a/include/asm-generic/bitops/__fls.h
74014 +++ b/include/asm-generic/bitops/__fls.h
74015 @@ -9,7 +9,7 @@
74016 *
74017 * Undefined if no set bit exists, so code should check against 0 first.
74018 */
74019 -static __always_inline unsigned long __fls(unsigned long word)
74020 +static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
74021 {
74022 int num = BITS_PER_LONG - 1;
74023
74024 diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
74025 index 0576d1f..dad6c71 100644
74026 --- a/include/asm-generic/bitops/fls.h
74027 +++ b/include/asm-generic/bitops/fls.h
74028 @@ -9,7 +9,7 @@
74029 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
74030 */
74031
74032 -static __always_inline int fls(int x)
74033 +static __always_inline int __intentional_overflow(-1) fls(int x)
74034 {
74035 int r = 32;
74036
74037 diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
74038 index b097cf8..3d40e14 100644
74039 --- a/include/asm-generic/bitops/fls64.h
74040 +++ b/include/asm-generic/bitops/fls64.h
74041 @@ -15,7 +15,7 @@
74042 * at position 64.
74043 */
74044 #if BITS_PER_LONG == 32
74045 -static __always_inline int fls64(__u64 x)
74046 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
74047 {
74048 __u32 h = x >> 32;
74049 if (h)
74050 @@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
74051 return fls(x);
74052 }
74053 #elif BITS_PER_LONG == 64
74054 -static __always_inline int fls64(__u64 x)
74055 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
74056 {
74057 if (x == 0)
74058 return 0;
74059 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
74060 index 1bfcfe5..e04c5c9 100644
74061 --- a/include/asm-generic/cache.h
74062 +++ b/include/asm-generic/cache.h
74063 @@ -6,7 +6,7 @@
74064 * cache lines need to provide their own cache.h.
74065 */
74066
74067 -#define L1_CACHE_SHIFT 5
74068 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
74069 +#define L1_CACHE_SHIFT 5UL
74070 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
74071
74072 #endif /* __ASM_GENERIC_CACHE_H */
74073 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
74074 index 0d68a1e..b74a761 100644
74075 --- a/include/asm-generic/emergency-restart.h
74076 +++ b/include/asm-generic/emergency-restart.h
74077 @@ -1,7 +1,7 @@
74078 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
74079 #define _ASM_GENERIC_EMERGENCY_RESTART_H
74080
74081 -static inline void machine_emergency_restart(void)
74082 +static inline __noreturn void machine_emergency_restart(void)
74083 {
74084 machine_restart(NULL);
74085 }
74086 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
74087 index 90f99c7..00ce236 100644
74088 --- a/include/asm-generic/kmap_types.h
74089 +++ b/include/asm-generic/kmap_types.h
74090 @@ -2,9 +2,9 @@
74091 #define _ASM_GENERIC_KMAP_TYPES_H
74092
74093 #ifdef __WITH_KM_FENCE
74094 -# define KM_TYPE_NR 41
74095 +# define KM_TYPE_NR 42
74096 #else
74097 -# define KM_TYPE_NR 20
74098 +# define KM_TYPE_NR 21
74099 #endif
74100
74101 #endif
74102 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
74103 index 9ceb03b..62b0b8f 100644
74104 --- a/include/asm-generic/local.h
74105 +++ b/include/asm-generic/local.h
74106 @@ -23,24 +23,37 @@ typedef struct
74107 atomic_long_t a;
74108 } local_t;
74109
74110 +typedef struct {
74111 + atomic_long_unchecked_t a;
74112 +} local_unchecked_t;
74113 +
74114 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
74115
74116 #define local_read(l) atomic_long_read(&(l)->a)
74117 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
74118 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
74119 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
74120 #define local_inc(l) atomic_long_inc(&(l)->a)
74121 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
74122 #define local_dec(l) atomic_long_dec(&(l)->a)
74123 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
74124 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
74125 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
74126 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
74127 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
74128
74129 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
74130 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
74131 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
74132 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
74133 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
74134 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
74135 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
74136 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
74137 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
74138
74139 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
74140 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
74141 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
74142 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
74143 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
74144 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
74145 index 725612b..9cc513a 100644
74146 --- a/include/asm-generic/pgtable-nopmd.h
74147 +++ b/include/asm-generic/pgtable-nopmd.h
74148 @@ -1,14 +1,19 @@
74149 #ifndef _PGTABLE_NOPMD_H
74150 #define _PGTABLE_NOPMD_H
74151
74152 -#ifndef __ASSEMBLY__
74153 -
74154 #include <asm-generic/pgtable-nopud.h>
74155
74156 -struct mm_struct;
74157 -
74158 #define __PAGETABLE_PMD_FOLDED
74159
74160 +#define PMD_SHIFT PUD_SHIFT
74161 +#define PTRS_PER_PMD 1
74162 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
74163 +#define PMD_MASK (~(PMD_SIZE-1))
74164 +
74165 +#ifndef __ASSEMBLY__
74166 +
74167 +struct mm_struct;
74168 +
74169 /*
74170 * Having the pmd type consist of a pud gets the size right, and allows
74171 * us to conceptually access the pud entry that this pmd is folded into
74172 @@ -16,11 +21,6 @@ struct mm_struct;
74173 */
74174 typedef struct { pud_t pud; } pmd_t;
74175
74176 -#define PMD_SHIFT PUD_SHIFT
74177 -#define PTRS_PER_PMD 1
74178 -#define PMD_SIZE (1UL << PMD_SHIFT)
74179 -#define PMD_MASK (~(PMD_SIZE-1))
74180 -
74181 /*
74182 * The "pud_xxx()" functions here are trivial for a folded two-level
74183 * setup: the pmd is never bad, and a pmd always exists (as it's folded
74184 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
74185 index 810431d..0ec4804f 100644
74186 --- a/include/asm-generic/pgtable-nopud.h
74187 +++ b/include/asm-generic/pgtable-nopud.h
74188 @@ -1,10 +1,15 @@
74189 #ifndef _PGTABLE_NOPUD_H
74190 #define _PGTABLE_NOPUD_H
74191
74192 -#ifndef __ASSEMBLY__
74193 -
74194 #define __PAGETABLE_PUD_FOLDED
74195
74196 +#define PUD_SHIFT PGDIR_SHIFT
74197 +#define PTRS_PER_PUD 1
74198 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
74199 +#define PUD_MASK (~(PUD_SIZE-1))
74200 +
74201 +#ifndef __ASSEMBLY__
74202 +
74203 /*
74204 * Having the pud type consist of a pgd gets the size right, and allows
74205 * us to conceptually access the pgd entry that this pud is folded into
74206 @@ -12,11 +17,6 @@
74207 */
74208 typedef struct { pgd_t pgd; } pud_t;
74209
74210 -#define PUD_SHIFT PGDIR_SHIFT
74211 -#define PTRS_PER_PUD 1
74212 -#define PUD_SIZE (1UL << PUD_SHIFT)
74213 -#define PUD_MASK (~(PUD_SIZE-1))
74214 -
74215 /*
74216 * The "pgd_xxx()" functions here are trivial for a folded two-level
74217 * setup: the pud is never bad, and a pud always exists (as it's folded
74218 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
74219 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
74220
74221 #define pgd_populate(mm, pgd, pud) do { } while (0)
74222 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
74223 /*
74224 * (puds are folded into pgds so this doesn't get actually called,
74225 * but the define is needed for a generic inline function.)
74226 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
74227 index b12079a..86683e3 100644
74228 --- a/include/asm-generic/pgtable.h
74229 +++ b/include/asm-generic/pgtable.h
74230 @@ -599,11 +599,10 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
74231 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
74232 barrier();
74233 #endif
74234 - if (pmd_none(pmdval))
74235 + if (pmd_none(pmdval) || pmd_trans_huge(pmdval))
74236 return 1;
74237 if (unlikely(pmd_bad(pmdval))) {
74238 - if (!pmd_trans_huge(pmdval))
74239 - pmd_clear_bad(pmd);
74240 + pmd_clear_bad(pmd);
74241 return 1;
74242 }
74243 return 0;
74244 @@ -737,6 +736,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
74245 }
74246 #endif /* CONFIG_NUMA_BALANCING */
74247
74248 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
74249 +#ifdef CONFIG_PAX_KERNEXEC
74250 +#error KERNEXEC requires pax_open_kernel
74251 +#else
74252 +static inline unsigned long pax_open_kernel(void) { return 0; }
74253 +#endif
74254 +#endif
74255 +
74256 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
74257 +#ifdef CONFIG_PAX_KERNEXEC
74258 +#error KERNEXEC requires pax_close_kernel
74259 +#else
74260 +static inline unsigned long pax_close_kernel(void) { return 0; }
74261 +#endif
74262 +#endif
74263 +
74264 #endif /* CONFIG_MMU */
74265
74266 #endif /* !__ASSEMBLY__ */
74267 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
74268 index dc1269c..48a4f51 100644
74269 --- a/include/asm-generic/uaccess.h
74270 +++ b/include/asm-generic/uaccess.h
74271 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
74272 return __clear_user(to, n);
74273 }
74274
74275 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
74276 +#ifdef CONFIG_PAX_MEMORY_UDEREF
74277 +#error UDEREF requires pax_open_userland
74278 +#else
74279 +static inline unsigned long pax_open_userland(void) { return 0; }
74280 +#endif
74281 +#endif
74282 +
74283 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
74284 +#ifdef CONFIG_PAX_MEMORY_UDEREF
74285 +#error UDEREF requires pax_close_userland
74286 +#else
74287 +static inline unsigned long pax_close_userland(void) { return 0; }
74288 +#endif
74289 +#endif
74290 +
74291 #endif /* __ASM_GENERIC_UACCESS_H */
74292 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
74293 index 83e2c31..eeb4a04 100644
74294 --- a/include/asm-generic/vmlinux.lds.h
74295 +++ b/include/asm-generic/vmlinux.lds.h
74296 @@ -232,6 +232,7 @@
74297 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
74298 VMLINUX_SYMBOL(__start_rodata) = .; \
74299 *(.rodata) *(.rodata.*) \
74300 + *(.data..read_only) \
74301 *(__vermagic) /* Kernel version magic */ \
74302 . = ALIGN(8); \
74303 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
74304 @@ -715,17 +716,18 @@
74305 * section in the linker script will go there too. @phdr should have
74306 * a leading colon.
74307 *
74308 - * Note that this macros defines __per_cpu_load as an absolute symbol.
74309 + * Note that this macros defines per_cpu_load as an absolute symbol.
74310 * If there is no need to put the percpu section at a predetermined
74311 * address, use PERCPU_SECTION.
74312 */
74313 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
74314 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
74315 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
74316 + per_cpu_load = .; \
74317 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
74318 - LOAD_OFFSET) { \
74319 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
74320 PERCPU_INPUT(cacheline) \
74321 } phdr \
74322 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
74323 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
74324
74325 /**
74326 * PERCPU_SECTION - define output section for percpu area, simple version
74327 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
74328 index 418d270..bfd2794 100644
74329 --- a/include/crypto/algapi.h
74330 +++ b/include/crypto/algapi.h
74331 @@ -34,7 +34,7 @@ struct crypto_type {
74332 unsigned int maskclear;
74333 unsigned int maskset;
74334 unsigned int tfmsize;
74335 -};
74336 +} __do_const;
74337
74338 struct crypto_instance {
74339 struct crypto_alg alg;
74340 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
74341 index b46fb45..b30d6d5 100644
74342 --- a/include/drm/drmP.h
74343 +++ b/include/drm/drmP.h
74344 @@ -66,6 +66,7 @@
74345 #include <linux/workqueue.h>
74346 #include <linux/poll.h>
74347 #include <asm/pgalloc.h>
74348 +#include <asm/local.h>
74349 #include <drm/drm.h>
74350 #include <drm/drm_sarea.h>
74351 #include <drm/drm_vma_manager.h>
74352 @@ -277,10 +278,12 @@ do { \
74353 * \param cmd command.
74354 * \param arg argument.
74355 */
74356 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
74357 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
74358 + struct drm_file *file_priv);
74359 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
74360 struct drm_file *file_priv);
74361
74362 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
74363 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
74364 unsigned long arg);
74365
74366 #define DRM_IOCTL_NR(n) _IOC_NR(n)
74367 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
74368 struct drm_ioctl_desc {
74369 unsigned int cmd;
74370 int flags;
74371 - drm_ioctl_t *func;
74372 + drm_ioctl_t func;
74373 unsigned int cmd_drv;
74374 const char *name;
74375 -};
74376 +} __do_const;
74377
74378 /**
74379 * Creates a driver or general drm_ioctl_desc array entry for the given
74380 @@ -1027,7 +1030,7 @@ struct drm_info_list {
74381 int (*show)(struct seq_file*, void*); /** show callback */
74382 u32 driver_features; /**< Required driver features for this entry */
74383 void *data;
74384 -};
74385 +} __do_const;
74386
74387 /**
74388 * debugfs node structure. This structure represents a debugfs file.
74389 @@ -1098,7 +1101,7 @@ struct drm_device {
74390
74391 /** \name Usage Counters */
74392 /*@{ */
74393 - int open_count; /**< Outstanding files open */
74394 + local_t open_count; /**< Outstanding files open */
74395 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
74396 atomic_t vma_count; /**< Outstanding vma areas open */
74397 int buf_use; /**< Buffers in use -- cannot alloc */
74398 @@ -1109,7 +1112,7 @@ struct drm_device {
74399 /*@{ */
74400 unsigned long counters;
74401 enum drm_stat_type types[15];
74402 - atomic_t counts[15];
74403 + atomic_unchecked_t counts[15];
74404 /*@} */
74405
74406 struct list_head filelist;
74407 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
74408 index f43d556..94d9343 100644
74409 --- a/include/drm/drm_crtc_helper.h
74410 +++ b/include/drm/drm_crtc_helper.h
74411 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
74412 struct drm_connector *connector);
74413 /* disable encoder when not in use - more explicit than dpms off */
74414 void (*disable)(struct drm_encoder *encoder);
74415 -};
74416 +} __no_const;
74417
74418 /**
74419 * drm_connector_helper_funcs - helper operations for connectors
74420 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
74421 index 8a10f5c..5de7f5c 100644
74422 --- a/include/drm/i915_pciids.h
74423 +++ b/include/drm/i915_pciids.h
74424 @@ -37,7 +37,7 @@
74425 */
74426 #define INTEL_VGA_DEVICE(id, info) { \
74427 0x8086, id, \
74428 - ~0, ~0, \
74429 + PCI_ANY_ID, PCI_ANY_ID, \
74430 0x030000, 0xff0000, \
74431 (unsigned long) info }
74432
74433 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
74434 index 72dcbe8..8db58d7 100644
74435 --- a/include/drm/ttm/ttm_memory.h
74436 +++ b/include/drm/ttm/ttm_memory.h
74437 @@ -48,7 +48,7 @@
74438
74439 struct ttm_mem_shrink {
74440 int (*do_shrink) (struct ttm_mem_shrink *);
74441 -};
74442 +} __no_const;
74443
74444 /**
74445 * struct ttm_mem_global - Global memory accounting structure.
74446 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
74447 index 4b840e8..155d235 100644
74448 --- a/include/keys/asymmetric-subtype.h
74449 +++ b/include/keys/asymmetric-subtype.h
74450 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
74451 /* Verify the signature on a key of this subtype (optional) */
74452 int (*verify_signature)(const struct key *key,
74453 const struct public_key_signature *sig);
74454 -};
74455 +} __do_const;
74456
74457 /**
74458 * asymmetric_key_subtype - Get the subtype from an asymmetric key
74459 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
74460 index c1da539..1dcec55 100644
74461 --- a/include/linux/atmdev.h
74462 +++ b/include/linux/atmdev.h
74463 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
74464 #endif
74465
74466 struct k_atm_aal_stats {
74467 -#define __HANDLE_ITEM(i) atomic_t i
74468 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
74469 __AAL_STAT_ITEMS
74470 #undef __HANDLE_ITEM
74471 };
74472 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
74473 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
74474 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
74475 struct module *owner;
74476 -};
74477 +} __do_const ;
74478
74479 struct atmphy_ops {
74480 int (*start)(struct atm_dev *dev);
74481 diff --git a/include/linux/audit.h b/include/linux/audit.h
74482 index 729a4d1..9b304ae 100644
74483 --- a/include/linux/audit.h
74484 +++ b/include/linux/audit.h
74485 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
74486 extern unsigned int audit_serial(void);
74487 extern int auditsc_get_stamp(struct audit_context *ctx,
74488 struct timespec *t, unsigned int *serial);
74489 -extern int audit_set_loginuid(kuid_t loginuid);
74490 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
74491
74492 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
74493 {
74494 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
74495 index 7554fd4..0f86379 100644
74496 --- a/include/linux/binfmts.h
74497 +++ b/include/linux/binfmts.h
74498 @@ -73,8 +73,10 @@ struct linux_binfmt {
74499 int (*load_binary)(struct linux_binprm *);
74500 int (*load_shlib)(struct file *);
74501 int (*core_dump)(struct coredump_params *cprm);
74502 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
74503 + void (*handle_mmap)(struct file *);
74504 unsigned long min_coredump; /* minimal dump size */
74505 -};
74506 +} __do_const;
74507
74508 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
74509
74510 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
74511 index a3b6b82..2a7d758 100644
74512 --- a/include/linux/bitops.h
74513 +++ b/include/linux/bitops.h
74514 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
74515 * @word: value to rotate
74516 * @shift: bits to roll
74517 */
74518 -static inline __u32 rol32(__u32 word, unsigned int shift)
74519 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
74520 {
74521 return (word << shift) | (word >> (32 - shift));
74522 }
74523 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
74524 * @word: value to rotate
74525 * @shift: bits to roll
74526 */
74527 -static inline __u32 ror32(__u32 word, unsigned int shift)
74528 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
74529 {
74530 return (word >> shift) | (word << (32 - shift));
74531 }
74532 @@ -157,7 +157,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
74533 return (__s32)(value << shift) >> shift;
74534 }
74535
74536 -static inline unsigned fls_long(unsigned long l)
74537 +static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
74538 {
74539 if (sizeof(l) == 4)
74540 return fls(l);
74541 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
74542 index 0e6f765..885bb2b 100644
74543 --- a/include/linux/blkdev.h
74544 +++ b/include/linux/blkdev.h
74545 @@ -1537,7 +1537,7 @@ struct block_device_operations {
74546 /* this callback is with swap_lock and sometimes page table lock held */
74547 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
74548 struct module *owner;
74549 -};
74550 +} __do_const;
74551
74552 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
74553 unsigned long);
74554 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
74555 index 7c2e030..b72475d 100644
74556 --- a/include/linux/blktrace_api.h
74557 +++ b/include/linux/blktrace_api.h
74558 @@ -23,7 +23,7 @@ struct blk_trace {
74559 struct dentry *dir;
74560 struct dentry *dropped_file;
74561 struct dentry *msg_file;
74562 - atomic_t dropped;
74563 + atomic_unchecked_t dropped;
74564 };
74565
74566 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
74567 diff --git a/include/linux/cache.h b/include/linux/cache.h
74568 index 4c57065..40346da 100644
74569 --- a/include/linux/cache.h
74570 +++ b/include/linux/cache.h
74571 @@ -16,6 +16,14 @@
74572 #define __read_mostly
74573 #endif
74574
74575 +#ifndef __read_only
74576 +#ifdef CONFIG_PAX_KERNEXEC
74577 +#error KERNEXEC requires __read_only
74578 +#else
74579 +#define __read_only __read_mostly
74580 +#endif
74581 +#endif
74582 +
74583 #ifndef ____cacheline_aligned
74584 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
74585 #endif
74586 diff --git a/include/linux/capability.h b/include/linux/capability.h
74587 index a6ee1f9..e1ca49d 100644
74588 --- a/include/linux/capability.h
74589 +++ b/include/linux/capability.h
74590 @@ -212,8 +212,13 @@ extern bool capable(int cap);
74591 extern bool ns_capable(struct user_namespace *ns, int cap);
74592 extern bool inode_capable(const struct inode *inode, int cap);
74593 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
74594 +extern bool capable_nolog(int cap);
74595 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
74596 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
74597
74598 /* audit system wants to get cap info from files as well */
74599 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
74600
74601 +extern int is_privileged_binary(const struct dentry *dentry);
74602 +
74603 #endif /* !_LINUX_CAPABILITY_H */
74604 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
74605 index 8609d57..86e4d79 100644
74606 --- a/include/linux/cdrom.h
74607 +++ b/include/linux/cdrom.h
74608 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
74609
74610 /* driver specifications */
74611 const int capability; /* capability flags */
74612 - int n_minors; /* number of active minor devices */
74613 /* handle uniform packets for scsi type devices (scsi,atapi) */
74614 int (*generic_packet) (struct cdrom_device_info *,
74615 struct packet_command *);
74616 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
74617 index 4ce9056..86caac6 100644
74618 --- a/include/linux/cleancache.h
74619 +++ b/include/linux/cleancache.h
74620 @@ -31,7 +31,7 @@ struct cleancache_ops {
74621 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
74622 void (*invalidate_inode)(int, struct cleancache_filekey);
74623 void (*invalidate_fs)(int);
74624 -};
74625 +} __no_const;
74626
74627 extern struct cleancache_ops *
74628 cleancache_register_ops(struct cleancache_ops *ops);
74629 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
74630 index 73bdb69..d66d47a 100644
74631 --- a/include/linux/clk-provider.h
74632 +++ b/include/linux/clk-provider.h
74633 @@ -141,6 +141,7 @@ struct clk_ops {
74634 unsigned long);
74635 void (*init)(struct clk_hw *hw);
74636 };
74637 +typedef struct clk_ops __no_const clk_ops_no_const;
74638
74639 /**
74640 * struct clk_init_data - holds init data that's common to all clocks and is
74641 diff --git a/include/linux/compat.h b/include/linux/compat.h
74642 index 345da00..b6eff26 100644
74643 --- a/include/linux/compat.h
74644 +++ b/include/linux/compat.h
74645 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
74646 compat_size_t __user *len_ptr);
74647
74648 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
74649 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
74650 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
74651 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
74652 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
74653 compat_ssize_t msgsz, int msgflg);
74654 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
74655 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
74656 compat_ulong_t addr, compat_ulong_t data);
74657 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
74658 - compat_long_t addr, compat_long_t data);
74659 + compat_ulong_t addr, compat_ulong_t data);
74660
74661 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
74662 /*
74663 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
74664 index ded4299..da50e3b 100644
74665 --- a/include/linux/compiler-gcc4.h
74666 +++ b/include/linux/compiler-gcc4.h
74667 @@ -39,9 +39,29 @@
74668 # define __compiletime_warning(message) __attribute__((warning(message)))
74669 # define __compiletime_error(message) __attribute__((error(message)))
74670 #endif /* __CHECKER__ */
74671 +
74672 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
74673 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
74674 +#define __bos0(ptr) __bos((ptr), 0)
74675 +#define __bos1(ptr) __bos((ptr), 1)
74676 #endif /* GCC_VERSION >= 40300 */
74677
74678 #if GCC_VERSION >= 40500
74679 +
74680 +#ifdef CONSTIFY_PLUGIN
74681 +#define __no_const __attribute__((no_const))
74682 +#define __do_const __attribute__((do_const))
74683 +#endif
74684 +
74685 +#ifdef SIZE_OVERFLOW_PLUGIN
74686 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
74687 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
74688 +#endif
74689 +
74690 +#ifdef LATENT_ENTROPY_PLUGIN
74691 +#define __latent_entropy __attribute__((latent_entropy))
74692 +#endif
74693 +
74694 /*
74695 * Mark a position in code as unreachable. This can be used to
74696 * suppress control flow warnings after asm blocks that transfer
74697 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
74698 index 92669cd..1771a15 100644
74699 --- a/include/linux/compiler.h
74700 +++ b/include/linux/compiler.h
74701 @@ -5,11 +5,14 @@
74702
74703 #ifdef __CHECKER__
74704 # define __user __attribute__((noderef, address_space(1)))
74705 +# define __force_user __force __user
74706 # define __kernel __attribute__((address_space(0)))
74707 +# define __force_kernel __force __kernel
74708 # define __safe __attribute__((safe))
74709 # define __force __attribute__((force))
74710 # define __nocast __attribute__((nocast))
74711 # define __iomem __attribute__((noderef, address_space(2)))
74712 +# define __force_iomem __force __iomem
74713 # define __must_hold(x) __attribute__((context(x,1,1)))
74714 # define __acquires(x) __attribute__((context(x,0,1)))
74715 # define __releases(x) __attribute__((context(x,1,0)))
74716 @@ -17,20 +20,37 @@
74717 # define __release(x) __context__(x,-1)
74718 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
74719 # define __percpu __attribute__((noderef, address_space(3)))
74720 +# define __force_percpu __force __percpu
74721 #ifdef CONFIG_SPARSE_RCU_POINTER
74722 # define __rcu __attribute__((noderef, address_space(4)))
74723 +# define __force_rcu __force __rcu
74724 #else
74725 # define __rcu
74726 +# define __force_rcu
74727 #endif
74728 extern void __chk_user_ptr(const volatile void __user *);
74729 extern void __chk_io_ptr(const volatile void __iomem *);
74730 #else
74731 -# define __user
74732 -# define __kernel
74733 +# ifdef CHECKER_PLUGIN
74734 +//# define __user
74735 +//# define __force_user
74736 +//# define __kernel
74737 +//# define __force_kernel
74738 +# else
74739 +# ifdef STRUCTLEAK_PLUGIN
74740 +# define __user __attribute__((user))
74741 +# else
74742 +# define __user
74743 +# endif
74744 +# define __force_user
74745 +# define __kernel
74746 +# define __force_kernel
74747 +# endif
74748 # define __safe
74749 # define __force
74750 # define __nocast
74751 # define __iomem
74752 +# define __force_iomem
74753 # define __chk_user_ptr(x) (void)0
74754 # define __chk_io_ptr(x) (void)0
74755 # define __builtin_warning(x, y...) (1)
74756 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
74757 # define __release(x) (void)0
74758 # define __cond_lock(x,c) (c)
74759 # define __percpu
74760 +# define __force_percpu
74761 # define __rcu
74762 +# define __force_rcu
74763 #endif
74764
74765 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
74766 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74767 # define __attribute_const__ /* unimplemented */
74768 #endif
74769
74770 +#ifndef __no_const
74771 +# define __no_const
74772 +#endif
74773 +
74774 +#ifndef __do_const
74775 +# define __do_const
74776 +#endif
74777 +
74778 +#ifndef __size_overflow
74779 +# define __size_overflow(...)
74780 +#endif
74781 +
74782 +#ifndef __intentional_overflow
74783 +# define __intentional_overflow(...)
74784 +#endif
74785 +
74786 +#ifndef __latent_entropy
74787 +# define __latent_entropy
74788 +#endif
74789 +
74790 /*
74791 * Tell gcc if a function is cold. The compiler will assume any path
74792 * directly leading to the call is unlikely.
74793 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74794 #define __cold
74795 #endif
74796
74797 +#ifndef __alloc_size
74798 +#define __alloc_size(...)
74799 +#endif
74800 +
74801 +#ifndef __bos
74802 +#define __bos(ptr, arg)
74803 +#endif
74804 +
74805 +#ifndef __bos0
74806 +#define __bos0(ptr)
74807 +#endif
74808 +
74809 +#ifndef __bos1
74810 +#define __bos1(ptr)
74811 +#endif
74812 +
74813 /* Simple shorthand for a section definition */
74814 #ifndef __section
74815 # define __section(S) __attribute__ ((__section__(#S)))
74816 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74817 * use is to mediate communication between process-level code and irq/NMI
74818 * handlers, all running on the same CPU.
74819 */
74820 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
74821 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
74822 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
74823
74824 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
74825 #ifdef CONFIG_KPROBES
74826 diff --git a/include/linux/completion.h b/include/linux/completion.h
74827 index 3cd574d..240dcb0 100644
74828 --- a/include/linux/completion.h
74829 +++ b/include/linux/completion.h
74830 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
74831
74832 extern void wait_for_completion(struct completion *);
74833 extern void wait_for_completion_io(struct completion *);
74834 -extern int wait_for_completion_interruptible(struct completion *x);
74835 -extern int wait_for_completion_killable(struct completion *x);
74836 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
74837 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
74838 extern unsigned long wait_for_completion_timeout(struct completion *x,
74839 - unsigned long timeout);
74840 + unsigned long timeout) __intentional_overflow(-1);
74841 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
74842 - unsigned long timeout);
74843 + unsigned long timeout) __intentional_overflow(-1);
74844 extern long wait_for_completion_interruptible_timeout(
74845 - struct completion *x, unsigned long timeout);
74846 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74847 extern long wait_for_completion_killable_timeout(
74848 - struct completion *x, unsigned long timeout);
74849 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74850 extern bool try_wait_for_completion(struct completion *x);
74851 extern bool completion_done(struct completion *x);
74852
74853 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
74854 index 34025df..d94bbbc 100644
74855 --- a/include/linux/configfs.h
74856 +++ b/include/linux/configfs.h
74857 @@ -125,7 +125,7 @@ struct configfs_attribute {
74858 const char *ca_name;
74859 struct module *ca_owner;
74860 umode_t ca_mode;
74861 -};
74862 +} __do_const;
74863
74864 /*
74865 * Users often need to create attribute structures for their configurable
74866 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
74867 index fcabc42..cba5d93 100644
74868 --- a/include/linux/cpufreq.h
74869 +++ b/include/linux/cpufreq.h
74870 @@ -167,6 +167,7 @@ struct global_attr {
74871 ssize_t (*store)(struct kobject *a, struct attribute *b,
74872 const char *c, size_t count);
74873 };
74874 +typedef struct global_attr __no_const global_attr_no_const;
74875
74876 #define define_one_global_ro(_name) \
74877 static struct global_attr _name = \
74878 @@ -208,7 +209,7 @@ struct cpufreq_driver {
74879 int (*suspend) (struct cpufreq_policy *policy);
74880 int (*resume) (struct cpufreq_policy *policy);
74881 struct freq_attr **attr;
74882 -};
74883 +} __do_const;
74884
74885 /* flags */
74886 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
74887 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
74888 index 781addc..d1e1fe6 100644
74889 --- a/include/linux/cpuidle.h
74890 +++ b/include/linux/cpuidle.h
74891 @@ -50,7 +50,8 @@ struct cpuidle_state {
74892 int index);
74893
74894 int (*enter_dead) (struct cpuidle_device *dev, int index);
74895 -};
74896 +} __do_const;
74897 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
74898
74899 /* Idle State Flags */
74900 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
74901 @@ -192,7 +193,7 @@ struct cpuidle_governor {
74902 void (*reflect) (struct cpuidle_device *dev, int index);
74903
74904 struct module *owner;
74905 -};
74906 +} __do_const;
74907
74908 #ifdef CONFIG_CPU_IDLE
74909
74910 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
74911 index d08e4d2..95fad61 100644
74912 --- a/include/linux/cpumask.h
74913 +++ b/include/linux/cpumask.h
74914 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74915 }
74916
74917 /* Valid inputs for n are -1 and 0. */
74918 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74919 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74920 {
74921 return n+1;
74922 }
74923
74924 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74925 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74926 {
74927 return n+1;
74928 }
74929
74930 -static inline unsigned int cpumask_next_and(int n,
74931 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
74932 const struct cpumask *srcp,
74933 const struct cpumask *andp)
74934 {
74935 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74936 *
74937 * Returns >= nr_cpu_ids if no further cpus set.
74938 */
74939 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74940 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74941 {
74942 /* -1 is a legal arg here. */
74943 if (n != -1)
74944 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74945 *
74946 * Returns >= nr_cpu_ids if no further cpus unset.
74947 */
74948 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74949 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74950 {
74951 /* -1 is a legal arg here. */
74952 if (n != -1)
74953 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74954 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
74955 }
74956
74957 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
74958 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
74959 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
74960
74961 /**
74962 diff --git a/include/linux/cred.h b/include/linux/cred.h
74963 index 04421e8..6bce4ef 100644
74964 --- a/include/linux/cred.h
74965 +++ b/include/linux/cred.h
74966 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
74967 static inline void validate_process_creds(void)
74968 {
74969 }
74970 +static inline void validate_task_creds(struct task_struct *task)
74971 +{
74972 +}
74973 #endif
74974
74975 /**
74976 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
74977 index b92eadf..b4ecdc1 100644
74978 --- a/include/linux/crypto.h
74979 +++ b/include/linux/crypto.h
74980 @@ -373,7 +373,7 @@ struct cipher_tfm {
74981 const u8 *key, unsigned int keylen);
74982 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74983 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74984 -};
74985 +} __no_const;
74986
74987 struct hash_tfm {
74988 int (*init)(struct hash_desc *desc);
74989 @@ -394,13 +394,13 @@ struct compress_tfm {
74990 int (*cot_decompress)(struct crypto_tfm *tfm,
74991 const u8 *src, unsigned int slen,
74992 u8 *dst, unsigned int *dlen);
74993 -};
74994 +} __no_const;
74995
74996 struct rng_tfm {
74997 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
74998 unsigned int dlen);
74999 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
75000 -};
75001 +} __no_const;
75002
75003 #define crt_ablkcipher crt_u.ablkcipher
75004 #define crt_aead crt_u.aead
75005 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
75006 index 653589e..4ef254a 100644
75007 --- a/include/linux/ctype.h
75008 +++ b/include/linux/ctype.h
75009 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
75010 * Fast implementation of tolower() for internal usage. Do not use in your
75011 * code.
75012 */
75013 -static inline char _tolower(const char c)
75014 +static inline unsigned char _tolower(const unsigned char c)
75015 {
75016 return c | 0x20;
75017 }
75018 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
75019 index 7925bf0..d5143d2 100644
75020 --- a/include/linux/decompress/mm.h
75021 +++ b/include/linux/decompress/mm.h
75022 @@ -77,7 +77,7 @@ static void free(void *where)
75023 * warnings when not needed (indeed large_malloc / large_free are not
75024 * needed by inflate */
75025
75026 -#define malloc(a) kmalloc(a, GFP_KERNEL)
75027 +#define malloc(a) kmalloc((a), GFP_KERNEL)
75028 #define free(a) kfree(a)
75029
75030 #define large_malloc(a) vmalloc(a)
75031 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
75032 index 5f1ab92..39c35ae 100644
75033 --- a/include/linux/devfreq.h
75034 +++ b/include/linux/devfreq.h
75035 @@ -114,7 +114,7 @@ struct devfreq_governor {
75036 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
75037 int (*event_handler)(struct devfreq *devfreq,
75038 unsigned int event, void *data);
75039 -};
75040 +} __do_const;
75041
75042 /**
75043 * struct devfreq - Device devfreq structure
75044 diff --git a/include/linux/device.h b/include/linux/device.h
75045 index 2a9d6ed..d14551e3 100644
75046 --- a/include/linux/device.h
75047 +++ b/include/linux/device.h
75048 @@ -313,7 +313,7 @@ struct subsys_interface {
75049 struct list_head node;
75050 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
75051 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
75052 -};
75053 +} __do_const;
75054
75055 int subsys_interface_register(struct subsys_interface *sif);
75056 void subsys_interface_unregister(struct subsys_interface *sif);
75057 @@ -501,7 +501,7 @@ struct device_type {
75058 void (*release)(struct device *dev);
75059
75060 const struct dev_pm_ops *pm;
75061 -};
75062 +} __do_const;
75063
75064 /* interface for exporting device attributes */
75065 struct device_attribute {
75066 @@ -511,11 +511,12 @@ struct device_attribute {
75067 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
75068 const char *buf, size_t count);
75069 };
75070 +typedef struct device_attribute __no_const device_attribute_no_const;
75071
75072 struct dev_ext_attribute {
75073 struct device_attribute attr;
75074 void *var;
75075 -};
75076 +} __do_const;
75077
75078 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
75079 char *buf);
75080 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
75081 index 3a8d0a2..c762be2 100644
75082 --- a/include/linux/dma-mapping.h
75083 +++ b/include/linux/dma-mapping.h
75084 @@ -54,7 +54,7 @@ struct dma_map_ops {
75085 u64 (*get_required_mask)(struct device *dev);
75086 #endif
75087 int is_phys;
75088 -};
75089 +} __do_const;
75090
75091 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
75092
75093 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
75094 index 0bc7275..4ccbf11 100644
75095 --- a/include/linux/dmaengine.h
75096 +++ b/include/linux/dmaengine.h
75097 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
75098 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
75099 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
75100
75101 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
75102 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
75103 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
75104 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
75105 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
75106 struct dma_pinned_list *pinned_list, struct page *page,
75107 unsigned int offset, size_t len);
75108
75109 diff --git a/include/linux/efi.h b/include/linux/efi.h
75110 index 094ddd0..f1dfcd3 100644
75111 --- a/include/linux/efi.h
75112 +++ b/include/linux/efi.h
75113 @@ -745,6 +745,7 @@ struct efivar_operations {
75114 efi_set_variable_t *set_variable;
75115 efi_query_variable_store_t *query_variable_store;
75116 };
75117 +typedef struct efivar_operations __no_const efivar_operations_no_const;
75118
75119 struct efivars {
75120 /*
75121 diff --git a/include/linux/elf.h b/include/linux/elf.h
75122 index 40a3c0e0..4c45a38 100644
75123 --- a/include/linux/elf.h
75124 +++ b/include/linux/elf.h
75125 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
75126 #define elf_note elf32_note
75127 #define elf_addr_t Elf32_Off
75128 #define Elf_Half Elf32_Half
75129 +#define elf_dyn Elf32_Dyn
75130
75131 #else
75132
75133 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
75134 #define elf_note elf64_note
75135 #define elf_addr_t Elf64_Off
75136 #define Elf_Half Elf64_Half
75137 +#define elf_dyn Elf64_Dyn
75138
75139 #endif
75140
75141 diff --git a/include/linux/err.h b/include/linux/err.h
75142 index 15f92e0..e825a8e 100644
75143 --- a/include/linux/err.h
75144 +++ b/include/linux/err.h
75145 @@ -19,12 +19,12 @@
75146
75147 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
75148
75149 -static inline void * __must_check ERR_PTR(long error)
75150 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
75151 {
75152 return (void *) error;
75153 }
75154
75155 -static inline long __must_check PTR_ERR(__force const void *ptr)
75156 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
75157 {
75158 return (long) ptr;
75159 }
75160 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
75161 index fcb51c8..bdafcf6 100644
75162 --- a/include/linux/extcon.h
75163 +++ b/include/linux/extcon.h
75164 @@ -134,7 +134,7 @@ struct extcon_dev {
75165 /* /sys/class/extcon/.../mutually_exclusive/... */
75166 struct attribute_group attr_g_muex;
75167 struct attribute **attrs_muex;
75168 - struct device_attribute *d_attrs_muex;
75169 + device_attribute_no_const *d_attrs_muex;
75170 };
75171
75172 /**
75173 diff --git a/include/linux/fb.h b/include/linux/fb.h
75174 index ffac70a..ca3e711 100644
75175 --- a/include/linux/fb.h
75176 +++ b/include/linux/fb.h
75177 @@ -304,7 +304,7 @@ struct fb_ops {
75178 /* called at KDB enter and leave time to prepare the console */
75179 int (*fb_debug_enter)(struct fb_info *info);
75180 int (*fb_debug_leave)(struct fb_info *info);
75181 -};
75182 +} __do_const;
75183
75184 #ifdef CONFIG_FB_TILEBLITTING
75185 #define FB_TILE_CURSOR_NONE 0
75186 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
75187 index 085197b..0fa6f0b 100644
75188 --- a/include/linux/fdtable.h
75189 +++ b/include/linux/fdtable.h
75190 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
75191 void put_files_struct(struct files_struct *fs);
75192 void reset_files_struct(struct files_struct *);
75193 int unshare_files(struct files_struct **);
75194 -struct files_struct *dup_fd(struct files_struct *, int *);
75195 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
75196 void do_close_on_exec(struct files_struct *);
75197 int iterate_fd(struct files_struct *, unsigned,
75198 int (*)(const void *, struct file *, unsigned),
75199 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
75200 index 8293262..2b3b8bd 100644
75201 --- a/include/linux/frontswap.h
75202 +++ b/include/linux/frontswap.h
75203 @@ -11,7 +11,7 @@ struct frontswap_ops {
75204 int (*load)(unsigned, pgoff_t, struct page *);
75205 void (*invalidate_page)(unsigned, pgoff_t);
75206 void (*invalidate_area)(unsigned);
75207 -};
75208 +} __no_const;
75209
75210 extern bool frontswap_enabled;
75211 extern struct frontswap_ops *
75212 diff --git a/include/linux/fs.h b/include/linux/fs.h
75213 index 164d2a9..0ffa41d0 100644
75214 --- a/include/linux/fs.h
75215 +++ b/include/linux/fs.h
75216 @@ -1552,7 +1552,8 @@ struct file_operations {
75217 long (*fallocate)(struct file *file, int mode, loff_t offset,
75218 loff_t len);
75219 int (*show_fdinfo)(struct seq_file *m, struct file *f);
75220 -};
75221 +} __do_const;
75222 +typedef struct file_operations __no_const file_operations_no_const;
75223
75224 struct inode_operations {
75225 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
75226 @@ -2747,4 +2748,14 @@ static inline bool dir_relax(struct inode *inode)
75227 return !IS_DEADDIR(inode);
75228 }
75229
75230 +static inline bool is_sidechannel_device(const struct inode *inode)
75231 +{
75232 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
75233 + umode_t mode = inode->i_mode;
75234 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
75235 +#else
75236 + return false;
75237 +#endif
75238 +}
75239 +
75240 #endif /* _LINUX_FS_H */
75241 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
75242 index 0efc3e6..e0e1e5f 100644
75243 --- a/include/linux/fs_struct.h
75244 +++ b/include/linux/fs_struct.h
75245 @@ -6,7 +6,7 @@
75246 #include <linux/seqlock.h>
75247
75248 struct fs_struct {
75249 - int users;
75250 + atomic_t users;
75251 spinlock_t lock;
75252 seqcount_t seq;
75253 int umask;
75254 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
75255 index 7823e9e..56b6f2f 100644
75256 --- a/include/linux/fscache-cache.h
75257 +++ b/include/linux/fscache-cache.h
75258 @@ -113,7 +113,7 @@ struct fscache_operation {
75259 fscache_operation_release_t release;
75260 };
75261
75262 -extern atomic_t fscache_op_debug_id;
75263 +extern atomic_unchecked_t fscache_op_debug_id;
75264 extern void fscache_op_work_func(struct work_struct *work);
75265
75266 extern void fscache_enqueue_operation(struct fscache_operation *);
75267 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
75268 INIT_WORK(&op->work, fscache_op_work_func);
75269 atomic_set(&op->usage, 1);
75270 op->state = FSCACHE_OP_ST_INITIALISED;
75271 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
75272 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
75273 op->processor = processor;
75274 op->release = release;
75275 INIT_LIST_HEAD(&op->pend_link);
75276 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
75277 index 19b4645..3b73dfc 100644
75278 --- a/include/linux/fscache.h
75279 +++ b/include/linux/fscache.h
75280 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
75281 * - this is mandatory for any object that may have data
75282 */
75283 void (*now_uncached)(void *cookie_netfs_data);
75284 -};
75285 +} __do_const;
75286
75287 /*
75288 * fscache cached network filesystem type
75289 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
75290 index 1c804b0..1432c2b 100644
75291 --- a/include/linux/fsnotify.h
75292 +++ b/include/linux/fsnotify.h
75293 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
75294 struct inode *inode = file_inode(file);
75295 __u32 mask = FS_ACCESS;
75296
75297 + if (is_sidechannel_device(inode))
75298 + return;
75299 +
75300 if (S_ISDIR(inode->i_mode))
75301 mask |= FS_ISDIR;
75302
75303 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
75304 struct inode *inode = file_inode(file);
75305 __u32 mask = FS_MODIFY;
75306
75307 + if (is_sidechannel_device(inode))
75308 + return;
75309 +
75310 if (S_ISDIR(inode->i_mode))
75311 mask |= FS_ISDIR;
75312
75313 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
75314 */
75315 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
75316 {
75317 - return kstrdup(name, GFP_KERNEL);
75318 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
75319 }
75320
75321 /*
75322 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
75323 index 9f3c275..8bdff5d 100644
75324 --- a/include/linux/genhd.h
75325 +++ b/include/linux/genhd.h
75326 @@ -194,7 +194,7 @@ struct gendisk {
75327 struct kobject *slave_dir;
75328
75329 struct timer_rand_state *random;
75330 - atomic_t sync_io; /* RAID */
75331 + atomic_unchecked_t sync_io; /* RAID */
75332 struct disk_events *ev;
75333 #ifdef CONFIG_BLK_DEV_INTEGRITY
75334 struct blk_integrity *integrity;
75335 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
75336 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
75337
75338 /* drivers/char/random.c */
75339 -extern void add_disk_randomness(struct gendisk *disk);
75340 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
75341 extern void rand_initialize_disk(struct gendisk *disk);
75342
75343 static inline sector_t get_start_sect(struct block_device *bdev)
75344 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
75345 index 023bc34..b02b46a 100644
75346 --- a/include/linux/genl_magic_func.h
75347 +++ b/include/linux/genl_magic_func.h
75348 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
75349 },
75350
75351 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
75352 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
75353 +static struct genl_ops ZZZ_genl_ops[] = {
75354 #include GENL_MAGIC_INCLUDE_FILE
75355 };
75356
75357 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
75358 index 9b4dd49..61fd41d 100644
75359 --- a/include/linux/gfp.h
75360 +++ b/include/linux/gfp.h
75361 @@ -35,6 +35,13 @@ struct vm_area_struct;
75362 #define ___GFP_NO_KSWAPD 0x400000u
75363 #define ___GFP_OTHER_NODE 0x800000u
75364 #define ___GFP_WRITE 0x1000000u
75365 +
75366 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75367 +#define ___GFP_USERCOPY 0x2000000u
75368 +#else
75369 +#define ___GFP_USERCOPY 0
75370 +#endif
75371 +
75372 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
75373
75374 /*
75375 @@ -92,6 +99,7 @@ struct vm_area_struct;
75376 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
75377 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
75378 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
75379 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
75380
75381 /*
75382 * This may seem redundant, but it's a way of annotating false positives vs.
75383 @@ -99,7 +107,7 @@ struct vm_area_struct;
75384 */
75385 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
75386
75387 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
75388 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
75389 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
75390
75391 /* This equals 0, but use constants in case they ever change */
75392 @@ -153,6 +161,8 @@ struct vm_area_struct;
75393 /* 4GB DMA on some platforms */
75394 #define GFP_DMA32 __GFP_DMA32
75395
75396 +#define GFP_USERCOPY __GFP_USERCOPY
75397 +
75398 /* Convert GFP flags to their corresponding migrate type */
75399 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
75400 {
75401 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
75402 new file mode 100644
75403 index 0000000..edb2cb6
75404 --- /dev/null
75405 +++ b/include/linux/gracl.h
75406 @@ -0,0 +1,340 @@
75407 +#ifndef GR_ACL_H
75408 +#define GR_ACL_H
75409 +
75410 +#include <linux/grdefs.h>
75411 +#include <linux/resource.h>
75412 +#include <linux/capability.h>
75413 +#include <linux/dcache.h>
75414 +#include <asm/resource.h>
75415 +
75416 +/* Major status information */
75417 +
75418 +#define GR_VERSION "grsecurity 3.0"
75419 +#define GRSECURITY_VERSION 0x3000
75420 +
75421 +enum {
75422 + GR_SHUTDOWN = 0,
75423 + GR_ENABLE = 1,
75424 + GR_SPROLE = 2,
75425 + GR_OLDRELOAD = 3,
75426 + GR_SEGVMOD = 4,
75427 + GR_STATUS = 5,
75428 + GR_UNSPROLE = 6,
75429 + GR_PASSSET = 7,
75430 + GR_SPROLEPAM = 8,
75431 + GR_RELOAD = 9,
75432 +};
75433 +
75434 +/* Password setup definitions
75435 + * kernel/grhash.c */
75436 +enum {
75437 + GR_PW_LEN = 128,
75438 + GR_SALT_LEN = 16,
75439 + GR_SHA_LEN = 32,
75440 +};
75441 +
75442 +enum {
75443 + GR_SPROLE_LEN = 64,
75444 +};
75445 +
75446 +enum {
75447 + GR_NO_GLOB = 0,
75448 + GR_REG_GLOB,
75449 + GR_CREATE_GLOB
75450 +};
75451 +
75452 +#define GR_NLIMITS 32
75453 +
75454 +/* Begin Data Structures */
75455 +
75456 +struct sprole_pw {
75457 + unsigned char *rolename;
75458 + unsigned char salt[GR_SALT_LEN];
75459 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
75460 +};
75461 +
75462 +struct name_entry {
75463 + __u32 key;
75464 + ino_t inode;
75465 + dev_t device;
75466 + char *name;
75467 + __u16 len;
75468 + __u8 deleted;
75469 + struct name_entry *prev;
75470 + struct name_entry *next;
75471 +};
75472 +
75473 +struct inodev_entry {
75474 + struct name_entry *nentry;
75475 + struct inodev_entry *prev;
75476 + struct inodev_entry *next;
75477 +};
75478 +
75479 +struct acl_role_db {
75480 + struct acl_role_label **r_hash;
75481 + __u32 r_size;
75482 +};
75483 +
75484 +struct inodev_db {
75485 + struct inodev_entry **i_hash;
75486 + __u32 i_size;
75487 +};
75488 +
75489 +struct name_db {
75490 + struct name_entry **n_hash;
75491 + __u32 n_size;
75492 +};
75493 +
75494 +struct crash_uid {
75495 + uid_t uid;
75496 + unsigned long expires;
75497 +};
75498 +
75499 +struct gr_hash_struct {
75500 + void **table;
75501 + void **nametable;
75502 + void *first;
75503 + __u32 table_size;
75504 + __u32 used_size;
75505 + int type;
75506 +};
75507 +
75508 +/* Userspace Grsecurity ACL data structures */
75509 +
75510 +struct acl_subject_label {
75511 + char *filename;
75512 + ino_t inode;
75513 + dev_t device;
75514 + __u32 mode;
75515 + kernel_cap_t cap_mask;
75516 + kernel_cap_t cap_lower;
75517 + kernel_cap_t cap_invert_audit;
75518 +
75519 + struct rlimit res[GR_NLIMITS];
75520 + __u32 resmask;
75521 +
75522 + __u8 user_trans_type;
75523 + __u8 group_trans_type;
75524 + uid_t *user_transitions;
75525 + gid_t *group_transitions;
75526 + __u16 user_trans_num;
75527 + __u16 group_trans_num;
75528 +
75529 + __u32 sock_families[2];
75530 + __u32 ip_proto[8];
75531 + __u32 ip_type;
75532 + struct acl_ip_label **ips;
75533 + __u32 ip_num;
75534 + __u32 inaddr_any_override;
75535 +
75536 + __u32 crashes;
75537 + unsigned long expires;
75538 +
75539 + struct acl_subject_label *parent_subject;
75540 + struct gr_hash_struct *hash;
75541 + struct acl_subject_label *prev;
75542 + struct acl_subject_label *next;
75543 +
75544 + struct acl_object_label **obj_hash;
75545 + __u32 obj_hash_size;
75546 + __u16 pax_flags;
75547 +};
75548 +
75549 +struct role_allowed_ip {
75550 + __u32 addr;
75551 + __u32 netmask;
75552 +
75553 + struct role_allowed_ip *prev;
75554 + struct role_allowed_ip *next;
75555 +};
75556 +
75557 +struct role_transition {
75558 + char *rolename;
75559 +
75560 + struct role_transition *prev;
75561 + struct role_transition *next;
75562 +};
75563 +
75564 +struct acl_role_label {
75565 + char *rolename;
75566 + uid_t uidgid;
75567 + __u16 roletype;
75568 +
75569 + __u16 auth_attempts;
75570 + unsigned long expires;
75571 +
75572 + struct acl_subject_label *root_label;
75573 + struct gr_hash_struct *hash;
75574 +
75575 + struct acl_role_label *prev;
75576 + struct acl_role_label *next;
75577 +
75578 + struct role_transition *transitions;
75579 + struct role_allowed_ip *allowed_ips;
75580 + uid_t *domain_children;
75581 + __u16 domain_child_num;
75582 +
75583 + umode_t umask;
75584 +
75585 + struct acl_subject_label **subj_hash;
75586 + __u32 subj_hash_size;
75587 +};
75588 +
75589 +struct user_acl_role_db {
75590 + struct acl_role_label **r_table;
75591 + __u32 num_pointers; /* Number of allocations to track */
75592 + __u32 num_roles; /* Number of roles */
75593 + __u32 num_domain_children; /* Number of domain children */
75594 + __u32 num_subjects; /* Number of subjects */
75595 + __u32 num_objects; /* Number of objects */
75596 +};
75597 +
75598 +struct acl_object_label {
75599 + char *filename;
75600 + ino_t inode;
75601 + dev_t device;
75602 + __u32 mode;
75603 +
75604 + struct acl_subject_label *nested;
75605 + struct acl_object_label *globbed;
75606 +
75607 + /* next two structures not used */
75608 +
75609 + struct acl_object_label *prev;
75610 + struct acl_object_label *next;
75611 +};
75612 +
75613 +struct acl_ip_label {
75614 + char *iface;
75615 + __u32 addr;
75616 + __u32 netmask;
75617 + __u16 low, high;
75618 + __u8 mode;
75619 + __u32 type;
75620 + __u32 proto[8];
75621 +
75622 + /* next two structures not used */
75623 +
75624 + struct acl_ip_label *prev;
75625 + struct acl_ip_label *next;
75626 +};
75627 +
75628 +struct gr_arg {
75629 + struct user_acl_role_db role_db;
75630 + unsigned char pw[GR_PW_LEN];
75631 + unsigned char salt[GR_SALT_LEN];
75632 + unsigned char sum[GR_SHA_LEN];
75633 + unsigned char sp_role[GR_SPROLE_LEN];
75634 + struct sprole_pw *sprole_pws;
75635 + dev_t segv_device;
75636 + ino_t segv_inode;
75637 + uid_t segv_uid;
75638 + __u16 num_sprole_pws;
75639 + __u16 mode;
75640 +};
75641 +
75642 +struct gr_arg_wrapper {
75643 + struct gr_arg *arg;
75644 + __u32 version;
75645 + __u32 size;
75646 +};
75647 +
75648 +struct subject_map {
75649 + struct acl_subject_label *user;
75650 + struct acl_subject_label *kernel;
75651 + struct subject_map *prev;
75652 + struct subject_map *next;
75653 +};
75654 +
75655 +struct acl_subj_map_db {
75656 + struct subject_map **s_hash;
75657 + __u32 s_size;
75658 +};
75659 +
75660 +struct gr_policy_state {
75661 + struct sprole_pw **acl_special_roles;
75662 + __u16 num_sprole_pws;
75663 + struct acl_role_label *kernel_role;
75664 + struct acl_role_label *role_list;
75665 + struct acl_role_label *default_role;
75666 + struct acl_role_db acl_role_set;
75667 + struct acl_subj_map_db subj_map_set;
75668 + struct name_db name_set;
75669 + struct inodev_db inodev_set;
75670 +};
75671 +
75672 +struct gr_alloc_state {
75673 + unsigned long alloc_stack_next;
75674 + unsigned long alloc_stack_size;
75675 + void **alloc_stack;
75676 +};
75677 +
75678 +struct gr_reload_state {
75679 + struct gr_policy_state oldpolicy;
75680 + struct gr_alloc_state oldalloc;
75681 + struct gr_policy_state newpolicy;
75682 + struct gr_alloc_state newalloc;
75683 + struct gr_policy_state *oldpolicy_ptr;
75684 + struct gr_alloc_state *oldalloc_ptr;
75685 + unsigned char oldmode;
75686 +};
75687 +
75688 +/* End Data Structures Section */
75689 +
75690 +/* Hash functions generated by empirical testing by Brad Spengler
75691 + Makes good use of the low bits of the inode. Generally 0-1 times
75692 + in loop for successful match. 0-3 for unsuccessful match.
75693 + Shift/add algorithm with modulus of table size and an XOR*/
75694 +
75695 +static __inline__ unsigned int
75696 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
75697 +{
75698 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
75699 +}
75700 +
75701 + static __inline__ unsigned int
75702 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
75703 +{
75704 + return ((const unsigned long)userp % sz);
75705 +}
75706 +
75707 +static __inline__ unsigned int
75708 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
75709 +{
75710 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
75711 +}
75712 +
75713 +static __inline__ unsigned int
75714 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
75715 +{
75716 + return full_name_hash((const unsigned char *)name, len) % sz;
75717 +}
75718 +
75719 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
75720 + subj = NULL; \
75721 + iter = 0; \
75722 + while (iter < role->subj_hash_size) { \
75723 + if (subj == NULL) \
75724 + subj = role->subj_hash[iter]; \
75725 + if (subj == NULL) { \
75726 + iter++; \
75727 + continue; \
75728 + }
75729 +
75730 +#define FOR_EACH_SUBJECT_END(subj,iter) \
75731 + subj = subj->next; \
75732 + if (subj == NULL) \
75733 + iter++; \
75734 + }
75735 +
75736 +
75737 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
75738 + subj = role->hash->first; \
75739 + while (subj != NULL) {
75740 +
75741 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
75742 + subj = subj->next; \
75743 + }
75744 +
75745 +#endif
75746 +
75747 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
75748 new file mode 100644
75749 index 0000000..33ebd1f
75750 --- /dev/null
75751 +++ b/include/linux/gracl_compat.h
75752 @@ -0,0 +1,156 @@
75753 +#ifndef GR_ACL_COMPAT_H
75754 +#define GR_ACL_COMPAT_H
75755 +
75756 +#include <linux/resource.h>
75757 +#include <asm/resource.h>
75758 +
75759 +struct sprole_pw_compat {
75760 + compat_uptr_t rolename;
75761 + unsigned char salt[GR_SALT_LEN];
75762 + unsigned char sum[GR_SHA_LEN];
75763 +};
75764 +
75765 +struct gr_hash_struct_compat {
75766 + compat_uptr_t table;
75767 + compat_uptr_t nametable;
75768 + compat_uptr_t first;
75769 + __u32 table_size;
75770 + __u32 used_size;
75771 + int type;
75772 +};
75773 +
75774 +struct acl_subject_label_compat {
75775 + compat_uptr_t filename;
75776 + compat_ino_t inode;
75777 + __u32 device;
75778 + __u32 mode;
75779 + kernel_cap_t cap_mask;
75780 + kernel_cap_t cap_lower;
75781 + kernel_cap_t cap_invert_audit;
75782 +
75783 + struct compat_rlimit res[GR_NLIMITS];
75784 + __u32 resmask;
75785 +
75786 + __u8 user_trans_type;
75787 + __u8 group_trans_type;
75788 + compat_uptr_t user_transitions;
75789 + compat_uptr_t group_transitions;
75790 + __u16 user_trans_num;
75791 + __u16 group_trans_num;
75792 +
75793 + __u32 sock_families[2];
75794 + __u32 ip_proto[8];
75795 + __u32 ip_type;
75796 + compat_uptr_t ips;
75797 + __u32 ip_num;
75798 + __u32 inaddr_any_override;
75799 +
75800 + __u32 crashes;
75801 + compat_ulong_t expires;
75802 +
75803 + compat_uptr_t parent_subject;
75804 + compat_uptr_t hash;
75805 + compat_uptr_t prev;
75806 + compat_uptr_t next;
75807 +
75808 + compat_uptr_t obj_hash;
75809 + __u32 obj_hash_size;
75810 + __u16 pax_flags;
75811 +};
75812 +
75813 +struct role_allowed_ip_compat {
75814 + __u32 addr;
75815 + __u32 netmask;
75816 +
75817 + compat_uptr_t prev;
75818 + compat_uptr_t next;
75819 +};
75820 +
75821 +struct role_transition_compat {
75822 + compat_uptr_t rolename;
75823 +
75824 + compat_uptr_t prev;
75825 + compat_uptr_t next;
75826 +};
75827 +
75828 +struct acl_role_label_compat {
75829 + compat_uptr_t rolename;
75830 + uid_t uidgid;
75831 + __u16 roletype;
75832 +
75833 + __u16 auth_attempts;
75834 + compat_ulong_t expires;
75835 +
75836 + compat_uptr_t root_label;
75837 + compat_uptr_t hash;
75838 +
75839 + compat_uptr_t prev;
75840 + compat_uptr_t next;
75841 +
75842 + compat_uptr_t transitions;
75843 + compat_uptr_t allowed_ips;
75844 + compat_uptr_t domain_children;
75845 + __u16 domain_child_num;
75846 +
75847 + umode_t umask;
75848 +
75849 + compat_uptr_t subj_hash;
75850 + __u32 subj_hash_size;
75851 +};
75852 +
75853 +struct user_acl_role_db_compat {
75854 + compat_uptr_t r_table;
75855 + __u32 num_pointers;
75856 + __u32 num_roles;
75857 + __u32 num_domain_children;
75858 + __u32 num_subjects;
75859 + __u32 num_objects;
75860 +};
75861 +
75862 +struct acl_object_label_compat {
75863 + compat_uptr_t filename;
75864 + compat_ino_t inode;
75865 + __u32 device;
75866 + __u32 mode;
75867 +
75868 + compat_uptr_t nested;
75869 + compat_uptr_t globbed;
75870 +
75871 + compat_uptr_t prev;
75872 + compat_uptr_t next;
75873 +};
75874 +
75875 +struct acl_ip_label_compat {
75876 + compat_uptr_t iface;
75877 + __u32 addr;
75878 + __u32 netmask;
75879 + __u16 low, high;
75880 + __u8 mode;
75881 + __u32 type;
75882 + __u32 proto[8];
75883 +
75884 + compat_uptr_t prev;
75885 + compat_uptr_t next;
75886 +};
75887 +
75888 +struct gr_arg_compat {
75889 + struct user_acl_role_db_compat role_db;
75890 + unsigned char pw[GR_PW_LEN];
75891 + unsigned char salt[GR_SALT_LEN];
75892 + unsigned char sum[GR_SHA_LEN];
75893 + unsigned char sp_role[GR_SPROLE_LEN];
75894 + compat_uptr_t sprole_pws;
75895 + __u32 segv_device;
75896 + compat_ino_t segv_inode;
75897 + uid_t segv_uid;
75898 + __u16 num_sprole_pws;
75899 + __u16 mode;
75900 +};
75901 +
75902 +struct gr_arg_wrapper_compat {
75903 + compat_uptr_t arg;
75904 + __u32 version;
75905 + __u32 size;
75906 +};
75907 +
75908 +#endif
75909 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
75910 new file mode 100644
75911 index 0000000..323ecf2
75912 --- /dev/null
75913 +++ b/include/linux/gralloc.h
75914 @@ -0,0 +1,9 @@
75915 +#ifndef __GRALLOC_H
75916 +#define __GRALLOC_H
75917 +
75918 +void acl_free_all(void);
75919 +int acl_alloc_stack_init(unsigned long size);
75920 +void *acl_alloc(unsigned long len);
75921 +void *acl_alloc_num(unsigned long num, unsigned long len);
75922 +
75923 +#endif
75924 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
75925 new file mode 100644
75926 index 0000000..be66033
75927 --- /dev/null
75928 +++ b/include/linux/grdefs.h
75929 @@ -0,0 +1,140 @@
75930 +#ifndef GRDEFS_H
75931 +#define GRDEFS_H
75932 +
75933 +/* Begin grsecurity status declarations */
75934 +
75935 +enum {
75936 + GR_READY = 0x01,
75937 + GR_STATUS_INIT = 0x00 // disabled state
75938 +};
75939 +
75940 +/* Begin ACL declarations */
75941 +
75942 +/* Role flags */
75943 +
75944 +enum {
75945 + GR_ROLE_USER = 0x0001,
75946 + GR_ROLE_GROUP = 0x0002,
75947 + GR_ROLE_DEFAULT = 0x0004,
75948 + GR_ROLE_SPECIAL = 0x0008,
75949 + GR_ROLE_AUTH = 0x0010,
75950 + GR_ROLE_NOPW = 0x0020,
75951 + GR_ROLE_GOD = 0x0040,
75952 + GR_ROLE_LEARN = 0x0080,
75953 + GR_ROLE_TPE = 0x0100,
75954 + GR_ROLE_DOMAIN = 0x0200,
75955 + GR_ROLE_PAM = 0x0400,
75956 + GR_ROLE_PERSIST = 0x0800
75957 +};
75958 +
75959 +/* ACL Subject and Object mode flags */
75960 +enum {
75961 + GR_DELETED = 0x80000000
75962 +};
75963 +
75964 +/* ACL Object-only mode flags */
75965 +enum {
75966 + GR_READ = 0x00000001,
75967 + GR_APPEND = 0x00000002,
75968 + GR_WRITE = 0x00000004,
75969 + GR_EXEC = 0x00000008,
75970 + GR_FIND = 0x00000010,
75971 + GR_INHERIT = 0x00000020,
75972 + GR_SETID = 0x00000040,
75973 + GR_CREATE = 0x00000080,
75974 + GR_DELETE = 0x00000100,
75975 + GR_LINK = 0x00000200,
75976 + GR_AUDIT_READ = 0x00000400,
75977 + GR_AUDIT_APPEND = 0x00000800,
75978 + GR_AUDIT_WRITE = 0x00001000,
75979 + GR_AUDIT_EXEC = 0x00002000,
75980 + GR_AUDIT_FIND = 0x00004000,
75981 + GR_AUDIT_INHERIT= 0x00008000,
75982 + GR_AUDIT_SETID = 0x00010000,
75983 + GR_AUDIT_CREATE = 0x00020000,
75984 + GR_AUDIT_DELETE = 0x00040000,
75985 + GR_AUDIT_LINK = 0x00080000,
75986 + GR_PTRACERD = 0x00100000,
75987 + GR_NOPTRACE = 0x00200000,
75988 + GR_SUPPRESS = 0x00400000,
75989 + GR_NOLEARN = 0x00800000,
75990 + GR_INIT_TRANSFER= 0x01000000
75991 +};
75992 +
75993 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
75994 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
75995 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
75996 +
75997 +/* ACL subject-only mode flags */
75998 +enum {
75999 + GR_KILL = 0x00000001,
76000 + GR_VIEW = 0x00000002,
76001 + GR_PROTECTED = 0x00000004,
76002 + GR_LEARN = 0x00000008,
76003 + GR_OVERRIDE = 0x00000010,
76004 + /* just a placeholder, this mode is only used in userspace */
76005 + GR_DUMMY = 0x00000020,
76006 + GR_PROTSHM = 0x00000040,
76007 + GR_KILLPROC = 0x00000080,
76008 + GR_KILLIPPROC = 0x00000100,
76009 + /* just a placeholder, this mode is only used in userspace */
76010 + GR_NOTROJAN = 0x00000200,
76011 + GR_PROTPROCFD = 0x00000400,
76012 + GR_PROCACCT = 0x00000800,
76013 + GR_RELAXPTRACE = 0x00001000,
76014 + //GR_NESTED = 0x00002000,
76015 + GR_INHERITLEARN = 0x00004000,
76016 + GR_PROCFIND = 0x00008000,
76017 + GR_POVERRIDE = 0x00010000,
76018 + GR_KERNELAUTH = 0x00020000,
76019 + GR_ATSECURE = 0x00040000,
76020 + GR_SHMEXEC = 0x00080000
76021 +};
76022 +
76023 +enum {
76024 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
76025 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
76026 + GR_PAX_ENABLE_MPROTECT = 0x0004,
76027 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
76028 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
76029 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
76030 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
76031 + GR_PAX_DISABLE_MPROTECT = 0x0400,
76032 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
76033 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
76034 +};
76035 +
76036 +enum {
76037 + GR_ID_USER = 0x01,
76038 + GR_ID_GROUP = 0x02,
76039 +};
76040 +
76041 +enum {
76042 + GR_ID_ALLOW = 0x01,
76043 + GR_ID_DENY = 0x02,
76044 +};
76045 +
76046 +#define GR_CRASH_RES 31
76047 +#define GR_UIDTABLE_MAX 500
76048 +
76049 +/* begin resource learning section */
76050 +enum {
76051 + GR_RLIM_CPU_BUMP = 60,
76052 + GR_RLIM_FSIZE_BUMP = 50000,
76053 + GR_RLIM_DATA_BUMP = 10000,
76054 + GR_RLIM_STACK_BUMP = 1000,
76055 + GR_RLIM_CORE_BUMP = 10000,
76056 + GR_RLIM_RSS_BUMP = 500000,
76057 + GR_RLIM_NPROC_BUMP = 1,
76058 + GR_RLIM_NOFILE_BUMP = 5,
76059 + GR_RLIM_MEMLOCK_BUMP = 50000,
76060 + GR_RLIM_AS_BUMP = 500000,
76061 + GR_RLIM_LOCKS_BUMP = 2,
76062 + GR_RLIM_SIGPENDING_BUMP = 5,
76063 + GR_RLIM_MSGQUEUE_BUMP = 10000,
76064 + GR_RLIM_NICE_BUMP = 1,
76065 + GR_RLIM_RTPRIO_BUMP = 1,
76066 + GR_RLIM_RTTIME_BUMP = 1000000
76067 +};
76068 +
76069 +#endif
76070 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
76071 new file mode 100644
76072 index 0000000..d25522e
76073 --- /dev/null
76074 +++ b/include/linux/grinternal.h
76075 @@ -0,0 +1,229 @@
76076 +#ifndef __GRINTERNAL_H
76077 +#define __GRINTERNAL_H
76078 +
76079 +#ifdef CONFIG_GRKERNSEC
76080 +
76081 +#include <linux/fs.h>
76082 +#include <linux/mnt_namespace.h>
76083 +#include <linux/nsproxy.h>
76084 +#include <linux/gracl.h>
76085 +#include <linux/grdefs.h>
76086 +#include <linux/grmsg.h>
76087 +
76088 +void gr_add_learn_entry(const char *fmt, ...)
76089 + __attribute__ ((format (printf, 1, 2)));
76090 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
76091 + const struct vfsmount *mnt);
76092 +__u32 gr_check_create(const struct dentry *new_dentry,
76093 + const struct dentry *parent,
76094 + const struct vfsmount *mnt, const __u32 mode);
76095 +int gr_check_protected_task(const struct task_struct *task);
76096 +__u32 to_gr_audit(const __u32 reqmode);
76097 +int gr_set_acls(const int type);
76098 +int gr_acl_is_enabled(void);
76099 +char gr_roletype_to_char(void);
76100 +
76101 +void gr_handle_alertkill(struct task_struct *task);
76102 +char *gr_to_filename(const struct dentry *dentry,
76103 + const struct vfsmount *mnt);
76104 +char *gr_to_filename1(const struct dentry *dentry,
76105 + const struct vfsmount *mnt);
76106 +char *gr_to_filename2(const struct dentry *dentry,
76107 + const struct vfsmount *mnt);
76108 +char *gr_to_filename3(const struct dentry *dentry,
76109 + const struct vfsmount *mnt);
76110 +
76111 +extern int grsec_enable_ptrace_readexec;
76112 +extern int grsec_enable_harden_ptrace;
76113 +extern int grsec_enable_link;
76114 +extern int grsec_enable_fifo;
76115 +extern int grsec_enable_execve;
76116 +extern int grsec_enable_shm;
76117 +extern int grsec_enable_execlog;
76118 +extern int grsec_enable_signal;
76119 +extern int grsec_enable_audit_ptrace;
76120 +extern int grsec_enable_forkfail;
76121 +extern int grsec_enable_time;
76122 +extern int grsec_enable_rofs;
76123 +extern int grsec_deny_new_usb;
76124 +extern int grsec_enable_chroot_shmat;
76125 +extern int grsec_enable_chroot_mount;
76126 +extern int grsec_enable_chroot_double;
76127 +extern int grsec_enable_chroot_pivot;
76128 +extern int grsec_enable_chroot_chdir;
76129 +extern int grsec_enable_chroot_chmod;
76130 +extern int grsec_enable_chroot_mknod;
76131 +extern int grsec_enable_chroot_fchdir;
76132 +extern int grsec_enable_chroot_nice;
76133 +extern int grsec_enable_chroot_execlog;
76134 +extern int grsec_enable_chroot_caps;
76135 +extern int grsec_enable_chroot_sysctl;
76136 +extern int grsec_enable_chroot_unix;
76137 +extern int grsec_enable_symlinkown;
76138 +extern kgid_t grsec_symlinkown_gid;
76139 +extern int grsec_enable_tpe;
76140 +extern kgid_t grsec_tpe_gid;
76141 +extern int grsec_enable_tpe_all;
76142 +extern int grsec_enable_tpe_invert;
76143 +extern int grsec_enable_socket_all;
76144 +extern kgid_t grsec_socket_all_gid;
76145 +extern int grsec_enable_socket_client;
76146 +extern kgid_t grsec_socket_client_gid;
76147 +extern int grsec_enable_socket_server;
76148 +extern kgid_t grsec_socket_server_gid;
76149 +extern kgid_t grsec_audit_gid;
76150 +extern int grsec_enable_group;
76151 +extern int grsec_enable_log_rwxmaps;
76152 +extern int grsec_enable_mount;
76153 +extern int grsec_enable_chdir;
76154 +extern int grsec_resource_logging;
76155 +extern int grsec_enable_blackhole;
76156 +extern int grsec_lastack_retries;
76157 +extern int grsec_enable_brute;
76158 +extern int grsec_enable_harden_ipc;
76159 +extern int grsec_lock;
76160 +
76161 +extern spinlock_t grsec_alert_lock;
76162 +extern unsigned long grsec_alert_wtime;
76163 +extern unsigned long grsec_alert_fyet;
76164 +
76165 +extern spinlock_t grsec_audit_lock;
76166 +
76167 +extern rwlock_t grsec_exec_file_lock;
76168 +
76169 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
76170 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
76171 + (tsk)->exec_file->f_path.mnt) : "/")
76172 +
76173 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
76174 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
76175 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
76176 +
76177 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
76178 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
76179 + (tsk)->exec_file->f_path.mnt) : "/")
76180 +
76181 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
76182 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
76183 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
76184 +
76185 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
76186 +
76187 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
76188 +
76189 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
76190 +{
76191 + if (file1 && file2) {
76192 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
76193 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
76194 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
76195 + return true;
76196 + }
76197 +
76198 + return false;
76199 +}
76200 +
76201 +#define GR_CHROOT_CAPS {{ \
76202 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
76203 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
76204 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
76205 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
76206 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
76207 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
76208 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
76209 +
76210 +#define security_learn(normal_msg,args...) \
76211 +({ \
76212 + read_lock(&grsec_exec_file_lock); \
76213 + gr_add_learn_entry(normal_msg "\n", ## args); \
76214 + read_unlock(&grsec_exec_file_lock); \
76215 +})
76216 +
76217 +enum {
76218 + GR_DO_AUDIT,
76219 + GR_DONT_AUDIT,
76220 + /* used for non-audit messages that we shouldn't kill the task on */
76221 + GR_DONT_AUDIT_GOOD
76222 +};
76223 +
76224 +enum {
76225 + GR_TTYSNIFF,
76226 + GR_RBAC,
76227 + GR_RBAC_STR,
76228 + GR_STR_RBAC,
76229 + GR_RBAC_MODE2,
76230 + GR_RBAC_MODE3,
76231 + GR_FILENAME,
76232 + GR_SYSCTL_HIDDEN,
76233 + GR_NOARGS,
76234 + GR_ONE_INT,
76235 + GR_ONE_INT_TWO_STR,
76236 + GR_ONE_STR,
76237 + GR_STR_INT,
76238 + GR_TWO_STR_INT,
76239 + GR_TWO_INT,
76240 + GR_TWO_U64,
76241 + GR_THREE_INT,
76242 + GR_FIVE_INT_TWO_STR,
76243 + GR_TWO_STR,
76244 + GR_THREE_STR,
76245 + GR_FOUR_STR,
76246 + GR_STR_FILENAME,
76247 + GR_FILENAME_STR,
76248 + GR_FILENAME_TWO_INT,
76249 + GR_FILENAME_TWO_INT_STR,
76250 + GR_TEXTREL,
76251 + GR_PTRACE,
76252 + GR_RESOURCE,
76253 + GR_CAP,
76254 + GR_SIG,
76255 + GR_SIG2,
76256 + GR_CRASH1,
76257 + GR_CRASH2,
76258 + GR_PSACCT,
76259 + GR_RWXMAP,
76260 + GR_RWXMAPVMA
76261 +};
76262 +
76263 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
76264 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
76265 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
76266 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
76267 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
76268 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
76269 +#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)
76270 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
76271 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
76272 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
76273 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
76274 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
76275 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
76276 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
76277 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
76278 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
76279 +#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)
76280 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
76281 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
76282 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
76283 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
76284 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
76285 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
76286 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
76287 +#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)
76288 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
76289 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
76290 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
76291 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
76292 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
76293 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
76294 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
76295 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
76296 +#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)
76297 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
76298 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
76299 +
76300 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
76301 +
76302 +#endif
76303 +
76304 +#endif
76305 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
76306 new file mode 100644
76307 index 0000000..195cbe4
76308 --- /dev/null
76309 +++ b/include/linux/grmsg.h
76310 @@ -0,0 +1,115 @@
76311 +#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"
76312 +#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"
76313 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
76314 +#define GR_STOPMOD_MSG "denied modification of module state by "
76315 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
76316 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
76317 +#define GR_IOPERM_MSG "denied use of ioperm() by "
76318 +#define GR_IOPL_MSG "denied use of iopl() by "
76319 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
76320 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
76321 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
76322 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
76323 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
76324 +#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"
76325 +#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"
76326 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
76327 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
76328 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
76329 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
76330 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
76331 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
76332 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
76333 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
76334 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
76335 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
76336 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
76337 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
76338 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
76339 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
76340 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
76341 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
76342 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
76343 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
76344 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
76345 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
76346 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
76347 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
76348 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
76349 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
76350 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
76351 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
76352 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
76353 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
76354 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
76355 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
76356 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
76357 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
76358 +#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
76359 +#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
76360 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
76361 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
76362 +#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"
76363 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
76364 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
76365 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
76366 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
76367 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
76368 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
76369 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
76370 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
76371 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
76372 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
76373 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
76374 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
76375 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
76376 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
76377 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
76378 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
76379 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
76380 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
76381 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
76382 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
76383 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
76384 +#define GR_NICE_CHROOT_MSG "denied priority change by "
76385 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
76386 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
76387 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
76388 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
76389 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
76390 +#define GR_TIME_MSG "time set by "
76391 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
76392 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
76393 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
76394 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
76395 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
76396 +#define GR_BIND_MSG "denied bind() by "
76397 +#define GR_CONNECT_MSG "denied connect() by "
76398 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
76399 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
76400 +#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"
76401 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
76402 +#define GR_CAP_ACL_MSG "use of %s denied for "
76403 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
76404 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
76405 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
76406 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
76407 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
76408 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
76409 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
76410 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
76411 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
76412 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
76413 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
76414 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
76415 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
76416 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
76417 +#define GR_VM86_MSG "denied use of vm86 by "
76418 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
76419 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
76420 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
76421 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
76422 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
76423 +#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 "
76424 +#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 "
76425 +#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
76426 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
76427 new file mode 100644
76428 index 0000000..d8b5b48
76429 --- /dev/null
76430 +++ b/include/linux/grsecurity.h
76431 @@ -0,0 +1,245 @@
76432 +#ifndef GR_SECURITY_H
76433 +#define GR_SECURITY_H
76434 +#include <linux/fs.h>
76435 +#include <linux/fs_struct.h>
76436 +#include <linux/binfmts.h>
76437 +#include <linux/gracl.h>
76438 +
76439 +/* notify of brain-dead configs */
76440 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76441 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
76442 +#endif
76443 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
76444 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
76445 +#endif
76446 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
76447 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
76448 +#endif
76449 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
76450 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
76451 +#endif
76452 +
76453 +int gr_handle_new_usb(void);
76454 +
76455 +void gr_handle_brute_attach(int dumpable);
76456 +void gr_handle_brute_check(void);
76457 +void gr_handle_kernel_exploit(void);
76458 +
76459 +char gr_roletype_to_char(void);
76460 +
76461 +int gr_acl_enable_at_secure(void);
76462 +
76463 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
76464 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
76465 +
76466 +void gr_del_task_from_ip_table(struct task_struct *p);
76467 +
76468 +int gr_pid_is_chrooted(struct task_struct *p);
76469 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
76470 +int gr_handle_chroot_nice(void);
76471 +int gr_handle_chroot_sysctl(const int op);
76472 +int gr_handle_chroot_setpriority(struct task_struct *p,
76473 + const int niceval);
76474 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
76475 +int gr_handle_chroot_chroot(const struct dentry *dentry,
76476 + const struct vfsmount *mnt);
76477 +void gr_handle_chroot_chdir(const struct path *path);
76478 +int gr_handle_chroot_chmod(const struct dentry *dentry,
76479 + const struct vfsmount *mnt, const int mode);
76480 +int gr_handle_chroot_mknod(const struct dentry *dentry,
76481 + const struct vfsmount *mnt, const int mode);
76482 +int gr_handle_chroot_mount(const struct dentry *dentry,
76483 + const struct vfsmount *mnt,
76484 + const char *dev_name);
76485 +int gr_handle_chroot_pivot(void);
76486 +int gr_handle_chroot_unix(const pid_t pid);
76487 +
76488 +int gr_handle_rawio(const struct inode *inode);
76489 +
76490 +void gr_handle_ioperm(void);
76491 +void gr_handle_iopl(void);
76492 +
76493 +umode_t gr_acl_umask(void);
76494 +
76495 +int gr_tpe_allow(const struct file *file);
76496 +
76497 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
76498 +void gr_clear_chroot_entries(struct task_struct *task);
76499 +
76500 +void gr_log_forkfail(const int retval);
76501 +void gr_log_timechange(void);
76502 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
76503 +void gr_log_chdir(const struct dentry *dentry,
76504 + const struct vfsmount *mnt);
76505 +void gr_log_chroot_exec(const struct dentry *dentry,
76506 + const struct vfsmount *mnt);
76507 +void gr_log_remount(const char *devname, const int retval);
76508 +void gr_log_unmount(const char *devname, const int retval);
76509 +void gr_log_mount(const char *from, const char *to, const int retval);
76510 +void gr_log_textrel(struct vm_area_struct *vma);
76511 +void gr_log_ptgnustack(struct file *file);
76512 +void gr_log_rwxmmap(struct file *file);
76513 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
76514 +
76515 +int gr_handle_follow_link(const struct inode *parent,
76516 + const struct inode *inode,
76517 + const struct dentry *dentry,
76518 + const struct vfsmount *mnt);
76519 +int gr_handle_fifo(const struct dentry *dentry,
76520 + const struct vfsmount *mnt,
76521 + const struct dentry *dir, const int flag,
76522 + const int acc_mode);
76523 +int gr_handle_hardlink(const struct dentry *dentry,
76524 + const struct vfsmount *mnt,
76525 + struct inode *inode,
76526 + const int mode, const struct filename *to);
76527 +
76528 +int gr_is_capable(const int cap);
76529 +int gr_is_capable_nolog(const int cap);
76530 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
76531 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
76532 +
76533 +void gr_copy_label(struct task_struct *tsk);
76534 +void gr_handle_crash(struct task_struct *task, const int sig);
76535 +int gr_handle_signal(const struct task_struct *p, const int sig);
76536 +int gr_check_crash_uid(const kuid_t uid);
76537 +int gr_check_protected_task(const struct task_struct *task);
76538 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
76539 +int gr_acl_handle_mmap(const struct file *file,
76540 + const unsigned long prot);
76541 +int gr_acl_handle_mprotect(const struct file *file,
76542 + const unsigned long prot);
76543 +int gr_check_hidden_task(const struct task_struct *tsk);
76544 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
76545 + const struct vfsmount *mnt);
76546 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
76547 + const struct vfsmount *mnt);
76548 +__u32 gr_acl_handle_access(const struct dentry *dentry,
76549 + const struct vfsmount *mnt, const int fmode);
76550 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
76551 + const struct vfsmount *mnt, umode_t *mode);
76552 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
76553 + const struct vfsmount *mnt);
76554 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
76555 + const struct vfsmount *mnt);
76556 +__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
76557 + const struct vfsmount *mnt);
76558 +int gr_handle_ptrace(struct task_struct *task, const long request);
76559 +int gr_handle_proc_ptrace(struct task_struct *task);
76560 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
76561 + const struct vfsmount *mnt);
76562 +int gr_check_crash_exec(const struct file *filp);
76563 +int gr_acl_is_enabled(void);
76564 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
76565 + const kgid_t gid);
76566 +int gr_set_proc_label(const struct dentry *dentry,
76567 + const struct vfsmount *mnt,
76568 + const int unsafe_flags);
76569 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
76570 + const struct vfsmount *mnt);
76571 +__u32 gr_acl_handle_open(const struct dentry *dentry,
76572 + const struct vfsmount *mnt, int acc_mode);
76573 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
76574 + const struct dentry *p_dentry,
76575 + const struct vfsmount *p_mnt,
76576 + int open_flags, int acc_mode, const int imode);
76577 +void gr_handle_create(const struct dentry *dentry,
76578 + const struct vfsmount *mnt);
76579 +void gr_handle_proc_create(const struct dentry *dentry,
76580 + const struct inode *inode);
76581 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
76582 + const struct dentry *parent_dentry,
76583 + const struct vfsmount *parent_mnt,
76584 + const int mode);
76585 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
76586 + const struct dentry *parent_dentry,
76587 + const struct vfsmount *parent_mnt);
76588 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
76589 + const struct vfsmount *mnt);
76590 +void gr_handle_delete(const ino_t ino, const dev_t dev);
76591 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
76592 + const struct vfsmount *mnt);
76593 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
76594 + const struct dentry *parent_dentry,
76595 + const struct vfsmount *parent_mnt,
76596 + const struct filename *from);
76597 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
76598 + const struct dentry *parent_dentry,
76599 + const struct vfsmount *parent_mnt,
76600 + const struct dentry *old_dentry,
76601 + const struct vfsmount *old_mnt, const struct filename *to);
76602 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
76603 +int gr_acl_handle_rename(struct dentry *new_dentry,
76604 + struct dentry *parent_dentry,
76605 + const struct vfsmount *parent_mnt,
76606 + struct dentry *old_dentry,
76607 + struct inode *old_parent_inode,
76608 + struct vfsmount *old_mnt, const struct filename *newname);
76609 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
76610 + struct dentry *old_dentry,
76611 + struct dentry *new_dentry,
76612 + struct vfsmount *mnt, const __u8 replace);
76613 +__u32 gr_check_link(const struct dentry *new_dentry,
76614 + const struct dentry *parent_dentry,
76615 + const struct vfsmount *parent_mnt,
76616 + const struct dentry *old_dentry,
76617 + const struct vfsmount *old_mnt);
76618 +int gr_acl_handle_filldir(const struct file *file, const char *name,
76619 + const unsigned int namelen, const ino_t ino);
76620 +
76621 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
76622 + const struct vfsmount *mnt);
76623 +void gr_acl_handle_exit(void);
76624 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
76625 +int gr_acl_handle_procpidmem(const struct task_struct *task);
76626 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
76627 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
76628 +void gr_audit_ptrace(struct task_struct *task);
76629 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
76630 +void gr_put_exec_file(struct task_struct *task);
76631 +
76632 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
76633 +
76634 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
76635 +extern void gr_learn_resource(const struct task_struct *task, const int res,
76636 + const unsigned long wanted, const int gt);
76637 +#else
76638 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
76639 + const unsigned long wanted, const int gt)
76640 +{
76641 +}
76642 +#endif
76643 +
76644 +#ifdef CONFIG_GRKERNSEC_RESLOG
76645 +extern void gr_log_resource(const struct task_struct *task, const int res,
76646 + const unsigned long wanted, const int gt);
76647 +#else
76648 +static inline void gr_log_resource(const struct task_struct *task, const int res,
76649 + const unsigned long wanted, const int gt)
76650 +{
76651 +}
76652 +#endif
76653 +
76654 +#ifdef CONFIG_GRKERNSEC
76655 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
76656 +void gr_handle_vm86(void);
76657 +void gr_handle_mem_readwrite(u64 from, u64 to);
76658 +
76659 +void gr_log_badprocpid(const char *entry);
76660 +
76661 +extern int grsec_enable_dmesg;
76662 +extern int grsec_disable_privio;
76663 +
76664 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
76665 +extern kgid_t grsec_proc_gid;
76666 +#endif
76667 +
76668 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
76669 +extern int grsec_enable_chroot_findtask;
76670 +#endif
76671 +#ifdef CONFIG_GRKERNSEC_SETXID
76672 +extern int grsec_enable_setxid;
76673 +#endif
76674 +#endif
76675 +
76676 +#endif
76677 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
76678 new file mode 100644
76679 index 0000000..e7ffaaf
76680 --- /dev/null
76681 +++ b/include/linux/grsock.h
76682 @@ -0,0 +1,19 @@
76683 +#ifndef __GRSOCK_H
76684 +#define __GRSOCK_H
76685 +
76686 +extern void gr_attach_curr_ip(const struct sock *sk);
76687 +extern int gr_handle_sock_all(const int family, const int type,
76688 + const int protocol);
76689 +extern int gr_handle_sock_server(const struct sockaddr *sck);
76690 +extern int gr_handle_sock_server_other(const struct sock *sck);
76691 +extern int gr_handle_sock_client(const struct sockaddr *sck);
76692 +extern int gr_search_connect(struct socket * sock,
76693 + struct sockaddr_in * addr);
76694 +extern int gr_search_bind(struct socket * sock,
76695 + struct sockaddr_in * addr);
76696 +extern int gr_search_listen(struct socket * sock);
76697 +extern int gr_search_accept(struct socket * sock);
76698 +extern int gr_search_socket(const int domain, const int type,
76699 + const int protocol);
76700 +
76701 +#endif
76702 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
76703 index 7fb31da..08b5114 100644
76704 --- a/include/linux/highmem.h
76705 +++ b/include/linux/highmem.h
76706 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
76707 kunmap_atomic(kaddr);
76708 }
76709
76710 +static inline void sanitize_highpage(struct page *page)
76711 +{
76712 + void *kaddr;
76713 + unsigned long flags;
76714 +
76715 + local_irq_save(flags);
76716 + kaddr = kmap_atomic(page);
76717 + clear_page(kaddr);
76718 + kunmap_atomic(kaddr);
76719 + local_irq_restore(flags);
76720 +}
76721 +
76722 static inline void zero_user_segments(struct page *page,
76723 unsigned start1, unsigned end1,
76724 unsigned start2, unsigned end2)
76725 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
76726 index 1c7b89a..7dda400 100644
76727 --- a/include/linux/hwmon-sysfs.h
76728 +++ b/include/linux/hwmon-sysfs.h
76729 @@ -25,7 +25,8 @@
76730 struct sensor_device_attribute{
76731 struct device_attribute dev_attr;
76732 int index;
76733 -};
76734 +} __do_const;
76735 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
76736 #define to_sensor_dev_attr(_dev_attr) \
76737 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
76738
76739 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
76740 struct device_attribute dev_attr;
76741 u8 index;
76742 u8 nr;
76743 -};
76744 +} __do_const;
76745 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
76746 #define to_sensor_dev_attr_2(_dev_attr) \
76747 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
76748
76749 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
76750 index 2ab11dc..663a3f2 100644
76751 --- a/include/linux/i2c.h
76752 +++ b/include/linux/i2c.h
76753 @@ -366,6 +366,7 @@ struct i2c_algorithm {
76754 /* To determine what the adapter supports */
76755 u32 (*functionality) (struct i2c_adapter *);
76756 };
76757 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
76758
76759 /**
76760 * struct i2c_bus_recovery_info - I2C bus recovery information
76761 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
76762 index d23c3c2..eb63c81 100644
76763 --- a/include/linux/i2o.h
76764 +++ b/include/linux/i2o.h
76765 @@ -565,7 +565,7 @@ struct i2o_controller {
76766 struct i2o_device *exec; /* Executive */
76767 #if BITS_PER_LONG == 64
76768 spinlock_t context_list_lock; /* lock for context_list */
76769 - atomic_t context_list_counter; /* needed for unique contexts */
76770 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
76771 struct list_head context_list; /* list of context id's
76772 and pointers */
76773 #endif
76774 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
76775 index aff7ad8..3942bbd 100644
76776 --- a/include/linux/if_pppox.h
76777 +++ b/include/linux/if_pppox.h
76778 @@ -76,7 +76,7 @@ struct pppox_proto {
76779 int (*ioctl)(struct socket *sock, unsigned int cmd,
76780 unsigned long arg);
76781 struct module *owner;
76782 -};
76783 +} __do_const;
76784
76785 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
76786 extern void unregister_pppox_proto(int proto_num);
76787 diff --git a/include/linux/init.h b/include/linux/init.h
76788 index f1c27a71..7d6010e 100644
76789 --- a/include/linux/init.h
76790 +++ b/include/linux/init.h
76791 @@ -39,9 +39,17 @@
76792 * Also note, that this data cannot be "const".
76793 */
76794
76795 +#define add_init_latent_entropy __latent_entropy
76796 +
76797 +#ifdef CONFIG_MEMORY_HOTPLUG
76798 +#define add_meminit_latent_entropy
76799 +#else
76800 +#define add_meminit_latent_entropy __latent_entropy
76801 +#endif
76802 +
76803 /* These are for everybody (although not all archs will actually
76804 discard it in modules) */
76805 -#define __init __section(.init.text) __cold notrace
76806 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
76807 #define __initdata __section(.init.data)
76808 #define __initconst __constsection(.init.rodata)
76809 #define __exitdata __section(.exit.data)
76810 @@ -102,7 +110,7 @@
76811 #define __cpuexitconst
76812
76813 /* Used for MEMORY_HOTPLUG */
76814 -#define __meminit __section(.meminit.text) __cold notrace
76815 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
76816 #define __meminitdata __section(.meminit.data)
76817 #define __meminitconst __constsection(.meminit.rodata)
76818 #define __memexit __section(.memexit.text) __exitused __cold notrace
76819 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
76820 index 5cd0f09..c9f67cc 100644
76821 --- a/include/linux/init_task.h
76822 +++ b/include/linux/init_task.h
76823 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
76824
76825 #define INIT_TASK_COMM "swapper"
76826
76827 +#ifdef CONFIG_X86
76828 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
76829 +#else
76830 +#define INIT_TASK_THREAD_INFO
76831 +#endif
76832 +
76833 /*
76834 * INIT_TASK is used to set up the first task table, touch at
76835 * your own risk!. Base=0, limit=0x1fffff (=2MB)
76836 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
76837 RCU_POINTER_INITIALIZER(cred, &init_cred), \
76838 .comm = INIT_TASK_COMM, \
76839 .thread = INIT_THREAD, \
76840 + INIT_TASK_THREAD_INFO \
76841 .fs = &init_fs, \
76842 .files = &init_files, \
76843 .signal = &init_signals, \
76844 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
76845 index 5e865b5..71bd258 100644
76846 --- a/include/linux/interrupt.h
76847 +++ b/include/linux/interrupt.h
76848 @@ -361,7 +361,7 @@ enum
76849 /* map softirq index to softirq name. update 'softirq_to_name' in
76850 * kernel/softirq.c when adding a new softirq.
76851 */
76852 -extern char *softirq_to_name[NR_SOFTIRQS];
76853 +extern const char * const softirq_to_name[NR_SOFTIRQS];
76854
76855 /* softirq mask and active fields moved to irq_cpustat_t in
76856 * asm/hardirq.h to get better cache usage. KAO
76857 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
76858
76859 struct softirq_action
76860 {
76861 - void (*action)(struct softirq_action *);
76862 -};
76863 + void (*action)(void);
76864 +} __no_const;
76865
76866 asmlinkage void do_softirq(void);
76867 asmlinkage void __do_softirq(void);
76868 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
76869 +extern void open_softirq(int nr, void (*action)(void));
76870 extern void softirq_init(void);
76871 extern void __raise_softirq_irqoff(unsigned int nr);
76872
76873 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
76874 index 7ea319e..f9e971d 100644
76875 --- a/include/linux/iommu.h
76876 +++ b/include/linux/iommu.h
76877 @@ -129,7 +129,7 @@ struct iommu_ops {
76878 u32 (*domain_get_windows)(struct iommu_domain *domain);
76879
76880 unsigned long pgsize_bitmap;
76881 -};
76882 +} __do_const;
76883
76884 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
76885 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
76886 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
76887 index 89b7c24..382af74 100644
76888 --- a/include/linux/ioport.h
76889 +++ b/include/linux/ioport.h
76890 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
76891 int adjust_resource(struct resource *res, resource_size_t start,
76892 resource_size_t size);
76893 resource_size_t resource_alignment(struct resource *res);
76894 -static inline resource_size_t resource_size(const struct resource *res)
76895 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
76896 {
76897 return res->end - res->start + 1;
76898 }
76899 diff --git a/include/linux/irq.h b/include/linux/irq.h
76900 index 56bb0dc..8ae94d62 100644
76901 --- a/include/linux/irq.h
76902 +++ b/include/linux/irq.h
76903 @@ -333,7 +333,8 @@ struct irq_chip {
76904 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
76905
76906 unsigned long flags;
76907 -};
76908 +} __do_const;
76909 +typedef struct irq_chip __no_const irq_chip_no_const;
76910
76911 /*
76912 * irq_chip specific flags
76913 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
76914 index 0e5d9ec..46acb3a 100644
76915 --- a/include/linux/irqchip/arm-gic.h
76916 +++ b/include/linux/irqchip/arm-gic.h
76917 @@ -59,9 +59,11 @@
76918
76919 #ifndef __ASSEMBLY__
76920
76921 +#include <linux/irq.h>
76922 +
76923 struct device_node;
76924
76925 -extern struct irq_chip gic_arch_extn;
76926 +extern irq_chip_no_const gic_arch_extn;
76927
76928 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
76929 u32 offset, struct device_node *);
76930 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
76931 index d235e88..8ccbe74 100644
76932 --- a/include/linux/jiffies.h
76933 +++ b/include/linux/jiffies.h
76934 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
76935 /*
76936 * Convert various time units to each other:
76937 */
76938 -extern unsigned int jiffies_to_msecs(const unsigned long j);
76939 -extern unsigned int jiffies_to_usecs(const unsigned long j);
76940 -extern unsigned long msecs_to_jiffies(const unsigned int m);
76941 -extern unsigned long usecs_to_jiffies(const unsigned int u);
76942 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
76943 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
76944 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
76945 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
76946 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
76947 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
76948 extern void jiffies_to_timespec(const unsigned long jiffies,
76949 struct timespec *value);
76950 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
76951 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
76952 extern void jiffies_to_timeval(const unsigned long jiffies,
76953 struct timeval *value);
76954
76955 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
76956 index 6883e19..e854fcb 100644
76957 --- a/include/linux/kallsyms.h
76958 +++ b/include/linux/kallsyms.h
76959 @@ -15,7 +15,8 @@
76960
76961 struct module;
76962
76963 -#ifdef CONFIG_KALLSYMS
76964 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
76965 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76966 /* Lookup the address for a symbol. Returns 0 if not found. */
76967 unsigned long kallsyms_lookup_name(const char *name);
76968
76969 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
76970 /* Stupid that this does nothing, but I didn't create this mess. */
76971 #define __print_symbol(fmt, addr)
76972 #endif /*CONFIG_KALLSYMS*/
76973 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
76974 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
76975 +extern unsigned long kallsyms_lookup_name(const char *name);
76976 +extern void __print_symbol(const char *fmt, unsigned long address);
76977 +extern int sprint_backtrace(char *buffer, unsigned long address);
76978 +extern int sprint_symbol(char *buffer, unsigned long address);
76979 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
76980 +const char *kallsyms_lookup(unsigned long addr,
76981 + unsigned long *symbolsize,
76982 + unsigned long *offset,
76983 + char **modname, char *namebuf);
76984 +extern int kallsyms_lookup_size_offset(unsigned long addr,
76985 + unsigned long *symbolsize,
76986 + unsigned long *offset);
76987 +#endif
76988
76989 /* This macro allows us to keep printk typechecking */
76990 static __printf(1, 2)
76991 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
76992 index 518a53a..5e28358 100644
76993 --- a/include/linux/key-type.h
76994 +++ b/include/linux/key-type.h
76995 @@ -125,7 +125,7 @@ struct key_type {
76996 /* internal fields */
76997 struct list_head link; /* link in types list */
76998 struct lock_class_key lock_class; /* key->sem lock class */
76999 -};
77000 +} __do_const;
77001
77002 extern struct key_type key_type_keyring;
77003
77004 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
77005 index c6e091b..a940adf 100644
77006 --- a/include/linux/kgdb.h
77007 +++ b/include/linux/kgdb.h
77008 @@ -52,7 +52,7 @@ extern int kgdb_connected;
77009 extern int kgdb_io_module_registered;
77010
77011 extern atomic_t kgdb_setting_breakpoint;
77012 -extern atomic_t kgdb_cpu_doing_single_step;
77013 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
77014
77015 extern struct task_struct *kgdb_usethread;
77016 extern struct task_struct *kgdb_contthread;
77017 @@ -254,7 +254,7 @@ struct kgdb_arch {
77018 void (*correct_hw_break)(void);
77019
77020 void (*enable_nmi)(bool on);
77021 -};
77022 +} __do_const;
77023
77024 /**
77025 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
77026 @@ -279,7 +279,7 @@ struct kgdb_io {
77027 void (*pre_exception) (void);
77028 void (*post_exception) (void);
77029 int is_console;
77030 -};
77031 +} __do_const;
77032
77033 extern struct kgdb_arch arch_kgdb_ops;
77034
77035 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
77036 index 0555cc6..40116ce 100644
77037 --- a/include/linux/kmod.h
77038 +++ b/include/linux/kmod.h
77039 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
77040 * usually useless though. */
77041 extern __printf(2, 3)
77042 int __request_module(bool wait, const char *name, ...);
77043 +extern __printf(3, 4)
77044 +int ___request_module(bool wait, char *param_name, const char *name, ...);
77045 #define request_module(mod...) __request_module(true, mod)
77046 #define request_module_nowait(mod...) __request_module(false, mod)
77047 #define try_then_request_module(x, mod...) \
77048 @@ -57,6 +59,9 @@ struct subprocess_info {
77049 struct work_struct work;
77050 struct completion *complete;
77051 char *path;
77052 +#ifdef CONFIG_GRKERNSEC
77053 + char *origpath;
77054 +#endif
77055 char **argv;
77056 char **envp;
77057 int wait;
77058 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
77059 index de6dcbcc..4735f88 100644
77060 --- a/include/linux/kobject.h
77061 +++ b/include/linux/kobject.h
77062 @@ -115,7 +115,7 @@ struct kobj_type {
77063 struct attribute **default_attrs;
77064 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
77065 const void *(*namespace)(struct kobject *kobj);
77066 -};
77067 +} __do_const;
77068
77069 struct kobj_uevent_env {
77070 char *envp[UEVENT_NUM_ENVP];
77071 @@ -138,6 +138,7 @@ struct kobj_attribute {
77072 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
77073 const char *buf, size_t count);
77074 };
77075 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
77076
77077 extern const struct sysfs_ops kobj_sysfs_ops;
77078
77079 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
77080 index df32d25..fb52e27 100644
77081 --- a/include/linux/kobject_ns.h
77082 +++ b/include/linux/kobject_ns.h
77083 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
77084 const void *(*netlink_ns)(struct sock *sk);
77085 const void *(*initial_ns)(void);
77086 void (*drop_ns)(void *);
77087 -};
77088 +} __do_const;
77089
77090 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
77091 int kobj_ns_type_registered(enum kobj_ns_type type);
77092 diff --git a/include/linux/kref.h b/include/linux/kref.h
77093 index 484604d..0f6c5b6 100644
77094 --- a/include/linux/kref.h
77095 +++ b/include/linux/kref.h
77096 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
77097 static inline int kref_sub(struct kref *kref, unsigned int count,
77098 void (*release)(struct kref *kref))
77099 {
77100 - WARN_ON(release == NULL);
77101 + BUG_ON(release == NULL);
77102
77103 if (atomic_sub_and_test((int) count, &kref->refcount)) {
77104 release(kref);
77105 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
77106 index 0fbbc7a..db081e3 100644
77107 --- a/include/linux/kvm_host.h
77108 +++ b/include/linux/kvm_host.h
77109 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
77110 {
77111 }
77112 #endif
77113 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
77114 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
77115 struct module *module);
77116 void kvm_exit(void);
77117
77118 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
77119 struct kvm_guest_debug *dbg);
77120 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
77121
77122 -int kvm_arch_init(void *opaque);
77123 +int kvm_arch_init(const void *opaque);
77124 void kvm_arch_exit(void);
77125
77126 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
77127 diff --git a/include/linux/libata.h b/include/linux/libata.h
77128 index 9b50337..712d748 100644
77129 --- a/include/linux/libata.h
77130 +++ b/include/linux/libata.h
77131 @@ -973,7 +973,7 @@ struct ata_port_operations {
77132 * fields must be pointers.
77133 */
77134 const struct ata_port_operations *inherits;
77135 -};
77136 +} __do_const;
77137
77138 struct ata_port_info {
77139 unsigned long flags;
77140 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
77141 index d3e8ad2..a949f68 100644
77142 --- a/include/linux/linkage.h
77143 +++ b/include/linux/linkage.h
77144 @@ -31,6 +31,7 @@
77145 #endif
77146
77147 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
77148 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
77149 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
77150
77151 /*
77152 diff --git a/include/linux/list.h b/include/linux/list.h
77153 index f4d8a2f..38e6e46 100644
77154 --- a/include/linux/list.h
77155 +++ b/include/linux/list.h
77156 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
77157 extern void list_del(struct list_head *entry);
77158 #endif
77159
77160 +extern void __pax_list_add(struct list_head *new,
77161 + struct list_head *prev,
77162 + struct list_head *next);
77163 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
77164 +{
77165 + __pax_list_add(new, head, head->next);
77166 +}
77167 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
77168 +{
77169 + __pax_list_add(new, head->prev, head);
77170 +}
77171 +extern void pax_list_del(struct list_head *entry);
77172 +
77173 /**
77174 * list_replace - replace old entry by new one
77175 * @old : the element to be replaced
77176 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
77177 INIT_LIST_HEAD(entry);
77178 }
77179
77180 +extern void pax_list_del_init(struct list_head *entry);
77181 +
77182 /**
77183 * list_move - delete from one list and add as another's head
77184 * @list: the entry to move
77185 diff --git a/include/linux/math64.h b/include/linux/math64.h
77186 index 69ed5f5..243ed51 100644
77187 --- a/include/linux/math64.h
77188 +++ b/include/linux/math64.h
77189 @@ -15,7 +15,7 @@
77190 * This is commonly provided by 32bit archs to provide an optimized 64bit
77191 * divide.
77192 */
77193 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
77194 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
77195 {
77196 *remainder = dividend % divisor;
77197 return dividend / divisor;
77198 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
77199 /**
77200 * div64_u64 - unsigned 64bit divide with 64bit divisor
77201 */
77202 -static inline u64 div64_u64(u64 dividend, u64 divisor)
77203 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
77204 {
77205 return dividend / divisor;
77206 }
77207 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
77208 #define div64_ul(x, y) div_u64((x), (y))
77209
77210 #ifndef div_u64_rem
77211 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
77212 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
77213 {
77214 *remainder = do_div(dividend, divisor);
77215 return dividend;
77216 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
77217 #endif
77218
77219 #ifndef div64_u64
77220 -extern u64 div64_u64(u64 dividend, u64 divisor);
77221 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
77222 #endif
77223
77224 #ifndef div64_s64
77225 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
77226 * divide.
77227 */
77228 #ifndef div_u64
77229 -static inline u64 div_u64(u64 dividend, u32 divisor)
77230 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
77231 {
77232 u32 remainder;
77233 return div_u64_rem(dividend, divisor, &remainder);
77234 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
77235 index da6716b..2e31db3 100644
77236 --- a/include/linux/mempolicy.h
77237 +++ b/include/linux/mempolicy.h
77238 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
77239 }
77240
77241 #define vma_policy(vma) ((vma)->vm_policy)
77242 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
77243 +{
77244 + vma->vm_policy = pol;
77245 +}
77246
77247 static inline void mpol_get(struct mempolicy *pol)
77248 {
77249 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
77250 }
77251
77252 #define vma_policy(vma) NULL
77253 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
77254 +{
77255 +}
77256
77257 static inline int
77258 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
77259 diff --git a/include/linux/mm.h b/include/linux/mm.h
77260 index 8b6e55e..c4edf39 100644
77261 --- a/include/linux/mm.h
77262 +++ b/include/linux/mm.h
77263 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
77264 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
77265 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
77266 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
77267 +
77268 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
77269 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
77270 +#endif
77271 +
77272 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
77273
77274 #ifdef CONFIG_MEM_SOFT_DIRTY
77275 @@ -215,8 +220,8 @@ struct vm_operations_struct {
77276 /* called by access_process_vm when get_user_pages() fails, typically
77277 * for use by special VMAs that can switch between memory and hardware
77278 */
77279 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
77280 - void *buf, int len, int write);
77281 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
77282 + void *buf, size_t len, int write);
77283 #ifdef CONFIG_NUMA
77284 /*
77285 * set_policy() op must add a reference to any non-NULL @new mempolicy
77286 @@ -246,6 +251,7 @@ struct vm_operations_struct {
77287 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
77288 unsigned long size, pgoff_t pgoff);
77289 };
77290 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
77291
77292 struct mmu_gather;
77293 struct inode;
77294 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
77295 unsigned long *pfn);
77296 int follow_phys(struct vm_area_struct *vma, unsigned long address,
77297 unsigned int flags, unsigned long *prot, resource_size_t *phys);
77298 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
77299 - void *buf, int len, int write);
77300 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
77301 + void *buf, size_t len, int write);
77302
77303 static inline void unmap_shared_mapping_range(struct address_space *mapping,
77304 loff_t const holebegin, loff_t const holelen)
77305 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
77306 }
77307 #endif
77308
77309 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
77310 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
77311 - void *buf, int len, int write);
77312 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
77313 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
77314 + void *buf, size_t len, int write);
77315
77316 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
77317 unsigned long start, unsigned long nr_pages,
77318 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
77319 int set_page_dirty_lock(struct page *page);
77320 int clear_page_dirty_for_io(struct page *page);
77321
77322 -/* Is the vma a continuation of the stack vma above it? */
77323 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
77324 -{
77325 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
77326 -}
77327 -
77328 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
77329 - unsigned long addr)
77330 -{
77331 - return (vma->vm_flags & VM_GROWSDOWN) &&
77332 - (vma->vm_start == addr) &&
77333 - !vma_growsdown(vma->vm_prev, addr);
77334 -}
77335 -
77336 -/* Is the vma a continuation of the stack vma below it? */
77337 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
77338 -{
77339 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
77340 -}
77341 -
77342 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
77343 - unsigned long addr)
77344 -{
77345 - return (vma->vm_flags & VM_GROWSUP) &&
77346 - (vma->vm_end == addr) &&
77347 - !vma_growsup(vma->vm_next, addr);
77348 -}
77349 -
77350 extern pid_t
77351 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
77352
77353 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
77354 }
77355 #endif
77356
77357 +#ifdef CONFIG_MMU
77358 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
77359 +#else
77360 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
77361 +{
77362 + return __pgprot(0);
77363 +}
77364 +#endif
77365 +
77366 int vma_wants_writenotify(struct vm_area_struct *vma);
77367
77368 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
77369 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
77370 {
77371 return 0;
77372 }
77373 +
77374 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
77375 + unsigned long address)
77376 +{
77377 + return 0;
77378 +}
77379 #else
77380 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
77381 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
77382 #endif
77383
77384 #ifdef __PAGETABLE_PMD_FOLDED
77385 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
77386 {
77387 return 0;
77388 }
77389 +
77390 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
77391 + unsigned long address)
77392 +{
77393 + return 0;
77394 +}
77395 #else
77396 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
77397 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
77398 #endif
77399
77400 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
77401 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
77402 NULL: pud_offset(pgd, address);
77403 }
77404
77405 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
77406 +{
77407 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
77408 + NULL: pud_offset(pgd, address);
77409 +}
77410 +
77411 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
77412 {
77413 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
77414 NULL: pmd_offset(pud, address);
77415 }
77416 +
77417 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
77418 +{
77419 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
77420 + NULL: pmd_offset(pud, address);
77421 +}
77422 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
77423
77424 #if USE_SPLIT_PTLOCKS
77425 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
77426 unsigned long addr, unsigned long len,
77427 unsigned long flags, struct page **pages);
77428
77429 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
77430 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
77431
77432 extern unsigned long mmap_region(struct file *file, unsigned long addr,
77433 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
77434 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
77435 unsigned long len, unsigned long prot, unsigned long flags,
77436 unsigned long pgoff, unsigned long *populate);
77437 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
77438 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
77439
77440 #ifdef CONFIG_MMU
77441 extern int __mm_populate(unsigned long addr, unsigned long len,
77442 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
77443 unsigned long high_limit;
77444 unsigned long align_mask;
77445 unsigned long align_offset;
77446 + unsigned long threadstack_offset;
77447 };
77448
77449 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
77450 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
77451 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
77452 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
77453
77454 /*
77455 * Search for an unmapped address range.
77456 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
77457 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
77458 */
77459 static inline unsigned long
77460 -vm_unmapped_area(struct vm_unmapped_area_info *info)
77461 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
77462 {
77463 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
77464 return unmapped_area(info);
77465 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
77466 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
77467 struct vm_area_struct **pprev);
77468
77469 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
77470 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
77471 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
77472 +
77473 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
77474 NULL if none. Assume start_addr < end_addr. */
77475 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
77476 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
77477 return vma;
77478 }
77479
77480 -#ifdef CONFIG_MMU
77481 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
77482 -#else
77483 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
77484 -{
77485 - return __pgprot(0);
77486 -}
77487 -#endif
77488 -
77489 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
77490 unsigned long change_prot_numa(struct vm_area_struct *vma,
77491 unsigned long start, unsigned long end);
77492 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
77493 static inline void vm_stat_account(struct mm_struct *mm,
77494 unsigned long flags, struct file *file, long pages)
77495 {
77496 +
77497 +#ifdef CONFIG_PAX_RANDMMAP
77498 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
77499 +#endif
77500 +
77501 mm->total_vm += pages;
77502 }
77503 #endif /* CONFIG_PROC_FS */
77504 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
77505 extern int sysctl_memory_failure_early_kill;
77506 extern int sysctl_memory_failure_recovery;
77507 extern void shake_page(struct page *p, int access);
77508 -extern atomic_long_t num_poisoned_pages;
77509 +extern atomic_long_unchecked_t num_poisoned_pages;
77510 extern int soft_offline_page(struct page *page, int flags);
77511
77512 extern void dump_page(struct page *page);
77513 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
77514 static inline void setup_nr_node_ids(void) {}
77515 #endif
77516
77517 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
77518 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
77519 +#else
77520 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
77521 +#endif
77522 +
77523 #endif /* __KERNEL__ */
77524 #endif /* _LINUX_MM_H */
77525 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
77526 index 8e082f1..f61f576 100644
77527 --- a/include/linux/mm_types.h
77528 +++ b/include/linux/mm_types.h
77529 @@ -289,6 +289,8 @@ struct vm_area_struct {
77530 #ifdef CONFIG_NUMA
77531 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
77532 #endif
77533 +
77534 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
77535 };
77536
77537 struct core_thread {
77538 @@ -444,6 +446,24 @@ struct mm_struct {
77539 bool tlb_flush_pending;
77540 #endif
77541 struct uprobes_state uprobes_state;
77542 +
77543 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77544 + unsigned long pax_flags;
77545 +#endif
77546 +
77547 +#ifdef CONFIG_PAX_DLRESOLVE
77548 + unsigned long call_dl_resolve;
77549 +#endif
77550 +
77551 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
77552 + unsigned long call_syscall;
77553 +#endif
77554 +
77555 +#ifdef CONFIG_PAX_ASLR
77556 + unsigned long delta_mmap; /* randomized offset */
77557 + unsigned long delta_stack; /* randomized offset */
77558 +#endif
77559 +
77560 };
77561
77562 /* first nid will either be a valid NID or one of these values */
77563 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
77564 index c5d5278..f0b68c8 100644
77565 --- a/include/linux/mmiotrace.h
77566 +++ b/include/linux/mmiotrace.h
77567 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
77568 /* Called from ioremap.c */
77569 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
77570 void __iomem *addr);
77571 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
77572 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
77573
77574 /* For anyone to insert markers. Remember trailing newline. */
77575 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
77576 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
77577 {
77578 }
77579
77580 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
77581 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
77582 {
77583 }
77584
77585 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
77586 index bd791e4..8617c34f 100644
77587 --- a/include/linux/mmzone.h
77588 +++ b/include/linux/mmzone.h
77589 @@ -396,7 +396,7 @@ struct zone {
77590 unsigned long flags; /* zone flags, see below */
77591
77592 /* Zone statistics */
77593 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77594 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77595
77596 /*
77597 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
77598 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
77599 index 45e9214..a7227d6 100644
77600 --- a/include/linux/mod_devicetable.h
77601 +++ b/include/linux/mod_devicetable.h
77602 @@ -13,7 +13,7 @@
77603 typedef unsigned long kernel_ulong_t;
77604 #endif
77605
77606 -#define PCI_ANY_ID (~0)
77607 +#define PCI_ANY_ID ((__u16)~0)
77608
77609 struct pci_device_id {
77610 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
77611 @@ -139,7 +139,7 @@ struct usb_device_id {
77612 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
77613 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
77614
77615 -#define HID_ANY_ID (~0)
77616 +#define HID_ANY_ID (~0U)
77617 #define HID_BUS_ANY 0xffff
77618 #define HID_GROUP_ANY 0x0000
77619
77620 @@ -467,7 +467,7 @@ struct dmi_system_id {
77621 const char *ident;
77622 struct dmi_strmatch matches[4];
77623 void *driver_data;
77624 -};
77625 +} __do_const;
77626 /*
77627 * struct dmi_device_id appears during expansion of
77628 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
77629 diff --git a/include/linux/module.h b/include/linux/module.h
77630 index 05f2447..2aee07c 100644
77631 --- a/include/linux/module.h
77632 +++ b/include/linux/module.h
77633 @@ -17,9 +17,11 @@
77634 #include <linux/moduleparam.h>
77635 #include <linux/tracepoint.h>
77636 #include <linux/export.h>
77637 +#include <linux/fs.h>
77638
77639 #include <linux/percpu.h>
77640 #include <asm/module.h>
77641 +#include <asm/pgtable.h>
77642
77643 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
77644 #define MODULE_SIG_STRING "~Module signature appended~\n"
77645 @@ -55,12 +57,13 @@ struct module_attribute {
77646 int (*test)(struct module *);
77647 void (*free)(struct module *);
77648 };
77649 +typedef struct module_attribute __no_const module_attribute_no_const;
77650
77651 struct module_version_attribute {
77652 struct module_attribute mattr;
77653 const char *module_name;
77654 const char *version;
77655 -} __attribute__ ((__aligned__(sizeof(void *))));
77656 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
77657
77658 extern ssize_t __modver_version_show(struct module_attribute *,
77659 struct module_kobject *, char *);
77660 @@ -238,7 +241,7 @@ struct module
77661
77662 /* Sysfs stuff. */
77663 struct module_kobject mkobj;
77664 - struct module_attribute *modinfo_attrs;
77665 + module_attribute_no_const *modinfo_attrs;
77666 const char *version;
77667 const char *srcversion;
77668 struct kobject *holders_dir;
77669 @@ -287,19 +290,16 @@ struct module
77670 int (*init)(void);
77671
77672 /* If this is non-NULL, vfree after init() returns */
77673 - void *module_init;
77674 + void *module_init_rx, *module_init_rw;
77675
77676 /* Here is the actual code + data, vfree'd on unload. */
77677 - void *module_core;
77678 + void *module_core_rx, *module_core_rw;
77679
77680 /* Here are the sizes of the init and core sections */
77681 - unsigned int init_size, core_size;
77682 + unsigned int init_size_rw, core_size_rw;
77683
77684 /* The size of the executable code in each section. */
77685 - unsigned int init_text_size, core_text_size;
77686 -
77687 - /* Size of RO sections of the module (text+rodata) */
77688 - unsigned int init_ro_size, core_ro_size;
77689 + unsigned int init_size_rx, core_size_rx;
77690
77691 /* Arch-specific module values */
77692 struct mod_arch_specific arch;
77693 @@ -355,6 +355,10 @@ struct module
77694 #ifdef CONFIG_EVENT_TRACING
77695 struct ftrace_event_call **trace_events;
77696 unsigned int num_trace_events;
77697 + struct file_operations trace_id;
77698 + struct file_operations trace_enable;
77699 + struct file_operations trace_format;
77700 + struct file_operations trace_filter;
77701 #endif
77702 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
77703 unsigned int num_ftrace_callsites;
77704 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
77705 bool is_module_percpu_address(unsigned long addr);
77706 bool is_module_text_address(unsigned long addr);
77707
77708 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
77709 +{
77710 +
77711 +#ifdef CONFIG_PAX_KERNEXEC
77712 + if (ktla_ktva(addr) >= (unsigned long)start &&
77713 + ktla_ktva(addr) < (unsigned long)start + size)
77714 + return 1;
77715 +#endif
77716 +
77717 + return ((void *)addr >= start && (void *)addr < start + size);
77718 +}
77719 +
77720 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
77721 +{
77722 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
77723 +}
77724 +
77725 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
77726 +{
77727 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
77728 +}
77729 +
77730 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
77731 +{
77732 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
77733 +}
77734 +
77735 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
77736 +{
77737 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
77738 +}
77739 +
77740 static inline int within_module_core(unsigned long addr, const struct module *mod)
77741 {
77742 - return (unsigned long)mod->module_core <= addr &&
77743 - addr < (unsigned long)mod->module_core + mod->core_size;
77744 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
77745 }
77746
77747 static inline int within_module_init(unsigned long addr, const struct module *mod)
77748 {
77749 - return (unsigned long)mod->module_init <= addr &&
77750 - addr < (unsigned long)mod->module_init + mod->init_size;
77751 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
77752 }
77753
77754 /* Search for module by name: must hold module_mutex. */
77755 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
77756 index 560ca53..ef621ef 100644
77757 --- a/include/linux/moduleloader.h
77758 +++ b/include/linux/moduleloader.h
77759 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
77760 sections. Returns NULL on failure. */
77761 void *module_alloc(unsigned long size);
77762
77763 +#ifdef CONFIG_PAX_KERNEXEC
77764 +void *module_alloc_exec(unsigned long size);
77765 +#else
77766 +#define module_alloc_exec(x) module_alloc(x)
77767 +#endif
77768 +
77769 /* Free memory returned from module_alloc. */
77770 void module_free(struct module *mod, void *module_region);
77771
77772 +#ifdef CONFIG_PAX_KERNEXEC
77773 +void module_free_exec(struct module *mod, void *module_region);
77774 +#else
77775 +#define module_free_exec(x, y) module_free((x), (y))
77776 +#endif
77777 +
77778 /*
77779 * Apply the given relocation to the (simplified) ELF. Return -error
77780 * or 0.
77781 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
77782 unsigned int relsec,
77783 struct module *me)
77784 {
77785 +#ifdef CONFIG_MODULES
77786 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77787 +#endif
77788 return -ENOEXEC;
77789 }
77790 #endif
77791 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
77792 unsigned int relsec,
77793 struct module *me)
77794 {
77795 +#ifdef CONFIG_MODULES
77796 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77797 +#endif
77798 return -ENOEXEC;
77799 }
77800 #endif
77801 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
77802 index c3eb102..073c4a6 100644
77803 --- a/include/linux/moduleparam.h
77804 +++ b/include/linux/moduleparam.h
77805 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
77806 * @len is usually just sizeof(string).
77807 */
77808 #define module_param_string(name, string, len, perm) \
77809 - static const struct kparam_string __param_string_##name \
77810 + static const struct kparam_string __param_string_##name __used \
77811 = { len, string }; \
77812 __module_param_call(MODULE_PARAM_PREFIX, name, \
77813 &param_ops_string, \
77814 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
77815 */
77816 #define module_param_array_named(name, array, type, nump, perm) \
77817 param_check_##type(name, &(array)[0]); \
77818 - static const struct kparam_array __param_arr_##name \
77819 + static const struct kparam_array __param_arr_##name __used \
77820 = { .max = ARRAY_SIZE(array), .num = nump, \
77821 .ops = &param_ops_##type, \
77822 .elemsize = sizeof(array[0]), .elem = array }; \
77823 diff --git a/include/linux/namei.h b/include/linux/namei.h
77824 index 8e47bc7..c70fd73 100644
77825 --- a/include/linux/namei.h
77826 +++ b/include/linux/namei.h
77827 @@ -19,7 +19,7 @@ struct nameidata {
77828 unsigned seq;
77829 int last_type;
77830 unsigned depth;
77831 - char *saved_names[MAX_NESTED_LINKS + 1];
77832 + const char *saved_names[MAX_NESTED_LINKS + 1];
77833 };
77834
77835 /*
77836 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
77837
77838 extern void nd_jump_link(struct nameidata *nd, struct path *path);
77839
77840 -static inline void nd_set_link(struct nameidata *nd, char *path)
77841 +static inline void nd_set_link(struct nameidata *nd, const char *path)
77842 {
77843 nd->saved_names[nd->depth] = path;
77844 }
77845
77846 -static inline char *nd_get_link(struct nameidata *nd)
77847 +static inline const char *nd_get_link(const struct nameidata *nd)
77848 {
77849 return nd->saved_names[nd->depth];
77850 }
77851 diff --git a/include/linux/net.h b/include/linux/net.h
77852 index 41103f8..631edff 100644
77853 --- a/include/linux/net.h
77854 +++ b/include/linux/net.h
77855 @@ -191,7 +191,7 @@ struct net_proto_family {
77856 int (*create)(struct net *net, struct socket *sock,
77857 int protocol, int kern);
77858 struct module *owner;
77859 -};
77860 +} __do_const;
77861
77862 struct iovec;
77863 struct kvec;
77864 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
77865 index 21eae43..4fff130 100644
77866 --- a/include/linux/netdevice.h
77867 +++ b/include/linux/netdevice.h
77868 @@ -1098,6 +1098,7 @@ struct net_device_ops {
77869 sa_family_t sa_family,
77870 __be16 port);
77871 };
77872 +typedef struct net_device_ops __no_const net_device_ops_no_const;
77873
77874 /*
77875 * The DEVICE structure.
77876 @@ -1169,7 +1170,7 @@ struct net_device {
77877 int iflink;
77878
77879 struct net_device_stats stats;
77880 - atomic_long_t rx_dropped; /* dropped packets by core network
77881 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
77882 * Do not use this in drivers.
77883 */
77884
77885 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
77886 index 708fe72ab9..77084a3 100644
77887 --- a/include/linux/netfilter.h
77888 +++ b/include/linux/netfilter.h
77889 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
77890 #endif
77891 /* Use the module struct to lock set/get code in place */
77892 struct module *owner;
77893 -};
77894 +} __do_const;
77895
77896 /* Function to register/unregister hook points. */
77897 int nf_register_hook(struct nf_hook_ops *reg);
77898 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
77899 index cadb740..d7c37c0 100644
77900 --- a/include/linux/netfilter/nfnetlink.h
77901 +++ b/include/linux/netfilter/nfnetlink.h
77902 @@ -16,7 +16,7 @@ struct nfnl_callback {
77903 const struct nlattr * const cda[]);
77904 const struct nla_policy *policy; /* netlink attribute policy */
77905 const u_int16_t attr_count; /* number of nlattr's */
77906 -};
77907 +} __do_const;
77908
77909 struct nfnetlink_subsystem {
77910 const char *name;
77911 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
77912 new file mode 100644
77913 index 0000000..33f4af8
77914 --- /dev/null
77915 +++ b/include/linux/netfilter/xt_gradm.h
77916 @@ -0,0 +1,9 @@
77917 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
77918 +#define _LINUX_NETFILTER_XT_GRADM_H 1
77919 +
77920 +struct xt_gradm_mtinfo {
77921 + __u16 flags;
77922 + __u16 invflags;
77923 +};
77924 +
77925 +#endif
77926 diff --git a/include/linux/nls.h b/include/linux/nls.h
77927 index 5dc635f..35f5e11 100644
77928 --- a/include/linux/nls.h
77929 +++ b/include/linux/nls.h
77930 @@ -31,7 +31,7 @@ struct nls_table {
77931 const unsigned char *charset2upper;
77932 struct module *owner;
77933 struct nls_table *next;
77934 -};
77935 +} __do_const;
77936
77937 /* this value hold the maximum octet of charset */
77938 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
77939 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
77940 index d14a4c3..a078786 100644
77941 --- a/include/linux/notifier.h
77942 +++ b/include/linux/notifier.h
77943 @@ -54,7 +54,8 @@ struct notifier_block {
77944 notifier_fn_t notifier_call;
77945 struct notifier_block __rcu *next;
77946 int priority;
77947 -};
77948 +} __do_const;
77949 +typedef struct notifier_block __no_const notifier_block_no_const;
77950
77951 struct atomic_notifier_head {
77952 spinlock_t lock;
77953 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
77954 index b2a0f15..4d7da32 100644
77955 --- a/include/linux/oprofile.h
77956 +++ b/include/linux/oprofile.h
77957 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
77958 int oprofilefs_create_ro_ulong(struct dentry * root,
77959 char const * name, ulong * val);
77960
77961 -/** Create a file for read-only access to an atomic_t. */
77962 +/** Create a file for read-only access to an atomic_unchecked_t. */
77963 int oprofilefs_create_ro_atomic(struct dentry * root,
77964 - char const * name, atomic_t * val);
77965 + char const * name, atomic_unchecked_t * val);
77966
77967 /** create a directory */
77968 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
77969 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
77970 index 430dd96..544e26e 100644
77971 --- a/include/linux/pci_hotplug.h
77972 +++ b/include/linux/pci_hotplug.h
77973 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
77974 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
77975 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
77976 int (*reset_slot) (struct hotplug_slot *slot, int probe);
77977 -};
77978 +} __do_const;
77979 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
77980
77981 /**
77982 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
77983 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
77984 index c8ba627..24bdfa8 100644
77985 --- a/include/linux/perf_event.h
77986 +++ b/include/linux/perf_event.h
77987 @@ -327,8 +327,8 @@ struct perf_event {
77988
77989 enum perf_event_active_state state;
77990 unsigned int attach_state;
77991 - local64_t count;
77992 - atomic64_t child_count;
77993 + local64_t count; /* PaX: fix it one day */
77994 + atomic64_unchecked_t child_count;
77995
77996 /*
77997 * These are the total time in nanoseconds that the event
77998 @@ -379,8 +379,8 @@ struct perf_event {
77999 * These accumulate total time (in nanoseconds) that children
78000 * events have been enabled and running, respectively.
78001 */
78002 - atomic64_t child_total_time_enabled;
78003 - atomic64_t child_total_time_running;
78004 + atomic64_unchecked_t child_total_time_enabled;
78005 + atomic64_unchecked_t child_total_time_running;
78006
78007 /*
78008 * Protect attach/detach and child_list:
78009 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
78010 entry->ip[entry->nr++] = ip;
78011 }
78012
78013 -extern int sysctl_perf_event_paranoid;
78014 +extern int sysctl_perf_event_legitimately_concerned;
78015 extern int sysctl_perf_event_mlock;
78016 extern int sysctl_perf_event_sample_rate;
78017 extern int sysctl_perf_cpu_time_max_percent;
78018 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
78019 loff_t *ppos);
78020
78021
78022 +static inline bool perf_paranoid_any(void)
78023 +{
78024 + return sysctl_perf_event_legitimately_concerned > 2;
78025 +}
78026 +
78027 static inline bool perf_paranoid_tracepoint_raw(void)
78028 {
78029 - return sysctl_perf_event_paranoid > -1;
78030 + return sysctl_perf_event_legitimately_concerned > -1;
78031 }
78032
78033 static inline bool perf_paranoid_cpu(void)
78034 {
78035 - return sysctl_perf_event_paranoid > 0;
78036 + return sysctl_perf_event_legitimately_concerned > 0;
78037 }
78038
78039 static inline bool perf_paranoid_kernel(void)
78040 {
78041 - return sysctl_perf_event_paranoid > 1;
78042 + return sysctl_perf_event_legitimately_concerned > 1;
78043 }
78044
78045 extern void perf_event_init(void);
78046 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
78047 struct device_attribute attr;
78048 u64 id;
78049 const char *event_str;
78050 -};
78051 +} __do_const;
78052
78053 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
78054 static struct perf_pmu_events_attr _var = { \
78055 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
78056 index b8809fe..ae4ccd0 100644
78057 --- a/include/linux/pipe_fs_i.h
78058 +++ b/include/linux/pipe_fs_i.h
78059 @@ -47,10 +47,10 @@ struct pipe_inode_info {
78060 struct mutex mutex;
78061 wait_queue_head_t wait;
78062 unsigned int nrbufs, curbuf, buffers;
78063 - unsigned int readers;
78064 - unsigned int writers;
78065 - unsigned int files;
78066 - unsigned int waiting_writers;
78067 + atomic_t readers;
78068 + atomic_t writers;
78069 + atomic_t files;
78070 + atomic_t waiting_writers;
78071 unsigned int r_counter;
78072 unsigned int w_counter;
78073 struct page *tmp_page;
78074 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
78075 index 5f28cae..3d23723 100644
78076 --- a/include/linux/platform_data/usb-ehci-s5p.h
78077 +++ b/include/linux/platform_data/usb-ehci-s5p.h
78078 @@ -14,7 +14,7 @@
78079 struct s5p_ehci_platdata {
78080 int (*phy_init)(struct platform_device *pdev, int type);
78081 int (*phy_exit)(struct platform_device *pdev, int type);
78082 -};
78083 +} __no_const;
78084
78085 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
78086
78087 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
78088 index c256c59..8ea94c7 100644
78089 --- a/include/linux/platform_data/usb-ohci-exynos.h
78090 +++ b/include/linux/platform_data/usb-ohci-exynos.h
78091 @@ -14,7 +14,7 @@
78092 struct exynos4_ohci_platdata {
78093 int (*phy_init)(struct platform_device *pdev, int type);
78094 int (*phy_exit)(struct platform_device *pdev, int type);
78095 -};
78096 +} __no_const;
78097
78098 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
78099
78100 diff --git a/include/linux/pm.h b/include/linux/pm.h
78101 index a224c7f..92d8a97 100644
78102 --- a/include/linux/pm.h
78103 +++ b/include/linux/pm.h
78104 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
78105 struct dev_pm_domain {
78106 struct dev_pm_ops ops;
78107 };
78108 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
78109
78110 /*
78111 * The PM_EVENT_ messages are also used by drivers implementing the legacy
78112 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
78113 index 7c1d252..c5c773e 100644
78114 --- a/include/linux/pm_domain.h
78115 +++ b/include/linux/pm_domain.h
78116 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
78117
78118 struct gpd_cpu_data {
78119 unsigned int saved_exit_latency;
78120 - struct cpuidle_state *idle_state;
78121 + cpuidle_state_no_const *idle_state;
78122 };
78123
78124 struct generic_pm_domain {
78125 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
78126 index 6fa7cea..7bf6415 100644
78127 --- a/include/linux/pm_runtime.h
78128 +++ b/include/linux/pm_runtime.h
78129 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
78130
78131 static inline void pm_runtime_mark_last_busy(struct device *dev)
78132 {
78133 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
78134 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
78135 }
78136
78137 #else /* !CONFIG_PM_RUNTIME */
78138 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
78139 index 195aafc..49a7bc2 100644
78140 --- a/include/linux/pnp.h
78141 +++ b/include/linux/pnp.h
78142 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
78143 struct pnp_fixup {
78144 char id[7];
78145 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
78146 -};
78147 +} __do_const;
78148
78149 /* config parameters */
78150 #define PNP_CONFIG_NORMAL 0x0001
78151 diff --git a/include/linux/poison.h b/include/linux/poison.h
78152 index 2110a81..13a11bb 100644
78153 --- a/include/linux/poison.h
78154 +++ b/include/linux/poison.h
78155 @@ -19,8 +19,8 @@
78156 * under normal circumstances, used to verify that nobody uses
78157 * non-initialized list entries.
78158 */
78159 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
78160 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
78161 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
78162 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
78163
78164 /********** include/linux/timer.h **********/
78165 /*
78166 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
78167 index d8b187c3..9a9257a 100644
78168 --- a/include/linux/power/smartreflex.h
78169 +++ b/include/linux/power/smartreflex.h
78170 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
78171 int (*notify)(struct omap_sr *sr, u32 status);
78172 u8 notify_flags;
78173 u8 class_type;
78174 -};
78175 +} __do_const;
78176
78177 /**
78178 * struct omap_sr_nvalue_table - Smartreflex n-target value info
78179 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
78180 index 4ea1d37..80f4b33 100644
78181 --- a/include/linux/ppp-comp.h
78182 +++ b/include/linux/ppp-comp.h
78183 @@ -84,7 +84,7 @@ struct compressor {
78184 struct module *owner;
78185 /* Extra skb space needed by the compressor algorithm */
78186 unsigned int comp_extra;
78187 -};
78188 +} __do_const;
78189
78190 /*
78191 * The return value from decompress routine is the length of the
78192 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
78193 index f5d4723..a6ea2fa 100644
78194 --- a/include/linux/preempt.h
78195 +++ b/include/linux/preempt.h
78196 @@ -18,8 +18,13 @@
78197 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
78198 #endif
78199
78200 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
78201 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
78202 +
78203 #define inc_preempt_count() add_preempt_count(1)
78204 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
78205 #define dec_preempt_count() sub_preempt_count(1)
78206 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
78207
78208 #define preempt_count() (current_thread_info()->preempt_count)
78209
78210 @@ -64,6 +69,12 @@ do { \
78211 barrier(); \
78212 } while (0)
78213
78214 +#define raw_preempt_disable() \
78215 +do { \
78216 + raw_inc_preempt_count(); \
78217 + barrier(); \
78218 +} while (0)
78219 +
78220 #define sched_preempt_enable_no_resched() \
78221 do { \
78222 barrier(); \
78223 @@ -72,6 +83,12 @@ do { \
78224
78225 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
78226
78227 +#define raw_preempt_enable_no_resched() \
78228 +do { \
78229 + barrier(); \
78230 + raw_dec_preempt_count(); \
78231 +} while (0)
78232 +
78233 #define preempt_enable() \
78234 do { \
78235 preempt_enable_no_resched(); \
78236 @@ -116,8 +133,10 @@ do { \
78237 * region.
78238 */
78239 #define preempt_disable() barrier()
78240 +#define raw_preempt_disable() barrier()
78241 #define sched_preempt_enable_no_resched() barrier()
78242 #define preempt_enable_no_resched() barrier()
78243 +#define raw_preempt_enable_no_resched() barrier()
78244 #define preempt_enable() barrier()
78245
78246 #define preempt_disable_notrace() barrier()
78247 diff --git a/include/linux/printk.h b/include/linux/printk.h
78248 index e6131a78..8e9fb61 100644
78249 --- a/include/linux/printk.h
78250 +++ b/include/linux/printk.h
78251 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
78252 void early_printk(const char *s, ...) { }
78253 #endif
78254
78255 +extern int kptr_restrict;
78256 +
78257 #ifdef CONFIG_PRINTK
78258 asmlinkage __printf(5, 0)
78259 int vprintk_emit(int facility, int level,
78260 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
78261
78262 extern int printk_delay_msec;
78263 extern int dmesg_restrict;
78264 -extern int kptr_restrict;
78265
78266 extern void wake_up_klogd(void);
78267
78268 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
78269 index 608e60a..c26f864 100644
78270 --- a/include/linux/proc_fs.h
78271 +++ b/include/linux/proc_fs.h
78272 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
78273 return proc_create_data(name, mode, parent, proc_fops, NULL);
78274 }
78275
78276 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
78277 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
78278 +{
78279 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78280 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
78281 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78282 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
78283 +#else
78284 + return proc_create_data(name, mode, parent, proc_fops, NULL);
78285 +#endif
78286 +}
78287 +
78288 +
78289 extern void proc_set_size(struct proc_dir_entry *, loff_t);
78290 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
78291 extern void *PDE_DATA(const struct inode *);
78292 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
78293 index 34a1e10..03a6d03 100644
78294 --- a/include/linux/proc_ns.h
78295 +++ b/include/linux/proc_ns.h
78296 @@ -14,7 +14,7 @@ struct proc_ns_operations {
78297 void (*put)(void *ns);
78298 int (*install)(struct nsproxy *nsproxy, void *ns);
78299 unsigned int (*inum)(void *ns);
78300 -};
78301 +} __do_const;
78302
78303 struct proc_ns {
78304 void *ns;
78305 diff --git a/include/linux/quota.h b/include/linux/quota.h
78306 index cc7494a..1e27036 100644
78307 --- a/include/linux/quota.h
78308 +++ b/include/linux/quota.h
78309 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
78310
78311 extern bool qid_eq(struct kqid left, struct kqid right);
78312 extern bool qid_lt(struct kqid left, struct kqid right);
78313 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
78314 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
78315 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
78316 extern bool qid_valid(struct kqid qid);
78317
78318 diff --git a/include/linux/random.h b/include/linux/random.h
78319 index bf9085e..02aca5f 100644
78320 --- a/include/linux/random.h
78321 +++ b/include/linux/random.h
78322 @@ -10,9 +10,19 @@
78323
78324
78325 extern void add_device_randomness(const void *, unsigned int);
78326 +
78327 +static inline void add_latent_entropy(void)
78328 +{
78329 +
78330 +#ifdef LATENT_ENTROPY_PLUGIN
78331 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
78332 +#endif
78333 +
78334 +}
78335 +
78336 extern void add_input_randomness(unsigned int type, unsigned int code,
78337 - unsigned int value);
78338 -extern void add_interrupt_randomness(int irq, int irq_flags);
78339 + unsigned int value) __latent_entropy;
78340 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
78341
78342 extern void get_random_bytes(void *buf, int nbytes);
78343 extern void get_random_bytes_arch(void *buf, int nbytes);
78344 @@ -23,16 +33,22 @@ extern int random_int_secret_init(void);
78345 extern const struct file_operations random_fops, urandom_fops;
78346 #endif
78347
78348 -unsigned int get_random_int(void);
78349 +unsigned int __intentional_overflow(-1) get_random_int(void);
78350 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
78351
78352 -u32 prandom_u32(void);
78353 +u32 prandom_u32(void) __intentional_overflow(-1);
78354 void prandom_bytes(void *buf, int nbytes);
78355 void prandom_seed(u32 seed);
78356 +void prandom_reseed_late(void);
78357
78358 -u32 prandom_u32_state(struct rnd_state *);
78359 +u32 prandom_u32_state(struct rnd_state *state);
78360 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
78361
78362 +static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
78363 +{
78364 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
78365 +}
78366 +
78367 /*
78368 * Handle minimum values for seeds
78369 */
78370 @@ -50,9 +66,10 @@ static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
78371 {
78372 u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
78373
78374 - state->s1 = __seed(i, 2);
78375 - state->s2 = __seed(i, 8);
78376 - state->s3 = __seed(i, 16);
78377 + state->s1 = __seed(i, 2U);
78378 + state->s2 = __seed(i, 8U);
78379 + state->s3 = __seed(i, 16U);
78380 + state->s4 = __seed(i, 128U);
78381 }
78382
78383 #ifdef CONFIG_ARCH_RANDOM
78384 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
78385 index 4106721..132d42c 100644
78386 --- a/include/linux/rculist.h
78387 +++ b/include/linux/rculist.h
78388 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
78389 struct list_head *prev, struct list_head *next);
78390 #endif
78391
78392 +extern void __pax_list_add_rcu(struct list_head *new,
78393 + struct list_head *prev, struct list_head *next);
78394 +
78395 /**
78396 * list_add_rcu - add a new entry to rcu-protected list
78397 * @new: new entry to be added
78398 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
78399 __list_add_rcu(new, head, head->next);
78400 }
78401
78402 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
78403 +{
78404 + __pax_list_add_rcu(new, head, head->next);
78405 +}
78406 +
78407 /**
78408 * list_add_tail_rcu - add a new entry to rcu-protected list
78409 * @new: new entry to be added
78410 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
78411 __list_add_rcu(new, head->prev, head);
78412 }
78413
78414 +static inline void pax_list_add_tail_rcu(struct list_head *new,
78415 + struct list_head *head)
78416 +{
78417 + __pax_list_add_rcu(new, head->prev, head);
78418 +}
78419 +
78420 /**
78421 * list_del_rcu - deletes entry from list without re-initialization
78422 * @entry: the element to delete from the list.
78423 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
78424 entry->prev = LIST_POISON2;
78425 }
78426
78427 +extern void pax_list_del_rcu(struct list_head *entry);
78428 +
78429 /**
78430 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
78431 * @n: the element to delete from the hash list.
78432 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
78433 index 9e7db9e..7d4fd72 100644
78434 --- a/include/linux/reboot.h
78435 +++ b/include/linux/reboot.h
78436 @@ -44,9 +44,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
78437 */
78438
78439 extern void migrate_to_reboot_cpu(void);
78440 -extern void machine_restart(char *cmd);
78441 -extern void machine_halt(void);
78442 -extern void machine_power_off(void);
78443 +extern void machine_restart(char *cmd) __noreturn;
78444 +extern void machine_halt(void) __noreturn;
78445 +extern void machine_power_off(void) __noreturn;
78446
78447 extern void machine_shutdown(void);
78448 struct pt_regs;
78449 @@ -57,9 +57,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
78450 */
78451
78452 extern void kernel_restart_prepare(char *cmd);
78453 -extern void kernel_restart(char *cmd);
78454 -extern void kernel_halt(void);
78455 -extern void kernel_power_off(void);
78456 +extern void kernel_restart(char *cmd) __noreturn;
78457 +extern void kernel_halt(void) __noreturn;
78458 +extern void kernel_power_off(void) __noreturn;
78459
78460 extern int C_A_D; /* for sysctl */
78461 void ctrl_alt_del(void);
78462 @@ -73,7 +73,7 @@ extern int orderly_poweroff(bool force);
78463 * Emergency restart, callable from an interrupt handler.
78464 */
78465
78466 -extern void emergency_restart(void);
78467 +extern void emergency_restart(void) __noreturn;
78468 #include <asm/emergency-restart.h>
78469
78470 #endif /* _LINUX_REBOOT_H */
78471 diff --git a/include/linux/regset.h b/include/linux/regset.h
78472 index 8e0c9fe..ac4d221 100644
78473 --- a/include/linux/regset.h
78474 +++ b/include/linux/regset.h
78475 @@ -161,7 +161,8 @@ struct user_regset {
78476 unsigned int align;
78477 unsigned int bias;
78478 unsigned int core_note_type;
78479 -};
78480 +} __do_const;
78481 +typedef struct user_regset __no_const user_regset_no_const;
78482
78483 /**
78484 * struct user_regset_view - available regsets
78485 diff --git a/include/linux/relay.h b/include/linux/relay.h
78486 index d7c8359..818daf5 100644
78487 --- a/include/linux/relay.h
78488 +++ b/include/linux/relay.h
78489 @@ -157,7 +157,7 @@ struct rchan_callbacks
78490 * The callback should return 0 if successful, negative if not.
78491 */
78492 int (*remove_buf_file)(struct dentry *dentry);
78493 -};
78494 +} __no_const;
78495
78496 /*
78497 * CONFIG_RELAY kernel API, kernel/relay.c
78498 diff --git a/include/linux/rio.h b/include/linux/rio.h
78499 index b71d573..2f940bd 100644
78500 --- a/include/linux/rio.h
78501 +++ b/include/linux/rio.h
78502 @@ -355,7 +355,7 @@ struct rio_ops {
78503 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
78504 u64 rstart, u32 size, u32 flags);
78505 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
78506 -};
78507 +} __no_const;
78508
78509 #define RIO_RESOURCE_MEM 0x00000100
78510 #define RIO_RESOURCE_DOORBELL 0x00000200
78511 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
78512 index 6dacb93..6174423 100644
78513 --- a/include/linux/rmap.h
78514 +++ b/include/linux/rmap.h
78515 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
78516 void anon_vma_init(void); /* create anon_vma_cachep */
78517 int anon_vma_prepare(struct vm_area_struct *);
78518 void unlink_anon_vmas(struct vm_area_struct *);
78519 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
78520 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
78521 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
78522 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
78523
78524 static inline void anon_vma_merge(struct vm_area_struct *vma,
78525 struct vm_area_struct *next)
78526 diff --git a/include/linux/sched.h b/include/linux/sched.h
78527 index b1e963e..4916219 100644
78528 --- a/include/linux/sched.h
78529 +++ b/include/linux/sched.h
78530 @@ -62,6 +62,7 @@ struct bio_list;
78531 struct fs_struct;
78532 struct perf_event_context;
78533 struct blk_plug;
78534 +struct linux_binprm;
78535
78536 /*
78537 * List of flags we want to share for kernel threads,
78538 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
78539 extern int in_sched_functions(unsigned long addr);
78540
78541 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
78542 -extern signed long schedule_timeout(signed long timeout);
78543 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
78544 extern signed long schedule_timeout_interruptible(signed long timeout);
78545 extern signed long schedule_timeout_killable(signed long timeout);
78546 extern signed long schedule_timeout_uninterruptible(signed long timeout);
78547 @@ -306,6 +307,19 @@ struct nsproxy;
78548 struct user_namespace;
78549
78550 #ifdef CONFIG_MMU
78551 +
78552 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
78553 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
78554 +#else
78555 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
78556 +{
78557 + return 0;
78558 +}
78559 +#endif
78560 +
78561 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
78562 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
78563 +
78564 extern void arch_pick_mmap_layout(struct mm_struct *mm);
78565 extern unsigned long
78566 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
78567 @@ -585,6 +599,17 @@ struct signal_struct {
78568 #ifdef CONFIG_TASKSTATS
78569 struct taskstats *stats;
78570 #endif
78571 +
78572 +#ifdef CONFIG_GRKERNSEC
78573 + u32 curr_ip;
78574 + u32 saved_ip;
78575 + u32 gr_saddr;
78576 + u32 gr_daddr;
78577 + u16 gr_sport;
78578 + u16 gr_dport;
78579 + u8 used_accept:1;
78580 +#endif
78581 +
78582 #ifdef CONFIG_AUDIT
78583 unsigned audit_tty;
78584 unsigned audit_tty_log_passwd;
78585 @@ -665,6 +690,14 @@ struct user_struct {
78586 struct key *session_keyring; /* UID's default session keyring */
78587 #endif
78588
78589 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
78590 + unsigned char kernel_banned;
78591 +#endif
78592 +#ifdef CONFIG_GRKERNSEC_BRUTE
78593 + unsigned char suid_banned;
78594 + unsigned long suid_ban_expires;
78595 +#endif
78596 +
78597 /* Hash table maintenance information */
78598 struct hlist_node uidhash_node;
78599 kuid_t uid;
78600 @@ -1150,8 +1183,8 @@ struct task_struct {
78601 struct list_head thread_group;
78602
78603 struct completion *vfork_done; /* for vfork() */
78604 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
78605 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78606 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
78607 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78608
78609 cputime_t utime, stime, utimescaled, stimescaled;
78610 cputime_t gtime;
78611 @@ -1176,11 +1209,6 @@ struct task_struct {
78612 struct task_cputime cputime_expires;
78613 struct list_head cpu_timers[3];
78614
78615 -/* process credentials */
78616 - const struct cred __rcu *real_cred; /* objective and real subjective task
78617 - * credentials (COW) */
78618 - const struct cred __rcu *cred; /* effective (overridable) subjective task
78619 - * credentials (COW) */
78620 char comm[TASK_COMM_LEN]; /* executable name excluding path
78621 - access with [gs]et_task_comm (which lock
78622 it with task_lock())
78623 @@ -1197,6 +1225,10 @@ struct task_struct {
78624 #endif
78625 /* CPU-specific state of this task */
78626 struct thread_struct thread;
78627 +/* thread_info moved to task_struct */
78628 +#ifdef CONFIG_X86
78629 + struct thread_info tinfo;
78630 +#endif
78631 /* filesystem information */
78632 struct fs_struct *fs;
78633 /* open file information */
78634 @@ -1270,6 +1302,10 @@ struct task_struct {
78635 gfp_t lockdep_reclaim_gfp;
78636 #endif
78637
78638 +/* process credentials */
78639 + const struct cred __rcu *real_cred; /* objective and real subjective task
78640 + * credentials (COW) */
78641 +
78642 /* journalling filesystem info */
78643 void *journal_info;
78644
78645 @@ -1308,6 +1344,10 @@ struct task_struct {
78646 /* cg_list protected by css_set_lock and tsk->alloc_lock */
78647 struct list_head cg_list;
78648 #endif
78649 +
78650 + const struct cred __rcu *cred; /* effective (overridable) subjective task
78651 + * credentials (COW) */
78652 +
78653 #ifdef CONFIG_FUTEX
78654 struct robust_list_head __user *robust_list;
78655 #ifdef CONFIG_COMPAT
78656 @@ -1411,8 +1451,79 @@ struct task_struct {
78657 unsigned int sequential_io;
78658 unsigned int sequential_io_avg;
78659 #endif
78660 +
78661 +#ifdef CONFIG_GRKERNSEC
78662 + /* grsecurity */
78663 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78664 + u64 exec_id;
78665 +#endif
78666 +#ifdef CONFIG_GRKERNSEC_SETXID
78667 + const struct cred *delayed_cred;
78668 +#endif
78669 + struct dentry *gr_chroot_dentry;
78670 + struct acl_subject_label *acl;
78671 + struct acl_subject_label *tmpacl;
78672 + struct acl_role_label *role;
78673 + struct file *exec_file;
78674 + unsigned long brute_expires;
78675 + u16 acl_role_id;
78676 + u8 inherited;
78677 + /* is this the task that authenticated to the special role */
78678 + u8 acl_sp_role;
78679 + u8 is_writable;
78680 + u8 brute;
78681 + u8 gr_is_chrooted;
78682 +#endif
78683 +
78684 };
78685
78686 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
78687 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
78688 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
78689 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
78690 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
78691 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
78692 +
78693 +#ifdef CONFIG_PAX_SOFTMODE
78694 +extern int pax_softmode;
78695 +#endif
78696 +
78697 +extern int pax_check_flags(unsigned long *);
78698 +#define PAX_PARSE_FLAGS_FALLBACK (~0UL)
78699 +
78700 +/* if tsk != current then task_lock must be held on it */
78701 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
78702 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
78703 +{
78704 + if (likely(tsk->mm))
78705 + return tsk->mm->pax_flags;
78706 + else
78707 + return 0UL;
78708 +}
78709 +
78710 +/* if tsk != current then task_lock must be held on it */
78711 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
78712 +{
78713 + if (likely(tsk->mm)) {
78714 + tsk->mm->pax_flags = flags;
78715 + return 0;
78716 + }
78717 + return -EINVAL;
78718 +}
78719 +#endif
78720 +
78721 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
78722 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
78723 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
78724 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
78725 +#endif
78726 +
78727 +struct path;
78728 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
78729 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
78730 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
78731 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
78732 +
78733 /* Future-safe accessor for struct task_struct's cpus_allowed. */
78734 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
78735
78736 @@ -1471,7 +1582,7 @@ struct pid_namespace;
78737 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
78738 struct pid_namespace *ns);
78739
78740 -static inline pid_t task_pid_nr(struct task_struct *tsk)
78741 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
78742 {
78743 return tsk->pid;
78744 }
78745 @@ -1921,7 +2032,9 @@ void yield(void);
78746 extern struct exec_domain default_exec_domain;
78747
78748 union thread_union {
78749 +#ifndef CONFIG_X86
78750 struct thread_info thread_info;
78751 +#endif
78752 unsigned long stack[THREAD_SIZE/sizeof(long)];
78753 };
78754
78755 @@ -1954,6 +2067,7 @@ extern struct pid_namespace init_pid_ns;
78756 */
78757
78758 extern struct task_struct *find_task_by_vpid(pid_t nr);
78759 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
78760 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
78761 struct pid_namespace *ns);
78762
78763 @@ -2118,7 +2232,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
78764 extern void exit_itimers(struct signal_struct *);
78765 extern void flush_itimer_signals(void);
78766
78767 -extern void do_group_exit(int);
78768 +extern __noreturn void do_group_exit(int);
78769
78770 extern int allow_signal(int);
78771 extern int disallow_signal(int);
78772 @@ -2309,9 +2423,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
78773
78774 #endif
78775
78776 -static inline int object_is_on_stack(void *obj)
78777 +static inline int object_starts_on_stack(void *obj)
78778 {
78779 - void *stack = task_stack_page(current);
78780 + const void *stack = task_stack_page(current);
78781
78782 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
78783 }
78784 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
78785 index bf8086b..962b035 100644
78786 --- a/include/linux/sched/sysctl.h
78787 +++ b/include/linux/sched/sysctl.h
78788 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
78789 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
78790
78791 extern int sysctl_max_map_count;
78792 +extern unsigned long sysctl_heap_stack_gap;
78793
78794 extern unsigned int sysctl_sched_latency;
78795 extern unsigned int sysctl_sched_min_granularity;
78796 diff --git a/include/linux/security.h b/include/linux/security.h
78797 index 9d37e2b..43368e4 100644
78798 --- a/include/linux/security.h
78799 +++ b/include/linux/security.h
78800 @@ -27,6 +27,7 @@
78801 #include <linux/slab.h>
78802 #include <linux/err.h>
78803 #include <linux/string.h>
78804 +#include <linux/grsecurity.h>
78805
78806 struct linux_binprm;
78807 struct cred;
78808 @@ -116,8 +117,6 @@ struct seq_file;
78809
78810 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
78811
78812 -void reset_security_ops(void);
78813 -
78814 #ifdef CONFIG_MMU
78815 extern unsigned long mmap_min_addr;
78816 extern unsigned long dac_mmap_min_addr;
78817 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
78818 index dc368b8..e895209 100644
78819 --- a/include/linux/semaphore.h
78820 +++ b/include/linux/semaphore.h
78821 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
78822 }
78823
78824 extern void down(struct semaphore *sem);
78825 -extern int __must_check down_interruptible(struct semaphore *sem);
78826 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
78827 extern int __must_check down_killable(struct semaphore *sem);
78828 extern int __must_check down_trylock(struct semaphore *sem);
78829 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
78830 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
78831 index 4e32edc..f8f2d18 100644
78832 --- a/include/linux/seq_file.h
78833 +++ b/include/linux/seq_file.h
78834 @@ -26,6 +26,9 @@ struct seq_file {
78835 struct mutex lock;
78836 const struct seq_operations *op;
78837 int poll_event;
78838 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78839 + u64 exec_id;
78840 +#endif
78841 #ifdef CONFIG_USER_NS
78842 struct user_namespace *user_ns;
78843 #endif
78844 @@ -38,6 +41,7 @@ struct seq_operations {
78845 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
78846 int (*show) (struct seq_file *m, void *v);
78847 };
78848 +typedef struct seq_operations __no_const seq_operations_no_const;
78849
78850 #define SEQ_SKIP 1
78851
78852 diff --git a/include/linux/shm.h b/include/linux/shm.h
78853 index 429c199..4d42e38 100644
78854 --- a/include/linux/shm.h
78855 +++ b/include/linux/shm.h
78856 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
78857
78858 /* The task created the shm object. NULL if the task is dead. */
78859 struct task_struct *shm_creator;
78860 +#ifdef CONFIG_GRKERNSEC
78861 + time_t shm_createtime;
78862 + pid_t shm_lapid;
78863 +#endif
78864 };
78865
78866 /* shm_mode upper byte flags */
78867 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
78868 index efa1649..ff898ac 100644
78869 --- a/include/linux/skbuff.h
78870 +++ b/include/linux/skbuff.h
78871 @@ -639,7 +639,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
78872 extern struct sk_buff *__alloc_skb(unsigned int size,
78873 gfp_t priority, int flags, int node);
78874 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
78875 -static inline struct sk_buff *alloc_skb(unsigned int size,
78876 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
78877 gfp_t priority)
78878 {
78879 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
78880 @@ -755,7 +755,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
78881 */
78882 static inline int skb_queue_empty(const struct sk_buff_head *list)
78883 {
78884 - return list->next == (struct sk_buff *)list;
78885 + return list->next == (const struct sk_buff *)list;
78886 }
78887
78888 /**
78889 @@ -768,7 +768,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
78890 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78891 const struct sk_buff *skb)
78892 {
78893 - return skb->next == (struct sk_buff *)list;
78894 + return skb->next == (const struct sk_buff *)list;
78895 }
78896
78897 /**
78898 @@ -781,7 +781,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78899 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
78900 const struct sk_buff *skb)
78901 {
78902 - return skb->prev == (struct sk_buff *)list;
78903 + return skb->prev == (const struct sk_buff *)list;
78904 }
78905
78906 /**
78907 @@ -1746,7 +1746,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
78908 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
78909 */
78910 #ifndef NET_SKB_PAD
78911 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
78912 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
78913 #endif
78914
78915 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
78916 @@ -2344,7 +2344,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
78917 int noblock, int *err);
78918 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
78919 struct poll_table_struct *wait);
78920 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
78921 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
78922 int offset, struct iovec *to,
78923 int size);
78924 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
78925 @@ -2623,6 +2623,9 @@ static inline void nf_reset(struct sk_buff *skb)
78926 nf_bridge_put(skb->nf_bridge);
78927 skb->nf_bridge = NULL;
78928 #endif
78929 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
78930 + skb->nf_trace = 0;
78931 +#endif
78932 }
78933
78934 static inline void nf_reset_trace(struct sk_buff *skb)
78935 diff --git a/include/linux/slab.h b/include/linux/slab.h
78936 index 74f1058..914b7da 100644
78937 --- a/include/linux/slab.h
78938 +++ b/include/linux/slab.h
78939 @@ -14,15 +14,29 @@
78940 #include <linux/gfp.h>
78941 #include <linux/types.h>
78942 #include <linux/workqueue.h>
78943 -
78944 +#include <linux/err.h>
78945
78946 /*
78947 * Flags to pass to kmem_cache_create().
78948 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
78949 */
78950 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
78951 +
78952 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78953 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
78954 +#else
78955 +#define SLAB_USERCOPY 0x00000000UL
78956 +#endif
78957 +
78958 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
78959 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
78960 +
78961 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78962 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
78963 +#else
78964 +#define SLAB_NO_SANITIZE 0x00000000UL
78965 +#endif
78966 +
78967 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
78968 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
78969 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
78970 @@ -91,10 +105,13 @@
78971 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
78972 * Both make kfree a no-op.
78973 */
78974 -#define ZERO_SIZE_PTR ((void *)16)
78975 +#define ZERO_SIZE_PTR \
78976 +({ \
78977 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
78978 + (void *)(-MAX_ERRNO-1L); \
78979 +})
78980
78981 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
78982 - (unsigned long)ZERO_SIZE_PTR)
78983 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
78984
78985 #include <linux/kmemleak.h>
78986
78987 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
78988 void kfree(const void *);
78989 void kzfree(const void *);
78990 size_t ksize(const void *);
78991 +const char *check_heap_object(const void *ptr, unsigned long n);
78992 +bool is_usercopy_object(const void *ptr);
78993
78994 /*
78995 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
78996 @@ -167,7 +186,7 @@ struct kmem_cache {
78997 unsigned int align; /* Alignment as calculated */
78998 unsigned long flags; /* Active flags on the slab */
78999 const char *name; /* Slab name for sysfs */
79000 - int refcount; /* Use counter */
79001 + atomic_t refcount; /* Use counter */
79002 void (*ctor)(void *); /* Called on object slot creation */
79003 struct list_head list; /* List of all slab caches on the system */
79004 };
79005 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
79006 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
79007 #endif
79008
79009 +#ifdef CONFIG_PAX_USERCOPY_SLABS
79010 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
79011 +#endif
79012 +
79013 /*
79014 * Figure out which kmalloc slab an allocation of a certain size
79015 * belongs to.
79016 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
79017 * 2 = 120 .. 192 bytes
79018 * n = 2^(n-1) .. 2^n -1
79019 */
79020 -static __always_inline int kmalloc_index(size_t size)
79021 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
79022 {
79023 if (!size)
79024 return 0;
79025 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
79026 }
79027 #endif /* !CONFIG_SLOB */
79028
79029 -void *__kmalloc(size_t size, gfp_t flags);
79030 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
79031 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
79032
79033 #ifdef CONFIG_NUMA
79034 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
79035 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
79036 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
79037 #else
79038 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
79039 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
79040 index e9346b4..1494959 100644
79041 --- a/include/linux/slab_def.h
79042 +++ b/include/linux/slab_def.h
79043 @@ -36,7 +36,7 @@ struct kmem_cache {
79044 /* 4) cache creation/removal */
79045 const char *name;
79046 struct list_head list;
79047 - int refcount;
79048 + atomic_t refcount;
79049 int object_size;
79050 int align;
79051
79052 @@ -52,10 +52,14 @@ struct kmem_cache {
79053 unsigned long node_allocs;
79054 unsigned long node_frees;
79055 unsigned long node_overflow;
79056 - atomic_t allochit;
79057 - atomic_t allocmiss;
79058 - atomic_t freehit;
79059 - atomic_t freemiss;
79060 + atomic_unchecked_t allochit;
79061 + atomic_unchecked_t allocmiss;
79062 + atomic_unchecked_t freehit;
79063 + atomic_unchecked_t freemiss;
79064 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
79065 + atomic_unchecked_t sanitized;
79066 + atomic_unchecked_t not_sanitized;
79067 +#endif
79068
79069 /*
79070 * If debugging is enabled, then the allocator can add additional
79071 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
79072 index cc0b67e..a0329b1 100644
79073 --- a/include/linux/slub_def.h
79074 +++ b/include/linux/slub_def.h
79075 @@ -74,7 +74,7 @@ struct kmem_cache {
79076 struct kmem_cache_order_objects max;
79077 struct kmem_cache_order_objects min;
79078 gfp_t allocflags; /* gfp flags to use on each alloc */
79079 - int refcount; /* Refcount for slab cache destroy */
79080 + atomic_t refcount; /* Refcount for slab cache destroy */
79081 void (*ctor)(void *);
79082 int inuse; /* Offset to metadata */
79083 int align; /* Alignment */
79084 diff --git a/include/linux/smp.h b/include/linux/smp.h
79085 index 731f523..3340268 100644
79086 --- a/include/linux/smp.h
79087 +++ b/include/linux/smp.h
79088 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
79089 #endif
79090
79091 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
79092 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
79093 #define put_cpu() preempt_enable()
79094 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
79095
79096 /*
79097 * Callback to arch code if there's nosmp or maxcpus=0 on the
79098 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
79099 index 54f91d3..be2c379 100644
79100 --- a/include/linux/sock_diag.h
79101 +++ b/include/linux/sock_diag.h
79102 @@ -11,7 +11,7 @@ struct sock;
79103 struct sock_diag_handler {
79104 __u8 family;
79105 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
79106 -};
79107 +} __do_const;
79108
79109 int sock_diag_register(const struct sock_diag_handler *h);
79110 void sock_diag_unregister(const struct sock_diag_handler *h);
79111 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
79112 index 680f9a3..f13aeb0 100644
79113 --- a/include/linux/sonet.h
79114 +++ b/include/linux/sonet.h
79115 @@ -7,7 +7,7 @@
79116 #include <uapi/linux/sonet.h>
79117
79118 struct k_sonet_stats {
79119 -#define __HANDLE_ITEM(i) atomic_t i
79120 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
79121 __SONET_ITEMS
79122 #undef __HANDLE_ITEM
79123 };
79124 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
79125 index 07d8e53..dc934c9 100644
79126 --- a/include/linux/sunrpc/addr.h
79127 +++ b/include/linux/sunrpc/addr.h
79128 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
79129 {
79130 switch (sap->sa_family) {
79131 case AF_INET:
79132 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
79133 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
79134 case AF_INET6:
79135 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
79136 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
79137 }
79138 return 0;
79139 }
79140 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
79141 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
79142 const struct sockaddr *src)
79143 {
79144 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
79145 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
79146 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
79147
79148 dsin->sin_family = ssin->sin_family;
79149 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
79150 if (sa->sa_family != AF_INET6)
79151 return 0;
79152
79153 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
79154 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
79155 }
79156
79157 #endif /* _LINUX_SUNRPC_ADDR_H */
79158 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
79159 index 6740801..c535f27 100644
79160 --- a/include/linux/sunrpc/clnt.h
79161 +++ b/include/linux/sunrpc/clnt.h
79162 @@ -96,7 +96,7 @@ struct rpc_procinfo {
79163 unsigned int p_timer; /* Which RTT timer to use */
79164 u32 p_statidx; /* Which procedure to account */
79165 const char * p_name; /* name of procedure */
79166 -};
79167 +} __do_const;
79168
79169 #ifdef __KERNEL__
79170
79171 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
79172 index 6eecfc2..7ada79d 100644
79173 --- a/include/linux/sunrpc/svc.h
79174 +++ b/include/linux/sunrpc/svc.h
79175 @@ -410,7 +410,7 @@ struct svc_procedure {
79176 unsigned int pc_count; /* call count */
79177 unsigned int pc_cachetype; /* cache info (NFS) */
79178 unsigned int pc_xdrressize; /* maximum size of XDR reply */
79179 -};
79180 +} __do_const;
79181
79182 /*
79183 * Function prototypes.
79184 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
79185 index 0b8e3e6..33e0a01 100644
79186 --- a/include/linux/sunrpc/svc_rdma.h
79187 +++ b/include/linux/sunrpc/svc_rdma.h
79188 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
79189 extern unsigned int svcrdma_max_requests;
79190 extern unsigned int svcrdma_max_req_size;
79191
79192 -extern atomic_t rdma_stat_recv;
79193 -extern atomic_t rdma_stat_read;
79194 -extern atomic_t rdma_stat_write;
79195 -extern atomic_t rdma_stat_sq_starve;
79196 -extern atomic_t rdma_stat_rq_starve;
79197 -extern atomic_t rdma_stat_rq_poll;
79198 -extern atomic_t rdma_stat_rq_prod;
79199 -extern atomic_t rdma_stat_sq_poll;
79200 -extern atomic_t rdma_stat_sq_prod;
79201 +extern atomic_unchecked_t rdma_stat_recv;
79202 +extern atomic_unchecked_t rdma_stat_read;
79203 +extern atomic_unchecked_t rdma_stat_write;
79204 +extern atomic_unchecked_t rdma_stat_sq_starve;
79205 +extern atomic_unchecked_t rdma_stat_rq_starve;
79206 +extern atomic_unchecked_t rdma_stat_rq_poll;
79207 +extern atomic_unchecked_t rdma_stat_rq_prod;
79208 +extern atomic_unchecked_t rdma_stat_sq_poll;
79209 +extern atomic_unchecked_t rdma_stat_sq_prod;
79210
79211 #define RPCRDMA_VERSION 1
79212
79213 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
79214 index 8d71d65..f79586e 100644
79215 --- a/include/linux/sunrpc/svcauth.h
79216 +++ b/include/linux/sunrpc/svcauth.h
79217 @@ -120,7 +120,7 @@ struct auth_ops {
79218 int (*release)(struct svc_rqst *rq);
79219 void (*domain_release)(struct auth_domain *);
79220 int (*set_client)(struct svc_rqst *rq);
79221 -};
79222 +} __do_const;
79223
79224 #define SVC_GARBAGE 1
79225 #define SVC_SYSERR 2
79226 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
79227 index a5ffd32..0935dea 100644
79228 --- a/include/linux/swiotlb.h
79229 +++ b/include/linux/swiotlb.h
79230 @@ -60,7 +60,8 @@ extern void
79231
79232 extern void
79233 swiotlb_free_coherent(struct device *hwdev, size_t size,
79234 - void *vaddr, dma_addr_t dma_handle);
79235 + void *vaddr, dma_addr_t dma_handle,
79236 + struct dma_attrs *attrs);
79237
79238 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
79239 unsigned long offset, size_t size,
79240 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
79241 index 7fac04e..de57300 100644
79242 --- a/include/linux/syscalls.h
79243 +++ b/include/linux/syscalls.h
79244 @@ -97,8 +97,14 @@ struct sigaltstack;
79245 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
79246
79247 #define __SC_DECL(t, a) t a
79248 +#define __TYPE_IS_U(t) (__same_type((t)0, 0UL) || __same_type((t)0, 0U) || __same_type((t)0, (unsigned short)0) || __same_type((t)0, (unsigned char)0))
79249 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
79250 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
79251 +#define __SC_LONG(t, a) __typeof( \
79252 + __builtin_choose_expr( \
79253 + sizeof(t) > sizeof(int), \
79254 + (t) 0, \
79255 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
79256 + )) a
79257 #define __SC_CAST(t, a) (t) a
79258 #define __SC_ARGS(t, a) a
79259 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
79260 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
79261 asmlinkage long sys_fsync(unsigned int fd);
79262 asmlinkage long sys_fdatasync(unsigned int fd);
79263 asmlinkage long sys_bdflush(int func, long data);
79264 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
79265 - char __user *type, unsigned long flags,
79266 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
79267 + const char __user *type, unsigned long flags,
79268 void __user *data);
79269 -asmlinkage long sys_umount(char __user *name, int flags);
79270 -asmlinkage long sys_oldumount(char __user *name);
79271 +asmlinkage long sys_umount(const char __user *name, int flags);
79272 +asmlinkage long sys_oldumount(const char __user *name);
79273 asmlinkage long sys_truncate(const char __user *path, long length);
79274 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
79275 asmlinkage long sys_stat(const char __user *filename,
79276 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
79277 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
79278 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
79279 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
79280 - struct sockaddr __user *, int);
79281 + struct sockaddr __user *, int) __intentional_overflow(0);
79282 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
79283 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
79284 unsigned int vlen, unsigned flags);
79285 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
79286 index 27b3b0b..e093dd9 100644
79287 --- a/include/linux/syscore_ops.h
79288 +++ b/include/linux/syscore_ops.h
79289 @@ -16,7 +16,7 @@ struct syscore_ops {
79290 int (*suspend)(void);
79291 void (*resume)(void);
79292 void (*shutdown)(void);
79293 -};
79294 +} __do_const;
79295
79296 extern void register_syscore_ops(struct syscore_ops *ops);
79297 extern void unregister_syscore_ops(struct syscore_ops *ops);
79298 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
79299 index 14a8ff2..af52bad 100644
79300 --- a/include/linux/sysctl.h
79301 +++ b/include/linux/sysctl.h
79302 @@ -34,13 +34,13 @@ struct ctl_table_root;
79303 struct ctl_table_header;
79304 struct ctl_dir;
79305
79306 -typedef struct ctl_table ctl_table;
79307 -
79308 typedef int proc_handler (struct ctl_table *ctl, int write,
79309 void __user *buffer, size_t *lenp, loff_t *ppos);
79310
79311 extern int proc_dostring(struct ctl_table *, int,
79312 void __user *, size_t *, loff_t *);
79313 +extern int proc_dostring_modpriv(struct ctl_table *, int,
79314 + void __user *, size_t *, loff_t *);
79315 extern int proc_dointvec(struct ctl_table *, int,
79316 void __user *, size_t *, loff_t *);
79317 extern int proc_dointvec_minmax(struct ctl_table *, int,
79318 @@ -115,7 +115,9 @@ struct ctl_table
79319 struct ctl_table_poll *poll;
79320 void *extra1;
79321 void *extra2;
79322 -};
79323 +} __do_const;
79324 +typedef struct ctl_table __no_const ctl_table_no_const;
79325 +typedef struct ctl_table ctl_table;
79326
79327 struct ctl_node {
79328 struct rb_node node;
79329 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
79330 index 11baec7..706f99f 100644
79331 --- a/include/linux/sysfs.h
79332 +++ b/include/linux/sysfs.h
79333 @@ -33,7 +33,8 @@ struct attribute {
79334 struct lock_class_key *key;
79335 struct lock_class_key skey;
79336 #endif
79337 -};
79338 +} __do_const;
79339 +typedef struct attribute __no_const attribute_no_const;
79340
79341 /**
79342 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
79343 @@ -62,7 +63,8 @@ struct attribute_group {
79344 struct attribute *, int);
79345 struct attribute **attrs;
79346 struct bin_attribute **bin_attrs;
79347 -};
79348 +} __do_const;
79349 +typedef struct attribute_group __no_const attribute_group_no_const;
79350
79351 /**
79352 * Use these macros to make defining attributes easier. See include/linux/device.h
79353 @@ -126,7 +128,8 @@ struct bin_attribute {
79354 char *, loff_t, size_t);
79355 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
79356 struct vm_area_struct *vma);
79357 -};
79358 +} __do_const;
79359 +typedef struct bin_attribute __no_const bin_attribute_no_const;
79360
79361 /**
79362 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
79363 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
79364 index 7faf933..9b85a0c 100644
79365 --- a/include/linux/sysrq.h
79366 +++ b/include/linux/sysrq.h
79367 @@ -16,6 +16,7 @@
79368
79369 #include <linux/errno.h>
79370 #include <linux/types.h>
79371 +#include <linux/compiler.h>
79372
79373 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
79374 #define SYSRQ_DEFAULT_ENABLE 1
79375 @@ -36,7 +37,7 @@ struct sysrq_key_op {
79376 char *help_msg;
79377 char *action_msg;
79378 int enable_mask;
79379 -};
79380 +} __do_const;
79381
79382 #ifdef CONFIG_MAGIC_SYSRQ
79383
79384 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
79385 index 4ae6f32..425d3e1 100644
79386 --- a/include/linux/thread_info.h
79387 +++ b/include/linux/thread_info.h
79388 @@ -150,6 +150,15 @@ static inline bool test_and_clear_restore_sigmask(void)
79389 #error "no set_restore_sigmask() provided and default one won't work"
79390 #endif
79391
79392 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
79393 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
79394 +{
79395 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
79396 + if (!__builtin_constant_p(n))
79397 +#endif
79398 + __check_object_size(ptr, n, to_user);
79399 +}
79400 +
79401 #endif /* __KERNEL__ */
79402
79403 #endif /* _LINUX_THREAD_INFO_H */
79404 diff --git a/include/linux/tty.h b/include/linux/tty.h
79405 index 64f8646..1515fc7 100644
79406 --- a/include/linux/tty.h
79407 +++ b/include/linux/tty.h
79408 @@ -197,7 +197,7 @@ struct tty_port {
79409 const struct tty_port_operations *ops; /* Port operations */
79410 spinlock_t lock; /* Lock protecting tty field */
79411 int blocked_open; /* Waiting to open */
79412 - int count; /* Usage count */
79413 + atomic_t count; /* Usage count */
79414 wait_queue_head_t open_wait; /* Open waiters */
79415 wait_queue_head_t close_wait; /* Close waiters */
79416 wait_queue_head_t delta_msr_wait; /* Modem status change */
79417 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
79418 struct tty_struct *tty, struct file *filp);
79419 static inline int tty_port_users(struct tty_port *port)
79420 {
79421 - return port->count + port->blocked_open;
79422 + return atomic_read(&port->count) + port->blocked_open;
79423 }
79424
79425 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
79426 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
79427 index 756a609..b302dd6 100644
79428 --- a/include/linux/tty_driver.h
79429 +++ b/include/linux/tty_driver.h
79430 @@ -285,7 +285,7 @@ struct tty_operations {
79431 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
79432 #endif
79433 const struct file_operations *proc_fops;
79434 -};
79435 +} __do_const;
79436
79437 struct tty_driver {
79438 int magic; /* magic number for this structure */
79439 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
79440 index f15c898..207b7d1 100644
79441 --- a/include/linux/tty_ldisc.h
79442 +++ b/include/linux/tty_ldisc.h
79443 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
79444
79445 struct module *owner;
79446
79447 - int refcount;
79448 + atomic_t refcount;
79449 };
79450
79451 struct tty_ldisc {
79452 diff --git a/include/linux/types.h b/include/linux/types.h
79453 index 4d118ba..c3ee9bf 100644
79454 --- a/include/linux/types.h
79455 +++ b/include/linux/types.h
79456 @@ -176,10 +176,26 @@ typedef struct {
79457 int counter;
79458 } atomic_t;
79459
79460 +#ifdef CONFIG_PAX_REFCOUNT
79461 +typedef struct {
79462 + int counter;
79463 +} atomic_unchecked_t;
79464 +#else
79465 +typedef atomic_t atomic_unchecked_t;
79466 +#endif
79467 +
79468 #ifdef CONFIG_64BIT
79469 typedef struct {
79470 long counter;
79471 } atomic64_t;
79472 +
79473 +#ifdef CONFIG_PAX_REFCOUNT
79474 +typedef struct {
79475 + long counter;
79476 +} atomic64_unchecked_t;
79477 +#else
79478 +typedef atomic64_t atomic64_unchecked_t;
79479 +#endif
79480 #endif
79481
79482 struct list_head {
79483 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
79484 index 5ca0951..ab496a5 100644
79485 --- a/include/linux/uaccess.h
79486 +++ b/include/linux/uaccess.h
79487 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
79488 long ret; \
79489 mm_segment_t old_fs = get_fs(); \
79490 \
79491 - set_fs(KERNEL_DS); \
79492 pagefault_disable(); \
79493 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
79494 - pagefault_enable(); \
79495 + set_fs(KERNEL_DS); \
79496 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
79497 set_fs(old_fs); \
79498 + pagefault_enable(); \
79499 ret; \
79500 })
79501
79502 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
79503 index 8e522cbc..aa8572d 100644
79504 --- a/include/linux/uidgid.h
79505 +++ b/include/linux/uidgid.h
79506 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
79507
79508 #endif /* CONFIG_USER_NS */
79509
79510 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
79511 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
79512 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
79513 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
79514 +
79515 #endif /* _LINUX_UIDGID_H */
79516 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
79517 index 99c1b4d..562e6f3 100644
79518 --- a/include/linux/unaligned/access_ok.h
79519 +++ b/include/linux/unaligned/access_ok.h
79520 @@ -4,34 +4,34 @@
79521 #include <linux/kernel.h>
79522 #include <asm/byteorder.h>
79523
79524 -static inline u16 get_unaligned_le16(const void *p)
79525 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
79526 {
79527 - return le16_to_cpup((__le16 *)p);
79528 + return le16_to_cpup((const __le16 *)p);
79529 }
79530
79531 -static inline u32 get_unaligned_le32(const void *p)
79532 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
79533 {
79534 - return le32_to_cpup((__le32 *)p);
79535 + return le32_to_cpup((const __le32 *)p);
79536 }
79537
79538 -static inline u64 get_unaligned_le64(const void *p)
79539 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
79540 {
79541 - return le64_to_cpup((__le64 *)p);
79542 + return le64_to_cpup((const __le64 *)p);
79543 }
79544
79545 -static inline u16 get_unaligned_be16(const void *p)
79546 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
79547 {
79548 - return be16_to_cpup((__be16 *)p);
79549 + return be16_to_cpup((const __be16 *)p);
79550 }
79551
79552 -static inline u32 get_unaligned_be32(const void *p)
79553 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
79554 {
79555 - return be32_to_cpup((__be32 *)p);
79556 + return be32_to_cpup((const __be32 *)p);
79557 }
79558
79559 -static inline u64 get_unaligned_be64(const void *p)
79560 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
79561 {
79562 - return be64_to_cpup((__be64 *)p);
79563 + return be64_to_cpup((const __be64 *)p);
79564 }
79565
79566 static inline void put_unaligned_le16(u16 val, void *p)
79567 diff --git a/include/linux/usb.h b/include/linux/usb.h
79568 index 6b02370..2355ffa 100644
79569 --- a/include/linux/usb.h
79570 +++ b/include/linux/usb.h
79571 @@ -563,7 +563,7 @@ struct usb_device {
79572 int maxchild;
79573
79574 u32 quirks;
79575 - atomic_t urbnum;
79576 + atomic_unchecked_t urbnum;
79577
79578 unsigned long active_duration;
79579
79580 @@ -1639,7 +1639,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
79581
79582 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
79583 __u8 request, __u8 requesttype, __u16 value, __u16 index,
79584 - void *data, __u16 size, int timeout);
79585 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
79586 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
79587 void *data, int len, int *actual_length, int timeout);
79588 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
79589 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
79590 index e452ba6..78f8e80 100644
79591 --- a/include/linux/usb/renesas_usbhs.h
79592 +++ b/include/linux/usb/renesas_usbhs.h
79593 @@ -39,7 +39,7 @@ enum {
79594 */
79595 struct renesas_usbhs_driver_callback {
79596 int (*notify_hotplug)(struct platform_device *pdev);
79597 -};
79598 +} __no_const;
79599
79600 /*
79601 * callback functions for platform
79602 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
79603 index 6f8fbcf..8259001 100644
79604 --- a/include/linux/vermagic.h
79605 +++ b/include/linux/vermagic.h
79606 @@ -25,9 +25,35 @@
79607 #define MODULE_ARCH_VERMAGIC ""
79608 #endif
79609
79610 +#ifdef CONFIG_PAX_REFCOUNT
79611 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
79612 +#else
79613 +#define MODULE_PAX_REFCOUNT ""
79614 +#endif
79615 +
79616 +#ifdef CONSTIFY_PLUGIN
79617 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
79618 +#else
79619 +#define MODULE_CONSTIFY_PLUGIN ""
79620 +#endif
79621 +
79622 +#ifdef STACKLEAK_PLUGIN
79623 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
79624 +#else
79625 +#define MODULE_STACKLEAK_PLUGIN ""
79626 +#endif
79627 +
79628 +#ifdef CONFIG_GRKERNSEC
79629 +#define MODULE_GRSEC "GRSEC "
79630 +#else
79631 +#define MODULE_GRSEC ""
79632 +#endif
79633 +
79634 #define VERMAGIC_STRING \
79635 UTS_RELEASE " " \
79636 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
79637 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
79638 - MODULE_ARCH_VERMAGIC
79639 + MODULE_ARCH_VERMAGIC \
79640 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
79641 + MODULE_GRSEC
79642
79643 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
79644 index 502073a..a7de024 100644
79645 --- a/include/linux/vga_switcheroo.h
79646 +++ b/include/linux/vga_switcheroo.h
79647 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
79648
79649 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
79650
79651 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
79652 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
79653 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
79654 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
79655 #else
79656
79657 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
79658 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
79659
79660 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
79661
79662 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79663 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79664 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79665 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79666
79667 #endif
79668 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
79669 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
79670 index 4b8a891..cb8df6e 100644
79671 --- a/include/linux/vmalloc.h
79672 +++ b/include/linux/vmalloc.h
79673 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
79674 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
79675 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
79676 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
79677 +
79678 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
79679 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
79680 +#endif
79681 +
79682 /* bits [20..32] reserved for arch specific ioremap internals */
79683
79684 /*
79685 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
79686
79687 /* for /dev/kmem */
79688 extern long vread(char *buf, char *addr, unsigned long count);
79689 -extern long vwrite(char *buf, char *addr, unsigned long count);
79690 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
79691
79692 /*
79693 * Internals. Dont't use..
79694 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
79695 index e4b9480..5a5f65a 100644
79696 --- a/include/linux/vmstat.h
79697 +++ b/include/linux/vmstat.h
79698 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
79699 /*
79700 * Zone based page accounting with per cpu differentials.
79701 */
79702 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79703 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79704
79705 static inline void zone_page_state_add(long x, struct zone *zone,
79706 enum zone_stat_item item)
79707 {
79708 - atomic_long_add(x, &zone->vm_stat[item]);
79709 - atomic_long_add(x, &vm_stat[item]);
79710 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
79711 + atomic_long_add_unchecked(x, &vm_stat[item]);
79712 }
79713
79714 -static inline unsigned long global_page_state(enum zone_stat_item item)
79715 +static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
79716 {
79717 - long x = atomic_long_read(&vm_stat[item]);
79718 + long x = atomic_long_read_unchecked(&vm_stat[item]);
79719 #ifdef CONFIG_SMP
79720 if (x < 0)
79721 x = 0;
79722 @@ -109,10 +109,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
79723 return x;
79724 }
79725
79726 -static inline unsigned long zone_page_state(struct zone *zone,
79727 +static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
79728 enum zone_stat_item item)
79729 {
79730 - long x = atomic_long_read(&zone->vm_stat[item]);
79731 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79732 #ifdef CONFIG_SMP
79733 if (x < 0)
79734 x = 0;
79735 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
79736 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
79737 enum zone_stat_item item)
79738 {
79739 - long x = atomic_long_read(&zone->vm_stat[item]);
79740 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79741
79742 #ifdef CONFIG_SMP
79743 int cpu;
79744 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
79745
79746 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
79747 {
79748 - atomic_long_inc(&zone->vm_stat[item]);
79749 - atomic_long_inc(&vm_stat[item]);
79750 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
79751 + atomic_long_inc_unchecked(&vm_stat[item]);
79752 }
79753
79754 static inline void __inc_zone_page_state(struct page *page,
79755 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
79756
79757 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
79758 {
79759 - atomic_long_dec(&zone->vm_stat[item]);
79760 - atomic_long_dec(&vm_stat[item]);
79761 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
79762 + atomic_long_dec_unchecked(&vm_stat[item]);
79763 }
79764
79765 static inline void __dec_zone_page_state(struct page *page,
79766 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
79767 index 91b0a68..0e9adf6 100644
79768 --- a/include/linux/xattr.h
79769 +++ b/include/linux/xattr.h
79770 @@ -28,7 +28,7 @@ struct xattr_handler {
79771 size_t size, int handler_flags);
79772 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
79773 size_t size, int flags, int handler_flags);
79774 -};
79775 +} __do_const;
79776
79777 struct xattr {
79778 const char *name;
79779 @@ -37,6 +37,9 @@ struct xattr {
79780 };
79781
79782 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
79783 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
79784 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
79785 +#endif
79786 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
79787 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
79788 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
79789 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
79790 index 9c5a6b4..09c9438 100644
79791 --- a/include/linux/zlib.h
79792 +++ b/include/linux/zlib.h
79793 @@ -31,6 +31,7 @@
79794 #define _ZLIB_H
79795
79796 #include <linux/zconf.h>
79797 +#include <linux/compiler.h>
79798
79799 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
79800 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
79801 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
79802
79803 /* basic functions */
79804
79805 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
79806 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
79807 /*
79808 Returns the number of bytes that needs to be allocated for a per-
79809 stream workspace with the specified parameters. A pointer to this
79810 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
79811 index c768c9f..bdcaa5a 100644
79812 --- a/include/media/v4l2-dev.h
79813 +++ b/include/media/v4l2-dev.h
79814 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
79815 int (*mmap) (struct file *, struct vm_area_struct *);
79816 int (*open) (struct file *);
79817 int (*release) (struct file *);
79818 -};
79819 +} __do_const;
79820
79821 /*
79822 * Newer version of video_device, handled by videodev2.c
79823 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
79824 index c9b1593..a572459 100644
79825 --- a/include/media/v4l2-device.h
79826 +++ b/include/media/v4l2-device.h
79827 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
79828 this function returns 0. If the name ends with a digit (e.g. cx18),
79829 then the name will be set to cx18-0 since cx180 looks really odd. */
79830 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
79831 - atomic_t *instance);
79832 + atomic_unchecked_t *instance);
79833
79834 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
79835 Since the parent disappears this ensures that v4l2_dev doesn't have an
79836 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
79837 index 9a36d92..0aafe2a 100644
79838 --- a/include/net/9p/transport.h
79839 +++ b/include/net/9p/transport.h
79840 @@ -60,7 +60,7 @@ struct p9_trans_module {
79841 int (*cancel) (struct p9_client *, struct p9_req_t *req);
79842 int (*zc_request)(struct p9_client *, struct p9_req_t *,
79843 char *, char *, int , int, int, int);
79844 -};
79845 +} __do_const;
79846
79847 void v9fs_register_trans(struct p9_trans_module *m);
79848 void v9fs_unregister_trans(struct p9_trans_module *m);
79849 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
79850 index 1a966af..2767cf6 100644
79851 --- a/include/net/bluetooth/l2cap.h
79852 +++ b/include/net/bluetooth/l2cap.h
79853 @@ -551,7 +551,7 @@ struct l2cap_ops {
79854 void (*defer) (struct l2cap_chan *chan);
79855 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
79856 unsigned long len, int nb);
79857 -};
79858 +} __do_const;
79859
79860 struct l2cap_conn {
79861 struct hci_conn *hcon;
79862 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
79863 index f2ae33d..c457cf0 100644
79864 --- a/include/net/caif/cfctrl.h
79865 +++ b/include/net/caif/cfctrl.h
79866 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
79867 void (*radioset_rsp)(void);
79868 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
79869 struct cflayer *client_layer);
79870 -};
79871 +} __no_const;
79872
79873 /* Link Setup Parameters for CAIF-Links. */
79874 struct cfctrl_link_param {
79875 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
79876 struct cfctrl {
79877 struct cfsrvl serv;
79878 struct cfctrl_rsp res;
79879 - atomic_t req_seq_no;
79880 - atomic_t rsp_seq_no;
79881 + atomic_unchecked_t req_seq_no;
79882 + atomic_unchecked_t rsp_seq_no;
79883 struct list_head list;
79884 /* Protects from simultaneous access to first_req list */
79885 spinlock_t info_list_lock;
79886 diff --git a/include/net/flow.h b/include/net/flow.h
79887 index 628e11b..4c475df 100644
79888 --- a/include/net/flow.h
79889 +++ b/include/net/flow.h
79890 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
79891
79892 extern void flow_cache_flush(void);
79893 extern void flow_cache_flush_deferred(void);
79894 -extern atomic_t flow_cache_genid;
79895 +extern atomic_unchecked_t flow_cache_genid;
79896
79897 #endif
79898 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
79899 index 8e0b6c8..73cf605 100644
79900 --- a/include/net/genetlink.h
79901 +++ b/include/net/genetlink.h
79902 @@ -120,7 +120,7 @@ struct genl_ops {
79903 struct netlink_callback *cb);
79904 int (*done)(struct netlink_callback *cb);
79905 struct list_head ops_list;
79906 -};
79907 +} __do_const;
79908
79909 extern int __genl_register_family(struct genl_family *family);
79910
79911 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
79912 index 734d9b5..48a9a4b 100644
79913 --- a/include/net/gro_cells.h
79914 +++ b/include/net/gro_cells.h
79915 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
79916 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
79917
79918 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
79919 - atomic_long_inc(&dev->rx_dropped);
79920 + atomic_long_inc_unchecked(&dev->rx_dropped);
79921 kfree_skb(skb);
79922 return;
79923 }
79924 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
79925 index de2c785..0588a6b 100644
79926 --- a/include/net/inet_connection_sock.h
79927 +++ b/include/net/inet_connection_sock.h
79928 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
79929 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
79930 int (*bind_conflict)(const struct sock *sk,
79931 const struct inet_bind_bucket *tb, bool relax);
79932 -};
79933 +} __do_const;
79934
79935 /** inet_connection_sock - INET connection oriented sock
79936 *
79937 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
79938 index 53f464d..0bd0b49 100644
79939 --- a/include/net/inetpeer.h
79940 +++ b/include/net/inetpeer.h
79941 @@ -47,8 +47,8 @@ struct inet_peer {
79942 */
79943 union {
79944 struct {
79945 - atomic_t rid; /* Frag reception counter */
79946 - atomic_t ip_id_count; /* IP ID for the next packet */
79947 + atomic_unchecked_t rid; /* Frag reception counter */
79948 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
79949 };
79950 struct rcu_head rcu;
79951 struct inet_peer *gc_next;
79952 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
79953 /* can be called with or without local BH being disabled */
79954 static inline int inet_getid(struct inet_peer *p, int more)
79955 {
79956 - int old, new;
79957 + int id;
79958 more++;
79959 inet_peer_refcheck(p);
79960 - do {
79961 - old = atomic_read(&p->ip_id_count);
79962 - new = old + more;
79963 - if (!new)
79964 - new = 1;
79965 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
79966 - return new;
79967 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
79968 + if (!id)
79969 + id = atomic_inc_return_unchecked(&p->ip_id_count);
79970 + return id;
79971 }
79972
79973 #endif /* _NET_INETPEER_H */
79974 diff --git a/include/net/ip.h b/include/net/ip.h
79975 index 301f10c..b52cdaf 100644
79976 --- a/include/net/ip.h
79977 +++ b/include/net/ip.h
79978 @@ -212,7 +212,7 @@ extern struct local_ports {
79979 } sysctl_local_ports;
79980 extern void inet_get_local_port_range(int *low, int *high);
79981
79982 -extern unsigned long *sysctl_local_reserved_ports;
79983 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
79984 static inline int inet_is_reserved_local_port(int port)
79985 {
79986 return test_bit(port, sysctl_local_reserved_ports);
79987 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
79988 index cbf2be3..3683f6d 100644
79989 --- a/include/net/ip_fib.h
79990 +++ b/include/net/ip_fib.h
79991 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
79992
79993 #define FIB_RES_SADDR(net, res) \
79994 ((FIB_RES_NH(res).nh_saddr_genid == \
79995 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
79996 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
79997 FIB_RES_NH(res).nh_saddr : \
79998 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
79999 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
80000 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
80001 index 772252d..1e69799 100644
80002 --- a/include/net/ip_vs.h
80003 +++ b/include/net/ip_vs.h
80004 @@ -558,7 +558,7 @@ struct ip_vs_conn {
80005 struct ip_vs_conn *control; /* Master control connection */
80006 atomic_t n_control; /* Number of controlled ones */
80007 struct ip_vs_dest *dest; /* real server */
80008 - atomic_t in_pkts; /* incoming packet counter */
80009 + atomic_unchecked_t in_pkts; /* incoming packet counter */
80010
80011 /* packet transmitter for different forwarding methods. If it
80012 mangles the packet, it must return NF_DROP or better NF_STOLEN,
80013 @@ -705,7 +705,7 @@ struct ip_vs_dest {
80014 __be16 port; /* port number of the server */
80015 union nf_inet_addr addr; /* IP address of the server */
80016 volatile unsigned int flags; /* dest status flags */
80017 - atomic_t conn_flags; /* flags to copy to conn */
80018 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
80019 atomic_t weight; /* server weight */
80020
80021 atomic_t refcnt; /* reference counter */
80022 @@ -960,11 +960,11 @@ struct netns_ipvs {
80023 /* ip_vs_lblc */
80024 int sysctl_lblc_expiration;
80025 struct ctl_table_header *lblc_ctl_header;
80026 - struct ctl_table *lblc_ctl_table;
80027 + ctl_table_no_const *lblc_ctl_table;
80028 /* ip_vs_lblcr */
80029 int sysctl_lblcr_expiration;
80030 struct ctl_table_header *lblcr_ctl_header;
80031 - struct ctl_table *lblcr_ctl_table;
80032 + ctl_table_no_const *lblcr_ctl_table;
80033 /* ip_vs_est */
80034 struct list_head est_list; /* estimator list */
80035 spinlock_t est_lock;
80036 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
80037 index 80ffde3..968b0f4 100644
80038 --- a/include/net/irda/ircomm_tty.h
80039 +++ b/include/net/irda/ircomm_tty.h
80040 @@ -35,6 +35,7 @@
80041 #include <linux/termios.h>
80042 #include <linux/timer.h>
80043 #include <linux/tty.h> /* struct tty_struct */
80044 +#include <asm/local.h>
80045
80046 #include <net/irda/irias_object.h>
80047 #include <net/irda/ircomm_core.h>
80048 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
80049 index 714cc9a..ea05f3e 100644
80050 --- a/include/net/iucv/af_iucv.h
80051 +++ b/include/net/iucv/af_iucv.h
80052 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
80053 struct iucv_sock_list {
80054 struct hlist_head head;
80055 rwlock_t lock;
80056 - atomic_t autobind_name;
80057 + atomic_unchecked_t autobind_name;
80058 };
80059
80060 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
80061 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
80062 index df83f69..9b640b8 100644
80063 --- a/include/net/llc_c_ac.h
80064 +++ b/include/net/llc_c_ac.h
80065 @@ -87,7 +87,7 @@
80066 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
80067 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
80068
80069 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
80070 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
80071
80072 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
80073 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
80074 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
80075 index 6ca3113..f8026dd 100644
80076 --- a/include/net/llc_c_ev.h
80077 +++ b/include/net/llc_c_ev.h
80078 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
80079 return (struct llc_conn_state_ev *)skb->cb;
80080 }
80081
80082 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
80083 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
80084 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
80085 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
80086
80087 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
80088 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
80089 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
80090 index 0e79cfb..f46db31 100644
80091 --- a/include/net/llc_c_st.h
80092 +++ b/include/net/llc_c_st.h
80093 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
80094 u8 next_state;
80095 llc_conn_ev_qfyr_t *ev_qualifiers;
80096 llc_conn_action_t *ev_actions;
80097 -};
80098 +} __do_const;
80099
80100 struct llc_conn_state {
80101 u8 current_state;
80102 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
80103 index 37a3bbd..55a4241 100644
80104 --- a/include/net/llc_s_ac.h
80105 +++ b/include/net/llc_s_ac.h
80106 @@ -23,7 +23,7 @@
80107 #define SAP_ACT_TEST_IND 9
80108
80109 /* All action functions must look like this */
80110 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
80111 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
80112
80113 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
80114 struct sk_buff *skb);
80115 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
80116 index 567c681..cd73ac0 100644
80117 --- a/include/net/llc_s_st.h
80118 +++ b/include/net/llc_s_st.h
80119 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
80120 llc_sap_ev_t ev;
80121 u8 next_state;
80122 llc_sap_action_t *ev_actions;
80123 -};
80124 +} __do_const;
80125
80126 struct llc_sap_state {
80127 u8 curr_state;
80128 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
80129 index cc6035f..a8406fc 100644
80130 --- a/include/net/mac80211.h
80131 +++ b/include/net/mac80211.h
80132 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
80133 void (*add_sta_debugfs)(void *priv, void *priv_sta,
80134 struct dentry *dir);
80135 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
80136 -};
80137 +} __do_const;
80138
80139 static inline int rate_supported(struct ieee80211_sta *sta,
80140 enum ieee80211_band band,
80141 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
80142 index 536501a..7c6193c 100644
80143 --- a/include/net/neighbour.h
80144 +++ b/include/net/neighbour.h
80145 @@ -123,7 +123,7 @@ struct neigh_ops {
80146 void (*error_report)(struct neighbour *, struct sk_buff *);
80147 int (*output)(struct neighbour *, struct sk_buff *);
80148 int (*connected_output)(struct neighbour *, struct sk_buff *);
80149 -};
80150 +} __do_const;
80151
80152 struct pneigh_entry {
80153 struct pneigh_entry *next;
80154 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
80155 index 9d22f08..980fbf8 100644
80156 --- a/include/net/net_namespace.h
80157 +++ b/include/net/net_namespace.h
80158 @@ -120,7 +120,7 @@ struct net {
80159 struct netns_ipvs *ipvs;
80160 #endif
80161 struct sock *diag_nlsk;
80162 - atomic_t fnhe_genid;
80163 + atomic_unchecked_t fnhe_genid;
80164 };
80165
80166 /*
80167 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
80168 #define __net_init __init
80169 #define __net_exit __exit_refok
80170 #define __net_initdata __initdata
80171 +#ifdef CONSTIFY_PLUGIN
80172 #define __net_initconst __initconst
80173 +#else
80174 +#define __net_initconst __initdata
80175 +#endif
80176 #endif
80177
80178 struct pernet_operations {
80179 @@ -287,7 +291,7 @@ struct pernet_operations {
80180 void (*exit_batch)(struct list_head *net_exit_list);
80181 int *id;
80182 size_t size;
80183 -};
80184 +} __do_const;
80185
80186 /*
80187 * Use these carefully. If you implement a network device and it
80188 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
80189
80190 static inline int rt_genid_ipv4(struct net *net)
80191 {
80192 - return atomic_read(&net->ipv4.rt_genid);
80193 + return atomic_read_unchecked(&net->ipv4.rt_genid);
80194 }
80195
80196 static inline void rt_genid_bump_ipv4(struct net *net)
80197 {
80198 - atomic_inc(&net->ipv4.rt_genid);
80199 + atomic_inc_unchecked(&net->ipv4.rt_genid);
80200 }
80201
80202 #if IS_ENABLED(CONFIG_IPV6)
80203 static inline int rt_genid_ipv6(struct net *net)
80204 {
80205 - return atomic_read(&net->ipv6.rt_genid);
80206 + return atomic_read_unchecked(&net->ipv6.rt_genid);
80207 }
80208
80209 static inline void rt_genid_bump_ipv6(struct net *net)
80210 {
80211 - atomic_inc(&net->ipv6.rt_genid);
80212 + atomic_inc_unchecked(&net->ipv6.rt_genid);
80213 }
80214 #else
80215 static inline int rt_genid_ipv6(struct net *net)
80216 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
80217
80218 static inline int fnhe_genid(struct net *net)
80219 {
80220 - return atomic_read(&net->fnhe_genid);
80221 + return atomic_read_unchecked(&net->fnhe_genid);
80222 }
80223
80224 static inline void fnhe_genid_bump(struct net *net)
80225 {
80226 - atomic_inc(&net->fnhe_genid);
80227 + atomic_inc_unchecked(&net->fnhe_genid);
80228 }
80229
80230 #endif /* __NET_NET_NAMESPACE_H */
80231 diff --git a/include/net/netdma.h b/include/net/netdma.h
80232 index 8ba8ce2..99b7fff 100644
80233 --- a/include/net/netdma.h
80234 +++ b/include/net/netdma.h
80235 @@ -24,7 +24,7 @@
80236 #include <linux/dmaengine.h>
80237 #include <linux/skbuff.h>
80238
80239 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
80240 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
80241 struct sk_buff *skb, int offset, struct iovec *to,
80242 size_t len, struct dma_pinned_list *pinned_list);
80243
80244 diff --git a/include/net/netlink.h b/include/net/netlink.h
80245 index 9690b0f..87aded7 100644
80246 --- a/include/net/netlink.h
80247 +++ b/include/net/netlink.h
80248 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
80249 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
80250 {
80251 if (mark)
80252 - skb_trim(skb, (unsigned char *) mark - skb->data);
80253 + skb_trim(skb, (const unsigned char *) mark - skb->data);
80254 }
80255
80256 /**
80257 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
80258 index c9c0c53..53f24c3 100644
80259 --- a/include/net/netns/conntrack.h
80260 +++ b/include/net/netns/conntrack.h
80261 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
80262 struct nf_proto_net {
80263 #ifdef CONFIG_SYSCTL
80264 struct ctl_table_header *ctl_table_header;
80265 - struct ctl_table *ctl_table;
80266 + ctl_table_no_const *ctl_table;
80267 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
80268 struct ctl_table_header *ctl_compat_header;
80269 - struct ctl_table *ctl_compat_table;
80270 + ctl_table_no_const *ctl_compat_table;
80271 #endif
80272 #endif
80273 unsigned int users;
80274 @@ -58,7 +58,7 @@ struct nf_ip_net {
80275 struct nf_icmp_net icmpv6;
80276 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
80277 struct ctl_table_header *ctl_table_header;
80278 - struct ctl_table *ctl_table;
80279 + ctl_table_no_const *ctl_table;
80280 #endif
80281 };
80282
80283 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
80284 index bf2ec22..5e7f9d9 100644
80285 --- a/include/net/netns/ipv4.h
80286 +++ b/include/net/netns/ipv4.h
80287 @@ -67,7 +67,7 @@ struct netns_ipv4 {
80288 kgid_t sysctl_ping_group_range[2];
80289 long sysctl_tcp_mem[3];
80290
80291 - atomic_t dev_addr_genid;
80292 + atomic_unchecked_t dev_addr_genid;
80293
80294 #ifdef CONFIG_IP_MROUTE
80295 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
80296 @@ -77,6 +77,6 @@ struct netns_ipv4 {
80297 struct fib_rules_ops *mr_rules_ops;
80298 #endif
80299 #endif
80300 - atomic_t rt_genid;
80301 + atomic_unchecked_t rt_genid;
80302 };
80303 #endif
80304 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
80305 index 0fb2401..477d81c 100644
80306 --- a/include/net/netns/ipv6.h
80307 +++ b/include/net/netns/ipv6.h
80308 @@ -71,8 +71,8 @@ struct netns_ipv6 {
80309 struct fib_rules_ops *mr6_rules_ops;
80310 #endif
80311 #endif
80312 - atomic_t dev_addr_genid;
80313 - atomic_t rt_genid;
80314 + atomic_unchecked_t dev_addr_genid;
80315 + atomic_unchecked_t rt_genid;
80316 };
80317
80318 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
80319 diff --git a/include/net/ping.h b/include/net/ping.h
80320 index 2b496e9..935fd8d 100644
80321 --- a/include/net/ping.h
80322 +++ b/include/net/ping.h
80323 @@ -56,7 +56,7 @@ struct ping_iter_state {
80324 extern struct proto ping_prot;
80325 extern struct ping_table ping_table;
80326 #if IS_ENABLED(CONFIG_IPV6)
80327 -extern struct pingv6_ops pingv6_ops;
80328 +extern struct pingv6_ops *pingv6_ops;
80329 #endif
80330
80331 struct pingfakehdr {
80332 diff --git a/include/net/protocol.h b/include/net/protocol.h
80333 index 047c047..b9dad15 100644
80334 --- a/include/net/protocol.h
80335 +++ b/include/net/protocol.h
80336 @@ -44,7 +44,7 @@ struct net_protocol {
80337 void (*err_handler)(struct sk_buff *skb, u32 info);
80338 unsigned int no_policy:1,
80339 netns_ok:1;
80340 -};
80341 +} __do_const;
80342
80343 #if IS_ENABLED(CONFIG_IPV6)
80344 struct inet6_protocol {
80345 @@ -57,7 +57,7 @@ struct inet6_protocol {
80346 u8 type, u8 code, int offset,
80347 __be32 info);
80348 unsigned int flags; /* INET6_PROTO_xxx */
80349 -};
80350 +} __do_const;
80351
80352 #define INET6_PROTO_NOPOLICY 0x1
80353 #define INET6_PROTO_FINAL 0x2
80354 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
80355 index 7026648..584cc8c 100644
80356 --- a/include/net/rtnetlink.h
80357 +++ b/include/net/rtnetlink.h
80358 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
80359 const struct net_device *dev);
80360 unsigned int (*get_num_tx_queues)(void);
80361 unsigned int (*get_num_rx_queues)(void);
80362 -};
80363 +} __do_const;
80364
80365 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
80366 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
80367 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
80368 index 4ef75af..5aa073a 100644
80369 --- a/include/net/sctp/sm.h
80370 +++ b/include/net/sctp/sm.h
80371 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
80372 typedef struct {
80373 sctp_state_fn_t *fn;
80374 const char *name;
80375 -} sctp_sm_table_entry_t;
80376 +} __do_const sctp_sm_table_entry_t;
80377
80378 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
80379 * currently in use.
80380 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
80381 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
80382
80383 /* Extern declarations for major data structures. */
80384 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
80385 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
80386
80387
80388 /* Get the size of a DATA chunk payload. */
80389 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
80390 index 2174d8d..71d5257 100644
80391 --- a/include/net/sctp/structs.h
80392 +++ b/include/net/sctp/structs.h
80393 @@ -508,7 +508,7 @@ struct sctp_pf {
80394 struct sctp_association *asoc);
80395 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
80396 struct sctp_af *af;
80397 -};
80398 +} __do_const;
80399
80400
80401 /* Structure to track chunk fragments that have been acked, but peer
80402 diff --git a/include/net/sock.h b/include/net/sock.h
80403 index 808cbc2..8617e9c 100644
80404 --- a/include/net/sock.h
80405 +++ b/include/net/sock.h
80406 @@ -332,7 +332,7 @@ struct sock {
80407 unsigned int sk_napi_id;
80408 unsigned int sk_ll_usec;
80409 #endif
80410 - atomic_t sk_drops;
80411 + atomic_unchecked_t sk_drops;
80412 int sk_rcvbuf;
80413
80414 struct sk_filter __rcu *sk_filter;
80415 @@ -1194,7 +1194,7 @@ static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
80416 return ret >> PAGE_SHIFT;
80417 }
80418
80419 -static inline long
80420 +static inline long __intentional_overflow(-1)
80421 sk_memory_allocated(const struct sock *sk)
80422 {
80423 struct proto *prot = sk->sk_prot;
80424 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
80425 }
80426
80427 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
80428 - char __user *from, char *to,
80429 + char __user *from, unsigned char *to,
80430 int copy, int offset)
80431 {
80432 if (skb->ip_summed == CHECKSUM_NONE) {
80433 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
80434 }
80435 }
80436
80437 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
80438 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
80439
80440 /**
80441 * sk_page_frag - return an appropriate page_frag
80442 diff --git a/include/net/tcp.h b/include/net/tcp.h
80443 index b1aa324..b8530ea 100644
80444 --- a/include/net/tcp.h
80445 +++ b/include/net/tcp.h
80446 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
80447 extern void tcp_xmit_retransmit_queue(struct sock *);
80448 extern void tcp_simple_retransmit(struct sock *);
80449 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
80450 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
80451 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
80452
80453 extern void tcp_send_probe0(struct sock *);
80454 extern void tcp_send_partial(struct sock *);
80455 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
80456 struct inet6_skb_parm h6;
80457 #endif
80458 } header; /* For incoming frames */
80459 - __u32 seq; /* Starting sequence number */
80460 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
80461 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
80462 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
80463 __u32 when; /* used to compute rtt's */
80464 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
80465
80466 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
80467
80468 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
80469 /* 1 byte hole */
80470 - __u32 ack_seq; /* Sequence number ACK'd */
80471 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
80472 };
80473
80474 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
80475 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
80476 index e253bf0..2278b4b 100644
80477 --- a/include/net/xfrm.h
80478 +++ b/include/net/xfrm.h
80479 @@ -287,7 +287,6 @@ struct xfrm_dst;
80480 struct xfrm_policy_afinfo {
80481 unsigned short family;
80482 struct dst_ops *dst_ops;
80483 - void (*garbage_collect)(struct net *net);
80484 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
80485 const xfrm_address_t *saddr,
80486 const xfrm_address_t *daddr);
80487 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
80488 struct net_device *dev,
80489 const struct flowi *fl);
80490 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
80491 -};
80492 +} __do_const;
80493
80494 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
80495 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
80496 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
80497 int (*transport_finish)(struct sk_buff *skb,
80498 int async);
80499 void (*local_error)(struct sk_buff *skb, u32 mtu);
80500 -};
80501 +} __do_const;
80502
80503 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
80504 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
80505 @@ -427,7 +426,7 @@ struct xfrm_mode {
80506 struct module *owner;
80507 unsigned int encap;
80508 int flags;
80509 -};
80510 +} __do_const;
80511
80512 /* Flags for xfrm_mode. */
80513 enum {
80514 @@ -524,7 +523,7 @@ struct xfrm_policy {
80515 struct timer_list timer;
80516
80517 struct flow_cache_object flo;
80518 - atomic_t genid;
80519 + atomic_unchecked_t genid;
80520 u32 priority;
80521 u32 index;
80522 struct xfrm_mark mark;
80523 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
80524 }
80525
80526 extern void xfrm_garbage_collect(struct net *net);
80527 +extern void xfrm_garbage_collect_deferred(struct net *net);
80528
80529 #else
80530
80531 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
80532 static inline void xfrm_garbage_collect(struct net *net)
80533 {
80534 }
80535 +static inline void xfrm_garbage_collect_deferred(struct net *net)
80536 +{
80537 +}
80538 #endif
80539
80540 static __inline__
80541 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
80542 index 1017e0b..227aa4d 100644
80543 --- a/include/rdma/iw_cm.h
80544 +++ b/include/rdma/iw_cm.h
80545 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
80546 int backlog);
80547
80548 int (*destroy_listen)(struct iw_cm_id *cm_id);
80549 -};
80550 +} __no_const;
80551
80552 /**
80553 * iw_create_cm_id - Create an IW CM identifier.
80554 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
80555 index e1379b4..67eafbe 100644
80556 --- a/include/scsi/libfc.h
80557 +++ b/include/scsi/libfc.h
80558 @@ -762,6 +762,7 @@ struct libfc_function_template {
80559 */
80560 void (*disc_stop_final) (struct fc_lport *);
80561 };
80562 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
80563
80564 /**
80565 * struct fc_disc - Discovery context
80566 @@ -866,7 +867,7 @@ struct fc_lport {
80567 struct fc_vport *vport;
80568
80569 /* Operational Information */
80570 - struct libfc_function_template tt;
80571 + libfc_function_template_no_const tt;
80572 u8 link_up;
80573 u8 qfull;
80574 enum fc_lport_state state;
80575 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
80576 index d65fbec..f80fef2 100644
80577 --- a/include/scsi/scsi_device.h
80578 +++ b/include/scsi/scsi_device.h
80579 @@ -180,9 +180,9 @@ struct scsi_device {
80580 unsigned int max_device_blocked; /* what device_blocked counts down from */
80581 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
80582
80583 - atomic_t iorequest_cnt;
80584 - atomic_t iodone_cnt;
80585 - atomic_t ioerr_cnt;
80586 + atomic_unchecked_t iorequest_cnt;
80587 + atomic_unchecked_t iodone_cnt;
80588 + atomic_unchecked_t ioerr_cnt;
80589
80590 struct device sdev_gendev,
80591 sdev_dev;
80592 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
80593 index b797e8f..8e2c3aa 100644
80594 --- a/include/scsi/scsi_transport_fc.h
80595 +++ b/include/scsi/scsi_transport_fc.h
80596 @@ -751,7 +751,8 @@ struct fc_function_template {
80597 unsigned long show_host_system_hostname:1;
80598
80599 unsigned long disable_target_scan:1;
80600 -};
80601 +} __do_const;
80602 +typedef struct fc_function_template __no_const fc_function_template_no_const;
80603
80604
80605 /**
80606 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
80607 index ae6c3b8..fd748ac 100644
80608 --- a/include/sound/compress_driver.h
80609 +++ b/include/sound/compress_driver.h
80610 @@ -128,7 +128,7 @@ struct snd_compr_ops {
80611 struct snd_compr_caps *caps);
80612 int (*get_codec_caps) (struct snd_compr_stream *stream,
80613 struct snd_compr_codec_caps *codec);
80614 -};
80615 +} __no_const;
80616
80617 /**
80618 * struct snd_compr: Compressed device
80619 diff --git a/include/sound/soc.h b/include/sound/soc.h
80620 index d22cb0a..c6ba150 100644
80621 --- a/include/sound/soc.h
80622 +++ b/include/sound/soc.h
80623 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
80624 /* probe ordering - for components with runtime dependencies */
80625 int probe_order;
80626 int remove_order;
80627 -};
80628 +} __do_const;
80629
80630 /* SoC platform interface */
80631 struct snd_soc_platform_driver {
80632 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
80633 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
80634 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
80635 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
80636 -};
80637 +} __do_const;
80638
80639 struct snd_soc_platform {
80640 const char *name;
80641 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
80642 index 23bfd10..1ff3e35 100644
80643 --- a/include/target/target_core_base.h
80644 +++ b/include/target/target_core_base.h
80645 @@ -664,7 +664,7 @@ struct se_device {
80646 spinlock_t stats_lock;
80647 /* Active commands on this virtual SE device */
80648 atomic_t simple_cmds;
80649 - atomic_t dev_ordered_id;
80650 + atomic_unchecked_t dev_ordered_id;
80651 atomic_t dev_ordered_sync;
80652 atomic_t dev_qf_count;
80653 int export_count;
80654 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
80655 new file mode 100644
80656 index 0000000..fb634b7
80657 --- /dev/null
80658 +++ b/include/trace/events/fs.h
80659 @@ -0,0 +1,53 @@
80660 +#undef TRACE_SYSTEM
80661 +#define TRACE_SYSTEM fs
80662 +
80663 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
80664 +#define _TRACE_FS_H
80665 +
80666 +#include <linux/fs.h>
80667 +#include <linux/tracepoint.h>
80668 +
80669 +TRACE_EVENT(do_sys_open,
80670 +
80671 + TP_PROTO(const char *filename, int flags, int mode),
80672 +
80673 + TP_ARGS(filename, flags, mode),
80674 +
80675 + TP_STRUCT__entry(
80676 + __string( filename, filename )
80677 + __field( int, flags )
80678 + __field( int, mode )
80679 + ),
80680 +
80681 + TP_fast_assign(
80682 + __assign_str(filename, filename);
80683 + __entry->flags = flags;
80684 + __entry->mode = mode;
80685 + ),
80686 +
80687 + TP_printk("\"%s\" %x %o",
80688 + __get_str(filename), __entry->flags, __entry->mode)
80689 +);
80690 +
80691 +TRACE_EVENT(open_exec,
80692 +
80693 + TP_PROTO(const char *filename),
80694 +
80695 + TP_ARGS(filename),
80696 +
80697 + TP_STRUCT__entry(
80698 + __string( filename, filename )
80699 + ),
80700 +
80701 + TP_fast_assign(
80702 + __assign_str(filename, filename);
80703 + ),
80704 +
80705 + TP_printk("\"%s\"",
80706 + __get_str(filename))
80707 +);
80708 +
80709 +#endif /* _TRACE_FS_H */
80710 +
80711 +/* This part must be outside protection */
80712 +#include <trace/define_trace.h>
80713 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
80714 index 1c09820..7f5ec79 100644
80715 --- a/include/trace/events/irq.h
80716 +++ b/include/trace/events/irq.h
80717 @@ -36,7 +36,7 @@ struct softirq_action;
80718 */
80719 TRACE_EVENT(irq_handler_entry,
80720
80721 - TP_PROTO(int irq, struct irqaction *action),
80722 + TP_PROTO(int irq, const struct irqaction *action),
80723
80724 TP_ARGS(irq, action),
80725
80726 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
80727 */
80728 TRACE_EVENT(irq_handler_exit,
80729
80730 - TP_PROTO(int irq, struct irqaction *action, int ret),
80731 + TP_PROTO(int irq, const struct irqaction *action, int ret),
80732
80733 TP_ARGS(irq, action, ret),
80734
80735 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
80736 index 7caf44c..23c6f27 100644
80737 --- a/include/uapi/linux/a.out.h
80738 +++ b/include/uapi/linux/a.out.h
80739 @@ -39,6 +39,14 @@ enum machine_type {
80740 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
80741 };
80742
80743 +/* Constants for the N_FLAGS field */
80744 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80745 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
80746 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
80747 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
80748 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80749 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80750 +
80751 #if !defined (N_MAGIC)
80752 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
80753 #endif
80754 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
80755 index d876736..ccce5c0 100644
80756 --- a/include/uapi/linux/byteorder/little_endian.h
80757 +++ b/include/uapi/linux/byteorder/little_endian.h
80758 @@ -42,51 +42,51 @@
80759
80760 static inline __le64 __cpu_to_le64p(const __u64 *p)
80761 {
80762 - return (__force __le64)*p;
80763 + return (__force const __le64)*p;
80764 }
80765 -static inline __u64 __le64_to_cpup(const __le64 *p)
80766 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
80767 {
80768 - return (__force __u64)*p;
80769 + return (__force const __u64)*p;
80770 }
80771 static inline __le32 __cpu_to_le32p(const __u32 *p)
80772 {
80773 - return (__force __le32)*p;
80774 + return (__force const __le32)*p;
80775 }
80776 static inline __u32 __le32_to_cpup(const __le32 *p)
80777 {
80778 - return (__force __u32)*p;
80779 + return (__force const __u32)*p;
80780 }
80781 static inline __le16 __cpu_to_le16p(const __u16 *p)
80782 {
80783 - return (__force __le16)*p;
80784 + return (__force const __le16)*p;
80785 }
80786 static inline __u16 __le16_to_cpup(const __le16 *p)
80787 {
80788 - return (__force __u16)*p;
80789 + return (__force const __u16)*p;
80790 }
80791 static inline __be64 __cpu_to_be64p(const __u64 *p)
80792 {
80793 - return (__force __be64)__swab64p(p);
80794 + return (__force const __be64)__swab64p(p);
80795 }
80796 static inline __u64 __be64_to_cpup(const __be64 *p)
80797 {
80798 - return __swab64p((__u64 *)p);
80799 + return __swab64p((const __u64 *)p);
80800 }
80801 static inline __be32 __cpu_to_be32p(const __u32 *p)
80802 {
80803 - return (__force __be32)__swab32p(p);
80804 + return (__force const __be32)__swab32p(p);
80805 }
80806 -static inline __u32 __be32_to_cpup(const __be32 *p)
80807 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
80808 {
80809 - return __swab32p((__u32 *)p);
80810 + return __swab32p((const __u32 *)p);
80811 }
80812 static inline __be16 __cpu_to_be16p(const __u16 *p)
80813 {
80814 - return (__force __be16)__swab16p(p);
80815 + return (__force const __be16)__swab16p(p);
80816 }
80817 static inline __u16 __be16_to_cpup(const __be16 *p)
80818 {
80819 - return __swab16p((__u16 *)p);
80820 + return __swab16p((const __u16 *)p);
80821 }
80822 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
80823 #define __le64_to_cpus(x) do { (void)(x); } while (0)
80824 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
80825 index ef6103b..d4e65dd 100644
80826 --- a/include/uapi/linux/elf.h
80827 +++ b/include/uapi/linux/elf.h
80828 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
80829 #define PT_GNU_EH_FRAME 0x6474e550
80830
80831 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
80832 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
80833 +
80834 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
80835 +
80836 +/* Constants for the e_flags field */
80837 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80838 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
80839 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
80840 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
80841 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80842 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80843
80844 /*
80845 * Extended Numbering
80846 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
80847 #define DT_DEBUG 21
80848 #define DT_TEXTREL 22
80849 #define DT_JMPREL 23
80850 +#define DT_FLAGS 30
80851 + #define DF_TEXTREL 0x00000004
80852 #define DT_ENCODING 32
80853 #define OLD_DT_LOOS 0x60000000
80854 #define DT_LOOS 0x6000000d
80855 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
80856 #define PF_W 0x2
80857 #define PF_X 0x1
80858
80859 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
80860 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
80861 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
80862 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
80863 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
80864 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
80865 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
80866 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
80867 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
80868 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
80869 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
80870 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
80871 +
80872 typedef struct elf32_phdr{
80873 Elf32_Word p_type;
80874 Elf32_Off p_offset;
80875 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
80876 #define EI_OSABI 7
80877 #define EI_PAD 8
80878
80879 +#define EI_PAX 14
80880 +
80881 #define ELFMAG0 0x7f /* EI_MAG */
80882 #define ELFMAG1 'E'
80883 #define ELFMAG2 'L'
80884 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
80885 index aa169c4..6a2771d 100644
80886 --- a/include/uapi/linux/personality.h
80887 +++ b/include/uapi/linux/personality.h
80888 @@ -30,6 +30,7 @@ enum {
80889 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
80890 ADDR_NO_RANDOMIZE | \
80891 ADDR_COMPAT_LAYOUT | \
80892 + ADDR_LIMIT_3GB | \
80893 MMAP_PAGE_ZERO)
80894
80895 /*
80896 diff --git a/include/uapi/linux/random.h b/include/uapi/linux/random.h
80897 index 7471b5b..f97f514 100644
80898 --- a/include/uapi/linux/random.h
80899 +++ b/include/uapi/linux/random.h
80900 @@ -41,7 +41,7 @@ struct rand_pool_info {
80901 };
80902
80903 struct rnd_state {
80904 - __u32 s1, s2, s3;
80905 + __u32 s1, s2, s3, s4;
80906 };
80907
80908 /* Exported functions */
80909 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
80910 index 7530e74..e714828 100644
80911 --- a/include/uapi/linux/screen_info.h
80912 +++ b/include/uapi/linux/screen_info.h
80913 @@ -43,7 +43,8 @@ struct screen_info {
80914 __u16 pages; /* 0x32 */
80915 __u16 vesa_attributes; /* 0x34 */
80916 __u32 capabilities; /* 0x36 */
80917 - __u8 _reserved[6]; /* 0x3a */
80918 + __u16 vesapm_size; /* 0x3a */
80919 + __u8 _reserved[4]; /* 0x3c */
80920 } __attribute__((packed));
80921
80922 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
80923 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
80924 index 0e011eb..82681b1 100644
80925 --- a/include/uapi/linux/swab.h
80926 +++ b/include/uapi/linux/swab.h
80927 @@ -43,7 +43,7 @@
80928 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
80929 */
80930
80931 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
80932 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
80933 {
80934 #ifdef __HAVE_BUILTIN_BSWAP16__
80935 return __builtin_bswap16(val);
80936 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
80937 #endif
80938 }
80939
80940 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
80941 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
80942 {
80943 #ifdef __HAVE_BUILTIN_BSWAP32__
80944 return __builtin_bswap32(val);
80945 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
80946 #endif
80947 }
80948
80949 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
80950 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
80951 {
80952 #ifdef __HAVE_BUILTIN_BSWAP64__
80953 return __builtin_bswap64(val);
80954 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
80955 index 6d67213..552fdd9 100644
80956 --- a/include/uapi/linux/sysctl.h
80957 +++ b/include/uapi/linux/sysctl.h
80958 @@ -155,8 +155,6 @@ enum
80959 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
80960 };
80961
80962 -
80963 -
80964 /* CTL_VM names: */
80965 enum
80966 {
80967 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
80968 index e4629b9..6958086 100644
80969 --- a/include/uapi/linux/xattr.h
80970 +++ b/include/uapi/linux/xattr.h
80971 @@ -63,5 +63,9 @@
80972 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
80973 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
80974
80975 +/* User namespace */
80976 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
80977 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
80978 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
80979
80980 #endif /* _UAPI_LINUX_XATTR_H */
80981 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
80982 index f9466fa..f4e2b81 100644
80983 --- a/include/video/udlfb.h
80984 +++ b/include/video/udlfb.h
80985 @@ -53,10 +53,10 @@ struct dlfb_data {
80986 u32 pseudo_palette[256];
80987 int blank_mode; /*one of FB_BLANK_ */
80988 /* blit-only rendering path metrics, exposed through sysfs */
80989 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80990 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
80991 - atomic_t bytes_sent; /* to usb, after compression including overhead */
80992 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
80993 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80994 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
80995 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
80996 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
80997 };
80998
80999 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
81000 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
81001 index 30f5362..8ed8ac9 100644
81002 --- a/include/video/uvesafb.h
81003 +++ b/include/video/uvesafb.h
81004 @@ -122,6 +122,7 @@ struct uvesafb_par {
81005 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
81006 u8 pmi_setpal; /* PMI for palette changes */
81007 u16 *pmi_base; /* protected mode interface location */
81008 + u8 *pmi_code; /* protected mode code location */
81009 void *pmi_start;
81010 void *pmi_pal;
81011 u8 *vbe_state_orig; /*
81012 diff --git a/init/Kconfig b/init/Kconfig
81013 index 3ecd8a1..627843f 100644
81014 --- a/init/Kconfig
81015 +++ b/init/Kconfig
81016 @@ -1086,6 +1086,7 @@ endif # CGROUPS
81017
81018 config CHECKPOINT_RESTORE
81019 bool "Checkpoint/restore support" if EXPERT
81020 + depends on !GRKERNSEC
81021 default n
81022 help
81023 Enables additional kernel features in a sake of checkpoint/restore.
81024 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
81025
81026 config COMPAT_BRK
81027 bool "Disable heap randomization"
81028 - default y
81029 + default n
81030 help
81031 Randomizing heap placement makes heap exploits harder, but it
81032 also breaks ancient binaries (including anything libc5 based).
81033 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
81034 config STOP_MACHINE
81035 bool
81036 default y
81037 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
81038 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
81039 help
81040 Need stop_machine() primitive.
81041
81042 diff --git a/init/Makefile b/init/Makefile
81043 index 7bc47ee..6da2dc7 100644
81044 --- a/init/Makefile
81045 +++ b/init/Makefile
81046 @@ -2,6 +2,9 @@
81047 # Makefile for the linux kernel.
81048 #
81049
81050 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
81051 +asflags-y := $(GCC_PLUGINS_AFLAGS)
81052 +
81053 obj-y := main.o version.o mounts.o
81054 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
81055 obj-y += noinitramfs.o
81056 diff --git a/init/do_mounts.c b/init/do_mounts.c
81057 index a51cddc..25c2768 100644
81058 --- a/init/do_mounts.c
81059 +++ b/init/do_mounts.c
81060 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
81061 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
81062 {
81063 struct super_block *s;
81064 - int err = sys_mount(name, "/root", fs, flags, data);
81065 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
81066 if (err)
81067 return err;
81068
81069 - sys_chdir("/root");
81070 + sys_chdir((const char __force_user *)"/root");
81071 s = current->fs->pwd.dentry->d_sb;
81072 ROOT_DEV = s->s_dev;
81073 printk(KERN_INFO
81074 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
81075 va_start(args, fmt);
81076 vsprintf(buf, fmt, args);
81077 va_end(args);
81078 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
81079 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
81080 if (fd >= 0) {
81081 sys_ioctl(fd, FDEJECT, 0);
81082 sys_close(fd);
81083 }
81084 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
81085 - fd = sys_open("/dev/console", O_RDWR, 0);
81086 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
81087 if (fd >= 0) {
81088 sys_ioctl(fd, TCGETS, (long)&termios);
81089 termios.c_lflag &= ~ICANON;
81090 sys_ioctl(fd, TCSETSF, (long)&termios);
81091 - sys_read(fd, &c, 1);
81092 + sys_read(fd, (char __user *)&c, 1);
81093 termios.c_lflag |= ICANON;
81094 sys_ioctl(fd, TCSETSF, (long)&termios);
81095 sys_close(fd);
81096 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
81097 mount_root();
81098 out:
81099 devtmpfs_mount("dev");
81100 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
81101 - sys_chroot(".");
81102 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
81103 + sys_chroot((const char __force_user *)".");
81104 }
81105
81106 static bool is_tmpfs;
81107 diff --git a/init/do_mounts.h b/init/do_mounts.h
81108 index f5b978a..69dbfe8 100644
81109 --- a/init/do_mounts.h
81110 +++ b/init/do_mounts.h
81111 @@ -15,15 +15,15 @@ extern int root_mountflags;
81112
81113 static inline int create_dev(char *name, dev_t dev)
81114 {
81115 - sys_unlink(name);
81116 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
81117 + sys_unlink((char __force_user *)name);
81118 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
81119 }
81120
81121 #if BITS_PER_LONG == 32
81122 static inline u32 bstat(char *name)
81123 {
81124 struct stat64 stat;
81125 - if (sys_stat64(name, &stat) != 0)
81126 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
81127 return 0;
81128 if (!S_ISBLK(stat.st_mode))
81129 return 0;
81130 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
81131 static inline u32 bstat(char *name)
81132 {
81133 struct stat stat;
81134 - if (sys_newstat(name, &stat) != 0)
81135 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
81136 return 0;
81137 if (!S_ISBLK(stat.st_mode))
81138 return 0;
81139 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
81140 index 3e0878e..8a9d7a0 100644
81141 --- a/init/do_mounts_initrd.c
81142 +++ b/init/do_mounts_initrd.c
81143 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
81144 {
81145 sys_unshare(CLONE_FS | CLONE_FILES);
81146 /* stdin/stdout/stderr for /linuxrc */
81147 - sys_open("/dev/console", O_RDWR, 0);
81148 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
81149 sys_dup(0);
81150 sys_dup(0);
81151 /* move initrd over / and chdir/chroot in initrd root */
81152 - sys_chdir("/root");
81153 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
81154 - sys_chroot(".");
81155 + sys_chdir((const char __force_user *)"/root");
81156 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
81157 + sys_chroot((const char __force_user *)".");
81158 sys_setsid();
81159 return 0;
81160 }
81161 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
81162 create_dev("/dev/root.old", Root_RAM0);
81163 /* mount initrd on rootfs' /root */
81164 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
81165 - sys_mkdir("/old", 0700);
81166 - sys_chdir("/old");
81167 + sys_mkdir((const char __force_user *)"/old", 0700);
81168 + sys_chdir((const char __force_user *)"/old");
81169
81170 /* try loading default modules from initrd */
81171 load_default_modules();
81172 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
81173 current->flags &= ~PF_FREEZER_SKIP;
81174
81175 /* move initrd to rootfs' /old */
81176 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
81177 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
81178 /* switch root and cwd back to / of rootfs */
81179 - sys_chroot("..");
81180 + sys_chroot((const char __force_user *)"..");
81181
81182 if (new_decode_dev(real_root_dev) == Root_RAM0) {
81183 - sys_chdir("/old");
81184 + sys_chdir((const char __force_user *)"/old");
81185 return;
81186 }
81187
81188 - sys_chdir("/");
81189 + sys_chdir((const char __force_user *)"/");
81190 ROOT_DEV = new_decode_dev(real_root_dev);
81191 mount_root();
81192
81193 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
81194 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
81195 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
81196 if (!error)
81197 printk("okay\n");
81198 else {
81199 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
81200 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
81201 if (error == -ENOENT)
81202 printk("/initrd does not exist. Ignored.\n");
81203 else
81204 printk("failed\n");
81205 printk(KERN_NOTICE "Unmounting old root\n");
81206 - sys_umount("/old", MNT_DETACH);
81207 + sys_umount((char __force_user *)"/old", MNT_DETACH);
81208 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
81209 if (fd < 0) {
81210 error = fd;
81211 @@ -127,11 +127,11 @@ int __init initrd_load(void)
81212 * mounted in the normal path.
81213 */
81214 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
81215 - sys_unlink("/initrd.image");
81216 + sys_unlink((const char __force_user *)"/initrd.image");
81217 handle_initrd();
81218 return 1;
81219 }
81220 }
81221 - sys_unlink("/initrd.image");
81222 + sys_unlink((const char __force_user *)"/initrd.image");
81223 return 0;
81224 }
81225 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
81226 index 8cb6db5..d729f50 100644
81227 --- a/init/do_mounts_md.c
81228 +++ b/init/do_mounts_md.c
81229 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
81230 partitioned ? "_d" : "", minor,
81231 md_setup_args[ent].device_names);
81232
81233 - fd = sys_open(name, 0, 0);
81234 + fd = sys_open((char __force_user *)name, 0, 0);
81235 if (fd < 0) {
81236 printk(KERN_ERR "md: open failed - cannot start "
81237 "array %s\n", name);
81238 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
81239 * array without it
81240 */
81241 sys_close(fd);
81242 - fd = sys_open(name, 0, 0);
81243 + fd = sys_open((char __force_user *)name, 0, 0);
81244 sys_ioctl(fd, BLKRRPART, 0);
81245 }
81246 sys_close(fd);
81247 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
81248
81249 wait_for_device_probe();
81250
81251 - fd = sys_open("/dev/md0", 0, 0);
81252 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
81253 if (fd >= 0) {
81254 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
81255 sys_close(fd);
81256 diff --git a/init/init_task.c b/init/init_task.c
81257 index ba0a7f36..2bcf1d5 100644
81258 --- a/init/init_task.c
81259 +++ b/init/init_task.c
81260 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
81261 * Initial thread structure. Alignment of this is handled by a special
81262 * linker map entry.
81263 */
81264 +#ifdef CONFIG_X86
81265 +union thread_union init_thread_union __init_task_data;
81266 +#else
81267 union thread_union init_thread_union __init_task_data =
81268 { INIT_THREAD_INFO(init_task) };
81269 +#endif
81270 diff --git a/init/initramfs.c b/init/initramfs.c
81271 index a67ef9d..2d17ed9 100644
81272 --- a/init/initramfs.c
81273 +++ b/init/initramfs.c
81274 @@ -84,7 +84,7 @@ static void __init free_hash(void)
81275 }
81276 }
81277
81278 -static long __init do_utime(char *filename, time_t mtime)
81279 +static long __init do_utime(char __force_user *filename, time_t mtime)
81280 {
81281 struct timespec t[2];
81282
81283 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
81284 struct dir_entry *de, *tmp;
81285 list_for_each_entry_safe(de, tmp, &dir_list, list) {
81286 list_del(&de->list);
81287 - do_utime(de->name, de->mtime);
81288 + do_utime((char __force_user *)de->name, de->mtime);
81289 kfree(de->name);
81290 kfree(de);
81291 }
81292 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
81293 if (nlink >= 2) {
81294 char *old = find_link(major, minor, ino, mode, collected);
81295 if (old)
81296 - return (sys_link(old, collected) < 0) ? -1 : 1;
81297 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
81298 }
81299 return 0;
81300 }
81301 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
81302 {
81303 struct stat st;
81304
81305 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
81306 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
81307 if (S_ISDIR(st.st_mode))
81308 - sys_rmdir(path);
81309 + sys_rmdir((char __force_user *)path);
81310 else
81311 - sys_unlink(path);
81312 + sys_unlink((char __force_user *)path);
81313 }
81314 }
81315
81316 @@ -315,7 +315,7 @@ static int __init do_name(void)
81317 int openflags = O_WRONLY|O_CREAT;
81318 if (ml != 1)
81319 openflags |= O_TRUNC;
81320 - wfd = sys_open(collected, openflags, mode);
81321 + wfd = sys_open((char __force_user *)collected, openflags, mode);
81322
81323 if (wfd >= 0) {
81324 sys_fchown(wfd, uid, gid);
81325 @@ -327,17 +327,17 @@ static int __init do_name(void)
81326 }
81327 }
81328 } else if (S_ISDIR(mode)) {
81329 - sys_mkdir(collected, mode);
81330 - sys_chown(collected, uid, gid);
81331 - sys_chmod(collected, mode);
81332 + sys_mkdir((char __force_user *)collected, mode);
81333 + sys_chown((char __force_user *)collected, uid, gid);
81334 + sys_chmod((char __force_user *)collected, mode);
81335 dir_add(collected, mtime);
81336 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
81337 S_ISFIFO(mode) || S_ISSOCK(mode)) {
81338 if (maybe_link() == 0) {
81339 - sys_mknod(collected, mode, rdev);
81340 - sys_chown(collected, uid, gid);
81341 - sys_chmod(collected, mode);
81342 - do_utime(collected, mtime);
81343 + sys_mknod((char __force_user *)collected, mode, rdev);
81344 + sys_chown((char __force_user *)collected, uid, gid);
81345 + sys_chmod((char __force_user *)collected, mode);
81346 + do_utime((char __force_user *)collected, mtime);
81347 }
81348 }
81349 return 0;
81350 @@ -346,15 +346,15 @@ static int __init do_name(void)
81351 static int __init do_copy(void)
81352 {
81353 if (count >= body_len) {
81354 - sys_write(wfd, victim, body_len);
81355 + sys_write(wfd, (char __force_user *)victim, body_len);
81356 sys_close(wfd);
81357 - do_utime(vcollected, mtime);
81358 + do_utime((char __force_user *)vcollected, mtime);
81359 kfree(vcollected);
81360 eat(body_len);
81361 state = SkipIt;
81362 return 0;
81363 } else {
81364 - sys_write(wfd, victim, count);
81365 + sys_write(wfd, (char __force_user *)victim, count);
81366 body_len -= count;
81367 eat(count);
81368 return 1;
81369 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
81370 {
81371 collected[N_ALIGN(name_len) + body_len] = '\0';
81372 clean_path(collected, 0);
81373 - sys_symlink(collected + N_ALIGN(name_len), collected);
81374 - sys_lchown(collected, uid, gid);
81375 - do_utime(collected, mtime);
81376 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
81377 + sys_lchown((char __force_user *)collected, uid, gid);
81378 + do_utime((char __force_user *)collected, mtime);
81379 state = SkipIt;
81380 next_state = Reset;
81381 return 0;
81382 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
81383 {
81384 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
81385 if (err)
81386 - panic(err); /* Failed to decompress INTERNAL initramfs */
81387 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
81388 if (initrd_start) {
81389 #ifdef CONFIG_BLK_DEV_RAM
81390 int fd;
81391 diff --git a/init/main.c b/init/main.c
81392 index 63d3e8f..50bd5f8 100644
81393 --- a/init/main.c
81394 +++ b/init/main.c
81395 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
81396 extern void tc_init(void);
81397 #endif
81398
81399 +extern void grsecurity_init(void);
81400 +
81401 /*
81402 * Debug helper: via this flag we know that we are in 'early bootup code'
81403 * where only the boot processor is running with IRQ disabled. This means
81404 @@ -156,6 +158,75 @@ static int __init set_reset_devices(char *str)
81405
81406 __setup("reset_devices", set_reset_devices);
81407
81408 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
81409 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
81410 +static int __init setup_grsec_proc_gid(char *str)
81411 +{
81412 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
81413 + return 1;
81414 +}
81415 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
81416 +#endif
81417 +
81418 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
81419 +unsigned long pax_user_shadow_base __read_only;
81420 +EXPORT_SYMBOL(pax_user_shadow_base);
81421 +extern char pax_enter_kernel_user[];
81422 +extern char pax_exit_kernel_user[];
81423 +#endif
81424 +
81425 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
81426 +static int __init setup_pax_nouderef(char *str)
81427 +{
81428 +#ifdef CONFIG_X86_32
81429 + unsigned int cpu;
81430 + struct desc_struct *gdt;
81431 +
81432 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
81433 + gdt = get_cpu_gdt_table(cpu);
81434 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
81435 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
81436 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
81437 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
81438 + }
81439 + loadsegment(ds, __KERNEL_DS);
81440 + loadsegment(es, __KERNEL_DS);
81441 + loadsegment(ss, __KERNEL_DS);
81442 +#else
81443 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
81444 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
81445 + clone_pgd_mask = ~(pgdval_t)0UL;
81446 + pax_user_shadow_base = 0UL;
81447 + setup_clear_cpu_cap(X86_FEATURE_PCID);
81448 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
81449 +#endif
81450 +
81451 + return 0;
81452 +}
81453 +early_param("pax_nouderef", setup_pax_nouderef);
81454 +
81455 +#ifdef CONFIG_X86_64
81456 +static int __init setup_pax_weakuderef(char *str)
81457 +{
81458 + if (clone_pgd_mask != ~(pgdval_t)0UL)
81459 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
81460 + return 1;
81461 +}
81462 +__setup("pax_weakuderef", setup_pax_weakuderef);
81463 +#endif
81464 +#endif
81465 +
81466 +#ifdef CONFIG_PAX_SOFTMODE
81467 +int pax_softmode;
81468 +
81469 +static int __init setup_pax_softmode(char *str)
81470 +{
81471 + get_option(&str, &pax_softmode);
81472 + return 1;
81473 +}
81474 +__setup("pax_softmode=", setup_pax_softmode);
81475 +#endif
81476 +
81477 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
81478 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
81479 static const char *panic_later, *panic_param;
81480 @@ -682,25 +753,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
81481 {
81482 int count = preempt_count();
81483 int ret;
81484 - char msgbuf[64];
81485 + const char *msg1 = "", *msg2 = "";
81486
81487 if (initcall_debug)
81488 ret = do_one_initcall_debug(fn);
81489 else
81490 ret = fn();
81491
81492 - msgbuf[0] = 0;
81493 -
81494 if (preempt_count() != count) {
81495 - sprintf(msgbuf, "preemption imbalance ");
81496 + msg1 = " preemption imbalance";
81497 preempt_count() = count;
81498 }
81499 if (irqs_disabled()) {
81500 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
81501 + msg2 = " disabled interrupts";
81502 local_irq_enable();
81503 }
81504 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
81505 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
81506
81507 + add_latent_entropy();
81508 return ret;
81509 }
81510
81511 @@ -807,10 +877,14 @@ static int run_init_process(const char *init_filename)
81512 {
81513 argv_init[0] = init_filename;
81514 return do_execve(init_filename,
81515 - (const char __user *const __user *)argv_init,
81516 - (const char __user *const __user *)envp_init);
81517 + (const char __user *const __force_user *)argv_init,
81518 + (const char __user *const __force_user *)envp_init);
81519 }
81520
81521 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
81522 +extern int gr_init_ran;
81523 +#endif
81524 +
81525 static noinline void __init kernel_init_freeable(void);
81526
81527 static int __ref kernel_init(void *unused)
81528 @@ -831,6 +905,11 @@ static int __ref kernel_init(void *unused)
81529 pr_err("Failed to execute %s\n", ramdisk_execute_command);
81530 }
81531
81532 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
81533 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
81534 + gr_init_ran = 1;
81535 +#endif
81536 +
81537 /*
81538 * We try each of these until one succeeds.
81539 *
81540 @@ -885,7 +964,7 @@ static noinline void __init kernel_init_freeable(void)
81541 do_basic_setup();
81542
81543 /* Open the /dev/console on the rootfs, this should never fail */
81544 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
81545 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
81546 pr_err("Warning: unable to open an initial console.\n");
81547
81548 (void) sys_dup(0);
81549 @@ -898,11 +977,13 @@ static noinline void __init kernel_init_freeable(void)
81550 if (!ramdisk_execute_command)
81551 ramdisk_execute_command = "/init";
81552
81553 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
81554 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
81555 ramdisk_execute_command = NULL;
81556 prepare_namespace();
81557 }
81558
81559 + grsecurity_init();
81560 +
81561 /*
81562 * Ok, we have completed the initial bootup, and
81563 * we're essentially up and running. Get rid of the
81564 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
81565 index b0e99de..09f385c 100644
81566 --- a/ipc/ipc_sysctl.c
81567 +++ b/ipc/ipc_sysctl.c
81568 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
81569 static int proc_ipc_dointvec(ctl_table *table, int write,
81570 void __user *buffer, size_t *lenp, loff_t *ppos)
81571 {
81572 - struct ctl_table ipc_table;
81573 + ctl_table_no_const ipc_table;
81574
81575 memcpy(&ipc_table, table, sizeof(ipc_table));
81576 ipc_table.data = get_ipc(table);
81577 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
81578 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
81579 void __user *buffer, size_t *lenp, loff_t *ppos)
81580 {
81581 - struct ctl_table ipc_table;
81582 + ctl_table_no_const ipc_table;
81583
81584 memcpy(&ipc_table, table, sizeof(ipc_table));
81585 ipc_table.data = get_ipc(table);
81586 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
81587 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81588 void __user *buffer, size_t *lenp, loff_t *ppos)
81589 {
81590 - struct ctl_table ipc_table;
81591 + ctl_table_no_const ipc_table;
81592 size_t lenp_bef = *lenp;
81593 int rc;
81594
81595 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81596 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
81597 void __user *buffer, size_t *lenp, loff_t *ppos)
81598 {
81599 - struct ctl_table ipc_table;
81600 + ctl_table_no_const ipc_table;
81601 memcpy(&ipc_table, table, sizeof(ipc_table));
81602 ipc_table.data = get_ipc(table);
81603
81604 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
81605 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
81606 void __user *buffer, size_t *lenp, loff_t *ppos)
81607 {
81608 - struct ctl_table ipc_table;
81609 + ctl_table_no_const ipc_table;
81610 size_t lenp_bef = *lenp;
81611 int oldval;
81612 int rc;
81613 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
81614 index 383d638..943fdbb 100644
81615 --- a/ipc/mq_sysctl.c
81616 +++ b/ipc/mq_sysctl.c
81617 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
81618 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
81619 void __user *buffer, size_t *lenp, loff_t *ppos)
81620 {
81621 - struct ctl_table mq_table;
81622 + ctl_table_no_const mq_table;
81623 memcpy(&mq_table, table, sizeof(mq_table));
81624 mq_table.data = get_mq(table);
81625
81626 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
81627 index ae1996d..a35f2cc 100644
81628 --- a/ipc/mqueue.c
81629 +++ b/ipc/mqueue.c
81630 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
81631 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
81632 info->attr.mq_msgsize);
81633
81634 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
81635 spin_lock(&mq_lock);
81636 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
81637 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
81638 diff --git a/ipc/msg.c b/ipc/msg.c
81639 index 558aa91..359e718 100644
81640 --- a/ipc/msg.c
81641 +++ b/ipc/msg.c
81642 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
81643 return security_msg_queue_associate(msq, msgflg);
81644 }
81645
81646 +static struct ipc_ops msg_ops = {
81647 + .getnew = newque,
81648 + .associate = msg_security,
81649 + .more_checks = NULL
81650 +};
81651 +
81652 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
81653 {
81654 struct ipc_namespace *ns;
81655 - struct ipc_ops msg_ops;
81656 struct ipc_params msg_params;
81657
81658 ns = current->nsproxy->ipc_ns;
81659
81660 - msg_ops.getnew = newque;
81661 - msg_ops.associate = msg_security;
81662 - msg_ops.more_checks = NULL;
81663 -
81664 msg_params.key = key;
81665 msg_params.flg = msgflg;
81666
81667 diff --git a/ipc/sem.c b/ipc/sem.c
81668 index db9d241..bc8427c 100644
81669 --- a/ipc/sem.c
81670 +++ b/ipc/sem.c
81671 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
81672 return 0;
81673 }
81674
81675 +static struct ipc_ops sem_ops = {
81676 + .getnew = newary,
81677 + .associate = sem_security,
81678 + .more_checks = sem_more_checks
81679 +};
81680 +
81681 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81682 {
81683 struct ipc_namespace *ns;
81684 - struct ipc_ops sem_ops;
81685 struct ipc_params sem_params;
81686
81687 ns = current->nsproxy->ipc_ns;
81688 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81689 if (nsems < 0 || nsems > ns->sc_semmsl)
81690 return -EINVAL;
81691
81692 - sem_ops.getnew = newary;
81693 - sem_ops.associate = sem_security;
81694 - sem_ops.more_checks = sem_more_checks;
81695 -
81696 sem_params.key = key;
81697 sem_params.flg = semflg;
81698 sem_params.u.nsems = nsems;
81699 diff --git a/ipc/shm.c b/ipc/shm.c
81700 index 7a51443..3a257d8 100644
81701 --- a/ipc/shm.c
81702 +++ b/ipc/shm.c
81703 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
81704 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
81705 #endif
81706
81707 +#ifdef CONFIG_GRKERNSEC
81708 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81709 + const time_t shm_createtime, const kuid_t cuid,
81710 + const int shmid);
81711 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81712 + const time_t shm_createtime);
81713 +#endif
81714 +
81715 void shm_init_ns(struct ipc_namespace *ns)
81716 {
81717 ns->shm_ctlmax = SHMMAX;
81718 @@ -554,6 +562,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
81719 shp->shm_lprid = 0;
81720 shp->shm_atim = shp->shm_dtim = 0;
81721 shp->shm_ctim = get_seconds();
81722 +#ifdef CONFIG_GRKERNSEC
81723 + {
81724 + struct timespec timeval;
81725 + do_posix_clock_monotonic_gettime(&timeval);
81726 +
81727 + shp->shm_createtime = timeval.tv_sec;
81728 + }
81729 +#endif
81730 shp->shm_segsz = size;
81731 shp->shm_nattch = 0;
81732 shp->shm_file = file;
81733 @@ -607,18 +623,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
81734 return 0;
81735 }
81736
81737 +static struct ipc_ops shm_ops = {
81738 + .getnew = newseg,
81739 + .associate = shm_security,
81740 + .more_checks = shm_more_checks
81741 +};
81742 +
81743 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
81744 {
81745 struct ipc_namespace *ns;
81746 - struct ipc_ops shm_ops;
81747 struct ipc_params shm_params;
81748
81749 ns = current->nsproxy->ipc_ns;
81750
81751 - shm_ops.getnew = newseg;
81752 - shm_ops.associate = shm_security;
81753 - shm_ops.more_checks = shm_more_checks;
81754 -
81755 shm_params.key = key;
81756 shm_params.flg = shmflg;
81757 shm_params.u.size = size;
81758 @@ -1089,6 +1106,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81759 f_mode = FMODE_READ | FMODE_WRITE;
81760 }
81761 if (shmflg & SHM_EXEC) {
81762 +
81763 +#ifdef CONFIG_PAX_MPROTECT
81764 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
81765 + goto out;
81766 +#endif
81767 +
81768 prot |= PROT_EXEC;
81769 acc_mode |= S_IXUGO;
81770 }
81771 @@ -1113,6 +1136,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81772 if (err)
81773 goto out_unlock;
81774
81775 +#ifdef CONFIG_GRKERNSEC
81776 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
81777 + shp->shm_perm.cuid, shmid) ||
81778 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
81779 + err = -EACCES;
81780 + goto out_unlock;
81781 + }
81782 +#endif
81783 +
81784 ipc_lock_object(&shp->shm_perm);
81785
81786 /* check if shm_destroy() is tearing down shp */
81787 @@ -1125,6 +1157,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81788 path = shp->shm_file->f_path;
81789 path_get(&path);
81790 shp->shm_nattch++;
81791 +#ifdef CONFIG_GRKERNSEC
81792 + shp->shm_lapid = current->pid;
81793 +#endif
81794 size = i_size_read(path.dentry->d_inode);
81795 ipc_unlock_object(&shp->shm_perm);
81796 rcu_read_unlock();
81797 diff --git a/ipc/util.c b/ipc/util.c
81798 index 7684f41..5bf1880 100644
81799 --- a/ipc/util.c
81800 +++ b/ipc/util.c
81801 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
81802 int (*show)(struct seq_file *, void *);
81803 };
81804
81805 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
81806 +
81807 static void ipc_memory_notifier(struct work_struct *work)
81808 {
81809 ipcns_notify(IPCNS_MEMCHANGED);
81810 @@ -560,6 +562,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
81811 granted_mode >>= 6;
81812 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
81813 granted_mode >>= 3;
81814 +
81815 + if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
81816 + return -1;
81817 +
81818 /* is there some bit set in requested_mode but not in granted_mode? */
81819 if ((requested_mode & ~granted_mode & 0007) &&
81820 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
81821 diff --git a/kernel/acct.c b/kernel/acct.c
81822 index 8d6e145..33e0b1e 100644
81823 --- a/kernel/acct.c
81824 +++ b/kernel/acct.c
81825 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
81826 */
81827 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
81828 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
81829 - file->f_op->write(file, (char *)&ac,
81830 + file->f_op->write(file, (char __force_user *)&ac,
81831 sizeof(acct_t), &file->f_pos);
81832 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
81833 set_fs(fs);
81834 diff --git a/kernel/audit.c b/kernel/audit.c
81835 index 7ddfd8a..49766eb 100644
81836 --- a/kernel/audit.c
81837 +++ b/kernel/audit.c
81838 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
81839 3) suppressed due to audit_rate_limit
81840 4) suppressed due to audit_backlog_limit
81841 */
81842 -static atomic_t audit_lost = ATOMIC_INIT(0);
81843 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
81844
81845 /* The netlink socket. */
81846 static struct sock *audit_sock;
81847 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
81848 unsigned long now;
81849 int print;
81850
81851 - atomic_inc(&audit_lost);
81852 + atomic_inc_unchecked(&audit_lost);
81853
81854 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
81855
81856 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
81857 printk(KERN_WARNING
81858 "audit: audit_lost=%d audit_rate_limit=%d "
81859 "audit_backlog_limit=%d\n",
81860 - atomic_read(&audit_lost),
81861 + atomic_read_unchecked(&audit_lost),
81862 audit_rate_limit,
81863 audit_backlog_limit);
81864 audit_panic(message);
81865 @@ -665,7 +665,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
81866 status_set.pid = audit_pid;
81867 status_set.rate_limit = audit_rate_limit;
81868 status_set.backlog_limit = audit_backlog_limit;
81869 - status_set.lost = atomic_read(&audit_lost);
81870 + status_set.lost = atomic_read_unchecked(&audit_lost);
81871 status_set.backlog = skb_queue_len(&audit_skb_queue);
81872 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
81873 &status_set, sizeof(status_set));
81874 @@ -1252,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
81875 int i, avail, new_len;
81876 unsigned char *ptr;
81877 struct sk_buff *skb;
81878 - static const unsigned char *hex = "0123456789ABCDEF";
81879 + static const unsigned char hex[] = "0123456789ABCDEF";
81880
81881 if (!ab)
81882 return;
81883 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
81884 index 9845cb3..3ec9369 100644
81885 --- a/kernel/auditsc.c
81886 +++ b/kernel/auditsc.c
81887 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
81888 }
81889
81890 /* global counter which is incremented every time something logs in */
81891 -static atomic_t session_id = ATOMIC_INIT(0);
81892 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
81893
81894 /**
81895 * audit_set_loginuid - set current task's audit_context loginuid
81896 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
81897 return -EPERM;
81898 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
81899
81900 - sessionid = atomic_inc_return(&session_id);
81901 + sessionid = atomic_inc_return_unchecked(&session_id);
81902 if (context && context->in_syscall) {
81903 struct audit_buffer *ab;
81904
81905 diff --git a/kernel/capability.c b/kernel/capability.c
81906 index 4e66bf9..cdccecf 100644
81907 --- a/kernel/capability.c
81908 +++ b/kernel/capability.c
81909 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
81910 * before modification is attempted and the application
81911 * fails.
81912 */
81913 + if (tocopy > ARRAY_SIZE(kdata))
81914 + return -EFAULT;
81915 +
81916 if (copy_to_user(dataptr, kdata, tocopy
81917 * sizeof(struct __user_cap_data_struct))) {
81918 return -EFAULT;
81919 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
81920 int ret;
81921
81922 rcu_read_lock();
81923 - ret = security_capable(__task_cred(t), ns, cap);
81924 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
81925 + gr_task_is_capable(t, __task_cred(t), cap);
81926 rcu_read_unlock();
81927
81928 - return (ret == 0);
81929 + return ret;
81930 }
81931
81932 /**
81933 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
81934 int ret;
81935
81936 rcu_read_lock();
81937 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
81938 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
81939 rcu_read_unlock();
81940
81941 - return (ret == 0);
81942 + return ret;
81943 }
81944
81945 /**
81946 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
81947 BUG();
81948 }
81949
81950 - if (security_capable(current_cred(), ns, cap) == 0) {
81951 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
81952 current->flags |= PF_SUPERPRIV;
81953 return true;
81954 }
81955 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
81956 }
81957 EXPORT_SYMBOL(ns_capable);
81958
81959 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
81960 +{
81961 + if (unlikely(!cap_valid(cap))) {
81962 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
81963 + BUG();
81964 + }
81965 +
81966 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
81967 + current->flags |= PF_SUPERPRIV;
81968 + return true;
81969 + }
81970 + return false;
81971 +}
81972 +EXPORT_SYMBOL(ns_capable_nolog);
81973 +
81974 /**
81975 * file_ns_capable - Determine if the file's opener had a capability in effect
81976 * @file: The file we want to check
81977 @@ -432,6 +451,12 @@ bool capable(int cap)
81978 }
81979 EXPORT_SYMBOL(capable);
81980
81981 +bool capable_nolog(int cap)
81982 +{
81983 + return ns_capable_nolog(&init_user_ns, cap);
81984 +}
81985 +EXPORT_SYMBOL(capable_nolog);
81986 +
81987 /**
81988 * inode_capable - Check superior capability over inode
81989 * @inode: The inode in question
81990 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
81991 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81992 }
81993 EXPORT_SYMBOL(inode_capable);
81994 +
81995 +bool inode_capable_nolog(const struct inode *inode, int cap)
81996 +{
81997 + struct user_namespace *ns = current_user_ns();
81998 +
81999 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
82000 +}
82001 +EXPORT_SYMBOL(inode_capable_nolog);
82002 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
82003 index b6fd783..7f526b7 100644
82004 --- a/kernel/cgroup.c
82005 +++ b/kernel/cgroup.c
82006 @@ -5855,7 +5855,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
82007 struct css_set *cset = link->cset;
82008 struct task_struct *task;
82009 int count = 0;
82010 - seq_printf(seq, "css_set %p\n", cset);
82011 + seq_printf(seq, "css_set %pK\n", cset);
82012 list_for_each_entry(task, &cset->tasks, cg_list) {
82013 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
82014 seq_puts(seq, " ...\n");
82015 diff --git a/kernel/compat.c b/kernel/compat.c
82016 index 0a09e48..f44f3f0 100644
82017 --- a/kernel/compat.c
82018 +++ b/kernel/compat.c
82019 @@ -13,6 +13,7 @@
82020
82021 #include <linux/linkage.h>
82022 #include <linux/compat.h>
82023 +#include <linux/module.h>
82024 #include <linux/errno.h>
82025 #include <linux/time.h>
82026 #include <linux/signal.h>
82027 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
82028 mm_segment_t oldfs;
82029 long ret;
82030
82031 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
82032 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
82033 oldfs = get_fs();
82034 set_fs(KERNEL_DS);
82035 ret = hrtimer_nanosleep_restart(restart);
82036 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
82037 oldfs = get_fs();
82038 set_fs(KERNEL_DS);
82039 ret = hrtimer_nanosleep(&tu,
82040 - rmtp ? (struct timespec __user *)&rmt : NULL,
82041 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
82042 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
82043 set_fs(oldfs);
82044
82045 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
82046 mm_segment_t old_fs = get_fs();
82047
82048 set_fs(KERNEL_DS);
82049 - ret = sys_sigpending((old_sigset_t __user *) &s);
82050 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
82051 set_fs(old_fs);
82052 if (ret == 0)
82053 ret = put_user(s, set);
82054 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
82055 mm_segment_t old_fs = get_fs();
82056
82057 set_fs(KERNEL_DS);
82058 - ret = sys_old_getrlimit(resource, &r);
82059 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
82060 set_fs(old_fs);
82061
82062 if (!ret) {
82063 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
82064 set_fs (KERNEL_DS);
82065 ret = sys_wait4(pid,
82066 (stat_addr ?
82067 - (unsigned int __user *) &status : NULL),
82068 - options, (struct rusage __user *) &r);
82069 + (unsigned int __force_user *) &status : NULL),
82070 + options, (struct rusage __force_user *) &r);
82071 set_fs (old_fs);
82072
82073 if (ret > 0) {
82074 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
82075 memset(&info, 0, sizeof(info));
82076
82077 set_fs(KERNEL_DS);
82078 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
82079 - uru ? (struct rusage __user *)&ru : NULL);
82080 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
82081 + uru ? (struct rusage __force_user *)&ru : NULL);
82082 set_fs(old_fs);
82083
82084 if ((ret < 0) || (info.si_signo == 0))
82085 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
82086 oldfs = get_fs();
82087 set_fs(KERNEL_DS);
82088 err = sys_timer_settime(timer_id, flags,
82089 - (struct itimerspec __user *) &newts,
82090 - (struct itimerspec __user *) &oldts);
82091 + (struct itimerspec __force_user *) &newts,
82092 + (struct itimerspec __force_user *) &oldts);
82093 set_fs(oldfs);
82094 if (!err && old && put_compat_itimerspec(old, &oldts))
82095 return -EFAULT;
82096 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
82097 oldfs = get_fs();
82098 set_fs(KERNEL_DS);
82099 err = sys_timer_gettime(timer_id,
82100 - (struct itimerspec __user *) &ts);
82101 + (struct itimerspec __force_user *) &ts);
82102 set_fs(oldfs);
82103 if (!err && put_compat_itimerspec(setting, &ts))
82104 return -EFAULT;
82105 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
82106 oldfs = get_fs();
82107 set_fs(KERNEL_DS);
82108 err = sys_clock_settime(which_clock,
82109 - (struct timespec __user *) &ts);
82110 + (struct timespec __force_user *) &ts);
82111 set_fs(oldfs);
82112 return err;
82113 }
82114 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
82115 oldfs = get_fs();
82116 set_fs(KERNEL_DS);
82117 err = sys_clock_gettime(which_clock,
82118 - (struct timespec __user *) &ts);
82119 + (struct timespec __force_user *) &ts);
82120 set_fs(oldfs);
82121 if (!err && put_compat_timespec(&ts, tp))
82122 return -EFAULT;
82123 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
82124
82125 oldfs = get_fs();
82126 set_fs(KERNEL_DS);
82127 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
82128 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
82129 set_fs(oldfs);
82130
82131 err = compat_put_timex(utp, &txc);
82132 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
82133 oldfs = get_fs();
82134 set_fs(KERNEL_DS);
82135 err = sys_clock_getres(which_clock,
82136 - (struct timespec __user *) &ts);
82137 + (struct timespec __force_user *) &ts);
82138 set_fs(oldfs);
82139 if (!err && tp && put_compat_timespec(&ts, tp))
82140 return -EFAULT;
82141 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
82142 long err;
82143 mm_segment_t oldfs;
82144 struct timespec tu;
82145 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
82146 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
82147
82148 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
82149 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
82150 oldfs = get_fs();
82151 set_fs(KERNEL_DS);
82152 err = clock_nanosleep_restart(restart);
82153 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
82154 oldfs = get_fs();
82155 set_fs(KERNEL_DS);
82156 err = sys_clock_nanosleep(which_clock, flags,
82157 - (struct timespec __user *) &in,
82158 - (struct timespec __user *) &out);
82159 + (struct timespec __force_user *) &in,
82160 + (struct timespec __force_user *) &out);
82161 set_fs(oldfs);
82162
82163 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
82164 diff --git a/kernel/configs.c b/kernel/configs.c
82165 index c18b1f1..b9a0132 100644
82166 --- a/kernel/configs.c
82167 +++ b/kernel/configs.c
82168 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
82169 struct proc_dir_entry *entry;
82170
82171 /* create the current config file */
82172 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
82173 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
82174 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
82175 + &ikconfig_file_ops);
82176 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82177 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
82178 + &ikconfig_file_ops);
82179 +#endif
82180 +#else
82181 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
82182 &ikconfig_file_ops);
82183 +#endif
82184 +
82185 if (!entry)
82186 return -ENOMEM;
82187
82188 diff --git a/kernel/cred.c b/kernel/cred.c
82189 index e0573a4..3874e41 100644
82190 --- a/kernel/cred.c
82191 +++ b/kernel/cred.c
82192 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
82193 validate_creds(cred);
82194 alter_cred_subscribers(cred, -1);
82195 put_cred(cred);
82196 +
82197 +#ifdef CONFIG_GRKERNSEC_SETXID
82198 + cred = (struct cred *) tsk->delayed_cred;
82199 + if (cred != NULL) {
82200 + tsk->delayed_cred = NULL;
82201 + validate_creds(cred);
82202 + alter_cred_subscribers(cred, -1);
82203 + put_cred(cred);
82204 + }
82205 +#endif
82206 }
82207
82208 /**
82209 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
82210 * Always returns 0 thus allowing this function to be tail-called at the end
82211 * of, say, sys_setgid().
82212 */
82213 -int commit_creds(struct cred *new)
82214 +static int __commit_creds(struct cred *new)
82215 {
82216 struct task_struct *task = current;
82217 const struct cred *old = task->real_cred;
82218 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
82219
82220 get_cred(new); /* we will require a ref for the subj creds too */
82221
82222 + gr_set_role_label(task, new->uid, new->gid);
82223 +
82224 /* dumpability changes */
82225 if (!uid_eq(old->euid, new->euid) ||
82226 !gid_eq(old->egid, new->egid) ||
82227 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
82228 put_cred(old);
82229 return 0;
82230 }
82231 +#ifdef CONFIG_GRKERNSEC_SETXID
82232 +extern int set_user(struct cred *new);
82233 +
82234 +void gr_delayed_cred_worker(void)
82235 +{
82236 + const struct cred *new = current->delayed_cred;
82237 + struct cred *ncred;
82238 +
82239 + current->delayed_cred = NULL;
82240 +
82241 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
82242 + // from doing get_cred on it when queueing this
82243 + put_cred(new);
82244 + return;
82245 + } else if (new == NULL)
82246 + return;
82247 +
82248 + ncred = prepare_creds();
82249 + if (!ncred)
82250 + goto die;
82251 + // uids
82252 + ncred->uid = new->uid;
82253 + ncred->euid = new->euid;
82254 + ncred->suid = new->suid;
82255 + ncred->fsuid = new->fsuid;
82256 + // gids
82257 + ncred->gid = new->gid;
82258 + ncred->egid = new->egid;
82259 + ncred->sgid = new->sgid;
82260 + ncred->fsgid = new->fsgid;
82261 + // groups
82262 + if (set_groups(ncred, new->group_info) < 0) {
82263 + abort_creds(ncred);
82264 + goto die;
82265 + }
82266 + // caps
82267 + ncred->securebits = new->securebits;
82268 + ncred->cap_inheritable = new->cap_inheritable;
82269 + ncred->cap_permitted = new->cap_permitted;
82270 + ncred->cap_effective = new->cap_effective;
82271 + ncred->cap_bset = new->cap_bset;
82272 +
82273 + if (set_user(ncred)) {
82274 + abort_creds(ncred);
82275 + goto die;
82276 + }
82277 +
82278 + // from doing get_cred on it when queueing this
82279 + put_cred(new);
82280 +
82281 + __commit_creds(ncred);
82282 + return;
82283 +die:
82284 + // from doing get_cred on it when queueing this
82285 + put_cred(new);
82286 + do_group_exit(SIGKILL);
82287 +}
82288 +#endif
82289 +
82290 +int commit_creds(struct cred *new)
82291 +{
82292 +#ifdef CONFIG_GRKERNSEC_SETXID
82293 + int ret;
82294 + int schedule_it = 0;
82295 + struct task_struct *t;
82296 +
82297 + /* we won't get called with tasklist_lock held for writing
82298 + and interrupts disabled as the cred struct in that case is
82299 + init_cred
82300 + */
82301 + if (grsec_enable_setxid && !current_is_single_threaded() &&
82302 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
82303 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
82304 + schedule_it = 1;
82305 + }
82306 + ret = __commit_creds(new);
82307 + if (schedule_it) {
82308 + rcu_read_lock();
82309 + read_lock(&tasklist_lock);
82310 + for (t = next_thread(current); t != current;
82311 + t = next_thread(t)) {
82312 + if (t->delayed_cred == NULL) {
82313 + t->delayed_cred = get_cred(new);
82314 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
82315 + set_tsk_need_resched(t);
82316 + }
82317 + }
82318 + read_unlock(&tasklist_lock);
82319 + rcu_read_unlock();
82320 + }
82321 + return ret;
82322 +#else
82323 + return __commit_creds(new);
82324 +#endif
82325 +}
82326 +
82327 EXPORT_SYMBOL(commit_creds);
82328
82329 /**
82330 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
82331 index 0506d44..2c20034 100644
82332 --- a/kernel/debug/debug_core.c
82333 +++ b/kernel/debug/debug_core.c
82334 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
82335 */
82336 static atomic_t masters_in_kgdb;
82337 static atomic_t slaves_in_kgdb;
82338 -static atomic_t kgdb_break_tasklet_var;
82339 +static atomic_unchecked_t kgdb_break_tasklet_var;
82340 atomic_t kgdb_setting_breakpoint;
82341
82342 struct task_struct *kgdb_usethread;
82343 @@ -133,7 +133,7 @@ int kgdb_single_step;
82344 static pid_t kgdb_sstep_pid;
82345
82346 /* to keep track of the CPU which is doing the single stepping*/
82347 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
82348 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
82349
82350 /*
82351 * If you are debugging a problem where roundup (the collection of
82352 @@ -541,7 +541,7 @@ return_normal:
82353 * kernel will only try for the value of sstep_tries before
82354 * giving up and continuing on.
82355 */
82356 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
82357 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
82358 (kgdb_info[cpu].task &&
82359 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
82360 atomic_set(&kgdb_active, -1);
82361 @@ -635,8 +635,8 @@ cpu_master_loop:
82362 }
82363
82364 kgdb_restore:
82365 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
82366 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
82367 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
82368 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
82369 if (kgdb_info[sstep_cpu].task)
82370 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
82371 else
82372 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
82373 static void kgdb_tasklet_bpt(unsigned long ing)
82374 {
82375 kgdb_breakpoint();
82376 - atomic_set(&kgdb_break_tasklet_var, 0);
82377 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
82378 }
82379
82380 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
82381
82382 void kgdb_schedule_breakpoint(void)
82383 {
82384 - if (atomic_read(&kgdb_break_tasklet_var) ||
82385 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
82386 atomic_read(&kgdb_active) != -1 ||
82387 atomic_read(&kgdb_setting_breakpoint))
82388 return;
82389 - atomic_inc(&kgdb_break_tasklet_var);
82390 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
82391 tasklet_schedule(&kgdb_tasklet_breakpoint);
82392 }
82393 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
82394 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
82395 index 00eb8f7..d7e3244 100644
82396 --- a/kernel/debug/kdb/kdb_main.c
82397 +++ b/kernel/debug/kdb/kdb_main.c
82398 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
82399 continue;
82400
82401 kdb_printf("%-20s%8u 0x%p ", mod->name,
82402 - mod->core_size, (void *)mod);
82403 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
82404 #ifdef CONFIG_MODULE_UNLOAD
82405 kdb_printf("%4ld ", module_refcount(mod));
82406 #endif
82407 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
82408 kdb_printf(" (Loading)");
82409 else
82410 kdb_printf(" (Live)");
82411 - kdb_printf(" 0x%p", mod->module_core);
82412 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
82413
82414 #ifdef CONFIG_MODULE_UNLOAD
82415 {
82416 diff --git a/kernel/events/core.c b/kernel/events/core.c
82417 index 953c143..5646bb1 100644
82418 --- a/kernel/events/core.c
82419 +++ b/kernel/events/core.c
82420 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
82421 * 0 - disallow raw tracepoint access for unpriv
82422 * 1 - disallow cpu events for unpriv
82423 * 2 - disallow kernel profiling for unpriv
82424 + * 3 - disallow all unpriv perf event use
82425 */
82426 -int sysctl_perf_event_paranoid __read_mostly = 1;
82427 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82428 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
82429 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
82430 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
82431 +#else
82432 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
82433 +#endif
82434
82435 /* Minimum for 512 kiB + 1 user control page */
82436 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
82437 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
82438 update_perf_cpu_limits();
82439 }
82440
82441 -static atomic64_t perf_event_id;
82442 +static atomic64_unchecked_t perf_event_id;
82443
82444 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
82445 enum event_type_t event_type);
82446 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
82447
82448 static inline u64 perf_event_count(struct perf_event *event)
82449 {
82450 - return local64_read(&event->count) + atomic64_read(&event->child_count);
82451 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
82452 }
82453
82454 static u64 perf_event_read(struct perf_event *event)
82455 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
82456 mutex_lock(&event->child_mutex);
82457 total += perf_event_read(event);
82458 *enabled += event->total_time_enabled +
82459 - atomic64_read(&event->child_total_time_enabled);
82460 + atomic64_read_unchecked(&event->child_total_time_enabled);
82461 *running += event->total_time_running +
82462 - atomic64_read(&event->child_total_time_running);
82463 + atomic64_read_unchecked(&event->child_total_time_running);
82464
82465 list_for_each_entry(child, &event->child_list, child_list) {
82466 total += perf_event_read(child);
82467 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
82468 userpg->offset -= local64_read(&event->hw.prev_count);
82469
82470 userpg->time_enabled = enabled +
82471 - atomic64_read(&event->child_total_time_enabled);
82472 + atomic64_read_unchecked(&event->child_total_time_enabled);
82473
82474 userpg->time_running = running +
82475 - atomic64_read(&event->child_total_time_running);
82476 + atomic64_read_unchecked(&event->child_total_time_running);
82477
82478 arch_perf_update_userpage(userpg, now);
82479
82480 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
82481
82482 /* Data. */
82483 sp = perf_user_stack_pointer(regs);
82484 - rem = __output_copy_user(handle, (void *) sp, dump_size);
82485 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
82486 dyn_size = dump_size - rem;
82487
82488 perf_output_skip(handle, rem);
82489 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
82490 values[n++] = perf_event_count(event);
82491 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
82492 values[n++] = enabled +
82493 - atomic64_read(&event->child_total_time_enabled);
82494 + atomic64_read_unchecked(&event->child_total_time_enabled);
82495 }
82496 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
82497 values[n++] = running +
82498 - atomic64_read(&event->child_total_time_running);
82499 + atomic64_read_unchecked(&event->child_total_time_running);
82500 }
82501 if (read_format & PERF_FORMAT_ID)
82502 values[n++] = primary_event_id(event);
82503 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
82504 * need to add enough zero bytes after the string to handle
82505 * the 64bit alignment we do later.
82506 */
82507 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
82508 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
82509 if (!buf) {
82510 name = strncpy(tmp, "//enomem", sizeof(tmp));
82511 goto got_name;
82512 }
82513 - name = d_path(&file->f_path, buf, PATH_MAX);
82514 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
82515 if (IS_ERR(name)) {
82516 name = strncpy(tmp, "//toolong", sizeof(tmp));
82517 goto got_name;
82518 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
82519 event->parent = parent_event;
82520
82521 event->ns = get_pid_ns(task_active_pid_ns(current));
82522 - event->id = atomic64_inc_return(&perf_event_id);
82523 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
82524
82525 event->state = PERF_EVENT_STATE_INACTIVE;
82526
82527 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
82528 if (flags & ~PERF_FLAG_ALL)
82529 return -EINVAL;
82530
82531 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82532 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
82533 + return -EACCES;
82534 +#endif
82535 +
82536 err = perf_copy_attr(attr_uptr, &attr);
82537 if (err)
82538 return err;
82539 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
82540 /*
82541 * Add back the child's count to the parent's count:
82542 */
82543 - atomic64_add(child_val, &parent_event->child_count);
82544 - atomic64_add(child_event->total_time_enabled,
82545 + atomic64_add_unchecked(child_val, &parent_event->child_count);
82546 + atomic64_add_unchecked(child_event->total_time_enabled,
82547 &parent_event->child_total_time_enabled);
82548 - atomic64_add(child_event->total_time_running,
82549 + atomic64_add_unchecked(child_event->total_time_running,
82550 &parent_event->child_total_time_running);
82551
82552 /*
82553 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
82554 index ca65997..60df03d 100644
82555 --- a/kernel/events/internal.h
82556 +++ b/kernel/events/internal.h
82557 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
82558 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
82559 }
82560
82561 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
82562 -static inline unsigned int \
82563 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
82564 +static inline unsigned long \
82565 func_name(struct perf_output_handle *handle, \
82566 - const void *buf, unsigned int len) \
82567 + const void user *buf, unsigned long len) \
82568 { \
82569 unsigned long size, written; \
82570 \
82571 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
82572 return n;
82573 }
82574
82575 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
82576 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
82577
82578 #define MEMCPY_SKIP(dst, src, n) (n)
82579
82580 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
82581 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
82582
82583 #ifndef arch_perf_out_copy_user
82584 #define arch_perf_out_copy_user __copy_from_user_inatomic
82585 #endif
82586
82587 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
82588 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
82589
82590 /* Callchain handling */
82591 extern struct perf_callchain_entry *
82592 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
82593 index ad8e1bd..fed7ba9 100644
82594 --- a/kernel/events/uprobes.c
82595 +++ b/kernel/events/uprobes.c
82596 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
82597 {
82598 struct page *page;
82599 uprobe_opcode_t opcode;
82600 - int result;
82601 + long result;
82602
82603 pagefault_disable();
82604 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
82605 diff --git a/kernel/exit.c b/kernel/exit.c
82606 index a949819..a5f127d 100644
82607 --- a/kernel/exit.c
82608 +++ b/kernel/exit.c
82609 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
82610 struct task_struct *leader;
82611 int zap_leader;
82612 repeat:
82613 +#ifdef CONFIG_NET
82614 + gr_del_task_from_ip_table(p);
82615 +#endif
82616 +
82617 /* don't need to get the RCU readlock here - the process is dead and
82618 * can't be modifying its own credentials. But shut RCU-lockdep up */
82619 rcu_read_lock();
82620 @@ -329,7 +333,7 @@ int allow_signal(int sig)
82621 * know it'll be handled, so that they don't get converted to
82622 * SIGKILL or just silently dropped.
82623 */
82624 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
82625 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
82626 recalc_sigpending();
82627 spin_unlock_irq(&current->sighand->siglock);
82628 return 0;
82629 @@ -698,6 +702,8 @@ void do_exit(long code)
82630 struct task_struct *tsk = current;
82631 int group_dead;
82632
82633 + set_fs(USER_DS);
82634 +
82635 profile_task_exit(tsk);
82636
82637 WARN_ON(blk_needs_flush_plug(tsk));
82638 @@ -714,7 +720,6 @@ void do_exit(long code)
82639 * mm_release()->clear_child_tid() from writing to a user-controlled
82640 * kernel address.
82641 */
82642 - set_fs(USER_DS);
82643
82644 ptrace_event(PTRACE_EVENT_EXIT, code);
82645
82646 @@ -773,6 +778,9 @@ void do_exit(long code)
82647 tsk->exit_code = code;
82648 taskstats_exit(tsk, group_dead);
82649
82650 + gr_acl_handle_psacct(tsk, code);
82651 + gr_acl_handle_exit();
82652 +
82653 exit_mm(tsk);
82654
82655 if (group_dead)
82656 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
82657 * Take down every thread in the group. This is called by fatal signals
82658 * as well as by sys_exit_group (below).
82659 */
82660 -void
82661 +__noreturn void
82662 do_group_exit(int exit_code)
82663 {
82664 struct signal_struct *sig = current->signal;
82665 diff --git a/kernel/fork.c b/kernel/fork.c
82666 index 690cfac..3be2d98 100644
82667 --- a/kernel/fork.c
82668 +++ b/kernel/fork.c
82669 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
82670 *stackend = STACK_END_MAGIC; /* for overflow detection */
82671
82672 #ifdef CONFIG_CC_STACKPROTECTOR
82673 - tsk->stack_canary = get_random_int();
82674 + tsk->stack_canary = pax_get_random_long();
82675 #endif
82676
82677 /*
82678 @@ -345,12 +345,80 @@ free_tsk:
82679 }
82680
82681 #ifdef CONFIG_MMU
82682 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82683 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
82684 +{
82685 + struct vm_area_struct *tmp;
82686 + unsigned long charge;
82687 + struct file *file;
82688 + int retval;
82689 +
82690 + charge = 0;
82691 + if (mpnt->vm_flags & VM_ACCOUNT) {
82692 + unsigned long len = vma_pages(mpnt);
82693 +
82694 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82695 + goto fail_nomem;
82696 + charge = len;
82697 + }
82698 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82699 + if (!tmp)
82700 + goto fail_nomem;
82701 + *tmp = *mpnt;
82702 + tmp->vm_mm = mm;
82703 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
82704 + retval = vma_dup_policy(mpnt, tmp);
82705 + if (retval)
82706 + goto fail_nomem_policy;
82707 + if (anon_vma_fork(tmp, mpnt))
82708 + goto fail_nomem_anon_vma_fork;
82709 + tmp->vm_flags &= ~VM_LOCKED;
82710 + tmp->vm_next = tmp->vm_prev = NULL;
82711 + tmp->vm_mirror = NULL;
82712 + file = tmp->vm_file;
82713 + if (file) {
82714 + struct inode *inode = file_inode(file);
82715 + struct address_space *mapping = file->f_mapping;
82716 +
82717 + get_file(file);
82718 + if (tmp->vm_flags & VM_DENYWRITE)
82719 + atomic_dec(&inode->i_writecount);
82720 + mutex_lock(&mapping->i_mmap_mutex);
82721 + if (tmp->vm_flags & VM_SHARED)
82722 + mapping->i_mmap_writable++;
82723 + flush_dcache_mmap_lock(mapping);
82724 + /* insert tmp into the share list, just after mpnt */
82725 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82726 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
82727 + else
82728 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
82729 + flush_dcache_mmap_unlock(mapping);
82730 + mutex_unlock(&mapping->i_mmap_mutex);
82731 + }
82732 +
82733 + /*
82734 + * Clear hugetlb-related page reserves for children. This only
82735 + * affects MAP_PRIVATE mappings. Faults generated by the child
82736 + * are not guaranteed to succeed, even if read-only
82737 + */
82738 + if (is_vm_hugetlb_page(tmp))
82739 + reset_vma_resv_huge_pages(tmp);
82740 +
82741 + return tmp;
82742 +
82743 +fail_nomem_anon_vma_fork:
82744 + mpol_put(vma_policy(tmp));
82745 +fail_nomem_policy:
82746 + kmem_cache_free(vm_area_cachep, tmp);
82747 +fail_nomem:
82748 + vm_unacct_memory(charge);
82749 + return NULL;
82750 +}
82751 +
82752 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82753 {
82754 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
82755 struct rb_node **rb_link, *rb_parent;
82756 int retval;
82757 - unsigned long charge;
82758
82759 uprobe_start_dup_mmap();
82760 down_write(&oldmm->mmap_sem);
82761 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82762
82763 prev = NULL;
82764 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
82765 - struct file *file;
82766 -
82767 if (mpnt->vm_flags & VM_DONTCOPY) {
82768 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
82769 -vma_pages(mpnt));
82770 continue;
82771 }
82772 - charge = 0;
82773 - if (mpnt->vm_flags & VM_ACCOUNT) {
82774 - unsigned long len = vma_pages(mpnt);
82775 -
82776 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82777 - goto fail_nomem;
82778 - charge = len;
82779 - }
82780 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82781 - if (!tmp)
82782 - goto fail_nomem;
82783 - *tmp = *mpnt;
82784 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
82785 - retval = vma_dup_policy(mpnt, tmp);
82786 - if (retval)
82787 - goto fail_nomem_policy;
82788 - tmp->vm_mm = mm;
82789 - if (anon_vma_fork(tmp, mpnt))
82790 - goto fail_nomem_anon_vma_fork;
82791 - tmp->vm_flags &= ~VM_LOCKED;
82792 - tmp->vm_next = tmp->vm_prev = NULL;
82793 - file = tmp->vm_file;
82794 - if (file) {
82795 - struct inode *inode = file_inode(file);
82796 - struct address_space *mapping = file->f_mapping;
82797 -
82798 - get_file(file);
82799 - if (tmp->vm_flags & VM_DENYWRITE)
82800 - atomic_dec(&inode->i_writecount);
82801 - mutex_lock(&mapping->i_mmap_mutex);
82802 - if (tmp->vm_flags & VM_SHARED)
82803 - mapping->i_mmap_writable++;
82804 - flush_dcache_mmap_lock(mapping);
82805 - /* insert tmp into the share list, just after mpnt */
82806 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82807 - vma_nonlinear_insert(tmp,
82808 - &mapping->i_mmap_nonlinear);
82809 - else
82810 - vma_interval_tree_insert_after(tmp, mpnt,
82811 - &mapping->i_mmap);
82812 - flush_dcache_mmap_unlock(mapping);
82813 - mutex_unlock(&mapping->i_mmap_mutex);
82814 + tmp = dup_vma(mm, oldmm, mpnt);
82815 + if (!tmp) {
82816 + retval = -ENOMEM;
82817 + goto out;
82818 }
82819
82820 /*
82821 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82822 if (retval)
82823 goto out;
82824 }
82825 +
82826 +#ifdef CONFIG_PAX_SEGMEXEC
82827 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
82828 + struct vm_area_struct *mpnt_m;
82829 +
82830 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
82831 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
82832 +
82833 + if (!mpnt->vm_mirror)
82834 + continue;
82835 +
82836 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
82837 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
82838 + mpnt->vm_mirror = mpnt_m;
82839 + } else {
82840 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
82841 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
82842 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
82843 + mpnt->vm_mirror->vm_mirror = mpnt;
82844 + }
82845 + }
82846 + BUG_ON(mpnt_m);
82847 + }
82848 +#endif
82849 +
82850 /* a new mm has just been created */
82851 arch_dup_mmap(oldmm, mm);
82852 retval = 0;
82853 @@ -468,14 +521,6 @@ out:
82854 up_write(&oldmm->mmap_sem);
82855 uprobe_end_dup_mmap();
82856 return retval;
82857 -fail_nomem_anon_vma_fork:
82858 - mpol_put(vma_policy(tmp));
82859 -fail_nomem_policy:
82860 - kmem_cache_free(vm_area_cachep, tmp);
82861 -fail_nomem:
82862 - retval = -ENOMEM;
82863 - vm_unacct_memory(charge);
82864 - goto out;
82865 }
82866
82867 static inline int mm_alloc_pgd(struct mm_struct *mm)
82868 @@ -689,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
82869 return ERR_PTR(err);
82870
82871 mm = get_task_mm(task);
82872 - if (mm && mm != current->mm &&
82873 - !ptrace_may_access(task, mode)) {
82874 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
82875 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
82876 mmput(mm);
82877 mm = ERR_PTR(-EACCES);
82878 }
82879 @@ -912,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
82880 spin_unlock(&fs->lock);
82881 return -EAGAIN;
82882 }
82883 - fs->users++;
82884 + atomic_inc(&fs->users);
82885 spin_unlock(&fs->lock);
82886 return 0;
82887 }
82888 tsk->fs = copy_fs_struct(fs);
82889 if (!tsk->fs)
82890 return -ENOMEM;
82891 + /* Carry through gr_chroot_dentry and is_chrooted instead
82892 + of recomputing it here. Already copied when the task struct
82893 + is duplicated. This allows pivot_root to not be treated as
82894 + a chroot
82895 + */
82896 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
82897 +
82898 return 0;
82899 }
82900
82901 @@ -1129,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
82902 * parts of the process environment (as per the clone
82903 * flags). The actual kick-off is left to the caller.
82904 */
82905 -static struct task_struct *copy_process(unsigned long clone_flags,
82906 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
82907 unsigned long stack_start,
82908 unsigned long stack_size,
82909 int __user *child_tidptr,
82910 @@ -1201,6 +1253,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82911 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
82912 #endif
82913 retval = -EAGAIN;
82914 +
82915 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
82916 +
82917 if (atomic_read(&p->real_cred->user->processes) >=
82918 task_rlimit(p, RLIMIT_NPROC)) {
82919 if (p->real_cred->user != INIT_USER &&
82920 @@ -1450,6 +1505,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82921 goto bad_fork_free_pid;
82922 }
82923
82924 + /* synchronizes with gr_set_acls()
82925 + we need to call this past the point of no return for fork()
82926 + */
82927 + gr_copy_label(p);
82928 +
82929 if (likely(p->pid)) {
82930 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
82931
82932 @@ -1535,6 +1595,8 @@ bad_fork_cleanup_count:
82933 bad_fork_free:
82934 free_task(p);
82935 fork_out:
82936 + gr_log_forkfail(retval);
82937 +
82938 return ERR_PTR(retval);
82939 }
82940
82941 @@ -1596,6 +1658,7 @@ long do_fork(unsigned long clone_flags,
82942
82943 p = copy_process(clone_flags, stack_start, stack_size,
82944 child_tidptr, NULL, trace);
82945 + add_latent_entropy();
82946 /*
82947 * Do this prior waking up the new thread - the thread pointer
82948 * might get invalid after that point, if the thread exits quickly.
82949 @@ -1610,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
82950 if (clone_flags & CLONE_PARENT_SETTID)
82951 put_user(nr, parent_tidptr);
82952
82953 + gr_handle_brute_check();
82954 +
82955 if (clone_flags & CLONE_VFORK) {
82956 p->vfork_done = &vfork;
82957 init_completion(&vfork);
82958 @@ -1726,7 +1791,7 @@ void __init proc_caches_init(void)
82959 mm_cachep = kmem_cache_create("mm_struct",
82960 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
82961 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
82962 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
82963 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
82964 mmap_init();
82965 nsproxy_cache_init();
82966 }
82967 @@ -1766,7 +1831,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
82968 return 0;
82969
82970 /* don't need lock here; in the worst case we'll do useless copy */
82971 - if (fs->users == 1)
82972 + if (atomic_read(&fs->users) == 1)
82973 return 0;
82974
82975 *new_fsp = copy_fs_struct(fs);
82976 @@ -1873,7 +1938,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
82977 fs = current->fs;
82978 spin_lock(&fs->lock);
82979 current->fs = new_fs;
82980 - if (--fs->users)
82981 + gr_set_chroot_entries(current, &current->fs->root);
82982 + if (atomic_dec_return(&fs->users))
82983 new_fs = NULL;
82984 else
82985 new_fs = fs;
82986 diff --git a/kernel/futex.c b/kernel/futex.c
82987 index 221a58f..1b8cfce 100644
82988 --- a/kernel/futex.c
82989 +++ b/kernel/futex.c
82990 @@ -54,6 +54,7 @@
82991 #include <linux/mount.h>
82992 #include <linux/pagemap.h>
82993 #include <linux/syscalls.h>
82994 +#include <linux/ptrace.h>
82995 #include <linux/signal.h>
82996 #include <linux/export.h>
82997 #include <linux/magic.h>
82998 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
82999 struct page *page, *page_head;
83000 int err, ro = 0;
83001
83002 +#ifdef CONFIG_PAX_SEGMEXEC
83003 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
83004 + return -EFAULT;
83005 +#endif
83006 +
83007 /*
83008 * The futex address must be "naturally" aligned.
83009 */
83010 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
83011
83012 static int get_futex_value_locked(u32 *dest, u32 __user *from)
83013 {
83014 - int ret;
83015 + unsigned long ret;
83016
83017 pagefault_disable();
83018 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
83019 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
83020 {
83021 u32 curval;
83022 int i;
83023 + mm_segment_t oldfs;
83024
83025 /*
83026 * This will fail and we want it. Some arch implementations do
83027 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
83028 * implementation, the non-functional ones will return
83029 * -ENOSYS.
83030 */
83031 + oldfs = get_fs();
83032 + set_fs(USER_DS);
83033 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
83034 futex_cmpxchg_enabled = 1;
83035 + set_fs(oldfs);
83036
83037 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
83038 plist_head_init(&futex_queues[i].chain);
83039 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
83040 index f9f44fd..29885e4 100644
83041 --- a/kernel/futex_compat.c
83042 +++ b/kernel/futex_compat.c
83043 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
83044 return 0;
83045 }
83046
83047 -static void __user *futex_uaddr(struct robust_list __user *entry,
83048 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
83049 compat_long_t futex_offset)
83050 {
83051 compat_uptr_t base = ptr_to_compat(entry);
83052 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
83053 index 9b22d03..6295b62 100644
83054 --- a/kernel/gcov/base.c
83055 +++ b/kernel/gcov/base.c
83056 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
83057 }
83058
83059 #ifdef CONFIG_MODULES
83060 -static inline int within(void *addr, void *start, unsigned long size)
83061 -{
83062 - return ((addr >= start) && (addr < start + size));
83063 -}
83064 -
83065 /* Update list and generate events when modules are unloaded. */
83066 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
83067 void *data)
83068 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
83069 prev = NULL;
83070 /* Remove entries located in module from linked list. */
83071 for (info = gcov_info_head; info; info = info->next) {
83072 - if (within(info, mod->module_core, mod->core_size)) {
83073 + if (within_module_core_rw((unsigned long)info, mod)) {
83074 if (prev)
83075 prev->next = info->next;
83076 else
83077 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
83078 index 383319b..56ebb13 100644
83079 --- a/kernel/hrtimer.c
83080 +++ b/kernel/hrtimer.c
83081 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
83082 local_irq_restore(flags);
83083 }
83084
83085 -static void run_hrtimer_softirq(struct softirq_action *h)
83086 +static __latent_entropy void run_hrtimer_softirq(void)
83087 {
83088 hrtimer_peek_ahead_timers();
83089 }
83090 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
83091 index 55fcce6..0e4cf34 100644
83092 --- a/kernel/irq_work.c
83093 +++ b/kernel/irq_work.c
83094 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
83095 return NOTIFY_OK;
83096 }
83097
83098 -static struct notifier_block cpu_notify;
83099 +static struct notifier_block cpu_notify = {
83100 + .notifier_call = irq_work_cpu_notify,
83101 + .priority = 0,
83102 +};
83103
83104 static __init int irq_work_init_cpu_notifier(void)
83105 {
83106 - cpu_notify.notifier_call = irq_work_cpu_notify;
83107 - cpu_notify.priority = 0;
83108 register_cpu_notifier(&cpu_notify);
83109 return 0;
83110 }
83111 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
83112 index 297a924..7290070 100644
83113 --- a/kernel/jump_label.c
83114 +++ b/kernel/jump_label.c
83115 @@ -14,6 +14,7 @@
83116 #include <linux/err.h>
83117 #include <linux/static_key.h>
83118 #include <linux/jump_label_ratelimit.h>
83119 +#include <linux/mm.h>
83120
83121 #ifdef HAVE_JUMP_LABEL
83122
83123 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
83124
83125 size = (((unsigned long)stop - (unsigned long)start)
83126 / sizeof(struct jump_entry));
83127 + pax_open_kernel();
83128 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
83129 + pax_close_kernel();
83130 }
83131
83132 static void jump_label_update(struct static_key *key, int enable);
83133 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
83134 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
83135 struct jump_entry *iter;
83136
83137 + pax_open_kernel();
83138 for (iter = iter_start; iter < iter_stop; iter++) {
83139 if (within_module_init(iter->code, mod))
83140 iter->code = 0;
83141 }
83142 + pax_close_kernel();
83143 }
83144
83145 static int
83146 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
83147 index 3127ad5..159d880 100644
83148 --- a/kernel/kallsyms.c
83149 +++ b/kernel/kallsyms.c
83150 @@ -11,6 +11,9 @@
83151 * Changed the compression method from stem compression to "table lookup"
83152 * compression (see scripts/kallsyms.c for a more complete description)
83153 */
83154 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83155 +#define __INCLUDED_BY_HIDESYM 1
83156 +#endif
83157 #include <linux/kallsyms.h>
83158 #include <linux/module.h>
83159 #include <linux/init.h>
83160 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
83161
83162 static inline int is_kernel_inittext(unsigned long addr)
83163 {
83164 + if (system_state != SYSTEM_BOOTING)
83165 + return 0;
83166 +
83167 if (addr >= (unsigned long)_sinittext
83168 && addr <= (unsigned long)_einittext)
83169 return 1;
83170 return 0;
83171 }
83172
83173 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83174 +#ifdef CONFIG_MODULES
83175 +static inline int is_module_text(unsigned long addr)
83176 +{
83177 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
83178 + return 1;
83179 +
83180 + addr = ktla_ktva(addr);
83181 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
83182 +}
83183 +#else
83184 +static inline int is_module_text(unsigned long addr)
83185 +{
83186 + return 0;
83187 +}
83188 +#endif
83189 +#endif
83190 +
83191 static inline int is_kernel_text(unsigned long addr)
83192 {
83193 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
83194 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
83195
83196 static inline int is_kernel(unsigned long addr)
83197 {
83198 +
83199 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83200 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
83201 + return 1;
83202 +
83203 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
83204 +#else
83205 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
83206 +#endif
83207 +
83208 return 1;
83209 return in_gate_area_no_mm(addr);
83210 }
83211
83212 static int is_ksym_addr(unsigned long addr)
83213 {
83214 +
83215 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83216 + if (is_module_text(addr))
83217 + return 0;
83218 +#endif
83219 +
83220 if (all_var)
83221 return is_kernel(addr);
83222
83223 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
83224
83225 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
83226 {
83227 - iter->name[0] = '\0';
83228 iter->nameoff = get_symbol_offset(new_pos);
83229 iter->pos = new_pos;
83230 }
83231 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
83232 {
83233 struct kallsym_iter *iter = m->private;
83234
83235 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83236 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
83237 + return 0;
83238 +#endif
83239 +
83240 /* Some debugging symbols have no name. Ignore them. */
83241 if (!iter->name[0])
83242 return 0;
83243 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
83244 */
83245 type = iter->exported ? toupper(iter->type) :
83246 tolower(iter->type);
83247 +
83248 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
83249 type, iter->name, iter->module_name);
83250 } else
83251 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
83252 struct kallsym_iter *iter;
83253 int ret;
83254
83255 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
83256 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
83257 if (!iter)
83258 return -ENOMEM;
83259 reset_iter(iter, 0);
83260 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
83261 index e30ac0f..3528cac 100644
83262 --- a/kernel/kcmp.c
83263 +++ b/kernel/kcmp.c
83264 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
83265 struct task_struct *task1, *task2;
83266 int ret;
83267
83268 +#ifdef CONFIG_GRKERNSEC
83269 + return -ENOSYS;
83270 +#endif
83271 +
83272 rcu_read_lock();
83273
83274 /*
83275 diff --git a/kernel/kexec.c b/kernel/kexec.c
83276 index 355e13a..06b25d2 100644
83277 --- a/kernel/kexec.c
83278 +++ b/kernel/kexec.c
83279 @@ -1044,7 +1044,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
83280 unsigned long flags)
83281 {
83282 struct compat_kexec_segment in;
83283 - struct kexec_segment out, __user *ksegments;
83284 + struct kexec_segment out;
83285 + struct kexec_segment __user *ksegments;
83286 unsigned long i, result;
83287
83288 /* Don't allow clients that don't understand the native
83289 diff --git a/kernel/kmod.c b/kernel/kmod.c
83290 index b086006..6d2e579 100644
83291 --- a/kernel/kmod.c
83292 +++ b/kernel/kmod.c
83293 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
83294 kfree(info->argv);
83295 }
83296
83297 -static int call_modprobe(char *module_name, int wait)
83298 +static int call_modprobe(char *module_name, char *module_param, int wait)
83299 {
83300 struct subprocess_info *info;
83301 static char *envp[] = {
83302 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
83303 NULL
83304 };
83305
83306 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
83307 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
83308 if (!argv)
83309 goto out;
83310
83311 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
83312 argv[1] = "-q";
83313 argv[2] = "--";
83314 argv[3] = module_name; /* check free_modprobe_argv() */
83315 - argv[4] = NULL;
83316 + argv[4] = module_param;
83317 + argv[5] = NULL;
83318
83319 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
83320 NULL, free_modprobe_argv, NULL);
83321 @@ -129,9 +130,8 @@ out:
83322 * If module auto-loading support is disabled then this function
83323 * becomes a no-operation.
83324 */
83325 -int __request_module(bool wait, const char *fmt, ...)
83326 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
83327 {
83328 - va_list args;
83329 char module_name[MODULE_NAME_LEN];
83330 unsigned int max_modprobes;
83331 int ret;
83332 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
83333 if (!modprobe_path[0])
83334 return 0;
83335
83336 - va_start(args, fmt);
83337 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
83338 - va_end(args);
83339 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
83340 if (ret >= MODULE_NAME_LEN)
83341 return -ENAMETOOLONG;
83342
83343 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
83344 if (ret)
83345 return ret;
83346
83347 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83348 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
83349 + /* hack to workaround consolekit/udisks stupidity */
83350 + read_lock(&tasklist_lock);
83351 + if (!strcmp(current->comm, "mount") &&
83352 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
83353 + read_unlock(&tasklist_lock);
83354 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
83355 + return -EPERM;
83356 + }
83357 + read_unlock(&tasklist_lock);
83358 + }
83359 +#endif
83360 +
83361 /* If modprobe needs a service that is in a module, we get a recursive
83362 * loop. Limit the number of running kmod threads to max_threads/2 or
83363 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
83364 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
83365
83366 trace_module_request(module_name, wait, _RET_IP_);
83367
83368 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
83369 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
83370
83371 atomic_dec(&kmod_concurrent);
83372 return ret;
83373 }
83374 +
83375 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
83376 +{
83377 + va_list args;
83378 + int ret;
83379 +
83380 + va_start(args, fmt);
83381 + ret = ____request_module(wait, module_param, fmt, args);
83382 + va_end(args);
83383 +
83384 + return ret;
83385 +}
83386 +
83387 +int __request_module(bool wait, const char *fmt, ...)
83388 +{
83389 + va_list args;
83390 + int ret;
83391 +
83392 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83393 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
83394 + char module_param[MODULE_NAME_LEN];
83395 +
83396 + memset(module_param, 0, sizeof(module_param));
83397 +
83398 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
83399 +
83400 + va_start(args, fmt);
83401 + ret = ____request_module(wait, module_param, fmt, args);
83402 + va_end(args);
83403 +
83404 + return ret;
83405 + }
83406 +#endif
83407 +
83408 + va_start(args, fmt);
83409 + ret = ____request_module(wait, NULL, fmt, args);
83410 + va_end(args);
83411 +
83412 + return ret;
83413 +}
83414 +
83415 EXPORT_SYMBOL(__request_module);
83416 #endif /* CONFIG_MODULES */
83417
83418 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
83419 */
83420 set_user_nice(current, 0);
83421
83422 +#ifdef CONFIG_GRKERNSEC
83423 + /* this is race-free as far as userland is concerned as we copied
83424 + out the path to be used prior to this point and are now operating
83425 + on that copy
83426 + */
83427 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
83428 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
83429 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
83430 + retval = -EPERM;
83431 + goto fail;
83432 + }
83433 +#endif
83434 +
83435 retval = -ENOMEM;
83436 new = prepare_kernel_cred(current);
83437 if (!new)
83438 @@ -260,6 +326,10 @@ static int call_helper(void *data)
83439
83440 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
83441 {
83442 +#ifdef CONFIG_GRKERNSEC
83443 + kfree(info->path);
83444 + info->path = info->origpath;
83445 +#endif
83446 if (info->cleanup)
83447 (*info->cleanup)(info);
83448 kfree(info);
83449 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
83450 *
83451 * Thus the __user pointer cast is valid here.
83452 */
83453 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
83454 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
83455
83456 /*
83457 * If ret is 0, either ____call_usermodehelper failed and the
83458 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
83459 goto out;
83460
83461 INIT_WORK(&sub_info->work, __call_usermodehelper);
83462 +#ifdef CONFIG_GRKERNSEC
83463 + sub_info->origpath = path;
83464 + sub_info->path = kstrdup(path, gfp_mask);
83465 +#else
83466 sub_info->path = path;
83467 +#endif
83468 sub_info->argv = argv;
83469 sub_info->envp = envp;
83470
83471 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
83472 static int proc_cap_handler(struct ctl_table *table, int write,
83473 void __user *buffer, size_t *lenp, loff_t *ppos)
83474 {
83475 - struct ctl_table t;
83476 + ctl_table_no_const t;
83477 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
83478 kernel_cap_t new_cap;
83479 int err, i;
83480 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
83481 index a0d367a..11c18b6 100644
83482 --- a/kernel/kprobes.c
83483 +++ b/kernel/kprobes.c
83484 @@ -31,6 +31,9 @@
83485 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
83486 * <prasanna@in.ibm.com> added function-return probes.
83487 */
83488 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83489 +#define __INCLUDED_BY_HIDESYM 1
83490 +#endif
83491 #include <linux/kprobes.h>
83492 #include <linux/hash.h>
83493 #include <linux/init.h>
83494 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
83495
83496 static void *alloc_insn_page(void)
83497 {
83498 - return module_alloc(PAGE_SIZE);
83499 + return module_alloc_exec(PAGE_SIZE);
83500 }
83501
83502 static void free_insn_page(void *page)
83503 {
83504 - module_free(NULL, page);
83505 + module_free_exec(NULL, page);
83506 }
83507
83508 struct kprobe_insn_cache kprobe_insn_slots = {
83509 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
83510 {
83511 int i, err = 0;
83512 unsigned long offset = 0, size = 0;
83513 - char *modname, namebuf[128];
83514 + char *modname, namebuf[KSYM_NAME_LEN];
83515 const char *symbol_name;
83516 void *addr;
83517 struct kprobe_blackpoint *kb;
83518 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
83519 kprobe_type = "k";
83520
83521 if (sym)
83522 - seq_printf(pi, "%p %s %s+0x%x %s ",
83523 + seq_printf(pi, "%pK %s %s+0x%x %s ",
83524 p->addr, kprobe_type, sym, offset,
83525 (modname ? modname : " "));
83526 else
83527 - seq_printf(pi, "%p %s %p ",
83528 + seq_printf(pi, "%pK %s %pK ",
83529 p->addr, kprobe_type, p->addr);
83530
83531 if (!pp)
83532 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
83533 const char *sym = NULL;
83534 unsigned int i = *(loff_t *) v;
83535 unsigned long offset = 0;
83536 - char *modname, namebuf[128];
83537 + char *modname, namebuf[KSYM_NAME_LEN];
83538
83539 head = &kprobe_table[i];
83540 preempt_disable();
83541 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
83542 index 9659d38..bffd520 100644
83543 --- a/kernel/ksysfs.c
83544 +++ b/kernel/ksysfs.c
83545 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
83546 {
83547 if (count+1 > UEVENT_HELPER_PATH_LEN)
83548 return -ENOENT;
83549 + if (!capable(CAP_SYS_ADMIN))
83550 + return -EPERM;
83551 memcpy(uevent_helper, buf, count);
83552 uevent_helper[count] = '\0';
83553 if (count && uevent_helper[count-1] == '\n')
83554 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
83555 return count;
83556 }
83557
83558 -static struct bin_attribute notes_attr = {
83559 +static bin_attribute_no_const notes_attr __read_only = {
83560 .attr = {
83561 .name = "notes",
83562 .mode = S_IRUGO,
83563 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
83564 index e16c45b..6f49c48 100644
83565 --- a/kernel/lockdep.c
83566 +++ b/kernel/lockdep.c
83567 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
83568 end = (unsigned long) &_end,
83569 addr = (unsigned long) obj;
83570
83571 +#ifdef CONFIG_PAX_KERNEXEC
83572 + start = ktla_ktva(start);
83573 +#endif
83574 +
83575 /*
83576 * static variable?
83577 */
83578 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
83579 if (!static_obj(lock->key)) {
83580 debug_locks_off();
83581 printk("INFO: trying to register non-static key.\n");
83582 + printk("lock:%pS key:%pS.\n", lock, lock->key);
83583 printk("the code is fine but needs lockdep annotation.\n");
83584 printk("turning off the locking correctness validator.\n");
83585 dump_stack();
83586 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
83587 if (!class)
83588 return 0;
83589 }
83590 - atomic_inc((atomic_t *)&class->ops);
83591 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
83592 if (very_verbose(class)) {
83593 printk("\nacquire class [%p] %s", class->key, class->name);
83594 if (class->name_version > 1)
83595 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
83596 index b2c71c5..7b88d63 100644
83597 --- a/kernel/lockdep_proc.c
83598 +++ b/kernel/lockdep_proc.c
83599 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
83600 return 0;
83601 }
83602
83603 - seq_printf(m, "%p", class->key);
83604 + seq_printf(m, "%pK", class->key);
83605 #ifdef CONFIG_DEBUG_LOCKDEP
83606 seq_printf(m, " OPS:%8ld", class->ops);
83607 #endif
83608 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
83609
83610 list_for_each_entry(entry, &class->locks_after, entry) {
83611 if (entry->distance == 1) {
83612 - seq_printf(m, " -> [%p] ", entry->class->key);
83613 + seq_printf(m, " -> [%pK] ", entry->class->key);
83614 print_name(m, entry->class);
83615 seq_puts(m, "\n");
83616 }
83617 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
83618 if (!class->key)
83619 continue;
83620
83621 - seq_printf(m, "[%p] ", class->key);
83622 + seq_printf(m, "[%pK] ", class->key);
83623 print_name(m, class);
83624 seq_puts(m, "\n");
83625 }
83626 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83627 if (!i)
83628 seq_line(m, '-', 40-namelen, namelen);
83629
83630 - snprintf(ip, sizeof(ip), "[<%p>]",
83631 + snprintf(ip, sizeof(ip), "[<%pK>]",
83632 (void *)class->contention_point[i]);
83633 seq_printf(m, "%40s %14lu %29s %pS\n",
83634 name, stats->contention_point[i],
83635 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83636 if (!i)
83637 seq_line(m, '-', 40-namelen, namelen);
83638
83639 - snprintf(ip, sizeof(ip), "[<%p>]",
83640 + snprintf(ip, sizeof(ip), "[<%pK>]",
83641 (void *)class->contending_point[i]);
83642 seq_printf(m, "%40s %14lu %29s %pS\n",
83643 name, stats->contending_point[i],
83644 diff --git a/kernel/module.c b/kernel/module.c
83645 index dc58274..3ddfa55 100644
83646 --- a/kernel/module.c
83647 +++ b/kernel/module.c
83648 @@ -61,6 +61,7 @@
83649 #include <linux/pfn.h>
83650 #include <linux/bsearch.h>
83651 #include <linux/fips.h>
83652 +#include <linux/grsecurity.h>
83653 #include <uapi/linux/module.h>
83654 #include "module-internal.h"
83655
83656 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
83657
83658 /* Bounds of module allocation, for speeding __module_address.
83659 * Protected by module_mutex. */
83660 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
83661 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
83662 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
83663
83664 int register_module_notifier(struct notifier_block * nb)
83665 {
83666 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83667 return true;
83668
83669 list_for_each_entry_rcu(mod, &modules, list) {
83670 - struct symsearch arr[] = {
83671 + struct symsearch modarr[] = {
83672 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
83673 NOT_GPL_ONLY, false },
83674 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
83675 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83676 if (mod->state == MODULE_STATE_UNFORMED)
83677 continue;
83678
83679 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
83680 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
83681 return true;
83682 }
83683 return false;
83684 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
83685 if (!pcpusec->sh_size)
83686 return 0;
83687
83688 - if (align > PAGE_SIZE) {
83689 + if (align-1 >= PAGE_SIZE) {
83690 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
83691 mod->name, align, PAGE_SIZE);
83692 align = PAGE_SIZE;
83693 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
83694 static ssize_t show_coresize(struct module_attribute *mattr,
83695 struct module_kobject *mk, char *buffer)
83696 {
83697 - return sprintf(buffer, "%u\n", mk->mod->core_size);
83698 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
83699 }
83700
83701 static struct module_attribute modinfo_coresize =
83702 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
83703 static ssize_t show_initsize(struct module_attribute *mattr,
83704 struct module_kobject *mk, char *buffer)
83705 {
83706 - return sprintf(buffer, "%u\n", mk->mod->init_size);
83707 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
83708 }
83709
83710 static struct module_attribute modinfo_initsize =
83711 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
83712 */
83713 #ifdef CONFIG_SYSFS
83714
83715 -#ifdef CONFIG_KALLSYMS
83716 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
83717 static inline bool sect_empty(const Elf_Shdr *sect)
83718 {
83719 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
83720 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
83721 {
83722 unsigned int notes, loaded, i;
83723 struct module_notes_attrs *notes_attrs;
83724 - struct bin_attribute *nattr;
83725 + bin_attribute_no_const *nattr;
83726
83727 /* failed to create section attributes, so can't create notes */
83728 if (!mod->sect_attrs)
83729 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
83730 static int module_add_modinfo_attrs(struct module *mod)
83731 {
83732 struct module_attribute *attr;
83733 - struct module_attribute *temp_attr;
83734 + module_attribute_no_const *temp_attr;
83735 int error = 0;
83736 int i;
83737
83738 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
83739
83740 static void unset_module_core_ro_nx(struct module *mod)
83741 {
83742 - set_page_attributes(mod->module_core + mod->core_text_size,
83743 - mod->module_core + mod->core_size,
83744 + set_page_attributes(mod->module_core_rw,
83745 + mod->module_core_rw + mod->core_size_rw,
83746 set_memory_x);
83747 - set_page_attributes(mod->module_core,
83748 - mod->module_core + mod->core_ro_size,
83749 + set_page_attributes(mod->module_core_rx,
83750 + mod->module_core_rx + mod->core_size_rx,
83751 set_memory_rw);
83752 }
83753
83754 static void unset_module_init_ro_nx(struct module *mod)
83755 {
83756 - set_page_attributes(mod->module_init + mod->init_text_size,
83757 - mod->module_init + mod->init_size,
83758 + set_page_attributes(mod->module_init_rw,
83759 + mod->module_init_rw + mod->init_size_rw,
83760 set_memory_x);
83761 - set_page_attributes(mod->module_init,
83762 - mod->module_init + mod->init_ro_size,
83763 + set_page_attributes(mod->module_init_rx,
83764 + mod->module_init_rx + mod->init_size_rx,
83765 set_memory_rw);
83766 }
83767
83768 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
83769 list_for_each_entry_rcu(mod, &modules, list) {
83770 if (mod->state == MODULE_STATE_UNFORMED)
83771 continue;
83772 - if ((mod->module_core) && (mod->core_text_size)) {
83773 - set_page_attributes(mod->module_core,
83774 - mod->module_core + mod->core_text_size,
83775 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83776 + set_page_attributes(mod->module_core_rx,
83777 + mod->module_core_rx + mod->core_size_rx,
83778 set_memory_rw);
83779 }
83780 - if ((mod->module_init) && (mod->init_text_size)) {
83781 - set_page_attributes(mod->module_init,
83782 - mod->module_init + mod->init_text_size,
83783 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83784 + set_page_attributes(mod->module_init_rx,
83785 + mod->module_init_rx + mod->init_size_rx,
83786 set_memory_rw);
83787 }
83788 }
83789 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
83790 list_for_each_entry_rcu(mod, &modules, list) {
83791 if (mod->state == MODULE_STATE_UNFORMED)
83792 continue;
83793 - if ((mod->module_core) && (mod->core_text_size)) {
83794 - set_page_attributes(mod->module_core,
83795 - mod->module_core + mod->core_text_size,
83796 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83797 + set_page_attributes(mod->module_core_rx,
83798 + mod->module_core_rx + mod->core_size_rx,
83799 set_memory_ro);
83800 }
83801 - if ((mod->module_init) && (mod->init_text_size)) {
83802 - set_page_attributes(mod->module_init,
83803 - mod->module_init + mod->init_text_size,
83804 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83805 + set_page_attributes(mod->module_init_rx,
83806 + mod->module_init_rx + mod->init_size_rx,
83807 set_memory_ro);
83808 }
83809 }
83810 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
83811
83812 /* This may be NULL, but that's OK */
83813 unset_module_init_ro_nx(mod);
83814 - module_free(mod, mod->module_init);
83815 + module_free(mod, mod->module_init_rw);
83816 + module_free_exec(mod, mod->module_init_rx);
83817 kfree(mod->args);
83818 percpu_modfree(mod);
83819
83820 /* Free lock-classes: */
83821 - lockdep_free_key_range(mod->module_core, mod->core_size);
83822 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
83823 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
83824
83825 /* Finally, free the core (containing the module structure) */
83826 unset_module_core_ro_nx(mod);
83827 - module_free(mod, mod->module_core);
83828 + module_free_exec(mod, mod->module_core_rx);
83829 + module_free(mod, mod->module_core_rw);
83830
83831 #ifdef CONFIG_MPU
83832 update_protections(current->mm);
83833 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83834 int ret = 0;
83835 const struct kernel_symbol *ksym;
83836
83837 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83838 + int is_fs_load = 0;
83839 + int register_filesystem_found = 0;
83840 + char *p;
83841 +
83842 + p = strstr(mod->args, "grsec_modharden_fs");
83843 + if (p) {
83844 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
83845 + /* copy \0 as well */
83846 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
83847 + is_fs_load = 1;
83848 + }
83849 +#endif
83850 +
83851 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
83852 const char *name = info->strtab + sym[i].st_name;
83853
83854 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83855 + /* it's a real shame this will never get ripped and copied
83856 + upstream! ;(
83857 + */
83858 + if (is_fs_load && !strcmp(name, "register_filesystem"))
83859 + register_filesystem_found = 1;
83860 +#endif
83861 +
83862 switch (sym[i].st_shndx) {
83863 case SHN_COMMON:
83864 /* We compiled with -fno-common. These are not
83865 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83866 ksym = resolve_symbol_wait(mod, info, name);
83867 /* Ok if resolved. */
83868 if (ksym && !IS_ERR(ksym)) {
83869 + pax_open_kernel();
83870 sym[i].st_value = ksym->value;
83871 + pax_close_kernel();
83872 break;
83873 }
83874
83875 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83876 secbase = (unsigned long)mod_percpu(mod);
83877 else
83878 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
83879 + pax_open_kernel();
83880 sym[i].st_value += secbase;
83881 + pax_close_kernel();
83882 break;
83883 }
83884 }
83885
83886 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83887 + if (is_fs_load && !register_filesystem_found) {
83888 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
83889 + ret = -EPERM;
83890 + }
83891 +#endif
83892 +
83893 return ret;
83894 }
83895
83896 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
83897 || s->sh_entsize != ~0UL
83898 || strstarts(sname, ".init"))
83899 continue;
83900 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
83901 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83902 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
83903 + else
83904 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
83905 pr_debug("\t%s\n", sname);
83906 }
83907 - switch (m) {
83908 - case 0: /* executable */
83909 - mod->core_size = debug_align(mod->core_size);
83910 - mod->core_text_size = mod->core_size;
83911 - break;
83912 - case 1: /* RO: text and ro-data */
83913 - mod->core_size = debug_align(mod->core_size);
83914 - mod->core_ro_size = mod->core_size;
83915 - break;
83916 - case 3: /* whole core */
83917 - mod->core_size = debug_align(mod->core_size);
83918 - break;
83919 - }
83920 }
83921
83922 pr_debug("Init section allocation order:\n");
83923 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
83924 || s->sh_entsize != ~0UL
83925 || !strstarts(sname, ".init"))
83926 continue;
83927 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
83928 - | INIT_OFFSET_MASK);
83929 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83930 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
83931 + else
83932 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
83933 + s->sh_entsize |= INIT_OFFSET_MASK;
83934 pr_debug("\t%s\n", sname);
83935 }
83936 - switch (m) {
83937 - case 0: /* executable */
83938 - mod->init_size = debug_align(mod->init_size);
83939 - mod->init_text_size = mod->init_size;
83940 - break;
83941 - case 1: /* RO: text and ro-data */
83942 - mod->init_size = debug_align(mod->init_size);
83943 - mod->init_ro_size = mod->init_size;
83944 - break;
83945 - case 3: /* whole init */
83946 - mod->init_size = debug_align(mod->init_size);
83947 - break;
83948 - }
83949 }
83950 }
83951
83952 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83953
83954 /* Put symbol section at end of init part of module. */
83955 symsect->sh_flags |= SHF_ALLOC;
83956 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
83957 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
83958 info->index.sym) | INIT_OFFSET_MASK;
83959 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
83960
83961 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83962 }
83963
83964 /* Append room for core symbols at end of core part. */
83965 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
83966 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
83967 - mod->core_size += strtab_size;
83968 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
83969 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
83970 + mod->core_size_rx += strtab_size;
83971
83972 /* Put string table section at end of init part of module. */
83973 strsect->sh_flags |= SHF_ALLOC;
83974 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
83975 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
83976 info->index.str) | INIT_OFFSET_MASK;
83977 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
83978 }
83979 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83980 /* Make sure we get permanent strtab: don't use info->strtab. */
83981 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
83982
83983 + pax_open_kernel();
83984 +
83985 /* Set types up while we still have access to sections. */
83986 for (i = 0; i < mod->num_symtab; i++)
83987 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
83988
83989 - mod->core_symtab = dst = mod->module_core + info->symoffs;
83990 - mod->core_strtab = s = mod->module_core + info->stroffs;
83991 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
83992 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
83993 src = mod->symtab;
83994 for (ndst = i = 0; i < mod->num_symtab; i++) {
83995 if (i == 0 ||
83996 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83997 }
83998 }
83999 mod->core_num_syms = ndst;
84000 +
84001 + pax_close_kernel();
84002 }
84003 #else
84004 static inline void layout_symtab(struct module *mod, struct load_info *info)
84005 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
84006 return vmalloc_exec(size);
84007 }
84008
84009 -static void *module_alloc_update_bounds(unsigned long size)
84010 +static void *module_alloc_update_bounds_rw(unsigned long size)
84011 {
84012 void *ret = module_alloc(size);
84013
84014 if (ret) {
84015 mutex_lock(&module_mutex);
84016 /* Update module bounds. */
84017 - if ((unsigned long)ret < module_addr_min)
84018 - module_addr_min = (unsigned long)ret;
84019 - if ((unsigned long)ret + size > module_addr_max)
84020 - module_addr_max = (unsigned long)ret + size;
84021 + if ((unsigned long)ret < module_addr_min_rw)
84022 + module_addr_min_rw = (unsigned long)ret;
84023 + if ((unsigned long)ret + size > module_addr_max_rw)
84024 + module_addr_max_rw = (unsigned long)ret + size;
84025 + mutex_unlock(&module_mutex);
84026 + }
84027 + return ret;
84028 +}
84029 +
84030 +static void *module_alloc_update_bounds_rx(unsigned long size)
84031 +{
84032 + void *ret = module_alloc_exec(size);
84033 +
84034 + if (ret) {
84035 + mutex_lock(&module_mutex);
84036 + /* Update module bounds. */
84037 + if ((unsigned long)ret < module_addr_min_rx)
84038 + module_addr_min_rx = (unsigned long)ret;
84039 + if ((unsigned long)ret + size > module_addr_max_rx)
84040 + module_addr_max_rx = (unsigned long)ret + size;
84041 mutex_unlock(&module_mutex);
84042 }
84043 return ret;
84044 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
84045 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
84046 {
84047 const char *modmagic = get_modinfo(info, "vermagic");
84048 + const char *license = get_modinfo(info, "license");
84049 int err;
84050
84051 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
84052 + if (!license || !license_is_gpl_compatible(license))
84053 + return -ENOEXEC;
84054 +#endif
84055 +
84056 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
84057 modmagic = NULL;
84058
84059 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
84060 }
84061
84062 /* Set up license info based on the info section */
84063 - set_license(mod, get_modinfo(info, "license"));
84064 + set_license(mod, license);
84065
84066 return 0;
84067 }
84068 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
84069 void *ptr;
84070
84071 /* Do the allocs. */
84072 - ptr = module_alloc_update_bounds(mod->core_size);
84073 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
84074 /*
84075 * The pointer to this block is stored in the module structure
84076 * which is inside the block. Just mark it as not being a
84077 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
84078 if (!ptr)
84079 return -ENOMEM;
84080
84081 - memset(ptr, 0, mod->core_size);
84082 - mod->module_core = ptr;
84083 + memset(ptr, 0, mod->core_size_rw);
84084 + mod->module_core_rw = ptr;
84085
84086 - if (mod->init_size) {
84087 - ptr = module_alloc_update_bounds(mod->init_size);
84088 + if (mod->init_size_rw) {
84089 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
84090 /*
84091 * The pointer to this block is stored in the module structure
84092 * which is inside the block. This block doesn't need to be
84093 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
84094 */
84095 kmemleak_ignore(ptr);
84096 if (!ptr) {
84097 - module_free(mod, mod->module_core);
84098 + module_free(mod, mod->module_core_rw);
84099 return -ENOMEM;
84100 }
84101 - memset(ptr, 0, mod->init_size);
84102 - mod->module_init = ptr;
84103 + memset(ptr, 0, mod->init_size_rw);
84104 + mod->module_init_rw = ptr;
84105 } else
84106 - mod->module_init = NULL;
84107 + mod->module_init_rw = NULL;
84108 +
84109 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
84110 + kmemleak_not_leak(ptr);
84111 + if (!ptr) {
84112 + if (mod->module_init_rw)
84113 + module_free(mod, mod->module_init_rw);
84114 + module_free(mod, mod->module_core_rw);
84115 + return -ENOMEM;
84116 + }
84117 +
84118 + pax_open_kernel();
84119 + memset(ptr, 0, mod->core_size_rx);
84120 + pax_close_kernel();
84121 + mod->module_core_rx = ptr;
84122 +
84123 + if (mod->init_size_rx) {
84124 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
84125 + kmemleak_ignore(ptr);
84126 + if (!ptr && mod->init_size_rx) {
84127 + module_free_exec(mod, mod->module_core_rx);
84128 + if (mod->module_init_rw)
84129 + module_free(mod, mod->module_init_rw);
84130 + module_free(mod, mod->module_core_rw);
84131 + return -ENOMEM;
84132 + }
84133 +
84134 + pax_open_kernel();
84135 + memset(ptr, 0, mod->init_size_rx);
84136 + pax_close_kernel();
84137 + mod->module_init_rx = ptr;
84138 + } else
84139 + mod->module_init_rx = NULL;
84140
84141 /* Transfer each section which specifies SHF_ALLOC */
84142 pr_debug("final section addresses:\n");
84143 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
84144 if (!(shdr->sh_flags & SHF_ALLOC))
84145 continue;
84146
84147 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
84148 - dest = mod->module_init
84149 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
84150 - else
84151 - dest = mod->module_core + shdr->sh_entsize;
84152 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
84153 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
84154 + dest = mod->module_init_rw
84155 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
84156 + else
84157 + dest = mod->module_init_rx
84158 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
84159 + } else {
84160 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
84161 + dest = mod->module_core_rw + shdr->sh_entsize;
84162 + else
84163 + dest = mod->module_core_rx + shdr->sh_entsize;
84164 + }
84165 +
84166 + if (shdr->sh_type != SHT_NOBITS) {
84167 +
84168 +#ifdef CONFIG_PAX_KERNEXEC
84169 +#ifdef CONFIG_X86_64
84170 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
84171 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
84172 +#endif
84173 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
84174 + pax_open_kernel();
84175 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
84176 + pax_close_kernel();
84177 + } else
84178 +#endif
84179
84180 - if (shdr->sh_type != SHT_NOBITS)
84181 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
84182 + }
84183 /* Update sh_addr to point to copy in image. */
84184 - shdr->sh_addr = (unsigned long)dest;
84185 +
84186 +#ifdef CONFIG_PAX_KERNEXEC
84187 + if (shdr->sh_flags & SHF_EXECINSTR)
84188 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
84189 + else
84190 +#endif
84191 +
84192 + shdr->sh_addr = (unsigned long)dest;
84193 pr_debug("\t0x%lx %s\n",
84194 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
84195 }
84196 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
84197 * Do it before processing of module parameters, so the module
84198 * can provide parameter accessor functions of its own.
84199 */
84200 - if (mod->module_init)
84201 - flush_icache_range((unsigned long)mod->module_init,
84202 - (unsigned long)mod->module_init
84203 - + mod->init_size);
84204 - flush_icache_range((unsigned long)mod->module_core,
84205 - (unsigned long)mod->module_core + mod->core_size);
84206 + if (mod->module_init_rx)
84207 + flush_icache_range((unsigned long)mod->module_init_rx,
84208 + (unsigned long)mod->module_init_rx
84209 + + mod->init_size_rx);
84210 + flush_icache_range((unsigned long)mod->module_core_rx,
84211 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
84212
84213 set_fs(old_fs);
84214 }
84215 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
84216 static void module_deallocate(struct module *mod, struct load_info *info)
84217 {
84218 percpu_modfree(mod);
84219 - module_free(mod, mod->module_init);
84220 - module_free(mod, mod->module_core);
84221 + module_free_exec(mod, mod->module_init_rx);
84222 + module_free_exec(mod, mod->module_core_rx);
84223 + module_free(mod, mod->module_init_rw);
84224 + module_free(mod, mod->module_core_rw);
84225 }
84226
84227 int __weak module_finalize(const Elf_Ehdr *hdr,
84228 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
84229 static int post_relocation(struct module *mod, const struct load_info *info)
84230 {
84231 /* Sort exception table now relocations are done. */
84232 + pax_open_kernel();
84233 sort_extable(mod->extable, mod->extable + mod->num_exentries);
84234 + pax_close_kernel();
84235
84236 /* Copy relocated percpu area over. */
84237 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
84238 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
84239 MODULE_STATE_COMING, mod);
84240
84241 /* Set RO and NX regions for core */
84242 - set_section_ro_nx(mod->module_core,
84243 - mod->core_text_size,
84244 - mod->core_ro_size,
84245 - mod->core_size);
84246 + set_section_ro_nx(mod->module_core_rx,
84247 + mod->core_size_rx,
84248 + mod->core_size_rx,
84249 + mod->core_size_rx);
84250
84251 /* Set RO and NX regions for init */
84252 - set_section_ro_nx(mod->module_init,
84253 - mod->init_text_size,
84254 - mod->init_ro_size,
84255 - mod->init_size);
84256 + set_section_ro_nx(mod->module_init_rx,
84257 + mod->init_size_rx,
84258 + mod->init_size_rx,
84259 + mod->init_size_rx);
84260
84261 do_mod_ctors(mod);
84262 /* Start the module */
84263 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
84264 mod->strtab = mod->core_strtab;
84265 #endif
84266 unset_module_init_ro_nx(mod);
84267 - module_free(mod, mod->module_init);
84268 - mod->module_init = NULL;
84269 - mod->init_size = 0;
84270 - mod->init_ro_size = 0;
84271 - mod->init_text_size = 0;
84272 + module_free(mod, mod->module_init_rw);
84273 + module_free_exec(mod, mod->module_init_rx);
84274 + mod->module_init_rw = NULL;
84275 + mod->module_init_rx = NULL;
84276 + mod->init_size_rw = 0;
84277 + mod->init_size_rx = 0;
84278 mutex_unlock(&module_mutex);
84279 wake_up_all(&module_wq);
84280
84281 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
84282 if (err)
84283 goto free_unload;
84284
84285 + /* Now copy in args */
84286 + mod->args = strndup_user(uargs, ~0UL >> 1);
84287 + if (IS_ERR(mod->args)) {
84288 + err = PTR_ERR(mod->args);
84289 + goto free_unload;
84290 + }
84291 +
84292 /* Set up MODINFO_ATTR fields */
84293 setup_modinfo(mod, info);
84294
84295 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
84296 + {
84297 + char *p, *p2;
84298 +
84299 + if (strstr(mod->args, "grsec_modharden_netdev")) {
84300 + 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);
84301 + err = -EPERM;
84302 + goto free_modinfo;
84303 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
84304 + p += sizeof("grsec_modharden_normal") - 1;
84305 + p2 = strstr(p, "_");
84306 + if (p2) {
84307 + *p2 = '\0';
84308 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
84309 + *p2 = '_';
84310 + }
84311 + err = -EPERM;
84312 + goto free_modinfo;
84313 + }
84314 + }
84315 +#endif
84316 +
84317 /* Fix up syms, so that st_value is a pointer to location. */
84318 err = simplify_symbols(mod, info);
84319 if (err < 0)
84320 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
84321
84322 flush_module_icache(mod);
84323
84324 - /* Now copy in args */
84325 - mod->args = strndup_user(uargs, ~0UL >> 1);
84326 - if (IS_ERR(mod->args)) {
84327 - err = PTR_ERR(mod->args);
84328 - goto free_arch_cleanup;
84329 - }
84330 -
84331 dynamic_debug_setup(info->debug, info->num_debug);
84332
84333 /* Finally it's fully formed, ready to start executing. */
84334 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
84335 ddebug_cleanup:
84336 dynamic_debug_remove(info->debug);
84337 synchronize_sched();
84338 - kfree(mod->args);
84339 - free_arch_cleanup:
84340 module_arch_cleanup(mod);
84341 free_modinfo:
84342 free_modinfo(mod);
84343 + kfree(mod->args);
84344 free_unload:
84345 module_unload_free(mod);
84346 unlink_mod:
84347 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
84348 unsigned long nextval;
84349
84350 /* At worse, next value is at end of module */
84351 - if (within_module_init(addr, mod))
84352 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
84353 + if (within_module_init_rx(addr, mod))
84354 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
84355 + else if (within_module_init_rw(addr, mod))
84356 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
84357 + else if (within_module_core_rx(addr, mod))
84358 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
84359 + else if (within_module_core_rw(addr, mod))
84360 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
84361 else
84362 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
84363 + return NULL;
84364
84365 /* Scan for closest preceding symbol, and next symbol. (ELF
84366 starts real symbols at 1). */
84367 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
84368 return 0;
84369
84370 seq_printf(m, "%s %u",
84371 - mod->name, mod->init_size + mod->core_size);
84372 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
84373 print_unload_info(m, mod);
84374
84375 /* Informative for users. */
84376 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
84377 mod->state == MODULE_STATE_COMING ? "Loading":
84378 "Live");
84379 /* Used by oprofile and other similar tools. */
84380 - seq_printf(m, " 0x%pK", mod->module_core);
84381 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
84382
84383 /* Taints info */
84384 if (mod->taints)
84385 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
84386
84387 static int __init proc_modules_init(void)
84388 {
84389 +#ifndef CONFIG_GRKERNSEC_HIDESYM
84390 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84391 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
84392 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84393 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
84394 +#else
84395 proc_create("modules", 0, NULL, &proc_modules_operations);
84396 +#endif
84397 +#else
84398 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
84399 +#endif
84400 return 0;
84401 }
84402 module_init(proc_modules_init);
84403 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
84404 {
84405 struct module *mod;
84406
84407 - if (addr < module_addr_min || addr > module_addr_max)
84408 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
84409 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
84410 return NULL;
84411
84412 list_for_each_entry_rcu(mod, &modules, list) {
84413 if (mod->state == MODULE_STATE_UNFORMED)
84414 continue;
84415 - if (within_module_core(addr, mod)
84416 - || within_module_init(addr, mod))
84417 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
84418 return mod;
84419 }
84420 return NULL;
84421 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
84422 */
84423 struct module *__module_text_address(unsigned long addr)
84424 {
84425 - struct module *mod = __module_address(addr);
84426 + struct module *mod;
84427 +
84428 +#ifdef CONFIG_X86_32
84429 + addr = ktla_ktva(addr);
84430 +#endif
84431 +
84432 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
84433 + return NULL;
84434 +
84435 + mod = __module_address(addr);
84436 +
84437 if (mod) {
84438 /* Make sure it's within the text section. */
84439 - if (!within(addr, mod->module_init, mod->init_text_size)
84440 - && !within(addr, mod->module_core, mod->core_text_size))
84441 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
84442 mod = NULL;
84443 }
84444 return mod;
84445 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
84446 index 7e3443f..b2a1e6b 100644
84447 --- a/kernel/mutex-debug.c
84448 +++ b/kernel/mutex-debug.c
84449 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
84450 }
84451
84452 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84453 - struct thread_info *ti)
84454 + struct task_struct *task)
84455 {
84456 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
84457
84458 /* Mark the current thread as blocked on the lock: */
84459 - ti->task->blocked_on = waiter;
84460 + task->blocked_on = waiter;
84461 }
84462
84463 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84464 - struct thread_info *ti)
84465 + struct task_struct *task)
84466 {
84467 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
84468 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
84469 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
84470 - ti->task->blocked_on = NULL;
84471 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
84472 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
84473 + task->blocked_on = NULL;
84474
84475 list_del_init(&waiter->list);
84476 waiter->task = NULL;
84477 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
84478 index 0799fd3..d06ae3b 100644
84479 --- a/kernel/mutex-debug.h
84480 +++ b/kernel/mutex-debug.h
84481 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
84482 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
84483 extern void debug_mutex_add_waiter(struct mutex *lock,
84484 struct mutex_waiter *waiter,
84485 - struct thread_info *ti);
84486 + struct task_struct *task);
84487 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84488 - struct thread_info *ti);
84489 + struct task_struct *task);
84490 extern void debug_mutex_unlock(struct mutex *lock);
84491 extern void debug_mutex_init(struct mutex *lock, const char *name,
84492 struct lock_class_key *key);
84493 diff --git a/kernel/mutex.c b/kernel/mutex.c
84494 index d24105b..15648eb 100644
84495 --- a/kernel/mutex.c
84496 +++ b/kernel/mutex.c
84497 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
84498 node->locked = 1;
84499 return;
84500 }
84501 - ACCESS_ONCE(prev->next) = node;
84502 + ACCESS_ONCE_RW(prev->next) = node;
84503 smp_wmb();
84504 /* Wait until the lock holder passes the lock down */
84505 while (!ACCESS_ONCE(node->locked))
84506 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
84507 while (!(next = ACCESS_ONCE(node->next)))
84508 arch_mutex_cpu_relax();
84509 }
84510 - ACCESS_ONCE(next->locked) = 1;
84511 + ACCESS_ONCE_RW(next->locked) = 1;
84512 smp_wmb();
84513 }
84514
84515 @@ -520,7 +520,7 @@ slowpath:
84516 goto skip_wait;
84517
84518 debug_mutex_lock_common(lock, &waiter);
84519 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
84520 + debug_mutex_add_waiter(lock, &waiter, task);
84521
84522 /* add waiting tasks to the end of the waitqueue (FIFO): */
84523 list_add_tail(&waiter.list, &lock->wait_list);
84524 @@ -564,7 +564,7 @@ slowpath:
84525 schedule_preempt_disabled();
84526 spin_lock_mutex(&lock->wait_lock, flags);
84527 }
84528 - mutex_remove_waiter(lock, &waiter, current_thread_info());
84529 + mutex_remove_waiter(lock, &waiter, task);
84530 /* set it to 0 if there are no waiters left: */
84531 if (likely(list_empty(&lock->wait_list)))
84532 atomic_set(&lock->count, 0);
84533 @@ -601,7 +601,7 @@ skip_wait:
84534 return 0;
84535
84536 err:
84537 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
84538 + mutex_remove_waiter(lock, &waiter, task);
84539 spin_unlock_mutex(&lock->wait_lock, flags);
84540 debug_mutex_free_waiter(&waiter);
84541 mutex_release(&lock->dep_map, 1, ip);
84542 diff --git a/kernel/notifier.c b/kernel/notifier.c
84543 index 2d5cc4c..d9ea600 100644
84544 --- a/kernel/notifier.c
84545 +++ b/kernel/notifier.c
84546 @@ -5,6 +5,7 @@
84547 #include <linux/rcupdate.h>
84548 #include <linux/vmalloc.h>
84549 #include <linux/reboot.h>
84550 +#include <linux/mm.h>
84551
84552 /*
84553 * Notifier list for kernel code which wants to be called
84554 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
84555 while ((*nl) != NULL) {
84556 if (n->priority > (*nl)->priority)
84557 break;
84558 - nl = &((*nl)->next);
84559 + nl = (struct notifier_block **)&((*nl)->next);
84560 }
84561 - n->next = *nl;
84562 + pax_open_kernel();
84563 + *(const void **)&n->next = *nl;
84564 rcu_assign_pointer(*nl, n);
84565 + pax_close_kernel();
84566 return 0;
84567 }
84568
84569 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
84570 return 0;
84571 if (n->priority > (*nl)->priority)
84572 break;
84573 - nl = &((*nl)->next);
84574 + nl = (struct notifier_block **)&((*nl)->next);
84575 }
84576 - n->next = *nl;
84577 + pax_open_kernel();
84578 + *(const void **)&n->next = *nl;
84579 rcu_assign_pointer(*nl, n);
84580 + pax_close_kernel();
84581 return 0;
84582 }
84583
84584 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
84585 {
84586 while ((*nl) != NULL) {
84587 if ((*nl) == n) {
84588 + pax_open_kernel();
84589 rcu_assign_pointer(*nl, n->next);
84590 + pax_close_kernel();
84591 return 0;
84592 }
84593 - nl = &((*nl)->next);
84594 + nl = (struct notifier_block **)&((*nl)->next);
84595 }
84596 return -ENOENT;
84597 }
84598 diff --git a/kernel/panic.c b/kernel/panic.c
84599 index b6c482c..5578061 100644
84600 --- a/kernel/panic.c
84601 +++ b/kernel/panic.c
84602 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
84603 disable_trace_on_warning();
84604
84605 pr_warn("------------[ cut here ]------------\n");
84606 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
84607 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
84608 raw_smp_processor_id(), current->pid, file, line, caller);
84609
84610 if (args)
84611 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
84612 */
84613 void __stack_chk_fail(void)
84614 {
84615 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
84616 + dump_stack();
84617 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
84618 __builtin_return_address(0));
84619 }
84620 EXPORT_SYMBOL(__stack_chk_fail);
84621 diff --git a/kernel/pid.c b/kernel/pid.c
84622 index 9b9a266..c20ef80 100644
84623 --- a/kernel/pid.c
84624 +++ b/kernel/pid.c
84625 @@ -33,6 +33,7 @@
84626 #include <linux/rculist.h>
84627 #include <linux/bootmem.h>
84628 #include <linux/hash.h>
84629 +#include <linux/security.h>
84630 #include <linux/pid_namespace.h>
84631 #include <linux/init_task.h>
84632 #include <linux/syscalls.h>
84633 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
84634
84635 int pid_max = PID_MAX_DEFAULT;
84636
84637 -#define RESERVED_PIDS 300
84638 +#define RESERVED_PIDS 500
84639
84640 int pid_max_min = RESERVED_PIDS + 1;
84641 int pid_max_max = PID_MAX_LIMIT;
84642 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
84643 */
84644 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
84645 {
84646 + struct task_struct *task;
84647 +
84648 rcu_lockdep_assert(rcu_read_lock_held(),
84649 "find_task_by_pid_ns() needs rcu_read_lock()"
84650 " protection");
84651 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84652 +
84653 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84654 +
84655 + if (gr_pid_is_chrooted(task))
84656 + return NULL;
84657 +
84658 + return task;
84659 }
84660
84661 struct task_struct *find_task_by_vpid(pid_t vnr)
84662 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
84663 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
84664 }
84665
84666 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
84667 +{
84668 + rcu_lockdep_assert(rcu_read_lock_held(),
84669 + "find_task_by_pid_ns() needs rcu_read_lock()"
84670 + " protection");
84671 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
84672 +}
84673 +
84674 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
84675 {
84676 struct pid *pid;
84677 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
84678 index 4208655..19f36a5 100644
84679 --- a/kernel/pid_namespace.c
84680 +++ b/kernel/pid_namespace.c
84681 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
84682 void __user *buffer, size_t *lenp, loff_t *ppos)
84683 {
84684 struct pid_namespace *pid_ns = task_active_pid_ns(current);
84685 - struct ctl_table tmp = *table;
84686 + ctl_table_no_const tmp = *table;
84687
84688 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
84689 return -EPERM;
84690 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
84691 index c7f31aa..2b44977 100644
84692 --- a/kernel/posix-cpu-timers.c
84693 +++ b/kernel/posix-cpu-timers.c
84694 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
84695
84696 static __init int init_posix_cpu_timers(void)
84697 {
84698 - struct k_clock process = {
84699 + static struct k_clock process = {
84700 .clock_getres = process_cpu_clock_getres,
84701 .clock_get = process_cpu_clock_get,
84702 .timer_create = process_cpu_timer_create,
84703 .nsleep = process_cpu_nsleep,
84704 .nsleep_restart = process_cpu_nsleep_restart,
84705 };
84706 - struct k_clock thread = {
84707 + static struct k_clock thread = {
84708 .clock_getres = thread_cpu_clock_getres,
84709 .clock_get = thread_cpu_clock_get,
84710 .timer_create = thread_cpu_timer_create,
84711 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
84712 index 424c2d4..679242f 100644
84713 --- a/kernel/posix-timers.c
84714 +++ b/kernel/posix-timers.c
84715 @@ -43,6 +43,7 @@
84716 #include <linux/hash.h>
84717 #include <linux/posix-clock.h>
84718 #include <linux/posix-timers.h>
84719 +#include <linux/grsecurity.h>
84720 #include <linux/syscalls.h>
84721 #include <linux/wait.h>
84722 #include <linux/workqueue.h>
84723 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
84724 * which we beg off on and pass to do_sys_settimeofday().
84725 */
84726
84727 -static struct k_clock posix_clocks[MAX_CLOCKS];
84728 +static struct k_clock *posix_clocks[MAX_CLOCKS];
84729
84730 /*
84731 * These ones are defined below.
84732 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
84733 */
84734 static __init int init_posix_timers(void)
84735 {
84736 - struct k_clock clock_realtime = {
84737 + static struct k_clock clock_realtime = {
84738 .clock_getres = hrtimer_get_res,
84739 .clock_get = posix_clock_realtime_get,
84740 .clock_set = posix_clock_realtime_set,
84741 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
84742 .timer_get = common_timer_get,
84743 .timer_del = common_timer_del,
84744 };
84745 - struct k_clock clock_monotonic = {
84746 + static struct k_clock clock_monotonic = {
84747 .clock_getres = hrtimer_get_res,
84748 .clock_get = posix_ktime_get_ts,
84749 .nsleep = common_nsleep,
84750 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
84751 .timer_get = common_timer_get,
84752 .timer_del = common_timer_del,
84753 };
84754 - struct k_clock clock_monotonic_raw = {
84755 + static struct k_clock clock_monotonic_raw = {
84756 .clock_getres = hrtimer_get_res,
84757 .clock_get = posix_get_monotonic_raw,
84758 };
84759 - struct k_clock clock_realtime_coarse = {
84760 + static struct k_clock clock_realtime_coarse = {
84761 .clock_getres = posix_get_coarse_res,
84762 .clock_get = posix_get_realtime_coarse,
84763 };
84764 - struct k_clock clock_monotonic_coarse = {
84765 + static struct k_clock clock_monotonic_coarse = {
84766 .clock_getres = posix_get_coarse_res,
84767 .clock_get = posix_get_monotonic_coarse,
84768 };
84769 - struct k_clock clock_tai = {
84770 + static struct k_clock clock_tai = {
84771 .clock_getres = hrtimer_get_res,
84772 .clock_get = posix_get_tai,
84773 .nsleep = common_nsleep,
84774 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
84775 .timer_get = common_timer_get,
84776 .timer_del = common_timer_del,
84777 };
84778 - struct k_clock clock_boottime = {
84779 + static struct k_clock clock_boottime = {
84780 .clock_getres = hrtimer_get_res,
84781 .clock_get = posix_get_boottime,
84782 .nsleep = common_nsleep,
84783 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
84784 return;
84785 }
84786
84787 - posix_clocks[clock_id] = *new_clock;
84788 + posix_clocks[clock_id] = new_clock;
84789 }
84790 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
84791
84792 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
84793 return (id & CLOCKFD_MASK) == CLOCKFD ?
84794 &clock_posix_dynamic : &clock_posix_cpu;
84795
84796 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
84797 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
84798 return NULL;
84799 - return &posix_clocks[id];
84800 + return posix_clocks[id];
84801 }
84802
84803 static int common_timer_create(struct k_itimer *new_timer)
84804 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
84805 struct k_clock *kc = clockid_to_kclock(which_clock);
84806 struct k_itimer *new_timer;
84807 int error, new_timer_id;
84808 - sigevent_t event;
84809 + sigevent_t event = { };
84810 int it_id_set = IT_ID_NOT_SET;
84811
84812 if (!kc)
84813 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
84814 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
84815 return -EFAULT;
84816
84817 + /* only the CLOCK_REALTIME clock can be set, all other clocks
84818 + have their clock_set fptr set to a nosettime dummy function
84819 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
84820 + call common_clock_set, which calls do_sys_settimeofday, which
84821 + we hook
84822 + */
84823 +
84824 return kc->clock_set(which_clock, &new_tp);
84825 }
84826
84827 diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
84828 index d444c4e..bc3de51 100644
84829 --- a/kernel/power/Kconfig
84830 +++ b/kernel/power/Kconfig
84831 @@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
84832 config HIBERNATION
84833 bool "Hibernation (aka 'suspend to disk')"
84834 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
84835 + depends on !GRKERNSEC_KMEM
84836 + depends on !PAX_MEMORY_SANITIZE
84837 select HIBERNATE_CALLBACKS
84838 select LZO_COMPRESS
84839 select LZO_DECOMPRESS
84840 diff --git a/kernel/power/process.c b/kernel/power/process.c
84841 index 06ec886..9dba35e 100644
84842 --- a/kernel/power/process.c
84843 +++ b/kernel/power/process.c
84844 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
84845 unsigned int elapsed_msecs;
84846 bool wakeup = false;
84847 int sleep_usecs = USEC_PER_MSEC;
84848 + bool timedout = false;
84849
84850 do_gettimeofday(&start);
84851
84852 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
84853
84854 while (true) {
84855 todo = 0;
84856 + if (time_after(jiffies, end_time))
84857 + timedout = true;
84858 read_lock(&tasklist_lock);
84859 do_each_thread(g, p) {
84860 if (p == current || !freeze_task(p))
84861 continue;
84862
84863 - if (!freezer_should_skip(p))
84864 + if (!freezer_should_skip(p)) {
84865 todo++;
84866 + if (timedout) {
84867 + printk(KERN_ERR "Task refusing to freeze:\n");
84868 + sched_show_task(p);
84869 + }
84870 + }
84871 } while_each_thread(g, p);
84872 read_unlock(&tasklist_lock);
84873
84874 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
84875 todo += wq_busy;
84876 }
84877
84878 - if (!todo || time_after(jiffies, end_time))
84879 + if (!todo || timedout)
84880 break;
84881
84882 if (pm_wakeup_pending()) {
84883 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
84884 index b4e8500..b457a6c 100644
84885 --- a/kernel/printk/printk.c
84886 +++ b/kernel/printk/printk.c
84887 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
84888 if (from_file && type != SYSLOG_ACTION_OPEN)
84889 return 0;
84890
84891 +#ifdef CONFIG_GRKERNSEC_DMESG
84892 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
84893 + return -EPERM;
84894 +#endif
84895 +
84896 if (syslog_action_restricted(type)) {
84897 if (capable(CAP_SYSLOG))
84898 return 0;
84899 diff --git a/kernel/profile.c b/kernel/profile.c
84900 index 6631e1e..310c266 100644
84901 --- a/kernel/profile.c
84902 +++ b/kernel/profile.c
84903 @@ -37,7 +37,7 @@ struct profile_hit {
84904 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
84905 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
84906
84907 -static atomic_t *prof_buffer;
84908 +static atomic_unchecked_t *prof_buffer;
84909 static unsigned long prof_len, prof_shift;
84910
84911 int prof_on __read_mostly;
84912 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
84913 hits[i].pc = 0;
84914 continue;
84915 }
84916 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84917 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84918 hits[i].hits = hits[i].pc = 0;
84919 }
84920 }
84921 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84922 * Add the current hit(s) and flush the write-queue out
84923 * to the global buffer:
84924 */
84925 - atomic_add(nr_hits, &prof_buffer[pc]);
84926 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
84927 for (i = 0; i < NR_PROFILE_HIT; ++i) {
84928 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84929 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84930 hits[i].pc = hits[i].hits = 0;
84931 }
84932 out:
84933 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84934 {
84935 unsigned long pc;
84936 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
84937 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84938 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84939 }
84940 #endif /* !CONFIG_SMP */
84941
84942 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
84943 return -EFAULT;
84944 buf++; p++; count--; read++;
84945 }
84946 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
84947 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
84948 if (copy_to_user(buf, (void *)pnt, count))
84949 return -EFAULT;
84950 read += count;
84951 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
84952 }
84953 #endif
84954 profile_discard_flip_buffers();
84955 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
84956 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
84957 return count;
84958 }
84959
84960 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
84961 index 1f4bcb3..99cf7ab 100644
84962 --- a/kernel/ptrace.c
84963 +++ b/kernel/ptrace.c
84964 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
84965 if (seize)
84966 flags |= PT_SEIZED;
84967 rcu_read_lock();
84968 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84969 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84970 flags |= PT_PTRACE_CAP;
84971 rcu_read_unlock();
84972 task->ptrace = flags;
84973 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
84974 break;
84975 return -EIO;
84976 }
84977 - if (copy_to_user(dst, buf, retval))
84978 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
84979 return -EFAULT;
84980 copied += retval;
84981 src += retval;
84982 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
84983 bool seized = child->ptrace & PT_SEIZED;
84984 int ret = -EIO;
84985 siginfo_t siginfo, *si;
84986 - void __user *datavp = (void __user *) data;
84987 + void __user *datavp = (__force void __user *) data;
84988 unsigned long __user *datalp = datavp;
84989 unsigned long flags;
84990
84991 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
84992 goto out;
84993 }
84994
84995 + if (gr_handle_ptrace(child, request)) {
84996 + ret = -EPERM;
84997 + goto out_put_task_struct;
84998 + }
84999 +
85000 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
85001 ret = ptrace_attach(child, request, addr, data);
85002 /*
85003 * Some architectures need to do book-keeping after
85004 * a ptrace attach.
85005 */
85006 - if (!ret)
85007 + if (!ret) {
85008 arch_ptrace_attach(child);
85009 + gr_audit_ptrace(child);
85010 + }
85011 goto out_put_task_struct;
85012 }
85013
85014 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
85015 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
85016 if (copied != sizeof(tmp))
85017 return -EIO;
85018 - return put_user(tmp, (unsigned long __user *)data);
85019 + return put_user(tmp, (__force unsigned long __user *)data);
85020 }
85021
85022 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
85023 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
85024 }
85025
85026 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
85027 - compat_long_t addr, compat_long_t data)
85028 + compat_ulong_t addr, compat_ulong_t data)
85029 {
85030 struct task_struct *child;
85031 long ret;
85032 @@ -1197,14 +1204,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
85033 goto out;
85034 }
85035
85036 + if (gr_handle_ptrace(child, request)) {
85037 + ret = -EPERM;
85038 + goto out_put_task_struct;
85039 + }
85040 +
85041 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
85042 ret = ptrace_attach(child, request, addr, data);
85043 /*
85044 * Some architectures need to do book-keeping after
85045 * a ptrace attach.
85046 */
85047 - if (!ret)
85048 + if (!ret) {
85049 arch_ptrace_attach(child);
85050 + gr_audit_ptrace(child);
85051 + }
85052 goto out_put_task_struct;
85053 }
85054
85055 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
85056 index b02a339..ce2d20c 100644
85057 --- a/kernel/rcupdate.c
85058 +++ b/kernel/rcupdate.c
85059 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
85060 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
85061 */
85062 if (till_stall_check < 3) {
85063 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
85064 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
85065 till_stall_check = 3;
85066 } else if (till_stall_check > 300) {
85067 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
85068 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
85069 till_stall_check = 300;
85070 }
85071 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
85072 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
85073 index 9ed6075..c9e8a63 100644
85074 --- a/kernel/rcutiny.c
85075 +++ b/kernel/rcutiny.c
85076 @@ -45,7 +45,7 @@
85077 /* Forward declarations for rcutiny_plugin.h. */
85078 struct rcu_ctrlblk;
85079 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
85080 -static void rcu_process_callbacks(struct softirq_action *unused);
85081 +static void rcu_process_callbacks(void);
85082 static void __call_rcu(struct rcu_head *head,
85083 void (*func)(struct rcu_head *rcu),
85084 struct rcu_ctrlblk *rcp);
85085 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
85086 false));
85087 }
85088
85089 -static void rcu_process_callbacks(struct softirq_action *unused)
85090 +static __latent_entropy void rcu_process_callbacks(void)
85091 {
85092 __rcu_process_callbacks(&rcu_sched_ctrlblk);
85093 __rcu_process_callbacks(&rcu_bh_ctrlblk);
85094 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
85095 index be63101..05cf721 100644
85096 --- a/kernel/rcutorture.c
85097 +++ b/kernel/rcutorture.c
85098 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
85099 { 0 };
85100 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
85101 { 0 };
85102 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
85103 -static atomic_t n_rcu_torture_alloc;
85104 -static atomic_t n_rcu_torture_alloc_fail;
85105 -static atomic_t n_rcu_torture_free;
85106 -static atomic_t n_rcu_torture_mberror;
85107 -static atomic_t n_rcu_torture_error;
85108 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
85109 +static atomic_unchecked_t n_rcu_torture_alloc;
85110 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
85111 +static atomic_unchecked_t n_rcu_torture_free;
85112 +static atomic_unchecked_t n_rcu_torture_mberror;
85113 +static atomic_unchecked_t n_rcu_torture_error;
85114 static long n_rcu_torture_barrier_error;
85115 static long n_rcu_torture_boost_ktrerror;
85116 static long n_rcu_torture_boost_rterror;
85117 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
85118
85119 spin_lock_bh(&rcu_torture_lock);
85120 if (list_empty(&rcu_torture_freelist)) {
85121 - atomic_inc(&n_rcu_torture_alloc_fail);
85122 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
85123 spin_unlock_bh(&rcu_torture_lock);
85124 return NULL;
85125 }
85126 - atomic_inc(&n_rcu_torture_alloc);
85127 + atomic_inc_unchecked(&n_rcu_torture_alloc);
85128 p = rcu_torture_freelist.next;
85129 list_del_init(p);
85130 spin_unlock_bh(&rcu_torture_lock);
85131 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
85132 static void
85133 rcu_torture_free(struct rcu_torture *p)
85134 {
85135 - atomic_inc(&n_rcu_torture_free);
85136 + atomic_inc_unchecked(&n_rcu_torture_free);
85137 spin_lock_bh(&rcu_torture_lock);
85138 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
85139 spin_unlock_bh(&rcu_torture_lock);
85140 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
85141 i = rp->rtort_pipe_count;
85142 if (i > RCU_TORTURE_PIPE_LEN)
85143 i = RCU_TORTURE_PIPE_LEN;
85144 - atomic_inc(&rcu_torture_wcount[i]);
85145 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
85146 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
85147 rp->rtort_mbtest = 0;
85148 rcu_torture_free(rp);
85149 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
85150 i = old_rp->rtort_pipe_count;
85151 if (i > RCU_TORTURE_PIPE_LEN)
85152 i = RCU_TORTURE_PIPE_LEN;
85153 - atomic_inc(&rcu_torture_wcount[i]);
85154 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
85155 old_rp->rtort_pipe_count++;
85156 if (gp_normal == gp_exp)
85157 exp = !!(rcu_random(&rand) & 0x80);
85158 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
85159 i = rp->rtort_pipe_count;
85160 if (i > RCU_TORTURE_PIPE_LEN)
85161 i = RCU_TORTURE_PIPE_LEN;
85162 - atomic_inc(&rcu_torture_wcount[i]);
85163 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
85164 if (++rp->rtort_pipe_count >=
85165 RCU_TORTURE_PIPE_LEN) {
85166 rp->rtort_mbtest = 0;
85167 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
85168 return;
85169 }
85170 if (p->rtort_mbtest == 0)
85171 - atomic_inc(&n_rcu_torture_mberror);
85172 + atomic_inc_unchecked(&n_rcu_torture_mberror);
85173 spin_lock(&rand_lock);
85174 cur_ops->read_delay(&rand);
85175 n_rcu_torture_timers++;
85176 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
85177 continue;
85178 }
85179 if (p->rtort_mbtest == 0)
85180 - atomic_inc(&n_rcu_torture_mberror);
85181 + atomic_inc_unchecked(&n_rcu_torture_mberror);
85182 cur_ops->read_delay(&rand);
85183 preempt_disable();
85184 pipe_count = p->rtort_pipe_count;
85185 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
85186 rcu_torture_current,
85187 rcu_torture_current_version,
85188 list_empty(&rcu_torture_freelist),
85189 - atomic_read(&n_rcu_torture_alloc),
85190 - atomic_read(&n_rcu_torture_alloc_fail),
85191 - atomic_read(&n_rcu_torture_free));
85192 + atomic_read_unchecked(&n_rcu_torture_alloc),
85193 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
85194 + atomic_read_unchecked(&n_rcu_torture_free));
85195 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
85196 - atomic_read(&n_rcu_torture_mberror),
85197 + atomic_read_unchecked(&n_rcu_torture_mberror),
85198 n_rcu_torture_boost_ktrerror,
85199 n_rcu_torture_boost_rterror);
85200 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
85201 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
85202 n_barrier_attempts,
85203 n_rcu_torture_barrier_error);
85204 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
85205 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
85206 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
85207 n_rcu_torture_barrier_error != 0 ||
85208 n_rcu_torture_boost_ktrerror != 0 ||
85209 n_rcu_torture_boost_rterror != 0 ||
85210 n_rcu_torture_boost_failure != 0 ||
85211 i > 1) {
85212 cnt += sprintf(&page[cnt], "!!! ");
85213 - atomic_inc(&n_rcu_torture_error);
85214 + atomic_inc_unchecked(&n_rcu_torture_error);
85215 WARN_ON_ONCE(1);
85216 }
85217 cnt += sprintf(&page[cnt], "Reader Pipe: ");
85218 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
85219 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
85220 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
85221 cnt += sprintf(&page[cnt], " %d",
85222 - atomic_read(&rcu_torture_wcount[i]));
85223 + atomic_read_unchecked(&rcu_torture_wcount[i]));
85224 }
85225 cnt += sprintf(&page[cnt], "\n");
85226 if (cur_ops->stats)
85227 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
85228
85229 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
85230
85231 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
85232 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
85233 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
85234 else if (n_online_successes != n_online_attempts ||
85235 n_offline_successes != n_offline_attempts)
85236 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
85237
85238 rcu_torture_current = NULL;
85239 rcu_torture_current_version = 0;
85240 - atomic_set(&n_rcu_torture_alloc, 0);
85241 - atomic_set(&n_rcu_torture_alloc_fail, 0);
85242 - atomic_set(&n_rcu_torture_free, 0);
85243 - atomic_set(&n_rcu_torture_mberror, 0);
85244 - atomic_set(&n_rcu_torture_error, 0);
85245 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
85246 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
85247 + atomic_set_unchecked(&n_rcu_torture_free, 0);
85248 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
85249 + atomic_set_unchecked(&n_rcu_torture_error, 0);
85250 n_rcu_torture_barrier_error = 0;
85251 n_rcu_torture_boost_ktrerror = 0;
85252 n_rcu_torture_boost_rterror = 0;
85253 n_rcu_torture_boost_failure = 0;
85254 n_rcu_torture_boosts = 0;
85255 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
85256 - atomic_set(&rcu_torture_wcount[i], 0);
85257 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
85258 for_each_possible_cpu(cpu) {
85259 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
85260 per_cpu(rcu_torture_count, cpu)[i] = 0;
85261 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
85262 index 32618b3..c1fb822 100644
85263 --- a/kernel/rcutree.c
85264 +++ b/kernel/rcutree.c
85265 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
85266 rcu_prepare_for_idle(smp_processor_id());
85267 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
85268 smp_mb__before_atomic_inc(); /* See above. */
85269 - atomic_inc(&rdtp->dynticks);
85270 + atomic_inc_unchecked(&rdtp->dynticks);
85271 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
85272 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
85273 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
85274
85275 /*
85276 * It is illegal to enter an extended quiescent state while
85277 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
85278 int user)
85279 {
85280 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
85281 - atomic_inc(&rdtp->dynticks);
85282 + atomic_inc_unchecked(&rdtp->dynticks);
85283 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
85284 smp_mb__after_atomic_inc(); /* See above. */
85285 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
85286 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
85287 rcu_cleanup_after_idle(smp_processor_id());
85288 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
85289 if (!user && !is_idle_task(current)) {
85290 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
85291 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
85292
85293 if (rdtp->dynticks_nmi_nesting == 0 &&
85294 - (atomic_read(&rdtp->dynticks) & 0x1))
85295 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
85296 return;
85297 rdtp->dynticks_nmi_nesting++;
85298 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
85299 - atomic_inc(&rdtp->dynticks);
85300 + atomic_inc_unchecked(&rdtp->dynticks);
85301 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
85302 smp_mb__after_atomic_inc(); /* See above. */
85303 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
85304 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
85305 }
85306
85307 /**
85308 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
85309 return;
85310 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
85311 smp_mb__before_atomic_inc(); /* See above. */
85312 - atomic_inc(&rdtp->dynticks);
85313 + atomic_inc_unchecked(&rdtp->dynticks);
85314 smp_mb__after_atomic_inc(); /* Force delay to next write. */
85315 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
85316 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
85317 }
85318
85319 /**
85320 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
85321 int ret;
85322
85323 preempt_disable();
85324 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
85325 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
85326 preempt_enable();
85327 return ret;
85328 }
85329 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
85330 static int dyntick_save_progress_counter(struct rcu_data *rdp,
85331 bool *isidle, unsigned long *maxj)
85332 {
85333 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
85334 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
85335 rcu_sysidle_check_cpu(rdp, isidle, maxj);
85336 return (rdp->dynticks_snap & 0x1) == 0;
85337 }
85338 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
85339 unsigned int curr;
85340 unsigned int snap;
85341
85342 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
85343 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
85344 snap = (unsigned int)rdp->dynticks_snap;
85345
85346 /*
85347 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
85348 rdp = this_cpu_ptr(rsp->rda);
85349 rcu_preempt_check_blocked_tasks(rnp);
85350 rnp->qsmask = rnp->qsmaskinit;
85351 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
85352 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
85353 WARN_ON_ONCE(rnp->completed != rsp->completed);
85354 - ACCESS_ONCE(rnp->completed) = rsp->completed;
85355 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
85356 if (rnp == rdp->mynode)
85357 __note_gp_changes(rsp, rnp, rdp);
85358 rcu_preempt_boost_start_gp(rnp);
85359 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
85360 */
85361 rcu_for_each_node_breadth_first(rsp, rnp) {
85362 raw_spin_lock_irq(&rnp->lock);
85363 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
85364 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
85365 rdp = this_cpu_ptr(rsp->rda);
85366 if (rnp == rdp->mynode)
85367 __note_gp_changes(rsp, rnp, rdp);
85368 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
85369 rsp->qlen += rdp->qlen;
85370 rdp->n_cbs_orphaned += rdp->qlen;
85371 rdp->qlen_lazy = 0;
85372 - ACCESS_ONCE(rdp->qlen) = 0;
85373 + ACCESS_ONCE_RW(rdp->qlen) = 0;
85374 }
85375
85376 /*
85377 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
85378 }
85379 smp_mb(); /* List handling before counting for rcu_barrier(). */
85380 rdp->qlen_lazy -= count_lazy;
85381 - ACCESS_ONCE(rdp->qlen) -= count;
85382 + ACCESS_ONCE_RW(rdp->qlen) -= count;
85383 rdp->n_cbs_invoked += count;
85384
85385 /* Reinstate batch limit if we have worked down the excess. */
85386 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
85387 /*
85388 * Do RCU core processing for the current CPU.
85389 */
85390 -static void rcu_process_callbacks(struct softirq_action *unused)
85391 +static __latent_entropy void rcu_process_callbacks(void)
85392 {
85393 struct rcu_state *rsp;
85394
85395 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
85396 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
85397 if (debug_rcu_head_queue(head)) {
85398 /* Probable double call_rcu(), so leak the callback. */
85399 - ACCESS_ONCE(head->func) = rcu_leak_callback;
85400 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
85401 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
85402 return;
85403 }
85404 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
85405 local_irq_restore(flags);
85406 return;
85407 }
85408 - ACCESS_ONCE(rdp->qlen)++;
85409 + ACCESS_ONCE_RW(rdp->qlen)++;
85410 if (lazy)
85411 rdp->qlen_lazy++;
85412 else
85413 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
85414 * counter wrap on a 32-bit system. Quite a few more CPUs would of
85415 * course be required on a 64-bit system.
85416 */
85417 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
85418 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
85419 (ulong)atomic_long_read(&rsp->expedited_done) +
85420 ULONG_MAX / 8)) {
85421 synchronize_sched();
85422 - atomic_long_inc(&rsp->expedited_wrap);
85423 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
85424 return;
85425 }
85426
85427 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
85428 * Take a ticket. Note that atomic_inc_return() implies a
85429 * full memory barrier.
85430 */
85431 - snap = atomic_long_inc_return(&rsp->expedited_start);
85432 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
85433 firstsnap = snap;
85434 get_online_cpus();
85435 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
85436 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
85437 synchronize_sched_expedited_cpu_stop,
85438 NULL) == -EAGAIN) {
85439 put_online_cpus();
85440 - atomic_long_inc(&rsp->expedited_tryfail);
85441 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
85442
85443 /* Check to see if someone else did our work for us. */
85444 s = atomic_long_read(&rsp->expedited_done);
85445 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
85446 /* ensure test happens before caller kfree */
85447 smp_mb__before_atomic_inc(); /* ^^^ */
85448 - atomic_long_inc(&rsp->expedited_workdone1);
85449 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
85450 return;
85451 }
85452
85453 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
85454 udelay(trycount * num_online_cpus());
85455 } else {
85456 wait_rcu_gp(call_rcu_sched);
85457 - atomic_long_inc(&rsp->expedited_normal);
85458 + atomic_long_inc_unchecked(&rsp->expedited_normal);
85459 return;
85460 }
85461
85462 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
85463 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
85464 /* ensure test happens before caller kfree */
85465 smp_mb__before_atomic_inc(); /* ^^^ */
85466 - atomic_long_inc(&rsp->expedited_workdone2);
85467 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
85468 return;
85469 }
85470
85471 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
85472 * period works for us.
85473 */
85474 get_online_cpus();
85475 - snap = atomic_long_read(&rsp->expedited_start);
85476 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
85477 smp_mb(); /* ensure read is before try_stop_cpus(). */
85478 }
85479 - atomic_long_inc(&rsp->expedited_stoppedcpus);
85480 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
85481
85482 /*
85483 * Everyone up to our most recent fetch is covered by our grace
85484 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
85485 * than we did already did their update.
85486 */
85487 do {
85488 - atomic_long_inc(&rsp->expedited_done_tries);
85489 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
85490 s = atomic_long_read(&rsp->expedited_done);
85491 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
85492 /* ensure test happens before caller kfree */
85493 smp_mb__before_atomic_inc(); /* ^^^ */
85494 - atomic_long_inc(&rsp->expedited_done_lost);
85495 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
85496 break;
85497 }
85498 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
85499 - atomic_long_inc(&rsp->expedited_done_exit);
85500 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
85501
85502 put_online_cpus();
85503 }
85504 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
85505 * ACCESS_ONCE() to prevent the compiler from speculating
85506 * the increment to precede the early-exit check.
85507 */
85508 - ACCESS_ONCE(rsp->n_barrier_done)++;
85509 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
85510 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
85511 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
85512 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
85513 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
85514
85515 /* Increment ->n_barrier_done to prevent duplicate work. */
85516 smp_mb(); /* Keep increment after above mechanism. */
85517 - ACCESS_ONCE(rsp->n_barrier_done)++;
85518 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
85519 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
85520 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
85521 smp_mb(); /* Keep increment before caller's subsequent code. */
85522 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
85523 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
85524 init_callback_list(rdp);
85525 rdp->qlen_lazy = 0;
85526 - ACCESS_ONCE(rdp->qlen) = 0;
85527 + ACCESS_ONCE_RW(rdp->qlen) = 0;
85528 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
85529 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
85530 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
85531 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
85532 rdp->cpu = cpu;
85533 rdp->rsp = rsp;
85534 rcu_boot_init_nocb_percpu_data(rdp);
85535 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
85536 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
85537 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
85538 rcu_sysidle_init_percpu_data(rdp->dynticks);
85539 - atomic_set(&rdp->dynticks->dynticks,
85540 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
85541 + atomic_set_unchecked(&rdp->dynticks->dynticks,
85542 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
85543 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
85544
85545 /* Add CPU to rcu_node bitmasks. */
85546 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
85547 index 5f97eab..db8f687 100644
85548 --- a/kernel/rcutree.h
85549 +++ b/kernel/rcutree.h
85550 @@ -87,11 +87,11 @@ struct rcu_dynticks {
85551 long long dynticks_nesting; /* Track irq/process nesting level. */
85552 /* Process level is worth LLONG_MAX/2. */
85553 int dynticks_nmi_nesting; /* Track NMI nesting level. */
85554 - atomic_t dynticks; /* Even value for idle, else odd. */
85555 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
85556 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
85557 long long dynticks_idle_nesting;
85558 /* irq/process nesting level from idle. */
85559 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
85560 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
85561 /* "Idle" excludes userspace execution. */
85562 unsigned long dynticks_idle_jiffies;
85563 /* End of last non-NMI non-idle period. */
85564 @@ -427,17 +427,17 @@ struct rcu_state {
85565 /* _rcu_barrier(). */
85566 /* End of fields guarded by barrier_mutex. */
85567
85568 - atomic_long_t expedited_start; /* Starting ticket. */
85569 - atomic_long_t expedited_done; /* Done ticket. */
85570 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
85571 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
85572 - atomic_long_t expedited_workdone1; /* # done by others #1. */
85573 - atomic_long_t expedited_workdone2; /* # done by others #2. */
85574 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
85575 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
85576 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
85577 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
85578 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
85579 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
85580 + atomic_long_t expedited_done; /* Done ticket. */
85581 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
85582 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
85583 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
85584 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
85585 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
85586 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
85587 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
85588 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
85589 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
85590
85591 unsigned long jiffies_force_qs; /* Time at which to invoke */
85592 /* force_quiescent_state(). */
85593 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
85594 index 130c97b..bcbe7f7 100644
85595 --- a/kernel/rcutree_plugin.h
85596 +++ b/kernel/rcutree_plugin.h
85597 @@ -744,7 +744,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
85598 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
85599 {
85600 return !rcu_preempted_readers_exp(rnp) &&
85601 - ACCESS_ONCE(rnp->expmask) == 0;
85602 + ACCESS_ONCE_RW(rnp->expmask) == 0;
85603 }
85604
85605 /*
85606 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
85607
85608 /* Clean up and exit. */
85609 smp_mb(); /* ensure expedited GP seen before counter increment. */
85610 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
85611 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
85612 unlock_mb_ret:
85613 mutex_unlock(&sync_rcu_preempt_exp_mutex);
85614 mb_ret:
85615 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
85616 free_cpumask_var(cm);
85617 }
85618
85619 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
85620 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
85621 .store = &rcu_cpu_kthread_task,
85622 .thread_should_run = rcu_cpu_kthread_should_run,
85623 .thread_fn = rcu_cpu_kthread,
85624 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
85625 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
85626 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
85627 cpu, ticks_value, ticks_title,
85628 - atomic_read(&rdtp->dynticks) & 0xfff,
85629 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
85630 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
85631 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
85632 fast_no_hz);
85633 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
85634
85635 /* Enqueue the callback on the nocb list and update counts. */
85636 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
85637 - ACCESS_ONCE(*old_rhpp) = rhp;
85638 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
85639 atomic_long_add(rhcount, &rdp->nocb_q_count);
85640 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
85641
85642 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
85643 * Extract queued callbacks, update counts, and wait
85644 * for a grace period to elapse.
85645 */
85646 - ACCESS_ONCE(rdp->nocb_head) = NULL;
85647 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
85648 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
85649 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
85650 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
85651 - ACCESS_ONCE(rdp->nocb_p_count) += c;
85652 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
85653 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
85654 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
85655 rcu_nocb_wait_gp(rdp);
85656
85657 /* Each pass through the following loop invokes a callback. */
85658 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
85659 list = next;
85660 }
85661 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
85662 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
85663 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
85664 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
85665 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
85666 rdp->n_nocbs_invoked += c;
85667 }
85668 return 0;
85669 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
85670 t = kthread_run(rcu_nocb_kthread, rdp,
85671 "rcuo%c/%d", rsp->abbr, cpu);
85672 BUG_ON(IS_ERR(t));
85673 - ACCESS_ONCE(rdp->nocb_kthread) = t;
85674 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
85675 }
85676 }
85677
85678 @@ -2423,11 +2423,11 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
85679
85680 /* Record start of fully idle period. */
85681 j = jiffies;
85682 - ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
85683 + ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
85684 smp_mb__before_atomic_inc();
85685 - atomic_inc(&rdtp->dynticks_idle);
85686 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85687 smp_mb__after_atomic_inc();
85688 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
85689 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
85690 }
85691
85692 /*
85693 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
85694
85695 /* Record end of idle period. */
85696 smp_mb__before_atomic_inc();
85697 - atomic_inc(&rdtp->dynticks_idle);
85698 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85699 smp_mb__after_atomic_inc();
85700 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
85701 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
85702
85703 /*
85704 * If we are the timekeeping CPU, we are permitted to be non-idle
85705 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
85706 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
85707
85708 /* Pick up current idle and NMI-nesting counter and check. */
85709 - cur = atomic_read(&rdtp->dynticks_idle);
85710 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
85711 if (cur & 0x1) {
85712 *isidle = false; /* We are not idle! */
85713 return;
85714 @@ -2598,7 +2598,7 @@ static void rcu_sysidle(unsigned long j)
85715 case RCU_SYSIDLE_NOT:
85716
85717 /* First time all are idle, so note a short idle period. */
85718 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85719 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85720 break;
85721
85722 case RCU_SYSIDLE_SHORT:
85723 @@ -2635,7 +2635,7 @@ static void rcu_sysidle(unsigned long j)
85724 static void rcu_sysidle_cancel(void)
85725 {
85726 smp_mb();
85727 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
85728 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
85729 }
85730
85731 /*
85732 @@ -2683,7 +2683,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
85733 smp_mb(); /* grace period precedes setting inuse. */
85734
85735 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
85736 - ACCESS_ONCE(rshp->inuse) = 0;
85737 + ACCESS_ONCE_RW(rshp->inuse) = 0;
85738 }
85739
85740 /*
85741 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
85742 index cf6c174..a8f4b50 100644
85743 --- a/kernel/rcutree_trace.c
85744 +++ b/kernel/rcutree_trace.c
85745 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
85746 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
85747 rdp->passed_quiesce, rdp->qs_pending);
85748 seq_printf(m, " dt=%d/%llx/%d df=%lu",
85749 - atomic_read(&rdp->dynticks->dynticks),
85750 + atomic_read_unchecked(&rdp->dynticks->dynticks),
85751 rdp->dynticks->dynticks_nesting,
85752 rdp->dynticks->dynticks_nmi_nesting,
85753 rdp->dynticks_fqs);
85754 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
85755 struct rcu_state *rsp = (struct rcu_state *)m->private;
85756
85757 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",
85758 - atomic_long_read(&rsp->expedited_start),
85759 + atomic_long_read_unchecked(&rsp->expedited_start),
85760 atomic_long_read(&rsp->expedited_done),
85761 - atomic_long_read(&rsp->expedited_wrap),
85762 - atomic_long_read(&rsp->expedited_tryfail),
85763 - atomic_long_read(&rsp->expedited_workdone1),
85764 - atomic_long_read(&rsp->expedited_workdone2),
85765 - atomic_long_read(&rsp->expedited_normal),
85766 - atomic_long_read(&rsp->expedited_stoppedcpus),
85767 - atomic_long_read(&rsp->expedited_done_tries),
85768 - atomic_long_read(&rsp->expedited_done_lost),
85769 - atomic_long_read(&rsp->expedited_done_exit));
85770 + atomic_long_read_unchecked(&rsp->expedited_wrap),
85771 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
85772 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
85773 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
85774 + atomic_long_read_unchecked(&rsp->expedited_normal),
85775 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
85776 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
85777 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
85778 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
85779 return 0;
85780 }
85781
85782 diff --git a/kernel/resource.c b/kernel/resource.c
85783 index 3f285dc..5755f62 100644
85784 --- a/kernel/resource.c
85785 +++ b/kernel/resource.c
85786 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
85787
85788 static int __init ioresources_init(void)
85789 {
85790 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85791 +#ifdef CONFIG_GRKERNSEC_PROC_USER
85792 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
85793 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
85794 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
85795 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
85796 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
85797 +#endif
85798 +#else
85799 proc_create("ioports", 0, NULL, &proc_ioports_operations);
85800 proc_create("iomem", 0, NULL, &proc_iomem_operations);
85801 +#endif
85802 return 0;
85803 }
85804 __initcall(ioresources_init);
85805 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
85806 index 1d96dd0..994ff19 100644
85807 --- a/kernel/rtmutex-tester.c
85808 +++ b/kernel/rtmutex-tester.c
85809 @@ -22,7 +22,7 @@
85810 #define MAX_RT_TEST_MUTEXES 8
85811
85812 static spinlock_t rttest_lock;
85813 -static atomic_t rttest_event;
85814 +static atomic_unchecked_t rttest_event;
85815
85816 struct test_thread_data {
85817 int opcode;
85818 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85819
85820 case RTTEST_LOCKCONT:
85821 td->mutexes[td->opdata] = 1;
85822 - td->event = atomic_add_return(1, &rttest_event);
85823 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85824 return 0;
85825
85826 case RTTEST_RESET:
85827 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85828 return 0;
85829
85830 case RTTEST_RESETEVENT:
85831 - atomic_set(&rttest_event, 0);
85832 + atomic_set_unchecked(&rttest_event, 0);
85833 return 0;
85834
85835 default:
85836 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85837 return ret;
85838
85839 td->mutexes[id] = 1;
85840 - td->event = atomic_add_return(1, &rttest_event);
85841 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85842 rt_mutex_lock(&mutexes[id]);
85843 - td->event = atomic_add_return(1, &rttest_event);
85844 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85845 td->mutexes[id] = 4;
85846 return 0;
85847
85848 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85849 return ret;
85850
85851 td->mutexes[id] = 1;
85852 - td->event = atomic_add_return(1, &rttest_event);
85853 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85854 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
85855 - td->event = atomic_add_return(1, &rttest_event);
85856 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85857 td->mutexes[id] = ret ? 0 : 4;
85858 return ret ? -EINTR : 0;
85859
85860 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85861 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
85862 return ret;
85863
85864 - td->event = atomic_add_return(1, &rttest_event);
85865 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85866 rt_mutex_unlock(&mutexes[id]);
85867 - td->event = atomic_add_return(1, &rttest_event);
85868 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85869 td->mutexes[id] = 0;
85870 return 0;
85871
85872 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85873 break;
85874
85875 td->mutexes[dat] = 2;
85876 - td->event = atomic_add_return(1, &rttest_event);
85877 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85878 break;
85879
85880 default:
85881 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85882 return;
85883
85884 td->mutexes[dat] = 3;
85885 - td->event = atomic_add_return(1, &rttest_event);
85886 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85887 break;
85888
85889 case RTTEST_LOCKNOWAIT:
85890 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85891 return;
85892
85893 td->mutexes[dat] = 1;
85894 - td->event = atomic_add_return(1, &rttest_event);
85895 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85896 return;
85897
85898 default:
85899 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
85900 index 4a07353..66b5291 100644
85901 --- a/kernel/sched/auto_group.c
85902 +++ b/kernel/sched/auto_group.c
85903 @@ -11,7 +11,7 @@
85904
85905 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
85906 static struct autogroup autogroup_default;
85907 -static atomic_t autogroup_seq_nr;
85908 +static atomic_unchecked_t autogroup_seq_nr;
85909
85910 void __init autogroup_init(struct task_struct *init_task)
85911 {
85912 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
85913
85914 kref_init(&ag->kref);
85915 init_rwsem(&ag->lock);
85916 - ag->id = atomic_inc_return(&autogroup_seq_nr);
85917 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
85918 ag->tg = tg;
85919 #ifdef CONFIG_RT_GROUP_SCHED
85920 /*
85921 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
85922 index ceae65e..3ac1344 100644
85923 --- a/kernel/sched/core.c
85924 +++ b/kernel/sched/core.c
85925 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
85926 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85927 * or number of jiffies left till timeout) if completed.
85928 */
85929 -long __sched
85930 +long __sched __intentional_overflow(-1)
85931 wait_for_completion_interruptible_timeout(struct completion *x,
85932 unsigned long timeout)
85933 {
85934 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
85935 *
85936 * Return: -ERESTARTSYS if interrupted, 0 if completed.
85937 */
85938 -int __sched wait_for_completion_killable(struct completion *x)
85939 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
85940 {
85941 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
85942 if (t == -ERESTARTSYS)
85943 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
85944 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85945 * or number of jiffies left till timeout) if completed.
85946 */
85947 -long __sched
85948 +long __sched __intentional_overflow(-1)
85949 wait_for_completion_killable_timeout(struct completion *x,
85950 unsigned long timeout)
85951 {
85952 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
85953 /* convert nice value [19,-20] to rlimit style value [1,40] */
85954 int nice_rlim = 20 - nice;
85955
85956 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
85957 +
85958 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
85959 capable(CAP_SYS_NICE));
85960 }
85961 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
85962 if (nice > 19)
85963 nice = 19;
85964
85965 - if (increment < 0 && !can_nice(current, nice))
85966 + if (increment < 0 && (!can_nice(current, nice) ||
85967 + gr_handle_chroot_nice()))
85968 return -EPERM;
85969
85970 retval = security_task_setnice(current, nice);
85971 @@ -3327,6 +3330,7 @@ recheck:
85972 unsigned long rlim_rtprio =
85973 task_rlimit(p, RLIMIT_RTPRIO);
85974
85975 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
85976 /* can't set/change the rt policy */
85977 if (policy != p->policy && !rlim_rtprio)
85978 return -EPERM;
85979 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
85980
85981 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
85982
85983 -static struct ctl_table sd_ctl_dir[] = {
85984 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
85985 {
85986 .procname = "sched_domain",
85987 .mode = 0555,
85988 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
85989 {}
85990 };
85991
85992 -static struct ctl_table *sd_alloc_ctl_entry(int n)
85993 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
85994 {
85995 - struct ctl_table *entry =
85996 + ctl_table_no_const *entry =
85997 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
85998
85999 return entry;
86000 }
86001
86002 -static void sd_free_ctl_entry(struct ctl_table **tablep)
86003 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
86004 {
86005 - struct ctl_table *entry;
86006 + ctl_table_no_const *entry;
86007
86008 /*
86009 * In the intermediate directories, both the child directory and
86010 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
86011 * will always be set. In the lowest directory the names are
86012 * static strings and all have proc handlers.
86013 */
86014 - for (entry = *tablep; entry->mode; entry++) {
86015 - if (entry->child)
86016 - sd_free_ctl_entry(&entry->child);
86017 + for (entry = tablep; entry->mode; entry++) {
86018 + if (entry->child) {
86019 + sd_free_ctl_entry(entry->child);
86020 + pax_open_kernel();
86021 + entry->child = NULL;
86022 + pax_close_kernel();
86023 + }
86024 if (entry->proc_handler == NULL)
86025 kfree(entry->procname);
86026 }
86027
86028 - kfree(*tablep);
86029 - *tablep = NULL;
86030 + kfree(tablep);
86031 }
86032
86033 static int min_load_idx = 0;
86034 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
86035
86036 static void
86037 -set_table_entry(struct ctl_table *entry,
86038 +set_table_entry(ctl_table_no_const *entry,
86039 const char *procname, void *data, int maxlen,
86040 umode_t mode, proc_handler *proc_handler,
86041 bool load_idx)
86042 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
86043 static struct ctl_table *
86044 sd_alloc_ctl_domain_table(struct sched_domain *sd)
86045 {
86046 - struct ctl_table *table = sd_alloc_ctl_entry(13);
86047 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
86048
86049 if (table == NULL)
86050 return NULL;
86051 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
86052 return table;
86053 }
86054
86055 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
86056 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
86057 {
86058 - struct ctl_table *entry, *table;
86059 + ctl_table_no_const *entry, *table;
86060 struct sched_domain *sd;
86061 int domain_num = 0, i;
86062 char buf[32];
86063 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
86064 static void register_sched_domain_sysctl(void)
86065 {
86066 int i, cpu_num = num_possible_cpus();
86067 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
86068 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
86069 char buf[32];
86070
86071 WARN_ON(sd_ctl_dir[0].child);
86072 + pax_open_kernel();
86073 sd_ctl_dir[0].child = entry;
86074 + pax_close_kernel();
86075
86076 if (entry == NULL)
86077 return;
86078 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
86079 if (sd_sysctl_header)
86080 unregister_sysctl_table(sd_sysctl_header);
86081 sd_sysctl_header = NULL;
86082 - if (sd_ctl_dir[0].child)
86083 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
86084 + if (sd_ctl_dir[0].child) {
86085 + sd_free_ctl_entry(sd_ctl_dir[0].child);
86086 + pax_open_kernel();
86087 + sd_ctl_dir[0].child = NULL;
86088 + pax_close_kernel();
86089 + }
86090 }
86091 #else
86092 static void register_sched_domain_sysctl(void)
86093 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
86094 index 4117323..91c91ac 100644
86095 --- a/kernel/sched/fair.c
86096 +++ b/kernel/sched/fair.c
86097 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
86098
86099 static void reset_ptenuma_scan(struct task_struct *p)
86100 {
86101 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
86102 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
86103 p->mm->numa_scan_offset = 0;
86104 }
86105
86106 @@ -5864,7 +5864,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
86107 * run_rebalance_domains is triggered when needed from the scheduler tick.
86108 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
86109 */
86110 -static void run_rebalance_domains(struct softirq_action *h)
86111 +static __latent_entropy void run_rebalance_domains(void)
86112 {
86113 int this_cpu = smp_processor_id();
86114 struct rq *this_rq = cpu_rq(this_cpu);
86115 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
86116 index a6208af..a2d7bb5 100644
86117 --- a/kernel/sched/sched.h
86118 +++ b/kernel/sched/sched.h
86119 @@ -1004,7 +1004,7 @@ struct sched_class {
86120 #ifdef CONFIG_FAIR_GROUP_SCHED
86121 void (*task_move_group) (struct task_struct *p, int on_rq);
86122 #endif
86123 -};
86124 +} __do_const;
86125
86126 #define sched_class_highest (&stop_sched_class)
86127 #define for_each_class(class) \
86128 diff --git a/kernel/signal.c b/kernel/signal.c
86129 index ded28b9..6886c08 100644
86130 --- a/kernel/signal.c
86131 +++ b/kernel/signal.c
86132 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
86133
86134 int print_fatal_signals __read_mostly;
86135
86136 -static void __user *sig_handler(struct task_struct *t, int sig)
86137 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
86138 {
86139 return t->sighand->action[sig - 1].sa.sa_handler;
86140 }
86141
86142 -static int sig_handler_ignored(void __user *handler, int sig)
86143 +static int sig_handler_ignored(__sighandler_t handler, int sig)
86144 {
86145 /* Is it explicitly or implicitly ignored? */
86146 return handler == SIG_IGN ||
86147 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
86148
86149 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
86150 {
86151 - void __user *handler;
86152 + __sighandler_t handler;
86153
86154 handler = sig_handler(t, sig);
86155
86156 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
86157 atomic_inc(&user->sigpending);
86158 rcu_read_unlock();
86159
86160 + if (!override_rlimit)
86161 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
86162 +
86163 if (override_rlimit ||
86164 atomic_read(&user->sigpending) <=
86165 task_rlimit(t, RLIMIT_SIGPENDING)) {
86166 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
86167
86168 int unhandled_signal(struct task_struct *tsk, int sig)
86169 {
86170 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
86171 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
86172 if (is_global_init(tsk))
86173 return 1;
86174 if (handler != SIG_IGN && handler != SIG_DFL)
86175 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
86176 }
86177 }
86178
86179 + /* allow glibc communication via tgkill to other threads in our
86180 + thread group */
86181 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
86182 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
86183 + && gr_handle_signal(t, sig))
86184 + return -EPERM;
86185 +
86186 return security_task_kill(t, info, sig, 0);
86187 }
86188
86189 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
86190 return send_signal(sig, info, p, 1);
86191 }
86192
86193 -static int
86194 +int
86195 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
86196 {
86197 return send_signal(sig, info, t, 0);
86198 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
86199 unsigned long int flags;
86200 int ret, blocked, ignored;
86201 struct k_sigaction *action;
86202 + int is_unhandled = 0;
86203
86204 spin_lock_irqsave(&t->sighand->siglock, flags);
86205 action = &t->sighand->action[sig-1];
86206 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
86207 }
86208 if (action->sa.sa_handler == SIG_DFL)
86209 t->signal->flags &= ~SIGNAL_UNKILLABLE;
86210 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
86211 + is_unhandled = 1;
86212 ret = specific_send_sig_info(sig, info, t);
86213 spin_unlock_irqrestore(&t->sighand->siglock, flags);
86214
86215 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
86216 + normal operation */
86217 + if (is_unhandled) {
86218 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
86219 + gr_handle_crash(t, sig);
86220 + }
86221 +
86222 return ret;
86223 }
86224
86225 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
86226 ret = check_kill_permission(sig, info, p);
86227 rcu_read_unlock();
86228
86229 - if (!ret && sig)
86230 + if (!ret && sig) {
86231 ret = do_send_sig_info(sig, info, p, true);
86232 + if (!ret)
86233 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
86234 + }
86235
86236 return ret;
86237 }
86238 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
86239 int error = -ESRCH;
86240
86241 rcu_read_lock();
86242 - p = find_task_by_vpid(pid);
86243 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
86244 + /* allow glibc communication via tgkill to other threads in our
86245 + thread group */
86246 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
86247 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
86248 + p = find_task_by_vpid_unrestricted(pid);
86249 + else
86250 +#endif
86251 + p = find_task_by_vpid(pid);
86252 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
86253 error = check_kill_permission(sig, info, p);
86254 /*
86255 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
86256 }
86257 seg = get_fs();
86258 set_fs(KERNEL_DS);
86259 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
86260 - (stack_t __force __user *) &uoss,
86261 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
86262 + (stack_t __force_user *) &uoss,
86263 compat_user_stack_pointer());
86264 set_fs(seg);
86265 if (ret >= 0 && uoss_ptr) {
86266 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
86267 index eb89e18..a4e6792 100644
86268 --- a/kernel/smpboot.c
86269 +++ b/kernel/smpboot.c
86270 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
86271 }
86272 smpboot_unpark_thread(plug_thread, cpu);
86273 }
86274 - list_add(&plug_thread->list, &hotplug_threads);
86275 + pax_list_add(&plug_thread->list, &hotplug_threads);
86276 out:
86277 mutex_unlock(&smpboot_threads_lock);
86278 return ret;
86279 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
86280 {
86281 get_online_cpus();
86282 mutex_lock(&smpboot_threads_lock);
86283 - list_del(&plug_thread->list);
86284 + pax_list_del(&plug_thread->list);
86285 smpboot_destroy_threads(plug_thread);
86286 mutex_unlock(&smpboot_threads_lock);
86287 put_online_cpus();
86288 diff --git a/kernel/softirq.c b/kernel/softirq.c
86289 index d7d498d..94fe0f7 100644
86290 --- a/kernel/softirq.c
86291 +++ b/kernel/softirq.c
86292 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
86293 EXPORT_SYMBOL(irq_stat);
86294 #endif
86295
86296 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
86297 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
86298
86299 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
86300
86301 -char *softirq_to_name[NR_SOFTIRQS] = {
86302 +const char * const softirq_to_name[NR_SOFTIRQS] = {
86303 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
86304 "TASKLET", "SCHED", "HRTIMER", "RCU"
86305 };
86306 @@ -248,7 +248,7 @@ restart:
86307 kstat_incr_softirqs_this_cpu(vec_nr);
86308
86309 trace_softirq_entry(vec_nr);
86310 - h->action(h);
86311 + h->action();
86312 trace_softirq_exit(vec_nr);
86313 if (unlikely(prev_count != preempt_count())) {
86314 printk(KERN_ERR "huh, entered softirq %u %s %p"
86315 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
86316 or_softirq_pending(1UL << nr);
86317 }
86318
86319 -void open_softirq(int nr, void (*action)(struct softirq_action *))
86320 +void __init open_softirq(int nr, void (*action)(void))
86321 {
86322 softirq_vec[nr].action = action;
86323 }
86324 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
86325
86326 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
86327
86328 -static void tasklet_action(struct softirq_action *a)
86329 +static __latent_entropy void tasklet_action(void)
86330 {
86331 struct tasklet_struct *list;
86332
86333 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
86334 }
86335 }
86336
86337 -static void tasklet_hi_action(struct softirq_action *a)
86338 +static __latent_entropy void tasklet_hi_action(void)
86339 {
86340 struct tasklet_struct *list;
86341
86342 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
86343 .notifier_call = cpu_callback
86344 };
86345
86346 -static struct smp_hotplug_thread softirq_threads = {
86347 +static struct smp_hotplug_thread softirq_threads __read_only = {
86348 .store = &ksoftirqd,
86349 .thread_should_run = ksoftirqd_should_run,
86350 .thread_fn = run_ksoftirqd,
86351 diff --git a/kernel/srcu.c b/kernel/srcu.c
86352 index 01d5ccb..cdcbee6 100644
86353 --- a/kernel/srcu.c
86354 +++ b/kernel/srcu.c
86355 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
86356
86357 idx = ACCESS_ONCE(sp->completed) & 0x1;
86358 preempt_disable();
86359 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
86360 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
86361 smp_mb(); /* B */ /* Avoid leaking the critical section. */
86362 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
86363 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
86364 preempt_enable();
86365 return idx;
86366 }
86367 diff --git a/kernel/sys.c b/kernel/sys.c
86368 index c18ecca..b3c2dd2 100644
86369 --- a/kernel/sys.c
86370 +++ b/kernel/sys.c
86371 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
86372 error = -EACCES;
86373 goto out;
86374 }
86375 +
86376 + if (gr_handle_chroot_setpriority(p, niceval)) {
86377 + error = -EACCES;
86378 + goto out;
86379 + }
86380 +
86381 no_nice = security_task_setnice(p, niceval);
86382 if (no_nice) {
86383 error = no_nice;
86384 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
86385 goto error;
86386 }
86387
86388 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
86389 + goto error;
86390 +
86391 if (rgid != (gid_t) -1 ||
86392 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
86393 new->sgid = new->egid;
86394 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
86395 old = current_cred();
86396
86397 retval = -EPERM;
86398 +
86399 + if (gr_check_group_change(kgid, kgid, kgid))
86400 + goto error;
86401 +
86402 if (ns_capable(old->user_ns, CAP_SETGID))
86403 new->gid = new->egid = new->sgid = new->fsgid = kgid;
86404 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
86405 @@ -404,7 +417,7 @@ error:
86406 /*
86407 * change the user struct in a credentials set to match the new UID
86408 */
86409 -static int set_user(struct cred *new)
86410 +int set_user(struct cred *new)
86411 {
86412 struct user_struct *new_user;
86413
86414 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
86415 goto error;
86416 }
86417
86418 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
86419 + goto error;
86420 +
86421 if (!uid_eq(new->uid, old->uid)) {
86422 retval = set_user(new);
86423 if (retval < 0)
86424 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
86425 old = current_cred();
86426
86427 retval = -EPERM;
86428 +
86429 + if (gr_check_crash_uid(kuid))
86430 + goto error;
86431 + if (gr_check_user_change(kuid, kuid, kuid))
86432 + goto error;
86433 +
86434 if (ns_capable(old->user_ns, CAP_SETUID)) {
86435 new->suid = new->uid = kuid;
86436 if (!uid_eq(kuid, old->uid)) {
86437 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
86438 goto error;
86439 }
86440
86441 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
86442 + goto error;
86443 +
86444 if (ruid != (uid_t) -1) {
86445 new->uid = kruid;
86446 if (!uid_eq(kruid, old->uid)) {
86447 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
86448 goto error;
86449 }
86450
86451 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
86452 + goto error;
86453 +
86454 if (rgid != (gid_t) -1)
86455 new->gid = krgid;
86456 if (egid != (gid_t) -1)
86457 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
86458 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
86459 ns_capable(old->user_ns, CAP_SETUID)) {
86460 if (!uid_eq(kuid, old->fsuid)) {
86461 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
86462 + goto error;
86463 +
86464 new->fsuid = kuid;
86465 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
86466 goto change_okay;
86467 }
86468 }
86469
86470 +error:
86471 abort_creds(new);
86472 return old_fsuid;
86473
86474 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
86475 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
86476 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
86477 ns_capable(old->user_ns, CAP_SETGID)) {
86478 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
86479 + goto error;
86480 +
86481 if (!gid_eq(kgid, old->fsgid)) {
86482 new->fsgid = kgid;
86483 goto change_okay;
86484 }
86485 }
86486
86487 +error:
86488 abort_creds(new);
86489 return old_fsgid;
86490
86491 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
86492 return -EFAULT;
86493
86494 down_read(&uts_sem);
86495 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
86496 + error = __copy_to_user(name->sysname, &utsname()->sysname,
86497 __OLD_UTS_LEN);
86498 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
86499 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
86500 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
86501 __OLD_UTS_LEN);
86502 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
86503 - error |= __copy_to_user(&name->release, &utsname()->release,
86504 + error |= __copy_to_user(name->release, &utsname()->release,
86505 __OLD_UTS_LEN);
86506 error |= __put_user(0, name->release + __OLD_UTS_LEN);
86507 - error |= __copy_to_user(&name->version, &utsname()->version,
86508 + error |= __copy_to_user(name->version, &utsname()->version,
86509 __OLD_UTS_LEN);
86510 error |= __put_user(0, name->version + __OLD_UTS_LEN);
86511 - error |= __copy_to_user(&name->machine, &utsname()->machine,
86512 + error |= __copy_to_user(name->machine, &utsname()->machine,
86513 __OLD_UTS_LEN);
86514 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
86515 up_read(&uts_sem);
86516 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
86517 */
86518 new_rlim->rlim_cur = 1;
86519 }
86520 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
86521 + is changed to a lower value. Since tasks can be created by the same
86522 + user in between this limit change and an execve by this task, force
86523 + a recheck only for this task by setting PF_NPROC_EXCEEDED
86524 + */
86525 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
86526 + tsk->flags |= PF_NPROC_EXCEEDED;
86527 }
86528 if (!retval) {
86529 if (old_rlim)
86530 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
86531 index b2f06f3..e6354ab 100644
86532 --- a/kernel/sysctl.c
86533 +++ b/kernel/sysctl.c
86534 @@ -93,7 +93,6 @@
86535
86536
86537 #if defined(CONFIG_SYSCTL)
86538 -
86539 /* External variables not in a header file. */
86540 extern int sysctl_overcommit_memory;
86541 extern int sysctl_overcommit_ratio;
86542 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
86543
86544 /* Constants used for minimum and maximum */
86545 #ifdef CONFIG_LOCKUP_DETECTOR
86546 -static int sixty = 60;
86547 +static int sixty __read_only = 60;
86548 #endif
86549
86550 -static int zero;
86551 -static int __maybe_unused one = 1;
86552 -static int __maybe_unused two = 2;
86553 -static int __maybe_unused three = 3;
86554 -static unsigned long one_ul = 1;
86555 -static int one_hundred = 100;
86556 +static int neg_one __read_only = -1;
86557 +static int zero __read_only = 0;
86558 +static int __maybe_unused one __read_only = 1;
86559 +static int __maybe_unused two __read_only = 2;
86560 +static int __maybe_unused three __read_only = 3;
86561 +static unsigned long one_ul __read_only = 1;
86562 +static int one_hundred __read_only = 100;
86563 #ifdef CONFIG_PRINTK
86564 -static int ten_thousand = 10000;
86565 +static int ten_thousand __read_only = 10000;
86566 #endif
86567
86568 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
86569 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
86570 void __user *buffer, size_t *lenp, loff_t *ppos);
86571 #endif
86572
86573 -#ifdef CONFIG_PRINTK
86574 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86575 void __user *buffer, size_t *lenp, loff_t *ppos);
86576 -#endif
86577
86578 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
86579 void __user *buffer, size_t *lenp, loff_t *ppos);
86580 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
86581
86582 #endif
86583
86584 +extern struct ctl_table grsecurity_table[];
86585 +
86586 static struct ctl_table kern_table[];
86587 static struct ctl_table vm_table[];
86588 static struct ctl_table fs_table[];
86589 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
86590 int sysctl_legacy_va_layout;
86591 #endif
86592
86593 +#ifdef CONFIG_PAX_SOFTMODE
86594 +static ctl_table pax_table[] = {
86595 + {
86596 + .procname = "softmode",
86597 + .data = &pax_softmode,
86598 + .maxlen = sizeof(unsigned int),
86599 + .mode = 0600,
86600 + .proc_handler = &proc_dointvec,
86601 + },
86602 +
86603 + { }
86604 +};
86605 +#endif
86606 +
86607 /* The default sysctl tables: */
86608
86609 static struct ctl_table sysctl_base_table[] = {
86610 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
86611 #endif
86612
86613 static struct ctl_table kern_table[] = {
86614 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
86615 + {
86616 + .procname = "grsecurity",
86617 + .mode = 0500,
86618 + .child = grsecurity_table,
86619 + },
86620 +#endif
86621 +
86622 +#ifdef CONFIG_PAX_SOFTMODE
86623 + {
86624 + .procname = "pax",
86625 + .mode = 0500,
86626 + .child = pax_table,
86627 + },
86628 +#endif
86629 +
86630 {
86631 .procname = "sched_child_runs_first",
86632 .data = &sysctl_sched_child_runs_first,
86633 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
86634 .data = &modprobe_path,
86635 .maxlen = KMOD_PATH_LEN,
86636 .mode = 0644,
86637 - .proc_handler = proc_dostring,
86638 + .proc_handler = proc_dostring_modpriv,
86639 },
86640 {
86641 .procname = "modules_disabled",
86642 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
86643 .extra1 = &zero,
86644 .extra2 = &one,
86645 },
86646 +#endif
86647 {
86648 .procname = "kptr_restrict",
86649 .data = &kptr_restrict,
86650 .maxlen = sizeof(int),
86651 .mode = 0644,
86652 .proc_handler = proc_dointvec_minmax_sysadmin,
86653 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86654 + .extra1 = &two,
86655 +#else
86656 .extra1 = &zero,
86657 +#endif
86658 .extra2 = &two,
86659 },
86660 -#endif
86661 {
86662 .procname = "ngroups_max",
86663 .data = &ngroups_max,
86664 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
86665 */
86666 {
86667 .procname = "perf_event_paranoid",
86668 - .data = &sysctl_perf_event_paranoid,
86669 - .maxlen = sizeof(sysctl_perf_event_paranoid),
86670 + .data = &sysctl_perf_event_legitimately_concerned,
86671 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
86672 .mode = 0644,
86673 - .proc_handler = proc_dointvec,
86674 + /* go ahead, be a hero */
86675 + .proc_handler = proc_dointvec_minmax_sysadmin,
86676 + .extra1 = &neg_one,
86677 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
86678 + .extra2 = &three,
86679 +#else
86680 + .extra2 = &two,
86681 +#endif
86682 },
86683 {
86684 .procname = "perf_event_mlock_kb",
86685 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
86686 .proc_handler = proc_dointvec_minmax,
86687 .extra1 = &zero,
86688 },
86689 + {
86690 + .procname = "heap_stack_gap",
86691 + .data = &sysctl_heap_stack_gap,
86692 + .maxlen = sizeof(sysctl_heap_stack_gap),
86693 + .mode = 0644,
86694 + .proc_handler = proc_doulongvec_minmax,
86695 + },
86696 #else
86697 {
86698 .procname = "nr_trim_pages",
86699 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
86700 buffer, lenp, ppos);
86701 }
86702
86703 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86704 + void __user *buffer, size_t *lenp, loff_t *ppos)
86705 +{
86706 + if (write && !capable(CAP_SYS_MODULE))
86707 + return -EPERM;
86708 +
86709 + return _proc_do_string(table->data, table->maxlen, write,
86710 + buffer, lenp, ppos);
86711 +}
86712 +
86713 static size_t proc_skip_spaces(char **buf)
86714 {
86715 size_t ret;
86716 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
86717 len = strlen(tmp);
86718 if (len > *size)
86719 len = *size;
86720 + if (len > sizeof(tmp))
86721 + len = sizeof(tmp);
86722 if (copy_to_user(*buf, tmp, len))
86723 return -EFAULT;
86724 *size -= len;
86725 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
86726 static int proc_taint(struct ctl_table *table, int write,
86727 void __user *buffer, size_t *lenp, loff_t *ppos)
86728 {
86729 - struct ctl_table t;
86730 + ctl_table_no_const t;
86731 unsigned long tmptaint = get_taint();
86732 int err;
86733
86734 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
86735 return err;
86736 }
86737
86738 -#ifdef CONFIG_PRINTK
86739 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86740 void __user *buffer, size_t *lenp, loff_t *ppos)
86741 {
86742 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86743
86744 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
86745 }
86746 -#endif
86747
86748 struct do_proc_dointvec_minmax_conv_param {
86749 int *min;
86750 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
86751 *i = val;
86752 } else {
86753 val = convdiv * (*i) / convmul;
86754 - if (!first)
86755 + if (!first) {
86756 err = proc_put_char(&buffer, &left, '\t');
86757 + if (err)
86758 + break;
86759 + }
86760 err = proc_put_long(&buffer, &left, val, false);
86761 if (err)
86762 break;
86763 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
86764 return -ENOSYS;
86765 }
86766
86767 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86768 + void __user *buffer, size_t *lenp, loff_t *ppos)
86769 +{
86770 + return -ENOSYS;
86771 +}
86772 +
86773 int proc_dointvec(struct ctl_table *table, int write,
86774 void __user *buffer, size_t *lenp, loff_t *ppos)
86775 {
86776 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
86777 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
86778 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
86779 EXPORT_SYMBOL(proc_dostring);
86780 +EXPORT_SYMBOL(proc_dostring_modpriv);
86781 EXPORT_SYMBOL(proc_doulongvec_minmax);
86782 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
86783 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
86784 index 145bb4d..b2aa969 100644
86785 --- a/kernel/taskstats.c
86786 +++ b/kernel/taskstats.c
86787 @@ -28,9 +28,12 @@
86788 #include <linux/fs.h>
86789 #include <linux/file.h>
86790 #include <linux/pid_namespace.h>
86791 +#include <linux/grsecurity.h>
86792 #include <net/genetlink.h>
86793 #include <linux/atomic.h>
86794
86795 +extern int gr_is_taskstats_denied(int pid);
86796 +
86797 /*
86798 * Maximum length of a cpumask that can be specified in
86799 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
86800 @@ -570,6 +573,9 @@ err:
86801
86802 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
86803 {
86804 + if (gr_is_taskstats_denied(current->pid))
86805 + return -EACCES;
86806 +
86807 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
86808 return cmd_attr_register_cpumask(info);
86809 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
86810 diff --git a/kernel/time.c b/kernel/time.c
86811 index 7c7964c..2a0d412 100644
86812 --- a/kernel/time.c
86813 +++ b/kernel/time.c
86814 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
86815 return error;
86816
86817 if (tz) {
86818 + /* we log in do_settimeofday called below, so don't log twice
86819 + */
86820 + if (!tv)
86821 + gr_log_timechange();
86822 +
86823 sys_tz = *tz;
86824 update_vsyscall_tz();
86825 if (firsttime) {
86826 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
86827 index 88c9c65..7497ebc 100644
86828 --- a/kernel/time/alarmtimer.c
86829 +++ b/kernel/time/alarmtimer.c
86830 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
86831 struct platform_device *pdev;
86832 int error = 0;
86833 int i;
86834 - struct k_clock alarm_clock = {
86835 + static struct k_clock alarm_clock = {
86836 .clock_getres = alarm_clock_getres,
86837 .clock_get = alarm_clock_get,
86838 .timer_create = alarm_timer_create,
86839 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
86840 index 5cf6c70..ac341b0 100644
86841 --- a/kernel/time/timekeeping.c
86842 +++ b/kernel/time/timekeeping.c
86843 @@ -15,6 +15,7 @@
86844 #include <linux/init.h>
86845 #include <linux/mm.h>
86846 #include <linux/sched.h>
86847 +#include <linux/grsecurity.h>
86848 #include <linux/syscore_ops.h>
86849 #include <linux/clocksource.h>
86850 #include <linux/jiffies.h>
86851 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
86852 if (!timespec_valid_strict(tv))
86853 return -EINVAL;
86854
86855 + gr_log_timechange();
86856 +
86857 raw_spin_lock_irqsave(&timekeeper_lock, flags);
86858 write_seqcount_begin(&timekeeper_seq);
86859
86860 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
86861 index 61ed862..3b52c65 100644
86862 --- a/kernel/time/timer_list.c
86863 +++ b/kernel/time/timer_list.c
86864 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
86865
86866 static void print_name_offset(struct seq_file *m, void *sym)
86867 {
86868 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86869 + SEQ_printf(m, "<%p>", NULL);
86870 +#else
86871 char symname[KSYM_NAME_LEN];
86872
86873 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
86874 SEQ_printf(m, "<%pK>", sym);
86875 else
86876 SEQ_printf(m, "%s", symname);
86877 +#endif
86878 }
86879
86880 static void
86881 @@ -119,7 +123,11 @@ next_one:
86882 static void
86883 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
86884 {
86885 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86886 + SEQ_printf(m, " .base: %p\n", NULL);
86887 +#else
86888 SEQ_printf(m, " .base: %pK\n", base);
86889 +#endif
86890 SEQ_printf(m, " .index: %d\n",
86891 base->index);
86892 SEQ_printf(m, " .resolution: %Lu nsecs\n",
86893 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
86894 {
86895 struct proc_dir_entry *pe;
86896
86897 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86898 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
86899 +#else
86900 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
86901 +#endif
86902 if (!pe)
86903 return -ENOMEM;
86904 return 0;
86905 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
86906 index 0b537f2..40d6c20 100644
86907 --- a/kernel/time/timer_stats.c
86908 +++ b/kernel/time/timer_stats.c
86909 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
86910 static unsigned long nr_entries;
86911 static struct entry entries[MAX_ENTRIES];
86912
86913 -static atomic_t overflow_count;
86914 +static atomic_unchecked_t overflow_count;
86915
86916 /*
86917 * The entries are in a hash-table, for fast lookup:
86918 @@ -140,7 +140,7 @@ static void reset_entries(void)
86919 nr_entries = 0;
86920 memset(entries, 0, sizeof(entries));
86921 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
86922 - atomic_set(&overflow_count, 0);
86923 + atomic_set_unchecked(&overflow_count, 0);
86924 }
86925
86926 static struct entry *alloc_entry(void)
86927 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86928 if (likely(entry))
86929 entry->count++;
86930 else
86931 - atomic_inc(&overflow_count);
86932 + atomic_inc_unchecked(&overflow_count);
86933
86934 out_unlock:
86935 raw_spin_unlock_irqrestore(lock, flags);
86936 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86937
86938 static void print_name_offset(struct seq_file *m, unsigned long addr)
86939 {
86940 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86941 + seq_printf(m, "<%p>", NULL);
86942 +#else
86943 char symname[KSYM_NAME_LEN];
86944
86945 if (lookup_symbol_name(addr, symname) < 0)
86946 - seq_printf(m, "<%p>", (void *)addr);
86947 + seq_printf(m, "<%pK>", (void *)addr);
86948 else
86949 seq_printf(m, "%s", symname);
86950 +#endif
86951 }
86952
86953 static int tstats_show(struct seq_file *m, void *v)
86954 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
86955
86956 seq_puts(m, "Timer Stats Version: v0.2\n");
86957 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
86958 - if (atomic_read(&overflow_count))
86959 + if (atomic_read_unchecked(&overflow_count))
86960 seq_printf(m, "Overflow: %d entries\n",
86961 - atomic_read(&overflow_count));
86962 + atomic_read_unchecked(&overflow_count));
86963
86964 for (i = 0; i < nr_entries; i++) {
86965 entry = entries + i;
86966 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
86967 {
86968 struct proc_dir_entry *pe;
86969
86970 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86971 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
86972 +#else
86973 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
86974 +#endif
86975 if (!pe)
86976 return -ENOMEM;
86977 return 0;
86978 diff --git a/kernel/timer.c b/kernel/timer.c
86979 index 4296d13..0164b04 100644
86980 --- a/kernel/timer.c
86981 +++ b/kernel/timer.c
86982 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
86983 /*
86984 * This function runs timers and the timer-tq in bottom half context.
86985 */
86986 -static void run_timer_softirq(struct softirq_action *h)
86987 +static __latent_entropy void run_timer_softirq(void)
86988 {
86989 struct tvec_base *base = __this_cpu_read(tvec_bases);
86990
86991 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
86992 *
86993 * In all cases the return value is guaranteed to be non-negative.
86994 */
86995 -signed long __sched schedule_timeout(signed long timeout)
86996 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
86997 {
86998 struct timer_list timer;
86999 unsigned long expire;
87000 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
87001 index b8b8560..75b1a09 100644
87002 --- a/kernel/trace/blktrace.c
87003 +++ b/kernel/trace/blktrace.c
87004 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
87005 struct blk_trace *bt = filp->private_data;
87006 char buf[16];
87007
87008 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
87009 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
87010
87011 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
87012 }
87013 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
87014 return 1;
87015
87016 bt = buf->chan->private_data;
87017 - atomic_inc(&bt->dropped);
87018 + atomic_inc_unchecked(&bt->dropped);
87019 return 0;
87020 }
87021
87022 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
87023
87024 bt->dir = dir;
87025 bt->dev = dev;
87026 - atomic_set(&bt->dropped, 0);
87027 + atomic_set_unchecked(&bt->dropped, 0);
87028
87029 ret = -EIO;
87030 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
87031 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
87032 index 1345d9f..db46efe 100644
87033 --- a/kernel/trace/ftrace.c
87034 +++ b/kernel/trace/ftrace.c
87035 @@ -1944,12 +1944,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
87036 if (unlikely(ftrace_disabled))
87037 return 0;
87038
87039 + ret = ftrace_arch_code_modify_prepare();
87040 + FTRACE_WARN_ON(ret);
87041 + if (ret)
87042 + return 0;
87043 +
87044 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
87045 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
87046 if (ret) {
87047 ftrace_bug(ret, ip);
87048 - return 0;
87049 }
87050 - return 1;
87051 + return ret ? 0 : 1;
87052 }
87053
87054 /*
87055 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
87056 if (!count)
87057 return 0;
87058
87059 + pax_open_kernel();
87060 sort(start, count, sizeof(*start),
87061 ftrace_cmp_ips, ftrace_swap_ips);
87062 + pax_close_kernel();
87063
87064 start_pg = ftrace_allocate_pages(count);
87065 if (!start_pg)
87066 @@ -4766,8 +4773,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
87067 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
87068
87069 static int ftrace_graph_active;
87070 -static struct notifier_block ftrace_suspend_notifier;
87071 -
87072 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
87073 {
87074 return 0;
87075 @@ -4918,6 +4923,10 @@ static struct ftrace_ops fgraph_ops __read_mostly = {
87076 FTRACE_OPS_FL_RECURSION_SAFE,
87077 };
87078
87079 +static struct notifier_block ftrace_suspend_notifier = {
87080 + .notifier_call = ftrace_suspend_notifier_call
87081 +};
87082 +
87083 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
87084 trace_func_graph_ent_t entryfunc)
87085 {
87086 @@ -4931,7 +4940,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
87087 goto out;
87088 }
87089
87090 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
87091 register_pm_notifier(&ftrace_suspend_notifier);
87092
87093 ftrace_graph_active++;
87094 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
87095 index cc2f66f..05edd54 100644
87096 --- a/kernel/trace/ring_buffer.c
87097 +++ b/kernel/trace/ring_buffer.c
87098 @@ -352,9 +352,9 @@ struct buffer_data_page {
87099 */
87100 struct buffer_page {
87101 struct list_head list; /* list of buffer pages */
87102 - local_t write; /* index for next write */
87103 + local_unchecked_t write; /* index for next write */
87104 unsigned read; /* index for next read */
87105 - local_t entries; /* entries on this page */
87106 + local_unchecked_t entries; /* entries on this page */
87107 unsigned long real_end; /* real end of data */
87108 struct buffer_data_page *page; /* Actual data page */
87109 };
87110 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
87111 unsigned long last_overrun;
87112 local_t entries_bytes;
87113 local_t entries;
87114 - local_t overrun;
87115 - local_t commit_overrun;
87116 + local_unchecked_t overrun;
87117 + local_unchecked_t commit_overrun;
87118 local_t dropped_events;
87119 local_t committing;
87120 local_t commits;
87121 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
87122 *
87123 * We add a counter to the write field to denote this.
87124 */
87125 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
87126 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
87127 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
87128 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
87129
87130 /*
87131 * Just make sure we have seen our old_write and synchronize
87132 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
87133 * cmpxchg to only update if an interrupt did not already
87134 * do it for us. If the cmpxchg fails, we don't care.
87135 */
87136 - (void)local_cmpxchg(&next_page->write, old_write, val);
87137 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
87138 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
87139 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
87140
87141 /*
87142 * No need to worry about races with clearing out the commit.
87143 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
87144
87145 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
87146 {
87147 - return local_read(&bpage->entries) & RB_WRITE_MASK;
87148 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
87149 }
87150
87151 static inline unsigned long rb_page_write(struct buffer_page *bpage)
87152 {
87153 - return local_read(&bpage->write) & RB_WRITE_MASK;
87154 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
87155 }
87156
87157 static int
87158 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
87159 * bytes consumed in ring buffer from here.
87160 * Increment overrun to account for the lost events.
87161 */
87162 - local_add(page_entries, &cpu_buffer->overrun);
87163 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
87164 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
87165 }
87166
87167 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
87168 * it is our responsibility to update
87169 * the counters.
87170 */
87171 - local_add(entries, &cpu_buffer->overrun);
87172 + local_add_unchecked(entries, &cpu_buffer->overrun);
87173 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
87174
87175 /*
87176 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
87177 if (tail == BUF_PAGE_SIZE)
87178 tail_page->real_end = 0;
87179
87180 - local_sub(length, &tail_page->write);
87181 + local_sub_unchecked(length, &tail_page->write);
87182 return;
87183 }
87184
87185 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
87186 rb_event_set_padding(event);
87187
87188 /* Set the write back to the previous setting */
87189 - local_sub(length, &tail_page->write);
87190 + local_sub_unchecked(length, &tail_page->write);
87191 return;
87192 }
87193
87194 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
87195
87196 /* Set write to end of buffer */
87197 length = (tail + length) - BUF_PAGE_SIZE;
87198 - local_sub(length, &tail_page->write);
87199 + local_sub_unchecked(length, &tail_page->write);
87200 }
87201
87202 /*
87203 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
87204 * about it.
87205 */
87206 if (unlikely(next_page == commit_page)) {
87207 - local_inc(&cpu_buffer->commit_overrun);
87208 + local_inc_unchecked(&cpu_buffer->commit_overrun);
87209 goto out_reset;
87210 }
87211
87212 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
87213 cpu_buffer->tail_page) &&
87214 (cpu_buffer->commit_page ==
87215 cpu_buffer->reader_page))) {
87216 - local_inc(&cpu_buffer->commit_overrun);
87217 + local_inc_unchecked(&cpu_buffer->commit_overrun);
87218 goto out_reset;
87219 }
87220 }
87221 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
87222 length += RB_LEN_TIME_EXTEND;
87223
87224 tail_page = cpu_buffer->tail_page;
87225 - write = local_add_return(length, &tail_page->write);
87226 + write = local_add_return_unchecked(length, &tail_page->write);
87227
87228 /* set write to only the index of the write */
87229 write &= RB_WRITE_MASK;
87230 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
87231 kmemcheck_annotate_bitfield(event, bitfield);
87232 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
87233
87234 - local_inc(&tail_page->entries);
87235 + local_inc_unchecked(&tail_page->entries);
87236
87237 /*
87238 * If this is the first commit on the page, then update
87239 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
87240
87241 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
87242 unsigned long write_mask =
87243 - local_read(&bpage->write) & ~RB_WRITE_MASK;
87244 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
87245 unsigned long event_length = rb_event_length(event);
87246 /*
87247 * This is on the tail page. It is possible that
87248 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
87249 */
87250 old_index += write_mask;
87251 new_index += write_mask;
87252 - index = local_cmpxchg(&bpage->write, old_index, new_index);
87253 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
87254 if (index == old_index) {
87255 /* update counters */
87256 local_sub(event_length, &cpu_buffer->entries_bytes);
87257 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
87258
87259 /* Do the likely case first */
87260 if (likely(bpage->page == (void *)addr)) {
87261 - local_dec(&bpage->entries);
87262 + local_dec_unchecked(&bpage->entries);
87263 return;
87264 }
87265
87266 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
87267 start = bpage;
87268 do {
87269 if (bpage->page == (void *)addr) {
87270 - local_dec(&bpage->entries);
87271 + local_dec_unchecked(&bpage->entries);
87272 return;
87273 }
87274 rb_inc_page(cpu_buffer, &bpage);
87275 @@ -3139,7 +3139,7 @@ static inline unsigned long
87276 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
87277 {
87278 return local_read(&cpu_buffer->entries) -
87279 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
87280 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
87281 }
87282
87283 /**
87284 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
87285 return 0;
87286
87287 cpu_buffer = buffer->buffers[cpu];
87288 - ret = local_read(&cpu_buffer->overrun);
87289 + ret = local_read_unchecked(&cpu_buffer->overrun);
87290
87291 return ret;
87292 }
87293 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
87294 return 0;
87295
87296 cpu_buffer = buffer->buffers[cpu];
87297 - ret = local_read(&cpu_buffer->commit_overrun);
87298 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
87299
87300 return ret;
87301 }
87302 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
87303 /* if you care about this being correct, lock the buffer */
87304 for_each_buffer_cpu(buffer, cpu) {
87305 cpu_buffer = buffer->buffers[cpu];
87306 - overruns += local_read(&cpu_buffer->overrun);
87307 + overruns += local_read_unchecked(&cpu_buffer->overrun);
87308 }
87309
87310 return overruns;
87311 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
87312 /*
87313 * Reset the reader page to size zero.
87314 */
87315 - local_set(&cpu_buffer->reader_page->write, 0);
87316 - local_set(&cpu_buffer->reader_page->entries, 0);
87317 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
87318 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
87319 local_set(&cpu_buffer->reader_page->page->commit, 0);
87320 cpu_buffer->reader_page->real_end = 0;
87321
87322 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
87323 * want to compare with the last_overrun.
87324 */
87325 smp_mb();
87326 - overwrite = local_read(&(cpu_buffer->overrun));
87327 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
87328
87329 /*
87330 * Here's the tricky part.
87331 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
87332
87333 cpu_buffer->head_page
87334 = list_entry(cpu_buffer->pages, struct buffer_page, list);
87335 - local_set(&cpu_buffer->head_page->write, 0);
87336 - local_set(&cpu_buffer->head_page->entries, 0);
87337 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
87338 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
87339 local_set(&cpu_buffer->head_page->page->commit, 0);
87340
87341 cpu_buffer->head_page->read = 0;
87342 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
87343
87344 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
87345 INIT_LIST_HEAD(&cpu_buffer->new_pages);
87346 - local_set(&cpu_buffer->reader_page->write, 0);
87347 - local_set(&cpu_buffer->reader_page->entries, 0);
87348 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
87349 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
87350 local_set(&cpu_buffer->reader_page->page->commit, 0);
87351 cpu_buffer->reader_page->read = 0;
87352
87353 local_set(&cpu_buffer->entries_bytes, 0);
87354 - local_set(&cpu_buffer->overrun, 0);
87355 - local_set(&cpu_buffer->commit_overrun, 0);
87356 + local_set_unchecked(&cpu_buffer->overrun, 0);
87357 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
87358 local_set(&cpu_buffer->dropped_events, 0);
87359 local_set(&cpu_buffer->entries, 0);
87360 local_set(&cpu_buffer->committing, 0);
87361 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
87362 rb_init_page(bpage);
87363 bpage = reader->page;
87364 reader->page = *data_page;
87365 - local_set(&reader->write, 0);
87366 - local_set(&reader->entries, 0);
87367 + local_set_unchecked(&reader->write, 0);
87368 + local_set_unchecked(&reader->entries, 0);
87369 reader->read = 0;
87370 *data_page = bpage;
87371
87372 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
87373 index b778e96..4e84621 100644
87374 --- a/kernel/trace/trace.c
87375 +++ b/kernel/trace/trace.c
87376 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
87377 return 0;
87378 }
87379
87380 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
87381 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
87382 {
87383 /* do nothing if flag is already set */
87384 if (!!(trace_flags & mask) == !!enabled)
87385 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
87386 index 10c86fb..645ab0a 100644
87387 --- a/kernel/trace/trace.h
87388 +++ b/kernel/trace/trace.h
87389 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
87390 void trace_printk_init_buffers(void);
87391 void trace_printk_start_comm(void);
87392 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
87393 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
87394 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
87395
87396 /*
87397 * Normal trace_printk() and friends allocates special buffers
87398 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
87399 index 26dc348..8708ca7 100644
87400 --- a/kernel/trace/trace_clock.c
87401 +++ b/kernel/trace/trace_clock.c
87402 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
87403 return now;
87404 }
87405
87406 -static atomic64_t trace_counter;
87407 +static atomic64_unchecked_t trace_counter;
87408
87409 /*
87410 * trace_clock_counter(): simply an atomic counter.
87411 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
87412 */
87413 u64 notrace trace_clock_counter(void)
87414 {
87415 - return atomic64_add_return(1, &trace_counter);
87416 + return atomic64_inc_return_unchecked(&trace_counter);
87417 }
87418 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
87419 index 368a4d5..7b6d1d5 100644
87420 --- a/kernel/trace/trace_events.c
87421 +++ b/kernel/trace/trace_events.c
87422 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
87423 return 0;
87424 }
87425
87426 -struct ftrace_module_file_ops;
87427 static void __add_event_to_tracers(struct ftrace_event_call *call);
87428
87429 /* Add an additional event_call dynamically */
87430 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
87431 index b3dcfb2..ebee344 100644
87432 --- a/kernel/trace/trace_mmiotrace.c
87433 +++ b/kernel/trace/trace_mmiotrace.c
87434 @@ -24,7 +24,7 @@ struct header_iter {
87435 static struct trace_array *mmio_trace_array;
87436 static bool overrun_detected;
87437 static unsigned long prev_overruns;
87438 -static atomic_t dropped_count;
87439 +static atomic_unchecked_t dropped_count;
87440
87441 static void mmio_reset_data(struct trace_array *tr)
87442 {
87443 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
87444
87445 static unsigned long count_overruns(struct trace_iterator *iter)
87446 {
87447 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
87448 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
87449 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
87450
87451 if (over > prev_overruns)
87452 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
87453 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
87454 sizeof(*entry), 0, pc);
87455 if (!event) {
87456 - atomic_inc(&dropped_count);
87457 + atomic_inc_unchecked(&dropped_count);
87458 return;
87459 }
87460 entry = ring_buffer_event_data(event);
87461 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
87462 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
87463 sizeof(*entry), 0, pc);
87464 if (!event) {
87465 - atomic_inc(&dropped_count);
87466 + atomic_inc_unchecked(&dropped_count);
87467 return;
87468 }
87469 entry = ring_buffer_event_data(event);
87470 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
87471 index 34e7cba..6f9a729 100644
87472 --- a/kernel/trace/trace_output.c
87473 +++ b/kernel/trace/trace_output.c
87474 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
87475
87476 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
87477 if (!IS_ERR(p)) {
87478 - p = mangle_path(s->buffer + s->len, p, "\n");
87479 + p = mangle_path(s->buffer + s->len, p, "\n\\");
87480 if (p) {
87481 s->len = p - s->buffer;
87482 return 1;
87483 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
87484 goto out;
87485 }
87486
87487 + pax_open_kernel();
87488 if (event->funcs->trace == NULL)
87489 - event->funcs->trace = trace_nop_print;
87490 + *(void **)&event->funcs->trace = trace_nop_print;
87491 if (event->funcs->raw == NULL)
87492 - event->funcs->raw = trace_nop_print;
87493 + *(void **)&event->funcs->raw = trace_nop_print;
87494 if (event->funcs->hex == NULL)
87495 - event->funcs->hex = trace_nop_print;
87496 + *(void **)&event->funcs->hex = trace_nop_print;
87497 if (event->funcs->binary == NULL)
87498 - event->funcs->binary = trace_nop_print;
87499 + *(void **)&event->funcs->binary = trace_nop_print;
87500 + pax_close_kernel();
87501
87502 key = event->type & (EVENT_HASHSIZE - 1);
87503
87504 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
87505 index b20428c..4845a10 100644
87506 --- a/kernel/trace/trace_stack.c
87507 +++ b/kernel/trace/trace_stack.c
87508 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
87509 return;
87510
87511 /* we do not handle interrupt stacks yet */
87512 - if (!object_is_on_stack(stack))
87513 + if (!object_starts_on_stack(stack))
87514 return;
87515
87516 local_irq_save(flags);
87517 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
87518 index 13fb113..a6ced3f 100644
87519 --- a/kernel/user_namespace.c
87520 +++ b/kernel/user_namespace.c
87521 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
87522 !kgid_has_mapping(parent_ns, group))
87523 return -EPERM;
87524
87525 +#ifdef CONFIG_GRKERNSEC
87526 + /*
87527 + * This doesn't really inspire confidence:
87528 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
87529 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
87530 + * Increases kernel attack surface in areas developers
87531 + * previously cared little about ("low importance due
87532 + * to requiring "root" capability")
87533 + * To be removed when this code receives *proper* review
87534 + */
87535 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
87536 + !capable(CAP_SETGID))
87537 + return -EPERM;
87538 +#endif
87539 +
87540 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
87541 if (!ns)
87542 return -ENOMEM;
87543 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
87544 if (atomic_read(&current->mm->mm_users) > 1)
87545 return -EINVAL;
87546
87547 - if (current->fs->users != 1)
87548 + if (atomic_read(&current->fs->users) != 1)
87549 return -EINVAL;
87550
87551 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
87552 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
87553 index 4f69f9a..7c6f8f8 100644
87554 --- a/kernel/utsname_sysctl.c
87555 +++ b/kernel/utsname_sysctl.c
87556 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
87557 static int proc_do_uts_string(ctl_table *table, int write,
87558 void __user *buffer, size_t *lenp, loff_t *ppos)
87559 {
87560 - struct ctl_table uts_table;
87561 + ctl_table_no_const uts_table;
87562 int r;
87563 memcpy(&uts_table, table, sizeof(uts_table));
87564 uts_table.data = get_uts(table, write);
87565 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
87566 index 4431610..4265616 100644
87567 --- a/kernel/watchdog.c
87568 +++ b/kernel/watchdog.c
87569 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
87570 static void watchdog_nmi_disable(unsigned int cpu) { return; }
87571 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
87572
87573 -static struct smp_hotplug_thread watchdog_threads = {
87574 +static struct smp_hotplug_thread watchdog_threads __read_only = {
87575 .store = &softlockup_watchdog,
87576 .thread_should_run = watchdog_should_run,
87577 .thread_fn = watchdog,
87578 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
87579 index 93c2652..66a1cfd 100644
87580 --- a/kernel/workqueue.c
87581 +++ b/kernel/workqueue.c
87582 @@ -4668,7 +4668,7 @@ static void rebind_workers(struct worker_pool *pool)
87583 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
87584 worker_flags |= WORKER_REBOUND;
87585 worker_flags &= ~WORKER_UNBOUND;
87586 - ACCESS_ONCE(worker->flags) = worker_flags;
87587 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
87588 }
87589
87590 spin_unlock_irq(&pool->lock);
87591 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
87592 index 094f315..244a824 100644
87593 --- a/lib/Kconfig.debug
87594 +++ b/lib/Kconfig.debug
87595 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
87596
87597 config DEBUG_WW_MUTEX_SLOWPATH
87598 bool "Wait/wound mutex debugging: Slowpath testing"
87599 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87600 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87601 select DEBUG_LOCK_ALLOC
87602 select DEBUG_SPINLOCK
87603 select DEBUG_MUTEXES
87604 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
87605
87606 config DEBUG_LOCK_ALLOC
87607 bool "Lock debugging: detect incorrect freeing of live locks"
87608 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87609 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87610 select DEBUG_SPINLOCK
87611 select DEBUG_MUTEXES
87612 select LOCKDEP
87613 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
87614
87615 config PROVE_LOCKING
87616 bool "Lock debugging: prove locking correctness"
87617 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87618 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87619 select LOCKDEP
87620 select DEBUG_SPINLOCK
87621 select DEBUG_MUTEXES
87622 @@ -914,7 +914,7 @@ config LOCKDEP
87623
87624 config LOCK_STAT
87625 bool "Lock usage statistics"
87626 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87627 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87628 select LOCKDEP
87629 select DEBUG_SPINLOCK
87630 select DEBUG_MUTEXES
87631 @@ -1376,6 +1376,7 @@ config LATENCYTOP
87632 depends on DEBUG_KERNEL
87633 depends on STACKTRACE_SUPPORT
87634 depends on PROC_FS
87635 + depends on !GRKERNSEC_HIDESYM
87636 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
87637 select KALLSYMS
87638 select KALLSYMS_ALL
87639 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87640 config DEBUG_STRICT_USER_COPY_CHECKS
87641 bool "Strict user copy size checks"
87642 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87643 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
87644 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
87645 help
87646 Enabling this option turns a certain set of sanity checks for user
87647 copy operations into compile time failures.
87648 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
87649
87650 config PROVIDE_OHCI1394_DMA_INIT
87651 bool "Remote debugging over FireWire early on boot"
87652 - depends on PCI && X86
87653 + depends on PCI && X86 && !GRKERNSEC
87654 help
87655 If you want to debug problems which hang or crash the kernel early
87656 on boot and the crashing machine has a FireWire port, you can use
87657 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
87658
87659 config FIREWIRE_OHCI_REMOTE_DMA
87660 bool "Remote debugging over FireWire with firewire-ohci"
87661 - depends on FIREWIRE_OHCI
87662 + depends on FIREWIRE_OHCI && !GRKERNSEC
87663 help
87664 This option lets you use the FireWire bus for remote debugging
87665 with help of the firewire-ohci driver. It enables unfiltered
87666 diff --git a/lib/Makefile b/lib/Makefile
87667 index f3bb2cb..b358ace 100644
87668 --- a/lib/Makefile
87669 +++ b/lib/Makefile
87670 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
87671
87672 obj-$(CONFIG_BTREE) += btree.o
87673 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
87674 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
87675 +obj-y += list_debug.o
87676 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
87677
87678 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
87679 diff --git a/lib/bitmap.c b/lib/bitmap.c
87680 index 06f7e4f..f3cf2b0 100644
87681 --- a/lib/bitmap.c
87682 +++ b/lib/bitmap.c
87683 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
87684 {
87685 int c, old_c, totaldigits, ndigits, nchunks, nbits;
87686 u32 chunk;
87687 - const char __user __force *ubuf = (const char __user __force *)buf;
87688 + const char __user *ubuf = (const char __force_user *)buf;
87689
87690 bitmap_zero(maskp, nmaskbits);
87691
87692 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
87693 {
87694 if (!access_ok(VERIFY_READ, ubuf, ulen))
87695 return -EFAULT;
87696 - return __bitmap_parse((const char __force *)ubuf,
87697 + return __bitmap_parse((const char __force_kernel *)ubuf,
87698 ulen, 1, maskp, nmaskbits);
87699
87700 }
87701 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
87702 {
87703 unsigned a, b;
87704 int c, old_c, totaldigits;
87705 - const char __user __force *ubuf = (const char __user __force *)buf;
87706 + const char __user *ubuf = (const char __force_user *)buf;
87707 int exp_digit, in_range;
87708
87709 totaldigits = c = 0;
87710 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
87711 {
87712 if (!access_ok(VERIFY_READ, ubuf, ulen))
87713 return -EFAULT;
87714 - return __bitmap_parselist((const char __force *)ubuf,
87715 + return __bitmap_parselist((const char __force_kernel *)ubuf,
87716 ulen, 1, maskp, nmaskbits);
87717 }
87718 EXPORT_SYMBOL(bitmap_parselist_user);
87719 diff --git a/lib/bug.c b/lib/bug.c
87720 index 1686034..a9c00c8 100644
87721 --- a/lib/bug.c
87722 +++ b/lib/bug.c
87723 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
87724 return BUG_TRAP_TYPE_NONE;
87725
87726 bug = find_bug(bugaddr);
87727 + if (!bug)
87728 + return BUG_TRAP_TYPE_NONE;
87729
87730 file = NULL;
87731 line = 0;
87732 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
87733 index bf2c8b1..1d00ccf 100644
87734 --- a/lib/debugobjects.c
87735 +++ b/lib/debugobjects.c
87736 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
87737 if (limit > 4)
87738 return;
87739
87740 - is_on_stack = object_is_on_stack(addr);
87741 + is_on_stack = object_starts_on_stack(addr);
87742 if (is_on_stack == onstack)
87743 return;
87744
87745 diff --git a/lib/devres.c b/lib/devres.c
87746 index 8235331..5881053 100644
87747 --- a/lib/devres.c
87748 +++ b/lib/devres.c
87749 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
87750 void devm_iounmap(struct device *dev, void __iomem *addr)
87751 {
87752 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
87753 - (void *)addr));
87754 + (void __force *)addr));
87755 iounmap(addr);
87756 }
87757 EXPORT_SYMBOL(devm_iounmap);
87758 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
87759 {
87760 ioport_unmap(addr);
87761 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
87762 - devm_ioport_map_match, (void *)addr));
87763 + devm_ioport_map_match, (void __force *)addr));
87764 }
87765 EXPORT_SYMBOL(devm_ioport_unmap);
87766 #endif /* CONFIG_HAS_IOPORT */
87767 diff --git a/lib/div64.c b/lib/div64.c
87768 index 4382ad7..08aa558 100644
87769 --- a/lib/div64.c
87770 +++ b/lib/div64.c
87771 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
87772 EXPORT_SYMBOL(__div64_32);
87773
87774 #ifndef div_s64_rem
87775 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87776 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87777 {
87778 u64 quotient;
87779
87780 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
87781 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
87782 */
87783 #ifndef div64_u64
87784 -u64 div64_u64(u64 dividend, u64 divisor)
87785 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
87786 {
87787 u32 high = divisor >> 32;
87788 u64 quot;
87789 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
87790 index d87a17a..ac0d79a 100644
87791 --- a/lib/dma-debug.c
87792 +++ b/lib/dma-debug.c
87793 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
87794
87795 void dma_debug_add_bus(struct bus_type *bus)
87796 {
87797 - struct notifier_block *nb;
87798 + notifier_block_no_const *nb;
87799
87800 if (global_disable)
87801 return;
87802 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
87803
87804 static void check_for_stack(struct device *dev, void *addr)
87805 {
87806 - if (object_is_on_stack(addr))
87807 + if (object_starts_on_stack(addr))
87808 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
87809 "stack [addr=%p]\n", addr);
87810 }
87811 diff --git a/lib/inflate.c b/lib/inflate.c
87812 index 013a761..c28f3fc 100644
87813 --- a/lib/inflate.c
87814 +++ b/lib/inflate.c
87815 @@ -269,7 +269,7 @@ static void free(void *where)
87816 malloc_ptr = free_mem_ptr;
87817 }
87818 #else
87819 -#define malloc(a) kmalloc(a, GFP_KERNEL)
87820 +#define malloc(a) kmalloc((a), GFP_KERNEL)
87821 #define free(a) kfree(a)
87822 #endif
87823
87824 diff --git a/lib/ioremap.c b/lib/ioremap.c
87825 index 0c9216c..863bd89 100644
87826 --- a/lib/ioremap.c
87827 +++ b/lib/ioremap.c
87828 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
87829 unsigned long next;
87830
87831 phys_addr -= addr;
87832 - pmd = pmd_alloc(&init_mm, pud, addr);
87833 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
87834 if (!pmd)
87835 return -ENOMEM;
87836 do {
87837 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
87838 unsigned long next;
87839
87840 phys_addr -= addr;
87841 - pud = pud_alloc(&init_mm, pgd, addr);
87842 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
87843 if (!pud)
87844 return -ENOMEM;
87845 do {
87846 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
87847 index bd2bea9..6b3c95e 100644
87848 --- a/lib/is_single_threaded.c
87849 +++ b/lib/is_single_threaded.c
87850 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
87851 struct task_struct *p, *t;
87852 bool ret;
87853
87854 + if (!mm)
87855 + return true;
87856 +
87857 if (atomic_read(&task->signal->live) != 1)
87858 return false;
87859
87860 diff --git a/lib/kobject.c b/lib/kobject.c
87861 index 084f7b1..d265b8a 100644
87862 --- a/lib/kobject.c
87863 +++ b/lib/kobject.c
87864 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
87865
87866
87867 static DEFINE_SPINLOCK(kobj_ns_type_lock);
87868 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
87869 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
87870
87871 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87872 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87873 {
87874 enum kobj_ns_type type = ops->type;
87875 int error;
87876 diff --git a/lib/list_debug.c b/lib/list_debug.c
87877 index c24c2f7..f0296f4 100644
87878 --- a/lib/list_debug.c
87879 +++ b/lib/list_debug.c
87880 @@ -11,7 +11,9 @@
87881 #include <linux/bug.h>
87882 #include <linux/kernel.h>
87883 #include <linux/rculist.h>
87884 +#include <linux/mm.h>
87885
87886 +#ifdef CONFIG_DEBUG_LIST
87887 /*
87888 * Insert a new entry between two known consecutive entries.
87889 *
87890 @@ -19,21 +21,40 @@
87891 * the prev/next entries already!
87892 */
87893
87894 +static bool __list_add_debug(struct list_head *new,
87895 + struct list_head *prev,
87896 + struct list_head *next)
87897 +{
87898 + if (unlikely(next->prev != prev)) {
87899 + printk(KERN_ERR "list_add corruption. next->prev should be "
87900 + "prev (%p), but was %p. (next=%p).\n",
87901 + prev, next->prev, next);
87902 + BUG();
87903 + return false;
87904 + }
87905 + if (unlikely(prev->next != next)) {
87906 + printk(KERN_ERR "list_add corruption. prev->next should be "
87907 + "next (%p), but was %p. (prev=%p).\n",
87908 + next, prev->next, prev);
87909 + BUG();
87910 + return false;
87911 + }
87912 + if (unlikely(new == prev || new == next)) {
87913 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
87914 + new, prev, next);
87915 + BUG();
87916 + return false;
87917 + }
87918 + return true;
87919 +}
87920 +
87921 void __list_add(struct list_head *new,
87922 - struct list_head *prev,
87923 - struct list_head *next)
87924 + struct list_head *prev,
87925 + struct list_head *next)
87926 {
87927 - WARN(next->prev != prev,
87928 - "list_add corruption. next->prev should be "
87929 - "prev (%p), but was %p. (next=%p).\n",
87930 - prev, next->prev, next);
87931 - WARN(prev->next != next,
87932 - "list_add corruption. prev->next should be "
87933 - "next (%p), but was %p. (prev=%p).\n",
87934 - next, prev->next, prev);
87935 - WARN(new == prev || new == next,
87936 - "list_add double add: new=%p, prev=%p, next=%p.\n",
87937 - new, prev, next);
87938 + if (!__list_add_debug(new, prev, next))
87939 + return;
87940 +
87941 next->prev = new;
87942 new->next = next;
87943 new->prev = prev;
87944 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
87945 }
87946 EXPORT_SYMBOL(__list_add);
87947
87948 -void __list_del_entry(struct list_head *entry)
87949 +static bool __list_del_entry_debug(struct list_head *entry)
87950 {
87951 struct list_head *prev, *next;
87952
87953 prev = entry->prev;
87954 next = entry->next;
87955
87956 - if (WARN(next == LIST_POISON1,
87957 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87958 - entry, LIST_POISON1) ||
87959 - WARN(prev == LIST_POISON2,
87960 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87961 - entry, LIST_POISON2) ||
87962 - WARN(prev->next != entry,
87963 - "list_del corruption. prev->next should be %p, "
87964 - "but was %p\n", entry, prev->next) ||
87965 - WARN(next->prev != entry,
87966 - "list_del corruption. next->prev should be %p, "
87967 - "but was %p\n", entry, next->prev))
87968 + if (unlikely(next == LIST_POISON1)) {
87969 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87970 + entry, LIST_POISON1);
87971 + BUG();
87972 + return false;
87973 + }
87974 + if (unlikely(prev == LIST_POISON2)) {
87975 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87976 + entry, LIST_POISON2);
87977 + BUG();
87978 + return false;
87979 + }
87980 + if (unlikely(entry->prev->next != entry)) {
87981 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
87982 + "but was %p\n", entry, prev->next);
87983 + BUG();
87984 + return false;
87985 + }
87986 + if (unlikely(entry->next->prev != entry)) {
87987 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
87988 + "but was %p\n", entry, next->prev);
87989 + BUG();
87990 + return false;
87991 + }
87992 + return true;
87993 +}
87994 +
87995 +void __list_del_entry(struct list_head *entry)
87996 +{
87997 + if (!__list_del_entry_debug(entry))
87998 return;
87999
88000 - __list_del(prev, next);
88001 + __list_del(entry->prev, entry->next);
88002 }
88003 EXPORT_SYMBOL(__list_del_entry);
88004
88005 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
88006 void __list_add_rcu(struct list_head *new,
88007 struct list_head *prev, struct list_head *next)
88008 {
88009 - WARN(next->prev != prev,
88010 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
88011 - prev, next->prev, next);
88012 - WARN(prev->next != next,
88013 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
88014 - next, prev->next, prev);
88015 + if (!__list_add_debug(new, prev, next))
88016 + return;
88017 +
88018 new->next = next;
88019 new->prev = prev;
88020 rcu_assign_pointer(list_next_rcu(prev), new);
88021 next->prev = new;
88022 }
88023 EXPORT_SYMBOL(__list_add_rcu);
88024 +#endif
88025 +
88026 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
88027 +{
88028 +#ifdef CONFIG_DEBUG_LIST
88029 + if (!__list_add_debug(new, prev, next))
88030 + return;
88031 +#endif
88032 +
88033 + pax_open_kernel();
88034 + next->prev = new;
88035 + new->next = next;
88036 + new->prev = prev;
88037 + prev->next = new;
88038 + pax_close_kernel();
88039 +}
88040 +EXPORT_SYMBOL(__pax_list_add);
88041 +
88042 +void pax_list_del(struct list_head *entry)
88043 +{
88044 +#ifdef CONFIG_DEBUG_LIST
88045 + if (!__list_del_entry_debug(entry))
88046 + return;
88047 +#endif
88048 +
88049 + pax_open_kernel();
88050 + __list_del(entry->prev, entry->next);
88051 + entry->next = LIST_POISON1;
88052 + entry->prev = LIST_POISON2;
88053 + pax_close_kernel();
88054 +}
88055 +EXPORT_SYMBOL(pax_list_del);
88056 +
88057 +void pax_list_del_init(struct list_head *entry)
88058 +{
88059 + pax_open_kernel();
88060 + __list_del(entry->prev, entry->next);
88061 + INIT_LIST_HEAD(entry);
88062 + pax_close_kernel();
88063 +}
88064 +EXPORT_SYMBOL(pax_list_del_init);
88065 +
88066 +void __pax_list_add_rcu(struct list_head *new,
88067 + struct list_head *prev, struct list_head *next)
88068 +{
88069 +#ifdef CONFIG_DEBUG_LIST
88070 + if (!__list_add_debug(new, prev, next))
88071 + return;
88072 +#endif
88073 +
88074 + pax_open_kernel();
88075 + new->next = next;
88076 + new->prev = prev;
88077 + rcu_assign_pointer(list_next_rcu(prev), new);
88078 + next->prev = new;
88079 + pax_close_kernel();
88080 +}
88081 +EXPORT_SYMBOL(__pax_list_add_rcu);
88082 +
88083 +void pax_list_del_rcu(struct list_head *entry)
88084 +{
88085 +#ifdef CONFIG_DEBUG_LIST
88086 + if (!__list_del_entry_debug(entry))
88087 + return;
88088 +#endif
88089 +
88090 + pax_open_kernel();
88091 + __list_del(entry->prev, entry->next);
88092 + entry->next = LIST_POISON1;
88093 + entry->prev = LIST_POISON2;
88094 + pax_close_kernel();
88095 +}
88096 +EXPORT_SYMBOL(pax_list_del_rcu);
88097 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
88098 index 1a53d49..ace934c 100644
88099 --- a/lib/percpu-refcount.c
88100 +++ b/lib/percpu-refcount.c
88101 @@ -29,7 +29,7 @@
88102 * can't hit 0 before we've added up all the percpu refs.
88103 */
88104
88105 -#define PCPU_COUNT_BIAS (1U << 31)
88106 +#define PCPU_COUNT_BIAS (1U << 30)
88107
88108 /**
88109 * percpu_ref_init - initialize a percpu refcount
88110 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
88111 index 7811ed3..f80ca19 100644
88112 --- a/lib/radix-tree.c
88113 +++ b/lib/radix-tree.c
88114 @@ -93,7 +93,7 @@ struct radix_tree_preload {
88115 int nr;
88116 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
88117 };
88118 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
88119 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
88120
88121 static inline void *ptr_to_indirect(void *ptr)
88122 {
88123 diff --git a/lib/random32.c b/lib/random32.c
88124 index 01e8890..1e5b2df 100644
88125 --- a/lib/random32.c
88126 +++ b/lib/random32.c
88127 @@ -2,19 +2,19 @@
88128 This is a maximally equidistributed combined Tausworthe generator
88129 based on code from GNU Scientific Library 1.5 (30 Jun 2004)
88130
88131 - x_n = (s1_n ^ s2_n ^ s3_n)
88132 + lfsr113 version:
88133
88134 - s1_{n+1} = (((s1_n & 4294967294) <<12) ^ (((s1_n <<13) ^ s1_n) >>19))
88135 - s2_{n+1} = (((s2_n & 4294967288) << 4) ^ (((s2_n << 2) ^ s2_n) >>25))
88136 - s3_{n+1} = (((s3_n & 4294967280) <<17) ^ (((s3_n << 3) ^ s3_n) >>11))
88137 + x_n = (s1_n ^ s2_n ^ s3_n ^ s4_n)
88138
88139 - The period of this generator is about 2^88.
88140 + s1_{n+1} = (((s1_n & 4294967294) << 18) ^ (((s1_n << 6) ^ s1_n) >> 13))
88141 + s2_{n+1} = (((s2_n & 4294967288) << 2) ^ (((s2_n << 2) ^ s2_n) >> 27))
88142 + s3_{n+1} = (((s3_n & 4294967280) << 7) ^ (((s3_n << 13) ^ s3_n) >> 21))
88143 + s4_{n+1} = (((s4_n & 4294967168) << 13) ^ (((s4_n << 3) ^ s4_n) >> 12))
88144 +
88145 + The period of this generator is about 2^113 (see erratum paper).
88146
88147 From: P. L'Ecuyer, "Maximally Equidistributed Combined Tausworthe
88148 - Generators", Mathematics of Computation, 65, 213 (1996), 203--213.
88149 -
88150 - This is available on the net from L'Ecuyer's home page,
88151 -
88152 + Generators", Mathematics of Computation, 65, 213 (1996), 203--213:
88153 http://www.iro.umontreal.ca/~lecuyer/myftp/papers/tausme.ps
88154 ftp://ftp.iro.umontreal.ca/pub/simulation/lecuyer/papers/tausme.ps
88155
88156 @@ -29,7 +29,7 @@
88157 that paper.)
88158
88159 This affects the seeding procedure by imposing the requirement
88160 - s1 > 1, s2 > 7, s3 > 15.
88161 + s1 > 1, s2 > 7, s3 > 15, s4 > 127.
88162
88163 */
88164
88165 @@ -38,6 +38,11 @@
88166 #include <linux/export.h>
88167 #include <linux/jiffies.h>
88168 #include <linux/random.h>
88169 +#include <linux/sched.h>
88170 +
88171 +#ifdef CONFIG_RANDOM32_SELFTEST
88172 +static void __init prandom_state_selftest(void);
88173 +#endif
88174
88175 static DEFINE_PER_CPU(struct rnd_state, net_rand_state);
88176
88177 @@ -52,11 +57,12 @@ u32 prandom_u32_state(struct rnd_state *state)
88178 {
88179 #define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b)
88180
88181 - state->s1 = TAUSWORTHE(state->s1, 13, 19, 4294967294UL, 12);
88182 - state->s2 = TAUSWORTHE(state->s2, 2, 25, 4294967288UL, 4);
88183 - state->s3 = TAUSWORTHE(state->s3, 3, 11, 4294967280UL, 17);
88184 + state->s1 = TAUSWORTHE(state->s1, 6U, 13U, 4294967294U, 18U);
88185 + state->s2 = TAUSWORTHE(state->s2, 2U, 27U, 4294967288U, 2U);
88186 + state->s3 = TAUSWORTHE(state->s3, 13U, 21U, 4294967280U, 7U);
88187 + state->s4 = TAUSWORTHE(state->s4, 3U, 12U, 4294967168U, 13U);
88188
88189 - return (state->s1 ^ state->s2 ^ state->s3);
88190 + return (state->s1 ^ state->s2 ^ state->s3 ^ state->s4);
88191 }
88192 EXPORT_SYMBOL(prandom_u32_state);
88193
88194 @@ -126,6 +132,38 @@ void prandom_bytes(void *buf, int bytes)
88195 }
88196 EXPORT_SYMBOL(prandom_bytes);
88197
88198 +static void prandom_warmup(struct rnd_state *state)
88199 +{
88200 + /* Calling RNG ten times to satify recurrence condition */
88201 + prandom_u32_state(state);
88202 + prandom_u32_state(state);
88203 + prandom_u32_state(state);
88204 + prandom_u32_state(state);
88205 + prandom_u32_state(state);
88206 + prandom_u32_state(state);
88207 + prandom_u32_state(state);
88208 + prandom_u32_state(state);
88209 + prandom_u32_state(state);
88210 + prandom_u32_state(state);
88211 +}
88212 +
88213 +static void prandom_seed_very_weak(struct rnd_state *state, u32 seed)
88214 +{
88215 + /* Note: This sort of seeding is ONLY used in test cases and
88216 + * during boot at the time from core_initcall until late_initcall
88217 + * as we don't have a stronger entropy source available yet.
88218 + * After late_initcall, we reseed entire state, we have to (!),
88219 + * otherwise an attacker just needs to search 32 bit space to
88220 + * probe for our internal 128 bit state if he knows a couple
88221 + * of prandom32 outputs!
88222 + */
88223 +#define LCG(x) ((x) * 69069U) /* super-duper LCG */
88224 + state->s1 = __seed(LCG(seed), 2U);
88225 + state->s2 = __seed(LCG(state->s1), 8U);
88226 + state->s3 = __seed(LCG(state->s2), 16U);
88227 + state->s4 = __seed(LCG(state->s3), 128U);
88228 +}
88229 +
88230 /**
88231 * prandom_seed - add entropy to pseudo random number generator
88232 * @seed: seed value
88233 @@ -141,7 +179,9 @@ void prandom_seed(u32 entropy)
88234 */
88235 for_each_possible_cpu (i) {
88236 struct rnd_state *state = &per_cpu(net_rand_state, i);
88237 - state->s1 = __seed(state->s1 ^ entropy, 2);
88238 +
88239 + state->s1 = __seed(state->s1 ^ entropy, 2U);
88240 + prandom_warmup(state);
88241 }
88242 }
88243 EXPORT_SYMBOL(prandom_seed);
88244 @@ -154,46 +194,249 @@ static int __init prandom_init(void)
88245 {
88246 int i;
88247
88248 +#ifdef CONFIG_RANDOM32_SELFTEST
88249 + prandom_state_selftest();
88250 +#endif
88251 +
88252 for_each_possible_cpu(i) {
88253 struct rnd_state *state = &per_cpu(net_rand_state,i);
88254
88255 -#define LCG(x) ((x) * 69069) /* super-duper LCG */
88256 - state->s1 = __seed(LCG(i + jiffies), 2);
88257 - state->s2 = __seed(LCG(state->s1), 8);
88258 - state->s3 = __seed(LCG(state->s2), 16);
88259 -
88260 - /* "warm it up" */
88261 - prandom_u32_state(state);
88262 - prandom_u32_state(state);
88263 - prandom_u32_state(state);
88264 - prandom_u32_state(state);
88265 - prandom_u32_state(state);
88266 - prandom_u32_state(state);
88267 + prandom_seed_very_weak(state, (i + jiffies) ^ random_get_entropy());
88268 + prandom_warmup(state);
88269 }
88270 return 0;
88271 }
88272 core_initcall(prandom_init);
88273
88274 +static void __prandom_timer(unsigned long dontcare);
88275 +static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0);
88276 +
88277 +static void __prandom_timer(unsigned long dontcare)
88278 +{
88279 + u32 entropy;
88280 + unsigned long expires;
88281 +
88282 + get_random_bytes(&entropy, sizeof(entropy));
88283 + prandom_seed(entropy);
88284 +
88285 + /* reseed every ~60 seconds, in [40 .. 80) interval with slack */
88286 + expires = 40 + (prandom_u32() % 40);
88287 + seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC);
88288 +
88289 + add_timer(&seed_timer);
88290 +}
88291 +
88292 +static void __init __prandom_start_seed_timer(void)
88293 +{
88294 + set_timer_slack(&seed_timer, HZ);
88295 + seed_timer.expires = jiffies + msecs_to_jiffies(40 * MSEC_PER_SEC);
88296 + add_timer(&seed_timer);
88297 +}
88298 +
88299 /*
88300 * Generate better values after random number generator
88301 * is fully initialized.
88302 */
88303 -static int __init prandom_reseed(void)
88304 +static void __prandom_reseed(bool late)
88305 {
88306 int i;
88307 + unsigned long flags;
88308 + static bool latch = false;
88309 + static DEFINE_SPINLOCK(lock);
88310 +
88311 + /* only allow initial seeding (late == false) once */
88312 + spin_lock_irqsave(&lock, flags);
88313 + if (latch && !late)
88314 + goto out;
88315 + latch = true;
88316
88317 for_each_possible_cpu(i) {
88318 struct rnd_state *state = &per_cpu(net_rand_state,i);
88319 - u32 seeds[3];
88320 + u32 seeds[4];
88321
88322 get_random_bytes(&seeds, sizeof(seeds));
88323 - state->s1 = __seed(seeds[0], 2);
88324 - state->s2 = __seed(seeds[1], 8);
88325 - state->s3 = __seed(seeds[2], 16);
88326 + state->s1 = __seed(seeds[0], 2U);
88327 + state->s2 = __seed(seeds[1], 8U);
88328 + state->s3 = __seed(seeds[2], 16U);
88329 + state->s4 = __seed(seeds[3], 128U);
88330
88331 - /* mix it in */
88332 - prandom_u32_state(state);
88333 + prandom_warmup(state);
88334 }
88335 +out:
88336 + spin_unlock_irqrestore(&lock, flags);
88337 +}
88338 +
88339 +void prandom_reseed_late(void)
88340 +{
88341 + __prandom_reseed(true);
88342 +}
88343 +
88344 +static int __init prandom_reseed(void)
88345 +{
88346 + __prandom_reseed(false);
88347 + __prandom_start_seed_timer();
88348 return 0;
88349 }
88350 late_initcall(prandom_reseed);
88351 +
88352 +#ifdef CONFIG_RANDOM32_SELFTEST
88353 +static struct prandom_test1 {
88354 + u32 seed;
88355 + u32 result;
88356 +} test1[] = {
88357 + { 1U, 3484351685U },
88358 + { 2U, 2623130059U },
88359 + { 3U, 3125133893U },
88360 + { 4U, 984847254U },
88361 +};
88362 +
88363 +static struct prandom_test2 {
88364 + u32 seed;
88365 + u32 iteration;
88366 + u32 result;
88367 +} test2[] = {
88368 + /* Test cases against taus113 from GSL library. */
88369 + { 931557656U, 959U, 2975593782U },
88370 + { 1339693295U, 876U, 3887776532U },
88371 + { 1545556285U, 961U, 1615538833U },
88372 + { 601730776U, 723U, 1776162651U },
88373 + { 1027516047U, 687U, 511983079U },
88374 + { 416526298U, 700U, 916156552U },
88375 + { 1395522032U, 652U, 2222063676U },
88376 + { 366221443U, 617U, 2992857763U },
88377 + { 1539836965U, 714U, 3783265725U },
88378 + { 556206671U, 994U, 799626459U },
88379 + { 684907218U, 799U, 367789491U },
88380 + { 2121230701U, 931U, 2115467001U },
88381 + { 1668516451U, 644U, 3620590685U },
88382 + { 768046066U, 883U, 2034077390U },
88383 + { 1989159136U, 833U, 1195767305U },
88384 + { 536585145U, 996U, 3577259204U },
88385 + { 1008129373U, 642U, 1478080776U },
88386 + { 1740775604U, 939U, 1264980372U },
88387 + { 1967883163U, 508U, 10734624U },
88388 + { 1923019697U, 730U, 3821419629U },
88389 + { 442079932U, 560U, 3440032343U },
88390 + { 1961302714U, 845U, 841962572U },
88391 + { 2030205964U, 962U, 1325144227U },
88392 + { 1160407529U, 507U, 240940858U },
88393 + { 635482502U, 779U, 4200489746U },
88394 + { 1252788931U, 699U, 867195434U },
88395 + { 1961817131U, 719U, 668237657U },
88396 + { 1071468216U, 983U, 917876630U },
88397 + { 1281848367U, 932U, 1003100039U },
88398 + { 582537119U, 780U, 1127273778U },
88399 + { 1973672777U, 853U, 1071368872U },
88400 + { 1896756996U, 762U, 1127851055U },
88401 + { 847917054U, 500U, 1717499075U },
88402 + { 1240520510U, 951U, 2849576657U },
88403 + { 1685071682U, 567U, 1961810396U },
88404 + { 1516232129U, 557U, 3173877U },
88405 + { 1208118903U, 612U, 1613145022U },
88406 + { 1817269927U, 693U, 4279122573U },
88407 + { 1510091701U, 717U, 638191229U },
88408 + { 365916850U, 807U, 600424314U },
88409 + { 399324359U, 702U, 1803598116U },
88410 + { 1318480274U, 779U, 2074237022U },
88411 + { 697758115U, 840U, 1483639402U },
88412 + { 1696507773U, 840U, 577415447U },
88413 + { 2081979121U, 981U, 3041486449U },
88414 + { 955646687U, 742U, 3846494357U },
88415 + { 1250683506U, 749U, 836419859U },
88416 + { 595003102U, 534U, 366794109U },
88417 + { 47485338U, 558U, 3521120834U },
88418 + { 619433479U, 610U, 3991783875U },
88419 + { 704096520U, 518U, 4139493852U },
88420 + { 1712224984U, 606U, 2393312003U },
88421 + { 1318233152U, 922U, 3880361134U },
88422 + { 855572992U, 761U, 1472974787U },
88423 + { 64721421U, 703U, 683860550U },
88424 + { 678931758U, 840U, 380616043U },
88425 + { 692711973U, 778U, 1382361947U },
88426 + { 677703619U, 530U, 2826914161U },
88427 + { 92393223U, 586U, 1522128471U },
88428 + { 1222592920U, 743U, 3466726667U },
88429 + { 358288986U, 695U, 1091956998U },
88430 + { 1935056945U, 958U, 514864477U },
88431 + { 735675993U, 990U, 1294239989U },
88432 + { 1560089402U, 897U, 2238551287U },
88433 + { 70616361U, 829U, 22483098U },
88434 + { 368234700U, 731U, 2913875084U },
88435 + { 20221190U, 879U, 1564152970U },
88436 + { 539444654U, 682U, 1835141259U },
88437 + { 1314987297U, 840U, 1801114136U },
88438 + { 2019295544U, 645U, 3286438930U },
88439 + { 469023838U, 716U, 1637918202U },
88440 + { 1843754496U, 653U, 2562092152U },
88441 + { 400672036U, 809U, 4264212785U },
88442 + { 404722249U, 965U, 2704116999U },
88443 + { 600702209U, 758U, 584979986U },
88444 + { 519953954U, 667U, 2574436237U },
88445 + { 1658071126U, 694U, 2214569490U },
88446 + { 420480037U, 749U, 3430010866U },
88447 + { 690103647U, 969U, 3700758083U },
88448 + { 1029424799U, 937U, 3787746841U },
88449 + { 2012608669U, 506U, 3362628973U },
88450 + { 1535432887U, 998U, 42610943U },
88451 + { 1330635533U, 857U, 3040806504U },
88452 + { 1223800550U, 539U, 3954229517U },
88453 + { 1322411537U, 680U, 3223250324U },
88454 + { 1877847898U, 945U, 2915147143U },
88455 + { 1646356099U, 874U, 965988280U },
88456 + { 805687536U, 744U, 4032277920U },
88457 + { 1948093210U, 633U, 1346597684U },
88458 + { 392609744U, 783U, 1636083295U },
88459 + { 690241304U, 770U, 1201031298U },
88460 + { 1360302965U, 696U, 1665394461U },
88461 + { 1220090946U, 780U, 1316922812U },
88462 + { 447092251U, 500U, 3438743375U },
88463 + { 1613868791U, 592U, 828546883U },
88464 + { 523430951U, 548U, 2552392304U },
88465 + { 726692899U, 810U, 1656872867U },
88466 + { 1364340021U, 836U, 3710513486U },
88467 + { 1986257729U, 931U, 935013962U },
88468 + { 407983964U, 921U, 728767059U },
88469 +};
88470 +
88471 +static void __init prandom_state_selftest(void)
88472 +{
88473 + int i, j, errors = 0, runs = 0;
88474 + bool error = false;
88475 +
88476 + for (i = 0; i < ARRAY_SIZE(test1); i++) {
88477 + struct rnd_state state;
88478 +
88479 + prandom_seed_very_weak(&state, test1[i].seed);
88480 + prandom_warmup(&state);
88481 +
88482 + if (test1[i].result != prandom_u32_state(&state))
88483 + error = true;
88484 + }
88485 +
88486 + if (error)
88487 + pr_warn("prandom: seed boundary self test failed\n");
88488 + else
88489 + pr_info("prandom: seed boundary self test passed\n");
88490 +
88491 + for (i = 0; i < ARRAY_SIZE(test2); i++) {
88492 + struct rnd_state state;
88493 +
88494 + prandom_seed_very_weak(&state, test2[i].seed);
88495 + prandom_warmup(&state);
88496 +
88497 + for (j = 0; j < test2[i].iteration - 1; j++)
88498 + prandom_u32_state(&state);
88499 +
88500 + if (test2[i].result != prandom_u32_state(&state))
88501 + errors++;
88502 +
88503 + runs++;
88504 + cond_resched();
88505 + }
88506 +
88507 + if (errors)
88508 + pr_warn("prandom: %d/%d self tests failed\n", errors, runs);
88509 + else
88510 + pr_info("prandom: %d self tests passed\n", runs);
88511 +}
88512 +#endif
88513 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
88514 index bb2b201..46abaf9 100644
88515 --- a/lib/strncpy_from_user.c
88516 +++ b/lib/strncpy_from_user.c
88517 @@ -21,7 +21,7 @@
88518 */
88519 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
88520 {
88521 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
88522 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
88523 long res = 0;
88524
88525 /*
88526 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
88527 index a28df52..3d55877 100644
88528 --- a/lib/strnlen_user.c
88529 +++ b/lib/strnlen_user.c
88530 @@ -26,7 +26,7 @@
88531 */
88532 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
88533 {
88534 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
88535 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
88536 long align, res = 0;
88537 unsigned long c;
88538
88539 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
88540 index 4e8686c..3e8c92f 100644
88541 --- a/lib/swiotlb.c
88542 +++ b/lib/swiotlb.c
88543 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
88544
88545 void
88546 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
88547 - dma_addr_t dev_addr)
88548 + dma_addr_t dev_addr, struct dma_attrs *attrs)
88549 {
88550 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
88551
88552 diff --git a/lib/usercopy.c b/lib/usercopy.c
88553 index 4f5b1dd..7cab418 100644
88554 --- a/lib/usercopy.c
88555 +++ b/lib/usercopy.c
88556 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
88557 WARN(1, "Buffer overflow detected!\n");
88558 }
88559 EXPORT_SYMBOL(copy_from_user_overflow);
88560 +
88561 +void copy_to_user_overflow(void)
88562 +{
88563 + WARN(1, "Buffer overflow detected!\n");
88564 +}
88565 +EXPORT_SYMBOL(copy_to_user_overflow);
88566 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
88567 index d76555c..62d4bfe 100644
88568 --- a/lib/vsprintf.c
88569 +++ b/lib/vsprintf.c
88570 @@ -16,6 +16,9 @@
88571 * - scnprintf and vscnprintf
88572 */
88573
88574 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88575 +#define __INCLUDED_BY_HIDESYM 1
88576 +#endif
88577 #include <stdarg.h>
88578 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
88579 #include <linux/types.h>
88580 @@ -1155,7 +1158,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
88581 return number(buf, end, *(const netdev_features_t *)addr, spec);
88582 }
88583
88584 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88585 +int kptr_restrict __read_mostly = 2;
88586 +#else
88587 int kptr_restrict __read_mostly;
88588 +#endif
88589
88590 /*
88591 * Show a '%p' thing. A kernel extension is that the '%p' is followed
88592 @@ -1168,6 +1175,7 @@ int kptr_restrict __read_mostly;
88593 * - 'f' For simple symbolic function names without offset
88594 * - 'S' For symbolic direct pointers with offset
88595 * - 's' For symbolic direct pointers without offset
88596 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
88597 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
88598 * - 'B' For backtraced symbolic direct pointers with offset
88599 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
88600 @@ -1232,12 +1240,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
88601
88602 if (!ptr && *fmt != 'K') {
88603 /*
88604 - * Print (null) with the same width as a pointer so it makes
88605 + * Print (nil) with the same width as a pointer so it makes
88606 * tabular output look nice.
88607 */
88608 if (spec.field_width == -1)
88609 spec.field_width = default_width;
88610 - return string(buf, end, "(null)", spec);
88611 + return string(buf, end, "(nil)", spec);
88612 }
88613
88614 switch (*fmt) {
88615 @@ -1247,6 +1255,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
88616 /* Fallthrough */
88617 case 'S':
88618 case 's':
88619 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88620 + break;
88621 +#else
88622 + return symbol_string(buf, end, ptr, spec, fmt);
88623 +#endif
88624 + case 'A':
88625 case 'B':
88626 return symbol_string(buf, end, ptr, spec, fmt);
88627 case 'R':
88628 @@ -1302,6 +1316,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
88629 va_end(va);
88630 return buf;
88631 }
88632 + case 'P':
88633 + break;
88634 case 'K':
88635 /*
88636 * %pK cannot be used in IRQ context because its test
88637 @@ -1363,6 +1379,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
88638 ((const struct file *)ptr)->f_path.dentry,
88639 spec, fmt);
88640 }
88641 +
88642 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88643 + /* 'P' = approved pointers to copy to userland,
88644 + as in the /proc/kallsyms case, as we make it display nothing
88645 + for non-root users, and the real contents for root users
88646 + Also ignore 'K' pointers, since we force their NULLing for non-root users
88647 + above
88648 + */
88649 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
88650 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
88651 + dump_stack();
88652 + ptr = NULL;
88653 + }
88654 +#endif
88655 +
88656 spec.flags |= SMALL;
88657 if (spec.field_width == -1) {
88658 spec.field_width = default_width;
88659 @@ -2086,11 +2117,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
88660 typeof(type) value; \
88661 if (sizeof(type) == 8) { \
88662 args = PTR_ALIGN(args, sizeof(u32)); \
88663 - *(u32 *)&value = *(u32 *)args; \
88664 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
88665 + *(u32 *)&value = *(const u32 *)args; \
88666 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
88667 } else { \
88668 args = PTR_ALIGN(args, sizeof(type)); \
88669 - value = *(typeof(type) *)args; \
88670 + value = *(const typeof(type) *)args; \
88671 } \
88672 args += sizeof(type); \
88673 value; \
88674 @@ -2153,7 +2184,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
88675 case FORMAT_TYPE_STR: {
88676 const char *str_arg = args;
88677 args += strlen(str_arg) + 1;
88678 - str = string(str, end, (char *)str_arg, spec);
88679 + str = string(str, end, str_arg, spec);
88680 break;
88681 }
88682
88683 diff --git a/localversion-grsec b/localversion-grsec
88684 new file mode 100644
88685 index 0000000..7cd6065
88686 --- /dev/null
88687 +++ b/localversion-grsec
88688 @@ -0,0 +1 @@
88689 +-grsec
88690 diff --git a/mm/Kconfig b/mm/Kconfig
88691 index 394838f..0e5f816 100644
88692 --- a/mm/Kconfig
88693 +++ b/mm/Kconfig
88694 @@ -317,10 +317,11 @@ config KSM
88695 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
88696
88697 config DEFAULT_MMAP_MIN_ADDR
88698 - int "Low address space to protect from user allocation"
88699 + int "Low address space to protect from user allocation"
88700 depends on MMU
88701 - default 4096
88702 - help
88703 + default 32768 if ALPHA || ARM || PARISC || SPARC32
88704 + default 65536
88705 + help
88706 This is the portion of low virtual memory which should be protected
88707 from userspace allocation. Keeping a user from writing to low pages
88708 can help reduce the impact of kernel NULL pointer bugs.
88709 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
88710
88711 config HWPOISON_INJECT
88712 tristate "HWPoison pages injector"
88713 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
88714 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
88715 select PROC_PAGE_MONITOR
88716
88717 config NOMMU_INITIAL_TRIM_EXCESS
88718 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
88719 index ce682f7..1fb54f9 100644
88720 --- a/mm/backing-dev.c
88721 +++ b/mm/backing-dev.c
88722 @@ -12,7 +12,7 @@
88723 #include <linux/device.h>
88724 #include <trace/events/writeback.h>
88725
88726 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
88727 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
88728
88729 struct backing_dev_info default_backing_dev_info = {
88730 .name = "default",
88731 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
88732 return err;
88733
88734 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
88735 - atomic_long_inc_return(&bdi_seq));
88736 + atomic_long_inc_return_unchecked(&bdi_seq));
88737 if (err) {
88738 bdi_destroy(bdi);
88739 return err;
88740 diff --git a/mm/filemap.c b/mm/filemap.c
88741 index ae4846f..b0acebe 100644
88742 --- a/mm/filemap.c
88743 +++ b/mm/filemap.c
88744 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
88745 struct address_space *mapping = file->f_mapping;
88746
88747 if (!mapping->a_ops->readpage)
88748 - return -ENOEXEC;
88749 + return -ENODEV;
88750 file_accessed(file);
88751 vma->vm_ops = &generic_file_vm_ops;
88752 return 0;
88753 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
88754
88755 while (bytes) {
88756 char __user *buf = iov->iov_base + base;
88757 - int copy = min(bytes, iov->iov_len - base);
88758 + size_t copy = min(bytes, iov->iov_len - base);
88759
88760 base = 0;
88761 left = __copy_from_user_inatomic(vaddr, buf, copy);
88762 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
88763 BUG_ON(!in_atomic());
88764 kaddr = kmap_atomic(page);
88765 if (likely(i->nr_segs == 1)) {
88766 - int left;
88767 + size_t left;
88768 char __user *buf = i->iov->iov_base + i->iov_offset;
88769 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
88770 copied = bytes - left;
88771 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
88772
88773 kaddr = kmap(page);
88774 if (likely(i->nr_segs == 1)) {
88775 - int left;
88776 + size_t left;
88777 char __user *buf = i->iov->iov_base + i->iov_offset;
88778 left = __copy_from_user(kaddr + offset, buf, bytes);
88779 copied = bytes - left;
88780 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
88781 * zero-length segments (without overruning the iovec).
88782 */
88783 while (bytes || unlikely(i->count && !iov->iov_len)) {
88784 - int copy;
88785 + size_t copy;
88786
88787 copy = min(bytes, iov->iov_len - base);
88788 BUG_ON(!i->count || i->count < copy);
88789 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
88790 *pos = i_size_read(inode);
88791
88792 if (limit != RLIM_INFINITY) {
88793 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
88794 if (*pos >= limit) {
88795 send_sig(SIGXFSZ, current, 0);
88796 return -EFBIG;
88797 diff --git a/mm/fremap.c b/mm/fremap.c
88798 index bbc4d66..117b798 100644
88799 --- a/mm/fremap.c
88800 +++ b/mm/fremap.c
88801 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
88802 retry:
88803 vma = find_vma(mm, start);
88804
88805 +#ifdef CONFIG_PAX_SEGMEXEC
88806 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
88807 + goto out;
88808 +#endif
88809 +
88810 /*
88811 * Make sure the vma is shared, that it supports prefaulting,
88812 * and that the remapped range is valid and fully within
88813 diff --git a/mm/highmem.c b/mm/highmem.c
88814 index b32b70c..e512eb0 100644
88815 --- a/mm/highmem.c
88816 +++ b/mm/highmem.c
88817 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
88818 * So no dangers, even with speculative execution.
88819 */
88820 page = pte_page(pkmap_page_table[i]);
88821 + pax_open_kernel();
88822 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
88823 -
88824 + pax_close_kernel();
88825 set_page_address(page, NULL);
88826 need_flush = 1;
88827 }
88828 @@ -198,9 +199,11 @@ start:
88829 }
88830 }
88831 vaddr = PKMAP_ADDR(last_pkmap_nr);
88832 +
88833 + pax_open_kernel();
88834 set_pte_at(&init_mm, vaddr,
88835 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
88836 -
88837 + pax_close_kernel();
88838 pkmap_count[last_pkmap_nr] = 1;
88839 set_page_address(page, (void *)vaddr);
88840
88841 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
88842 index 4796245..292a266 100644
88843 --- a/mm/huge_memory.c
88844 +++ b/mm/huge_memory.c
88845 @@ -1154,7 +1154,7 @@ alloc:
88846 new_page = NULL;
88847
88848 if (unlikely(!new_page)) {
88849 - if (is_huge_zero_pmd(orig_pmd)) {
88850 + if (!page) {
88851 ret = do_huge_pmd_wp_zero_page_fallback(mm, vma,
88852 address, pmd, orig_pmd, haddr);
88853 } else {
88854 @@ -1181,7 +1181,7 @@ alloc:
88855
88856 count_vm_event(THP_FAULT_ALLOC);
88857
88858 - if (is_huge_zero_pmd(orig_pmd))
88859 + if (!page)
88860 clear_huge_page(new_page, haddr, HPAGE_PMD_NR);
88861 else
88862 copy_user_huge_page(new_page, page, haddr, vma, HPAGE_PMD_NR);
88863 @@ -1207,7 +1207,7 @@ alloc:
88864 page_add_new_anon_rmap(new_page, vma, haddr);
88865 set_pmd_at(mm, haddr, pmd, entry);
88866 update_mmu_cache_pmd(vma, address, pmd);
88867 - if (is_huge_zero_pmd(orig_pmd)) {
88868 + if (!page) {
88869 add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR);
88870 put_huge_zero_page();
88871 } else {
88872 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
88873 index 0b7656e..d21cefc 100644
88874 --- a/mm/hugetlb.c
88875 +++ b/mm/hugetlb.c
88876 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
88877 struct hstate *h = &default_hstate;
88878 unsigned long tmp;
88879 int ret;
88880 + ctl_table_no_const hugetlb_table;
88881
88882 tmp = h->max_huge_pages;
88883
88884 if (write && h->order >= MAX_ORDER)
88885 return -EINVAL;
88886
88887 - table->data = &tmp;
88888 - table->maxlen = sizeof(unsigned long);
88889 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
88890 + hugetlb_table = *table;
88891 + hugetlb_table.data = &tmp;
88892 + hugetlb_table.maxlen = sizeof(unsigned long);
88893 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
88894 if (ret)
88895 goto out;
88896
88897 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
88898 struct hstate *h = &default_hstate;
88899 unsigned long tmp;
88900 int ret;
88901 + ctl_table_no_const hugetlb_table;
88902
88903 tmp = h->nr_overcommit_huge_pages;
88904
88905 if (write && h->order >= MAX_ORDER)
88906 return -EINVAL;
88907
88908 - table->data = &tmp;
88909 - table->maxlen = sizeof(unsigned long);
88910 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
88911 + hugetlb_table = *table;
88912 + hugetlb_table.data = &tmp;
88913 + hugetlb_table.maxlen = sizeof(unsigned long);
88914 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
88915 if (ret)
88916 goto out;
88917
88918 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
88919 return 1;
88920 }
88921
88922 +#ifdef CONFIG_PAX_SEGMEXEC
88923 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
88924 +{
88925 + struct mm_struct *mm = vma->vm_mm;
88926 + struct vm_area_struct *vma_m;
88927 + unsigned long address_m;
88928 + pte_t *ptep_m;
88929 +
88930 + vma_m = pax_find_mirror_vma(vma);
88931 + if (!vma_m)
88932 + return;
88933 +
88934 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88935 + address_m = address + SEGMEXEC_TASK_SIZE;
88936 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
88937 + get_page(page_m);
88938 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
88939 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
88940 +}
88941 +#endif
88942 +
88943 /*
88944 * Hugetlb_cow() should be called with page lock of the original hugepage held.
88945 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
88946 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
88947 make_huge_pte(vma, new_page, 1));
88948 page_remove_rmap(old_page);
88949 hugepage_add_new_anon_rmap(new_page, vma, address);
88950 +
88951 +#ifdef CONFIG_PAX_SEGMEXEC
88952 + pax_mirror_huge_pte(vma, address, new_page);
88953 +#endif
88954 +
88955 /* Make the old page be freed below */
88956 new_page = old_page;
88957 }
88958 @@ -2883,6 +2913,10 @@ retry:
88959 && (vma->vm_flags & VM_SHARED)));
88960 set_huge_pte_at(mm, address, ptep, new_pte);
88961
88962 +#ifdef CONFIG_PAX_SEGMEXEC
88963 + pax_mirror_huge_pte(vma, address, page);
88964 +#endif
88965 +
88966 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
88967 /* Optimization, do the COW without a second fault */
88968 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
88969 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88970 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
88971 struct hstate *h = hstate_vma(vma);
88972
88973 +#ifdef CONFIG_PAX_SEGMEXEC
88974 + struct vm_area_struct *vma_m;
88975 +#endif
88976 +
88977 address &= huge_page_mask(h);
88978
88979 ptep = huge_pte_offset(mm, address);
88980 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88981 VM_FAULT_SET_HINDEX(hstate_index(h));
88982 }
88983
88984 +#ifdef CONFIG_PAX_SEGMEXEC
88985 + vma_m = pax_find_mirror_vma(vma);
88986 + if (vma_m) {
88987 + unsigned long address_m;
88988 +
88989 + if (vma->vm_start > vma_m->vm_start) {
88990 + address_m = address;
88991 + address -= SEGMEXEC_TASK_SIZE;
88992 + vma = vma_m;
88993 + h = hstate_vma(vma);
88994 + } else
88995 + address_m = address + SEGMEXEC_TASK_SIZE;
88996 +
88997 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
88998 + return VM_FAULT_OOM;
88999 + address_m &= HPAGE_MASK;
89000 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
89001 + }
89002 +#endif
89003 +
89004 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
89005 if (!ptep)
89006 return VM_FAULT_OOM;
89007 diff --git a/mm/internal.h b/mm/internal.h
89008 index 684f7aa..9eb9edc 100644
89009 --- a/mm/internal.h
89010 +++ b/mm/internal.h
89011 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
89012 * in mm/page_alloc.c
89013 */
89014 extern void __free_pages_bootmem(struct page *page, unsigned int order);
89015 +extern void free_compound_page(struct page *page);
89016 extern void prep_compound_page(struct page *page, unsigned long order);
89017 #ifdef CONFIG_MEMORY_FAILURE
89018 extern bool is_free_buddy_page(struct page *page);
89019 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
89020
89021 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
89022 unsigned long, unsigned long,
89023 - unsigned long, unsigned long);
89024 + unsigned long, unsigned long) __intentional_overflow(-1);
89025
89026 extern void set_pageblock_order(void);
89027 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
89028 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
89029 index e126b0e..e986018 100644
89030 --- a/mm/kmemleak.c
89031 +++ b/mm/kmemleak.c
89032 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
89033
89034 for (i = 0; i < object->trace_len; i++) {
89035 void *ptr = (void *)object->trace[i];
89036 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
89037 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
89038 }
89039 }
89040
89041 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
89042 return -ENOMEM;
89043 }
89044
89045 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
89046 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
89047 &kmemleak_fops);
89048 if (!dentry)
89049 pr_warning("Failed to create the debugfs kmemleak file\n");
89050 diff --git a/mm/maccess.c b/mm/maccess.c
89051 index d53adf9..03a24bf 100644
89052 --- a/mm/maccess.c
89053 +++ b/mm/maccess.c
89054 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
89055 set_fs(KERNEL_DS);
89056 pagefault_disable();
89057 ret = __copy_from_user_inatomic(dst,
89058 - (__force const void __user *)src, size);
89059 + (const void __force_user *)src, size);
89060 pagefault_enable();
89061 set_fs(old_fs);
89062
89063 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
89064
89065 set_fs(KERNEL_DS);
89066 pagefault_disable();
89067 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
89068 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
89069 pagefault_enable();
89070 set_fs(old_fs);
89071
89072 diff --git a/mm/madvise.c b/mm/madvise.c
89073 index 539eeb9..e24a987 100644
89074 --- a/mm/madvise.c
89075 +++ b/mm/madvise.c
89076 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
89077 pgoff_t pgoff;
89078 unsigned long new_flags = vma->vm_flags;
89079
89080 +#ifdef CONFIG_PAX_SEGMEXEC
89081 + struct vm_area_struct *vma_m;
89082 +#endif
89083 +
89084 switch (behavior) {
89085 case MADV_NORMAL:
89086 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
89087 @@ -126,6 +130,13 @@ success:
89088 /*
89089 * vm_flags is protected by the mmap_sem held in write mode.
89090 */
89091 +
89092 +#ifdef CONFIG_PAX_SEGMEXEC
89093 + vma_m = pax_find_mirror_vma(vma);
89094 + if (vma_m)
89095 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
89096 +#endif
89097 +
89098 vma->vm_flags = new_flags;
89099
89100 out:
89101 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
89102 struct vm_area_struct **prev,
89103 unsigned long start, unsigned long end)
89104 {
89105 +
89106 +#ifdef CONFIG_PAX_SEGMEXEC
89107 + struct vm_area_struct *vma_m;
89108 +#endif
89109 +
89110 *prev = vma;
89111 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
89112 return -EINVAL;
89113 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
89114 zap_page_range(vma, start, end - start, &details);
89115 } else
89116 zap_page_range(vma, start, end - start, NULL);
89117 +
89118 +#ifdef CONFIG_PAX_SEGMEXEC
89119 + vma_m = pax_find_mirror_vma(vma);
89120 + if (vma_m) {
89121 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
89122 + struct zap_details details = {
89123 + .nonlinear_vma = vma_m,
89124 + .last_index = ULONG_MAX,
89125 + };
89126 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
89127 + } else
89128 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
89129 + }
89130 +#endif
89131 +
89132 return 0;
89133 }
89134
89135 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
89136 if (end < start)
89137 return error;
89138
89139 +#ifdef CONFIG_PAX_SEGMEXEC
89140 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
89141 + if (end > SEGMEXEC_TASK_SIZE)
89142 + return error;
89143 + } else
89144 +#endif
89145 +
89146 + if (end > TASK_SIZE)
89147 + return error;
89148 +
89149 error = 0;
89150 if (end == start)
89151 return error;
89152 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
89153 index 9aea53f..f239c30 100644
89154 --- a/mm/memory-failure.c
89155 +++ b/mm/memory-failure.c
89156 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
89157
89158 int sysctl_memory_failure_recovery __read_mostly = 1;
89159
89160 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
89161 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
89162
89163 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
89164
89165 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
89166 pfn, t->comm, t->pid);
89167 si.si_signo = SIGBUS;
89168 si.si_errno = 0;
89169 - si.si_addr = (void *)addr;
89170 + si.si_addr = (void __user *)addr;
89171 #ifdef __ARCH_SI_TRAPNO
89172 si.si_trapno = trapno;
89173 #endif
89174 @@ -762,7 +762,7 @@ static struct page_state {
89175 unsigned long res;
89176 char *msg;
89177 int (*action)(struct page *p, unsigned long pfn);
89178 -} error_states[] = {
89179 +} __do_const error_states[] = {
89180 { reserved, reserved, "reserved kernel", me_kernel },
89181 /*
89182 * free pages are specially detected outside this table:
89183 @@ -1063,7 +1063,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
89184 nr_pages = 1 << compound_order(hpage);
89185 else /* normal page or thp */
89186 nr_pages = 1;
89187 - atomic_long_add(nr_pages, &num_poisoned_pages);
89188 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
89189
89190 /*
89191 * We need/can do nothing about count=0 pages.
89192 @@ -1093,7 +1093,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
89193 if (!PageHWPoison(hpage)
89194 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
89195 || (p != hpage && TestSetPageHWPoison(hpage))) {
89196 - atomic_long_sub(nr_pages, &num_poisoned_pages);
89197 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
89198 return 0;
89199 }
89200 set_page_hwpoison_huge_page(hpage);
89201 @@ -1162,7 +1162,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
89202 }
89203 if (hwpoison_filter(p)) {
89204 if (TestClearPageHWPoison(p))
89205 - atomic_long_sub(nr_pages, &num_poisoned_pages);
89206 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
89207 unlock_page(hpage);
89208 put_page(hpage);
89209 return 0;
89210 @@ -1380,7 +1380,7 @@ int unpoison_memory(unsigned long pfn)
89211 return 0;
89212 }
89213 if (TestClearPageHWPoison(p))
89214 - atomic_long_dec(&num_poisoned_pages);
89215 + atomic_long_dec_unchecked(&num_poisoned_pages);
89216 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
89217 return 0;
89218 }
89219 @@ -1394,7 +1394,7 @@ int unpoison_memory(unsigned long pfn)
89220 */
89221 if (TestClearPageHWPoison(page)) {
89222 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
89223 - atomic_long_sub(nr_pages, &num_poisoned_pages);
89224 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
89225 freeit = 1;
89226 if (PageHuge(page))
89227 clear_page_hwpoison_huge_page(page);
89228 @@ -1533,11 +1533,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
89229 if (PageHuge(page)) {
89230 set_page_hwpoison_huge_page(hpage);
89231 dequeue_hwpoisoned_huge_page(hpage);
89232 - atomic_long_add(1 << compound_order(hpage),
89233 + atomic_long_add_unchecked(1 << compound_order(hpage),
89234 &num_poisoned_pages);
89235 } else {
89236 SetPageHWPoison(page);
89237 - atomic_long_inc(&num_poisoned_pages);
89238 + atomic_long_inc_unchecked(&num_poisoned_pages);
89239 }
89240 }
89241 return ret;
89242 @@ -1576,7 +1576,7 @@ static int __soft_offline_page(struct page *page, int flags)
89243 put_page(page);
89244 pr_info("soft_offline: %#lx: invalidated\n", pfn);
89245 SetPageHWPoison(page);
89246 - atomic_long_inc(&num_poisoned_pages);
89247 + atomic_long_inc_unchecked(&num_poisoned_pages);
89248 return 0;
89249 }
89250
89251 @@ -1621,7 +1621,7 @@ static int __soft_offline_page(struct page *page, int flags)
89252 if (!is_free_buddy_page(page))
89253 pr_info("soft offline: %#lx: page leaked\n",
89254 pfn);
89255 - atomic_long_inc(&num_poisoned_pages);
89256 + atomic_long_inc_unchecked(&num_poisoned_pages);
89257 }
89258 } else {
89259 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
89260 @@ -1682,11 +1682,11 @@ int soft_offline_page(struct page *page, int flags)
89261 if (PageHuge(page)) {
89262 set_page_hwpoison_huge_page(hpage);
89263 dequeue_hwpoisoned_huge_page(hpage);
89264 - atomic_long_add(1 << compound_order(hpage),
89265 + atomic_long_add_unchecked(1 << compound_order(hpage),
89266 &num_poisoned_pages);
89267 } else {
89268 SetPageHWPoison(page);
89269 - atomic_long_inc(&num_poisoned_pages);
89270 + atomic_long_inc_unchecked(&num_poisoned_pages);
89271 }
89272 }
89273 unset:
89274 diff --git a/mm/memory.c b/mm/memory.c
89275 index d176154..cd1b387 100644
89276 --- a/mm/memory.c
89277 +++ b/mm/memory.c
89278 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
89279 free_pte_range(tlb, pmd, addr);
89280 } while (pmd++, addr = next, addr != end);
89281
89282 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
89283 start &= PUD_MASK;
89284 if (start < floor)
89285 return;
89286 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
89287 pmd = pmd_offset(pud, start);
89288 pud_clear(pud);
89289 pmd_free_tlb(tlb, pmd, start);
89290 +#endif
89291 +
89292 }
89293
89294 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
89295 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
89296 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
89297 } while (pud++, addr = next, addr != end);
89298
89299 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
89300 start &= PGDIR_MASK;
89301 if (start < floor)
89302 return;
89303 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
89304 pud = pud_offset(pgd, start);
89305 pgd_clear(pgd);
89306 pud_free_tlb(tlb, pud, start);
89307 +#endif
89308 +
89309 }
89310
89311 /*
89312 @@ -1636,12 +1642,6 @@ no_page_table:
89313 return page;
89314 }
89315
89316 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
89317 -{
89318 - return stack_guard_page_start(vma, addr) ||
89319 - stack_guard_page_end(vma, addr+PAGE_SIZE);
89320 -}
89321 -
89322 /**
89323 * __get_user_pages() - pin user pages in memory
89324 * @tsk: task_struct of target task
89325 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
89326
89327 i = 0;
89328
89329 - do {
89330 + while (nr_pages) {
89331 struct vm_area_struct *vma;
89332
89333 - vma = find_extend_vma(mm, start);
89334 + vma = find_vma(mm, start);
89335 if (!vma && in_gate_area(mm, start)) {
89336 unsigned long pg = start & PAGE_MASK;
89337 pgd_t *pgd;
89338 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
89339 goto next_page;
89340 }
89341
89342 - if (!vma ||
89343 + if (!vma || start < vma->vm_start ||
89344 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
89345 !(vm_flags & vma->vm_flags))
89346 return i ? : -EFAULT;
89347 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
89348 int ret;
89349 unsigned int fault_flags = 0;
89350
89351 - /* For mlock, just skip the stack guard page. */
89352 - if (foll_flags & FOLL_MLOCK) {
89353 - if (stack_guard_page(vma, start))
89354 - goto next_page;
89355 - }
89356 if (foll_flags & FOLL_WRITE)
89357 fault_flags |= FAULT_FLAG_WRITE;
89358 if (nonblocking)
89359 @@ -1893,7 +1888,7 @@ next_page:
89360 start += page_increm * PAGE_SIZE;
89361 nr_pages -= page_increm;
89362 } while (nr_pages && start < vma->vm_end);
89363 - } while (nr_pages);
89364 + }
89365 return i;
89366 }
89367 EXPORT_SYMBOL(__get_user_pages);
89368 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
89369 page_add_file_rmap(page);
89370 set_pte_at(mm, addr, pte, mk_pte(page, prot));
89371
89372 +#ifdef CONFIG_PAX_SEGMEXEC
89373 + pax_mirror_file_pte(vma, addr, page, ptl);
89374 +#endif
89375 +
89376 retval = 0;
89377 pte_unmap_unlock(pte, ptl);
89378 return retval;
89379 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
89380 if (!page_count(page))
89381 return -EINVAL;
89382 if (!(vma->vm_flags & VM_MIXEDMAP)) {
89383 +
89384 +#ifdef CONFIG_PAX_SEGMEXEC
89385 + struct vm_area_struct *vma_m;
89386 +#endif
89387 +
89388 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
89389 BUG_ON(vma->vm_flags & VM_PFNMAP);
89390 vma->vm_flags |= VM_MIXEDMAP;
89391 +
89392 +#ifdef CONFIG_PAX_SEGMEXEC
89393 + vma_m = pax_find_mirror_vma(vma);
89394 + if (vma_m)
89395 + vma_m->vm_flags |= VM_MIXEDMAP;
89396 +#endif
89397 +
89398 }
89399 return insert_page(vma, addr, page, vma->vm_page_prot);
89400 }
89401 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
89402 unsigned long pfn)
89403 {
89404 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
89405 + BUG_ON(vma->vm_mirror);
89406
89407 if (addr < vma->vm_start || addr >= vma->vm_end)
89408 return -EFAULT;
89409 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
89410
89411 BUG_ON(pud_huge(*pud));
89412
89413 - pmd = pmd_alloc(mm, pud, addr);
89414 + pmd = (mm == &init_mm) ?
89415 + pmd_alloc_kernel(mm, pud, addr) :
89416 + pmd_alloc(mm, pud, addr);
89417 if (!pmd)
89418 return -ENOMEM;
89419 do {
89420 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
89421 unsigned long next;
89422 int err;
89423
89424 - pud = pud_alloc(mm, pgd, addr);
89425 + pud = (mm == &init_mm) ?
89426 + pud_alloc_kernel(mm, pgd, addr) :
89427 + pud_alloc(mm, pgd, addr);
89428 if (!pud)
89429 return -ENOMEM;
89430 do {
89431 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
89432 copy_user_highpage(dst, src, va, vma);
89433 }
89434
89435 +#ifdef CONFIG_PAX_SEGMEXEC
89436 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
89437 +{
89438 + struct mm_struct *mm = vma->vm_mm;
89439 + spinlock_t *ptl;
89440 + pte_t *pte, entry;
89441 +
89442 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
89443 + entry = *pte;
89444 + if (!pte_present(entry)) {
89445 + if (!pte_none(entry)) {
89446 + BUG_ON(pte_file(entry));
89447 + free_swap_and_cache(pte_to_swp_entry(entry));
89448 + pte_clear_not_present_full(mm, address, pte, 0);
89449 + }
89450 + } else {
89451 + struct page *page;
89452 +
89453 + flush_cache_page(vma, address, pte_pfn(entry));
89454 + entry = ptep_clear_flush(vma, address, pte);
89455 + BUG_ON(pte_dirty(entry));
89456 + page = vm_normal_page(vma, address, entry);
89457 + if (page) {
89458 + update_hiwater_rss(mm);
89459 + if (PageAnon(page))
89460 + dec_mm_counter_fast(mm, MM_ANONPAGES);
89461 + else
89462 + dec_mm_counter_fast(mm, MM_FILEPAGES);
89463 + page_remove_rmap(page);
89464 + page_cache_release(page);
89465 + }
89466 + }
89467 + pte_unmap_unlock(pte, ptl);
89468 +}
89469 +
89470 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
89471 + *
89472 + * the ptl of the lower mapped page is held on entry and is not released on exit
89473 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
89474 + */
89475 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
89476 +{
89477 + struct mm_struct *mm = vma->vm_mm;
89478 + unsigned long address_m;
89479 + spinlock_t *ptl_m;
89480 + struct vm_area_struct *vma_m;
89481 + pmd_t *pmd_m;
89482 + pte_t *pte_m, entry_m;
89483 +
89484 + BUG_ON(!page_m || !PageAnon(page_m));
89485 +
89486 + vma_m = pax_find_mirror_vma(vma);
89487 + if (!vma_m)
89488 + return;
89489 +
89490 + BUG_ON(!PageLocked(page_m));
89491 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
89492 + address_m = address + SEGMEXEC_TASK_SIZE;
89493 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
89494 + pte_m = pte_offset_map(pmd_m, address_m);
89495 + ptl_m = pte_lockptr(mm, pmd_m);
89496 + if (ptl != ptl_m) {
89497 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
89498 + if (!pte_none(*pte_m))
89499 + goto out;
89500 + }
89501 +
89502 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
89503 + page_cache_get(page_m);
89504 + page_add_anon_rmap(page_m, vma_m, address_m);
89505 + inc_mm_counter_fast(mm, MM_ANONPAGES);
89506 + set_pte_at(mm, address_m, pte_m, entry_m);
89507 + update_mmu_cache(vma_m, address_m, pte_m);
89508 +out:
89509 + if (ptl != ptl_m)
89510 + spin_unlock(ptl_m);
89511 + pte_unmap(pte_m);
89512 + unlock_page(page_m);
89513 +}
89514 +
89515 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
89516 +{
89517 + struct mm_struct *mm = vma->vm_mm;
89518 + unsigned long address_m;
89519 + spinlock_t *ptl_m;
89520 + struct vm_area_struct *vma_m;
89521 + pmd_t *pmd_m;
89522 + pte_t *pte_m, entry_m;
89523 +
89524 + BUG_ON(!page_m || PageAnon(page_m));
89525 +
89526 + vma_m = pax_find_mirror_vma(vma);
89527 + if (!vma_m)
89528 + return;
89529 +
89530 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
89531 + address_m = address + SEGMEXEC_TASK_SIZE;
89532 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
89533 + pte_m = pte_offset_map(pmd_m, address_m);
89534 + ptl_m = pte_lockptr(mm, pmd_m);
89535 + if (ptl != ptl_m) {
89536 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
89537 + if (!pte_none(*pte_m))
89538 + goto out;
89539 + }
89540 +
89541 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
89542 + page_cache_get(page_m);
89543 + page_add_file_rmap(page_m);
89544 + inc_mm_counter_fast(mm, MM_FILEPAGES);
89545 + set_pte_at(mm, address_m, pte_m, entry_m);
89546 + update_mmu_cache(vma_m, address_m, pte_m);
89547 +out:
89548 + if (ptl != ptl_m)
89549 + spin_unlock(ptl_m);
89550 + pte_unmap(pte_m);
89551 +}
89552 +
89553 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
89554 +{
89555 + struct mm_struct *mm = vma->vm_mm;
89556 + unsigned long address_m;
89557 + spinlock_t *ptl_m;
89558 + struct vm_area_struct *vma_m;
89559 + pmd_t *pmd_m;
89560 + pte_t *pte_m, entry_m;
89561 +
89562 + vma_m = pax_find_mirror_vma(vma);
89563 + if (!vma_m)
89564 + return;
89565 +
89566 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
89567 + address_m = address + SEGMEXEC_TASK_SIZE;
89568 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
89569 + pte_m = pte_offset_map(pmd_m, address_m);
89570 + ptl_m = pte_lockptr(mm, pmd_m);
89571 + if (ptl != ptl_m) {
89572 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
89573 + if (!pte_none(*pte_m))
89574 + goto out;
89575 + }
89576 +
89577 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
89578 + set_pte_at(mm, address_m, pte_m, entry_m);
89579 +out:
89580 + if (ptl != ptl_m)
89581 + spin_unlock(ptl_m);
89582 + pte_unmap(pte_m);
89583 +}
89584 +
89585 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
89586 +{
89587 + struct page *page_m;
89588 + pte_t entry;
89589 +
89590 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
89591 + goto out;
89592 +
89593 + entry = *pte;
89594 + page_m = vm_normal_page(vma, address, entry);
89595 + if (!page_m)
89596 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
89597 + else if (PageAnon(page_m)) {
89598 + if (pax_find_mirror_vma(vma)) {
89599 + pte_unmap_unlock(pte, ptl);
89600 + lock_page(page_m);
89601 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
89602 + if (pte_same(entry, *pte))
89603 + pax_mirror_anon_pte(vma, address, page_m, ptl);
89604 + else
89605 + unlock_page(page_m);
89606 + }
89607 + } else
89608 + pax_mirror_file_pte(vma, address, page_m, ptl);
89609 +
89610 +out:
89611 + pte_unmap_unlock(pte, ptl);
89612 +}
89613 +#endif
89614 +
89615 /*
89616 * This routine handles present pages, when users try to write
89617 * to a shared page. It is done by copying the page to a new address
89618 @@ -2800,6 +2996,12 @@ gotten:
89619 */
89620 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
89621 if (likely(pte_same(*page_table, orig_pte))) {
89622 +
89623 +#ifdef CONFIG_PAX_SEGMEXEC
89624 + if (pax_find_mirror_vma(vma))
89625 + BUG_ON(!trylock_page(new_page));
89626 +#endif
89627 +
89628 if (old_page) {
89629 if (!PageAnon(old_page)) {
89630 dec_mm_counter_fast(mm, MM_FILEPAGES);
89631 @@ -2851,6 +3053,10 @@ gotten:
89632 page_remove_rmap(old_page);
89633 }
89634
89635 +#ifdef CONFIG_PAX_SEGMEXEC
89636 + pax_mirror_anon_pte(vma, address, new_page, ptl);
89637 +#endif
89638 +
89639 /* Free the old page.. */
89640 new_page = old_page;
89641 ret |= VM_FAULT_WRITE;
89642 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
89643 swap_free(entry);
89644 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
89645 try_to_free_swap(page);
89646 +
89647 +#ifdef CONFIG_PAX_SEGMEXEC
89648 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
89649 +#endif
89650 +
89651 unlock_page(page);
89652 if (page != swapcache) {
89653 /*
89654 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
89655
89656 /* No need to invalidate - it was non-present before */
89657 update_mmu_cache(vma, address, page_table);
89658 +
89659 +#ifdef CONFIG_PAX_SEGMEXEC
89660 + pax_mirror_anon_pte(vma, address, page, ptl);
89661 +#endif
89662 +
89663 unlock:
89664 pte_unmap_unlock(page_table, ptl);
89665 out:
89666 @@ -3170,40 +3386,6 @@ out_release:
89667 }
89668
89669 /*
89670 - * This is like a special single-page "expand_{down|up}wards()",
89671 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
89672 - * doesn't hit another vma.
89673 - */
89674 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
89675 -{
89676 - address &= PAGE_MASK;
89677 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
89678 - struct vm_area_struct *prev = vma->vm_prev;
89679 -
89680 - /*
89681 - * Is there a mapping abutting this one below?
89682 - *
89683 - * That's only ok if it's the same stack mapping
89684 - * that has gotten split..
89685 - */
89686 - if (prev && prev->vm_end == address)
89687 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
89688 -
89689 - expand_downwards(vma, address - PAGE_SIZE);
89690 - }
89691 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
89692 - struct vm_area_struct *next = vma->vm_next;
89693 -
89694 - /* As VM_GROWSDOWN but s/below/above/ */
89695 - if (next && next->vm_start == address + PAGE_SIZE)
89696 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
89697 -
89698 - expand_upwards(vma, address + PAGE_SIZE);
89699 - }
89700 - return 0;
89701 -}
89702 -
89703 -/*
89704 * We enter with non-exclusive mmap_sem (to exclude vma changes,
89705 * but allow concurrent faults), and pte mapped but not yet locked.
89706 * We return with mmap_sem still held, but pte unmapped and unlocked.
89707 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
89708 unsigned long address, pte_t *page_table, pmd_t *pmd,
89709 unsigned int flags)
89710 {
89711 - struct page *page;
89712 + struct page *page = NULL;
89713 spinlock_t *ptl;
89714 pte_t entry;
89715
89716 - pte_unmap(page_table);
89717 -
89718 - /* Check if we need to add a guard page to the stack */
89719 - if (check_stack_guard_page(vma, address) < 0)
89720 - return VM_FAULT_SIGBUS;
89721 -
89722 - /* Use the zero-page for reads */
89723 if (!(flags & FAULT_FLAG_WRITE)) {
89724 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
89725 vma->vm_page_prot));
89726 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
89727 + ptl = pte_lockptr(mm, pmd);
89728 + spin_lock(ptl);
89729 if (!pte_none(*page_table))
89730 goto unlock;
89731 goto setpte;
89732 }
89733
89734 /* Allocate our own private page. */
89735 + pte_unmap(page_table);
89736 +
89737 if (unlikely(anon_vma_prepare(vma)))
89738 goto oom;
89739 page = alloc_zeroed_user_highpage_movable(vma, address);
89740 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
89741 if (!pte_none(*page_table))
89742 goto release;
89743
89744 +#ifdef CONFIG_PAX_SEGMEXEC
89745 + if (pax_find_mirror_vma(vma))
89746 + BUG_ON(!trylock_page(page));
89747 +#endif
89748 +
89749 inc_mm_counter_fast(mm, MM_ANONPAGES);
89750 page_add_new_anon_rmap(page, vma, address);
89751 setpte:
89752 @@ -3263,6 +3446,12 @@ setpte:
89753
89754 /* No need to invalidate - it was non-present before */
89755 update_mmu_cache(vma, address, page_table);
89756 +
89757 +#ifdef CONFIG_PAX_SEGMEXEC
89758 + if (page)
89759 + pax_mirror_anon_pte(vma, address, page, ptl);
89760 +#endif
89761 +
89762 unlock:
89763 pte_unmap_unlock(page_table, ptl);
89764 return 0;
89765 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89766 */
89767 /* Only go through if we didn't race with anybody else... */
89768 if (likely(pte_same(*page_table, orig_pte))) {
89769 +
89770 +#ifdef CONFIG_PAX_SEGMEXEC
89771 + if (anon && pax_find_mirror_vma(vma))
89772 + BUG_ON(!trylock_page(page));
89773 +#endif
89774 +
89775 flush_icache_page(vma, page);
89776 entry = mk_pte(page, vma->vm_page_prot);
89777 if (flags & FAULT_FLAG_WRITE)
89778 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89779
89780 /* no need to invalidate: a not-present page won't be cached */
89781 update_mmu_cache(vma, address, page_table);
89782 +
89783 +#ifdef CONFIG_PAX_SEGMEXEC
89784 + if (anon)
89785 + pax_mirror_anon_pte(vma, address, page, ptl);
89786 + else
89787 + pax_mirror_file_pte(vma, address, page, ptl);
89788 +#endif
89789 +
89790 } else {
89791 if (cow_page)
89792 mem_cgroup_uncharge_page(cow_page);
89793 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
89794 if (flags & FAULT_FLAG_WRITE)
89795 flush_tlb_fix_spurious_fault(vma, address);
89796 }
89797 +
89798 +#ifdef CONFIG_PAX_SEGMEXEC
89799 + pax_mirror_pte(vma, address, pte, pmd, ptl);
89800 + return 0;
89801 +#endif
89802 +
89803 unlock:
89804 pte_unmap_unlock(pte, ptl);
89805 return 0;
89806 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89807 pmd_t *pmd;
89808 pte_t *pte;
89809
89810 +#ifdef CONFIG_PAX_SEGMEXEC
89811 + struct vm_area_struct *vma_m;
89812 +#endif
89813 +
89814 if (unlikely(is_vm_hugetlb_page(vma)))
89815 return hugetlb_fault(mm, vma, address, flags);
89816
89817 +#ifdef CONFIG_PAX_SEGMEXEC
89818 + vma_m = pax_find_mirror_vma(vma);
89819 + if (vma_m) {
89820 + unsigned long address_m;
89821 + pgd_t *pgd_m;
89822 + pud_t *pud_m;
89823 + pmd_t *pmd_m;
89824 +
89825 + if (vma->vm_start > vma_m->vm_start) {
89826 + address_m = address;
89827 + address -= SEGMEXEC_TASK_SIZE;
89828 + vma = vma_m;
89829 + } else
89830 + address_m = address + SEGMEXEC_TASK_SIZE;
89831 +
89832 + pgd_m = pgd_offset(mm, address_m);
89833 + pud_m = pud_alloc(mm, pgd_m, address_m);
89834 + if (!pud_m)
89835 + return VM_FAULT_OOM;
89836 + pmd_m = pmd_alloc(mm, pud_m, address_m);
89837 + if (!pmd_m)
89838 + return VM_FAULT_OOM;
89839 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
89840 + return VM_FAULT_OOM;
89841 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
89842 + }
89843 +#endif
89844 +
89845 retry:
89846 pgd = pgd_offset(mm, address);
89847 pud = pud_alloc(mm, pgd, address);
89848 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
89849 spin_unlock(&mm->page_table_lock);
89850 return 0;
89851 }
89852 +
89853 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
89854 +{
89855 + pud_t *new = pud_alloc_one(mm, address);
89856 + if (!new)
89857 + return -ENOMEM;
89858 +
89859 + smp_wmb(); /* See comment in __pte_alloc */
89860 +
89861 + spin_lock(&mm->page_table_lock);
89862 + if (pgd_present(*pgd)) /* Another has populated it */
89863 + pud_free(mm, new);
89864 + else
89865 + pgd_populate_kernel(mm, pgd, new);
89866 + spin_unlock(&mm->page_table_lock);
89867 + return 0;
89868 +}
89869 #endif /* __PAGETABLE_PUD_FOLDED */
89870
89871 #ifndef __PAGETABLE_PMD_FOLDED
89872 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
89873 spin_unlock(&mm->page_table_lock);
89874 return 0;
89875 }
89876 +
89877 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
89878 +{
89879 + pmd_t *new = pmd_alloc_one(mm, address);
89880 + if (!new)
89881 + return -ENOMEM;
89882 +
89883 + smp_wmb(); /* See comment in __pte_alloc */
89884 +
89885 + spin_lock(&mm->page_table_lock);
89886 +#ifndef __ARCH_HAS_4LEVEL_HACK
89887 + if (pud_present(*pud)) /* Another has populated it */
89888 + pmd_free(mm, new);
89889 + else
89890 + pud_populate_kernel(mm, pud, new);
89891 +#else
89892 + if (pgd_present(*pud)) /* Another has populated it */
89893 + pmd_free(mm, new);
89894 + else
89895 + pgd_populate_kernel(mm, pud, new);
89896 +#endif /* __ARCH_HAS_4LEVEL_HACK */
89897 + spin_unlock(&mm->page_table_lock);
89898 + return 0;
89899 +}
89900 #endif /* __PAGETABLE_PMD_FOLDED */
89901
89902 #if !defined(__HAVE_ARCH_GATE_AREA)
89903 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
89904 gate_vma.vm_start = FIXADDR_USER_START;
89905 gate_vma.vm_end = FIXADDR_USER_END;
89906 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
89907 - gate_vma.vm_page_prot = __P101;
89908 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
89909
89910 return 0;
89911 }
89912 @@ -4071,8 +4353,8 @@ out:
89913 return ret;
89914 }
89915
89916 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
89917 - void *buf, int len, int write)
89918 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
89919 + void *buf, size_t len, int write)
89920 {
89921 resource_size_t phys_addr;
89922 unsigned long prot = 0;
89923 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
89924 * Access another process' address space as given in mm. If non-NULL, use the
89925 * given task for page fault accounting.
89926 */
89927 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89928 - unsigned long addr, void *buf, int len, int write)
89929 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89930 + unsigned long addr, void *buf, size_t len, int write)
89931 {
89932 struct vm_area_struct *vma;
89933 void *old_buf = buf;
89934 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89935 down_read(&mm->mmap_sem);
89936 /* ignore errors, just check how much was successfully transferred */
89937 while (len) {
89938 - int bytes, ret, offset;
89939 + ssize_t bytes, ret, offset;
89940 void *maddr;
89941 struct page *page = NULL;
89942
89943 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89944 *
89945 * The caller must hold a reference on @mm.
89946 */
89947 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89948 - void *buf, int len, int write)
89949 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89950 + void *buf, size_t len, int write)
89951 {
89952 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89953 }
89954 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89955 * Source/target buffer must be kernel space,
89956 * Do not walk the page table directly, use get_user_pages
89957 */
89958 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
89959 - void *buf, int len, int write)
89960 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
89961 + void *buf, size_t len, int write)
89962 {
89963 struct mm_struct *mm;
89964 - int ret;
89965 + ssize_t ret;
89966
89967 mm = get_task_mm(tsk);
89968 if (!mm)
89969 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
89970 index 6b22d8f9..8b5f6cf 100644
89971 --- a/mm/mempolicy.c
89972 +++ b/mm/mempolicy.c
89973 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
89974 unsigned long vmstart;
89975 unsigned long vmend;
89976
89977 +#ifdef CONFIG_PAX_SEGMEXEC
89978 + struct vm_area_struct *vma_m;
89979 +#endif
89980 +
89981 vma = find_vma(mm, start);
89982 if (!vma || vma->vm_start > start)
89983 return -EFAULT;
89984 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
89985 err = vma_replace_policy(vma, new_pol);
89986 if (err)
89987 goto out;
89988 +
89989 +#ifdef CONFIG_PAX_SEGMEXEC
89990 + vma_m = pax_find_mirror_vma(vma);
89991 + if (vma_m) {
89992 + err = vma_replace_policy(vma_m, new_pol);
89993 + if (err)
89994 + goto out;
89995 + }
89996 +#endif
89997 +
89998 }
89999
90000 out:
90001 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
90002
90003 if (end < start)
90004 return -EINVAL;
90005 +
90006 +#ifdef CONFIG_PAX_SEGMEXEC
90007 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
90008 + if (end > SEGMEXEC_TASK_SIZE)
90009 + return -EINVAL;
90010 + } else
90011 +#endif
90012 +
90013 + if (end > TASK_SIZE)
90014 + return -EINVAL;
90015 +
90016 if (end == start)
90017 return 0;
90018
90019 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
90020 */
90021 tcred = __task_cred(task);
90022 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
90023 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
90024 - !capable(CAP_SYS_NICE)) {
90025 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
90026 rcu_read_unlock();
90027 err = -EPERM;
90028 goto out_put;
90029 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
90030 goto out;
90031 }
90032
90033 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
90034 + if (mm != current->mm &&
90035 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
90036 + mmput(mm);
90037 + err = -EPERM;
90038 + goto out;
90039 + }
90040 +#endif
90041 +
90042 err = do_migrate_pages(mm, old, new,
90043 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
90044
90045 diff --git a/mm/migrate.c b/mm/migrate.c
90046 index e3cf71d..c94506c 100644
90047 --- a/mm/migrate.c
90048 +++ b/mm/migrate.c
90049 @@ -1406,8 +1406,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
90050 */
90051 tcred = __task_cred(task);
90052 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
90053 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
90054 - !capable(CAP_SYS_NICE)) {
90055 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
90056 rcu_read_unlock();
90057 err = -EPERM;
90058 goto out;
90059 diff --git a/mm/mlock.c b/mm/mlock.c
90060 index 192e6ee..b044449 100644
90061 --- a/mm/mlock.c
90062 +++ b/mm/mlock.c
90063 @@ -14,6 +14,7 @@
90064 #include <linux/pagevec.h>
90065 #include <linux/mempolicy.h>
90066 #include <linux/syscalls.h>
90067 +#include <linux/security.h>
90068 #include <linux/sched.h>
90069 #include <linux/export.h>
90070 #include <linux/rmap.h>
90071 @@ -588,7 +589,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
90072 {
90073 unsigned long nstart, end, tmp;
90074 struct vm_area_struct * vma, * prev;
90075 - int error;
90076 + int error = 0;
90077
90078 VM_BUG_ON(start & ~PAGE_MASK);
90079 VM_BUG_ON(len != PAGE_ALIGN(len));
90080 @@ -597,6 +598,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
90081 return -EINVAL;
90082 if (end == start)
90083 return 0;
90084 + if (end > TASK_SIZE)
90085 + return -EINVAL;
90086 +
90087 vma = find_vma(current->mm, start);
90088 if (!vma || vma->vm_start > start)
90089 return -ENOMEM;
90090 @@ -608,6 +612,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
90091 for (nstart = start ; ; ) {
90092 vm_flags_t newflags;
90093
90094 +#ifdef CONFIG_PAX_SEGMEXEC
90095 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
90096 + break;
90097 +#endif
90098 +
90099 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
90100
90101 newflags = vma->vm_flags & ~VM_LOCKED;
90102 @@ -720,6 +729,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
90103 lock_limit >>= PAGE_SHIFT;
90104
90105 /* check against resource limits */
90106 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
90107 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
90108 error = do_mlock(start, len, 1);
90109 up_write(&current->mm->mmap_sem);
90110 @@ -754,6 +764,11 @@ static int do_mlockall(int flags)
90111 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
90112 vm_flags_t newflags;
90113
90114 +#ifdef CONFIG_PAX_SEGMEXEC
90115 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
90116 + break;
90117 +#endif
90118 +
90119 newflags = vma->vm_flags & ~VM_LOCKED;
90120 if (flags & MCL_CURRENT)
90121 newflags |= VM_LOCKED;
90122 @@ -787,6 +802,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
90123 lock_limit >>= PAGE_SHIFT;
90124
90125 ret = -ENOMEM;
90126 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
90127 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
90128 capable(CAP_IPC_LOCK))
90129 ret = do_mlockall(flags);
90130 diff --git a/mm/mmap.c b/mm/mmap.c
90131 index 362e5f1..8968e02 100644
90132 --- a/mm/mmap.c
90133 +++ b/mm/mmap.c
90134 @@ -36,6 +36,7 @@
90135 #include <linux/sched/sysctl.h>
90136 #include <linux/notifier.h>
90137 #include <linux/memory.h>
90138 +#include <linux/random.h>
90139
90140 #include <asm/uaccess.h>
90141 #include <asm/cacheflush.h>
90142 @@ -52,6 +53,16 @@
90143 #define arch_rebalance_pgtables(addr, len) (addr)
90144 #endif
90145
90146 +static inline void verify_mm_writelocked(struct mm_struct *mm)
90147 +{
90148 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
90149 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
90150 + up_read(&mm->mmap_sem);
90151 + BUG();
90152 + }
90153 +#endif
90154 +}
90155 +
90156 static void unmap_region(struct mm_struct *mm,
90157 struct vm_area_struct *vma, struct vm_area_struct *prev,
90158 unsigned long start, unsigned long end);
90159 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
90160 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
90161 *
90162 */
90163 -pgprot_t protection_map[16] = {
90164 +pgprot_t protection_map[16] __read_only = {
90165 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
90166 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
90167 };
90168
90169 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
90170 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
90171 {
90172 - return __pgprot(pgprot_val(protection_map[vm_flags &
90173 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
90174 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
90175 pgprot_val(arch_vm_get_page_prot(vm_flags)));
90176 +
90177 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
90178 + if (!(__supported_pte_mask & _PAGE_NX) &&
90179 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
90180 + (vm_flags & (VM_READ | VM_WRITE)))
90181 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
90182 +#endif
90183 +
90184 + return prot;
90185 }
90186 EXPORT_SYMBOL(vm_get_page_prot);
90187
90188 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
90189 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
90190 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
90191 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
90192 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
90193 /*
90194 * Make sure vm_committed_as in one cacheline and not cacheline shared with
90195 * other variables. It can be updated by several CPUs frequently.
90196 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
90197 struct vm_area_struct *next = vma->vm_next;
90198
90199 might_sleep();
90200 + BUG_ON(vma->vm_mirror);
90201 if (vma->vm_ops && vma->vm_ops->close)
90202 vma->vm_ops->close(vma);
90203 if (vma->vm_file)
90204 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
90205 * not page aligned -Ram Gupta
90206 */
90207 rlim = rlimit(RLIMIT_DATA);
90208 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
90209 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
90210 (mm->end_data - mm->start_data) > rlim)
90211 goto out;
90212 @@ -933,6 +956,12 @@ static int
90213 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
90214 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
90215 {
90216 +
90217 +#ifdef CONFIG_PAX_SEGMEXEC
90218 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
90219 + return 0;
90220 +#endif
90221 +
90222 if (is_mergeable_vma(vma, file, vm_flags) &&
90223 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
90224 if (vma->vm_pgoff == vm_pgoff)
90225 @@ -952,6 +981,12 @@ static int
90226 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
90227 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
90228 {
90229 +
90230 +#ifdef CONFIG_PAX_SEGMEXEC
90231 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
90232 + return 0;
90233 +#endif
90234 +
90235 if (is_mergeable_vma(vma, file, vm_flags) &&
90236 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
90237 pgoff_t vm_pglen;
90238 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
90239 struct vm_area_struct *vma_merge(struct mm_struct *mm,
90240 struct vm_area_struct *prev, unsigned long addr,
90241 unsigned long end, unsigned long vm_flags,
90242 - struct anon_vma *anon_vma, struct file *file,
90243 + struct anon_vma *anon_vma, struct file *file,
90244 pgoff_t pgoff, struct mempolicy *policy)
90245 {
90246 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
90247 struct vm_area_struct *area, *next;
90248 int err;
90249
90250 +#ifdef CONFIG_PAX_SEGMEXEC
90251 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
90252 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
90253 +
90254 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
90255 +#endif
90256 +
90257 /*
90258 * We later require that vma->vm_flags == vm_flags,
90259 * so this tests vma->vm_flags & VM_SPECIAL, too.
90260 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
90261 if (next && next->vm_end == end) /* cases 6, 7, 8 */
90262 next = next->vm_next;
90263
90264 +#ifdef CONFIG_PAX_SEGMEXEC
90265 + if (prev)
90266 + prev_m = pax_find_mirror_vma(prev);
90267 + if (area)
90268 + area_m = pax_find_mirror_vma(area);
90269 + if (next)
90270 + next_m = pax_find_mirror_vma(next);
90271 +#endif
90272 +
90273 /*
90274 * Can it merge with the predecessor?
90275 */
90276 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
90277 /* cases 1, 6 */
90278 err = vma_adjust(prev, prev->vm_start,
90279 next->vm_end, prev->vm_pgoff, NULL);
90280 - } else /* cases 2, 5, 7 */
90281 +
90282 +#ifdef CONFIG_PAX_SEGMEXEC
90283 + if (!err && prev_m)
90284 + err = vma_adjust(prev_m, prev_m->vm_start,
90285 + next_m->vm_end, prev_m->vm_pgoff, NULL);
90286 +#endif
90287 +
90288 + } else { /* cases 2, 5, 7 */
90289 err = vma_adjust(prev, prev->vm_start,
90290 end, prev->vm_pgoff, NULL);
90291 +
90292 +#ifdef CONFIG_PAX_SEGMEXEC
90293 + if (!err && prev_m)
90294 + err = vma_adjust(prev_m, prev_m->vm_start,
90295 + end_m, prev_m->vm_pgoff, NULL);
90296 +#endif
90297 +
90298 + }
90299 if (err)
90300 return NULL;
90301 khugepaged_enter_vma_merge(prev);
90302 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
90303 mpol_equal(policy, vma_policy(next)) &&
90304 can_vma_merge_before(next, vm_flags,
90305 anon_vma, file, pgoff+pglen)) {
90306 - if (prev && addr < prev->vm_end) /* case 4 */
90307 + if (prev && addr < prev->vm_end) { /* case 4 */
90308 err = vma_adjust(prev, prev->vm_start,
90309 addr, prev->vm_pgoff, NULL);
90310 - else /* cases 3, 8 */
90311 +
90312 +#ifdef CONFIG_PAX_SEGMEXEC
90313 + if (!err && prev_m)
90314 + err = vma_adjust(prev_m, prev_m->vm_start,
90315 + addr_m, prev_m->vm_pgoff, NULL);
90316 +#endif
90317 +
90318 + } else { /* cases 3, 8 */
90319 err = vma_adjust(area, addr, next->vm_end,
90320 next->vm_pgoff - pglen, NULL);
90321 +
90322 +#ifdef CONFIG_PAX_SEGMEXEC
90323 + if (!err && area_m)
90324 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
90325 + next_m->vm_pgoff - pglen, NULL);
90326 +#endif
90327 +
90328 + }
90329 if (err)
90330 return NULL;
90331 khugepaged_enter_vma_merge(area);
90332 @@ -1165,8 +1246,10 @@ none:
90333 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
90334 struct file *file, long pages)
90335 {
90336 - const unsigned long stack_flags
90337 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
90338 +
90339 +#ifdef CONFIG_PAX_RANDMMAP
90340 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
90341 +#endif
90342
90343 mm->total_vm += pages;
90344
90345 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
90346 mm->shared_vm += pages;
90347 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
90348 mm->exec_vm += pages;
90349 - } else if (flags & stack_flags)
90350 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
90351 mm->stack_vm += pages;
90352 }
90353 #endif /* CONFIG_PROC_FS */
90354 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
90355 * (the exception is when the underlying filesystem is noexec
90356 * mounted, in which case we dont add PROT_EXEC.)
90357 */
90358 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
90359 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
90360 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
90361 prot |= PROT_EXEC;
90362
90363 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
90364 /* Obtain the address to map to. we verify (or select) it and ensure
90365 * that it represents a valid section of the address space.
90366 */
90367 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
90368 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
90369 if (addr & ~PAGE_MASK)
90370 return addr;
90371
90372 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
90373 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
90374 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
90375
90376 +#ifdef CONFIG_PAX_MPROTECT
90377 + if (mm->pax_flags & MF_PAX_MPROTECT) {
90378 +
90379 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
90380 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
90381 + mm->binfmt->handle_mmap)
90382 + mm->binfmt->handle_mmap(file);
90383 +#endif
90384 +
90385 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
90386 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
90387 + gr_log_rwxmmap(file);
90388 +
90389 +#ifdef CONFIG_PAX_EMUPLT
90390 + vm_flags &= ~VM_EXEC;
90391 +#else
90392 + return -EPERM;
90393 +#endif
90394 +
90395 + }
90396 +
90397 + if (!(vm_flags & VM_EXEC))
90398 + vm_flags &= ~VM_MAYEXEC;
90399 +#else
90400 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
90401 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
90402 +#endif
90403 + else
90404 + vm_flags &= ~VM_MAYWRITE;
90405 + }
90406 +#endif
90407 +
90408 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
90409 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
90410 + vm_flags &= ~VM_PAGEEXEC;
90411 +#endif
90412 +
90413 if (flags & MAP_LOCKED)
90414 if (!can_do_mlock())
90415 return -EPERM;
90416 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
90417 locked += mm->locked_vm;
90418 lock_limit = rlimit(RLIMIT_MEMLOCK);
90419 lock_limit >>= PAGE_SHIFT;
90420 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
90421 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
90422 return -EAGAIN;
90423 }
90424 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
90425 vm_flags |= VM_NORESERVE;
90426 }
90427
90428 + if (!gr_acl_handle_mmap(file, prot))
90429 + return -EACCES;
90430 +
90431 addr = mmap_region(file, addr, len, vm_flags, pgoff);
90432 if (!IS_ERR_VALUE(addr) &&
90433 ((vm_flags & VM_LOCKED) ||
90434 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
90435 vm_flags_t vm_flags = vma->vm_flags;
90436
90437 /* If it was private or non-writable, the write bit is already clear */
90438 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
90439 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
90440 return 0;
90441
90442 /* The backer wishes to know when pages are first written to? */
90443 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
90444 struct rb_node **rb_link, *rb_parent;
90445 unsigned long charged = 0;
90446
90447 +#ifdef CONFIG_PAX_SEGMEXEC
90448 + struct vm_area_struct *vma_m = NULL;
90449 +#endif
90450 +
90451 + /*
90452 + * mm->mmap_sem is required to protect against another thread
90453 + * changing the mappings in case we sleep.
90454 + */
90455 + verify_mm_writelocked(mm);
90456 +
90457 /* Check against address space limit. */
90458 +
90459 +#ifdef CONFIG_PAX_RANDMMAP
90460 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
90461 +#endif
90462 +
90463 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
90464 unsigned long nr_pages;
90465
90466 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
90467
90468 /* Clear old maps */
90469 error = -ENOMEM;
90470 -munmap_back:
90471 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
90472 if (do_munmap(mm, addr, len))
90473 return -ENOMEM;
90474 - goto munmap_back;
90475 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
90476 }
90477
90478 /*
90479 @@ -1537,6 +1675,16 @@ munmap_back:
90480 goto unacct_error;
90481 }
90482
90483 +#ifdef CONFIG_PAX_SEGMEXEC
90484 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
90485 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90486 + if (!vma_m) {
90487 + error = -ENOMEM;
90488 + goto free_vma;
90489 + }
90490 + }
90491 +#endif
90492 +
90493 vma->vm_mm = mm;
90494 vma->vm_start = addr;
90495 vma->vm_end = addr + len;
90496 @@ -1556,6 +1704,13 @@ munmap_back:
90497 if (error)
90498 goto unmap_and_free_vma;
90499
90500 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
90501 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
90502 + vma->vm_flags |= VM_PAGEEXEC;
90503 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
90504 + }
90505 +#endif
90506 +
90507 /* Can addr have changed??
90508 *
90509 * Answer: Yes, several device drivers can do it in their
90510 @@ -1589,6 +1744,12 @@ munmap_back:
90511 }
90512
90513 vma_link(mm, vma, prev, rb_link, rb_parent);
90514 +
90515 +#ifdef CONFIG_PAX_SEGMEXEC
90516 + if (vma_m)
90517 + BUG_ON(pax_mirror_vma(vma_m, vma));
90518 +#endif
90519 +
90520 /* Once vma denies write, undo our temporary denial count */
90521 if (vm_flags & VM_DENYWRITE)
90522 allow_write_access(file);
90523 @@ -1597,6 +1758,7 @@ out:
90524 perf_event_mmap(vma);
90525
90526 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
90527 + track_exec_limit(mm, addr, addr + len, vm_flags);
90528 if (vm_flags & VM_LOCKED) {
90529 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
90530 vma == get_gate_vma(current->mm)))
90531 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
90532 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
90533 charged = 0;
90534 free_vma:
90535 +
90536 +#ifdef CONFIG_PAX_SEGMEXEC
90537 + if (vma_m)
90538 + kmem_cache_free(vm_area_cachep, vma_m);
90539 +#endif
90540 +
90541 kmem_cache_free(vm_area_cachep, vma);
90542 unacct_error:
90543 if (charged)
90544 @@ -1636,7 +1804,63 @@ unacct_error:
90545 return error;
90546 }
90547
90548 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
90549 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
90550 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
90551 +{
90552 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
90553 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
90554 +
90555 + return 0;
90556 +}
90557 +#endif
90558 +
90559 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
90560 +{
90561 + if (!vma) {
90562 +#ifdef CONFIG_STACK_GROWSUP
90563 + if (addr > sysctl_heap_stack_gap)
90564 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
90565 + else
90566 + vma = find_vma(current->mm, 0);
90567 + if (vma && (vma->vm_flags & VM_GROWSUP))
90568 + return false;
90569 +#endif
90570 + return true;
90571 + }
90572 +
90573 + if (addr + len > vma->vm_start)
90574 + return false;
90575 +
90576 + if (vma->vm_flags & VM_GROWSDOWN)
90577 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
90578 +#ifdef CONFIG_STACK_GROWSUP
90579 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
90580 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
90581 +#endif
90582 + else if (offset)
90583 + return offset <= vma->vm_start - addr - len;
90584 +
90585 + return true;
90586 +}
90587 +
90588 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
90589 +{
90590 + if (vma->vm_start < len)
90591 + return -ENOMEM;
90592 +
90593 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
90594 + if (offset <= vma->vm_start - len)
90595 + return vma->vm_start - len - offset;
90596 + else
90597 + return -ENOMEM;
90598 + }
90599 +
90600 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
90601 + return vma->vm_start - len - sysctl_heap_stack_gap;
90602 + return -ENOMEM;
90603 +}
90604 +
90605 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
90606 {
90607 /*
90608 * We implement the search by looking for an rbtree node that
90609 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
90610 }
90611 }
90612
90613 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
90614 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
90615 check_current:
90616 /* Check if current node has a suitable gap */
90617 if (gap_start > high_limit)
90618 return -ENOMEM;
90619 +
90620 + if (gap_end - gap_start > info->threadstack_offset)
90621 + gap_start += info->threadstack_offset;
90622 + else
90623 + gap_start = gap_end;
90624 +
90625 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
90626 + if (gap_end - gap_start > sysctl_heap_stack_gap)
90627 + gap_start += sysctl_heap_stack_gap;
90628 + else
90629 + gap_start = gap_end;
90630 + }
90631 + if (vma->vm_flags & VM_GROWSDOWN) {
90632 + if (gap_end - gap_start > sysctl_heap_stack_gap)
90633 + gap_end -= sysctl_heap_stack_gap;
90634 + else
90635 + gap_end = gap_start;
90636 + }
90637 if (gap_end >= low_limit && gap_end - gap_start >= length)
90638 goto found;
90639
90640 @@ -1738,7 +1980,7 @@ found:
90641 return gap_start;
90642 }
90643
90644 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
90645 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
90646 {
90647 struct mm_struct *mm = current->mm;
90648 struct vm_area_struct *vma;
90649 @@ -1792,6 +2034,24 @@ check_current:
90650 gap_end = vma->vm_start;
90651 if (gap_end < low_limit)
90652 return -ENOMEM;
90653 +
90654 + if (gap_end - gap_start > info->threadstack_offset)
90655 + gap_end -= info->threadstack_offset;
90656 + else
90657 + gap_end = gap_start;
90658 +
90659 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
90660 + if (gap_end - gap_start > sysctl_heap_stack_gap)
90661 + gap_start += sysctl_heap_stack_gap;
90662 + else
90663 + gap_start = gap_end;
90664 + }
90665 + if (vma->vm_flags & VM_GROWSDOWN) {
90666 + if (gap_end - gap_start > sysctl_heap_stack_gap)
90667 + gap_end -= sysctl_heap_stack_gap;
90668 + else
90669 + gap_end = gap_start;
90670 + }
90671 if (gap_start <= high_limit && gap_end - gap_start >= length)
90672 goto found;
90673
90674 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
90675 struct mm_struct *mm = current->mm;
90676 struct vm_area_struct *vma;
90677 struct vm_unmapped_area_info info;
90678 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
90679
90680 if (len > TASK_SIZE - mmap_min_addr)
90681 return -ENOMEM;
90682 @@ -1862,19 +2123,30 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
90683 if (flags & MAP_FIXED)
90684 return addr;
90685
90686 +#ifdef CONFIG_PAX_RANDMMAP
90687 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
90688 +#endif
90689 +
90690 if (addr) {
90691 addr = PAGE_ALIGN(addr);
90692 vma = find_vma(mm, addr);
90693 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
90694 - (!vma || addr + len <= vma->vm_start))
90695 + check_heap_stack_gap(vma, addr, len, offset))
90696 return addr;
90697 }
90698
90699 info.flags = 0;
90700 info.length = len;
90701 info.low_limit = TASK_UNMAPPED_BASE;
90702 +
90703 +#ifdef CONFIG_PAX_RANDMMAP
90704 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90705 + info.low_limit += mm->delta_mmap;
90706 +#endif
90707 +
90708 info.high_limit = TASK_SIZE;
90709 info.align_mask = 0;
90710 + info.threadstack_offset = offset;
90711 return vm_unmapped_area(&info);
90712 }
90713 #endif
90714 @@ -1893,6 +2165,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90715 struct mm_struct *mm = current->mm;
90716 unsigned long addr = addr0;
90717 struct vm_unmapped_area_info info;
90718 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
90719
90720 /* requested length too big for entire address space */
90721 if (len > TASK_SIZE - mmap_min_addr)
90722 @@ -1901,12 +2174,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90723 if (flags & MAP_FIXED)
90724 return addr;
90725
90726 +#ifdef CONFIG_PAX_RANDMMAP
90727 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
90728 +#endif
90729 +
90730 /* requesting a specific address */
90731 if (addr) {
90732 addr = PAGE_ALIGN(addr);
90733 vma = find_vma(mm, addr);
90734 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
90735 - (!vma || addr + len <= vma->vm_start))
90736 + check_heap_stack_gap(vma, addr, len, offset))
90737 return addr;
90738 }
90739
90740 @@ -1915,6 +2192,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90741 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
90742 info.high_limit = mm->mmap_base;
90743 info.align_mask = 0;
90744 + info.threadstack_offset = offset;
90745 addr = vm_unmapped_area(&info);
90746
90747 /*
90748 @@ -1927,6 +2205,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90749 VM_BUG_ON(addr != -ENOMEM);
90750 info.flags = 0;
90751 info.low_limit = TASK_UNMAPPED_BASE;
90752 +
90753 +#ifdef CONFIG_PAX_RANDMMAP
90754 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90755 + info.low_limit += mm->delta_mmap;
90756 +#endif
90757 +
90758 info.high_limit = TASK_SIZE;
90759 addr = vm_unmapped_area(&info);
90760 }
90761 @@ -2028,6 +2312,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
90762 return vma;
90763 }
90764
90765 +#ifdef CONFIG_PAX_SEGMEXEC
90766 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
90767 +{
90768 + struct vm_area_struct *vma_m;
90769 +
90770 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
90771 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
90772 + BUG_ON(vma->vm_mirror);
90773 + return NULL;
90774 + }
90775 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
90776 + vma_m = vma->vm_mirror;
90777 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
90778 + BUG_ON(vma->vm_file != vma_m->vm_file);
90779 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
90780 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
90781 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
90782 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
90783 + return vma_m;
90784 +}
90785 +#endif
90786 +
90787 /*
90788 * Verify that the stack growth is acceptable and
90789 * update accounting. This is shared with both the
90790 @@ -2044,6 +2350,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90791 return -ENOMEM;
90792
90793 /* Stack limit test */
90794 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
90795 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
90796 return -ENOMEM;
90797
90798 @@ -2054,6 +2361,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90799 locked = mm->locked_vm + grow;
90800 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
90801 limit >>= PAGE_SHIFT;
90802 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
90803 if (locked > limit && !capable(CAP_IPC_LOCK))
90804 return -ENOMEM;
90805 }
90806 @@ -2083,37 +2391,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90807 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
90808 * vma is the last one with address > vma->vm_end. Have to extend vma.
90809 */
90810 +#ifndef CONFIG_IA64
90811 +static
90812 +#endif
90813 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
90814 {
90815 int error;
90816 + bool locknext;
90817
90818 if (!(vma->vm_flags & VM_GROWSUP))
90819 return -EFAULT;
90820
90821 + /* Also guard against wrapping around to address 0. */
90822 + if (address < PAGE_ALIGN(address+1))
90823 + address = PAGE_ALIGN(address+1);
90824 + else
90825 + return -ENOMEM;
90826 +
90827 /*
90828 * We must make sure the anon_vma is allocated
90829 * so that the anon_vma locking is not a noop.
90830 */
90831 if (unlikely(anon_vma_prepare(vma)))
90832 return -ENOMEM;
90833 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
90834 + if (locknext && anon_vma_prepare(vma->vm_next))
90835 + return -ENOMEM;
90836 vma_lock_anon_vma(vma);
90837 + if (locknext)
90838 + vma_lock_anon_vma(vma->vm_next);
90839
90840 /*
90841 * vma->vm_start/vm_end cannot change under us because the caller
90842 * is required to hold the mmap_sem in read mode. We need the
90843 - * anon_vma lock to serialize against concurrent expand_stacks.
90844 - * Also guard against wrapping around to address 0.
90845 + * anon_vma locks to serialize against concurrent expand_stacks
90846 + * and expand_upwards.
90847 */
90848 - if (address < PAGE_ALIGN(address+4))
90849 - address = PAGE_ALIGN(address+4);
90850 - else {
90851 - vma_unlock_anon_vma(vma);
90852 - return -ENOMEM;
90853 - }
90854 error = 0;
90855
90856 /* Somebody else might have raced and expanded it already */
90857 - if (address > vma->vm_end) {
90858 + 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)
90859 + error = -ENOMEM;
90860 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
90861 unsigned long size, grow;
90862
90863 size = address - vma->vm_start;
90864 @@ -2148,6 +2467,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
90865 }
90866 }
90867 }
90868 + if (locknext)
90869 + vma_unlock_anon_vma(vma->vm_next);
90870 vma_unlock_anon_vma(vma);
90871 khugepaged_enter_vma_merge(vma);
90872 validate_mm(vma->vm_mm);
90873 @@ -2162,6 +2483,8 @@ int expand_downwards(struct vm_area_struct *vma,
90874 unsigned long address)
90875 {
90876 int error;
90877 + bool lockprev = false;
90878 + struct vm_area_struct *prev;
90879
90880 /*
90881 * We must make sure the anon_vma is allocated
90882 @@ -2175,6 +2498,15 @@ int expand_downwards(struct vm_area_struct *vma,
90883 if (error)
90884 return error;
90885
90886 + prev = vma->vm_prev;
90887 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
90888 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
90889 +#endif
90890 + if (lockprev && anon_vma_prepare(prev))
90891 + return -ENOMEM;
90892 + if (lockprev)
90893 + vma_lock_anon_vma(prev);
90894 +
90895 vma_lock_anon_vma(vma);
90896
90897 /*
90898 @@ -2184,9 +2516,17 @@ int expand_downwards(struct vm_area_struct *vma,
90899 */
90900
90901 /* Somebody else might have raced and expanded it already */
90902 - if (address < vma->vm_start) {
90903 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
90904 + error = -ENOMEM;
90905 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
90906 unsigned long size, grow;
90907
90908 +#ifdef CONFIG_PAX_SEGMEXEC
90909 + struct vm_area_struct *vma_m;
90910 +
90911 + vma_m = pax_find_mirror_vma(vma);
90912 +#endif
90913 +
90914 size = vma->vm_end - address;
90915 grow = (vma->vm_start - address) >> PAGE_SHIFT;
90916
90917 @@ -2211,13 +2551,27 @@ int expand_downwards(struct vm_area_struct *vma,
90918 vma->vm_pgoff -= grow;
90919 anon_vma_interval_tree_post_update_vma(vma);
90920 vma_gap_update(vma);
90921 +
90922 +#ifdef CONFIG_PAX_SEGMEXEC
90923 + if (vma_m) {
90924 + anon_vma_interval_tree_pre_update_vma(vma_m);
90925 + vma_m->vm_start -= grow << PAGE_SHIFT;
90926 + vma_m->vm_pgoff -= grow;
90927 + anon_vma_interval_tree_post_update_vma(vma_m);
90928 + vma_gap_update(vma_m);
90929 + }
90930 +#endif
90931 +
90932 spin_unlock(&vma->vm_mm->page_table_lock);
90933
90934 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
90935 perf_event_mmap(vma);
90936 }
90937 }
90938 }
90939 vma_unlock_anon_vma(vma);
90940 + if (lockprev)
90941 + vma_unlock_anon_vma(prev);
90942 khugepaged_enter_vma_merge(vma);
90943 validate_mm(vma->vm_mm);
90944 return error;
90945 @@ -2315,6 +2669,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
90946 do {
90947 long nrpages = vma_pages(vma);
90948
90949 +#ifdef CONFIG_PAX_SEGMEXEC
90950 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
90951 + vma = remove_vma(vma);
90952 + continue;
90953 + }
90954 +#endif
90955 +
90956 if (vma->vm_flags & VM_ACCOUNT)
90957 nr_accounted += nrpages;
90958 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
90959 @@ -2359,6 +2720,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
90960 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
90961 vma->vm_prev = NULL;
90962 do {
90963 +
90964 +#ifdef CONFIG_PAX_SEGMEXEC
90965 + if (vma->vm_mirror) {
90966 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
90967 + vma->vm_mirror->vm_mirror = NULL;
90968 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
90969 + vma->vm_mirror = NULL;
90970 + }
90971 +#endif
90972 +
90973 vma_rb_erase(vma, &mm->mm_rb);
90974 mm->map_count--;
90975 tail_vma = vma;
90976 @@ -2384,14 +2755,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90977 struct vm_area_struct *new;
90978 int err = -ENOMEM;
90979
90980 +#ifdef CONFIG_PAX_SEGMEXEC
90981 + struct vm_area_struct *vma_m, *new_m = NULL;
90982 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
90983 +#endif
90984 +
90985 if (is_vm_hugetlb_page(vma) && (addr &
90986 ~(huge_page_mask(hstate_vma(vma)))))
90987 return -EINVAL;
90988
90989 +#ifdef CONFIG_PAX_SEGMEXEC
90990 + vma_m = pax_find_mirror_vma(vma);
90991 +#endif
90992 +
90993 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
90994 if (!new)
90995 goto out_err;
90996
90997 +#ifdef CONFIG_PAX_SEGMEXEC
90998 + if (vma_m) {
90999 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
91000 + if (!new_m) {
91001 + kmem_cache_free(vm_area_cachep, new);
91002 + goto out_err;
91003 + }
91004 + }
91005 +#endif
91006 +
91007 /* most fields are the same, copy all, and then fixup */
91008 *new = *vma;
91009
91010 @@ -2404,6 +2794,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
91011 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
91012 }
91013
91014 +#ifdef CONFIG_PAX_SEGMEXEC
91015 + if (vma_m) {
91016 + *new_m = *vma_m;
91017 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
91018 + new_m->vm_mirror = new;
91019 + new->vm_mirror = new_m;
91020 +
91021 + if (new_below)
91022 + new_m->vm_end = addr_m;
91023 + else {
91024 + new_m->vm_start = addr_m;
91025 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
91026 + }
91027 + }
91028 +#endif
91029 +
91030 err = vma_dup_policy(vma, new);
91031 if (err)
91032 goto out_free_vma;
91033 @@ -2423,6 +2829,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
91034 else
91035 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
91036
91037 +#ifdef CONFIG_PAX_SEGMEXEC
91038 + if (!err && vma_m) {
91039 + struct mempolicy *pol = vma_policy(new);
91040 +
91041 + if (anon_vma_clone(new_m, vma_m))
91042 + goto out_free_mpol;
91043 +
91044 + mpol_get(pol);
91045 + set_vma_policy(new_m, pol);
91046 +
91047 + if (new_m->vm_file)
91048 + get_file(new_m->vm_file);
91049 +
91050 + if (new_m->vm_ops && new_m->vm_ops->open)
91051 + new_m->vm_ops->open(new_m);
91052 +
91053 + if (new_below)
91054 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
91055 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
91056 + else
91057 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
91058 +
91059 + if (err) {
91060 + if (new_m->vm_ops && new_m->vm_ops->close)
91061 + new_m->vm_ops->close(new_m);
91062 + if (new_m->vm_file)
91063 + fput(new_m->vm_file);
91064 + mpol_put(pol);
91065 + }
91066 + }
91067 +#endif
91068 +
91069 /* Success. */
91070 if (!err)
91071 return 0;
91072 @@ -2432,10 +2870,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
91073 new->vm_ops->close(new);
91074 if (new->vm_file)
91075 fput(new->vm_file);
91076 - unlink_anon_vmas(new);
91077 out_free_mpol:
91078 mpol_put(vma_policy(new));
91079 out_free_vma:
91080 +
91081 +#ifdef CONFIG_PAX_SEGMEXEC
91082 + if (new_m) {
91083 + unlink_anon_vmas(new_m);
91084 + kmem_cache_free(vm_area_cachep, new_m);
91085 + }
91086 +#endif
91087 +
91088 + unlink_anon_vmas(new);
91089 kmem_cache_free(vm_area_cachep, new);
91090 out_err:
91091 return err;
91092 @@ -2448,6 +2894,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
91093 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
91094 unsigned long addr, int new_below)
91095 {
91096 +
91097 +#ifdef CONFIG_PAX_SEGMEXEC
91098 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
91099 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
91100 + if (mm->map_count >= sysctl_max_map_count-1)
91101 + return -ENOMEM;
91102 + } else
91103 +#endif
91104 +
91105 if (mm->map_count >= sysctl_max_map_count)
91106 return -ENOMEM;
91107
91108 @@ -2459,11 +2914,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
91109 * work. This now handles partial unmappings.
91110 * Jeremy Fitzhardinge <jeremy@goop.org>
91111 */
91112 +#ifdef CONFIG_PAX_SEGMEXEC
91113 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
91114 {
91115 + int ret = __do_munmap(mm, start, len);
91116 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
91117 + return ret;
91118 +
91119 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
91120 +}
91121 +
91122 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
91123 +#else
91124 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
91125 +#endif
91126 +{
91127 unsigned long end;
91128 struct vm_area_struct *vma, *prev, *last;
91129
91130 + /*
91131 + * mm->mmap_sem is required to protect against another thread
91132 + * changing the mappings in case we sleep.
91133 + */
91134 + verify_mm_writelocked(mm);
91135 +
91136 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
91137 return -EINVAL;
91138
91139 @@ -2538,6 +3012,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
91140 /* Fix up all other VM information */
91141 remove_vma_list(mm, vma);
91142
91143 + track_exec_limit(mm, start, end, 0UL);
91144 +
91145 return 0;
91146 }
91147
91148 @@ -2546,6 +3022,13 @@ int vm_munmap(unsigned long start, size_t len)
91149 int ret;
91150 struct mm_struct *mm = current->mm;
91151
91152 +
91153 +#ifdef CONFIG_PAX_SEGMEXEC
91154 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
91155 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
91156 + return -EINVAL;
91157 +#endif
91158 +
91159 down_write(&mm->mmap_sem);
91160 ret = do_munmap(mm, start, len);
91161 up_write(&mm->mmap_sem);
91162 @@ -2559,16 +3042,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
91163 return vm_munmap(addr, len);
91164 }
91165
91166 -static inline void verify_mm_writelocked(struct mm_struct *mm)
91167 -{
91168 -#ifdef CONFIG_DEBUG_VM
91169 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
91170 - WARN_ON(1);
91171 - up_read(&mm->mmap_sem);
91172 - }
91173 -#endif
91174 -}
91175 -
91176 /*
91177 * this is really a simplified "do_mmap". it only handles
91178 * anonymous maps. eventually we may be able to do some
91179 @@ -2582,6 +3055,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
91180 struct rb_node ** rb_link, * rb_parent;
91181 pgoff_t pgoff = addr >> PAGE_SHIFT;
91182 int error;
91183 + unsigned long charged;
91184
91185 len = PAGE_ALIGN(len);
91186 if (!len)
91187 @@ -2589,16 +3063,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
91188
91189 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
91190
91191 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
91192 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
91193 + flags &= ~VM_EXEC;
91194 +
91195 +#ifdef CONFIG_PAX_MPROTECT
91196 + if (mm->pax_flags & MF_PAX_MPROTECT)
91197 + flags &= ~VM_MAYEXEC;
91198 +#endif
91199 +
91200 + }
91201 +#endif
91202 +
91203 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
91204 if (error & ~PAGE_MASK)
91205 return error;
91206
91207 + charged = len >> PAGE_SHIFT;
91208 +
91209 /*
91210 * mlock MCL_FUTURE?
91211 */
91212 if (mm->def_flags & VM_LOCKED) {
91213 unsigned long locked, lock_limit;
91214 - locked = len >> PAGE_SHIFT;
91215 + locked = charged;
91216 locked += mm->locked_vm;
91217 lock_limit = rlimit(RLIMIT_MEMLOCK);
91218 lock_limit >>= PAGE_SHIFT;
91219 @@ -2615,21 +3103,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
91220 /*
91221 * Clear old maps. this also does some error checking for us
91222 */
91223 - munmap_back:
91224 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
91225 if (do_munmap(mm, addr, len))
91226 return -ENOMEM;
91227 - goto munmap_back;
91228 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
91229 }
91230
91231 /* Check against address space limits *after* clearing old maps... */
91232 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
91233 + if (!may_expand_vm(mm, charged))
91234 return -ENOMEM;
91235
91236 if (mm->map_count > sysctl_max_map_count)
91237 return -ENOMEM;
91238
91239 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
91240 + if (security_vm_enough_memory_mm(mm, charged))
91241 return -ENOMEM;
91242
91243 /* Can we just expand an old private anonymous mapping? */
91244 @@ -2643,7 +3130,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
91245 */
91246 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
91247 if (!vma) {
91248 - vm_unacct_memory(len >> PAGE_SHIFT);
91249 + vm_unacct_memory(charged);
91250 return -ENOMEM;
91251 }
91252
91253 @@ -2657,10 +3144,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
91254 vma_link(mm, vma, prev, rb_link, rb_parent);
91255 out:
91256 perf_event_mmap(vma);
91257 - mm->total_vm += len >> PAGE_SHIFT;
91258 + mm->total_vm += charged;
91259 if (flags & VM_LOCKED)
91260 - mm->locked_vm += (len >> PAGE_SHIFT);
91261 + mm->locked_vm += charged;
91262 vma->vm_flags |= VM_SOFTDIRTY;
91263 + track_exec_limit(mm, addr, addr + len, flags);
91264 return addr;
91265 }
91266
91267 @@ -2722,6 +3210,7 @@ void exit_mmap(struct mm_struct *mm)
91268 while (vma) {
91269 if (vma->vm_flags & VM_ACCOUNT)
91270 nr_accounted += vma_pages(vma);
91271 + vma->vm_mirror = NULL;
91272 vma = remove_vma(vma);
91273 }
91274 vm_unacct_memory(nr_accounted);
91275 @@ -2738,6 +3227,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
91276 struct vm_area_struct *prev;
91277 struct rb_node **rb_link, *rb_parent;
91278
91279 +#ifdef CONFIG_PAX_SEGMEXEC
91280 + struct vm_area_struct *vma_m = NULL;
91281 +#endif
91282 +
91283 + if (security_mmap_addr(vma->vm_start))
91284 + return -EPERM;
91285 +
91286 /*
91287 * The vm_pgoff of a purely anonymous vma should be irrelevant
91288 * until its first write fault, when page's anon_vma and index
91289 @@ -2761,7 +3257,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
91290 security_vm_enough_memory_mm(mm, vma_pages(vma)))
91291 return -ENOMEM;
91292
91293 +#ifdef CONFIG_PAX_SEGMEXEC
91294 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
91295 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
91296 + if (!vma_m)
91297 + return -ENOMEM;
91298 + }
91299 +#endif
91300 +
91301 vma_link(mm, vma, prev, rb_link, rb_parent);
91302 +
91303 +#ifdef CONFIG_PAX_SEGMEXEC
91304 + if (vma_m)
91305 + BUG_ON(pax_mirror_vma(vma_m, vma));
91306 +#endif
91307 +
91308 return 0;
91309 }
91310
91311 @@ -2780,6 +3290,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
91312 struct rb_node **rb_link, *rb_parent;
91313 bool faulted_in_anon_vma = true;
91314
91315 + BUG_ON(vma->vm_mirror);
91316 +
91317 /*
91318 * If anonymous vma has not yet been faulted, update new pgoff
91319 * to match new location, to increase its chance of merging.
91320 @@ -2844,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
91321 return NULL;
91322 }
91323
91324 +#ifdef CONFIG_PAX_SEGMEXEC
91325 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
91326 +{
91327 + struct vm_area_struct *prev_m;
91328 + struct rb_node **rb_link_m, *rb_parent_m;
91329 + struct mempolicy *pol_m;
91330 +
91331 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
91332 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
91333 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
91334 + *vma_m = *vma;
91335 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
91336 + if (anon_vma_clone(vma_m, vma))
91337 + return -ENOMEM;
91338 + pol_m = vma_policy(vma_m);
91339 + mpol_get(pol_m);
91340 + set_vma_policy(vma_m, pol_m);
91341 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
91342 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
91343 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
91344 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
91345 + if (vma_m->vm_file)
91346 + get_file(vma_m->vm_file);
91347 + if (vma_m->vm_ops && vma_m->vm_ops->open)
91348 + vma_m->vm_ops->open(vma_m);
91349 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
91350 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
91351 + vma_m->vm_mirror = vma;
91352 + vma->vm_mirror = vma_m;
91353 + return 0;
91354 +}
91355 +#endif
91356 +
91357 /*
91358 * Return true if the calling process may expand its vm space by the passed
91359 * number of pages
91360 @@ -2855,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
91361
91362 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
91363
91364 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
91365 if (cur + npages > lim)
91366 return 0;
91367 return 1;
91368 @@ -2925,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
91369 vma->vm_start = addr;
91370 vma->vm_end = addr + len;
91371
91372 +#ifdef CONFIG_PAX_MPROTECT
91373 + if (mm->pax_flags & MF_PAX_MPROTECT) {
91374 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
91375 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
91376 + return -EPERM;
91377 + if (!(vm_flags & VM_EXEC))
91378 + vm_flags &= ~VM_MAYEXEC;
91379 +#else
91380 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
91381 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
91382 +#endif
91383 + else
91384 + vm_flags &= ~VM_MAYWRITE;
91385 + }
91386 +#endif
91387 +
91388 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
91389 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
91390
91391 diff --git a/mm/mprotect.c b/mm/mprotect.c
91392 index 7651a57..d761c62 100644
91393 --- a/mm/mprotect.c
91394 +++ b/mm/mprotect.c
91395 @@ -23,10 +23,18 @@
91396 #include <linux/mmu_notifier.h>
91397 #include <linux/migrate.h>
91398 #include <linux/perf_event.h>
91399 +#include <linux/sched/sysctl.h>
91400 +
91401 +#ifdef CONFIG_PAX_MPROTECT
91402 +#include <linux/elf.h>
91403 +#include <linux/binfmts.h>
91404 +#endif
91405 +
91406 #include <asm/uaccess.h>
91407 #include <asm/pgtable.h>
91408 #include <asm/cacheflush.h>
91409 #include <asm/tlbflush.h>
91410 +#include <asm/mmu_context.h>
91411
91412 #ifndef pgprot_modify
91413 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
91414 @@ -250,6 +258,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
91415 return pages;
91416 }
91417
91418 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
91419 +/* called while holding the mmap semaphor for writing except stack expansion */
91420 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
91421 +{
91422 + unsigned long oldlimit, newlimit = 0UL;
91423 +
91424 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
91425 + return;
91426 +
91427 + spin_lock(&mm->page_table_lock);
91428 + oldlimit = mm->context.user_cs_limit;
91429 + if ((prot & VM_EXEC) && oldlimit < end)
91430 + /* USER_CS limit moved up */
91431 + newlimit = end;
91432 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
91433 + /* USER_CS limit moved down */
91434 + newlimit = start;
91435 +
91436 + if (newlimit) {
91437 + mm->context.user_cs_limit = newlimit;
91438 +
91439 +#ifdef CONFIG_SMP
91440 + wmb();
91441 + cpus_clear(mm->context.cpu_user_cs_mask);
91442 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
91443 +#endif
91444 +
91445 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
91446 + }
91447 + spin_unlock(&mm->page_table_lock);
91448 + if (newlimit == end) {
91449 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
91450 +
91451 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
91452 + if (is_vm_hugetlb_page(vma))
91453 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
91454 + else
91455 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
91456 + }
91457 +}
91458 +#endif
91459 +
91460 int
91461 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
91462 unsigned long start, unsigned long end, unsigned long newflags)
91463 @@ -262,11 +312,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
91464 int error;
91465 int dirty_accountable = 0;
91466
91467 +#ifdef CONFIG_PAX_SEGMEXEC
91468 + struct vm_area_struct *vma_m = NULL;
91469 + unsigned long start_m, end_m;
91470 +
91471 + start_m = start + SEGMEXEC_TASK_SIZE;
91472 + end_m = end + SEGMEXEC_TASK_SIZE;
91473 +#endif
91474 +
91475 if (newflags == oldflags) {
91476 *pprev = vma;
91477 return 0;
91478 }
91479
91480 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
91481 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
91482 +
91483 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
91484 + return -ENOMEM;
91485 +
91486 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
91487 + return -ENOMEM;
91488 + }
91489 +
91490 /*
91491 * If we make a private mapping writable we increase our commit;
91492 * but (without finer accounting) cannot reduce our commit if we
91493 @@ -283,6 +351,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
91494 }
91495 }
91496
91497 +#ifdef CONFIG_PAX_SEGMEXEC
91498 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
91499 + if (start != vma->vm_start) {
91500 + error = split_vma(mm, vma, start, 1);
91501 + if (error)
91502 + goto fail;
91503 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
91504 + *pprev = (*pprev)->vm_next;
91505 + }
91506 +
91507 + if (end != vma->vm_end) {
91508 + error = split_vma(mm, vma, end, 0);
91509 + if (error)
91510 + goto fail;
91511 + }
91512 +
91513 + if (pax_find_mirror_vma(vma)) {
91514 + error = __do_munmap(mm, start_m, end_m - start_m);
91515 + if (error)
91516 + goto fail;
91517 + } else {
91518 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
91519 + if (!vma_m) {
91520 + error = -ENOMEM;
91521 + goto fail;
91522 + }
91523 + vma->vm_flags = newflags;
91524 + error = pax_mirror_vma(vma_m, vma);
91525 + if (error) {
91526 + vma->vm_flags = oldflags;
91527 + goto fail;
91528 + }
91529 + }
91530 + }
91531 +#endif
91532 +
91533 /*
91534 * First try to merge with previous and/or next vma.
91535 */
91536 @@ -313,9 +417,21 @@ success:
91537 * vm_flags and vm_page_prot are protected by the mmap_sem
91538 * held in write mode.
91539 */
91540 +
91541 +#ifdef CONFIG_PAX_SEGMEXEC
91542 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
91543 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
91544 +#endif
91545 +
91546 vma->vm_flags = newflags;
91547 +
91548 +#ifdef CONFIG_PAX_MPROTECT
91549 + if (mm->binfmt && mm->binfmt->handle_mprotect)
91550 + mm->binfmt->handle_mprotect(vma, newflags);
91551 +#endif
91552 +
91553 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
91554 - vm_get_page_prot(newflags));
91555 + vm_get_page_prot(vma->vm_flags));
91556
91557 if (vma_wants_writenotify(vma)) {
91558 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
91559 @@ -354,6 +470,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
91560 end = start + len;
91561 if (end <= start)
91562 return -ENOMEM;
91563 +
91564 +#ifdef CONFIG_PAX_SEGMEXEC
91565 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
91566 + if (end > SEGMEXEC_TASK_SIZE)
91567 + return -EINVAL;
91568 + } else
91569 +#endif
91570 +
91571 + if (end > TASK_SIZE)
91572 + return -EINVAL;
91573 +
91574 if (!arch_validate_prot(prot))
91575 return -EINVAL;
91576
91577 @@ -361,7 +488,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
91578 /*
91579 * Does the application expect PROT_READ to imply PROT_EXEC:
91580 */
91581 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
91582 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
91583 prot |= PROT_EXEC;
91584
91585 vm_flags = calc_vm_prot_bits(prot);
91586 @@ -393,6 +520,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
91587 if (start > vma->vm_start)
91588 prev = vma;
91589
91590 +#ifdef CONFIG_PAX_MPROTECT
91591 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
91592 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
91593 +#endif
91594 +
91595 for (nstart = start ; ; ) {
91596 unsigned long newflags;
91597
91598 @@ -403,6 +535,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
91599
91600 /* newflags >> 4 shift VM_MAY% in place of VM_% */
91601 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
91602 + if (prot & (PROT_WRITE | PROT_EXEC))
91603 + gr_log_rwxmprotect(vma);
91604 +
91605 + error = -EACCES;
91606 + goto out;
91607 + }
91608 +
91609 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
91610 error = -EACCES;
91611 goto out;
91612 }
91613 @@ -417,6 +557,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
91614 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
91615 if (error)
91616 goto out;
91617 +
91618 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
91619 +
91620 nstart = tmp;
91621
91622 if (nstart < prev->vm_end)
91623 diff --git a/mm/mremap.c b/mm/mremap.c
91624 index 0843feb..4f5b2e6 100644
91625 --- a/mm/mremap.c
91626 +++ b/mm/mremap.c
91627 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
91628 continue;
91629 pte = ptep_get_and_clear(mm, old_addr, old_pte);
91630 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
91631 +
91632 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
91633 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
91634 + pte = pte_exprotect(pte);
91635 +#endif
91636 +
91637 pte = move_soft_dirty_pte(pte);
91638 set_pte_at(mm, new_addr, new_pte, pte);
91639 }
91640 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
91641 if (is_vm_hugetlb_page(vma))
91642 goto Einval;
91643
91644 +#ifdef CONFIG_PAX_SEGMEXEC
91645 + if (pax_find_mirror_vma(vma))
91646 + goto Einval;
91647 +#endif
91648 +
91649 /* We can't remap across vm area boundaries */
91650 if (old_len > vma->vm_end - addr)
91651 goto Efault;
91652 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
91653 unsigned long ret = -EINVAL;
91654 unsigned long charged = 0;
91655 unsigned long map_flags;
91656 + unsigned long pax_task_size = TASK_SIZE;
91657
91658 if (new_addr & ~PAGE_MASK)
91659 goto out;
91660
91661 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
91662 +#ifdef CONFIG_PAX_SEGMEXEC
91663 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
91664 + pax_task_size = SEGMEXEC_TASK_SIZE;
91665 +#endif
91666 +
91667 + pax_task_size -= PAGE_SIZE;
91668 +
91669 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
91670 goto out;
91671
91672 /* Check if the location we're moving into overlaps the
91673 * old location at all, and fail if it does.
91674 */
91675 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
91676 - goto out;
91677 -
91678 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
91679 + if (addr + old_len > new_addr && new_addr + new_len > addr)
91680 goto out;
91681
91682 ret = do_munmap(mm, new_addr, new_len);
91683 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91684 unsigned long ret = -EINVAL;
91685 unsigned long charged = 0;
91686 bool locked = false;
91687 + unsigned long pax_task_size = TASK_SIZE;
91688
91689 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
91690 return ret;
91691 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91692 if (!new_len)
91693 return ret;
91694
91695 +#ifdef CONFIG_PAX_SEGMEXEC
91696 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
91697 + pax_task_size = SEGMEXEC_TASK_SIZE;
91698 +#endif
91699 +
91700 + pax_task_size -= PAGE_SIZE;
91701 +
91702 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
91703 + old_len > pax_task_size || addr > pax_task_size-old_len)
91704 + return ret;
91705 +
91706 down_write(&current->mm->mmap_sem);
91707
91708 if (flags & MREMAP_FIXED) {
91709 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91710 new_addr = addr;
91711 }
91712 ret = addr;
91713 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
91714 goto out;
91715 }
91716 }
91717 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91718 goto out;
91719 }
91720
91721 + map_flags = vma->vm_flags;
91722 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
91723 + if (!(ret & ~PAGE_MASK)) {
91724 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
91725 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
91726 + }
91727 }
91728 out:
91729 if (ret & ~PAGE_MASK)
91730 diff --git a/mm/nommu.c b/mm/nommu.c
91731 index ecd1f15..77039bd 100644
91732 --- a/mm/nommu.c
91733 +++ b/mm/nommu.c
91734 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
91735 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
91736 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
91737 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
91738 -int heap_stack_gap = 0;
91739
91740 atomic_long_t mmap_pages_allocated;
91741
91742 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
91743 EXPORT_SYMBOL(find_vma);
91744
91745 /*
91746 - * find a VMA
91747 - * - we don't extend stack VMAs under NOMMU conditions
91748 - */
91749 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
91750 -{
91751 - return find_vma(mm, addr);
91752 -}
91753 -
91754 -/*
91755 * expand a stack to a given address
91756 * - not supported under NOMMU conditions
91757 */
91758 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
91759
91760 /* most fields are the same, copy all, and then fixup */
91761 *new = *vma;
91762 + INIT_LIST_HEAD(&new->anon_vma_chain);
91763 *region = *vma->vm_region;
91764 new->vm_region = region;
91765
91766 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
91767 }
91768 EXPORT_SYMBOL(generic_file_remap_pages);
91769
91770 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91771 - unsigned long addr, void *buf, int len, int write)
91772 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91773 + unsigned long addr, void *buf, size_t len, int write)
91774 {
91775 struct vm_area_struct *vma;
91776
91777 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91778 *
91779 * The caller must hold a reference on @mm.
91780 */
91781 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
91782 - void *buf, int len, int write)
91783 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
91784 + void *buf, size_t len, int write)
91785 {
91786 return __access_remote_vm(NULL, mm, addr, buf, len, write);
91787 }
91788 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
91789 * Access another process' address space.
91790 * - source/target buffer must be kernel space
91791 */
91792 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
91793 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
91794 {
91795 struct mm_struct *mm;
91796
91797 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
91798 index 6380758..4064aec 100644
91799 --- a/mm/page-writeback.c
91800 +++ b/mm/page-writeback.c
91801 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
91802 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
91803 * - the bdi dirty thresh drops quickly due to change of JBOD workload
91804 */
91805 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
91806 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
91807 unsigned long thresh,
91808 unsigned long bg_thresh,
91809 unsigned long dirty,
91810 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
91811 index 317ea74..a4a1977 100644
91812 --- a/mm/page_alloc.c
91813 +++ b/mm/page_alloc.c
91814 @@ -61,6 +61,7 @@
91815 #include <linux/page-debug-flags.h>
91816 #include <linux/hugetlb.h>
91817 #include <linux/sched/rt.h>
91818 +#include <linux/random.h>
91819
91820 #include <asm/sections.h>
91821 #include <asm/tlbflush.h>
91822 @@ -354,7 +355,7 @@ out:
91823 * This usage means that zero-order pages may not be compound.
91824 */
91825
91826 -static void free_compound_page(struct page *page)
91827 +void free_compound_page(struct page *page)
91828 {
91829 __free_pages_ok(page, compound_order(page));
91830 }
91831 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
91832 int i;
91833 int bad = 0;
91834
91835 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91836 + unsigned long index = 1UL << order;
91837 +#endif
91838 +
91839 trace_mm_page_free(page, order);
91840 kmemcheck_free_shadow(page, order);
91841
91842 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
91843 debug_check_no_obj_freed(page_address(page),
91844 PAGE_SIZE << order);
91845 }
91846 +
91847 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91848 + for (; index; --index)
91849 + sanitize_highpage(page + index - 1);
91850 +#endif
91851 +
91852 arch_free_page(page, order);
91853 kernel_map_pages(page, 1 << order, 0);
91854
91855 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
91856 local_irq_restore(flags);
91857 }
91858
91859 +#ifdef CONFIG_PAX_LATENT_ENTROPY
91860 +bool __meminitdata extra_latent_entropy;
91861 +
91862 +static int __init setup_pax_extra_latent_entropy(char *str)
91863 +{
91864 + extra_latent_entropy = true;
91865 + return 0;
91866 +}
91867 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
91868 +
91869 +volatile u64 latent_entropy __latent_entropy;
91870 +EXPORT_SYMBOL(latent_entropy);
91871 +#endif
91872 +
91873 void __init __free_pages_bootmem(struct page *page, unsigned int order)
91874 {
91875 unsigned int nr_pages = 1 << order;
91876 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
91877 __ClearPageReserved(p);
91878 set_page_count(p, 0);
91879
91880 +#ifdef CONFIG_PAX_LATENT_ENTROPY
91881 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
91882 + u64 hash = 0;
91883 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
91884 + const u64 *data = lowmem_page_address(page);
91885 +
91886 + for (index = 0; index < end; index++)
91887 + hash ^= hash + data[index];
91888 + latent_entropy ^= hash;
91889 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
91890 + }
91891 +#endif
91892 +
91893 page_zone(page)->managed_pages += nr_pages;
91894 set_page_refcounted(page);
91895 __free_pages(page, order);
91896 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
91897 arch_alloc_page(page, order);
91898 kernel_map_pages(page, 1 << order, 1);
91899
91900 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
91901 if (gfp_flags & __GFP_ZERO)
91902 prep_zero_page(page, order, gfp_flags);
91903 +#endif
91904
91905 if (order && (gfp_flags & __GFP_COMP))
91906 prep_compound_page(page, order);
91907 diff --git a/mm/page_io.c b/mm/page_io.c
91908 index 8c79a47..a689e0d 100644
91909 --- a/mm/page_io.c
91910 +++ b/mm/page_io.c
91911 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
91912 struct file *swap_file = sis->swap_file;
91913 struct address_space *mapping = swap_file->f_mapping;
91914 struct iovec iov = {
91915 - .iov_base = kmap(page),
91916 + .iov_base = (void __force_user *)kmap(page),
91917 .iov_len = PAGE_SIZE,
91918 };
91919
91920 diff --git a/mm/percpu.c b/mm/percpu.c
91921 index 8c8e08f..73a5cda 100644
91922 --- a/mm/percpu.c
91923 +++ b/mm/percpu.c
91924 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
91925 static unsigned int pcpu_high_unit_cpu __read_mostly;
91926
91927 /* the address of the first chunk which starts with the kernel static area */
91928 -void *pcpu_base_addr __read_mostly;
91929 +void *pcpu_base_addr __read_only;
91930 EXPORT_SYMBOL_GPL(pcpu_base_addr);
91931
91932 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
91933 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
91934 index fd26d04..0cea1b0 100644
91935 --- a/mm/process_vm_access.c
91936 +++ b/mm/process_vm_access.c
91937 @@ -13,6 +13,7 @@
91938 #include <linux/uio.h>
91939 #include <linux/sched.h>
91940 #include <linux/highmem.h>
91941 +#include <linux/security.h>
91942 #include <linux/ptrace.h>
91943 #include <linux/slab.h>
91944 #include <linux/syscalls.h>
91945 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
91946 size_t iov_l_curr_offset = 0;
91947 ssize_t iov_len;
91948
91949 + return -ENOSYS; // PaX: until properly audited
91950 +
91951 /*
91952 * Work out how many pages of struct pages we're going to need
91953 * when eventually calling get_user_pages
91954 */
91955 for (i = 0; i < riovcnt; i++) {
91956 iov_len = rvec[i].iov_len;
91957 - if (iov_len > 0) {
91958 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
91959 - + iov_len)
91960 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
91961 - / PAGE_SIZE + 1;
91962 - nr_pages = max(nr_pages, nr_pages_iov);
91963 - }
91964 + if (iov_len <= 0)
91965 + continue;
91966 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
91967 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
91968 + nr_pages = max(nr_pages, nr_pages_iov);
91969 }
91970
91971 if (nr_pages == 0)
91972 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
91973 goto free_proc_pages;
91974 }
91975
91976 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
91977 + rc = -EPERM;
91978 + goto put_task_struct;
91979 + }
91980 +
91981 mm = mm_access(task, PTRACE_MODE_ATTACH);
91982 if (!mm || IS_ERR(mm)) {
91983 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
91984 diff --git a/mm/rmap.c b/mm/rmap.c
91985 index b9d2222..e4baa1f 100644
91986 --- a/mm/rmap.c
91987 +++ b/mm/rmap.c
91988 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91989 struct anon_vma *anon_vma = vma->anon_vma;
91990 struct anon_vma_chain *avc;
91991
91992 +#ifdef CONFIG_PAX_SEGMEXEC
91993 + struct anon_vma_chain *avc_m = NULL;
91994 +#endif
91995 +
91996 might_sleep();
91997 if (unlikely(!anon_vma)) {
91998 struct mm_struct *mm = vma->vm_mm;
91999 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
92000 if (!avc)
92001 goto out_enomem;
92002
92003 +#ifdef CONFIG_PAX_SEGMEXEC
92004 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
92005 + if (!avc_m)
92006 + goto out_enomem_free_avc;
92007 +#endif
92008 +
92009 anon_vma = find_mergeable_anon_vma(vma);
92010 allocated = NULL;
92011 if (!anon_vma) {
92012 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
92013 /* page_table_lock to protect against threads */
92014 spin_lock(&mm->page_table_lock);
92015 if (likely(!vma->anon_vma)) {
92016 +
92017 +#ifdef CONFIG_PAX_SEGMEXEC
92018 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
92019 +
92020 + if (vma_m) {
92021 + BUG_ON(vma_m->anon_vma);
92022 + vma_m->anon_vma = anon_vma;
92023 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
92024 + avc_m = NULL;
92025 + }
92026 +#endif
92027 +
92028 vma->anon_vma = anon_vma;
92029 anon_vma_chain_link(vma, avc, anon_vma);
92030 allocated = NULL;
92031 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
92032
92033 if (unlikely(allocated))
92034 put_anon_vma(allocated);
92035 +
92036 +#ifdef CONFIG_PAX_SEGMEXEC
92037 + if (unlikely(avc_m))
92038 + anon_vma_chain_free(avc_m);
92039 +#endif
92040 +
92041 if (unlikely(avc))
92042 anon_vma_chain_free(avc);
92043 }
92044 return 0;
92045
92046 out_enomem_free_avc:
92047 +
92048 +#ifdef CONFIG_PAX_SEGMEXEC
92049 + if (avc_m)
92050 + anon_vma_chain_free(avc_m);
92051 +#endif
92052 +
92053 anon_vma_chain_free(avc);
92054 out_enomem:
92055 return -ENOMEM;
92056 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
92057 * Attach the anon_vmas from src to dst.
92058 * Returns 0 on success, -ENOMEM on failure.
92059 */
92060 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
92061 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
92062 {
92063 struct anon_vma_chain *avc, *pavc;
92064 struct anon_vma *root = NULL;
92065 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
92066 * the corresponding VMA in the parent process is attached to.
92067 * Returns 0 on success, non-zero on failure.
92068 */
92069 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
92070 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
92071 {
92072 struct anon_vma_chain *avc;
92073 struct anon_vma *anon_vma;
92074 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
92075 void __init anon_vma_init(void)
92076 {
92077 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
92078 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
92079 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
92080 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
92081 + anon_vma_ctor);
92082 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
92083 + SLAB_PANIC|SLAB_NO_SANITIZE);
92084 }
92085
92086 /*
92087 diff --git a/mm/shmem.c b/mm/shmem.c
92088 index 8297623..6b9dfe9 100644
92089 --- a/mm/shmem.c
92090 +++ b/mm/shmem.c
92091 @@ -33,7 +33,7 @@
92092 #include <linux/swap.h>
92093 #include <linux/aio.h>
92094
92095 -static struct vfsmount *shm_mnt;
92096 +struct vfsmount *shm_mnt;
92097
92098 #ifdef CONFIG_SHMEM
92099 /*
92100 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
92101 #define BOGO_DIRENT_SIZE 20
92102
92103 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
92104 -#define SHORT_SYMLINK_LEN 128
92105 +#define SHORT_SYMLINK_LEN 64
92106
92107 /*
92108 * shmem_fallocate and shmem_writepage communicate via inode->i_private
92109 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
92110 static int shmem_xattr_validate(const char *name)
92111 {
92112 struct { const char *prefix; size_t len; } arr[] = {
92113 +
92114 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
92115 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
92116 +#endif
92117 +
92118 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
92119 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
92120 };
92121 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
92122 if (err)
92123 return err;
92124
92125 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
92126 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
92127 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
92128 + return -EOPNOTSUPP;
92129 + if (size > 8)
92130 + return -EINVAL;
92131 + }
92132 +#endif
92133 +
92134 return simple_xattr_set(&info->xattrs, name, value, size, flags);
92135 }
92136
92137 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
92138 int err = -ENOMEM;
92139
92140 /* Round up to L1_CACHE_BYTES to resist false sharing */
92141 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
92142 - L1_CACHE_BYTES), GFP_KERNEL);
92143 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
92144 if (!sbinfo)
92145 return -ENOMEM;
92146
92147 diff --git a/mm/slab.c b/mm/slab.c
92148 index 2580db0..0523956 100644
92149 --- a/mm/slab.c
92150 +++ b/mm/slab.c
92151 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
92152 if ((x)->max_freeable < i) \
92153 (x)->max_freeable = i; \
92154 } while (0)
92155 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
92156 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
92157 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
92158 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
92159 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
92160 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
92161 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
92162 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
92163 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
92164 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
92165 #else
92166 #define STATS_INC_ACTIVE(x) do { } while (0)
92167 #define STATS_DEC_ACTIVE(x) do { } while (0)
92168 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
92169 #define STATS_INC_ALLOCMISS(x) do { } while (0)
92170 #define STATS_INC_FREEHIT(x) do { } while (0)
92171 #define STATS_INC_FREEMISS(x) do { } while (0)
92172 +#define STATS_INC_SANITIZED(x) do { } while (0)
92173 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
92174 #endif
92175
92176 #if DEBUG
92177 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
92178 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
92179 */
92180 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
92181 - const struct slab *slab, void *obj)
92182 + const struct slab *slab, const void *obj)
92183 {
92184 u32 offset = (obj - slab->s_mem);
92185 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
92186 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
92187 */
92188
92189 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
92190 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
92191 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
92192
92193 if (INDEX_AC != INDEX_NODE)
92194 kmalloc_caches[INDEX_NODE] =
92195 create_kmalloc_cache("kmalloc-node",
92196 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
92197 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
92198
92199 slab_early_init = 0;
92200
92201 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
92202 struct array_cache *ac = cpu_cache_get(cachep);
92203
92204 check_irq_off();
92205 +
92206 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92207 + if (pax_sanitize_slab) {
92208 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
92209 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
92210 +
92211 + if (cachep->ctor)
92212 + cachep->ctor(objp);
92213 +
92214 + STATS_INC_SANITIZED(cachep);
92215 + } else
92216 + STATS_INC_NOT_SANITIZED(cachep);
92217 + }
92218 +#endif
92219 +
92220 kmemleak_free_recursive(objp, cachep->flags);
92221 objp = cache_free_debugcheck(cachep, objp, caller);
92222
92223 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
92224
92225 if (unlikely(ZERO_OR_NULL_PTR(objp)))
92226 return;
92227 + VM_BUG_ON(!virt_addr_valid(objp));
92228 local_irq_save(flags);
92229 kfree_debugcheck(objp);
92230 c = virt_to_cache(objp);
92231 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
92232 }
92233 /* cpu stats */
92234 {
92235 - unsigned long allochit = atomic_read(&cachep->allochit);
92236 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
92237 - unsigned long freehit = atomic_read(&cachep->freehit);
92238 - unsigned long freemiss = atomic_read(&cachep->freemiss);
92239 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
92240 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
92241 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
92242 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
92243
92244 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
92245 allochit, allocmiss, freehit, freemiss);
92246 }
92247 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92248 + {
92249 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
92250 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
92251 +
92252 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
92253 + }
92254 +#endif
92255 #endif
92256 }
92257
92258 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
92259 static int __init slab_proc_init(void)
92260 {
92261 #ifdef CONFIG_DEBUG_SLAB_LEAK
92262 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
92263 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
92264 #endif
92265 return 0;
92266 }
92267 module_init(slab_proc_init);
92268 #endif
92269
92270 +bool is_usercopy_object(const void *ptr)
92271 +{
92272 + struct page *page;
92273 + struct kmem_cache *cachep;
92274 +
92275 + if (ZERO_OR_NULL_PTR(ptr))
92276 + return false;
92277 +
92278 + if (!slab_is_available())
92279 + return false;
92280 +
92281 + if (!virt_addr_valid(ptr))
92282 + return false;
92283 +
92284 + page = virt_to_head_page(ptr);
92285 +
92286 + if (!PageSlab(page))
92287 + return false;
92288 +
92289 + cachep = page->slab_cache;
92290 + return cachep->flags & SLAB_USERCOPY;
92291 +}
92292 +
92293 +#ifdef CONFIG_PAX_USERCOPY
92294 +const char *check_heap_object(const void *ptr, unsigned long n)
92295 +{
92296 + struct page *page;
92297 + struct kmem_cache *cachep;
92298 + struct slab *slabp;
92299 + unsigned int objnr;
92300 + unsigned long offset;
92301 +
92302 + if (ZERO_OR_NULL_PTR(ptr))
92303 + return "<null>";
92304 +
92305 + if (!virt_addr_valid(ptr))
92306 + return NULL;
92307 +
92308 + page = virt_to_head_page(ptr);
92309 +
92310 + if (!PageSlab(page))
92311 + return NULL;
92312 +
92313 + cachep = page->slab_cache;
92314 + if (!(cachep->flags & SLAB_USERCOPY))
92315 + return cachep->name;
92316 +
92317 + slabp = page->slab_page;
92318 + objnr = obj_to_index(cachep, slabp, ptr);
92319 + BUG_ON(objnr >= cachep->num);
92320 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
92321 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
92322 + return NULL;
92323 +
92324 + return cachep->name;
92325 +}
92326 +#endif
92327 +
92328 /**
92329 * ksize - get the actual amount of memory allocated for a given object
92330 * @objp: Pointer to the object
92331 diff --git a/mm/slab.h b/mm/slab.h
92332 index a535033..2f98fe5 100644
92333 --- a/mm/slab.h
92334 +++ b/mm/slab.h
92335 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
92336 /* The slab cache that manages slab cache information */
92337 extern struct kmem_cache *kmem_cache;
92338
92339 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92340 +#ifdef CONFIG_X86_64
92341 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
92342 +#else
92343 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
92344 +#endif
92345 +extern bool pax_sanitize_slab;
92346 +#endif
92347 +
92348 unsigned long calculate_alignment(unsigned long flags,
92349 unsigned long align, unsigned long size);
92350
92351 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92352
92353 /* Legal flag mask for kmem_cache_create(), for various configurations */
92354 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
92355 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
92356 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
92357 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
92358
92359 #if defined(CONFIG_DEBUG_SLAB)
92360 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
92361 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
92362 return s;
92363
92364 page = virt_to_head_page(x);
92365 +
92366 + BUG_ON(!PageSlab(page));
92367 +
92368 cachep = page->slab_cache;
92369 if (slab_equal_or_root(cachep, s))
92370 return cachep;
92371 diff --git a/mm/slab_common.c b/mm/slab_common.c
92372 index e2e98af..3b1a163 100644
92373 --- a/mm/slab_common.c
92374 +++ b/mm/slab_common.c
92375 @@ -23,11 +23,22 @@
92376
92377 #include "slab.h"
92378
92379 -enum slab_state slab_state;
92380 +enum slab_state slab_state __read_only;
92381 LIST_HEAD(slab_caches);
92382 DEFINE_MUTEX(slab_mutex);
92383 struct kmem_cache *kmem_cache;
92384
92385 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92386 +bool pax_sanitize_slab __read_only = true;
92387 +static int __init pax_sanitize_slab_setup(char *str)
92388 +{
92389 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
92390 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
92391 + return 1;
92392 +}
92393 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
92394 +#endif
92395 +
92396 #ifdef CONFIG_DEBUG_VM
92397 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
92398 size_t size)
92399 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
92400
92401 err = __kmem_cache_create(s, flags);
92402 if (!err) {
92403 - s->refcount = 1;
92404 + atomic_set(&s->refcount, 1);
92405 list_add(&s->list, &slab_caches);
92406 memcg_cache_list_add(memcg, s);
92407 } else {
92408 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
92409
92410 get_online_cpus();
92411 mutex_lock(&slab_mutex);
92412 - s->refcount--;
92413 - if (!s->refcount) {
92414 + if (atomic_dec_and_test(&s->refcount)) {
92415 list_del(&s->list);
92416
92417 if (!__kmem_cache_shutdown(s)) {
92418 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
92419 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
92420 name, size, err);
92421
92422 - s->refcount = -1; /* Exempt from merging for now */
92423 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
92424 }
92425
92426 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
92427 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
92428
92429 create_boot_cache(s, name, size, flags);
92430 list_add(&s->list, &slab_caches);
92431 - s->refcount = 1;
92432 + atomic_set(&s->refcount, 1);
92433 return s;
92434 }
92435
92436 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
92437 EXPORT_SYMBOL(kmalloc_dma_caches);
92438 #endif
92439
92440 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92441 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
92442 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
92443 +#endif
92444 +
92445 /*
92446 * Conversion table for small slabs sizes / 8 to the index in the
92447 * kmalloc array. This is necessary for slabs < 192 since we have non power
92448 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
92449 return kmalloc_dma_caches[index];
92450
92451 #endif
92452 +
92453 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92454 + if (unlikely((flags & GFP_USERCOPY)))
92455 + return kmalloc_usercopy_caches[index];
92456 +
92457 +#endif
92458 +
92459 return kmalloc_caches[index];
92460 }
92461
92462 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
92463 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
92464 if (!kmalloc_caches[i]) {
92465 kmalloc_caches[i] = create_kmalloc_cache(NULL,
92466 - 1 << i, flags);
92467 + 1 << i, SLAB_USERCOPY | flags);
92468 }
92469
92470 /*
92471 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
92472 * earlier power of two caches
92473 */
92474 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
92475 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
92476 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
92477
92478 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
92479 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
92480 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
92481 }
92482
92483 /* Kmalloc array is now usable */
92484 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
92485 }
92486 }
92487 #endif
92488 +
92489 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92490 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
92491 + struct kmem_cache *s = kmalloc_caches[i];
92492 +
92493 + if (s) {
92494 + int size = kmalloc_size(i);
92495 + char *n = kasprintf(GFP_NOWAIT,
92496 + "usercopy-kmalloc-%d", size);
92497 +
92498 + BUG_ON(!n);
92499 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
92500 + size, SLAB_USERCOPY | flags);
92501 + }
92502 + }
92503 +#endif
92504 +
92505 }
92506 #endif /* !CONFIG_SLOB */
92507
92508 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
92509 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
92510 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
92511 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
92512 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92513 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
92514 +#endif
92515 #endif
92516 seq_putc(m, '\n');
92517 }
92518 diff --git a/mm/slob.c b/mm/slob.c
92519 index 4bf8809..98a6914 100644
92520 --- a/mm/slob.c
92521 +++ b/mm/slob.c
92522 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
92523 /*
92524 * Return the size of a slob block.
92525 */
92526 -static slobidx_t slob_units(slob_t *s)
92527 +static slobidx_t slob_units(const slob_t *s)
92528 {
92529 if (s->units > 0)
92530 return s->units;
92531 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
92532 /*
92533 * Return the next free slob block pointer after this one.
92534 */
92535 -static slob_t *slob_next(slob_t *s)
92536 +static slob_t *slob_next(const slob_t *s)
92537 {
92538 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
92539 slobidx_t next;
92540 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
92541 /*
92542 * Returns true if s is the last free block in its page.
92543 */
92544 -static int slob_last(slob_t *s)
92545 +static int slob_last(const slob_t *s)
92546 {
92547 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
92548 }
92549
92550 -static void *slob_new_pages(gfp_t gfp, int order, int node)
92551 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
92552 {
92553 - void *page;
92554 + struct page *page;
92555
92556 #ifdef CONFIG_NUMA
92557 if (node != NUMA_NO_NODE)
92558 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
92559 if (!page)
92560 return NULL;
92561
92562 - return page_address(page);
92563 + __SetPageSlab(page);
92564 + return page;
92565 }
92566
92567 -static void slob_free_pages(void *b, int order)
92568 +static void slob_free_pages(struct page *sp, int order)
92569 {
92570 if (current->reclaim_state)
92571 current->reclaim_state->reclaimed_slab += 1 << order;
92572 - free_pages((unsigned long)b, order);
92573 + __ClearPageSlab(sp);
92574 + page_mapcount_reset(sp);
92575 + sp->private = 0;
92576 + __free_pages(sp, order);
92577 }
92578
92579 /*
92580 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
92581
92582 /* Not enough space: must allocate a new page */
92583 if (!b) {
92584 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
92585 - if (!b)
92586 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
92587 + if (!sp)
92588 return NULL;
92589 - sp = virt_to_page(b);
92590 - __SetPageSlab(sp);
92591 + b = page_address(sp);
92592
92593 spin_lock_irqsave(&slob_lock, flags);
92594 sp->units = SLOB_UNITS(PAGE_SIZE);
92595 sp->freelist = b;
92596 + sp->private = 0;
92597 INIT_LIST_HEAD(&sp->list);
92598 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
92599 set_slob_page_free(sp, slob_list);
92600 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
92601 if (slob_page_free(sp))
92602 clear_slob_page_free(sp);
92603 spin_unlock_irqrestore(&slob_lock, flags);
92604 - __ClearPageSlab(sp);
92605 - page_mapcount_reset(sp);
92606 - slob_free_pages(b, 0);
92607 + slob_free_pages(sp, 0);
92608 return;
92609 }
92610
92611 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92612 + if (pax_sanitize_slab)
92613 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
92614 +#endif
92615 +
92616 if (!slob_page_free(sp)) {
92617 /* This slob page is about to become partially free. Easy! */
92618 sp->units = units;
92619 @@ -424,11 +431,10 @@ out:
92620 */
92621
92622 static __always_inline void *
92623 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
92624 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
92625 {
92626 - unsigned int *m;
92627 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92628 - void *ret;
92629 + slob_t *m;
92630 + void *ret = NULL;
92631
92632 gfp &= gfp_allowed_mask;
92633
92634 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
92635
92636 if (!m)
92637 return NULL;
92638 - *m = size;
92639 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
92640 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
92641 + m[0].units = size;
92642 + m[1].units = align;
92643 ret = (void *)m + align;
92644
92645 trace_kmalloc_node(caller, ret,
92646 size, size + align, gfp, node);
92647 } else {
92648 unsigned int order = get_order(size);
92649 + struct page *page;
92650
92651 if (likely(order))
92652 gfp |= __GFP_COMP;
92653 - ret = slob_new_pages(gfp, order, node);
92654 + page = slob_new_pages(gfp, order, node);
92655 + if (page) {
92656 + ret = page_address(page);
92657 + page->private = size;
92658 + }
92659
92660 trace_kmalloc_node(caller, ret,
92661 size, PAGE_SIZE << order, gfp, node);
92662 }
92663
92664 - kmemleak_alloc(ret, size, 1, gfp);
92665 + return ret;
92666 +}
92667 +
92668 +static __always_inline void *
92669 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
92670 +{
92671 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92672 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
92673 +
92674 + if (!ZERO_OR_NULL_PTR(ret))
92675 + kmemleak_alloc(ret, size, 1, gfp);
92676 return ret;
92677 }
92678
92679 @@ -493,34 +517,112 @@ void kfree(const void *block)
92680 return;
92681 kmemleak_free(block);
92682
92683 + VM_BUG_ON(!virt_addr_valid(block));
92684 sp = virt_to_page(block);
92685 - if (PageSlab(sp)) {
92686 + VM_BUG_ON(!PageSlab(sp));
92687 + if (!sp->private) {
92688 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92689 - unsigned int *m = (unsigned int *)(block - align);
92690 - slob_free(m, *m + align);
92691 - } else
92692 + slob_t *m = (slob_t *)(block - align);
92693 + slob_free(m, m[0].units + align);
92694 + } else {
92695 + __ClearPageSlab(sp);
92696 + page_mapcount_reset(sp);
92697 + sp->private = 0;
92698 __free_pages(sp, compound_order(sp));
92699 + }
92700 }
92701 EXPORT_SYMBOL(kfree);
92702
92703 +bool is_usercopy_object(const void *ptr)
92704 +{
92705 + if (!slab_is_available())
92706 + return false;
92707 +
92708 + // PAX: TODO
92709 +
92710 + return false;
92711 +}
92712 +
92713 +#ifdef CONFIG_PAX_USERCOPY
92714 +const char *check_heap_object(const void *ptr, unsigned long n)
92715 +{
92716 + struct page *page;
92717 + const slob_t *free;
92718 + const void *base;
92719 + unsigned long flags;
92720 +
92721 + if (ZERO_OR_NULL_PTR(ptr))
92722 + return "<null>";
92723 +
92724 + if (!virt_addr_valid(ptr))
92725 + return NULL;
92726 +
92727 + page = virt_to_head_page(ptr);
92728 + if (!PageSlab(page))
92729 + return NULL;
92730 +
92731 + if (page->private) {
92732 + base = page;
92733 + if (base <= ptr && n <= page->private - (ptr - base))
92734 + return NULL;
92735 + return "<slob>";
92736 + }
92737 +
92738 + /* some tricky double walking to find the chunk */
92739 + spin_lock_irqsave(&slob_lock, flags);
92740 + base = (void *)((unsigned long)ptr & PAGE_MASK);
92741 + free = page->freelist;
92742 +
92743 + while (!slob_last(free) && (void *)free <= ptr) {
92744 + base = free + slob_units(free);
92745 + free = slob_next(free);
92746 + }
92747 +
92748 + while (base < (void *)free) {
92749 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
92750 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
92751 + int offset;
92752 +
92753 + if (ptr < base + align)
92754 + break;
92755 +
92756 + offset = ptr - base - align;
92757 + if (offset >= m) {
92758 + base += size;
92759 + continue;
92760 + }
92761 +
92762 + if (n > m - offset)
92763 + break;
92764 +
92765 + spin_unlock_irqrestore(&slob_lock, flags);
92766 + return NULL;
92767 + }
92768 +
92769 + spin_unlock_irqrestore(&slob_lock, flags);
92770 + return "<slob>";
92771 +}
92772 +#endif
92773 +
92774 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
92775 size_t ksize(const void *block)
92776 {
92777 struct page *sp;
92778 int align;
92779 - unsigned int *m;
92780 + slob_t *m;
92781
92782 BUG_ON(!block);
92783 if (unlikely(block == ZERO_SIZE_PTR))
92784 return 0;
92785
92786 sp = virt_to_page(block);
92787 - if (unlikely(!PageSlab(sp)))
92788 - return PAGE_SIZE << compound_order(sp);
92789 + VM_BUG_ON(!PageSlab(sp));
92790 + if (sp->private)
92791 + return sp->private;
92792
92793 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92794 - m = (unsigned int *)(block - align);
92795 - return SLOB_UNITS(*m) * SLOB_UNIT;
92796 + m = (slob_t *)(block - align);
92797 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
92798 }
92799 EXPORT_SYMBOL(ksize);
92800
92801 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
92802
92803 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
92804 {
92805 - void *b;
92806 + void *b = NULL;
92807
92808 flags &= gfp_allowed_mask;
92809
92810 lockdep_trace_alloc(flags);
92811
92812 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92813 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
92814 +#else
92815 if (c->size < PAGE_SIZE) {
92816 b = slob_alloc(c->size, flags, c->align, node);
92817 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
92818 SLOB_UNITS(c->size) * SLOB_UNIT,
92819 flags, node);
92820 } else {
92821 - b = slob_new_pages(flags, get_order(c->size), node);
92822 + struct page *sp;
92823 +
92824 + sp = slob_new_pages(flags, get_order(c->size), node);
92825 + if (sp) {
92826 + b = page_address(sp);
92827 + sp->private = c->size;
92828 + }
92829 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
92830 PAGE_SIZE << get_order(c->size),
92831 flags, node);
92832 }
92833 +#endif
92834
92835 if (b && c->ctor)
92836 c->ctor(b);
92837 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
92838
92839 static void __kmem_cache_free(void *b, int size)
92840 {
92841 - if (size < PAGE_SIZE)
92842 + struct page *sp;
92843 +
92844 + sp = virt_to_page(b);
92845 + BUG_ON(!PageSlab(sp));
92846 + if (!sp->private)
92847 slob_free(b, size);
92848 else
92849 - slob_free_pages(b, get_order(size));
92850 + slob_free_pages(sp, get_order(size));
92851 }
92852
92853 static void kmem_rcu_free(struct rcu_head *head)
92854 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
92855
92856 void kmem_cache_free(struct kmem_cache *c, void *b)
92857 {
92858 + int size = c->size;
92859 +
92860 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92861 + if (size + c->align < PAGE_SIZE) {
92862 + size += c->align;
92863 + b -= c->align;
92864 + }
92865 +#endif
92866 +
92867 kmemleak_free_recursive(b, c->flags);
92868 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
92869 struct slob_rcu *slob_rcu;
92870 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
92871 - slob_rcu->size = c->size;
92872 + slob_rcu = b + (size - sizeof(struct slob_rcu));
92873 + slob_rcu->size = size;
92874 call_rcu(&slob_rcu->head, kmem_rcu_free);
92875 } else {
92876 - __kmem_cache_free(b, c->size);
92877 + __kmem_cache_free(b, size);
92878 }
92879
92880 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92881 + trace_kfree(_RET_IP_, b);
92882 +#else
92883 trace_kmem_cache_free(_RET_IP_, b);
92884 +#endif
92885 +
92886 }
92887 EXPORT_SYMBOL(kmem_cache_free);
92888
92889 diff --git a/mm/slub.c b/mm/slub.c
92890 index 96f2169..9111a59 100644
92891 --- a/mm/slub.c
92892 +++ b/mm/slub.c
92893 @@ -207,7 +207,7 @@ struct track {
92894
92895 enum track_item { TRACK_ALLOC, TRACK_FREE };
92896
92897 -#ifdef CONFIG_SYSFS
92898 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92899 static int sysfs_slab_add(struct kmem_cache *);
92900 static int sysfs_slab_alias(struct kmem_cache *, const char *);
92901 static void sysfs_slab_remove(struct kmem_cache *);
92902 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
92903 if (!t->addr)
92904 return;
92905
92906 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
92907 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
92908 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
92909 #ifdef CONFIG_STACKTRACE
92910 {
92911 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
92912
92913 slab_free_hook(s, x);
92914
92915 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92916 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
92917 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
92918 + if (s->ctor)
92919 + s->ctor(x);
92920 + }
92921 +#endif
92922 +
92923 redo:
92924 /*
92925 * Determine the currently cpus per cpu slab.
92926 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
92927 * Merge control. If this is set then no merging of slab caches will occur.
92928 * (Could be removed. This was introduced to pacify the merge skeptics.)
92929 */
92930 -static int slub_nomerge;
92931 +static int slub_nomerge = 1;
92932
92933 /*
92934 * Calculate the order of allocation given an slab object size.
92935 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
92936 s->inuse = size;
92937
92938 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
92939 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92940 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
92941 +#endif
92942 s->ctor)) {
92943 /*
92944 * Relocate free pointer after the object if it is not
92945 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
92946 EXPORT_SYMBOL(__kmalloc_node);
92947 #endif
92948
92949 +bool is_usercopy_object(const void *ptr)
92950 +{
92951 + struct page *page;
92952 + struct kmem_cache *s;
92953 +
92954 + if (ZERO_OR_NULL_PTR(ptr))
92955 + return false;
92956 +
92957 + if (!slab_is_available())
92958 + return false;
92959 +
92960 + if (!virt_addr_valid(ptr))
92961 + return false;
92962 +
92963 + page = virt_to_head_page(ptr);
92964 +
92965 + if (!PageSlab(page))
92966 + return false;
92967 +
92968 + s = page->slab_cache;
92969 + return s->flags & SLAB_USERCOPY;
92970 +}
92971 +
92972 +#ifdef CONFIG_PAX_USERCOPY
92973 +const char *check_heap_object(const void *ptr, unsigned long n)
92974 +{
92975 + struct page *page;
92976 + struct kmem_cache *s;
92977 + unsigned long offset;
92978 +
92979 + if (ZERO_OR_NULL_PTR(ptr))
92980 + return "<null>";
92981 +
92982 + if (!virt_addr_valid(ptr))
92983 + return NULL;
92984 +
92985 + page = virt_to_head_page(ptr);
92986 +
92987 + if (!PageSlab(page))
92988 + return NULL;
92989 +
92990 + s = page->slab_cache;
92991 + if (!(s->flags & SLAB_USERCOPY))
92992 + return s->name;
92993 +
92994 + offset = (ptr - page_address(page)) % s->size;
92995 + if (offset <= s->object_size && n <= s->object_size - offset)
92996 + return NULL;
92997 +
92998 + return s->name;
92999 +}
93000 +#endif
93001 +
93002 size_t ksize(const void *object)
93003 {
93004 struct page *page;
93005 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
93006 if (unlikely(ZERO_OR_NULL_PTR(x)))
93007 return;
93008
93009 + VM_BUG_ON(!virt_addr_valid(x));
93010 page = virt_to_head_page(x);
93011 if (unlikely(!PageSlab(page))) {
93012 BUG_ON(!PageCompound(page));
93013 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
93014 /*
93015 * We may have set a slab to be unmergeable during bootstrap.
93016 */
93017 - if (s->refcount < 0)
93018 + if (atomic_read(&s->refcount) < 0)
93019 return 1;
93020
93021 return 0;
93022 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
93023
93024 s = find_mergeable(memcg, size, align, flags, name, ctor);
93025 if (s) {
93026 - s->refcount++;
93027 + atomic_inc(&s->refcount);
93028 /*
93029 * Adjust the object sizes so that we clear
93030 * the complete object on kzalloc.
93031 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
93032 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
93033
93034 if (sysfs_slab_alias(s, name)) {
93035 - s->refcount--;
93036 + atomic_dec(&s->refcount);
93037 s = NULL;
93038 }
93039 }
93040 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
93041 }
93042 #endif
93043
93044 -#ifdef CONFIG_SYSFS
93045 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
93046 static int count_inuse(struct page *page)
93047 {
93048 return page->inuse;
93049 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
93050 validate_slab_cache(kmalloc_caches[9]);
93051 }
93052 #else
93053 -#ifdef CONFIG_SYSFS
93054 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
93055 static void resiliency_test(void) {};
93056 #endif
93057 #endif
93058
93059 -#ifdef CONFIG_SYSFS
93060 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
93061 enum slab_stat_type {
93062 SL_ALL, /* All slabs */
93063 SL_PARTIAL, /* Only partially allocated slabs */
93064 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
93065
93066 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
93067 {
93068 - return sprintf(buf, "%d\n", s->refcount - 1);
93069 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
93070 }
93071 SLAB_ATTR_RO(aliases);
93072
93073 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
93074 SLAB_ATTR_RO(cache_dma);
93075 #endif
93076
93077 +#ifdef CONFIG_PAX_USERCOPY_SLABS
93078 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
93079 +{
93080 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
93081 +}
93082 +SLAB_ATTR_RO(usercopy);
93083 +#endif
93084 +
93085 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
93086 {
93087 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
93088 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
93089 #ifdef CONFIG_ZONE_DMA
93090 &cache_dma_attr.attr,
93091 #endif
93092 +#ifdef CONFIG_PAX_USERCOPY_SLABS
93093 + &usercopy_attr.attr,
93094 +#endif
93095 #ifdef CONFIG_NUMA
93096 &remote_node_defrag_ratio_attr.attr,
93097 #endif
93098 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
93099 return name;
93100 }
93101
93102 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
93103 static int sysfs_slab_add(struct kmem_cache *s)
93104 {
93105 int err;
93106 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
93107 }
93108
93109 s->kobj.kset = slab_kset;
93110 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
93111 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
93112 if (err) {
93113 kobject_put(&s->kobj);
93114 return err;
93115 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
93116 kobject_del(&s->kobj);
93117 kobject_put(&s->kobj);
93118 }
93119 +#endif
93120
93121 /*
93122 * Need to buffer aliases during bootup until sysfs becomes
93123 @@ -5183,6 +5261,7 @@ struct saved_alias {
93124
93125 static struct saved_alias *alias_list;
93126
93127 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
93128 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
93129 {
93130 struct saved_alias *al;
93131 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
93132 alias_list = al;
93133 return 0;
93134 }
93135 +#endif
93136
93137 static int __init slab_sysfs_init(void)
93138 {
93139 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
93140 index 27eeab3..7c3f7f2 100644
93141 --- a/mm/sparse-vmemmap.c
93142 +++ b/mm/sparse-vmemmap.c
93143 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
93144 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
93145 if (!p)
93146 return NULL;
93147 - pud_populate(&init_mm, pud, p);
93148 + pud_populate_kernel(&init_mm, pud, p);
93149 }
93150 return pud;
93151 }
93152 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
93153 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
93154 if (!p)
93155 return NULL;
93156 - pgd_populate(&init_mm, pgd, p);
93157 + pgd_populate_kernel(&init_mm, pgd, p);
93158 }
93159 return pgd;
93160 }
93161 diff --git a/mm/sparse.c b/mm/sparse.c
93162 index 4ac1d7e..bbfcb1f 100644
93163 --- a/mm/sparse.c
93164 +++ b/mm/sparse.c
93165 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
93166
93167 for (i = 0; i < PAGES_PER_SECTION; i++) {
93168 if (PageHWPoison(&memmap[i])) {
93169 - atomic_long_sub(1, &num_poisoned_pages);
93170 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
93171 ClearPageHWPoison(&memmap[i]);
93172 }
93173 }
93174 diff --git a/mm/swap.c b/mm/swap.c
93175 index 759c3ca..7c1a5b4 100644
93176 --- a/mm/swap.c
93177 +++ b/mm/swap.c
93178 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
93179
93180 __page_cache_release(page);
93181 dtor = get_compound_page_dtor(page);
93182 + if (!PageHuge(page))
93183 + BUG_ON(dtor != free_compound_page);
93184 (*dtor)(page);
93185 }
93186
93187 diff --git a/mm/swapfile.c b/mm/swapfile.c
93188 index de7c904..c84bf11 100644
93189 --- a/mm/swapfile.c
93190 +++ b/mm/swapfile.c
93191 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
93192
93193 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
93194 /* Activity counter to indicate that a swapon or swapoff has occurred */
93195 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
93196 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
93197
93198 static inline unsigned char swap_count(unsigned char ent)
93199 {
93200 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
93201 }
93202 filp_close(swap_file, NULL);
93203 err = 0;
93204 - atomic_inc(&proc_poll_event);
93205 + atomic_inc_unchecked(&proc_poll_event);
93206 wake_up_interruptible(&proc_poll_wait);
93207
93208 out_dput:
93209 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
93210
93211 poll_wait(file, &proc_poll_wait, wait);
93212
93213 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
93214 - seq->poll_event = atomic_read(&proc_poll_event);
93215 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
93216 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
93217 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
93218 }
93219
93220 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
93221 return ret;
93222
93223 seq = file->private_data;
93224 - seq->poll_event = atomic_read(&proc_poll_event);
93225 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
93226 return 0;
93227 }
93228
93229 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
93230 (frontswap_map) ? "FS" : "");
93231
93232 mutex_unlock(&swapon_mutex);
93233 - atomic_inc(&proc_poll_event);
93234 + atomic_inc_unchecked(&proc_poll_event);
93235 wake_up_interruptible(&proc_poll_wait);
93236
93237 if (S_ISREG(inode->i_mode))
93238 diff --git a/mm/util.c b/mm/util.c
93239 index eaf63fc2..c6952b2 100644
93240 --- a/mm/util.c
93241 +++ b/mm/util.c
93242 @@ -294,6 +294,12 @@ done:
93243 void arch_pick_mmap_layout(struct mm_struct *mm)
93244 {
93245 mm->mmap_base = TASK_UNMAPPED_BASE;
93246 +
93247 +#ifdef CONFIG_PAX_RANDMMAP
93248 + if (mm->pax_flags & MF_PAX_RANDMMAP)
93249 + mm->mmap_base += mm->delta_mmap;
93250 +#endif
93251 +
93252 mm->get_unmapped_area = arch_get_unmapped_area;
93253 }
93254 #endif
93255 @@ -387,7 +393,10 @@ struct address_space *page_mapping(struct page *page)
93256 {
93257 struct address_space *mapping = page->mapping;
93258
93259 - VM_BUG_ON(PageSlab(page));
93260 + /* This happens if someone calls flush_dcache_page on slab page */
93261 + if (unlikely(PageSlab(page)))
93262 + return NULL;
93263 +
93264 if (unlikely(PageSwapCache(page))) {
93265 swp_entry_t entry;
93266
93267 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
93268 index 1074543..136dbe0 100644
93269 --- a/mm/vmalloc.c
93270 +++ b/mm/vmalloc.c
93271 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
93272
93273 pte = pte_offset_kernel(pmd, addr);
93274 do {
93275 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
93276 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
93277 +
93278 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
93279 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
93280 + BUG_ON(!pte_exec(*pte));
93281 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
93282 + continue;
93283 + }
93284 +#endif
93285 +
93286 + {
93287 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
93288 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
93289 + }
93290 } while (pte++, addr += PAGE_SIZE, addr != end);
93291 }
93292
93293 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
93294 pte = pte_alloc_kernel(pmd, addr);
93295 if (!pte)
93296 return -ENOMEM;
93297 +
93298 + pax_open_kernel();
93299 do {
93300 struct page *page = pages[*nr];
93301
93302 - if (WARN_ON(!pte_none(*pte)))
93303 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
93304 + if (pgprot_val(prot) & _PAGE_NX)
93305 +#endif
93306 +
93307 + if (!pte_none(*pte)) {
93308 + pax_close_kernel();
93309 + WARN_ON(1);
93310 return -EBUSY;
93311 - if (WARN_ON(!page))
93312 + }
93313 + if (!page) {
93314 + pax_close_kernel();
93315 + WARN_ON(1);
93316 return -ENOMEM;
93317 + }
93318 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
93319 (*nr)++;
93320 } while (pte++, addr += PAGE_SIZE, addr != end);
93321 + pax_close_kernel();
93322 return 0;
93323 }
93324
93325 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
93326 pmd_t *pmd;
93327 unsigned long next;
93328
93329 - pmd = pmd_alloc(&init_mm, pud, addr);
93330 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
93331 if (!pmd)
93332 return -ENOMEM;
93333 do {
93334 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
93335 pud_t *pud;
93336 unsigned long next;
93337
93338 - pud = pud_alloc(&init_mm, pgd, addr);
93339 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
93340 if (!pud)
93341 return -ENOMEM;
93342 do {
93343 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
93344 if (addr >= MODULES_VADDR && addr < MODULES_END)
93345 return 1;
93346 #endif
93347 +
93348 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
93349 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
93350 + return 1;
93351 +#endif
93352 +
93353 return is_vmalloc_addr(x);
93354 }
93355
93356 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
93357
93358 if (!pgd_none(*pgd)) {
93359 pud_t *pud = pud_offset(pgd, addr);
93360 +#ifdef CONFIG_X86
93361 + if (!pud_large(*pud))
93362 +#endif
93363 if (!pud_none(*pud)) {
93364 pmd_t *pmd = pmd_offset(pud, addr);
93365 +#ifdef CONFIG_X86
93366 + if (!pmd_large(*pmd))
93367 +#endif
93368 if (!pmd_none(*pmd)) {
93369 pte_t *ptep, pte;
93370
93371 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
93372 struct vm_struct *area;
93373
93374 BUG_ON(in_interrupt());
93375 +
93376 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
93377 + if (flags & VM_KERNEXEC) {
93378 + if (start != VMALLOC_START || end != VMALLOC_END)
93379 + return NULL;
93380 + start = (unsigned long)MODULES_EXEC_VADDR;
93381 + end = (unsigned long)MODULES_EXEC_END;
93382 + }
93383 +#endif
93384 +
93385 if (flags & VM_IOREMAP)
93386 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
93387
93388 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
93389 if (count > totalram_pages)
93390 return NULL;
93391
93392 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
93393 + if (!(pgprot_val(prot) & _PAGE_NX))
93394 + flags |= VM_KERNEXEC;
93395 +#endif
93396 +
93397 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
93398 __builtin_return_address(0));
93399 if (!area)
93400 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
93401 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
93402 goto fail;
93403
93404 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
93405 + if (!(pgprot_val(prot) & _PAGE_NX))
93406 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
93407 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
93408 + else
93409 +#endif
93410 +
93411 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
93412 start, end, node, gfp_mask, caller);
93413 if (!area)
93414 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
93415 * For tight control over page level allocator and protection flags
93416 * use __vmalloc() instead.
93417 */
93418 -
93419 void *vmalloc_exec(unsigned long size)
93420 {
93421 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
93422 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
93423 NUMA_NO_NODE, __builtin_return_address(0));
93424 }
93425
93426 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
93427 {
93428 struct vm_struct *area;
93429
93430 + BUG_ON(vma->vm_mirror);
93431 +
93432 size = PAGE_ALIGN(size);
93433
93434 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
93435 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
93436 v->addr, v->addr + v->size, v->size);
93437
93438 if (v->caller)
93439 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93440 + seq_printf(m, " %pK", v->caller);
93441 +#else
93442 seq_printf(m, " %pS", v->caller);
93443 +#endif
93444
93445 if (v->nr_pages)
93446 seq_printf(m, " pages=%d", v->nr_pages);
93447 diff --git a/mm/vmstat.c b/mm/vmstat.c
93448 index 5a442a7..dbbda4a 100644
93449 --- a/mm/vmstat.c
93450 +++ b/mm/vmstat.c
93451 @@ -20,6 +20,7 @@
93452 #include <linux/writeback.h>
93453 #include <linux/compaction.h>
93454 #include <linux/mm_inline.h>
93455 +#include <linux/grsecurity.h>
93456
93457 #include "internal.h"
93458
93459 @@ -79,7 +80,7 @@ void vm_events_fold_cpu(int cpu)
93460 *
93461 * vm_stat contains the global counters
93462 */
93463 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
93464 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
93465 EXPORT_SYMBOL(vm_stat);
93466
93467 #ifdef CONFIG_SMP
93468 @@ -423,7 +424,7 @@ static inline void fold_diff(int *diff)
93469
93470 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
93471 if (diff[i])
93472 - atomic_long_add(diff[i], &vm_stat[i]);
93473 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
93474 }
93475
93476 /*
93477 @@ -455,7 +456,7 @@ static void refresh_cpu_vm_stats(void)
93478 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
93479 if (v) {
93480
93481 - atomic_long_add(v, &zone->vm_stat[i]);
93482 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
93483 global_diff[i] += v;
93484 #ifdef CONFIG_NUMA
93485 /* 3 seconds idle till flush */
93486 @@ -517,7 +518,7 @@ void cpu_vm_stats_fold(int cpu)
93487
93488 v = p->vm_stat_diff[i];
93489 p->vm_stat_diff[i] = 0;
93490 - atomic_long_add(v, &zone->vm_stat[i]);
93491 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
93492 global_diff[i] += v;
93493 }
93494 }
93495 @@ -537,8 +538,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
93496 if (pset->vm_stat_diff[i]) {
93497 int v = pset->vm_stat_diff[i];
93498 pset->vm_stat_diff[i] = 0;
93499 - atomic_long_add(v, &zone->vm_stat[i]);
93500 - atomic_long_add(v, &vm_stat[i]);
93501 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
93502 + atomic_long_add_unchecked(v, &vm_stat[i]);
93503 }
93504 }
93505 #endif
93506 @@ -1148,10 +1149,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
93507 stat_items_size += sizeof(struct vm_event_state);
93508 #endif
93509
93510 - v = kmalloc(stat_items_size, GFP_KERNEL);
93511 + v = kzalloc(stat_items_size, GFP_KERNEL);
93512 m->private = v;
93513 if (!v)
93514 return ERR_PTR(-ENOMEM);
93515 +
93516 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
93517 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
93518 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
93519 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
93520 + && !in_group_p(grsec_proc_gid)
93521 +#endif
93522 + )
93523 + return (unsigned long *)m->private + *pos;
93524 +#endif
93525 +#endif
93526 +
93527 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
93528 v[i] = global_page_state(i);
93529 v += NR_VM_ZONE_STAT_ITEMS;
93530 @@ -1281,10 +1294,16 @@ static int __init setup_vmstat(void)
93531 start_cpu_timer(cpu);
93532 #endif
93533 #ifdef CONFIG_PROC_FS
93534 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
93535 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
93536 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
93537 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
93538 + {
93539 + mode_t gr_mode = S_IRUGO;
93540 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
93541 + gr_mode = S_IRUSR;
93542 +#endif
93543 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
93544 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
93545 + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
93546 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
93547 + }
93548 #endif
93549 return 0;
93550 }
93551 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
93552 index 61fc573..b5e47d0 100644
93553 --- a/net/8021q/vlan.c
93554 +++ b/net/8021q/vlan.c
93555 @@ -472,7 +472,7 @@ out:
93556 return NOTIFY_DONE;
93557 }
93558
93559 -static struct notifier_block vlan_notifier_block __read_mostly = {
93560 +static struct notifier_block vlan_notifier_block = {
93561 .notifier_call = vlan_device_event,
93562 };
93563
93564 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
93565 err = -EPERM;
93566 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
93567 break;
93568 - if ((args.u.name_type >= 0) &&
93569 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
93570 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
93571 struct vlan_net *vn;
93572
93573 vn = net_generic(net, vlan_net_id);
93574 diff --git a/net/9p/mod.c b/net/9p/mod.c
93575 index 6ab36ae..6f1841b 100644
93576 --- a/net/9p/mod.c
93577 +++ b/net/9p/mod.c
93578 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
93579 void v9fs_register_trans(struct p9_trans_module *m)
93580 {
93581 spin_lock(&v9fs_trans_lock);
93582 - list_add_tail(&m->list, &v9fs_trans_list);
93583 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
93584 spin_unlock(&v9fs_trans_lock);
93585 }
93586 EXPORT_SYMBOL(v9fs_register_trans);
93587 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
93588 void v9fs_unregister_trans(struct p9_trans_module *m)
93589 {
93590 spin_lock(&v9fs_trans_lock);
93591 - list_del_init(&m->list);
93592 + pax_list_del_init((struct list_head *)&m->list);
93593 spin_unlock(&v9fs_trans_lock);
93594 }
93595 EXPORT_SYMBOL(v9fs_unregister_trans);
93596 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
93597 index 3ffda1b..fceac96 100644
93598 --- a/net/9p/trans_fd.c
93599 +++ b/net/9p/trans_fd.c
93600 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
93601 oldfs = get_fs();
93602 set_fs(get_ds());
93603 /* The cast to a user pointer is valid due to the set_fs() */
93604 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
93605 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
93606 set_fs(oldfs);
93607
93608 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
93609 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
93610 index 876fbe8..8bbea9f 100644
93611 --- a/net/atm/atm_misc.c
93612 +++ b/net/atm/atm_misc.c
93613 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
93614 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
93615 return 1;
93616 atm_return(vcc, truesize);
93617 - atomic_inc(&vcc->stats->rx_drop);
93618 + atomic_inc_unchecked(&vcc->stats->rx_drop);
93619 return 0;
93620 }
93621 EXPORT_SYMBOL(atm_charge);
93622 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
93623 }
93624 }
93625 atm_return(vcc, guess);
93626 - atomic_inc(&vcc->stats->rx_drop);
93627 + atomic_inc_unchecked(&vcc->stats->rx_drop);
93628 return NULL;
93629 }
93630 EXPORT_SYMBOL(atm_alloc_charge);
93631 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
93632
93633 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
93634 {
93635 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
93636 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
93637 __SONET_ITEMS
93638 #undef __HANDLE_ITEM
93639 }
93640 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
93641
93642 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
93643 {
93644 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
93645 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
93646 __SONET_ITEMS
93647 #undef __HANDLE_ITEM
93648 }
93649 diff --git a/net/atm/lec.h b/net/atm/lec.h
93650 index 4149db1..f2ab682 100644
93651 --- a/net/atm/lec.h
93652 +++ b/net/atm/lec.h
93653 @@ -48,7 +48,7 @@ struct lane2_ops {
93654 const u8 *tlvs, u32 sizeoftlvs);
93655 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
93656 const u8 *tlvs, u32 sizeoftlvs);
93657 -};
93658 +} __no_const;
93659
93660 /*
93661 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
93662 diff --git a/net/atm/proc.c b/net/atm/proc.c
93663 index bbb6461..cf04016 100644
93664 --- a/net/atm/proc.c
93665 +++ b/net/atm/proc.c
93666 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
93667 const struct k_atm_aal_stats *stats)
93668 {
93669 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
93670 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
93671 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
93672 - atomic_read(&stats->rx_drop));
93673 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
93674 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
93675 + atomic_read_unchecked(&stats->rx_drop));
93676 }
93677
93678 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
93679 diff --git a/net/atm/resources.c b/net/atm/resources.c
93680 index 0447d5d..3cf4728 100644
93681 --- a/net/atm/resources.c
93682 +++ b/net/atm/resources.c
93683 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
93684 static void copy_aal_stats(struct k_atm_aal_stats *from,
93685 struct atm_aal_stats *to)
93686 {
93687 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
93688 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
93689 __AAL_STAT_ITEMS
93690 #undef __HANDLE_ITEM
93691 }
93692 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
93693 static void subtract_aal_stats(struct k_atm_aal_stats *from,
93694 struct atm_aal_stats *to)
93695 {
93696 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
93697 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
93698 __AAL_STAT_ITEMS
93699 #undef __HANDLE_ITEM
93700 }
93701 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
93702 index 919a5ce..cc6b444 100644
93703 --- a/net/ax25/sysctl_net_ax25.c
93704 +++ b/net/ax25/sysctl_net_ax25.c
93705 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
93706 {
93707 char path[sizeof("net/ax25/") + IFNAMSIZ];
93708 int k;
93709 - struct ctl_table *table;
93710 + ctl_table_no_const *table;
93711
93712 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
93713 if (!table)
93714 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
93715 index 0a8a80c..f7e89aa 100644
93716 --- a/net/batman-adv/bat_iv_ogm.c
93717 +++ b/net/batman-adv/bat_iv_ogm.c
93718 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
93719
93720 /* randomize initial seqno to avoid collision */
93721 get_random_bytes(&random_seqno, sizeof(random_seqno));
93722 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
93723 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
93724
93725 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
93726 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
93727 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
93728 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
93729
93730 /* change sequence number to network order */
93731 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
93732 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
93733 batadv_ogm_packet->seqno = htonl(seqno);
93734 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
93735 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
93736
93737 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
93738 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
93739 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
93740 return;
93741
93742 /* could be changed by schedule_own_packet() */
93743 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
93744 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
93745
93746 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
93747 has_directlink_flag = 1;
93748 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
93749 index c478e6b..469fd2f 100644
93750 --- a/net/batman-adv/hard-interface.c
93751 +++ b/net/batman-adv/hard-interface.c
93752 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
93753 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
93754 dev_add_pack(&hard_iface->batman_adv_ptype);
93755
93756 - atomic_set(&hard_iface->frag_seqno, 1);
93757 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
93758 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
93759 hard_iface->net_dev->name);
93760
93761 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
93762 index 813db4e..847edac 100644
93763 --- a/net/batman-adv/soft-interface.c
93764 +++ b/net/batman-adv/soft-interface.c
93765 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
93766 primary_if->net_dev->dev_addr, ETH_ALEN);
93767
93768 /* set broadcast sequence number */
93769 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
93770 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
93771 bcast_packet->seqno = htonl(seqno);
93772
93773 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
93774 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
93775 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
93776
93777 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
93778 - atomic_set(&bat_priv->bcast_seqno, 1);
93779 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
93780 atomic_set(&bat_priv->tt.vn, 0);
93781 atomic_set(&bat_priv->tt.local_changes, 0);
93782 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
93783 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
93784 index b2c94e1..3d47e07 100644
93785 --- a/net/batman-adv/types.h
93786 +++ b/net/batman-adv/types.h
93787 @@ -51,7 +51,7 @@
93788 struct batadv_hard_iface_bat_iv {
93789 unsigned char *ogm_buff;
93790 int ogm_buff_len;
93791 - atomic_t ogm_seqno;
93792 + atomic_unchecked_t ogm_seqno;
93793 };
93794
93795 /**
93796 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
93797 int16_t if_num;
93798 char if_status;
93799 struct net_device *net_dev;
93800 - atomic_t frag_seqno;
93801 + atomic_unchecked_t frag_seqno;
93802 uint8_t num_bcasts;
93803 struct kobject *hardif_obj;
93804 atomic_t refcount;
93805 @@ -560,7 +560,7 @@ struct batadv_priv {
93806 #ifdef CONFIG_BATMAN_ADV_DEBUG
93807 atomic_t log_level;
93808 #endif
93809 - atomic_t bcast_seqno;
93810 + atomic_unchecked_t bcast_seqno;
93811 atomic_t bcast_queue_left;
93812 atomic_t batman_queue_left;
93813 char num_ifaces;
93814 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
93815 index 48b31d3..62a0bcb 100644
93816 --- a/net/batman-adv/unicast.c
93817 +++ b/net/batman-adv/unicast.c
93818 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
93819 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
93820 frag2->flags = large_tail;
93821
93822 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
93823 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
93824 frag1->seqno = htons(seqno - 1);
93825 frag2->seqno = htons(seqno);
93826
93827 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
93828 index fa4bf66..e92948f 100644
93829 --- a/net/bluetooth/hci_sock.c
93830 +++ b/net/bluetooth/hci_sock.c
93831 @@ -932,7 +932,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
93832 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
93833 }
93834
93835 - len = min_t(unsigned int, len, sizeof(uf));
93836 + len = min((size_t)len, sizeof(uf));
93837 if (copy_from_user(&uf, optval, len)) {
93838 err = -EFAULT;
93839 break;
93840 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
93841 index 63fa111..b166ec6 100644
93842 --- a/net/bluetooth/l2cap_core.c
93843 +++ b/net/bluetooth/l2cap_core.c
93844 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
93845 break;
93846
93847 case L2CAP_CONF_RFC:
93848 - if (olen == sizeof(rfc))
93849 - memcpy(&rfc, (void *)val, olen);
93850 + if (olen != sizeof(rfc))
93851 + break;
93852 +
93853 + memcpy(&rfc, (void *)val, olen);
93854
93855 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
93856 rfc.mode != chan->mode)
93857 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
93858 index 0098af8..fb5a31f 100644
93859 --- a/net/bluetooth/l2cap_sock.c
93860 +++ b/net/bluetooth/l2cap_sock.c
93861 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
93862 struct sock *sk = sock->sk;
93863 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
93864 struct l2cap_options opts;
93865 - int len, err = 0;
93866 + int err = 0;
93867 + size_t len = optlen;
93868 u32 opt;
93869
93870 BT_DBG("sk %p", sk);
93871 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
93872 opts.max_tx = chan->max_tx;
93873 opts.txwin_size = chan->tx_win;
93874
93875 - len = min_t(unsigned int, sizeof(opts), optlen);
93876 + len = min(sizeof(opts), len);
93877 if (copy_from_user((char *) &opts, optval, len)) {
93878 err = -EFAULT;
93879 break;
93880 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93881 struct bt_security sec;
93882 struct bt_power pwr;
93883 struct l2cap_conn *conn;
93884 - int len, err = 0;
93885 + int err = 0;
93886 + size_t len = optlen;
93887 u32 opt;
93888
93889 BT_DBG("sk %p", sk);
93890 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93891
93892 sec.level = BT_SECURITY_LOW;
93893
93894 - len = min_t(unsigned int, sizeof(sec), optlen);
93895 + len = min(sizeof(sec), len);
93896 if (copy_from_user((char *) &sec, optval, len)) {
93897 err = -EFAULT;
93898 break;
93899 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93900
93901 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
93902
93903 - len = min_t(unsigned int, sizeof(pwr), optlen);
93904 + len = min(sizeof(pwr), len);
93905 if (copy_from_user((char *) &pwr, optval, len)) {
93906 err = -EFAULT;
93907 break;
93908 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
93909 index c1c6028..17e8dcc 100644
93910 --- a/net/bluetooth/rfcomm/sock.c
93911 +++ b/net/bluetooth/rfcomm/sock.c
93912 @@ -665,7 +665,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
93913 struct sock *sk = sock->sk;
93914 struct bt_security sec;
93915 int err = 0;
93916 - size_t len;
93917 + size_t len = optlen;
93918 u32 opt;
93919
93920 BT_DBG("sk %p", sk);
93921 @@ -687,7 +687,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
93922
93923 sec.level = BT_SECURITY_LOW;
93924
93925 - len = min_t(unsigned int, sizeof(sec), optlen);
93926 + len = min(sizeof(sec), len);
93927 if (copy_from_user((char *) &sec, optval, len)) {
93928 err = -EFAULT;
93929 break;
93930 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
93931 index 84fcf9f..e389b27 100644
93932 --- a/net/bluetooth/rfcomm/tty.c
93933 +++ b/net/bluetooth/rfcomm/tty.c
93934 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
93935 BT_DBG("tty %p id %d", tty, tty->index);
93936
93937 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
93938 - dev->channel, dev->port.count);
93939 + dev->channel, atomic_read(&dev->port.count));
93940
93941 err = tty_port_open(&dev->port, tty, filp);
93942 if (err)
93943 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
93944 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
93945
93946 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
93947 - dev->port.count);
93948 + atomic_read(&dev->port.count));
93949
93950 tty_port_close(&dev->port, tty, filp);
93951 }
93952 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
93953 index 5180938..7c470c3 100644
93954 --- a/net/bridge/netfilter/ebt_ulog.c
93955 +++ b/net/bridge/netfilter/ebt_ulog.c
93956 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93957 ub->qlen++;
93958
93959 pm = nlmsg_data(nlh);
93960 + memset(pm, 0, sizeof(*pm));
93961
93962 /* Fill in the ulog data */
93963 pm->version = EBT_ULOG_VERSION;
93964 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93965 pm->hook = hooknr;
93966 if (uloginfo->prefix != NULL)
93967 strcpy(pm->prefix, uloginfo->prefix);
93968 - else
93969 - *(pm->prefix) = '\0';
93970
93971 if (in) {
93972 strcpy(pm->physindev, in->name);
93973 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93974 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
93975 else
93976 strcpy(pm->indev, in->name);
93977 - } else
93978 - pm->indev[0] = pm->physindev[0] = '\0';
93979 + }
93980
93981 if (out) {
93982 /* If out exists, then out is a bridge port */
93983 strcpy(pm->physoutdev, out->name);
93984 /* rcu_read_lock()ed by nf_hook_slow */
93985 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
93986 - } else
93987 - pm->outdev[0] = pm->physoutdev[0] = '\0';
93988 + }
93989
93990 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
93991 BUG();
93992 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
93993 index ac78024..161a80c 100644
93994 --- a/net/bridge/netfilter/ebtables.c
93995 +++ b/net/bridge/netfilter/ebtables.c
93996 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93997 tmp.valid_hooks = t->table->valid_hooks;
93998 }
93999 mutex_unlock(&ebt_mutex);
94000 - if (copy_to_user(user, &tmp, *len) != 0){
94001 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
94002 BUGPRINT("c2u Didn't work\n");
94003 ret = -EFAULT;
94004 break;
94005 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
94006 goto out;
94007 tmp.valid_hooks = t->valid_hooks;
94008
94009 - if (copy_to_user(user, &tmp, *len) != 0) {
94010 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
94011 ret = -EFAULT;
94012 break;
94013 }
94014 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
94015 tmp.entries_size = t->table->entries_size;
94016 tmp.valid_hooks = t->table->valid_hooks;
94017
94018 - if (copy_to_user(user, &tmp, *len) != 0) {
94019 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
94020 ret = -EFAULT;
94021 break;
94022 }
94023 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
94024 index 0f45522..dab651f 100644
94025 --- a/net/caif/cfctrl.c
94026 +++ b/net/caif/cfctrl.c
94027 @@ -10,6 +10,7 @@
94028 #include <linux/spinlock.h>
94029 #include <linux/slab.h>
94030 #include <linux/pkt_sched.h>
94031 +#include <linux/sched.h>
94032 #include <net/caif/caif_layer.h>
94033 #include <net/caif/cfpkt.h>
94034 #include <net/caif/cfctrl.h>
94035 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
94036 memset(&dev_info, 0, sizeof(dev_info));
94037 dev_info.id = 0xff;
94038 cfsrvl_init(&this->serv, 0, &dev_info, false);
94039 - atomic_set(&this->req_seq_no, 1);
94040 - atomic_set(&this->rsp_seq_no, 1);
94041 + atomic_set_unchecked(&this->req_seq_no, 1);
94042 + atomic_set_unchecked(&this->rsp_seq_no, 1);
94043 this->serv.layer.receive = cfctrl_recv;
94044 sprintf(this->serv.layer.name, "ctrl");
94045 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
94046 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
94047 struct cfctrl_request_info *req)
94048 {
94049 spin_lock_bh(&ctrl->info_list_lock);
94050 - atomic_inc(&ctrl->req_seq_no);
94051 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
94052 + atomic_inc_unchecked(&ctrl->req_seq_no);
94053 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
94054 list_add_tail(&req->list, &ctrl->list);
94055 spin_unlock_bh(&ctrl->info_list_lock);
94056 }
94057 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
94058 if (p != first)
94059 pr_warn("Requests are not received in order\n");
94060
94061 - atomic_set(&ctrl->rsp_seq_no,
94062 + atomic_set_unchecked(&ctrl->rsp_seq_no,
94063 p->sequence_no);
94064 list_del(&p->list);
94065 goto out;
94066 diff --git a/net/can/af_can.c b/net/can/af_can.c
94067 index 3ab8dd2..b9aef13 100644
94068 --- a/net/can/af_can.c
94069 +++ b/net/can/af_can.c
94070 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
94071 };
94072
94073 /* notifier block for netdevice event */
94074 -static struct notifier_block can_netdev_notifier __read_mostly = {
94075 +static struct notifier_block can_netdev_notifier = {
94076 .notifier_call = can_notifier,
94077 };
94078
94079 diff --git a/net/can/gw.c b/net/can/gw.c
94080 index 3f9b0f3..fc6d4fa 100644
94081 --- a/net/can/gw.c
94082 +++ b/net/can/gw.c
94083 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
94084 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
94085
94086 static HLIST_HEAD(cgw_list);
94087 -static struct notifier_block notifier;
94088
94089 static struct kmem_cache *cgw_cache __read_mostly;
94090
94091 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
94092 return err;
94093 }
94094
94095 +static struct notifier_block notifier = {
94096 + .notifier_call = cgw_notifier
94097 +};
94098 +
94099 static __init int cgw_module_init(void)
94100 {
94101 /* sanitize given module parameter */
94102 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
94103 return -ENOMEM;
94104
94105 /* set notifier */
94106 - notifier.notifier_call = cgw_notifier;
94107 register_netdevice_notifier(&notifier);
94108
94109 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
94110 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
94111 index 4a5df7b..9ad1f1d 100644
94112 --- a/net/ceph/messenger.c
94113 +++ b/net/ceph/messenger.c
94114 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
94115 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
94116
94117 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
94118 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
94119 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
94120
94121 static struct page *zero_page; /* used in certain error cases */
94122
94123 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
94124 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
94125 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
94126
94127 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
94128 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
94129 s = addr_str[i];
94130
94131 switch (ss->ss_family) {
94132 diff --git a/net/compat.c b/net/compat.c
94133 index dd32e34..6066f87 100644
94134 --- a/net/compat.c
94135 +++ b/net/compat.c
94136 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
94137 return -EFAULT;
94138 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
94139 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
94140 - kmsg->msg_name = compat_ptr(tmp1);
94141 - kmsg->msg_iov = compat_ptr(tmp2);
94142 - kmsg->msg_control = compat_ptr(tmp3);
94143 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
94144 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
94145 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
94146 return 0;
94147 }
94148
94149 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
94150
94151 if (kern_msg->msg_namelen) {
94152 if (mode == VERIFY_READ) {
94153 - int err = move_addr_to_kernel(kern_msg->msg_name,
94154 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
94155 kern_msg->msg_namelen,
94156 kern_address);
94157 if (err < 0)
94158 @@ -99,7 +99,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
94159 kern_msg->msg_name = NULL;
94160
94161 tot_len = iov_from_user_compat_to_kern(kern_iov,
94162 - (struct compat_iovec __user *)kern_msg->msg_iov,
94163 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
94164 kern_msg->msg_iovlen);
94165 if (tot_len >= 0)
94166 kern_msg->msg_iov = kern_iov;
94167 @@ -119,20 +119,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
94168
94169 #define CMSG_COMPAT_FIRSTHDR(msg) \
94170 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
94171 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
94172 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
94173 (struct compat_cmsghdr __user *)NULL)
94174
94175 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
94176 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
94177 (ucmlen) <= (unsigned long) \
94178 ((mhdr)->msg_controllen - \
94179 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
94180 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
94181
94182 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
94183 struct compat_cmsghdr __user *cmsg, int cmsg_len)
94184 {
94185 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
94186 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
94187 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
94188 msg->msg_controllen)
94189 return NULL;
94190 return (struct compat_cmsghdr __user *)ptr;
94191 @@ -222,7 +222,7 @@ Efault:
94192
94193 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
94194 {
94195 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
94196 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
94197 struct compat_cmsghdr cmhdr;
94198 struct compat_timeval ctv;
94199 struct compat_timespec cts[3];
94200 @@ -278,7 +278,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
94201
94202 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
94203 {
94204 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
94205 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
94206 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
94207 int fdnum = scm->fp->count;
94208 struct file **fp = scm->fp->fp;
94209 @@ -366,7 +366,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
94210 return -EFAULT;
94211 old_fs = get_fs();
94212 set_fs(KERNEL_DS);
94213 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
94214 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
94215 set_fs(old_fs);
94216
94217 return err;
94218 @@ -427,7 +427,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
94219 len = sizeof(ktime);
94220 old_fs = get_fs();
94221 set_fs(KERNEL_DS);
94222 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
94223 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
94224 set_fs(old_fs);
94225
94226 if (!err) {
94227 @@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
94228 case MCAST_JOIN_GROUP:
94229 case MCAST_LEAVE_GROUP:
94230 {
94231 - struct compat_group_req __user *gr32 = (void *)optval;
94232 + struct compat_group_req __user *gr32 = (void __user *)optval;
94233 struct group_req __user *kgr =
94234 compat_alloc_user_space(sizeof(struct group_req));
94235 u32 interface;
94236 @@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
94237 case MCAST_BLOCK_SOURCE:
94238 case MCAST_UNBLOCK_SOURCE:
94239 {
94240 - struct compat_group_source_req __user *gsr32 = (void *)optval;
94241 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
94242 struct group_source_req __user *kgsr = compat_alloc_user_space(
94243 sizeof(struct group_source_req));
94244 u32 interface;
94245 @@ -612,7 +612,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
94246 }
94247 case MCAST_MSFILTER:
94248 {
94249 - struct compat_group_filter __user *gf32 = (void *)optval;
94250 + struct compat_group_filter __user *gf32 = (void __user *)optval;
94251 struct group_filter __user *kgf;
94252 u32 interface, fmode, numsrc;
94253
94254 @@ -650,7 +650,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
94255 char __user *optval, int __user *optlen,
94256 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
94257 {
94258 - struct compat_group_filter __user *gf32 = (void *)optval;
94259 + struct compat_group_filter __user *gf32 = (void __user *)optval;
94260 struct group_filter __user *kgf;
94261 int __user *koptlen;
94262 u32 interface, fmode, numsrc;
94263 @@ -808,7 +808,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
94264
94265 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
94266 return -EINVAL;
94267 - if (copy_from_user(a, args, nas[call]))
94268 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
94269 return -EFAULT;
94270 a0 = a[0];
94271 a1 = a[1];
94272 diff --git a/net/core/datagram.c b/net/core/datagram.c
94273 index af814e7..3d761de 100644
94274 --- a/net/core/datagram.c
94275 +++ b/net/core/datagram.c
94276 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
94277 }
94278
94279 kfree_skb(skb);
94280 - atomic_inc(&sk->sk_drops);
94281 + atomic_inc_unchecked(&sk->sk_drops);
94282 sk_mem_reclaim_partial(sk);
94283
94284 return err;
94285 diff --git a/net/core/dev.c b/net/core/dev.c
94286 index 3d13874..6e78dc7 100644
94287 --- a/net/core/dev.c
94288 +++ b/net/core/dev.c
94289 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
94290 {
94291 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
94292 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
94293 - atomic_long_inc(&dev->rx_dropped);
94294 + atomic_long_inc_unchecked(&dev->rx_dropped);
94295 kfree_skb(skb);
94296 return NET_RX_DROP;
94297 }
94298 }
94299
94300 if (unlikely(!is_skb_forwardable(dev, skb))) {
94301 - atomic_long_inc(&dev->rx_dropped);
94302 + atomic_long_inc_unchecked(&dev->rx_dropped);
94303 kfree_skb(skb);
94304 return NET_RX_DROP;
94305 }
94306 @@ -2428,7 +2428,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
94307
94308 struct dev_gso_cb {
94309 void (*destructor)(struct sk_buff *skb);
94310 -};
94311 +} __no_const;
94312
94313 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
94314
94315 @@ -3203,7 +3203,7 @@ enqueue:
94316
94317 local_irq_restore(flags);
94318
94319 - atomic_long_inc(&skb->dev->rx_dropped);
94320 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
94321 kfree_skb(skb);
94322 return NET_RX_DROP;
94323 }
94324 @@ -3275,7 +3275,7 @@ int netif_rx_ni(struct sk_buff *skb)
94325 }
94326 EXPORT_SYMBOL(netif_rx_ni);
94327
94328 -static void net_tx_action(struct softirq_action *h)
94329 +static __latent_entropy void net_tx_action(void)
94330 {
94331 struct softnet_data *sd = &__get_cpu_var(softnet_data);
94332
94333 @@ -3609,7 +3609,7 @@ ncls:
94334 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
94335 } else {
94336 drop:
94337 - atomic_long_inc(&skb->dev->rx_dropped);
94338 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
94339 kfree_skb(skb);
94340 /* Jamal, now you will not able to escape explaining
94341 * me how you were going to use this. :-)
94342 @@ -4269,7 +4269,7 @@ void netif_napi_del(struct napi_struct *napi)
94343 }
94344 EXPORT_SYMBOL(netif_napi_del);
94345
94346 -static void net_rx_action(struct softirq_action *h)
94347 +static __latent_entropy void net_rx_action(void)
94348 {
94349 struct softnet_data *sd = &__get_cpu_var(softnet_data);
94350 unsigned long time_limit = jiffies + 2;
94351 @@ -5973,7 +5973,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
94352 } else {
94353 netdev_stats_to_stats64(storage, &dev->stats);
94354 }
94355 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
94356 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
94357 return storage;
94358 }
94359 EXPORT_SYMBOL(dev_get_stats);
94360 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
94361 index 5b7d0e1..cb960fc 100644
94362 --- a/net/core/dev_ioctl.c
94363 +++ b/net/core/dev_ioctl.c
94364 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
94365 if (no_module && capable(CAP_NET_ADMIN))
94366 no_module = request_module("netdev-%s", name);
94367 if (no_module && capable(CAP_SYS_MODULE)) {
94368 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
94369 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
94370 +#else
94371 if (!request_module("%s", name))
94372 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
94373 name);
94374 +#endif
94375 }
94376 }
94377 EXPORT_SYMBOL(dev_load);
94378 diff --git a/net/core/filter.c b/net/core/filter.c
94379 index 01b7808..ad30d62 100644
94380 --- a/net/core/filter.c
94381 +++ b/net/core/filter.c
94382 @@ -36,7 +36,6 @@
94383 #include <asm/uaccess.h>
94384 #include <asm/unaligned.h>
94385 #include <linux/filter.h>
94386 -#include <linux/reciprocal_div.h>
94387 #include <linux/ratelimit.h>
94388 #include <linux/seccomp.h>
94389 #include <linux/if_vlan.h>
94390 @@ -166,7 +165,7 @@ unsigned int sk_run_filter(const struct sk_buff *skb,
94391 A /= X;
94392 continue;
94393 case BPF_S_ALU_DIV_K:
94394 - A = reciprocal_divide(A, K);
94395 + A /= K;
94396 continue;
94397 case BPF_S_ALU_MOD_X:
94398 if (X == 0)
94399 @@ -553,11 +552,6 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
94400 /* Some instructions need special checks */
94401 switch (code) {
94402 case BPF_S_ALU_DIV_K:
94403 - /* check for division by zero */
94404 - if (ftest->k == 0)
94405 - return -EINVAL;
94406 - ftest->k = reciprocal_value(ftest->k);
94407 - break;
94408 case BPF_S_ALU_MOD_K:
94409 /* check for division by zero */
94410 if (ftest->k == 0)
94411 @@ -853,27 +847,7 @@ void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to)
94412 to->code = decodes[code];
94413 to->jt = filt->jt;
94414 to->jf = filt->jf;
94415 -
94416 - if (code == BPF_S_ALU_DIV_K) {
94417 - /*
94418 - * When loaded this rule user gave us X, which was
94419 - * translated into R = r(X). Now we calculate the
94420 - * RR = r(R) and report it back. If next time this
94421 - * value is loaded and RRR = r(RR) is calculated
94422 - * then the R == RRR will be true.
94423 - *
94424 - * One exception. X == 1 translates into R == 0 and
94425 - * we can't calculate RR out of it with r().
94426 - */
94427 -
94428 - if (filt->k == 0)
94429 - to->k = 1;
94430 - else
94431 - to->k = reciprocal_value(filt->k);
94432 -
94433 - BUG_ON(reciprocal_value(to->k) != filt->k);
94434 - } else
94435 - to->k = filt->k;
94436 + to->k = filt->k;
94437 }
94438
94439 int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, unsigned int len)
94440 diff --git a/net/core/flow.c b/net/core/flow.c
94441 index dfa602c..3103d88 100644
94442 --- a/net/core/flow.c
94443 +++ b/net/core/flow.c
94444 @@ -61,7 +61,7 @@ struct flow_cache {
94445 struct timer_list rnd_timer;
94446 };
94447
94448 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
94449 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
94450 EXPORT_SYMBOL(flow_cache_genid);
94451 static struct flow_cache flow_cache_global;
94452 static struct kmem_cache *flow_cachep __read_mostly;
94453 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
94454
94455 static int flow_entry_valid(struct flow_cache_entry *fle)
94456 {
94457 - if (atomic_read(&flow_cache_genid) != fle->genid)
94458 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
94459 return 0;
94460 if (fle->object && !fle->object->ops->check(fle->object))
94461 return 0;
94462 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
94463 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
94464 fcp->hash_count++;
94465 }
94466 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
94467 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
94468 flo = fle->object;
94469 if (!flo)
94470 goto ret_object;
94471 @@ -279,7 +279,7 @@ nocache:
94472 }
94473 flo = resolver(net, key, family, dir, flo, ctx);
94474 if (fle) {
94475 - fle->genid = atomic_read(&flow_cache_genid);
94476 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
94477 if (!IS_ERR(flo))
94478 fle->object = flo;
94479 else
94480 diff --git a/net/core/iovec.c b/net/core/iovec.c
94481 index 7d84ea1..55385ae 100644
94482 --- a/net/core/iovec.c
94483 +++ b/net/core/iovec.c
94484 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
94485 if (m->msg_namelen) {
94486 if (mode == VERIFY_READ) {
94487 void __user *namep;
94488 - namep = (void __user __force *) m->msg_name;
94489 + namep = (void __force_user *) m->msg_name;
94490 err = move_addr_to_kernel(namep, m->msg_namelen,
94491 address);
94492 if (err < 0)
94493 @@ -55,7 +55,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
94494 }
94495
94496 size = m->msg_iovlen * sizeof(struct iovec);
94497 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
94498 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
94499 return -EFAULT;
94500
94501 m->msg_iov = iov;
94502 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
94503 index 11af243..7357d84 100644
94504 --- a/net/core/neighbour.c
94505 +++ b/net/core/neighbour.c
94506 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
94507 void __user *buffer, size_t *lenp, loff_t *ppos)
94508 {
94509 int size, ret;
94510 - struct ctl_table tmp = *ctl;
94511 + ctl_table_no_const tmp = *ctl;
94512
94513 tmp.extra1 = &zero;
94514 tmp.extra2 = &unres_qlen_max;
94515 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
94516 index 2bf8329..7960607 100644
94517 --- a/net/core/net-procfs.c
94518 +++ b/net/core/net-procfs.c
94519 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
94520 else
94521 seq_printf(seq, "%04x", ntohs(pt->type));
94522
94523 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94524 + seq_printf(seq, " %-8s %pf\n",
94525 + pt->dev ? pt->dev->name : "", NULL);
94526 +#else
94527 seq_printf(seq, " %-8s %pf\n",
94528 pt->dev ? pt->dev->name : "", pt->func);
94529 +#endif
94530 }
94531
94532 return 0;
94533 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
94534 index d954b56..b0a0f7a 100644
94535 --- a/net/core/net-sysfs.c
94536 +++ b/net/core/net-sysfs.c
94537 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
94538 }
94539 EXPORT_SYMBOL(netdev_class_remove_file);
94540
94541 -int netdev_kobject_init(void)
94542 +int __init netdev_kobject_init(void)
94543 {
94544 kobj_ns_type_register(&net_ns_type_operations);
94545 return class_register(&net_class);
94546 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
94547 index 81d3a9a..a0bd7a8 100644
94548 --- a/net/core/net_namespace.c
94549 +++ b/net/core/net_namespace.c
94550 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
94551 int error;
94552 LIST_HEAD(net_exit_list);
94553
94554 - list_add_tail(&ops->list, list);
94555 + pax_list_add_tail((struct list_head *)&ops->list, list);
94556 if (ops->init || (ops->id && ops->size)) {
94557 for_each_net(net) {
94558 error = ops_init(ops, net);
94559 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
94560
94561 out_undo:
94562 /* If I have an error cleanup all namespaces I initialized */
94563 - list_del(&ops->list);
94564 + pax_list_del((struct list_head *)&ops->list);
94565 ops_exit_list(ops, &net_exit_list);
94566 ops_free_list(ops, &net_exit_list);
94567 return error;
94568 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
94569 struct net *net;
94570 LIST_HEAD(net_exit_list);
94571
94572 - list_del(&ops->list);
94573 + pax_list_del((struct list_head *)&ops->list);
94574 for_each_net(net)
94575 list_add_tail(&net->exit_list, &net_exit_list);
94576 ops_exit_list(ops, &net_exit_list);
94577 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
94578 mutex_lock(&net_mutex);
94579 error = register_pernet_operations(&pernet_list, ops);
94580 if (!error && (first_device == &pernet_list))
94581 - first_device = &ops->list;
94582 + first_device = (struct list_head *)&ops->list;
94583 mutex_unlock(&net_mutex);
94584 return error;
94585 }
94586 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
94587 index 0c1482c..f7ae314 100644
94588 --- a/net/core/netpoll.c
94589 +++ b/net/core/netpoll.c
94590 @@ -435,7 +435,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
94591 struct udphdr *udph;
94592 struct iphdr *iph;
94593 struct ethhdr *eth;
94594 - static atomic_t ip_ident;
94595 + static atomic_unchecked_t ip_ident;
94596 struct ipv6hdr *ip6h;
94597
94598 udp_len = len + sizeof(*udph);
94599 @@ -506,7 +506,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
94600 put_unaligned(0x45, (unsigned char *)iph);
94601 iph->tos = 0;
94602 put_unaligned(htons(ip_len), &(iph->tot_len));
94603 - iph->id = htons(atomic_inc_return(&ip_ident));
94604 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
94605 iph->frag_off = 0;
94606 iph->ttl = 64;
94607 iph->protocol = IPPROTO_UDP;
94608 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
94609 index 2a0e21d..6ad7642 100644
94610 --- a/net/core/rtnetlink.c
94611 +++ b/net/core/rtnetlink.c
94612 @@ -58,7 +58,7 @@ struct rtnl_link {
94613 rtnl_doit_func doit;
94614 rtnl_dumpit_func dumpit;
94615 rtnl_calcit_func calcit;
94616 -};
94617 +} __no_const;
94618
94619 static DEFINE_MUTEX(rtnl_mutex);
94620
94621 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
94622 if (rtnl_link_ops_get(ops->kind))
94623 return -EEXIST;
94624
94625 - if (!ops->dellink)
94626 - ops->dellink = unregister_netdevice_queue;
94627 + if (!ops->dellink) {
94628 + pax_open_kernel();
94629 + *(void **)&ops->dellink = unregister_netdevice_queue;
94630 + pax_close_kernel();
94631 + }
94632
94633 - list_add_tail(&ops->list, &link_ops);
94634 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
94635 return 0;
94636 }
94637 EXPORT_SYMBOL_GPL(__rtnl_link_register);
94638 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
94639 for_each_net(net) {
94640 __rtnl_kill_links(net, ops);
94641 }
94642 - list_del(&ops->list);
94643 + pax_list_del((struct list_head *)&ops->list);
94644 }
94645 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
94646
94647 diff --git a/net/core/scm.c b/net/core/scm.c
94648 index b442e7e..6f5b5a2 100644
94649 --- a/net/core/scm.c
94650 +++ b/net/core/scm.c
94651 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
94652 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
94653 {
94654 struct cmsghdr __user *cm
94655 - = (__force struct cmsghdr __user *)msg->msg_control;
94656 + = (struct cmsghdr __force_user *)msg->msg_control;
94657 struct cmsghdr cmhdr;
94658 int cmlen = CMSG_LEN(len);
94659 int err;
94660 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
94661 err = -EFAULT;
94662 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
94663 goto out;
94664 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
94665 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
94666 goto out;
94667 cmlen = CMSG_SPACE(len);
94668 if (msg->msg_controllen < cmlen)
94669 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
94670 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
94671 {
94672 struct cmsghdr __user *cm
94673 - = (__force struct cmsghdr __user*)msg->msg_control;
94674 + = (struct cmsghdr __force_user *)msg->msg_control;
94675
94676 int fdmax = 0;
94677 int fdnum = scm->fp->count;
94678 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
94679 if (fdnum < fdmax)
94680 fdmax = fdnum;
94681
94682 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
94683 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
94684 i++, cmfptr++)
94685 {
94686 struct socket *sock;
94687 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
94688 index 743e6eb..a399a6d 100644
94689 --- a/net/core/skbuff.c
94690 +++ b/net/core/skbuff.c
94691 @@ -3104,13 +3104,15 @@ void __init skb_init(void)
94692 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
94693 sizeof(struct sk_buff),
94694 0,
94695 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
94696 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
94697 + SLAB_NO_SANITIZE,
94698 NULL);
94699 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
94700 (2*sizeof(struct sk_buff)) +
94701 sizeof(atomic_t),
94702 0,
94703 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
94704 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
94705 + SLAB_NO_SANITIZE,
94706 NULL);
94707 }
94708
94709 diff --git a/net/core/sock.c b/net/core/sock.c
94710 index 5cec994..81aa1dd 100644
94711 --- a/net/core/sock.c
94712 +++ b/net/core/sock.c
94713 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
94714 struct sk_buff_head *list = &sk->sk_receive_queue;
94715
94716 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
94717 - atomic_inc(&sk->sk_drops);
94718 + atomic_inc_unchecked(&sk->sk_drops);
94719 trace_sock_rcvqueue_full(sk, skb);
94720 return -ENOMEM;
94721 }
94722 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
94723 return err;
94724
94725 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
94726 - atomic_inc(&sk->sk_drops);
94727 + atomic_inc_unchecked(&sk->sk_drops);
94728 return -ENOBUFS;
94729 }
94730
94731 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
94732 skb_dst_force(skb);
94733
94734 spin_lock_irqsave(&list->lock, flags);
94735 - skb->dropcount = atomic_read(&sk->sk_drops);
94736 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
94737 __skb_queue_tail(list, skb);
94738 spin_unlock_irqrestore(&list->lock, flags);
94739
94740 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
94741 skb->dev = NULL;
94742
94743 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
94744 - atomic_inc(&sk->sk_drops);
94745 + atomic_inc_unchecked(&sk->sk_drops);
94746 goto discard_and_relse;
94747 }
94748 if (nested)
94749 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
94750 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
94751 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
94752 bh_unlock_sock(sk);
94753 - atomic_inc(&sk->sk_drops);
94754 + atomic_inc_unchecked(&sk->sk_drops);
94755 goto discard_and_relse;
94756 }
94757
94758 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94759 struct timeval tm;
94760 } v;
94761
94762 - int lv = sizeof(int);
94763 - int len;
94764 + unsigned int lv = sizeof(int);
94765 + unsigned int len;
94766
94767 if (get_user(len, optlen))
94768 return -EFAULT;
94769 - if (len < 0)
94770 + if (len > INT_MAX)
94771 return -EINVAL;
94772
94773 memset(&v, 0, sizeof(v));
94774 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94775
94776 case SO_PEERNAME:
94777 {
94778 - char address[128];
94779 + char address[_K_SS_MAXSIZE];
94780
94781 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
94782 return -ENOTCONN;
94783 - if (lv < len)
94784 + if (lv < len || sizeof address < len)
94785 return -EINVAL;
94786 if (copy_to_user(optval, address, len))
94787 return -EFAULT;
94788 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94789
94790 if (len > lv)
94791 len = lv;
94792 - if (copy_to_user(optval, &v, len))
94793 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
94794 return -EFAULT;
94795 lenout:
94796 if (put_user(len, optlen))
94797 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
94798 */
94799 smp_wmb();
94800 atomic_set(&sk->sk_refcnt, 1);
94801 - atomic_set(&sk->sk_drops, 0);
94802 + atomic_set_unchecked(&sk->sk_drops, 0);
94803 }
94804 EXPORT_SYMBOL(sock_init_data);
94805
94806 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
94807 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
94808 int level, int type)
94809 {
94810 + struct sock_extended_err ee;
94811 struct sock_exterr_skb *serr;
94812 struct sk_buff *skb, *skb2;
94813 int copied, err;
94814 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
94815 sock_recv_timestamp(msg, sk, skb);
94816
94817 serr = SKB_EXT_ERR(skb);
94818 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
94819 + ee = serr->ee;
94820 + put_cmsg(msg, level, type, sizeof ee, &ee);
94821
94822 msg->msg_flags |= MSG_ERRQUEUE;
94823 err = copied;
94824 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
94825 index a0e9cf6..ef7f9ed 100644
94826 --- a/net/core/sock_diag.c
94827 +++ b/net/core/sock_diag.c
94828 @@ -9,26 +9,33 @@
94829 #include <linux/inet_diag.h>
94830 #include <linux/sock_diag.h>
94831
94832 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
94833 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
94834 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
94835 static DEFINE_MUTEX(sock_diag_table_mutex);
94836
94837 int sock_diag_check_cookie(void *sk, __u32 *cookie)
94838 {
94839 +#ifndef CONFIG_GRKERNSEC_HIDESYM
94840 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
94841 cookie[1] != INET_DIAG_NOCOOKIE) &&
94842 ((u32)(unsigned long)sk != cookie[0] ||
94843 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
94844 return -ESTALE;
94845 else
94846 +#endif
94847 return 0;
94848 }
94849 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
94850
94851 void sock_diag_save_cookie(void *sk, __u32 *cookie)
94852 {
94853 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94854 + cookie[0] = 0;
94855 + cookie[1] = 0;
94856 +#else
94857 cookie[0] = (u32)(unsigned long)sk;
94858 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
94859 +#endif
94860 }
94861 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
94862
94863 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
94864 mutex_lock(&sock_diag_table_mutex);
94865 if (sock_diag_handlers[hndl->family])
94866 err = -EBUSY;
94867 - else
94868 + else {
94869 + pax_open_kernel();
94870 sock_diag_handlers[hndl->family] = hndl;
94871 + pax_close_kernel();
94872 + }
94873 mutex_unlock(&sock_diag_table_mutex);
94874
94875 return err;
94876 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
94877
94878 mutex_lock(&sock_diag_table_mutex);
94879 BUG_ON(sock_diag_handlers[family] != hnld);
94880 + pax_open_kernel();
94881 sock_diag_handlers[family] = NULL;
94882 + pax_close_kernel();
94883 mutex_unlock(&sock_diag_table_mutex);
94884 }
94885 EXPORT_SYMBOL_GPL(sock_diag_unregister);
94886 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
94887 index cca4441..5e616de 100644
94888 --- a/net/core/sysctl_net_core.c
94889 +++ b/net/core/sysctl_net_core.c
94890 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
94891 {
94892 unsigned int orig_size, size;
94893 int ret, i;
94894 - struct ctl_table tmp = {
94895 + ctl_table_no_const tmp = {
94896 .data = &size,
94897 .maxlen = sizeof(size),
94898 .mode = table->mode
94899 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
94900 void __user *buffer, size_t *lenp, loff_t *ppos)
94901 {
94902 char id[IFNAMSIZ];
94903 - struct ctl_table tbl = {
94904 + ctl_table_no_const tbl = {
94905 .data = id,
94906 .maxlen = IFNAMSIZ,
94907 };
94908 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
94909
94910 static __net_init int sysctl_core_net_init(struct net *net)
94911 {
94912 - struct ctl_table *tbl;
94913 + ctl_table_no_const *tbl = NULL;
94914
94915 net->core.sysctl_somaxconn = SOMAXCONN;
94916
94917 - tbl = netns_core_table;
94918 if (!net_eq(net, &init_net)) {
94919 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
94920 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
94921 if (tbl == NULL)
94922 goto err_dup;
94923
94924 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
94925 if (net->user_ns != &init_user_ns) {
94926 tbl[0].procname = NULL;
94927 }
94928 - }
94929 -
94930 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
94931 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
94932 + } else
94933 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
94934 if (net->core.sysctl_hdr == NULL)
94935 goto err_reg;
94936
94937 return 0;
94938
94939 err_reg:
94940 - if (tbl != netns_core_table)
94941 - kfree(tbl);
94942 + kfree(tbl);
94943 err_dup:
94944 return -ENOMEM;
94945 }
94946 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
94947 kfree(tbl);
94948 }
94949
94950 -static __net_initdata struct pernet_operations sysctl_core_ops = {
94951 +static __net_initconst struct pernet_operations sysctl_core_ops = {
94952 .init = sysctl_core_net_init,
94953 .exit = sysctl_core_net_exit,
94954 };
94955 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
94956 index dd4d506..fb2fb87 100644
94957 --- a/net/decnet/af_decnet.c
94958 +++ b/net/decnet/af_decnet.c
94959 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
94960 .sysctl_rmem = sysctl_decnet_rmem,
94961 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
94962 .obj_size = sizeof(struct dn_sock),
94963 + .slab_flags = SLAB_USERCOPY,
94964 };
94965
94966 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
94967 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
94968 index 5325b54..a0d4d69 100644
94969 --- a/net/decnet/sysctl_net_decnet.c
94970 +++ b/net/decnet/sysctl_net_decnet.c
94971 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
94972
94973 if (len > *lenp) len = *lenp;
94974
94975 - if (copy_to_user(buffer, addr, len))
94976 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
94977 return -EFAULT;
94978
94979 *lenp = len;
94980 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
94981
94982 if (len > *lenp) len = *lenp;
94983
94984 - if (copy_to_user(buffer, devname, len))
94985 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
94986 return -EFAULT;
94987
94988 *lenp = len;
94989 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
94990 index 008f337..b03b8c9 100644
94991 --- a/net/ieee802154/6lowpan.c
94992 +++ b/net/ieee802154/6lowpan.c
94993 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
94994 hc06_ptr += 3;
94995 } else {
94996 /* compress nothing */
94997 - memcpy(hc06_ptr, &hdr, 4);
94998 + memcpy(hc06_ptr, hdr, 4);
94999 /* replace the top byte with new ECN | DSCP format */
95000 *hc06_ptr = tmp;
95001 hc06_ptr += 4;
95002 diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
95003 index 22b1a70..4efd237 100644
95004 --- a/net/ieee802154/nl-phy.c
95005 +++ b/net/ieee802154/nl-phy.c
95006 @@ -224,8 +224,10 @@ static int ieee802154_add_iface(struct sk_buff *skb,
95007
95008 if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) {
95009 type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]);
95010 - if (type >= __IEEE802154_DEV_MAX)
95011 - return -EINVAL;
95012 + if (type >= __IEEE802154_DEV_MAX) {
95013 + rc = -EINVAL;
95014 + goto nla_put_failure;
95015 + }
95016 }
95017
95018 dev = phy->add_iface(phy, devname, type);
95019 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
95020 index cfeb85c..385989a 100644
95021 --- a/net/ipv4/af_inet.c
95022 +++ b/net/ipv4/af_inet.c
95023 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
95024
95025 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
95026
95027 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
95028 - if (!sysctl_local_reserved_ports)
95029 - goto out;
95030 -
95031 rc = proto_register(&tcp_prot, 1);
95032 if (rc)
95033 - goto out_free_reserved_ports;
95034 + goto out;
95035
95036 rc = proto_register(&udp_prot, 1);
95037 if (rc)
95038 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
95039 proto_unregister(&udp_prot);
95040 out_unregister_tcp_proto:
95041 proto_unregister(&tcp_prot);
95042 -out_free_reserved_ports:
95043 - kfree(sysctl_local_reserved_ports);
95044 goto out;
95045 }
95046
95047 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
95048 index a1b5bcb..62ec5c6 100644
95049 --- a/net/ipv4/devinet.c
95050 +++ b/net/ipv4/devinet.c
95051 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
95052 idx = 0;
95053 head = &net->dev_index_head[h];
95054 rcu_read_lock();
95055 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
95056 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
95057 net->dev_base_seq;
95058 hlist_for_each_entry_rcu(dev, head, index_hlist) {
95059 if (idx < s_idx)
95060 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
95061 idx = 0;
95062 head = &net->dev_index_head[h];
95063 rcu_read_lock();
95064 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
95065 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
95066 net->dev_base_seq;
95067 hlist_for_each_entry_rcu(dev, head, index_hlist) {
95068 if (idx < s_idx)
95069 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
95070 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
95071 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
95072
95073 -static struct devinet_sysctl_table {
95074 +static const struct devinet_sysctl_table {
95075 struct ctl_table_header *sysctl_header;
95076 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
95077 } devinet_sysctl = {
95078 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
95079 int err;
95080 struct ipv4_devconf *all, *dflt;
95081 #ifdef CONFIG_SYSCTL
95082 - struct ctl_table *tbl = ctl_forward_entry;
95083 + ctl_table_no_const *tbl = NULL;
95084 struct ctl_table_header *forw_hdr;
95085 #endif
95086
95087 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
95088 goto err_alloc_dflt;
95089
95090 #ifdef CONFIG_SYSCTL
95091 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
95092 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
95093 if (tbl == NULL)
95094 goto err_alloc_ctl;
95095
95096 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
95097 goto err_reg_dflt;
95098
95099 err = -ENOMEM;
95100 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
95101 + if (!net_eq(net, &init_net))
95102 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
95103 + else
95104 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
95105 if (forw_hdr == NULL)
95106 goto err_reg_ctl;
95107 net->ipv4.forw_hdr = forw_hdr;
95108 @@ -2245,8 +2248,7 @@ err_reg_ctl:
95109 err_reg_dflt:
95110 __devinet_sysctl_unregister(all);
95111 err_reg_all:
95112 - if (tbl != ctl_forward_entry)
95113 - kfree(tbl);
95114 + kfree(tbl);
95115 err_alloc_ctl:
95116 #endif
95117 if (dflt != &ipv4_devconf_dflt)
95118 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
95119 index b3f627a..b0f3e99 100644
95120 --- a/net/ipv4/fib_frontend.c
95121 +++ b/net/ipv4/fib_frontend.c
95122 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
95123 #ifdef CONFIG_IP_ROUTE_MULTIPATH
95124 fib_sync_up(dev);
95125 #endif
95126 - atomic_inc(&net->ipv4.dev_addr_genid);
95127 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
95128 rt_cache_flush(dev_net(dev));
95129 break;
95130 case NETDEV_DOWN:
95131 fib_del_ifaddr(ifa, NULL);
95132 - atomic_inc(&net->ipv4.dev_addr_genid);
95133 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
95134 if (ifa->ifa_dev->ifa_list == NULL) {
95135 /* Last address was deleted from this interface.
95136 * Disable IP.
95137 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
95138 #ifdef CONFIG_IP_ROUTE_MULTIPATH
95139 fib_sync_up(dev);
95140 #endif
95141 - atomic_inc(&net->ipv4.dev_addr_genid);
95142 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
95143 rt_cache_flush(net);
95144 break;
95145 case NETDEV_DOWN:
95146 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
95147 index d5dbca5..6251d5f 100644
95148 --- a/net/ipv4/fib_semantics.c
95149 +++ b/net/ipv4/fib_semantics.c
95150 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
95151 nh->nh_saddr = inet_select_addr(nh->nh_dev,
95152 nh->nh_gw,
95153 nh->nh_parent->fib_scope);
95154 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
95155 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
95156
95157 return nh->nh_saddr;
95158 }
95159 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
95160 index 6acb541..9ea617d 100644
95161 --- a/net/ipv4/inet_connection_sock.c
95162 +++ b/net/ipv4/inet_connection_sock.c
95163 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
95164 .range = { 32768, 61000 },
95165 };
95166
95167 -unsigned long *sysctl_local_reserved_ports;
95168 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
95169 EXPORT_SYMBOL(sysctl_local_reserved_ports);
95170
95171 void inet_get_local_port_range(int *low, int *high)
95172 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
95173 index 96da9c7..b956690 100644
95174 --- a/net/ipv4/inet_hashtables.c
95175 +++ b/net/ipv4/inet_hashtables.c
95176 @@ -18,12 +18,15 @@
95177 #include <linux/sched.h>
95178 #include <linux/slab.h>
95179 #include <linux/wait.h>
95180 +#include <linux/security.h>
95181
95182 #include <net/inet_connection_sock.h>
95183 #include <net/inet_hashtables.h>
95184 #include <net/secure_seq.h>
95185 #include <net/ip.h>
95186
95187 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
95188 +
95189 /*
95190 * Allocate and initialize a new local port bind bucket.
95191 * The bindhash mutex for snum's hash chain must be held here.
95192 @@ -554,6 +557,8 @@ ok:
95193 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
95194 spin_unlock(&head->lock);
95195
95196 + gr_update_task_in_ip_table(current, inet_sk(sk));
95197 +
95198 if (tw) {
95199 inet_twsk_deschedule(tw, death_row);
95200 while (twrefcnt) {
95201 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
95202 index 33d5537..da337a4 100644
95203 --- a/net/ipv4/inetpeer.c
95204 +++ b/net/ipv4/inetpeer.c
95205 @@ -503,8 +503,8 @@ relookup:
95206 if (p) {
95207 p->daddr = *daddr;
95208 atomic_set(&p->refcnt, 1);
95209 - atomic_set(&p->rid, 0);
95210 - atomic_set(&p->ip_id_count,
95211 + atomic_set_unchecked(&p->rid, 0);
95212 + atomic_set_unchecked(&p->ip_id_count,
95213 (daddr->family == AF_INET) ?
95214 secure_ip_id(daddr->addr.a4) :
95215 secure_ipv6_id(daddr->addr.a6));
95216 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
95217 index b66910a..cfe416e 100644
95218 --- a/net/ipv4/ip_fragment.c
95219 +++ b/net/ipv4/ip_fragment.c
95220 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
95221 return 0;
95222
95223 start = qp->rid;
95224 - end = atomic_inc_return(&peer->rid);
95225 + end = atomic_inc_return_unchecked(&peer->rid);
95226 qp->rid = end;
95227
95228 rc = qp->q.fragments && (end - start) > max;
95229 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
95230
95231 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
95232 {
95233 - struct ctl_table *table;
95234 + ctl_table_no_const *table = NULL;
95235 struct ctl_table_header *hdr;
95236
95237 - table = ip4_frags_ns_ctl_table;
95238 if (!net_eq(net, &init_net)) {
95239 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
95240 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
95241 if (table == NULL)
95242 goto err_alloc;
95243
95244 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
95245 /* Don't export sysctls to unprivileged users */
95246 if (net->user_ns != &init_user_ns)
95247 table[0].procname = NULL;
95248 - }
95249 + hdr = register_net_sysctl(net, "net/ipv4", table);
95250 + } else
95251 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
95252
95253 - hdr = register_net_sysctl(net, "net/ipv4", table);
95254 if (hdr == NULL)
95255 goto err_reg;
95256
95257 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
95258 return 0;
95259
95260 err_reg:
95261 - if (!net_eq(net, &init_net))
95262 - kfree(table);
95263 + kfree(table);
95264 err_alloc:
95265 return -ENOMEM;
95266 }
95267 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
95268 index e560ef3..218c5c5 100644
95269 --- a/net/ipv4/ip_gre.c
95270 +++ b/net/ipv4/ip_gre.c
95271 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
95272 module_param(log_ecn_error, bool, 0644);
95273 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
95274
95275 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
95276 +static struct rtnl_link_ops ipgre_link_ops;
95277 static int ipgre_tunnel_init(struct net_device *dev);
95278
95279 static int ipgre_net_id __read_mostly;
95280 @@ -732,7 +732,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
95281 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
95282 };
95283
95284 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
95285 +static struct rtnl_link_ops ipgre_link_ops = {
95286 .kind = "gre",
95287 .maxtype = IFLA_GRE_MAX,
95288 .policy = ipgre_policy,
95289 @@ -746,7 +746,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
95290 .fill_info = ipgre_fill_info,
95291 };
95292
95293 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
95294 +static struct rtnl_link_ops ipgre_tap_ops = {
95295 .kind = "gretap",
95296 .maxtype = IFLA_GRE_MAX,
95297 .policy = ipgre_policy,
95298 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
95299 index 23e6ab0..be67a57 100644
95300 --- a/net/ipv4/ip_sockglue.c
95301 +++ b/net/ipv4/ip_sockglue.c
95302 @@ -1153,7 +1153,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
95303 len = min_t(unsigned int, len, opt->optlen);
95304 if (put_user(len, optlen))
95305 return -EFAULT;
95306 - if (copy_to_user(optval, opt->__data, len))
95307 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
95308 + copy_to_user(optval, opt->__data, len))
95309 return -EFAULT;
95310 return 0;
95311 }
95312 @@ -1284,7 +1285,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
95313 if (sk->sk_type != SOCK_STREAM)
95314 return -ENOPROTOOPT;
95315
95316 - msg.msg_control = optval;
95317 + msg.msg_control = (void __force_kernel *)optval;
95318 msg.msg_controllen = len;
95319 msg.msg_flags = flags;
95320
95321 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
95322 index 26847e1..75d2d2f 100644
95323 --- a/net/ipv4/ip_vti.c
95324 +++ b/net/ipv4/ip_vti.c
95325 @@ -44,7 +44,7 @@
95326 #include <net/net_namespace.h>
95327 #include <net/netns/generic.h>
95328
95329 -static struct rtnl_link_ops vti_link_ops __read_mostly;
95330 +static struct rtnl_link_ops vti_link_ops;
95331
95332 static int vti_net_id __read_mostly;
95333 static int vti_tunnel_init(struct net_device *dev);
95334 @@ -425,7 +425,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
95335 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
95336 };
95337
95338 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
95339 +static struct rtnl_link_ops vti_link_ops = {
95340 .kind = "vti",
95341 .maxtype = IFLA_VTI_MAX,
95342 .policy = vti_policy,
95343 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
95344 index efa1138..20dbba0 100644
95345 --- a/net/ipv4/ipconfig.c
95346 +++ b/net/ipv4/ipconfig.c
95347 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
95348
95349 mm_segment_t oldfs = get_fs();
95350 set_fs(get_ds());
95351 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
95352 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
95353 set_fs(oldfs);
95354 return res;
95355 }
95356 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
95357
95358 mm_segment_t oldfs = get_fs();
95359 set_fs(get_ds());
95360 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
95361 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
95362 set_fs(oldfs);
95363 return res;
95364 }
95365 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
95366
95367 mm_segment_t oldfs = get_fs();
95368 set_fs(get_ds());
95369 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
95370 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
95371 set_fs(oldfs);
95372 return res;
95373 }
95374 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
95375 index 7f80fb4..b0328f6 100644
95376 --- a/net/ipv4/ipip.c
95377 +++ b/net/ipv4/ipip.c
95378 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
95379 static int ipip_net_id __read_mostly;
95380
95381 static int ipip_tunnel_init(struct net_device *dev);
95382 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
95383 +static struct rtnl_link_ops ipip_link_ops;
95384
95385 static int ipip_err(struct sk_buff *skb, u32 info)
95386 {
95387 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
95388 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
95389 };
95390
95391 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
95392 +static struct rtnl_link_ops ipip_link_ops = {
95393 .kind = "ipip",
95394 .maxtype = IFLA_IPTUN_MAX,
95395 .policy = ipip_policy,
95396 diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
95397 index 62212c7..1672409 100644
95398 --- a/net/ipv4/ipmr.c
95399 +++ b/net/ipv4/ipmr.c
95400 @@ -157,9 +157,12 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)
95401 static int ipmr_fib_lookup(struct net *net, struct flowi4 *flp4,
95402 struct mr_table **mrt)
95403 {
95404 + int err;
95405 struct ipmr_result res;
95406 - struct fib_lookup_arg arg = { .result = &res, };
95407 - int err;
95408 + struct fib_lookup_arg arg = {
95409 + .result = &res,
95410 + .flags = FIB_LOOKUP_NOREF,
95411 + };
95412
95413 err = fib_rules_lookup(net->ipv4.mr_rules_ops,
95414 flowi4_to_flowi(flp4), 0, &arg);
95415 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
95416 index 85a4f21..1beb1f5 100644
95417 --- a/net/ipv4/netfilter/arp_tables.c
95418 +++ b/net/ipv4/netfilter/arp_tables.c
95419 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
95420 #endif
95421
95422 static int get_info(struct net *net, void __user *user,
95423 - const int *len, int compat)
95424 + int len, int compat)
95425 {
95426 char name[XT_TABLE_MAXNAMELEN];
95427 struct xt_table *t;
95428 int ret;
95429
95430 - if (*len != sizeof(struct arpt_getinfo)) {
95431 - duprintf("length %u != %Zu\n", *len,
95432 + if (len != sizeof(struct arpt_getinfo)) {
95433 + duprintf("length %u != %Zu\n", len,
95434 sizeof(struct arpt_getinfo));
95435 return -EINVAL;
95436 }
95437 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
95438 info.size = private->size;
95439 strcpy(info.name, name);
95440
95441 - if (copy_to_user(user, &info, *len) != 0)
95442 + if (copy_to_user(user, &info, len) != 0)
95443 ret = -EFAULT;
95444 else
95445 ret = 0;
95446 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
95447
95448 switch (cmd) {
95449 case ARPT_SO_GET_INFO:
95450 - ret = get_info(sock_net(sk), user, len, 1);
95451 + ret = get_info(sock_net(sk), user, *len, 1);
95452 break;
95453 case ARPT_SO_GET_ENTRIES:
95454 ret = compat_get_entries(sock_net(sk), user, len);
95455 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
95456
95457 switch (cmd) {
95458 case ARPT_SO_GET_INFO:
95459 - ret = get_info(sock_net(sk), user, len, 0);
95460 + ret = get_info(sock_net(sk), user, *len, 0);
95461 break;
95462
95463 case ARPT_SO_GET_ENTRIES:
95464 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
95465 index d23118d..6ad7277 100644
95466 --- a/net/ipv4/netfilter/ip_tables.c
95467 +++ b/net/ipv4/netfilter/ip_tables.c
95468 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
95469 #endif
95470
95471 static int get_info(struct net *net, void __user *user,
95472 - const int *len, int compat)
95473 + int len, int compat)
95474 {
95475 char name[XT_TABLE_MAXNAMELEN];
95476 struct xt_table *t;
95477 int ret;
95478
95479 - if (*len != sizeof(struct ipt_getinfo)) {
95480 - duprintf("length %u != %zu\n", *len,
95481 + if (len != sizeof(struct ipt_getinfo)) {
95482 + duprintf("length %u != %zu\n", len,
95483 sizeof(struct ipt_getinfo));
95484 return -EINVAL;
95485 }
95486 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
95487 info.size = private->size;
95488 strcpy(info.name, name);
95489
95490 - if (copy_to_user(user, &info, *len) != 0)
95491 + if (copy_to_user(user, &info, len) != 0)
95492 ret = -EFAULT;
95493 else
95494 ret = 0;
95495 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95496
95497 switch (cmd) {
95498 case IPT_SO_GET_INFO:
95499 - ret = get_info(sock_net(sk), user, len, 1);
95500 + ret = get_info(sock_net(sk), user, *len, 1);
95501 break;
95502 case IPT_SO_GET_ENTRIES:
95503 ret = compat_get_entries(sock_net(sk), user, len);
95504 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95505
95506 switch (cmd) {
95507 case IPT_SO_GET_INFO:
95508 - ret = get_info(sock_net(sk), user, len, 0);
95509 + ret = get_info(sock_net(sk), user, *len, 0);
95510 break;
95511
95512 case IPT_SO_GET_ENTRIES:
95513 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
95514 index cbc2215..9cb993c 100644
95515 --- a/net/ipv4/netfilter/ipt_ULOG.c
95516 +++ b/net/ipv4/netfilter/ipt_ULOG.c
95517 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
95518 ub->qlen++;
95519
95520 pm = nlmsg_data(nlh);
95521 + memset(pm, 0, sizeof(*pm));
95522
95523 /* We might not have a timestamp, get one */
95524 if (skb->tstamp.tv64 == 0)
95525 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
95526 }
95527 else if (loginfo->prefix[0] != '\0')
95528 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
95529 - else
95530 - *(pm->prefix) = '\0';
95531
95532 if (in && in->hard_header_len > 0 &&
95533 skb->mac_header != skb->network_header &&
95534 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
95535
95536 if (in)
95537 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
95538 - else
95539 - pm->indev_name[0] = '\0';
95540
95541 if (out)
95542 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
95543 - else
95544 - pm->outdev_name[0] = '\0';
95545
95546 /* copy_len <= skb->len, so can't fail. */
95547 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
95548 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
95549 index c482f7c..2784262 100644
95550 --- a/net/ipv4/ping.c
95551 +++ b/net/ipv4/ping.c
95552 @@ -55,7 +55,7 @@
95553
95554
95555 struct ping_table ping_table;
95556 -struct pingv6_ops pingv6_ops;
95557 +struct pingv6_ops *pingv6_ops;
95558 EXPORT_SYMBOL_GPL(pingv6_ops);
95559
95560 static u16 ping_port_rover;
95561 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
95562 return -ENODEV;
95563 }
95564 }
95565 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
95566 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
95567 scoped);
95568 rcu_read_unlock();
95569
95570 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
95571 }
95572 #if IS_ENABLED(CONFIG_IPV6)
95573 } else if (skb->protocol == htons(ETH_P_IPV6)) {
95574 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
95575 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
95576 #endif
95577 }
95578
95579 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
95580 info, (u8 *)icmph);
95581 #if IS_ENABLED(CONFIG_IPV6)
95582 } else if (family == AF_INET6) {
95583 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
95584 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
95585 info, (u8 *)icmph);
95586 #endif
95587 }
95588 @@ -841,7 +841,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
95589 return ip_recv_error(sk, msg, len, addr_len);
95590 #if IS_ENABLED(CONFIG_IPV6)
95591 } else if (family == AF_INET6) {
95592 - return pingv6_ops.ipv6_recv_error(sk, msg, len,
95593 + return pingv6_ops->ipv6_recv_error(sk, msg, len,
95594 addr_len);
95595 #endif
95596 }
95597 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
95598 }
95599
95600 if (inet6_sk(sk)->rxopt.all)
95601 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
95602 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
95603 #endif
95604 } else {
95605 BUG();
95606 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
95607 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
95608 0, sock_i_ino(sp),
95609 atomic_read(&sp->sk_refcnt), sp,
95610 - atomic_read(&sp->sk_drops), len);
95611 + atomic_read_unchecked(&sp->sk_drops), len);
95612 }
95613
95614 static int ping_v4_seq_show(struct seq_file *seq, void *v)
95615 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
95616 index 7d3db78..9fd511d 100644
95617 --- a/net/ipv4/raw.c
95618 +++ b/net/ipv4/raw.c
95619 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
95620 int raw_rcv(struct sock *sk, struct sk_buff *skb)
95621 {
95622 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
95623 - atomic_inc(&sk->sk_drops);
95624 + atomic_inc_unchecked(&sk->sk_drops);
95625 kfree_skb(skb);
95626 return NET_RX_DROP;
95627 }
95628 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
95629
95630 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
95631 {
95632 + struct icmp_filter filter;
95633 +
95634 if (optlen > sizeof(struct icmp_filter))
95635 optlen = sizeof(struct icmp_filter);
95636 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
95637 + if (copy_from_user(&filter, optval, optlen))
95638 return -EFAULT;
95639 + raw_sk(sk)->filter = filter;
95640 return 0;
95641 }
95642
95643 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
95644 {
95645 int len, ret = -EFAULT;
95646 + struct icmp_filter filter;
95647
95648 if (get_user(len, optlen))
95649 goto out;
95650 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
95651 if (len > sizeof(struct icmp_filter))
95652 len = sizeof(struct icmp_filter);
95653 ret = -EFAULT;
95654 - if (put_user(len, optlen) ||
95655 - copy_to_user(optval, &raw_sk(sk)->filter, len))
95656 + filter = raw_sk(sk)->filter;
95657 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
95658 goto out;
95659 ret = 0;
95660 out: return ret;
95661 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
95662 0, 0L, 0,
95663 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
95664 0, sock_i_ino(sp),
95665 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
95666 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
95667 }
95668
95669 static int raw_seq_show(struct seq_file *seq, void *v)
95670 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
95671 index 62290b5..f0d944f 100644
95672 --- a/net/ipv4/route.c
95673 +++ b/net/ipv4/route.c
95674 @@ -2617,34 +2617,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
95675 .maxlen = sizeof(int),
95676 .mode = 0200,
95677 .proc_handler = ipv4_sysctl_rtcache_flush,
95678 + .extra1 = &init_net,
95679 },
95680 { },
95681 };
95682
95683 static __net_init int sysctl_route_net_init(struct net *net)
95684 {
95685 - struct ctl_table *tbl;
95686 + ctl_table_no_const *tbl = NULL;
95687
95688 - tbl = ipv4_route_flush_table;
95689 if (!net_eq(net, &init_net)) {
95690 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
95691 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
95692 if (tbl == NULL)
95693 goto err_dup;
95694
95695 /* Don't export sysctls to unprivileged users */
95696 if (net->user_ns != &init_user_ns)
95697 tbl[0].procname = NULL;
95698 - }
95699 - tbl[0].extra1 = net;
95700 + tbl[0].extra1 = net;
95701 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
95702 + } else
95703 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
95704
95705 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
95706 if (net->ipv4.route_hdr == NULL)
95707 goto err_reg;
95708 return 0;
95709
95710 err_reg:
95711 - if (tbl != ipv4_route_flush_table)
95712 - kfree(tbl);
95713 + kfree(tbl);
95714 err_dup:
95715 return -ENOMEM;
95716 }
95717 @@ -2667,8 +2667,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
95718
95719 static __net_init int rt_genid_init(struct net *net)
95720 {
95721 - atomic_set(&net->ipv4.rt_genid, 0);
95722 - atomic_set(&net->fnhe_genid, 0);
95723 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
95724 + atomic_set_unchecked(&net->fnhe_genid, 0);
95725 get_random_bytes(&net->ipv4.dev_addr_genid,
95726 sizeof(net->ipv4.dev_addr_genid));
95727 return 0;
95728 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
95729 index 540279f..9855b16 100644
95730 --- a/net/ipv4/sysctl_net_ipv4.c
95731 +++ b/net/ipv4/sysctl_net_ipv4.c
95732 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
95733 {
95734 int ret;
95735 int range[2];
95736 - struct ctl_table tmp = {
95737 + ctl_table_no_const tmp = {
95738 .data = &range,
95739 .maxlen = sizeof(range),
95740 .mode = table->mode,
95741 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
95742 int ret;
95743 gid_t urange[2];
95744 kgid_t low, high;
95745 - struct ctl_table tmp = {
95746 + ctl_table_no_const tmp = {
95747 .data = &urange,
95748 .maxlen = sizeof(urange),
95749 .mode = table->mode,
95750 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
95751 void __user *buffer, size_t *lenp, loff_t *ppos)
95752 {
95753 char val[TCP_CA_NAME_MAX];
95754 - struct ctl_table tbl = {
95755 + ctl_table_no_const tbl = {
95756 .data = val,
95757 .maxlen = TCP_CA_NAME_MAX,
95758 };
95759 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
95760 void __user *buffer, size_t *lenp,
95761 loff_t *ppos)
95762 {
95763 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
95764 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
95765 int ret;
95766
95767 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
95768 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
95769 void __user *buffer, size_t *lenp,
95770 loff_t *ppos)
95771 {
95772 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
95773 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
95774 int ret;
95775
95776 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
95777 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
95778 struct mem_cgroup *memcg;
95779 #endif
95780
95781 - struct ctl_table tmp = {
95782 + ctl_table_no_const tmp = {
95783 .data = &vec,
95784 .maxlen = sizeof(vec),
95785 .mode = ctl->mode,
95786 };
95787
95788 if (!write) {
95789 - ctl->data = &net->ipv4.sysctl_tcp_mem;
95790 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
95791 + ctl_table_no_const tcp_mem = *ctl;
95792 +
95793 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
95794 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
95795 }
95796
95797 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
95798 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
95799 void __user *buffer, size_t *lenp,
95800 loff_t *ppos)
95801 {
95802 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
95803 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
95804 struct tcp_fastopen_context *ctxt;
95805 int ret;
95806 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
95807 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
95808 },
95809 {
95810 .procname = "ip_local_reserved_ports",
95811 - .data = NULL, /* initialized in sysctl_ipv4_init */
95812 + .data = sysctl_local_reserved_ports,
95813 .maxlen = 65536,
95814 .mode = 0644,
95815 .proc_handler = proc_do_large_bitmap,
95816 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
95817
95818 static __net_init int ipv4_sysctl_init_net(struct net *net)
95819 {
95820 - struct ctl_table *table;
95821 + ctl_table_no_const *table = NULL;
95822
95823 - table = ipv4_net_table;
95824 if (!net_eq(net, &init_net)) {
95825 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
95826 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
95827 if (table == NULL)
95828 goto err_alloc;
95829
95830 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
95831
95832 tcp_init_mem(net);
95833
95834 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
95835 + if (!net_eq(net, &init_net))
95836 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
95837 + else
95838 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
95839 if (net->ipv4.ipv4_hdr == NULL)
95840 goto err_reg;
95841
95842 return 0;
95843
95844 err_reg:
95845 - if (!net_eq(net, &init_net))
95846 - kfree(table);
95847 + kfree(table);
95848 err_alloc:
95849 return -ENOMEM;
95850 }
95851 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
95852 static __init int sysctl_ipv4_init(void)
95853 {
95854 struct ctl_table_header *hdr;
95855 - struct ctl_table *i;
95856 -
95857 - for (i = ipv4_table; i->procname; i++) {
95858 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
95859 - i->data = sysctl_local_reserved_ports;
95860 - break;
95861 - }
95862 - }
95863 - if (!i->procname)
95864 - return -EINVAL;
95865
95866 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
95867 if (hdr == NULL)
95868 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
95869 index 068c8fb..a755c52 100644
95870 --- a/net/ipv4/tcp_input.c
95871 +++ b/net/ipv4/tcp_input.c
95872 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
95873 * simplifies code)
95874 */
95875 static void
95876 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
95877 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
95878 struct sk_buff *head, struct sk_buff *tail,
95879 u32 start, u32 end)
95880 {
95881 @@ -5520,6 +5520,7 @@ discard:
95882 tcp_paws_reject(&tp->rx_opt, 0))
95883 goto discard_and_undo;
95884
95885 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
95886 if (th->syn) {
95887 /* We see SYN without ACK. It is attempt of
95888 * simultaneous connect with crossed SYNs.
95889 @@ -5570,6 +5571,7 @@ discard:
95890 goto discard;
95891 #endif
95892 }
95893 +#endif
95894 /* "fifth, if neither of the SYN or RST bits is set then
95895 * drop the segment and return."
95896 */
95897 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
95898 goto discard;
95899
95900 if (th->syn) {
95901 - if (th->fin)
95902 + if (th->fin || th->urg || th->psh)
95903 goto discard;
95904 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
95905 return 1;
95906 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
95907 index 5031f68..91569e2 100644
95908 --- a/net/ipv4/tcp_ipv4.c
95909 +++ b/net/ipv4/tcp_ipv4.c
95910 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
95911 EXPORT_SYMBOL(sysctl_tcp_low_latency);
95912
95913
95914 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95915 +extern int grsec_enable_blackhole;
95916 +#endif
95917 +
95918 #ifdef CONFIG_TCP_MD5SIG
95919 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
95920 __be32 daddr, __be32 saddr, const struct tcphdr *th);
95921 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
95922 return 0;
95923
95924 reset:
95925 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95926 + if (!grsec_enable_blackhole)
95927 +#endif
95928 tcp_v4_send_reset(rsk, skb);
95929 discard:
95930 kfree_skb(skb);
95931 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
95932 TCP_SKB_CB(skb)->sacked = 0;
95933
95934 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95935 - if (!sk)
95936 + if (!sk) {
95937 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95938 + ret = 1;
95939 +#endif
95940 goto no_tcp_socket;
95941 -
95942 + }
95943 process:
95944 - if (sk->sk_state == TCP_TIME_WAIT)
95945 + if (sk->sk_state == TCP_TIME_WAIT) {
95946 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95947 + ret = 2;
95948 +#endif
95949 goto do_time_wait;
95950 + }
95951
95952 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
95953 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95954 @@ -2033,6 +2047,10 @@ csum_error:
95955 bad_packet:
95956 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95957 } else {
95958 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95959 + if (!grsec_enable_blackhole || (ret == 1 &&
95960 + (skb->dev->flags & IFF_LOOPBACK)))
95961 +#endif
95962 tcp_v4_send_reset(NULL, skb);
95963 }
95964
95965 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
95966 index 58a3e69..7f0626e 100644
95967 --- a/net/ipv4/tcp_minisocks.c
95968 +++ b/net/ipv4/tcp_minisocks.c
95969 @@ -27,6 +27,10 @@
95970 #include <net/inet_common.h>
95971 #include <net/xfrm.h>
95972
95973 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95974 +extern int grsec_enable_blackhole;
95975 +#endif
95976 +
95977 int sysctl_tcp_syncookies __read_mostly = 1;
95978 EXPORT_SYMBOL(sysctl_tcp_syncookies);
95979
95980 @@ -711,7 +715,10 @@ embryonic_reset:
95981 * avoid becoming vulnerable to outside attack aiming at
95982 * resetting legit local connections.
95983 */
95984 - req->rsk_ops->send_reset(sk, skb);
95985 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95986 + if (!grsec_enable_blackhole)
95987 +#endif
95988 + req->rsk_ops->send_reset(sk, skb);
95989 } else if (fastopen) { /* received a valid RST pkt */
95990 reqsk_fastopen_remove(sk, req, true);
95991 tcp_reset(sk);
95992 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
95993 index 611beab..c4b6e1d 100644
95994 --- a/net/ipv4/tcp_probe.c
95995 +++ b/net/ipv4/tcp_probe.c
95996 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
95997 if (cnt + width >= len)
95998 break;
95999
96000 - if (copy_to_user(buf + cnt, tbuf, width))
96001 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
96002 return -EFAULT;
96003 cnt += width;
96004 }
96005 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
96006 index 4b85e6f..22f9ac9 100644
96007 --- a/net/ipv4/tcp_timer.c
96008 +++ b/net/ipv4/tcp_timer.c
96009 @@ -22,6 +22,10 @@
96010 #include <linux/gfp.h>
96011 #include <net/tcp.h>
96012
96013 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96014 +extern int grsec_lastack_retries;
96015 +#endif
96016 +
96017 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
96018 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
96019 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
96020 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
96021 }
96022 }
96023
96024 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96025 + if ((sk->sk_state == TCP_LAST_ACK) &&
96026 + (grsec_lastack_retries > 0) &&
96027 + (grsec_lastack_retries < retry_until))
96028 + retry_until = grsec_lastack_retries;
96029 +#endif
96030 +
96031 if (retransmits_timed_out(sk, retry_until,
96032 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
96033 /* Has it gone just too far? */
96034 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
96035 index 6ca9907..a1e6c00 100644
96036 --- a/net/ipv4/udp.c
96037 +++ b/net/ipv4/udp.c
96038 @@ -87,6 +87,7 @@
96039 #include <linux/types.h>
96040 #include <linux/fcntl.h>
96041 #include <linux/module.h>
96042 +#include <linux/security.h>
96043 #include <linux/socket.h>
96044 #include <linux/sockios.h>
96045 #include <linux/igmp.h>
96046 @@ -112,6 +113,10 @@
96047 #include <net/busy_poll.h>
96048 #include "udp_impl.h"
96049
96050 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96051 +extern int grsec_enable_blackhole;
96052 +#endif
96053 +
96054 struct udp_table udp_table __read_mostly;
96055 EXPORT_SYMBOL(udp_table);
96056
96057 @@ -595,6 +600,9 @@ found:
96058 return s;
96059 }
96060
96061 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
96062 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
96063 +
96064 /*
96065 * This routine is called by the ICMP module when it gets some
96066 * sort of error condition. If err < 0 then the socket should
96067 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
96068 dport = usin->sin_port;
96069 if (dport == 0)
96070 return -EINVAL;
96071 +
96072 + err = gr_search_udp_sendmsg(sk, usin);
96073 + if (err)
96074 + return err;
96075 } else {
96076 if (sk->sk_state != TCP_ESTABLISHED)
96077 return -EDESTADDRREQ;
96078 +
96079 + err = gr_search_udp_sendmsg(sk, NULL);
96080 + if (err)
96081 + return err;
96082 +
96083 daddr = inet->inet_daddr;
96084 dport = inet->inet_dport;
96085 /* Open fast path for connected socket.
96086 @@ -1141,7 +1158,7 @@ static unsigned int first_packet_length(struct sock *sk)
96087 IS_UDPLITE(sk));
96088 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
96089 IS_UDPLITE(sk));
96090 - atomic_inc(&sk->sk_drops);
96091 + atomic_inc_unchecked(&sk->sk_drops);
96092 __skb_unlink(skb, rcvq);
96093 __skb_queue_tail(&list_kill, skb);
96094 }
96095 @@ -1221,6 +1238,10 @@ try_again:
96096 if (!skb)
96097 goto out;
96098
96099 + err = gr_search_udp_recvmsg(sk, skb);
96100 + if (err)
96101 + goto out_free;
96102 +
96103 ulen = skb->len - sizeof(struct udphdr);
96104 copied = len;
96105 if (copied > ulen)
96106 @@ -1254,7 +1275,7 @@ try_again:
96107 if (unlikely(err)) {
96108 trace_kfree_skb(skb, udp_recvmsg);
96109 if (!peeked) {
96110 - atomic_inc(&sk->sk_drops);
96111 + atomic_inc_unchecked(&sk->sk_drops);
96112 UDP_INC_STATS_USER(sock_net(sk),
96113 UDP_MIB_INERRORS, is_udplite);
96114 }
96115 @@ -1542,7 +1563,7 @@ csum_error:
96116 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
96117 drop:
96118 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
96119 - atomic_inc(&sk->sk_drops);
96120 + atomic_inc_unchecked(&sk->sk_drops);
96121 kfree_skb(skb);
96122 return -1;
96123 }
96124 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
96125 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
96126
96127 if (!skb1) {
96128 - atomic_inc(&sk->sk_drops);
96129 + atomic_inc_unchecked(&sk->sk_drops);
96130 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
96131 IS_UDPLITE(sk));
96132 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
96133 @@ -1733,6 +1754,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
96134 goto csum_error;
96135
96136 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
96137 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96138 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
96139 +#endif
96140 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
96141
96142 /*
96143 @@ -2165,7 +2189,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
96144 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
96145 0, sock_i_ino(sp),
96146 atomic_read(&sp->sk_refcnt), sp,
96147 - atomic_read(&sp->sk_drops), len);
96148 + atomic_read_unchecked(&sp->sk_drops), len);
96149 }
96150
96151 int udp4_seq_show(struct seq_file *seq, void *v)
96152 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
96153 index adf9983..8e45d0a 100644
96154 --- a/net/ipv4/xfrm4_policy.c
96155 +++ b/net/ipv4/xfrm4_policy.c
96156 @@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
96157 fl4->flowi4_tos = iph->tos;
96158 }
96159
96160 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
96161 +static int xfrm4_garbage_collect(struct dst_ops *ops)
96162 {
96163 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
96164
96165 - xfrm4_policy_afinfo.garbage_collect(net);
96166 + xfrm_garbage_collect_deferred(net);
96167 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
96168 }
96169
96170 @@ -269,19 +269,18 @@ static struct ctl_table xfrm4_policy_table[] = {
96171
96172 static int __net_init xfrm4_net_init(struct net *net)
96173 {
96174 - struct ctl_table *table;
96175 + ctl_table_no_const *table = NULL;
96176 struct ctl_table_header *hdr;
96177
96178 - table = xfrm4_policy_table;
96179 if (!net_eq(net, &init_net)) {
96180 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
96181 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
96182 if (!table)
96183 goto err_alloc;
96184
96185 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
96186 - }
96187 -
96188 - hdr = register_net_sysctl(net, "net/ipv4", table);
96189 + hdr = register_net_sysctl(net, "net/ipv4", table);
96190 + } else
96191 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
96192 if (!hdr)
96193 goto err_reg;
96194
96195 @@ -289,8 +288,7 @@ static int __net_init xfrm4_net_init(struct net *net)
96196 return 0;
96197
96198 err_reg:
96199 - if (!net_eq(net, &init_net))
96200 - kfree(table);
96201 + kfree(table);
96202 err_alloc:
96203 return -ENOMEM;
96204 }
96205 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
96206 index cd3fb30..b7dfef7 100644
96207 --- a/net/ipv6/addrconf.c
96208 +++ b/net/ipv6/addrconf.c
96209 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
96210 idx = 0;
96211 head = &net->dev_index_head[h];
96212 rcu_read_lock();
96213 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
96214 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
96215 net->dev_base_seq;
96216 hlist_for_each_entry_rcu(dev, head, index_hlist) {
96217 if (idx < s_idx)
96218 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
96219 p.iph.ihl = 5;
96220 p.iph.protocol = IPPROTO_IPV6;
96221 p.iph.ttl = 64;
96222 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
96223 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
96224
96225 if (ops->ndo_do_ioctl) {
96226 mm_segment_t oldfs = get_fs();
96227 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
96228 s_ip_idx = ip_idx = cb->args[2];
96229
96230 rcu_read_lock();
96231 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
96232 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
96233 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
96234 idx = 0;
96235 head = &net->dev_index_head[h];
96236 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
96237 dst_free(&ifp->rt->dst);
96238 break;
96239 }
96240 - atomic_inc(&net->ipv6.dev_addr_genid);
96241 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
96242 rt_genid_bump_ipv6(net);
96243 }
96244
96245 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
96246 int *valp = ctl->data;
96247 int val = *valp;
96248 loff_t pos = *ppos;
96249 - struct ctl_table lctl;
96250 + ctl_table_no_const lctl;
96251 int ret;
96252
96253 /*
96254 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
96255 int *valp = ctl->data;
96256 int val = *valp;
96257 loff_t pos = *ppos;
96258 - struct ctl_table lctl;
96259 + ctl_table_no_const lctl;
96260 int ret;
96261
96262 /*
96263 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
96264 index 8132b44..b8eca70 100644
96265 --- a/net/ipv6/af_inet6.c
96266 +++ b/net/ipv6/af_inet6.c
96267 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
96268
96269 net->ipv6.sysctl.bindv6only = 0;
96270 net->ipv6.sysctl.icmpv6_time = 1*HZ;
96271 - atomic_set(&net->ipv6.rt_genid, 0);
96272 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
96273
96274 err = ipv6_init_mibs(net);
96275 if (err)
96276 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
96277 index c66c6df..f375d3c 100644
96278 --- a/net/ipv6/datagram.c
96279 +++ b/net/ipv6/datagram.c
96280 @@ -908,5 +908,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
96281 0,
96282 sock_i_ino(sp),
96283 atomic_read(&sp->sk_refcnt), sp,
96284 - atomic_read(&sp->sk_drops));
96285 + atomic_read_unchecked(&sp->sk_drops));
96286 }
96287 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
96288 index eef8d94..cfa1852 100644
96289 --- a/net/ipv6/icmp.c
96290 +++ b/net/ipv6/icmp.c
96291 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
96292
96293 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
96294 {
96295 - struct ctl_table *table;
96296 + ctl_table_no_const *table;
96297
96298 table = kmemdup(ipv6_icmp_table_template,
96299 sizeof(ipv6_icmp_table_template),
96300 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
96301 index bf4a9a0..e5f6ac5 100644
96302 --- a/net/ipv6/ip6_gre.c
96303 +++ b/net/ipv6/ip6_gre.c
96304 @@ -74,7 +74,7 @@ struct ip6gre_net {
96305 struct net_device *fb_tunnel_dev;
96306 };
96307
96308 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
96309 +static struct rtnl_link_ops ip6gre_link_ops;
96310 static int ip6gre_tunnel_init(struct net_device *dev);
96311 static void ip6gre_tunnel_setup(struct net_device *dev);
96312 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
96313 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
96314 }
96315
96316
96317 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
96318 +static struct inet6_protocol ip6gre_protocol = {
96319 .handler = ip6gre_rcv,
96320 .err_handler = ip6gre_err,
96321 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
96322 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
96323 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
96324 };
96325
96326 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
96327 +static struct rtnl_link_ops ip6gre_link_ops = {
96328 .kind = "ip6gre",
96329 .maxtype = IFLA_GRE_MAX,
96330 .policy = ip6gre_policy,
96331 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
96332 .fill_info = ip6gre_fill_info,
96333 };
96334
96335 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
96336 +static struct rtnl_link_ops ip6gre_tap_ops = {
96337 .kind = "ip6gretap",
96338 .maxtype = IFLA_GRE_MAX,
96339 .policy = ip6gre_policy,
96340 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
96341 index c1e11b5..568e633 100644
96342 --- a/net/ipv6/ip6_tunnel.c
96343 +++ b/net/ipv6/ip6_tunnel.c
96344 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
96345
96346 static int ip6_tnl_dev_init(struct net_device *dev);
96347 static void ip6_tnl_dev_setup(struct net_device *dev);
96348 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
96349 +static struct rtnl_link_ops ip6_link_ops;
96350
96351 static int ip6_tnl_net_id __read_mostly;
96352 struct ip6_tnl_net {
96353 @@ -1699,7 +1699,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
96354 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
96355 };
96356
96357 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
96358 +static struct rtnl_link_ops ip6_link_ops = {
96359 .kind = "ip6tnl",
96360 .maxtype = IFLA_IPTUN_MAX,
96361 .policy = ip6_tnl_policy,
96362 diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
96363 index f365310..0eb4038 100644
96364 --- a/net/ipv6/ip6mr.c
96365 +++ b/net/ipv6/ip6mr.c
96366 @@ -141,9 +141,12 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id)
96367 static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
96368 struct mr6_table **mrt)
96369 {
96370 + int err;
96371 struct ip6mr_result res;
96372 - struct fib_lookup_arg arg = { .result = &res, };
96373 - int err;
96374 + struct fib_lookup_arg arg = {
96375 + .result = &res,
96376 + .flags = FIB_LOOKUP_NOREF,
96377 + };
96378
96379 err = fib_rules_lookup(net->ipv6.mr6_rules_ops,
96380 flowi6_to_flowi(flp6), 0, &arg);
96381 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
96382 index d1e2e8e..51c19ae 100644
96383 --- a/net/ipv6/ipv6_sockglue.c
96384 +++ b/net/ipv6/ipv6_sockglue.c
96385 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
96386 if (sk->sk_type != SOCK_STREAM)
96387 return -ENOPROTOOPT;
96388
96389 - msg.msg_control = optval;
96390 + msg.msg_control = (void __force_kernel *)optval;
96391 msg.msg_controllen = len;
96392 msg.msg_flags = flags;
96393
96394 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
96395 index 44400c2..8e11f52 100644
96396 --- a/net/ipv6/netfilter/ip6_tables.c
96397 +++ b/net/ipv6/netfilter/ip6_tables.c
96398 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
96399 #endif
96400
96401 static int get_info(struct net *net, void __user *user,
96402 - const int *len, int compat)
96403 + int len, int compat)
96404 {
96405 char name[XT_TABLE_MAXNAMELEN];
96406 struct xt_table *t;
96407 int ret;
96408
96409 - if (*len != sizeof(struct ip6t_getinfo)) {
96410 - duprintf("length %u != %zu\n", *len,
96411 + if (len != sizeof(struct ip6t_getinfo)) {
96412 + duprintf("length %u != %zu\n", len,
96413 sizeof(struct ip6t_getinfo));
96414 return -EINVAL;
96415 }
96416 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
96417 info.size = private->size;
96418 strcpy(info.name, name);
96419
96420 - if (copy_to_user(user, &info, *len) != 0)
96421 + if (copy_to_user(user, &info, len) != 0)
96422 ret = -EFAULT;
96423 else
96424 ret = 0;
96425 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
96426
96427 switch (cmd) {
96428 case IP6T_SO_GET_INFO:
96429 - ret = get_info(sock_net(sk), user, len, 1);
96430 + ret = get_info(sock_net(sk), user, *len, 1);
96431 break;
96432 case IP6T_SO_GET_ENTRIES:
96433 ret = compat_get_entries(sock_net(sk), user, len);
96434 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
96435
96436 switch (cmd) {
96437 case IP6T_SO_GET_INFO:
96438 - ret = get_info(sock_net(sk), user, len, 0);
96439 + ret = get_info(sock_net(sk), user, *len, 0);
96440 break;
96441
96442 case IP6T_SO_GET_ENTRIES:
96443 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
96444 index 253566a..9fa50c7 100644
96445 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
96446 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
96447 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
96448
96449 static int nf_ct_frag6_sysctl_register(struct net *net)
96450 {
96451 - struct ctl_table *table;
96452 + ctl_table_no_const *table = NULL;
96453 struct ctl_table_header *hdr;
96454
96455 - table = nf_ct_frag6_sysctl_table;
96456 if (!net_eq(net, &init_net)) {
96457 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
96458 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
96459 GFP_KERNEL);
96460 if (table == NULL)
96461 goto err_alloc;
96462 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
96463 table[0].data = &net->nf_frag.frags.timeout;
96464 table[1].data = &net->nf_frag.frags.low_thresh;
96465 table[2].data = &net->nf_frag.frags.high_thresh;
96466 - }
96467 -
96468 - hdr = register_net_sysctl(net, "net/netfilter", table);
96469 + hdr = register_net_sysctl(net, "net/netfilter", table);
96470 + } else
96471 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
96472 if (hdr == NULL)
96473 goto err_reg;
96474
96475 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
96476 return 0;
96477
96478 err_reg:
96479 - if (!net_eq(net, &init_net))
96480 - kfree(table);
96481 + kfree(table);
96482 err_alloc:
96483 return -ENOMEM;
96484 }
96485 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
96486 index 827f795..7e28e82 100644
96487 --- a/net/ipv6/output_core.c
96488 +++ b/net/ipv6/output_core.c
96489 @@ -9,8 +9,8 @@
96490
96491 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
96492 {
96493 - static atomic_t ipv6_fragmentation_id;
96494 - int old, new;
96495 + static atomic_unchecked_t ipv6_fragmentation_id;
96496 + int id;
96497
96498 #if IS_ENABLED(CONFIG_IPV6)
96499 if (rt && !(rt->dst.flags & DST_NOPEER)) {
96500 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
96501 }
96502 }
96503 #endif
96504 - do {
96505 - old = atomic_read(&ipv6_fragmentation_id);
96506 - new = old + 1;
96507 - if (!new)
96508 - new = 1;
96509 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
96510 - fhdr->identification = htonl(new);
96511 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
96512 + if (!id)
96513 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
96514 + fhdr->identification = htonl(id);
96515 }
96516 EXPORT_SYMBOL(ipv6_select_ident);
96517
96518 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
96519 index 7856e96..75ebc7f 100644
96520 --- a/net/ipv6/ping.c
96521 +++ b/net/ipv6/ping.c
96522 @@ -246,6 +246,22 @@ static struct pernet_operations ping_v6_net_ops = {
96523 };
96524 #endif
96525
96526 +static struct pingv6_ops real_pingv6_ops = {
96527 + .ipv6_recv_error = ipv6_recv_error,
96528 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
96529 + .icmpv6_err_convert = icmpv6_err_convert,
96530 + .ipv6_icmp_error = ipv6_icmp_error,
96531 + .ipv6_chk_addr = ipv6_chk_addr,
96532 +};
96533 +
96534 +static struct pingv6_ops dummy_pingv6_ops = {
96535 + .ipv6_recv_error = dummy_ipv6_recv_error,
96536 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
96537 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
96538 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
96539 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
96540 +};
96541 +
96542 int __init pingv6_init(void)
96543 {
96544 #ifdef CONFIG_PROC_FS
96545 @@ -253,11 +269,7 @@ int __init pingv6_init(void)
96546 if (ret)
96547 return ret;
96548 #endif
96549 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
96550 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
96551 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
96552 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
96553 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
96554 + pingv6_ops = &real_pingv6_ops;
96555 return inet6_register_protosw(&pingv6_protosw);
96556 }
96557
96558 @@ -266,11 +278,7 @@ int __init pingv6_init(void)
96559 */
96560 void pingv6_exit(void)
96561 {
96562 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
96563 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
96564 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
96565 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
96566 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
96567 + pingv6_ops = &dummy_pingv6_ops;
96568 #ifdef CONFIG_PROC_FS
96569 unregister_pernet_subsys(&ping_v6_net_ops);
96570 #endif
96571 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
96572 index 430067c..4adf088 100644
96573 --- a/net/ipv6/raw.c
96574 +++ b/net/ipv6/raw.c
96575 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
96576 {
96577 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
96578 skb_checksum_complete(skb)) {
96579 - atomic_inc(&sk->sk_drops);
96580 + atomic_inc_unchecked(&sk->sk_drops);
96581 kfree_skb(skb);
96582 return NET_RX_DROP;
96583 }
96584 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
96585 struct raw6_sock *rp = raw6_sk(sk);
96586
96587 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
96588 - atomic_inc(&sk->sk_drops);
96589 + atomic_inc_unchecked(&sk->sk_drops);
96590 kfree_skb(skb);
96591 return NET_RX_DROP;
96592 }
96593 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
96594
96595 if (inet->hdrincl) {
96596 if (skb_checksum_complete(skb)) {
96597 - atomic_inc(&sk->sk_drops);
96598 + atomic_inc_unchecked(&sk->sk_drops);
96599 kfree_skb(skb);
96600 return NET_RX_DROP;
96601 }
96602 @@ -607,7 +607,7 @@ out:
96603 return err;
96604 }
96605
96606 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
96607 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
96608 struct flowi6 *fl6, struct dst_entry **dstp,
96609 unsigned int flags)
96610 {
96611 @@ -920,12 +920,15 @@ do_confirm:
96612 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
96613 char __user *optval, int optlen)
96614 {
96615 + struct icmp6_filter filter;
96616 +
96617 switch (optname) {
96618 case ICMPV6_FILTER:
96619 if (optlen > sizeof(struct icmp6_filter))
96620 optlen = sizeof(struct icmp6_filter);
96621 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
96622 + if (copy_from_user(&filter, optval, optlen))
96623 return -EFAULT;
96624 + raw6_sk(sk)->filter = filter;
96625 return 0;
96626 default:
96627 return -ENOPROTOOPT;
96628 @@ -938,6 +941,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
96629 char __user *optval, int __user *optlen)
96630 {
96631 int len;
96632 + struct icmp6_filter filter;
96633
96634 switch (optname) {
96635 case ICMPV6_FILTER:
96636 @@ -949,7 +953,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
96637 len = sizeof(struct icmp6_filter);
96638 if (put_user(len, optlen))
96639 return -EFAULT;
96640 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
96641 + filter = raw6_sk(sk)->filter;
96642 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
96643 return -EFAULT;
96644 return 0;
96645 default:
96646 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
96647 index 1aeb473..bea761c 100644
96648 --- a/net/ipv6/reassembly.c
96649 +++ b/net/ipv6/reassembly.c
96650 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
96651
96652 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
96653 {
96654 - struct ctl_table *table;
96655 + ctl_table_no_const *table = NULL;
96656 struct ctl_table_header *hdr;
96657
96658 - table = ip6_frags_ns_ctl_table;
96659 if (!net_eq(net, &init_net)) {
96660 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
96661 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
96662 if (table == NULL)
96663 goto err_alloc;
96664
96665 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
96666 /* Don't export sysctls to unprivileged users */
96667 if (net->user_ns != &init_user_ns)
96668 table[0].procname = NULL;
96669 - }
96670 + hdr = register_net_sysctl(net, "net/ipv6", table);
96671 + } else
96672 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
96673
96674 - hdr = register_net_sysctl(net, "net/ipv6", table);
96675 if (hdr == NULL)
96676 goto err_reg;
96677
96678 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
96679 return 0;
96680
96681 err_reg:
96682 - if (!net_eq(net, &init_net))
96683 - kfree(table);
96684 + kfree(table);
96685 err_alloc:
96686 return -ENOMEM;
96687 }
96688 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
96689 index 0accb13..f793130 100644
96690 --- a/net/ipv6/route.c
96691 +++ b/net/ipv6/route.c
96692 @@ -3003,7 +3003,7 @@ struct ctl_table ipv6_route_table_template[] = {
96693
96694 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
96695 {
96696 - struct ctl_table *table;
96697 + ctl_table_no_const *table;
96698
96699 table = kmemdup(ipv6_route_table_template,
96700 sizeof(ipv6_route_table_template),
96701 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
96702 index b433884..3875266 100644
96703 --- a/net/ipv6/sit.c
96704 +++ b/net/ipv6/sit.c
96705 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
96706 static void ipip6_dev_free(struct net_device *dev);
96707 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
96708 __be32 *v4dst);
96709 -static struct rtnl_link_ops sit_link_ops __read_mostly;
96710 +static struct rtnl_link_ops sit_link_ops;
96711
96712 static int sit_net_id __read_mostly;
96713 struct sit_net {
96714 @@ -1603,7 +1603,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
96715 unregister_netdevice_queue(dev, head);
96716 }
96717
96718 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
96719 +static struct rtnl_link_ops sit_link_ops = {
96720 .kind = "sit",
96721 .maxtype = IFLA_IPTUN_MAX,
96722 .policy = ipip6_policy,
96723 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
96724 index 107b2f1..72741a9 100644
96725 --- a/net/ipv6/sysctl_net_ipv6.c
96726 +++ b/net/ipv6/sysctl_net_ipv6.c
96727 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
96728
96729 static int __net_init ipv6_sysctl_net_init(struct net *net)
96730 {
96731 - struct ctl_table *ipv6_table;
96732 + ctl_table_no_const *ipv6_table;
96733 struct ctl_table *ipv6_route_table;
96734 struct ctl_table *ipv6_icmp_table;
96735 int err;
96736 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
96737 index 5c71501..7e8d5d3 100644
96738 --- a/net/ipv6/tcp_ipv6.c
96739 +++ b/net/ipv6/tcp_ipv6.c
96740 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
96741 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
96742 }
96743
96744 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96745 +extern int grsec_enable_blackhole;
96746 +#endif
96747 +
96748 static void tcp_v6_hash(struct sock *sk)
96749 {
96750 if (sk->sk_state != TCP_CLOSE) {
96751 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
96752 return 0;
96753
96754 reset:
96755 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96756 + if (!grsec_enable_blackhole)
96757 +#endif
96758 tcp_v6_send_reset(sk, skb);
96759 discard:
96760 if (opt_skb)
96761 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
96762 TCP_SKB_CB(skb)->sacked = 0;
96763
96764 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
96765 - if (!sk)
96766 + if (!sk) {
96767 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96768 + ret = 1;
96769 +#endif
96770 goto no_tcp_socket;
96771 + }
96772
96773 process:
96774 - if (sk->sk_state == TCP_TIME_WAIT)
96775 + if (sk->sk_state == TCP_TIME_WAIT) {
96776 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96777 + ret = 2;
96778 +#endif
96779 goto do_time_wait;
96780 + }
96781
96782 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
96783 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
96784 @@ -1536,6 +1551,10 @@ csum_error:
96785 bad_packet:
96786 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
96787 } else {
96788 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96789 + if (!grsec_enable_blackhole || (ret == 1 &&
96790 + (skb->dev->flags & IFF_LOOPBACK)))
96791 +#endif
96792 tcp_v6_send_reset(NULL, skb);
96793 }
96794
96795 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
96796 index 3d2758d..626c422 100644
96797 --- a/net/ipv6/udp.c
96798 +++ b/net/ipv6/udp.c
96799 @@ -53,6 +53,10 @@
96800 #include <trace/events/skb.h>
96801 #include "udp_impl.h"
96802
96803 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96804 +extern int grsec_enable_blackhole;
96805 +#endif
96806 +
96807 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
96808 {
96809 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
96810 @@ -417,7 +421,7 @@ try_again:
96811 if (unlikely(err)) {
96812 trace_kfree_skb(skb, udpv6_recvmsg);
96813 if (!peeked) {
96814 - atomic_inc(&sk->sk_drops);
96815 + atomic_inc_unchecked(&sk->sk_drops);
96816 if (is_udp4)
96817 UDP_INC_STATS_USER(sock_net(sk),
96818 UDP_MIB_INERRORS,
96819 @@ -665,7 +669,7 @@ csum_error:
96820 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
96821 drop:
96822 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
96823 - atomic_inc(&sk->sk_drops);
96824 + atomic_inc_unchecked(&sk->sk_drops);
96825 kfree_skb(skb);
96826 return -1;
96827 }
96828 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
96829 if (likely(skb1 == NULL))
96830 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
96831 if (!skb1) {
96832 - atomic_inc(&sk->sk_drops);
96833 + atomic_inc_unchecked(&sk->sk_drops);
96834 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
96835 IS_UDPLITE(sk));
96836 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
96837 @@ -863,6 +867,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
96838 goto csum_error;
96839
96840 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
96841 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96842 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
96843 +#endif
96844 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
96845
96846 kfree_skb(skb);
96847 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
96848 index 550b195..6acea83 100644
96849 --- a/net/ipv6/xfrm6_policy.c
96850 +++ b/net/ipv6/xfrm6_policy.c
96851 @@ -212,11 +212,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
96852 }
96853 }
96854
96855 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
96856 +static int xfrm6_garbage_collect(struct dst_ops *ops)
96857 {
96858 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
96859
96860 - xfrm6_policy_afinfo.garbage_collect(net);
96861 + xfrm_garbage_collect_deferred(net);
96862 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
96863 }
96864
96865 @@ -329,19 +329,19 @@ static struct ctl_table xfrm6_policy_table[] = {
96866
96867 static int __net_init xfrm6_net_init(struct net *net)
96868 {
96869 - struct ctl_table *table;
96870 + ctl_table_no_const *table = NULL;
96871 struct ctl_table_header *hdr;
96872
96873 - table = xfrm6_policy_table;
96874 if (!net_eq(net, &init_net)) {
96875 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
96876 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
96877 if (!table)
96878 goto err_alloc;
96879
96880 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
96881 - }
96882 + hdr = register_net_sysctl(net, "net/ipv6", table);
96883 + } else
96884 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
96885
96886 - hdr = register_net_sysctl(net, "net/ipv6", table);
96887 if (!hdr)
96888 goto err_reg;
96889
96890 @@ -349,8 +349,7 @@ static int __net_init xfrm6_net_init(struct net *net)
96891 return 0;
96892
96893 err_reg:
96894 - if (!net_eq(net, &init_net))
96895 - kfree(table);
96896 + kfree(table);
96897 err_alloc:
96898 return -ENOMEM;
96899 }
96900 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
96901 index 41ac7938..75e3bb1 100644
96902 --- a/net/irda/ircomm/ircomm_tty.c
96903 +++ b/net/irda/ircomm/ircomm_tty.c
96904 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96905 add_wait_queue(&port->open_wait, &wait);
96906
96907 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
96908 - __FILE__, __LINE__, tty->driver->name, port->count);
96909 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96910
96911 spin_lock_irqsave(&port->lock, flags);
96912 if (!tty_hung_up_p(filp))
96913 - port->count--;
96914 + atomic_dec(&port->count);
96915 port->blocked_open++;
96916 spin_unlock_irqrestore(&port->lock, flags);
96917
96918 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96919 }
96920
96921 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
96922 - __FILE__, __LINE__, tty->driver->name, port->count);
96923 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96924
96925 schedule();
96926 }
96927 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96928
96929 spin_lock_irqsave(&port->lock, flags);
96930 if (!tty_hung_up_p(filp))
96931 - port->count++;
96932 + atomic_inc(&port->count);
96933 port->blocked_open--;
96934 spin_unlock_irqrestore(&port->lock, flags);
96935
96936 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
96937 - __FILE__, __LINE__, tty->driver->name, port->count);
96938 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96939
96940 if (!retval)
96941 port->flags |= ASYNC_NORMAL_ACTIVE;
96942 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
96943
96944 /* ++ is not atomic, so this should be protected - Jean II */
96945 spin_lock_irqsave(&self->port.lock, flags);
96946 - self->port.count++;
96947 + atomic_inc(&self->port.count);
96948 spin_unlock_irqrestore(&self->port.lock, flags);
96949 tty_port_tty_set(&self->port, tty);
96950
96951 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
96952 - self->line, self->port.count);
96953 + self->line, atomic_read(&self->port.count));
96954
96955 /* Not really used by us, but lets do it anyway */
96956 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
96957 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
96958 tty_kref_put(port->tty);
96959 }
96960 port->tty = NULL;
96961 - port->count = 0;
96962 + atomic_set(&port->count, 0);
96963 spin_unlock_irqrestore(&port->lock, flags);
96964
96965 wake_up_interruptible(&port->open_wait);
96966 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
96967 seq_putc(m, '\n');
96968
96969 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
96970 - seq_printf(m, "Open count: %d\n", self->port.count);
96971 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
96972 seq_printf(m, "Max data size: %d\n", self->max_data_size);
96973 seq_printf(m, "Max header size: %d\n", self->max_header_size);
96974
96975 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
96976 index c4b7218..3e83259 100644
96977 --- a/net/iucv/af_iucv.c
96978 +++ b/net/iucv/af_iucv.c
96979 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
96980
96981 write_lock_bh(&iucv_sk_list.lock);
96982
96983 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
96984 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
96985 while (__iucv_get_sock_by_name(name)) {
96986 sprintf(name, "%08x",
96987 - atomic_inc_return(&iucv_sk_list.autobind_name));
96988 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
96989 }
96990
96991 write_unlock_bh(&iucv_sk_list.lock);
96992 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
96993 index cd5b8ec..f205e6b 100644
96994 --- a/net/iucv/iucv.c
96995 +++ b/net/iucv/iucv.c
96996 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
96997 return NOTIFY_OK;
96998 }
96999
97000 -static struct notifier_block __refdata iucv_cpu_notifier = {
97001 +static struct notifier_block iucv_cpu_notifier = {
97002 .notifier_call = iucv_cpu_notify,
97003 };
97004
97005 diff --git a/net/key/af_key.c b/net/key/af_key.c
97006 index 545f047..9757a9d 100644
97007 --- a/net/key/af_key.c
97008 +++ b/net/key/af_key.c
97009 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
97010 static u32 get_acqseq(void)
97011 {
97012 u32 res;
97013 - static atomic_t acqseq;
97014 + static atomic_unchecked_t acqseq;
97015
97016 do {
97017 - res = atomic_inc_return(&acqseq);
97018 + res = atomic_inc_return_unchecked(&acqseq);
97019 } while (!res);
97020 return res;
97021 }
97022 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
97023 index 9903ee5..18978be 100644
97024 --- a/net/mac80211/cfg.c
97025 +++ b/net/mac80211/cfg.c
97026 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
97027 ret = ieee80211_vif_use_channel(sdata, chandef,
97028 IEEE80211_CHANCTX_EXCLUSIVE);
97029 }
97030 - } else if (local->open_count == local->monitors) {
97031 + } else if (local_read(&local->open_count) == local->monitors) {
97032 local->_oper_chandef = *chandef;
97033 ieee80211_hw_config(local, 0);
97034 }
97035 @@ -3124,7 +3124,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
97036 else
97037 local->probe_req_reg--;
97038
97039 - if (!local->open_count)
97040 + if (!local_read(&local->open_count))
97041 break;
97042
97043 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
97044 @@ -3587,8 +3587,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
97045 if (chanctx_conf) {
97046 *chandef = chanctx_conf->def;
97047 ret = 0;
97048 - } else if (local->open_count > 0 &&
97049 - local->open_count == local->monitors &&
97050 + } else if (local_read(&local->open_count) > 0 &&
97051 + local_read(&local->open_count) == local->monitors &&
97052 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
97053 if (local->use_chanctx)
97054 *chandef = local->monitor_chandef;
97055 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
97056 index 611abfc..8c2c7e4 100644
97057 --- a/net/mac80211/ieee80211_i.h
97058 +++ b/net/mac80211/ieee80211_i.h
97059 @@ -28,6 +28,7 @@
97060 #include <net/ieee80211_radiotap.h>
97061 #include <net/cfg80211.h>
97062 #include <net/mac80211.h>
97063 +#include <asm/local.h>
97064 #include "key.h"
97065 #include "sta_info.h"
97066 #include "debug.h"
97067 @@ -945,7 +946,7 @@ struct ieee80211_local {
97068 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
97069 spinlock_t queue_stop_reason_lock;
97070
97071 - int open_count;
97072 + local_t open_count;
97073 int monitors, cooked_mntrs;
97074 /* number of interfaces with corresponding FIF_ flags */
97075 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
97076 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
97077 index fcecd63..a404454 100644
97078 --- a/net/mac80211/iface.c
97079 +++ b/net/mac80211/iface.c
97080 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
97081 break;
97082 }
97083
97084 - if (local->open_count == 0) {
97085 + if (local_read(&local->open_count) == 0) {
97086 res = drv_start(local);
97087 if (res)
97088 goto err_del_bss;
97089 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
97090 res = drv_add_interface(local, sdata);
97091 if (res)
97092 goto err_stop;
97093 - } else if (local->monitors == 0 && local->open_count == 0) {
97094 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
97095 res = ieee80211_add_virtual_monitor(local);
97096 if (res)
97097 goto err_stop;
97098 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
97099 atomic_inc(&local->iff_promiscs);
97100
97101 if (coming_up)
97102 - local->open_count++;
97103 + local_inc(&local->open_count);
97104
97105 if (hw_reconf_flags)
97106 ieee80211_hw_config(local, hw_reconf_flags);
97107 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
97108 err_del_interface:
97109 drv_remove_interface(local, sdata);
97110 err_stop:
97111 - if (!local->open_count)
97112 + if (!local_read(&local->open_count))
97113 drv_stop(local);
97114 err_del_bss:
97115 sdata->bss = NULL;
97116 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
97117 }
97118
97119 if (going_down)
97120 - local->open_count--;
97121 + local_dec(&local->open_count);
97122
97123 switch (sdata->vif.type) {
97124 case NL80211_IFTYPE_AP_VLAN:
97125 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
97126 }
97127 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
97128
97129 - if (local->open_count == 0)
97130 + if (local_read(&local->open_count) == 0)
97131 ieee80211_clear_tx_pending(local);
97132
97133 /*
97134 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
97135
97136 ieee80211_recalc_ps(local, -1);
97137
97138 - if (local->open_count == 0) {
97139 + if (local_read(&local->open_count) == 0) {
97140 ieee80211_stop_device(local);
97141
97142 /* no reconfiguring after stop! */
97143 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
97144 ieee80211_configure_filter(local);
97145 ieee80211_hw_config(local, hw_reconf_flags);
97146
97147 - if (local->monitors == local->open_count)
97148 + if (local->monitors == local_read(&local->open_count))
97149 ieee80211_add_virtual_monitor(local);
97150 }
97151
97152 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
97153 index e765f77..dfd72e7 100644
97154 --- a/net/mac80211/main.c
97155 +++ b/net/mac80211/main.c
97156 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
97157 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
97158 IEEE80211_CONF_CHANGE_POWER);
97159
97160 - if (changed && local->open_count) {
97161 + if (changed && local_read(&local->open_count)) {
97162 ret = drv_config(local, changed);
97163 /*
97164 * Goal:
97165 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
97166 index 3401262..d5cd68d 100644
97167 --- a/net/mac80211/pm.c
97168 +++ b/net/mac80211/pm.c
97169 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
97170 struct ieee80211_sub_if_data *sdata;
97171 struct sta_info *sta;
97172
97173 - if (!local->open_count)
97174 + if (!local_read(&local->open_count))
97175 goto suspend;
97176
97177 ieee80211_scan_cancel(local);
97178 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
97179 cancel_work_sync(&local->dynamic_ps_enable_work);
97180 del_timer_sync(&local->dynamic_ps_timer);
97181
97182 - local->wowlan = wowlan && local->open_count;
97183 + local->wowlan = wowlan && local_read(&local->open_count);
97184 if (local->wowlan) {
97185 int err = drv_suspend(local, wowlan);
97186 if (err < 0) {
97187 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
97188 WARN_ON(!list_empty(&local->chanctx_list));
97189
97190 /* stop hardware - this must stop RX */
97191 - if (local->open_count)
97192 + if (local_read(&local->open_count))
97193 ieee80211_stop_device(local);
97194
97195 suspend:
97196 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
97197 index e126605..73d2c39 100644
97198 --- a/net/mac80211/rate.c
97199 +++ b/net/mac80211/rate.c
97200 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
97201
97202 ASSERT_RTNL();
97203
97204 - if (local->open_count)
97205 + if (local_read(&local->open_count))
97206 return -EBUSY;
97207
97208 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
97209 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
97210 index c97a065..ff61928 100644
97211 --- a/net/mac80211/rc80211_pid_debugfs.c
97212 +++ b/net/mac80211/rc80211_pid_debugfs.c
97213 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
97214
97215 spin_unlock_irqrestore(&events->lock, status);
97216
97217 - if (copy_to_user(buf, pb, p))
97218 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
97219 return -EFAULT;
97220
97221 return p;
97222 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
97223 index 69e4ef5..e8e4b92 100644
97224 --- a/net/mac80211/util.c
97225 +++ b/net/mac80211/util.c
97226 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
97227 }
97228 #endif
97229 /* everything else happens only if HW was up & running */
97230 - if (!local->open_count)
97231 + if (!local_read(&local->open_count))
97232 goto wake_up;
97233
97234 /*
97235 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
97236 local->in_reconfig = false;
97237 barrier();
97238
97239 - if (local->monitors == local->open_count && local->monitors > 0)
97240 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
97241 ieee80211_add_virtual_monitor(local);
97242
97243 /*
97244 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
97245 index 6e839b6..002a233 100644
97246 --- a/net/netfilter/Kconfig
97247 +++ b/net/netfilter/Kconfig
97248 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
97249
97250 To compile it as a module, choose M here. If unsure, say N.
97251
97252 +config NETFILTER_XT_MATCH_GRADM
97253 + tristate '"gradm" match support'
97254 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
97255 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
97256 + ---help---
97257 + The gradm match allows to match on grsecurity RBAC being enabled.
97258 + It is useful when iptables rules are applied early on bootup to
97259 + prevent connections to the machine (except from a trusted host)
97260 + while the RBAC system is disabled.
97261 +
97262 config NETFILTER_XT_MATCH_HASHLIMIT
97263 tristate '"hashlimit" match support'
97264 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
97265 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
97266 index c3a0a12..90b587f 100644
97267 --- a/net/netfilter/Makefile
97268 +++ b/net/netfilter/Makefile
97269 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
97270 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
97271 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
97272 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
97273 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
97274 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
97275 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
97276 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
97277 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
97278 index f2e30fb..f131862 100644
97279 --- a/net/netfilter/ipset/ip_set_core.c
97280 +++ b/net/netfilter/ipset/ip_set_core.c
97281 @@ -1819,7 +1819,7 @@ done:
97282 return ret;
97283 }
97284
97285 -static struct nf_sockopt_ops so_set __read_mostly = {
97286 +static struct nf_sockopt_ops so_set = {
97287 .pf = PF_INET,
97288 .get_optmin = SO_IP_SET,
97289 .get_optmax = SO_IP_SET + 1,
97290 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
97291 index 4c8e5c0..5a79b4d 100644
97292 --- a/net/netfilter/ipvs/ip_vs_conn.c
97293 +++ b/net/netfilter/ipvs/ip_vs_conn.c
97294 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
97295 /* Increase the refcnt counter of the dest */
97296 ip_vs_dest_hold(dest);
97297
97298 - conn_flags = atomic_read(&dest->conn_flags);
97299 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
97300 if (cp->protocol != IPPROTO_UDP)
97301 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
97302 flags = cp->flags;
97303 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
97304
97305 cp->control = NULL;
97306 atomic_set(&cp->n_control, 0);
97307 - atomic_set(&cp->in_pkts, 0);
97308 + atomic_set_unchecked(&cp->in_pkts, 0);
97309
97310 cp->packet_xmit = NULL;
97311 cp->app = NULL;
97312 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
97313
97314 /* Don't drop the entry if its number of incoming packets is not
97315 located in [0, 8] */
97316 - i = atomic_read(&cp->in_pkts);
97317 + i = atomic_read_unchecked(&cp->in_pkts);
97318 if (i > 8 || i < 0) return 0;
97319
97320 if (!todrop_rate[i]) return 0;
97321 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
97322 index 3581736..c0453e9 100644
97323 --- a/net/netfilter/ipvs/ip_vs_core.c
97324 +++ b/net/netfilter/ipvs/ip_vs_core.c
97325 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
97326 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
97327 /* do not touch skb anymore */
97328
97329 - atomic_inc(&cp->in_pkts);
97330 + atomic_inc_unchecked(&cp->in_pkts);
97331 ip_vs_conn_put(cp);
97332 return ret;
97333 }
97334 @@ -1706,7 +1706,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
97335 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
97336 pkts = sysctl_sync_threshold(ipvs);
97337 else
97338 - pkts = atomic_add_return(1, &cp->in_pkts);
97339 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
97340
97341 if (ipvs->sync_state & IP_VS_STATE_MASTER)
97342 ip_vs_sync_conn(net, cp, pkts);
97343 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
97344 index a3df9bd..895ae09 100644
97345 --- a/net/netfilter/ipvs/ip_vs_ctl.c
97346 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
97347 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
97348 */
97349 ip_vs_rs_hash(ipvs, dest);
97350 }
97351 - atomic_set(&dest->conn_flags, conn_flags);
97352 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
97353
97354 /* bind the service */
97355 old_svc = rcu_dereference_protected(dest->svc, 1);
97356 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
97357 * align with netns init in ip_vs_control_net_init()
97358 */
97359
97360 -static struct ctl_table vs_vars[] = {
97361 +static ctl_table_no_const vs_vars[] __read_only = {
97362 {
97363 .procname = "amemthresh",
97364 .maxlen = sizeof(int),
97365 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
97366 " %-7s %-6d %-10d %-10d\n",
97367 &dest->addr.in6,
97368 ntohs(dest->port),
97369 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
97370 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
97371 atomic_read(&dest->weight),
97372 atomic_read(&dest->activeconns),
97373 atomic_read(&dest->inactconns));
97374 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
97375 "%-7s %-6d %-10d %-10d\n",
97376 ntohl(dest->addr.ip),
97377 ntohs(dest->port),
97378 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
97379 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
97380 atomic_read(&dest->weight),
97381 atomic_read(&dest->activeconns),
97382 atomic_read(&dest->inactconns));
97383 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
97384
97385 entry.addr = dest->addr.ip;
97386 entry.port = dest->port;
97387 - entry.conn_flags = atomic_read(&dest->conn_flags);
97388 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
97389 entry.weight = atomic_read(&dest->weight);
97390 entry.u_threshold = dest->u_threshold;
97391 entry.l_threshold = dest->l_threshold;
97392 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
97393 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
97394 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
97395 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
97396 - (atomic_read(&dest->conn_flags) &
97397 + (atomic_read_unchecked(&dest->conn_flags) &
97398 IP_VS_CONN_F_FWD_MASK)) ||
97399 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
97400 atomic_read(&dest->weight)) ||
97401 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
97402 {
97403 int idx;
97404 struct netns_ipvs *ipvs = net_ipvs(net);
97405 - struct ctl_table *tbl;
97406 + ctl_table_no_const *tbl;
97407
97408 atomic_set(&ipvs->dropentry, 0);
97409 spin_lock_init(&ipvs->dropentry_lock);
97410 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
97411 index eff13c9..c1aab3e 100644
97412 --- a/net/netfilter/ipvs/ip_vs_lblc.c
97413 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
97414 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
97415 * IPVS LBLC sysctl table
97416 */
97417 #ifdef CONFIG_SYSCTL
97418 -static struct ctl_table vs_vars_table[] = {
97419 +static ctl_table_no_const vs_vars_table[] __read_only = {
97420 {
97421 .procname = "lblc_expiration",
97422 .data = NULL,
97423 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
97424 index 0b85500..8513fa5 100644
97425 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
97426 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
97427 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
97428 * IPVS LBLCR sysctl table
97429 */
97430
97431 -static struct ctl_table vs_vars_table[] = {
97432 +static ctl_table_no_const vs_vars_table[] __read_only = {
97433 {
97434 .procname = "lblcr_expiration",
97435 .data = NULL,
97436 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
97437 index f448471..995f131 100644
97438 --- a/net/netfilter/ipvs/ip_vs_sync.c
97439 +++ b/net/netfilter/ipvs/ip_vs_sync.c
97440 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
97441 cp = cp->control;
97442 if (cp) {
97443 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
97444 - pkts = atomic_add_return(1, &cp->in_pkts);
97445 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
97446 else
97447 pkts = sysctl_sync_threshold(ipvs);
97448 ip_vs_sync_conn(net, cp->control, pkts);
97449 @@ -771,7 +771,7 @@ control:
97450 if (!cp)
97451 return;
97452 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
97453 - pkts = atomic_add_return(1, &cp->in_pkts);
97454 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
97455 else
97456 pkts = sysctl_sync_threshold(ipvs);
97457 goto sloop;
97458 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
97459
97460 if (opt)
97461 memcpy(&cp->in_seq, opt, sizeof(*opt));
97462 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
97463 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
97464 cp->state = state;
97465 cp->old_state = cp->state;
97466 /*
97467 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
97468 index c47444e..b0961c6 100644
97469 --- a/net/netfilter/ipvs/ip_vs_xmit.c
97470 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
97471 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
97472 else
97473 rc = NF_ACCEPT;
97474 /* do not touch skb anymore */
97475 - atomic_inc(&cp->in_pkts);
97476 + atomic_inc_unchecked(&cp->in_pkts);
97477 goto out;
97478 }
97479
97480 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
97481 else
97482 rc = NF_ACCEPT;
97483 /* do not touch skb anymore */
97484 - atomic_inc(&cp->in_pkts);
97485 + atomic_inc_unchecked(&cp->in_pkts);
97486 goto out;
97487 }
97488
97489 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
97490 index 2d3030a..7ba1c0a 100644
97491 --- a/net/netfilter/nf_conntrack_acct.c
97492 +++ b/net/netfilter/nf_conntrack_acct.c
97493 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
97494 #ifdef CONFIG_SYSCTL
97495 static int nf_conntrack_acct_init_sysctl(struct net *net)
97496 {
97497 - struct ctl_table *table;
97498 + ctl_table_no_const *table;
97499
97500 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
97501 GFP_KERNEL);
97502 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
97503 index 5d892fe..d2fc9d8 100644
97504 --- a/net/netfilter/nf_conntrack_core.c
97505 +++ b/net/netfilter/nf_conntrack_core.c
97506 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
97507 #define DYING_NULLS_VAL ((1<<30)+1)
97508 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
97509
97510 +#ifdef CONFIG_GRKERNSEC_HIDESYM
97511 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
97512 +#endif
97513 +
97514 int nf_conntrack_init_net(struct net *net)
97515 {
97516 int ret;
97517 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
97518 goto err_stat;
97519 }
97520
97521 +#ifdef CONFIG_GRKERNSEC_HIDESYM
97522 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
97523 +#else
97524 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
97525 +#endif
97526 if (!net->ct.slabname) {
97527 ret = -ENOMEM;
97528 goto err_slabname;
97529 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
97530 index 1df1761..ce8b88a 100644
97531 --- a/net/netfilter/nf_conntrack_ecache.c
97532 +++ b/net/netfilter/nf_conntrack_ecache.c
97533 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
97534 #ifdef CONFIG_SYSCTL
97535 static int nf_conntrack_event_init_sysctl(struct net *net)
97536 {
97537 - struct ctl_table *table;
97538 + ctl_table_no_const *table;
97539
97540 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
97541 GFP_KERNEL);
97542 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
97543 index 974a2a4..52cc6ff 100644
97544 --- a/net/netfilter/nf_conntrack_helper.c
97545 +++ b/net/netfilter/nf_conntrack_helper.c
97546 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
97547
97548 static int nf_conntrack_helper_init_sysctl(struct net *net)
97549 {
97550 - struct ctl_table *table;
97551 + ctl_table_no_const *table;
97552
97553 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
97554 GFP_KERNEL);
97555 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
97556 index ce30041..3861b5d 100644
97557 --- a/net/netfilter/nf_conntrack_proto.c
97558 +++ b/net/netfilter/nf_conntrack_proto.c
97559 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
97560
97561 static void
97562 nf_ct_unregister_sysctl(struct ctl_table_header **header,
97563 - struct ctl_table **table,
97564 + ctl_table_no_const **table,
97565 unsigned int users)
97566 {
97567 if (users > 0)
97568 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
97569 index a99b6c3..cb372f9 100644
97570 --- a/net/netfilter/nf_conntrack_proto_dccp.c
97571 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
97572 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
97573 const char *msg;
97574 u_int8_t state;
97575
97576 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
97577 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
97578 BUG_ON(dh == NULL);
97579
97580 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
97581 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
97582 out_invalid:
97583 if (LOG_INVALID(net, IPPROTO_DCCP))
97584 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
97585 - NULL, msg);
97586 + NULL, "%s", msg);
97587 return false;
97588 }
97589
97590 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
97591 u_int8_t type, old_state, new_state;
97592 enum ct_dccp_roles role;
97593
97594 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
97595 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
97596 BUG_ON(dh == NULL);
97597 type = dh->dccph_type;
97598
97599 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
97600 unsigned int cscov;
97601 const char *msg;
97602
97603 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
97604 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
97605 if (dh == NULL) {
97606 msg = "nf_ct_dccp: short packet ";
97607 goto out_invalid;
97608 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
97609
97610 out_invalid:
97611 if (LOG_INVALID(net, IPPROTO_DCCP))
97612 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
97613 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
97614 return -NF_ACCEPT;
97615 }
97616
97617 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
97618 index f641751..d3c5b51 100644
97619 --- a/net/netfilter/nf_conntrack_standalone.c
97620 +++ b/net/netfilter/nf_conntrack_standalone.c
97621 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
97622
97623 static int nf_conntrack_standalone_init_sysctl(struct net *net)
97624 {
97625 - struct ctl_table *table;
97626 + ctl_table_no_const *table;
97627
97628 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
97629 GFP_KERNEL);
97630 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
97631 index 902fb0a..87f7fdb 100644
97632 --- a/net/netfilter/nf_conntrack_timestamp.c
97633 +++ b/net/netfilter/nf_conntrack_timestamp.c
97634 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
97635 #ifdef CONFIG_SYSCTL
97636 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
97637 {
97638 - struct ctl_table *table;
97639 + ctl_table_no_const *table;
97640
97641 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
97642 GFP_KERNEL);
97643 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
97644 index 85296d4..8becdec 100644
97645 --- a/net/netfilter/nf_log.c
97646 +++ b/net/netfilter/nf_log.c
97647 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
97648
97649 #ifdef CONFIG_SYSCTL
97650 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
97651 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
97652 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
97653
97654 static int nf_log_proc_dostring(struct ctl_table *table, int write,
97655 void __user *buffer, size_t *lenp, loff_t *ppos)
97656 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
97657 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
97658 mutex_unlock(&nf_log_mutex);
97659 } else {
97660 + ctl_table_no_const nf_log_table = *table;
97661 +
97662 mutex_lock(&nf_log_mutex);
97663 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
97664 lockdep_is_held(&nf_log_mutex));
97665 if (!logger)
97666 - table->data = "NONE";
97667 + nf_log_table.data = "NONE";
97668 else
97669 - table->data = logger->name;
97670 - r = proc_dostring(table, write, buffer, lenp, ppos);
97671 + nf_log_table.data = logger->name;
97672 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
97673 mutex_unlock(&nf_log_mutex);
97674 }
97675
97676 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
97677 index f042ae5..30ea486 100644
97678 --- a/net/netfilter/nf_sockopt.c
97679 +++ b/net/netfilter/nf_sockopt.c
97680 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
97681 }
97682 }
97683
97684 - list_add(&reg->list, &nf_sockopts);
97685 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
97686 out:
97687 mutex_unlock(&nf_sockopt_mutex);
97688 return ret;
97689 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
97690 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
97691 {
97692 mutex_lock(&nf_sockopt_mutex);
97693 - list_del(&reg->list);
97694 + pax_list_del((struct list_head *)&reg->list);
97695 mutex_unlock(&nf_sockopt_mutex);
97696 }
97697 EXPORT_SYMBOL(nf_unregister_sockopt);
97698 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
97699 index d92cc31..e46f350 100644
97700 --- a/net/netfilter/nfnetlink_log.c
97701 +++ b/net/netfilter/nfnetlink_log.c
97702 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
97703 struct nfnl_log_net {
97704 spinlock_t instances_lock;
97705 struct hlist_head instance_table[INSTANCE_BUCKETS];
97706 - atomic_t global_seq;
97707 + atomic_unchecked_t global_seq;
97708 };
97709
97710 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
97711 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
97712 /* global sequence number */
97713 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
97714 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
97715 - htonl(atomic_inc_return(&log->global_seq))))
97716 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
97717 goto nla_put_failure;
97718
97719 if (data_len) {
97720 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
97721 new file mode 100644
97722 index 0000000..c566332
97723 --- /dev/null
97724 +++ b/net/netfilter/xt_gradm.c
97725 @@ -0,0 +1,51 @@
97726 +/*
97727 + * gradm match for netfilter
97728 + * Copyright © Zbigniew Krzystolik, 2010
97729 + *
97730 + * This program is free software; you can redistribute it and/or modify
97731 + * it under the terms of the GNU General Public License; either version
97732 + * 2 or 3 as published by the Free Software Foundation.
97733 + */
97734 +#include <linux/module.h>
97735 +#include <linux/moduleparam.h>
97736 +#include <linux/skbuff.h>
97737 +#include <linux/netfilter/x_tables.h>
97738 +#include <linux/grsecurity.h>
97739 +#include <linux/netfilter/xt_gradm.h>
97740 +
97741 +static bool
97742 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
97743 +{
97744 + const struct xt_gradm_mtinfo *info = par->matchinfo;
97745 + bool retval = false;
97746 + if (gr_acl_is_enabled())
97747 + retval = true;
97748 + return retval ^ info->invflags;
97749 +}
97750 +
97751 +static struct xt_match gradm_mt_reg __read_mostly = {
97752 + .name = "gradm",
97753 + .revision = 0,
97754 + .family = NFPROTO_UNSPEC,
97755 + .match = gradm_mt,
97756 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
97757 + .me = THIS_MODULE,
97758 +};
97759 +
97760 +static int __init gradm_mt_init(void)
97761 +{
97762 + return xt_register_match(&gradm_mt_reg);
97763 +}
97764 +
97765 +static void __exit gradm_mt_exit(void)
97766 +{
97767 + xt_unregister_match(&gradm_mt_reg);
97768 +}
97769 +
97770 +module_init(gradm_mt_init);
97771 +module_exit(gradm_mt_exit);
97772 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
97773 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
97774 +MODULE_LICENSE("GPL");
97775 +MODULE_ALIAS("ipt_gradm");
97776 +MODULE_ALIAS("ip6t_gradm");
97777 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
97778 index 4fe4fb4..87a89e5 100644
97779 --- a/net/netfilter/xt_statistic.c
97780 +++ b/net/netfilter/xt_statistic.c
97781 @@ -19,7 +19,7 @@
97782 #include <linux/module.h>
97783
97784 struct xt_statistic_priv {
97785 - atomic_t count;
97786 + atomic_unchecked_t count;
97787 } ____cacheline_aligned_in_smp;
97788
97789 MODULE_LICENSE("GPL");
97790 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
97791 break;
97792 case XT_STATISTIC_MODE_NTH:
97793 do {
97794 - oval = atomic_read(&info->master->count);
97795 + oval = atomic_read_unchecked(&info->master->count);
97796 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
97797 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
97798 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
97799 if (nval == 0)
97800 ret = !ret;
97801 break;
97802 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
97803 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
97804 if (info->master == NULL)
97805 return -ENOMEM;
97806 - atomic_set(&info->master->count, info->u.nth.count);
97807 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
97808
97809 return 0;
97810 }
97811 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
97812 index 6135635..5bdc54a 100644
97813 --- a/net/netlink/af_netlink.c
97814 +++ b/net/netlink/af_netlink.c
97815 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
97816 sk->sk_error_report(sk);
97817 }
97818 }
97819 - atomic_inc(&sk->sk_drops);
97820 + atomic_inc_unchecked(&sk->sk_drops);
97821 }
97822
97823 static void netlink_rcv_wake(struct sock *sk)
97824 @@ -2940,7 +2940,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
97825 sk_wmem_alloc_get(s),
97826 nlk->cb_running,
97827 atomic_read(&s->sk_refcnt),
97828 - atomic_read(&s->sk_drops),
97829 + atomic_read_unchecked(&s->sk_drops),
97830 sock_i_ino(s)
97831 );
97832
97833 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
97834 index 0c741ce..f8c8ca7 100644
97835 --- a/net/netlink/genetlink.c
97836 +++ b/net/netlink/genetlink.c
97837 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
97838 goto errout;
97839 }
97840
97841 + pax_open_kernel();
97842 if (ops->dumpit)
97843 - ops->flags |= GENL_CMD_CAP_DUMP;
97844 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
97845 if (ops->doit)
97846 - ops->flags |= GENL_CMD_CAP_DO;
97847 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
97848 if (ops->policy)
97849 - ops->flags |= GENL_CMD_CAP_HASPOL;
97850 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
97851 + pax_close_kernel();
97852
97853 genl_lock_all();
97854 - list_add_tail(&ops->ops_list, &family->ops_list);
97855 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
97856 genl_unlock_all();
97857
97858 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
97859 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
97860 err = 0;
97861 errout:
97862 return err;
97863 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
97864 genl_lock_all();
97865 list_for_each_entry(rc, &family->ops_list, ops_list) {
97866 if (rc == ops) {
97867 - list_del(&ops->ops_list);
97868 + pax_list_del((struct list_head *)&ops->ops_list);
97869 genl_unlock_all();
97870 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
97871 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
97872 return 0;
97873 }
97874 }
97875 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
97876 index 53c19a3..b0ac04a 100644
97877 --- a/net/netrom/af_netrom.c
97878 +++ b/net/netrom/af_netrom.c
97879 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
97880 *uaddr_len = sizeof(struct full_sockaddr_ax25);
97881 } else {
97882 sax->fsa_ax25.sax25_family = AF_NETROM;
97883 - sax->fsa_ax25.sax25_ndigis = 0;
97884 sax->fsa_ax25.sax25_call = nr->source_addr;
97885 *uaddr_len = sizeof(struct sockaddr_ax25);
97886 }
97887 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
97888 index 88cfbc1..05d73f5 100644
97889 --- a/net/packet/af_packet.c
97890 +++ b/net/packet/af_packet.c
97891 @@ -1720,7 +1720,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
97892
97893 spin_lock(&sk->sk_receive_queue.lock);
97894 po->stats.stats1.tp_packets++;
97895 - skb->dropcount = atomic_read(&sk->sk_drops);
97896 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
97897 __skb_queue_tail(&sk->sk_receive_queue, skb);
97898 spin_unlock(&sk->sk_receive_queue.lock);
97899 sk->sk_data_ready(sk, skb->len);
97900 @@ -1729,7 +1729,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
97901 drop_n_acct:
97902 spin_lock(&sk->sk_receive_queue.lock);
97903 po->stats.stats1.tp_drops++;
97904 - atomic_inc(&sk->sk_drops);
97905 + atomic_inc_unchecked(&sk->sk_drops);
97906 spin_unlock(&sk->sk_receive_queue.lock);
97907
97908 drop_n_restore:
97909 @@ -3275,7 +3275,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
97910 case PACKET_HDRLEN:
97911 if (len > sizeof(int))
97912 len = sizeof(int);
97913 - if (copy_from_user(&val, optval, len))
97914 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
97915 return -EFAULT;
97916 switch (val) {
97917 case TPACKET_V1:
97918 @@ -3318,7 +3318,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
97919 len = lv;
97920 if (put_user(len, optlen))
97921 return -EFAULT;
97922 - if (copy_to_user(optval, data, len))
97923 + if (len > sizeof(st) || copy_to_user(optval, data, len))
97924 return -EFAULT;
97925 return 0;
97926 }
97927 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
97928 index e774117..900b8b7 100644
97929 --- a/net/phonet/pep.c
97930 +++ b/net/phonet/pep.c
97931 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
97932
97933 case PNS_PEP_CTRL_REQ:
97934 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
97935 - atomic_inc(&sk->sk_drops);
97936 + atomic_inc_unchecked(&sk->sk_drops);
97937 break;
97938 }
97939 __skb_pull(skb, 4);
97940 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
97941 }
97942
97943 if (pn->rx_credits == 0) {
97944 - atomic_inc(&sk->sk_drops);
97945 + atomic_inc_unchecked(&sk->sk_drops);
97946 err = -ENOBUFS;
97947 break;
97948 }
97949 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
97950 }
97951
97952 if (pn->rx_credits == 0) {
97953 - atomic_inc(&sk->sk_drops);
97954 + atomic_inc_unchecked(&sk->sk_drops);
97955 err = NET_RX_DROP;
97956 break;
97957 }
97958 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
97959 index 77e38f7..f4ef5c3 100644
97960 --- a/net/phonet/socket.c
97961 +++ b/net/phonet/socket.c
97962 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
97963 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
97964 sock_i_ino(sk),
97965 atomic_read(&sk->sk_refcnt), sk,
97966 - atomic_read(&sk->sk_drops), &len);
97967 + atomic_read_unchecked(&sk->sk_drops), &len);
97968 }
97969 seq_printf(seq, "%*s\n", 127 - len, "");
97970 return 0;
97971 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
97972 index c02a8c4..3c5b600 100644
97973 --- a/net/phonet/sysctl.c
97974 +++ b/net/phonet/sysctl.c
97975 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
97976 {
97977 int ret;
97978 int range[2] = {local_port_range[0], local_port_range[1]};
97979 - struct ctl_table tmp = {
97980 + ctl_table_no_const tmp = {
97981 .data = &range,
97982 .maxlen = sizeof(range),
97983 .mode = table->mode,
97984 diff --git a/net/rds/cong.c b/net/rds/cong.c
97985 index e5b65ac..f3b6fb7 100644
97986 --- a/net/rds/cong.c
97987 +++ b/net/rds/cong.c
97988 @@ -78,7 +78,7 @@
97989 * finds that the saved generation number is smaller than the global generation
97990 * number, it wakes up the process.
97991 */
97992 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
97993 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
97994
97995 /*
97996 * Congestion monitoring
97997 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
97998 rdsdebug("waking map %p for %pI4\n",
97999 map, &map->m_addr);
98000 rds_stats_inc(s_cong_update_received);
98001 - atomic_inc(&rds_cong_generation);
98002 + atomic_inc_unchecked(&rds_cong_generation);
98003 if (waitqueue_active(&map->m_waitq))
98004 wake_up(&map->m_waitq);
98005 if (waitqueue_active(&rds_poll_waitq))
98006 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
98007
98008 int rds_cong_updated_since(unsigned long *recent)
98009 {
98010 - unsigned long gen = atomic_read(&rds_cong_generation);
98011 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
98012
98013 if (likely(*recent == gen))
98014 return 0;
98015 diff --git a/net/rds/ib.h b/net/rds/ib.h
98016 index 7280ab8..e04f4ea 100644
98017 --- a/net/rds/ib.h
98018 +++ b/net/rds/ib.h
98019 @@ -128,7 +128,7 @@ struct rds_ib_connection {
98020 /* sending acks */
98021 unsigned long i_ack_flags;
98022 #ifdef KERNEL_HAS_ATOMIC64
98023 - atomic64_t i_ack_next; /* next ACK to send */
98024 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
98025 #else
98026 spinlock_t i_ack_lock; /* protect i_ack_next */
98027 u64 i_ack_next; /* next ACK to send */
98028 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
98029 index 31b74f5..dc1fbfa 100644
98030 --- a/net/rds/ib_cm.c
98031 +++ b/net/rds/ib_cm.c
98032 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
98033 /* Clear the ACK state */
98034 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
98035 #ifdef KERNEL_HAS_ATOMIC64
98036 - atomic64_set(&ic->i_ack_next, 0);
98037 + atomic64_set_unchecked(&ic->i_ack_next, 0);
98038 #else
98039 ic->i_ack_next = 0;
98040 #endif
98041 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
98042 index 8eb9501..0c386ff 100644
98043 --- a/net/rds/ib_recv.c
98044 +++ b/net/rds/ib_recv.c
98045 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
98046 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
98047 int ack_required)
98048 {
98049 - atomic64_set(&ic->i_ack_next, seq);
98050 + atomic64_set_unchecked(&ic->i_ack_next, seq);
98051 if (ack_required) {
98052 smp_mb__before_clear_bit();
98053 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
98054 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
98055 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
98056 smp_mb__after_clear_bit();
98057
98058 - return atomic64_read(&ic->i_ack_next);
98059 + return atomic64_read_unchecked(&ic->i_ack_next);
98060 }
98061 #endif
98062
98063 diff --git a/net/rds/iw.h b/net/rds/iw.h
98064 index 04ce3b1..48119a6 100644
98065 --- a/net/rds/iw.h
98066 +++ b/net/rds/iw.h
98067 @@ -134,7 +134,7 @@ struct rds_iw_connection {
98068 /* sending acks */
98069 unsigned long i_ack_flags;
98070 #ifdef KERNEL_HAS_ATOMIC64
98071 - atomic64_t i_ack_next; /* next ACK to send */
98072 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
98073 #else
98074 spinlock_t i_ack_lock; /* protect i_ack_next */
98075 u64 i_ack_next; /* next ACK to send */
98076 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
98077 index a91e1db..cf3053f 100644
98078 --- a/net/rds/iw_cm.c
98079 +++ b/net/rds/iw_cm.c
98080 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
98081 /* Clear the ACK state */
98082 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
98083 #ifdef KERNEL_HAS_ATOMIC64
98084 - atomic64_set(&ic->i_ack_next, 0);
98085 + atomic64_set_unchecked(&ic->i_ack_next, 0);
98086 #else
98087 ic->i_ack_next = 0;
98088 #endif
98089 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
98090 index 4503335..db566b4 100644
98091 --- a/net/rds/iw_recv.c
98092 +++ b/net/rds/iw_recv.c
98093 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
98094 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
98095 int ack_required)
98096 {
98097 - atomic64_set(&ic->i_ack_next, seq);
98098 + atomic64_set_unchecked(&ic->i_ack_next, seq);
98099 if (ack_required) {
98100 smp_mb__before_clear_bit();
98101 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
98102 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
98103 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
98104 smp_mb__after_clear_bit();
98105
98106 - return atomic64_read(&ic->i_ack_next);
98107 + return atomic64_read_unchecked(&ic->i_ack_next);
98108 }
98109 #endif
98110
98111 diff --git a/net/rds/rds.h b/net/rds/rds.h
98112 index ec1d731..90a3a8d 100644
98113 --- a/net/rds/rds.h
98114 +++ b/net/rds/rds.h
98115 @@ -449,7 +449,7 @@ struct rds_transport {
98116 void (*sync_mr)(void *trans_private, int direction);
98117 void (*free_mr)(void *trans_private, int invalidate);
98118 void (*flush_mrs)(void);
98119 -};
98120 +} __do_const;
98121
98122 struct rds_sock {
98123 struct sock rs_sk;
98124 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
98125 index edac9ef..16bcb98 100644
98126 --- a/net/rds/tcp.c
98127 +++ b/net/rds/tcp.c
98128 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
98129 int val = 1;
98130
98131 set_fs(KERNEL_DS);
98132 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
98133 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
98134 sizeof(val));
98135 set_fs(oldfs);
98136 }
98137 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
98138 index 81cf5a4..b5826ff 100644
98139 --- a/net/rds/tcp_send.c
98140 +++ b/net/rds/tcp_send.c
98141 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
98142
98143 oldfs = get_fs();
98144 set_fs(KERNEL_DS);
98145 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
98146 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
98147 sizeof(val));
98148 set_fs(oldfs);
98149 }
98150 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
98151 index e61aa60..f07cc89 100644
98152 --- a/net/rxrpc/af_rxrpc.c
98153 +++ b/net/rxrpc/af_rxrpc.c
98154 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
98155 __be32 rxrpc_epoch;
98156
98157 /* current debugging ID */
98158 -atomic_t rxrpc_debug_id;
98159 +atomic_unchecked_t rxrpc_debug_id;
98160
98161 /* count of skbs currently in use */
98162 atomic_t rxrpc_n_skbs;
98163 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
98164 index e4d9cbc..b229649 100644
98165 --- a/net/rxrpc/ar-ack.c
98166 +++ b/net/rxrpc/ar-ack.c
98167 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
98168
98169 _enter("{%d,%d,%d,%d},",
98170 call->acks_hard, call->acks_unacked,
98171 - atomic_read(&call->sequence),
98172 + atomic_read_unchecked(&call->sequence),
98173 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
98174
98175 stop = 0;
98176 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
98177
98178 /* each Tx packet has a new serial number */
98179 sp->hdr.serial =
98180 - htonl(atomic_inc_return(&call->conn->serial));
98181 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
98182
98183 hdr = (struct rxrpc_header *) txb->head;
98184 hdr->serial = sp->hdr.serial;
98185 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
98186 */
98187 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
98188 {
98189 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
98190 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
98191 }
98192
98193 /*
98194 @@ -629,7 +629,7 @@ process_further:
98195
98196 latest = ntohl(sp->hdr.serial);
98197 hard = ntohl(ack.firstPacket);
98198 - tx = atomic_read(&call->sequence);
98199 + tx = atomic_read_unchecked(&call->sequence);
98200
98201 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
98202 latest,
98203 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
98204 goto maybe_reschedule;
98205
98206 send_ACK_with_skew:
98207 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
98208 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
98209 ntohl(ack.serial));
98210 send_ACK:
98211 mtu = call->conn->trans->peer->if_mtu;
98212 @@ -1173,7 +1173,7 @@ send_ACK:
98213 ackinfo.rxMTU = htonl(5692);
98214 ackinfo.jumbo_max = htonl(4);
98215
98216 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
98217 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
98218 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
98219 ntohl(hdr.serial),
98220 ntohs(ack.maxSkew),
98221 @@ -1191,7 +1191,7 @@ send_ACK:
98222 send_message:
98223 _debug("send message");
98224
98225 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
98226 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
98227 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
98228 send_message_2:
98229
98230 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
98231 index a3bbb36..3341fb9 100644
98232 --- a/net/rxrpc/ar-call.c
98233 +++ b/net/rxrpc/ar-call.c
98234 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
98235 spin_lock_init(&call->lock);
98236 rwlock_init(&call->state_lock);
98237 atomic_set(&call->usage, 1);
98238 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
98239 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
98240 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
98241
98242 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
98243 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
98244 index 4106ca9..a338d7a 100644
98245 --- a/net/rxrpc/ar-connection.c
98246 +++ b/net/rxrpc/ar-connection.c
98247 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
98248 rwlock_init(&conn->lock);
98249 spin_lock_init(&conn->state_lock);
98250 atomic_set(&conn->usage, 1);
98251 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
98252 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
98253 conn->avail_calls = RXRPC_MAXCALLS;
98254 conn->size_align = 4;
98255 conn->header_size = sizeof(struct rxrpc_header);
98256 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
98257 index e7ed43a..6afa140 100644
98258 --- a/net/rxrpc/ar-connevent.c
98259 +++ b/net/rxrpc/ar-connevent.c
98260 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
98261
98262 len = iov[0].iov_len + iov[1].iov_len;
98263
98264 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
98265 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
98266 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
98267
98268 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
98269 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
98270 index 529572f..c758ca7 100644
98271 --- a/net/rxrpc/ar-input.c
98272 +++ b/net/rxrpc/ar-input.c
98273 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
98274 /* track the latest serial number on this connection for ACK packet
98275 * information */
98276 serial = ntohl(sp->hdr.serial);
98277 - hi_serial = atomic_read(&call->conn->hi_serial);
98278 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
98279 while (serial > hi_serial)
98280 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
98281 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
98282 serial);
98283
98284 /* request ACK generation for any ACK or DATA packet that requests
98285 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
98286 index a693aca..81e7293 100644
98287 --- a/net/rxrpc/ar-internal.h
98288 +++ b/net/rxrpc/ar-internal.h
98289 @@ -272,8 +272,8 @@ struct rxrpc_connection {
98290 int error; /* error code for local abort */
98291 int debug_id; /* debug ID for printks */
98292 unsigned int call_counter; /* call ID counter */
98293 - atomic_t serial; /* packet serial number counter */
98294 - atomic_t hi_serial; /* highest serial number received */
98295 + atomic_unchecked_t serial; /* packet serial number counter */
98296 + atomic_unchecked_t hi_serial; /* highest serial number received */
98297 u8 avail_calls; /* number of calls available */
98298 u8 size_align; /* data size alignment (for security) */
98299 u8 header_size; /* rxrpc + security header size */
98300 @@ -346,7 +346,7 @@ struct rxrpc_call {
98301 spinlock_t lock;
98302 rwlock_t state_lock; /* lock for state transition */
98303 atomic_t usage;
98304 - atomic_t sequence; /* Tx data packet sequence counter */
98305 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
98306 u32 abort_code; /* local/remote abort code */
98307 enum { /* current state of call */
98308 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
98309 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
98310 */
98311 extern atomic_t rxrpc_n_skbs;
98312 extern __be32 rxrpc_epoch;
98313 -extern atomic_t rxrpc_debug_id;
98314 +extern atomic_unchecked_t rxrpc_debug_id;
98315 extern struct workqueue_struct *rxrpc_workqueue;
98316
98317 /*
98318 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
98319 index 87f7135..74d3703 100644
98320 --- a/net/rxrpc/ar-local.c
98321 +++ b/net/rxrpc/ar-local.c
98322 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
98323 spin_lock_init(&local->lock);
98324 rwlock_init(&local->services_lock);
98325 atomic_set(&local->usage, 1);
98326 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
98327 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
98328 memcpy(&local->srx, srx, sizeof(*srx));
98329 }
98330
98331 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
98332 index e1ac183..b43e10e 100644
98333 --- a/net/rxrpc/ar-output.c
98334 +++ b/net/rxrpc/ar-output.c
98335 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
98336 sp->hdr.cid = call->cid;
98337 sp->hdr.callNumber = call->call_id;
98338 sp->hdr.seq =
98339 - htonl(atomic_inc_return(&call->sequence));
98340 + htonl(atomic_inc_return_unchecked(&call->sequence));
98341 sp->hdr.serial =
98342 - htonl(atomic_inc_return(&conn->serial));
98343 + htonl(atomic_inc_return_unchecked(&conn->serial));
98344 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
98345 sp->hdr.userStatus = 0;
98346 sp->hdr.securityIndex = conn->security_ix;
98347 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
98348 index bebaa43..2644591 100644
98349 --- a/net/rxrpc/ar-peer.c
98350 +++ b/net/rxrpc/ar-peer.c
98351 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
98352 INIT_LIST_HEAD(&peer->error_targets);
98353 spin_lock_init(&peer->lock);
98354 atomic_set(&peer->usage, 1);
98355 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
98356 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
98357 memcpy(&peer->srx, srx, sizeof(*srx));
98358
98359 rxrpc_assess_MTU_size(peer);
98360 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
98361 index 38047f7..9f48511 100644
98362 --- a/net/rxrpc/ar-proc.c
98363 +++ b/net/rxrpc/ar-proc.c
98364 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
98365 atomic_read(&conn->usage),
98366 rxrpc_conn_states[conn->state],
98367 key_serial(conn->key),
98368 - atomic_read(&conn->serial),
98369 - atomic_read(&conn->hi_serial));
98370 + atomic_read_unchecked(&conn->serial),
98371 + atomic_read_unchecked(&conn->hi_serial));
98372
98373 return 0;
98374 }
98375 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
98376 index 92df566..87ec1bf 100644
98377 --- a/net/rxrpc/ar-transport.c
98378 +++ b/net/rxrpc/ar-transport.c
98379 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
98380 spin_lock_init(&trans->client_lock);
98381 rwlock_init(&trans->conn_lock);
98382 atomic_set(&trans->usage, 1);
98383 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
98384 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
98385
98386 if (peer->srx.transport.family == AF_INET) {
98387 switch (peer->srx.transport_type) {
98388 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
98389 index f226709..0e735a8 100644
98390 --- a/net/rxrpc/rxkad.c
98391 +++ b/net/rxrpc/rxkad.c
98392 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
98393
98394 len = iov[0].iov_len + iov[1].iov_len;
98395
98396 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
98397 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
98398 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
98399
98400 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
98401 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
98402
98403 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
98404
98405 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
98406 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
98407 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
98408
98409 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
98410 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
98411 index e7b2d4f..bb1efd0 100644
98412 --- a/net/sctp/ipv6.c
98413 +++ b/net/sctp/ipv6.c
98414 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
98415 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
98416 };
98417
98418 -static struct sctp_af sctp_af_inet6 = {
98419 +static struct sctp_af sctp_af_inet6 __read_only = {
98420 .sa_family = AF_INET6,
98421 .sctp_xmit = sctp_v6_xmit,
98422 .setsockopt = ipv6_setsockopt,
98423 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
98424 #endif
98425 };
98426
98427 -static struct sctp_pf sctp_pf_inet6 = {
98428 +static struct sctp_pf sctp_pf_inet6 __read_only = {
98429 .event_msgname = sctp_inet6_event_msgname,
98430 .skb_msgname = sctp_inet6_skb_msgname,
98431 .af_supported = sctp_inet6_af_supported,
98432 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
98433
98434 void sctp_v6_pf_exit(void)
98435 {
98436 - list_del(&sctp_af_inet6.list);
98437 + pax_list_del(&sctp_af_inet6.list);
98438 }
98439
98440 /* Initialize IPv6 support and register with socket layer. */
98441 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
98442 index 5e17092..19be1d4 100644
98443 --- a/net/sctp/protocol.c
98444 +++ b/net/sctp/protocol.c
98445 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
98446 return 0;
98447 }
98448
98449 + pax_open_kernel();
98450 INIT_LIST_HEAD(&af->list);
98451 - list_add_tail(&af->list, &sctp_address_families);
98452 + pax_close_kernel();
98453 + pax_list_add_tail(&af->list, &sctp_address_families);
98454 return 1;
98455 }
98456
98457 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
98458
98459 static struct sctp_af sctp_af_inet;
98460
98461 -static struct sctp_pf sctp_pf_inet = {
98462 +static struct sctp_pf sctp_pf_inet __read_only = {
98463 .event_msgname = sctp_inet_event_msgname,
98464 .skb_msgname = sctp_inet_skb_msgname,
98465 .af_supported = sctp_inet_af_supported,
98466 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
98467 };
98468
98469 /* IPv4 address related functions. */
98470 -static struct sctp_af sctp_af_inet = {
98471 +static struct sctp_af sctp_af_inet __read_only = {
98472 .sa_family = AF_INET,
98473 .sctp_xmit = sctp_v4_xmit,
98474 .setsockopt = ip_setsockopt,
98475 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
98476
98477 static void sctp_v4_pf_exit(void)
98478 {
98479 - list_del(&sctp_af_inet.list);
98480 + pax_list_del(&sctp_af_inet.list);
98481 }
98482
98483 static int sctp_v4_protosw_init(void)
98484 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
98485 index 1a6eef3..17e898f 100644
98486 --- a/net/sctp/sm_sideeffect.c
98487 +++ b/net/sctp/sm_sideeffect.c
98488 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
98489 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
98490 }
98491
98492 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
98493 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
98494 NULL,
98495 sctp_generate_t1_cookie_event,
98496 sctp_generate_t1_init_event,
98497 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
98498 index 911b71b..90ade0a 100644
98499 --- a/net/sctp/socket.c
98500 +++ b/net/sctp/socket.c
98501 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
98502 {
98503 struct sctp_association *asoc;
98504 struct sctp_ulpevent *event;
98505 + struct sctp_event_subscribe subscribe;
98506
98507 if (optlen > sizeof(struct sctp_event_subscribe))
98508 return -EINVAL;
98509 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
98510 + if (copy_from_user(&subscribe, optval, optlen))
98511 return -EFAULT;
98512 + sctp_sk(sk)->subscribe = subscribe;
98513
98514 /*
98515 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
98516 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
98517 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
98518 int __user *optlen)
98519 {
98520 + struct sctp_event_subscribe subscribe;
98521 +
98522 if (len <= 0)
98523 return -EINVAL;
98524 if (len > sizeof(struct sctp_event_subscribe))
98525 len = sizeof(struct sctp_event_subscribe);
98526 if (put_user(len, optlen))
98527 return -EFAULT;
98528 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
98529 + subscribe = sctp_sk(sk)->subscribe;
98530 + if (copy_to_user(optval, &subscribe, len))
98531 return -EFAULT;
98532 return 0;
98533 }
98534 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
98535 */
98536 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
98537 {
98538 + __u32 autoclose;
98539 +
98540 /* Applicable to UDP-style socket only */
98541 if (sctp_style(sk, TCP))
98542 return -EOPNOTSUPP;
98543 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
98544 len = sizeof(int);
98545 if (put_user(len, optlen))
98546 return -EFAULT;
98547 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
98548 + autoclose = sctp_sk(sk)->autoclose;
98549 + if (copy_to_user(optval, &autoclose, sizeof(int)))
98550 return -EFAULT;
98551 return 0;
98552 }
98553 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
98554 */
98555 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
98556 {
98557 + struct sctp_initmsg initmsg;
98558 +
98559 if (len < sizeof(struct sctp_initmsg))
98560 return -EINVAL;
98561 len = sizeof(struct sctp_initmsg);
98562 if (put_user(len, optlen))
98563 return -EFAULT;
98564 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
98565 + initmsg = sctp_sk(sk)->initmsg;
98566 + if (copy_to_user(optval, &initmsg, len))
98567 return -EFAULT;
98568 return 0;
98569 }
98570 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
98571 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
98572 if (space_left < addrlen)
98573 return -ENOMEM;
98574 + if (addrlen > sizeof(temp) || addrlen < 0)
98575 + return -EFAULT;
98576 if (copy_to_user(to, &temp, addrlen))
98577 return -EFAULT;
98578 to += addrlen;
98579 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
98580 index 6b36561..4f21064 100644
98581 --- a/net/sctp/sysctl.c
98582 +++ b/net/sctp/sysctl.c
98583 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
98584 {
98585 struct net *net = current->nsproxy->net_ns;
98586 char tmp[8];
98587 - struct ctl_table tbl;
98588 + ctl_table_no_const tbl;
98589 int ret;
98590 int changed = 0;
98591 char *none = "none";
98592 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
98593
98594 int sctp_sysctl_net_register(struct net *net)
98595 {
98596 - struct ctl_table *table;
98597 + ctl_table_no_const *table;
98598 int i;
98599
98600 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
98601 diff --git a/net/socket.c b/net/socket.c
98602 index e83c416..6342a2f 100644
98603 --- a/net/socket.c
98604 +++ b/net/socket.c
98605 @@ -88,6 +88,7 @@
98606 #include <linux/magic.h>
98607 #include <linux/slab.h>
98608 #include <linux/xattr.h>
98609 +#include <linux/in.h>
98610
98611 #include <asm/uaccess.h>
98612 #include <asm/unistd.h>
98613 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
98614 unsigned int sysctl_net_busy_poll __read_mostly;
98615 #endif
98616
98617 +#include <linux/grsock.h>
98618 +
98619 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
98620 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
98621 unsigned long nr_segs, loff_t pos);
98622 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
98623 */
98624
98625 static DEFINE_SPINLOCK(net_family_lock);
98626 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
98627 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
98628
98629 /*
98630 * Statistics counters of the socket lists
98631 @@ -328,7 +331,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
98632 &sockfs_dentry_operations, SOCKFS_MAGIC);
98633 }
98634
98635 -static struct vfsmount *sock_mnt __read_mostly;
98636 +struct vfsmount *sock_mnt __read_mostly;
98637
98638 static struct file_system_type sock_fs_type = {
98639 .name = "sockfs",
98640 @@ -1255,6 +1258,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
98641 return -EAFNOSUPPORT;
98642 if (type < 0 || type >= SOCK_MAX)
98643 return -EINVAL;
98644 + if (protocol < 0)
98645 + return -EINVAL;
98646
98647 /* Compatibility.
98648
98649 @@ -1275,6 +1280,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
98650 if (err)
98651 return err;
98652
98653 + if(!kern && !gr_search_socket(family, type, protocol)) {
98654 + if (rcu_access_pointer(net_families[family]) == NULL)
98655 + return -EAFNOSUPPORT;
98656 + else
98657 + return -EACCES;
98658 + }
98659 +
98660 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
98661 + if (rcu_access_pointer(net_families[family]) == NULL)
98662 + return -EAFNOSUPPORT;
98663 + else
98664 + return -EACCES;
98665 + }
98666 +
98667 /*
98668 * Allocate the socket and allow the family to set things up. if
98669 * the protocol is 0, the family is instructed to select an appropriate
98670 @@ -1513,6 +1532,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
98671 if (sock) {
98672 err = move_addr_to_kernel(umyaddr, addrlen, &address);
98673 if (err >= 0) {
98674 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
98675 + err = -EACCES;
98676 + goto error;
98677 + }
98678 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
98679 + if (err)
98680 + goto error;
98681 +
98682 err = security_socket_bind(sock,
98683 (struct sockaddr *)&address,
98684 addrlen);
98685 @@ -1521,6 +1548,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
98686 (struct sockaddr *)
98687 &address, addrlen);
98688 }
98689 +error:
98690 fput_light(sock->file, fput_needed);
98691 }
98692 return err;
98693 @@ -1544,10 +1572,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
98694 if ((unsigned int)backlog > somaxconn)
98695 backlog = somaxconn;
98696
98697 + if (gr_handle_sock_server_other(sock->sk)) {
98698 + err = -EPERM;
98699 + goto error;
98700 + }
98701 +
98702 + err = gr_search_listen(sock);
98703 + if (err)
98704 + goto error;
98705 +
98706 err = security_socket_listen(sock, backlog);
98707 if (!err)
98708 err = sock->ops->listen(sock, backlog);
98709
98710 +error:
98711 fput_light(sock->file, fput_needed);
98712 }
98713 return err;
98714 @@ -1591,6 +1629,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
98715 newsock->type = sock->type;
98716 newsock->ops = sock->ops;
98717
98718 + if (gr_handle_sock_server_other(sock->sk)) {
98719 + err = -EPERM;
98720 + sock_release(newsock);
98721 + goto out_put;
98722 + }
98723 +
98724 + err = gr_search_accept(sock);
98725 + if (err) {
98726 + sock_release(newsock);
98727 + goto out_put;
98728 + }
98729 +
98730 /*
98731 * We don't need try_module_get here, as the listening socket (sock)
98732 * has the protocol module (sock->ops->owner) held.
98733 @@ -1636,6 +1686,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
98734 fd_install(newfd, newfile);
98735 err = newfd;
98736
98737 + gr_attach_curr_ip(newsock->sk);
98738 +
98739 out_put:
98740 fput_light(sock->file, fput_needed);
98741 out:
98742 @@ -1668,6 +1720,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
98743 int, addrlen)
98744 {
98745 struct socket *sock;
98746 + struct sockaddr *sck;
98747 struct sockaddr_storage address;
98748 int err, fput_needed;
98749
98750 @@ -1678,6 +1731,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
98751 if (err < 0)
98752 goto out_put;
98753
98754 + sck = (struct sockaddr *)&address;
98755 +
98756 + if (gr_handle_sock_client(sck)) {
98757 + err = -EACCES;
98758 + goto out_put;
98759 + }
98760 +
98761 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
98762 + if (err)
98763 + goto out_put;
98764 +
98765 err =
98766 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
98767 if (err)
98768 @@ -1759,6 +1823,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
98769 * the protocol.
98770 */
98771
98772 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
98773 +
98774 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
98775 unsigned int, flags, struct sockaddr __user *, addr,
98776 int, addr_len)
98777 @@ -2047,7 +2113,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
98778 * checking falls down on this.
98779 */
98780 if (copy_from_user(ctl_buf,
98781 - (void __user __force *)msg_sys->msg_control,
98782 + (void __force_user *)msg_sys->msg_control,
98783 ctl_len))
98784 goto out_freectl;
98785 msg_sys->msg_control = ctl_buf;
98786 @@ -2227,7 +2293,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
98787 /* Save the user-mode address (verify_iovec will change the
98788 * kernel msghdr to use the kernel address space)
98789 */
98790 - uaddr = (__force void __user *)msg_sys->msg_name;
98791 + uaddr = (void __force_user *)msg_sys->msg_name;
98792 uaddr_len = COMPAT_NAMELEN(msg);
98793 if (MSG_CMSG_COMPAT & flags)
98794 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
98795 @@ -2985,7 +3051,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
98796 old_fs = get_fs();
98797 set_fs(KERNEL_DS);
98798 err = dev_ioctl(net, cmd,
98799 - (struct ifreq __user __force *) &kifr);
98800 + (struct ifreq __force_user *) &kifr);
98801 set_fs(old_fs);
98802
98803 return err;
98804 @@ -3094,7 +3160,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
98805
98806 old_fs = get_fs();
98807 set_fs(KERNEL_DS);
98808 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
98809 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
98810 set_fs(old_fs);
98811
98812 if (cmd == SIOCGIFMAP && !err) {
98813 @@ -3199,7 +3265,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
98814 ret |= get_user(rtdev, &(ur4->rt_dev));
98815 if (rtdev) {
98816 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
98817 - r4.rt_dev = (char __user __force *)devname;
98818 + r4.rt_dev = (char __force_user *)devname;
98819 devname[15] = 0;
98820 } else
98821 r4.rt_dev = NULL;
98822 @@ -3425,8 +3491,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
98823 int __user *uoptlen;
98824 int err;
98825
98826 - uoptval = (char __user __force *) optval;
98827 - uoptlen = (int __user __force *) optlen;
98828 + uoptval = (char __force_user *) optval;
98829 + uoptlen = (int __force_user *) optlen;
98830
98831 set_fs(KERNEL_DS);
98832 if (level == SOL_SOCKET)
98833 @@ -3446,7 +3512,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
98834 char __user *uoptval;
98835 int err;
98836
98837 - uoptval = (char __user __force *) optval;
98838 + uoptval = (char __force_user *) optval;
98839
98840 set_fs(KERNEL_DS);
98841 if (level == SOL_SOCKET)
98842 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
98843 index 09fb638..2e6a5c5 100644
98844 --- a/net/sunrpc/auth_gss/svcauth_gss.c
98845 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
98846 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
98847 uint64_t *handle)
98848 {
98849 struct rsc rsci, *rscp = NULL;
98850 - static atomic64_t ctxhctr;
98851 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
98852 long long ctxh;
98853 struct gss_api_mech *gm = NULL;
98854 time_t expiry;
98855 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
98856 status = -ENOMEM;
98857 /* the handle needs to be just a unique id,
98858 * use a static counter */
98859 - ctxh = atomic64_inc_return(&ctxhctr);
98860 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
98861
98862 /* make a copy for the caller */
98863 *handle = ctxh;
98864 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
98865 index 941d19f..c85ff07 100644
98866 --- a/net/sunrpc/clnt.c
98867 +++ b/net/sunrpc/clnt.c
98868 @@ -1319,7 +1319,9 @@ call_start(struct rpc_task *task)
98869 (RPC_IS_ASYNC(task) ? "async" : "sync"));
98870
98871 /* Increment call count */
98872 - task->tk_msg.rpc_proc->p_count++;
98873 + pax_open_kernel();
98874 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
98875 + pax_close_kernel();
98876 clnt->cl_stats->rpccnt++;
98877 task->tk_action = call_reserve;
98878 }
98879 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
98880 index ff3cc4b..7612a9e 100644
98881 --- a/net/sunrpc/sched.c
98882 +++ b/net/sunrpc/sched.c
98883 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
98884 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
98885 static void rpc_task_set_debuginfo(struct rpc_task *task)
98886 {
98887 - static atomic_t rpc_pid;
98888 + static atomic_unchecked_t rpc_pid;
98889
98890 - task->tk_pid = atomic_inc_return(&rpc_pid);
98891 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
98892 }
98893 #else
98894 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
98895 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
98896 index b974571..678ed90 100644
98897 --- a/net/sunrpc/svc.c
98898 +++ b/net/sunrpc/svc.c
98899 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
98900 svc_putnl(resv, RPC_SUCCESS);
98901
98902 /* Bump per-procedure stats counter */
98903 - procp->pc_count++;
98904 + pax_open_kernel();
98905 + (*(unsigned int *)&procp->pc_count)++;
98906 + pax_close_kernel();
98907
98908 /* Initialize storage for argp and resp */
98909 memset(rqstp->rq_argp, 0, procp->pc_argsize);
98910 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
98911 index 621ca7b..59421dd 100644
98912 --- a/net/sunrpc/svcauth_unix.c
98913 +++ b/net/sunrpc/svcauth_unix.c
98914 @@ -414,7 +414,7 @@ struct unix_gid {
98915 struct group_info *gi;
98916 };
98917
98918 -static int unix_gid_hash(kuid_t uid)
98919 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
98920 {
98921 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
98922 }
98923 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
98924 (*bpp)[-1] = '\n';
98925 }
98926
98927 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
98928 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
98929
98930 static int unix_gid_parse(struct cache_detail *cd,
98931 char *mesg, int mlen)
98932 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
98933 index c1b6270..05089c1 100644
98934 --- a/net/sunrpc/xprtrdma/svc_rdma.c
98935 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
98936 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
98937 static unsigned int min_max_inline = 4096;
98938 static unsigned int max_max_inline = 65536;
98939
98940 -atomic_t rdma_stat_recv;
98941 -atomic_t rdma_stat_read;
98942 -atomic_t rdma_stat_write;
98943 -atomic_t rdma_stat_sq_starve;
98944 -atomic_t rdma_stat_rq_starve;
98945 -atomic_t rdma_stat_rq_poll;
98946 -atomic_t rdma_stat_rq_prod;
98947 -atomic_t rdma_stat_sq_poll;
98948 -atomic_t rdma_stat_sq_prod;
98949 +atomic_unchecked_t rdma_stat_recv;
98950 +atomic_unchecked_t rdma_stat_read;
98951 +atomic_unchecked_t rdma_stat_write;
98952 +atomic_unchecked_t rdma_stat_sq_starve;
98953 +atomic_unchecked_t rdma_stat_rq_starve;
98954 +atomic_unchecked_t rdma_stat_rq_poll;
98955 +atomic_unchecked_t rdma_stat_rq_prod;
98956 +atomic_unchecked_t rdma_stat_sq_poll;
98957 +atomic_unchecked_t rdma_stat_sq_prod;
98958
98959 /* Temporary NFS request map and context caches */
98960 struct kmem_cache *svc_rdma_map_cachep;
98961 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
98962 len -= *ppos;
98963 if (len > *lenp)
98964 len = *lenp;
98965 - if (len && copy_to_user(buffer, str_buf, len))
98966 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
98967 return -EFAULT;
98968 *lenp = len;
98969 *ppos += len;
98970 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
98971 {
98972 .procname = "rdma_stat_read",
98973 .data = &rdma_stat_read,
98974 - .maxlen = sizeof(atomic_t),
98975 + .maxlen = sizeof(atomic_unchecked_t),
98976 .mode = 0644,
98977 .proc_handler = read_reset_stat,
98978 },
98979 {
98980 .procname = "rdma_stat_recv",
98981 .data = &rdma_stat_recv,
98982 - .maxlen = sizeof(atomic_t),
98983 + .maxlen = sizeof(atomic_unchecked_t),
98984 .mode = 0644,
98985 .proc_handler = read_reset_stat,
98986 },
98987 {
98988 .procname = "rdma_stat_write",
98989 .data = &rdma_stat_write,
98990 - .maxlen = sizeof(atomic_t),
98991 + .maxlen = sizeof(atomic_unchecked_t),
98992 .mode = 0644,
98993 .proc_handler = read_reset_stat,
98994 },
98995 {
98996 .procname = "rdma_stat_sq_starve",
98997 .data = &rdma_stat_sq_starve,
98998 - .maxlen = sizeof(atomic_t),
98999 + .maxlen = sizeof(atomic_unchecked_t),
99000 .mode = 0644,
99001 .proc_handler = read_reset_stat,
99002 },
99003 {
99004 .procname = "rdma_stat_rq_starve",
99005 .data = &rdma_stat_rq_starve,
99006 - .maxlen = sizeof(atomic_t),
99007 + .maxlen = sizeof(atomic_unchecked_t),
99008 .mode = 0644,
99009 .proc_handler = read_reset_stat,
99010 },
99011 {
99012 .procname = "rdma_stat_rq_poll",
99013 .data = &rdma_stat_rq_poll,
99014 - .maxlen = sizeof(atomic_t),
99015 + .maxlen = sizeof(atomic_unchecked_t),
99016 .mode = 0644,
99017 .proc_handler = read_reset_stat,
99018 },
99019 {
99020 .procname = "rdma_stat_rq_prod",
99021 .data = &rdma_stat_rq_prod,
99022 - .maxlen = sizeof(atomic_t),
99023 + .maxlen = sizeof(atomic_unchecked_t),
99024 .mode = 0644,
99025 .proc_handler = read_reset_stat,
99026 },
99027 {
99028 .procname = "rdma_stat_sq_poll",
99029 .data = &rdma_stat_sq_poll,
99030 - .maxlen = sizeof(atomic_t),
99031 + .maxlen = sizeof(atomic_unchecked_t),
99032 .mode = 0644,
99033 .proc_handler = read_reset_stat,
99034 },
99035 {
99036 .procname = "rdma_stat_sq_prod",
99037 .data = &rdma_stat_sq_prod,
99038 - .maxlen = sizeof(atomic_t),
99039 + .maxlen = sizeof(atomic_unchecked_t),
99040 .mode = 0644,
99041 .proc_handler = read_reset_stat,
99042 },
99043 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
99044 index 0ce7552..d074459 100644
99045 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
99046 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
99047 @@ -501,7 +501,7 @@ next_sge:
99048 svc_rdma_put_context(ctxt, 0);
99049 goto out;
99050 }
99051 - atomic_inc(&rdma_stat_read);
99052 + atomic_inc_unchecked(&rdma_stat_read);
99053
99054 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
99055 chl_map->ch[ch_no].count -= read_wr.num_sge;
99056 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
99057 dto_q);
99058 list_del_init(&ctxt->dto_q);
99059 } else {
99060 - atomic_inc(&rdma_stat_rq_starve);
99061 + atomic_inc_unchecked(&rdma_stat_rq_starve);
99062 clear_bit(XPT_DATA, &xprt->xpt_flags);
99063 ctxt = NULL;
99064 }
99065 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
99066 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
99067 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
99068 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
99069 - atomic_inc(&rdma_stat_recv);
99070 + atomic_inc_unchecked(&rdma_stat_recv);
99071
99072 /* Build up the XDR from the receive buffers. */
99073 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
99074 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
99075 index c1d124d..acfc59e 100644
99076 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
99077 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
99078 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
99079 write_wr.wr.rdma.remote_addr = to;
99080
99081 /* Post It */
99082 - atomic_inc(&rdma_stat_write);
99083 + atomic_inc_unchecked(&rdma_stat_write);
99084 if (svc_rdma_send(xprt, &write_wr))
99085 goto err;
99086 return 0;
99087 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
99088 index 62e4f9b..dd3f2d7 100644
99089 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
99090 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
99091 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
99092 return;
99093
99094 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
99095 - atomic_inc(&rdma_stat_rq_poll);
99096 + atomic_inc_unchecked(&rdma_stat_rq_poll);
99097
99098 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
99099 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
99100 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
99101 }
99102
99103 if (ctxt)
99104 - atomic_inc(&rdma_stat_rq_prod);
99105 + atomic_inc_unchecked(&rdma_stat_rq_prod);
99106
99107 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
99108 /*
99109 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
99110 return;
99111
99112 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
99113 - atomic_inc(&rdma_stat_sq_poll);
99114 + atomic_inc_unchecked(&rdma_stat_sq_poll);
99115 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
99116 if (wc.status != IB_WC_SUCCESS)
99117 /* Close the transport */
99118 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
99119 }
99120
99121 if (ctxt)
99122 - atomic_inc(&rdma_stat_sq_prod);
99123 + atomic_inc_unchecked(&rdma_stat_sq_prod);
99124 }
99125
99126 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
99127 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
99128 spin_lock_bh(&xprt->sc_lock);
99129 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
99130 spin_unlock_bh(&xprt->sc_lock);
99131 - atomic_inc(&rdma_stat_sq_starve);
99132 + atomic_inc_unchecked(&rdma_stat_sq_starve);
99133
99134 /* See if we can opportunistically reap SQ WR to make room */
99135 sq_cq_reap(xprt);
99136 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
99137 index e7000be..e3b0ba7 100644
99138 --- a/net/sysctl_net.c
99139 +++ b/net/sysctl_net.c
99140 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
99141 kgid_t root_gid = make_kgid(net->user_ns, 0);
99142
99143 /* Allow network administrator to have same access as root. */
99144 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
99145 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
99146 uid_eq(root_uid, current_euid())) {
99147 int mode = (table->mode >> 6) & 7;
99148 return (mode << 6) | (mode << 3) | mode;
99149 diff --git a/net/tipc/link.c b/net/tipc/link.c
99150 index 0cc3d90..cc42021 100644
99151 --- a/net/tipc/link.c
99152 +++ b/net/tipc/link.c
99153 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
99154 struct tipc_msg fragm_hdr;
99155 struct sk_buff *buf, *buf_chain, *prev;
99156 u32 fragm_crs, fragm_rest, hsz, sect_rest;
99157 - const unchar *sect_crs;
99158 + const unchar __user *sect_crs;
99159 int curr_sect;
99160 u32 fragm_no;
99161 int res = 0;
99162 @@ -1207,7 +1207,7 @@ again:
99163
99164 if (!sect_rest) {
99165 sect_rest = msg_sect[++curr_sect].iov_len;
99166 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
99167 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
99168 }
99169
99170 if (sect_rest < fragm_rest)
99171 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
99172 index ced60e2..54eab6c 100644
99173 --- a/net/tipc/msg.c
99174 +++ b/net/tipc/msg.c
99175 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
99176 skb_copy_to_linear_data(*buf, hdr, hsz);
99177 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
99178 skb_copy_to_linear_data_offset(*buf, pos,
99179 - msg_sect[cnt].iov_base,
99180 + (const void __force_kernel *)msg_sect[cnt].iov_base,
99181 msg_sect[cnt].iov_len);
99182 pos += msg_sect[cnt].iov_len;
99183 }
99184 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
99185 index d38bb45..4fd6ac6 100644
99186 --- a/net/tipc/subscr.c
99187 +++ b/net/tipc/subscr.c
99188 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
99189 struct kvec msg_sect;
99190 int ret;
99191
99192 - msg_sect.iov_base = (void *)&sub->evt;
99193 + msg_sect.iov_base = (void __force_user *)&sub->evt;
99194 msg_sect.iov_len = sizeof(struct tipc_event);
99195
99196 sub->evt.event = htohl(event, sub->swap);
99197 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
99198 index a427623..387c80b 100644
99199 --- a/net/unix/af_unix.c
99200 +++ b/net/unix/af_unix.c
99201 @@ -790,6 +790,12 @@ static struct sock *unix_find_other(struct net *net,
99202 err = -ECONNREFUSED;
99203 if (!S_ISSOCK(inode->i_mode))
99204 goto put_fail;
99205 +
99206 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
99207 + err = -EACCES;
99208 + goto put_fail;
99209 + }
99210 +
99211 u = unix_find_socket_byinode(inode);
99212 if (!u)
99213 goto put_fail;
99214 @@ -810,6 +816,13 @@ static struct sock *unix_find_other(struct net *net,
99215 if (u) {
99216 struct dentry *dentry;
99217 dentry = unix_sk(u)->path.dentry;
99218 +
99219 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
99220 + err = -EPERM;
99221 + sock_put(u);
99222 + goto fail;
99223 + }
99224 +
99225 if (dentry)
99226 touch_atime(&unix_sk(u)->path);
99227 } else
99228 @@ -843,12 +856,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
99229 */
99230 err = security_path_mknod(&path, dentry, mode, 0);
99231 if (!err) {
99232 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
99233 + err = -EACCES;
99234 + goto out;
99235 + }
99236 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
99237 if (!err) {
99238 res->mnt = mntget(path.mnt);
99239 res->dentry = dget(dentry);
99240 + gr_handle_create(dentry, path.mnt);
99241 }
99242 }
99243 +out:
99244 done_path_create(&path, dentry);
99245 return err;
99246 }
99247 @@ -2336,9 +2355,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
99248 seq_puts(seq, "Num RefCount Protocol Flags Type St "
99249 "Inode Path\n");
99250 else {
99251 - struct sock *s = v;
99252 + struct sock *s = v, *peer;
99253 struct unix_sock *u = unix_sk(s);
99254 unix_state_lock(s);
99255 + peer = unix_peer(s);
99256 + unix_state_unlock(s);
99257 +
99258 + unix_state_double_lock(s, peer);
99259
99260 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
99261 s,
99262 @@ -2365,8 +2388,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
99263 }
99264 for ( ; i < len; i++)
99265 seq_putc(seq, u->addr->name->sun_path[i]);
99266 - }
99267 - unix_state_unlock(s);
99268 + } else if (peer)
99269 + seq_printf(seq, " P%lu", sock_i_ino(peer));
99270 +
99271 + unix_state_double_unlock(s, peer);
99272 seq_putc(seq, '\n');
99273 }
99274
99275 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
99276 index b3d5150..ff3a837 100644
99277 --- a/net/unix/sysctl_net_unix.c
99278 +++ b/net/unix/sysctl_net_unix.c
99279 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
99280
99281 int __net_init unix_sysctl_register(struct net *net)
99282 {
99283 - struct ctl_table *table;
99284 + ctl_table_no_const *table;
99285
99286 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
99287 if (table == NULL)
99288 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
99289 index c8717c1..08539f5 100644
99290 --- a/net/wireless/wext-core.c
99291 +++ b/net/wireless/wext-core.c
99292 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
99293 */
99294
99295 /* Support for very large requests */
99296 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
99297 - (user_length > descr->max_tokens)) {
99298 + if (user_length > descr->max_tokens) {
99299 /* Allow userspace to GET more than max so
99300 * we can support any size GET requests.
99301 * There is still a limit : -ENOMEM.
99302 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
99303 }
99304 }
99305
99306 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
99307 - /*
99308 - * If this is a GET, but not NOMAX, it means that the extra
99309 - * data is not bounded by userspace, but by max_tokens. Thus
99310 - * set the length to max_tokens. This matches the extra data
99311 - * allocation.
99312 - * The driver should fill it with the number of tokens it
99313 - * provided, and it may check iwp->length rather than having
99314 - * knowledge of max_tokens. If the driver doesn't change the
99315 - * iwp->length, this ioctl just copies back max_token tokens
99316 - * filled with zeroes. Hopefully the driver isn't claiming
99317 - * them to be valid data.
99318 - */
99319 - iwp->length = descr->max_tokens;
99320 - }
99321 -
99322 err = handler(dev, info, (union iwreq_data *) iwp, extra);
99323
99324 iwp->length += essid_compat;
99325 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
99326 index 76e1873..4a12664 100644
99327 --- a/net/xfrm/xfrm_policy.c
99328 +++ b/net/xfrm/xfrm_policy.c
99329 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
99330 {
99331 policy->walk.dead = 1;
99332
99333 - atomic_inc(&policy->genid);
99334 + atomic_inc_unchecked(&policy->genid);
99335
99336 if (del_timer(&policy->polq.hold_timer))
99337 xfrm_pol_put(policy);
99338 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
99339 hlist_add_head(&policy->bydst, chain);
99340 xfrm_pol_hold(policy);
99341 net->xfrm.policy_count[dir]++;
99342 - atomic_inc(&flow_cache_genid);
99343 + atomic_inc_unchecked(&flow_cache_genid);
99344
99345 /* After previous checking, family can either be AF_INET or AF_INET6 */
99346 if (policy->family == AF_INET)
99347 @@ -1636,7 +1636,7 @@ free_dst:
99348 goto out;
99349 }
99350
99351 -static int inline
99352 +static inline int
99353 xfrm_dst_alloc_copy(void **target, const void *src, int size)
99354 {
99355 if (!*target) {
99356 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
99357 return 0;
99358 }
99359
99360 -static int inline
99361 +static inline int
99362 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
99363 {
99364 #ifdef CONFIG_XFRM_SUB_POLICY
99365 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
99366 #endif
99367 }
99368
99369 -static int inline
99370 +static inline int
99371 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
99372 {
99373 #ifdef CONFIG_XFRM_SUB_POLICY
99374 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
99375
99376 xdst->num_pols = num_pols;
99377 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
99378 - xdst->policy_genid = atomic_read(&pols[0]->genid);
99379 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
99380
99381 return xdst;
99382 }
99383 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
99384 }
99385 EXPORT_SYMBOL(xfrm_garbage_collect);
99386
99387 -static void xfrm_garbage_collect_deferred(struct net *net)
99388 +void xfrm_garbage_collect_deferred(struct net *net)
99389 {
99390 flow_cache_flush_deferred();
99391 __xfrm_garbage_collect(net);
99392 }
99393 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
99394
99395 static void xfrm_init_pmtu(struct dst_entry *dst)
99396 {
99397 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
99398 if (xdst->xfrm_genid != dst->xfrm->genid)
99399 return 0;
99400 if (xdst->num_pols > 0 &&
99401 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
99402 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
99403 return 0;
99404
99405 mtu = dst_mtu(dst->child);
99406 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
99407 dst_ops->link_failure = xfrm_link_failure;
99408 if (likely(dst_ops->neigh_lookup == NULL))
99409 dst_ops->neigh_lookup = xfrm_neigh_lookup;
99410 - if (likely(afinfo->garbage_collect == NULL))
99411 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
99412 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
99413 }
99414 spin_unlock(&xfrm_policy_afinfo_lock);
99415 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
99416 dst_ops->check = NULL;
99417 dst_ops->negative_advice = NULL;
99418 dst_ops->link_failure = NULL;
99419 - afinfo->garbage_collect = NULL;
99420 }
99421 return err;
99422 }
99423 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
99424 sizeof(pol->xfrm_vec[i].saddr));
99425 pol->xfrm_vec[i].encap_family = mp->new_family;
99426 /* flush bundles */
99427 - atomic_inc(&pol->genid);
99428 + atomic_inc_unchecked(&pol->genid);
99429 }
99430 }
99431
99432 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
99433 index b9c3f9e..4767526 100644
99434 --- a/net/xfrm/xfrm_state.c
99435 +++ b/net/xfrm/xfrm_state.c
99436 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
99437
99438 if (unlikely(afinfo == NULL))
99439 return -EAFNOSUPPORT;
99440 - typemap = afinfo->type_map;
99441 + typemap = (const struct xfrm_type **)afinfo->type_map;
99442 spin_lock_bh(&xfrm_type_lock);
99443
99444 - if (likely(typemap[type->proto] == NULL))
99445 + if (likely(typemap[type->proto] == NULL)) {
99446 + pax_open_kernel();
99447 typemap[type->proto] = type;
99448 - else
99449 + pax_close_kernel();
99450 + } else
99451 err = -EEXIST;
99452 spin_unlock_bh(&xfrm_type_lock);
99453 xfrm_state_put_afinfo(afinfo);
99454 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
99455
99456 if (unlikely(afinfo == NULL))
99457 return -EAFNOSUPPORT;
99458 - typemap = afinfo->type_map;
99459 + typemap = (const struct xfrm_type **)afinfo->type_map;
99460 spin_lock_bh(&xfrm_type_lock);
99461
99462 if (unlikely(typemap[type->proto] != type))
99463 err = -ENOENT;
99464 - else
99465 + else {
99466 + pax_open_kernel();
99467 typemap[type->proto] = NULL;
99468 + pax_close_kernel();
99469 + }
99470 spin_unlock_bh(&xfrm_type_lock);
99471 xfrm_state_put_afinfo(afinfo);
99472 return err;
99473 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
99474 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
99475 {
99476 struct xfrm_state_afinfo *afinfo;
99477 - const struct xfrm_type **typemap;
99478 const struct xfrm_type *type;
99479 int modload_attempted = 0;
99480
99481 @@ -219,9 +223,8 @@ retry:
99482 afinfo = xfrm_state_get_afinfo(family);
99483 if (unlikely(afinfo == NULL))
99484 return NULL;
99485 - typemap = afinfo->type_map;
99486
99487 - type = typemap[proto];
99488 + type = afinfo->type_map[proto];
99489 if (unlikely(type && !try_module_get(type->owner)))
99490 type = NULL;
99491 if (!type && !modload_attempted) {
99492 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
99493 return -EAFNOSUPPORT;
99494
99495 err = -EEXIST;
99496 - modemap = afinfo->mode_map;
99497 + modemap = (struct xfrm_mode **)afinfo->mode_map;
99498 spin_lock_bh(&xfrm_mode_lock);
99499 if (modemap[mode->encap])
99500 goto out;
99501 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
99502 if (!try_module_get(afinfo->owner))
99503 goto out;
99504
99505 - mode->afinfo = afinfo;
99506 + pax_open_kernel();
99507 + *(const void **)&mode->afinfo = afinfo;
99508 modemap[mode->encap] = mode;
99509 + pax_close_kernel();
99510 err = 0;
99511
99512 out:
99513 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
99514 return -EAFNOSUPPORT;
99515
99516 err = -ENOENT;
99517 - modemap = afinfo->mode_map;
99518 + modemap = (struct xfrm_mode **)afinfo->mode_map;
99519 spin_lock_bh(&xfrm_mode_lock);
99520 if (likely(modemap[mode->encap] == mode)) {
99521 + pax_open_kernel();
99522 modemap[mode->encap] = NULL;
99523 + pax_close_kernel();
99524 module_put(mode->afinfo->owner);
99525 err = 0;
99526 }
99527 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
99528 u32 xfrm_get_acqseq(void)
99529 {
99530 u32 res;
99531 - static atomic_t acqseq;
99532 + static atomic_unchecked_t acqseq;
99533
99534 do {
99535 - res = atomic_inc_return(&acqseq);
99536 + res = atomic_inc_return_unchecked(&acqseq);
99537 } while (!res);
99538
99539 return res;
99540 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
99541 index 05a6e3d..6716ec9 100644
99542 --- a/net/xfrm/xfrm_sysctl.c
99543 +++ b/net/xfrm/xfrm_sysctl.c
99544 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
99545
99546 int __net_init xfrm_sysctl_init(struct net *net)
99547 {
99548 - struct ctl_table *table;
99549 + ctl_table_no_const *table;
99550
99551 __xfrm_sysctl_init(net);
99552
99553 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
99554 index d5d859c..781cbcb 100644
99555 --- a/scripts/Makefile.build
99556 +++ b/scripts/Makefile.build
99557 @@ -111,7 +111,7 @@ endif
99558 endif
99559
99560 # Do not include host rules unless needed
99561 -ifneq ($(hostprogs-y)$(hostprogs-m),)
99562 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
99563 include scripts/Makefile.host
99564 endif
99565
99566 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
99567 index 686cb0d..9d653bf 100644
99568 --- a/scripts/Makefile.clean
99569 +++ b/scripts/Makefile.clean
99570 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
99571 __clean-files := $(extra-y) $(always) \
99572 $(targets) $(clean-files) \
99573 $(host-progs) \
99574 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
99575 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
99576 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
99577
99578 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
99579
99580 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
99581 index 1ac414f..38575f7 100644
99582 --- a/scripts/Makefile.host
99583 +++ b/scripts/Makefile.host
99584 @@ -31,6 +31,8 @@
99585 # Note: Shared libraries consisting of C++ files are not supported
99586
99587 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
99588 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
99589 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
99590
99591 # C code
99592 # Executables compiled from a single .c file
99593 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
99594 # Shared libaries (only .c supported)
99595 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
99596 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
99597 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
99598 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
99599 # Remove .so files from "xxx-objs"
99600 host-cobjs := $(filter-out %.so,$(host-cobjs))
99601 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
99602
99603 -#Object (.o) files used by the shared libaries
99604 +# Object (.o) files used by the shared libaries
99605 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
99606 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
99607
99608 # output directory for programs/.o files
99609 # hostprogs-y := tools/build may have been specified. Retrieve directory
99610 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
99611 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
99612 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
99613 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
99614 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
99615 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
99616 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
99617 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
99618
99619 obj-dirs += $(host-objdirs)
99620 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
99621 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
99622 $(call if_changed_dep,host-cshobjs)
99623
99624 +# Compile .c file, create position independent .o file
99625 +# host-cxxshobjs -> .o
99626 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
99627 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
99628 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
99629 + $(call if_changed_dep,host-cxxshobjs)
99630 +
99631 # Link a shared library, based on position independent .o files
99632 # *.o -> .so shared library (host-cshlib)
99633 quiet_cmd_host-cshlib = HOSTLLD -shared $@
99634 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
99635 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
99636 $(call if_changed,host-cshlib)
99637
99638 +# Link a shared library, based on position independent .o files
99639 +# *.o -> .so shared library (host-cxxshlib)
99640 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
99641 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
99642 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
99643 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
99644 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
99645 + $(call if_changed,host-cxxshlib)
99646 +
99647 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
99648 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
99649 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
99650
99651 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
99652 index 078fe1d..fbdb363 100644
99653 --- a/scripts/basic/fixdep.c
99654 +++ b/scripts/basic/fixdep.c
99655 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
99656 /*
99657 * Lookup a value in the configuration string.
99658 */
99659 -static int is_defined_config(const char *name, int len, unsigned int hash)
99660 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
99661 {
99662 struct item *aux;
99663
99664 @@ -211,10 +211,10 @@ static void clear_config(void)
99665 /*
99666 * Record the use of a CONFIG_* word.
99667 */
99668 -static void use_config(const char *m, int slen)
99669 +static void use_config(const char *m, unsigned int slen)
99670 {
99671 unsigned int hash = strhash(m, slen);
99672 - int c, i;
99673 + unsigned int c, i;
99674
99675 if (is_defined_config(m, slen, hash))
99676 return;
99677 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
99678
99679 static void parse_config_file(const char *map, size_t len)
99680 {
99681 - const int *end = (const int *) (map + len);
99682 + const unsigned int *end = (const unsigned int *) (map + len);
99683 /* start at +1, so that p can never be < map */
99684 - const int *m = (const int *) map + 1;
99685 + const unsigned int *m = (const unsigned int *) map + 1;
99686 const char *p, *q;
99687
99688 for (; m < end; m++) {
99689 @@ -435,7 +435,7 @@ static void print_deps(void)
99690 static void traps(void)
99691 {
99692 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
99693 - int *p = (int *)test;
99694 + unsigned int *p = (unsigned int *)test;
99695
99696 if (*p != INT_CONF) {
99697 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
99698 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
99699 new file mode 100644
99700 index 0000000..5e0222d
99701 --- /dev/null
99702 +++ b/scripts/gcc-plugin.sh
99703 @@ -0,0 +1,17 @@
99704 +#!/bin/bash
99705 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
99706 +#include "gcc-plugin.h"
99707 +#include "tree.h"
99708 +#include "tm.h"
99709 +#include "rtl.h"
99710 +#ifdef ENABLE_BUILD_WITH_CXX
99711 +#warning $2
99712 +#else
99713 +#warning $1
99714 +#endif
99715 +EOF`
99716 +if [ $? -eq 0 ]
99717 +then
99718 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
99719 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
99720 +fi
99721 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
99722 index 5de5660..d3deb89 100644
99723 --- a/scripts/headers_install.sh
99724 +++ b/scripts/headers_install.sh
99725 @@ -32,6 +32,7 @@ do
99726 FILE="$(basename "$i")"
99727 sed -r \
99728 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
99729 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
99730 -e 's/__attribute_const__([ \t]|$)/\1/g' \
99731 -e 's@^#include <linux/compiler.h>@@' \
99732 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
99733 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
99734 index 2dcb377..a82c500 100644
99735 --- a/scripts/link-vmlinux.sh
99736 +++ b/scripts/link-vmlinux.sh
99737 @@ -162,7 +162,7 @@ else
99738 fi;
99739
99740 # final build of init/
99741 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
99742 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
99743
99744 kallsymso=""
99745 kallsyms_vmlinux=""
99746 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
99747 index 2370863..212fbca 100644
99748 --- a/scripts/mod/file2alias.c
99749 +++ b/scripts/mod/file2alias.c
99750 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
99751 unsigned long size, unsigned long id_size,
99752 void *symval)
99753 {
99754 - int i;
99755 + unsigned int i;
99756
99757 if (size % id_size || size < id_size) {
99758 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
99759 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
99760 /* USB is special because the bcdDevice can be matched against a numeric range */
99761 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
99762 static void do_usb_entry(void *symval,
99763 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
99764 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
99765 unsigned char range_lo, unsigned char range_hi,
99766 unsigned char max, struct module *mod)
99767 {
99768 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
99769 {
99770 unsigned int devlo, devhi;
99771 unsigned char chi, clo, max;
99772 - int ndigits;
99773 + unsigned int ndigits;
99774
99775 DEF_FIELD(symval, usb_device_id, match_flags);
99776 DEF_FIELD(symval, usb_device_id, idVendor);
99777 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
99778 for (i = 0; i < count; i++) {
99779 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
99780 char acpi_id[sizeof(*id)];
99781 - int j;
99782 + unsigned int j;
99783
99784 buf_printf(&mod->dev_table_buf,
99785 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
99786 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
99787
99788 for (j = 0; j < PNP_MAX_DEVICES; j++) {
99789 const char *id = (char *)(*devs)[j].id;
99790 - int i2, j2;
99791 + unsigned int i2, j2;
99792 int dup = 0;
99793
99794 if (!id[0])
99795 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
99796 /* add an individual alias for every device entry */
99797 if (!dup) {
99798 char acpi_id[PNP_ID_LEN];
99799 - int k;
99800 + unsigned int k;
99801
99802 buf_printf(&mod->dev_table_buf,
99803 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
99804 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
99805 static int do_dmi_entry(const char *filename, void *symval,
99806 char *alias)
99807 {
99808 - int i, j;
99809 + unsigned int i, j;
99810 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
99811 sprintf(alias, "dmi*");
99812
99813 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
99814 index 8247979..815ec76 100644
99815 --- a/scripts/mod/modpost.c
99816 +++ b/scripts/mod/modpost.c
99817 @@ -931,6 +931,7 @@ enum mismatch {
99818 ANY_INIT_TO_ANY_EXIT,
99819 ANY_EXIT_TO_ANY_INIT,
99820 EXPORT_TO_INIT_EXIT,
99821 + DATA_TO_TEXT
99822 };
99823
99824 struct sectioncheck {
99825 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
99826 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
99827 .mismatch = EXPORT_TO_INIT_EXIT,
99828 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
99829 +},
99830 +/* Do not reference code from writable data */
99831 +{
99832 + .fromsec = { DATA_SECTIONS, NULL },
99833 + .tosec = { TEXT_SECTIONS, NULL },
99834 + .mismatch = DATA_TO_TEXT
99835 }
99836 };
99837
99838 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
99839 continue;
99840 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
99841 continue;
99842 - if (sym->st_value == addr)
99843 - return sym;
99844 /* Find a symbol nearby - addr are maybe negative */
99845 d = sym->st_value - addr;
99846 + if (d == 0)
99847 + return sym;
99848 if (d < 0)
99849 d = addr - sym->st_value;
99850 if (d < distance) {
99851 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
99852 tosym, prl_to, prl_to, tosym);
99853 free(prl_to);
99854 break;
99855 + case DATA_TO_TEXT:
99856 +#if 0
99857 + fprintf(stderr,
99858 + "The %s %s:%s references\n"
99859 + "the %s %s:%s%s\n",
99860 + from, fromsec, fromsym, to, tosec, tosym, to_p);
99861 +#endif
99862 + break;
99863 }
99864 fprintf(stderr, "\n");
99865 }
99866 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
99867 static void check_sec_ref(struct module *mod, const char *modname,
99868 struct elf_info *elf)
99869 {
99870 - int i;
99871 + unsigned int i;
99872 Elf_Shdr *sechdrs = elf->sechdrs;
99873
99874 /* Walk through all sections */
99875 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
99876 va_end(ap);
99877 }
99878
99879 -void buf_write(struct buffer *buf, const char *s, int len)
99880 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
99881 {
99882 if (buf->size - buf->pos < len) {
99883 buf->size += len + SZ;
99884 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
99885 if (fstat(fileno(file), &st) < 0)
99886 goto close_write;
99887
99888 - if (st.st_size != b->pos)
99889 + if (st.st_size != (off_t)b->pos)
99890 goto close_write;
99891
99892 tmp = NOFAIL(malloc(b->pos));
99893 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
99894 index 51207e4..f7d603d 100644
99895 --- a/scripts/mod/modpost.h
99896 +++ b/scripts/mod/modpost.h
99897 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
99898
99899 struct buffer {
99900 char *p;
99901 - int pos;
99902 - int size;
99903 + unsigned int pos;
99904 + unsigned int size;
99905 };
99906
99907 void __attribute__((format(printf, 2, 3)))
99908 buf_printf(struct buffer *buf, const char *fmt, ...);
99909
99910 void
99911 -buf_write(struct buffer *buf, const char *s, int len);
99912 +buf_write(struct buffer *buf, const char *s, unsigned int len);
99913
99914 struct module {
99915 struct module *next;
99916 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
99917 index 9dfcd6d..099068e 100644
99918 --- a/scripts/mod/sumversion.c
99919 +++ b/scripts/mod/sumversion.c
99920 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
99921 goto out;
99922 }
99923
99924 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
99925 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
99926 warn("writing sum in %s failed: %s\n",
99927 filename, strerror(errno));
99928 goto out;
99929 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
99930 index 0865b3e..7235dd4 100644
99931 --- a/scripts/module-common.lds
99932 +++ b/scripts/module-common.lds
99933 @@ -6,6 +6,10 @@
99934 SECTIONS {
99935 /DISCARD/ : { *(.discard) }
99936
99937 + .rodata : {
99938 + *(.rodata) *(.rodata.*)
99939 + *(.data..read_only)
99940 + }
99941 __ksymtab : { *(SORT(___ksymtab+*)) }
99942 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
99943 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
99944 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
99945 index 90e521f..e9eaf8f 100644
99946 --- a/scripts/package/builddeb
99947 +++ b/scripts/package/builddeb
99948 @@ -281,6 +281,7 @@ fi
99949 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
99950 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
99951 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
99952 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
99953 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
99954 mkdir -p "$destdir"
99955 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
99956 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
99957 index 68bb4ef..2f419e1 100644
99958 --- a/scripts/pnmtologo.c
99959 +++ b/scripts/pnmtologo.c
99960 @@ -244,14 +244,14 @@ static void write_header(void)
99961 fprintf(out, " * Linux logo %s\n", logoname);
99962 fputs(" */\n\n", out);
99963 fputs("#include <linux/linux_logo.h>\n\n", out);
99964 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
99965 + fprintf(out, "static unsigned char %s_data[] = {\n",
99966 logoname);
99967 }
99968
99969 static void write_footer(void)
99970 {
99971 fputs("\n};\n\n", out);
99972 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
99973 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
99974 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
99975 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
99976 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
99977 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
99978 fputs("\n};\n\n", out);
99979
99980 /* write logo clut */
99981 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
99982 + fprintf(out, "static unsigned char %s_clut[] = {\n",
99983 logoname);
99984 write_hex_cnt = 0;
99985 for (i = 0; i < logo_clutsize; i++) {
99986 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
99987 index f5eb43d..1814de8 100644
99988 --- a/scripts/sortextable.h
99989 +++ b/scripts/sortextable.h
99990 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
99991 const char *secstrtab;
99992 const char *strtab;
99993 char *extab_image;
99994 - int extab_index = 0;
99995 - int i;
99996 - int idx;
99997 + unsigned int extab_index = 0;
99998 + unsigned int i;
99999 + unsigned int idx;
100000
100001 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
100002 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
100003 diff --git a/security/Kconfig b/security/Kconfig
100004 index e9c6ac7..9551ea7 100644
100005 --- a/security/Kconfig
100006 +++ b/security/Kconfig
100007 @@ -4,6 +4,958 @@
100008
100009 menu "Security options"
100010
100011 +menu "Grsecurity"
100012 +
100013 + config ARCH_TRACK_EXEC_LIMIT
100014 + bool
100015 +
100016 + config PAX_KERNEXEC_PLUGIN
100017 + bool
100018 +
100019 + config PAX_PER_CPU_PGD
100020 + bool
100021 +
100022 + config TASK_SIZE_MAX_SHIFT
100023 + int
100024 + depends on X86_64
100025 + default 47 if !PAX_PER_CPU_PGD
100026 + default 42 if PAX_PER_CPU_PGD
100027 +
100028 + config PAX_ENABLE_PAE
100029 + bool
100030 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
100031 +
100032 + config PAX_USERCOPY_SLABS
100033 + bool
100034 +
100035 +config GRKERNSEC
100036 + bool "Grsecurity"
100037 + select CRYPTO
100038 + select CRYPTO_SHA256
100039 + select PROC_FS
100040 + select STOP_MACHINE
100041 + select TTY
100042 + select DEBUG_LIST
100043 + help
100044 + If you say Y here, you will be able to configure many features
100045 + that will enhance the security of your system. It is highly
100046 + recommended that you say Y here and read through the help
100047 + for each option so that you fully understand the features and
100048 + can evaluate their usefulness for your machine.
100049 +
100050 +choice
100051 + prompt "Configuration Method"
100052 + depends on GRKERNSEC
100053 + default GRKERNSEC_CONFIG_CUSTOM
100054 + help
100055 +
100056 +config GRKERNSEC_CONFIG_AUTO
100057 + bool "Automatic"
100058 + help
100059 + If you choose this configuration method, you'll be able to answer a small
100060 + number of simple questions about how you plan to use this kernel.
100061 + The settings of grsecurity and PaX will be automatically configured for
100062 + the highest commonly-used settings within the provided constraints.
100063 +
100064 + If you require additional configuration, custom changes can still be made
100065 + from the "custom configuration" menu.
100066 +
100067 +config GRKERNSEC_CONFIG_CUSTOM
100068 + bool "Custom"
100069 + help
100070 + If you choose this configuration method, you'll be able to configure all
100071 + grsecurity and PaX settings manually. Via this method, no options are
100072 + automatically enabled.
100073 +
100074 +endchoice
100075 +
100076 +choice
100077 + prompt "Usage Type"
100078 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
100079 + default GRKERNSEC_CONFIG_SERVER
100080 + help
100081 +
100082 +config GRKERNSEC_CONFIG_SERVER
100083 + bool "Server"
100084 + help
100085 + Choose this option if you plan to use this kernel on a server.
100086 +
100087 +config GRKERNSEC_CONFIG_DESKTOP
100088 + bool "Desktop"
100089 + help
100090 + Choose this option if you plan to use this kernel on a desktop.
100091 +
100092 +endchoice
100093 +
100094 +choice
100095 + prompt "Virtualization Type"
100096 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
100097 + default GRKERNSEC_CONFIG_VIRT_NONE
100098 + help
100099 +
100100 +config GRKERNSEC_CONFIG_VIRT_NONE
100101 + bool "None"
100102 + help
100103 + Choose this option if this kernel will be run on bare metal.
100104 +
100105 +config GRKERNSEC_CONFIG_VIRT_GUEST
100106 + bool "Guest"
100107 + help
100108 + Choose this option if this kernel will be run as a VM guest.
100109 +
100110 +config GRKERNSEC_CONFIG_VIRT_HOST
100111 + bool "Host"
100112 + help
100113 + Choose this option if this kernel will be run as a VM host.
100114 +
100115 +endchoice
100116 +
100117 +choice
100118 + prompt "Virtualization Hardware"
100119 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
100120 + help
100121 +
100122 +config GRKERNSEC_CONFIG_VIRT_EPT
100123 + bool "EPT/RVI Processor Support"
100124 + depends on X86
100125 + help
100126 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
100127 + hardware virtualization. This allows for additional kernel hardening protections
100128 + to operate without additional performance impact.
100129 +
100130 + To see if your Intel processor supports EPT, see:
100131 + http://ark.intel.com/Products/VirtualizationTechnology
100132 + (Most Core i3/5/7 support EPT)
100133 +
100134 + To see if your AMD processor supports RVI, see:
100135 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
100136 +
100137 +config GRKERNSEC_CONFIG_VIRT_SOFT
100138 + bool "First-gen/No Hardware Virtualization"
100139 + help
100140 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
100141 + support hardware virtualization or doesn't support the EPT/RVI extensions.
100142 +
100143 +endchoice
100144 +
100145 +choice
100146 + prompt "Virtualization Software"
100147 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
100148 + help
100149 +
100150 +config GRKERNSEC_CONFIG_VIRT_XEN
100151 + bool "Xen"
100152 + help
100153 + Choose this option if this kernel is running as a Xen guest or host.
100154 +
100155 +config GRKERNSEC_CONFIG_VIRT_VMWARE
100156 + bool "VMWare"
100157 + help
100158 + Choose this option if this kernel is running as a VMWare guest or host.
100159 +
100160 +config GRKERNSEC_CONFIG_VIRT_KVM
100161 + bool "KVM"
100162 + help
100163 + Choose this option if this kernel is running as a KVM guest or host.
100164 +
100165 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
100166 + bool "VirtualBox"
100167 + help
100168 + Choose this option if this kernel is running as a VirtualBox guest or host.
100169 +
100170 +endchoice
100171 +
100172 +choice
100173 + prompt "Required Priorities"
100174 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
100175 + default GRKERNSEC_CONFIG_PRIORITY_PERF
100176 + help
100177 +
100178 +config GRKERNSEC_CONFIG_PRIORITY_PERF
100179 + bool "Performance"
100180 + help
100181 + Choose this option if performance is of highest priority for this deployment
100182 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
100183 + clearing of structures intended for userland, and freed memory sanitizing will
100184 + be disabled.
100185 +
100186 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
100187 + bool "Security"
100188 + help
100189 + Choose this option if security is of highest priority for this deployment of
100190 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
100191 + for userland, and freed memory sanitizing will be enabled for this kernel.
100192 + In a worst-case scenario, these features can introduce a 20% performance hit
100193 + (UDEREF on x64 contributing half of this hit).
100194 +
100195 +endchoice
100196 +
100197 +menu "Default Special Groups"
100198 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
100199 +
100200 +config GRKERNSEC_PROC_GID
100201 + int "GID exempted from /proc restrictions"
100202 + default 1001
100203 + help
100204 + Setting this GID determines which group will be exempted from
100205 + grsecurity's /proc restrictions, allowing users of the specified
100206 + group to view network statistics and the existence of other users'
100207 + processes on the system. This GID may also be chosen at boot time
100208 + via "grsec_proc_gid=" on the kernel commandline.
100209 +
100210 +config GRKERNSEC_TPE_UNTRUSTED_GID
100211 + int "GID for TPE-untrusted users"
100212 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
100213 + default 1005
100214 + help
100215 + Setting this GID determines which group untrusted users should
100216 + be added to. These users will be placed under grsecurity's Trusted Path
100217 + Execution mechanism, preventing them from executing their own binaries.
100218 + The users will only be able to execute binaries in directories owned and
100219 + writable only by the root user. If the sysctl option is enabled, a sysctl
100220 + option with name "tpe_gid" is created.
100221 +
100222 +config GRKERNSEC_TPE_TRUSTED_GID
100223 + int "GID for TPE-trusted users"
100224 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
100225 + default 1005
100226 + help
100227 + Setting this GID determines what group TPE restrictions will be
100228 + *disabled* for. If the sysctl option is enabled, a sysctl option
100229 + with name "tpe_gid" is created.
100230 +
100231 +config GRKERNSEC_SYMLINKOWN_GID
100232 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
100233 + depends on GRKERNSEC_CONFIG_SERVER
100234 + default 1006
100235 + help
100236 + Setting this GID determines what group kernel-enforced
100237 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
100238 + is enabled, a sysctl option with name "symlinkown_gid" is created.
100239 +
100240 +
100241 +endmenu
100242 +
100243 +menu "Customize Configuration"
100244 +depends on GRKERNSEC
100245 +
100246 +menu "PaX"
100247 +
100248 +config PAX
100249 + bool "Enable various PaX features"
100250 + default y if GRKERNSEC_CONFIG_AUTO
100251 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
100252 + help
100253 + This allows you to enable various PaX features. PaX adds
100254 + intrusion prevention mechanisms to the kernel that reduce
100255 + the risks posed by exploitable memory corruption bugs.
100256 +
100257 +menu "PaX Control"
100258 + depends on PAX
100259 +
100260 +config PAX_SOFTMODE
100261 + bool 'Support soft mode'
100262 + help
100263 + Enabling this option will allow you to run PaX in soft mode, that
100264 + is, PaX features will not be enforced by default, only on executables
100265 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
100266 + support as they are the only way to mark executables for soft mode use.
100267 +
100268 + Soft mode can be activated by using the "pax_softmode=1" kernel command
100269 + line option on boot. Furthermore you can control various PaX features
100270 + at runtime via the entries in /proc/sys/kernel/pax.
100271 +
100272 +config PAX_EI_PAX
100273 + bool 'Use legacy ELF header marking'
100274 + default y if GRKERNSEC_CONFIG_AUTO
100275 + help
100276 + Enabling this option will allow you to control PaX features on
100277 + a per executable basis via the 'chpax' utility available at
100278 + http://pax.grsecurity.net/. The control flags will be read from
100279 + an otherwise reserved part of the ELF header. This marking has
100280 + numerous drawbacks (no support for soft-mode, toolchain does not
100281 + know about the non-standard use of the ELF header) therefore it
100282 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
100283 + support.
100284 +
100285 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
100286 + support as well, they will override the legacy EI_PAX marks.
100287 +
100288 + If you enable none of the marking options then all applications
100289 + will run with PaX enabled on them by default.
100290 +
100291 +config PAX_PT_PAX_FLAGS
100292 + bool 'Use ELF program header marking'
100293 + default y if GRKERNSEC_CONFIG_AUTO
100294 + help
100295 + Enabling this option will allow you to control PaX features on
100296 + a per executable basis via the 'paxctl' utility available at
100297 + http://pax.grsecurity.net/. The control flags will be read from
100298 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
100299 + has the benefits of supporting both soft mode and being fully
100300 + integrated into the toolchain (the binutils patch is available
100301 + from http://pax.grsecurity.net).
100302 +
100303 + Note that if you enable the legacy EI_PAX marking support as well,
100304 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
100305 +
100306 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
100307 + must make sure that the marks are the same if a binary has both marks.
100308 +
100309 + If you enable none of the marking options then all applications
100310 + will run with PaX enabled on them by default.
100311 +
100312 +config PAX_XATTR_PAX_FLAGS
100313 + bool 'Use filesystem extended attributes marking'
100314 + default y if GRKERNSEC_CONFIG_AUTO
100315 + select CIFS_XATTR if CIFS
100316 + select EXT2_FS_XATTR if EXT2_FS
100317 + select EXT3_FS_XATTR if EXT3_FS
100318 + select JFFS2_FS_XATTR if JFFS2_FS
100319 + select REISERFS_FS_XATTR if REISERFS_FS
100320 + select SQUASHFS_XATTR if SQUASHFS
100321 + select TMPFS_XATTR if TMPFS
100322 + select UBIFS_FS_XATTR if UBIFS_FS
100323 + help
100324 + Enabling this option will allow you to control PaX features on
100325 + a per executable basis via the 'setfattr' utility. The control
100326 + flags will be read from the user.pax.flags extended attribute of
100327 + the file. This marking has the benefit of supporting binary-only
100328 + applications that self-check themselves (e.g., skype) and would
100329 + not tolerate chpax/paxctl changes. The main drawback is that
100330 + extended attributes are not supported by some filesystems (e.g.,
100331 + isofs, udf, vfat) so copying files through such filesystems will
100332 + lose the extended attributes and these PaX markings.
100333 +
100334 + Note that if you enable the legacy EI_PAX marking support as well,
100335 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
100336 +
100337 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
100338 + must make sure that the marks are the same if a binary has both marks.
100339 +
100340 + If you enable none of the marking options then all applications
100341 + will run with PaX enabled on them by default.
100342 +
100343 +choice
100344 + prompt 'MAC system integration'
100345 + default PAX_HAVE_ACL_FLAGS
100346 + help
100347 + Mandatory Access Control systems have the option of controlling
100348 + PaX flags on a per executable basis, choose the method supported
100349 + by your particular system.
100350 +
100351 + - "none": if your MAC system does not interact with PaX,
100352 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
100353 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
100354 +
100355 + NOTE: this option is for developers/integrators only.
100356 +
100357 + config PAX_NO_ACL_FLAGS
100358 + bool 'none'
100359 +
100360 + config PAX_HAVE_ACL_FLAGS
100361 + bool 'direct'
100362 +
100363 + config PAX_HOOK_ACL_FLAGS
100364 + bool 'hook'
100365 +endchoice
100366 +
100367 +endmenu
100368 +
100369 +menu "Non-executable pages"
100370 + depends on PAX
100371 +
100372 +config PAX_NOEXEC
100373 + bool "Enforce non-executable pages"
100374 + default y if GRKERNSEC_CONFIG_AUTO
100375 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
100376 + help
100377 + By design some architectures do not allow for protecting memory
100378 + pages against execution or even if they do, Linux does not make
100379 + use of this feature. In practice this means that if a page is
100380 + readable (such as the stack or heap) it is also executable.
100381 +
100382 + There is a well known exploit technique that makes use of this
100383 + fact and a common programming mistake where an attacker can
100384 + introduce code of his choice somewhere in the attacked program's
100385 + memory (typically the stack or the heap) and then execute it.
100386 +
100387 + If the attacked program was running with different (typically
100388 + higher) privileges than that of the attacker, then he can elevate
100389 + his own privilege level (e.g. get a root shell, write to files for
100390 + which he does not have write access to, etc).
100391 +
100392 + Enabling this option will let you choose from various features
100393 + that prevent the injection and execution of 'foreign' code in
100394 + a program.
100395 +
100396 + This will also break programs that rely on the old behaviour and
100397 + expect that dynamically allocated memory via the malloc() family
100398 + of functions is executable (which it is not). Notable examples
100399 + are the XFree86 4.x server, the java runtime and wine.
100400 +
100401 +config PAX_PAGEEXEC
100402 + bool "Paging based non-executable pages"
100403 + default y if GRKERNSEC_CONFIG_AUTO
100404 + 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)
100405 + select ARCH_TRACK_EXEC_LIMIT if X86_32
100406 + help
100407 + This implementation is based on the paging feature of the CPU.
100408 + On i386 without hardware non-executable bit support there is a
100409 + variable but usually low performance impact, however on Intel's
100410 + P4 core based CPUs it is very high so you should not enable this
100411 + for kernels meant to be used on such CPUs.
100412 +
100413 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
100414 + with hardware non-executable bit support there is no performance
100415 + impact, on ppc the impact is negligible.
100416 +
100417 + Note that several architectures require various emulations due to
100418 + badly designed userland ABIs, this will cause a performance impact
100419 + but will disappear as soon as userland is fixed. For example, ppc
100420 + userland MUST have been built with secure-plt by a recent toolchain.
100421 +
100422 +config PAX_SEGMEXEC
100423 + bool "Segmentation based non-executable pages"
100424 + default y if GRKERNSEC_CONFIG_AUTO
100425 + depends on PAX_NOEXEC && X86_32
100426 + help
100427 + This implementation is based on the segmentation feature of the
100428 + CPU and has a very small performance impact, however applications
100429 + will be limited to a 1.5 GB address space instead of the normal
100430 + 3 GB.
100431 +
100432 +config PAX_EMUTRAMP
100433 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
100434 + default y if PARISC
100435 + help
100436 + There are some programs and libraries that for one reason or
100437 + another attempt to execute special small code snippets from
100438 + non-executable memory pages. Most notable examples are the
100439 + signal handler return code generated by the kernel itself and
100440 + the GCC trampolines.
100441 +
100442 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
100443 + such programs will no longer work under your kernel.
100444 +
100445 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
100446 + utilities to enable trampoline emulation for the affected programs
100447 + yet still have the protection provided by the non-executable pages.
100448 +
100449 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
100450 + your system will not even boot.
100451 +
100452 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
100453 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
100454 + for the affected files.
100455 +
100456 + NOTE: enabling this feature *may* open up a loophole in the
100457 + protection provided by non-executable pages that an attacker
100458 + could abuse. Therefore the best solution is to not have any
100459 + files on your system that would require this option. This can
100460 + be achieved by not using libc5 (which relies on the kernel
100461 + signal handler return code) and not using or rewriting programs
100462 + that make use of the nested function implementation of GCC.
100463 + Skilled users can just fix GCC itself so that it implements
100464 + nested function calls in a way that does not interfere with PaX.
100465 +
100466 +config PAX_EMUSIGRT
100467 + bool "Automatically emulate sigreturn trampolines"
100468 + depends on PAX_EMUTRAMP && PARISC
100469 + default y
100470 + help
100471 + Enabling this option will have the kernel automatically detect
100472 + and emulate signal return trampolines executing on the stack
100473 + that would otherwise lead to task termination.
100474 +
100475 + This solution is intended as a temporary one for users with
100476 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
100477 + Modula-3 runtime, etc) or executables linked to such, basically
100478 + everything that does not specify its own SA_RESTORER function in
100479 + normal executable memory like glibc 2.1+ does.
100480 +
100481 + On parisc you MUST enable this option, otherwise your system will
100482 + not even boot.
100483 +
100484 + NOTE: this feature cannot be disabled on a per executable basis
100485 + and since it *does* open up a loophole in the protection provided
100486 + by non-executable pages, the best solution is to not have any
100487 + files on your system that would require this option.
100488 +
100489 +config PAX_MPROTECT
100490 + bool "Restrict mprotect()"
100491 + default y if GRKERNSEC_CONFIG_AUTO
100492 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
100493 + help
100494 + Enabling this option will prevent programs from
100495 + - changing the executable status of memory pages that were
100496 + not originally created as executable,
100497 + - making read-only executable pages writable again,
100498 + - creating executable pages from anonymous memory,
100499 + - making read-only-after-relocations (RELRO) data pages writable again.
100500 +
100501 + You should say Y here to complete the protection provided by
100502 + the enforcement of non-executable pages.
100503 +
100504 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
100505 + this feature on a per file basis.
100506 +
100507 +config PAX_MPROTECT_COMPAT
100508 + bool "Use legacy/compat protection demoting (read help)"
100509 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
100510 + depends on PAX_MPROTECT
100511 + help
100512 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
100513 + by sending the proper error code to the application. For some broken
100514 + userland, this can cause problems with Python or other applications. The
100515 + current implementation however allows for applications like clamav to
100516 + detect if JIT compilation/execution is allowed and to fall back gracefully
100517 + to an interpreter-based mode if it does not. While we encourage everyone
100518 + to use the current implementation as-is and push upstream to fix broken
100519 + userland (note that the RWX logging option can assist with this), in some
100520 + environments this may not be possible. Having to disable MPROTECT
100521 + completely on certain binaries reduces the security benefit of PaX,
100522 + so this option is provided for those environments to revert to the old
100523 + behavior.
100524 +
100525 +config PAX_ELFRELOCS
100526 + bool "Allow ELF text relocations (read help)"
100527 + depends on PAX_MPROTECT
100528 + default n
100529 + help
100530 + Non-executable pages and mprotect() restrictions are effective
100531 + in preventing the introduction of new executable code into an
100532 + attacked task's address space. There remain only two venues
100533 + for this kind of attack: if the attacker can execute already
100534 + existing code in the attacked task then he can either have it
100535 + create and mmap() a file containing his code or have it mmap()
100536 + an already existing ELF library that does not have position
100537 + independent code in it and use mprotect() on it to make it
100538 + writable and copy his code there. While protecting against
100539 + the former approach is beyond PaX, the latter can be prevented
100540 + by having only PIC ELF libraries on one's system (which do not
100541 + need to relocate their code). If you are sure this is your case,
100542 + as is the case with all modern Linux distributions, then leave
100543 + this option disabled. You should say 'n' here.
100544 +
100545 +config PAX_ETEXECRELOCS
100546 + bool "Allow ELF ET_EXEC text relocations"
100547 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
100548 + select PAX_ELFRELOCS
100549 + default y
100550 + help
100551 + On some architectures there are incorrectly created applications
100552 + that require text relocations and would not work without enabling
100553 + this option. If you are an alpha, ia64 or parisc user, you should
100554 + enable this option and disable it once you have made sure that
100555 + none of your applications need it.
100556 +
100557 +config PAX_EMUPLT
100558 + bool "Automatically emulate ELF PLT"
100559 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
100560 + default y
100561 + help
100562 + Enabling this option will have the kernel automatically detect
100563 + and emulate the Procedure Linkage Table entries in ELF files.
100564 + On some architectures such entries are in writable memory, and
100565 + become non-executable leading to task termination. Therefore
100566 + it is mandatory that you enable this option on alpha, parisc,
100567 + sparc and sparc64, otherwise your system would not even boot.
100568 +
100569 + NOTE: this feature *does* open up a loophole in the protection
100570 + provided by the non-executable pages, therefore the proper
100571 + solution is to modify the toolchain to produce a PLT that does
100572 + not need to be writable.
100573 +
100574 +config PAX_DLRESOLVE
100575 + bool 'Emulate old glibc resolver stub'
100576 + depends on PAX_EMUPLT && SPARC
100577 + default n
100578 + help
100579 + This option is needed if userland has an old glibc (before 2.4)
100580 + that puts a 'save' instruction into the runtime generated resolver
100581 + stub that needs special emulation.
100582 +
100583 +config PAX_KERNEXEC
100584 + bool "Enforce non-executable kernel pages"
100585 + 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))
100586 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
100587 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
100588 + select PAX_KERNEXEC_PLUGIN if X86_64
100589 + help
100590 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
100591 + that is, enabling this option will make it harder to inject
100592 + and execute 'foreign' code in kernel memory itself.
100593 +
100594 +choice
100595 + prompt "Return Address Instrumentation Method"
100596 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
100597 + depends on PAX_KERNEXEC_PLUGIN
100598 + help
100599 + Select the method used to instrument function pointer dereferences.
100600 + Note that binary modules cannot be instrumented by this approach.
100601 +
100602 + Note that the implementation requires a gcc with plugin support,
100603 + i.e., gcc 4.5 or newer. You may need to install the supporting
100604 + headers explicitly in addition to the normal gcc package.
100605 +
100606 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
100607 + bool "bts"
100608 + help
100609 + This method is compatible with binary only modules but has
100610 + a higher runtime overhead.
100611 +
100612 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
100613 + bool "or"
100614 + depends on !PARAVIRT
100615 + help
100616 + This method is incompatible with binary only modules but has
100617 + a lower runtime overhead.
100618 +endchoice
100619 +
100620 +config PAX_KERNEXEC_PLUGIN_METHOD
100621 + string
100622 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
100623 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
100624 + default ""
100625 +
100626 +config PAX_KERNEXEC_MODULE_TEXT
100627 + int "Minimum amount of memory reserved for module code"
100628 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
100629 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
100630 + depends on PAX_KERNEXEC && X86_32
100631 + help
100632 + Due to implementation details the kernel must reserve a fixed
100633 + amount of memory for runtime allocated code (such as modules)
100634 + at compile time that cannot be changed at runtime. Here you
100635 + can specify the minimum amount in MB that will be reserved.
100636 + Due to the same implementation details this size will always
100637 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
100638 + the actually available memory for runtime allocated code will
100639 + usually be more than this minimum.
100640 +
100641 + The default 4 MB should be enough for most users but if you have
100642 + an excessive number of modules (e.g., most distribution configs
100643 + compile many drivers as modules) or use huge modules such as
100644 + nvidia's kernel driver, you will need to adjust this amount.
100645 + A good rule of thumb is to look at your currently loaded kernel
100646 + modules and add up their sizes.
100647 +
100648 +endmenu
100649 +
100650 +menu "Address Space Layout Randomization"
100651 + depends on PAX
100652 +
100653 +config PAX_ASLR
100654 + bool "Address Space Layout Randomization"
100655 + default y if GRKERNSEC_CONFIG_AUTO
100656 + help
100657 + Many if not most exploit techniques rely on the knowledge of
100658 + certain addresses in the attacked program. The following options
100659 + will allow the kernel to apply a certain amount of randomization
100660 + to specific parts of the program thereby forcing an attacker to
100661 + guess them in most cases. Any failed guess will most likely crash
100662 + the attacked program which allows the kernel to detect such attempts
100663 + and react on them. PaX itself provides no reaction mechanisms,
100664 + instead it is strongly encouraged that you make use of Nergal's
100665 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
100666 + (http://www.grsecurity.net/) built-in crash detection features or
100667 + develop one yourself.
100668 +
100669 + By saying Y here you can choose to randomize the following areas:
100670 + - top of the task's kernel stack
100671 + - top of the task's userland stack
100672 + - base address for mmap() requests that do not specify one
100673 + (this includes all libraries)
100674 + - base address of the main executable
100675 +
100676 + It is strongly recommended to say Y here as address space layout
100677 + randomization has negligible impact on performance yet it provides
100678 + a very effective protection.
100679 +
100680 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
100681 + this feature on a per file basis.
100682 +
100683 +config PAX_RANDKSTACK
100684 + bool "Randomize kernel stack base"
100685 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
100686 + depends on X86_TSC && X86
100687 + help
100688 + By saying Y here the kernel will randomize every task's kernel
100689 + stack on every system call. This will not only force an attacker
100690 + to guess it but also prevent him from making use of possible
100691 + leaked information about it.
100692 +
100693 + Since the kernel stack is a rather scarce resource, randomization
100694 + may cause unexpected stack overflows, therefore you should very
100695 + carefully test your system. Note that once enabled in the kernel
100696 + configuration, this feature cannot be disabled on a per file basis.
100697 +
100698 +config PAX_RANDUSTACK
100699 + bool "Randomize user stack base"
100700 + default y if GRKERNSEC_CONFIG_AUTO
100701 + depends on PAX_ASLR
100702 + help
100703 + By saying Y here the kernel will randomize every task's userland
100704 + stack. The randomization is done in two steps where the second
100705 + one may apply a big amount of shift to the top of the stack and
100706 + cause problems for programs that want to use lots of memory (more
100707 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
100708 + For this reason the second step can be controlled by 'chpax' or
100709 + 'paxctl' on a per file basis.
100710 +
100711 +config PAX_RANDMMAP
100712 + bool "Randomize mmap() base"
100713 + default y if GRKERNSEC_CONFIG_AUTO
100714 + depends on PAX_ASLR
100715 + help
100716 + By saying Y here the kernel will use a randomized base address for
100717 + mmap() requests that do not specify one themselves. As a result
100718 + all dynamically loaded libraries will appear at random addresses
100719 + and therefore be harder to exploit by a technique where an attacker
100720 + attempts to execute library code for his purposes (e.g. spawn a
100721 + shell from an exploited program that is running at an elevated
100722 + privilege level).
100723 +
100724 + Furthermore, if a program is relinked as a dynamic ELF file, its
100725 + base address will be randomized as well, completing the full
100726 + randomization of the address space layout. Attacking such programs
100727 + becomes a guess game. You can find an example of doing this at
100728 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
100729 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
100730 +
100731 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
100732 + feature on a per file basis.
100733 +
100734 +endmenu
100735 +
100736 +menu "Miscellaneous hardening features"
100737 +
100738 +config PAX_MEMORY_SANITIZE
100739 + bool "Sanitize all freed memory"
100740 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
100741 + help
100742 + By saying Y here the kernel will erase memory pages and slab objects
100743 + as soon as they are freed. This in turn reduces the lifetime of data
100744 + stored in them, making it less likely that sensitive information such
100745 + as passwords, cryptographic secrets, etc stay in memory for too long.
100746 +
100747 + This is especially useful for programs whose runtime is short, long
100748 + lived processes and the kernel itself benefit from this as long as
100749 + they ensure timely freeing of memory that may hold sensitive
100750 + information.
100751 +
100752 + A nice side effect of the sanitization of slab objects is the
100753 + reduction of possible info leaks caused by padding bytes within the
100754 + leaky structures. Use-after-free bugs for structures containing
100755 + pointers can also be detected as dereferencing the sanitized pointer
100756 + will generate an access violation.
100757 +
100758 + The tradeoff is performance impact, on a single CPU system kernel
100759 + compilation sees a 3% slowdown, other systems and workloads may vary
100760 + and you are advised to test this feature on your expected workload
100761 + before deploying it.
100762 +
100763 + To reduce the performance penalty by sanitizing pages only, albeit
100764 + limiting the effectiveness of this feature at the same time, slab
100765 + sanitization can be disabled with the kernel commandline parameter
100766 + "pax_sanitize_slab=0".
100767 +
100768 + Note that this feature does not protect data stored in live pages,
100769 + e.g., process memory swapped to disk may stay there for a long time.
100770 +
100771 +config PAX_MEMORY_STACKLEAK
100772 + bool "Sanitize kernel stack"
100773 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
100774 + depends on X86
100775 + help
100776 + By saying Y here the kernel will erase the kernel stack before it
100777 + returns from a system call. This in turn reduces the information
100778 + that a kernel stack leak bug can reveal.
100779 +
100780 + Note that such a bug can still leak information that was put on
100781 + the stack by the current system call (the one eventually triggering
100782 + the bug) but traces of earlier system calls on the kernel stack
100783 + cannot leak anymore.
100784 +
100785 + The tradeoff is performance impact: on a single CPU system kernel
100786 + compilation sees a 1% slowdown, other systems and workloads may vary
100787 + and you are advised to test this feature on your expected workload
100788 + before deploying it.
100789 +
100790 + Note that the full feature requires a gcc with plugin support,
100791 + i.e., gcc 4.5 or newer. You may need to install the supporting
100792 + headers explicitly in addition to the normal gcc package. Using
100793 + older gcc versions means that functions with large enough stack
100794 + frames may leave uninitialized memory behind that may be exposed
100795 + to a later syscall leaking the stack.
100796 +
100797 +config PAX_MEMORY_STRUCTLEAK
100798 + bool "Forcibly initialize local variables copied to userland"
100799 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
100800 + help
100801 + By saying Y here the kernel will zero initialize some local
100802 + variables that are going to be copied to userland. This in
100803 + turn prevents unintended information leakage from the kernel
100804 + stack should later code forget to explicitly set all parts of
100805 + the copied variable.
100806 +
100807 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
100808 + at a much smaller coverage.
100809 +
100810 + Note that the implementation requires a gcc with plugin support,
100811 + i.e., gcc 4.5 or newer. You may need to install the supporting
100812 + headers explicitly in addition to the normal gcc package.
100813 +
100814 +config PAX_MEMORY_UDEREF
100815 + bool "Prevent invalid userland pointer dereference"
100816 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
100817 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
100818 + select PAX_PER_CPU_PGD if X86_64
100819 + help
100820 + By saying Y here the kernel will be prevented from dereferencing
100821 + userland pointers in contexts where the kernel expects only kernel
100822 + pointers. This is both a useful runtime debugging feature and a
100823 + security measure that prevents exploiting a class of kernel bugs.
100824 +
100825 + The tradeoff is that some virtualization solutions may experience
100826 + a huge slowdown and therefore you should not enable this feature
100827 + for kernels meant to run in such environments. Whether a given VM
100828 + solution is affected or not is best determined by simply trying it
100829 + out, the performance impact will be obvious right on boot as this
100830 + mechanism engages from very early on. A good rule of thumb is that
100831 + VMs running on CPUs without hardware virtualization support (i.e.,
100832 + the majority of IA-32 CPUs) will likely experience the slowdown.
100833 +
100834 + On X86_64 the kernel will make use of PCID support when available
100835 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
100836 + or performance impact. Pass pax_weakuderef on the kernel command
100837 + line to choose the latter.
100838 +
100839 +config PAX_REFCOUNT
100840 + bool "Prevent various kernel object reference counter overflows"
100841 + default y if GRKERNSEC_CONFIG_AUTO
100842 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
100843 + help
100844 + By saying Y here the kernel will detect and prevent overflowing
100845 + various (but not all) kinds of object reference counters. Such
100846 + overflows can normally occur due to bugs only and are often, if
100847 + not always, exploitable.
100848 +
100849 + The tradeoff is that data structures protected by an overflowed
100850 + refcount will never be freed and therefore will leak memory. Note
100851 + that this leak also happens even without this protection but in
100852 + that case the overflow can eventually trigger the freeing of the
100853 + data structure while it is still being used elsewhere, resulting
100854 + in the exploitable situation that this feature prevents.
100855 +
100856 + Since this has a negligible performance impact, you should enable
100857 + this feature.
100858 +
100859 +config PAX_CONSTIFY_PLUGIN
100860 + bool "Automatically constify eligible structures"
100861 + default y
100862 + depends on !UML && PAX_KERNEXEC
100863 + help
100864 + By saying Y here the compiler will automatically constify a class
100865 + of types that contain only function pointers. This reduces the
100866 + kernel's attack surface and also produces a better memory layout.
100867 +
100868 + Note that the implementation requires a gcc with plugin support,
100869 + i.e., gcc 4.5 or newer. You may need to install the supporting
100870 + headers explicitly in addition to the normal gcc package.
100871 +
100872 + Note that if some code really has to modify constified variables
100873 + then the source code will have to be patched to allow it. Examples
100874 + can be found in PaX itself (the no_const attribute) and for some
100875 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
100876 +
100877 +config PAX_USERCOPY
100878 + bool "Harden heap object copies between kernel and userland"
100879 + default y if GRKERNSEC_CONFIG_AUTO
100880 + depends on ARM || IA64 || PPC || SPARC || X86
100881 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
100882 + select PAX_USERCOPY_SLABS
100883 + help
100884 + By saying Y here the kernel will enforce the size of heap objects
100885 + when they are copied in either direction between the kernel and
100886 + userland, even if only a part of the heap object is copied.
100887 +
100888 + Specifically, this checking prevents information leaking from the
100889 + kernel heap during kernel to userland copies (if the kernel heap
100890 + object is otherwise fully initialized) and prevents kernel heap
100891 + overflows during userland to kernel copies.
100892 +
100893 + Note that the current implementation provides the strictest bounds
100894 + checks for the SLUB allocator.
100895 +
100896 + Enabling this option also enables per-slab cache protection against
100897 + data in a given cache being copied into/out of via userland
100898 + accessors. Though the whitelist of regions will be reduced over
100899 + time, it notably protects important data structures like task structs.
100900 +
100901 + If frame pointers are enabled on x86, this option will also restrict
100902 + copies into and out of the kernel stack to local variables within a
100903 + single frame.
100904 +
100905 + Since this has a negligible performance impact, you should enable
100906 + this feature.
100907 +
100908 +config PAX_USERCOPY_DEBUG
100909 + bool
100910 + depends on X86 && PAX_USERCOPY
100911 + default n
100912 +
100913 +config PAX_SIZE_OVERFLOW
100914 + bool "Prevent various integer overflows in function size parameters"
100915 + default y if GRKERNSEC_CONFIG_AUTO
100916 + depends on X86
100917 + help
100918 + By saying Y here the kernel recomputes expressions of function
100919 + arguments marked by a size_overflow attribute with double integer
100920 + precision (DImode/TImode for 32/64 bit integer types).
100921 +
100922 + The recomputed argument is checked against TYPE_MAX and an event
100923 + is logged on overflow and the triggering process is killed.
100924 +
100925 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
100926 +
100927 + Note that the implementation requires a gcc with plugin support,
100928 + i.e., gcc 4.5 or newer. You may need to install the supporting
100929 + headers explicitly in addition to the normal gcc package.
100930 +
100931 +config PAX_LATENT_ENTROPY
100932 + bool "Generate some entropy during boot and runtime"
100933 + default y if GRKERNSEC_CONFIG_AUTO
100934 + help
100935 + By saying Y here the kernel will instrument some kernel code to
100936 + extract some entropy from both original and artificially created
100937 + program state. This will help especially embedded systems where
100938 + there is little 'natural' source of entropy normally. The cost
100939 + is some slowdown of the boot process and fork and irq processing.
100940 +
100941 + When pax_extra_latent_entropy is passed on the kernel command line,
100942 + entropy will be extracted from up to the first 4GB of RAM while the
100943 + runtime memory allocator is being initialized. This costs even more
100944 + slowdown of the boot process.
100945 +
100946 + Note that the implementation requires a gcc with plugin support,
100947 + i.e., gcc 4.5 or newer. You may need to install the supporting
100948 + headers explicitly in addition to the normal gcc package.
100949 +
100950 + Note that entropy extracted this way is not cryptographically
100951 + secure!
100952 +
100953 +endmenu
100954 +
100955 +endmenu
100956 +
100957 +source grsecurity/Kconfig
100958 +
100959 +endmenu
100960 +
100961 +endmenu
100962 +
100963 source security/keys/Kconfig
100964
100965 config SECURITY_DMESG_RESTRICT
100966 @@ -103,7 +1055,7 @@ config INTEL_TXT
100967 config LSM_MMAP_MIN_ADDR
100968 int "Low address space for LSM to protect from user allocation"
100969 depends on SECURITY && SECURITY_SELINUX
100970 - default 32768 if ARM
100971 + default 32768 if ALPHA || ARM || PARISC || SPARC32
100972 default 65536
100973 help
100974 This is the portion of low virtual memory which should be protected
100975 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
100976 index fb99e18..b3e0bbb 100644
100977 --- a/security/apparmor/lsm.c
100978 +++ b/security/apparmor/lsm.c
100979 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
100980 return error;
100981 }
100982
100983 -static struct security_operations apparmor_ops = {
100984 +static struct security_operations apparmor_ops __read_only = {
100985 .name = "apparmor",
100986
100987 .ptrace_access_check = apparmor_ptrace_access_check,
100988 diff --git a/security/commoncap.c b/security/commoncap.c
100989 index b9d613e..f68305c 100644
100990 --- a/security/commoncap.c
100991 +++ b/security/commoncap.c
100992 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
100993 return 0;
100994 }
100995
100996 +/* returns:
100997 + 1 for suid privilege
100998 + 2 for sgid privilege
100999 + 3 for fscap privilege
101000 +*/
101001 +int is_privileged_binary(const struct dentry *dentry)
101002 +{
101003 + struct cpu_vfs_cap_data capdata;
101004 + struct inode *inode = dentry->d_inode;
101005 +
101006 + if (!inode || S_ISDIR(inode->i_mode))
101007 + return 0;
101008 +
101009 + if (inode->i_mode & S_ISUID)
101010 + return 1;
101011 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
101012 + return 2;
101013 +
101014 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
101015 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
101016 + return 3;
101017 + }
101018 +
101019 + return 0;
101020 +}
101021 +
101022 /*
101023 * Attempt to get the on-exec apply capability sets for an executable file from
101024 * its xattrs and, if present, apply them to the proposed credentials being
101025 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
101026 const struct cred *cred = current_cred();
101027 kuid_t root_uid = make_kuid(cred->user_ns, 0);
101028
101029 + if (gr_acl_enable_at_secure())
101030 + return 1;
101031 +
101032 if (!uid_eq(cred->uid, root_uid)) {
101033 if (bprm->cap_effective)
101034 return 1;
101035 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
101036 index b3dd616..4bb17f3 100644
101037 --- a/security/integrity/ima/ima.h
101038 +++ b/security/integrity/ima/ima.h
101039 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
101040 extern spinlock_t ima_queue_lock;
101041
101042 struct ima_h_table {
101043 - atomic_long_t len; /* number of stored measurements in the list */
101044 - atomic_long_t violations;
101045 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
101046 + atomic_long_unchecked_t violations;
101047 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
101048 };
101049 extern struct ima_h_table ima_htable;
101050 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
101051 index 1c03e8f1..398a941 100644
101052 --- a/security/integrity/ima/ima_api.c
101053 +++ b/security/integrity/ima/ima_api.c
101054 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
101055 int result;
101056
101057 /* can overflow, only indicator */
101058 - atomic_long_inc(&ima_htable.violations);
101059 + atomic_long_inc_unchecked(&ima_htable.violations);
101060
101061 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
101062 if (!entry) {
101063 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
101064 index 38477c9..87a60c7 100644
101065 --- a/security/integrity/ima/ima_fs.c
101066 +++ b/security/integrity/ima/ima_fs.c
101067 @@ -28,12 +28,12 @@
101068 static int valid_policy = 1;
101069 #define TMPBUFLEN 12
101070 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
101071 - loff_t *ppos, atomic_long_t *val)
101072 + loff_t *ppos, atomic_long_unchecked_t *val)
101073 {
101074 char tmpbuf[TMPBUFLEN];
101075 ssize_t len;
101076
101077 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
101078 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
101079 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
101080 }
101081
101082 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
101083 index ff63fe0..809cd96 100644
101084 --- a/security/integrity/ima/ima_queue.c
101085 +++ b/security/integrity/ima/ima_queue.c
101086 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
101087 INIT_LIST_HEAD(&qe->later);
101088 list_add_tail_rcu(&qe->later, &ima_measurements);
101089
101090 - atomic_long_inc(&ima_htable.len);
101091 + atomic_long_inc_unchecked(&ima_htable.len);
101092 key = ima_hash_key(entry->digest);
101093 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
101094 return 0;
101095 diff --git a/security/keys/compat.c b/security/keys/compat.c
101096 index d65fa7f..cbfe366 100644
101097 --- a/security/keys/compat.c
101098 +++ b/security/keys/compat.c
101099 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
101100 if (ret == 0)
101101 goto no_payload_free;
101102
101103 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
101104 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
101105 err:
101106 if (iov != iovstack)
101107 kfree(iov);
101108 diff --git a/security/keys/internal.h b/security/keys/internal.h
101109 index d4f1468..cc52f92 100644
101110 --- a/security/keys/internal.h
101111 +++ b/security/keys/internal.h
101112 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
101113 extern long keyctl_invalidate_key(key_serial_t);
101114
101115 extern long keyctl_instantiate_key_common(key_serial_t,
101116 - const struct iovec *,
101117 + const struct iovec __user *,
101118 unsigned, size_t, key_serial_t);
101119
101120 /*
101121 diff --git a/security/keys/key.c b/security/keys/key.c
101122 index 8fb7c7b..ba3610d 100644
101123 --- a/security/keys/key.c
101124 +++ b/security/keys/key.c
101125 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
101126
101127 atomic_set(&key->usage, 1);
101128 init_rwsem(&key->sem);
101129 - lockdep_set_class(&key->sem, &type->lock_class);
101130 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
101131 key->type = type;
101132 key->user = user;
101133 key->quotalen = quotalen;
101134 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
101135 struct key_type *p;
101136 int ret;
101137
101138 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
101139 + pax_open_kernel();
101140 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
101141 + pax_close_kernel();
101142
101143 ret = -EEXIST;
101144 down_write(&key_types_sem);
101145 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
101146 }
101147
101148 /* store the type */
101149 - list_add(&ktype->link, &key_types_list);
101150 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
101151
101152 pr_notice("Key type %s registered\n", ktype->name);
101153 ret = 0;
101154 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
101155 void unregister_key_type(struct key_type *ktype)
101156 {
101157 down_write(&key_types_sem);
101158 - list_del_init(&ktype->link);
101159 + pax_list_del_init((struct list_head *)&ktype->link);
101160 downgrade_write(&key_types_sem);
101161 key_gc_keytype(ktype);
101162 pr_notice("Key type %s unregistered\n", ktype->name);
101163 @@ -1084,10 +1086,10 @@ void __init key_init(void)
101164 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
101165
101166 /* add the special key types */
101167 - list_add_tail(&key_type_keyring.link, &key_types_list);
101168 - list_add_tail(&key_type_dead.link, &key_types_list);
101169 - list_add_tail(&key_type_user.link, &key_types_list);
101170 - list_add_tail(&key_type_logon.link, &key_types_list);
101171 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
101172 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
101173 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
101174 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
101175
101176 /* record the root user tracking */
101177 rb_link_node(&root_key_user.node,
101178 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
101179 index 33cfd27..842fc5a 100644
101180 --- a/security/keys/keyctl.c
101181 +++ b/security/keys/keyctl.c
101182 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
101183 /*
101184 * Copy the iovec data from userspace
101185 */
101186 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
101187 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
101188 unsigned ioc)
101189 {
101190 for (; ioc > 0; ioc--) {
101191 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
101192 * If successful, 0 will be returned.
101193 */
101194 long keyctl_instantiate_key_common(key_serial_t id,
101195 - const struct iovec *payload_iov,
101196 + const struct iovec __user *payload_iov,
101197 unsigned ioc,
101198 size_t plen,
101199 key_serial_t ringid)
101200 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
101201 [0].iov_len = plen
101202 };
101203
101204 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
101205 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
101206 }
101207
101208 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
101209 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
101210 if (ret == 0)
101211 goto no_payload_free;
101212
101213 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
101214 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
101215 err:
101216 if (iov != iovstack)
101217 kfree(iov);
101218 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
101219 index 6ece7f2..ecdb55c 100644
101220 --- a/security/keys/keyring.c
101221 +++ b/security/keys/keyring.c
101222 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
101223 ret = -EFAULT;
101224
101225 for (loop = 0; loop < klist->nkeys; loop++) {
101226 + key_serial_t serial;
101227 key = rcu_deref_link_locked(klist, loop,
101228 keyring);
101229 + serial = key->serial;
101230
101231 tmp = sizeof(key_serial_t);
101232 if (tmp > buflen)
101233 tmp = buflen;
101234
101235 - if (copy_to_user(buffer,
101236 - &key->serial,
101237 - tmp) != 0)
101238 + if (copy_to_user(buffer, &serial, tmp))
101239 goto error;
101240
101241 buflen -= tmp;
101242 diff --git a/security/min_addr.c b/security/min_addr.c
101243 index f728728..6457a0c 100644
101244 --- a/security/min_addr.c
101245 +++ b/security/min_addr.c
101246 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
101247 */
101248 static void update_mmap_min_addr(void)
101249 {
101250 +#ifndef SPARC
101251 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
101252 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
101253 mmap_min_addr = dac_mmap_min_addr;
101254 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
101255 #else
101256 mmap_min_addr = dac_mmap_min_addr;
101257 #endif
101258 +#endif
101259 }
101260
101261 /*
101262 diff --git a/security/security.c b/security/security.c
101263 index 4dc31f4..eabcf41 100644
101264 --- a/security/security.c
101265 +++ b/security/security.c
101266 @@ -33,8 +33,8 @@
101267 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
101268 CONFIG_DEFAULT_SECURITY;
101269
101270 -static struct security_operations *security_ops;
101271 -static struct security_operations default_security_ops = {
101272 +struct security_operations *security_ops __read_only;
101273 +struct security_operations default_security_ops __read_only = {
101274 .name = "default",
101275 };
101276
101277 @@ -73,11 +73,6 @@ int __init security_init(void)
101278 return 0;
101279 }
101280
101281 -void reset_security_ops(void)
101282 -{
101283 - security_ops = &default_security_ops;
101284 -}
101285 -
101286 /* Save user chosen LSM */
101287 static int __init choose_lsm(char *str)
101288 {
101289 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
101290 index fc3e662..7844c60 100644
101291 --- a/security/selinux/avc.c
101292 +++ b/security/selinux/avc.c
101293 @@ -59,7 +59,7 @@ struct avc_node {
101294 struct avc_cache {
101295 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
101296 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
101297 - atomic_t lru_hint; /* LRU hint for reclaim scan */
101298 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
101299 atomic_t active_nodes;
101300 u32 latest_notif; /* latest revocation notification */
101301 };
101302 @@ -167,7 +167,7 @@ void __init avc_init(void)
101303 spin_lock_init(&avc_cache.slots_lock[i]);
101304 }
101305 atomic_set(&avc_cache.active_nodes, 0);
101306 - atomic_set(&avc_cache.lru_hint, 0);
101307 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
101308
101309 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
101310 0, SLAB_PANIC, NULL);
101311 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
101312 spinlock_t *lock;
101313
101314 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
101315 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
101316 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
101317 head = &avc_cache.slots[hvalue];
101318 lock = &avc_cache.slots_lock[hvalue];
101319
101320 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
101321 index 392a044..c3eb2bd 100644
101322 --- a/security/selinux/hooks.c
101323 +++ b/security/selinux/hooks.c
101324 @@ -220,6 +220,14 @@ static int inode_alloc_security(struct inode *inode)
101325 return 0;
101326 }
101327
101328 +static void inode_free_rcu(struct rcu_head *head)
101329 +{
101330 + struct inode_security_struct *isec;
101331 +
101332 + isec = container_of(head, struct inode_security_struct, rcu);
101333 + kmem_cache_free(sel_inode_cache, isec);
101334 +}
101335 +
101336 static void inode_free_security(struct inode *inode)
101337 {
101338 struct inode_security_struct *isec = inode->i_security;
101339 @@ -230,8 +238,16 @@ static void inode_free_security(struct inode *inode)
101340 list_del_init(&isec->list);
101341 spin_unlock(&sbsec->isec_lock);
101342
101343 - inode->i_security = NULL;
101344 - kmem_cache_free(sel_inode_cache, isec);
101345 + /*
101346 + * The inode may still be referenced in a path walk and
101347 + * a call to selinux_inode_permission() can be made
101348 + * after inode_free_security() is called. Ideally, the VFS
101349 + * wouldn't do this, but fixing that is a much harder
101350 + * job. For now, simply free the i_security via RCU, and
101351 + * leave the current inode->i_security pointer intact.
101352 + * The inode will be freed after the RCU grace period too.
101353 + */
101354 + call_rcu(&isec->rcu, inode_free_rcu);
101355 }
101356
101357 static int file_alloc_security(struct file *file)
101358 @@ -5693,7 +5709,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
101359
101360 #endif
101361
101362 -static struct security_operations selinux_ops = {
101363 +static struct security_operations selinux_ops __read_only = {
101364 .name = "selinux",
101365
101366 .ptrace_access_check = selinux_ptrace_access_check,
101367 @@ -6045,6 +6061,9 @@ static void selinux_nf_ip_exit(void)
101368 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
101369 static int selinux_disabled;
101370
101371 +extern struct security_operations *security_ops;
101372 +extern struct security_operations default_security_ops;
101373 +
101374 int selinux_disable(void)
101375 {
101376 if (ss_initialized) {
101377 @@ -6062,7 +6081,9 @@ int selinux_disable(void)
101378 selinux_disabled = 1;
101379 selinux_enabled = 0;
101380
101381 - reset_security_ops();
101382 + pax_open_kernel();
101383 + security_ops = &default_security_ops;
101384 + pax_close_kernel();
101385
101386 /* Try to destroy the avc node cache */
101387 avc_disable();
101388 diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
101389 index aa47bca..6fd9dd2 100644
101390 --- a/security/selinux/include/objsec.h
101391 +++ b/security/selinux/include/objsec.h
101392 @@ -38,7 +38,10 @@ struct task_security_struct {
101393
101394 struct inode_security_struct {
101395 struct inode *inode; /* back pointer to inode object */
101396 - struct list_head list; /* list of inode_security_struct */
101397 + union {
101398 + struct list_head list; /* list of inode_security_struct */
101399 + struct rcu_head rcu; /* for freeing the inode_security_struct */
101400 + };
101401 u32 task_sid; /* SID of creating task */
101402 u32 sid; /* SID of this object */
101403 u16 sclass; /* security class of this object */
101404 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
101405 index c1af4e1..bcb003c 100644
101406 --- a/security/selinux/include/xfrm.h
101407 +++ b/security/selinux/include/xfrm.h
101408 @@ -53,7 +53,7 @@ static inline void selinux_xfrm_notify_policyload(void)
101409 {
101410 struct net *net;
101411
101412 - atomic_inc(&flow_cache_genid);
101413 + atomic_inc_unchecked(&flow_cache_genid);
101414 rtnl_lock();
101415 for_each_net(net)
101416 rt_genid_bump_all(net);
101417 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
101418 index 8825375..97a623b 100644
101419 --- a/security/smack/smack_lsm.c
101420 +++ b/security/smack/smack_lsm.c
101421 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
101422 return 0;
101423 }
101424
101425 -struct security_operations smack_ops = {
101426 +struct security_operations smack_ops __read_only = {
101427 .name = "smack",
101428
101429 .ptrace_access_check = smack_ptrace_access_check,
101430 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
101431 index 390c646..f2f8db3 100644
101432 --- a/security/tomoyo/mount.c
101433 +++ b/security/tomoyo/mount.c
101434 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
101435 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
101436 need_dev = -1; /* dev_name is a directory */
101437 } else {
101438 + if (!capable(CAP_SYS_ADMIN)) {
101439 + error = -EPERM;
101440 + goto out;
101441 + }
101442 fstype = get_fs_type(type);
101443 if (!fstype) {
101444 error = -ENODEV;
101445 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
101446 index f0b756e..b129202 100644
101447 --- a/security/tomoyo/tomoyo.c
101448 +++ b/security/tomoyo/tomoyo.c
101449 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
101450 * tomoyo_security_ops is a "struct security_operations" which is used for
101451 * registering TOMOYO.
101452 */
101453 -static struct security_operations tomoyo_security_ops = {
101454 +static struct security_operations tomoyo_security_ops __read_only = {
101455 .name = "tomoyo",
101456 .cred_alloc_blank = tomoyo_cred_alloc_blank,
101457 .cred_prepare = tomoyo_cred_prepare,
101458 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
101459 index 20ef514..4182bed 100644
101460 --- a/security/yama/Kconfig
101461 +++ b/security/yama/Kconfig
101462 @@ -1,6 +1,6 @@
101463 config SECURITY_YAMA
101464 bool "Yama support"
101465 - depends on SECURITY
101466 + depends on SECURITY && !GRKERNSEC
101467 select SECURITYFS
101468 select SECURITY_PATH
101469 default n
101470 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
101471 index 13c88fbc..f8c115e 100644
101472 --- a/security/yama/yama_lsm.c
101473 +++ b/security/yama/yama_lsm.c
101474 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
101475 }
101476
101477 #ifndef CONFIG_SECURITY_YAMA_STACKED
101478 -static struct security_operations yama_ops = {
101479 +static struct security_operations yama_ops __read_only = {
101480 .name = "yama",
101481
101482 .ptrace_access_check = yama_ptrace_access_check,
101483 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
101484 #endif
101485
101486 #ifdef CONFIG_SYSCTL
101487 +static int zero __read_only;
101488 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
101489 +
101490 static int yama_dointvec_minmax(struct ctl_table *table, int write,
101491 void __user *buffer, size_t *lenp, loff_t *ppos)
101492 {
101493 - int rc;
101494 + ctl_table_no_const yama_table;
101495
101496 if (write && !capable(CAP_SYS_PTRACE))
101497 return -EPERM;
101498
101499 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
101500 - if (rc)
101501 - return rc;
101502 -
101503 + yama_table = *table;
101504 /* Lock the max value if it ever gets set. */
101505 - if (write && *(int *)table->data == *(int *)table->extra2)
101506 - table->extra1 = table->extra2;
101507 -
101508 - return rc;
101509 + if (ptrace_scope == max_scope)
101510 + yama_table.extra1 = &max_scope;
101511 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
101512 }
101513
101514 -static int zero;
101515 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
101516 -
101517 struct ctl_path yama_sysctl_path[] = {
101518 { .procname = "kernel", },
101519 { .procname = "yama", },
101520 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
101521 index 4cedc69..e59d8a3 100644
101522 --- a/sound/aoa/codecs/onyx.c
101523 +++ b/sound/aoa/codecs/onyx.c
101524 @@ -54,7 +54,7 @@ struct onyx {
101525 spdif_locked:1,
101526 analog_locked:1,
101527 original_mute:2;
101528 - int open_count;
101529 + local_t open_count;
101530 struct codec_info *codec_info;
101531
101532 /* mutex serializes concurrent access to the device
101533 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
101534 struct onyx *onyx = cii->codec_data;
101535
101536 mutex_lock(&onyx->mutex);
101537 - onyx->open_count++;
101538 + local_inc(&onyx->open_count);
101539 mutex_unlock(&onyx->mutex);
101540
101541 return 0;
101542 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
101543 struct onyx *onyx = cii->codec_data;
101544
101545 mutex_lock(&onyx->mutex);
101546 - onyx->open_count--;
101547 - if (!onyx->open_count)
101548 + if (local_dec_and_test(&onyx->open_count))
101549 onyx->spdif_locked = onyx->analog_locked = 0;
101550 mutex_unlock(&onyx->mutex);
101551
101552 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
101553 index ffd2025..df062c9 100644
101554 --- a/sound/aoa/codecs/onyx.h
101555 +++ b/sound/aoa/codecs/onyx.h
101556 @@ -11,6 +11,7 @@
101557 #include <linux/i2c.h>
101558 #include <asm/pmac_low_i2c.h>
101559 #include <asm/prom.h>
101560 +#include <asm/local.h>
101561
101562 /* PCM3052 register definitions */
101563
101564 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
101565 index 4c1cc51..16040040 100644
101566 --- a/sound/core/oss/pcm_oss.c
101567 +++ b/sound/core/oss/pcm_oss.c
101568 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
101569 if (in_kernel) {
101570 mm_segment_t fs;
101571 fs = snd_enter_user();
101572 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
101573 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
101574 snd_leave_user(fs);
101575 } else {
101576 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
101577 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
101578 }
101579 if (ret != -EPIPE && ret != -ESTRPIPE)
101580 break;
101581 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
101582 if (in_kernel) {
101583 mm_segment_t fs;
101584 fs = snd_enter_user();
101585 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
101586 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
101587 snd_leave_user(fs);
101588 } else {
101589 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
101590 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
101591 }
101592 if (ret == -EPIPE) {
101593 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
101594 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
101595 struct snd_pcm_plugin_channel *channels;
101596 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
101597 if (!in_kernel) {
101598 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
101599 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
101600 return -EFAULT;
101601 buf = runtime->oss.buffer;
101602 }
101603 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
101604 }
101605 } else {
101606 tmp = snd_pcm_oss_write2(substream,
101607 - (const char __force *)buf,
101608 + (const char __force_kernel *)buf,
101609 runtime->oss.period_bytes, 0);
101610 if (tmp <= 0)
101611 goto err;
101612 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
101613 struct snd_pcm_runtime *runtime = substream->runtime;
101614 snd_pcm_sframes_t frames, frames1;
101615 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
101616 - char __user *final_dst = (char __force __user *)buf;
101617 + char __user *final_dst = (char __force_user *)buf;
101618 if (runtime->oss.plugin_first) {
101619 struct snd_pcm_plugin_channel *channels;
101620 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
101621 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
101622 xfer += tmp;
101623 runtime->oss.buffer_used -= tmp;
101624 } else {
101625 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
101626 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
101627 runtime->oss.period_bytes, 0);
101628 if (tmp <= 0)
101629 goto err;
101630 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
101631 size1);
101632 size1 /= runtime->channels; /* frames */
101633 fs = snd_enter_user();
101634 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
101635 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
101636 snd_leave_user(fs);
101637 }
101638 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
101639 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
101640 index af49721..e85058e 100644
101641 --- a/sound/core/pcm_compat.c
101642 +++ b/sound/core/pcm_compat.c
101643 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
101644 int err;
101645
101646 fs = snd_enter_user();
101647 - err = snd_pcm_delay(substream, &delay);
101648 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
101649 snd_leave_user(fs);
101650 if (err < 0)
101651 return err;
101652 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
101653 index a68d4c6..72af3cf 100644
101654 --- a/sound/core/pcm_native.c
101655 +++ b/sound/core/pcm_native.c
101656 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
101657 switch (substream->stream) {
101658 case SNDRV_PCM_STREAM_PLAYBACK:
101659 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
101660 - (void __user *)arg);
101661 + (void __force_user *)arg);
101662 break;
101663 case SNDRV_PCM_STREAM_CAPTURE:
101664 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
101665 - (void __user *)arg);
101666 + (void __force_user *)arg);
101667 break;
101668 default:
101669 result = -EINVAL;
101670 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
101671 index 040c60e..989a19a 100644
101672 --- a/sound/core/seq/seq_device.c
101673 +++ b/sound/core/seq/seq_device.c
101674 @@ -64,7 +64,7 @@ struct ops_list {
101675 int argsize; /* argument size */
101676
101677 /* operators */
101678 - struct snd_seq_dev_ops ops;
101679 + struct snd_seq_dev_ops *ops;
101680
101681 /* registered devices */
101682 struct list_head dev_list; /* list of devices */
101683 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
101684
101685 mutex_lock(&ops->reg_mutex);
101686 /* copy driver operators */
101687 - ops->ops = *entry;
101688 + ops->ops = entry;
101689 ops->driver |= DRIVER_LOADED;
101690 ops->argsize = argsize;
101691
101692 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
101693 dev->name, ops->id, ops->argsize, dev->argsize);
101694 return -EINVAL;
101695 }
101696 - if (ops->ops.init_device(dev) >= 0) {
101697 + if (ops->ops->init_device(dev) >= 0) {
101698 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
101699 ops->num_init_devices++;
101700 } else {
101701 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
101702 dev->name, ops->id, ops->argsize, dev->argsize);
101703 return -EINVAL;
101704 }
101705 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
101706 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
101707 dev->status = SNDRV_SEQ_DEVICE_FREE;
101708 dev->driver_data = NULL;
101709 ops->num_init_devices--;
101710 diff --git a/sound/core/sound.c b/sound/core/sound.c
101711 index f002bd9..c462985 100644
101712 --- a/sound/core/sound.c
101713 +++ b/sound/core/sound.c
101714 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
101715 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
101716 default: return;
101717 }
101718 - request_module(str);
101719 + request_module("%s", str);
101720 }
101721
101722 #endif /* modular kernel */
101723 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
101724 index 4e0dd22..7a1f32c 100644
101725 --- a/sound/drivers/mts64.c
101726 +++ b/sound/drivers/mts64.c
101727 @@ -29,6 +29,7 @@
101728 #include <sound/initval.h>
101729 #include <sound/rawmidi.h>
101730 #include <sound/control.h>
101731 +#include <asm/local.h>
101732
101733 #define CARD_NAME "Miditerminal 4140"
101734 #define DRIVER_NAME "MTS64"
101735 @@ -67,7 +68,7 @@ struct mts64 {
101736 struct pardevice *pardev;
101737 int pardev_claimed;
101738
101739 - int open_count;
101740 + local_t open_count;
101741 int current_midi_output_port;
101742 int current_midi_input_port;
101743 u8 mode[MTS64_NUM_INPUT_PORTS];
101744 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
101745 {
101746 struct mts64 *mts = substream->rmidi->private_data;
101747
101748 - if (mts->open_count == 0) {
101749 + if (local_read(&mts->open_count) == 0) {
101750 /* We don't need a spinlock here, because this is just called
101751 if the device has not been opened before.
101752 So there aren't any IRQs from the device */
101753 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
101754
101755 msleep(50);
101756 }
101757 - ++(mts->open_count);
101758 + local_inc(&mts->open_count);
101759
101760 return 0;
101761 }
101762 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
101763 struct mts64 *mts = substream->rmidi->private_data;
101764 unsigned long flags;
101765
101766 - --(mts->open_count);
101767 - if (mts->open_count == 0) {
101768 + if (local_dec_return(&mts->open_count) == 0) {
101769 /* We need the spinlock_irqsave here because we can still
101770 have IRQs at this point */
101771 spin_lock_irqsave(&mts->lock, flags);
101772 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
101773
101774 msleep(500);
101775
101776 - } else if (mts->open_count < 0)
101777 - mts->open_count = 0;
101778 + } else if (local_read(&mts->open_count) < 0)
101779 + local_set(&mts->open_count, 0);
101780
101781 return 0;
101782 }
101783 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
101784 index b953fb4..1999c01 100644
101785 --- a/sound/drivers/opl4/opl4_lib.c
101786 +++ b/sound/drivers/opl4/opl4_lib.c
101787 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
101788 MODULE_DESCRIPTION("OPL4 driver");
101789 MODULE_LICENSE("GPL");
101790
101791 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
101792 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
101793 {
101794 int timeout = 10;
101795 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
101796 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
101797 index 991018d..8984740 100644
101798 --- a/sound/drivers/portman2x4.c
101799 +++ b/sound/drivers/portman2x4.c
101800 @@ -48,6 +48,7 @@
101801 #include <sound/initval.h>
101802 #include <sound/rawmidi.h>
101803 #include <sound/control.h>
101804 +#include <asm/local.h>
101805
101806 #define CARD_NAME "Portman 2x4"
101807 #define DRIVER_NAME "portman"
101808 @@ -85,7 +86,7 @@ struct portman {
101809 struct pardevice *pardev;
101810 int pardev_claimed;
101811
101812 - int open_count;
101813 + local_t open_count;
101814 int mode[PORTMAN_NUM_INPUT_PORTS];
101815 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
101816 };
101817 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
101818 index ea995af..f1bfa37 100644
101819 --- a/sound/firewire/amdtp.c
101820 +++ b/sound/firewire/amdtp.c
101821 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
101822 ptr = s->pcm_buffer_pointer + data_blocks;
101823 if (ptr >= pcm->runtime->buffer_size)
101824 ptr -= pcm->runtime->buffer_size;
101825 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
101826 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
101827
101828 s->pcm_period_pointer += data_blocks;
101829 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
101830 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
101831 */
101832 void amdtp_out_stream_update(struct amdtp_out_stream *s)
101833 {
101834 - ACCESS_ONCE(s->source_node_id_field) =
101835 + ACCESS_ONCE_RW(s->source_node_id_field) =
101836 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
101837 }
101838 EXPORT_SYMBOL(amdtp_out_stream_update);
101839 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
101840 index f6103d6..4843fbf 100644
101841 --- a/sound/firewire/amdtp.h
101842 +++ b/sound/firewire/amdtp.h
101843 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
101844 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
101845 struct snd_pcm_substream *pcm)
101846 {
101847 - ACCESS_ONCE(s->pcm) = pcm;
101848 + ACCESS_ONCE_RW(s->pcm) = pcm;
101849 }
101850
101851 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
101852 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
101853 index 58a5afe..af5bd64 100644
101854 --- a/sound/firewire/isight.c
101855 +++ b/sound/firewire/isight.c
101856 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
101857 ptr += count;
101858 if (ptr >= runtime->buffer_size)
101859 ptr -= runtime->buffer_size;
101860 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
101861 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
101862
101863 isight->period_counter += count;
101864 if (isight->period_counter >= runtime->period_size) {
101865 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
101866 if (err < 0)
101867 return err;
101868
101869 - ACCESS_ONCE(isight->pcm_active) = true;
101870 + ACCESS_ONCE_RW(isight->pcm_active) = true;
101871
101872 return 0;
101873 }
101874 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
101875 {
101876 struct isight *isight = substream->private_data;
101877
101878 - ACCESS_ONCE(isight->pcm_active) = false;
101879 + ACCESS_ONCE_RW(isight->pcm_active) = false;
101880
101881 mutex_lock(&isight->mutex);
101882 isight_stop_streaming(isight);
101883 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
101884
101885 switch (cmd) {
101886 case SNDRV_PCM_TRIGGER_START:
101887 - ACCESS_ONCE(isight->pcm_running) = true;
101888 + ACCESS_ONCE_RW(isight->pcm_running) = true;
101889 break;
101890 case SNDRV_PCM_TRIGGER_STOP:
101891 - ACCESS_ONCE(isight->pcm_running) = false;
101892 + ACCESS_ONCE_RW(isight->pcm_running) = false;
101893 break;
101894 default:
101895 return -EINVAL;
101896 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
101897 index 505fc81..62e569e 100644
101898 --- a/sound/firewire/scs1x.c
101899 +++ b/sound/firewire/scs1x.c
101900 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
101901 {
101902 struct scs *scs = stream->rmidi->private_data;
101903
101904 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
101905 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
101906 if (up) {
101907 scs->output_idle = false;
101908 tasklet_schedule(&scs->tasklet);
101909 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
101910 {
101911 struct scs *scs = stream->rmidi->private_data;
101912
101913 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
101914 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
101915 }
101916
101917 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
101918 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
101919
101920 snd_card_disconnect(scs->card);
101921
101922 - ACCESS_ONCE(scs->output) = NULL;
101923 - ACCESS_ONCE(scs->input) = NULL;
101924 + ACCESS_ONCE_RW(scs->output) = NULL;
101925 + ACCESS_ONCE_RW(scs->input) = NULL;
101926
101927 wait_event(scs->idle_wait, scs->output_idle);
101928
101929 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
101930 index 048439a..3be9f6f 100644
101931 --- a/sound/oss/sb_audio.c
101932 +++ b/sound/oss/sb_audio.c
101933 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
101934 buf16 = (signed short *)(localbuf + localoffs);
101935 while (c)
101936 {
101937 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101938 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101939 if (copy_from_user(lbuf8,
101940 userbuf+useroffs + p,
101941 locallen))
101942 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
101943 index 7d8803a..559f8d0 100644
101944 --- a/sound/oss/swarm_cs4297a.c
101945 +++ b/sound/oss/swarm_cs4297a.c
101946 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
101947 {
101948 struct cs4297a_state *s;
101949 u32 pwr, id;
101950 - mm_segment_t fs;
101951 int rval;
101952 #ifndef CONFIG_BCM_CS4297A_CSWARM
101953 u64 cfg;
101954 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
101955 if (!rval) {
101956 char *sb1250_duart_present;
101957
101958 +#if 0
101959 + mm_segment_t fs;
101960 fs = get_fs();
101961 set_fs(KERNEL_DS);
101962 -#if 0
101963 val = SOUND_MASK_LINE;
101964 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
101965 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
101966 val = initvol[i].vol;
101967 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
101968 }
101969 + set_fs(fs);
101970 // cs4297a_write_ac97(s, 0x18, 0x0808);
101971 #else
101972 // cs4297a_write_ac97(s, 0x5e, 0x180);
101973 cs4297a_write_ac97(s, 0x02, 0x0808);
101974 cs4297a_write_ac97(s, 0x18, 0x0808);
101975 #endif
101976 - set_fs(fs);
101977
101978 list_add(&s->list, &cs4297a_devs);
101979
101980 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
101981 index e938a68..2a728ad 100644
101982 --- a/sound/pci/hda/hda_codec.c
101983 +++ b/sound/pci/hda/hda_codec.c
101984 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
101985 mutex_unlock(&preset_mutex);
101986
101987 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
101988 - char name[32];
101989 if (!mod_requested)
101990 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
101991 - codec->vendor_id);
101992 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
101993 else
101994 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
101995 - (codec->vendor_id >> 16) & 0xffff);
101996 - request_module(name);
101997 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
101998 mod_requested++;
101999 goto again;
102000 }
102001 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
102002 index 4631a23..001ae57 100644
102003 --- a/sound/pci/ymfpci/ymfpci.h
102004 +++ b/sound/pci/ymfpci/ymfpci.h
102005 @@ -358,7 +358,7 @@ struct snd_ymfpci {
102006 spinlock_t reg_lock;
102007 spinlock_t voice_lock;
102008 wait_queue_head_t interrupt_sleep;
102009 - atomic_t interrupt_sleep_count;
102010 + atomic_unchecked_t interrupt_sleep_count;
102011 struct snd_info_entry *proc_entry;
102012 const struct firmware *dsp_microcode;
102013 const struct firmware *controller_microcode;
102014 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
102015 index d591c15..8cb8f94 100644
102016 --- a/sound/pci/ymfpci/ymfpci_main.c
102017 +++ b/sound/pci/ymfpci/ymfpci_main.c
102018 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
102019 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
102020 break;
102021 }
102022 - if (atomic_read(&chip->interrupt_sleep_count)) {
102023 - atomic_set(&chip->interrupt_sleep_count, 0);
102024 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
102025 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
102026 wake_up(&chip->interrupt_sleep);
102027 }
102028 __end:
102029 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
102030 continue;
102031 init_waitqueue_entry(&wait, current);
102032 add_wait_queue(&chip->interrupt_sleep, &wait);
102033 - atomic_inc(&chip->interrupt_sleep_count);
102034 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
102035 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
102036 remove_wait_queue(&chip->interrupt_sleep, &wait);
102037 }
102038 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
102039 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
102040 spin_unlock(&chip->reg_lock);
102041
102042 - if (atomic_read(&chip->interrupt_sleep_count)) {
102043 - atomic_set(&chip->interrupt_sleep_count, 0);
102044 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
102045 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
102046 wake_up(&chip->interrupt_sleep);
102047 }
102048 }
102049 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
102050 spin_lock_init(&chip->reg_lock);
102051 spin_lock_init(&chip->voice_lock);
102052 init_waitqueue_head(&chip->interrupt_sleep);
102053 - atomic_set(&chip->interrupt_sleep_count, 0);
102054 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
102055 chip->card = card;
102056 chip->pci = pci;
102057 chip->irq = -1;
102058 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
102059 index 6b81d0c..031c056 100644
102060 --- a/sound/soc/fsl/fsl_ssi.c
102061 +++ b/sound/soc/fsl/fsl_ssi.c
102062 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
102063 {
102064 struct fsl_ssi_private *ssi_private;
102065 int ret = 0;
102066 - struct device_attribute *dev_attr = NULL;
102067 + device_attribute_no_const *dev_attr = NULL;
102068 struct device_node *np = pdev->dev.of_node;
102069 const char *p, *sprop;
102070 const uint32_t *iprop;
102071 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
102072 index 1a38be0..66809d1 100644
102073 --- a/sound/soc/soc-core.c
102074 +++ b/sound/soc/soc-core.c
102075 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
102076 if (ret)
102077 return ret;
102078
102079 - ops->warm_reset = snd_soc_ac97_warm_reset;
102080 - ops->reset = snd_soc_ac97_reset;
102081 + pax_open_kernel();
102082 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
102083 + *(void **)&ops->reset = snd_soc_ac97_reset;
102084 + pax_close_kernel();
102085
102086 snd_ac97_rst_cfg = cfg;
102087 return 0;
102088 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
102089 new file mode 100644
102090 index 0000000..50f2f2f
102091 --- /dev/null
102092 +++ b/tools/gcc/.gitignore
102093 @@ -0,0 +1 @@
102094 +size_overflow_hash.h
102095 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
102096 new file mode 100644
102097 index 0000000..144dbee
102098 --- /dev/null
102099 +++ b/tools/gcc/Makefile
102100 @@ -0,0 +1,45 @@
102101 +#CC := gcc
102102 +#PLUGIN_SOURCE_FILES := pax_plugin.c
102103 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
102104 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
102105 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
102106 +
102107 +ifeq ($(PLUGINCC),$(HOSTCC))
102108 +HOSTLIBS := hostlibs
102109 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
102110 +else
102111 +HOSTLIBS := hostcxxlibs
102112 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
102113 +endif
102114 +
102115 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
102116 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
102117 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
102118 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
102119 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
102120 +$(HOSTLIBS)-y += colorize_plugin.so
102121 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
102122 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
102123 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
102124 +
102125 +always := $($(HOSTLIBS)-y)
102126 +
102127 +constify_plugin-objs := constify_plugin.o
102128 +stackleak_plugin-objs := stackleak_plugin.o
102129 +kallocstat_plugin-objs := kallocstat_plugin.o
102130 +kernexec_plugin-objs := kernexec_plugin.o
102131 +checker_plugin-objs := checker_plugin.o
102132 +colorize_plugin-objs := colorize_plugin.o
102133 +size_overflow_plugin-objs := size_overflow_plugin.o
102134 +latent_entropy_plugin-objs := latent_entropy_plugin.o
102135 +structleak_plugin-objs := structleak_plugin.o
102136 +
102137 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
102138 +
102139 +quiet_cmd_build_size_overflow_hash = GENHASH $@
102140 + cmd_build_size_overflow_hash = \
102141 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
102142 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
102143 + $(call if_changed,build_size_overflow_hash)
102144 +
102145 +targets += size_overflow_hash.h
102146 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
102147 new file mode 100644
102148 index 0000000..22f03c0
102149 --- /dev/null
102150 +++ b/tools/gcc/checker_plugin.c
102151 @@ -0,0 +1,172 @@
102152 +/*
102153 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
102154 + * Licensed under the GPL v2
102155 + *
102156 + * Note: the choice of the license means that the compilation process is
102157 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102158 + * but for the kernel it doesn't matter since it doesn't link against
102159 + * any of the gcc libraries
102160 + *
102161 + * gcc plugin to implement various sparse (source code checker) features
102162 + *
102163 + * TODO:
102164 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
102165 + *
102166 + * BUGS:
102167 + * - none known
102168 + */
102169 +#include "gcc-plugin.h"
102170 +#include "config.h"
102171 +#include "system.h"
102172 +#include "coretypes.h"
102173 +#include "tree.h"
102174 +#include "tree-pass.h"
102175 +#include "flags.h"
102176 +#include "intl.h"
102177 +#include "toplev.h"
102178 +#include "plugin.h"
102179 +//#include "expr.h" where are you...
102180 +#include "diagnostic.h"
102181 +#include "plugin-version.h"
102182 +#include "tm.h"
102183 +#include "function.h"
102184 +#include "basic-block.h"
102185 +#include "gimple.h"
102186 +#include "rtl.h"
102187 +#include "emit-rtl.h"
102188 +#include "tree-flow.h"
102189 +#include "target.h"
102190 +
102191 +extern void c_register_addr_space (const char *str, addr_space_t as);
102192 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
102193 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
102194 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
102195 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
102196 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
102197 +
102198 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102199 +extern rtx emit_move_insn(rtx x, rtx y);
102200 +
102201 +int plugin_is_GPL_compatible;
102202 +
102203 +static struct plugin_info checker_plugin_info = {
102204 + .version = "201111150100",
102205 + .help = NULL,
102206 +};
102207 +
102208 +#define ADDR_SPACE_KERNEL 0
102209 +#define ADDR_SPACE_FORCE_KERNEL 1
102210 +#define ADDR_SPACE_USER 2
102211 +#define ADDR_SPACE_FORCE_USER 3
102212 +#define ADDR_SPACE_IOMEM 0
102213 +#define ADDR_SPACE_FORCE_IOMEM 0
102214 +#define ADDR_SPACE_PERCPU 0
102215 +#define ADDR_SPACE_FORCE_PERCPU 0
102216 +#define ADDR_SPACE_RCU 0
102217 +#define ADDR_SPACE_FORCE_RCU 0
102218 +
102219 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
102220 +{
102221 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
102222 +}
102223 +
102224 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
102225 +{
102226 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
102227 +}
102228 +
102229 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
102230 +{
102231 + return default_addr_space_valid_pointer_mode(mode, as);
102232 +}
102233 +
102234 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
102235 +{
102236 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
102237 +}
102238 +
102239 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
102240 +{
102241 + return default_addr_space_legitimize_address(x, oldx, mode, as);
102242 +}
102243 +
102244 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
102245 +{
102246 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
102247 + return true;
102248 +
102249 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
102250 + return true;
102251 +
102252 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
102253 + return true;
102254 +
102255 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
102256 + return true;
102257 +
102258 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
102259 + return true;
102260 +
102261 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
102262 + return true;
102263 +
102264 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
102265 + return true;
102266 +
102267 + return subset == superset;
102268 +}
102269 +
102270 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
102271 +{
102272 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
102273 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
102274 +
102275 + return op;
102276 +}
102277 +
102278 +static void register_checker_address_spaces(void *event_data, void *data)
102279 +{
102280 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
102281 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
102282 + c_register_addr_space("__user", ADDR_SPACE_USER);
102283 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
102284 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
102285 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
102286 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
102287 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
102288 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
102289 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
102290 +
102291 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
102292 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
102293 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
102294 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
102295 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
102296 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
102297 + targetm.addr_space.convert = checker_addr_space_convert;
102298 +}
102299 +
102300 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102301 +{
102302 + const char * const plugin_name = plugin_info->base_name;
102303 + const int argc = plugin_info->argc;
102304 + const struct plugin_argument * const argv = plugin_info->argv;
102305 + int i;
102306 +
102307 + if (!plugin_default_version_check(version, &gcc_version)) {
102308 + error(G_("incompatible gcc/plugin versions"));
102309 + return 1;
102310 + }
102311 +
102312 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
102313 +
102314 + for (i = 0; i < argc; ++i)
102315 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102316 +
102317 + if (TARGET_64BIT == 0)
102318 + return 0;
102319 +
102320 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
102321 +
102322 + return 0;
102323 +}
102324 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
102325 new file mode 100644
102326 index 0000000..414fe5e
102327 --- /dev/null
102328 +++ b/tools/gcc/colorize_plugin.c
102329 @@ -0,0 +1,151 @@
102330 +/*
102331 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
102332 + * Licensed under the GPL v2
102333 + *
102334 + * Note: the choice of the license means that the compilation process is
102335 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102336 + * but for the kernel it doesn't matter since it doesn't link against
102337 + * any of the gcc libraries
102338 + *
102339 + * gcc plugin to colorize diagnostic output
102340 + *
102341 + */
102342 +
102343 +#include "gcc-plugin.h"
102344 +#include "config.h"
102345 +#include "system.h"
102346 +#include "coretypes.h"
102347 +#include "tree.h"
102348 +#include "tree-pass.h"
102349 +#include "flags.h"
102350 +#include "intl.h"
102351 +#include "toplev.h"
102352 +#include "plugin.h"
102353 +#include "diagnostic.h"
102354 +#include "plugin-version.h"
102355 +#include "tm.h"
102356 +
102357 +int plugin_is_GPL_compatible;
102358 +
102359 +static struct plugin_info colorize_plugin_info = {
102360 + .version = "201302112000",
102361 + .help = NULL,
102362 +};
102363 +
102364 +#define GREEN "\033[32m\033[2m"
102365 +#define LIGHTGREEN "\033[32m\033[1m"
102366 +#define YELLOW "\033[33m\033[2m"
102367 +#define LIGHTYELLOW "\033[33m\033[1m"
102368 +#define RED "\033[31m\033[2m"
102369 +#define LIGHTRED "\033[31m\033[1m"
102370 +#define BLUE "\033[34m\033[2m"
102371 +#define LIGHTBLUE "\033[34m\033[1m"
102372 +#define BRIGHT "\033[m\033[1m"
102373 +#define NORMAL "\033[m"
102374 +
102375 +static diagnostic_starter_fn old_starter;
102376 +static diagnostic_finalizer_fn old_finalizer;
102377 +
102378 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
102379 +{
102380 + const char *color;
102381 + char *newprefix;
102382 +
102383 + switch (diagnostic->kind) {
102384 + case DK_NOTE:
102385 + color = LIGHTBLUE;
102386 + break;
102387 +
102388 + case DK_PEDWARN:
102389 + case DK_WARNING:
102390 + color = LIGHTYELLOW;
102391 + break;
102392 +
102393 + case DK_ERROR:
102394 + case DK_FATAL:
102395 + case DK_ICE:
102396 + case DK_PERMERROR:
102397 + case DK_SORRY:
102398 + color = LIGHTRED;
102399 + break;
102400 +
102401 + default:
102402 + color = NORMAL;
102403 + }
102404 +
102405 + old_starter(context, diagnostic);
102406 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
102407 + return;
102408 + pp_destroy_prefix(context->printer);
102409 + pp_set_prefix(context->printer, newprefix);
102410 +}
102411 +
102412 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
102413 +{
102414 + old_finalizer(context, diagnostic);
102415 +}
102416 +
102417 +static void colorize_arm(void)
102418 +{
102419 + old_starter = diagnostic_starter(global_dc);
102420 + old_finalizer = diagnostic_finalizer(global_dc);
102421 +
102422 + diagnostic_starter(global_dc) = start_colorize;
102423 + diagnostic_finalizer(global_dc) = finalize_colorize;
102424 +}
102425 +
102426 +static unsigned int execute_colorize_rearm(void)
102427 +{
102428 + if (diagnostic_starter(global_dc) == start_colorize)
102429 + return 0;
102430 +
102431 + colorize_arm();
102432 + return 0;
102433 +}
102434 +
102435 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
102436 + .pass = {
102437 + .type = SIMPLE_IPA_PASS,
102438 + .name = "colorize_rearm",
102439 +#if BUILDING_GCC_VERSION >= 4008
102440 + .optinfo_flags = OPTGROUP_NONE,
102441 +#endif
102442 + .gate = NULL,
102443 + .execute = execute_colorize_rearm,
102444 + .sub = NULL,
102445 + .next = NULL,
102446 + .static_pass_number = 0,
102447 + .tv_id = TV_NONE,
102448 + .properties_required = 0,
102449 + .properties_provided = 0,
102450 + .properties_destroyed = 0,
102451 + .todo_flags_start = 0,
102452 + .todo_flags_finish = 0
102453 + }
102454 +};
102455 +
102456 +static void colorize_start_unit(void *gcc_data, void *user_data)
102457 +{
102458 + colorize_arm();
102459 +}
102460 +
102461 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102462 +{
102463 + const char * const plugin_name = plugin_info->base_name;
102464 + struct register_pass_info colorize_rearm_pass_info = {
102465 + .pass = &pass_ipa_colorize_rearm.pass,
102466 + .reference_pass_name = "*free_lang_data",
102467 + .ref_pass_instance_number = 1,
102468 + .pos_op = PASS_POS_INSERT_AFTER
102469 + };
102470 +
102471 + if (!plugin_default_version_check(version, &gcc_version)) {
102472 + error(G_("incompatible gcc/plugin versions"));
102473 + return 1;
102474 + }
102475 +
102476 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
102477 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
102478 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
102479 + return 0;
102480 +}
102481 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
102482 new file mode 100644
102483 index 0000000..59bf839
102484 --- /dev/null
102485 +++ b/tools/gcc/constify_plugin.c
102486 @@ -0,0 +1,557 @@
102487 +/*
102488 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
102489 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
102490 + * Licensed under the GPL v2, or (at your option) v3
102491 + *
102492 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
102493 + *
102494 + * Homepage:
102495 + * http://www.grsecurity.net/~ephox/const_plugin/
102496 + *
102497 + * Usage:
102498 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
102499 + * $ gcc -fplugin=constify_plugin.so test.c -O2
102500 + */
102501 +
102502 +#include "gcc-plugin.h"
102503 +#include "config.h"
102504 +#include "system.h"
102505 +#include "coretypes.h"
102506 +#include "tree.h"
102507 +#include "tree-pass.h"
102508 +#include "flags.h"
102509 +#include "intl.h"
102510 +#include "toplev.h"
102511 +#include "plugin.h"
102512 +#include "diagnostic.h"
102513 +#include "plugin-version.h"
102514 +#include "tm.h"
102515 +#include "function.h"
102516 +#include "basic-block.h"
102517 +#include "gimple.h"
102518 +#include "rtl.h"
102519 +#include "emit-rtl.h"
102520 +#include "tree-flow.h"
102521 +#include "target.h"
102522 +#include "langhooks.h"
102523 +
102524 +// should come from c-tree.h if only it were installed for gcc 4.5...
102525 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
102526 +
102527 +// unused type flag in all versions 4.5-4.8
102528 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
102529 +
102530 +int plugin_is_GPL_compatible;
102531 +
102532 +static struct plugin_info const_plugin_info = {
102533 + .version = "201401140130",
102534 + .help = "no-constify\tturn off constification\n",
102535 +};
102536 +
102537 +typedef struct {
102538 + bool has_fptr_field;
102539 + bool has_writable_field;
102540 + bool has_do_const_field;
102541 + bool has_no_const_field;
102542 +} constify_info;
102543 +
102544 +static const_tree get_field_type(const_tree field)
102545 +{
102546 + return strip_array_types(TREE_TYPE(field));
102547 +}
102548 +
102549 +static bool is_fptr(const_tree field)
102550 +{
102551 + const_tree ptr = get_field_type(field);
102552 +
102553 + if (TREE_CODE(ptr) != POINTER_TYPE)
102554 + return false;
102555 +
102556 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
102557 +}
102558 +
102559 +/*
102560 + * determine whether the given structure type meets the requirements for automatic constification,
102561 + * including the constification attributes on nested structure types
102562 + */
102563 +static void constifiable(const_tree node, constify_info *cinfo)
102564 +{
102565 + const_tree field;
102566 +
102567 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
102568 +
102569 + // e.g., pointer to structure fields while still constructing the structure type
102570 + if (TYPE_FIELDS(node) == NULL_TREE)
102571 + return;
102572 +
102573 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
102574 + const_tree type = get_field_type(field);
102575 + enum tree_code code = TREE_CODE(type);
102576 +
102577 + if (node == type)
102578 + continue;
102579 +
102580 + if (is_fptr(field))
102581 + cinfo->has_fptr_field = true;
102582 + else if (!TREE_READONLY(field))
102583 + cinfo->has_writable_field = true;
102584 +
102585 + if (code == RECORD_TYPE || code == UNION_TYPE) {
102586 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
102587 + cinfo->has_do_const_field = true;
102588 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
102589 + cinfo->has_no_const_field = true;
102590 + else
102591 + constifiable(type, cinfo);
102592 + }
102593 + }
102594 +}
102595 +
102596 +static bool constified(const_tree node)
102597 +{
102598 + constify_info cinfo = {
102599 + .has_fptr_field = false,
102600 + .has_writable_field = false,
102601 + .has_do_const_field = false,
102602 + .has_no_const_field = false
102603 + };
102604 +
102605 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
102606 +
102607 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
102608 + gcc_assert(!TYPE_READONLY(node));
102609 + return false;
102610 + }
102611 +
102612 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
102613 + gcc_assert(TYPE_READONLY(node));
102614 + return true;
102615 + }
102616 +
102617 + constifiable(node, &cinfo);
102618 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
102619 + return false;
102620 +
102621 + return TYPE_READONLY(node);
102622 +}
102623 +
102624 +static void deconstify_tree(tree node);
102625 +
102626 +static void deconstify_type(tree type)
102627 +{
102628 + tree field;
102629 +
102630 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
102631 +
102632 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
102633 + const_tree fieldtype = get_field_type(field);
102634 +
102635 + // special case handling of simple ptr-to-same-array-type members
102636 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
102637 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
102638 +
102639 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
102640 + continue;
102641 + if (TREE_TYPE(TREE_TYPE(field)) == type)
102642 + continue;
102643 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
102644 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
102645 + TREE_TYPE(TREE_TYPE(field)) = type;
102646 + }
102647 + continue;
102648 + }
102649 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
102650 + continue;
102651 + if (!constified(fieldtype))
102652 + continue;
102653 +
102654 + deconstify_tree(field);
102655 + TREE_READONLY(field) = 0;
102656 + }
102657 + TYPE_READONLY(type) = 0;
102658 + C_TYPE_FIELDS_READONLY(type) = 0;
102659 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102660 + TYPE_ATTRIBUTES(type) = copy_list(TYPE_ATTRIBUTES(type));
102661 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
102662 + }
102663 +}
102664 +
102665 +static void deconstify_tree(tree node)
102666 +{
102667 + tree old_type, new_type, field;
102668 +
102669 + old_type = TREE_TYPE(node);
102670 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
102671 + node = TREE_TYPE(node) = copy_node(old_type);
102672 + old_type = TREE_TYPE(old_type);
102673 + }
102674 +
102675 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
102676 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
102677 +
102678 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
102679 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
102680 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
102681 + DECL_FIELD_CONTEXT(field) = new_type;
102682 +
102683 + deconstify_type(new_type);
102684 +
102685 + TREE_TYPE(node) = new_type;
102686 +}
102687 +
102688 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102689 +{
102690 + tree type;
102691 + constify_info cinfo = {
102692 + .has_fptr_field = false,
102693 + .has_writable_field = false,
102694 + .has_do_const_field = false,
102695 + .has_no_const_field = false
102696 + };
102697 +
102698 + *no_add_attrs = true;
102699 + if (TREE_CODE(*node) == FUNCTION_DECL) {
102700 + error("%qE attribute does not apply to functions (%qF)", name, *node);
102701 + return NULL_TREE;
102702 + }
102703 +
102704 + if (TREE_CODE(*node) == PARM_DECL) {
102705 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
102706 + return NULL_TREE;
102707 + }
102708 +
102709 + if (TREE_CODE(*node) == VAR_DECL) {
102710 + error("%qE attribute does not apply to variables (%qD)", name, *node);
102711 + return NULL_TREE;
102712 + }
102713 +
102714 + if (TYPE_P(*node)) {
102715 + type = *node;
102716 + } else {
102717 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
102718 + type = TREE_TYPE(*node);
102719 + }
102720 +
102721 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
102722 + error("%qE attribute used on %qT applies to struct and union types only", name, type);
102723 + return NULL_TREE;
102724 + }
102725 +
102726 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
102727 + error("%qE attribute is already applied to the type %qT", name, type);
102728 + return NULL_TREE;
102729 + }
102730 +
102731 + if (TYPE_P(*node)) {
102732 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
102733 + error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type);
102734 + else
102735 + *no_add_attrs = false;
102736 + return NULL_TREE;
102737 + }
102738 +
102739 + constifiable(type, &cinfo);
102740 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102741 + deconstify_tree(*node);
102742 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
102743 + return NULL_TREE;
102744 + }
102745 +
102746 + error("%qE attribute used on type %qT that is not constified", name, type);
102747 + return NULL_TREE;
102748 +}
102749 +
102750 +static void constify_type(tree type)
102751 +{
102752 + TYPE_READONLY(type) = 1;
102753 + C_TYPE_FIELDS_READONLY(type) = 1;
102754 + TYPE_CONSTIFY_VISITED(type) = 1;
102755 +// TYPE_ATTRIBUTES(type) = copy_list(TYPE_ATTRIBUTES(type));
102756 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
102757 +}
102758 +
102759 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102760 +{
102761 + *no_add_attrs = true;
102762 + if (!TYPE_P(*node)) {
102763 + error("%qE attribute applies to types only (%qD)", name, *node);
102764 + return NULL_TREE;
102765 + }
102766 +
102767 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
102768 + error("%qE attribute used on %qT applies to struct and union types only", name, *node);
102769 + return NULL_TREE;
102770 + }
102771 +
102772 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
102773 + error("%qE attribute used on %qT is already applied to the type", name, *node);
102774 + return NULL_TREE;
102775 + }
102776 +
102777 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
102778 + error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node);
102779 + return NULL_TREE;
102780 + }
102781 +
102782 + *no_add_attrs = false;
102783 + return NULL_TREE;
102784 +}
102785 +
102786 +static struct attribute_spec no_const_attr = {
102787 + .name = "no_const",
102788 + .min_length = 0,
102789 + .max_length = 0,
102790 + .decl_required = false,
102791 + .type_required = false,
102792 + .function_type_required = false,
102793 + .handler = handle_no_const_attribute,
102794 +#if BUILDING_GCC_VERSION >= 4007
102795 + .affects_type_identity = true
102796 +#endif
102797 +};
102798 +
102799 +static struct attribute_spec do_const_attr = {
102800 + .name = "do_const",
102801 + .min_length = 0,
102802 + .max_length = 0,
102803 + .decl_required = false,
102804 + .type_required = false,
102805 + .function_type_required = false,
102806 + .handler = handle_do_const_attribute,
102807 +#if BUILDING_GCC_VERSION >= 4007
102808 + .affects_type_identity = true
102809 +#endif
102810 +};
102811 +
102812 +static void register_attributes(void *event_data, void *data)
102813 +{
102814 + register_attribute(&no_const_attr);
102815 + register_attribute(&do_const_attr);
102816 +}
102817 +
102818 +static void finish_type(void *event_data, void *data)
102819 +{
102820 + tree type = (tree)event_data;
102821 + constify_info cinfo = {
102822 + .has_fptr_field = false,
102823 + .has_writable_field = false,
102824 + .has_do_const_field = false,
102825 + .has_no_const_field = false
102826 + };
102827 +
102828 + if (type == NULL_TREE || type == error_mark_node)
102829 + return;
102830 +
102831 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
102832 + return;
102833 +
102834 + constifiable(type, &cinfo);
102835 +
102836 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
102837 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
102838 + deconstify_type(type);
102839 + TYPE_CONSTIFY_VISITED(type) = 1;
102840 + } else
102841 + error("'no_const' attribute used on type %qT that is not constified", type);
102842 + return;
102843 + }
102844 +
102845 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102846 + if (!cinfo.has_writable_field) {
102847 + error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not ");
102848 + return;
102849 + }
102850 + constify_type(type);
102851 + return;
102852 + }
102853 +
102854 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
102855 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102856 + error("'do_const' attribute used on type %qT that is constified", type);
102857 + return;
102858 + }
102859 + constify_type(type);
102860 + return;
102861 + }
102862 +
102863 + deconstify_type(type);
102864 + TYPE_CONSTIFY_VISITED(type) = 1;
102865 +}
102866 +
102867 +static void check_global_variables(void *event_data, void *data)
102868 +{
102869 + struct varpool_node *node;
102870 +
102871 +#if BUILDING_GCC_VERSION <= 4007
102872 + for (node = varpool_nodes; node; node = node->next) {
102873 + tree var = node->decl;
102874 +#else
102875 + FOR_EACH_VARIABLE(node) {
102876 + tree var = node->symbol.decl;
102877 +#endif
102878 + tree type = TREE_TYPE(var);
102879 +
102880 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102881 + continue;
102882 +
102883 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102884 + continue;
102885 +
102886 + if (!TYPE_CONSTIFY_VISITED(type))
102887 + continue;
102888 +
102889 + if (DECL_EXTERNAL(var))
102890 + continue;
102891 +
102892 + if (DECL_INITIAL(var))
102893 + continue;
102894 +
102895 + // this works around a gcc bug/feature where uninitialized globals
102896 + // are moved into the .bss section regardless of any constification
102897 + DECL_INITIAL(var) = build_constructor(type, NULL);
102898 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
102899 + }
102900 +}
102901 +
102902 +static unsigned int check_local_variables(void)
102903 +{
102904 + unsigned int ret = 0;
102905 + tree var;
102906 +
102907 +#if BUILDING_GCC_VERSION == 4005
102908 + tree vars;
102909 +#else
102910 + unsigned int i;
102911 +#endif
102912 +
102913 +#if BUILDING_GCC_VERSION == 4005
102914 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102915 + var = TREE_VALUE(vars);
102916 +#else
102917 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102918 +#endif
102919 + tree type = TREE_TYPE(var);
102920 +
102921 + gcc_assert(DECL_P(var));
102922 + if (is_global_var(var))
102923 + continue;
102924 +
102925 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102926 + continue;
102927 +
102928 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102929 + continue;
102930 +
102931 + if (!TYPE_CONSTIFY_VISITED(type))
102932 + continue;
102933 +
102934 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
102935 + ret = 1;
102936 + }
102937 + return ret;
102938 +}
102939 +
102940 +static struct gimple_opt_pass pass_local_variable = {
102941 + {
102942 + .type = GIMPLE_PASS,
102943 + .name = "check_local_variables",
102944 +#if BUILDING_GCC_VERSION >= 4008
102945 + .optinfo_flags = OPTGROUP_NONE,
102946 +#endif
102947 + .gate = NULL,
102948 + .execute = check_local_variables,
102949 + .sub = NULL,
102950 + .next = NULL,
102951 + .static_pass_number = 0,
102952 + .tv_id = TV_NONE,
102953 + .properties_required = 0,
102954 + .properties_provided = 0,
102955 + .properties_destroyed = 0,
102956 + .todo_flags_start = 0,
102957 + .todo_flags_finish = 0
102958 + }
102959 +};
102960 +
102961 +static struct {
102962 + const char *name;
102963 + const char *asm_op;
102964 +} sections[] = {
102965 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
102966 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
102967 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
102968 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
102969 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
102970 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
102971 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
102972 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
102973 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
102974 +};
102975 +
102976 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
102977 +
102978 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
102979 +{
102980 + size_t i;
102981 +
102982 + for (i = 0; i < ARRAY_SIZE(sections); i++)
102983 + if (!strcmp(sections[i].name, name))
102984 + return 0;
102985 + return old_section_type_flags(decl, name, reloc);
102986 +}
102987 +
102988 +static void constify_start_unit(void *gcc_data, void *user_data)
102989 +{
102990 +// size_t i;
102991 +
102992 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
102993 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
102994 +// sections[i].section = get_section(sections[i].name, 0, NULL);
102995 +
102996 + old_section_type_flags = targetm.section_type_flags;
102997 + targetm.section_type_flags = constify_section_type_flags;
102998 +}
102999 +
103000 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103001 +{
103002 + const char * const plugin_name = plugin_info->base_name;
103003 + const int argc = plugin_info->argc;
103004 + const struct plugin_argument * const argv = plugin_info->argv;
103005 + int i;
103006 + bool constify = true;
103007 +
103008 + struct register_pass_info local_variable_pass_info = {
103009 + .pass = &pass_local_variable.pass,
103010 + .reference_pass_name = "ssa",
103011 + .ref_pass_instance_number = 1,
103012 + .pos_op = PASS_POS_INSERT_BEFORE
103013 + };
103014 +
103015 + if (!plugin_default_version_check(version, &gcc_version)) {
103016 + error(G_("incompatible gcc/plugin versions"));
103017 + return 1;
103018 + }
103019 +
103020 + for (i = 0; i < argc; ++i) {
103021 + if (!(strcmp(argv[i].key, "no-constify"))) {
103022 + constify = false;
103023 + continue;
103024 + }
103025 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103026 + }
103027 +
103028 + if (strcmp(lang_hooks.name, "GNU C")) {
103029 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103030 + constify = false;
103031 + }
103032 +
103033 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
103034 + if (constify) {
103035 + register_callback(plugin_name, PLUGIN_ALL_IPA_PASSES_START, check_global_variables, NULL);
103036 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103037 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
103038 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
103039 + }
103040 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103041 +
103042 + return 0;
103043 +}
103044 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
103045 new file mode 100644
103046 index 0000000..e518932
103047 --- /dev/null
103048 +++ b/tools/gcc/generate_size_overflow_hash.sh
103049 @@ -0,0 +1,94 @@
103050 +#!/bin/bash
103051 +
103052 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
103053 +
103054 +header1="size_overflow_hash.h"
103055 +database="size_overflow_hash.data"
103056 +n=65536
103057 +
103058 +usage() {
103059 +cat <<EOF
103060 +usage: $0 options
103061 +OPTIONS:
103062 + -h|--help help
103063 + -o header file
103064 + -d database file
103065 + -n hash array size
103066 +EOF
103067 + return 0
103068 +}
103069 +
103070 +while true
103071 +do
103072 + case "$1" in
103073 + -h|--help) usage && exit 0;;
103074 + -n) n=$2; shift 2;;
103075 + -o) header1="$2"; shift 2;;
103076 + -d) database="$2"; shift 2;;
103077 + --) shift 1; break ;;
103078 + *) break ;;
103079 + esac
103080 +done
103081 +
103082 +create_defines() {
103083 + for i in `seq 0 31`
103084 + do
103085 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
103086 + done
103087 + echo >> "$header1"
103088 +}
103089 +
103090 +create_structs() {
103091 + rm -f "$header1"
103092 +
103093 + create_defines
103094 +
103095 + cat "$database" | while read data
103096 + do
103097 + data_array=($data)
103098 + struct_hash_name="${data_array[0]}"
103099 + funcn="${data_array[1]}"
103100 + params="${data_array[2]}"
103101 + next="${data_array[4]}"
103102 +
103103 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
103104 +
103105 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
103106 + echo -en "\t.param\t= " >> "$header1"
103107 + line=
103108 + for param_num in ${params//-/ };
103109 + do
103110 + line="${line}PARAM"$param_num"|"
103111 + done
103112 +
103113 + echo -e "${line%?},\n};\n" >> "$header1"
103114 + done
103115 +}
103116 +
103117 +create_headers() {
103118 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
103119 +}
103120 +
103121 +create_array_elements() {
103122 + index=0
103123 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
103124 + do
103125 + data_array=($data)
103126 + i="${data_array[3]}"
103127 + hash="${data_array[0]}"
103128 + while [[ $index -lt $i ]]
103129 + do
103130 + echo -e "\t["$index"]\t= NULL," >> "$header1"
103131 + index=$(($index + 1))
103132 + done
103133 + index=$(($index + 1))
103134 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
103135 + done
103136 + echo '};' >> $header1
103137 +}
103138 +
103139 +create_structs
103140 +create_headers
103141 +create_array_elements
103142 +
103143 +exit 0
103144 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
103145 new file mode 100644
103146 index 0000000..568b360
103147 --- /dev/null
103148 +++ b/tools/gcc/kallocstat_plugin.c
103149 @@ -0,0 +1,170 @@
103150 +/*
103151 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103152 + * Licensed under the GPL v2
103153 + *
103154 + * Note: the choice of the license means that the compilation process is
103155 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103156 + * but for the kernel it doesn't matter since it doesn't link against
103157 + * any of the gcc libraries
103158 + *
103159 + * gcc plugin to find the distribution of k*alloc sizes
103160 + *
103161 + * TODO:
103162 + *
103163 + * BUGS:
103164 + * - none known
103165 + */
103166 +#include "gcc-plugin.h"
103167 +#include "config.h"
103168 +#include "system.h"
103169 +#include "coretypes.h"
103170 +#include "tree.h"
103171 +#include "tree-pass.h"
103172 +#include "flags.h"
103173 +#include "intl.h"
103174 +#include "toplev.h"
103175 +#include "plugin.h"
103176 +//#include "expr.h" where are you...
103177 +#include "diagnostic.h"
103178 +#include "plugin-version.h"
103179 +#include "tm.h"
103180 +#include "function.h"
103181 +#include "basic-block.h"
103182 +#include "gimple.h"
103183 +#include "rtl.h"
103184 +#include "emit-rtl.h"
103185 +
103186 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103187 +
103188 +int plugin_is_GPL_compatible;
103189 +
103190 +static const char * const kalloc_functions[] = {
103191 + "__kmalloc",
103192 + "kmalloc",
103193 + "kmalloc_large",
103194 + "kmalloc_node",
103195 + "kmalloc_order",
103196 + "kmalloc_order_trace",
103197 + "kmalloc_slab",
103198 + "kzalloc",
103199 + "kzalloc_node",
103200 +};
103201 +
103202 +static struct plugin_info kallocstat_plugin_info = {
103203 + .version = "201302112000",
103204 +};
103205 +
103206 +static unsigned int execute_kallocstat(void);
103207 +
103208 +static struct gimple_opt_pass kallocstat_pass = {
103209 + .pass = {
103210 + .type = GIMPLE_PASS,
103211 + .name = "kallocstat",
103212 +#if BUILDING_GCC_VERSION >= 4008
103213 + .optinfo_flags = OPTGROUP_NONE,
103214 +#endif
103215 + .gate = NULL,
103216 + .execute = execute_kallocstat,
103217 + .sub = NULL,
103218 + .next = NULL,
103219 + .static_pass_number = 0,
103220 + .tv_id = TV_NONE,
103221 + .properties_required = 0,
103222 + .properties_provided = 0,
103223 + .properties_destroyed = 0,
103224 + .todo_flags_start = 0,
103225 + .todo_flags_finish = 0
103226 + }
103227 +};
103228 +
103229 +static bool is_kalloc(const char *fnname)
103230 +{
103231 + size_t i;
103232 +
103233 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
103234 + if (!strcmp(fnname, kalloc_functions[i]))
103235 + return true;
103236 + return false;
103237 +}
103238 +
103239 +static unsigned int execute_kallocstat(void)
103240 +{
103241 + basic_block bb;
103242 +
103243 + // 1. loop through BBs and GIMPLE statements
103244 + FOR_EACH_BB(bb) {
103245 + gimple_stmt_iterator gsi;
103246 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103247 + // gimple match:
103248 + tree fndecl, size;
103249 + gimple call_stmt;
103250 + const char *fnname;
103251 +
103252 + // is it a call
103253 + call_stmt = gsi_stmt(gsi);
103254 + if (!is_gimple_call(call_stmt))
103255 + continue;
103256 + fndecl = gimple_call_fndecl(call_stmt);
103257 + if (fndecl == NULL_TREE)
103258 + continue;
103259 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
103260 + continue;
103261 +
103262 + // is it a call to k*alloc
103263 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
103264 + if (!is_kalloc(fnname))
103265 + continue;
103266 +
103267 + // is the size arg the result of a simple const assignment
103268 + size = gimple_call_arg(call_stmt, 0);
103269 + while (true) {
103270 + gimple def_stmt;
103271 + expanded_location xloc;
103272 + size_t size_val;
103273 +
103274 + if (TREE_CODE(size) != SSA_NAME)
103275 + break;
103276 + def_stmt = SSA_NAME_DEF_STMT(size);
103277 + if (!def_stmt || !is_gimple_assign(def_stmt))
103278 + break;
103279 + if (gimple_num_ops(def_stmt) != 2)
103280 + break;
103281 + size = gimple_assign_rhs1(def_stmt);
103282 + if (!TREE_CONSTANT(size))
103283 + continue;
103284 + xloc = expand_location(gimple_location(def_stmt));
103285 + if (!xloc.file)
103286 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103287 + size_val = TREE_INT_CST_LOW(size);
103288 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
103289 + break;
103290 + }
103291 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
103292 +//debug_tree(gimple_call_fn(call_stmt));
103293 +//print_node(stderr, "pax", fndecl, 4);
103294 + }
103295 + }
103296 +
103297 + return 0;
103298 +}
103299 +
103300 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103301 +{
103302 + const char * const plugin_name = plugin_info->base_name;
103303 + struct register_pass_info kallocstat_pass_info = {
103304 + .pass = &kallocstat_pass.pass,
103305 + .reference_pass_name = "ssa",
103306 + .ref_pass_instance_number = 1,
103307 + .pos_op = PASS_POS_INSERT_AFTER
103308 + };
103309 +
103310 + if (!plugin_default_version_check(version, &gcc_version)) {
103311 + error(G_("incompatible gcc/plugin versions"));
103312 + return 1;
103313 + }
103314 +
103315 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
103316 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
103317 +
103318 + return 0;
103319 +}
103320 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
103321 new file mode 100644
103322 index 0000000..a25306b
103323 --- /dev/null
103324 +++ b/tools/gcc/kernexec_plugin.c
103325 @@ -0,0 +1,474 @@
103326 +/*
103327 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103328 + * Licensed under the GPL v2
103329 + *
103330 + * Note: the choice of the license means that the compilation process is
103331 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103332 + * but for the kernel it doesn't matter since it doesn't link against
103333 + * any of the gcc libraries
103334 + *
103335 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
103336 + *
103337 + * TODO:
103338 + *
103339 + * BUGS:
103340 + * - none known
103341 + */
103342 +#include "gcc-plugin.h"
103343 +#include "config.h"
103344 +#include "system.h"
103345 +#include "coretypes.h"
103346 +#include "tree.h"
103347 +#include "tree-pass.h"
103348 +#include "flags.h"
103349 +#include "intl.h"
103350 +#include "toplev.h"
103351 +#include "plugin.h"
103352 +//#include "expr.h" where are you...
103353 +#include "diagnostic.h"
103354 +#include "plugin-version.h"
103355 +#include "tm.h"
103356 +#include "function.h"
103357 +#include "basic-block.h"
103358 +#include "gimple.h"
103359 +#include "rtl.h"
103360 +#include "emit-rtl.h"
103361 +#include "tree-flow.h"
103362 +
103363 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103364 +extern rtx emit_move_insn(rtx x, rtx y);
103365 +
103366 +#if BUILDING_GCC_VERSION <= 4006
103367 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
103368 +#endif
103369 +
103370 +#if BUILDING_GCC_VERSION >= 4008
103371 +#define TODO_dump_func 0
103372 +#endif
103373 +
103374 +int plugin_is_GPL_compatible;
103375 +
103376 +static struct plugin_info kernexec_plugin_info = {
103377 + .version = "201308230150",
103378 + .help = "method=[bts|or]\tinstrumentation method\n"
103379 +};
103380 +
103381 +static unsigned int execute_kernexec_reload(void);
103382 +static unsigned int execute_kernexec_fptr(void);
103383 +static unsigned int execute_kernexec_retaddr(void);
103384 +static bool kernexec_cmodel_check(void);
103385 +
103386 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
103387 +static void (*kernexec_instrument_retaddr)(rtx);
103388 +
103389 +static struct gimple_opt_pass kernexec_reload_pass = {
103390 + .pass = {
103391 + .type = GIMPLE_PASS,
103392 + .name = "kernexec_reload",
103393 +#if BUILDING_GCC_VERSION >= 4008
103394 + .optinfo_flags = OPTGROUP_NONE,
103395 +#endif
103396 + .gate = kernexec_cmodel_check,
103397 + .execute = execute_kernexec_reload,
103398 + .sub = NULL,
103399 + .next = NULL,
103400 + .static_pass_number = 0,
103401 + .tv_id = TV_NONE,
103402 + .properties_required = 0,
103403 + .properties_provided = 0,
103404 + .properties_destroyed = 0,
103405 + .todo_flags_start = 0,
103406 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
103407 + }
103408 +};
103409 +
103410 +static struct gimple_opt_pass kernexec_fptr_pass = {
103411 + .pass = {
103412 + .type = GIMPLE_PASS,
103413 + .name = "kernexec_fptr",
103414 +#if BUILDING_GCC_VERSION >= 4008
103415 + .optinfo_flags = OPTGROUP_NONE,
103416 +#endif
103417 + .gate = kernexec_cmodel_check,
103418 + .execute = execute_kernexec_fptr,
103419 + .sub = NULL,
103420 + .next = NULL,
103421 + .static_pass_number = 0,
103422 + .tv_id = TV_NONE,
103423 + .properties_required = 0,
103424 + .properties_provided = 0,
103425 + .properties_destroyed = 0,
103426 + .todo_flags_start = 0,
103427 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
103428 + }
103429 +};
103430 +
103431 +static struct rtl_opt_pass kernexec_retaddr_pass = {
103432 + .pass = {
103433 + .type = RTL_PASS,
103434 + .name = "kernexec_retaddr",
103435 +#if BUILDING_GCC_VERSION >= 4008
103436 + .optinfo_flags = OPTGROUP_NONE,
103437 +#endif
103438 + .gate = kernexec_cmodel_check,
103439 + .execute = execute_kernexec_retaddr,
103440 + .sub = NULL,
103441 + .next = NULL,
103442 + .static_pass_number = 0,
103443 + .tv_id = TV_NONE,
103444 + .properties_required = 0,
103445 + .properties_provided = 0,
103446 + .properties_destroyed = 0,
103447 + .todo_flags_start = 0,
103448 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
103449 + }
103450 +};
103451 +
103452 +static bool kernexec_cmodel_check(void)
103453 +{
103454 + tree section;
103455 +
103456 + if (ix86_cmodel != CM_KERNEL)
103457 + return false;
103458 +
103459 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
103460 + if (!section || !TREE_VALUE(section))
103461 + return true;
103462 +
103463 + section = TREE_VALUE(TREE_VALUE(section));
103464 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
103465 + return true;
103466 +
103467 + return false;
103468 +}
103469 +
103470 +/*
103471 + * add special KERNEXEC instrumentation: reload %r12 after it has been clobbered
103472 + */
103473 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
103474 +{
103475 + gimple asm_movabs_stmt;
103476 +
103477 + // build asm volatile("movabs $0x8000000000000000, %%r12\n\t" : : : );
103478 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r12\n\t", NULL, NULL, NULL, NULL);
103479 + gimple_asm_set_volatile(asm_movabs_stmt, true);
103480 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
103481 + update_stmt(asm_movabs_stmt);
103482 +}
103483 +
103484 +/*
103485 + * find all asm() stmts that clobber r12 and add a reload of r12
103486 + */
103487 +static unsigned int execute_kernexec_reload(void)
103488 +{
103489 + basic_block bb;
103490 +
103491 + // 1. loop through BBs and GIMPLE statements
103492 + FOR_EACH_BB(bb) {
103493 + gimple_stmt_iterator gsi;
103494 +
103495 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103496 + // gimple match: __asm__ ("" : : : "r12");
103497 + gimple asm_stmt;
103498 + size_t nclobbers;
103499 +
103500 + // is it an asm ...
103501 + asm_stmt = gsi_stmt(gsi);
103502 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
103503 + continue;
103504 +
103505 + // ... clobbering r12
103506 + nclobbers = gimple_asm_nclobbers(asm_stmt);
103507 + while (nclobbers--) {
103508 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
103509 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r12"))
103510 + continue;
103511 + kernexec_reload_fptr_mask(&gsi);
103512 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
103513 + break;
103514 + }
103515 + }
103516 + }
103517 +
103518 + return 0;
103519 +}
103520 +
103521 +/*
103522 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
103523 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
103524 + */
103525 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
103526 +{
103527 + gimple assign_intptr, assign_new_fptr, call_stmt;
103528 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
103529 +
103530 + call_stmt = gsi_stmt(*gsi);
103531 + old_fptr = gimple_call_fn(call_stmt);
103532 +
103533 + // create temporary unsigned long variable used for bitops and cast fptr to it
103534 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
103535 +#if BUILDING_GCC_VERSION <= 4007
103536 + add_referenced_var(intptr);
103537 +#endif
103538 + intptr = make_ssa_name(intptr, NULL);
103539 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
103540 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
103541 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
103542 + update_stmt(assign_intptr);
103543 +
103544 + // apply logical or to temporary unsigned long and bitmask
103545 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
103546 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
103547 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
103548 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
103549 + assign_intptr = gimple_build_assign(intptr, orptr);
103550 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
103551 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
103552 + update_stmt(assign_intptr);
103553 +
103554 + // cast temporary unsigned long back to a temporary fptr variable
103555 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
103556 +#if BUILDING_GCC_VERSION <= 4007
103557 + add_referenced_var(new_fptr);
103558 +#endif
103559 + new_fptr = make_ssa_name(new_fptr, NULL);
103560 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
103561 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
103562 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
103563 + update_stmt(assign_new_fptr);
103564 +
103565 + // replace call stmt fn with the new fptr
103566 + gimple_call_set_fn(call_stmt, new_fptr);
103567 + update_stmt(call_stmt);
103568 +}
103569 +
103570 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
103571 +{
103572 + gimple asm_or_stmt, call_stmt;
103573 + tree old_fptr, new_fptr, input, output;
103574 +#if BUILDING_GCC_VERSION <= 4007
103575 + VEC(tree, gc) *inputs = NULL;
103576 + VEC(tree, gc) *outputs = NULL;
103577 +#else
103578 + vec<tree, va_gc> *inputs = NULL;
103579 + vec<tree, va_gc> *outputs = NULL;
103580 +#endif
103581 +
103582 + call_stmt = gsi_stmt(*gsi);
103583 + old_fptr = gimple_call_fn(call_stmt);
103584 +
103585 + // create temporary fptr variable
103586 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
103587 +#if BUILDING_GCC_VERSION <= 4007
103588 + add_referenced_var(new_fptr);
103589 +#endif
103590 + new_fptr = make_ssa_name(new_fptr, NULL);
103591 +
103592 + // build asm volatile("orq %%r12, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
103593 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
103594 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
103595 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
103596 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
103597 +#if BUILDING_GCC_VERSION <= 4007
103598 + VEC_safe_push(tree, gc, inputs, input);
103599 + VEC_safe_push(tree, gc, outputs, output);
103600 +#else
103601 + vec_safe_push(inputs, input);
103602 + vec_safe_push(outputs, output);
103603 +#endif
103604 + asm_or_stmt = gimple_build_asm_vec("orq %%r12, %0\n\t", inputs, outputs, NULL, NULL);
103605 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
103606 + gimple_asm_set_volatile(asm_or_stmt, true);
103607 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
103608 + update_stmt(asm_or_stmt);
103609 +
103610 + // replace call stmt fn with the new fptr
103611 + gimple_call_set_fn(call_stmt, new_fptr);
103612 + update_stmt(call_stmt);
103613 +}
103614 +
103615 +/*
103616 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
103617 + */
103618 +static unsigned int execute_kernexec_fptr(void)
103619 +{
103620 + basic_block bb;
103621 +
103622 + // 1. loop through BBs and GIMPLE statements
103623 + FOR_EACH_BB(bb) {
103624 + gimple_stmt_iterator gsi;
103625 +
103626 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103627 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
103628 + tree fn;
103629 + gimple call_stmt;
103630 +
103631 + // is it a call ...
103632 + call_stmt = gsi_stmt(gsi);
103633 + if (!is_gimple_call(call_stmt))
103634 + continue;
103635 + fn = gimple_call_fn(call_stmt);
103636 + if (TREE_CODE(fn) == ADDR_EXPR)
103637 + continue;
103638 + if (TREE_CODE(fn) != SSA_NAME)
103639 + gcc_unreachable();
103640 +
103641 + // ... through a function pointer
103642 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
103643 + fn = SSA_NAME_VAR(fn);
103644 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
103645 + debug_tree(fn);
103646 + gcc_unreachable();
103647 + }
103648 + }
103649 + fn = TREE_TYPE(fn);
103650 + if (TREE_CODE(fn) != POINTER_TYPE)
103651 + continue;
103652 + fn = TREE_TYPE(fn);
103653 + if (TREE_CODE(fn) != FUNCTION_TYPE)
103654 + continue;
103655 +
103656 + kernexec_instrument_fptr(&gsi);
103657 +
103658 +//debug_tree(gimple_call_fn(call_stmt));
103659 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
103660 + }
103661 + }
103662 +
103663 + return 0;
103664 +}
103665 +
103666 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
103667 +static void kernexec_instrument_retaddr_bts(rtx insn)
103668 +{
103669 + rtx btsq;
103670 + rtvec argvec, constraintvec, labelvec;
103671 + int line;
103672 +
103673 + // create asm volatile("btsq $63,(%%rsp)":::)
103674 + argvec = rtvec_alloc(0);
103675 + constraintvec = rtvec_alloc(0);
103676 + labelvec = rtvec_alloc(0);
103677 + line = expand_location(RTL_LOCATION(insn)).line;
103678 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
103679 + MEM_VOLATILE_P(btsq) = 1;
103680 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
103681 + emit_insn_before(btsq, insn);
103682 +}
103683 +
103684 +// add special KERNEXEC instrumentation: orq %r12,(%rsp) just before retn
103685 +static void kernexec_instrument_retaddr_or(rtx insn)
103686 +{
103687 + rtx orq;
103688 + rtvec argvec, constraintvec, labelvec;
103689 + int line;
103690 +
103691 + // create asm volatile("orq %%r12,(%%rsp)":::)
103692 + argvec = rtvec_alloc(0);
103693 + constraintvec = rtvec_alloc(0);
103694 + labelvec = rtvec_alloc(0);
103695 + line = expand_location(RTL_LOCATION(insn)).line;
103696 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r12,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
103697 + MEM_VOLATILE_P(orq) = 1;
103698 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
103699 + emit_insn_before(orq, insn);
103700 +}
103701 +
103702 +/*
103703 + * find all asm level function returns and forcibly set the highest bit of the return address
103704 + */
103705 +static unsigned int execute_kernexec_retaddr(void)
103706 +{
103707 + rtx insn;
103708 +
103709 +// if (stack_realign_drap)
103710 +// inform(DECL_SOURCE_LOCATION(current_function_decl), "drap detected in %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
103711 +
103712 + // 1. find function returns
103713 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
103714 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
103715 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
103716 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
103717 + rtx body;
103718 +
103719 + // is it a retn
103720 + if (!JUMP_P(insn))
103721 + continue;
103722 + body = PATTERN(insn);
103723 + if (GET_CODE(body) == PARALLEL)
103724 + body = XVECEXP(body, 0, 0);
103725 + if (!ANY_RETURN_P(body))
103726 + continue;
103727 + kernexec_instrument_retaddr(insn);
103728 + }
103729 +
103730 +// print_simple_rtl(stderr, get_insns());
103731 +// print_rtl(stderr, get_insns());
103732 +
103733 + return 0;
103734 +}
103735 +
103736 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103737 +{
103738 + const char * const plugin_name = plugin_info->base_name;
103739 + const int argc = plugin_info->argc;
103740 + const struct plugin_argument * const argv = plugin_info->argv;
103741 + int i;
103742 + struct register_pass_info kernexec_reload_pass_info = {
103743 + .pass = &kernexec_reload_pass.pass,
103744 + .reference_pass_name = "ssa",
103745 + .ref_pass_instance_number = 1,
103746 + .pos_op = PASS_POS_INSERT_AFTER
103747 + };
103748 + struct register_pass_info kernexec_fptr_pass_info = {
103749 + .pass = &kernexec_fptr_pass.pass,
103750 + .reference_pass_name = "ssa",
103751 + .ref_pass_instance_number = 1,
103752 + .pos_op = PASS_POS_INSERT_AFTER
103753 + };
103754 + struct register_pass_info kernexec_retaddr_pass_info = {
103755 + .pass = &kernexec_retaddr_pass.pass,
103756 + .reference_pass_name = "pro_and_epilogue",
103757 + .ref_pass_instance_number = 1,
103758 + .pos_op = PASS_POS_INSERT_AFTER
103759 + };
103760 +
103761 + if (!plugin_default_version_check(version, &gcc_version)) {
103762 + error(G_("incompatible gcc/plugin versions"));
103763 + return 1;
103764 + }
103765 +
103766 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
103767 +
103768 + if (TARGET_64BIT == 0)
103769 + return 0;
103770 +
103771 + for (i = 0; i < argc; ++i) {
103772 + if (!strcmp(argv[i].key, "method")) {
103773 + if (!argv[i].value) {
103774 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103775 + continue;
103776 + }
103777 + if (!strcmp(argv[i].value, "bts")) {
103778 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
103779 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
103780 + } else if (!strcmp(argv[i].value, "or")) {
103781 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
103782 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
103783 + fix_register("r12", 1, 1);
103784 + } else
103785 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103786 + continue;
103787 + }
103788 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103789 + }
103790 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
103791 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
103792 +
103793 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
103794 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
103795 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
103796 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
103797 +
103798 + return 0;
103799 +}
103800 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
103801 new file mode 100644
103802 index 0000000..679b9ef
103803 --- /dev/null
103804 +++ b/tools/gcc/latent_entropy_plugin.c
103805 @@ -0,0 +1,335 @@
103806 +/*
103807 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
103808 + * Licensed under the GPL v2
103809 + *
103810 + * Note: the choice of the license means that the compilation process is
103811 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103812 + * but for the kernel it doesn't matter since it doesn't link against
103813 + * any of the gcc libraries
103814 + *
103815 + * gcc plugin to help generate a little bit of entropy from program state,
103816 + * used during boot in the kernel
103817 + *
103818 + * TODO:
103819 + * - add ipa pass to identify not explicitly marked candidate functions
103820 + * - mix in more program state (function arguments/return values, loop variables, etc)
103821 + * - more instrumentation control via attribute parameters
103822 + *
103823 + * BUGS:
103824 + * - LTO needs -flto-partition=none for now
103825 + */
103826 +#include "gcc-plugin.h"
103827 +#include "config.h"
103828 +#include "system.h"
103829 +#include "coretypes.h"
103830 +#include "tree.h"
103831 +#include "tree-pass.h"
103832 +#include "flags.h"
103833 +#include "intl.h"
103834 +#include "toplev.h"
103835 +#include "plugin.h"
103836 +//#include "expr.h" where are you...
103837 +#include "diagnostic.h"
103838 +#include "plugin-version.h"
103839 +#include "tm.h"
103840 +#include "function.h"
103841 +#include "basic-block.h"
103842 +#include "gimple.h"
103843 +#include "rtl.h"
103844 +#include "emit-rtl.h"
103845 +#include "tree-flow.h"
103846 +#include "langhooks.h"
103847 +
103848 +#if BUILDING_GCC_VERSION >= 4008
103849 +#define TODO_dump_func 0
103850 +#endif
103851 +
103852 +int plugin_is_GPL_compatible;
103853 +
103854 +static tree latent_entropy_decl;
103855 +
103856 +static struct plugin_info latent_entropy_plugin_info = {
103857 + .version = "201308230230",
103858 + .help = NULL
103859 +};
103860 +
103861 +static unsigned int execute_latent_entropy(void);
103862 +static bool gate_latent_entropy(void);
103863 +
103864 +static struct gimple_opt_pass latent_entropy_pass = {
103865 + .pass = {
103866 + .type = GIMPLE_PASS,
103867 + .name = "latent_entropy",
103868 +#if BUILDING_GCC_VERSION >= 4008
103869 + .optinfo_flags = OPTGROUP_NONE,
103870 +#endif
103871 + .gate = gate_latent_entropy,
103872 + .execute = execute_latent_entropy,
103873 + .sub = NULL,
103874 + .next = NULL,
103875 + .static_pass_number = 0,
103876 + .tv_id = TV_NONE,
103877 + .properties_required = PROP_gimple_leh | PROP_cfg,
103878 + .properties_provided = 0,
103879 + .properties_destroyed = 0,
103880 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103881 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103882 + }
103883 +};
103884 +
103885 +static unsigned HOST_WIDE_INT seed;
103886 +static unsigned HOST_WIDE_INT get_random_const(void)
103887 +{
103888 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
103889 + return seed;
103890 +}
103891 +
103892 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103893 +{
103894 + switch (TREE_CODE(*node)) {
103895 + default:
103896 + *no_add_attrs = true;
103897 + error("%qE attribute only applies to functions and variables", name);
103898 + break;
103899 +
103900 + case VAR_DECL:
103901 + if (DECL_INITIAL(*node)) {
103902 + *no_add_attrs = true;
103903 + error("variable %qD with %qE attribute must not be initialized", *node, name);
103904 + break;
103905 + }
103906 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
103907 + break;
103908 +
103909 + case FUNCTION_DECL:
103910 + break;
103911 + }
103912 +
103913 + return NULL_TREE;
103914 +}
103915 +
103916 +static struct attribute_spec latent_entropy_attr = {
103917 + .name = "latent_entropy",
103918 + .min_length = 0,
103919 + .max_length = 0,
103920 + .decl_required = true,
103921 + .type_required = false,
103922 + .function_type_required = false,
103923 + .handler = handle_latent_entropy_attribute,
103924 +#if BUILDING_GCC_VERSION >= 4007
103925 + .affects_type_identity = false
103926 +#endif
103927 +};
103928 +
103929 +static void register_attributes(void *event_data, void *data)
103930 +{
103931 + register_attribute(&latent_entropy_attr);
103932 +}
103933 +
103934 +static bool gate_latent_entropy(void)
103935 +{
103936 + tree latent_entropy_attr;
103937 +
103938 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
103939 + return latent_entropy_attr != NULL_TREE;
103940 +}
103941 +
103942 +static enum tree_code get_op(tree *rhs)
103943 +{
103944 + static enum tree_code op;
103945 + unsigned HOST_WIDE_INT random_const;
103946 +
103947 + random_const = get_random_const();
103948 +
103949 + switch (op) {
103950 + case BIT_XOR_EXPR:
103951 + op = PLUS_EXPR;
103952 + break;
103953 +
103954 + case PLUS_EXPR:
103955 + if (rhs) {
103956 + op = LROTATE_EXPR;
103957 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
103958 + break;
103959 + }
103960 +
103961 + case LROTATE_EXPR:
103962 + default:
103963 + op = BIT_XOR_EXPR;
103964 + break;
103965 + }
103966 + if (rhs)
103967 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
103968 + return op;
103969 +}
103970 +
103971 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
103972 +{
103973 + gimple_stmt_iterator gsi;
103974 + gimple assign;
103975 + tree addxorrol, rhs;
103976 + enum tree_code op;
103977 +
103978 + op = get_op(&rhs);
103979 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
103980 + assign = gimple_build_assign(local_entropy, addxorrol);
103981 + gsi = gsi_after_labels(bb);
103982 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
103983 + update_stmt(assign);
103984 +//debug_bb(bb);
103985 +}
103986 +
103987 +static void perturb_latent_entropy(basic_block bb, tree rhs)
103988 +{
103989 + gimple_stmt_iterator gsi;
103990 + gimple assign;
103991 + tree addxorrol, temp;
103992 +
103993 + // 1. create temporary copy of latent_entropy
103994 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
103995 +#if BUILDING_GCC_VERSION <= 4007
103996 + add_referenced_var(temp);
103997 +#endif
103998 +
103999 + // 2. read...
104000 + temp = make_ssa_name(temp, NULL);
104001 + assign = gimple_build_assign(temp, latent_entropy_decl);
104002 + SSA_NAME_DEF_STMT(temp) = assign;
104003 +#if BUILDING_GCC_VERSION <= 4007
104004 + add_referenced_var(latent_entropy_decl);
104005 +#endif
104006 + gsi = gsi_after_labels(bb);
104007 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
104008 + update_stmt(assign);
104009 +
104010 + // 3. ...modify...
104011 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
104012 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
104013 + assign = gimple_build_assign(temp, addxorrol);
104014 + SSA_NAME_DEF_STMT(temp) = assign;
104015 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
104016 + update_stmt(assign);
104017 +
104018 + // 4. ...write latent_entropy
104019 + assign = gimple_build_assign(latent_entropy_decl, temp);
104020 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
104021 + update_stmt(assign);
104022 +}
104023 +
104024 +static unsigned int execute_latent_entropy(void)
104025 +{
104026 + basic_block bb;
104027 + gimple assign;
104028 + gimple_stmt_iterator gsi;
104029 + tree local_entropy;
104030 +
104031 + if (!latent_entropy_decl) {
104032 + struct varpool_node *node;
104033 +
104034 +#if BUILDING_GCC_VERSION <= 4007
104035 + for (node = varpool_nodes; node; node = node->next) {
104036 + tree var = node->decl;
104037 +#else
104038 + FOR_EACH_VARIABLE(node) {
104039 + tree var = node->symbol.decl;
104040 +#endif
104041 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
104042 + continue;
104043 + latent_entropy_decl = var;
104044 +// debug_tree(var);
104045 + break;
104046 + }
104047 + if (!latent_entropy_decl) {
104048 +// debug_tree(current_function_decl);
104049 + return 0;
104050 + }
104051 + }
104052 +
104053 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
104054 +
104055 + // 1. create local entropy variable
104056 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
104057 +#if BUILDING_GCC_VERSION <= 4007
104058 + add_referenced_var(local_entropy);
104059 + mark_sym_for_renaming(local_entropy);
104060 +#endif
104061 +
104062 + // 2. initialize local entropy variable
104063 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104064 + if (dom_info_available_p(CDI_DOMINATORS))
104065 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104066 + gsi = gsi_start_bb(bb);
104067 +
104068 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
104069 +// gimple_set_location(assign, loc);
104070 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
104071 + update_stmt(assign);
104072 +//debug_bb(bb);
104073 + bb = bb->next_bb;
104074 +
104075 + // 3. instrument each BB with an operation on the local entropy variable
104076 + while (bb != EXIT_BLOCK_PTR) {
104077 + perturb_local_entropy(bb, local_entropy);
104078 +//debug_bb(bb);
104079 + bb = bb->next_bb;
104080 + };
104081 +
104082 + // 4. mix local entropy into the global entropy variable
104083 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
104084 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
104085 + return 0;
104086 +}
104087 +
104088 +static void start_unit_callback(void *gcc_data, void *user_data)
104089 +{
104090 + tree latent_entropy_type;
104091 +
104092 +#if BUILDING_GCC_VERSION >= 4007
104093 + seed = get_random_seed(false);
104094 +#else
104095 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
104096 + seed *= seed;
104097 +#endif
104098 +
104099 + if (in_lto_p)
104100 + return;
104101 +
104102 + // extern volatile u64 latent_entropy
104103 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
104104 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
104105 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
104106 +
104107 + TREE_STATIC(latent_entropy_decl) = 1;
104108 + TREE_PUBLIC(latent_entropy_decl) = 1;
104109 + TREE_USED(latent_entropy_decl) = 1;
104110 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
104111 + DECL_EXTERNAL(latent_entropy_decl) = 1;
104112 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
104113 + lang_hooks.decls.pushdecl(latent_entropy_decl);
104114 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
104115 +// varpool_finalize_decl(latent_entropy_decl);
104116 +// varpool_mark_needed_node(latent_entropy_decl);
104117 +}
104118 +
104119 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104120 +{
104121 + const char * const plugin_name = plugin_info->base_name;
104122 + struct register_pass_info latent_entropy_pass_info = {
104123 + .pass = &latent_entropy_pass.pass,
104124 + .reference_pass_name = "optimized",
104125 + .ref_pass_instance_number = 1,
104126 + .pos_op = PASS_POS_INSERT_BEFORE
104127 + };
104128 +
104129 + if (!plugin_default_version_check(version, &gcc_version)) {
104130 + error(G_("incompatible gcc/plugin versions"));
104131 + return 1;
104132 + }
104133 +
104134 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
104135 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
104136 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
104137 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104138 +
104139 + return 0;
104140 +}
104141 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
104142 new file mode 100644
104143 index 0000000..3d6cc0f
104144 --- /dev/null
104145 +++ b/tools/gcc/size_overflow_hash.data
104146 @@ -0,0 +1,7743 @@
104147 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
104148 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
104149 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
104150 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
104151 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
104152 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
104153 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
104154 +padzero_55 padzero 1 55 &sel_read_policyvers_55
104155 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
104156 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
104157 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
104158 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
104159 +load_msg_95 load_msg 2 95 NULL
104160 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
104161 +write_all_supers_117 write_all_supers 0 117 NULL nohasharray
104162 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 &write_all_supers_117
104163 +init_q_132 init_q 4 132 NULL
104164 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
104165 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
104166 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
104167 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
104168 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
104169 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
104170 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
104171 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
104172 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
104173 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
104174 +br_port_info_size_268 br_port_info_size 0 268 NULL
104175 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
104176 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
104177 +SYSC_connect_304 SYSC_connect 3 304 NULL
104178 +syslog_print_307 syslog_print 2 307 NULL
104179 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
104180 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
104181 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
104182 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
104183 +get_more_blocks_367 get_more_blocks 0 367 NULL
104184 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
104185 +hw_device_state_409 hw_device_state 0 409 NULL
104186 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
104187 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
104188 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
104189 +sparse_index_init_482 sparse_index_init 2 482 NULL
104190 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
104191 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
104192 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
104193 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
104194 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
104195 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
104196 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
104197 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
104198 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
104199 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
104200 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
104201 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
104202 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
104203 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
104204 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
104205 +cl_page_own0_599 cl_page_own0 0 599 NULL
104206 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
104207 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
104208 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
104209 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
104210 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
104211 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
104212 +clone_split_bio_633 clone_split_bio 6 633 NULL
104213 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
104214 +remap_to_cache_640 remap_to_cache 3 640 NULL
104215 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
104216 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
104217 +unlink_queued_645 unlink_queued 4 645 NULL
104218 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
104219 +div_u64_rem_672 div_u64_rem 0 672 NULL
104220 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
104221 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
104222 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
104223 +disk_max_parts_719 disk_max_parts 0 719 NULL
104224 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
104225 +dvb_video_write_754 dvb_video_write 3 754 NULL
104226 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
104227 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
104228 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
104229 +__vmalloc_node_range_811 __vmalloc_node_range 7 811 NULL nohasharray
104230 +snd_pcm_drain_811 snd_pcm_drain 0 811 &__vmalloc_node_range_811
104231 +if_writecmd_815 if_writecmd 2 815 NULL
104232 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
104233 +SyS_write_846 SyS_write 3 846 NULL
104234 +um_idi_read_850 um_idi_read 3 850 NULL
104235 +error_state_read_859 error_state_read 6 859 NULL
104236 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
104237 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
104238 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
104239 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
104240 +readw_931 readw 0 931 NULL
104241 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
104242 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
104243 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
104244 +memcmp_990 memcmp 0 990 NULL
104245 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
104246 +free_ind_block_999 free_ind_block 0 999 NULL
104247 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
104248 +readreg_1017 readreg 0-1 1017 NULL
104249 +_do_truncate_1019 _do_truncate 2 1019 NULL
104250 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
104251 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
104252 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
104253 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
104254 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
104255 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
104256 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
104257 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
104258 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
104259 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
104260 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
104261 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
104262 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
104263 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
104264 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
104265 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
104266 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
104267 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
104268 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
104269 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
104270 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
104271 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
104272 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
104273 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
104274 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
104275 +nested_get_page_1252 nested_get_page 2 1252 NULL
104276 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
104277 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
104278 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
104279 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
104280 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
104281 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
104282 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
104283 +ffs_1322 ffs 0 1322 NULL
104284 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
104285 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
104286 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
104287 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
104288 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
104289 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
104290 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
104291 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
104292 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
104293 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
104294 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
104295 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
104296 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
104297 +zone_page_state_1393 zone_page_state 0 1393 NULL
104298 +file_read_actor_1401 file_read_actor 4 1401 NULL
104299 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
104300 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
104301 +pq_init_1423 pq_init 1 1423 NULL
104302 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
104303 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
104304 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
104305 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
104306 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
104307 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
104308 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
104309 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
104310 +fpregs_set_1497 fpregs_set 4 1497 NULL
104311 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
104312 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
104313 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
104314 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
104315 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
104316 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
104317 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
104318 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
104319 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
104320 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
104321 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
104322 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
104323 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
104324 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
104325 +rmap_add_1677 rmap_add 3 1677 NULL
104326 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
104327 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
104328 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
104329 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
104330 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
104331 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
104332 +internal_create_group_1733 internal_create_group 0 1733 NULL
104333 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
104334 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
104335 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
104336 +cosa_write_1774 cosa_write 3 1774 NULL
104337 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
104338 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
104339 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
104340 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
104341 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
104342 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
104343 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
104344 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
104345 +bdev_erase_1933 bdev_erase 3 1933 NULL
104346 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
104347 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
104348 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
104349 +read_swap_header_1957 read_swap_header 0 1957 NULL
104350 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
104351 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
104352 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
104353 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
104354 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
104355 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
104356 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
104357 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
104358 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
104359 +ksm_madvise_2012 ksm_madvise 0 2012 NULL
104360 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
104361 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
104362 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
104363 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
104364 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
104365 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
104366 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
104367 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
104368 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
104369 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
104370 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
104371 +audit_expand_2098 audit_expand 0 2098 NULL
104372 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
104373 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
104374 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
104375 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
104376 +enable_read_2117 enable_read 3 2117 NULL
104377 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
104378 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
104379 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
104380 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
104381 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
104382 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
104383 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
104384 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
104385 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
104386 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
104387 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
104388 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
104389 +vhci_write_2224 vhci_write 3 2224 NULL
104390 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
104391 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
104392 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
104393 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
104394 +do_update_counters_2259 do_update_counters 4 2259 NULL
104395 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
104396 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
104397 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
104398 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
104399 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
104400 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
104401 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
104402 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
104403 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
104404 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
104405 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
104406 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
104407 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
104408 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
104409 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
104410 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
104411 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
104412 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
104413 +raid1_size_2419 raid1_size 0-2 2419 NULL
104414 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
104415 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
104416 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
104417 +wiphy_new_2482 wiphy_new 2 2482 NULL
104418 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
104419 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
104420 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
104421 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
104422 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
104423 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
104424 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
104425 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
104426 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
104427 +slot_bytes_2609 slot_bytes 0 2609 NULL
104428 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
104429 +switch_status_2629 switch_status 5 2629 NULL
104430 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
104431 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
104432 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
104433 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
104434 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
104435 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
104436 +oti6858_write_2692 oti6858_write 4 2692 NULL
104437 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
104438 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
104439 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
104440 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
104441 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
104442 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
104443 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
104444 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
104445 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
104446 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
104447 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
104448 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
104449 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
104450 +vmemmap_pte_populate_2822 vmemmap_pte_populate 3 2822 NULL
104451 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
104452 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
104453 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
104454 +sock_create_2838 sock_create 0 2838 NULL
104455 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
104456 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
104457 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
104458 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
104459 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
104460 +mq_map_2871 mq_map 2 2871 NULL
104461 +__swab64p_2875 __swab64p 0 2875 NULL
104462 +nla_padlen_2883 nla_padlen 1 2883 NULL
104463 +cmm_write_2896 cmm_write 3 2896 NULL
104464 +alloc_page_cgroup_2919 alloc_page_cgroup 1-2 2919 NULL
104465 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
104466 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
104467 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
104468 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
104469 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
104470 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
104471 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
104472 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
104473 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
104474 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
104475 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
104476 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
104477 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
104478 +depth_write_3021 depth_write 3 3021 NULL
104479 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
104480 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
104481 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
104482 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
104483 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
104484 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
104485 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
104486 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
104487 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
104488 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
104489 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
104490 +free_coherent_3082 free_coherent 4-2 3082 NULL
104491 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
104492 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
104493 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
104494 +rb_alloc_3102 rb_alloc 1-3 3102 NULL
104495 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
104496 +print_time_3132 print_time 0 3132 NULL
104497 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
104498 +find_free_extent_3153 find_free_extent 5 3153 NULL
104499 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
104500 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
104501 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
104502 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
104503 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
104504 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
104505 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
104506 +mempool_create_node_3191 mempool_create_node 1-6 3191 NULL
104507 +alloc_context_3194 alloc_context 1 3194 NULL
104508 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
104509 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
104510 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
104511 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
104512 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
104513 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
104514 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
104515 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
104516 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
104517 +key_key_read_3241 key_key_read 3 3241 NULL
104518 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
104519 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
104520 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
104521 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
104522 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
104523 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
104524 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
104525 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
104526 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
104527 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
104528 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
104529 +scnprintf_3360 scnprintf 0-2 3360 NULL
104530 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
104531 +sr_read_3366 sr_read 3 3366 NULL
104532 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
104533 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
104534 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
104535 +send_stream_3397 send_stream 4 3397 NULL
104536 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
104537 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
104538 +zone_to_nid_3415 zone_to_nid 0 3415 NULL
104539 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
104540 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
104541 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
104542 +send_unlink_3438 send_unlink 0 3438 NULL
104543 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
104544 +map_single_3449 map_single 0 3449 NULL
104545 +softsynth_write_3455 softsynth_write 3 3455 NULL
104546 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
104547 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
104548 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
104549 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
104550 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
104551 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
104552 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
104553 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
104554 +SyS_readv_3539 SyS_readv 3 3539 NULL
104555 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
104556 +iommu_map_3554 iommu_map 3-2 3554 NULL
104557 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
104558 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
104559 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
104560 +evtchn_read_3569 evtchn_read 3 3569 NULL
104561 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
104562 +vc_resize_3585 vc_resize 3-2 3585 NULL
104563 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
104564 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
104565 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
104566 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
104567 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
104568 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
104569 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
104570 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
104571 +replace_pin_at_irq_node_3687 replace_pin_at_irq_node 2 3687 NULL
104572 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0-2 3694 NULL
104573 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
104574 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
104575 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
104576 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
104577 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
104578 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
104579 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
104580 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
104581 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
104582 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
104583 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
104584 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
104585 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
104586 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
104587 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
104588 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
104589 +get_fd_set_3866 get_fd_set 1 3866 NULL
104590 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
104591 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
104592 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
104593 +nvram_write_3894 nvram_write 3 3894 NULL
104594 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
104595 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
104596 +vcs_write_3910 vcs_write 3 3910 NULL
104597 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
104598 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
104599 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
104600 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
104601 +do_add_counters_3992 do_add_counters 3 3992 NULL
104602 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
104603 +userspace_status_4004 userspace_status 4 4004 NULL
104604 +mei_write_4005 mei_write 3 4005 NULL nohasharray
104605 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
104606 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
104607 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
104608 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
104609 +blk_end_request_4024 blk_end_request 3 4024 NULL
104610 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
104611 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
104612 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
104613 +vmemmap_pmd_populate_4071 vmemmap_pmd_populate 3 4071 NULL
104614 +read_file_queues_4078 read_file_queues 3 4078 NULL
104615 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
104616 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
104617 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
104618 +tm6000_read_4151 tm6000_read 3 4151 NULL
104619 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
104620 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
104621 +get_alua_req_4166 get_alua_req 3 4166 NULL
104622 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
104623 +read_file_bool_4180 read_file_bool 3 4180 NULL
104624 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
104625 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
104626 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
104627 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
104628 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
104629 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
104630 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
104631 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
104632 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
104633 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
104634 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
104635 +__pool_find_4308 __pool_find 3 4308 NULL
104636 +count_strings_4315 count_strings 0 4315 NULL
104637 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
104638 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
104639 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
104640 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
104641 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
104642 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
104643 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
104644 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
104645 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
104646 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
104647 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
104648 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
104649 +memparse_4444 memparse 0 4444 NULL
104650 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
104651 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
104652 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
104653 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
104654 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
104655 +set_link_security_4502 set_link_security 4 4502 NULL
104656 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
104657 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
104658 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
104659 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
104660 +tty_register_device_4544 tty_register_device 2 4544 NULL
104661 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
104662 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
104663 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
104664 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
104665 +bch_alloc_4593 bch_alloc 1 4593 NULL
104666 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
104667 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
104668 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
104669 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
104670 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
104671 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
104672 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
104673 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
104674 +kone_receive_4690 kone_receive 4 4690 NULL
104675 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
104676 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
104677 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
104678 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
104679 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
104680 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
104681 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
104682 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
104683 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
104684 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
104685 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
104686 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
104687 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
104688 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
104689 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
104690 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
104691 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
104692 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
104693 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
104694 +get_new_location_4866 get_new_location 0 4866 NULL
104695 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
104696 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
104697 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
104698 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
104699 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
104700 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
104701 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
104702 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
104703 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
104704 +do_sync_read_4977 do_sync_read 0 4977 NULL
104705 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
104706 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
104707 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
104708 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
104709 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
104710 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
104711 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
104712 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
104713 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
104714 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
104715 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
104716 +sound_write_5102 sound_write 3 5102 NULL
104717 +clear_dirty_5105 clear_dirty 3 5105 NULL
104718 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
104719 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
104720 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
104721 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
104722 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
104723 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
104724 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
104725 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
104726 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
104727 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
104728 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
104729 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
104730 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
104731 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
104732 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
104733 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
104734 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
104735 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
104736 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
104737 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
104738 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
104739 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
104740 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
104741 +cq_free_res_5355 cq_free_res 5 5355 NULL
104742 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
104743 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
104744 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
104745 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
104746 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
104747 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
104748 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
104749 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
104750 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
104751 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
104752 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
104753 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
104754 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
104755 +tty_write_5494 tty_write 3 5494 NULL
104756 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
104757 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
104758 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
104759 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
104760 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
104761 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
104762 +le_readq_5557 le_readq 0 5557 NULL
104763 +inw_5558 inw 0 5558 NULL
104764 +bioset_create_5580 bioset_create 1 5580 NULL
104765 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
104766 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
104767 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
104768 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
104769 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
104770 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
104771 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
104772 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
104773 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
104774 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
104775 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
104776 +get_arg_5694 get_arg 3 5694 NULL
104777 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
104778 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
104779 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
104780 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
104781 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
104782 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
104783 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
104784 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
104785 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
104786 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
104787 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
104788 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
104789 +setup_req_5848 setup_req 3 5848 NULL
104790 +ria_page_count_5849 ria_page_count 0 5849 NULL
104791 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
104792 +config_buf_5862 config_buf 0 5862 NULL
104793 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
104794 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
104795 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
104796 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
104797 +port_show_regs_5904 port_show_regs 3 5904 NULL
104798 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
104799 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
104800 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
104801 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
104802 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
104803 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
104804 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
104805 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
104806 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
104807 +native_pte_val_5978 native_pte_val 0 5978 NULL
104808 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
104809 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
104810 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
104811 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
104812 +alloc_msg_6072 alloc_msg 1 6072 NULL
104813 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
104814 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
104815 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
104816 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
104817 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
104818 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
104819 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
104820 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
104821 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
104822 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
104823 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
104824 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
104825 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
104826 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
104827 +__add_pin_to_irq_node_6188 __add_pin_to_irq_node 2 6188 NULL
104828 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
104829 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
104830 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
104831 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
104832 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
104833 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
104834 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
104835 +changed_ref_6242 changed_ref 0 6242 NULL
104836 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
104837 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
104838 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
104839 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
104840 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
104841 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
104842 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
104843 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
104844 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
104845 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
104846 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
104847 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
104848 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
104849 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
104850 +utc2ntfs_6347 utc2ntfs 0 6347 NULL
104851 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
104852 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
104853 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
104854 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
104855 +msb_write_block_6379 msb_write_block 3 6379 NULL
104856 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
104857 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
104858 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
104859 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
104860 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
104861 +add_to_list_6433 add_to_list 0 6433 NULL
104862 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
104863 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
104864 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
104865 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
104866 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
104867 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
104868 +ntfs_cluster_free_6497 ntfs_cluster_free 0 6497 NULL
104869 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
104870 +mei_read_6507 mei_read 3 6507 NULL
104871 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
104872 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
104873 +wdm_read_6549 wdm_read 3 6549 NULL
104874 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
104875 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
104876 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
104877 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
104878 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
104879 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
104880 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
104881 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
104882 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
104883 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
104884 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
104885 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
104886 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
104887 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
104888 +mpeg_read_6708 mpeg_read 3 6708 NULL
104889 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
104890 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
104891 +video_proc_write_6724 video_proc_write 3 6724 NULL
104892 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
104893 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
104894 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
104895 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
104896 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
104897 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
104898 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
104899 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
104900 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
104901 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
104902 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
104903 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
104904 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
104905 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
104906 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
104907 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
104908 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
104909 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
104910 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
104911 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
104912 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
104913 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
104914 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
104915 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
104916 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
104917 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
104918 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
104919 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
104920 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
104921 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
104922 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
104923 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
104924 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
104925 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
104926 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
104927 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
104928 +request_key_async_6990 request_key_async 4 6990 NULL
104929 +tpl_write_6998 tpl_write 3 6998 NULL
104930 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
104931 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
104932 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
104933 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
104934 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
104935 +wimax_msg_7030 wimax_msg 4 7030 NULL
104936 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
104937 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
104938 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
104939 +event_enable_read_7074 event_enable_read 3 7074 NULL
104940 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
104941 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
104942 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
104943 +check_header_7108 check_header 0 7108 NULL
104944 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
104945 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
104946 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
104947 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
104948 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
104949 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
104950 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
104951 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
104952 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
104953 +get_param_h_7247 get_param_h 0 7247 NULL
104954 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
104955 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
104956 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
104957 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
104958 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
104959 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
104960 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
104961 +get_string_7302 get_string 0 7302 NULL
104962 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
104963 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
104964 +mgmt_control_7349 mgmt_control 3 7349 NULL
104965 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
104966 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
104967 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
104968 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
104969 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
104970 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
104971 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
104972 +hweight_long_7388 hweight_long 1-0 7388 NULL
104973 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
104974 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
104975 +readb_7401 readb 0 7401 NULL
104976 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
104977 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
104978 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
104979 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
104980 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
104981 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
104982 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
104983 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
104984 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
104985 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
104986 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
104987 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
104988 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
104989 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
104990 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
104991 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
104992 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
104993 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
104994 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
104995 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
104996 +create_dir_7614 create_dir 0 7614 NULL nohasharray
104997 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
104998 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
104999 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
105000 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
105001 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
105002 +dev_write_7708 dev_write 3 7708 NULL
105003 +unmap_region_7709 unmap_region 1 7709 NULL
105004 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
105005 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
105006 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
105007 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
105008 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
105009 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
105010 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
105011 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
105012 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
105013 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
105014 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
105015 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
105016 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
105017 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
105018 +config_desc_7878 config_desc 0 7878 NULL
105019 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
105020 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
105021 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
105022 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
105023 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
105024 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1-2 7934 NULL
105025 +compare_refs_7938 compare_refs 0 7938 NULL
105026 +fsnotify_7943 fsnotify 0 7943 NULL
105027 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
105028 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
105029 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
105030 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
105031 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
105032 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
105033 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
105034 +vcs_read_8017 vcs_read 3 8017 NULL
105035 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
105036 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
105037 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
105038 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
105039 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
105040 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
105041 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
105042 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
105043 +venus_lookup_8121 venus_lookup 4 8121 NULL
105044 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
105045 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
105046 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
105047 +ore_truncate_8181 ore_truncate 3 8181 NULL
105048 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
105049 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
105050 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
105051 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
105052 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
105053 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
105054 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
105055 +play_iframe_8219 play_iframe 3 8219 NULL
105056 +create_log_8225 create_log 2 8225 NULL nohasharray
105057 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
105058 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
105059 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
105060 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
105061 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
105062 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
105063 +init_cdev_8274 init_cdev 1 8274 NULL
105064 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
105065 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
105066 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
105067 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
105068 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
105069 +cfs_cpt_spread_node_8338 cfs_cpt_spread_node 0 8338 NULL
105070 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
105071 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
105072 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
105073 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
105074 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
105075 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
105076 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
105077 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
105078 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
105079 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
105080 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
105081 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
105082 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
105083 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
105084 +dir_changed_8471 dir_changed 0 8471 NULL
105085 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
105086 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
105087 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
105088 +dev_config_8506 dev_config 3 8506 NULL
105089 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
105090 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
105091 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
105092 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
105093 +user_on_off_8552 user_on_off 2 8552 NULL
105094 +profile_remove_8556 profile_remove 3 8556 NULL
105095 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
105096 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
105097 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
105098 +tower_write_8580 tower_write 3 8580 NULL
105099 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
105100 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
105101 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
105102 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
105103 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
105104 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
105105 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
105106 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
105107 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
105108 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
105109 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
105110 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
105111 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
105112 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
105113 +arcfb_write_8702 arcfb_write 3 8702 NULL
105114 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
105115 +init_header_8703 init_header 0 8703 &i_size_read_8703
105116 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
105117 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
105118 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
105119 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
105120 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
105121 +f_dupfd_8730 f_dupfd 1 8730 NULL
105122 +__create_irqs_8733 __create_irqs 2-1-0-3 8733 NULL
105123 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
105124 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
105125 +compound_order_8750 compound_order 0 8750 NULL
105126 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
105127 +yurex_write_8761 yurex_write 3 8761 NULL
105128 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
105129 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
105130 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
105131 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
105132 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
105133 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
105134 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
105135 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
105136 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
105137 +ntfs_commit_pages_after_write_8809 ntfs_commit_pages_after_write 4-3 8809 NULL
105138 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
105139 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
105140 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
105141 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
105142 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
105143 +clear_bitset_8840 clear_bitset 2 8840 NULL
105144 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
105145 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
105146 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
105147 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
105148 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
105149 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
105150 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
105151 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
105152 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
105153 +write_file_ani_8918 write_file_ani 3 8918 NULL
105154 +layout_commit_8926 layout_commit 3 8926 NULL
105155 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
105156 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
105157 +lookup_zone_8956 lookup_zone 2 8956 NULL
105158 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
105159 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
105160 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
105161 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
105162 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
105163 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
105164 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
105165 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
105166 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
105167 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
105168 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
105169 +sparse_index_alloc_9021 sparse_index_alloc 1 9021 NULL
105170 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
105171 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
105172 +nla_put_9042 nla_put 3 9042 NULL
105173 +offset_il_node_9059 offset_il_node 0 9059 NULL
105174 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
105175 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
105176 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
105177 +create_queues_9088 create_queues 3-2 9088 NULL
105178 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
105179 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
105180 +alloc_slabmgmt_9109 alloc_slabmgmt 5 9109 NULL
105181 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
105182 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
105183 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
105184 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
105185 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
105186 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
105187 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
105188 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
105189 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
105190 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
105191 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
105192 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
105193 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
105194 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
105195 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
105196 +get_pfn_9207 get_pfn 1 9207 NULL
105197 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
105198 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
105199 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
105200 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
105201 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
105202 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
105203 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
105204 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
105205 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
105206 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
105207 +flakey_status_9274 flakey_status 5 9274 NULL
105208 +migrate_misplaced_transhuge_page_9298 migrate_misplaced_transhuge_page 7 9298 NULL
105209 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
105210 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
105211 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
105212 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
105213 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
105214 +__ksm_enter_9347 __ksm_enter 0 9347 NULL
105215 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
105216 +of_node_to_nid_9367 of_node_to_nid 0 9367 NULL
105217 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
105218 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
105219 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
105220 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
105221 +read_9397 read 3 9397 NULL
105222 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
105223 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
105224 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
105225 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
105226 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
105227 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
105228 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
105229 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
105230 +crypt_status_9492 crypt_status 5 9492 NULL
105231 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
105232 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
105233 +lp_write_9511 lp_write 3 9511 NULL
105234 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
105235 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
105236 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
105237 +read_file_dma_9530 read_file_dma 3 9530 NULL
105238 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
105239 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
105240 +unmerge_ksm_pages_9546 unmerge_ksm_pages 0 9546 NULL nohasharray
105241 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 &unmerge_ksm_pages_9546
105242 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
105243 +readl_9557 readl 0 9557 NULL
105244 +fw_node_create_9559 fw_node_create 2 9559 NULL
105245 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
105246 +kobj_map_9566 kobj_map 3-2 9566 NULL
105247 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
105248 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
105249 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
105250 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
105251 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
105252 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
105253 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
105254 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
105255 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
105256 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
105257 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
105258 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
105259 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
105260 +dns_query_9676 dns_query 3 9676 NULL
105261 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
105262 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
105263 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
105264 +fnb_9703 fnb 2-3-0 9703 NULL
105265 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
105266 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
105267 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
105268 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
105269 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
105270 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
105271 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
105272 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
105273 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
105274 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
105275 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
105276 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
105277 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
105278 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
105279 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
105280 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
105281 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
105282 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
105283 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
105284 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
105285 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
105286 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
105287 +svc_pool_map_get_node_9817 svc_pool_map_get_node 0 9817 NULL
105288 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
105289 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
105290 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
105291 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
105292 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
105293 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
105294 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
105295 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
105296 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
105297 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
105298 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
105299 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
105300 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
105301 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
105302 +read_file_misc_9948 read_file_misc 3 9948 NULL
105303 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
105304 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
105305 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
105306 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
105307 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
105308 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
105309 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
105310 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
105311 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
105312 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
105313 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
105314 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
105315 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
105316 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
105317 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
105318 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
105319 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
105320 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
105321 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
105322 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
105323 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
105324 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
105325 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
105326 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
105327 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
105328 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
105329 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
105330 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
105331 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
105332 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
105333 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
105334 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
105335 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
105336 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
105337 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
105338 +read_emulate_10310 read_emulate 2-4 10310 NULL
105339 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
105340 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
105341 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
105342 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
105343 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
105344 +get_dump_page_10338 get_dump_page 1 10338 NULL
105345 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
105346 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
105347 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
105348 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
105349 +__ntfs_cluster_free_10360 __ntfs_cluster_free 0 10360 NULL
105350 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
105351 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
105352 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
105353 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
105354 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
105355 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
105356 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
105357 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
105358 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
105359 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
105360 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
105361 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
105362 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
105363 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
105364 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
105365 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
105366 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
105367 +SYSC_read_10545 SYSC_read 3 10545 NULL
105368 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
105369 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
105370 +otp_read_10594 otp_read 5-4-2 10594 NULL
105371 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
105372 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
105373 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
105374 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
105375 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
105376 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
105377 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
105378 +parport_write_10669 parport_write 0 10669 NULL
105379 +alloc_vmap_area_10682 alloc_vmap_area 5 10682 NULL
105380 +edge_write_10692 edge_write 4 10692 NULL
105381 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
105382 +inl_10708 inl 0 10708 NULL nohasharray
105383 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
105384 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
105385 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
105386 +spi_sync_10731 spi_sync 0 10731 NULL
105387 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
105388 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
105389 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
105390 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
105391 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
105392 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
105393 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
105394 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
105395 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
105396 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
105397 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
105398 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
105399 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
105400 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
105401 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
105402 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
105403 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
105404 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
105405 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
105406 +get_scq_10897 get_scq 2 10897 NULL
105407 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
105408 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
105409 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
105410 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
105411 +kobject_add_10919 kobject_add 0 10919 NULL
105412 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
105413 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
105414 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
105415 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
105416 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
105417 +lz4_compress_10986 lz4_compress 2 10986 NULL
105418 +do_switch_10994 do_switch 0 10994 NULL
105419 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
105420 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
105421 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
105422 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
105423 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
105424 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
105425 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
105426 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
105427 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
105428 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
105429 +count_argc_11083 count_argc 0 11083 NULL
105430 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
105431 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
105432 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
105433 +page_offset_11120 page_offset 0 11120 NULL
105434 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
105435 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
105436 +alloc_alien_cache_11127 alloc_alien_cache 2-1 11127 NULL
105437 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
105438 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
105439 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
105440 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
105441 +mmap_region_11247 mmap_region 0-2 11247 NULL
105442 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
105443 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
105444 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
105445 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
105446 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
105447 +split_vma_11312 split_vma 0 11312 NULL
105448 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
105449 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
105450 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
105451 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
105452 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
105453 +construct_key_11329 construct_key 3 11329 NULL nohasharray
105454 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
105455 +next_segment_11330 next_segment 0-2-1 11330 NULL
105456 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
105457 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
105458 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
105459 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
105460 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
105461 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
105462 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
105463 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
105464 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
105465 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
105466 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
105467 +str_to_user_11411 str_to_user 2 11411 NULL
105468 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
105469 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
105470 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
105471 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
105472 +trace_options_read_11419 trace_options_read 3 11419 NULL
105473 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
105474 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
105475 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
105476 +prepare_image_11424 prepare_image 0 11424 NULL
105477 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
105478 +bttv_read_11432 bttv_read 3 11432 NULL
105479 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
105480 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
105481 +swp_offset_11475 swp_offset 0 11475 NULL
105482 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
105483 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
105484 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
105485 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
105486 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
105487 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
105488 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
105489 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
105490 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
105491 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
105492 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
105493 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
105494 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
105495 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
105496 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
105497 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
105498 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
105499 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
105500 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
105501 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
105502 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
105503 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
105504 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
105505 +slab_ksize_11664 slab_ksize 0 11664 NULL
105506 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
105507 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
105508 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
105509 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
105510 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
105511 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
105512 +split_11691 split 2 11691 NULL
105513 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
105514 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
105515 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
105516 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
105517 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
105518 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
105519 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
105520 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
105521 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
105522 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
105523 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
105524 +umc_device_register_11824 umc_device_register 0 11824 NULL
105525 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
105526 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
105527 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
105528 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
105529 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
105530 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
105531 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
105532 +perf_mmap_alloc_page_11904 perf_mmap_alloc_page 1 11904 NULL
105533 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
105534 +ti_write_11916 ti_write 4 11916 NULL
105535 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
105536 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
105537 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
105538 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
105539 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
105540 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
105541 +split_node_11976 split_node 0 11976 &usc_InReg_11976
105542 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
105543 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
105544 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
105545 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
105546 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
105547 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
105548 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
105549 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
105550 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
105551 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
105552 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
105553 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
105554 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
105555 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
105556 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
105557 +set_powered_12129 set_powered 4 12129 NULL
105558 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
105559 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
105560 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
105561 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
105562 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
105563 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
105564 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
105565 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
105566 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
105567 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
105568 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
105569 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
105570 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
105571 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
105572 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
105573 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
105574 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
105575 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
105576 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
105577 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
105578 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
105579 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
105580 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
105581 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
105582 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
105583 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
105584 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
105585 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
105586 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
105587 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
105588 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
105589 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
105590 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
105591 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
105592 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
105593 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
105594 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
105595 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
105596 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
105597 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
105598 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
105599 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
105600 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
105601 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
105602 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
105603 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
105604 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
105605 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
105606 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
105607 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
105608 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
105609 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
105610 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
105611 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
105612 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
105613 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
105614 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
105615 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
105616 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
105617 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
105618 +wb_create_12651 wb_create 1 12651 NULL
105619 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
105620 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
105621 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
105622 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4-5 12669 &sel_read_class_12669
105623 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
105624 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
105625 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
105626 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
105627 +ivtv_write_12721 ivtv_write 3 12721 NULL
105628 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
105629 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
105630 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
105631 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
105632 +listxattr_12769 listxattr 3 12769 NULL
105633 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
105634 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
105635 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
105636 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
105637 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
105638 +readq_12825 readq 0 12825 NULL
105639 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
105640 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
105641 +spidev_sync_12842 spidev_sync 0 12842 NULL
105642 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
105643 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
105644 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
105645 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
105646 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
105647 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
105648 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
105649 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
105650 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
105651 +bm_status_write_12964 bm_status_write 3 12964 NULL
105652 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
105653 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
105654 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
105655 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
105656 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
105657 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
105658 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
105659 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
105660 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
105661 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
105662 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
105663 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
105664 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
105665 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
105666 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
105667 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
105668 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
105669 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
105670 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
105671 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
105672 +blk_update_request_13146 blk_update_request 3 13146 NULL
105673 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
105674 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
105675 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
105676 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
105677 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
105678 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
105679 +comedi_read_13199 comedi_read 3 13199 NULL
105680 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
105681 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
105682 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
105683 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
105684 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
105685 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
105686 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
105687 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
105688 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
105689 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
105690 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
105691 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
105692 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
105693 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
105694 +sd_major_13294 sd_major 0-1 13294 NULL
105695 +kempld_read16_13297 kempld_read16 0 13297 NULL
105696 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
105697 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
105698 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
105699 +get_bits_13353 get_bits 0-2 13353 NULL
105700 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
105701 +snd_ctl_elem_info_13363 snd_ctl_elem_info 0 13363 NULL
105702 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
105703 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
105704 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
105705 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
105706 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
105707 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
105708 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
105709 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
105710 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
105711 +keyring_read_13438 keyring_read 3 13438 NULL
105712 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
105713 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
105714 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
105715 +data_read_13494 data_read 3 13494 NULL
105716 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
105717 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
105718 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
105719 +core_status_13515 core_status 4 13515 NULL
105720 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
105721 +bm_init_13529 bm_init 2 13529 NULL
105722 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
105723 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
105724 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
105725 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
105726 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
105727 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
105728 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
105729 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
105730 +cache_write_13589 cache_write 3 13589 NULL
105731 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
105732 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
105733 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
105734 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
105735 +packet_snd_13634 packet_snd 3 13634 NULL
105736 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
105737 +cache_downcall_13666 cache_downcall 3 13666 NULL
105738 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
105739 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
105740 +usb_get_string_13693 usb_get_string 0 13693 NULL
105741 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
105742 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
105743 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
105744 +netdev_queue_numa_node_read_13732 netdev_queue_numa_node_read 0 13732 NULL
105745 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
105746 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
105747 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
105748 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
105749 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
105750 +random_read_13815 random_read 3 13815 NULL
105751 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
105752 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
105753 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
105754 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
105755 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
105756 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
105757 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
105758 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
105759 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
105760 +window_alignment_13895 window_alignment 0 13895 NULL
105761 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
105762 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
105763 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
105764 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
105765 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
105766 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
105767 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
105768 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
105769 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
105770 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
105771 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
105772 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
105773 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
105774 +qcam_read_13977 qcam_read 3 13977 NULL
105775 +dsp_read_13980 dsp_read 2 13980 NULL
105776 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
105777 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
105778 +create_files_14003 create_files 0 14003 NULL
105779 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
105780 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
105781 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
105782 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
105783 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
105784 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
105785 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
105786 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
105787 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
105788 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
105789 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
105790 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
105791 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
105792 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
105793 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
105794 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
105795 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
105796 +em_canid_change_14150 em_canid_change 3 14150 NULL
105797 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
105798 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
105799 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
105800 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
105801 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
105802 +do_splice_14196 do_splice 5 14196 NULL
105803 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
105804 +alloc_async_14208 alloc_async 1 14208 NULL
105805 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
105806 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
105807 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
105808 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
105809 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
105810 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
105811 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
105812 +numa_mem_id_14279 numa_mem_id 0 14279 NULL
105813 +rr_status_14293 rr_status 5 14293 NULL
105814 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
105815 +__readl_14308 __readl 0 14308 NULL
105816 +send_chown_14309 send_chown 0 14309 NULL
105817 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
105818 +oo_objects_14319 oo_objects 0 14319 NULL
105819 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
105820 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
105821 +down_write_failed_14331 down_write_failed 2 14331 NULL
105822 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
105823 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
105824 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
105825 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
105826 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
105827 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
105828 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
105829 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
105830 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
105831 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
105832 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
105833 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
105834 +block_size_14443 block_size 0 14443 NULL
105835 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
105836 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
105837 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
105838 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
105839 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
105840 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
105841 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
105842 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
105843 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 NULL nohasharray
105844 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
105845 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
105846 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
105847 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
105848 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
105849 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
105850 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
105851 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
105852 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
105853 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
105854 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
105855 +dbJoin_14644 dbJoin 0 14644 NULL
105856 +profile_replace_14652 profile_replace 3 14652 NULL
105857 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
105858 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
105859 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
105860 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
105861 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
105862 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
105863 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
105864 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
105865 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
105866 +cgroup_path_14713 cgroup_path 3 14713 NULL
105867 +get_bio_block_14714 get_bio_block 0 14714 NULL
105868 +vfd_write_14717 vfd_write 3 14717 NULL
105869 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
105870 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
105871 +raid1_resize_14740 raid1_resize 2 14740 NULL
105872 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
105873 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
105874 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
105875 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
105876 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
105877 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
105878 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
105879 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
105880 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 NULL nohasharray
105881 +hpet_readl_14801 hpet_readl 0 14801 &snd_als300_gcr_read_14801
105882 +changed_cb_14819 changed_cb 0 14819 NULL
105883 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
105884 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
105885 +lcd_write_14857 lcd_write 3 14857 NULL
105886 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
105887 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
105888 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
105889 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
105890 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
105891 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
105892 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
105893 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
105894 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
105895 +queue_cnt_14951 queue_cnt 0 14951 NULL
105896 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
105897 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
105898 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
105899 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
105900 +setkey_14987 setkey 3 14987 NULL nohasharray
105901 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
105902 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
105903 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
105904 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
105905 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
105906 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
105907 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
105908 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
105909 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
105910 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
105911 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
105912 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
105913 +start_port_15124 start_port 0 15124 NULL
105914 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
105915 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
105916 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
105917 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
105918 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
105919 +reserve_resources_15194 reserve_resources 3 15194 NULL
105920 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
105921 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
105922 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
105923 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
105924 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
105925 +simple_strtol_15273 simple_strtol 0 15273 NULL
105926 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
105927 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
105928 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
105929 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
105930 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
105931 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
105932 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
105933 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
105934 +ioread16_15342 ioread16 0 15342 NULL
105935 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
105936 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
105937 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
105938 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
105939 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
105940 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
105941 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
105942 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
105943 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
105944 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
105945 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
105946 +get_modalias_15406 get_modalias 2 15406 NULL
105947 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
105948 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
105949 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
105950 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
105951 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
105952 +memweight_15450 memweight 2 15450 NULL
105953 +vmalloc_15464 vmalloc 1 15464 NULL
105954 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
105955 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
105956 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
105957 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
105958 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
105959 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
105960 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
105961 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
105962 +persistent_status_15574 persistent_status 4 15574 NULL
105963 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
105964 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
105965 +vme_user_write_15587 vme_user_write 3 15587 NULL
105966 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
105967 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
105968 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
105969 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
105970 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
105971 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
105972 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
105973 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
105974 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
105975 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
105976 +xsd_read_15653 xsd_read 3 15653 NULL
105977 +unix_bind_15668 unix_bind 3 15668 NULL
105978 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
105979 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
105980 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
105981 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL nohasharray
105982 +uncore_alloc_box_15705 uncore_alloc_box 2 15705 &i915_gem_object_set_to_cpu_domain_15705
105983 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
105984 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
105985 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
105986 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
105987 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
105988 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
105989 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
105990 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
105991 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
105992 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
105993 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
105994 +table_size_15851 table_size 0-1-2 15851 NULL
105995 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
105996 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
105997 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
105998 +profile_pc_15887 profile_pc 0 15887 NULL
105999 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
106000 +native_read_msr_15905 native_read_msr 0 15905 NULL
106001 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
106002 +power_read_15939 power_read 3 15939 NULL
106003 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
106004 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
106005 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
106006 +frame_alloc_15981 frame_alloc 4 15981 NULL
106007 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
106008 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
106009 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
106010 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
106011 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
106012 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
106013 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
106014 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
106015 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
106016 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
106017 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
106018 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
106019 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
106020 +fsm_init_16134 fsm_init 2 16134 NULL
106021 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
106022 +update_block_group_16155 update_block_group 0 16155 NULL
106023 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
106024 +mapping_level_16188 mapping_level 2-0 16188 NULL
106025 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
106026 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
106027 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
106028 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
106029 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
106030 +create_table_16213 create_table 2 16213 NULL
106031 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
106032 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
106033 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
106034 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
106035 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
106036 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
106037 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
106038 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
106039 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
106040 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
106041 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
106042 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
106043 +account_16283 account 0-4-2 16283 NULL nohasharray
106044 +mirror_status_16283 mirror_status 5 16283 &account_16283
106045 +retry_instruction_16285 retry_instruction 2 16285 NULL
106046 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
106047 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
106048 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
106049 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
106050 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
106051 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
106052 +wb_map_16301 wb_map 2 16301 NULL
106053 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
106054 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
106055 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
106056 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
106057 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
106058 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
106059 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
106060 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
106061 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
106062 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
106063 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
106064 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0-4 16452 NULL
106065 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
106066 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
106067 +alloc_disk_node_16458 alloc_disk_node 2 16458 NULL
106068 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
106069 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
106070 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
106071 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
106072 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
106073 +start_this_handle_16519 start_this_handle 0 16519 NULL
106074 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
106075 +raid10_resize_16537 raid10_resize 2 16537 NULL
106076 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
106077 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
106078 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
106079 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
106080 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
106081 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
106082 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
106083 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
106084 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
106085 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
106086 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
106087 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
106088 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
106089 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
106090 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
106091 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
106092 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
106093 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
106094 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
106095 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
106096 +cache_grow_16818 cache_grow 3 16818 NULL
106097 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
106098 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
106099 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
106100 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
106101 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
106102 +st_write_16874 st_write 3 16874 NULL
106103 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
106104 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
106105 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
106106 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
106107 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
106108 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
106109 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
106110 +wrm_16966 wrm 0 16966 NULL
106111 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
106112 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
106113 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
106114 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
106115 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
106116 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
106117 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
106118 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
106119 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
106120 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
106121 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
106122 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
106123 +__kmalloc_reserve_17080 __kmalloc_reserve 3 17080 NULL
106124 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
106125 +entry_length_17093 entry_length 0 17093 NULL
106126 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
106127 +write_mem_17114 write_mem 3 17114 NULL
106128 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
106129 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
106130 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
106131 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
106132 +sep_read_17161 sep_read 3 17161 NULL
106133 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
106134 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
106135 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
106136 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
106137 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
106138 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
106139 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
106140 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
106141 +sync_request_17208 sync_request 2 17208 NULL
106142 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
106143 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
106144 +to_oblock_17254 to_oblock 0-1 17254 NULL
106145 +unpack_value_17259 unpack_value 1 17259 NULL
106146 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
106147 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
106148 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
106149 +alloc_ep_17269 alloc_ep 1 17269 NULL
106150 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
106151 +pg_read_17276 pg_read 3 17276 NULL
106152 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
106153 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
106154 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
106155 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
106156 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
106157 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
106158 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
106159 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
106160 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
106161 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
106162 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
106163 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
106164 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
106165 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
106166 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
106167 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
106168 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
106169 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
106170 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
106171 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
106172 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
106173 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
106174 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
106175 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
106176 +qp_free_res_17541 qp_free_res 5 17541 NULL
106177 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
106178 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
106179 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
106180 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
106181 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
106182 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
106183 +__inode_info_17603 __inode_info 0 17603 NULL
106184 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
106185 +osst_execute_17607 osst_execute 7-6 17607 NULL
106186 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
106187 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
106188 +dma_map_page_17628 dma_map_page 0 17628 NULL
106189 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
106190 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
106191 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
106192 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
106193 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
106194 +kernel_write_17665 kernel_write 3 17665 NULL
106195 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
106196 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
106197 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
106198 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
106199 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
106200 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
106201 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
106202 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
106203 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
106204 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
106205 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
106206 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
106207 +perf_clock_17787 perf_clock 0 17787 NULL
106208 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
106209 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
106210 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
106211 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
106212 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
106213 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
106214 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
106215 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
106216 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
106217 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
106218 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
106219 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
106220 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
106221 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
106222 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
106223 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
106224 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
106225 +recover_head_17904 recover_head 3 17904 NULL
106226 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
106227 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
106228 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
106229 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
106230 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
106231 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
106232 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
106233 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
106234 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
106235 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
106236 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
106237 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
106238 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
106239 +fill_read_18019 fill_read 0 18019 NULL
106240 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
106241 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
106242 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
106243 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
106244 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
106245 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
106246 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
106247 +fpregs_get_18066 fpregs_get 4 18066 NULL
106248 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
106249 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
106250 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
106251 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
106252 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
106253 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
106254 +svc_getnl_18120 svc_getnl 0 18120 NULL
106255 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
106256 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
106257 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
106258 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
106259 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
106260 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
106261 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
106262 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
106263 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
106264 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
106265 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
106266 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
106267 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
106268 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
106269 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
106270 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
106271 +alloc_ring_18278 alloc_ring 4-2-8 18278 NULL
106272 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
106273 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
106274 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
106275 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
106276 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
106277 +um_idi_write_18293 um_idi_write 3 18293 NULL
106278 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
106279 +vga_r_18310 vga_r 0 18310 NULL
106280 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
106281 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
106282 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
106283 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
106284 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
106285 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
106286 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
106287 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
106288 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
106289 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
106290 +ep_io_18367 ep_io 0 18367 NULL
106291 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
106292 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
106293 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
106294 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
106295 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
106296 +__video_register_device_18399 __video_register_device 3 18399 NULL
106297 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
106298 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
106299 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
106300 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
106301 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
106302 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
106303 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
106304 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
106305 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
106306 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
106307 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
106308 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
106309 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
106310 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
106311 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
106312 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
106313 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
106314 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
106315 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
106316 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
106317 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
106318 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
106319 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
106320 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
106321 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
106322 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
106323 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
106324 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
106325 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
106326 +debug_output_18575 debug_output 3 18575 NULL
106327 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
106328 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
106329 +numa_node_id_18596 numa_node_id 0 18596 NULL
106330 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
106331 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
106332 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
106333 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
106334 +from_buffer_18625 from_buffer 3 18625 NULL
106335 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
106336 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
106337 +unmap_page_18665 unmap_page 2-3 18665 NULL
106338 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
106339 +__alloc_skb_head_18683 __alloc_skb_head 2 18683 NULL
106340 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
106341 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
106342 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
106343 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
106344 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
106345 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
106346 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
106347 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
106348 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
106349 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
106350 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
106351 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
106352 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
106353 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
106354 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
106355 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
106356 +prealloc_18800 prealloc 0 18800 NULL
106357 +alloc_pages_node_18809 alloc_pages_node 1 18809 NULL
106358 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
106359 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
106360 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
106361 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
106362 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
106363 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
106364 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
106365 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
106366 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
106367 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
106368 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
106369 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
106370 +overwrite_item_18896 overwrite_item 0 18896 NULL
106371 +kmem_cache_alloc_node_18899 kmem_cache_alloc_node 3 18899 NULL
106372 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
106373 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
106374 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
106375 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
106376 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
106377 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
106378 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
106379 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
106380 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
106381 +get_inode_path_18988 get_inode_path 0 18988 NULL
106382 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
106383 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
106384 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
106385 +huge_page_size_19008 huge_page_size 0 19008 NULL
106386 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
106387 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
106388 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
106389 +revalidate_19043 revalidate 2 19043 NULL
106390 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
106391 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
106392 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
106393 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
106394 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
106395 +kvm_lapic_set_vapic_addr_19083 kvm_lapic_set_vapic_addr 2 19083 NULL
106396 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
106397 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
106398 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
106399 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
106400 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
106401 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
106402 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
106403 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
106404 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
106405 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
106406 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
106407 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
106408 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
106409 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
106410 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
106411 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
106412 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
106413 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
106414 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
106415 +ucma_query_19260 ucma_query 4 19260 NULL
106416 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
106417 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
106418 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
106419 +____cache_alloc_node_19297 ____cache_alloc_node 3 19297 NULL
106420 +qc_capture_19298 qc_capture 3 19298 NULL
106421 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
106422 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
106423 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
106424 +debug_read_19322 debug_read 3 19322 NULL
106425 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
106426 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
106427 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
106428 +closure_sub_19359 closure_sub 2 19359 NULL
106429 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
106430 +read_zero_19366 read_zero 3 19366 NULL
106431 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
106432 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
106433 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
106434 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
106435 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
106436 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
106437 +__phys_addr_19434 __phys_addr 0 19434 NULL
106438 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
106439 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
106440 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
106441 +sky2_read16_19475 sky2_read16 0 19475 NULL
106442 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
106443 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
106444 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
106445 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
106446 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
106447 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
106448 +howmany_64_19548 howmany_64 2 19548 NULL
106449 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
106450 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
106451 +kernel_read_19559 kernel_read 4-0 19559 NULL
106452 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
106453 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
106454 +nfsd_read_19568 nfsd_read 5 19568 NULL
106455 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
106456 +bm_status_read_19583 bm_status_read 3 19583 NULL
106457 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
106458 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
106459 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
106460 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
106461 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
106462 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
106463 +bio_detain_19690 bio_detain 2 19690 NULL
106464 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
106465 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
106466 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
106467 +read_reg_19723 read_reg 0 19723 NULL
106468 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
106469 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
106470 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
106471 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
106472 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
106473 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
106474 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
106475 +readhscx_19769 readhscx 0 19769 NULL
106476 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
106477 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
106478 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
106479 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
106480 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
106481 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
106482 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
106483 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
106484 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
106485 +__nla_put_19857 __nla_put 3 19857 NULL
106486 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
106487 +blk_alloc_queue_node_19887 blk_alloc_queue_node 2 19887 NULL
106488 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
106489 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
106490 +mangle_name_19923 mangle_name 0 19923 NULL
106491 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
106492 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
106493 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
106494 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
106495 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
106496 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
106497 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
106498 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
106499 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
106500 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
106501 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
106502 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
106503 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
106504 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
106505 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
106506 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
106507 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
106508 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
106509 +target_message_20072 target_message 2 20072 NULL
106510 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
106511 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
106512 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
106513 +team_options_register_20091 team_options_register 3 20091 NULL
106514 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
106515 +read_int_20098 read_int 0 20098 NULL
106516 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
106517 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
106518 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
106519 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
106520 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
106521 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
106522 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
106523 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
106524 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
106525 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
106526 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
106527 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
106528 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
106529 +resource_size_20256 resource_size 0 20256 NULL
106530 +uv_blade_to_memory_nid_20259 uv_blade_to_memory_nid 0 20259 NULL
106531 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
106532 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
106533 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
106534 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
106535 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
106536 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
106537 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
106538 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
106539 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
106540 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
106541 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
106542 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
106543 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
106544 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
106545 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
106546 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
106547 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
106548 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
106549 +read_buf_20469 read_buf 2 20469 NULL
106550 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
106551 +fast_user_write_20494 fast_user_write 5 20494 NULL
106552 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
106553 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
106554 +link_free_space_20512 link_free_space 0 20512 NULL
106555 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
106556 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
106557 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
106558 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
106559 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
106560 +venus_create_20555 venus_create 4 20555 NULL
106561 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
106562 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
106563 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
106564 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
106565 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
106566 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
106567 +lirc_write_20604 lirc_write 3 20604 NULL
106568 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
106569 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
106570 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
106571 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
106572 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
106573 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
106574 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
106575 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 NULL nohasharray
106576 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 &btrfs_qgroup_reserve_20676
106577 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
106578 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
106579 +cpumask_size_20683 cpumask_size 0 20683 NULL
106580 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
106581 +gru_vtop_20689 gru_vtop 2 20689 NULL
106582 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
106583 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
106584 +__maestro_read_20700 __maestro_read 0 20700 NULL
106585 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
106586 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
106587 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
106588 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
106589 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
106590 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
106591 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
106592 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
106593 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
106594 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
106595 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
106596 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
106597 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
106598 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
106599 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
106600 +strndup_user_20819 strndup_user 2 20819 NULL
106601 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
106602 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
106603 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
106604 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
106605 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
106606 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
106607 +get_name_20855 get_name 4 20855 NULL
106608 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
106609 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
106610 +srq_free_res_20868 srq_free_res 5 20868 NULL
106611 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
106612 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
106613 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
106614 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
106615 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
106616 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
106617 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
106618 +htable_bits_20933 htable_bits 0 20933 NULL
106619 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
106620 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
106621 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
106622 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
106623 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
106624 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
106625 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
106626 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
106627 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
106628 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
106629 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
106630 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
106631 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
106632 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
106633 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
106634 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
106635 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
106636 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
106637 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
106638 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
106639 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
106640 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
106641 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
106642 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
106643 +chunk_size_21146 chunk_size 0 21146 NULL
106644 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
106645 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
106646 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
106647 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
106648 +get_current_ntfs_time_21198 get_current_ntfs_time 0 21198 NULL
106649 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
106650 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
106651 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
106652 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
106653 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
106654 +input_ff_create_21240 input_ff_create 2 21240 NULL
106655 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
106656 +fru_length_21257 fru_length 0 21257 NULL
106657 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
106658 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
106659 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
106660 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
106661 +add_res_range_21310 add_res_range 4 21310 NULL
106662 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
106663 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
106664 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
106665 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
106666 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
106667 +split_leaf_21378 split_leaf 0 21378 NULL
106668 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
106669 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
106670 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
106671 +sle64_to_cpu_21400 sle64_to_cpu 0-1 21400 NULL
106672 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
106673 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
106674 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
106675 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
106676 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
106677 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
106678 +ReadISAR_21453 ReadISAR 0 21453 NULL
106679 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
106680 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
106681 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
106682 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
106683 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
106684 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
106685 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
106686 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
106687 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
106688 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
106689 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
106690 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
106691 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
106692 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
106693 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
106694 +add_pin_to_irq_node_21628 add_pin_to_irq_node 2 21628 NULL
106695 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
106696 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
106697 +validate_nnode_21638 validate_nnode 0 21638 NULL
106698 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3-4 21639 NULL
106699 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
106700 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
106701 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
106702 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
106703 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
106704 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
106705 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
106706 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
106707 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
106708 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
106709 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
106710 +vm_brk_21739 vm_brk 1-2 21739 NULL
106711 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
106712 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
106713 +gen_pool_add_21776 gen_pool_add 3-4 21776 NULL
106714 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
106715 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
106716 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
106717 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
106718 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
106719 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
106720 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
106721 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
106722 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
106723 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
106724 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
106725 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
106726 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
106727 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
106728 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
106729 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
106730 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
106731 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
106732 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
106733 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
106734 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
106735 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
106736 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
106737 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
106738 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
106739 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
106740 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
106741 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
106742 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
106743 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
106744 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
106745 +write_opcode_22082 write_opcode 2 22082 NULL
106746 +mem_rw_22085 mem_rw 3 22085 NULL
106747 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
106748 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
106749 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
106750 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
106751 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
106752 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
106753 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
106754 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
106755 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
106756 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
106757 +fls_22210 fls 0 22210 NULL
106758 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
106759 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
106760 +mem_write_22232 mem_write 3 22232 NULL
106761 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
106762 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
106763 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
106764 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
106765 +add_res_tree_22263 add_res_tree 7 22263 NULL
106766 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
106767 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
106768 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
106769 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
106770 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
106771 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
106772 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
106773 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
106774 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
106775 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
106776 +atomic_read_22342 atomic_read 0 22342 NULL
106777 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
106778 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
106779 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
106780 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
106781 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
106782 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
106783 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
106784 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
106785 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
106786 +zoran_write_22404 zoran_write 3 22404 NULL
106787 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
106788 +queue_reply_22416 queue_reply 3 22416 NULL
106789 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
106790 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
106791 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
106792 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
106793 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
106794 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
106795 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
106796 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
106797 +alloc_desc_22487 alloc_desc 2 22487 NULL
106798 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
106799 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
106800 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
106801 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
106802 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
106803 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
106804 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
106805 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
106806 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
106807 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
106808 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
106809 +snapshot_read_22601 snapshot_read 3 22601 NULL
106810 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
106811 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
106812 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
106813 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
106814 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
106815 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
106816 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
106817 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
106818 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
106819 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
106820 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
106821 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
106822 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
106823 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
106824 +reg_umr_22686 reg_umr 5 22686 NULL
106825 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
106826 +map_22700 map 2 22700 NULL nohasharray
106827 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
106828 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
106829 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
106830 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
106831 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
106832 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
106833 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
106834 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
106835 +print_frame_22769 print_frame 0 22769 NULL
106836 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
106837 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
106838 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
106839 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
106840 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
106841 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
106842 +create_attr_set_22861 create_attr_set 1 22861 NULL
106843 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
106844 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
106845 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
106846 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
106847 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
106848 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
106849 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
106850 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
106851 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
106852 +vme_get_size_22964 vme_get_size 0 22964 NULL
106853 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
106854 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
106855 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
106856 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
106857 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
106858 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
106859 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
106860 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
106861 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
106862 +st_status_23032 st_status 5 23032 NULL
106863 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
106864 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
106865 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
106866 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
106867 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
106868 +filp_close_23071 filp_close 0 23071 NULL
106869 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
106870 +vm_map_ram_23078 vm_map_ram 3 23078 NULL nohasharray
106871 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
106872 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
106873 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
106874 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
106875 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
106876 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
106877 +fls_long_23096 fls_long 0 23096 NULL
106878 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
106879 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
106880 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
106881 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
106882 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
106883 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
106884 +__clear_user_23118 __clear_user 0-2 23118 NULL
106885 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
106886 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
106887 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
106888 +read_file_ani_23161 read_file_ani 3 23161 NULL
106889 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
106890 +usblp_write_23178 usblp_write 3 23178 NULL
106891 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
106892 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
106893 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
106894 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
106895 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
106896 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
106897 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
106898 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
106899 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
106900 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
106901 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
106902 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
106903 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
106904 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
106905 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
106906 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
106907 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
106908 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
106909 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
106910 +page_readlink_23346 page_readlink 3 23346 NULL
106911 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
106912 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
106913 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
106914 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
106915 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
106916 +vzalloc_node_23424 vzalloc_node 1-2 23424 NULL
106917 +vmemmap_populate_basepages_23435 vmemmap_populate_basepages 3 23435 NULL
106918 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
106919 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
106920 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
106921 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
106922 +linear_conf_23485 linear_conf 2 23485 NULL
106923 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
106924 +event_filter_read_23494 event_filter_read 3 23494 NULL
106925 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
106926 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
106927 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
106928 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
106929 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
106930 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
106931 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
106932 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
106933 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
106934 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
106935 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
106936 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
106937 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
106938 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
106939 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
106940 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
106941 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
106942 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
106943 +alloc_pte_23642 alloc_pte 3 23642 NULL
106944 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
106945 +sInW_23663 sInW 0 23663 NULL
106946 +SyS_connect_23669 SyS_connect 3 23669 NULL
106947 +cx18_read_23699 cx18_read 3 23699 NULL
106948 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
106949 +at_get_23708 at_get 0 23708 NULL
106950 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
106951 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
106952 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
106953 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
106954 +svc_prepare_thread_23772 svc_prepare_thread 3 23772 NULL
106955 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
106956 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
106957 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
106958 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
106959 +map_write_23795 map_write 3 23795 NULL
106960 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
106961 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
106962 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
106963 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
106964 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
106965 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
106966 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
106967 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
106968 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
106969 +p54_init_common_23850 p54_init_common 1 23850 NULL
106970 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
106971 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
106972 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
106973 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
106974 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
106975 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
106976 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
106977 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
106978 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
106979 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
106980 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
106981 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
106982 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
106983 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
106984 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
106985 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
106986 +__alloc_skb_23940 __alloc_skb 4 23940 NULL
106987 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
106988 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
106989 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
106990 +vfs_write_23971 vfs_write 0-3 23971 NULL
106991 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
106992 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
106993 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
106994 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
106995 +give_pages_24021 give_pages 3 24021 NULL
106996 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
106997 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
106998 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
106999 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
107000 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
107001 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
107002 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
107003 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
107004 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
107005 +lov_brw_24122 lov_brw 4 24122 NULL
107006 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
107007 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
107008 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
107009 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
107010 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
107011 +set_discard_24162 set_discard 2 24162 NULL
107012 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
107013 +adu_read_24177 adu_read 3 24177 NULL
107014 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
107015 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
107016 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
107017 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
107018 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
107019 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
107020 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
107021 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
107022 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
107023 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
107024 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
107025 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
107026 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
107027 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
107028 +thin_status_24278 thin_status 5 24278 NULL
107029 +msg_size_24288 msg_size 0 24288 NULL
107030 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
107031 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
107032 +map_page_24298 map_page 3-4 24298 NULL
107033 +gserial_connect_24302 gserial_connect 0 24302 NULL
107034 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
107035 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
107036 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
107037 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
107038 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
107039 +kzalloc_node_24352 kzalloc_node 1-3 24352 NULL
107040 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
107041 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
107042 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
107043 +igetword_24373 igetword 0 24373 NULL
107044 +max_io_len_24384 max_io_len 0-1 24384 NULL
107045 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
107046 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
107047 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
107048 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
107049 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
107050 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
107051 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
107052 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
107053 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
107054 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
107055 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
107056 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
107057 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
107058 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
107059 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
107060 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
107061 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
107062 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
107063 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
107064 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
107065 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
107066 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
107067 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
107068 +pd_video_read_24510 pd_video_read 3 24510 NULL
107069 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
107070 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
107071 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
107072 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
107073 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
107074 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
107075 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
107076 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
107077 +SyS_poll_24620 SyS_poll 2 24620 NULL
107078 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
107079 +context_alloc_24645 context_alloc 3 24645 NULL
107080 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
107081 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
107082 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
107083 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
107084 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
107085 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
107086 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
107087 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
107088 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
107089 +kempld_read8_24756 kempld_read8 0 24756 NULL
107090 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
107091 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
107092 +cache_read_24790 cache_read 3 24790 NULL
107093 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
107094 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
107095 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
107096 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
107097 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
107098 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
107099 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
107100 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
107101 +net2272_read_24825 net2272_read 0 24825 NULL
107102 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
107103 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
107104 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
107105 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
107106 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
107107 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
107108 +setup_buffering_24872 setup_buffering 3 24872 NULL
107109 +queues_read_24877 queues_read 3 24877 NULL
107110 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
107111 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
107112 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
107113 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
107114 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
107115 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
107116 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
107117 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
107118 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
107119 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
107120 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
107121 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
107122 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
107123 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
107124 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
107125 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
107126 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
107127 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
107128 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
107129 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
107130 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
107131 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
107132 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
107133 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
107134 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
107135 +record_new_ref_25154 record_new_ref 0 25154 NULL
107136 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
107137 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
107138 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
107139 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
107140 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
107141 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
107142 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
107143 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
107144 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
107145 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
107146 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
107147 +stripe_status_25259 stripe_status 5 25259 NULL
107148 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
107149 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
107150 +vfs_writev_25278 vfs_writev 3 25278 NULL
107151 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
107152 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
107153 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
107154 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
107155 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
107156 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
107157 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
107158 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
107159 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
107160 +SyS_splice_25390 SyS_splice 5 25390 NULL
107161 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
107162 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
107163 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
107164 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
107165 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
107166 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
107167 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
107168 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
107169 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
107170 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
107171 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
107172 +sb_permission_25523 sb_permission 0 25523 NULL
107173 +down_read_failed_25532 down_read_failed 2 25532 NULL
107174 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
107175 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
107176 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
107177 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
107178 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
107179 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
107180 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
107181 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
107182 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
107183 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
107184 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
107185 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
107186 +__direct_map_25647 __direct_map 6-5 25647 NULL
107187 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
107188 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
107189 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
107190 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
107191 +sparse_mem_map_populate_25693 sparse_mem_map_populate 2 25693 NULL
107192 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
107193 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
107194 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
107195 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
107196 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
107197 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
107198 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
107199 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
107200 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
107201 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
107202 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
107203 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
107204 +sg_read_25799 sg_read 3 25799 NULL
107205 +system_enable_read_25815 system_enable_read 3 25815 NULL
107206 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
107207 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
107208 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
107209 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
107210 +parport_read_25855 parport_read 0 25855 NULL
107211 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
107212 +key_attr_size_25865 key_attr_size 0 25865 NULL
107213 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
107214 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
107215 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
107216 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
107217 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
107218 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
107219 +rcname_read_25919 rcname_read 3 25919 NULL
107220 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
107221 +key_flags_read_25931 key_flags_read 3 25931 NULL
107222 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
107223 +flush_25957 flush 2 25957 NULL
107224 +video_register_device_25971 video_register_device 3 25971 NULL
107225 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
107226 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
107227 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
107228 +blk_init_queue_node_26015 blk_init_queue_node 3 26015 NULL
107229 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
107230 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
107231 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
107232 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
107233 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
107234 +tun_do_read_26047 tun_do_read 5 26047 NULL
107235 +make_bfloat_26056 make_bfloat 2 26056 NULL
107236 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
107237 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
107238 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
107239 +dup_ref_26100 dup_ref 0 26100 NULL
107240 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
107241 +read_sb_page_26119 read_sb_page 5 26119 NULL
107242 +__fswab64_26155 __fswab64 0 26155 NULL
107243 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
107244 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 NULL nohasharray
107245 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 &ath6kl_roam_table_read_26166
107246 +disk_devt_26180 disk_devt 0 26180 NULL
107247 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
107248 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
107249 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
107250 +mce_write_26201 mce_write 3 26201 NULL
107251 +SyS_splice_26206 SyS_splice 5 26206 NULL
107252 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
107253 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
107254 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
107255 +bio_split_26235 bio_split 2 26235 NULL
107256 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
107257 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
107258 +do_setxattr_26264 do_setxattr 0 26264 NULL
107259 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
107260 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
107261 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
107262 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
107263 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
107264 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
107265 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
107266 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
107267 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
107268 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
107269 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
107270 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
107271 +ntty_write_26404 ntty_write 3 26404 NULL
107272 +pagemap_read_26441 pagemap_read 3 26441 NULL
107273 +tower_read_26461 tower_read 3 26461 NULL nohasharray
107274 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
107275 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
107276 +memory_present_26470 memory_present 1 26470 NULL
107277 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
107278 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
107279 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
107280 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
107281 +read_vmcore_26501 read_vmcore 3 26501 NULL
107282 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
107283 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
107284 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
107285 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
107286 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
107287 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
107288 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
107289 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
107290 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
107291 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
107292 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
107293 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
107294 +dev_to_node_26617 dev_to_node 0 26617 NULL
107295 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
107296 +pack_value_26625 pack_value 1 26625 NULL
107297 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
107298 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
107299 +process_extent_26646 process_extent 0 26646 NULL nohasharray
107300 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
107301 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
107302 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
107303 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
107304 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
107305 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
107306 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
107307 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
107308 +bos_desc_26752 bos_desc 0 26752 NULL
107309 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
107310 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
107311 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
107312 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
107313 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
107314 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
107315 +smk_write_load_26829 smk_write_load 3 26829 NULL
107316 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
107317 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
107318 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
107319 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
107320 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
107321 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
107322 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
107323 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
107324 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
107325 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
107326 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
107327 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
107328 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
107329 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
107330 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
107331 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
107332 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
107333 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
107334 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
107335 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
107336 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
107337 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
107338 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
107339 +fill_read_buf_27036 fill_read_buf 0 27036 NULL
107340 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
107341 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
107342 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
107343 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
107344 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
107345 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
107346 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
107347 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
107348 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
107349 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
107350 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
107351 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
107352 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
107353 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
107354 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
107355 +pms_capture_27142 pms_capture 4 27142 NULL
107356 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
107357 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
107358 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
107359 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
107360 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
107361 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
107362 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
107363 +write_kmem_27225 write_kmem 3 27225 NULL
107364 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
107365 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
107366 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
107367 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
107368 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
107369 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
107370 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
107371 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
107372 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
107373 +write_buf_27316 write_buf 0-3 27316 NULL
107374 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
107375 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
107376 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
107377 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
107378 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
107379 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
107380 +seq_read_27411 seq_read 3 27411 NULL
107381 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL nohasharray
107382 +zalloc_cpumask_var_node_27413 zalloc_cpumask_var_node 3 27413 &ib_dma_map_sg_27413
107383 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
107384 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
107385 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
107386 +cypress_write_27423 cypress_write 4 27423 NULL
107387 +vmemmap_populate_27442 vmemmap_populate 3 27442 NULL
107388 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
107389 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
107390 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
107391 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
107392 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
107393 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
107394 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
107395 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
107396 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
107397 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
107398 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
107399 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
107400 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
107401 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
107402 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
107403 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
107404 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
107405 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
107406 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
107407 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
107408 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
107409 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
107410 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
107411 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
107412 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
107413 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
107414 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
107415 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
107416 +evm_write_key_27715 evm_write_key 3 27715 NULL
107417 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
107418 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
107419 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
107420 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
107421 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
107422 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
107423 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
107424 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
107425 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
107426 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
107427 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
107428 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
107429 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
107430 +init_header_complete_27833 init_header_complete 0 27833 NULL
107431 +read_profile_27859 read_profile 3 27859 NULL
107432 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
107433 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
107434 +process_all_extents_27879 process_all_extents 0 27879 NULL
107435 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
107436 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
107437 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
107438 +bm_find_next_27929 bm_find_next 2 27929 NULL
107439 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
107440 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
107441 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
107442 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
107443 +device_register_27972 device_register 0 27972 NULL nohasharray
107444 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
107445 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
107446 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
107447 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
107448 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
107449 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
107450 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
107451 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
107452 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
107453 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
107454 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
107455 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
107456 +pool_status_28055 pool_status 5 28055 NULL
107457 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
107458 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
107459 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
107460 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
107461 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
107462 +SyS_brk_28096 SyS_brk 1 28096 NULL
107463 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
107464 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
107465 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
107466 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
107467 +video_read_28148 video_read 3 28148 NULL
107468 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
107469 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
107470 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
107471 +vread_28173 vread 0-3 28173 NULL
107472 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
107473 +counter_free_res_28187 counter_free_res 5 28187 NULL
107474 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
107475 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
107476 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
107477 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
107478 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
107479 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
107480 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
107481 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
107482 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
107483 +usemap_size_28281 usemap_size 0 28281 NULL
107484 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
107485 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
107486 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
107487 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
107488 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
107489 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
107490 +create_io_context_28306 create_io_context 2 28306 NULL
107491 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
107492 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
107493 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
107494 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
107495 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
107496 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
107497 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
107498 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
107499 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
107500 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
107501 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
107502 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
107503 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
107504 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
107505 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
107506 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
107507 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
107508 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
107509 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
107510 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
107511 +clear_discard_28494 clear_discard 2 28494 NULL
107512 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
107513 +__next_node_28521 __next_node 1-0 28521 NULL
107514 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
107515 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
107516 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
107517 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
107518 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
107519 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
107520 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
107521 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
107522 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
107523 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
107524 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
107525 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
107526 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
107527 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
107528 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
107529 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
107530 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
107531 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
107532 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
107533 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
107534 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
107535 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
107536 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
107537 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
107538 +balance_level_28707 balance_level 0 28707 NULL
107539 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
107540 +alloc_irq_cfg_28734 alloc_irq_cfg 2 28734 NULL
107541 +spi_execute_28736 spi_execute 5 28736 NULL
107542 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
107543 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
107544 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
107545 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
107546 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
107547 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
107548 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
107549 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
107550 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
107551 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
107552 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
107553 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
107554 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
107555 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
107556 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
107557 +to_cblock_28899 to_cblock 0-1 28899 NULL
107558 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
107559 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
107560 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
107561 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
107562 +push_rx_28939 push_rx 3 28939 NULL
107563 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
107564 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
107565 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
107566 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
107567 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
107568 +bin_uuid_28999 bin_uuid 3 28999 NULL
107569 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
107570 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
107571 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
107572 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
107573 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
107574 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL nohasharray
107575 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 &rxrpc_sendmsg_29049
107576 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
107577 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
107578 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
107579 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
107580 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
107581 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
107582 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
107583 +init_cache_node_node_29092 init_cache_node_node 1 29092 NULL
107584 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
107585 +snprintf_29125 snprintf 0 29125 NULL
107586 +iov_shorten_29130 iov_shorten 0 29130 NULL
107587 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
107588 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0-3 29152 NULL
107589 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
107590 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
107591 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
107592 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
107593 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
107594 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
107595 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
107596 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
107597 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
107598 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
107599 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
107600 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
107601 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
107602 +block_div_29268 block_div 0-1-2 29268 NULL
107603 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
107604 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
107605 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
107606 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
107607 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
107608 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
107609 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
107610 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
107611 +tun_put_user_29337 tun_put_user 5 29337 NULL
107612 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
107613 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
107614 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
107615 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
107616 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
107617 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
107618 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
107619 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
107620 +mempool_create_29437 mempool_create 1 29437 NULL
107621 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
107622 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
107623 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
107624 +__kmalloc_node_29455 __kmalloc_node 3 29455 NULL
107625 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
107626 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
107627 +do_register_entry_29478 do_register_entry 4 29478 NULL
107628 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
107629 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
107630 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
107631 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
107632 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
107633 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
107634 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
107635 +vfs_read_29543 vfs_read 0-3 29543 NULL
107636 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
107637 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
107638 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
107639 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
107640 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
107641 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
107642 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
107643 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
107644 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
107645 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
107646 +slots_per_page_29601 slots_per_page 0 29601 NULL
107647 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
107648 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
107649 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
107650 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
107651 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
107652 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
107653 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
107654 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
107655 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
107656 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
107657 +probes_write_29711 probes_write 3 29711 NULL
107658 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
107659 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
107660 +std_nic_write_29752 std_nic_write 3 29752 NULL
107661 +dbAlloc_29794 dbAlloc 0 29794 NULL
107662 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
107663 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
107664 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
107665 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
107666 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
107667 +count_partial_29850 count_partial 0 29850 NULL
107668 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
107669 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
107670 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
107671 +tlv_put_29872 tlv_put 0 29872 NULL
107672 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
107673 +changed_extent_29881 changed_extent 0 29881 NULL
107674 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
107675 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
107676 +write_file_queue_29922 write_file_queue 3 29922 NULL
107677 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
107678 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL nohasharray
107679 +ipv6_recv_error_29947 ipv6_recv_error 3 29947 &__btrfs_getxattr_29947
107680 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
107681 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
107682 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
107683 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
107684 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
107685 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
107686 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
107687 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
107688 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
107689 +SyS_write_30059 SyS_write 3 30059 NULL
107690 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
107691 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
107692 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
107693 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
107694 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
107695 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
107696 +recv_stream_30138 recv_stream 4 30138 NULL
107697 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
107698 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
107699 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
107700 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
107701 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
107702 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
107703 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
107704 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
107705 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
107706 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
107707 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
107708 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
107709 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
107710 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
107711 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
107712 +compat_readv_30273 compat_readv 3 30273 NULL
107713 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
107714 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
107715 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
107716 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
107717 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
107718 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
107719 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
107720 +i8254_read_30330 i8254_read 0 30330 NULL
107721 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
107722 +resource_from_user_30341 resource_from_user 3 30341 NULL
107723 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
107724 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1-2 30352 NULL
107725 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
107726 +inet_getid_30365 inet_getid 2 30365 NULL
107727 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
107728 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
107729 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
107730 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
107731 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
107732 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
107733 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
107734 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
107735 +mq_create_30425 mq_create 1 30425 NULL nohasharray
107736 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
107737 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
107738 +enable_write_30456 enable_write 3 30456 NULL
107739 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
107740 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
107741 +urandom_read_30462 urandom_read 3 30462 NULL
107742 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
107743 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
107744 +send_rmdir_30470 send_rmdir 0 30470 NULL
107745 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
107746 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
107747 +write_head_30481 write_head 4 30481 NULL
107748 +adu_write_30487 adu_write 3 30487 NULL
107749 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
107750 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
107751 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
107752 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
107753 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
107754 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
107755 +set_le_30581 set_le 4 30581 NULL
107756 +from_cblock_30582 from_cblock 0-1 30582 NULL
107757 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
107758 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
107759 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
107760 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
107761 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
107762 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
107763 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
107764 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
107765 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
107766 +agp_remap_30665 agp_remap 2 30665 NULL
107767 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
107768 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
107769 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
107770 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
107771 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
107772 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
107773 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
107774 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
107775 +snapshot_status_30744 snapshot_status 5 30744 NULL
107776 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
107777 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
107778 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
107779 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
107780 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
107781 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
107782 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
107783 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
107784 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
107785 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
107786 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
107787 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
107788 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
107789 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
107790 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
107791 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
107792 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
107793 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
107794 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
107795 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
107796 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
107797 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
107798 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
107799 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
107800 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
107801 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
107802 +depth_read_31112 depth_read 3 31112 NULL
107803 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
107804 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
107805 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
107806 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
107807 +crypto_rng_seedsize_31196 crypto_rng_seedsize 0 31196 NULL
107808 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
107809 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
107810 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
107811 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
107812 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
107813 +__read_reg_31216 __read_reg 0 31216 NULL
107814 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
107815 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
107816 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
107817 +cyy_readb_31240 cyy_readb 0 31240 NULL
107818 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
107819 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
107820 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
107821 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
107822 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
107823 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
107824 +command_file_write_31318 command_file_write 3 31318 NULL
107825 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
107826 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
107827 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
107828 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
107829 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
107830 +outlen_write_31358 outlen_write 3 31358 NULL
107831 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
107832 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
107833 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
107834 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
107835 +inb_31388 inb 0 31388 NULL
107836 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
107837 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
107838 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
107839 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
107840 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
107841 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
107842 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
107843 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
107844 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
107845 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
107846 +do_fcntl_31468 do_fcntl 3 31468 NULL
107847 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
107848 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
107849 +alg_setkey_31485 alg_setkey 3 31485 NULL
107850 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
107851 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
107852 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
107853 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
107854 +hidraw_write_31536 hidraw_write 3 31536 NULL
107855 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
107856 +usbvision_read_31555 usbvision_read 3 31555 NULL
107857 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
107858 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
107859 +osst_write_31581 osst_write 3 31581 NULL
107860 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
107861 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
107862 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
107863 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
107864 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
107865 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
107866 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
107867 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
107868 +__lgread_31668 __lgread 4 31668 NULL
107869 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
107870 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
107871 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
107872 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
107873 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
107874 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
107875 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
107876 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
107877 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
107878 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
107879 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
107880 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
107881 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
107882 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
107883 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
107884 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
107885 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
107886 +data_write_31805 data_write 3 31805 NULL
107887 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
107888 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
107889 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
107890 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
107891 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
107892 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
107893 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
107894 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
107895 +xattr_permission_31907 xattr_permission 0 31907 NULL
107896 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
107897 +new_dir_31919 new_dir 3 31919 NULL
107898 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
107899 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
107900 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
107901 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
107902 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
107903 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
107904 +vb2_write_31948 vb2_write 3 31948 NULL
107905 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
107906 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
107907 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
107908 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
107909 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
107910 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
107911 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
107912 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
107913 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
107914 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
107915 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
107916 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
107917 +calc_hmac_32010 calc_hmac 3 32010 NULL
107918 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
107919 +resource_alignment_32020 resource_alignment 0 32020 NULL
107920 +aead_len_32021 aead_len 0 32021 NULL
107921 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
107922 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
107923 +stk_read_32038 stk_read 3 32038 NULL
107924 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
107925 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
107926 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
107927 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
107928 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
107929 +bio_alloc_32095 bio_alloc 2 32095 NULL
107930 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
107931 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
107932 +disk_status_32120 disk_status 4 32120 NULL
107933 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
107934 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
107935 +venus_link_32165 venus_link 5 32165 NULL
107936 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
107937 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
107938 +load_header_32183 load_header 0 32183 NULL
107939 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
107940 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
107941 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
107942 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
107943 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
107944 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
107945 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
107946 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
107947 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
107948 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
107949 +SyS_select_32319 SyS_select 1 32319 NULL
107950 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
107951 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
107952 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
107953 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
107954 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
107955 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
107956 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
107957 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
107958 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
107959 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
107960 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
107961 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
107962 +local_clock_32385 local_clock 0 32385 NULL
107963 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
107964 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
107965 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
107966 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
107967 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
107968 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
107969 +break_ksm_32439 break_ksm 0 32439 NULL
107970 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
107971 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
107972 +cache_status_32462 cache_status 5 32462 NULL
107973 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
107974 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
107975 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
107976 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
107977 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
107978 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
107979 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
107980 +disconnect_32521 disconnect 4 32521 NULL
107981 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
107982 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
107983 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
107984 +ilo_read_32531 ilo_read 3 32531 NULL
107985 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
107986 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
107987 +__first_node_32558 __first_node 0 32558 NULL
107988 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
107989 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
107990 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
107991 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
107992 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
107993 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
107994 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
107995 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
107996 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
107997 +kvmalloc_32646 kvmalloc 1 32646 NULL
107998 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
107999 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
108000 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
108001 +get_unaligned_be24_32667 get_unaligned_be24 0 32667 NULL
108002 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
108003 +apei_res_add_32674 apei_res_add 0 32674 NULL
108004 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
108005 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
108006 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
108007 +get_arg_page_32746 get_arg_page 2 32746 NULL
108008 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
108009 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
108010 +begin_cmd_32766 begin_cmd 0 32766 NULL
108011 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
108012 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
108013 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
108014 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
108015 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
108016 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1-2 32868 NULL
108017 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
108018 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
108019 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
108020 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
108021 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
108022 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
108023 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
108024 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
108025 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
108026 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
108027 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
108028 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
108029 +compat_filldir_32999 compat_filldir 3 32999 NULL
108030 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
108031 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
108032 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
108033 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
108034 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
108035 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
108036 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
108037 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
108038 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
108039 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
108040 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
108041 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
108042 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
108043 +alloc_tio_33077 alloc_tio 3 33077 NULL
108044 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
108045 +write_node_33121 write_node 4 33121 NULL
108046 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
108047 +__len_within_target_33132 __len_within_target 0 33132 NULL
108048 +SyS_poll_33152 SyS_poll 2 33152 NULL
108049 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
108050 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
108051 +pp_read_33210 pp_read 3 33210 NULL
108052 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
108053 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
108054 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
108055 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
108056 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
108057 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
108058 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
108059 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
108060 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
108061 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
108062 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
108063 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
108064 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
108065 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
108066 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
108067 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
108068 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
108069 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
108070 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
108071 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
108072 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
108073 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
108074 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
108075 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
108076 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
108077 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
108078 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
108079 +message_stats_list_33440 message_stats_list 5 33440 NULL
108080 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
108081 +create_entry_33479 create_entry 2 33479 NULL
108082 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
108083 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
108084 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
108085 +res_counter_read_33499 res_counter_read 4 33499 NULL
108086 +fb_read_33506 fb_read 3 33506 NULL
108087 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
108088 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
108089 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
108090 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
108091 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
108092 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
108093 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
108094 +read_symlink_33572 read_symlink 0 33572 NULL
108095 +count_subheaders_33591 count_subheaders 0 33591 NULL
108096 +scsi_execute_33596 scsi_execute 5 33596 NULL
108097 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
108098 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
108099 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
108100 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
108101 +do_sync_write_33624 do_sync_write 0 33624 NULL
108102 +stride_page_count_33641 stride_page_count 2 33641 NULL
108103 +slab_alloc_node_33663 slab_alloc_node 3 33663 NULL
108104 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
108105 +inw_p_33668 inw_p 0 33668 NULL
108106 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
108107 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
108108 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
108109 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
108110 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
108111 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
108112 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
108113 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
108114 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
108115 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
108116 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
108117 +do_munmap_33752 do_munmap 0 33752 NULL
108118 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
108119 +hashtab_create_33769 hashtab_create 3 33769 NULL
108120 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
108121 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
108122 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
108123 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
108124 +filter_write_33819 filter_write 3 33819 NULL
108125 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
108126 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
108127 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
108128 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
108129 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
108130 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
108131 +bin_string_33884 bin_string 3-5 33884 NULL
108132 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
108133 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
108134 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
108135 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
108136 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
108137 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
108138 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
108139 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
108140 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
108141 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
108142 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
108143 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
108144 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
108145 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
108146 +ppp_write_34034 ppp_write 3 34034 NULL
108147 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
108148 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
108149 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
108150 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
108151 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
108152 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
108153 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
108154 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
108155 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
108156 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
108157 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
108158 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
108159 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
108160 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
108161 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
108162 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
108163 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
108164 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
108165 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
108166 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
108167 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
108168 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
108169 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
108170 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
108171 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
108172 +device_private_init_34279 device_private_init 0 34279 NULL
108173 +get_task_io_context_34316 get_task_io_context 3 34316 NULL
108174 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
108175 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
108176 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
108177 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
108178 +__insert_34349 __insert 2-3 34349 NULL
108179 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
108180 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
108181 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
108182 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
108183 +ea_read_34378 ea_read 0 34378 NULL
108184 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
108185 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
108186 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
108187 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
108188 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
108189 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
108190 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
108191 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
108192 +security_socket_create_34439 security_socket_create 0 34439 NULL
108193 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
108194 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
108195 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
108196 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
108197 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
108198 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
108199 +__ffs64_34494 __ffs64 1-0 34494 NULL nohasharray
108200 +SyS_pwritev_34494 SyS_pwritev 3 34494 &__ffs64_34494
108201 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
108202 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
108203 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
108204 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL nohasharray
108205 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 &tracing_stats_read_34537
108206 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
108207 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
108208 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
108209 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
108210 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
108211 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
108212 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
108213 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
108214 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
108215 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
108216 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
108217 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
108218 +mtd_write_34609 mtd_write 0 34609 NULL nohasharray
108219 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 &mtd_write_34609
108220 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
108221 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
108222 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
108223 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
108224 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
108225 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
108226 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
108227 +port_print_34704 port_print 3 34704 NULL
108228 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1-2 34706 NULL
108229 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
108230 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
108231 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
108232 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
108233 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
108234 +device_add_34766 device_add 0 34766 NULL
108235 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
108236 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
108237 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
108238 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
108239 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
108240 +file_page_index_34820 file_page_index 0-2 34820 NULL
108241 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
108242 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
108243 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
108244 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
108245 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
108246 +msg_print_text_34889 msg_print_text 0 34889 NULL
108247 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
108248 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
108249 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
108250 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
108251 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
108252 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
108253 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
108254 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
108255 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
108256 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
108257 +mq_lookup_34990 mq_lookup 2 34990 NULL
108258 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
108259 +schedule_erase_34996 schedule_erase 0 34996 NULL
108260 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
108261 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
108262 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
108263 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
108264 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
108265 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
108266 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
108267 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
108268 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
108269 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
108270 +ntfs_attr_extend_initialized_35084 ntfs_attr_extend_initialized 2 35084 NULL
108271 +store_ifalias_35088 store_ifalias 4 35088 NULL
108272 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
108273 +alloc_thread_info_node_35101 alloc_thread_info_node 2 35101 NULL
108274 +capi_write_35104 capi_write 3 35104 NULL nohasharray
108275 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
108276 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
108277 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
108278 +message_stats_print_35158 message_stats_print 6 35158 NULL
108279 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
108280 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
108281 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
108282 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
108283 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
108284 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
108285 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
108286 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
108287 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
108288 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
108289 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
108290 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
108291 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
108292 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
108293 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
108294 +set_fd_set_35249 set_fd_set 1 35249 NULL
108295 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
108296 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
108297 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
108298 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
108299 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
108300 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
108301 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
108302 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
108303 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
108304 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
108305 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
108306 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
108307 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
108308 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
108309 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
108310 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
108311 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
108312 +read_kmem_35372 read_kmem 3 35372 NULL
108313 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
108314 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
108315 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
108316 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
108317 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
108318 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
108319 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
108320 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
108321 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
108322 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
108323 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
108324 +async_setkey_35521 async_setkey 3 35521 NULL
108325 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
108326 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
108327 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
108328 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
108329 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
108330 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
108331 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
108332 +send_update_extent_35556 send_update_extent 0 35556 NULL
108333 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
108334 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
108335 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
108336 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
108337 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
108338 +kernel_readv_35617 kernel_readv 3 35617 NULL
108339 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
108340 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
108341 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
108342 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
108343 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
108344 +cpu_to_sle64_35677 cpu_to_sle64 0-1 35677 NULL
108345 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
108346 +dm_table_create_35687 dm_table_create 3 35687 NULL
108347 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
108348 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
108349 +md_super_write_35703 md_super_write 4 35703 NULL
108350 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
108351 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
108352 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
108353 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
108354 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
108355 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
108356 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
108357 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
108358 +changed_xattr_35860 changed_xattr 0 35860 NULL
108359 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
108360 +fls64_35862 fls64 0 35862 NULL
108361 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
108362 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
108363 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
108364 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
108365 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
108366 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
108367 +balance_node_right_35920 balance_node_right 0 35920 NULL
108368 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
108369 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
108370 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
108371 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
108372 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
108373 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
108374 +acl_alloc_35979 acl_alloc 1 35979 NULL
108375 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
108376 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
108377 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
108378 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
108379 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
108380 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
108381 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
108382 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
108383 +account_shadowed_36048 account_shadowed 2 36048 NULL
108384 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
108385 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
108386 +did_create_dir_36062 did_create_dir 0 36062 NULL
108387 +write_emulate_36065 write_emulate 2-4 36065 NULL
108388 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
108389 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
108390 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
108391 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
108392 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
108393 +vmemmap_pud_populate_36080 vmemmap_pud_populate 3 36080 NULL nohasharray
108394 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 &vmemmap_pud_populate_36080
108395 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
108396 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
108397 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
108398 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
108399 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
108400 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
108401 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
108402 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
108403 +twl_set_36154 twl_set 2 36154 NULL
108404 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
108405 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
108406 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
108407 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
108408 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
108409 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
108410 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
108411 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
108412 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
108413 +is_dirty_36223 is_dirty 2 36223 NULL
108414 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
108415 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
108416 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
108417 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
108418 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
108419 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
108420 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
108421 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
108422 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
108423 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
108424 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
108425 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
108426 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
108427 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
108428 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
108429 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
108430 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
108431 +lc_create_36332 lc_create 4 36332 NULL
108432 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
108433 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
108434 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
108435 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
108436 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
108437 +to_sector_36361 to_sector 0-1 36361 NULL
108438 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
108439 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
108440 +tunables_read_36385 tunables_read 3 36385 NULL
108441 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
108442 +sierra_write_36402 sierra_write 4 36402 NULL
108443 +msb_update_block_36412 msb_update_block 2 36412 NULL
108444 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
108445 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
108446 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
108447 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
108448 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
108449 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
108450 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
108451 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
108452 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
108453 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
108454 +cmd_loop_36491 cmd_loop 0 36491 NULL
108455 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
108456 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
108457 +get_param_l_36518 get_param_l 0 36518 NULL
108458 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
108459 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
108460 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
108461 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
108462 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
108463 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
108464 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
108465 +__erst_read_36579 __erst_read 0 36579 NULL
108466 +put_cmsg_36589 put_cmsg 4 36589 NULL
108467 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
108468 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
108469 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
108470 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
108471 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
108472 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
108473 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
108474 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
108475 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
108476 +xillybus_read_36678 xillybus_read 3 36678 NULL
108477 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
108478 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
108479 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
108480 +sched_clock_36717 sched_clock 0 36717 NULL
108481 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
108482 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
108483 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
108484 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
108485 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
108486 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
108487 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
108488 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
108489 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
108490 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
108491 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
108492 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
108493 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
108494 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
108495 +cm_write_36858 cm_write 3 36858 NULL
108496 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
108497 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
108498 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
108499 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
108500 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
108501 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
108502 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
108503 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
108504 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
108505 +build_key_36931 build_key 1 36931 NULL
108506 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
108507 +div_u64_36951 div_u64 0 36951 NULL
108508 +write_leb_36957 write_leb 0-5 36957 NULL
108509 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
108510 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
108511 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
108512 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
108513 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
108514 +setxattr_37006 setxattr 4 37006 NULL
108515 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
108516 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
108517 +command_file_read_37038 command_file_read 3 37038 NULL
108518 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
108519 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
108520 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
108521 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
108522 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
108523 +parse_command_37079 parse_command 2 37079 NULL
108524 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
108525 +tun_get_user_37094 tun_get_user 5 37094 NULL
108526 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
108527 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
108528 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
108529 +msg_word_37164 msg_word 0 37164 NULL
108530 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
108531 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
108532 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
108533 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
108534 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
108535 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
108536 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
108537 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
108538 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
108539 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
108540 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
108541 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
108542 +__do_replace_37227 __do_replace 5 37227 NULL
108543 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
108544 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
108545 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
108546 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
108547 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
108548 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
108549 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
108550 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
108551 +create_cq_user_37278 create_cq_user 5 37278 NULL
108552 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
108553 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
108554 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
108555 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
108556 +send_msg_37323 send_msg 4 37323 NULL
108557 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
108558 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
108559 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
108560 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
108561 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
108562 +move_vma_37341 move_vma 0-5 37341 NULL
108563 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
108564 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
108565 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
108566 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
108567 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
108568 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
108569 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
108570 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
108571 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
108572 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
108573 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
108574 +fru_alloc_37442 fru_alloc 1 37442 NULL
108575 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
108576 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
108577 +__remove_37457 __remove 2 37457 NULL
108578 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
108579 +get_est_timing_37484 get_est_timing 0 37484 NULL
108580 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
108581 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
108582 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
108583 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
108584 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
108585 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
108586 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
108587 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
108588 +hdr_size_37536 hdr_size 0 37536 NULL
108589 +extent_map_end_37550 extent_map_end 0 37550 NULL
108590 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
108591 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
108592 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
108593 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
108594 +alloc_descs_37593 alloc_descs 0-1-3 37593 NULL
108595 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
108596 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
108597 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
108598 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
108599 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
108600 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
108601 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
108602 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
108603 +alloc_fd_37637 alloc_fd 1 37637 NULL
108604 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
108605 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
108606 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
108607 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
108608 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
108609 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
108610 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
108611 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
108612 +page_chain_free_37697 page_chain_free 0 37697 NULL
108613 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
108614 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
108615 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
108616 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
108617 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
108618 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
108619 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
108620 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
108621 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
108622 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
108623 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
108624 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
108625 +deny_write_access_37813 deny_write_access 0 37813 NULL
108626 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
108627 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
108628 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
108629 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
108630 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
108631 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
108632 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
108633 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
108634 +set_registers_37883 set_registers 4 37883 NULL
108635 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
108636 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
108637 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
108638 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
108639 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
108640 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
108641 +write_file_bool_37957 write_file_bool 3 37957 NULL
108642 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
108643 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
108644 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
108645 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
108646 +vfs_readv_38011 vfs_readv 3 38011 NULL
108647 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
108648 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
108649 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
108650 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
108651 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
108652 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
108653 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
108654 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
108655 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
108656 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
108657 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
108658 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
108659 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
108660 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
108661 +ep0_read_38095 ep0_read 3 38095 NULL
108662 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
108663 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
108664 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
108665 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
108666 +_get_val_38115 _get_val 2 38115 NULL
108667 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
108668 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
108669 +btrfs_extent_same_38163 btrfs_extent_same 3-2 38163 NULL
108670 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
108671 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
108672 +send_rename_38170 send_rename 0 38170 NULL
108673 +cdev_add_38176 cdev_add 2-3 38176 NULL
108674 +create_srq_user_38191 create_srq_user 5 38191 NULL
108675 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
108676 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
108677 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
108678 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
108679 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
108680 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
108681 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
108682 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
108683 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
108684 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
108685 +from_dblock_38256 from_dblock 0-1 38256 NULL
108686 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
108687 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
108688 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
108689 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
108690 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
108691 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
108692 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
108693 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
108694 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
108695 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
108696 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
108697 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
108698 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
108699 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
108700 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
108701 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
108702 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
108703 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
108704 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
108705 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
108706 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
108707 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
108708 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
108709 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
108710 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
108711 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
108712 +dev_names_read_38509 dev_names_read 3 38509 NULL
108713 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
108714 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
108715 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
108716 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
108717 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
108718 +kuc_len_38557 kuc_len 0-1 38557 NULL
108719 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
108720 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
108721 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
108722 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
108723 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
108724 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
108725 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
108726 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
108727 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
108728 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
108729 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
108730 +cma_create_area_38642 cma_create_area 2 38642 NULL
108731 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
108732 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
108733 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
108734 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
108735 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
108736 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
108737 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
108738 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
108739 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
108740 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
108741 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
108742 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
108743 +udf_readpages_38761 udf_readpages 4 38761 NULL
108744 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
108745 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
108746 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
108747 +slab_order_38794 slab_order 0 38794 NULL
108748 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
108749 +err_decode_38804 err_decode 2 38804 NULL
108750 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
108751 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
108752 +direct_entry_38836 direct_entry 3 38836 NULL
108753 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
108754 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
108755 +interfaces_38859 interfaces 2 38859 NULL
108756 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
108757 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
108758 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
108759 +traverse_38897 traverse 0 38897 NULL
108760 +__fswab16_38898 __fswab16 0 38898 NULL
108761 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
108762 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
108763 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
108764 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL nohasharray
108765 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 &usb_maxpacket_38977
108766 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
108767 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
108768 +udf_new_block_38999 udf_new_block 4 38999 NULL
108769 +get_nodes_39012 get_nodes 3 39012 NULL
108770 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
108771 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
108772 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
108773 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
108774 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
108775 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
108776 +gen_pool_create_39064 gen_pool_create 2 39064 NULL
108777 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
108778 +ReadHFC_39104 ReadHFC 0 39104 NULL
108779 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
108780 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
108781 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
108782 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
108783 +ea_foreach_39133 ea_foreach 0 39133 NULL
108784 +generic_permission_39150 generic_permission 0 39150 NULL
108785 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
108786 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
108787 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
108788 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
108789 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
108790 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
108791 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
108792 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
108793 +drm_order_39244 drm_order 0 39244 NULL
108794 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
108795 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
108796 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
108797 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
108798 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
108799 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
108800 +__vmalloc_node_39308 __vmalloc_node 1-5 39308 NULL
108801 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
108802 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
108803 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
108804 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
108805 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
108806 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
108807 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
108808 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
108809 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
108810 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
108811 +__send_to_port_39386 __send_to_port 3 39386 NULL
108812 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
108813 +user_power_read_39414 user_power_read 3 39414 NULL
108814 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
108815 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
108816 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
108817 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
108818 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
108819 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
108820 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
108821 +int_proc_write_39542 int_proc_write 3 39542 NULL
108822 +pp_write_39554 pp_write 3 39554 NULL
108823 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
108824 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
108825 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
108826 +ext_depth_39607 ext_depth 0 39607 NULL
108827 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
108828 +sdio_readb_39618 sdio_readb 0 39618 NULL
108829 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 NULL nohasharray
108830 +set_dev_class_39645 set_dev_class 4 39645 &dm_exception_table_init_39645
108831 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
108832 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
108833 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
108834 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
108835 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
108836 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
108837 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
108838 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
108839 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
108840 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
108841 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
108842 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
108843 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
108844 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
108845 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
108846 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
108847 +can_rmdir_39890 can_rmdir 0 39890 NULL
108848 +pkt_add_39897 pkt_add 3 39897 NULL
108849 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
108850 +gen_pool_add_virt_39913 gen_pool_add_virt 4-5 39913 NULL
108851 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
108852 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
108853 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
108854 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
108855 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
108856 +__spi_async_39932 __spi_async 0 39932 NULL
108857 +__get_order_39935 __get_order 0 39935 NULL
108858 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
108859 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
108860 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
108861 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
108862 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
108863 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
108864 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
108865 +server_name2svname_39998 server_name2svname 4 39998 NULL
108866 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
108867 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
108868 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
108869 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
108870 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
108871 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
108872 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
108873 +add_tty_40055 add_tty 1 40055 NULL nohasharray
108874 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
108875 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
108876 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
108877 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
108878 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
108879 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
108880 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
108881 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
108882 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
108883 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
108884 +pt_write_40159 pt_write 3 40159 NULL
108885 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
108886 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
108887 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
108888 +allocate_probes_40204 allocate_probes 1 40204 NULL
108889 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
108890 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
108891 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
108892 +osst_read_40237 osst_read 3 40237 NULL
108893 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
108894 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
108895 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
108896 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
108897 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
108898 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
108899 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
108900 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
108901 +SyS_bind_40303 SyS_bind 3 40303 NULL
108902 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
108903 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
108904 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
108905 +mmio_read_40348 mmio_read 4 40348 NULL
108906 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
108907 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
108908 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
108909 +get_chars_40373 get_chars 3 40373 NULL
108910 +submit_page_section_40408 submit_page_section 0 40408 NULL
108911 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
108912 +slab_node_40421 slab_node 0 40421 NULL
108913 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
108914 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
108915 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
108916 +SyS_writev_40467 SyS_writev 3 40467 NULL
108917 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
108918 +SyS_select_40473 SyS_select 1 40473 NULL
108919 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
108920 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
108921 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
108922 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
108923 +sg_phys_40507 sg_phys 0 40507 NULL
108924 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
108925 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
108926 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
108927 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
108928 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
108929 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
108930 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
108931 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
108932 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
108933 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
108934 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
108935 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
108936 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
108937 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
108938 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
108939 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
108940 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
108941 +fops_read_40672 fops_read 3 40672 NULL
108942 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
108943 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
108944 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
108945 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
108946 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
108947 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
108948 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
108949 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
108950 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
108951 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
108952 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
108953 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
108954 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
108955 +card_send_command_40757 card_send_command 3 40757 NULL
108956 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
108957 +pg_write_40766 pg_write 3 40766 NULL
108958 +show_list_40775 show_list 3-0 40775 NULL
108959 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
108960 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
108961 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
108962 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
108963 +add_action_40811 add_action 4 40811 NULL
108964 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
108965 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
108966 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
108967 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
108968 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
108969 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
108970 +read_file_queue_40895 read_file_queue 3 40895 NULL
108971 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
108972 +waiters_read_40902 waiters_read 3 40902 NULL
108973 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
108974 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
108975 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
108976 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
108977 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
108978 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
108979 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
108980 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
108981 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
108982 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
108983 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
108984 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
108985 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
108986 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
108987 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
108988 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
108989 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
108990 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
108991 +calculate_order_41061 calculate_order 0 41061 NULL
108992 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
108993 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
108994 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
108995 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
108996 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
108997 +dma_attach_41094 dma_attach 6-5 41094 NULL
108998 +provide_user_output_41105 provide_user_output 3 41105 NULL
108999 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
109000 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
109001 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
109002 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
109003 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
109004 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
109005 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
109006 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
109007 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
109008 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
109009 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
109010 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
109011 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
109012 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
109013 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
109014 +create_dir_41256 create_dir 0 41256 NULL
109015 +erst_read_41260 erst_read 0 41260 NULL
109016 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
109017 +alloc_context_41283 alloc_context 1 41283 NULL
109018 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
109019 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
109020 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
109021 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
109022 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
109023 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
109024 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
109025 +kmp_init_41373 kmp_init 2 41373 NULL
109026 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
109027 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
109028 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
109029 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
109030 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
109031 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
109032 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
109033 +vmemmap_populate_hugepages_41434 vmemmap_populate_hugepages 3 41434 NULL
109034 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
109035 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
109036 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
109037 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
109038 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
109039 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
109040 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
109041 +split_item_41483 split_item 0 41483 NULL
109042 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
109043 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
109044 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
109045 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
109046 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
109047 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
109048 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
109049 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
109050 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
109051 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
109052 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
109053 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
109054 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
109055 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
109056 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
109057 +vga_io_r_41609 vga_io_r 0 41609 NULL
109058 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
109059 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
109060 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
109061 +a2mp_send_41615 a2mp_send 4 41615 NULL
109062 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
109063 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
109064 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
109065 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
109066 +get_std_timing_41654 get_std_timing 0 41654 NULL
109067 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
109068 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
109069 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
109070 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
109071 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
109072 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
109073 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
109074 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
109075 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
109076 +fillonedir_41746 fillonedir 3 41746 NULL
109077 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
109078 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
109079 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
109080 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
109081 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
109082 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
109083 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
109084 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
109085 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
109086 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
109087 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
109088 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
109089 +pci_map_single_41869 pci_map_single 0 41869 NULL
109090 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
109091 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
109092 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
109093 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
109094 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
109095 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
109096 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
109097 +read_gssp_41947 read_gssp 3 41947 NULL
109098 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
109099 +portnames_read_41958 portnames_read 3 41958 NULL
109100 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
109101 +dst_mtu_41969 dst_mtu 0 41969 NULL
109102 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
109103 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
109104 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
109105 +pool_allocate_42012 pool_allocate 3 42012 NULL
109106 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
109107 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
109108 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
109109 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
109110 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
109111 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
109112 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
109113 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
109114 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
109115 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
109116 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
109117 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
109118 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
109119 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
109120 +send_truncate_42107 send_truncate 0 42107 NULL
109121 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
109122 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
109123 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
109124 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
109125 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
109126 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
109127 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
109128 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
109129 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
109130 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
109131 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
109132 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
109133 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
109134 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
109135 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
109136 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
109137 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
109138 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
109139 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
109140 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
109141 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
109142 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
109143 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
109144 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
109145 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
109146 +free_cblock_42318 free_cblock 2 42318 NULL
109147 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
109148 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
109149 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
109150 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
109151 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
109152 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
109153 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
109154 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
109155 +krng_get_random_42420 krng_get_random 3 42420 NULL
109156 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
109157 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
109158 +alloc_request_42448 alloc_request 0 42448 NULL
109159 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
109160 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
109161 +kuc_free_42455 kuc_free 2 42455 NULL
109162 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
109163 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
109164 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
109165 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
109166 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
109167 +bypass_write_42498 bypass_write 3 42498 NULL
109168 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
109169 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
109170 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
109171 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
109172 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
109173 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
109174 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
109175 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
109176 +inorder_next_42548 inorder_next 1-0 42548 NULL
109177 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
109178 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
109179 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
109180 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
109181 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
109182 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
109183 +map_state_42602 map_state 1 42602 NULL
109184 +resp_write_42628 resp_write 2 42628 NULL
109185 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
109186 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
109187 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
109188 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
109189 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
109190 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
109191 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
109192 +vb2_read_42703 vb2_read 3 42703 NULL
109193 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
109194 +read_status_42722 read_status 0 42722 NULL
109195 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
109196 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
109197 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
109198 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
109199 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
109200 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
109201 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
109202 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
109203 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
109204 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
109205 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
109206 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2-3 42796 NULL
109207 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
109208 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
109209 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
109210 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
109211 +set_arg_42824 set_arg 3 42824 NULL
109212 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
109213 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
109214 +prandom_u32_42853 prandom_u32 0 42853 NULL
109215 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
109216 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
109217 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
109218 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
109219 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
109220 +hd_end_request_42904 hd_end_request 2 42904 NULL
109221 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
109222 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
109223 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
109224 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
109225 +send_link_42948 send_link 0 42948 NULL
109226 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
109227 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
109228 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
109229 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
109230 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
109231 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
109232 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
109233 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
109234 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
109235 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
109236 +send_to_group_43051 send_to_group 0 43051 NULL
109237 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
109238 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
109239 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
109240 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
109241 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
109242 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
109243 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
109244 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
109245 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
109246 +send_cmd_43168 send_cmd 0 43168 NULL
109247 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
109248 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
109249 +uio_write_43202 uio_write 3 43202 NULL
109250 +iso_callback_43208 iso_callback 3 43208 NULL
109251 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
109252 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
109253 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
109254 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1-2 43245 NULL
109255 +fixup_leb_43256 fixup_leb 3 43256 NULL
109256 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
109257 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
109258 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
109259 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
109260 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
109261 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
109262 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
109263 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
109264 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
109265 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
109266 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
109267 +activation_descriptor_init_43358 activation_descriptor_init 1 43358 NULL
109268 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
109269 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
109270 +xenfb_write_43412 xenfb_write 3 43412 NULL
109271 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
109272 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
109273 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
109274 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
109275 +usb_string_43443 usb_string 0 43443 NULL nohasharray
109276 +usemap_size_43443 usemap_size 0-2-1 43443 &usb_string_43443
109277 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
109278 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
109279 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
109280 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
109281 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
109282 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
109283 +do_readlink_43518 do_readlink 2 43518 NULL
109284 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
109285 +read_events_43534 read_events 3 43534 NULL
109286 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
109287 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
109288 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
109289 +request_resource_43548 request_resource 0 43548 NULL
109290 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
109291 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
109292 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
109293 +proc_read_43614 proc_read 3 43614 NULL
109294 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
109295 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
109296 +alloc_thread_groups_43625 alloc_thread_groups 2 43625 NULL
109297 +random_write_43656 random_write 3 43656 NULL
109298 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
109299 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
109300 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
109301 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
109302 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
109303 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
109304 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
109305 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
109306 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
109307 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
109308 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
109309 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
109310 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
109311 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
109312 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
109313 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
109314 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
109315 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
109316 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
109317 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
109318 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
109319 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
109320 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
109321 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
109322 +read_flush_43851 read_flush 3 43851 NULL
109323 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
109324 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
109325 +SendString_43928 SendString 3 43928 NULL
109326 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
109327 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
109328 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
109329 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
109330 +nla_reserve_43984 nla_reserve 3 43984 NULL
109331 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
109332 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
109333 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
109334 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
109335 +ulist_add_43994 ulist_add 0 43994 NULL
109336 +emit_flags_44006 emit_flags 4-3 44006 NULL
109337 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
109338 +fru_strlen_44046 fru_strlen 0 44046 NULL
109339 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
109340 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
109341 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
109342 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
109343 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
109344 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
109345 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
109346 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
109347 +hwif_to_node_44127 hwif_to_node 0 44127 NULL
109348 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
109349 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
109350 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
109351 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
109352 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
109353 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
109354 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
109355 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
109356 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
109357 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
109358 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
109359 +__set_free_44211 __set_free 2 44211 NULL
109360 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
109361 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
109362 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
109363 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
109364 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
109365 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
109366 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
109367 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
109368 +device_create_file_44285 device_create_file 0 44285 NULL
109369 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
109370 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
109371 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
109372 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
109373 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
109374 +rs_init_44327 rs_init 1 44327 NULL
109375 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
109376 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
109377 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
109378 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
109379 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
109380 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
109381 +__is_discarded_44359 __is_discarded 2 44359 NULL
109382 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
109383 +alloc_requests_44372 alloc_requests 0 44372 NULL
109384 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
109385 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
109386 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
109387 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
109388 +strlcpy_44400 strlcpy 3 44400 NULL
109389 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
109390 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
109391 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
109392 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
109393 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
109394 +write_file_debug_44476 write_file_debug 3 44476 NULL
109395 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
109396 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
109397 +bio_advance_44496 bio_advance 2 44496 NULL
109398 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
109399 +ac_register_board_44504 ac_register_board 3 44504 NULL
109400 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
109401 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
109402 +spidev_write_44510 spidev_write 3 44510 NULL
109403 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
109404 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
109405 +comm_write_44537 comm_write 3 44537 NULL
109406 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
109407 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
109408 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
109409 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
109410 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
109411 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
109412 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
109413 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
109414 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
109415 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
109416 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
109417 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
109418 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
109419 +mpi_resize_44674 mpi_resize 2 44674 NULL
109420 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
109421 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
109422 +ts_read_44687 ts_read 3 44687 NULL
109423 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
109424 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
109425 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
109426 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
109427 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
109428 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
109429 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
109430 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
109431 +SyS_read_44732 SyS_read 3 44732 NULL
109432 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
109433 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
109434 +set_brk_44749 set_brk 1-2 44749 NULL
109435 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
109436 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
109437 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
109438 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
109439 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
109440 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
109441 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
109442 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
109443 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
109444 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
109445 +sisusb_write_44834 sisusb_write 3 44834 NULL
109446 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
109447 +cubic_root_44848 cubic_root 1 44848 NULL
109448 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
109449 +copydesc_user_44855 copydesc_user 3 44855 NULL
109450 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
109451 +init_rs_44873 init_rs 1 44873 NULL
109452 +skb_availroom_44883 skb_availroom 0 44883 NULL
109453 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
109454 +do_tty_write_44896 do_tty_write 5 44896 NULL
109455 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
109456 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
109457 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
109458 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
109459 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
109460 +send_chmod_45011 send_chmod 0 45011 NULL
109461 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
109462 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
109463 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
109464 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
109465 +dm_kvzalloc_45025 dm_kvzalloc 1-2 45025 NULL
109466 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
109467 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
109468 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
109469 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
109470 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
109471 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
109472 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
109473 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
109474 +usbdev_read_45114 usbdev_read 3 45114 NULL
109475 +send_to_tty_45141 send_to_tty 3 45141 NULL
109476 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
109477 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
109478 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
109479 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
109480 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
109481 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
109482 +SYSC_write_45160 SYSC_write 3 45160 NULL
109483 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
109484 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
109485 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
109486 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
109487 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
109488 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
109489 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
109490 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
109491 +__dirty_45228 __dirty 2 45228 NULL
109492 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
109493 +event_enable_write_45238 event_enable_write 3 45238 NULL
109494 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
109495 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
109496 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
109497 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
109498 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
109499 +pte_val_45313 pte_val 0 45313 NULL
109500 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
109501 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
109502 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
109503 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
109504 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
109505 +alloc_task_struct_node_45426 alloc_task_struct_node 1 45426 NULL
109506 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
109507 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
109508 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
109509 +__node_remap_45458 __node_remap 4 45458 NULL
109510 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
109511 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
109512 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
109513 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
109514 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
109515 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
109516 +__split_vma_45522 __split_vma 0 45522 NULL
109517 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
109518 +copy_macs_45534 copy_macs 4 45534 NULL
109519 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
109520 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
109521 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
109522 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
109523 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
109524 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
109525 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
109526 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
109527 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
109528 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
109529 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
109530 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
109531 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
109532 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
109533 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
109534 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
109535 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
109536 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
109537 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
109538 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
109539 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
109540 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
109541 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
109542 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
109543 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
109544 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
109545 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
109546 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
109547 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
109548 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
109549 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
109550 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
109551 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
109552 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
109553 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
109554 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
109555 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
109556 +ipv6_recv_rxpmtu_45830 ipv6_recv_rxpmtu 3 45830 NULL
109557 +task_state_char_45839 task_state_char 1 45839 NULL
109558 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
109559 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
109560 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
109561 +isdn_write_45863 isdn_write 3 45863 NULL
109562 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
109563 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
109564 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
109565 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
109566 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
109567 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
109568 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
109569 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
109570 +alloc_mr_45935 alloc_mr 1 45935 NULL
109571 +kmem_cache_alloc_node_trace_45968 kmem_cache_alloc_node_trace 3 45968 NULL
109572 +copy_to_45969 copy_to 3 45969 NULL
109573 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
109574 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
109575 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
109576 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
109577 +get_free_entries_46030 get_free_entries 1 46030 NULL
109578 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
109579 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
109580 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
109581 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
109582 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
109583 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
109584 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
109585 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 NULL nohasharray
109586 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 &il3945_ucode_general_stats_read_46111
109587 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
109588 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
109589 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
109590 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
109591 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
109592 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
109593 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
109594 +alloc_iova_46160 alloc_iova 2 46160 NULL
109595 +kmalloc_section_memmap_46168 kmalloc_section_memmap 2 46168 NULL
109596 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
109597 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
109598 +fq_resize_46195 fq_resize 2 46195 NULL
109599 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
109600 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
109601 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
109602 +dsp_write_46218 dsp_write 2 46218 NULL
109603 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
109604 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
109605 +ReadReg_46277 ReadReg 0 46277 NULL
109606 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
109607 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 NULL nohasharray
109608 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 &compat_SyS_readv_46328
109609 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
109610 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
109611 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
109612 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
109613 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
109614 +vma_adjust_46390 vma_adjust 0 46390 NULL
109615 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
109616 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
109617 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
109618 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
109619 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
109620 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
109621 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
109622 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
109623 +filldir64_46469 filldir64 3 46469 NULL
109624 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
109625 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
109626 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
109627 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
109628 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
109629 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
109630 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
109631 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
109632 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
109633 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
109634 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
109635 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
109636 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
109637 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
109638 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
109639 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
109640 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
109641 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
109642 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
109643 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
109644 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
109645 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
109646 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
109647 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
109648 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
109649 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
109650 +ide_read_status_46719 ide_read_status 0 46719 NULL
109651 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
109652 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
109653 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
109654 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
109655 +ntfs2utc_46762 ntfs2utc 1 46762 NULL
109656 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
109657 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
109658 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
109659 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
109660 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
109661 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
109662 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
109663 +readreg_46845 readreg 0 46845 NULL
109664 +spi_async_46857 spi_async 0 46857 NULL
109665 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
109666 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
109667 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
109668 +rvmalloc_46873 rvmalloc 1 46873 NULL
109669 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
109670 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
109671 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
109672 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
109673 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
109674 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
109675 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
109676 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
109677 +fb_write_46924 fb_write 3 46924 NULL
109678 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
109679 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
109680 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
109681 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
109682 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
109683 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
109684 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
109685 +strlcat_46985 strlcat 3 46985 NULL
109686 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
109687 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
109688 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
109689 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
109690 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
109691 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
109692 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
109693 +fs_path_len_47060 fs_path_len 0 47060 NULL
109694 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
109695 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
109696 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
109697 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
109698 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
109699 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
109700 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
109701 +mousedev_read_47123 mousedev_read 3 47123 NULL
109702 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
109703 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
109704 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
109705 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
109706 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
109707 +alloc_cpumask_var_node_47167 alloc_cpumask_var_node 3 47167 NULL
109708 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
109709 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
109710 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
109711 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
109712 +options_write_47243 options_write 3 47243 NULL
109713 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
109714 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
109715 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
109716 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
109717 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
109718 +vsnprintf_47291 vsnprintf 0 47291 NULL
109719 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
109720 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
109721 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
109722 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
109723 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
109724 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
109725 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
109726 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
109727 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
109728 +nametbl_list_47391 nametbl_list 2 47391 NULL
109729 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
109730 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
109731 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
109732 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
109733 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
109734 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
109735 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
109736 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
109737 +vzalloc_47421 vzalloc 1 47421 NULL
109738 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
109739 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
109740 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
109741 +environ_read_47451 environ_read 3 47451 NULL
109742 +__load_mapping_47460 __load_mapping 2 47460 NULL
109743 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
109744 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
109745 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
109746 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
109747 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
109748 +core_sys_select_47494 core_sys_select 1 47494 NULL
109749 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
109750 +alloc_arraycache_47505 alloc_arraycache 2-1 47505 NULL nohasharray
109751 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
109752 +unlink_simple_47506 unlink_simple 3 47506 NULL
109753 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
109754 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
109755 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
109756 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
109757 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
109758 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
109759 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
109760 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
109761 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
109762 +read_ldt_47570 read_ldt 2 47570 NULL
109763 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
109764 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
109765 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
109766 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
109767 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
109768 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
109769 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
109770 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
109771 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
109772 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
109773 +get_size_47644 get_size 1-2 47644 NULL
109774 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
109775 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
109776 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
109777 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
109778 +save_microcode_47717 save_microcode 3 47717 NULL
109779 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
109780 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
109781 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
109782 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
109783 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
109784 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
109785 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
109786 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
109787 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
109788 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
109789 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
109790 +lov_packmd_47810 lov_packmd 0 47810 NULL
109791 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
109792 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
109793 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
109794 +vhci_read_47878 vhci_read 3 47878 NULL
109795 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
109796 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
109797 +load_mapping_47904 load_mapping 3 47904 NULL
109798 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
109799 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
109800 +comedi_write_47926 comedi_write 3 47926 NULL
109801 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
109802 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
109803 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
109804 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
109805 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
109806 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
109807 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
109808 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
109809 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
109810 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
109811 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
109812 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
109813 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
109814 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
109815 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
109816 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
109817 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
109818 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
109819 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
109820 +disc_write_48070 disc_write 3 48070 NULL
109821 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
109822 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
109823 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
109824 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
109825 +set_discoverable_48141 set_discoverable 4 48141 NULL
109826 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
109827 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
109828 +bitmap_onto_48152 bitmap_onto 4 48152 NULL nohasharray
109829 +_add_to_r4w_48152 _add_to_r4w 4 48152 &bitmap_onto_48152
109830 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
109831 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
109832 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
109833 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
109834 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
109835 +init_ipath_48187 init_ipath 1 48187 NULL
109836 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
109837 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
109838 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
109839 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
109840 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
109841 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
109842 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
109843 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
109844 +read_file_recv_48232 read_file_recv 3 48232 NULL
109845 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
109846 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
109847 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
109848 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
109849 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
109850 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
109851 +trace_options_write_48275 trace_options_write 3 48275 NULL
109852 +send_set_info_48288 send_set_info 7 48288 NULL
109853 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
109854 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
109855 +hash_setkey_48310 hash_setkey 3 48310 NULL
109856 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
109857 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
109858 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
109859 +skb_add_data_48363 skb_add_data 3 48363 NULL
109860 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
109861 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
109862 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
109863 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
109864 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
109865 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
109866 +hugepage_madvise_48435 hugepage_madvise 0 48435 NULL
109867 +print_filtered_48442 print_filtered 2-0 48442 NULL
109868 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
109869 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
109870 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
109871 +init_section_page_cgroup_48489 init_section_page_cgroup 2 48489 NULL nohasharray
109872 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 &init_section_page_cgroup_48489
109873 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
109874 +send_control_msg_48498 send_control_msg 6 48498 NULL
109875 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
109876 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
109877 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
109878 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
109879 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
109880 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
109881 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
109882 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
109883 +llog_data_len_48607 llog_data_len 1 48607 NULL
109884 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
109885 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
109886 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
109887 +mtd_read_48655 mtd_read 0 48655 NULL
109888 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
109889 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
109890 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
109891 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
109892 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
109893 +altera_drscan_48698 altera_drscan 2 48698 NULL
109894 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
109895 +recv_msg_48709 recv_msg 4 48709 NULL
109896 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
109897 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
109898 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
109899 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
109900 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
109901 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
109902 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
109903 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
109904 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
109905 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
109906 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
109907 +azx_get_position_48841 azx_get_position 0 48841 NULL
109908 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
109909 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
109910 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
109911 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL nohasharray
109912 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 &viafb_dvp1_proc_write_48864
109913 +ide_port_alloc_devices_48866 ide_port_alloc_devices 2 48866 NULL
109914 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
109915 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
109916 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
109917 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
109918 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
109919 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
109920 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
109921 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
109922 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
109923 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
109924 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
109925 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
109926 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
109927 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
109928 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
109929 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
109930 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
109931 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
109932 +aic_inb_49023 aic_inb 0 49023 NULL
109933 +transient_status_49027 transient_status 4 49027 NULL
109934 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
109935 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
109936 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
109937 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
109938 +ubi_read_49061 ubi_read 0 49061 NULL
109939 +sparse_early_nid_49094 sparse_early_nid 0 49094 NULL nohasharray
109940 +scsi_register_49094 scsi_register 2 49094 &sparse_early_nid_49094
109941 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
109942 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
109943 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
109944 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
109945 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
109946 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
109947 +read_file_49137 read_file 4 49137 NULL
109948 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
109949 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
109950 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
109951 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
109952 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
109953 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
109954 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
109955 +print_queue_49191 print_queue 0 49191 NULL
109956 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
109957 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
109958 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
109959 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
109960 +resp_write_same_49217 resp_write_same 2 49217 NULL
109961 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
109962 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
109963 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
109964 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
109965 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
109966 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
109967 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
109968 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
109969 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
109970 +uio_read_49300 uio_read 3 49300 NULL
109971 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
109972 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
109973 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
109974 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
109975 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
109976 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
109977 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
109978 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
109979 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
109980 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
109981 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
109982 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
109983 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
109984 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
109985 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
109986 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
109987 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
109988 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
109989 +get_lru_size_49441 get_lru_size 0 49441 NULL
109990 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
109991 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
109992 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
109993 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
109994 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
109995 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
109996 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
109997 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
109998 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
109999 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
110000 +smk_write_access_49561 smk_write_access 3 49561 NULL
110001 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
110002 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
110003 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
110004 +readfifo_49583 readfifo 1 49583 NULL
110005 +tap_write_49595 tap_write 3 49595 NULL
110006 +create_task_io_context_49601 create_task_io_context 3 49601 NULL
110007 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
110008 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
110009 +heap_init_49617 heap_init 2 49617 NULL
110010 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
110011 +port_fops_read_49626 port_fops_read 3 49626 NULL
110012 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
110013 +__swab32p_49657 __swab32p 0 49657 NULL
110014 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
110015 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
110016 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
110017 +__setup_irq_49696 __setup_irq 0 49696 NULL
110018 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
110019 +do_splice_to_49714 do_splice_to 4 49714 NULL
110020 +write_pool_49718 write_pool 3 49718 NULL
110021 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
110022 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
110023 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
110024 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
110025 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
110026 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
110027 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
110028 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
110029 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
110030 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
110031 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
110032 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
110033 +add_uuid_49831 add_uuid 4 49831 NULL
110034 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
110035 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
110036 +twl4030_write_49846 twl4030_write 2 49846 NULL
110037 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
110038 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
110039 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
110040 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
110041 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
110042 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
110043 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
110044 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
110045 +osc_brw_49896 osc_brw 4 49896 NULL
110046 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
110047 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
110048 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
110049 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
110050 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
110051 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
110052 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
110053 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
110054 +__module_alloc_50004 __module_alloc 1 50004 NULL
110055 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
110056 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
110057 +isdn_read_50021 isdn_read 3 50021 NULL
110058 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
110059 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
110060 +ioread8_50049 ioread8 0 50049 NULL
110061 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
110062 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
110063 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
110064 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
110065 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
110066 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
110067 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
110068 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
110069 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
110070 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
110071 +read_file_slot_50111 read_file_slot 3 50111 NULL
110072 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
110073 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
110074 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
110075 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
110076 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
110077 +copy_items_50140 copy_items 6 50140 NULL
110078 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
110079 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
110080 +kmalloc_node_50163 kmalloc_node 1-3 50163 NULL
110081 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
110082 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
110083 +odev_update_50169 odev_update 2 50169 NULL
110084 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
110085 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
110086 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
110087 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
110088 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
110089 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
110090 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
110091 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
110092 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
110093 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
110094 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
110095 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
110096 +vma_dup_policy_50269 vma_dup_policy 0 50269 NULL
110097 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
110098 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
110099 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
110100 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
110101 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
110102 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
110103 +do_launder_page_50329 do_launder_page 0 50329 NULL
110104 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
110105 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
110106 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
110107 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
110108 +tpm_read_50344 tpm_read 3 50344 NULL
110109 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
110110 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
110111 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
110112 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
110113 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
110114 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
110115 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
110116 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
110117 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
110118 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
110119 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
110120 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
110121 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
110122 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
110123 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
110124 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
110125 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
110126 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
110127 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
110128 +force_mapping_50464 force_mapping 2 50464 NULL
110129 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
110130 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
110131 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
110132 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
110133 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
110134 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
110135 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
110136 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
110137 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
110138 +fat_readpages_50582 fat_readpages 4 50582 NULL
110139 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
110140 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
110141 +xillybus_write_50605 xillybus_write 3 50605 NULL
110142 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
110143 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
110144 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
110145 +__ffs_50625 __ffs 0-1 50625 NULL
110146 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
110147 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
110148 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
110149 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
110150 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
110151 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
110152 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
110153 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
110154 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
110155 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
110156 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
110157 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
110158 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
110159 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
110160 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
110161 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
110162 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
110163 +tpm_write_50798 tpm_write 3 50798 NULL
110164 +write_flush_50803 write_flush 3 50803 NULL
110165 +dvb_play_50814 dvb_play 3 50814 NULL
110166 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
110167 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
110168 +SetArea_50835 SetArea 4 50835 NULL nohasharray
110169 +mask_from_50835 mask_from 0-1-2 50835 &SetArea_50835 nohasharray
110170 +create_mem_extents_50835 create_mem_extents 0 50835 &mask_from_50835
110171 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
110172 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
110173 +self_check_write_50856 self_check_write 0-5 50856 NULL
110174 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
110175 +alloc_masks_50861 alloc_masks 3 50861 NULL
110176 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
110177 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
110178 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
110179 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
110180 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
110181 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
110182 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
110183 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
110184 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
110185 +show_device_status_50947 show_device_status 0 50947 NULL
110186 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
110187 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
110188 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
110189 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
110190 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
110191 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
110192 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
110193 +timeout_write_50991 timeout_write 3 50991 NULL
110194 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
110195 +proc_write_51003 proc_write 3 51003 NULL
110196 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
110197 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
110198 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
110199 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
110200 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
110201 +dump_midi_51040 dump_midi 3 51040 NULL
110202 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
110203 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
110204 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
110205 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
110206 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
110207 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
110208 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
110209 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
110210 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
110211 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
110212 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
110213 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
110214 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
110215 +set_dirty_51144 set_dirty 3 51144 NULL
110216 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
110217 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
110218 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
110219 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
110220 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
110221 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
110222 +tipc_send_51238 tipc_send 4 51238 NULL
110223 +drm_property_create_51239 drm_property_create 4 51239 NULL
110224 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
110225 +st_read_51251 st_read 3 51251 NULL
110226 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
110227 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
110228 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
110229 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
110230 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
110231 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
110232 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
110233 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
110234 +get_cell_51316 get_cell 2 51316 NULL
110235 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
110236 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
110237 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
110238 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
110239 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
110240 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
110241 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
110242 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
110243 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
110244 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
110245 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
110246 +get_first_ref_51413 get_first_ref 0 51413 NULL
110247 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
110248 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
110249 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
110250 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
110251 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
110252 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
110253 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
110254 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
110255 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
110256 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
110257 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
110258 +key_search_51533 key_search 0 51533 NULL
110259 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
110260 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
110261 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
110262 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 NULL nohasharray
110263 +get_cur_path_51589 get_cur_path 0 51589 &snd_interval_refine_first_51589
110264 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
110265 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
110266 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
110267 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
110268 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
110269 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
110270 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
110271 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
110272 +host_mapping_level_51696 host_mapping_level 2-0 51696 NULL
110273 +sel_write_access_51704 sel_write_access 3 51704 NULL
110274 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
110275 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
110276 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
110277 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
110278 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
110279 +cm4040_read_51732 cm4040_read 3 51732 NULL
110280 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
110281 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
110282 +if_write_51756 if_write 3 51756 NULL
110283 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
110284 +__fswab32_51781 __fswab32 0 51781 NULL
110285 +to_ratio_51809 to_ratio 1-2 51809 NULL
110286 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
110287 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
110288 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
110289 +ioread32_51847 ioread32 0 51847 NULL nohasharray
110290 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
110291 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
110292 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
110293 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
110294 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
110295 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
110296 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
110297 +user_read_51881 user_read 3 51881 NULL
110298 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
110299 +virt_to_phys_51896 virt_to_phys 0 51896 NULL nohasharray
110300 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 &virt_to_phys_51896
110301 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
110302 +uvhub_to_first_node_51916 uvhub_to_first_node 0 51916 NULL
110303 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
110304 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
110305 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
110306 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
110307 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
110308 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
110309 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
110310 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
110311 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
110312 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
110313 +get_zone_51981 get_zone 0-1 51981 NULL
110314 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
110315 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
110316 +ntfs_attr_size_51994 ntfs_attr_size 0 51994 NULL
110317 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
110318 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
110319 +rdmalt_52022 rdmalt 0 52022 NULL
110320 +override_release_52032 override_release 2 52032 NULL
110321 +end_port_52042 end_port 0 52042 NULL
110322 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
110323 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
110324 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
110325 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
110326 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
110327 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
110328 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
110329 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
110330 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
110331 +retry_count_read_52129 retry_count_read 3 52129 NULL
110332 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
110333 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
110334 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
110335 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
110336 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
110337 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
110338 +htable_size_52148 htable_size 0-1 52148 NULL
110339 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
110340 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
110341 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
110342 +print_prefix_52176 print_prefix 0 52176 NULL
110343 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
110344 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
110345 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
110346 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
110347 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
110348 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
110349 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
110350 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
110351 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
110352 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
110353 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
110354 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
110355 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
110356 +read_file_reset_52310 read_file_reset 3 52310 NULL
110357 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
110358 +hwflags_read_52318 hwflags_read 3 52318 NULL
110359 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
110360 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
110361 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
110362 +hur_len_52339 hur_len 0 52339 NULL
110363 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
110364 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
110365 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
110366 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
110367 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
110368 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
110369 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
110370 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
110371 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
110372 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
110373 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
110374 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
110375 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
110376 +delay_status_52431 delay_status 5 52431 NULL
110377 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
110378 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
110379 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
110380 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
110381 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
110382 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
110383 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
110384 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
110385 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
110386 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
110387 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
110388 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
110389 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
110390 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
110391 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
110392 +from_oblock_52546 from_oblock 0-1 52546 NULL
110393 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
110394 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
110395 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
110396 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
110397 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
110398 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
110399 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
110400 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
110401 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
110402 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
110403 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
110404 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
110405 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
110406 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
110407 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
110408 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
110409 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
110410 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
110411 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
110412 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
110413 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
110414 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
110415 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
110416 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
110417 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
110418 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
110419 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
110420 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
110421 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
110422 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
110423 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
110424 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
110425 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
110426 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
110427 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
110428 +twlreg_write_52880 twlreg_write 3 52880 NULL
110429 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
110430 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
110431 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
110432 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
110433 +create_vtbl_52909 create_vtbl 0 52909 NULL
110434 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
110435 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
110436 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
110437 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
110438 +send_packet_52960 send_packet 4 52960 NULL
110439 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
110440 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
110441 +num_node_state_52989 num_node_state 0 52989 NULL
110442 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
110443 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
110444 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
110445 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
110446 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
110447 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
110448 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
110449 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
110450 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
110451 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
110452 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
110453 +page_to_nid_53085 page_to_nid 0 53085 NULL
110454 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
110455 +insert_new_root_53097 insert_new_root 0 53097 NULL
110456 +verity_status_53120 verity_status 5 53120 NULL
110457 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
110458 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
110459 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
110460 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
110461 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
110462 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
110463 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
110464 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
110465 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
110466 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
110467 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
110468 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
110469 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
110470 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
110471 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
110472 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
110473 +tsk_fork_get_node_53271 tsk_fork_get_node 0 53271 NULL
110474 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
110475 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
110476 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
110477 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
110478 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
110479 +vm_mmap_53339 vm_mmap 0 53339 NULL
110480 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
110481 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
110482 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
110483 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
110484 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
110485 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
110486 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
110487 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
110488 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
110489 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
110490 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
110491 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
110492 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
110493 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
110494 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
110495 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
110496 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
110497 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
110498 +check_acl_53512 check_acl 0 53512 NULL
110499 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 1 53515 NULL
110500 +send_utimes_53516 send_utimes 0 53516 NULL
110501 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
110502 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
110503 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
110504 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
110505 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
110506 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
110507 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
110508 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
110509 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
110510 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
110511 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
110512 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
110513 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 NULL nohasharray
110514 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
110515 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
110516 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
110517 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
110518 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
110519 +wdm_write_53735 wdm_write 3 53735 NULL
110520 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
110521 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
110522 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
110523 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
110524 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
110525 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
110526 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
110527 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
110528 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
110529 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
110530 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
110531 +setup_data_read_53822 setup_data_read 3 53822 NULL
110532 +pms_read_53873 pms_read 3 53873 NULL
110533 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
110534 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
110535 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
110536 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
110537 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
110538 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
110539 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
110540 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
110541 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
110542 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
110543 +send_clone_54011 send_clone 0 54011 NULL
110544 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
110545 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
110546 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
110547 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
110548 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
110549 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
110550 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
110551 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
110552 +_malloc_54077 _malloc 1 54077 NULL
110553 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
110554 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
110555 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
110556 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
110557 +strn_len_54122 strn_len 0 54122 NULL
110558 +isku_receive_54130 isku_receive 4 54130 NULL
110559 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
110560 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
110561 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
110562 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
110563 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
110564 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
110565 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
110566 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
110567 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
110568 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
110569 +reada_add_block_54247 reada_add_block 2 54247 NULL
110570 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
110571 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
110572 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
110573 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
110574 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
110575 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
110576 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
110577 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
110578 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
110579 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
110580 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
110581 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
110582 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
110583 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
110584 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
110585 +sprintf_54306 sprintf 0 54306 NULL
110586 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
110587 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
110588 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
110589 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
110590 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
110591 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
110592 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
110593 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
110594 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
110595 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
110596 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
110597 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
110598 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
110599 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
110600 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
110601 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
110602 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
110603 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4-5 54485 NULL
110604 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
110605 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
110606 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
110607 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
110608 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
110609 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
110610 +viacam_read_54526 viacam_read 3 54526 NULL
110611 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
110612 +setsockopt_54539 setsockopt 5 54539 NULL
110613 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
110614 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
110615 +ntfs_commit_pages_after_non_resident_write_54555 ntfs_commit_pages_after_non_resident_write 4-3 54555 NULL nohasharray
110616 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 &ntfs_commit_pages_after_non_resident_write_54555
110617 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
110618 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
110619 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
110620 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
110621 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
110622 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
110623 +devm_gen_pool_create_54607 devm_gen_pool_create 3 54607 NULL
110624 +port_fops_write_54627 port_fops_write 3 54627 NULL
110625 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
110626 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
110627 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
110628 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
110629 +tdp_page_fault_54663 tdp_page_fault 2 54663 NULL
110630 +bus_add_device_54665 bus_add_device 0 54665 NULL
110631 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
110632 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
110633 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
110634 +evm_read_key_54674 evm_read_key 3 54674 NULL
110635 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
110636 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
110637 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
110638 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
110639 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
110640 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
110641 +kzalloc_54740 kzalloc 1 54740 NULL
110642 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
110643 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
110644 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
110645 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
110646 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
110647 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
110648 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
110649 +domain_init_54797 domain_init 2 54797 NULL
110650 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
110651 +get_dev_size_54807 get_dev_size 0 54807 NULL
110652 +nfsd_write_54809 nfsd_write 6 54809 NULL
110653 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
110654 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
110655 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
110656 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
110657 +write_rio_54837 write_rio 3 54837 NULL
110658 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
110659 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
110660 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
110661 +printer_read_54851 printer_read 3 54851 NULL
110662 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
110663 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
110664 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
110665 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
110666 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
110667 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
110668 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
110669 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
110670 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
110671 +add_port_54941 add_port 2 54941 NULL
110672 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
110673 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
110674 +c4_add_card_54968 c4_add_card 3 54968 NULL
110675 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
110676 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
110677 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
110678 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
110679 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
110680 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
110681 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
110682 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
110683 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
110684 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
110685 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
110686 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
110687 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
110688 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
110689 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
110690 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
110691 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
110692 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
110693 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
110694 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
110695 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
110696 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
110697 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
110698 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
110699 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
110700 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
110701 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
110702 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
110703 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
110704 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
110705 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
110706 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
110707 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
110708 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
110709 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
110710 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
110711 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
110712 +ptrace_request_55288 ptrace_request 3 55288 NULL
110713 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
110714 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
110715 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
110716 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
110717 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 NULL nohasharray
110718 +__get_vm_area_node_55305 __get_vm_area_node 6 55305 &qp_alloc_guest_work_55305
110719 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
110720 +do_shmat_55336 do_shmat 5 55336 NULL
110721 +vme_user_read_55338 vme_user_read 3 55338 NULL
110722 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
110723 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
110724 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
110725 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
110726 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
110727 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
110728 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
110729 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
110730 +SyS_read_55449 SyS_read 3 55449 NULL
110731 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
110732 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
110733 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
110734 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
110735 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
110736 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
110737 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
110738 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
110739 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
110740 +ea_get_55522 ea_get 3-0 55522 NULL
110741 +buffer_size_55534 buffer_size 0 55534 NULL
110742 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
110743 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
110744 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
110745 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
110746 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
110747 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
110748 +add_partition_55588 add_partition 2 55588 NULL
110749 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
110750 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
110751 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
110752 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
110753 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
110754 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
110755 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
110756 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
110757 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
110758 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
110759 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
110760 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
110761 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
110762 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
110763 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
110764 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
110765 +get_info_55681 get_info 3 55681 NULL
110766 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
110767 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
110768 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
110769 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
110770 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
110771 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
110772 +set_local_name_55757 set_local_name 4 55757 NULL
110773 +strlen_55778 strlen 0 55778 NULL nohasharray
110774 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
110775 +set_spte_55783 set_spte 4-5 55783 NULL
110776 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
110777 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
110778 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
110779 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
110780 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
110781 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
110782 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
110783 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
110784 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
110785 +hsc_write_55875 hsc_write 3 55875 NULL
110786 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
110787 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
110788 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
110789 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
110790 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
110791 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
110792 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
110793 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
110794 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
110795 +btrfs_clone_55977 btrfs_clone 5-3 55977 NULL
110796 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
110797 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
110798 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
110799 +__set_discard_56081 __set_discard 2 56081 NULL
110800 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
110801 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
110802 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
110803 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
110804 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
110805 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
110806 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
110807 +create_irq_nr_56180 create_irq_nr 1-0-2 56180 NULL
110808 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
110809 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
110810 +update_space_info_56213 update_space_info 0 56213 NULL
110811 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
110812 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
110813 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
110814 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
110815 +fd_copyin_56247 fd_copyin 3 56247 NULL
110816 +svc_init_buffer_56249 svc_init_buffer 3 56249 NULL
110817 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
110818 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
110819 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
110820 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
110821 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
110822 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
110823 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
110824 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
110825 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
110826 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
110827 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
110828 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
110829 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
110830 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
110831 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
110832 +dev_read_56369 dev_read 3 56369 NULL
110833 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
110834 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
110835 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
110836 +write_gssp_56404 write_gssp 3 56404 NULL
110837 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
110838 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
110839 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
110840 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
110841 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
110842 +fl_create_56435 fl_create 5 56435 NULL
110843 +gnttab_map_56439 gnttab_map 2 56439 NULL
110844 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
110845 +set_connectable_56458 set_connectable 4 56458 NULL
110846 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
110847 +putused_user_56467 putused_user 3 56467 NULL
110848 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
110849 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
110850 +global_rt_period_56476 global_rt_period 0 56476 NULL
110851 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
110852 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
110853 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
110854 +init_map_ip_56508 init_map_ip 5 56508 NULL
110855 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
110856 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
110857 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
110858 +ip_options_get_56538 ip_options_get 4 56538 NULL
110859 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
110860 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
110861 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
110862 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
110863 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
110864 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
110865 +event_filter_write_56609 event_filter_write 3 56609 NULL
110866 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
110867 +gather_array_56641 gather_array 3 56641 NULL
110868 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
110869 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
110870 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
110871 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
110872 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
110873 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
110874 +build_map_info_56696 build_map_info 2 56696 NULL
110875 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
110876 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
110877 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
110878 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
110879 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
110880 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
110881 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
110882 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
110883 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
110884 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
110885 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
110886 +do_syslog_56807 do_syslog 3 56807 NULL
110887 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
110888 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
110889 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
110890 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
110891 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
110892 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
110893 +wb_lookup_56858 wb_lookup 2 56858 NULL
110894 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
110895 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
110896 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
110897 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
110898 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
110899 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
110900 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
110901 +strcspn_56913 strcspn 0 56913 NULL
110902 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
110903 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL nohasharray
110904 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 &journal_init_revoke_56933
110905 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
110906 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
110907 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
110908 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
110909 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
110910 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
110911 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
110912 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
110913 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
110914 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
110915 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
110916 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
110917 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
110918 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
110919 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
110920 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
110921 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
110922 +altera_get_note_57099 altera_get_note 6 57099 NULL
110923 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
110924 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
110925 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
110926 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
110927 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
110928 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
110929 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
110930 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
110931 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
110932 +changed_inode_57156 changed_inode 0 57156 NULL
110933 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
110934 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
110935 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
110936 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
110937 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
110938 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
110939 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
110940 +flush_space_57241 flush_space 3-0 57241 NULL
110941 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
110942 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
110943 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
110944 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
110945 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
110946 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
110947 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
110948 +fw_file_size_57307 fw_file_size 0 57307 NULL
110949 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
110950 +write_file_regval_57313 write_file_regval 3 57313 NULL
110951 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
110952 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
110953 +usblp_read_57342 usblp_read 3 57342 NULL
110954 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
110955 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
110956 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
110957 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
110958 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
110959 +read_file_blob_57406 read_file_blob 3 57406 NULL
110960 +enclosure_register_57412 enclosure_register 3 57412 NULL
110961 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
110962 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
110963 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
110964 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
110965 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
110966 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
110967 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
110968 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
110969 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
110970 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
110971 +skb_headlen_57501 skb_headlen 0 57501 NULL
110972 +copy_in_user_57502 copy_in_user 3 57502 NULL
110973 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
110974 +init_tag_map_57515 init_tag_map 3 57515 NULL
110975 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
110976 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
110977 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
110978 +cmm_read_57520 cmm_read 3 57520 NULL
110979 +inode_permission_57531 inode_permission 0 57531 NULL
110980 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
110981 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
110982 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
110983 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
110984 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
110985 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
110986 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
110987 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
110988 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
110989 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
110990 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
110991 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
110992 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
110993 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
110994 +mem_read_57631 mem_read 3 57631 NULL
110995 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
110996 +r3964_write_57662 r3964_write 4 57662 NULL
110997 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
110998 +__lgwrite_57669 __lgwrite 4 57669 NULL
110999 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
111000 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
111001 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
111002 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
111003 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
111004 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
111005 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
111006 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
111007 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
111008 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
111009 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
111010 +ld2_57794 ld2 0 57794 NULL
111011 +ivtv_read_57796 ivtv_read 3 57796 NULL
111012 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
111013 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
111014 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
111015 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
111016 +flash_read_57843 flash_read 3 57843 NULL
111017 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
111018 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
111019 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
111020 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 NULL nohasharray
111021 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 &atomic_add_return_unchecked_57910
111022 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
111023 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
111024 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
111025 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
111026 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
111027 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
111028 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
111029 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
111030 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
111031 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
111032 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
111033 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
111034 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
111035 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
111036 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
111037 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
111038 +mce_async_out_58056 mce_async_out 3 58056 NULL
111039 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
111040 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
111041 +cm4040_write_58079 cm4040_write 3 58079 NULL
111042 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
111043 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
111044 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
111045 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
111046 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
111047 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
111048 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
111049 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
111050 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
111051 +read_file_debug_58256 read_file_debug 3 58256 NULL
111052 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
111053 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
111054 +profile_load_58267 profile_load 3 58267 NULL
111055 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
111056 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
111057 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
111058 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
111059 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
111060 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
111061 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
111062 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3-0 58331 NULL
111063 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
111064 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
111065 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
111066 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
111067 +save_hint_58359 save_hint 2 58359 NULL
111068 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
111069 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
111070 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
111071 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
111072 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
111073 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
111074 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
111075 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
111076 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
111077 +capabilities_read_58457 capabilities_read 3 58457 NULL
111078 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
111079 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
111080 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
111081 +nv_rd08_58472 nv_rd08 0 58472 NULL
111082 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
111083 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
111084 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
111085 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
111086 +__clear_discard_58546 __clear_discard 2 58546 NULL
111087 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
111088 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
111089 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
111090 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
111091 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
111092 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
111093 +xip_file_read_58592 xip_file_read 3 58592 NULL
111094 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
111095 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
111096 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
111097 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
111098 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
111099 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
111100 +vb2_qbuf_58631 vb2_qbuf 0 58631 NULL
111101 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
111102 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
111103 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
111104 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
111105 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
111106 +find_zero_58685 find_zero 0-1 58685 NULL
111107 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
111108 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
111109 +vmalloc_node_58700 vmalloc_node 1-2 58700 NULL
111110 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
111111 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
111112 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
111113 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
111114 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
111115 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
111116 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
111117 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
111118 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
111119 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
111120 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
111121 +write_file_58812 write_file 4 58812 NULL
111122 +ep_read_58813 ep_read 3 58813 NULL
111123 +command_write_58841 command_write 3 58841 NULL
111124 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
111125 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
111126 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
111127 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
111128 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
111129 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
111130 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
111131 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
111132 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
111133 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
111134 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
111135 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
111136 +init_list_58990 init_list 3 58990 NULL
111137 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
111138 +ep_write_59008 ep_write 3 59008 NULL
111139 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
111140 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
111141 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
111142 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
111143 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
111144 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
111145 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
111146 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
111147 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
111148 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
111149 +init_status_page_59124 init_status_page 0 59124 NULL
111150 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
111151 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
111152 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
111153 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
111154 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
111155 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
111156 +ksize_59176 ksize 0 59176 NULL
111157 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
111158 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
111159 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
111160 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
111161 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
111162 +dt3155_read_59226 dt3155_read 3 59226 NULL
111163 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
111164 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
111165 +nla_len_59258 nla_len 0 59258 NULL
111166 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
111167 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
111168 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
111169 +fd_copyout_59323 fd_copyout 3 59323 NULL
111170 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
111171 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
111172 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
111173 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
111174 +__map_request_59350 __map_request 0 59350 NULL
111175 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
111176 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
111177 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
111178 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
111179 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
111180 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
111181 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
111182 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
111183 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
111184 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
111185 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
111186 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
111187 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
111188 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
111189 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
111190 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
111191 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
111192 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
111193 +kmalloc_large_node_59542 kmalloc_large_node 3 59542 NULL
111194 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
111195 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
111196 +tunables_write_59563 tunables_write 3 59563 NULL
111197 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
111198 +write_pbl_59583 write_pbl 4 59583 NULL
111199 +memdup_user_59590 memdup_user 2 59590 NULL
111200 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
111201 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
111202 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
111203 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
111204 +mtrr_write_59622 mtrr_write 3 59622 NULL
111205 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
111206 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
111207 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
111208 +hidraw_read_59650 hidraw_read 3 59650 NULL
111209 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
111210 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
111211 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
111212 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
111213 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
111214 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
111215 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
111216 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
111217 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
111218 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
111219 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
111220 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
111221 +strnlen_59746 strnlen 0 59746 NULL
111222 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
111223 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
111224 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
111225 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
111226 +venus_remove_59781 venus_remove 4 59781 NULL
111227 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
111228 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
111229 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
111230 +ipw_write_59807 ipw_write 3 59807 NULL
111231 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
111232 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
111233 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
111234 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
111235 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
111236 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
111237 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
111238 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
111239 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
111240 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
111241 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
111242 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
111243 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
111244 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
111245 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
111246 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
111247 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
111248 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
111249 +lookup_node_59953 lookup_node 2 59953 NULL
111250 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
111251 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
111252 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
111253 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
111254 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
111255 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
111256 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
111257 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
111258 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
111259 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
111260 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
111261 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
111262 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
111263 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
111264 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
111265 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
111266 +compat_writev_60063 compat_writev 3 60063 NULL
111267 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
111268 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
111269 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
111270 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
111271 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
111272 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
111273 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
111274 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
111275 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
111276 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
111277 +init_state_60165 init_state 2 60165 NULL
111278 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
111279 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
111280 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
111281 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
111282 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
111283 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
111284 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
111285 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
111286 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
111287 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
111288 +printer_write_60276 printer_write 3 60276 NULL
111289 +alloc_irq_pin_list_60277 alloc_irq_pin_list 1 60277 NULL
111290 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
111291 +getDataLength_60301 getDataLength 0 60301 NULL
111292 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
111293 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
111294 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
111295 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
111296 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
111297 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
111298 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
111299 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
111300 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
111301 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
111302 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
111303 +driver_names_read_60399 driver_names_read 3 60399 NULL
111304 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
111305 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
111306 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
111307 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
111308 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
111309 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
111310 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
111311 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
111312 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
111313 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
111314 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
111315 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
111316 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
111317 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
111318 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
111319 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
111320 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
111321 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
111322 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
111323 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
111324 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
111325 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
111326 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
111327 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
111328 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
111329 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
111330 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
111331 +init_data_container_60709 init_data_container 1 60709 NULL
111332 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
111333 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
111334 +raid_status_60755 raid_status 5 60755 NULL
111335 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
111336 +opticon_write_60775 opticon_write 4 60775 NULL
111337 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
111338 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
111339 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
111340 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
111341 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
111342 +generic_writepages_60871 generic_writepages 0 60871 NULL
111343 +tipc_createport_60875 tipc_createport 4 60875 NULL
111344 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
111345 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
111346 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
111347 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
111348 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
111349 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
111350 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
111351 +pti_char_write_60960 pti_char_write 3 60960 NULL
111352 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
111353 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
111354 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
111355 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
111356 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
111357 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
111358 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
111359 +symtab_init_61050 symtab_init 2 61050 NULL
111360 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
111361 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
111362 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
111363 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
111364 +journal_stop_61080 journal_stop 0 61080 NULL
111365 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
111366 +get_derived_key_61100 get_derived_key 4 61100 NULL
111367 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
111368 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
111369 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
111370 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
111371 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1-2 61126 NULL
111372 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
111373 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
111374 +__vmalloc_61168 __vmalloc 1 61168 NULL
111375 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
111376 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
111377 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
111378 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
111379 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
111380 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
111381 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
111382 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
111383 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
111384 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
111385 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
111386 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
111387 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
111388 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
111389 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
111390 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
111391 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
111392 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
111393 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
111394 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
111395 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
111396 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
111397 +__fls_61340 __fls 0 61340 NULL nohasharray
111398 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
111399 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
111400 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
111401 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
111402 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
111403 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
111404 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
111405 +get_inode_info_61387 get_inode_info 0 61387 NULL
111406 +system_enable_write_61396 system_enable_write 3 61396 NULL
111407 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
111408 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
111409 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
111410 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
111411 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
111412 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
111413 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
111414 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
111415 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
111416 +__vmalloc_area_node_61525 __vmalloc_area_node 4 61525 NULL
111417 +erst_errno_61526 erst_errno 0 61526 NULL
111418 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
111419 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
111420 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
111421 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
111422 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
111423 +alloc_pgtable_page_61562 alloc_pgtable_page 1 61562 NULL
111424 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
111425 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
111426 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
111427 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
111428 +seq_open_private_61589 seq_open_private 3 61589 NULL
111429 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
111430 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
111431 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
111432 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
111433 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
111434 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
111435 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
111436 +resize_stripes_61650 resize_stripes 2 61650 NULL
111437 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
111438 +insert_one_name_61668 insert_one_name 7 61668 NULL
111439 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
111440 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
111441 +lock_loop_61681 lock_loop 1 61681 NULL
111442 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
111443 +filter_read_61692 filter_read 3 61692 NULL
111444 +prog_page_61711 prog_page 2 61711 NULL
111445 +iov_length_61716 iov_length 0 61716 NULL
111446 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
111447 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
111448 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
111449 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
111450 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
111451 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
111452 +num_counter_active_61789 num_counter_active 0 61789 NULL
111453 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
111454 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
111455 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
111456 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
111457 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
111458 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
111459 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
111460 +get_fw_name_61874 get_fw_name 3 61874 NULL
111461 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
111462 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
111463 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
111464 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
111465 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
111466 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
111467 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
111468 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
111469 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
111470 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
111471 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
111472 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
111473 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
111474 +fix_read_error_61965 fix_read_error 4 61965 NULL
111475 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
111476 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
111477 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
111478 +cow_file_range_61979 cow_file_range 3 61979 NULL
111479 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
111480 +dequeue_event_62000 dequeue_event 3 62000 NULL
111481 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
111482 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
111483 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
111484 +SYSC_select_62024 SYSC_select 1 62024 NULL
111485 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
111486 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
111487 +do_pselect_62061 do_pselect 1 62061 NULL
111488 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
111489 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
111490 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
111491 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
111492 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
111493 +ip_recv_error_62117 ip_recv_error 3 62117 NULL
111494 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
111495 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
111496 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
111497 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
111498 +ql_status_62135 ql_status 5 62135 NULL nohasharray
111499 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
111500 +video_usercopy_62151 video_usercopy 2 62151 NULL
111501 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
111502 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
111503 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
111504 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
111505 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
111506 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
111507 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
111508 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
111509 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
111510 +allocate_partition_62245 allocate_partition 4 62245 NULL
111511 +security_file_permission_62278 security_file_permission 0 62278 NULL
111512 +get_random_int_62279 get_random_int 0 62279 NULL
111513 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
111514 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
111515 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
111516 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
111517 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
111518 +vmemmap_pgd_populate_62315 vmemmap_pgd_populate 2 62315 NULL
111519 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
111520 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
111521 +subseq_list_62332 subseq_list 3-0 62332 NULL
111522 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
111523 +flash_write_62354 flash_write 3 62354 NULL
111524 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
111525 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
111526 +altera_irscan_62396 altera_irscan 2 62396 NULL
111527 +set_ssp_62411 set_ssp 4 62411 NULL
111528 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
111529 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
111530 +mtip_get_next_rr_node_62502 mtip_get_next_rr_node 0 62502 NULL
111531 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
111532 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
111533 +test_iso_queue_62534 test_iso_queue 5 62534 NULL nohasharray
111534 +__kmalloc_node_track_caller_62534 __kmalloc_node_track_caller 3 62534 &test_iso_queue_62534
111535 +debugfs_read_62535 debugfs_read 3 62535 NULL
111536 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
111537 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
111538 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
111539 +get_subdir_62581 get_subdir 3 62581 NULL
111540 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
111541 +get_desc_base_62617 get_desc_base 0 62617 NULL
111542 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
111543 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
111544 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
111545 +write_62671 write 3 62671 NULL
111546 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
111547 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
111548 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
111549 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
111550 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
111551 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
111552 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
111553 +rdm_62719 rdm 0 62719 NULL
111554 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
111555 +key_replays_read_62746 key_replays_read 3 62746 NULL
111556 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
111557 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
111558 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
111559 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
111560 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
111561 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
111562 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
111563 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
111564 +is_first_ref_62805 is_first_ref 0 62805 NULL
111565 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
111566 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
111567 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
111568 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
111569 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
111570 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
111571 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
111572 +set_swbp_62853 set_swbp 3 62853 NULL
111573 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
111574 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
111575 +aoechr_write_62883 aoechr_write 3 62883 NULL
111576 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
111577 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
111578 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
111579 +getdqbuf_62908 getdqbuf 1 62908 NULL
111580 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
111581 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
111582 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
111583 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
111584 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
111585 +send_write_62969 send_write 0-3 62969 NULL
111586 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
111587 +alloc_mem_cgroup_per_zone_info_63024 alloc_mem_cgroup_per_zone_info 2 63024 NULL
111588 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
111589 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
111590 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
111591 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
111592 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
111593 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
111594 +unlink1_63059 unlink1 3 63059 NULL
111595 +__do_munmap_63063 __do_munmap 0 63063 NULL
111596 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
111597 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
111598 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
111599 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
111600 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
111601 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
111602 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
111603 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
111604 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
111605 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
111606 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
111607 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
111608 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
111609 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
111610 +vme_master_read_63221 vme_master_read 0 63221 NULL
111611 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
111612 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
111613 +ptp_read_63251 ptp_read 4 63251 NULL
111614 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
111615 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
111616 +raid5_resize_63306 raid5_resize 2 63306 NULL
111617 +proc_info_read_63344 proc_info_read 3 63344 NULL
111618 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
111619 +idmouse_read_63374 idmouse_read 3 63374 NULL
111620 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
111621 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
111622 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
111623 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
111624 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
111625 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
111626 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
111627 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
111628 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
111629 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
111630 +__do_kmalloc_node_63461 __do_kmalloc_node 3 63461 NULL
111631 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
111632 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
111633 +do_work_63483 do_work 0 63483 NULL
111634 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
111635 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
111636 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
111637 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
111638 +save_hint_63497 save_hint 2 63497 NULL
111639 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
111640 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
111641 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
111642 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
111643 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
111644 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
111645 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
111646 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
111647 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
111648 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
111649 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
111650 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
111651 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
111652 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
111653 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
111654 +write_debug_level_63613 write_debug_level 3 63613 NULL
111655 +module_alloc_63630 module_alloc 1 63630 NULL
111656 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
111657 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
111658 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
111659 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
111660 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
111661 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
111662 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
111663 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
111664 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
111665 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
111666 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
111667 +bin_search_63697 bin_search 0 63697 NULL
111668 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
111669 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
111670 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
111671 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
111672 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
111673 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
111674 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
111675 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
111676 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
111677 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
111678 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
111679 +prepare_copy_63826 prepare_copy 2 63826 NULL
111680 +sel_write_load_63830 sel_write_load 3 63830 NULL
111681 +ll_readlink_63836 ll_readlink 3 63836 NULL
111682 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
111683 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
111684 +divas_write_63901 divas_write 3 63901 NULL
111685 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
111686 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
111687 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
111688 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
111689 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
111690 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
111691 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
111692 +__team_options_register_63941 __team_options_register 3 63941 NULL
111693 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
111694 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
111695 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
111696 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
111697 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
111698 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
111699 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
111700 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
111701 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
111702 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
111703 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
111704 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
111705 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
111706 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
111707 +__sock_create_64069 __sock_create 0 64069 NULL
111708 +get_u8_64076 get_u8 0 64076 NULL
111709 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
111710 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
111711 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
111712 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
111713 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
111714 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
111715 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
111716 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
111717 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
111718 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
111719 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
111720 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
111721 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
111722 +init_bch_64130 init_bch 2-1 64130 NULL
111723 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
111724 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
111725 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
111726 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
111727 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
111728 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
111729 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
111730 +read_pulse_64227 read_pulse 0-3 64227 NULL
111731 +ea_len_64229 ea_len 0 64229 NULL
111732 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
111733 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
111734 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
111735 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
111736 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
111737 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
111738 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
111739 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
111740 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
111741 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
111742 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
111743 +ffz_64324 ffz 0-1 64324 NULL
111744 +map_region_64328 map_region 1 64328 NULL
111745 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
111746 +ts_write_64336 ts_write 3 64336 NULL
111747 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
111748 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
111749 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
111750 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
111751 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
111752 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
111753 +reg_create_64372 reg_create 5 64372 NULL
111754 +ilo_write_64378 ilo_write 3 64378 NULL
111755 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
111756 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
111757 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
111758 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
111759 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
111760 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
111761 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
111762 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
111763 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
111764 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
111765 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
111766 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
111767 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
111768 +single_open_size_64483 single_open_size 4 64483 NULL
111769 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
111770 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
111771 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
111772 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
111773 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
111774 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
111775 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
111776 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
111777 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
111778 +SyS_bind_64544 SyS_bind 3 64544 NULL
111779 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
111780 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
111781 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
111782 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
111783 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
111784 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
111785 +do_erase_64574 do_erase 4 64574 NULL
111786 +fanotify_write_64623 fanotify_write 3 64623 NULL
111787 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
111788 +to_dblock_64655 to_dblock 0-1 64655 NULL
111789 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
111790 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
111791 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
111792 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
111793 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
111794 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
111795 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
111796 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL nohasharray
111797 +mremap_to_64691 mremap_to 0-3 64691 &sec_bulk_write_64691
111798 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
111799 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
111800 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
111801 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
111802 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
111803 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
111804 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
111805 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
111806 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
111807 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
111808 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
111809 +message_for_md_64777 message_for_md 5 64777 NULL
111810 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
111811 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
111812 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
111813 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
111814 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
111815 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
111816 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
111817 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
111818 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
111819 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
111820 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
111821 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
111822 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
111823 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
111824 +mk_pid_64894 mk_pid 0-3 64894 NULL
111825 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
111826 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
111827 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
111828 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
111829 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
111830 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
111831 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
111832 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
111833 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
111834 +insert_dent_65034 insert_dent 7 65034 NULL
111835 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
111836 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
111837 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
111838 +make_idx_node_65068 make_idx_node 0 65068 NULL
111839 +count_run_65072 count_run 0-2-4-5 65072 NULL
111840 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
111841 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
111842 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
111843 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
111844 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
111845 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
111846 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
111847 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
111848 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
111849 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
111850 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
111851 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
111852 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
111853 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
111854 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
111855 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
111856 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
111857 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
111858 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
111859 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
111860 +get_var_len_65304 get_var_len 0 65304 NULL
111861 +unpack_array_65318 unpack_array 0 65318 NULL
111862 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
111863 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
111864 +init_list_set_65351 init_list_set 3-2 65351 NULL
111865 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
111866 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
111867 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
111868 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
111869 +SyS_writev_65372 SyS_writev 3 65372 NULL
111870 +mi_set_context_65395 mi_set_context 0 65395 NULL
111871 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
111872 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
111873 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
111874 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
111875 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
111876 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
111877 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
111878 +device_add_groups_65423 device_add_groups 0 65423 NULL
111879 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
111880 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
111881 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
111882 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
111883 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
111884 +clear_user_65470 clear_user 2 65470 NULL
111885 +__pcibus_to_node_65489 __pcibus_to_node 0 65489 NULL nohasharray
111886 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 &__pcibus_to_node_65489
111887 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
111888 +qib_create_ctxtdata_65497 qib_create_ctxtdata 3 65497 NULL
111889 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
111890 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
111891 new file mode 100644
111892 index 0000000..50f8464
111893 --- /dev/null
111894 +++ b/tools/gcc/size_overflow_plugin.c
111895 @@ -0,0 +1,4072 @@
111896 +/*
111897 + * Copyright 2011, 2012, 2013, 2014 by Emese Revfy <re.emese@gmail.com>
111898 + * Licensed under the GPL v2, or (at your option) v3
111899 + *
111900 + * Homepage:
111901 + * http://www.grsecurity.net/~ephox/overflow_plugin/
111902 + *
111903 + * Documentation:
111904 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
111905 + *
111906 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
111907 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
111908 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
111909 + *
111910 + * Usage:
111911 + * $ 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
111912 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
111913 + */
111914 +
111915 +#include "gcc-plugin.h"
111916 +#include "config.h"
111917 +#include "system.h"
111918 +#include "coretypes.h"
111919 +#include "tree.h"
111920 +#include "tree-pass.h"
111921 +#include "intl.h"
111922 +#include "plugin-version.h"
111923 +#include "tm.h"
111924 +#include "toplev.h"
111925 +#include "function.h"
111926 +#include "tree-flow.h"
111927 +#include "plugin.h"
111928 +#include "gimple.h"
111929 +#include "diagnostic.h"
111930 +#include "cfgloop.h"
111931 +
111932 +#if BUILDING_GCC_VERSION >= 4008
111933 +#define TODO_dump_func 0
111934 +#define TODO_dump_cgraph 0
111935 +#endif
111936 +
111937 +#define __unused __attribute__((__unused__))
111938 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
111939 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
111940 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
111941 +#define BEFORE_STMT true
111942 +#define AFTER_STMT false
111943 +#define CREATE_NEW_VAR NULL_TREE
111944 +#define CODES_LIMIT 32
111945 +#define MAX_PARAM 31
111946 +#define VEC_LEN 128
111947 +#define MY_STMT GF_PLF_1
111948 +#define NO_CAST_CHECK GF_PLF_2
111949 +#define RET_CHECK NULL_TREE
111950 +#define CANNOT_FIND_ARG 32
111951 +#define WRONG_NODE 32
111952 +#define NOT_INTENTIONAL_ASM NULL
111953 +#define MIN_CHECK true
111954 +#define MAX_CHECK false
111955 +
111956 +#define TURN_OFF_ASM_STR "# size_overflow MARK_TURN_OFF "
111957 +#define YES_ASM_STR "# size_overflow MARK_YES "
111958 +#define OK_ASM_STR "# size_overflow "
111959 +
111960 +#if BUILDING_GCC_VERSION == 4005
111961 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
111962 +#endif
111963 +
111964 +struct size_overflow_hash {
111965 + const struct size_overflow_hash * const next;
111966 + const char * const name;
111967 + const unsigned int param;
111968 +};
111969 +
111970 +#include "size_overflow_hash.h"
111971 +
111972 +enum mark {
111973 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
111974 +};
111975 +
111976 +static unsigned int call_count;
111977 +
111978 +struct visited {
111979 + struct visited *next;
111980 + const_tree fndecl;
111981 + unsigned int num;
111982 + const_gimple first_stmt;
111983 +};
111984 +
111985 +struct next_cgraph_node {
111986 + struct next_cgraph_node *next;
111987 + struct cgraph_node *current_function;
111988 + tree callee_fndecl;
111989 + unsigned int num;
111990 +};
111991 +
111992 +struct interesting_node {
111993 + struct interesting_node *next;
111994 + gimple first_stmt;
111995 + const_tree fndecl;
111996 + tree node;
111997 +#if BUILDING_GCC_VERSION <= 4007
111998 + VEC(tree, gc) *last_nodes;
111999 +#else
112000 + vec<tree, va_gc> *last_nodes;
112001 +#endif
112002 + unsigned int num;
112003 + enum mark intentional_attr_decl;
112004 + enum mark intentional_attr_cur_fndecl;
112005 + gimple intentional_mark_from_gimple;
112006 +};
112007 +
112008 +int plugin_is_GPL_compatible;
112009 +void debug_gimple_stmt(gimple gs);
112010 +
112011 +static tree report_size_overflow_decl;
112012 +static const_tree const_char_ptr_type_node;
112013 +
112014 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
112015 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
112016 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
112017 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
112018 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
112019 +
112020 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
112021 +static tree get_size_overflow_type(gimple stmt, const_tree node);
112022 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
112023 +
112024 +static struct plugin_info size_overflow_plugin_info = {
112025 + .version = "20140111beta",
112026 + .help = "no-size-overflow\tturn off size overflow checking\n",
112027 +};
112028 +
112029 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
112030 +{
112031 + unsigned int arg_count;
112032 + enum tree_code code = TREE_CODE(*node);
112033 +
112034 + switch (code) {
112035 + case FUNCTION_DECL:
112036 + arg_count = type_num_arguments(TREE_TYPE(*node));
112037 + break;
112038 + case FUNCTION_TYPE:
112039 + case METHOD_TYPE:
112040 + arg_count = type_num_arguments(*node);
112041 + break;
112042 + default:
112043 + *no_add_attrs = true;
112044 + error("%s: %qE attribute only applies to functions", __func__, name);
112045 + return NULL_TREE;
112046 + }
112047 +
112048 + for (; args; args = TREE_CHAIN(args)) {
112049 + tree position = TREE_VALUE(args);
112050 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
112051 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
112052 + *no_add_attrs = true;
112053 + }
112054 + }
112055 + return NULL_TREE;
112056 +}
112057 +
112058 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
112059 +{
112060 + unsigned int arg_count;
112061 + enum tree_code code = TREE_CODE(*node);
112062 +
112063 + switch (code) {
112064 + case FUNCTION_DECL:
112065 + arg_count = type_num_arguments(TREE_TYPE(*node));
112066 + break;
112067 + case FUNCTION_TYPE:
112068 + case METHOD_TYPE:
112069 + arg_count = type_num_arguments(*node);
112070 + break;
112071 + case FIELD_DECL:
112072 + return NULL_TREE;
112073 + default:
112074 + *no_add_attrs = true;
112075 + error("%qE attribute only applies to functions", name);
112076 + return NULL_TREE;
112077 + }
112078 +
112079 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
112080 + return NULL_TREE;
112081 +
112082 + for (; args; args = TREE_CHAIN(args)) {
112083 + tree position = TREE_VALUE(args);
112084 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
112085 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
112086 + *no_add_attrs = true;
112087 + }
112088 + }
112089 + return NULL_TREE;
112090 +}
112091 +
112092 +static struct attribute_spec size_overflow_attr = {
112093 + .name = "size_overflow",
112094 + .min_length = 1,
112095 + .max_length = -1,
112096 + .decl_required = true,
112097 + .type_required = false,
112098 + .function_type_required = false,
112099 + .handler = handle_size_overflow_attribute,
112100 +#if BUILDING_GCC_VERSION >= 4007
112101 + .affects_type_identity = false
112102 +#endif
112103 +};
112104 +
112105 +static struct attribute_spec intentional_overflow_attr = {
112106 + .name = "intentional_overflow",
112107 + .min_length = 1,
112108 + .max_length = -1,
112109 + .decl_required = true,
112110 + .type_required = false,
112111 + .function_type_required = false,
112112 + .handler = handle_intentional_overflow_attribute,
112113 +#if BUILDING_GCC_VERSION >= 4007
112114 + .affects_type_identity = false
112115 +#endif
112116 +};
112117 +
112118 +static void register_attributes(void __unused *event_data, void __unused *data)
112119 +{
112120 + register_attribute(&size_overflow_attr);
112121 + register_attribute(&intentional_overflow_attr);
112122 +}
112123 +
112124 +static bool is_bool(const_tree node)
112125 +{
112126 + const_tree type;
112127 +
112128 + if (node == NULL_TREE)
112129 + return false;
112130 +
112131 + type = TREE_TYPE(node);
112132 + if (!INTEGRAL_TYPE_P(type))
112133 + return false;
112134 + if (TREE_CODE(type) == BOOLEAN_TYPE)
112135 + return true;
112136 + if (TYPE_PRECISION(type) == 1)
112137 + return true;
112138 + return false;
112139 +}
112140 +
112141 +static bool skip_types(const_tree var)
112142 +{
112143 + tree type;
112144 + enum tree_code code;
112145 +
112146 + if (is_gimple_constant(var))
112147 + return true;
112148 +
112149 + switch (TREE_CODE(var)) {
112150 + case ADDR_EXPR:
112151 +#if BUILDING_GCC_VERSION >= 4006
112152 + case MEM_REF:
112153 +#endif
112154 + case ARRAY_REF:
112155 + case BIT_FIELD_REF:
112156 + case INDIRECT_REF:
112157 + case TARGET_MEM_REF:
112158 + case COMPONENT_REF:
112159 + case VAR_DECL:
112160 + case VIEW_CONVERT_EXPR:
112161 + return true;
112162 + default:
112163 + break;
112164 + }
112165 +
112166 + code = TREE_CODE(var);
112167 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
112168 +
112169 + type = TREE_TYPE(var);
112170 + switch (TREE_CODE(type)) {
112171 + case INTEGER_TYPE:
112172 + case ENUMERAL_TYPE:
112173 + return false;
112174 + case BOOLEAN_TYPE:
112175 + return is_bool(var);
112176 + default:
112177 + return true;
112178 + }
112179 +}
112180 +
112181 +static inline gimple get_def_stmt(const_tree node)
112182 +{
112183 + gcc_assert(node != NULL_TREE);
112184 +
112185 + if (skip_types(node))
112186 + return NULL;
112187 +
112188 + if (TREE_CODE(node) != SSA_NAME)
112189 + return NULL;
112190 + return SSA_NAME_DEF_STMT(node);
112191 +}
112192 +
112193 +static unsigned char get_tree_code(const_tree type)
112194 +{
112195 + switch (TREE_CODE(type)) {
112196 + case ARRAY_TYPE:
112197 + return 0;
112198 + case BOOLEAN_TYPE:
112199 + return 1;
112200 + case ENUMERAL_TYPE:
112201 + return 2;
112202 + case FUNCTION_TYPE:
112203 + return 3;
112204 + case INTEGER_TYPE:
112205 + return 4;
112206 + case POINTER_TYPE:
112207 + return 5;
112208 + case RECORD_TYPE:
112209 + return 6;
112210 + case UNION_TYPE:
112211 + return 7;
112212 + case VOID_TYPE:
112213 + return 8;
112214 + case REAL_TYPE:
112215 + return 9;
112216 + case VECTOR_TYPE:
112217 + return 10;
112218 + case REFERENCE_TYPE:
112219 + return 11;
112220 + case OFFSET_TYPE:
112221 + return 12;
112222 + case COMPLEX_TYPE:
112223 + return 13;
112224 + default:
112225 + debug_tree((tree)type);
112226 + gcc_unreachable();
112227 + }
112228 +}
112229 +
112230 +struct function_hash {
112231 + size_t tree_codes_len;
112232 + unsigned char tree_codes[CODES_LIMIT];
112233 + tree fndecl;
112234 + unsigned int hash;
112235 +};
112236 +
112237 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
112238 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
112239 +{
112240 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
112241 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
112242 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
112243 +
112244 + unsigned int m = 0x57559429;
112245 + unsigned int n = 0x5052acdb;
112246 + const unsigned int *key4 = (const unsigned int *)key;
112247 + unsigned int h = len;
112248 + unsigned int k = len + seed + n;
112249 + unsigned long long p;
112250 +
112251 + while (len >= 8) {
112252 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
112253 + len -= 8;
112254 + }
112255 + if (len >= 4) {
112256 + cwmixb(key4[0]) key4 += 1;
112257 + len -= 4;
112258 + }
112259 + if (len)
112260 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
112261 + cwmixb(h ^ (k + n));
112262 + return k ^ h;
112263 +
112264 +#undef cwfold
112265 +#undef cwmixa
112266 +#undef cwmixb
112267 +}
112268 +
112269 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
112270 +{
112271 + unsigned int fn, codes, seed = 0;
112272 +
112273 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
112274 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
112275 +
112276 + fn_hash_data->hash = fn ^ codes;
112277 +}
112278 +
112279 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
112280 +{
112281 + gcc_assert(type != NULL_TREE);
112282 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
112283 +
112284 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
112285 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
112286 + fn_hash_data->tree_codes_len++;
112287 + type = TREE_TYPE(type);
112288 + }
112289 +}
112290 +
112291 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
112292 +{
112293 + const_tree result;
112294 +
112295 + gcc_assert(node != NULL_TREE);
112296 +
112297 + if (DECL_P(node)) {
112298 + result = DECL_RESULT(node);
112299 + if (result != NULL_TREE)
112300 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
112301 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
112302 + }
112303 +
112304 + gcc_assert(TYPE_P(node));
112305 +
112306 + if (TREE_CODE(node) == FUNCTION_TYPE)
112307 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
112308 +
112309 + return set_node_codes(node, fn_hash_data);
112310 +}
112311 +
112312 +static void set_function_codes(struct function_hash *fn_hash_data)
112313 +{
112314 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
112315 + enum tree_code code = TREE_CODE(type);
112316 +
112317 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
112318 +
112319 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
112320 +
112321 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
112322 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
112323 +}
112324 +
112325 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
112326 +{
112327 + const struct size_overflow_hash *entry;
112328 + struct function_hash fn_hash_data;
112329 + const char *func_name;
112330 +
112331 + // skip builtins __builtin_constant_p
112332 + if (DECL_BUILT_IN(fndecl))
112333 + return NULL;
112334 +
112335 + fn_hash_data.fndecl = fndecl;
112336 + fn_hash_data.tree_codes_len = 0;
112337 +
112338 + set_function_codes(&fn_hash_data);
112339 + gcc_assert(fn_hash_data.tree_codes_len != 0);
112340 +
112341 + func_name = ASM_NAME(fn_hash_data.fndecl);
112342 + set_hash(func_name, &fn_hash_data);
112343 +
112344 + entry = size_overflow_hash[fn_hash_data.hash];
112345 +
112346 + while (entry) {
112347 + if (!strcmp(entry->name, func_name))
112348 + return entry;
112349 + entry = entry->next;
112350 + }
112351 + return NULL;
112352 +}
112353 +
112354 +static void print_missing_msg(tree func, unsigned int argnum)
112355 +{
112356 + location_t loc;
112357 + const char *curfunc;
112358 + struct function_hash fn_hash_data;
112359 +
112360 + fn_hash_data.fndecl = DECL_ORIGIN(func);
112361 + fn_hash_data.tree_codes_len = 0;
112362 +
112363 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
112364 + curfunc = ASM_NAME(fn_hash_data.fndecl);
112365 +
112366 + set_function_codes(&fn_hash_data);
112367 + set_hash(curfunc, &fn_hash_data);
112368 +
112369 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
112370 +}
112371 +
112372 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
112373 +{
112374 + tree var;
112375 + unsigned int argnum = 1;
112376 +
112377 + if (TREE_CODE(arg) == SSA_NAME)
112378 + arg = SSA_NAME_VAR(arg);
112379 +
112380 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
112381 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
112382 + continue;
112383 + if (!skip_types(var))
112384 + return argnum;
112385 + }
112386 +
112387 + return CANNOT_FIND_ARG;
112388 +}
112389 +
112390 +static tree create_new_var(tree type)
112391 +{
112392 + tree new_var = create_tmp_var(type, "cicus");
112393 +
112394 +#if BUILDING_GCC_VERSION <= 4007
112395 + add_referenced_var(new_var);
112396 +#endif
112397 + return new_var;
112398 +}
112399 +
112400 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
112401 +{
112402 + gimple assign;
112403 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112404 + tree type = TREE_TYPE(rhs1);
112405 + tree lhs = create_new_var(type);
112406 +
112407 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
112408 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
112409 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
112410 +
112411 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
112412 + update_stmt(assign);
112413 + gimple_set_plf(assign, MY_STMT, true);
112414 + return assign;
112415 +}
112416 +
112417 +static tree cast_a_tree(tree type, tree var)
112418 +{
112419 + gcc_assert(type != NULL_TREE);
112420 + gcc_assert(var != NULL_TREE);
112421 + gcc_assert(fold_convertible_p(type, var));
112422 +
112423 + return fold_convert(type, var);
112424 +}
112425 +
112426 +static tree get_lhs(const_gimple stmt)
112427 +{
112428 + switch (gimple_code(stmt)) {
112429 + case GIMPLE_ASSIGN:
112430 + case GIMPLE_CALL:
112431 + return gimple_get_lhs(stmt);
112432 + case GIMPLE_PHI:
112433 + return gimple_phi_result(stmt);
112434 + default:
112435 + return NULL_TREE;
112436 + }
112437 +}
112438 +
112439 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
112440 +{
112441 + const_gimple def_stmt = get_def_stmt(rhs);
112442 +
112443 + if (force)
112444 + return false;
112445 +
112446 + if (is_gimple_constant(rhs))
112447 + return false;
112448 +
112449 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
112450 + return false;
112451 +
112452 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
112453 + return false;
112454 +
112455 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
112456 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
112457 + return false;
112458 +
112459 + return true;
112460 +}
112461 +
112462 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
112463 +{
112464 + gimple assign, def_stmt;
112465 +
112466 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
112467 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
112468 + gcc_unreachable();
112469 +
112470 + def_stmt = get_def_stmt(rhs);
112471 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
112472 + return def_stmt;
112473 +
112474 + if (lhs == CREATE_NEW_VAR)
112475 + lhs = create_new_var(dst_type);
112476 +
112477 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
112478 +
112479 + if (!gsi_end_p(*gsi)) {
112480 + location_t loc = gimple_location(gsi_stmt(*gsi));
112481 + gimple_set_location(assign, loc);
112482 + }
112483 +
112484 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
112485 +
112486 + if (before)
112487 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
112488 + else
112489 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
112490 + update_stmt(assign);
112491 + return assign;
112492 +}
112493 +
112494 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
112495 +{
112496 + gimple_stmt_iterator gsi;
112497 + tree lhs;
112498 + gimple new_stmt;
112499 +
112500 + if (rhs == NULL_TREE)
112501 + return NULL_TREE;
112502 +
112503 + gsi = gsi_for_stmt(stmt);
112504 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
112505 + gimple_set_plf(new_stmt, MY_STMT, true);
112506 +
112507 + lhs = get_lhs(new_stmt);
112508 + gcc_assert(lhs != NULL_TREE);
112509 + return lhs;
112510 +}
112511 +
112512 +static tree cast_to_TI_type(gimple stmt, tree node)
112513 +{
112514 + gimple_stmt_iterator gsi;
112515 + gimple cast_stmt;
112516 + tree type = TREE_TYPE(node);
112517 +
112518 + if (types_compatible_p(type, intTI_type_node))
112519 + return node;
112520 +
112521 + gsi = gsi_for_stmt(stmt);
112522 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112523 + gimple_set_plf(cast_stmt, MY_STMT, true);
112524 + return gimple_assign_lhs(cast_stmt);
112525 +}
112526 +
112527 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
112528 +{
112529 + tree lhs, new_lhs;
112530 + gimple_stmt_iterator gsi;
112531 +
112532 + if (rhs1 == NULL_TREE) {
112533 + debug_gimple_stmt(oldstmt);
112534 + error("%s: rhs1 is NULL_TREE", __func__);
112535 + gcc_unreachable();
112536 + }
112537 +
112538 + switch (gimple_code(oldstmt)) {
112539 + case GIMPLE_ASM:
112540 + lhs = rhs1;
112541 + break;
112542 + case GIMPLE_CALL:
112543 + case GIMPLE_ASSIGN:
112544 + lhs = gimple_get_lhs(oldstmt);
112545 + break;
112546 + default:
112547 + debug_gimple_stmt(oldstmt);
112548 + gcc_unreachable();
112549 + }
112550 +
112551 + gsi = gsi_for_stmt(oldstmt);
112552 + pointer_set_insert(visited, oldstmt);
112553 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
112554 + basic_block next_bb, cur_bb;
112555 + const_edge e;
112556 +
112557 + gcc_assert(before == false);
112558 + gcc_assert(stmt_can_throw_internal(oldstmt));
112559 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
112560 + gcc_assert(!gsi_end_p(gsi));
112561 +
112562 + cur_bb = gimple_bb(oldstmt);
112563 + next_bb = cur_bb->next_bb;
112564 + e = find_edge(cur_bb, next_bb);
112565 + gcc_assert(e != NULL);
112566 + gcc_assert(e->flags & EDGE_FALLTHRU);
112567 +
112568 + gsi = gsi_after_labels(next_bb);
112569 + gcc_assert(!gsi_end_p(gsi));
112570 +
112571 + before = true;
112572 + oldstmt = gsi_stmt(gsi);
112573 + }
112574 +
112575 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
112576 + return new_lhs;
112577 +}
112578 +
112579 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
112580 +{
112581 + gimple stmt;
112582 + gimple_stmt_iterator gsi;
112583 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
112584 +
112585 + if (gimple_plf(oldstmt, MY_STMT))
112586 + return lhs;
112587 +
112588 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
112589 + rhs1 = gimple_assign_rhs1(oldstmt);
112590 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
112591 + }
112592 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
112593 + rhs2 = gimple_assign_rhs2(oldstmt);
112594 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
112595 + }
112596 +
112597 + stmt = gimple_copy(oldstmt);
112598 + gimple_set_location(stmt, gimple_location(oldstmt));
112599 + gimple_set_plf(stmt, MY_STMT, true);
112600 +
112601 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
112602 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
112603 +
112604 + size_overflow_type = get_size_overflow_type(oldstmt, node);
112605 +
112606 + new_var = create_new_var(size_overflow_type);
112607 + new_var = make_ssa_name(new_var, stmt);
112608 + gimple_assign_set_lhs(stmt, new_var);
112609 +
112610 + if (rhs1 != NULL_TREE)
112611 + gimple_assign_set_rhs1(stmt, rhs1);
112612 +
112613 + if (rhs2 != NULL_TREE)
112614 + gimple_assign_set_rhs2(stmt, rhs2);
112615 +#if BUILDING_GCC_VERSION >= 4007
112616 + if (rhs3 != NULL_TREE)
112617 + gimple_assign_set_rhs3(stmt, rhs3);
112618 +#endif
112619 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
112620 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
112621 +
112622 + gsi = gsi_for_stmt(oldstmt);
112623 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
112624 + update_stmt(stmt);
112625 + pointer_set_insert(visited, oldstmt);
112626 + return gimple_assign_lhs(stmt);
112627 +}
112628 +
112629 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
112630 +{
112631 + gimple assign;
112632 + gimple_stmt_iterator gsi;
112633 + basic_block first_bb;
112634 +
112635 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
112636 +
112637 + if (bb->index == 0) {
112638 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
112639 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
112640 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
112641 + bb = first_bb;
112642 + }
112643 +
112644 + gsi = gsi_after_labels(bb);
112645 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
112646 + gimple_set_plf(assign, MY_STMT, true);
112647 +
112648 + return gimple_assign_lhs(assign);
112649 +}
112650 +
112651 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
112652 +{
112653 + gimple_stmt_iterator gsi;
112654 + gimple assign, def_stmt = get_def_stmt(new_arg);
112655 +
112656 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
112657 + gsi = gsi_after_labels(gimple_bb(def_stmt));
112658 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
112659 + } else {
112660 + gsi = gsi_for_stmt(def_stmt);
112661 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
112662 + }
112663 +
112664 + gimple_set_plf(assign, MY_STMT, true);
112665 + return gimple_assign_lhs(assign);
112666 +}
112667 +
112668 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
112669 +{
112670 + basic_block bb;
112671 + gimple_stmt_iterator gsi;
112672 + const_gimple def_stmt;
112673 + gimple assign;
112674 +
112675 + def_stmt = get_def_stmt(arg);
112676 + bb = gimple_bb(def_stmt);
112677 + gcc_assert(bb->index != 0);
112678 + gsi = gsi_after_labels(bb);
112679 +
112680 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
112681 + gimple_set_plf(assign, MY_STMT, true);
112682 + return gimple_assign_lhs(assign);
112683 +}
112684 +
112685 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
112686 +{
112687 + tree size_overflow_type;
112688 + tree arg;
112689 + const_gimple def_stmt;
112690 +
112691 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
112692 + return new_arg;
112693 +
112694 + arg = gimple_phi_arg_def(oldstmt, i);
112695 + def_stmt = get_def_stmt(arg);
112696 + gcc_assert(def_stmt != NULL);
112697 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
112698 +
112699 + switch (gimple_code(def_stmt)) {
112700 + case GIMPLE_PHI:
112701 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
112702 + case GIMPLE_NOP: {
112703 + basic_block bb;
112704 +
112705 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
112706 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
112707 + }
112708 + case GIMPLE_ASM: {
112709 + gimple_stmt_iterator gsi;
112710 + gimple assign, stmt = get_def_stmt(arg);
112711 +
112712 + gsi = gsi_for_stmt(stmt);
112713 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
112714 + gimple_set_plf(assign, MY_STMT, true);
112715 + return gimple_assign_lhs(assign);
112716 + }
112717 + default:
112718 + gcc_assert(new_arg != NULL_TREE);
112719 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
112720 + return use_phi_ssa_name(ssa_name_var, new_arg);
112721 + }
112722 +}
112723 +
112724 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
112725 +{
112726 + basic_block bb;
112727 + gimple phi;
112728 + gimple_seq seq;
112729 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
112730 +
112731 + bb = gsi_bb(gsi);
112732 +
112733 + if (result == NULL_TREE) {
112734 + tree old_result = gimple_phi_result(oldstmt);
112735 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
112736 +
112737 + result = create_new_var(size_overflow_type);
112738 + }
112739 +
112740 + phi = create_phi_node(result, bb);
112741 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
112742 + seq = phi_nodes(bb);
112743 + gsi = gsi_last(seq);
112744 + gsi_remove(&gsi, false);
112745 +
112746 + gsi = gsi_for_stmt(oldstmt);
112747 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
112748 + gimple_set_bb(phi, bb);
112749 + gimple_set_plf(phi, MY_STMT, true);
112750 + return phi;
112751 +}
112752 +
112753 +#if BUILDING_GCC_VERSION <= 4007
112754 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
112755 +#else
112756 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
112757 +#endif
112758 +{
112759 + gimple new_phi;
112760 + unsigned int i;
112761 + tree arg, result;
112762 + location_t loc = gimple_location(oldstmt);
112763 +
112764 +#if BUILDING_GCC_VERSION <= 4007
112765 + gcc_assert(!VEC_empty(tree, args));
112766 +#else
112767 + gcc_assert(!args->is_empty());
112768 +#endif
112769 +
112770 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
112771 + result = gimple_phi_result(new_phi);
112772 + ssa_name_var = SSA_NAME_VAR(result);
112773 +
112774 +
112775 +#if BUILDING_GCC_VERSION == 4005
112776 + for (i = 0; i < VEC_length(tree, args); i++) {
112777 + arg = VEC_index(tree, args, i);
112778 +#elif BUILDING_GCC_VERSION <= 4007
112779 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
112780 +#else
112781 + FOR_EACH_VEC_ELT(*args, i, arg) {
112782 +#endif
112783 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
112784 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
112785 + }
112786 +
112787 +#if BUILDING_GCC_VERSION <= 4007
112788 + VEC_free(tree, gc, args);
112789 +#else
112790 + vec_free(args);
112791 +#endif
112792 + update_stmt(new_phi);
112793 + return result;
112794 +}
112795 +
112796 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
112797 +{
112798 + tree ssa_name_var = NULL_TREE;
112799 +#if BUILDING_GCC_VERSION <= 4007
112800 + VEC(tree, gc) *args;
112801 +#else
112802 + vec<tree, va_gc> *args;
112803 +#endif
112804 + gimple oldstmt = get_def_stmt(orig_result);
112805 + unsigned int i, len = gimple_phi_num_args(oldstmt);
112806 +
112807 + pointer_set_insert(visited, oldstmt);
112808 +#if BUILDING_GCC_VERSION <= 4007
112809 + args = VEC_alloc(tree, gc, len);
112810 +#else
112811 + vec_alloc(args, len);
112812 +#endif
112813 + for (i = 0; i < len; i++) {
112814 + tree arg, new_arg;
112815 +
112816 + arg = gimple_phi_arg_def(oldstmt, i);
112817 + new_arg = expand(visited, caller_node, arg);
112818 +
112819 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
112820 + ssa_name_var = SSA_NAME_VAR(new_arg);
112821 +
112822 + if (is_gimple_constant(arg)) {
112823 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
112824 +
112825 + new_arg = cast_a_tree(size_overflow_type, arg);
112826 + }
112827 +
112828 +#if BUILDING_GCC_VERSION <= 4007
112829 + VEC_safe_push(tree, gc, args, new_arg);
112830 +#else
112831 + vec_safe_push(args, new_arg);
112832 +#endif
112833 + }
112834 +
112835 + return create_new_phi_node(args, ssa_name_var, oldstmt);
112836 +}
112837 +
112838 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
112839 +{
112840 + gimple assign;
112841 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112842 + tree origtype = TREE_TYPE(orig_rhs);
112843 +
112844 + gcc_assert(is_gimple_assign(stmt));
112845 +
112846 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112847 + gimple_set_plf(assign, MY_STMT, true);
112848 + return gimple_assign_lhs(assign);
112849 +}
112850 +
112851 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
112852 +{
112853 + const_tree rhs1, lhs, rhs1_type, lhs_type;
112854 + enum machine_mode lhs_mode, rhs_mode;
112855 + gimple def_stmt = get_def_stmt(no_const_rhs);
112856 +
112857 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112858 + return false;
112859 +
112860 + rhs1 = gimple_assign_rhs1(def_stmt);
112861 + lhs = gimple_assign_lhs(def_stmt);
112862 + rhs1_type = TREE_TYPE(rhs1);
112863 + lhs_type = TREE_TYPE(lhs);
112864 + rhs_mode = TYPE_MODE(rhs1_type);
112865 + lhs_mode = TYPE_MODE(lhs_type);
112866 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
112867 + return false;
112868 +
112869 + return true;
112870 +}
112871 +
112872 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
112873 +{
112874 + tree rhs1 = gimple_assign_rhs1(stmt);
112875 + tree lhs = gimple_assign_lhs(stmt);
112876 + const_tree rhs1_type = TREE_TYPE(rhs1);
112877 + const_tree lhs_type = TREE_TYPE(lhs);
112878 +
112879 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
112880 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112881 +
112882 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
112883 +}
112884 +
112885 +static bool no_uses(tree node)
112886 +{
112887 + imm_use_iterator imm_iter;
112888 + use_operand_p use_p;
112889 +
112890 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112891 + const_gimple use_stmt = USE_STMT(use_p);
112892 +
112893 + if (use_stmt == NULL)
112894 + return true;
112895 + if (is_gimple_debug(use_stmt))
112896 + continue;
112897 + return false;
112898 + }
112899 + return true;
112900 +}
112901 +
112902 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
112903 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
112904 +{
112905 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
112906 + gimple def_stmt = get_def_stmt(lhs);
112907 +
112908 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112909 + return false;
112910 +
112911 + rhs1 = gimple_assign_rhs1(def_stmt);
112912 + rhs_type = TREE_TYPE(rhs1);
112913 + lhs_type = TREE_TYPE(lhs);
112914 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
112915 + return false;
112916 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
112917 + return false;
112918 +
112919 + def_stmt = get_def_stmt(rhs1);
112920 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
112921 + return false;
112922 +
112923 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
112924 + return false;
112925 +
112926 + rhs1 = gimple_assign_rhs1(def_stmt);
112927 + rhs2 = gimple_assign_rhs2(def_stmt);
112928 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
112929 + return false;
112930 +
112931 + if (is_gimple_constant(rhs2))
112932 + not_const_rhs = rhs1;
112933 + else
112934 + not_const_rhs = rhs2;
112935 +
112936 + return no_uses(not_const_rhs);
112937 +}
112938 +
112939 +static bool skip_lhs_cast_check(const_gimple stmt)
112940 +{
112941 + const_tree rhs = gimple_assign_rhs1(stmt);
112942 + const_gimple def_stmt = get_def_stmt(rhs);
112943 +
112944 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
112945 + if (gimple_code(def_stmt) == GIMPLE_ASM)
112946 + return true;
112947 +
112948 + if (is_const_plus_unsigned_signed_truncation(rhs))
112949 + return true;
112950 +
112951 + return false;
112952 +}
112953 +
112954 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
112955 +{
112956 + bool cast_lhs, cast_rhs;
112957 + tree lhs = gimple_assign_lhs(stmt);
112958 + tree rhs = gimple_assign_rhs1(stmt);
112959 + const_tree lhs_type = TREE_TYPE(lhs);
112960 + const_tree rhs_type = TREE_TYPE(rhs);
112961 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
112962 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
112963 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
112964 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
112965 +
112966 + static bool check_lhs[3][4] = {
112967 + // ss su us uu
112968 + { false, true, true, false }, // lhs > rhs
112969 + { false, false, false, false }, // lhs = rhs
112970 + { true, true, true, true }, // lhs < rhs
112971 + };
112972 +
112973 + static bool check_rhs[3][4] = {
112974 + // ss su us uu
112975 + { true, false, true, true }, // lhs > rhs
112976 + { true, false, true, true }, // lhs = rhs
112977 + { true, false, true, true }, // lhs < rhs
112978 + };
112979 +
112980 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
112981 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
112982 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112983 +
112984 + if (lhs_size > rhs_size) {
112985 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112986 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112987 + } else if (lhs_size == rhs_size) {
112988 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112989 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112990 + } else {
112991 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112992 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112993 + }
112994 +
112995 + if (!cast_lhs && !cast_rhs)
112996 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112997 +
112998 + if (cast_lhs && !skip_lhs_cast_check(stmt))
112999 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
113000 +
113001 + if (cast_rhs)
113002 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
113003 +
113004 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
113005 +}
113006 +
113007 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
113008 +{
113009 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
113010 +
113011 + if (gimple_plf(stmt, MY_STMT))
113012 + return lhs;
113013 +
113014 + rhs1 = gimple_assign_rhs1(stmt);
113015 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
113016 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113017 +
113018 + new_rhs1 = expand(visited, caller_node, rhs1);
113019 +
113020 + if (new_rhs1 == NULL_TREE)
113021 + return create_cast_assign(visited, stmt);
113022 +
113023 + if (gimple_plf(stmt, NO_CAST_CHECK))
113024 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
113025 +
113026 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
113027 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
113028 +
113029 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
113030 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
113031 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113032 + }
113033 +
113034 + if (!gimple_assign_cast_p(stmt))
113035 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
113036 +
113037 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
113038 +}
113039 +
113040 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
113041 +{
113042 + tree rhs1, lhs = gimple_assign_lhs(stmt);
113043 + gimple def_stmt = get_def_stmt(lhs);
113044 +
113045 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
113046 + rhs1 = gimple_assign_rhs1(def_stmt);
113047 +
113048 + if (is_gimple_constant(rhs1))
113049 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
113050 +
113051 + switch (TREE_CODE(rhs1)) {
113052 + case SSA_NAME:
113053 + return handle_unary_rhs(visited, caller_node, def_stmt);
113054 + case ARRAY_REF:
113055 + case BIT_FIELD_REF:
113056 + case ADDR_EXPR:
113057 + case COMPONENT_REF:
113058 + case INDIRECT_REF:
113059 +#if BUILDING_GCC_VERSION >= 4006
113060 + case MEM_REF:
113061 +#endif
113062 + case TARGET_MEM_REF:
113063 + case VIEW_CONVERT_EXPR:
113064 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
113065 + case PARM_DECL:
113066 + case VAR_DECL:
113067 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113068 +
113069 + default:
113070 + debug_gimple_stmt(def_stmt);
113071 + debug_tree(rhs1);
113072 + gcc_unreachable();
113073 + }
113074 +}
113075 +
113076 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
113077 +{
113078 + gimple cond_stmt;
113079 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
113080 +
113081 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
113082 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
113083 + update_stmt(cond_stmt);
113084 +}
113085 +
113086 +static tree create_string_param(tree string)
113087 +{
113088 + tree i_type, a_type;
113089 + const int length = TREE_STRING_LENGTH(string);
113090 +
113091 + gcc_assert(length > 0);
113092 +
113093 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
113094 + a_type = build_array_type(char_type_node, i_type);
113095 +
113096 + TREE_TYPE(string) = a_type;
113097 + TREE_CONSTANT(string) = 1;
113098 + TREE_READONLY(string) = 1;
113099 +
113100 + return build1(ADDR_EXPR, ptr_type_node, string);
113101 +}
113102 +
113103 +#if BUILDING_GCC_VERSION <= 4006
113104 +struct cgraph_node *cgraph_get_create_node(tree decl);
113105 +
113106 +struct cgraph_node *cgraph_get_create_node(tree decl)
113107 +{
113108 + struct cgraph_node *node;
113109 +
113110 + node = cgraph_get_node(decl);
113111 + if (node)
113112 + return node;
113113 + return cgraph_node(decl);
113114 +}
113115 +#endif
113116 +
113117 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
113118 +{
113119 + gimple func_stmt;
113120 + const_gimple def_stmt;
113121 + const_tree loc_line;
113122 + tree loc_file, ssa_name, current_func;
113123 + expanded_location xloc;
113124 + char *ssa_name_buf;
113125 + int len;
113126 + struct cgraph_edge *edge;
113127 + struct cgraph_node *callee_node;
113128 + int frequency;
113129 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
113130 +
113131 + def_stmt = get_def_stmt(arg);
113132 + xloc = expand_location(gimple_location(def_stmt));
113133 +
113134 + if (!gimple_has_location(def_stmt)) {
113135 + xloc = expand_location(gimple_location(stmt));
113136 + if (!gimple_has_location(stmt))
113137 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
113138 + }
113139 +
113140 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
113141 +
113142 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
113143 + loc_file = create_string_param(loc_file);
113144 +
113145 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
113146 + current_func = create_string_param(current_func);
113147 +
113148 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
113149 + call_count++;
113150 + 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);
113151 + gcc_assert(len > 0);
113152 + ssa_name = build_string(len + 1, ssa_name_buf);
113153 + free(ssa_name_buf);
113154 + ssa_name = create_string_param(ssa_name);
113155 +
113156 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
113157 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
113158 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
113159 +
113160 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
113161 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
113162 +
113163 +#if BUILDING_GCC_VERSION <= 4006
113164 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
113165 +#else
113166 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
113167 +#endif
113168 + gcc_assert(edge != NULL);
113169 +}
113170 +
113171 +static void __unused print_the_code_insertions(const_gimple stmt)
113172 +{
113173 + location_t loc = gimple_location(stmt);
113174 +
113175 + inform(loc, "Integer size_overflow check applied here.");
113176 +}
113177 +
113178 +static void insert_check_size_overflow(struct cgraph_node *caller_node, gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
113179 +{
113180 + basic_block cond_bb, join_bb, bb_true;
113181 + edge e;
113182 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
113183 +
113184 + cond_bb = gimple_bb(stmt);
113185 + if (before)
113186 + gsi_prev(&gsi);
113187 + if (gsi_end_p(gsi))
113188 + e = split_block_after_labels(cond_bb);
113189 + else
113190 + e = split_block(cond_bb, gsi_stmt(gsi));
113191 + cond_bb = e->src;
113192 + join_bb = e->dest;
113193 + e->flags = EDGE_FALSE_VALUE;
113194 + e->probability = REG_BR_PROB_BASE;
113195 +
113196 + bb_true = create_empty_bb(cond_bb);
113197 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
113198 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
113199 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
113200 +
113201 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
113202 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
113203 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
113204 +
113205 + if (current_loops != NULL) {
113206 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
113207 + add_bb_to_loop(bb_true, cond_bb->loop_father);
113208 + }
113209 +
113210 + insert_cond(cond_bb, arg, cond_code, type_value);
113211 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
113212 +
113213 +// print_the_code_insertions(stmt);
113214 +}
113215 +
113216 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
113217 +{
113218 + const_tree rhs_type = TREE_TYPE(rhs);
113219 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
113220 +
113221 + gcc_assert(rhs_type != NULL_TREE);
113222 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
113223 + return;
113224 +
113225 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
113226 +
113227 + if (is_const_plus_unsigned_signed_truncation(rhs))
113228 + return;
113229 +
113230 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
113231 + // typemax (-1) < typemin (0)
113232 + if (TREE_OVERFLOW(type_max))
113233 + return;
113234 +
113235 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
113236 +
113237 + cast_rhs_type = TREE_TYPE(cast_rhs);
113238 + type_max_type = TREE_TYPE(type_max);
113239 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
113240 +
113241 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
113242 +
113243 + // special case: get_size_overflow_type(), 32, u64->s
113244 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode) && TYPE_UNSIGNED(size_overflow_type) && !TYPE_UNSIGNED(rhs_type))
113245 + return;
113246 +
113247 + type_min_type = TREE_TYPE(type_min);
113248 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
113249 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
113250 +}
113251 +
113252 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
113253 +{
113254 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
113255 + return false;
113256 + if (!is_gimple_constant(rhs))
113257 + return false;
113258 + return true;
113259 +}
113260 +
113261 +static tree get_def_stmt_rhs(const_tree var)
113262 +{
113263 + tree rhs1, def_stmt_rhs1;
113264 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
113265 +
113266 + def_stmt = get_def_stmt(var);
113267 + if (!gimple_assign_cast_p(def_stmt))
113268 + return NULL_TREE;
113269 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
113270 +
113271 + rhs1 = gimple_assign_rhs1(def_stmt);
113272 + rhs1_def_stmt = get_def_stmt(rhs1);
113273 + if (!gimple_assign_cast_p(rhs1_def_stmt))
113274 + return rhs1;
113275 +
113276 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
113277 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
113278 +
113279 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
113280 + case GIMPLE_CALL:
113281 + case GIMPLE_NOP:
113282 + case GIMPLE_ASM:
113283 + case GIMPLE_PHI:
113284 + return def_stmt_rhs1;
113285 + case GIMPLE_ASSIGN:
113286 + return rhs1;
113287 + default:
113288 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
113289 + gcc_unreachable();
113290 + }
113291 +}
113292 +
113293 +static tree handle_intentional_overflow(struct pointer_set_t *visited, struct cgraph_node *caller_node, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
113294 +{
113295 + tree new_rhs, orig_rhs;
113296 + void (*gimple_assign_set_rhs)(gimple, tree);
113297 + tree rhs1 = gimple_assign_rhs1(stmt);
113298 + tree rhs2 = gimple_assign_rhs2(stmt);
113299 + tree lhs = gimple_assign_lhs(stmt);
113300 +
113301 + if (!check_overflow)
113302 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113303 +
113304 + if (change_rhs == NULL_TREE)
113305 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113306 +
113307 + if (new_rhs2 == NULL_TREE) {
113308 + orig_rhs = rhs1;
113309 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
113310 + } else {
113311 + orig_rhs = rhs2;
113312 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
113313 + }
113314 +
113315 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
113316 +
113317 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
113318 + gimple_assign_set_rhs(stmt, new_rhs);
113319 + update_stmt(stmt);
113320 +
113321 + return create_assign(visited, stmt, lhs, AFTER_STMT);
113322 +}
113323 +
113324 +static bool is_subtraction_special(const_gimple stmt)
113325 +{
113326 + gimple rhs1_def_stmt, rhs2_def_stmt;
113327 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
113328 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
113329 + const_tree rhs1 = gimple_assign_rhs1(stmt);
113330 + const_tree rhs2 = gimple_assign_rhs2(stmt);
113331 +
113332 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
113333 + return false;
113334 +
113335 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
113336 +
113337 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
113338 + return false;
113339 +
113340 + rhs1_def_stmt = get_def_stmt(rhs1);
113341 + rhs2_def_stmt = get_def_stmt(rhs2);
113342 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
113343 + return false;
113344 +
113345 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
113346 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
113347 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
113348 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
113349 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
113350 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
113351 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
113352 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
113353 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
113354 + return false;
113355 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
113356 + return false;
113357 +
113358 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
113359 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
113360 + return true;
113361 +}
113362 +
113363 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
113364 +{
113365 + tree new_rhs1, new_rhs2;
113366 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
113367 + gimple assign, stmt = get_def_stmt(lhs);
113368 + tree rhs1 = gimple_assign_rhs1(stmt);
113369 + tree rhs2 = gimple_assign_rhs2(stmt);
113370 +
113371 + if (!is_subtraction_special(stmt))
113372 + return NULL_TREE;
113373 +
113374 + new_rhs1 = expand(visited, caller_node, rhs1);
113375 + new_rhs2 = expand(visited, caller_node, rhs2);
113376 +
113377 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
113378 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
113379 +
113380 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
113381 + return NULL_TREE;
113382 +
113383 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
113384 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
113385 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
113386 + }
113387 +
113388 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
113389 + new_lhs = gimple_assign_lhs(assign);
113390 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
113391 +
113392 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
113393 +}
113394 +
113395 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
113396 +{
113397 + const_gimple def_stmt;
113398 +
113399 + if (TREE_CODE(rhs) != SSA_NAME)
113400 + return false;
113401 +
113402 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
113403 + return false;
113404 +
113405 + def_stmt = get_def_stmt(rhs);
113406 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
113407 + return false;
113408 +
113409 + return true;
113410 +}
113411 +
113412 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
113413 +{
113414 + tree rhs1, rhs2, new_lhs;
113415 + gimple def_stmt = get_def_stmt(lhs);
113416 + tree new_rhs1 = NULL_TREE;
113417 + tree new_rhs2 = NULL_TREE;
113418 +
113419 + rhs1 = gimple_assign_rhs1(def_stmt);
113420 + rhs2 = gimple_assign_rhs2(def_stmt);
113421 +
113422 + /* no DImode/TImode division in the 32/64 bit kernel */
113423 + switch (gimple_assign_rhs_code(def_stmt)) {
113424 + case RDIV_EXPR:
113425 + case TRUNC_DIV_EXPR:
113426 + case CEIL_DIV_EXPR:
113427 + case FLOOR_DIV_EXPR:
113428 + case ROUND_DIV_EXPR:
113429 + case TRUNC_MOD_EXPR:
113430 + case CEIL_MOD_EXPR:
113431 + case FLOOR_MOD_EXPR:
113432 + case ROUND_MOD_EXPR:
113433 + case EXACT_DIV_EXPR:
113434 + case POINTER_PLUS_EXPR:
113435 + case BIT_AND_EXPR:
113436 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
113437 + default:
113438 + break;
113439 + }
113440 +
113441 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
113442 + if (new_lhs != NULL_TREE)
113443 + return new_lhs;
113444 +
113445 + if (TREE_CODE(rhs1) == SSA_NAME)
113446 + new_rhs1 = expand(visited, caller_node, rhs1);
113447 + if (TREE_CODE(rhs2) == SSA_NAME)
113448 + new_rhs2 = expand(visited, caller_node, rhs2);
113449 +
113450 + if (is_a_neg_overflow(def_stmt, rhs2))
113451 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
113452 + if (is_a_neg_overflow(def_stmt, rhs1))
113453 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
113454 +
113455 +
113456 + if (is_a_constant_overflow(def_stmt, rhs2))
113457 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
113458 + if (is_a_constant_overflow(def_stmt, rhs1))
113459 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
113460 +
113461 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
113462 +}
113463 +
113464 +#if BUILDING_GCC_VERSION >= 4007
113465 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
113466 +{
113467 + if (is_gimple_constant(rhs))
113468 + return cast_a_tree(size_overflow_type, rhs);
113469 + if (TREE_CODE(rhs) != SSA_NAME)
113470 + return NULL_TREE;
113471 + return expand(visited, caller_node, rhs);
113472 +}
113473 +
113474 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
113475 +{
113476 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
113477 + gimple def_stmt = get_def_stmt(lhs);
113478 +
113479 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
113480 +
113481 + rhs1 = gimple_assign_rhs1(def_stmt);
113482 + rhs2 = gimple_assign_rhs2(def_stmt);
113483 + rhs3 = gimple_assign_rhs3(def_stmt);
113484 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
113485 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
113486 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
113487 +
113488 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
113489 +}
113490 +#endif
113491 +
113492 +static tree get_size_overflow_type(gimple stmt, const_tree node)
113493 +{
113494 + const_tree type;
113495 + tree new_type;
113496 +
113497 + gcc_assert(node != NULL_TREE);
113498 +
113499 + type = TREE_TYPE(node);
113500 +
113501 + if (gimple_plf(stmt, MY_STMT))
113502 + return TREE_TYPE(node);
113503 +
113504 + switch (TYPE_MODE(type)) {
113505 + case QImode:
113506 + new_type = intHI_type_node;
113507 + break;
113508 + case HImode:
113509 + new_type = intSI_type_node;
113510 + break;
113511 + case SImode:
113512 + new_type = intDI_type_node;
113513 + break;
113514 + case DImode:
113515 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
113516 + new_type = TYPE_UNSIGNED(type) ? unsigned_intDI_type_node : intDI_type_node;
113517 + else
113518 + new_type = intTI_type_node;
113519 + break;
113520 + case TImode:
113521 + gcc_assert(!TYPE_UNSIGNED(type));
113522 + new_type = intTI_type_node;
113523 + break;
113524 + default:
113525 + debug_tree((tree)node);
113526 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
113527 + gcc_unreachable();
113528 + }
113529 +
113530 + if (TYPE_QUALS(type) != 0)
113531 + return build_qualified_type(new_type, TYPE_QUALS(type));
113532 + return new_type;
113533 +}
113534 +
113535 +static tree expand_visited(gimple def_stmt)
113536 +{
113537 + const_gimple next_stmt;
113538 + gimple_stmt_iterator gsi;
113539 + enum gimple_code code = gimple_code(def_stmt);
113540 +
113541 + if (code == GIMPLE_ASM)
113542 + return NULL_TREE;
113543 +
113544 + gsi = gsi_for_stmt(def_stmt);
113545 + gsi_next(&gsi);
113546 +
113547 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
113548 + return NULL_TREE;
113549 + gcc_assert(!gsi_end_p(gsi));
113550 + next_stmt = gsi_stmt(gsi);
113551 +
113552 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
113553 + return NULL_TREE;
113554 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
113555 +
113556 + return get_lhs(next_stmt);
113557 +}
113558 +
113559 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
113560 +{
113561 + gimple def_stmt;
113562 +
113563 + def_stmt = get_def_stmt(lhs);
113564 +
113565 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
113566 + return NULL_TREE;
113567 +
113568 + if (gimple_plf(def_stmt, MY_STMT))
113569 + return lhs;
113570 +
113571 + if (pointer_set_contains(visited, def_stmt))
113572 + return expand_visited(def_stmt);
113573 +
113574 + switch (gimple_code(def_stmt)) {
113575 + case GIMPLE_PHI:
113576 + return handle_phi(visited, caller_node, lhs);
113577 + case GIMPLE_CALL:
113578 + case GIMPLE_ASM:
113579 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
113580 + case GIMPLE_ASSIGN:
113581 + switch (gimple_num_ops(def_stmt)) {
113582 + case 2:
113583 + return handle_unary_ops(visited, caller_node, def_stmt);
113584 + case 3:
113585 + return handle_binary_ops(visited, caller_node, lhs);
113586 +#if BUILDING_GCC_VERSION >= 4007
113587 + case 4:
113588 + return handle_ternary_ops(visited, caller_node, lhs);
113589 +#endif
113590 + }
113591 + default:
113592 + debug_gimple_stmt(def_stmt);
113593 + error("%s: unknown gimple code", __func__);
113594 + gcc_unreachable();
113595 + }
113596 +}
113597 +
113598 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
113599 +{
113600 + const_gimple assign;
113601 + tree orig_type = TREE_TYPE(orig_node);
113602 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
113603 +
113604 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
113605 + return gimple_assign_lhs(assign);
113606 +}
113607 +
113608 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
113609 +{
113610 + void (*set_rhs)(gimple, tree);
113611 + gimple stmt = cur_node->first_stmt;
113612 + const_tree orig_node = cur_node->node;
113613 +
113614 + switch (gimple_code(stmt)) {
113615 + case GIMPLE_RETURN:
113616 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
113617 + break;
113618 + case GIMPLE_CALL:
113619 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
113620 + break;
113621 + case GIMPLE_ASSIGN:
113622 + switch (cur_node->num) {
113623 + case 1:
113624 + set_rhs = &gimple_assign_set_rhs1;
113625 + break;
113626 + case 2:
113627 + set_rhs = &gimple_assign_set_rhs2;
113628 + break;
113629 +#if BUILDING_GCC_VERSION > 4005
113630 + case 3:
113631 + set_rhs = &gimple_assign_set_rhs3;
113632 + break;
113633 +#endif
113634 + default:
113635 + gcc_unreachable();
113636 + }
113637 +
113638 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
113639 + break;
113640 + default:
113641 + debug_gimple_stmt(stmt);
113642 + gcc_unreachable();
113643 + }
113644 +
113645 + update_stmt(stmt);
113646 +}
113647 +
113648 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
113649 +{
113650 + const struct size_overflow_hash *hash;
113651 + unsigned int new_argnum;
113652 + tree arg;
113653 + const_tree origarg;
113654 +
113655 + if (argnum == 0)
113656 + return argnum;
113657 +
113658 + hash = get_function_hash(fndecl);
113659 + if (hash && hash->param & (1U << argnum))
113660 + return argnum;
113661 +
113662 + if (DECL_EXTERNAL(fndecl))
113663 + return argnum;
113664 +
113665 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
113666 + argnum--;
113667 + while (origarg && argnum) {
113668 + origarg = TREE_CHAIN(origarg);
113669 + argnum--;
113670 + }
113671 + gcc_assert(argnum == 0);
113672 + gcc_assert(origarg != NULL_TREE);
113673 +
113674 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
113675 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
113676 + return new_argnum;
113677 +
113678 + return CANNOT_FIND_ARG;
113679 +}
113680 +
113681 +// Don't want to duplicate entries in next_cgraph_node
113682 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
113683 +{
113684 + const_tree new_callee_fndecl;
113685 + struct next_cgraph_node *cur_node;
113686 +
113687 + if (fndecl == RET_CHECK)
113688 +#if BUILDING_GCC_VERSION <= 4007
113689 + new_callee_fndecl = node->decl;
113690 +#else
113691 + new_callee_fndecl = node->symbol.decl;
113692 +#endif
113693 + else
113694 + new_callee_fndecl = fndecl;
113695 +
113696 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
113697 +#if BUILDING_GCC_VERSION <= 4007
113698 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
113699 +#else
113700 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
113701 +#endif
113702 + continue;
113703 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
113704 + continue;
113705 + if (num == cur_node->num)
113706 + return true;
113707 + }
113708 + return false;
113709 +}
113710 +
113711 +/* Add a next_cgraph_node into the list for handle_function().
113712 + * handle_function() iterates over all the next cgraph nodes and
113713 + * starts the overflow check insertion process.
113714 + */
113715 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
113716 +{
113717 + struct next_cgraph_node *new_node;
113718 +
113719 + if (is_in_next_cgraph_node(head, node, fndecl, num))
113720 + return head;
113721 +
113722 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
113723 + new_node->current_function = node;
113724 + new_node->next = NULL;
113725 + new_node->num = num;
113726 + if (fndecl == RET_CHECK)
113727 +#if BUILDING_GCC_VERSION <= 4007
113728 + new_node->callee_fndecl = node->decl;
113729 +#else
113730 + new_node->callee_fndecl = node->symbol.decl;
113731 +#endif
113732 + else
113733 + new_node->callee_fndecl = fndecl;
113734 +
113735 + if (!head)
113736 + return new_node;
113737 +
113738 + new_node->next = head;
113739 + return new_node;
113740 +}
113741 +
113742 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
113743 +{
113744 + struct cgraph_edge *e;
113745 +
113746 + if (num == 0)
113747 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
113748 +
113749 + for (e = node->callers; e; e = e->next_caller) {
113750 + tree fndecl = gimple_call_fndecl(e->call_stmt);
113751 +
113752 + gcc_assert(fndecl != NULL_TREE);
113753 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
113754 + }
113755 +
113756 + return head;
113757 +}
113758 +
113759 +static bool is_a_return_check(const_tree node)
113760 +{
113761 + if (TREE_CODE(node) == FUNCTION_DECL)
113762 + return true;
113763 +
113764 + gcc_assert(TREE_CODE(node) == PARM_DECL);
113765 + return false;
113766 +}
113767 +
113768 +static bool is_in_hash_table(tree fndecl, unsigned int num)
113769 +{
113770 + const struct size_overflow_hash *hash;
113771 +
113772 + hash = get_function_hash(fndecl);
113773 + if (hash && (hash->param & (1U << num)))
113774 + return true;
113775 + return false;
113776 +}
113777 +
113778 +struct missing_functions {
113779 + struct missing_functions *next;
113780 + const_tree node;
113781 + tree fndecl;
113782 +};
113783 +
113784 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
113785 +{
113786 + struct missing_functions *new_function;
113787 +
113788 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
113789 + new_function->node = node;
113790 + new_function->next = NULL;
113791 +
113792 + if (TREE_CODE(node) == FUNCTION_DECL)
113793 + new_function->fndecl = node;
113794 + else
113795 + new_function->fndecl = current_function_decl;
113796 + gcc_assert(new_function->fndecl);
113797 +
113798 + if (!missing_fn_head)
113799 + return new_function;
113800 +
113801 + new_function->next = missing_fn_head;
113802 + return new_function;
113803 +}
113804 +
113805 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
113806 + * If the function is missing everywhere then print the missing message into stderr.
113807 + */
113808 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
113809 +{
113810 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
113811 +#if BUILDING_GCC_VERSION >= 4008
113812 + case BUILT_IN_BSWAP16:
113813 +#endif
113814 + case BUILT_IN_BSWAP32:
113815 + case BUILT_IN_BSWAP64:
113816 + case BUILT_IN_EXPECT:
113817 + case BUILT_IN_MEMCMP:
113818 + return false;
113819 + default:
113820 + break;
113821 + }
113822 +
113823 + // skip test.c
113824 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
113825 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
113826 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
113827 + }
113828 +
113829 + if (is_in_hash_table(orig_fndecl, num))
113830 + return false;
113831 +
113832 + print_missing_msg(orig_fndecl, num);
113833 + return true;
113834 +}
113835 +
113836 +// Get the argnum of a function decl, if node is a return then the argnum is 0
113837 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
113838 +{
113839 + if (is_a_return_check(node))
113840 + return 0;
113841 + else
113842 + return find_arg_number_tree(node, orig_fndecl);
113843 +}
113844 +
113845 +/* If the function is missing from the hash table and it is a static function
113846 + * then create a next_cgraph_node from it for handle_function()
113847 + */
113848 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
113849 +{
113850 + unsigned int num;
113851 + tree orig_fndecl;
113852 + struct cgraph_node *next_node = NULL;
113853 +
113854 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
113855 +
113856 + num = get_function_num(missing_fn_head->node, orig_fndecl);
113857 + if (num == CANNOT_FIND_ARG)
113858 + return cnodes;
113859 +
113860 + if (!is_missing_function(orig_fndecl, num))
113861 + return cnodes;
113862 +
113863 + next_node = cgraph_get_node(missing_fn_head->fndecl);
113864 + if (next_node && next_node->local.local)
113865 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
113866 + return cnodes;
113867 +}
113868 +
113869 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
113870 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
113871 + */
113872 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
113873 +{
113874 + unsigned int i;
113875 + tree node;
113876 + struct missing_functions *cur, *missing_fn_head = NULL;
113877 +
113878 +#if BUILDING_GCC_VERSION == 4005
113879 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113880 + node = VEC_index(tree, cur_node->last_nodes, i);
113881 +#elif BUILDING_GCC_VERSION <= 4007
113882 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
113883 +#else
113884 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
113885 +#endif
113886 + switch (TREE_CODE(node)) {
113887 + case PARM_DECL:
113888 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
113889 + break;
113890 + case FUNCTION_DECL:
113891 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
113892 + break;
113893 + default:
113894 + break;
113895 + }
113896 + }
113897 +
113898 + while (missing_fn_head) {
113899 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
113900 +
113901 + cur = missing_fn_head->next;
113902 + free(missing_fn_head);
113903 + missing_fn_head = cur;
113904 + }
113905 +
113906 + return cnodes;
113907 +}
113908 +
113909 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
113910 +{
113911 + gimple phi = get_def_stmt(result);
113912 + unsigned int i, n = gimple_phi_num_args(phi);
113913 +
113914 + pointer_set_insert(visited, phi);
113915 + for (i = 0; i < n; i++) {
113916 + const_tree arg = gimple_phi_arg_def(phi, i);
113917 +
113918 + set_conditions(visited, interesting_conditions, arg);
113919 + }
113920 +}
113921 +
113922 +enum conditions {
113923 + FROM_CONST, NOT_UNARY, CAST
113924 +};
113925 +
113926 +// Search for constants, cast assignments and binary/ternary assignments
113927 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
113928 +{
113929 + gimple def_stmt = get_def_stmt(lhs);
113930 +
113931 + if (is_gimple_constant(lhs)) {
113932 + interesting_conditions[FROM_CONST] = true;
113933 + return;
113934 + }
113935 +
113936 + if (!def_stmt)
113937 + return;
113938 +
113939 + if (pointer_set_contains(visited, def_stmt))
113940 + return;
113941 +
113942 + switch (gimple_code(def_stmt)) {
113943 + case GIMPLE_NOP:
113944 + case GIMPLE_CALL:
113945 + case GIMPLE_ASM:
113946 + return;
113947 + case GIMPLE_PHI:
113948 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
113949 + case GIMPLE_ASSIGN:
113950 + if (gimple_num_ops(def_stmt) == 2) {
113951 + const_tree rhs = gimple_assign_rhs1(def_stmt);
113952 +
113953 + if (gimple_assign_cast_p(def_stmt))
113954 + interesting_conditions[CAST] = true;
113955 +
113956 + return set_conditions(visited, interesting_conditions, rhs);
113957 + } else {
113958 + interesting_conditions[NOT_UNARY] = true;
113959 + return;
113960 + }
113961 + default:
113962 + debug_gimple_stmt(def_stmt);
113963 + gcc_unreachable();
113964 + }
113965 +}
113966 +
113967 +// determine whether duplication will be necessary or not.
113968 +static void search_interesting_conditions(struct interesting_node *cur_node, bool *interesting_conditions)
113969 +{
113970 + struct pointer_set_t *visited;
113971 +
113972 + if (gimple_assign_cast_p(cur_node->first_stmt))
113973 + interesting_conditions[CAST] = true;
113974 + else if (is_gimple_assign(cur_node->first_stmt) && gimple_num_ops(cur_node->first_stmt) > 2)
113975 + interesting_conditions[NOT_UNARY] = true;
113976 +
113977 + visited = pointer_set_create();
113978 + set_conditions(visited, interesting_conditions, cur_node->node);
113979 + pointer_set_destroy(visited);
113980 +}
113981 +
113982 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
113983 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
113984 +{
113985 + gimple assign;
113986 + gimple_stmt_iterator gsi;
113987 +
113988 + // already removed
113989 + if (gimple_bb(asm_stmt) == NULL)
113990 + return;
113991 + gsi = gsi_for_stmt(asm_stmt);
113992 +
113993 + assign = gimple_build_assign(lhs, rhs);
113994 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
113995 + SSA_NAME_DEF_STMT(lhs) = assign;
113996 +
113997 + gsi_remove(&gsi, true);
113998 +}
113999 +
114000 +// Get the field decl of a component ref for intentional_overflow checking
114001 +static const_tree search_field_decl(const_tree comp_ref)
114002 +{
114003 + const_tree field = NULL_TREE;
114004 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
114005 +
114006 + for (i = 0; i < len; i++) {
114007 + field = TREE_OPERAND(comp_ref, i);
114008 + if (TREE_CODE(field) == FIELD_DECL)
114009 + break;
114010 + }
114011 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
114012 + return field;
114013 +}
114014 +
114015 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
114016 + * stmt is a return otherwise it is the callee function.
114017 + */
114018 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
114019 +{
114020 + const_tree fndecl;
114021 +
114022 + if (argnum == 0)
114023 + fndecl = current_function_decl;
114024 + else
114025 + fndecl = gimple_call_fndecl(stmt);
114026 +
114027 + if (fndecl == NULL_TREE)
114028 + return NULL_TREE;
114029 +
114030 + return DECL_ORIGIN(fndecl);
114031 +}
114032 +
114033 +/* Get the param of the intentional_overflow attribute.
114034 + * * 0: MARK_NOT_INTENTIONAL
114035 + * * 1..MAX_PARAM: MARK_YES
114036 + * * -1: MARK_TURN_OFF
114037 + */
114038 +static tree get_attribute_param(const_tree decl)
114039 +{
114040 + const_tree attr;
114041 +
114042 + if (decl == NULL_TREE)
114043 + return NULL_TREE;
114044 +
114045 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
114046 + if (!attr || !TREE_VALUE(attr))
114047 + return NULL_TREE;
114048 +
114049 + return TREE_VALUE(attr);
114050 +}
114051 +
114052 +// MARK_TURN_OFF
114053 +static bool is_turn_off_intentional_attr(const_tree decl)
114054 +{
114055 + const_tree param_head;
114056 +
114057 + param_head = get_attribute_param(decl);
114058 + if (param_head == NULL_TREE)
114059 + return false;
114060 +
114061 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
114062 + return true;
114063 + return false;
114064 +}
114065 +
114066 +// MARK_NOT_INTENTIONAL
114067 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
114068 +{
114069 + const_tree param_head;
114070 +
114071 + if (argnum == 0)
114072 + return false;
114073 +
114074 + param_head = get_attribute_param(decl);
114075 + if (param_head == NULL_TREE)
114076 + return false;
114077 +
114078 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
114079 + return true;
114080 + return false;
114081 +}
114082 +
114083 +// MARK_YES
114084 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
114085 +{
114086 + tree param, param_head;
114087 +
114088 + if (argnum == 0)
114089 + return false;
114090 +
114091 + param_head = get_attribute_param(decl);
114092 + for (param = param_head; param; param = TREE_CHAIN(param))
114093 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
114094 + return true;
114095 + return false;
114096 +}
114097 +
114098 +static const char *get_asm_string(const_gimple stmt)
114099 +{
114100 + if (!stmt)
114101 + return NULL;
114102 + if (gimple_code(stmt) != GIMPLE_ASM)
114103 + return NULL;
114104 +
114105 + return gimple_asm_string(stmt);
114106 +}
114107 +
114108 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
114109 +{
114110 + const char *str;
114111 +
114112 + str = get_asm_string(stmt);
114113 + if (!str)
114114 + return false;
114115 + return !strncmp(str, TURN_OFF_ASM_STR, sizeof(TURN_OFF_ASM_STR) - 1);
114116 +}
114117 +
114118 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
114119 +{
114120 + const char *str;
114121 +
114122 + str = get_asm_string(stmt);
114123 + if (!str)
114124 + return false;
114125 + return !strncmp(str, YES_ASM_STR, sizeof(YES_ASM_STR) - 1);
114126 +}
114127 +
114128 +static bool is_size_overflow_asm(const_gimple stmt)
114129 +{
114130 + const char *str;
114131 +
114132 + str = get_asm_string(stmt);
114133 + if (!str)
114134 + return false;
114135 + return !strncmp(str, OK_ASM_STR, sizeof(OK_ASM_STR) - 1);
114136 +}
114137 +
114138 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
114139 +{
114140 + location_t loc;
114141 +
114142 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
114143 + return;
114144 +
114145 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
114146 + return;
114147 +
114148 + loc = DECL_SOURCE_LOCATION(decl);
114149 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
114150 +}
114151 +
114152 +/* Get the type of the intentional_overflow attribute of a node
114153 + * * MARK_TURN_OFF
114154 + * * MARK_YES
114155 + * * MARK_NO
114156 + * * MARK_NOT_INTENTIONAL
114157 + */
114158 +static enum mark get_intentional_attr_type(const_tree node)
114159 +{
114160 + const_tree cur_decl;
114161 +
114162 + if (node == NULL_TREE)
114163 + return MARK_NO;
114164 +
114165 + switch (TREE_CODE(node)) {
114166 + case COMPONENT_REF:
114167 + cur_decl = search_field_decl(node);
114168 + if (is_turn_off_intentional_attr(cur_decl))
114169 + return MARK_TURN_OFF;
114170 + if (is_end_intentional_intentional_attr(cur_decl, 1))
114171 + return MARK_YES;
114172 + break;
114173 + case PARM_DECL: {
114174 + unsigned int argnum;
114175 +
114176 + cur_decl = DECL_ORIGIN(current_function_decl);
114177 + argnum = find_arg_number_tree(node, cur_decl);
114178 + if (argnum == CANNOT_FIND_ARG)
114179 + return MARK_NO;
114180 + if (is_yes_intentional_attr(cur_decl, argnum))
114181 + return MARK_YES;
114182 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
114183 + return MARK_NOT_INTENTIONAL;
114184 + break;
114185 + }
114186 + case FUNCTION_DECL:
114187 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
114188 + return MARK_TURN_OFF;
114189 + break;
114190 + default:
114191 + break;
114192 + }
114193 + return MARK_NO;
114194 +}
114195 +
114196 +// Search for the intentional_overflow attribute on the last nodes
114197 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
114198 +{
114199 + unsigned int i;
114200 + tree last_node;
114201 + enum mark mark = MARK_NO;
114202 +
114203 +#if BUILDING_GCC_VERSION == 4005
114204 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
114205 + last_node = VEC_index(tree, cur_node->last_nodes, i);
114206 +#elif BUILDING_GCC_VERSION <= 4007
114207 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
114208 +#else
114209 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
114210 +#endif
114211 + mark = get_intentional_attr_type(last_node);
114212 + if (mark != MARK_NO)
114213 + break;
114214 + }
114215 + return mark;
114216 +}
114217 +
114218 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
114219 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
114220 + */
114221 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
114222 +{
114223 + if (!cur_node->intentional_mark_from_gimple)
114224 + return false;
114225 +
114226 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
114227 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
114228 + else
114229 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
114230 +
114231 + // skip param decls
114232 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
114233 + return true;
114234 + return true;
114235 +}
114236 +
114237 +/* Search intentional_overflow attribute on caller and on callee too.
114238 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
114239 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
114240 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
114241 +*/
114242 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
114243 +{
114244 + const_tree fndecl;
114245 +
114246 + if (is_intentional_attribute_from_gimple(cur_node))
114247 + return;
114248 +
114249 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
114250 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
114251 + return;
114252 + }
114253 +
114254 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
114255 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
114256 + return;
114257 + }
114258 +
114259 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
114260 + return;
114261 +
114262 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
114263 + if (is_turn_off_intentional_attr(fndecl)) {
114264 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
114265 + return;
114266 + }
114267 +
114268 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
114269 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
114270 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
114271 + cur_node->intentional_attr_decl = MARK_YES;
114272 +
114273 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
114274 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
114275 +}
114276 +
114277 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
114278 +static bool skip_asm(const_tree arg)
114279 +{
114280 + gimple def_stmt = get_def_stmt(arg);
114281 +
114282 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
114283 + return false;
114284 +
114285 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
114286 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
114287 +}
114288 +
114289 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
114290 +{
114291 + gimple phi = get_def_stmt(result);
114292 + unsigned int i, n = gimple_phi_num_args(phi);
114293 +
114294 + pointer_set_insert(visited, phi);
114295 + for (i = 0; i < n; i++) {
114296 + tree arg = gimple_phi_arg_def(phi, i);
114297 +
114298 + walk_use_def(visited, cur_node, arg);
114299 + }
114300 +}
114301 +
114302 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
114303 +{
114304 + gimple def_stmt = get_def_stmt(lhs);
114305 + tree rhs1, rhs2;
114306 +
114307 + rhs1 = gimple_assign_rhs1(def_stmt);
114308 + rhs2 = gimple_assign_rhs2(def_stmt);
114309 +
114310 + walk_use_def(visited, cur_node, rhs1);
114311 + walk_use_def(visited, cur_node, rhs2);
114312 +}
114313 +
114314 +static void insert_last_node(struct interesting_node *cur_node, tree node)
114315 +{
114316 + unsigned int i;
114317 + tree element;
114318 + enum tree_code code;
114319 +
114320 + gcc_assert(node != NULL_TREE);
114321 +
114322 + if (is_gimple_constant(node))
114323 + return;
114324 +
114325 + code = TREE_CODE(node);
114326 + if (code == VAR_DECL) {
114327 + node = DECL_ORIGIN(node);
114328 + code = TREE_CODE(node);
114329 + }
114330 +
114331 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
114332 + return;
114333 +
114334 +#if BUILDING_GCC_VERSION == 4005
114335 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
114336 + element = VEC_index(tree, cur_node->last_nodes, i);
114337 +#elif BUILDING_GCC_VERSION <= 4007
114338 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
114339 +#else
114340 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
114341 +#endif
114342 + if (operand_equal_p(node, element, 0))
114343 + return;
114344 + }
114345 +
114346 +#if BUILDING_GCC_VERSION <= 4007
114347 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
114348 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
114349 +#else
114350 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
114351 + vec_safe_push(cur_node->last_nodes, node);
114352 +#endif
114353 +}
114354 +
114355 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
114356 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
114357 +{
114358 + if (!is_size_overflow_asm(stmt))
114359 + walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
114360 +}
114361 +
114362 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
114363 + * and component refs (for checking the intentional_overflow attribute).
114364 + */
114365 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
114366 +{
114367 + const_gimple def_stmt;
114368 +
114369 + if (TREE_CODE(lhs) != SSA_NAME) {
114370 + insert_last_node(cur_node, lhs);
114371 + return;
114372 + }
114373 +
114374 + def_stmt = get_def_stmt(lhs);
114375 + if (!def_stmt)
114376 + return;
114377 +
114378 + if (pointer_set_insert(visited, def_stmt))
114379 + return;
114380 +
114381 + switch (gimple_code(def_stmt)) {
114382 + case GIMPLE_NOP:
114383 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
114384 + case GIMPLE_ASM:
114385 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
114386 + case GIMPLE_CALL: {
114387 + tree fndecl = gimple_call_fndecl(def_stmt);
114388 +
114389 + if (fndecl == NULL_TREE)
114390 + return;
114391 + insert_last_node(cur_node, fndecl);
114392 + return;
114393 + }
114394 + case GIMPLE_PHI:
114395 + return walk_use_def_phi(visited, cur_node, lhs);
114396 + case GIMPLE_ASSIGN:
114397 + switch (gimple_num_ops(def_stmt)) {
114398 + case 2:
114399 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
114400 + case 3:
114401 + return walk_use_def_binary(visited, cur_node, lhs);
114402 + }
114403 + default:
114404 + debug_gimple_stmt((gimple)def_stmt);
114405 + error("%s: unknown gimple code", __func__);
114406 + gcc_unreachable();
114407 + }
114408 +}
114409 +
114410 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
114411 +static void set_last_nodes(struct interesting_node *cur_node)
114412 +{
114413 + struct pointer_set_t *visited;
114414 +
114415 + visited = pointer_set_create();
114416 + walk_use_def(visited, cur_node, cur_node->node);
114417 + pointer_set_destroy(visited);
114418 +}
114419 +
114420 +enum precond {
114421 + NO_ATTRIBUTE_SEARCH, NO_CHECK_INSERT, NONE
114422 +};
114423 +
114424 +/* If there is a mark_turn_off intentional attribute on the caller or the callee then there is no duplication and missing size_overflow attribute check anywhere.
114425 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
114426 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
114427 + * It skips the possible error codes too. If the def_stmts trace back to a constant and there are no binary/ternary assigments then we assume that it is some kind of error code.
114428 + */
114429 +static enum precond check_preconditions(struct interesting_node *cur_node)
114430 +{
114431 + bool interesting_conditions[3] = {false, false, false};
114432 +
114433 + set_last_nodes(cur_node);
114434 +
114435 + check_intentional_attribute_ipa(cur_node);
114436 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
114437 + return NO_ATTRIBUTE_SEARCH;
114438 +
114439 + search_interesting_conditions(cur_node, interesting_conditions);
114440 +
114441 + // error code
114442 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
114443 + return NO_ATTRIBUTE_SEARCH;
114444 +
114445 + // unnecessary overflow check
114446 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
114447 + return NO_CHECK_INSERT;
114448 +
114449 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
114450 + return NO_CHECK_INSERT;
114451 +
114452 + return NONE;
114453 +}
114454 +
114455 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
114456 + * it decides whether the duplication is necessary or not and it searches for missing size_overflow attributes. After expand() it changes the orig node to the duplicated node
114457 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
114458 + */
114459 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
114460 +{
114461 + enum precond ret;
114462 + struct pointer_set_t *visited;
114463 + tree new_node, orig_node = cur_node->node;
114464 +
114465 + ret = check_preconditions(cur_node);
114466 + if (ret == NO_ATTRIBUTE_SEARCH)
114467 + return cnodes;
114468 +
114469 + cnodes = search_overflow_attribute(cnodes, cur_node);
114470 +
114471 + if (ret == NO_CHECK_INSERT)
114472 + return cnodes;
114473 +
114474 + visited = pointer_set_create();
114475 + new_node = expand(visited, caller_node, orig_node);
114476 + pointer_set_destroy(visited);
114477 +
114478 + if (new_node == NULL_TREE)
114479 + return cnodes;
114480 +
114481 + change_orig_node(cur_node, new_node);
114482 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
114483 +
114484 + return cnodes;
114485 +}
114486 +
114487 +// Check visited interesting nodes.
114488 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
114489 +{
114490 + struct interesting_node *cur;
114491 +
114492 + for (cur = head; cur; cur = cur->next) {
114493 + if (!operand_equal_p(node, cur->node, 0))
114494 + continue;
114495 + if (num != cur->num)
114496 + continue;
114497 + if (first_stmt == cur->first_stmt)
114498 + return true;
114499 + }
114500 + return false;
114501 +}
114502 +
114503 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
114504 + first_stmt: it is the call or assignment or ret stmt, change_orig_node() will change the original node (retval, or function arg) in this
114505 + last_nodes: they are the last stmts in the recursion (they haven't a def_stmt). They are useful in the missing size_overflow attribute check and
114506 + the intentional_overflow attribute check. They are collected by set_last_nodes().
114507 + num: arg count of a call stmt or 0 when it is a ret
114508 + node: the recursion starts from here, it is a call arg or a return value
114509 + fndecl: the fndecl of the interesting node when the node is an arg. it is the fndecl of the callee function otherwise it is the fndecl of the caller (current_function_fndecl) function.
114510 + intentional_attr_decl: intentional_overflow attribute of the callee function
114511 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
114512 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
114513 + */
114514 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
114515 +{
114516 + struct interesting_node *new_node;
114517 + tree fndecl;
114518 + enum gimple_code code;
114519 +
114520 + gcc_assert(node != NULL_TREE);
114521 + code = gimple_code(first_stmt);
114522 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
114523 +
114524 + if (num == CANNOT_FIND_ARG)
114525 + return head;
114526 +
114527 + if (skip_types(node))
114528 + return head;
114529 +
114530 + if (skip_asm(node))
114531 + return head;
114532 +
114533 + if (is_gimple_call(first_stmt))
114534 + fndecl = gimple_call_fndecl(first_stmt);
114535 + else
114536 + fndecl = current_function_decl;
114537 +
114538 + if (fndecl == NULL_TREE)
114539 + return head;
114540 +
114541 + if (is_in_interesting_node(head, first_stmt, node, num))
114542 + return head;
114543 +
114544 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
114545 +
114546 + new_node->next = NULL;
114547 + new_node->first_stmt = first_stmt;
114548 +#if BUILDING_GCC_VERSION <= 4007
114549 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
114550 +#else
114551 + vec_alloc(new_node->last_nodes, VEC_LEN);
114552 +#endif
114553 + new_node->num = num;
114554 + new_node->node = node;
114555 + new_node->fndecl = fndecl;
114556 + new_node->intentional_attr_decl = MARK_NO;
114557 + new_node->intentional_attr_cur_fndecl = MARK_NO;
114558 + new_node->intentional_mark_from_gimple = asm_stmt;
114559 +
114560 + if (!head)
114561 + return new_node;
114562 +
114563 + new_node->next = head;
114564 + return new_node;
114565 +}
114566 +
114567 +/* Check the ret stmts in the functions on the next cgraph node list (these functions will be in the hash table and they are reachable from ipa).
114568 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
114569 + */
114570 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
114571 +{
114572 + struct next_cgraph_node *cur_node;
114573 + tree ret = gimple_return_retval(stmt);
114574 +
114575 + if (ret == NULL_TREE)
114576 + return head;
114577 +
114578 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
114579 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
114580 + continue;
114581 + if (cur_node->num == 0)
114582 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
114583 + }
114584 +
114585 + return head;
114586 +}
114587 +
114588 +/* Check the call stmts in the functions on the next cgraph node list (these functions will be in the hash table and they are reachable from ipa).
114589 + * If the call stmt is in the next cgraph node list then it's an interesting call.
114590 + */
114591 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
114592 +{
114593 + unsigned int argnum;
114594 + tree fndecl, arg;
114595 + struct next_cgraph_node *cur_node;
114596 +
114597 + fndecl = gimple_call_fndecl(stmt);
114598 + if (fndecl == NULL_TREE)
114599 + return head;
114600 +
114601 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
114602 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
114603 + continue;
114604 + argnum = get_correct_arg_count(cur_node->num, fndecl);
114605 + gcc_assert(argnum != CANNOT_FIND_ARG);
114606 + if (argnum == 0)
114607 + continue;
114608 +
114609 + arg = gimple_call_arg(stmt, argnum - 1);
114610 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
114611 + }
114612 +
114613 + return head;
114614 +}
114615 +
114616 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
114617 +{
114618 + if (!operand_equal_p(orig_node, node, 0))
114619 + return WRONG_NODE;
114620 + if (skip_types(node))
114621 + return WRONG_NODE;
114622 + return ret_count;
114623 +}
114624 +
114625 +// Get the index of the rhs node in an assignment
114626 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
114627 +{
114628 + const_tree rhs1, rhs2;
114629 + unsigned int ret;
114630 +
114631 + gcc_assert(stmt);
114632 + gcc_assert(is_gimple_assign(stmt));
114633 +
114634 + rhs1 = gimple_assign_rhs1(stmt);
114635 + gcc_assert(rhs1 != NULL_TREE);
114636 +
114637 + switch (gimple_num_ops(stmt)) {
114638 + case 2:
114639 + return check_ops(node, rhs1, 1);
114640 + case 3:
114641 + ret = check_ops(node, rhs1, 1);
114642 + if (ret != WRONG_NODE)
114643 + return ret;
114644 +
114645 + rhs2 = gimple_assign_rhs2(stmt);
114646 + gcc_assert(rhs2 != NULL_TREE);
114647 + return check_ops(node, rhs2, 2);
114648 + default:
114649 + gcc_unreachable();
114650 + }
114651 +}
114652 +
114653 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
114654 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
114655 +{
114656 + unsigned int i;
114657 +
114658 + if (gimple_call_fndecl(stmt) == NULL_TREE)
114659 + return CANNOT_FIND_ARG;
114660 +
114661 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
114662 + tree node;
114663 +
114664 + node = gimple_call_arg(stmt, i);
114665 + if (!operand_equal_p(arg, node, 0))
114666 + continue;
114667 + if (!skip_types(node))
114668 + return i + 1;
114669 + }
114670 +
114671 + return CANNOT_FIND_ARG;
114672 +}
114673 +
114674 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
114675 + * any of return, call or assignment stmts (because of inlining).
114676 + */
114677 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
114678 +{
114679 + use_operand_p use_p;
114680 + imm_use_iterator imm_iter;
114681 + unsigned int argnum;
114682 +
114683 + gcc_assert(TREE_CODE(node) == SSA_NAME);
114684 +
114685 + if (pointer_set_insert(visited, node))
114686 + return head;
114687 +
114688 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
114689 + gimple stmt = USE_STMT(use_p);
114690 +
114691 + if (stmt == NULL)
114692 + return head;
114693 + if (is_gimple_debug(stmt))
114694 + continue;
114695 +
114696 + switch (gimple_code(stmt)) {
114697 + case GIMPLE_CALL:
114698 + argnum = find_arg_number_gimple(node, stmt);
114699 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
114700 + break;
114701 + case GIMPLE_RETURN:
114702 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
114703 + break;
114704 + case GIMPLE_ASSIGN:
114705 + argnum = get_assign_ops_count(stmt, node);
114706 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
114707 + break;
114708 + case GIMPLE_PHI: {
114709 + tree result = gimple_phi_result(stmt);
114710 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
114711 + break;
114712 + }
114713 + case GIMPLE_ASM:
114714 + if (gimple_asm_noutputs(stmt) != 0)
114715 + break;
114716 + if (!is_size_overflow_asm(stmt))
114717 + break;
114718 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
114719 + break;
114720 + case GIMPLE_COND:
114721 + case GIMPLE_SWITCH:
114722 + break;
114723 + default:
114724 + debug_gimple_stmt(stmt);
114725 + gcc_unreachable();
114726 + break;
114727 + }
114728 + }
114729 + return head;
114730 +}
114731 +
114732 +static void remove_size_overflow_asm(gimple stmt)
114733 +{
114734 + gimple_stmt_iterator gsi;
114735 + tree input, output;
114736 +
114737 + if (!is_size_overflow_asm(stmt))
114738 + return;
114739 +
114740 + if (gimple_asm_noutputs(stmt) == 0) {
114741 + gsi = gsi_for_stmt(stmt);
114742 + gsi_remove(&gsi, true);
114743 + return;
114744 + }
114745 +
114746 + input = gimple_asm_input_op(stmt, 0);
114747 + output = gimple_asm_output_op(stmt, 0);
114748 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
114749 +}
114750 +
114751 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
114752 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
114753 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
114754 + */
114755 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
114756 +{
114757 + const_tree output;
114758 + struct pointer_set_t *visited;
114759 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
114760 +
114761 + if (!is_size_overflow_asm(stmt))
114762 + return head;
114763 +
114764 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
114765 + intentional_asm = stmt;
114766 +
114767 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
114768 +
114769 + if (gimple_asm_noutputs(stmt) == 0 && is_size_overflow_intentional_asm_turn_off(stmt))
114770 + return head;
114771 +
114772 + if (gimple_asm_noutputs(stmt) == 0) {
114773 + const_tree input;
114774 +
114775 + if (!is_size_overflow_intentional_asm_turn_off(stmt))
114776 + return head;
114777 +
114778 + input = gimple_asm_input_op(stmt, 0);
114779 + remove_size_overflow_asm(stmt);
114780 + if (is_gimple_constant(TREE_VALUE(input)))
114781 + return head;
114782 + visited = pointer_set_create();
114783 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
114784 + pointer_set_destroy(visited);
114785 + return head;
114786 + }
114787 +
114788 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
114789 + remove_size_overflow_asm(stmt);
114790 +
114791 + visited = pointer_set_create();
114792 + output = gimple_asm_output_op(stmt, 0);
114793 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
114794 + pointer_set_destroy(visited);
114795 + return head;
114796 +}
114797 +
114798 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
114799 + * or a call stmt or a return stmt and store them in the interesting_node list
114800 + */
114801 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
114802 +{
114803 + basic_block bb;
114804 + struct interesting_node *head = NULL;
114805 +
114806 + FOR_ALL_BB(bb) {
114807 + gimple_stmt_iterator gsi;
114808 +
114809 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114810 + enum gimple_code code;
114811 + gimple stmt = gsi_stmt(gsi);
114812 +
114813 + code = gimple_code(stmt);
114814 +
114815 + if (code == GIMPLE_ASM)
114816 + head = handle_stmt_by_size_overflow_asm(stmt, head);
114817 +
114818 + if (!next_node)
114819 + continue;
114820 + if (code == GIMPLE_CALL)
114821 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
114822 + if (code == GIMPLE_RETURN)
114823 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
114824 + }
114825 + }
114826 + return head;
114827 +}
114828 +
114829 +static void set_current_function_decl(tree fndecl)
114830 +{
114831 + gcc_assert(fndecl != NULL_TREE);
114832 +
114833 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
114834 + calculate_dominance_info(CDI_DOMINATORS);
114835 + current_function_decl = fndecl;
114836 +}
114837 +
114838 +static void unset_current_function_decl(void)
114839 +{
114840 + free_dominance_info(CDI_DOMINATORS);
114841 + pop_cfun();
114842 + current_function_decl = NULL_TREE;
114843 +}
114844 +
114845 +static void free_interesting_node(struct interesting_node *head)
114846 +{
114847 + struct interesting_node *cur;
114848 +
114849 + while (head) {
114850 + cur = head->next;
114851 +#if BUILDING_GCC_VERSION <= 4007
114852 + VEC_free(tree, gc, head->last_nodes);
114853 +#else
114854 + vec_free(head->last_nodes);
114855 +#endif
114856 + free(head);
114857 + head = cur;
114858 + }
114859 +}
114860 +
114861 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
114862 +{
114863 + struct visited *new_visited;
114864 +
114865 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
114866 + new_visited->fndecl = cur_node->fndecl;
114867 + new_visited->num = cur_node->num;
114868 + new_visited->first_stmt = cur_node->first_stmt;
114869 + new_visited->next = NULL;
114870 +
114871 + if (!head)
114872 + return new_visited;
114873 +
114874 + new_visited->next = head;
114875 + return new_visited;
114876 +}
114877 +
114878 +/* Check whether the function was already visited. If the fndecl, the arg count of the fndecl and the first_stmt (call or return) are same then
114879 + * it is a visited function.
114880 + */
114881 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
114882 +{
114883 + struct visited *cur;
114884 +
114885 + if (!head)
114886 + return false;
114887 +
114888 + for (cur = head; cur; cur = cur->next) {
114889 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
114890 + continue;
114891 + if (cur_node->num != cur->num)
114892 + continue;
114893 + if (cur_node->first_stmt == cur->first_stmt)
114894 + return true;
114895 + }
114896 + return false;
114897 +}
114898 +
114899 +static void free_next_cgraph_node(struct next_cgraph_node *head)
114900 +{
114901 + struct next_cgraph_node *cur;
114902 +
114903 + while (head) {
114904 + cur = head->next;
114905 + free(head);
114906 + head = cur;
114907 + }
114908 +}
114909 +
114910 +static void remove_all_size_overflow_asm(void)
114911 +{
114912 + basic_block bb;
114913 +
114914 + FOR_ALL_BB(bb) {
114915 + gimple_stmt_iterator si;
114916 +
114917 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114918 + remove_size_overflow_asm(gsi_stmt(si));
114919 + }
114920 +}
114921 +
114922 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
114923 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
114924 + * the newly collected interesting functions (they are interesting if there is control flow between
114925 + * the interesting stmts and them).
114926 + */
114927 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
114928 +{
114929 + struct interesting_node *head, *cur_node;
114930 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
114931 +
114932 +#if BUILDING_GCC_VERSION <= 4007
114933 + set_current_function_decl(node->decl);
114934 +#else
114935 + set_current_function_decl(node->symbol.decl);
114936 +#endif
114937 + call_count = 0;
114938 +
114939 + head = collect_interesting_stmts(next_node);
114940 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
114941 + if (is_visited_function(visited, cur_node))
114942 + continue;
114943 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
114944 + visited = insert_visited_function(visited, cur_node);
114945 + }
114946 +
114947 + free_interesting_node(head);
114948 + remove_all_size_overflow_asm();
114949 + unset_current_function_decl();
114950 +
114951 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
114952 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
114953 +
114954 + free_next_cgraph_node(cnodes_head);
114955 + return visited;
114956 +}
114957 +
114958 +static void free_visited(struct visited *head)
114959 +{
114960 + struct visited *cur;
114961 +
114962 + while (head) {
114963 + cur = head->next;
114964 + free(head);
114965 + head = cur;
114966 + }
114967 +}
114968 +
114969 +// erase the local flag
114970 +static void set_plf_false(void)
114971 +{
114972 + basic_block bb;
114973 +
114974 + FOR_ALL_BB(bb) {
114975 + gimple_stmt_iterator si;
114976 +
114977 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114978 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
114979 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
114980 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
114981 + }
114982 +}
114983 +
114984 +#if BUILDING_GCC_VERSION <= 4006
114985 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
114986 +{
114987 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
114988 +}
114989 +
114990 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
114991 +{
114992 + struct cgraph_node *node;
114993 +
114994 + for (node = cgraph_nodes; node; node = node->next) {
114995 + if (cgraph_function_with_gimple_body_p(node))
114996 + return node;
114997 + }
114998 + return NULL;
114999 +}
115000 +
115001 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
115002 +{
115003 + for (node = node->next; node; node = node->next) {
115004 + if (cgraph_function_with_gimple_body_p(node))
115005 + return node;
115006 + }
115007 + return NULL;
115008 +}
115009 +
115010 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
115011 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
115012 + (node) = cgraph_next_function_with_gimple_body (node))
115013 +
115014 +#endif
115015 +
115016 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
115017 +static unsigned int search_function(void)
115018 +{
115019 + struct cgraph_node *node;
115020 + struct visited *visited = NULL;
115021 +
115022 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
115023 +#if BUILDING_GCC_VERSION <= 4007
115024 + set_current_function_decl(node->decl);
115025 +#else
115026 + set_current_function_decl(node->symbol.decl);
115027 +#endif
115028 + set_plf_false();
115029 + unset_current_function_decl();
115030 + }
115031 +
115032 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
115033 + gcc_assert(cgraph_function_flags_ready);
115034 +#if BUILDING_GCC_VERSION <= 4007
115035 + gcc_assert(node->reachable);
115036 +#endif
115037 +
115038 + visited = handle_function(node, NULL, visited);
115039 + }
115040 +
115041 + free_visited(visited);
115042 + return 0;
115043 +}
115044 +
115045 +static struct ipa_opt_pass_d pass_ipa = {
115046 + .pass = {
115047 + .type = SIMPLE_IPA_PASS,
115048 + .name = "size_overflow",
115049 +#if BUILDING_GCC_VERSION >= 4008
115050 + .optinfo_flags = OPTGROUP_NONE,
115051 +#endif
115052 + .gate = NULL,
115053 + .execute = search_function,
115054 + .sub = NULL,
115055 + .next = NULL,
115056 + .static_pass_number = 0,
115057 + .tv_id = TV_NONE,
115058 + .properties_required = 0,
115059 + .properties_provided = 0,
115060 + .properties_destroyed = 0,
115061 + .todo_flags_start = 0,
115062 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_remove_unused_locals | TODO_ggc_collect | TODO_verify_flow | TODO_dump_cgraph | TODO_dump_func | TODO_update_ssa_no_phi,
115063 + },
115064 + .generate_summary = NULL,
115065 + .write_summary = NULL,
115066 + .read_summary = NULL,
115067 +#if BUILDING_GCC_VERSION >= 4006
115068 + .write_optimization_summary = NULL,
115069 + .read_optimization_summary = NULL,
115070 +#endif
115071 + .stmt_fixup = NULL,
115072 + .function_transform_todo_flags_start = 0,
115073 + .function_transform = NULL,
115074 + .variable_transform = NULL,
115075 +};
115076 +
115077 +// data for the size_overflow asm stmt
115078 +struct asm_data {
115079 + gimple def_stmt;
115080 + tree input;
115081 + tree output;
115082 +};
115083 +
115084 +#if BUILDING_GCC_VERSION <= 4007
115085 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
115086 +#else
115087 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
115088 +#endif
115089 +{
115090 + tree list;
115091 +#if BUILDING_GCC_VERSION <= 4007
115092 + VEC(tree, gc) *vec_list = NULL;
115093 +#else
115094 + vec<tree, va_gc> *vec_list = NULL;
115095 +#endif
115096 +
115097 + list = build_tree_list(NULL_TREE, string);
115098 + list = chainon(NULL_TREE, build_tree_list(list, io));
115099 +#if BUILDING_GCC_VERSION <= 4007
115100 + VEC_safe_push(tree, gc, vec_list, list);
115101 +#else
115102 + vec_safe_push(vec_list, list);
115103 +#endif
115104 + return vec_list;
115105 +}
115106 +
115107 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
115108 +{
115109 + gimple asm_stmt;
115110 + gimple_stmt_iterator gsi;
115111 +#if BUILDING_GCC_VERSION <= 4007
115112 + VEC(tree, gc) *input, *output = NULL;
115113 +#else
115114 + vec<tree, va_gc> *input, *output = NULL;
115115 +#endif
115116 +
115117 + input = create_asm_io_list(str_input, asm_data->input);
115118 +
115119 + if (asm_data->output)
115120 + output = create_asm_io_list(str_output, asm_data->output);
115121 +
115122 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
115123 + gsi = gsi_for_stmt(asm_data->def_stmt);
115124 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
115125 +
115126 + if (asm_data->output)
115127 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
115128 +}
115129 +
115130 +static void replace_call_lhs(const struct asm_data *asm_data)
115131 +{
115132 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
115133 + update_stmt(asm_data->def_stmt);
115134 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
115135 +}
115136 +
115137 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
115138 +{
115139 + enum mark cur_fndecl_attr;
115140 + gimple phi = get_def_stmt(result);
115141 + unsigned int i, n = gimple_phi_num_args(phi);
115142 +
115143 + pointer_set_insert(visited, phi);
115144 + for (i = 0; i < n; i++) {
115145 + tree arg = gimple_phi_arg_def(phi, i);
115146 +
115147 + cur_fndecl_attr = search_intentional(visited, arg);
115148 + if (cur_fndecl_attr != MARK_NO)
115149 + return cur_fndecl_attr;
115150 + }
115151 + return MARK_NO;
115152 +}
115153 +
115154 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
115155 +{
115156 + enum mark cur_fndecl_attr;
115157 + const_tree rhs1, rhs2;
115158 + gimple def_stmt = get_def_stmt(lhs);
115159 +
115160 + rhs1 = gimple_assign_rhs1(def_stmt);
115161 + rhs2 = gimple_assign_rhs2(def_stmt);
115162 +
115163 + cur_fndecl_attr = search_intentional(visited, rhs1);
115164 + if (cur_fndecl_attr != MARK_NO)
115165 + return cur_fndecl_attr;
115166 + return search_intentional(visited, rhs2);
115167 +}
115168 +
115169 +// Look up the intentional_overflow attribute on the caller and the callee functions.
115170 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
115171 +{
115172 + const_gimple def_stmt;
115173 +
115174 + if (TREE_CODE(lhs) != SSA_NAME)
115175 + return get_intentional_attr_type(lhs);
115176 +
115177 + def_stmt = get_def_stmt(lhs);
115178 + if (!def_stmt)
115179 + return MARK_NO;
115180 +
115181 + if (pointer_set_contains(visited, def_stmt))
115182 + return MARK_NO;
115183 +
115184 + switch (gimple_code(def_stmt)) {
115185 + case GIMPLE_NOP:
115186 + return search_intentional(visited, SSA_NAME_VAR(lhs));
115187 + case GIMPLE_ASM:
115188 + if (is_size_overflow_intentional_asm_turn_off(def_stmt))
115189 + return MARK_TURN_OFF;
115190 + return MARK_NO;
115191 + case GIMPLE_CALL:
115192 + return MARK_NO;
115193 + case GIMPLE_PHI:
115194 + return search_intentional_phi(visited, lhs);
115195 + case GIMPLE_ASSIGN:
115196 + switch (gimple_num_ops(def_stmt)) {
115197 + case 2:
115198 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
115199 + case 3:
115200 + return search_intentional_binary(visited, lhs);
115201 + }
115202 + case GIMPLE_RETURN:
115203 + return MARK_NO;
115204 + default:
115205 + debug_gimple_stmt((gimple)def_stmt);
115206 + error("%s: unknown gimple code", __func__);
115207 + gcc_unreachable();
115208 + }
115209 +}
115210 +
115211 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
115212 +static enum mark check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
115213 +{
115214 + const_tree fndecl;
115215 + struct pointer_set_t *visited;
115216 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
115217 +
115218 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
115219 + if (is_end_intentional_intentional_attr(fndecl, argnum))
115220 + decl_attr = MARK_NOT_INTENTIONAL;
115221 + else if (is_yes_intentional_attr(fndecl, argnum))
115222 + decl_attr = MARK_YES;
115223 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
115224 + return MARK_TURN_OFF;
115225 + }
115226 +
115227 + visited = pointer_set_create();
115228 + cur_fndecl_attr = search_intentional(visited, arg);
115229 + pointer_set_destroy(visited);
115230 +
115231 + switch (cur_fndecl_attr) {
115232 + case MARK_NO:
115233 + case MARK_TURN_OFF:
115234 + return cur_fndecl_attr;
115235 + default:
115236 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
115237 + return MARK_YES;
115238 + }
115239 +}
115240 +
115241 +static void check_missing_size_overflow_attribute(tree var)
115242 +{
115243 + tree orig_fndecl;
115244 + unsigned int num;
115245 +
115246 + if (is_a_return_check(var))
115247 + orig_fndecl = DECL_ORIGIN(var);
115248 + else
115249 + orig_fndecl = DECL_ORIGIN(current_function_decl);
115250 +
115251 + num = get_function_num(var, orig_fndecl);
115252 + if (num == CANNOT_FIND_ARG)
115253 + return;
115254 +
115255 + is_missing_function(orig_fndecl, num);
115256 +}
115257 +
115258 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
115259 +{
115260 + gimple phi = get_def_stmt(result);
115261 + unsigned int i, n = gimple_phi_num_args(phi);
115262 +
115263 + pointer_set_insert(visited, phi);
115264 + for (i = 0; i < n; i++) {
115265 + tree arg = gimple_phi_arg_def(phi, i);
115266 +
115267 + search_size_overflow_attribute(visited, arg);
115268 + }
115269 +}
115270 +
115271 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
115272 +{
115273 + const_gimple def_stmt = get_def_stmt(lhs);
115274 + tree rhs1, rhs2;
115275 +
115276 + rhs1 = gimple_assign_rhs1(def_stmt);
115277 + rhs2 = gimple_assign_rhs2(def_stmt);
115278 +
115279 + search_size_overflow_attribute(visited, rhs1);
115280 + search_size_overflow_attribute(visited, rhs2);
115281 +}
115282 +
115283 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
115284 +{
115285 + const_gimple def_stmt;
115286 +
115287 + if (TREE_CODE(lhs) == PARM_DECL) {
115288 + check_missing_size_overflow_attribute(lhs);
115289 + return;
115290 + }
115291 +
115292 + def_stmt = get_def_stmt(lhs);
115293 + if (!def_stmt)
115294 + return;
115295 +
115296 + if (pointer_set_insert(visited, def_stmt))
115297 + return;
115298 +
115299 + switch (gimple_code(def_stmt)) {
115300 + case GIMPLE_NOP:
115301 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
115302 + case GIMPLE_ASM:
115303 + return;
115304 + case GIMPLE_CALL: {
115305 + tree fndecl = gimple_call_fndecl(def_stmt);
115306 +
115307 + if (fndecl == NULL_TREE)
115308 + return;
115309 + check_missing_size_overflow_attribute(fndecl);
115310 + return;
115311 + }
115312 + case GIMPLE_PHI:
115313 + return search_size_overflow_attribute_phi(visited, lhs);
115314 + case GIMPLE_ASSIGN:
115315 + switch (gimple_num_ops(def_stmt)) {
115316 + case 2:
115317 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
115318 + case 3:
115319 + return search_size_overflow_attribute_binary(visited, lhs);
115320 + }
115321 + default:
115322 + debug_gimple_stmt((gimple)def_stmt);
115323 + error("%s: unknown gimple code", __func__);
115324 + gcc_unreachable();
115325 + }
115326 +}
115327 +
115328 +// Search missing entries in the hash table (invoked from the gimple pass)
115329 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
115330 +{
115331 + tree fndecl = NULL_TREE;
115332 + tree lhs;
115333 + struct pointer_set_t *visited;
115334 +
115335 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
115336 + return;
115337 +
115338 + if (num == 0) {
115339 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
115340 + lhs = gimple_return_retval(stmt);
115341 + } else {
115342 + gcc_assert(is_gimple_call(stmt));
115343 + lhs = gimple_call_arg(stmt, num - 1);
115344 + fndecl = gimple_call_fndecl(stmt);
115345 + }
115346 +
115347 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
115348 + return;
115349 +
115350 + visited = pointer_set_create();
115351 + search_size_overflow_attribute(visited, lhs);
115352 + pointer_set_destroy(visited);
115353 +}
115354 +
115355 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
115356 +{
115357 + gimple_stmt_iterator gsi;
115358 + gimple assign;
115359 +
115360 + assign = gimple_build_assign(asm_data->input, asm_data->output);
115361 + gsi = gsi_for_stmt(stmt);
115362 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
115363 + asm_data->def_stmt = assign;
115364 +
115365 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
115366 + asm_data->output = make_ssa_name(asm_data->output, stmt);
115367 + if (gimple_code(stmt) == GIMPLE_RETURN)
115368 + gimple_return_set_retval(stmt, asm_data->output);
115369 + else
115370 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
115371 + update_stmt(stmt);
115372 +}
115373 +
115374 +static char *create_asm_comment(unsigned int argnum, const_gimple stmt , const char *mark_str)
115375 +{
115376 + const char *fn_name;
115377 + char *asm_comment;
115378 + unsigned int len;
115379 +
115380 + if (argnum == 0)
115381 + fn_name = NAME(current_function_decl);
115382 + else
115383 + fn_name = NAME(gimple_call_fndecl(stmt));
115384 +
115385 + len = asprintf(&asm_comment, "%s %s %u", mark_str, fn_name, argnum);
115386 + gcc_assert(len > 0);
115387 +
115388 + return asm_comment;
115389 +}
115390 +
115391 +static const char *convert_mark_to_str(enum mark mark)
115392 +{
115393 + switch (mark) {
115394 + case MARK_NO:
115395 + return OK_ASM_STR;
115396 + case MARK_YES:
115397 + case MARK_NOT_INTENTIONAL:
115398 + return YES_ASM_STR;
115399 + case MARK_TURN_OFF:
115400 + return TURN_OFF_ASM_STR;
115401 + }
115402 +
115403 + gcc_unreachable();
115404 +}
115405 +
115406 +/* Create the input of the size_overflow asm stmt.
115407 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
115408 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
115409 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
115410 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
115411 + */
115412 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
115413 +{
115414 + if (!asm_data->def_stmt) {
115415 + asm_data->input = NULL_TREE;
115416 + return;
115417 + }
115418 +
115419 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
115420 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
115421 +
115422 + switch (gimple_code(asm_data->def_stmt)) {
115423 + case GIMPLE_ASSIGN:
115424 + case GIMPLE_CALL:
115425 + replace_call_lhs(asm_data);
115426 + break;
115427 + case GIMPLE_PHI:
115428 + create_output_from_phi(stmt, argnum, asm_data);
115429 + break;
115430 + case GIMPLE_NOP: {
115431 + enum mark mark;
115432 + const char *mark_str;
115433 + char *asm_comment;
115434 +
115435 + mark = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
115436 +
115437 + asm_data->input = asm_data->output;
115438 + asm_data->output = NULL;
115439 + asm_data->def_stmt = stmt;
115440 +
115441 + mark_str = convert_mark_to_str(mark);
115442 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
115443 +
115444 + create_asm_stmt(asm_comment, build_string(2, "rm"), NULL, asm_data);
115445 + free(asm_comment);
115446 + asm_data->input = NULL_TREE;
115447 + break;
115448 + }
115449 + case GIMPLE_ASM:
115450 + if (is_size_overflow_asm(asm_data->def_stmt)) {
115451 + asm_data->input = NULL_TREE;
115452 + break;
115453 + }
115454 + default:
115455 + debug_gimple_stmt(asm_data->def_stmt);
115456 + gcc_unreachable();
115457 + }
115458 +}
115459 +
115460 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
115461 + * is of the right kind create the appropriate size_overflow asm stmts:
115462 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
115463 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
115464 + */
115465 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
115466 +{
115467 + struct asm_data asm_data;
115468 + const char *mark_str;
115469 + char *asm_comment;
115470 + enum mark mark;
115471 +
115472 + if (is_gimple_constant(output_node))
115473 + return;
115474 +
115475 + asm_data.output = output_node;
115476 + mark = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
115477 + if (mark != MARK_TURN_OFF)
115478 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
115479 +
115480 + asm_data.def_stmt = get_def_stmt(asm_data.output);
115481 + if (is_size_overflow_intentional_asm_turn_off(asm_data.def_stmt))
115482 + return;
115483 +
115484 + create_asm_input(stmt, argnum, &asm_data);
115485 + if (asm_data.input == NULL_TREE)
115486 + return;
115487 +
115488 + mark_str = convert_mark_to_str(mark);
115489 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
115490 + create_asm_stmt(asm_comment, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
115491 + free(asm_comment);
115492 +}
115493 +
115494 +// Insert an asm stmt with "MARK_TURN_OFF", "MARK_YES" or "MARK_NOT_INTENTIONAL".
115495 +static bool create_mark_asm(gimple stmt, enum mark mark)
115496 +{
115497 + struct asm_data asm_data;
115498 + const char *asm_str;
115499 +
115500 + switch (mark) {
115501 + case MARK_TURN_OFF:
115502 + asm_str = TURN_OFF_ASM_STR;
115503 + break;
115504 + case MARK_NOT_INTENTIONAL:
115505 + case MARK_YES:
115506 + asm_str = YES_ASM_STR;
115507 + break;
115508 + default:
115509 + gcc_unreachable();
115510 + }
115511 +
115512 + asm_data.def_stmt = stmt;
115513 + asm_data.output = gimple_call_lhs(stmt);
115514 +
115515 + if (asm_data.output == NULL_TREE) {
115516 + asm_data.input = gimple_call_arg(stmt, 0);
115517 + if (is_gimple_constant(asm_data.input))
115518 + return false;
115519 + asm_data.output = NULL;
115520 + create_asm_stmt(asm_str, build_string(2, "rm"), NULL, &asm_data);
115521 + return true;
115522 + }
115523 +
115524 + create_asm_input(stmt, 0, &asm_data);
115525 + gcc_assert(asm_data.input != NULL_TREE);
115526 +
115527 + create_asm_stmt(asm_str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
115528 + return true;
115529 +}
115530 +
115531 +static bool is_from_cast(const_tree node)
115532 +{
115533 + gimple def_stmt = get_def_stmt(node);
115534 +
115535 + if (!def_stmt)
115536 + return false;
115537 +
115538 + if (gimple_assign_cast_p(def_stmt))
115539 + return true;
115540 +
115541 + return false;
115542 +}
115543 +
115544 +// Skip duplication when there is a minus expr and the type of rhs1 or rhs2 is a pointer_type.
115545 +static bool skip_ptr_minus(gimple stmt)
115546 +{
115547 + const_tree rhs1, rhs2, ptr1_rhs, ptr2_rhs;
115548 +
115549 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
115550 + return false;
115551 +
115552 + rhs1 = gimple_assign_rhs1(stmt);
115553 + if (!is_from_cast(rhs1))
115554 + return false;
115555 +
115556 + rhs2 = gimple_assign_rhs2(stmt);
115557 + if (!is_from_cast(rhs2))
115558 + return false;
115559 +
115560 + ptr1_rhs = gimple_assign_rhs1(get_def_stmt(rhs1));
115561 + ptr2_rhs = gimple_assign_rhs1(get_def_stmt(rhs2));
115562 +
115563 + if (TREE_CODE(TREE_TYPE(ptr1_rhs)) != POINTER_TYPE && TREE_CODE(TREE_TYPE(ptr2_rhs)) != POINTER_TYPE)
115564 + return false;
115565 +
115566 + create_mark_asm(stmt, MARK_YES);
115567 + return true;
115568 +}
115569 +
115570 +static void walk_use_def_ptr(struct pointer_set_t *visited, const_tree lhs)
115571 +{
115572 + gimple def_stmt;
115573 +
115574 + def_stmt = get_def_stmt(lhs);
115575 + if (!def_stmt)
115576 + return;
115577 +
115578 + if (pointer_set_insert(visited, def_stmt))
115579 + return;
115580 +
115581 + switch (gimple_code(def_stmt)) {
115582 + case GIMPLE_NOP:
115583 + case GIMPLE_ASM:
115584 + case GIMPLE_CALL:
115585 + break;
115586 + case GIMPLE_PHI: {
115587 + unsigned int i, n = gimple_phi_num_args(def_stmt);
115588 +
115589 + pointer_set_insert(visited, def_stmt);
115590 +
115591 + for (i = 0; i < n; i++) {
115592 + tree arg = gimple_phi_arg_def(def_stmt, i);
115593 +
115594 + walk_use_def_ptr(visited, arg);
115595 + }
115596 + }
115597 + case GIMPLE_ASSIGN:
115598 + switch (gimple_num_ops(def_stmt)) {
115599 + case 2:
115600 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
115601 + return;
115602 + case 3:
115603 + if (skip_ptr_minus(def_stmt))
115604 + return;
115605 +
115606 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
115607 + walk_use_def_ptr(visited, gimple_assign_rhs2(def_stmt));
115608 + return;
115609 + default:
115610 + return;
115611 + }
115612 + default:
115613 + debug_gimple_stmt((gimple)def_stmt);
115614 + error("%s: unknown gimple code", __func__);
115615 + gcc_unreachable();
115616 + }
115617 +}
115618 +
115619 +// Look for a ptr - ptr expression (e.g., cpuset_common_file_read() s - page)
115620 +static void insert_mark_not_intentional_asm_at_ptr(const_tree arg)
115621 +{
115622 + struct pointer_set_t *visited;
115623 +
115624 + visited = pointer_set_create();
115625 + walk_use_def_ptr(visited, arg);
115626 + pointer_set_destroy(visited);
115627 +}
115628 +
115629 +// Determine the return value and insert the asm stmt to mark the return stmt.
115630 +static void insert_asm_ret(gimple stmt)
115631 +{
115632 + tree ret;
115633 +
115634 + ret = gimple_return_retval(stmt);
115635 + create_size_overflow_asm(stmt, ret, 0);
115636 +}
115637 +
115638 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
115639 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
115640 +{
115641 + tree arg;
115642 + unsigned int argnum;
115643 +
115644 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
115645 + gcc_assert(argnum != 0);
115646 + if (argnum == CANNOT_FIND_ARG)
115647 + return;
115648 +
115649 + arg = gimple_call_arg(stmt, argnum - 1);
115650 + gcc_assert(arg != NULL_TREE);
115651 +
115652 + // skip all ptr - ptr expressions
115653 + insert_mark_not_intentional_asm_at_ptr(arg);
115654 +
115655 + create_size_overflow_asm(stmt, arg, argnum);
115656 +}
115657 +
115658 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
115659 +static void set_argnum_attribute(const_tree attr, bool *argnums)
115660 +{
115661 + unsigned int argnum;
115662 + tree attr_value;
115663 +
115664 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
115665 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
115666 + argnums[argnum] = true;
115667 + }
115668 +}
115669 +
115670 +// If a function arg or the return value is in the hash table then set its index in the array.
115671 +static void set_argnum_hash(tree fndecl, bool *argnums)
115672 +{
115673 + unsigned int num;
115674 + const struct size_overflow_hash *hash;
115675 +
115676 + hash = get_function_hash(DECL_ORIGIN(fndecl));
115677 + if (!hash)
115678 + return;
115679 +
115680 + for (num = 0; num <= MAX_PARAM; num++) {
115681 + if (!(hash->param & (1U << num)))
115682 + continue;
115683 +
115684 + argnums[num] = true;
115685 + }
115686 +}
115687 +
115688 +static bool is_all_the_argnums_empty(bool *argnums)
115689 +{
115690 + unsigned int i;
115691 +
115692 + for (i = 0; i <= MAX_PARAM; i++)
115693 + if (argnums[i])
115694 + return false;
115695 + return true;
115696 +}
115697 +
115698 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
115699 +static void search_interesting_args(tree fndecl, bool *argnums)
115700 +{
115701 + const_tree attr;
115702 +
115703 + set_argnum_hash(fndecl, argnums);
115704 + if (!is_all_the_argnums_empty(argnums))
115705 + return;
115706 +
115707 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
115708 + if (attr && TREE_VALUE(attr))
115709 + set_argnum_attribute(attr, argnums);
115710 +}
115711 +
115712 +/*
115713 + * Look up the intentional_overflow attribute that turns off ipa based duplication
115714 + * on the callee function.
115715 + */
115716 +static bool is_mark_turn_off_attribute(gimple stmt)
115717 +{
115718 + enum mark mark;
115719 + const_tree fndecl = gimple_call_fndecl(stmt);
115720 +
115721 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
115722 + if (mark == MARK_TURN_OFF)
115723 + return true;
115724 + return false;
115725 +}
115726 +
115727 +// If the argument(s) of the callee function is/are in the hash table or are marked by an attribute then mark the call stmt with an asm stmt
115728 +static void handle_interesting_function(gimple stmt)
115729 +{
115730 + unsigned int argnum;
115731 + tree fndecl;
115732 + bool orig_argnums[MAX_PARAM + 1] = {false};
115733 +
115734 + if (gimple_call_num_args(stmt) == 0)
115735 + return;
115736 + fndecl = gimple_call_fndecl(stmt);
115737 + if (fndecl == NULL_TREE)
115738 + return;
115739 + fndecl = DECL_ORIGIN(fndecl);
115740 +
115741 + if (is_mark_turn_off_attribute(stmt)) {
115742 + create_mark_asm(stmt, MARK_TURN_OFF);
115743 + return;
115744 + }
115745 +
115746 + search_interesting_args(fndecl, orig_argnums);
115747 +
115748 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
115749 + if (orig_argnums[argnum])
115750 + insert_asm_arg(stmt, argnum);
115751 +}
115752 +
115753 +// If the return value of the caller function is in hash table (its index is 0) then mark the return stmt with an asm stmt
115754 +static void handle_interesting_ret(gimple stmt)
115755 +{
115756 + bool orig_argnums[MAX_PARAM + 1] = {false};
115757 +
115758 + search_interesting_args(current_function_decl, orig_argnums);
115759 +
115760 + if (orig_argnums[0])
115761 + insert_asm_ret(stmt);
115762 +}
115763 +
115764 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
115765 +static unsigned int search_interesting_functions(void)
115766 +{
115767 + basic_block bb;
115768 +
115769 + FOR_ALL_BB(bb) {
115770 + gimple_stmt_iterator gsi;
115771 +
115772 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
115773 + gimple stmt = gsi_stmt(gsi);
115774 +
115775 + if (is_size_overflow_asm(stmt))
115776 + continue;
115777 +
115778 + if (is_gimple_call(stmt))
115779 + handle_interesting_function(stmt);
115780 + else if (gimple_code(stmt) == GIMPLE_RETURN)
115781 + handle_interesting_ret(stmt);
115782 + }
115783 + }
115784 + return 0;
115785 +}
115786 +
115787 +/*
115788 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
115789 + * this pass inserts asm stmts to mark the interesting args
115790 + * that the ipa pass will detect and insert the size overflow checks for.
115791 + */
115792 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
115793 + .pass = {
115794 + .type = GIMPLE_PASS,
115795 + .name = "insert_size_overflow_asm",
115796 +#if BUILDING_GCC_VERSION >= 4008
115797 + .optinfo_flags = OPTGROUP_NONE,
115798 +#endif
115799 + .gate = NULL,
115800 + .execute = search_interesting_functions,
115801 + .sub = NULL,
115802 + .next = NULL,
115803 + .static_pass_number = 0,
115804 + .tv_id = TV_NONE,
115805 + .properties_required = PROP_cfg,
115806 + .properties_provided = 0,
115807 + .properties_destroyed = 0,
115808 + .todo_flags_start = 0,
115809 + .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
115810 + }
115811 +};
115812 +
115813 +// Create the noreturn report_size_overflow() function decl.
115814 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
115815 +{
115816 + tree fntype;
115817 +
115818 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
115819 +
115820 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
115821 + fntype = build_function_type_list(void_type_node,
115822 + const_char_ptr_type_node,
115823 + unsigned_type_node,
115824 + const_char_ptr_type_node,
115825 + const_char_ptr_type_node,
115826 + NULL_TREE);
115827 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
115828 +
115829 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
115830 + TREE_PUBLIC(report_size_overflow_decl) = 1;
115831 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
115832 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
115833 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
115834 +}
115835 +
115836 +static unsigned int dump_functions(void)
115837 +{
115838 + struct cgraph_node *node;
115839 +
115840 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
115841 + basic_block bb;
115842 +
115843 +#if BUILDING_GCC_VERSION <= 4007
115844 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
115845 + current_function_decl = node->decl;
115846 +#else
115847 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
115848 + current_function_decl = node->symbol.decl;
115849 +#endif
115850 +
115851 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
115852 +
115853 + FOR_ALL_BB(bb) {
115854 + gimple_stmt_iterator si;
115855 +
115856 + fprintf(stderr, "<bb %u>:\n", bb->index);
115857 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
115858 + debug_gimple_stmt(gsi_stmt(si));
115859 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
115860 + debug_gimple_stmt(gsi_stmt(si));
115861 + fprintf(stderr, "\n");
115862 + }
115863 +
115864 + fprintf(stderr, "-------------------------------------------------------------------------\n");
115865 +
115866 + pop_cfun();
115867 + current_function_decl = NULL_TREE;
115868 + }
115869 +
115870 + fprintf(stderr, "###############################################################################\n");
115871 +
115872 + return 0;
115873 +}
115874 +
115875 +static struct ipa_opt_pass_d pass_dump = {
115876 + .pass = {
115877 + .type = SIMPLE_IPA_PASS,
115878 + .name = "dump",
115879 +#if BUILDING_GCC_VERSION >= 4008
115880 + .optinfo_flags = OPTGROUP_NONE,
115881 +#endif
115882 + .gate = NULL,
115883 + .execute = dump_functions,
115884 + .sub = NULL,
115885 + .next = NULL,
115886 + .static_pass_number = 0,
115887 + .tv_id = TV_NONE,
115888 + .properties_required = 0,
115889 + .properties_provided = 0,
115890 + .properties_destroyed = 0,
115891 + .todo_flags_start = 0,
115892 + .todo_flags_finish = 0,
115893 + },
115894 + .generate_summary = NULL,
115895 + .write_summary = NULL,
115896 + .read_summary = NULL,
115897 +#if BUILDING_GCC_VERSION >= 4006
115898 + .write_optimization_summary = NULL,
115899 + .read_optimization_summary = NULL,
115900 +#endif
115901 + .stmt_fixup = NULL,
115902 + .function_transform_todo_flags_start = 0,
115903 + .function_transform = NULL,
115904 + .variable_transform = NULL,
115905 +};
115906 +
115907 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115908 +{
115909 + int i;
115910 + const char * const plugin_name = plugin_info->base_name;
115911 + const int argc = plugin_info->argc;
115912 + const struct plugin_argument * const argv = plugin_info->argv;
115913 + bool enable = true;
115914 +
115915 + struct register_pass_info insert_size_overflow_asm_pass_info = {
115916 + .pass = &insert_size_overflow_asm_pass.pass,
115917 + .reference_pass_name = "ssa",
115918 + .ref_pass_instance_number = 1,
115919 + .pos_op = PASS_POS_INSERT_AFTER
115920 + };
115921 +
115922 + struct register_pass_info __unused dump_before_pass_info = {
115923 + .pass = &pass_dump.pass,
115924 + .reference_pass_name = "increase_alignment",
115925 + .ref_pass_instance_number = 1,
115926 + .pos_op = PASS_POS_INSERT_BEFORE
115927 + };
115928 +
115929 + struct register_pass_info ipa_pass_info = {
115930 + .pass = &pass_ipa.pass,
115931 + .reference_pass_name = "increase_alignment",
115932 + .ref_pass_instance_number = 1,
115933 + .pos_op = PASS_POS_INSERT_BEFORE
115934 + };
115935 +
115936 + struct register_pass_info __unused dump_after_pass_info = {
115937 + .pass = &pass_dump.pass,
115938 + .reference_pass_name = "increase_alignment",
115939 + .ref_pass_instance_number = 1,
115940 + .pos_op = PASS_POS_INSERT_BEFORE
115941 + };
115942 +
115943 + if (!plugin_default_version_check(version, &gcc_version)) {
115944 + error(G_("incompatible gcc/plugin versions"));
115945 + return 1;
115946 + }
115947 +
115948 + for (i = 0; i < argc; ++i) {
115949 + if (!strcmp(argv[i].key, "no-size-overflow")) {
115950 + enable = false;
115951 + continue;
115952 + }
115953 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115954 + }
115955 +
115956 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
115957 + if (enable) {
115958 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
115959 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
115960 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
115961 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
115962 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
115963 + }
115964 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
115965 +
115966 + return 0;
115967 +}
115968 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
115969 new file mode 100644
115970 index 0000000..ac2901e
115971 --- /dev/null
115972 +++ b/tools/gcc/stackleak_plugin.c
115973 @@ -0,0 +1,327 @@
115974 +/*
115975 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
115976 + * Licensed under the GPL v2
115977 + *
115978 + * Note: the choice of the license means that the compilation process is
115979 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
115980 + * but for the kernel it doesn't matter since it doesn't link against
115981 + * any of the gcc libraries
115982 + *
115983 + * gcc plugin to help implement various PaX features
115984 + *
115985 + * - track lowest stack pointer
115986 + *
115987 + * TODO:
115988 + * - initialize all local variables
115989 + *
115990 + * BUGS:
115991 + * - none known
115992 + */
115993 +#include "gcc-plugin.h"
115994 +#include "config.h"
115995 +#include "system.h"
115996 +#include "coretypes.h"
115997 +#include "tree.h"
115998 +#include "tree-pass.h"
115999 +#include "flags.h"
116000 +#include "intl.h"
116001 +#include "toplev.h"
116002 +#include "plugin.h"
116003 +//#include "expr.h" where are you...
116004 +#include "diagnostic.h"
116005 +#include "plugin-version.h"
116006 +#include "tm.h"
116007 +#include "function.h"
116008 +#include "basic-block.h"
116009 +#include "gimple.h"
116010 +#include "rtl.h"
116011 +#include "emit-rtl.h"
116012 +
116013 +#if BUILDING_GCC_VERSION >= 4008
116014 +#define TODO_dump_func 0
116015 +#endif
116016 +
116017 +extern void print_gimple_stmt(FILE *, gimple, int, int);
116018 +
116019 +int plugin_is_GPL_compatible;
116020 +
116021 +static int track_frame_size = -1;
116022 +static const char track_function[] = "pax_track_stack";
116023 +static const char check_function[] = "pax_check_alloca";
116024 +static bool init_locals;
116025 +
116026 +static struct plugin_info stackleak_plugin_info = {
116027 + .version = "201302112000",
116028 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
116029 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
116030 +};
116031 +
116032 +static bool gate_stackleak_track_stack(void);
116033 +static unsigned int execute_stackleak_tree_instrument(void);
116034 +static unsigned int execute_stackleak_final(void);
116035 +
116036 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
116037 + .pass = {
116038 + .type = GIMPLE_PASS,
116039 + .name = "stackleak_tree_instrument",
116040 +#if BUILDING_GCC_VERSION >= 4008
116041 + .optinfo_flags = OPTGROUP_NONE,
116042 +#endif
116043 + .gate = gate_stackleak_track_stack,
116044 + .execute = execute_stackleak_tree_instrument,
116045 + .sub = NULL,
116046 + .next = NULL,
116047 + .static_pass_number = 0,
116048 + .tv_id = TV_NONE,
116049 + .properties_required = PROP_gimple_leh | PROP_cfg,
116050 + .properties_provided = 0,
116051 + .properties_destroyed = 0,
116052 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
116053 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
116054 + }
116055 +};
116056 +
116057 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
116058 + .pass = {
116059 + .type = RTL_PASS,
116060 + .name = "stackleak_final",
116061 +#if BUILDING_GCC_VERSION >= 4008
116062 + .optinfo_flags = OPTGROUP_NONE,
116063 +#endif
116064 + .gate = gate_stackleak_track_stack,
116065 + .execute = execute_stackleak_final,
116066 + .sub = NULL,
116067 + .next = NULL,
116068 + .static_pass_number = 0,
116069 + .tv_id = TV_NONE,
116070 + .properties_required = 0,
116071 + .properties_provided = 0,
116072 + .properties_destroyed = 0,
116073 + .todo_flags_start = 0,
116074 + .todo_flags_finish = TODO_dump_func
116075 + }
116076 +};
116077 +
116078 +static bool gate_stackleak_track_stack(void)
116079 +{
116080 + return track_frame_size >= 0;
116081 +}
116082 +
116083 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
116084 +{
116085 + gimple check_alloca;
116086 + tree fntype, fndecl, alloca_size;
116087 +
116088 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
116089 + fndecl = build_fn_decl(check_function, fntype);
116090 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
116091 +
116092 + // insert call to void pax_check_alloca(unsigned long size)
116093 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
116094 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
116095 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
116096 +}
116097 +
116098 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
116099 +{
116100 + gimple track_stack;
116101 + tree fntype, fndecl;
116102 +
116103 + fntype = build_function_type_list(void_type_node, NULL_TREE);
116104 + fndecl = build_fn_decl(track_function, fntype);
116105 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
116106 +
116107 + // insert call to void pax_track_stack(void)
116108 + track_stack = gimple_build_call(fndecl, 0);
116109 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
116110 +}
116111 +
116112 +#if BUILDING_GCC_VERSION == 4005
116113 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
116114 +{
116115 + tree fndecl;
116116 +
116117 + if (!is_gimple_call(stmt))
116118 + return false;
116119 + fndecl = gimple_call_fndecl(stmt);
116120 + if (!fndecl)
116121 + return false;
116122 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
116123 + return false;
116124 +// print_node(stderr, "pax", fndecl, 4);
116125 + return DECL_FUNCTION_CODE(fndecl) == code;
116126 +}
116127 +#endif
116128 +
116129 +static bool is_alloca(gimple stmt)
116130 +{
116131 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
116132 + return true;
116133 +
116134 +#if BUILDING_GCC_VERSION >= 4007
116135 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
116136 + return true;
116137 +#endif
116138 +
116139 + return false;
116140 +}
116141 +
116142 +static unsigned int execute_stackleak_tree_instrument(void)
116143 +{
116144 + basic_block bb, entry_bb;
116145 + bool prologue_instrumented = false, is_leaf = true;
116146 +
116147 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
116148 +
116149 + // 1. loop through BBs and GIMPLE statements
116150 + FOR_EACH_BB(bb) {
116151 + gimple_stmt_iterator gsi;
116152 +
116153 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
116154 + gimple stmt;
116155 +
116156 + stmt = gsi_stmt(gsi);
116157 +
116158 + if (is_gimple_call(stmt))
116159 + is_leaf = false;
116160 +
116161 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
116162 + if (!is_alloca(stmt))
116163 + continue;
116164 +
116165 + // 2. insert stack overflow check before each __builtin_alloca call
116166 + stackleak_check_alloca(&gsi);
116167 +
116168 + // 3. insert track call after each __builtin_alloca call
116169 + stackleak_add_instrumentation(&gsi);
116170 + if (bb == entry_bb)
116171 + prologue_instrumented = true;
116172 + }
116173 + }
116174 +
116175 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
116176 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
116177 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
116178 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
116179 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
116180 + return 0;
116181 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
116182 + return 0;
116183 +
116184 + // 4. insert track call at the beginning
116185 + if (!prologue_instrumented) {
116186 + gimple_stmt_iterator gsi;
116187 +
116188 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
116189 + if (dom_info_available_p(CDI_DOMINATORS))
116190 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
116191 + gsi = gsi_start_bb(bb);
116192 + stackleak_add_instrumentation(&gsi);
116193 + }
116194 +
116195 + return 0;
116196 +}
116197 +
116198 +static unsigned int execute_stackleak_final(void)
116199 +{
116200 + rtx insn, next;
116201 +
116202 + if (cfun->calls_alloca)
116203 + return 0;
116204 +
116205 + // keep calls only if function frame is big enough
116206 + if (get_frame_size() >= track_frame_size)
116207 + return 0;
116208 +
116209 + // 1. find pax_track_stack calls
116210 + for (insn = get_insns(); insn; insn = next) {
116211 + // 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))
116212 + rtx body;
116213 +
116214 + next = NEXT_INSN(insn);
116215 + if (!CALL_P(insn))
116216 + continue;
116217 + body = PATTERN(insn);
116218 + if (GET_CODE(body) != CALL)
116219 + continue;
116220 + body = XEXP(body, 0);
116221 + if (GET_CODE(body) != MEM)
116222 + continue;
116223 + body = XEXP(body, 0);
116224 + if (GET_CODE(body) != SYMBOL_REF)
116225 + continue;
116226 + if (strcmp(XSTR(body, 0), track_function))
116227 + continue;
116228 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
116229 + // 2. delete call
116230 + delete_insn_and_edges(insn);
116231 +#if BUILDING_GCC_VERSION >= 4007
116232 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
116233 + insn = next;
116234 + next = NEXT_INSN(insn);
116235 + delete_insn_and_edges(insn);
116236 + }
116237 +#endif
116238 + }
116239 +
116240 +// print_simple_rtl(stderr, get_insns());
116241 +// print_rtl(stderr, get_insns());
116242 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
116243 +
116244 + return 0;
116245 +}
116246 +
116247 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
116248 +{
116249 + const char * const plugin_name = plugin_info->base_name;
116250 + const int argc = plugin_info->argc;
116251 + const struct plugin_argument * const argv = plugin_info->argv;
116252 + int i;
116253 + struct register_pass_info stackleak_tree_instrument_pass_info = {
116254 + .pass = &stackleak_tree_instrument_pass.pass,
116255 +// .reference_pass_name = "tree_profile",
116256 + .reference_pass_name = "optimized",
116257 + .ref_pass_instance_number = 1,
116258 + .pos_op = PASS_POS_INSERT_BEFORE
116259 + };
116260 + struct register_pass_info stackleak_final_pass_info = {
116261 + .pass = &stackleak_final_rtl_opt_pass.pass,
116262 + .reference_pass_name = "final",
116263 + .ref_pass_instance_number = 1,
116264 + .pos_op = PASS_POS_INSERT_BEFORE
116265 + };
116266 +
116267 + if (!plugin_default_version_check(version, &gcc_version)) {
116268 + error(G_("incompatible gcc/plugin versions"));
116269 + return 1;
116270 + }
116271 +
116272 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
116273 +
116274 + for (i = 0; i < argc; ++i) {
116275 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
116276 + if (!argv[i].value) {
116277 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
116278 + continue;
116279 + }
116280 + track_frame_size = atoi(argv[i].value);
116281 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
116282 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
116283 + continue;
116284 + }
116285 + if (!strcmp(argv[i].key, "initialize-locals")) {
116286 + if (argv[i].value) {
116287 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
116288 + continue;
116289 + }
116290 + init_locals = true;
116291 + continue;
116292 + }
116293 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
116294 + }
116295 +
116296 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
116297 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
116298 +
116299 + return 0;
116300 +}
116301 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
116302 new file mode 100644
116303 index 0000000..4fae911
116304 --- /dev/null
116305 +++ b/tools/gcc/structleak_plugin.c
116306 @@ -0,0 +1,277 @@
116307 +/*
116308 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
116309 + * Licensed under the GPL v2
116310 + *
116311 + * Note: the choice of the license means that the compilation process is
116312 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
116313 + * but for the kernel it doesn't matter since it doesn't link against
116314 + * any of the gcc libraries
116315 + *
116316 + * gcc plugin to forcibly initialize certain local variables that could
116317 + * otherwise leak kernel stack to userland if they aren't properly initialized
116318 + * by later code
116319 + *
116320 + * Homepage: http://pax.grsecurity.net/
116321 + *
116322 + * Usage:
116323 + * $ # for 4.5/4.6/C based 4.7
116324 + * $ 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
116325 + * $ # for C++ based 4.7/4.8+
116326 + * $ 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
116327 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
116328 + *
116329 + * TODO: eliminate redundant initializers
116330 + * increase type coverage
116331 + */
116332 +
116333 +#include "gcc-plugin.h"
116334 +#include "config.h"
116335 +#include "system.h"
116336 +#include "coretypes.h"
116337 +#include "tree.h"
116338 +#include "tree-pass.h"
116339 +#include "intl.h"
116340 +#include "plugin-version.h"
116341 +#include "tm.h"
116342 +#include "toplev.h"
116343 +#include "function.h"
116344 +#include "tree-flow.h"
116345 +#include "plugin.h"
116346 +#include "gimple.h"
116347 +#include "diagnostic.h"
116348 +#include "cfgloop.h"
116349 +#include "langhooks.h"
116350 +
116351 +#if BUILDING_GCC_VERSION >= 4008
116352 +#define TODO_dump_func 0
116353 +#endif
116354 +
116355 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
116356 +
116357 +// unused type flag in all versions 4.5-4.8
116358 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
116359 +
116360 +int plugin_is_GPL_compatible;
116361 +void debug_gimple_stmt(gimple gs);
116362 +
116363 +static struct plugin_info structleak_plugin_info = {
116364 + .version = "201304082245",
116365 + .help = "disable\tdo not activate plugin\n",
116366 +};
116367 +
116368 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
116369 +{
116370 + *no_add_attrs = true;
116371 +
116372 + // check for types? for now accept everything linux has to offer
116373 + if (TREE_CODE(*node) != FIELD_DECL)
116374 + return NULL_TREE;
116375 +
116376 + *no_add_attrs = false;
116377 + return NULL_TREE;
116378 +}
116379 +
116380 +static struct attribute_spec user_attr = {
116381 + .name = "user",
116382 + .min_length = 0,
116383 + .max_length = 0,
116384 + .decl_required = false,
116385 + .type_required = false,
116386 + .function_type_required = false,
116387 + .handler = handle_user_attribute,
116388 +#if BUILDING_GCC_VERSION >= 4007
116389 + .affects_type_identity = true
116390 +#endif
116391 +};
116392 +
116393 +static void register_attributes(void *event_data, void *data)
116394 +{
116395 + register_attribute(&user_attr);
116396 +// register_attribute(&force_attr);
116397 +}
116398 +
116399 +static tree get_field_type(tree field)
116400 +{
116401 + return strip_array_types(TREE_TYPE(field));
116402 +}
116403 +
116404 +static bool is_userspace_type(tree type)
116405 +{
116406 + tree field;
116407 +
116408 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
116409 + tree fieldtype = get_field_type(field);
116410 + enum tree_code code = TREE_CODE(fieldtype);
116411 +
116412 + if (code == RECORD_TYPE || code == UNION_TYPE)
116413 + if (is_userspace_type(fieldtype))
116414 + return true;
116415 +
116416 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
116417 + return true;
116418 + }
116419 + return false;
116420 +}
116421 +
116422 +static void finish_type(void *event_data, void *data)
116423 +{
116424 + tree type = (tree)event_data;
116425 +
116426 + if (TYPE_USERSPACE(type))
116427 + return;
116428 +
116429 + if (is_userspace_type(type))
116430 + TYPE_USERSPACE(type) = 1;
116431 +}
116432 +
116433 +static void initialize(tree var)
116434 +{
116435 + basic_block bb;
116436 + gimple_stmt_iterator gsi;
116437 + tree initializer;
116438 + gimple init_stmt;
116439 +
116440 + // this is the original entry bb before the forced split
116441 + // TODO: check further BBs in case more splits occured before us
116442 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
116443 +
116444 + // first check if the variable is already initialized, warn otherwise
116445 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
116446 + gimple stmt = gsi_stmt(gsi);
116447 + tree rhs1;
116448 +
116449 + // we're looking for an assignment of a single rhs...
116450 + if (!gimple_assign_single_p(stmt))
116451 + continue;
116452 + rhs1 = gimple_assign_rhs1(stmt);
116453 +#if BUILDING_GCC_VERSION >= 4007
116454 + // ... of a non-clobbering expression...
116455 + if (TREE_CLOBBER_P(rhs1))
116456 + continue;
116457 +#endif
116458 + // ... to our variable...
116459 + if (gimple_get_lhs(stmt) != var)
116460 + continue;
116461 + // if it's an initializer then we're good
116462 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
116463 + return;
116464 + }
116465 +
116466 + // these aren't the 0days you're looking for
116467 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
116468 +
116469 + // build the initializer expression
116470 + initializer = build_constructor(TREE_TYPE(var), NULL);
116471 +
116472 + // build the initializer stmt
116473 + init_stmt = gimple_build_assign(var, initializer);
116474 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
116475 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
116476 + update_stmt(init_stmt);
116477 +}
116478 +
116479 +static unsigned int handle_function(void)
116480 +{
116481 + basic_block bb;
116482 + unsigned int ret = 0;
116483 + tree var;
116484 +
116485 +#if BUILDING_GCC_VERSION == 4005
116486 + tree vars;
116487 +#else
116488 + unsigned int i;
116489 +#endif
116490 +
116491 + // split the first bb where we can put the forced initializers
116492 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
116493 + if (dom_info_available_p(CDI_DOMINATORS))
116494 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
116495 +
116496 + // enumarate all local variables and forcibly initialize our targets
116497 +#if BUILDING_GCC_VERSION == 4005
116498 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
116499 + var = TREE_VALUE(vars);
116500 +#else
116501 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
116502 +#endif
116503 + tree type = TREE_TYPE(var);
116504 +
116505 + gcc_assert(DECL_P(var));
116506 + if (!auto_var_in_fn_p(var, current_function_decl))
116507 + continue;
116508 +
116509 + // only care about structure types
116510 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
116511 + continue;
116512 +
116513 + // if the type is of interest, examine the variable
116514 + if (TYPE_USERSPACE(type))
116515 + initialize(var);
116516 + }
116517 +
116518 + return ret;
116519 +}
116520 +
116521 +static struct gimple_opt_pass structleak_pass = {
116522 + .pass = {
116523 + .type = GIMPLE_PASS,
116524 + .name = "structleak",
116525 +#if BUILDING_GCC_VERSION >= 4008
116526 + .optinfo_flags = OPTGROUP_NONE,
116527 +#endif
116528 + .gate = NULL,
116529 + .execute = handle_function,
116530 + .sub = NULL,
116531 + .next = NULL,
116532 + .static_pass_number = 0,
116533 + .tv_id = TV_NONE,
116534 + .properties_required = PROP_cfg,
116535 + .properties_provided = 0,
116536 + .properties_destroyed = 0,
116537 + .todo_flags_start = 0,
116538 + .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
116539 + }
116540 +};
116541 +
116542 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
116543 +{
116544 + int i;
116545 + const char * const plugin_name = plugin_info->base_name;
116546 + const int argc = plugin_info->argc;
116547 + const struct plugin_argument * const argv = plugin_info->argv;
116548 + bool enable = true;
116549 +
116550 + struct register_pass_info structleak_pass_info = {
116551 + .pass = &structleak_pass.pass,
116552 + .reference_pass_name = "ssa",
116553 + .ref_pass_instance_number = 1,
116554 + .pos_op = PASS_POS_INSERT_AFTER
116555 + };
116556 +
116557 + if (!plugin_default_version_check(version, &gcc_version)) {
116558 + error(G_("incompatible gcc/plugin versions"));
116559 + return 1;
116560 + }
116561 +
116562 + if (strcmp(lang_hooks.name, "GNU C")) {
116563 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
116564 + enable = false;
116565 + }
116566 +
116567 + for (i = 0; i < argc; ++i) {
116568 + if (!strcmp(argv[i].key, "disable")) {
116569 + enable = false;
116570 + continue;
116571 + }
116572 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
116573 + }
116574 +
116575 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
116576 + if (enable) {
116577 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
116578 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
116579 + }
116580 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
116581 +
116582 + return 0;
116583 +}
116584 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
116585 index 3dba0a4..97175dc 100644
116586 --- a/tools/lib/lk/Makefile
116587 +++ b/tools/lib/lk/Makefile
116588 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
116589
116590 LIBFILE = liblk.a
116591
116592 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
116593 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
116594 EXTLIBS = -lelf -lpthread -lrt -lm
116595 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
116596 ALL_LDFLAGS = $(LDFLAGS)
116597 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
116598 index 6789d78..4afd019e 100644
116599 --- a/tools/perf/util/include/asm/alternative-asm.h
116600 +++ b/tools/perf/util/include/asm/alternative-asm.h
116601 @@ -5,4 +5,7 @@
116602
116603 #define altinstruction_entry #
116604
116605 + .macro pax_force_retaddr rip=0, reload=0
116606 + .endm
116607 +
116608 #endif
116609 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
116610 index 96b919d..c49bb74 100644
116611 --- a/tools/perf/util/include/linux/compiler.h
116612 +++ b/tools/perf/util/include/linux/compiler.h
116613 @@ -18,4 +18,12 @@
116614 #define __force
116615 #endif
116616
116617 +#ifndef __size_overflow
116618 +# define __size_overflow(...)
116619 +#endif
116620 +
116621 +#ifndef __intentional_overflow
116622 +# define __intentional_overflow(...)
116623 +#endif
116624 +
116625 #endif
116626 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
116627 index aac732d..bc87a5d 100644
116628 --- a/virt/kvm/kvm_main.c
116629 +++ b/virt/kvm/kvm_main.c
116630 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
116631
116632 static cpumask_var_t cpus_hardware_enabled;
116633 static int kvm_usage_count = 0;
116634 -static atomic_t hardware_enable_failed;
116635 +static atomic_unchecked_t hardware_enable_failed;
116636
116637 struct kmem_cache *kvm_vcpu_cache;
116638 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
116639
116640 -static __read_mostly struct preempt_ops kvm_preempt_ops;
116641 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
116642 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
116643 +static struct preempt_ops kvm_preempt_ops = {
116644 + .sched_in = kvm_sched_in,
116645 + .sched_out = kvm_sched_out,
116646 +};
116647
116648 struct dentry *kvm_debugfs_dir;
116649
116650 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
116651 /* We can read the guest memory with __xxx_user() later on. */
116652 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
116653 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
116654 - !access_ok(VERIFY_WRITE,
116655 + !__access_ok(VERIFY_WRITE,
116656 (void __user *)(unsigned long)mem->userspace_addr,
116657 mem->memory_size)))
116658 goto out;
116659 @@ -1613,8 +1618,17 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
116660
116661 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
116662 {
116663 - return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page,
116664 - offset, len);
116665 + int r;
116666 + unsigned long addr;
116667 +
116668 + addr = gfn_to_hva(kvm, gfn);
116669 + if (kvm_is_error_hva(addr))
116670 + return -EFAULT;
116671 + r = __clear_user((void __user *)addr + offset, len);
116672 + if (r)
116673 + return -EFAULT;
116674 + mark_page_dirty(kvm, gfn);
116675 + return 0;
116676 }
116677 EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
116678
116679 @@ -1867,7 +1881,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
116680 return 0;
116681 }
116682
116683 -static struct file_operations kvm_vcpu_fops = {
116684 +static file_operations_no_const kvm_vcpu_fops __read_only = {
116685 .release = kvm_vcpu_release,
116686 .unlocked_ioctl = kvm_vcpu_ioctl,
116687 #ifdef CONFIG_COMPAT
116688 @@ -2553,7 +2567,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
116689 return 0;
116690 }
116691
116692 -static struct file_operations kvm_vm_fops = {
116693 +static file_operations_no_const kvm_vm_fops __read_only = {
116694 .release = kvm_vm_release,
116695 .unlocked_ioctl = kvm_vm_ioctl,
116696 #ifdef CONFIG_COMPAT
116697 @@ -2654,7 +2668,7 @@ out:
116698 return r;
116699 }
116700
116701 -static struct file_operations kvm_chardev_ops = {
116702 +static file_operations_no_const kvm_chardev_ops __read_only = {
116703 .unlocked_ioctl = kvm_dev_ioctl,
116704 .compat_ioctl = kvm_dev_ioctl,
116705 .llseek = noop_llseek,
116706 @@ -2680,7 +2694,7 @@ static void hardware_enable_nolock(void *junk)
116707
116708 if (r) {
116709 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
116710 - atomic_inc(&hardware_enable_failed);
116711 + atomic_inc_unchecked(&hardware_enable_failed);
116712 printk(KERN_INFO "kvm: enabling virtualization on "
116713 "CPU%d failed\n", cpu);
116714 }
116715 @@ -2734,10 +2748,10 @@ static int hardware_enable_all(void)
116716
116717 kvm_usage_count++;
116718 if (kvm_usage_count == 1) {
116719 - atomic_set(&hardware_enable_failed, 0);
116720 + atomic_set_unchecked(&hardware_enable_failed, 0);
116721 on_each_cpu(hardware_enable_nolock, NULL, 1);
116722
116723 - if (atomic_read(&hardware_enable_failed)) {
116724 + if (atomic_read_unchecked(&hardware_enable_failed)) {
116725 hardware_disable_all_nolock();
116726 r = -EBUSY;
116727 }
116728 @@ -3171,7 +3185,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
116729 kvm_arch_vcpu_put(vcpu);
116730 }
116731
116732 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
116733 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
116734 struct module *module)
116735 {
116736 int r;
116737 @@ -3218,7 +3232,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
116738 if (!vcpu_align)
116739 vcpu_align = __alignof__(struct kvm_vcpu);
116740 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
116741 - 0, NULL);
116742 + SLAB_USERCOPY, NULL);
116743 if (!kvm_vcpu_cache) {
116744 r = -ENOMEM;
116745 goto out_free_3;
116746 @@ -3228,9 +3242,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
116747 if (r)
116748 goto out_free;
116749
116750 + pax_open_kernel();
116751 kvm_chardev_ops.owner = module;
116752 kvm_vm_fops.owner = module;
116753 kvm_vcpu_fops.owner = module;
116754 + pax_close_kernel();
116755
116756 r = misc_register(&kvm_dev);
116757 if (r) {
116758 @@ -3240,9 +3256,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
116759
116760 register_syscore_ops(&kvm_syscore_ops);
116761
116762 - kvm_preempt_ops.sched_in = kvm_sched_in;
116763 - kvm_preempt_ops.sched_out = kvm_sched_out;
116764 -
116765 r = kvm_init_debug();
116766 if (r) {
116767 printk(KERN_ERR "kvm: create debugfs files failed\n");